system.cc revision 8885
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;
513745Sgblack@eecs.umich.edu
522567SN/A    /**
532567SN/A     * Load the boot code, and hypervisor into memory.
542567SN/A     */
552567SN/A    // Read the reset binary
563584Ssaidi@eecs.umich.edu    reset = createObjectFile(params()->reset_bin, true);
572567SN/A    if (reset == NULL)
582567SN/A        fatal("Could not load reset binary %s", params()->reset_bin);
592567SN/A
602567SN/A    // Read the openboot binary
613584Ssaidi@eecs.umich.edu    openboot = createObjectFile(params()->openboot_bin, true);
622567SN/A    if (openboot == NULL)
632567SN/A        fatal("Could not load openboot bianry %s", params()->openboot_bin);
642567SN/A
652567SN/A    // Read the hypervisor binary
663584Ssaidi@eecs.umich.edu    hypervisor = createObjectFile(params()->hypervisor_bin, true);
672567SN/A    if (hypervisor == NULL)
682567SN/A        fatal("Could not load hypervisor binary %s", params()->hypervisor_bin);
692567SN/A
703745Sgblack@eecs.umich.edu    // Read the nvram image
713745Sgblack@eecs.umich.edu    nvram = createObjectFile(params()->nvram_bin, true);
723745Sgblack@eecs.umich.edu    if (nvram == NULL)
733745Sgblack@eecs.umich.edu        fatal("Could not load nvram image %s", params()->nvram_bin);
743745Sgblack@eecs.umich.edu
753745Sgblack@eecs.umich.edu    // Read the hypervisor description image
763745Sgblack@eecs.umich.edu    hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true);
773745Sgblack@eecs.umich.edu    if (hypervisor_desc == NULL)
783745Sgblack@eecs.umich.edu        fatal("Could not load hypervisor description image %s",
793745Sgblack@eecs.umich.edu                params()->hypervisor_desc_bin);
803745Sgblack@eecs.umich.edu
813745Sgblack@eecs.umich.edu    // Read the partition description image
823745Sgblack@eecs.umich.edu    partition_desc = createObjectFile(params()->partition_desc_bin, true);
833745Sgblack@eecs.umich.edu    if (partition_desc == NULL)
843745Sgblack@eecs.umich.edu        fatal("Could not load partition description image %s",
853745Sgblack@eecs.umich.edu                params()->partition_desc_bin);
863745Sgblack@eecs.umich.edu
872567SN/A    // load symbols
883527Sgblack@eecs.umich.edu    if (!reset->loadGlobalSymbols(resetSymtab))
892567SN/A        panic("could not load reset symbols\n");
902567SN/A
912567SN/A    if (!openboot->loadGlobalSymbols(openbootSymtab))
922567SN/A        panic("could not load openboot symbols\n");
932567SN/A
942567SN/A    if (!hypervisor->loadLocalSymbols(hypervisorSymtab))
952567SN/A        panic("could not load hypervisor symbols\n");
962567SN/A
973745Sgblack@eecs.umich.edu    if (!nvram->loadLocalSymbols(nvramSymtab))
983745Sgblack@eecs.umich.edu        panic("could not load nvram symbols\n");
993745Sgblack@eecs.umich.edu
1003745Sgblack@eecs.umich.edu    if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab))
1013745Sgblack@eecs.umich.edu        panic("could not load hypervisor description symbols\n");
1023745Sgblack@eecs.umich.edu
1033745Sgblack@eecs.umich.edu    if (!partition_desc->loadLocalSymbols(partitionDescSymtab))
1043745Sgblack@eecs.umich.edu        panic("could not load partition description symbols\n");
1053745Sgblack@eecs.umich.edu
1062567SN/A    // load symbols into debug table
1072567SN/A    if (!reset->loadGlobalSymbols(debugSymbolTable))
1082567SN/A        panic("could not load reset symbols\n");
1092567SN/A
1102567SN/A    if (!openboot->loadGlobalSymbols(debugSymbolTable))
1112567SN/A        panic("could not load openboot symbols\n");
1122567SN/A
1132567SN/A    if (!hypervisor->loadLocalSymbols(debugSymbolTable))
1142567SN/A        panic("could not load hypervisor symbols\n");
1152567SN/A
1163812Ssaidi@eecs.umich.edu    // Strip off the rom address so when the hypervisor is copied into memory we
1173812Ssaidi@eecs.umich.edu    // have symbols still
1183812Ssaidi@eecs.umich.edu    if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF))
1193812Ssaidi@eecs.umich.edu        panic("could not load hypervisor symbols\n");
1203812Ssaidi@eecs.umich.edu
1213745Sgblack@eecs.umich.edu    if (!nvram->loadGlobalSymbols(debugSymbolTable))
1223745Sgblack@eecs.umich.edu        panic("could not load reset symbols\n");
1233745Sgblack@eecs.umich.edu
1243745Sgblack@eecs.umich.edu    if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable))
1253745Sgblack@eecs.umich.edu        panic("could not load hypervisor description symbols\n");
1263745Sgblack@eecs.umich.edu
1273745Sgblack@eecs.umich.edu    if (!partition_desc->loadLocalSymbols(debugSymbolTable))
1283745Sgblack@eecs.umich.edu        panic("could not load partition description symbols\n");
1293745Sgblack@eecs.umich.edu
1308885SAli.Saidi@ARM.com}
1318885SAli.Saidi@ARM.com
1328885SAli.Saidi@ARM.comvoid
1338885SAli.Saidi@ARM.comSparcSystem::initState()
1348885SAli.Saidi@ARM.com{
1358885SAli.Saidi@ARM.com    // Call the initialisation of the super class
1368885SAli.Saidi@ARM.com    System::initState();
1378885SAli.Saidi@ARM.com
1388885SAli.Saidi@ARM.com    // Load reset binary into memory
1398885SAli.Saidi@ARM.com    reset->setTextBase(params()->reset_addr);
1408885SAli.Saidi@ARM.com    reset->loadSections(physProxy);
1418885SAli.Saidi@ARM.com    // Load the openboot binary
1428885SAli.Saidi@ARM.com    openboot->setTextBase(params()->openboot_addr);
1438885SAli.Saidi@ARM.com    openboot->loadSections(physProxy);
1448885SAli.Saidi@ARM.com    // Load the hypervisor binary
1458885SAli.Saidi@ARM.com    hypervisor->setTextBase(params()->hypervisor_addr);
1468885SAli.Saidi@ARM.com    hypervisor->loadSections(physProxy);
1478885SAli.Saidi@ARM.com    // Load the nvram image
1488885SAli.Saidi@ARM.com    nvram->setTextBase(params()->nvram_addr);
1498885SAli.Saidi@ARM.com    nvram->loadSections(physProxy);
1508885SAli.Saidi@ARM.com    // Load the hypervisor description image
1518885SAli.Saidi@ARM.com    hypervisor_desc->setTextBase(params()->hypervisor_desc_addr);
1528885SAli.Saidi@ARM.com    hypervisor_desc->loadSections(physProxy);
1538885SAli.Saidi@ARM.com    // Load the partition description image
1548885SAli.Saidi@ARM.com    partition_desc->setTextBase(params()->partition_desc_addr);
1558885SAli.Saidi@ARM.com    partition_desc->loadSections(physProxy);
1568885SAli.Saidi@ARM.com
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 &section)
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