2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Steve Reinhardt
39 #include "base/loader/symtab.hh"
40 #include "base/misc.hh"
41 #include "base/statistics.hh"
42 #include "config/full_system.hh"
43 #include "cpu/pc_event.hh"
44 #include "enums/MemoryMode.hh"
45 #include "mem/port.hh"
46 #include "params/System.hh"
47 #include "sim/sim_object.hh"
49 #include "kern/system_events.hh"
50 #include "mem/vport.hh"
67 class System : public SimObject
71 static const char *MemoryModeStrings[3];
80 /** Change the memory mode of the system. This should only be called by the
82 * @param mode Mode to change to (atomic/timing)
84 void setMemoryMode(Enums::MemoryMode mode);
86 PhysicalMemory *physmem;
87 PCEventQueue pcEventQueue;
89 std::vector<ThreadContext *> threadContexts;
92 ThreadContext *getThreadContext(int tid)
94 return threadContexts[tid];
99 assert(_numContexts == threadContexts.size());
103 /** Return number of running (non-halted) thread contexts in
104 * system. These threads could be Active or Suspended. */
105 int numRunningContexts();
111 /** Port to physical memory used for writing object files into ram at
113 FunctionalPort functionalPort;
114 VirtualPort virtPort;
116 /** kernel symbol table */
117 SymbolTable *kernelSymtab;
119 /** Object pointer for the kernel code */
122 /** Begining of kernel code */
125 /** End of kernel code */
128 /** Entry point in the kernel to start at */
139 uint64_t allocatePID()
144 /** Amount of physical memory that is still free */
147 /** Amount of physical memory that exists */
151 #endif // FULL_SYSTEM
154 Enums::MemoryMode memoryMode;
158 * Fix up an address used to match PCs for hooking simulator
159 * events on to target function executions. See comment in
160 * system.cc for details.
162 virtual Addr fixFuncEventAddr(Addr addr) = 0;
165 * Add a function-based event to the given function, to be looked
166 * up in the specified symbol table.
169 T *addFuncEvent(SymbolTable *symtab, const char *lbl)
171 Addr addr = 0; // initialize only to avoid compiler warning
173 if (symtab->findAddress(lbl, addr)) {
174 T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr));
181 /** Add a function-based event to kernel code. */
183 T *addKernelFuncEvent(const char *lbl)
185 return addFuncEvent<T>(kernelSymtab, lbl);
190 std::vector<TheISA::RemoteGDB *> remoteGDB;
191 std::vector<GDBListener *> gdbListen;
195 typedef SystemParams Params;
206 const Params *params() const { return (const Params *)_params; }
212 * Returns the addess the kernel starts at.
213 * @return address the kernel starts at
215 Addr getKernelStart() const { return kernelStart; }
218 * Returns the addess the kernel ends at.
219 * @return address the kernel ends at
221 Addr getKernelEnd() const { return kernelEnd; }
224 * Returns the addess the entry point to the kernel code.
225 * @return entry point of the kernel code
227 Addr getKernelEntry() const { return kernelEntry; }
233 #endif // FULL_SYSTEM
235 int registerThreadContext(ThreadContext *tc, int assigned=-1);
236 void replaceThreadContext(ThreadContext *tc, int context_id);
238 void serialize(std::ostream &os);
239 void unserialize(Checkpoint *cp, const std::string §ion);
242 ////////////////////////////////////////////
244 // STATIC GLOBAL SYSTEM LIST
246 ////////////////////////////////////////////
248 static std::vector<System *> systemList;
249 static int numSystemsRunning;
251 static void printSystems();
256 #endif // __SYSTEM_HH__