X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsim%2Fsystem.hh;h=cdf7d3d7e9d606c6a4c796a867fb10eacbdcfc43;hb=a368fba7d4fa01b58d5c2d9b3cafd56e1102287c;hp=758da709e9efe73cb68d9f872adea2bab391dbb8;hpb=0358ccee23072eef0b6448e3170457037682a452;p=gem5.git diff --git a/src/sim/system.hh b/src/sim/system.hh index 758da709e..cdf7d3d7e 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -41,11 +41,13 @@ #include "base/statistics.hh" #include "config/full_system.hh" #include "cpu/pc_event.hh" +#include "enums/MemoryMode.hh" #include "mem/port.hh" +#include "params/System.hh" #include "sim/sim_object.hh" + #if FULL_SYSTEM #include "kern/system_events.hh" -#include "mem/vport.hh" #endif class BaseCPU; @@ -55,12 +57,11 @@ class PhysicalMemory; #if FULL_SYSTEM class Platform; +class FunctionalPort; +class VirtualPort; #endif class GDBListener; -namespace TheISA -{ - class RemoteGDB; -} +class BaseRemoteGDB; class System : public SimObject { @@ -68,36 +69,48 @@ class System : public SimObject static const char *MemoryModeStrings[3]; - SimObject::MemoryMode getMemoryMode() { assert(memoryMode); return memoryMode; } + Enums::MemoryMode + getMemoryMode() + { + assert(memoryMode); + return memoryMode; + } /** Change the memory mode of the system. This should only be called by the * python!! * @param mode Mode to change to (atomic/timing) */ - void setMemoryMode(SimObject::MemoryMode mode); + void setMemoryMode(Enums::MemoryMode mode); PhysicalMemory *physmem; PCEventQueue pcEventQueue; std::vector threadContexts; - int numcpus; + int _numContexts; - int getNumCPUs() + ThreadContext *getThreadContext(ThreadID tid) { - if (numcpus != threadContexts.size()) - panic("cpu array not fully populated!"); + return threadContexts[tid]; + } - return numcpus; + int numContexts() + { + assert(_numContexts == (int)threadContexts.size()); + return _numContexts; } + /** Return number of running (non-halted) thread contexts in + * system. These threads could be Active or Suspended. */ + int numRunningContexts(); + #if FULL_SYSTEM Platform *platform; uint64_t init_param; /** Port to physical memory used for writing object files into ram at * boot.*/ - FunctionalPort functionalPort; - VirtualPort virtPort; + FunctionalPort *functionalPort; + VirtualPort *virtPort; /** kernel symbol table */ SymbolTable *kernelSymtab; @@ -114,16 +127,38 @@ class System : public SimObject /** Entry point in the kernel to start at */ Addr kernelEntry; + /** Mask that should be anded for binary/symbol loading. + * This allows one two different OS requirements for the same ISA to be + * handled. Some OSes are compiled for a virtual address and need to be + * loaded into physical memory that starts at address 0, while other + * bare metal tools generate images that start at address 0. + */ + Addr loadAddrMask; + #else - int page_ptr; + Addr pagePtr; + + protected: + uint64_t nextPID; + + public: + uint64_t allocatePID() + { + return nextPID++; + } + + /** Amount of physical memory that is still free */ + Addr freeMemSize(); + + /** Amount of physical memory that exists */ + Addr memSize(); #endif // FULL_SYSTEM protected: - - SimObject::MemoryMode memoryMode; + Enums::MemoryMode memoryMode; #if FULL_SYSTEM /** @@ -159,27 +194,12 @@ class System : public SimObject #endif public: - std::vector remoteGDB; + std::vector remoteGDB; std::vector gdbListen; bool breakpoint(); public: - struct Params - { - std::string name; - PhysicalMemory *physmem; - SimObject::MemoryMode mem_mode; - -#if FULL_SYSTEM - Tick boot_cpu_frequency; - std::string boot_osflags; - uint64_t init_param; - - std::string kernel_path; - std::string readfile; - std::string symbolfile; -#endif - }; + typedef SystemParams Params; protected: Params *_params; @@ -188,7 +208,7 @@ class System : public SimObject System(Params *p); ~System(); - void startup(); + void initState(); const Params *params() const { return (const Params *)_params; } @@ -219,8 +239,8 @@ class System : public SimObject #endif // FULL_SYSTEM - int registerThreadContext(ThreadContext *tc, int tcIndex); - void replaceThreadContext(ThreadContext *tc, int tcIndex); + int registerThreadContext(ThreadContext *tc, int assigned=-1); + void replaceThreadContext(ThreadContext *tc, int context_id); void serialize(std::ostream &os); void unserialize(Checkpoint *cp, const std::string §ion);