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"
50 #include "kern/system_events.hh"
66 class System : public SimObject
70 static const char *MemoryModeStrings[3];
79 /** Change the memory mode of the system. This should only be called by the
81 * @param mode Mode to change to (atomic/timing)
83 void setMemoryMode(Enums::MemoryMode mode);
85 PhysicalMemory *physmem;
86 PCEventQueue pcEventQueue;
88 std::vector<ThreadContext *> threadContexts;
91 ThreadContext *getThreadContext(ThreadID tid)
93 return threadContexts[tid];
98 assert(_numContexts == (int)threadContexts.size());
102 /** Return number of running (non-halted) thread contexts in
103 * system. These threads could be Active or Suspended. */
104 int numRunningContexts();
110 /** Port to physical memory used for writing object files into ram at
112 FunctionalPort *functionalPort;
113 VirtualPort *virtPort;
115 /** kernel symbol table */
116 SymbolTable *kernelSymtab;
118 /** Object pointer for the kernel code */
121 /** Begining of kernel code */
124 /** End of kernel code */
127 /** Entry point in the kernel to start at */
130 /** Mask that should be anded for binary/symbol loading.
131 * This allows one two different OS requirements for the same ISA to be
132 * handled. Some OSes are compiled for a virtual address and need to be
133 * loaded into physical memory that starts at address 0, while other
134 * bare metal tools generate images that start at address 0.
146 uint64_t allocatePID()
151 /** Amount of physical memory that is still free */
154 /** Amount of physical memory that exists */
158 #endif // FULL_SYSTEM
161 Enums::MemoryMode memoryMode;
165 * Fix up an address used to match PCs for hooking simulator
166 * events on to target function executions. See comment in
167 * system.cc for details.
169 virtual Addr fixFuncEventAddr(Addr addr) = 0;
172 * Add a function-based event to the given function, to be looked
173 * up in the specified symbol table.
176 T *addFuncEvent(SymbolTable *symtab, const char *lbl)
178 Addr addr = 0; // initialize only to avoid compiler warning
180 if (symtab->findAddress(lbl, addr)) {
181 T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr));
188 /** Add a function-based event to kernel code. */
190 T *addKernelFuncEvent(const char *lbl)
192 return addFuncEvent<T>(kernelSymtab, lbl);
197 std::vector<BaseRemoteGDB *> remoteGDB;
198 std::vector<GDBListener *> gdbListen;
202 typedef SystemParams Params;
213 const Params *params() const { return (const Params *)_params; }
219 * Returns the addess the kernel starts at.
220 * @return address the kernel starts at
222 Addr getKernelStart() const { return kernelStart; }
225 * Returns the addess the kernel ends at.
226 * @return address the kernel ends at
228 Addr getKernelEnd() const { return kernelEnd; }
231 * Returns the addess the entry point to the kernel code.
232 * @return entry point of the kernel code
234 Addr getKernelEntry() const { return kernelEntry; }
240 #endif // FULL_SYSTEM
242 int registerThreadContext(ThreadContext *tc, int assigned=-1);
243 void replaceThreadContext(ThreadContext *tc, int context_id);
245 void serialize(std::ostream &os);
246 void unserialize(Checkpoint *cp, const std::string §ion);
249 ////////////////////////////////////////////
251 // STATIC GLOBAL SYSTEM LIST
253 ////////////////////////////////////////////
255 static std::vector<System *> systemList;
256 static int numSystemsRunning;
258 static void printSystems();
263 #endif // __SYSTEM_HH__