system.cc revision 2665
12567SN/A/* 27585SAli.Saidi@arm.com * Copyright (c) 2002-2006 The Regents of The University of Michigan 37585SAli.Saidi@arm.com * All rights reserved. 47585SAli.Saidi@arm.com * 57585SAli.Saidi@arm.com * Redistribution and use in source and binary forms, with or without 67585SAli.Saidi@arm.com * modification, are permitted provided that the following conditions are 77585SAli.Saidi@arm.com * met: redistributions of source code must retain the above copyright 87585SAli.Saidi@arm.com * notice, this list of conditions and the following disclaimer; 97585SAli.Saidi@arm.com * redistributions in binary form must reproduce the above copyright 107585SAli.Saidi@arm.com * notice, this list of conditions and the following disclaimer in the 117585SAli.Saidi@arm.com * documentation and/or other materials provided with the distribution; 127585SAli.Saidi@arm.com * neither the name of the copyright holders nor the names of its 137585SAli.Saidi@arm.com * contributors may be used to endorse or promote products derived from 142567SN/A * this software without specific prior written permission. 152567SN/A * 162567SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172567SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182567SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192567SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202567SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212567SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222567SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232567SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242567SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252567SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262567SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272567SN/A * 282567SN/A * Authors: Ali Saidi 292567SN/A */ 302567SN/A 312567SN/A#include "arch/sparc/system.hh" 322567SN/A#include "arch/vtophys.hh" 332567SN/A#include "base/remote_gdb.hh" 342567SN/A#include "base/loader/object_file.hh" 352567SN/A#include "base/loader/symtab.hh" 362567SN/A#include "base/trace.hh" 372567SN/A#include "mem/physical.hh" 382567SN/A#include "sim/byteswap.hh" 392665SN/A#include "sim/builder.hh" 402665SN/A 412567SN/A 422567SN/Ausing namespace BigEndianGuest; 438229Snate@binkert.org 448229Snate@binkert.orgSparcSystem::SparcSystem(Params *p) 456757SAli.Saidi@ARM.com : System(p), sysTick(0) 468286SAli.Saidi@ARM.com 478286SAli.Saidi@ARM.com{ 488286SAli.Saidi@ARM.com resetSymtab = new SymbolTable; 498286SAli.Saidi@ARM.com hypervisorSymtab = new SymbolTable; 502567SN/A openbootSymtab = new SymbolTable; 517650SAli.Saidi@ARM.com 527650SAli.Saidi@ARM.com 532567SN/A /** 546757SAli.Saidi@ARM.com * Load the boot code, and hypervisor into memory. 558286SAli.Saidi@ARM.com */ 562567SN/A // Read the reset binary 577650SAli.Saidi@ARM.com reset = createObjectFile(params()->reset_bin); 582567SN/A if (reset == NULL) 598286SAli.Saidi@ARM.com fatal("Could not load reset binary %s", params()->reset_bin); 608286SAli.Saidi@ARM.com 618286SAli.Saidi@ARM.com // Read the openboot binary 628286SAli.Saidi@ARM.com openboot = createObjectFile(params()->openboot_bin); 638286SAli.Saidi@ARM.com if (openboot == NULL) 648286SAli.Saidi@ARM.com fatal("Could not load openboot bianry %s", params()->openboot_bin); 658286SAli.Saidi@ARM.com 668286SAli.Saidi@ARM.com // Read the hypervisor binary 678286SAli.Saidi@ARM.com hypervisor = createObjectFile(params()->hypervisor_bin); 688286SAli.Saidi@ARM.com if (hypervisor == NULL) 698286SAli.Saidi@ARM.com fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 708286SAli.Saidi@ARM.com 718286SAli.Saidi@ARM.com 728286SAli.Saidi@ARM.com // Load reset binary into memory 738286SAli.Saidi@ARM.com reset->loadSections(&functionalPort, SparcISA::LoadAddrMask); 748286SAli.Saidi@ARM.com // Load the openboot binary 758286SAli.Saidi@ARM.com openboot->loadSections(&functionalPort, SparcISA::LoadAddrMask); 768286SAli.Saidi@ARM.com // Load the hypervisor binary 778286SAli.Saidi@ARM.com hypervisor->loadSections(&functionalPort, SparcISA::LoadAddrMask); 788286SAli.Saidi@ARM.com 798286SAli.Saidi@ARM.com // load symbols 808286SAli.Saidi@ARM.com if (!reset->loadGlobalSymbols(reset)) 818286SAli.Saidi@ARM.com panic("could not load reset symbols\n"); 828286SAli.Saidi@ARM.com 838286SAli.Saidi@ARM.com if (!openboot->loadGlobalSymbols(openbootSymtab)) 848286SAli.Saidi@ARM.com panic("could not load openboot symbols\n"); 858286SAli.Saidi@ARM.com 868286SAli.Saidi@ARM.com if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 878286SAli.Saidi@ARM.com panic("could not load hypervisor symbols\n"); 888286SAli.Saidi@ARM.com 898286SAli.Saidi@ARM.com // load symbols into debug table 908286SAli.Saidi@ARM.com if (!reset->loadGlobalSymbols(debugSymbolTable)) 918286SAli.Saidi@ARM.com panic("could not load reset symbols\n"); 928286SAli.Saidi@ARM.com 938286SAli.Saidi@ARM.com if (!openboot->loadGlobalSymbols(debugSymbolTable)) 948286SAli.Saidi@ARM.com panic("could not load openboot symbols\n"); 958286SAli.Saidi@ARM.com 968286SAli.Saidi@ARM.com if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 978286SAli.Saidi@ARM.com panic("could not load hypervisor symbols\n"); 988286SAli.Saidi@ARM.com 998286SAli.Saidi@ARM.com 1008286SAli.Saidi@ARM.com // @todo any fixup code over writing data in binaries on setting break 1018286SAli.Saidi@ARM.com // events on functions should happen here. 1028286SAli.Saidi@ARM.com 1038286SAli.Saidi@ARM.com} 1048286SAli.Saidi@ARM.com 1058286SAli.Saidi@ARM.comSparcSystem::~SparcSystem() 1068286SAli.Saidi@ARM.com{ 1078299Schander.sudanthi@arm.com delete resetSymtab; 1088299Schander.sudanthi@arm.com delete hypervisorSymtab; 1098299Schander.sudanthi@arm.com delete openbootSymtab; 1108299Schander.sudanthi@arm.com delete reset; 1118299Schander.sudanthi@arm.com delete openboot; 1128299Schander.sudanthi@arm.com delete hypervisor; 1138299Schander.sudanthi@arm.com} 1142567SN/A 1152567SN/Abool 1166757SAli.Saidi@ARM.comSparcSystem::breakpoint() 1172567SN/A{ 1188286SAli.Saidi@ARM.com panic("Need to implement"); 1198286SAli.Saidi@ARM.com} 1202567SN/A 1212567SN/Avoid 1226757SAli.Saidi@ARM.comSparcSystem::serialize(std::ostream &os) 1236757SAli.Saidi@ARM.com{ 1246757SAli.Saidi@ARM.com System::serialize(os); 1252567SN/A resetSymtab->serialize("reset_symtab", os); 1266757SAli.Saidi@ARM.com hypervisorSymtab->serialize("hypervisor_symtab", os); 1272567SN/A 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; 144 145 Param<std::string> kernel; 146 Param<std::string> reset_bin; 147 Param<std::string> hypervisor_bin; 148 Param<std::string> openboot_bin; 149 150 Param<std::string> boot_osflags; 151 Param<std::string> readfile; 152 Param<unsigned int> init_param; 153 154 Param<bool> bin; 155 VectorParam<std::string> binned_fns; 156 Param<bool> bin_int; 157 158END_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 159 160BEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem) 161 162 INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"), 163 INIT_PARAM(physmem, "phsyical memory"), 164 INIT_PARAM(kernel, "file that contains the kernel code"), 165 INIT_PARAM(reset_bin, "file that contains the reset code"), 166 INIT_PARAM(hypervisor_bin, "file that contains the hypervisor code"), 167 INIT_PARAM(openboot_bin, "file that contains the openboot code"), 168 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", 169 "a"), 170 INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), 171 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0), 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(bin, "is this system to be binned", false), 175 INIT_PARAM(binned_fns, "functions to be broken down and binned"), 176 INIT_PARAM_DFLT(bin_int, "is interrupt code binned seperately?", true) 177 178END_INIT_SIM_OBJECT_PARAMS(SparcSystem) 179 180CREATE_SIM_OBJECT(SparcSystem) 181{ 182 SparcSystem::Params *p = new SparcSystem::Params; 183 p->name = getInstanceName(); 184 p->boot_cpu_frequency = boot_cpu_frequency; 185 p->physmem = physmem; 186 p->kernel_path = kernel; 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; 193 p->system_type = system_type; 194 p->system_rev = system_rev; 195 p->bin = bin; 196 p->binned_fns = binned_fns; 197 p->bin_int = bin_int; 198 return new SparcSystem(p); 199} 200 201REGISTER_SIM_OBJECT("SparcSystem", SparcSystem) 202 203 204