system.cc revision 8885:52bbd95b31ed
111841Sandreas.sandberg@arm.com/* 27090SN/A * Copyright (c) 2002-2006 The Regents of The University of Michigan 37090SN/A * All rights reserved. 47090SN/A * 57090SN/A * Redistribution and use in source and binary forms, with or without 67090SN/A * modification, are permitted provided that the following conditions are 77090SN/A * met: redistributions of source code must retain the above copyright 87090SN/A * notice, this list of conditions and the following disclaimer; 97090SN/A * redistributions in binary form must reproduce the above copyright 107090SN/A * notice, this list of conditions and the following disclaimer in the 117090SN/A * documentation and/or other materials provided with the distribution; 127090SN/A * neither the name of the copyright holders nor the names of its 134486SN/A * contributors may be used to endorse or promote products derived from 144486SN/A * this software without specific prior written permission. 154486SN/A * 164486SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 174486SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 184486SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 194486SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 204486SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 214486SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 224486SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 234486SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 244486SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 254486SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 264486SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274486SN/A * 284486SN/A * Authors: Ali Saidi 294486SN/A */ 304486SN/A 314486SN/A#include "arch/sparc/system.hh" 324486SN/A#include "arch/vtophys.hh" 334486SN/A#include "base/loader/object_file.hh" 344486SN/A#include "base/loader/symtab.hh" 354486SN/A#include "base/trace.hh" 364486SN/A#include "mem/physical.hh" 374486SN/A#include "params/SparcSystem.hh" 384486SN/A#include "sim/byteswap.hh" 397584SAli.Saidi@arm.com 407584SAli.Saidi@arm.comusing namespace BigEndianGuest; 417754SWilliam.Wang@arm.com 424486SN/ASparcSystem::SparcSystem(Params *p) 433630SN/A : System(p), sysTick(0) 443630SN/A{ 4511011SAndreas.Sandberg@ARM.com resetSymtab = new SymbolTable; 4611011SAndreas.Sandberg@ARM.com hypervisorSymtab = new SymbolTable; 477587SAli.Saidi@arm.com openbootSymtab = new SymbolTable; 4811244Sandreas.sandberg@arm.com nvramSymtab = new SymbolTable; 4910353SGeoffrey.Blake@arm.com hypervisorDescSymtab = new SymbolTable; 508212SAli.Saidi@ARM.com partitionDescSymtab = new SymbolTable; 515478SN/A 525478SN/A /** 537584SAli.Saidi@arm.com * Load the boot code, and hypervisor into memory. 548931Sandreas.hansson@arm.com */ 559525SAndreas.Sandberg@ARM.com // Read the reset binary 5610397Sstephan.diestelhorst@arm.com reset = createObjectFile(params()->reset_bin, true); 5711090Sandreas.sandberg@arm.com if (reset == NULL) 5811236Sandreas.sandberg@arm.com fatal("Could not load reset binary %s", params()->reset_bin); 593630SN/A 6011841Sandreas.sandberg@arm.com // Read the openboot binary 6111841Sandreas.sandberg@arm.com openboot = createObjectFile(params()->openboot_bin, true); 6211841Sandreas.sandberg@arm.com if (openboot == NULL) 6311841Sandreas.sandberg@arm.com fatal("Could not load openboot bianry %s", params()->openboot_bin); 6411841Sandreas.sandberg@arm.com 6511841Sandreas.sandberg@arm.com // Read the hypervisor binary 6611841Sandreas.sandberg@arm.com hypervisor = createObjectFile(params()->hypervisor_bin, true); 6711841Sandreas.sandberg@arm.com if (hypervisor == NULL) 6811841Sandreas.sandberg@arm.com fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 6911841Sandreas.sandberg@arm.com 7011841Sandreas.sandberg@arm.com // Read the nvram image 7111841Sandreas.sandberg@arm.com nvram = createObjectFile(params()->nvram_bin, true); 729806Sstever@gmail.com if (nvram == NULL) 739806Sstever@gmail.com fatal("Could not load nvram image %s", params()->nvram_bin); 747584SAli.Saidi@arm.com 759338SAndreas.Sandberg@arm.com // Read the hypervisor description image 767584SAli.Saidi@arm.com hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true); 773898SN/A if (hypervisor_desc == NULL) 789806Sstever@gmail.com fatal("Could not load hypervisor description image %s", 797950SAli.Saidi@ARM.com params()->hypervisor_desc_bin); 807950SAli.Saidi@ARM.com 819338SAndreas.Sandberg@arm.com // Read the partition description image 829525SAndreas.Sandberg@ARM.com partition_desc = createObjectFile(params()->partition_desc_bin, true); 837950SAli.Saidi@ARM.com if (partition_desc == NULL) 847950SAli.Saidi@ARM.com fatal("Could not load partition description image %s", 857950SAli.Saidi@ARM.com params()->partition_desc_bin); 867950SAli.Saidi@ARM.com 877587SAli.Saidi@arm.com // load symbols 887587SAli.Saidi@arm.com if (!reset->loadGlobalSymbols(resetSymtab)) 897587SAli.Saidi@arm.com panic("could not load reset symbols\n"); 909338SAndreas.Sandberg@arm.com 917753SWilliam.Wang@arm.com if (!openboot->loadGlobalSymbols(openbootSymtab)) 927753SWilliam.Wang@arm.com panic("could not load openboot symbols\n"); 939525SAndreas.Sandberg@ARM.com 947753SWilliam.Wang@arm.com if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 957587SAli.Saidi@arm.com panic("could not load hypervisor symbols\n"); 967587SAli.Saidi@arm.com 978282SAli.Saidi@ARM.com if (!nvram->loadLocalSymbols(nvramSymtab)) 988282SAli.Saidi@ARM.com panic("could not load nvram symbols\n"); 999338SAndreas.Sandberg@arm.com 1008282SAli.Saidi@ARM.com if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab)) 10111296Sandreas.sandberg@arm.com panic("could not load hypervisor description symbols\n"); 10211296Sandreas.sandberg@arm.com 10311296Sandreas.sandberg@arm.com if (!partition_desc->loadLocalSymbols(partitionDescSymtab)) 10411296Sandreas.sandberg@arm.com panic("could not load partition description symbols\n"); 10511296Sandreas.sandberg@arm.com 10611296Sandreas.sandberg@arm.com // load symbols into debug table 10711296Sandreas.sandberg@arm.com if (!reset->loadGlobalSymbols(debugSymbolTable)) 10811296Sandreas.sandberg@arm.com panic("could not load reset symbols\n"); 10911296Sandreas.sandberg@arm.com 11011296Sandreas.sandberg@arm.com if (!openboot->loadGlobalSymbols(debugSymbolTable)) 11111296Sandreas.sandberg@arm.com panic("could not load openboot symbols\n"); 11211296Sandreas.sandberg@arm.com 11311296Sandreas.sandberg@arm.com if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 11411296Sandreas.sandberg@arm.com panic("could not load hypervisor symbols\n"); 1157584SAli.Saidi@arm.com 1167584SAli.Saidi@arm.com // Strip off the rom address so when the hypervisor is copied into memory we 1179338SAndreas.Sandberg@arm.com // have symbols still 1188524SAli.Saidi@ARM.com if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF)) 1198524SAli.Saidi@ARM.com panic("could not load hypervisor symbols\n"); 1208299Schander.sudanthi@arm.com 1217584SAli.Saidi@arm.com if (!nvram->loadGlobalSymbols(debugSymbolTable)) 12211011SAndreas.Sandberg@ARM.com panic("could not load reset symbols\n"); 12311011SAndreas.Sandberg@ARM.com 12411011SAndreas.Sandberg@ARM.com if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable)) 12511011SAndreas.Sandberg@ARM.com panic("could not load hypervisor description symbols\n"); 12611011SAndreas.Sandberg@ARM.com 12711011SAndreas.Sandberg@ARM.com if (!partition_desc->loadLocalSymbols(debugSymbolTable)) 12811011SAndreas.Sandberg@ARM.com panic("could not load partition description symbols\n"); 12911011SAndreas.Sandberg@ARM.com 13011011SAndreas.Sandberg@ARM.com} 13111011SAndreas.Sandberg@ARM.com 13211011SAndreas.Sandberg@ARM.comvoid 13311011SAndreas.Sandberg@ARM.comSparcSystem::initState() 13411011SAndreas.Sandberg@ARM.com{ 13511011SAndreas.Sandberg@ARM.com // Call the initialisation of the super class 13611011SAndreas.Sandberg@ARM.com System::initState(); 13711011SAndreas.Sandberg@ARM.com 13811011SAndreas.Sandberg@ARM.com // Load reset binary into memory 13911011SAndreas.Sandberg@ARM.com reset->setTextBase(params()->reset_addr); 14011011SAndreas.Sandberg@ARM.com reset->loadSections(physProxy); 14111011SAndreas.Sandberg@ARM.com // Load the openboot binary 14211011SAndreas.Sandberg@ARM.com openboot->setTextBase(params()->openboot_addr); 14311011SAndreas.Sandberg@ARM.com openboot->loadSections(physProxy); 14411421Sdavid.guillen@arm.com // Load the hypervisor binary 14511421Sdavid.guillen@arm.com hypervisor->setTextBase(params()->hypervisor_addr); 14611421Sdavid.guillen@arm.com hypervisor->loadSections(physProxy); 14711421Sdavid.guillen@arm.com // Load the nvram image 14811421Sdavid.guillen@arm.com nvram->setTextBase(params()->nvram_addr); 14911421Sdavid.guillen@arm.com nvram->loadSections(physProxy); 15011421Sdavid.guillen@arm.com // Load the hypervisor description image 15111421Sdavid.guillen@arm.com hypervisor_desc->setTextBase(params()->hypervisor_desc_addr); 15211421Sdavid.guillen@arm.com hypervisor_desc->loadSections(physProxy); 15311421Sdavid.guillen@arm.com // Load the partition description image 15411421Sdavid.guillen@arm.com partition_desc->setTextBase(params()->partition_desc_addr); 15511421Sdavid.guillen@arm.com partition_desc->loadSections(physProxy); 15611421Sdavid.guillen@arm.com 15711421Sdavid.guillen@arm.com 15811421Sdavid.guillen@arm.com // @todo any fixup code over writing data in binaries on setting break 15911421Sdavid.guillen@arm.com // events on functions should happen here. 16011236Sandreas.sandberg@arm.com 16111236Sandreas.sandberg@arm.com} 16211236Sandreas.sandberg@arm.com 16311236Sandreas.sandberg@arm.comSparcSystem::~SparcSystem() 16411236Sandreas.sandberg@arm.com{ 16511236Sandreas.sandberg@arm.com delete resetSymtab; 16611236Sandreas.sandberg@arm.com delete hypervisorSymtab; 16711236Sandreas.sandberg@arm.com delete openbootSymtab; 16811236Sandreas.sandberg@arm.com delete nvramSymtab; 16911011SAndreas.Sandberg@ARM.com delete hypervisorDescSymtab; 17011011SAndreas.Sandberg@ARM.com delete partitionDescSymtab; 17111421Sdavid.guillen@arm.com delete reset; 17211421Sdavid.guillen@arm.com delete openboot; 17311421Sdavid.guillen@arm.com delete hypervisor; 17411236Sandreas.sandberg@arm.com delete nvram; 17511236Sandreas.sandberg@arm.com delete hypervisor_desc; 17611236Sandreas.sandberg@arm.com delete partition_desc; 17711236Sandreas.sandberg@arm.com} 17811236Sandreas.sandberg@arm.com 17911421Sdavid.guillen@arm.comvoid 18011421Sdavid.guillen@arm.comSparcSystem::serialize(std::ostream &os) 18111421Sdavid.guillen@arm.com{ 18211236Sandreas.sandberg@arm.com System::serialize(os); 18311236Sandreas.sandberg@arm.com resetSymtab->serialize("reset_symtab", os); 18411236Sandreas.sandberg@arm.com hypervisorSymtab->serialize("hypervisor_symtab", os); 18511236Sandreas.sandberg@arm.com openbootSymtab->serialize("openboot_symtab", os); 18611236Sandreas.sandberg@arm.com nvramSymtab->serialize("nvram_symtab", os); 18711236Sandreas.sandberg@arm.com hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os); 18811236Sandreas.sandberg@arm.com partitionDescSymtab->serialize("partition_desc_symtab", os); 18911236Sandreas.sandberg@arm.com} 19011236Sandreas.sandberg@arm.com 19111011SAndreas.Sandberg@ARM.com 19211011SAndreas.Sandberg@ARM.comvoid 19311236Sandreas.sandberg@arm.comSparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 19411236Sandreas.sandberg@arm.com{ 19511236Sandreas.sandberg@arm.com System::unserialize(cp,section); 19611236Sandreas.sandberg@arm.com resetSymtab->unserialize("reset_symtab", cp, section); 19711236Sandreas.sandberg@arm.com hypervisorSymtab->unserialize("hypervisor_symtab", cp, section); 19811236Sandreas.sandberg@arm.com openbootSymtab->unserialize("openboot_symtab", cp, section); 19911236Sandreas.sandberg@arm.com nvramSymtab->unserialize("nvram_symtab", cp, section); 20011011SAndreas.Sandberg@ARM.com hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section); 20110037SARM gem5 Developers partitionDescSymtab->unserialize("partition_desc_symtab", cp, section); 20210037SARM gem5 Developers} 20310037SARM gem5 Developers 20410037SARM gem5 DevelopersSparcSystem * 20510037SARM gem5 DevelopersSparcSystemParams::create() 20610037SARM gem5 Developers{ 20710037SARM gem5 Developers return new SparcSystem(this); 20810037SARM gem5 Developers} 20910037SARM gem5 Developers