system.cc revision 6222
12SN/A/* 21762SN/A * Copyright (c) 2002-2006 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Ali Saidi 292665Ssaidi@eecs.umich.edu */ 302665Ssaidi@eecs.umich.edu 312SN/A#include "arch/sparc/system.hh" 322SN/A#include "arch/vtophys.hh" 332623SN/A#include "base/remote_gdb.hh" 342623SN/A#include "base/loader/object_file.hh" 352SN/A#include "base/loader/symtab.hh" 364182Sgblack@eecs.umich.edu#include "base/trace.hh" 371354SN/A#include "mem/physical.hh" 381858SN/A#include "params/SparcSystem.hh" 391717SN/A#include "sim/byteswap.hh" 402683Sktlim@umich.edu 411354SN/A 421354SN/Ausing namespace BigEndianGuest; 432387SN/A 442387SN/ASparcSystem::SparcSystem(Params *p) 452387SN/A : System(p), sysTick(0),funcRomPort(p->name + "-fromport"), 4656SN/A funcNvramPort(p->name + "-fnvramport"), 475348Ssaidi@eecs.umich.edu funcHypDescPort(p->name + "-fhypdescport"), 482SN/A funcPartDescPort(p->name + "-fpartdescport") 492SN/A{ 501858SN/A resetSymtab = new SymbolTable; 512SN/A hypervisorSymtab = new SymbolTable; 523453Sgblack@eecs.umich.edu openbootSymtab = new SymbolTable; 533453Sgblack@eecs.umich.edu nvramSymtab = new SymbolTable; 543453Sgblack@eecs.umich.edu hypervisorDescSymtab = new SymbolTable; 553453Sgblack@eecs.umich.edu partitionDescSymtab = new SymbolTable; 563453Sgblack@eecs.umich.edu 572462SN/A Port *rom_port; 582SN/A rom_port = params()->rom->getPort("functional"); 59715SN/A funcRomPort.setPeer(rom_port); 60715SN/A rom_port->setPeer(&funcRomPort); 61715SN/A 62715SN/A rom_port = params()->nvram->getPort("functional"); 632SN/A funcNvramPort.setPeer(rom_port); 642SN/A rom_port->setPeer(&funcNvramPort); 653960Sgblack@eecs.umich.edu 663960Sgblack@eecs.umich.edu rom_port = params()->hypervisor_desc->getPort("functional"); 673960Sgblack@eecs.umich.edu funcHypDescPort.setPeer(rom_port); 684182Sgblack@eecs.umich.edu rom_port->setPeer(&funcHypDescPort); 694182Sgblack@eecs.umich.edu 704182Sgblack@eecs.umich.edu rom_port = params()->partition_desc->getPort("functional"); 714182Sgblack@eecs.umich.edu funcPartDescPort.setPeer(rom_port); 722680Sktlim@umich.edu rom_port->setPeer(&funcPartDescPort); 73237SN/A 742SN/A /** 752SN/A * Load the boot code, and hypervisor into memory. 762SN/A */ 772SN/A // Read the reset binary 782SN/A reset = createObjectFile(params()->reset_bin, true); 792420SN/A if (reset == NULL) 802623SN/A fatal("Could not load reset binary %s", params()->reset_bin); 812SN/A 822107SN/A // Read the openboot binary 832159SN/A openboot = createObjectFile(params()->openboot_bin, true); 842455SN/A if (openboot == NULL) 852455SN/A fatal("Could not load openboot bianry %s", params()->openboot_bin); 862386SN/A 872623SN/A // Read the hypervisor binary 882SN/A hypervisor = createObjectFile(params()->hypervisor_bin, true); 891371SN/A if (hypervisor == NULL) 905348Ssaidi@eecs.umich.edu fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 915348Ssaidi@eecs.umich.edu 925348Ssaidi@eecs.umich.edu // Read the nvram image 935348Ssaidi@eecs.umich.edu nvram = createObjectFile(params()->nvram_bin, true); 945348Ssaidi@eecs.umich.edu if (nvram == NULL) 955348Ssaidi@eecs.umich.edu fatal("Could not load nvram image %s", params()->nvram_bin); 965348Ssaidi@eecs.umich.edu 975348Ssaidi@eecs.umich.edu // Read the hypervisor description image 982SN/A hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true); 992SN/A if (hypervisor_desc == NULL) 1002SN/A fatal("Could not load hypervisor description image %s", 1012SN/A params()->hypervisor_desc_bin); 1022SN/A 1032SN/A // Read the partition description image 1042SN/A partition_desc = createObjectFile(params()->partition_desc_bin, true); 1052SN/A if (partition_desc == NULL) 1062SN/A fatal("Could not load partition description image %s", 1072SN/A params()->partition_desc_bin); 1082SN/A 1091400SN/A 1101400SN/A // Load reset binary into memory 1111400SN/A reset->setTextBase(params()->reset_addr); 1123453Sgblack@eecs.umich.edu reset->loadSections(&funcRomPort); 1133453Sgblack@eecs.umich.edu // Load the openboot binary 1144997Sgblack@eecs.umich.edu openboot->setTextBase(params()->openboot_addr); 1151400SN/A openboot->loadSections(&funcRomPort); 1162SN/A // Load the hypervisor binary 1171400SN/A hypervisor->setTextBase(params()->hypervisor_addr); 1182623SN/A hypervisor->loadSections(&funcRomPort); 1192623SN/A // Load the nvram image 1202SN/A nvram->setTextBase(params()->nvram_addr); 1211400SN/A nvram->loadSections(&funcNvramPort); 1222683Sktlim@umich.edu // Load the hypervisor description image 1232683Sktlim@umich.edu hypervisor_desc->setTextBase(params()->hypervisor_desc_addr); 1242190SN/A hypervisor_desc->loadSections(&funcHypDescPort); 1252683Sktlim@umich.edu // Load the partition description image 1262683Sktlim@umich.edu partition_desc->setTextBase(params()->partition_desc_addr); 1272683Sktlim@umich.edu partition_desc->loadSections(&funcPartDescPort); 1282680Sktlim@umich.edu 1295169Ssaidi@eecs.umich.edu // load symbols 1305169Ssaidi@eecs.umich.edu if (!reset->loadGlobalSymbols(resetSymtab)) 1315169Ssaidi@eecs.umich.edu panic("could not load reset symbols\n"); 1325496Ssaidi@eecs.umich.edu 1335496Ssaidi@eecs.umich.edu if (!openboot->loadGlobalSymbols(openbootSymtab)) 1345496Ssaidi@eecs.umich.edu panic("could not load openboot symbols\n"); 1355496Ssaidi@eecs.umich.edu 1365496Ssaidi@eecs.umich.edu if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 1375496Ssaidi@eecs.umich.edu panic("could not load hypervisor symbols\n"); 1385496Ssaidi@eecs.umich.edu 1395496Ssaidi@eecs.umich.edu if (!nvram->loadLocalSymbols(nvramSymtab)) 1405496Ssaidi@eecs.umich.edu panic("could not load nvram symbols\n"); 1415496Ssaidi@eecs.umich.edu 1425496Ssaidi@eecs.umich.edu if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab)) 1435496Ssaidi@eecs.umich.edu panic("could not load hypervisor description symbols\n"); 1445496Ssaidi@eecs.umich.edu 1455496Ssaidi@eecs.umich.edu if (!partition_desc->loadLocalSymbols(partitionDescSymtab)) 1465169Ssaidi@eecs.umich.edu panic("could not load partition description symbols\n"); 1472SN/A 1481858SN/A // load symbols into debug table 1492SN/A if (!reset->loadGlobalSymbols(debugSymbolTable)) 1502SN/A panic("could not load reset symbols\n"); 1512SN/A 1522SN/A if (!openboot->loadGlobalSymbols(debugSymbolTable)) 1532SN/A panic("could not load openboot symbols\n"); 1542SN/A 1554181Sgblack@eecs.umich.edu if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 1564181Sgblack@eecs.umich.edu panic("could not load hypervisor symbols\n"); 1574182Sgblack@eecs.umich.edu 1584182Sgblack@eecs.umich.edu // Strip off the rom address so when the hypervisor is copied into memory we 1592SN/A // have symbols still 1602107SN/A if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF)) 1613276Sgblack@eecs.umich.edu panic("could not load hypervisor symbols\n"); 1621469SN/A 1634377Sgblack@eecs.umich.edu if (!nvram->loadGlobalSymbols(debugSymbolTable)) 1644377Sgblack@eecs.umich.edu panic("could not load reset symbols\n"); 1654377Sgblack@eecs.umich.edu 1664377Sgblack@eecs.umich.edu if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable)) 1674377Sgblack@eecs.umich.edu panic("could not load hypervisor description symbols\n"); 1684377Sgblack@eecs.umich.edu 1692623SN/A if (!partition_desc->loadLocalSymbols(debugSymbolTable)) 1702662Sstever@eecs.umich.edu panic("could not load partition description symbols\n"); 1712623SN/A 1722623SN/A 1732623SN/A // @todo any fixup code over writing data in binaries on setting break 174180SN/A // events on functions should happen here. 175393SN/A 176393SN/A} 1772SN/A 1782SN/ASparcSystem::~SparcSystem() 179334SN/A{ 180334SN/A delete resetSymtab; 1812SN/A delete hypervisorSymtab; 1822SN/A delete openbootSymtab; 1832SN/A delete nvramSymtab; 184334SN/A delete hypervisorDescSymtab; 185729SN/A delete partitionDescSymtab; 186707SN/A delete reset; 1874998Sgblack@eecs.umich.edu delete openboot; 1884998Sgblack@eecs.umich.edu delete hypervisor; 1894998Sgblack@eecs.umich.edu delete nvram; 1904998Sgblack@eecs.umich.edu delete hypervisor_desc; 1914998Sgblack@eecs.umich.edu delete partition_desc; 1924998Sgblack@eecs.umich.edu} 1934998Sgblack@eecs.umich.edu 1944998Sgblack@eecs.umich.eduvoid 195707SN/ASparcSystem::serialize(std::ostream &os) 196707SN/A{ 197707SN/A System::serialize(os); 198707SN/A resetSymtab->serialize("reset_symtab", os); 1992SN/A hypervisorSymtab->serialize("hypervisor_symtab", os); 2004564Sgblack@eecs.umich.edu openbootSymtab->serialize("openboot_symtab", os); 2014564Sgblack@eecs.umich.edu nvramSymtab->serialize("nvram_symtab", os); 2024564Sgblack@eecs.umich.edu hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os); 2032SN/A partitionDescSymtab->serialize("partition_desc_symtab", os); 204729SN/A} 2052SN/A 206124SN/A 207124SN/Avoid 208334SN/ASparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 209124SN/A{ 2102SN/A System::unserialize(cp,section); 211729SN/A resetSymtab->unserialize("reset_symtab", cp, section); 212729SN/A hypervisorSymtab->unserialize("hypervisor_symtab", cp, section); 2132SN/A openbootSymtab->unserialize("openboot_symtab", cp, section); 2142390SN/A nvramSymtab->unserialize("nvram_symtab", cp, section); 215729SN/A hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section); 2162SN/A partitionDescSymtab->unserialize("partition_desc_symtab", cp, section); 2172SN/A} 2182390SN/A 2192390SN/ASparcSystem * 2202390SN/ASparcSystemParams::create() 2212390SN/A{ 2222390SN/A return new SparcSystem(this); 223729SN/A} 2242SN/A