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/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 "sim/byteswap.hh"
39 #include "sim/builder.hh"
42 using namespace BigEndianGuest
;
44 SparcSystem::SparcSystem(Params
*p
)
45 : System(p
), sysTick(0)
48 resetSymtab
= new SymbolTable
;
49 hypervisorSymtab
= new SymbolTable
;
50 openbootSymtab
= new SymbolTable
;
54 * Load the boot code, and hypervisor into memory.
56 // Read the reset binary
57 reset
= createObjectFile(params()->reset_bin
);
59 fatal("Could not load reset binary %s", params()->reset_bin
);
61 // Read the openboot binary
62 openboot
= createObjectFile(params()->openboot_bin
);
64 fatal("Could not load openboot bianry %s", params()->openboot_bin
);
66 // Read the hypervisor binary
67 hypervisor
= createObjectFile(params()->hypervisor_bin
);
68 if (hypervisor
== NULL
)
69 fatal("Could not load hypervisor binary %s", params()->hypervisor_bin
);
72 // Load reset binary into memory
73 reset
->loadSections(&functionalPort
, SparcISA::LoadAddrMask
);
74 // Load the openboot binary
75 openboot
->loadSections(&functionalPort
, SparcISA::LoadAddrMask
);
76 // Load the hypervisor binary
77 hypervisor
->loadSections(&functionalPort
, SparcISA::LoadAddrMask
);
80 if (!reset
->loadGlobalSymbols(reset
))
81 panic("could not load reset symbols\n");
83 if (!openboot
->loadGlobalSymbols(openbootSymtab
))
84 panic("could not load openboot symbols\n");
86 if (!hypervisor
->loadLocalSymbols(hypervisorSymtab
))
87 panic("could not load hypervisor symbols\n");
89 // load symbols into debug table
90 if (!reset
->loadGlobalSymbols(debugSymbolTable
))
91 panic("could not load reset symbols\n");
93 if (!openboot
->loadGlobalSymbols(debugSymbolTable
))
94 panic("could not load openboot symbols\n");
96 if (!hypervisor
->loadLocalSymbols(debugSymbolTable
))
97 panic("could not load hypervisor symbols\n");
100 // @todo any fixup code over writing data in binaries on setting break
101 // events on functions should happen here.
105 SparcSystem::~SparcSystem()
108 delete hypervisorSymtab
;
109 delete openbootSymtab
;
116 SparcSystem::breakpoint()
118 panic("Need to implement");
122 SparcSystem::serialize(std::ostream
&os
)
124 System::serialize(os
);
125 resetSymtab
->serialize("reset_symtab", os
);
126 hypervisorSymtab
->serialize("hypervisor_symtab", os
);
127 openbootSymtab
->serialize("openboot_symtab", os
);
132 SparcSystem::unserialize(Checkpoint
*cp
, const std::string
§ion
)
134 System::unserialize(cp
,section
);
135 resetSymtab
->unserialize("reset_symtab", cp
, section
);
136 hypervisorSymtab
->unserialize("hypervisor_symtab", cp
, section
);
137 openbootSymtab
->unserialize("openboot_symtab", cp
, section
);
141 BEGIN_DECLARE_SIM_OBJECT_PARAMS(SparcSystem
)
143 SimObjectParam
<PhysicalMemory
*> physmem
;
144 SimpleEnumParam
<System::MemoryMode
> mem_mode
;
146 Param
<std::string
> kernel
;
147 Param
<std::string
> reset_bin
;
148 Param
<std::string
> hypervisor_bin
;
149 Param
<std::string
> openboot_bin
;
151 Param
<std::string
> boot_osflags
;
152 Param
<std::string
> readfile
;
153 Param
<unsigned int> init_param
;
155 END_DECLARE_SIM_OBJECT_PARAMS(SparcSystem
)
157 BEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem
)
159 INIT_PARAM(boot_cpu_frequency
, "Frequency of the boot CPU"),
160 INIT_PARAM(physmem
, "phsyical memory"),
161 INIT_ENUM_PARAM(mem_mode
, "Memory Mode, (1=atomic, 2=timing)",
162 System::MemoryModeStrings
),
163 INIT_PARAM(kernel
, "file that contains the kernel code"),
164 INIT_PARAM(reset_bin
, "file that contains the reset code"),
165 INIT_PARAM(hypervisor_bin
, "file that contains the hypervisor code"),
166 INIT_PARAM(openboot_bin
, "file that contains the openboot code"),
167 INIT_PARAM_DFLT(boot_osflags
, "flags to pass to the kernel during boot",
169 INIT_PARAM_DFLT(readfile
, "file to read startup script from", ""),
170 INIT_PARAM_DFLT(init_param
, "numerical value to pass into simulator", 0),
171 INIT_PARAM_DFLT(system_type
, "Type of system we are emulating", 34),
172 INIT_PARAM_DFLT(system_rev
, "Revision of system we are emulating", 1<<10)
174 END_INIT_SIM_OBJECT_PARAMS(SparcSystem
)
176 CREATE_SIM_OBJECT(SparcSystem
)
178 SparcSystem::Params
*p
= new SparcSystem::Params
;
179 p
->name
= getInstanceName();
180 p
->boot_cpu_frequency
= boot_cpu_frequency
;
181 p
->physmem
= physmem
;
182 p
->mem_mode
= mem_mode
;
183 p
->kernel_path
= kernel
;
184 p
->reset_bin
= reset_bin
;
185 p
->hypervisor_bin
= hypervisor_bin
;
186 p
->openboot_bin
= openboot_bin
;
187 p
->boot_osflags
= boot_osflags
;
188 p
->init_param
= init_param
;
189 p
->readfile
= readfile
;
190 p
->system_type
= system_type
;
191 p
->system_rev
= system_rev
;
192 return new SparcSystem(p
);
195 REGISTER_SIM_OBJECT("SparcSystem", SparcSystem
)