system.cc revision 8706
12567SN/A/* 22567SN/A * Copyright (c) 2002-2006 The Regents of The University of Michigan 32567SN/A * All rights reserved. 42567SN/A * 52567SN/A * Redistribution and use in source and binary forms, with or without 62567SN/A * modification, are permitted provided that the following conditions are 72567SN/A * met: redistributions of source code must retain the above copyright 82567SN/A * notice, this list of conditions and the following disclaimer; 92567SN/A * redistributions in binary form must reproduce the above copyright 102567SN/A * notice, this list of conditions and the following disclaimer in the 112567SN/A * documentation and/or other materials provided with the distribution; 122567SN/A * neither the name of the copyright holders nor the names of its 132567SN/A * 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. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Ali Saidi 292567SN/A */ 302567SN/A 312567SN/A#include "arch/sparc/system.hh" 322567SN/A#include "arch/vtophys.hh" 332567SN/A#include "base/loader/object_file.hh" 342567SN/A#include "base/loader/symtab.hh" 352567SN/A#include "base/trace.hh" 362567SN/A#include "mem/physical.hh" 374762Snate@binkert.org#include "params/SparcSystem.hh" 382567SN/A#include "sim/byteswap.hh" 392567SN/A 402567SN/Ausing namespace BigEndianGuest; 412567SN/A 422567SN/ASparcSystem::SparcSystem(Params *p) 438706Sandreas.hansson@arm.com : System(p), sysTick(0) 442567SN/A{ 452567SN/A resetSymtab = new SymbolTable; 462567SN/A hypervisorSymtab = new SymbolTable; 472567SN/A openbootSymtab = new SymbolTable; 483745Sgblack@eecs.umich.edu nvramSymtab = new SymbolTable; 493745Sgblack@eecs.umich.edu hypervisorDescSymtab = new SymbolTable; 503745Sgblack@eecs.umich.edu partitionDescSymtab = new SymbolTable; 518706Sandreas.hansson@arm.com} 522567SN/A 538706Sandreas.hansson@arm.comvoid 548706Sandreas.hansson@arm.comSparcSystem::initState() 558706Sandreas.hansson@arm.com{ 568706Sandreas.hansson@arm.com // Call the initialisation of the super class 578706Sandreas.hansson@arm.com System::initState(); 583745Sgblack@eecs.umich.edu 592567SN/A /** 602567SN/A * Load the boot code, and hypervisor into memory. 612567SN/A */ 622567SN/A // Read the reset binary 633584Ssaidi@eecs.umich.edu reset = createObjectFile(params()->reset_bin, true); 642567SN/A if (reset == NULL) 652567SN/A fatal("Could not load reset binary %s", params()->reset_bin); 662567SN/A 672567SN/A // Read the openboot binary 683584Ssaidi@eecs.umich.edu openboot = createObjectFile(params()->openboot_bin, true); 692567SN/A if (openboot == NULL) 702567SN/A fatal("Could not load openboot bianry %s", params()->openboot_bin); 712567SN/A 722567SN/A // Read the hypervisor binary 733584Ssaidi@eecs.umich.edu hypervisor = createObjectFile(params()->hypervisor_bin, true); 742567SN/A if (hypervisor == NULL) 752567SN/A fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 762567SN/A 773745Sgblack@eecs.umich.edu // Read the nvram image 783745Sgblack@eecs.umich.edu nvram = createObjectFile(params()->nvram_bin, true); 793745Sgblack@eecs.umich.edu if (nvram == NULL) 803745Sgblack@eecs.umich.edu fatal("Could not load nvram image %s", params()->nvram_bin); 813745Sgblack@eecs.umich.edu 823745Sgblack@eecs.umich.edu // Read the hypervisor description image 833745Sgblack@eecs.umich.edu hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true); 843745Sgblack@eecs.umich.edu if (hypervisor_desc == NULL) 853745Sgblack@eecs.umich.edu fatal("Could not load hypervisor description image %s", 863745Sgblack@eecs.umich.edu params()->hypervisor_desc_bin); 873745Sgblack@eecs.umich.edu 883745Sgblack@eecs.umich.edu // Read the partition description image 893745Sgblack@eecs.umich.edu partition_desc = createObjectFile(params()->partition_desc_bin, true); 903745Sgblack@eecs.umich.edu if (partition_desc == NULL) 913745Sgblack@eecs.umich.edu fatal("Could not load partition description image %s", 923745Sgblack@eecs.umich.edu params()->partition_desc_bin); 933745Sgblack@eecs.umich.edu 942567SN/A 952567SN/A // Load reset binary into memory 963584Ssaidi@eecs.umich.edu reset->setTextBase(params()->reset_addr); 978706Sandreas.hansson@arm.com reset->loadSections(physProxy); 982567SN/A // Load the openboot binary 993584Ssaidi@eecs.umich.edu openboot->setTextBase(params()->openboot_addr); 1008706Sandreas.hansson@arm.com openboot->loadSections(physProxy); 1012567SN/A // Load the hypervisor binary 1023584Ssaidi@eecs.umich.edu hypervisor->setTextBase(params()->hypervisor_addr); 1038706Sandreas.hansson@arm.com hypervisor->loadSections(physProxy); 1043745Sgblack@eecs.umich.edu // Load the nvram image 1053745Sgblack@eecs.umich.edu nvram->setTextBase(params()->nvram_addr); 1068706Sandreas.hansson@arm.com nvram->loadSections(physProxy); 1073745Sgblack@eecs.umich.edu // Load the hypervisor description image 1083745Sgblack@eecs.umich.edu hypervisor_desc->setTextBase(params()->hypervisor_desc_addr); 1098706Sandreas.hansson@arm.com hypervisor_desc->loadSections(physProxy); 1103745Sgblack@eecs.umich.edu // Load the partition description image 1113745Sgblack@eecs.umich.edu partition_desc->setTextBase(params()->partition_desc_addr); 1128706Sandreas.hansson@arm.com partition_desc->loadSections(physProxy); 1132567SN/A 1142567SN/A // load symbols 1153527Sgblack@eecs.umich.edu if (!reset->loadGlobalSymbols(resetSymtab)) 1162567SN/A panic("could not load reset symbols\n"); 1172567SN/A 1182567SN/A if (!openboot->loadGlobalSymbols(openbootSymtab)) 1192567SN/A panic("could not load openboot symbols\n"); 1202567SN/A 1212567SN/A if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 1222567SN/A panic("could not load hypervisor symbols\n"); 1232567SN/A 1243745Sgblack@eecs.umich.edu if (!nvram->loadLocalSymbols(nvramSymtab)) 1253745Sgblack@eecs.umich.edu panic("could not load nvram symbols\n"); 1263745Sgblack@eecs.umich.edu 1273745Sgblack@eecs.umich.edu if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab)) 1283745Sgblack@eecs.umich.edu panic("could not load hypervisor description symbols\n"); 1293745Sgblack@eecs.umich.edu 1303745Sgblack@eecs.umich.edu if (!partition_desc->loadLocalSymbols(partitionDescSymtab)) 1313745Sgblack@eecs.umich.edu panic("could not load partition description symbols\n"); 1323745Sgblack@eecs.umich.edu 1332567SN/A // load symbols into debug table 1342567SN/A if (!reset->loadGlobalSymbols(debugSymbolTable)) 1352567SN/A panic("could not load reset symbols\n"); 1362567SN/A 1372567SN/A if (!openboot->loadGlobalSymbols(debugSymbolTable)) 1382567SN/A panic("could not load openboot symbols\n"); 1392567SN/A 1402567SN/A if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 1412567SN/A panic("could not load hypervisor symbols\n"); 1422567SN/A 1433812Ssaidi@eecs.umich.edu // Strip off the rom address so when the hypervisor is copied into memory we 1443812Ssaidi@eecs.umich.edu // have symbols still 1453812Ssaidi@eecs.umich.edu if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF)) 1463812Ssaidi@eecs.umich.edu panic("could not load hypervisor symbols\n"); 1473812Ssaidi@eecs.umich.edu 1483745Sgblack@eecs.umich.edu if (!nvram->loadGlobalSymbols(debugSymbolTable)) 1493745Sgblack@eecs.umich.edu panic("could not load reset symbols\n"); 1503745Sgblack@eecs.umich.edu 1513745Sgblack@eecs.umich.edu if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable)) 1523745Sgblack@eecs.umich.edu panic("could not load hypervisor description symbols\n"); 1533745Sgblack@eecs.umich.edu 1543745Sgblack@eecs.umich.edu if (!partition_desc->loadLocalSymbols(debugSymbolTable)) 1553745Sgblack@eecs.umich.edu panic("could not load partition description symbols\n"); 1563745Sgblack@eecs.umich.edu 1572567SN/A 1582567SN/A // @todo any fixup code over writing data in binaries on setting break 1592567SN/A // events on functions should happen here. 1602567SN/A 1612567SN/A} 1622567SN/A 1632567SN/ASparcSystem::~SparcSystem() 1642567SN/A{ 1652567SN/A delete resetSymtab; 1662567SN/A delete hypervisorSymtab; 1672567SN/A delete openbootSymtab; 1683745Sgblack@eecs.umich.edu delete nvramSymtab; 1693745Sgblack@eecs.umich.edu delete hypervisorDescSymtab; 1703745Sgblack@eecs.umich.edu delete partitionDescSymtab; 1712567SN/A delete reset; 1722567SN/A delete openboot; 1732567SN/A delete hypervisor; 1743745Sgblack@eecs.umich.edu delete nvram; 1753745Sgblack@eecs.umich.edu delete hypervisor_desc; 1763745Sgblack@eecs.umich.edu delete partition_desc; 1772567SN/A} 1782567SN/A 1792567SN/Avoid 1802567SN/ASparcSystem::serialize(std::ostream &os) 1812567SN/A{ 1822567SN/A System::serialize(os); 1832567SN/A resetSymtab->serialize("reset_symtab", os); 1842567SN/A hypervisorSymtab->serialize("hypervisor_symtab", os); 1852567SN/A openbootSymtab->serialize("openboot_symtab", os); 1863745Sgblack@eecs.umich.edu nvramSymtab->serialize("nvram_symtab", os); 1873745Sgblack@eecs.umich.edu hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os); 1883745Sgblack@eecs.umich.edu partitionDescSymtab->serialize("partition_desc_symtab", os); 1892567SN/A} 1902567SN/A 1912567SN/A 1922567SN/Avoid 1932567SN/ASparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 1942567SN/A{ 1952567SN/A System::unserialize(cp,section); 1962567SN/A resetSymtab->unserialize("reset_symtab", cp, section); 1972567SN/A hypervisorSymtab->unserialize("hypervisor_symtab", cp, section); 1982567SN/A openbootSymtab->unserialize("openboot_symtab", cp, section); 1993745Sgblack@eecs.umich.edu nvramSymtab->unserialize("nvram_symtab", cp, section); 2003745Sgblack@eecs.umich.edu hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section); 2013745Sgblack@eecs.umich.edu partitionDescSymtab->unserialize("partition_desc_symtab", cp, section); 2022567SN/A} 2032567SN/A 2044762Snate@binkert.orgSparcSystem * 2054762Snate@binkert.orgSparcSystemParams::create() 2062567SN/A{ 2074762Snate@binkert.org return new SparcSystem(this); 2082567SN/A} 209