system.cc revision 5222
14825Sgblack@eecs.umich.edu/* 29582Snilay@cs.wisc.edu * Copyright (c) 2002-2006 The Regents of The University of Michigan 34825Sgblack@eecs.umich.edu * All rights reserved. 44825Sgblack@eecs.umich.edu * 57087Snate@binkert.org * Redistribution and use in source and binary forms, with or without 67087Snate@binkert.org * modification, are permitted provided that the following conditions are 77087Snate@binkert.org * met: redistributions of source code must retain the above copyright 87087Snate@binkert.org * notice, this list of conditions and the following disclaimer; 97087Snate@binkert.org * redistributions in binary form must reproduce the above copyright 107087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 117087Snate@binkert.org * documentation and/or other materials provided with the distribution; 127087Snate@binkert.org * neither the name of the copyright holders nor the names of its 134825Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 147087Snate@binkert.org * this software without specific prior written permission. 157087Snate@binkert.org * 167087Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 177087Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 187087Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 197087Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 207087Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 217087Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 224825Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237087Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 244825Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 254825Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 264825Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274825Sgblack@eecs.umich.edu * 284825Sgblack@eecs.umich.edu * Authors: Ali Saidi 294825Sgblack@eecs.umich.edu */ 304825Sgblack@eecs.umich.edu 314825Sgblack@eecs.umich.edu#include "arch/sparc/system.hh" 324825Sgblack@eecs.umich.edu#include "arch/vtophys.hh" 334825Sgblack@eecs.umich.edu#include "base/remote_gdb.hh" 344825Sgblack@eecs.umich.edu#include "base/loader/object_file.hh" 354825Sgblack@eecs.umich.edu#include "base/loader/symtab.hh" 364825Sgblack@eecs.umich.edu#include "base/trace.hh" 374825Sgblack@eecs.umich.edu#include "mem/physical.hh" 389582Snilay@cs.wisc.edu#include "params/SparcSystem.hh" 394825Sgblack@eecs.umich.edu#include "sim/byteswap.hh" 405162Sgblack@eecs.umich.edu 415162Sgblack@eecs.umich.edu 425162Sgblack@eecs.umich.eduusing namespace BigEndianGuest; 4310044Snilay@cs.wisc.edu 4410044Snilay@cs.wisc.eduSparcSystem::SparcSystem(Params *p) 4510044Snilay@cs.wisc.edu : System(p), sysTick(0),funcRomPort(p->name + "-fromport"), 4610044Snilay@cs.wisc.edu funcNvramPort(p->name + "-fnvramport"), 4710044Snilay@cs.wisc.edu funcHypDescPort(p->name + "-fhypdescport"), 485162Sgblack@eecs.umich.edu funcPartDescPort(p->name + "-fpartdescport") 495162Sgblack@eecs.umich.edu{ 505162Sgblack@eecs.umich.edu resetSymtab = new SymbolTable; 5110044Snilay@cs.wisc.edu hypervisorSymtab = new SymbolTable; 5210044Snilay@cs.wisc.edu openbootSymtab = new SymbolTable; 5310044Snilay@cs.wisc.edu nvramSymtab = new SymbolTable; 5410044Snilay@cs.wisc.edu hypervisorDescSymtab = new SymbolTable; 555162Sgblack@eecs.umich.edu partitionDescSymtab = new SymbolTable; 565162Sgblack@eecs.umich.edu 575162Sgblack@eecs.umich.edu Port *rom_port; 584825Sgblack@eecs.umich.edu rom_port = params()->rom->getPort("functional"); 595162Sgblack@eecs.umich.edu funcRomPort.setPeer(rom_port); 609582Snilay@cs.wisc.edu rom_port->setPeer(&funcRomPort); 619582Snilay@cs.wisc.edu 629582Snilay@cs.wisc.edu rom_port = params()->nvram->getPort("functional"); 639582Snilay@cs.wisc.edu funcNvramPort.setPeer(rom_port); 649582Snilay@cs.wisc.edu rom_port->setPeer(&funcNvramPort); 655162Sgblack@eecs.umich.edu 6610043Snilay@cs.wisc.edu rom_port = params()->hypervisor_desc->getPort("functional"); 674825Sgblack@eecs.umich.edu funcHypDescPort.setPeer(rom_port); 684825Sgblack@eecs.umich.edu rom_port->setPeer(&funcHypDescPort); 695162Sgblack@eecs.umich.edu 705162Sgblack@eecs.umich.edu rom_port = params()->partition_desc->getPort("functional"); 715162Sgblack@eecs.umich.edu funcPartDescPort.setPeer(rom_port); 725162Sgblack@eecs.umich.edu rom_port->setPeer(&funcPartDescPort); 735162Sgblack@eecs.umich.edu 749894Sandreas@sandberg.pp.se /** 755162Sgblack@eecs.umich.edu * Load the boot code, and hypervisor into memory. 765162Sgblack@eecs.umich.edu */ 775162Sgblack@eecs.umich.edu // Read the reset binary 789894Sandreas@sandberg.pp.se reset = createObjectFile(params()->reset_bin, true); 795162Sgblack@eecs.umich.edu if (reset == NULL) 805162Sgblack@eecs.umich.edu fatal("Could not load reset binary %s", params()->reset_bin); 815162Sgblack@eecs.umich.edu 829470Snilay@cs.wisc.edu // Read the openboot binary 839470Snilay@cs.wisc.edu openboot = createObjectFile(params()->openboot_bin, true); 845162Sgblack@eecs.umich.edu if (openboot == NULL) 855162Sgblack@eecs.umich.edu fatal("Could not load openboot bianry %s", params()->openboot_bin); 865162Sgblack@eecs.umich.edu 875162Sgblack@eecs.umich.edu // Read the hypervisor binary 889895Sandreas@sandberg.pp.se hypervisor = createObjectFile(params()->hypervisor_bin, true); 895162Sgblack@eecs.umich.edu if (hypervisor == NULL) 905162Sgblack@eecs.umich.edu fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 915162Sgblack@eecs.umich.edu 929582Snilay@cs.wisc.edu // Read the nvram image 939582Snilay@cs.wisc.edu nvram = createObjectFile(params()->nvram_bin, true); 949582Snilay@cs.wisc.edu if (nvram == NULL) 959582Snilay@cs.wisc.edu fatal("Could not load nvram image %s", params()->nvram_bin); 969582Snilay@cs.wisc.edu 979582Snilay@cs.wisc.edu // Read the hypervisor description image 989582Snilay@cs.wisc.edu hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true); 995162Sgblack@eecs.umich.edu if (hypervisor_desc == NULL) 1009582Snilay@cs.wisc.edu fatal("Could not load hypervisor description image %s", 1015162Sgblack@eecs.umich.edu params()->hypervisor_desc_bin); 1025162Sgblack@eecs.umich.edu 1035162Sgblack@eecs.umich.edu // Read the partition description image 1045162Sgblack@eecs.umich.edu partition_desc = createObjectFile(params()->partition_desc_bin, true); 1059582Snilay@cs.wisc.edu if (partition_desc == NULL) 1069582Snilay@cs.wisc.edu fatal("Could not load partition description image %s", 1075162Sgblack@eecs.umich.edu params()->partition_desc_bin); 1085162Sgblack@eecs.umich.edu 1099582Snilay@cs.wisc.edu 1105162Sgblack@eecs.umich.edu // Load reset binary into memory 1115162Sgblack@eecs.umich.edu reset->setTextBase(params()->reset_addr); 1125162Sgblack@eecs.umich.edu reset->loadSections(&funcRomPort); 1139895Sandreas@sandberg.pp.se // Load the openboot binary 1145162Sgblack@eecs.umich.edu openboot->setTextBase(params()->openboot_addr); 1155162Sgblack@eecs.umich.edu openboot->loadSections(&funcRomPort); 1165162Sgblack@eecs.umich.edu // Load the hypervisor binary 1179582Snilay@cs.wisc.edu hypervisor->setTextBase(params()->hypervisor_addr); 1185162Sgblack@eecs.umich.edu hypervisor->loadSections(&funcRomPort); 1195162Sgblack@eecs.umich.edu // Load the nvram image 1209371Snilay@cs.wisc.edu nvram->setTextBase(params()->nvram_addr); 1215162Sgblack@eecs.umich.edu nvram->loadSections(&funcNvramPort); 1225162Sgblack@eecs.umich.edu // Load the hypervisor description image 1239472Snilay@cs.wisc.edu hypervisor_desc->setTextBase(params()->hypervisor_desc_addr); 1249472Snilay@cs.wisc.edu hypervisor_desc->loadSections(&funcHypDescPort); 1255162Sgblack@eecs.umich.edu // Load the partition description image 1269372Snilay@cs.wisc.edu partition_desc->setTextBase(params()->partition_desc_addr); 1275162Sgblack@eecs.umich.edu partition_desc->loadSections(&funcPartDescPort); 1284825Sgblack@eecs.umich.edu 1295162Sgblack@eecs.umich.edu // load symbols 1305162Sgblack@eecs.umich.edu if (!reset->loadGlobalSymbols(resetSymtab)) 1315162Sgblack@eecs.umich.edu panic("could not load reset symbols\n"); 1325162Sgblack@eecs.umich.edu 1335162Sgblack@eecs.umich.edu if (!openboot->loadGlobalSymbols(openbootSymtab)) 1345162Sgblack@eecs.umich.edu panic("could not load openboot symbols\n"); 1355162Sgblack@eecs.umich.edu 1365162Sgblack@eecs.umich.edu if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 1375162Sgblack@eecs.umich.edu panic("could not load hypervisor symbols\n"); 1385162Sgblack@eecs.umich.edu 1395162Sgblack@eecs.umich.edu if (!nvram->loadLocalSymbols(nvramSymtab)) 1405162Sgblack@eecs.umich.edu panic("could not load nvram symbols\n"); 1415162Sgblack@eecs.umich.edu 1425162Sgblack@eecs.umich.edu if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab)) 1435162Sgblack@eecs.umich.edu panic("could not load hypervisor description symbols\n"); 1445162Sgblack@eecs.umich.edu 1455162Sgblack@eecs.umich.edu if (!partition_desc->loadLocalSymbols(partitionDescSymtab)) 1465162Sgblack@eecs.umich.edu panic("could not load partition description symbols\n"); 1475162Sgblack@eecs.umich.edu 1485162Sgblack@eecs.umich.edu // load symbols into debug table 1495162Sgblack@eecs.umich.edu if (!reset->loadGlobalSymbols(debugSymbolTable)) 1505162Sgblack@eecs.umich.edu panic("could not load reset symbols\n"); 1515162Sgblack@eecs.umich.edu 1525162Sgblack@eecs.umich.edu if (!openboot->loadGlobalSymbols(debugSymbolTable)) 1535162Sgblack@eecs.umich.edu panic("could not load openboot symbols\n"); 1545162Sgblack@eecs.umich.edu 1555162Sgblack@eecs.umich.edu if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 1565162Sgblack@eecs.umich.edu panic("could not load hypervisor symbols\n"); 1575162Sgblack@eecs.umich.edu 1585162Sgblack@eecs.umich.edu // Strip off the rom address so when the hypervisor is copied into memory we 1595162Sgblack@eecs.umich.edu // have symbols still 1605162Sgblack@eecs.umich.edu if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF)) 1615162Sgblack@eecs.umich.edu panic("could not load hypervisor symbols\n"); 1625162Sgblack@eecs.umich.edu 1635162Sgblack@eecs.umich.edu if (!nvram->loadGlobalSymbols(debugSymbolTable)) 1645162Sgblack@eecs.umich.edu panic("could not load reset symbols\n"); 1655162Sgblack@eecs.umich.edu 1664825Sgblack@eecs.umich.edu if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable)) 1675162Sgblack@eecs.umich.edu panic("could not load hypervisor description symbols\n"); 1685162Sgblack@eecs.umich.edu 1695162Sgblack@eecs.umich.edu if (!partition_desc->loadLocalSymbols(debugSymbolTable)) 1705162Sgblack@eecs.umich.edu panic("could not load partition description symbols\n"); 1715162Sgblack@eecs.umich.edu 1725162Sgblack@eecs.umich.edu 1735162Sgblack@eecs.umich.edu // @todo any fixup code over writing data in binaries on setting break 1745162Sgblack@eecs.umich.edu // events on functions should happen here. 1755162Sgblack@eecs.umich.edu 1765162Sgblack@eecs.umich.edu} 1775162Sgblack@eecs.umich.edu 1785162Sgblack@eecs.umich.eduSparcSystem::~SparcSystem() 1795162Sgblack@eecs.umich.edu{ 1805162Sgblack@eecs.umich.edu delete resetSymtab; 1815162Sgblack@eecs.umich.edu delete hypervisorSymtab; 1825162Sgblack@eecs.umich.edu delete openbootSymtab; 1835162Sgblack@eecs.umich.edu delete nvramSymtab; 1845162Sgblack@eecs.umich.edu delete hypervisorDescSymtab; 1855162Sgblack@eecs.umich.edu delete partitionDescSymtab; 1865162Sgblack@eecs.umich.edu delete reset; 1875162Sgblack@eecs.umich.edu delete openboot; 1885162Sgblack@eecs.umich.edu delete hypervisor; 1895162Sgblack@eecs.umich.edu delete nvram; 1905162Sgblack@eecs.umich.edu delete hypervisor_desc; 1914825Sgblack@eecs.umich.edu delete partition_desc; 1924825Sgblack@eecs.umich.edu} 1935162Sgblack@eecs.umich.edu 1945162Sgblack@eecs.umich.eduvoid 1959582Snilay@cs.wisc.eduSparcSystem::serialize(std::ostream &os) 1969894Sandreas@sandberg.pp.se{ 1974825Sgblack@eecs.umich.edu System::serialize(os); 1985162Sgblack@eecs.umich.edu resetSymtab->serialize("reset_symtab", os); 1995162Sgblack@eecs.umich.edu hypervisorSymtab->serialize("hypervisor_symtab", os); 2004825Sgblack@eecs.umich.edu openbootSymtab->serialize("openboot_symtab", os); 2014825Sgblack@eecs.umich.edu nvramSymtab->serialize("nvram_symtab", os); 2025162Sgblack@eecs.umich.edu hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os); 2035162Sgblack@eecs.umich.edu partitionDescSymtab->serialize("partition_desc_symtab", os); 2049894Sandreas@sandberg.pp.se} 2055162Sgblack@eecs.umich.edu 2064825Sgblack@eecs.umich.edu 2075162Sgblack@eecs.umich.eduvoid 2085162Sgblack@eecs.umich.eduSparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 20910044Snilay@cs.wisc.edu{ 21010044Snilay@cs.wisc.edu System::unserialize(cp,section); 21110044Snilay@cs.wisc.edu resetSymtab->unserialize("reset_symtab", cp, section); 21210044Snilay@cs.wisc.edu hypervisorSymtab->unserialize("hypervisor_symtab", cp, section); 2135162Sgblack@eecs.umich.edu openbootSymtab->unserialize("openboot_symtab", cp, section); 2145162Sgblack@eecs.umich.edu nvramSymtab->unserialize("nvram_symtab", cp, section); 2155162Sgblack@eecs.umich.edu hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section); 2165162Sgblack@eecs.umich.edu partitionDescSymtab->unserialize("partition_desc_symtab", cp, section); 2175162Sgblack@eecs.umich.edu} 2185162Sgblack@eecs.umich.edu 2195162Sgblack@eecs.umich.eduSparcSystem * 2205162Sgblack@eecs.umich.eduSparcSystemParams::create() 2215162Sgblack@eecs.umich.edu{ 2225162Sgblack@eecs.umich.edu return new SparcSystem(this); 2235162Sgblack@eecs.umich.edu} 22410044Snilay@cs.wisc.edu