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 "mem/port.hh"
45 #include "sim/sim_object.hh"
47 #include "kern/system_events.hh"
48 #include "mem/vport.hh"
62 class System : public SimObject
66 static const char *MemoryModeStrings[3];
68 SimObject::MemoryMode getMemoryMode() { assert(memoryMode); return memoryMode; }
70 /** Change the memory mode of the system. This should only be called by the
72 * @param mode Mode to change to (atomic/timing)
74 void setMemoryMode(SimObject::MemoryMode mode);
76 PhysicalMemory *physmem;
77 PCEventQueue pcEventQueue;
79 std::vector<ThreadContext *> threadContexts;
84 if (numcpus != threadContexts.size())
85 panic("cpu array not fully populated!");
94 /** Port to physical memory used for writing object files into ram at
96 FunctionalPort functionalPort;
99 /** kernel symbol table */
100 SymbolTable *kernelSymtab;
102 /** Object pointer for the kernel code */
105 /** Begining of kernel code */
108 /** End of kernel code */
111 /** Entry point in the kernel to start at */
119 #endif // FULL_SYSTEM
123 SimObject::MemoryMode memoryMode;
127 * Fix up an address used to match PCs for hooking simulator
128 * events on to target function executions. See comment in
129 * system.cc for details.
131 virtual Addr fixFuncEventAddr(Addr addr) = 0;
134 * Add a function-based event to the given function, to be looked
135 * up in the specified symbol table.
138 T *addFuncEvent(SymbolTable *symtab, const char *lbl)
140 Addr addr = 0; // initialize only to avoid compiler warning
142 if (symtab->findAddress(lbl, addr)) {
143 T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr));
150 /** Add a function-based event to kernel code. */
152 T *addKernelFuncEvent(const char *lbl)
154 return addFuncEvent<T>(kernelSymtab, lbl);
160 std::vector<RemoteGDB *> remoteGDB;
161 std::vector<GDBListener *> gdbListen;
162 virtual bool breakpoint() = 0;
163 #endif // FULL_SYSTEM
169 PhysicalMemory *physmem;
170 SimObject::MemoryMode mem_mode;
173 Tick boot_cpu_frequency;
174 std::string boot_osflags;
177 std::string kernel_path;
178 std::string readfile;
179 std::string symbolfile;
192 const Params *params() const { return (const Params *)_params; }
198 * Returns the addess the kernel starts at.
199 * @return address the kernel starts at
201 Addr getKernelStart() const { return kernelStart; }
204 * Returns the addess the kernel ends at.
205 * @return address the kernel ends at
207 Addr getKernelEnd() const { return kernelEnd; }
210 * Returns the addess the entry point to the kernel code.
211 * @return entry point of the kernel code
213 Addr getKernelEntry() const { return kernelEntry; }
219 #endif // FULL_SYSTEM
221 int registerThreadContext(ThreadContext *tc, int tcIndex);
222 void replaceThreadContext(ThreadContext *tc, int tcIndex);
224 void serialize(std::ostream &os);
225 void unserialize(Checkpoint *cp, const std::string §ion);
228 ////////////////////////////////////////////
230 // STATIC GLOBAL SYSTEM LIST
232 ////////////////////////////////////////////
234 static std::vector<System *> systemList;
235 static int numSystemsRunning;
237 static void printSystems();
242 #endif // __SYSTEM_HH__