system.hh revision 5991
12SN/A/* 21762SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt 292665Ssaidi@eecs.umich.edu * Lisa Hsu 302665Ssaidi@eecs.umich.edu * Nathan Binkert 312SN/A */ 322SN/A 332SN/A#ifndef __SYSTEM_HH__ 342SN/A#define __SYSTEM_HH__ 352SN/A 362SN/A#include <string> 3775SN/A#include <vector> 382SN/A 392439SN/A#include "base/loader/symtab.hh" 402439SN/A#include "base/misc.hh" 41603SN/A#include "base/statistics.hh" 422986Sgblack@eecs.umich.edu#include "config/full_system.hh" 43603SN/A#include "cpu/pc_event.hh" 444762Snate@binkert.org#include "enums/MemoryMode.hh" 452520SN/A#include "mem/port.hh" 464762Snate@binkert.org#include "params/System.hh" 472378SN/A#include "sim/sim_object.hh" 482378SN/A#if FULL_SYSTEM 49722SN/A#include "kern/system_events.hh" 502521SN/A#include "mem/vport.hh" 512378SN/A#endif 52312SN/A 531634SN/Aclass BaseCPU; 542680Sktlim@umich.educlass ThreadContext; 551634SN/Aclass ObjectFile; 562521SN/Aclass PhysicalMemory; 572378SN/A 582378SN/A#if FULL_SYSTEM 59803SN/Aclass Platform; 603960Sgblack@eecs.umich.edu#endif 612378SN/Aclass GDBListener; 623536Sgblack@eecs.umich.edunamespace TheISA 633536Sgblack@eecs.umich.edu{ 643536Sgblack@eecs.umich.edu class RemoteGDB; 653536Sgblack@eecs.umich.edu} 662SN/A 672SN/Aclass System : public SimObject 682SN/A{ 69603SN/A public: 702901Ssaidi@eecs.umich.edu 712902Ssaidi@eecs.umich.edu static const char *MemoryModeStrings[3]; 722902Ssaidi@eecs.umich.edu 734762Snate@binkert.org Enums::MemoryMode 744762Snate@binkert.org getMemoryMode() 754762Snate@binkert.org { 764762Snate@binkert.org assert(memoryMode); 774762Snate@binkert.org return memoryMode; 784762Snate@binkert.org } 792901Ssaidi@eecs.umich.edu 802901Ssaidi@eecs.umich.edu /** Change the memory mode of the system. This should only be called by the 812901Ssaidi@eecs.umich.edu * python!! 822901Ssaidi@eecs.umich.edu * @param mode Mode to change to (atomic/timing) 832901Ssaidi@eecs.umich.edu */ 844762Snate@binkert.org void setMemoryMode(Enums::MemoryMode mode); 852901Ssaidi@eecs.umich.edu 862521SN/A PhysicalMemory *physmem; 872SN/A PCEventQueue pcEventQueue; 882SN/A 892680Sktlim@umich.edu std::vector<ThreadContext *> threadContexts; 905714Shsul@eecs.umich.edu int _numContexts; 911806SN/A 925713Shsul@eecs.umich.edu ThreadContext * getThreadContext(int tid) 935713Shsul@eecs.umich.edu { 945713Shsul@eecs.umich.edu return threadContexts[tid]; 955713Shsul@eecs.umich.edu } 965713Shsul@eecs.umich.edu 975714Shsul@eecs.umich.edu int numContexts() 981806SN/A { 995714Shsul@eecs.umich.edu if (_numContexts != threadContexts.size()) 1001806SN/A panic("cpu array not fully populated!"); 1011806SN/A 1025714Shsul@eecs.umich.edu return _numContexts; 1031806SN/A } 104180SN/A 1052378SN/A#if FULL_SYSTEM 1062378SN/A Platform *platform; 1072378SN/A uint64_t init_param; 1082378SN/A 1092520SN/A /** Port to physical memory used for writing object files into ram at 1102520SN/A * boot.*/ 1112520SN/A FunctionalPort functionalPort; 1122521SN/A VirtualPort virtPort; 1132520SN/A 1141885SN/A /** kernel symbol table */ 1151070SN/A SymbolTable *kernelSymtab; 116954SN/A 1171070SN/A /** Object pointer for the kernel code */ 1181070SN/A ObjectFile *kernel; 1191070SN/A 1201070SN/A /** Begining of kernel code */ 1211070SN/A Addr kernelStart; 1221070SN/A 1231070SN/A /** End of kernel code */ 1241070SN/A Addr kernelEnd; 1251070SN/A 1261070SN/A /** Entry point in the kernel to start at */ 1271070SN/A Addr kernelEntry; 1281070SN/A 1292378SN/A#else 1302378SN/A 1312378SN/A int page_ptr; 1322378SN/A 1334997Sgblack@eecs.umich.edu protected: 1344997Sgblack@eecs.umich.edu uint64_t next_PID; 1354997Sgblack@eecs.umich.edu 1364997Sgblack@eecs.umich.edu public: 1374997Sgblack@eecs.umich.edu uint64_t allocatePID() 1384997Sgblack@eecs.umich.edu { 1394997Sgblack@eecs.umich.edu return next_PID++; 1404997Sgblack@eecs.umich.edu } 1414997Sgblack@eecs.umich.edu 1425795Ssaidi@eecs.umich.edu /** Amount of physical memory that is still free */ 1435795Ssaidi@eecs.umich.edu Addr freeMemSize(); 1445795Ssaidi@eecs.umich.edu 1455795Ssaidi@eecs.umich.edu /** Amount of physical memory that exists */ 1465795Ssaidi@eecs.umich.edu Addr memSize(); 1475795Ssaidi@eecs.umich.edu 1482378SN/A 1492378SN/A#endif // FULL_SYSTEM 1502378SN/A 1511885SN/A protected: 1524762Snate@binkert.org Enums::MemoryMode memoryMode; 1532901Ssaidi@eecs.umich.edu 1542424SN/A#if FULL_SYSTEM 1551885SN/A /** 1561885SN/A * Fix up an address used to match PCs for hooking simulator 1571885SN/A * events on to target function executions. See comment in 1581885SN/A * system.cc for details. 1591885SN/A */ 1602158SN/A virtual Addr fixFuncEventAddr(Addr addr) = 0; 1611885SN/A 1621885SN/A /** 1631885SN/A * Add a function-based event to the given function, to be looked 1641885SN/A * up in the specified symbol table. 1651885SN/A */ 1661885SN/A template <class T> 1672989Ssaidi@eecs.umich.edu T *addFuncEvent(SymbolTable *symtab, const char *lbl) 1681885SN/A { 1691913SN/A Addr addr = 0; // initialize only to avoid compiler warning 1701885SN/A 1711885SN/A if (symtab->findAddress(lbl, addr)) { 1721885SN/A T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr)); 1731885SN/A return ev; 1741885SN/A } 1751885SN/A 1761885SN/A return NULL; 1771885SN/A } 1781885SN/A 1791885SN/A /** Add a function-based event to kernel code. */ 1801885SN/A template <class T> 1812989Ssaidi@eecs.umich.edu T *addKernelFuncEvent(const char *lbl) 1821885SN/A { 1831885SN/A return addFuncEvent<T>(kernelSymtab, lbl); 1841885SN/A } 1851885SN/A 1862378SN/A#endif 18777SN/A public: 1883536Sgblack@eecs.umich.edu std::vector<TheISA::RemoteGDB *> remoteGDB; 1891070SN/A std::vector<GDBListener *> gdbListen; 1903960Sgblack@eecs.umich.edu bool breakpoint(); 1911070SN/A 1921070SN/A public: 1934762Snate@binkert.org typedef SystemParams Params; 1941070SN/A 1952158SN/A protected: 1962158SN/A Params *_params; 1971070SN/A 1982158SN/A public: 1991070SN/A System(Params *p); 2002SN/A ~System(); 2012SN/A 2021129SN/A void startup(); 2031129SN/A 2042158SN/A const Params *params() const { return (const Params *)_params; } 2052158SN/A 2061070SN/A public: 2072378SN/A 2082378SN/A#if FULL_SYSTEM 2091070SN/A /** 2101070SN/A * Returns the addess the kernel starts at. 2111070SN/A * @return address the kernel starts at 2121070SN/A */ 2131070SN/A Addr getKernelStart() const { return kernelStart; } 2141070SN/A 2151070SN/A /** 2161070SN/A * Returns the addess the kernel ends at. 2171070SN/A * @return address the kernel ends at 2181070SN/A */ 2191070SN/A Addr getKernelEnd() const { return kernelEnd; } 2201070SN/A 2211070SN/A /** 2221070SN/A * Returns the addess the entry point to the kernel code. 2231070SN/A * @return entry point of the kernel code 2241070SN/A */ 2251070SN/A Addr getKernelEntry() const { return kernelEntry; } 2261070SN/A 2272378SN/A#else 2282378SN/A 2292378SN/A Addr new_page(); 2302378SN/A 2312378SN/A#endif // FULL_SYSTEM 2322378SN/A 2335718Shsul@eecs.umich.edu int registerThreadContext(ThreadContext *tc, int assigned=-1); 2345713Shsul@eecs.umich.edu void replaceThreadContext(ThreadContext *tc, int context_id); 2351070SN/A 2361070SN/A void serialize(std::ostream &os); 2371070SN/A void unserialize(Checkpoint *cp, const std::string §ion); 2382SN/A 23977SN/A public: 2402SN/A //////////////////////////////////////////// 2412SN/A // 2422SN/A // STATIC GLOBAL SYSTEM LIST 2432SN/A // 2442SN/A //////////////////////////////////////////// 2452SN/A 2462SN/A static std::vector<System *> systemList; 2472SN/A static int numSystemsRunning; 2482SN/A 2492SN/A static void printSystems(); 2502158SN/A 2512158SN/A 2522SN/A}; 2532SN/A 2542SN/A#endif // __SYSTEM_HH__ 255