changeset 52bbd95b31ed in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=52bbd95b31ed
description:
        System: Move code in initState() back into constructor whenever 
possible.

        The change to port proxies recently moved code out of the constructor 
into
        initState(). This is needed for code that loads data into memory, 
however
        for code that setups symbol tables, kernel based events, etc this is 
the wrong
        thing to do as that code is only called when a checkpoint isn't being 
restored
        from.

diffstat:

 src/arch/alpha/linux/system.cc |   7 +++
 src/arch/alpha/linux/system.hh |   6 +++
 src/arch/alpha/system.cc       |  76 +++++++++++++++++++++++++++--------------
 src/arch/alpha/system.hh       |  10 +++++
 src/arch/arm/linux/system.cc   |  69 ++++++++++++++++++-------------------
 src/arch/arm/system.cc         |  34 +++++++++--------
 src/arch/sparc/system.cc       |  54 ++++++++++++++--------------
 src/sim/system.cc              |  71 +++++++++++++++++++++-----------------
 8 files changed, 190 insertions(+), 137 deletions(-)

diffs (truncated from 509 to 300 lines):

diff -r fd92c46655ad -r 52bbd95b31ed src/arch/alpha/linux/system.cc
--- a/src/arch/alpha/linux/system.cc    Fri Mar 09 09:59:26 2012 -0500
+++ b/src/arch/alpha/linux/system.cc    Fri Mar 09 09:59:26 2012 -0500
@@ -113,6 +113,12 @@
     else
         panic("could not find dp264_mv\n");
 
