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 "sim/byteswap.hh" 39#include "sim/builder.hh" 40 41 42using namespace BigEndianGuest; 43 44SparcSystem::SparcSystem(Params *p)
| 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 "sim/byteswap.hh" 39#include "sim/builder.hh" 40 41 42using namespace BigEndianGuest; 43 44SparcSystem::SparcSystem(Params *p)
|
45 : System(p), sysTick(0)
| 45 : System(p), sysTick(0),funcRomPort(p->name + "-fport")
|
46 47{ 48 resetSymtab = new SymbolTable; 49 hypervisorSymtab = new SymbolTable; 50 openbootSymtab = new SymbolTable; 51
| 46 47{ 48 resetSymtab = new SymbolTable; 49 hypervisorSymtab = new SymbolTable; 50 openbootSymtab = new SymbolTable; 51
|
| 52 Port *rom_port; 53 rom_port = params()->rom->getPort("functional"); 54 funcRomPort.setPeer(rom_port); 55 rom_port->setPeer(&funcRomPort);
|
52 53 /** 54 * Load the boot code, and hypervisor into memory. 55 */ 56 // Read the reset binary
| 56 57 /** 58 * Load the boot code, and hypervisor into memory. 59 */ 60 // Read the reset binary
|
57 reset = createObjectFile(params()->reset_bin);
| 61 reset = createObjectFile(params()->reset_bin, true);
|
58 if (reset == NULL) 59 fatal("Could not load reset binary %s", params()->reset_bin); 60 61 // Read the openboot binary
| 62 if (reset == NULL) 63 fatal("Could not load reset binary %s", params()->reset_bin); 64 65 // Read the openboot binary
|
62 openboot = createObjectFile(params()->openboot_bin);
| 66 openboot = createObjectFile(params()->openboot_bin, true);
|
63 if (openboot == NULL) 64 fatal("Could not load openboot bianry %s", params()->openboot_bin); 65 66 // Read the hypervisor binary
| 67 if (openboot == NULL) 68 fatal("Could not load openboot bianry %s", params()->openboot_bin); 69 70 // Read the hypervisor binary
|
67 hypervisor = createObjectFile(params()->hypervisor_bin);
| 71 hypervisor = createObjectFile(params()->hypervisor_bin, true);
|
68 if (hypervisor == NULL) 69 fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 70 71 72 // Load reset binary into memory
| 72 if (hypervisor == NULL) 73 fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 74 75 76 // Load reset binary into memory
|
73 reset->loadSections(&functionalPort, SparcISA::LoadAddrMask);
| 77 reset->setTextBase(params()->reset_addr); 78 reset->loadSections(&funcRomPort);
|
74 // Load the openboot binary
| 79 // Load the openboot binary
|
75 openboot->loadSections(&functionalPort, SparcISA::LoadAddrMask);
| 80 openboot->setTextBase(params()->openboot_addr); 81 openboot->loadSections(&funcRomPort);
|
76 // Load the hypervisor binary
| 82 // Load the hypervisor binary
|
77 hypervisor->loadSections(&functionalPort, SparcISA::LoadAddrMask);
| 83 hypervisor->setTextBase(params()->hypervisor_addr); 84 hypervisor->loadSections(&funcRomPort);
|
78 79 // load symbols 80 if (!reset->loadGlobalSymbols(resetSymtab)) 81 panic("could not load reset symbols\n"); 82 83 if (!openboot->loadGlobalSymbols(openbootSymtab)) 84 panic("could not load openboot symbols\n"); 85 86 if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 87 panic("could not load hypervisor symbols\n"); 88 89 // load symbols into debug table 90 if (!reset->loadGlobalSymbols(debugSymbolTable)) 91 panic("could not load reset symbols\n"); 92 93 if (!openboot->loadGlobalSymbols(debugSymbolTable)) 94 panic("could not load openboot symbols\n"); 95 96 if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 97 panic("could not load hypervisor symbols\n"); 98 99 100 // @todo any fixup code over writing data in binaries on setting break 101 // events on functions should happen here. 102 103} 104 105SparcSystem::~SparcSystem() 106{ 107 delete resetSymtab; 108 delete hypervisorSymtab; 109 delete openbootSymtab; 110 delete reset; 111 delete openboot; 112 delete hypervisor; 113} 114 115bool 116SparcSystem::breakpoint() 117{ 118 panic("Need to implement"); 119} 120 121void 122SparcSystem::serialize(std::ostream &os) 123{ 124 System::serialize(os); 125 resetSymtab->serialize("reset_symtab", os); 126 hypervisorSymtab->serialize("hypervisor_symtab", os); 127 openbootSymtab->serialize("openboot_symtab", os); 128} 129 130 131void 132SparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 133{ 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); 138} 139 140 141BEGIN_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 142 143 SimObjectParam<PhysicalMemory *> physmem;
| 85 86 // load symbols 87 if (!reset->loadGlobalSymbols(resetSymtab)) 88 panic("could not load reset symbols\n"); 89 90 if (!openboot->loadGlobalSymbols(openbootSymtab)) 91 panic("could not load openboot symbols\n"); 92 93 if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 94 panic("could not load hypervisor symbols\n"); 95 96 // load symbols into debug table 97 if (!reset->loadGlobalSymbols(debugSymbolTable)) 98 panic("could not load reset symbols\n"); 99 100 if (!openboot->loadGlobalSymbols(debugSymbolTable)) 101 panic("could not load openboot symbols\n"); 102 103 if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 104 panic("could not load hypervisor symbols\n"); 105 106 107 // @todo any fixup code over writing data in binaries on setting break 108 // events on functions should happen here. 109 110} 111 112SparcSystem::~SparcSystem() 113{ 114 delete resetSymtab; 115 delete hypervisorSymtab; 116 delete openbootSymtab; 117 delete reset; 118 delete openboot; 119 delete hypervisor; 120} 121 122bool 123SparcSystem::breakpoint() 124{ 125 panic("Need to implement"); 126} 127 128void 129SparcSystem::serialize(std::ostream &os) 130{ 131 System::serialize(os); 132 resetSymtab->serialize("reset_symtab", os); 133 hypervisorSymtab->serialize("hypervisor_symtab", os); 134 openbootSymtab->serialize("openboot_symtab", os); 135} 136 137 138void 139SparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 140{ 141 System::unserialize(cp,section); 142 resetSymtab->unserialize("reset_symtab", cp, section); 143 hypervisorSymtab->unserialize("hypervisor_symtab", cp, section); 144 openbootSymtab->unserialize("openboot_symtab", cp, section); 145} 146 147 148BEGIN_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 149 150 SimObjectParam<PhysicalMemory *> physmem;
|
| 151 SimObjectParam<PhysicalMemory *> rom;
|
144 SimpleEnumParam<System::MemoryMode> mem_mode; 145
| 152 SimpleEnumParam<System::MemoryMode> mem_mode; 153
|
| 154 Param<Addr> reset_addr; 155 Param<Addr> hypervisor_addr; 156 Param<Addr> openboot_addr; 157
|
146 Param<std::string> kernel; 147 Param<std::string> reset_bin; 148 Param<std::string> hypervisor_bin; 149 Param<std::string> openboot_bin; 150 151 Param<Tick> boot_cpu_frequency; 152 Param<std::string> boot_osflags;
| 158 Param<std::string> kernel; 159 Param<std::string> reset_bin; 160 Param<std::string> hypervisor_bin; 161 Param<std::string> openboot_bin; 162 163 Param<Tick> boot_cpu_frequency; 164 Param<std::string> boot_osflags;
|
153 Param<uint64_t> system_type; 154 Param<uint64_t> system_rev;
| |
155 Param<std::string> readfile; 156 Param<unsigned int> init_param; 157 158END_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 159 160BEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem) 161 162 INIT_PARAM(physmem, "phsyical memory"),
| 165 Param<std::string> readfile; 166 Param<unsigned int> init_param; 167 168END_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 169 170BEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem) 171 172 INIT_PARAM(physmem, "phsyical memory"),
|
| 173 INIT_PARAM(rom, "ROM for boot code"),
|
163 INIT_ENUM_PARAM(mem_mode, "Memory Mode, (1=atomic, 2=timing)", 164 System::MemoryModeStrings),
| 174 INIT_ENUM_PARAM(mem_mode, "Memory Mode, (1=atomic, 2=timing)", 175 System::MemoryModeStrings),
|
| 176 177 INIT_PARAM(reset_addr, "Address that reset should be loaded at"), 178 INIT_PARAM(hypervisor_addr, "Address that hypervisor should be loaded at"), 179 INIT_PARAM(openboot_addr, "Address that openboot should be loaded at"), 180
|
165 INIT_PARAM(kernel, "file that contains the kernel code"), 166 INIT_PARAM(reset_bin, "file that contains the reset code"), 167 INIT_PARAM(hypervisor_bin, "file that contains the hypervisor code"), 168 INIT_PARAM(openboot_bin, "file that contains the openboot code"), 169 INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"), 170 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", 171 "a"),
| 181 INIT_PARAM(kernel, "file that contains the kernel code"), 182 INIT_PARAM(reset_bin, "file that contains the reset code"), 183 INIT_PARAM(hypervisor_bin, "file that contains the hypervisor code"), 184 INIT_PARAM(openboot_bin, "file that contains the openboot code"), 185 INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"), 186 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", 187 "a"),
|
172 INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34), 173 INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10),
| |
174 INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), 175 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0) 176 177END_INIT_SIM_OBJECT_PARAMS(SparcSystem) 178 179CREATE_SIM_OBJECT(SparcSystem) 180{ 181 SparcSystem::Params *p = new SparcSystem::Params; 182 p->name = getInstanceName(); 183 p->boot_cpu_frequency = boot_cpu_frequency; 184 p->physmem = physmem;
| 188 INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), 189 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0) 190 191END_INIT_SIM_OBJECT_PARAMS(SparcSystem) 192 193CREATE_SIM_OBJECT(SparcSystem) 194{ 195 SparcSystem::Params *p = new SparcSystem::Params; 196 p->name = getInstanceName(); 197 p->boot_cpu_frequency = boot_cpu_frequency; 198 p->physmem = physmem;
|
| 199 p->rom = rom;
|
185 p->mem_mode = mem_mode; 186 p->kernel_path = kernel;
| 200 p->mem_mode = mem_mode; 201 p->kernel_path = kernel;
|
| 202 p->reset_addr = reset_addr; 203 p->hypervisor_addr = hypervisor_addr; 204 p->openboot_addr = openboot_addr;
|
187 p->reset_bin = reset_bin; 188 p->hypervisor_bin = hypervisor_bin; 189 p->openboot_bin = openboot_bin; 190 p->boot_osflags = boot_osflags; 191 p->init_param = init_param; 192 p->readfile = readfile;
| 205 p->reset_bin = reset_bin; 206 p->hypervisor_bin = hypervisor_bin; 207 p->openboot_bin = openboot_bin; 208 p->boot_osflags = boot_osflags; 209 p->init_param = init_param; 210 p->readfile = readfile;
|
193 p->system_type = system_type; 194 p->system_rev = system_rev;
| |
195 return new SparcSystem(p); 196} 197 198REGISTER_SIM_OBJECT("SparcSystem", SparcSystem) 199 200
| 211 return new SparcSystem(p); 212} 213 214REGISTER_SIM_OBJECT("SparcSystem", SparcSystem) 215 216
|