Merge zizzer:/bk/m5 into vm1.reinhardt.house:/z/stever/bk/m5
[gem5.git] / sim / system.hh
1 /*
2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
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.
15 *
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.
27 */
28
29 #ifndef __SYSTEM_HH__
30 #define __SYSTEM_HH__
31
32 #include <string>
33 #include <vector>
34
35 #include "base/statistics.hh"
36 #include "cpu/pc_event.hh"
37 #include "kern/system_events.hh"
38 #include "sim/sim_object.hh"
39
40 class BaseCPU;
41 class ExecContext;
42 class GDBListener;
43 class MemoryController;
44 class ObjectFile;
45 class PhysicalMemory;
46 class Platform;
47 class RemoteGDB;
48 class SymbolTable;
49 namespace Kernel { class Binning; }
50
51 class System : public SimObject
52 {
53 public:
54 MemoryController *memctrl;
55 PhysicalMemory *physmem;
56 Platform *platform;
57 PCEventQueue pcEventQueue;
58 uint64_t init_param;
59
60 std::vector<ExecContext *> execContexts;
61
62 /** kernel Symbol table */
63 SymbolTable *kernelSymtab;
64
65 /** console symbol table */
66 SymbolTable *consoleSymtab;
67
68 /** pal symbol table */
69 SymbolTable *palSymtab;
70
71 /** Object pointer for the kernel code */
72 ObjectFile *kernel;
73
74 /** Object pointer for the console code */
75 ObjectFile *console;
76
77 /** Object pointer for the PAL code */
78 ObjectFile *pal;
79
80 /** Begining of kernel code */
81 Addr kernelStart;
82
83 /** End of kernel code */
84 Addr kernelEnd;
85
86 /** Entry point in the kernel to start at */
87 Addr kernelEntry;
88
89 Kernel::Binning *kernelBinning;
90
91 #ifdef DEBUG
92 /** Event to halt the simulator if the console calls panic() */
93 BreakPCEvent *consolePanicEvent;
94 #endif
95
96 public:
97 std::vector<RemoteGDB *> remoteGDB;
98 std::vector<GDBListener *> gdbListen;
99 bool breakpoint();
100
101 public:
102 struct Params
103 {
104 std::string name;
105 Tick boot_cpu_frequency;
106 MemoryController *memctrl;
107 PhysicalMemory *physmem;
108 uint64_t init_param;
109 bool bin;
110 std::vector<std::string> binned_fns;
111 bool bin_int;
112
113 std::string kernel_path;
114 std::string console_path;
115 std::string palcode;
116 std::string boot_osflags;
117
118 std::string readfile;
119 uint64_t system_type;
120 uint64_t system_rev;
121 };
122 Params *params;
123
124 System(Params *p);
125 ~System();
126
127 void startup();
128
129 public:
130 /**
131 * Returns the addess the kernel starts at.
132 * @return address the kernel starts at
133 */
134 Addr getKernelStart() const { return kernelStart; }
135
136 /**
137 * Returns the addess the kernel ends at.
138 * @return address the kernel ends at
139 */
140 Addr getKernelEnd() const { return kernelEnd; }
141
142 /**
143 * Returns the addess the entry point to the kernel code.
144 * @return entry point of the kernel code
145 */
146 Addr getKernelEntry() const { return kernelEntry; }
147
148 int registerExecContext(ExecContext *xc);
149 void replaceExecContext(ExecContext *xc, int xcIndex);
150
151 void regStats();
152 void serialize(std::ostream &os);
153 void unserialize(Checkpoint *cp, const std::string &section);
154
155 public:
156 ////////////////////////////////////////////
157 //
158 // STATIC GLOBAL SYSTEM LIST
159 //
160 ////////////////////////////////////////////
161
162 static std::vector<System *> systemList;
163 static int numSystemsRunning;
164
165 static void printSystems();
166 };
167
168 #endif // __SYSTEM_HH__