2 * Copyright (c) 2002-2006 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.
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"
40 using namespace BigEndianGuest
;
42 SparcSystem::SparcSystem(Params
*p
)
43 : System(p
), sysTick(0)
45 resetSymtab
= new SymbolTable
;
46 hypervisorSymtab
= new SymbolTable
;
47 openbootSymtab
= new SymbolTable
;
48 nvramSymtab
= new SymbolTable
;
49 hypervisorDescSymtab
= new SymbolTable
;
50 partitionDescSymtab
= new SymbolTable
;
53 * Load the boot code, and hypervisor into memory.
55 // Read the reset binary
56 reset
= createObjectFile(params()->reset_bin
, true);
58 fatal("Could not load reset binary %s", params()->reset_bin
);
60 // Read the openboot binary
61 openboot
= createObjectFile(params()->openboot_bin
, true);
63 fatal("Could not load openboot bianry %s", params()->openboot_bin
);
65 // Read the hypervisor binary
66 hypervisor
= createObjectFile(params()->hypervisor_bin
, true);
67 if (hypervisor
== NULL
)
68 fatal("Could not load hypervisor binary %s", params()->hypervisor_bin
);
70 // Read the nvram image
71 nvram
= createObjectFile(params()->nvram_bin
, true);
73 fatal("Could not load nvram image %s", params()->nvram_bin
);
75 // Read the hypervisor description image
76 hypervisor_desc
= createObjectFile(params()->hypervisor_desc_bin
, true);
77 if (hypervisor_desc
== NULL
)
78 fatal("Could not load hypervisor description image %s",
79 params()->hypervisor_desc_bin
);
81 // Read the partition description image
82 partition_desc
= createObjectFile(params()->partition_desc_bin
, true);
83 if (partition_desc
== NULL
)
84 fatal("Could not load partition description image %s",
85 params()->partition_desc_bin
);
88 if (!reset
->loadGlobalSymbols(resetSymtab
))
89 panic("could not load reset symbols\n");
91 if (!openboot
->loadGlobalSymbols(openbootSymtab
))
92 panic("could not load openboot symbols\n");
94 if (!hypervisor
->loadLocalSymbols(hypervisorSymtab
))
95 panic("could not load hypervisor symbols\n");
97 if (!nvram
->loadLocalSymbols(nvramSymtab
))
98 panic("could not load nvram symbols\n");
100 if (!hypervisor_desc
->loadLocalSymbols(hypervisorDescSymtab
))
101 panic("could not load hypervisor description symbols\n");
103 if (!partition_desc
->loadLocalSymbols(partitionDescSymtab
))
104 panic("could not load partition description symbols\n");
106 // load symbols into debug table
107 if (!reset
->loadGlobalSymbols(debugSymbolTable
))
108 panic("could not load reset symbols\n");
110 if (!openboot
->loadGlobalSymbols(debugSymbolTable
))
111 panic("could not load openboot symbols\n");
113 if (!hypervisor
->loadLocalSymbols(debugSymbolTable
))
114 panic("could not load hypervisor symbols\n");
116 // Strip off the rom address so when the hypervisor is copied into memory we
117 // have symbols still
118 if (!hypervisor
->loadLocalSymbols(debugSymbolTable
, 0xFFFFFF))
119 panic("could not load hypervisor symbols\n");
121 if (!nvram
->loadGlobalSymbols(debugSymbolTable
))
122 panic("could not load reset symbols\n");
124 if (!hypervisor_desc
->loadGlobalSymbols(debugSymbolTable
))
125 panic("could not load hypervisor description symbols\n");
127 if (!partition_desc
->loadLocalSymbols(debugSymbolTable
))
128 panic("could not load partition description symbols\n");
133 SparcSystem::initState()
135 // Call the initialisation of the super class
138 // Load reset binary into memory
139 reset
->setTextBase(params()->reset_addr
);
140 reset
->loadSections(physProxy
);
141 // Load the openboot binary
142 openboot
->setTextBase(params()->openboot_addr
);
143 openboot
->loadSections(physProxy
);
144 // Load the hypervisor binary
145 hypervisor
->setTextBase(params()->hypervisor_addr
);
146 hypervisor
->loadSections(physProxy
);
147 // Load the nvram image
148 nvram
->setTextBase(params()->nvram_addr
);
149 nvram
->loadSections(physProxy
);
150 // Load the hypervisor description image
151 hypervisor_desc
->setTextBase(params()->hypervisor_desc_addr
);
152 hypervisor_desc
->loadSections(physProxy
);
153 // Load the partition description image
154 partition_desc
->setTextBase(params()->partition_desc_addr
);
155 partition_desc
->loadSections(physProxy
);
158 // @todo any fixup code over writing data in binaries on setting break
159 // events on functions should happen here.
163 SparcSystem::~SparcSystem()
166 delete hypervisorSymtab
;
167 delete openbootSymtab
;
169 delete hypervisorDescSymtab
;
170 delete partitionDescSymtab
;
175 delete hypervisor_desc
;
176 delete partition_desc
;
180 SparcSystem::serializeSymtab(std::ostream
&os
)
182 resetSymtab
->serialize("reset_symtab", os
);
183 hypervisorSymtab
->serialize("hypervisor_symtab", os
);
184 openbootSymtab
->serialize("openboot_symtab", os
);
185 nvramSymtab
->serialize("nvram_symtab", os
);
186 hypervisorDescSymtab
->serialize("hypervisor_desc_symtab", os
);
187 partitionDescSymtab
->serialize("partition_desc_symtab", os
);
192 SparcSystem::unserializeSymtab(Checkpoint
*cp
, const std::string
§ion
)
194 resetSymtab
->unserialize("reset_symtab", cp
, section
);
195 hypervisorSymtab
->unserialize("hypervisor_symtab", cp
, section
);
196 openbootSymtab
->unserialize("openboot_symtab", cp
, section
);
197 nvramSymtab
->unserialize("nvram_symtab", cp
, section
);
198 hypervisorDescSymtab
->unserialize("hypervisor_desc_symtab", cp
, section
);
199 partitionDescSymtab
->unserialize("partition_desc_symtab", cp
, section
);
203 SparcSystemParams::create()
205 return new SparcSystem(this);