system.cc (3980:9bcb2a2e9bb8) system.cc (4762:c94e103c83ad)
1/*
2 * Copyright (c) 2002-2006 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: Ali Saidi
29 */
30
31#include "arch/sparc/system.hh"
32#include "arch/vtophys.hh"
33#include "base/remote_gdb.hh"
34#include "base/loader/object_file.hh"
35#include "base/loader/symtab.hh"
36#include "base/trace.hh"
37#include "mem/physical.hh"
1/*
2 * Copyright (c) 2002-2006 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: Ali Saidi
29 */
30
31#include "arch/sparc/system.hh"
32#include "arch/vtophys.hh"
33#include "base/remote_gdb.hh"
34#include "base/loader/object_file.hh"
35#include "base/loader/symtab.hh"
36#include "base/trace.hh"
37#include "mem/physical.hh"
38#include "params/SparcSystem.hh"
38#include "sim/byteswap.hh"
39#include "sim/byteswap.hh"
39#include "sim/builder.hh"
40
41
42using namespace BigEndianGuest;
43
44SparcSystem::SparcSystem(Params *p)
45 : System(p), sysTick(0),funcRomPort(p->name + "-fromport"),
46 funcNvramPort(p->name + "-fnvramport"),
47 funcHypDescPort(p->name + "-fhypdescport"),
48 funcPartDescPort(p->name + "-fpartdescport")
49{
50 resetSymtab = new SymbolTable;
51 hypervisorSymtab = new SymbolTable;
52 openbootSymtab = new SymbolTable;
53 nvramSymtab = new SymbolTable;
54 hypervisorDescSymtab = new SymbolTable;
55 partitionDescSymtab = new SymbolTable;
56
57 Port *rom_port;
58 rom_port = params()->rom->getPort("functional");
59 funcRomPort.setPeer(rom_port);
60 rom_port->setPeer(&funcRomPort);
61
62 rom_port = params()->nvram->getPort("functional");
63 funcNvramPort.setPeer(rom_port);
64 rom_port->setPeer(&funcNvramPort);
65
66 rom_port = params()->hypervisor_desc->getPort("functional");
67 funcHypDescPort.setPeer(rom_port);
68 rom_port->setPeer(&funcHypDescPort);
69
70 rom_port = params()->partition_desc->getPort("functional");
71 funcPartDescPort.setPeer(rom_port);
72 rom_port->setPeer(&funcPartDescPort);
73
74 /**
75 * Load the boot code, and hypervisor into memory.
76 */
77 // Read the reset binary
78 reset = createObjectFile(params()->reset_bin, true);
79 if (reset == NULL)
80 fatal("Could not load reset binary %s", params()->reset_bin);
81
82 // Read the openboot binary
83 openboot = createObjectFile(params()->openboot_bin, true);
84 if (openboot == NULL)
85 fatal("Could not load openboot bianry %s", params()->openboot_bin);
86
87 // Read the hypervisor binary
88 hypervisor = createObjectFile(params()->hypervisor_bin, true);
89 if (hypervisor == NULL)
90 fatal("Could not load hypervisor binary %s", params()->hypervisor_bin);
91
92 // Read the nvram image
93 nvram = createObjectFile(params()->nvram_bin, true);
94 if (nvram == NULL)
95 fatal("Could not load nvram image %s", params()->nvram_bin);
96
97 // Read the hypervisor description image
98 hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true);
99 if (hypervisor_desc == NULL)
100 fatal("Could not load hypervisor description image %s",
101 params()->hypervisor_desc_bin);
102
103 // Read the partition description image
104 partition_desc = createObjectFile(params()->partition_desc_bin, true);
105 if (partition_desc == NULL)
106 fatal("Could not load partition description image %s",
107 params()->partition_desc_bin);
108
109
110 // Load reset binary into memory
111 reset->setTextBase(params()->reset_addr);
112 reset->loadSections(&funcRomPort);
113 // Load the openboot binary
114 openboot->setTextBase(params()->openboot_addr);
115 openboot->loadSections(&funcRomPort);
116 // Load the hypervisor binary
117 hypervisor->setTextBase(params()->hypervisor_addr);
118 hypervisor->loadSections(&funcRomPort);
119 // Load the nvram image
120 nvram->setTextBase(params()->nvram_addr);
121 nvram->loadSections(&funcNvramPort);
122 // Load the hypervisor description image
123 hypervisor_desc->setTextBase(params()->hypervisor_desc_addr);
124 hypervisor_desc->loadSections(&funcHypDescPort);
125 // Load the partition description image
126 partition_desc->setTextBase(params()->partition_desc_addr);
127 partition_desc->loadSections(&funcPartDescPort);
128
129 // load symbols
130 if (!reset->loadGlobalSymbols(resetSymtab))
131 panic("could not load reset symbols\n");
132
133 if (!openboot->loadGlobalSymbols(openbootSymtab))
134 panic("could not load openboot symbols\n");
135
136 if (!hypervisor->loadLocalSymbols(hypervisorSymtab))
137 panic("could not load hypervisor symbols\n");
138
139 if (!nvram->loadLocalSymbols(nvramSymtab))
140 panic("could not load nvram symbols\n");
141
142 if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab))
143 panic("could not load hypervisor description symbols\n");
144
145 if (!partition_desc->loadLocalSymbols(partitionDescSymtab))
146 panic("could not load partition description symbols\n");
147
148 // load symbols into debug table
149 if (!reset->loadGlobalSymbols(debugSymbolTable))
150 panic("could not load reset symbols\n");
151
152 if (!openboot->loadGlobalSymbols(debugSymbolTable))
153 panic("could not load openboot symbols\n");
154
155 if (!hypervisor->loadLocalSymbols(debugSymbolTable))
156 panic("could not load hypervisor symbols\n");
157
158 // Strip off the rom address so when the hypervisor is copied into memory we
159 // have symbols still
160 if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF))
161 panic("could not load hypervisor symbols\n");
162
163 if (!nvram->loadGlobalSymbols(debugSymbolTable))
164 panic("could not load reset symbols\n");
165
166 if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable))
167 panic("could not load hypervisor description symbols\n");
168
169 if (!partition_desc->loadLocalSymbols(debugSymbolTable))
170 panic("could not load partition description symbols\n");
171
172
173 // @todo any fixup code over writing data in binaries on setting break
174 // events on functions should happen here.
175
176}
177
178SparcSystem::~SparcSystem()
179{
180 delete resetSymtab;
181 delete hypervisorSymtab;
182 delete openbootSymtab;
183 delete nvramSymtab;
184 delete hypervisorDescSymtab;
185 delete partitionDescSymtab;
186 delete reset;
187 delete openboot;
188 delete hypervisor;
189 delete nvram;
190 delete hypervisor_desc;
191 delete partition_desc;
192}
193
194void
195SparcSystem::serialize(std::ostream &os)
196{
197 System::serialize(os);
198 resetSymtab->serialize("reset_symtab", os);
199 hypervisorSymtab->serialize("hypervisor_symtab", os);
200 openbootSymtab->serialize("openboot_symtab", os);
201 nvramSymtab->serialize("nvram_symtab", os);
202 hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os);
203 partitionDescSymtab->serialize("partition_desc_symtab", os);
204}
205
206
207void
208SparcSystem::unserialize(Checkpoint *cp, const std::string &section)
209{
210 System::unserialize(cp,section);
211 resetSymtab->unserialize("reset_symtab", cp, section);
212 hypervisorSymtab->unserialize("hypervisor_symtab", cp, section);
213 openbootSymtab->unserialize("openboot_symtab", cp, section);
214 nvramSymtab->unserialize("nvram_symtab", cp, section);
215 hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section);
216 partitionDescSymtab->unserialize("partition_desc_symtab", cp, section);
217}
218
40
41
42using namespace BigEndianGuest;
43
44SparcSystem::SparcSystem(Params *p)
45 : System(p), sysTick(0),funcRomPort(p->name + "-fromport"),
46 funcNvramPort(p->name + "-fnvramport"),
47 funcHypDescPort(p->name + "-fhypdescport"),
48 funcPartDescPort(p->name + "-fpartdescport")
49{
50 resetSymtab = new SymbolTable;
51 hypervisorSymtab = new SymbolTable;
52 openbootSymtab = new SymbolTable;
53 nvramSymtab = new SymbolTable;
54 hypervisorDescSymtab = new SymbolTable;
55 partitionDescSymtab = new SymbolTable;
56
57 Port *rom_port;
58 rom_port = params()->rom->getPort("functional");
59 funcRomPort.setPeer(rom_port);
60 rom_port->setPeer(&funcRomPort);
61
62 rom_port = params()->nvram->getPort("functional");
63 funcNvramPort.setPeer(rom_port);
64 rom_port->setPeer(&funcNvramPort);
65
66 rom_port = params()->hypervisor_desc->getPort("functional");
67 funcHypDescPort.setPeer(rom_port);
68 rom_port->setPeer(&funcHypDescPort);
69
70 rom_port = params()->partition_desc->getPort("functional");
71 funcPartDescPort.setPeer(rom_port);
72 rom_port->setPeer(&funcPartDescPort);
73
74 /**
75 * Load the boot code, and hypervisor into memory.
76 */
77 // Read the reset binary
78 reset = createObjectFile(params()->reset_bin, true);
79 if (reset == NULL)
80 fatal("Could not load reset binary %s", params()->reset_bin);
81
82 // Read the openboot binary
83 openboot = createObjectFile(params()->openboot_bin, true);
84 if (openboot == NULL)
85 fatal("Could not load openboot bianry %s", params()->openboot_bin);
86
87 // Read the hypervisor binary
88 hypervisor = createObjectFile(params()->hypervisor_bin, true);
89 if (hypervisor == NULL)
90 fatal("Could not load hypervisor binary %s", params()->hypervisor_bin);
91
92 // Read the nvram image
93 nvram = createObjectFile(params()->nvram_bin, true);
94 if (nvram == NULL)
95 fatal("Could not load nvram image %s", params()->nvram_bin);
96
97 // Read the hypervisor description image
98 hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true);
99 if (hypervisor_desc == NULL)
100 fatal("Could not load hypervisor description image %s",
101 params()->hypervisor_desc_bin);
102
103 // Read the partition description image
104 partition_desc = createObjectFile(params()->partition_desc_bin, true);
105 if (partition_desc == NULL)
106 fatal("Could not load partition description image %s",
107 params()->partition_desc_bin);
108
109
110 // Load reset binary into memory
111 reset->setTextBase(params()->reset_addr);
112 reset->loadSections(&funcRomPort);
113 // Load the openboot binary
114 openboot->setTextBase(params()->openboot_addr);
115 openboot->loadSections(&funcRomPort);
116 // Load the hypervisor binary
117 hypervisor->setTextBase(params()->hypervisor_addr);
118 hypervisor->loadSections(&funcRomPort);
119 // Load the nvram image
120 nvram->setTextBase(params()->nvram_addr);
121 nvram->loadSections(&funcNvramPort);
122 // Load the hypervisor description image
123 hypervisor_desc->setTextBase(params()->hypervisor_desc_addr);
124 hypervisor_desc->loadSections(&funcHypDescPort);
125 // Load the partition description image
126 partition_desc->setTextBase(params()->partition_desc_addr);
127 partition_desc->loadSections(&funcPartDescPort);
128
129 // load symbols
130 if (!reset->loadGlobalSymbols(resetSymtab))
131 panic("could not load reset symbols\n");
132
133 if (!openboot->loadGlobalSymbols(openbootSymtab))
134 panic("could not load openboot symbols\n");
135
136 if (!hypervisor->loadLocalSymbols(hypervisorSymtab))
137 panic("could not load hypervisor symbols\n");
138
139 if (!nvram->loadLocalSymbols(nvramSymtab))
140 panic("could not load nvram symbols\n");
141
142 if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab))
143 panic("could not load hypervisor description symbols\n");
144
145 if (!partition_desc->loadLocalSymbols(partitionDescSymtab))
146 panic("could not load partition description symbols\n");
147
148 // load symbols into debug table
149 if (!reset->loadGlobalSymbols(debugSymbolTable))
150 panic("could not load reset symbols\n");
151
152 if (!openboot->loadGlobalSymbols(debugSymbolTable))
153 panic("could not load openboot symbols\n");
154
155 if (!hypervisor->loadLocalSymbols(debugSymbolTable))
156 panic("could not load hypervisor symbols\n");
157
158 // Strip off the rom address so when the hypervisor is copied into memory we
159 // have symbols still
160 if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF))
161 panic("could not load hypervisor symbols\n");
162
163 if (!nvram->loadGlobalSymbols(debugSymbolTable))
164 panic("could not load reset symbols\n");
165
166 if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable))
167 panic("could not load hypervisor description symbols\n");
168
169 if (!partition_desc->loadLocalSymbols(debugSymbolTable))
170 panic("could not load partition description symbols\n");
171
172
173 // @todo any fixup code over writing data in binaries on setting break
174 // events on functions should happen here.
175
176}
177
178SparcSystem::~SparcSystem()
179{
180 delete resetSymtab;
181 delete hypervisorSymtab;
182 delete openbootSymtab;
183 delete nvramSymtab;
184 delete hypervisorDescSymtab;
185 delete partitionDescSymtab;
186 delete reset;
187 delete openboot;
188 delete hypervisor;
189 delete nvram;
190 delete hypervisor_desc;
191 delete partition_desc;
192}
193
194void
195SparcSystem::serialize(std::ostream &os)
196{
197 System::serialize(os);
198 resetSymtab->serialize("reset_symtab", os);
199 hypervisorSymtab->serialize("hypervisor_symtab", os);
200 openbootSymtab->serialize("openboot_symtab", os);
201 nvramSymtab->serialize("nvram_symtab", os);
202 hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os);
203 partitionDescSymtab->serialize("partition_desc_symtab", os);
204}
205
206
207void
208SparcSystem::unserialize(Checkpoint *cp, const std::string &section)
209{
210 System::unserialize(cp,section);
211 resetSymtab->unserialize("reset_symtab", cp, section);
212 hypervisorSymtab->unserialize("hypervisor_symtab", cp, section);
213 openbootSymtab->unserialize("openboot_symtab", cp, section);
214 nvramSymtab->unserialize("nvram_symtab", cp, section);
215 hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section);
216 partitionDescSymtab->unserialize("partition_desc_symtab", cp, section);
217}
218
219
220BEGIN_DECLARE_SIM_OBJECT_PARAMS(SparcSystem)
221
222 SimObjectParam<PhysicalMemory *> physmem;
223 SimObjectParam<PhysicalMemory *> rom;
224 SimObjectParam<PhysicalMemory *> nvram;
225 SimObjectParam<PhysicalMemory *> hypervisor_desc;
226 SimObjectParam<PhysicalMemory *> partition_desc;
227 SimpleEnumParam<System::MemoryMode> mem_mode;
228
229 Param<Addr> reset_addr;
230 Param<Addr> hypervisor_addr;
231 Param<Addr> openboot_addr;
232 Param<Addr> nvram_addr;
233 Param<Addr> hypervisor_desc_addr;
234 Param<Addr> partition_desc_addr;
235
236 Param<std::string> kernel;
237 Param<std::string> reset_bin;
238 Param<std::string> hypervisor_bin;
239 Param<std::string> openboot_bin;
240 Param<std::string> nvram_bin;
241 Param<std::string> hypervisor_desc_bin;
242 Param<std::string> partition_desc_bin;
243
244 Param<Tick> boot_cpu_frequency;
245 Param<std::string> boot_osflags;
246 Param<std::string> readfile;
247 Param<unsigned int> init_param;
248
249END_DECLARE_SIM_OBJECT_PARAMS(SparcSystem)
250
251BEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem)
252
253 INIT_PARAM(physmem, "phsyical memory"),
254 INIT_PARAM(rom, "ROM for boot code"),
255 INIT_PARAM(nvram, "Non-volatile RAM for the nvram"),
256 INIT_PARAM(hypervisor_desc, "ROM for the hypervisor description"),
257 INIT_PARAM(partition_desc, "ROM for the partition description"),
258 INIT_ENUM_PARAM(mem_mode, "Memory Mode, (1=atomic, 2=timing)",
259 System::MemoryModeStrings),
260
261 INIT_PARAM(reset_addr, "Address that reset should be loaded at"),
262 INIT_PARAM(hypervisor_addr, "Address that hypervisor should be loaded at"),
263 INIT_PARAM(openboot_addr, "Address that openboot should be loaded at"),
264 INIT_PARAM(nvram_addr, "Address that nvram should be loaded at"),
265 INIT_PARAM(hypervisor_desc_addr,
266 "Address that hypervisor description should be loaded at"),
267 INIT_PARAM(partition_desc_addr,
268 "Address that partition description should be loaded at"),
269
270 INIT_PARAM(kernel, "file that contains the kernel code"),
271 INIT_PARAM(reset_bin, "file that contains the reset code"),
272 INIT_PARAM(hypervisor_bin, "file that contains the hypervisor code"),
273 INIT_PARAM(openboot_bin, "file that contains the openboot code"),
274 INIT_PARAM(nvram_bin, "file that contains the nvram image"),
275 INIT_PARAM(hypervisor_desc_bin,
276 "file that contains the hypervisor description image"),
277 INIT_PARAM(partition_desc_bin,
278 "file that contains the partition description image"),
279 INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"),
280 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot",
281 "a"),
282 INIT_PARAM_DFLT(readfile, "file to read startup script from", ""),
283 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0)
284
285END_INIT_SIM_OBJECT_PARAMS(SparcSystem)
286
287CREATE_SIM_OBJECT(SparcSystem)
219SparcSystem *
220SparcSystemParams::create()
288{
221{
289 SparcSystem::Params *p = new SparcSystem::Params;
290 p->name = getInstanceName();
291 p->boot_cpu_frequency = boot_cpu_frequency;
292 p->physmem = physmem;
293 p->rom = rom;
294 p->nvram = nvram;
295 p->hypervisor_desc = hypervisor_desc;
296 p->partition_desc = partition_desc;
297 p->mem_mode = mem_mode;
298 p->kernel_path = kernel;
299 p->reset_addr = reset_addr;
300 p->hypervisor_addr = hypervisor_addr;
301 p->openboot_addr = openboot_addr;
302 p->nvram_addr = nvram_addr;
303 p->hypervisor_desc_addr = hypervisor_desc_addr;
304 p->partition_desc_addr = partition_desc_addr;
305 p->reset_bin = reset_bin;
306 p->hypervisor_bin = hypervisor_bin;
307 p->openboot_bin = openboot_bin;
308 p->nvram_bin = nvram_bin;
309 p->hypervisor_desc_bin = hypervisor_desc_bin;
310 p->partition_desc_bin = partition_desc_bin;
311 p->boot_osflags = boot_osflags;
312 p->init_param = init_param;
313 p->readfile = readfile;
314 return new SparcSystem(p);
222 return new SparcSystem(this);
315}
223}
316
317REGISTER_SIM_OBJECT("SparcSystem", SparcSystem)
318
319