system.cc revision 2567
12086SN/A/* 22086SN/A * Copyright (c) 2002-2006 The Regents of The University of Michigan 35268Sksewell@umich.edu * All rights reserved. 42086SN/A * 52086SN/A * Redistribution and use in source and binary forms, with or without 62086SN/A * modification, are permitted provided that the following conditions are 72086SN/A * met: redistributions of source code must retain the above copyright 82086SN/A * notice, this list of conditions and the following disclaimer; 92086SN/A * redistributions in binary form must reproduce the above copyright 102086SN/A * notice, this list of conditions and the following disclaimer in the 112086SN/A * documentation and/or other materials provided with the distribution; 122086SN/A * neither the name of the copyright holders nor the names of its 132086SN/A * contributors may be used to endorse or promote products derived from 142086SN/A * this software without specific prior written permission. 152086SN/A * 162086SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172086SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182086SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192086SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202086SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212086SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222086SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232086SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242086SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252086SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262086SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272086SN/A */ 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.edu#include "arch/sparc/system.hh" 302665Ssaidi@eecs.umich.edu#include "arch/vtophys.hh" 312686Sksewell@umich.edu#include "base/remote_gdb.hh" 322086SN/A#include "base/loader/object_file.hh" 334202Sbinkertn@umich.edu#include "base/loader/symtab.hh" 342086SN/A#include "base/trace.hh" 354202Sbinkertn@umich.edu#include "mem/physical.hh" 368775Sgblack@eecs.umich.edu#include "sim/byteswap.hh" 379022Sgblack@eecs.umich.edu#include "sim/builder.hh" 388758Sgblack@eecs.umich.edu 394202Sbinkertn@umich.edu 408775Sgblack@eecs.umich.eduusing namespace BigEndianGuest; 418745Sgblack@eecs.umich.edu 426313Sgblack@eecs.umich.eduSparcSystem::SparcSystem(Params *p) 438775Sgblack@eecs.umich.edu : System(p) 448775Sgblack@eecs.umich.edu{ 458775Sgblack@eecs.umich.edu resetSymtab = new SymbolTable; 468758Sgblack@eecs.umich.edu hypervisorSymtab = new SymbolTable; 478775Sgblack@eecs.umich.edu openbootSymtab = new SymbolTable; 488758Sgblack@eecs.umich.edu 498775Sgblack@eecs.umich.edu 508775Sgblack@eecs.umich.edu /** 514997Sgblack@eecs.umich.edu * Load the boot code, and hypervisor into memory. 524202Sbinkertn@umich.edu */ 538758Sgblack@eecs.umich.edu // Read the reset binary 544997Sgblack@eecs.umich.edu reset = createObjectFile(params()->reset_bin); 558745Sgblack@eecs.umich.edu if (reset == NULL) 569384SAndreas.Sandberg@arm.com fatal("Could not load reset binary %s", params()->reset_bin); 578775Sgblack@eecs.umich.edu 584997Sgblack@eecs.umich.edu // Read the openboot binary 595192Ssaidi@eecs.umich.edu openboot = createObjectFile(params()->openboot_bin); 608775Sgblack@eecs.umich.edu if (openboot == NULL) 612086SN/A fatal("Could not load openboot bianry %s", params()->openboot_bin); 624202Sbinkertn@umich.edu 634202Sbinkertn@umich.edu // Read the hypervisor binary 644202Sbinkertn@umich.edu hypervisor = createObjectFile(params()->hypervisor_bin); 654202Sbinkertn@umich.edu if (hypervisor == NULL) 664202Sbinkertn@umich.edu fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 674202Sbinkertn@umich.edu 68 69 // Load reset binary into memory 70 reset->loadSections(&functionalPort, SparcISA::LoadAddrMask); 71 // Load the openboot binary 72 openboot->loadSections(&functionalPort, SparcISA::LoadAddrMask); 73 // Load the hypervisor binary 74 hypervisor->loadSections(&functionalPort, SparcISA::LoadAddrMask); 75 76 // load symbols 77 if (!reset->loadGlobalSymbols(reset)) 78 panic("could not load reset symbols\n"); 79 80 if (!openboot->loadGlobalSymbols(openbootSymtab)) 81 panic("could not load openboot symbols\n"); 82 83 if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 84 panic("could not load hypervisor symbols\n"); 85 86 // load symbols into debug table 87 if (!reset->loadGlobalSymbols(debugSymbolTable)) 88 panic("could not load reset symbols\n"); 89 90 if (!openboot->loadGlobalSymbols(debugSymbolTable)) 91 panic("could not load openboot symbols\n"); 92 93 if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 94 panic("could not load hypervisor symbols\n"); 95 96 97 // @todo any fixup code over writing data in binaries on setting break 98 // events on functions should happen here. 99 100} 101 102SparcSystem::~SparcSystem() 103{ 104 delete resetSymtab; 105 delete hypervisorSymtab; 106 delete openbootSymtab; 107 delete reset; 108 delete openboot; 109 delete hypervisor; 110} 111 112bool 113SparcSystem::breakpoint() 114{ 115 panic("Need to implement"); 116} 117 118void 119SparcSystem::serialize(std::ostream &os) 120{ 121 System::serialize(os); 122 resetSymtab->serialize("reset_symtab", os); 123 hypervisorSymtab->serialize("hypervisor_symtab", os); 124 openbootSymtab->serialize("openboot_symtab", os); 125} 126 127 128void 129SparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 130{ 131 System::unserialize(cp,section); 132 resetSymtab->unserialize("reset_symtab", cp, section); 133 hypervisorSymtab->unserialize("hypervisor_symtab", cp, section); 134 openbootSymtab->unserialize("openboot_symtab", cp, section); 135} 136 137 138BEGIN_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 139 140 SimObjectParam<PhysicalMemory *> physmem; 141 142 Param<std::string> kernel; 143 Param<std::string> reset_bin; 144 Param<std::string> hypervisor_bin; 145 Param<std::string> openboot_bin; 146 147 Param<std::string> boot_osflags; 148 Param<std::string> readfile; 149 Param<unsigned int> init_param; 150 151 Param<bool> bin; 152 VectorParam<std::string> binned_fns; 153 Param<bool> bin_int; 154 155END_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 156 157BEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem) 158 159 INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"), 160 INIT_PARAM(physmem, "phsyical memory"), 161 INIT_PARAM(kernel, "file that contains the kernel code"), 162 INIT_PARAM(reset_bin, "file that contains the reset code"), 163 INIT_PARAM(hypervisor_bin, "file that contains the hypervisor code"), 164 INIT_PARAM(openboot_bin, "file that contains the openboot code"), 165 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", 166 "a"), 167 INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), 168 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0), 169 INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34), 170 INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10), 171 INIT_PARAM_DFLT(bin, "is this system to be binned", false), 172 INIT_PARAM(binned_fns, "functions to be broken down and binned"), 173 INIT_PARAM_DFLT(bin_int, "is interrupt code binned seperately?", true) 174 175END_INIT_SIM_OBJECT_PARAMS(SparcSystem) 176 177CREATE_SIM_OBJECT(SparcSystem) 178{ 179 SparcSystem::Params *p = new SparcSystem::Params; 180 p->name = getInstanceName(); 181 p->boot_cpu_frequency = boot_cpu_frequency; 182 p->physmem = physmem; 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 p->bin = bin; 193 p->binned_fns = binned_fns; 194 p->bin_int = bin_int; 195 return new SparcSystem(p); 196} 197 198REGISTER_SIM_OBJECT("SparcSystem", SparcSystem) 199 200 201