+}
+
+void
+LinuxAlphaSystem::setupFuncEvents()
+{
+    AlphaSystem::setupFuncEvents();
 #ifndef NDEBUG
     kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic");
     if (!kernelPanicEvent)
@@ -148,6 +154,7 @@
     // re-enable, but we should find a better way to turn it on than
     // using DTRACE(Thread), since looking at a trace flag at tick 0
     // leads to non-intuitive behavior with --trace-start.
+    Addr addr = 0;
     if (false && kernelSymtab->findAddress("alpha_switch_to", addr)) {
         printThreadEvent = new PrintThreadInfo(&pcEventQueue, "threadinfo",
                                                addr + sizeof(MachInst) * 6);
diff -r fd92c46655ad -r 52bbd95b31ed src/arch/alpha/linux/system.hh
--- a/src/arch/alpha/linux/system.hh    Fri Mar 09 09:59:26 2012 -0500
+++ b/src/arch/alpha/linux/system.hh    Fri Mar 09 09:59:26 2012 -0500
@@ -123,6 +123,12 @@
     /** Grab the PCBB of the idle process when it starts */
     IdleStartEvent *idleStartEvent;
 
+  protected:
+    /** Setup all the function events. Must be done after init() for Alpha 
since
+     * fixFuncEvent() requires a function port
+     */
+    virtual void setupFuncEvents();
+
   public:
     typedef LinuxAlphaSystemParams Params;
     LinuxAlphaSystem(Params *p);
diff -r fd92c46655ad -r 52bbd95b31ed src/arch/alpha/system.cc
--- a/src/arch/alpha/system.cc  Fri Mar 09 09:59:26 2012 -0500
+++ b/src/arch/alpha/system.cc  Fri Mar 09 09:59:26 2012 -0500
@@ -63,30 +63,6 @@
     pal = createObjectFile(params()->pal);
     if (pal == NULL)
         fatal("Could not load PALcode file %s", params()->pal);
-}
-
-AlphaSystem::~AlphaSystem()
-{
-    delete consoleSymtab;
-    delete console;
-    delete pal;
-#ifdef DEBUG
-    delete consolePanicEvent;
-#endif
-}
-
-void
-AlphaSystem::initState()
-{
-    // Moved from the constructor to here since it relies on the
-    // address map being resolved in the interconnect
-
-    // Call the initialisation of the super class
-    System::initState();
-
-    // Load program sections into memory
-    pal->loadSections(physProxy, loadAddrMask);
-    console->loadSections(physProxy, loadAddrMask);
 
     // load symbols
     if (!console->loadGlobalSymbols(consoleSymtab))
@@ -107,10 +83,33 @@
     if (!pal->loadLocalSymbols(debugSymbolTable))
         panic("could not load pal symbols\n");
 
+
+}
+
+AlphaSystem::~AlphaSystem()
+{
+    delete consoleSymtab;
+    delete console;
+    delete pal;
+#ifdef DEBUG
+    delete consolePanicEvent;
+#endif
+}
+
+void
+AlphaSystem::initState()
+{
      Addr addr = 0;
-#ifndef NDEBUG
-    consolePanicEvent = addConsoleFuncEvent<BreakPCEvent>("panic");
-#endif
+
+    // Moved from the constructor to here since it relies on the
+    // address map being resolved in the interconnect
+
+    // Call the initialisation of the super class
+    System::initState();
+
+    // Load program sections into memory
+    pal->loadSections(physProxy, loadAddrMask);
+    console->loadSections(physProxy, loadAddrMask);
 
     /**
      * Copy the osflags (kernel arguments) into the consoles
@@ -135,6 +134,29 @@
         virtProxy.write(addr+0x58, data);
     } else
         panic("could not find hwrpb\n");
+
+    // Setup all the function events now that we have a system and a symbol
+    // table
+    setupFuncEvents();
+}
+
+void
+AlphaSystem::loadState(Checkpoint *cp)
+{
+    System::loadState(cp);
+
+    // Setup all the function events now that we have a system and a symbol
+    // table
+    setupFuncEvents();
+
+}
+
+void
+AlphaSystem::setupFuncEvents()
+{
+#ifndef NDEBUG
+    consolePanicEvent = addConsoleFuncEvent<BreakPCEvent>("panic");
+#endif
 }
 
 /**
diff -r fd92c46655ad -r 52bbd95b31ed src/arch/alpha/system.hh
--- a/src/arch/alpha/system.hh  Fri Mar 09 09:59:26 2012 -0500
+++ b/src/arch/alpha/system.hh  Fri Mar 09 09:59:26 2012 -0500
@@ -62,6 +62,10 @@
     virtual void serialize(std::ostream &os);
     virtual void unserialize(Checkpoint *cp, const std::string &section);
 
+    /** Override loadState to provide a path to call setupFuncEvents()
+     */
+    virtual void loadState(Checkpoint *cp);
+
     /**
      * Set the m5AlphaAccess pointer in the console
      */
@@ -89,6 +93,12 @@
 
     const Params *params() const { return (const Params *)_params; }
 
+
+    /** Setup all the function events. Must be done after init() for Alpha 
since
+     * fixFuncEvent() requires a function port
+     */
+    virtual void setupFuncEvents();
+
     /** Add a function-based event to PALcode. */
     template <class T>
     T *
diff -r fd92c46655ad -r 52bbd95b31ed src/arch/arm/linux/system.cc
--- a/src/arch/arm/linux/system.cc      Fri Mar 09 09:59:26 2012 -0500
+++ b/src/arch/arm/linux/system.cc      Fri Mar 09 09:59:26 2012 -0500
@@ -58,6 +58,40 @@
 LinuxArmSystem::LinuxArmSystem(Params *p)
     : ArmSystem(p)
 {
+#ifndef NDEBUG
+    kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic");
+    if (!kernelPanicEvent)
+        panic("could not find kernel symbol \'panic\'");
+#endif
+
+    // With ARM udelay() is #defined to __udelay
+    Addr addr = 0;
+    if (kernelSymtab->findAddress("__udelay", addr)) {
+        uDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__udelay",
+                fixFuncEventAddr(addr), 1000, 0);
+    } else {
+        panic("couldn't find kernel symbol \'udelay\'");
+    }
+
+    // constant arguments to udelay() have some precomputation done ahead of
+    // time. Constant comes from code.
+    if (kernelSymtab->findAddress("__const_udelay", addr)) {
+        constUDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__const_udelay",
+                fixFuncEventAddr(addr), 1000, 107374);
+    } else {
+        panic("couldn't find kernel symbol \'udelay\'");
+    }
+
+    secDataPtrAddr = 0;
+    secDataAddr = 0;
+    penReleaseAddr = 0;
+    kernelSymtab->findAddress("__secondary_data", secDataPtrAddr);
+    kernelSymtab->findAddress("secondary_data", secDataAddr);
+    kernelSymtab->findAddress("pen_release", penReleaseAddr);
+
+    secDataPtrAddr &= ~ULL(0x7F);
+    secDataAddr &= ~ULL(0x7F);
+    penReleaseAddr &= ~ULL(0x7F);
 }
 
 bool
