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