system.cc revision 3745
14120Sgblack@eecs.umich.edu/* 24120Sgblack@eecs.umich.edu * Copyright (c) 2002-2006 The Regents of The University of Michigan 34120Sgblack@eecs.umich.edu * All rights reserved. 44120Sgblack@eecs.umich.edu * 54120Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 64120Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 74120Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 84120Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 94120Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 104120Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 114120Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 124120Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 134120Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 144120Sgblack@eecs.umich.edu * this software without specific prior written permission. 154120Sgblack@eecs.umich.edu * 164120Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 174120Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 184120Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 194120Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 204120Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 214120Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 224120Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 234120Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 244120Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 254120Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 264120Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274120Sgblack@eecs.umich.edu * 284120Sgblack@eecs.umich.edu * Authors: Ali Saidi 294120Sgblack@eecs.umich.edu */ 304120Sgblack@eecs.umich.edu 314120Sgblack@eecs.umich.edu#include "arch/sparc/system.hh" 324120Sgblack@eecs.umich.edu#include "arch/vtophys.hh" 334120Sgblack@eecs.umich.edu#include "base/remote_gdb.hh" 344120Sgblack@eecs.umich.edu#include "base/loader/object_file.hh" 354120Sgblack@eecs.umich.edu#include "base/loader/symtab.hh" 364120Sgblack@eecs.umich.edu#include "base/trace.hh" 374120Sgblack@eecs.umich.edu#include "mem/physical.hh" 384120Sgblack@eecs.umich.edu#include "sim/byteswap.hh" 394120Sgblack@eecs.umich.edu#include "sim/builder.hh" 404120Sgblack@eecs.umich.edu 414120Sgblack@eecs.umich.edu 424120Sgblack@eecs.umich.eduusing namespace BigEndianGuest; 434120Sgblack@eecs.umich.edu 444120Sgblack@eecs.umich.eduSparcSystem::SparcSystem(Params *p) 454120Sgblack@eecs.umich.edu : System(p), sysTick(0),funcRomPort(p->name + "-fromport"), 464120Sgblack@eecs.umich.edu funcNvramPort(p->name + "-fnvramport"), 474120Sgblack@eecs.umich.edu funcHypDescPort(p->name + "-fhypdescport"), 484120Sgblack@eecs.umich.edu funcPartDescPort(p->name + "-fpartdescport") 494120Sgblack@eecs.umich.edu{ 504120Sgblack@eecs.umich.edu resetSymtab = new SymbolTable; 514120Sgblack@eecs.umich.edu hypervisorSymtab = new SymbolTable; 524120Sgblack@eecs.umich.edu openbootSymtab = new SymbolTable; 534120Sgblack@eecs.umich.edu nvramSymtab = new SymbolTable; 544120Sgblack@eecs.umich.edu hypervisorDescSymtab = new SymbolTable; 554120Sgblack@eecs.umich.edu partitionDescSymtab = new SymbolTable; 564120Sgblack@eecs.umich.edu 574120Sgblack@eecs.umich.edu Port *rom_port; 584120Sgblack@eecs.umich.edu rom_port = params()->rom->getPort("functional"); 594120Sgblack@eecs.umich.edu funcRomPort.setPeer(rom_port); 604120Sgblack@eecs.umich.edu rom_port->setPeer(&funcRomPort); 614139Sgblack@eecs.umich.edu 624135Sgblack@eecs.umich.edu rom_port = params()->nvram->getPort("functional"); 634120Sgblack@eecs.umich.edu funcNvramPort.setPeer(rom_port); 644120Sgblack@eecs.umich.edu rom_port->setPeer(&funcNvramPort); 654120Sgblack@eecs.umich.edu 664135Sgblack@eecs.umich.edu rom_port = params()->hypervisor_desc->getPort("functional"); 674135Sgblack@eecs.umich.edu funcHypDescPort.setPeer(rom_port); 684135Sgblack@eecs.umich.edu rom_port->setPeer(&funcHypDescPort); 694135Sgblack@eecs.umich.edu 704135Sgblack@eecs.umich.edu rom_port = params()->partition_desc->getPort("functional"); 714135Sgblack@eecs.umich.edu funcPartDescPort.setPeer(rom_port); 724135Sgblack@eecs.umich.edu rom_port->setPeer(&funcPartDescPort); 734150Sgblack@eecs.umich.edu 744150Sgblack@eecs.umich.edu /** 754150Sgblack@eecs.umich.edu * Load the boot code, and hypervisor into memory. 764150Sgblack@eecs.umich.edu */ 774150Sgblack@eecs.umich.edu // Read the reset binary 784150Sgblack@eecs.umich.edu reset = createObjectFile(params()->reset_bin, true); 794150Sgblack@eecs.umich.edu if (reset == NULL) 804150Sgblack@eecs.umich.edu fatal("Could not load reset binary %s", params()->reset_bin); 814150Sgblack@eecs.umich.edu 824150Sgblack@eecs.umich.edu // Read the openboot binary 834150Sgblack@eecs.umich.edu openboot = createObjectFile(params()->openboot_bin, true); 844150Sgblack@eecs.umich.edu if (openboot == NULL) 854150Sgblack@eecs.umich.edu fatal("Could not load openboot bianry %s", params()->openboot_bin); 864150Sgblack@eecs.umich.edu 874150Sgblack@eecs.umich.edu // Read the hypervisor binary 884120Sgblack@eecs.umich.edu hypervisor = createObjectFile(params()->hypervisor_bin, true); 894120Sgblack@eecs.umich.edu if (hypervisor == NULL) 904120Sgblack@eecs.umich.edu fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 91 92 // Read the nvram image 93 nvram = createObjectFile(params()->nvram_bin, true); 94 if (nvram == NULL) 95 fatal("Could not load nvram image %s", params()->nvram_bin); 96 97 // Read the hypervisor description image 98 hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true); 99 if (hypervisor_desc == NULL) 100 fatal("Could not load hypervisor description image %s", 101 params()->hypervisor_desc_bin); 102 103 // Read the partition description image 104 partition_desc = createObjectFile(params()->partition_desc_bin, true); 105 if (partition_desc == NULL) 106 fatal("Could not load partition description image %s", 107 params()->partition_desc_bin); 108 109 110 // Load reset binary into memory 111 reset->setTextBase(params()->reset_addr); 112 reset->loadSections(&funcRomPort); 113 // Load the openboot binary 114 openboot->setTextBase(params()->openboot_addr); 115 openboot->loadSections(&funcRomPort); 116 // Load the hypervisor binary 117 hypervisor->setTextBase(params()->hypervisor_addr); 118 hypervisor->loadSections(&funcRomPort); 119 // Load the nvram image 120 nvram->setTextBase(params()->nvram_addr); 121 nvram->loadSections(&funcNvramPort); 122 // Load the hypervisor description image 123 hypervisor_desc->setTextBase(params()->hypervisor_desc_addr); 124 hypervisor_desc->loadSections(&funcHypDescPort); 125 // Load the partition description image 126 partition_desc->setTextBase(params()->partition_desc_addr); 127 partition_desc->loadSections(&funcPartDescPort); 128 129 // load symbols 130 if (!reset->loadGlobalSymbols(resetSymtab)) 131 panic("could not load reset symbols\n"); 132 133 if (!openboot->loadGlobalSymbols(openbootSymtab)) 134 panic("could not load openboot symbols\n"); 135 136 if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 137 panic("could not load hypervisor symbols\n"); 138 139 if (!nvram->loadLocalSymbols(nvramSymtab)) 140 panic("could not load nvram symbols\n"); 141 142 if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab)) 143 panic("could not load hypervisor description symbols\n"); 144 145 if (!partition_desc->loadLocalSymbols(partitionDescSymtab)) 146 panic("could not load partition description symbols\n"); 147 148 // load symbols into debug table 149 if (!reset->loadGlobalSymbols(debugSymbolTable)) 150 panic("could not load reset symbols\n"); 151 152 if (!openboot->loadGlobalSymbols(debugSymbolTable)) 153 panic("could not load openboot symbols\n"); 154 155 if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 156 panic("could not load hypervisor symbols\n"); 157 158 if (!nvram->loadGlobalSymbols(debugSymbolTable)) 159 panic("could not load reset symbols\n"); 160 161 if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable)) 162 panic("could not load hypervisor description symbols\n"); 163 164 if (!partition_desc->loadLocalSymbols(debugSymbolTable)) 165 panic("could not load partition description symbols\n"); 166 167 168 // @todo any fixup code over writing data in binaries on setting break 169 // events on functions should happen here. 170 171} 172 173SparcSystem::~SparcSystem() 174{ 175 delete resetSymtab; 176 delete hypervisorSymtab; 177 delete openbootSymtab; 178 delete nvramSymtab; 179 delete hypervisorDescSymtab; 180 delete partitionDescSymtab; 181 delete reset; 182 delete openboot; 183 delete hypervisor; 184 delete nvram; 185 delete hypervisor_desc; 186 delete partition_desc; 187} 188 189bool 190SparcSystem::breakpoint() 191{ 192 panic("Need to implement"); 193} 194 195void 196SparcSystem::serialize(std::ostream &os) 197{ 198 System::serialize(os); 199 resetSymtab->serialize("reset_symtab", os); 200 hypervisorSymtab->serialize("hypervisor_symtab", os); 201 openbootSymtab->serialize("openboot_symtab", os); 202 nvramSymtab->serialize("nvram_symtab", os); 203 hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os); 204 partitionDescSymtab->serialize("partition_desc_symtab", os); 205} 206 207 208void 209SparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 210{ 211 System::unserialize(cp,section); 212 resetSymtab->unserialize("reset_symtab", cp, section); 213 hypervisorSymtab->unserialize("hypervisor_symtab", cp, section); 214 openbootSymtab->unserialize("openboot_symtab", cp, section); 215 nvramSymtab->unserialize("nvram_symtab", cp, section); 216 hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section); 217 partitionDescSymtab->unserialize("partition_desc_symtab", cp, section); 218} 219 220 221BEGIN_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 222 223 SimObjectParam<PhysicalMemory *> physmem; 224 SimObjectParam<PhysicalMemory *> rom; 225 SimObjectParam<PhysicalMemory *> nvram; 226 SimObjectParam<PhysicalMemory *> hypervisor_desc; 227 SimObjectParam<PhysicalMemory *> partition_desc; 228 SimpleEnumParam<System::MemoryMode> mem_mode; 229 230 Param<Addr> reset_addr; 231 Param<Addr> hypervisor_addr; 232 Param<Addr> openboot_addr; 233 Param<Addr> nvram_addr; 234 Param<Addr> hypervisor_desc_addr; 235 Param<Addr> partition_desc_addr; 236 237 Param<std::string> kernel; 238 Param<std::string> reset_bin; 239 Param<std::string> hypervisor_bin; 240 Param<std::string> openboot_bin; 241 Param<std::string> nvram_bin; 242 Param<std::string> hypervisor_desc_bin; 243 Param<std::string> partition_desc_bin; 244 245 Param<Tick> boot_cpu_frequency; 246 Param<std::string> boot_osflags; 247 Param<std::string> readfile; 248 Param<unsigned int> init_param; 249 250END_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 251 252BEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem) 253 254 INIT_PARAM(physmem, "phsyical memory"), 255 INIT_PARAM(rom, "ROM for boot code"), 256 INIT_PARAM(nvram, "Non-volatile RAM for the nvram"), 257 INIT_PARAM(hypervisor_desc, "ROM for the hypervisor description"), 258 INIT_PARAM(partition_desc, "ROM for the partition description"), 259 INIT_ENUM_PARAM(mem_mode, "Memory Mode, (1=atomic, 2=timing)", 260 System::MemoryModeStrings), 261 262 INIT_PARAM(reset_addr, "Address that reset should be loaded at"), 263 INIT_PARAM(hypervisor_addr, "Address that hypervisor should be loaded at"), 264 INIT_PARAM(openboot_addr, "Address that openboot should be loaded at"), 265 INIT_PARAM(nvram_addr, "Address that nvram should be loaded at"), 266 INIT_PARAM(hypervisor_desc_addr, 267 "Address that hypervisor description should be loaded at"), 268 INIT_PARAM(partition_desc_addr, 269 "Address that partition description should be loaded at"), 270 271 INIT_PARAM(kernel, "file that contains the kernel code"), 272 INIT_PARAM(reset_bin, "file that contains the reset code"), 273 INIT_PARAM(hypervisor_bin, "file that contains the hypervisor code"), 274 INIT_PARAM(openboot_bin, "file that contains the openboot code"), 275 INIT_PARAM(nvram_bin, "file that contains the nvram image"), 276 INIT_PARAM(hypervisor_desc_bin, 277 "file that contains the hypervisor description image"), 278 INIT_PARAM(partition_desc_bin, 279 "file that contains the partition description image"), 280 INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"), 281 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", 282 "a"), 283 INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), 284 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0) 285 286END_INIT_SIM_OBJECT_PARAMS(SparcSystem) 287 288CREATE_SIM_OBJECT(SparcSystem) 289{ 290 SparcSystem::Params *p = new SparcSystem::Params; 291 p->name = getInstanceName(); 292 p->boot_cpu_frequency = boot_cpu_frequency; 293 p->physmem = physmem; 294 p->rom = rom; 295 p->nvram = nvram; 296 p->hypervisor_desc = hypervisor_desc; 297 p->partition_desc = partition_desc; 298 p->mem_mode = mem_mode; 299 p->kernel_path = kernel; 300 p->reset_addr = reset_addr; 301 p->hypervisor_addr = hypervisor_addr; 302 p->openboot_addr = openboot_addr; 303 p->nvram_addr = nvram_addr; 304 p->hypervisor_desc_addr = hypervisor_desc_addr; 305 p->partition_desc_addr = partition_desc_addr; 306 p->reset_bin = reset_bin; 307 p->hypervisor_bin = hypervisor_bin; 308 p->openboot_bin = openboot_bin; 309 p->nvram_bin = nvram_bin; 310 p->hypervisor_desc_bin = hypervisor_desc_bin; 311 p->partition_desc_bin = partition_desc_bin; 312 p->boot_osflags = boot_osflags; 313 p->init_param = init_param; 314 p->readfile = readfile; 315 return new SparcSystem(p); 316} 317 318REGISTER_SIM_OBJECT("SparcSystem", SparcSystem) 319 320 321