@@ -116,41 +150,6 @@
 
     physProxy.writeBlob(params()->atags_addr, boot_data, size << 2);
 
-#ifndef NDEBUG
-    kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic");
-    if (!kernelPanicEvent)
-        panic("could not find kernel symbol \'panic\'");
-#endif
-
-    // With ARM udelay() is #defined to __udelay
-    Addr addr = 0;
-    if (kernelSymtab->findAddress("__udelay", addr)) {
-        uDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__udelay",
-                fixFuncEventAddr(addr), 1000, 0);
-    } else {
-        panic("couldn't find kernel symbol \'udelay\'");
-    }
-
-    // constant arguments to udelay() have some precomputation done ahead of
-    // time. Constant comes from code.
-    if (kernelSymtab->findAddress("__const_udelay", addr)) {
-        constUDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__const_udelay",
-                fixFuncEventAddr(addr), 1000, 107374);
-    } else {
-        panic("couldn't find kernel symbol \'udelay\'");
-    }
-
-    secDataPtrAddr = 0;
-    secDataAddr = 0;
-    penReleaseAddr = 0;
-    kernelSymtab->findAddress("__secondary_data", secDataPtrAddr);
-    kernelSymtab->findAddress("secondary_data", secDataAddr);
-    kernelSymtab->findAddress("pen_release", penReleaseAddr);
-
-    secDataPtrAddr &= ~ULL(0x7F);
-    secDataAddr &= ~ULL(0x7F);
-    penReleaseAddr &= ~ULL(0x7F);
-
     for (int i = 0; i < threadContexts.size(); i++) {
         threadContexts[i]->setIntReg(0, 0);
         threadContexts[i]->setIntReg(1, params()->machine_type);
diff -r fd92c46655ad -r 52bbd95b31ed src/arch/arm/system.cc
--- a/src/arch/arm/system.cc    Fri Mar 09 09:59:26 2012 -0500
+++ b/src/arch/arm/system.cc    Fri Mar 09 09:59:26 2012 -0500
@@ -55,6 +55,19 @@
 ArmSystem::ArmSystem(Params *p)
     : System(p), bootldr(NULL)
 {
+    if ((p->boot_loader == "") != (p->boot_loader_mem == NULL))
+        fatal("If boot_loader is specifed, memory to load it must be also.\n");
+
+    if (p->boot_loader != "") {
+        bootldr = createObjectFile(p->boot_loader);
+
+        if (!bootldr)
+            fatal("Could not read bootloader: %s\n", p->boot_loader);
+
+        bootldr->loadGlobalSymbols(debugSymbolTable);
+
+    }
+    debugPrintkEvent = addKernelFuncEvent<DebugPrintkEvent>("dprintk");
 }
 
 void
@@ -68,17 +81,8 @@
 
     const Params* p = params();
 
-    if ((p->boot_loader == "") != (p->boot_loader_mem == NULL))
-        fatal("If boot_loader is specifed, memory to load it must be also.\n");
-
-    if (p->boot_loader != "") {
-        bootldr = createObjectFile(p->boot_loader);
-
-        if (!bootldr)
-            fatal("Could not read bootloader: %s\n", p->boot_loader);
-
+    if (bootldr) {
         bootldr->loadSections(physProxy);
-        bootldr->loadGlobalSymbols(debugSymbolTable);
 
         uint8_t jump_to_bl[] =
         {
@@ -87,32 +91,30 @@
         physProxy.writeBlob(0x0, jump_to_bl, sizeof(jump_to_bl));
 
         inform("Using bootloader at address %#x\n", bootldr->entryPoint());
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to