First steps toward getting full system to work with
[gem5.git] / sim / system.hh
index 4f003f282c885232a4c8b8b3615a0e7b9906d908..7e21bd5872d6b108f9e0299e737cad369e514031 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002-2004 The Regents of The University of Michigan
+ * Copyright (c) 2002-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include <string>
 #include <vector>
 
+#include "base/loader/symtab.hh"
+#include "base/misc.hh"
 #include "base/statistics.hh"
 #include "cpu/pc_event.hh"
-#include "kern/system_events.hh"
+#include "mem/port.hh"
 #include "sim/sim_object.hh"
+#if FULL_SYSTEM
+#include "kern/system_events.hh"
+#include "mem/vport.hh"
+#endif
 
 class BaseCPU;
 class ExecContext;
-class GDBListener;
-class MemoryController;
 class ObjectFile;
 class PhysicalMemory;
+
+#if FULL_SYSTEM
 class Platform;
+class GDBListener;
 class RemoteGDB;
-class SymbolTable;
 namespace Kernel { class Binning; }
+#endif
 
 class System : public SimObject
 {
   public:
-    MemoryController *memctrl;
     PhysicalMemory *physmem;
-    Platform *platform;
     PCEventQueue pcEventQueue;
-    uint64_t init_param;
 
     std::vector<ExecContext *> execContexts;
+    int numcpus;
 
-    /** kernel Symbol table */
-    SymbolTable *kernelSymtab;
+    int getNumCPUs()
+    {
+        if (numcpus != execContexts.size())
+            panic("cpu array not fully populated!");
+
+        return numcpus;
+    }
+
+#if FULL_SYSTEM
+    Platform *platform;
+    uint64_t init_param;
 
-    /** console symbol table */
-    SymbolTable *consoleSymtab;
+    /** Port to physical memory used for writing object files into ram at
+     * boot.*/
+    FunctionalPort functionalPort;
+    VirtualPort virtPort;
 
-    /** pal symbol table */
-    SymbolTable *palSymtab;
+    /** kernel symbol table */
+    SymbolTable *kernelSymtab;
 
     /** Object pointer for the kernel code */
     ObjectFile *kernel;
 
-    /** Object pointer for the console code */
-    ObjectFile *console;
-
-    /** Object pointer for the PAL code */
-    ObjectFile *pal;
-
     /** Begining of kernel code */
     Addr kernelStart;
 
@@ -88,45 +98,88 @@ class System : public SimObject
 
     Kernel::Binning *kernelBinning;
 
-#ifdef DEBUG
-    /** Event to halt the simulator if the console calls panic() */
-    BreakPCEvent *consolePanicEvent;
-#endif
+#else
+
+    int page_ptr;
+
+
+#endif // FULL_SYSTEM
+
+  protected:
+
+#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;
 
+    /**
+     * Add a function-based event to the given function, to be looked
+     * up in the specified symbol table.
+     */
+    template <class T>
+    T *System::addFuncEvent(SymbolTable *symtab, const char *lbl)
+    {
+        Addr addr = 0; // initialize only to avoid compiler warning
+
+        if (symtab->findAddress(lbl, addr)) {
+            T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr));
+            return ev;
+        }
+
+        return NULL;
+    }
+
+    /** Add a function-based event to kernel code. */
+    template <class T>
+    T *System::addKernelFuncEvent(const char *lbl)
+    {
+        return addFuncEvent<T>(kernelSymtab, lbl);
+    }
+
+#endif
   public:
+#if FULL_SYSTEM
     std::vector<RemoteGDB *> remoteGDB;
     std::vector<GDBListener *> gdbListen;
-    bool breakpoint();
+    virtual bool breakpoint() = 0;
+#endif // FULL_SYSTEM
 
   public:
     struct Params
     {
         std::string name;
-        Tick boot_cpu_frequency;
-        MemoryController *memctrl;
         PhysicalMemory *physmem;
+
+#if FULL_SYSTEM
+        Tick boot_cpu_frequency;
+        std::string boot_osflags;
         uint64_t init_param;
         bool bin;
         std::vector<std::string> binned_fns;
         bool bin_int;
 
         std::string kernel_path;
-        std::string console_path;
-        std::string palcode;
-        std::string boot_osflags;
-
         std::string readfile;
-        uint64_t system_type;
-        uint64_t system_rev;
+#endif
     };
-    Params *params;
 
+  protected:
+    Params *_params;
+
+  public:
     System(Params *p);
     ~System();
 
     void startup();
 
+    const Params *params() const { return (const Params *)_params; }
+
   public:
+
+#if FULL_SYSTEM
     /**
      * Returns the addess the kernel starts at.
      * @return address the kernel starts at
@@ -145,7 +198,13 @@ class System : public SimObject
      */
     Addr getKernelEntry() const { return kernelEntry; }
 
-    int registerExecContext(ExecContext *xc);
+#else
+
+    Addr new_page();
+
+#endif // FULL_SYSTEM
+
+    int registerExecContext(ExecContext *xc, int xcIndex);
     void replaceExecContext(ExecContext *xc, int xcIndex);
 
     void regStats();
@@ -163,6 +222,8 @@ class System : public SimObject
     static int numSystemsRunning;
 
     static void printSystems();
+
+
 };
 
 #endif // __SYSTEM_HH__