From: Gabe Black Date: Sun, 30 Oct 2011 09:30:55 +0000 (-0700) Subject: SE/FS: Make the system object more consistent between SE and FS. X-Git-Tag: stable_2012_06_28~304 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c81db77f218d414e13f4721f19b1f7ac5305592;p=gem5.git SE/FS: Make the system object more consistent between SE and FS. --- diff --git a/src/sim/System.py b/src/sim/System.py index a6897d834..948be7e77 100644 --- a/src/sim/System.py +++ b/src/sim/System.py @@ -62,14 +62,12 @@ class System(SimObject): work_cpus_ckpt_count = Param.Counter(0, "create checkpoint when active cpu count value is reached") - if buildEnv['FULL_SYSTEM']: - abstract = True - boot_cpu_frequency = Param.Frequency(Self.cpu[0].clock.frequency, - "boot processor frequency") - init_param = Param.UInt64(0, "numerical value to pass into simulator") - boot_osflags = Param.String("a", "boot flags to pass to the kernel") - kernel = Param.String("", "file that contains the kernel code") - readfile = Param.String("", "file to read startup script from") - symbolfile = Param.String("", "file to get the symbols from") - load_addr_mask = Param.UInt64(0xffffffffff, - "Address to mask loading binaries with"); + boot_cpu_frequency = Param.Frequency(Self.cpu[0].clock.frequency, + "boot processor frequency") + init_param = Param.UInt64(0, "numerical value to pass into simulator") + boot_osflags = Param.String("a", "boot flags to pass to the kernel") + kernel = Param.String("", "file that contains the kernel code") + readfile = Param.String("", "file to read startup script from") + symbolfile = Param.String("", "file to get the symbols from") + load_addr_mask = Param.UInt64(0xffffffffff, + "Address to mask loading binaries with"); diff --git a/src/sim/system.cc b/src/sim/system.cc index f8e9b31b8..654bcef80 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -36,27 +36,23 @@ #include "arch/isa_traits.hh" #include "arch/remote_gdb.hh" #include "arch/utility.hh" +#include "arch/vtophys.hh" #include "base/loader/object_file.hh" #include "base/loader/symtab.hh" #include "base/trace.hh" -#include "config/full_system.hh" #include "config/the_isa.hh" #include "cpu/thread_context.hh" #include "debug/Loader.hh" +#include "kern/kernel_stats.hh" #include "mem/mem_object.hh" #include "mem/physical.hh" +#include "mem/vport.hh" +#include "params/System.hh" #include "sim/byteswap.hh" #include "sim/debug.hh" +#include "sim/full_system.hh" #include "sim/system.hh" -#if FULL_SYSTEM -#include "arch/vtophys.hh" -#include "kern/kernel_stats.hh" -#include "mem/vport.hh" -#else -#include "params/System.hh" -#endif - using namespace std; using namespace TheISA; @@ -66,10 +62,8 @@ int System::numSystemsRunning = 0; System::System(Params *p) : SimObject(p), physmem(p->physmem), _numContexts(0), pagePtr(0), -#if FULL_SYSTEM init_param(p->init_param), loadAddrMask(p->load_addr_mask), -#endif nextPID(0), memoryMode(p->mem_mode), workItemsBegin(0), @@ -91,68 +85,68 @@ System::System(Params *p) p->memories[x]->size())); } -#if FULL_SYSTEM - kernelSymtab = new SymbolTable; - if (!debugSymbolTable) - debugSymbolTable = new SymbolTable; - - - /** - * Get a functional port to memory - */ - Port *mem_port; - functionalPort = new FunctionalPort(name() + "-fport"); - mem_port = physmem->getPort("functional"); - functionalPort->setPeer(mem_port); - mem_port->setPeer(functionalPort); - - virtPort = new VirtualPort(name() + "-fport"); - mem_port = physmem->getPort("functional"); - virtPort->setPeer(mem_port); - mem_port->setPeer(virtPort); - - - /** - * Load the kernel code into memory - */ - if (params()->kernel == "") { - inform("No kernel set for full system simulation. Assuming you know what" - " you're doing...\n"); - } else { - // Load kernel code - kernel = createObjectFile(params()->kernel); - inform("kernel located at: %s", params()->kernel); - - if (kernel == NULL) - fatal("Could not load kernel file %s", params()->kernel); - - // Load program sections into memory - kernel->loadSections(functionalPort, loadAddrMask); - - // setup entry points - kernelStart = kernel->textBase(); - kernelEnd = kernel->bssBase() + kernel->bssSize(); - kernelEntry = kernel->entryPoint(); - - // load symbols - if (!kernel->loadGlobalSymbols(kernelSymtab)) - fatal("could not load kernel symbols\n"); - - if (!kernel->loadLocalSymbols(kernelSymtab)) - fatal("could not load kernel local symbols\n"); - - if (!kernel->loadGlobalSymbols(debugSymbolTable)) - fatal("could not load kernel symbols\n"); - - if (!kernel->loadLocalSymbols(debugSymbolTable)) - fatal("could not load kernel local symbols\n"); - - DPRINTF(Loader, "Kernel start = %#x\n", kernelStart); - DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd); - DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry); - DPRINTF(Loader, "Kernel loaded...\n"); + if (FullSystem) { + kernelSymtab = new SymbolTable; + if (!debugSymbolTable) + debugSymbolTable = new SymbolTable; + + + /** + * Get a functional port to memory + */ + Port *mem_port; + functionalPort = new FunctionalPort(name() + "-fport"); + mem_port = physmem->getPort("functional"); + functionalPort->setPeer(mem_port); + mem_port->setPeer(functionalPort); + + virtPort = new VirtualPort(name() + "-fport"); + mem_port = physmem->getPort("functional"); + virtPort->setPeer(mem_port); + mem_port->setPeer(virtPort); + + + /** + * Load the kernel code into memory + */ + if (params()->kernel == "") { + inform("No kernel set for full system simulation. " + "Assuming you know what you're doing...\n"); + } else { + // Load kernel code + kernel = createObjectFile(params()->kernel); + inform("kernel located at: %s", params()->kernel); + + if (kernel == NULL) + fatal("Could not load kernel file %s", params()->kernel); + + // Load program sections into memory + kernel->loadSections(functionalPort, loadAddrMask); + + // setup entry points + kernelStart = kernel->textBase(); + kernelEnd = kernel->bssBase() + kernel->bssSize(); + kernelEntry = kernel->entryPoint(); + + // load symbols + if (!kernel->loadGlobalSymbols(kernelSymtab)) + fatal("could not load kernel symbols\n"); + + if (!kernel->loadLocalSymbols(kernelSymtab)) + fatal("could not load kernel local symbols\n"); + + if (!kernel->loadGlobalSymbols(debugSymbolTable)) + fatal("could not load kernel symbols\n"); + + if (!kernel->loadLocalSymbols(debugSymbolTable)) + fatal("could not load kernel local symbols\n"); + + DPRINTF(Loader, "Kernel start = %#x\n", kernelStart); + DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd); + DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry); + DPRINTF(Loader, "Kernel loaded...\n"); + } } -#endif // FULL_SYSTEM // increment the number of running systms numSystemsRunning++; @@ -162,13 +156,8 @@ System::System(Params *p) System::~System() { -#if FULL_SYSTEM delete kernelSymtab; delete kernel; -#else - panic("System::fixFuncEventAddr needs to be rewritten " - "to work with syscall emulation"); -#endif // FULL_SYSTEM} } void @@ -251,11 +240,11 @@ System::numRunningContexts() void System::initState() { -#if FULL_SYSTEM - int i; - for (i = 0; i < threadContexts.size(); i++) - TheISA::startupCPU(threadContexts[i], i); -#endif + if (FullSystem) { + int i; + for (i = 0; i < threadContexts.size(); i++) + TheISA::startupCPU(threadContexts[i], i); + } } void @@ -314,9 +303,8 @@ System::resume() void System::serialize(ostream &os) { -#if FULL_SYSTEM - kernelSymtab->serialize("kernel_symtab", os); -#endif + if (FullSystem) + kernelSymtab->serialize("kernel_symtab", os); SERIALIZE_SCALAR(pagePtr); SERIALIZE_SCALAR(nextPID); } @@ -325,9 +313,8 @@ System::serialize(ostream &os) void System::unserialize(Checkpoint *cp, const string §ion) { -#if FULL_SYSTEM - kernelSymtab->unserialize("kernel_symtab", cp, section); -#endif + if (FullSystem) + kernelSymtab->unserialize("kernel_symtab", cp, section); UNSERIALIZE_SCALAR(pagePtr); UNSERIALIZE_SCALAR(nextPID); } @@ -352,12 +339,8 @@ printSystems() const char *System::MemoryModeStrings[3] = {"invalid", "atomic", "timing"}; -#if !FULL_SYSTEM - System * SystemParams::create() { return new System(this); } - -#endif diff --git a/src/sim/system.hh b/src/sim/system.hh index 37729a397..77d935dbd 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -44,26 +44,20 @@ #include "config/full_system.hh" #include "cpu/pc_event.hh" #include "enums/MemoryMode.hh" +#include "kern/system_events.hh" #include "mem/port.hh" #include "params/System.hh" #include "sim/sim_object.hh" -#if FULL_SYSTEM -#include "kern/system_events.hh" -#endif - class BaseCPU; -class ThreadContext; +class BaseRemoteGDB; +class FunctionalPort; +class GDBListener; class ObjectFile; class PhysicalMemory; - -#if FULL_SYSTEM class Platform; -class FunctionalPort; +class ThreadContext; class VirtualPort; -#endif -class GDBListener; -class BaseRemoteGDB; class System : public SimObject { @@ -115,7 +109,6 @@ class System : public SimObject Addr pagePtr; -#if FULL_SYSTEM uint64_t init_param; /** Port to physical memory used for writing object files into ram at @@ -146,8 +139,6 @@ class System : public SimObject */ Addr loadAddrMask; -#endif // FULL_SYSTEM - protected: uint64_t nextPID; @@ -208,13 +199,15 @@ class System : public SimObject return count; } -#if FULL_SYSTEM /** * Fix up an address used to match PCs for hooking simulator * events on to target function executions. See comment in * system.cc for details. */ - virtual Addr fixFuncEventAddr(Addr addr) = 0; + virtual Addr fixFuncEventAddr(Addr addr) + { + panic("Base fixFuncEventAddr not implemented.\n"); + } /** * Add a function-based event to the given function, to be looked @@ -240,7 +233,6 @@ class System : public SimObject return addFuncEvent(kernelSymtab, lbl); } -#endif public: std::vector remoteGDB; std::vector gdbListen; @@ -262,7 +254,6 @@ class System : public SimObject public: -#if FULL_SYSTEM /** * Returns the addess the kernel starts at. * @return address the kernel starts at @@ -281,8 +272,6 @@ class System : public SimObject */ Addr getKernelEntry() const { return kernelEntry; } -#endif - Addr new_page(); int registerThreadContext(ThreadContext *tc, int assigned=-1);