system.cc revision 2650
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.
272567SN/A */
282567SN/A
292567SN/A#include "arch/sparc/system.hh"
302567SN/A#include "arch/vtophys.hh"
312567SN/A#include "base/remote_gdb.hh"
322567SN/A#include "base/loader/object_file.hh"
332567SN/A#include "base/loader/symtab.hh"
342567SN/A#include "base/trace.hh"
352567SN/A#include "mem/physical.hh"
362567SN/A#include "sim/byteswap.hh"
372567SN/A#include "sim/builder.hh"
382567SN/A
392567SN/A
402567SN/Ausing namespace BigEndianGuest;
412567SN/A
422567SN/ASparcSystem::SparcSystem(Params *p)
432650Ssaidi@eecs.umich.edu    : System(p), sysTick(0)
442650Ssaidi@eecs.umich.edu
452567SN/A{
462567SN/A    resetSymtab = new SymbolTable;
472567SN/A    hypervisorSymtab = new SymbolTable;
482567SN/A    openbootSymtab = new SymbolTable;
492567SN/A
502567SN/A
512567SN/A    /**
522567SN/A     * Load the boot code, and hypervisor into memory.
532567SN/A     */
542567SN/A    // Read the reset binary
552567SN/A    reset = createObjectFile(params()->reset_bin);
562567SN/A    if (reset == NULL)
572567SN/A        fatal("Could not load reset binary %s", params()->reset_bin);
582567SN/A
592567SN/A    // Read the openboot binary
602567SN/A    openboot = createObjectFile(params()->openboot_bin);
612567SN/A    if (openboot == NULL)
622567SN/A        fatal("Could not load openboot bianry %s", params()->openboot_bin);
632567SN/A
642567SN/A    // Read the hypervisor binary
652567SN/A    hypervisor = createObjectFile(params()->hypervisor_bin);
662567SN/A    if (hypervisor == NULL)
672567SN/A        fatal("Could not load hypervisor binary %s", params()->hypervisor_bin);
682567SN/A
692567SN/A
702567SN/A    // Load reset binary into memory
712567SN/A    reset->loadSections(&functionalPort, SparcISA::LoadAddrMask);
722567SN/A    // Load the openboot binary
732567SN/A    openboot->loadSections(&functionalPort, SparcISA::LoadAddrMask);
742567SN/A    // Load the hypervisor binary
752567SN/A    hypervisor->loadSections(&functionalPort, SparcISA::LoadAddrMask);
762567SN/A
772567SN/A    // load symbols
782567SN/A    if (!reset->loadGlobalSymbols(reset))
792567SN/A        panic("could not load reset symbols\n");
802567SN/A
812567SN/A    if (!openboot->loadGlobalSymbols(openbootSymtab))
822567SN/A        panic("could not load openboot symbols\n");
832567SN/A
842567SN/A    if (!hypervisor->loadLocalSymbols(hypervisorSymtab))
852567SN/A        panic("could not load hypervisor symbols\n");
862567SN/A
872567SN/A    // load symbols into debug table
882567SN/A    if (!reset->loadGlobalSymbols(debugSymbolTable))
892567SN/A        panic("could not load reset symbols\n");
902567SN/A
912567SN/A    if (!openboot->loadGlobalSymbols(debugSymbolTable))
922567SN/A        panic("could not load openboot symbols\n");
932567SN/A
942567SN/A    if (!hypervisor->loadLocalSymbols(debugSymbolTable))
952567SN/A        panic("could not load hypervisor symbols\n");
962567SN/A
972567SN/A
982567SN/A    // @todo any fixup code over writing data in binaries on setting break
992567SN/A    // events on functions should happen here.
1002567SN/A
1012567SN/A}
1022567SN/A
1032567SN/ASparcSystem::~SparcSystem()
1042567SN/A{
1052567SN/A    delete resetSymtab;
1062567SN/A    delete hypervisorSymtab;
1072567SN/A    delete openbootSymtab;
1082567SN/A    delete reset;
1092567SN/A    delete openboot;
1102567SN/A    delete hypervisor;
1112567SN/A}
1122567SN/A
1132567SN/Abool
1142567SN/ASparcSystem::breakpoint()
1152567SN/A{
1162567SN/A    panic("Need to implement");
1172567SN/A}
1182567SN/A
1192567SN/Avoid
1202567SN/ASparcSystem::serialize(std::ostream &os)
1212567SN/A{
1222567SN/A    System::serialize(os);
1232567SN/A    resetSymtab->serialize("reset_symtab", os);
1242567SN/A    hypervisorSymtab->serialize("hypervisor_symtab", os);
1252567SN/A    openbootSymtab->serialize("openboot_symtab", os);
1262567SN/A}
1272567SN/A
1282567SN/A
1292567SN/Avoid
1302567SN/ASparcSystem::unserialize(Checkpoint *cp, const std::string &section)
1312567SN/A{
1322567SN/A    System::unserialize(cp,section);
1332567SN/A    resetSymtab->unserialize("reset_symtab", cp, section);
1342567SN/A    hypervisorSymtab->unserialize("hypervisor_symtab", cp, section);
1352567SN/A    openbootSymtab->unserialize("openboot_symtab", cp, section);
1362567SN/A}
1372567SN/A
1382567SN/A
1392567SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(SparcSystem)
1402567SN/A
1412567SN/A    SimObjectParam<PhysicalMemory *> physmem;
1422567SN/A
1432567SN/A    Param<std::string> kernel;
1442567SN/A    Param<std::string> reset_bin;
1452567SN/A    Param<std::string> hypervisor_bin;
1462567SN/A    Param<std::string> openboot_bin;
1472567SN/A
1482567SN/A    Param<std::string> boot_osflags;
1492567SN/A    Param<std::string> readfile;
1502567SN/A    Param<unsigned int> init_param;
1512567SN/A
1522567SN/A    Param<bool> bin;
1532567SN/A    VectorParam<std::string> binned_fns;
1542567SN/A    Param<bool> bin_int;
1552567SN/A
1562567SN/AEND_DECLARE_SIM_OBJECT_PARAMS(SparcSystem)
1572567SN/A
1582567SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem)
1592567SN/A
1602567SN/A    INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"),
1612567SN/A    INIT_PARAM(physmem, "phsyical memory"),
1622567SN/A    INIT_PARAM(kernel, "file that contains the kernel code"),
1632567SN/A    INIT_PARAM(reset_bin, "file that contains the reset code"),
1642567SN/A    INIT_PARAM(hypervisor_bin, "file that contains the hypervisor code"),
1652567SN/A    INIT_PARAM(openboot_bin, "file that contains the openboot code"),
1662567SN/A    INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot",
1672567SN/A                    "a"),
1682567SN/A    INIT_PARAM_DFLT(readfile, "file to read startup script from", ""),
1692567SN/A    INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0),
1702567SN/A    INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34),
1712567SN/A    INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10),
1722567SN/A    INIT_PARAM_DFLT(bin, "is this system to be binned", false),
1732567SN/A    INIT_PARAM(binned_fns, "functions to be broken down and binned"),
1742567SN/A    INIT_PARAM_DFLT(bin_int, "is interrupt code binned seperately?", true)
1752567SN/A
1762567SN/AEND_INIT_SIM_OBJECT_PARAMS(SparcSystem)
1772567SN/A
1782567SN/ACREATE_SIM_OBJECT(SparcSystem)
1792567SN/A{
1802567SN/A    SparcSystem::Params *p = new SparcSystem::Params;
1812567SN/A    p->name = getInstanceName();
1822567SN/A    p->boot_cpu_frequency = boot_cpu_frequency;
1832567SN/A    p->physmem = physmem;
1842567SN/A    p->kernel_path = kernel;
1852567SN/A    p->reset_bin = reset_bin;
1862567SN/A    p->hypervisor_bin = hypervisor_bin;
1872567SN/A    p->openboot_bin = openboot_bin;
1882567SN/A    p->boot_osflags = boot_osflags;
1892567SN/A    p->init_param = init_param;
1902567SN/A    p->readfile = readfile;
1912567SN/A    p->system_type = system_type;
1922567SN/A    p->system_rev = system_rev;
1932567SN/A    p->bin = bin;
1942567SN/A    p->binned_fns = binned_fns;
1952567SN/A    p->bin_int = bin_int;
1962567SN/A    return new SparcSystem(p);
1972567SN/A}
1982567SN/A
1992567SN/AREGISTER_SIM_OBJECT("SparcSystem", SparcSystem)
2002567SN/A
2012567SN/A
202