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
;
54 SparcSystem::initState()
56 // Call the initialisation of the super class
60 * Load the boot code, and hypervisor into memory.
62 // Read the reset binary
63 reset
= createObjectFile(params()->reset_bin
, true);
65 fatal("Could not load reset binary %s", params()->reset_bin
);
67 // Read the openboot binary
68 openboot
= createObjectFile(params()->openboot_bin
, true);
70 fatal("Could not load openboot bianry %s", params()->openboot_bin
);
72 // Read the hypervisor binary
73 hypervisor
= createObjectFile(params()->hypervisor_bin
, true);
74 if (hypervisor
== NULL
)
75 fatal("Could not load hypervisor binary %s", params()->hypervisor_bin
);
77 // Read the nvram image
78 nvram
= createObjectFile(params()->nvram_bin
, true);
80 fatal("Could not load nvram image %s", params()->nvram_bin
);
82 // Read the hypervisor description image
83 hypervisor_desc
= createObjectFile(params()->hypervisor_desc_bin
, true);
84 if (hypervisor_desc
== NULL
)
85 fatal("Could not load hypervisor description image %s",
86 params()->hypervisor_desc_bin
);
88 // Read the partition description image
89 partition_desc
= createObjectFile(params()->partition_desc_bin
, true);
90 if (partition_desc
== NULL
)
91 fatal("Could not load partition description image %s",
92 params()->partition_desc_bin
);
95 // Load reset binary into memory
96 reset
->setTextBase(params()->reset_addr
);
97 reset
->loadSections(physProxy
);
98 // Load the openboot binary
99 openboot
->setTextBase(params()->openboot_addr
);
100 openboot
->loadSections(physProxy
);
101 // Load the hypervisor binary
102 hypervisor
->setTextBase(params()->hypervisor_addr
);
103 hypervisor
->loadSections(physProxy
);
104 // Load the nvram image
105 nvram
->setTextBase(params()->nvram_addr
);
106 nvram
->loadSections(physProxy
);
107 // Load the hypervisor description image
108 hypervisor_desc
->setTextBase(params()->hypervisor_desc_addr
);
109 hypervisor_desc
->loadSections(physProxy
);
110 // Load the partition description image
111 partition_desc
->setTextBase(params()->partition_desc_addr
);
112 partition_desc
->loadSections(physProxy
);
115 if (!reset
->loadGlobalSymbols(resetSymtab
))
116 panic("could not load reset symbols\n");
118 if (!openboot
->loadGlobalSymbols(openbootSymtab
))
119 panic("could not load openboot symbols\n");
121 if (!hypervisor
->loadLocalSymbols(hypervisorSymtab
))
122 panic("could not load hypervisor symbols\n");
124 if (!nvram
->loadLocalSymbols(nvramSymtab
))
125 panic("could not load nvram symbols\n");
127 if (!hypervisor_desc
->loadLocalSymbols(hypervisorDescSymtab
))
128 panic("could not load hypervisor description symbols\n");
130 if (!partition_desc
->loadLocalSymbols(partitionDescSymtab
))
131 panic("could not load partition description symbols\n");
133 // load symbols into debug table
134 if (!reset
->loadGlobalSymbols(debugSymbolTable
))
135 panic("could not load reset symbols\n");
137 if (!openboot
->loadGlobalSymbols(debugSymbolTable
))
138 panic("could not load openboot symbols\n");
140 if (!hypervisor
->loadLocalSymbols(debugSymbolTable
))
141 panic("could not load hypervisor symbols\n");
143 // Strip off the rom address so when the hypervisor is copied into memory we
144 // have symbols still
145 if (!hypervisor
->loadLocalSymbols(debugSymbolTable
, 0xFFFFFF))
146 panic("could not load hypervisor symbols\n");
148 if (!nvram
->loadGlobalSymbols(debugSymbolTable
))
149 panic("could not load reset symbols\n");
151 if (!hypervisor_desc
->loadGlobalSymbols(debugSymbolTable
))
152 panic("could not load hypervisor description symbols\n");
154 if (!partition_desc
->loadLocalSymbols(debugSymbolTable
))
155 panic("could not load partition description symbols\n");
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::serialize(std::ostream
&os
)
182 System::serialize(os
);
183 resetSymtab
->serialize("reset_symtab", os
);
184 hypervisorSymtab
->serialize("hypervisor_symtab", os
);
185 openbootSymtab
->serialize("openboot_symtab", os
);
186 nvramSymtab
->serialize("nvram_symtab", os
);
187 hypervisorDescSymtab
->serialize("hypervisor_desc_symtab", os
);
188 partitionDescSymtab
->serialize("partition_desc_symtab", os
);
193 SparcSystem::unserialize(Checkpoint
*cp
, const std::string
§ion
)
195 System::unserialize(cp
,section
);
196 resetSymtab
->unserialize("reset_symtab", cp
, section
);
197 hypervisorSymtab
->unserialize("hypervisor_symtab", cp
, section
);
198 openbootSymtab
->unserialize("openboot_symtab", cp
, section
);
199 nvramSymtab
->unserialize("nvram_symtab", cp
, section
);
200 hypervisorDescSymtab
->unserialize("hypervisor_desc_symtab", cp
, section
);
201 partitionDescSymtab
->unserialize("partition_desc_symtab", cp
, section
);
205 SparcSystemParams::create()
207 return new SparcSystem(this);