system.hh (2632:1bb2f91485ea) system.hh (2665:a124942bacb8)
1/*
2 * Copyright (c) 2002-2005 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.
1/*
2 * Copyright (c) 2002-2005 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 * Authors: Steve Reinhardt
29 * Lisa Hsu
30 * Nathan Binkert
27 */
28
29#ifndef __SYSTEM_HH__
30#define __SYSTEM_HH__
31
32#include <string>
33#include <vector>
34
35#include "base/loader/symtab.hh"
36#include "base/misc.hh"
37#include "base/statistics.hh"
38#include "cpu/pc_event.hh"
39#include "mem/port.hh"
40#include "sim/sim_object.hh"
41#if FULL_SYSTEM
42#include "kern/system_events.hh"
43#include "mem/vport.hh"
44#endif
45
46class BaseCPU;
47class ExecContext;
48class ObjectFile;
49class PhysicalMemory;
50
51#if FULL_SYSTEM
52class Platform;
53class GDBListener;
54class RemoteGDB;
55namespace Kernel { class Binning; }
56#endif
57
58class System : public SimObject
59{
60 public:
61 PhysicalMemory *physmem;
62 PCEventQueue pcEventQueue;
63
64 std::vector<ExecContext *> execContexts;
65 int numcpus;
66
67 int getNumCPUs()
68 {
69 if (numcpus != execContexts.size())
70 panic("cpu array not fully populated!");
71
72 return numcpus;
73 }
74
75#if FULL_SYSTEM
76 Platform *platform;
77 uint64_t init_param;
78
79 /** Port to physical memory used for writing object files into ram at
80 * boot.*/
81 FunctionalPort functionalPort;
82 VirtualPort virtPort;
83
84 /** kernel symbol table */
85 SymbolTable *kernelSymtab;
86
87 /** Object pointer for the kernel code */
88 ObjectFile *kernel;
89
90 /** Begining of kernel code */
91 Addr kernelStart;
92
93 /** End of kernel code */
94 Addr kernelEnd;
95
96 /** Entry point in the kernel to start at */
97 Addr kernelEntry;
98
99 Kernel::Binning *kernelBinning;
100
101#else
102
103 int page_ptr;
104
105
106#endif // FULL_SYSTEM
107
108 protected:
109
110#if FULL_SYSTEM
111 /**
112 * Fix up an address used to match PCs for hooking simulator
113 * events on to target function executions. See comment in
114 * system.cc for details.
115 */
116 virtual Addr fixFuncEventAddr(Addr addr) = 0;
117
118 /**
119 * Add a function-based event to the given function, to be looked
120 * up in the specified symbol table.
121 */
122 template <class T>
123 T *System::addFuncEvent(SymbolTable *symtab, const char *lbl)
124 {
125 Addr addr = 0; // initialize only to avoid compiler warning
126
127 if (symtab->findAddress(lbl, addr)) {
128 T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr));
129 return ev;
130 }
131
132 return NULL;
133 }
134
135 /** Add a function-based event to kernel code. */
136 template <class T>
137 T *System::addKernelFuncEvent(const char *lbl)
138 {
139 return addFuncEvent<T>(kernelSymtab, lbl);
140 }
141
142#endif
143 public:
144#if FULL_SYSTEM
145 std::vector<RemoteGDB *> remoteGDB;
146 std::vector<GDBListener *> gdbListen;
147 virtual bool breakpoint() = 0;
148#endif // FULL_SYSTEM
149
150 public:
151 struct Params
152 {
153 std::string name;
154 PhysicalMemory *physmem;
155
156#if FULL_SYSTEM
157 Tick boot_cpu_frequency;
158 std::string boot_osflags;
159 uint64_t init_param;
160 bool bin;
161 std::vector<std::string> binned_fns;
162 bool bin_int;
163
164 std::string kernel_path;
165 std::string readfile;
166#endif
167 };
168
169 protected:
170 Params *_params;
171
172 public:
173 System(Params *p);
174 ~System();
175
176 void startup();
177
178 const Params *params() const { return (const Params *)_params; }
179
180 public:
181
182#if FULL_SYSTEM
183 /**
184 * Returns the addess the kernel starts at.
185 * @return address the kernel starts at
186 */
187 Addr getKernelStart() const { return kernelStart; }
188
189 /**
190 * Returns the addess the kernel ends at.
191 * @return address the kernel ends at
192 */
193 Addr getKernelEnd() const { return kernelEnd; }
194
195 /**
196 * Returns the addess the entry point to the kernel code.
197 * @return entry point of the kernel code
198 */
199 Addr getKernelEntry() const { return kernelEntry; }
200
201#else
202
203 Addr new_page();
204
205#endif // FULL_SYSTEM
206
207 int registerExecContext(ExecContext *xc, int xcIndex);
208 void replaceExecContext(ExecContext *xc, int xcIndex);
209
210 void regStats();
211 void serialize(std::ostream &os);
212 void unserialize(Checkpoint *cp, const std::string &section);
213
214 public:
215 ////////////////////////////////////////////
216 //
217 // STATIC GLOBAL SYSTEM LIST
218 //
219 ////////////////////////////////////////////
220
221 static std::vector<System *> systemList;
222 static int numSystemsRunning;
223
224 static void printSystems();
225
226
227};
228
229#endif // __SYSTEM_HH__
31 */
32
33#ifndef __SYSTEM_HH__
34#define __SYSTEM_HH__
35
36#include <string>
37#include <vector>
38
39#include "base/loader/symtab.hh"
40#include "base/misc.hh"
41#include "base/statistics.hh"
42#include "cpu/pc_event.hh"
43#include "mem/port.hh"
44#include "sim/sim_object.hh"
45#if FULL_SYSTEM
46#include "kern/system_events.hh"
47#include "mem/vport.hh"
48#endif
49
50class BaseCPU;
51class ExecContext;
52class ObjectFile;
53class PhysicalMemory;
54
55#if FULL_SYSTEM
56class Platform;
57class GDBListener;
58class RemoteGDB;
59namespace Kernel { class Binning; }
60#endif
61
62class System : public SimObject
63{
64 public:
65 PhysicalMemory *physmem;
66 PCEventQueue pcEventQueue;
67
68 std::vector<ExecContext *> execContexts;
69 int numcpus;
70
71 int getNumCPUs()
72 {
73 if (numcpus != execContexts.size())
74 panic("cpu array not fully populated!");
75
76 return numcpus;
77 }
78
79#if FULL_SYSTEM
80 Platform *platform;
81 uint64_t init_param;
82
83 /** Port to physical memory used for writing object files into ram at
84 * boot.*/
85 FunctionalPort functionalPort;
86 VirtualPort virtPort;
87
88 /** kernel symbol table */
89 SymbolTable *kernelSymtab;
90
91 /** Object pointer for the kernel code */
92 ObjectFile *kernel;
93
94 /** Begining of kernel code */
95 Addr kernelStart;
96
97 /** End of kernel code */
98 Addr kernelEnd;
99
100 /** Entry point in the kernel to start at */
101 Addr kernelEntry;
102
103 Kernel::Binning *kernelBinning;
104
105#else
106
107 int page_ptr;
108
109
110#endif // FULL_SYSTEM
111
112 protected:
113
114#if FULL_SYSTEM
115 /**
116 * Fix up an address used to match PCs for hooking simulator
117 * events on to target function executions. See comment in
118 * system.cc for details.
119 */
120 virtual Addr fixFuncEventAddr(Addr addr) = 0;
121
122 /**
123 * Add a function-based event to the given function, to be looked
124 * up in the specified symbol table.
125 */
126 template <class T>
127 T *System::addFuncEvent(SymbolTable *symtab, const char *lbl)
128 {
129 Addr addr = 0; // initialize only to avoid compiler warning
130
131 if (symtab->findAddress(lbl, addr)) {
132 T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr));
133 return ev;
134 }
135
136 return NULL;
137 }
138
139 /** Add a function-based event to kernel code. */
140 template <class T>
141 T *System::addKernelFuncEvent(const char *lbl)
142 {
143 return addFuncEvent<T>(kernelSymtab, lbl);
144 }
145
146#endif
147 public:
148#if FULL_SYSTEM
149 std::vector<RemoteGDB *> remoteGDB;
150 std::vector<GDBListener *> gdbListen;
151 virtual bool breakpoint() = 0;
152#endif // FULL_SYSTEM
153
154 public:
155 struct Params
156 {
157 std::string name;
158 PhysicalMemory *physmem;
159
160#if FULL_SYSTEM
161 Tick boot_cpu_frequency;
162 std::string boot_osflags;
163 uint64_t init_param;
164 bool bin;
165 std::vector<std::string> binned_fns;
166 bool bin_int;
167
168 std::string kernel_path;
169 std::string readfile;
170#endif
171 };
172
173 protected:
174 Params *_params;
175
176 public:
177 System(Params *p);
178 ~System();
179
180 void startup();
181
182 const Params *params() const { return (const Params *)_params; }
183
184 public:
185
186#if FULL_SYSTEM
187 /**
188 * Returns the addess the kernel starts at.
189 * @return address the kernel starts at
190 */
191 Addr getKernelStart() const { return kernelStart; }
192
193 /**
194 * Returns the addess the kernel ends at.
195 * @return address the kernel ends at
196 */
197 Addr getKernelEnd() const { return kernelEnd; }
198
199 /**
200 * Returns the addess the entry point to the kernel code.
201 * @return entry point of the kernel code
202 */
203 Addr getKernelEntry() const { return kernelEntry; }
204
205#else
206
207 Addr new_page();
208
209#endif // FULL_SYSTEM
210
211 int registerExecContext(ExecContext *xc, int xcIndex);
212 void replaceExecContext(ExecContext *xc, int xcIndex);
213
214 void regStats();
215 void serialize(std::ostream &os);
216 void unserialize(Checkpoint *cp, const std::string &section);
217
218 public:
219 ////////////////////////////////////////////
220 //
221 // STATIC GLOBAL SYSTEM LIST
222 //
223 ////////////////////////////////////////////
224
225 static std::vector<System *> systemList;
226 static int numSystemsRunning;
227
228 static void printSystems();
229
230
231};
232
233#endif // __SYSTEM_HH__