SE: move page allocation from PageTable to Process
[gem5.git] / src / arch / sparc / system.cc
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/loader/object_file.hh"
34 #include "base/loader/symtab.hh"
35 #include "base/trace.hh"
36 #include "mem/physical.hh"
37 #include "params/SparcSystem.hh"
38 #include "sim/byteswap.hh"
39
40 using namespace BigEndianGuest;
41
42 SparcSystem::SparcSystem(Params *p)
43 : System(p), sysTick(0),funcRomPort(p->name + "-fromport"),
44 funcNvramPort(p->name + "-fnvramport"),
45 funcHypDescPort(p->name + "-fhypdescport"),
46 funcPartDescPort(p->name + "-fpartdescport")
47 {
48 resetSymtab = new SymbolTable;
49 hypervisorSymtab = new SymbolTable;
50 openbootSymtab = new SymbolTable;
51 nvramSymtab = new SymbolTable;
52 hypervisorDescSymtab = new SymbolTable;
53 partitionDescSymtab = new SymbolTable;
54
55 Port *rom_port;
56 rom_port = params()->rom->getPort("functional");
57 funcRomPort.setPeer(rom_port);
58 rom_port->setPeer(&funcRomPort);
59
60 rom_port = params()->nvram->getPort("functional");
61 funcNvramPort.setPeer(rom_port);
62 rom_port->setPeer(&funcNvramPort);
63
64 rom_port = params()->hypervisor_desc->getPort("functional");
65 funcHypDescPort.setPeer(rom_port);
66 rom_port->setPeer(&funcHypDescPort);
67
68 rom_port = params()->partition_desc->getPort("functional");
69 funcPartDescPort.setPeer(rom_port);
70 rom_port->setPeer(&funcPartDescPort);
71
72 /**
73 * Load the boot code, and hypervisor into memory.
74 */
75 // Read the reset binary
76 reset = createObjectFile(params()->reset_bin, true);
77 if (reset == NULL)
78 fatal("Could not load reset binary %s", params()->reset_bin);
79
80 // Read the openboot binary
81 openboot = createObjectFile(params()->openboot_bin, true);
82 if (openboot == NULL)
83 fatal("Could not load openboot bianry %s", params()->openboot_bin);
84
85 // Read the hypervisor binary
86 hypervisor = createObjectFile(params()->hypervisor_bin, true);
87 if (hypervisor == NULL)
88 fatal("Could not load hypervisor binary %s", params()->hypervisor_bin);
89
90 // Read the nvram image
91 nvram = createObjectFile(params()->nvram_bin, true);
92 if (nvram == NULL)
93 fatal("Could not load nvram image %s", params()->nvram_bin);
94
95 // Read the hypervisor description image
96 hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true);
97 if (hypervisor_desc == NULL)
98 fatal("Could not load hypervisor description image %s",
99 params()->hypervisor_desc_bin);
100
101 // Read the partition description image
102 partition_desc = createObjectFile(params()->partition_desc_bin, true);
103 if (partition_desc == NULL)
104 fatal("Could not load partition description image %s",
105 params()->partition_desc_bin);
106
107
108 // Load reset binary into memory
109 reset->setTextBase(params()->reset_addr);
110 reset->loadSections(&funcRomPort);
111 // Load the openboot binary
112 openboot->setTextBase(params()->openboot_addr);
113 openboot->loadSections(&funcRomPort);
114 // Load the hypervisor binary
115 hypervisor->setTextBase(params()->hypervisor_addr);
116 hypervisor->loadSections(&funcRomPort);
117 // Load the nvram image
118 nvram->setTextBase(params()->nvram_addr);
119 nvram->loadSections(&funcNvramPort);
120 // Load the hypervisor description image
121 hypervisor_desc->setTextBase(params()->hypervisor_desc_addr);
122 hypervisor_desc->loadSections(&funcHypDescPort);
123 // Load the partition description image
124 partition_desc->setTextBase(params()->partition_desc_addr);
125 partition_desc->loadSections(&funcPartDescPort);
126
127 // load symbols
128 if (!reset->loadGlobalSymbols(resetSymtab))
129 panic("could not load reset symbols\n");
130
131 if (!openboot->loadGlobalSymbols(openbootSymtab))
132 panic("could not load openboot symbols\n");
133
134 if (!hypervisor->loadLocalSymbols(hypervisorSymtab))
135 panic("could not load hypervisor symbols\n");
136
137 if (!nvram->loadLocalSymbols(nvramSymtab))
138 panic("could not load nvram symbols\n");
139
140 if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab))
141 panic("could not load hypervisor description symbols\n");
142
143 if (!partition_desc->loadLocalSymbols(partitionDescSymtab))
144 panic("could not load partition description symbols\n");
145
146 // load symbols into debug table
147 if (!reset->loadGlobalSymbols(debugSymbolTable))
148 panic("could not load reset symbols\n");
149
150 if (!openboot->loadGlobalSymbols(debugSymbolTable))
151 panic("could not load openboot symbols\n");
152
153 if (!hypervisor->loadLocalSymbols(debugSymbolTable))
154 panic("could not load hypervisor symbols\n");
155
156 // Strip off the rom address so when the hypervisor is copied into memory we
157 // have symbols still
158 if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF))
159 panic("could not load hypervisor symbols\n");
160
161 if (!nvram->loadGlobalSymbols(debugSymbolTable))
162 panic("could not load reset symbols\n");
163
164 if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable))
165 panic("could not load hypervisor description symbols\n");
166
167 if (!partition_desc->loadLocalSymbols(debugSymbolTable))
168 panic("could not load partition description symbols\n");
169
170
171 // @todo any fixup code over writing data in binaries on setting break
172 // events on functions should happen here.
173
174 }
175
176 SparcSystem::~SparcSystem()
177 {
178 delete resetSymtab;
179 delete hypervisorSymtab;
180 delete openbootSymtab;
181 delete nvramSymtab;
182 delete hypervisorDescSymtab;
183 delete partitionDescSymtab;
184 delete reset;
185 delete openboot;
186 delete hypervisor;
187 delete nvram;
188 delete hypervisor_desc;
189 delete partition_desc;
190 }
191
192 void
193 SparcSystem::serialize(std::ostream &os)
194 {
195 System::serialize(os);
196 resetSymtab->serialize("reset_symtab", os);
197 hypervisorSymtab->serialize("hypervisor_symtab", os);
198 openbootSymtab->serialize("openboot_symtab", os);
199 nvramSymtab->serialize("nvram_symtab", os);
200 hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os);
201 partitionDescSymtab->serialize("partition_desc_symtab", os);
202 }
203
204
205 void
206 SparcSystem::unserialize(Checkpoint *cp, const std::string &section)
207 {
208 System::unserialize(cp,section);
209 resetSymtab->unserialize("reset_symtab", cp, section);
210 hypervisorSymtab->unserialize("hypervisor_symtab", cp, section);
211 openbootSymtab->unserialize("openboot_symtab", cp, section);
212 nvramSymtab->unserialize("nvram_symtab", cp, section);
213 hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section);
214 partitionDescSymtab->unserialize("partition_desc_symtab", cp, section);
215 }
216
217 SparcSystem *
218 SparcSystemParams::create()
219 {
220 return new SparcSystem(this);
221 }