system.cc revision 3584
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) 453584Ssaidi@eecs.umich.edu : System(p), sysTick(0),funcRomPort(p->name + "-fport") 462650Ssaidi@eecs.umich.edu 472567SN/A{ 482567SN/A resetSymtab = new SymbolTable; 492567SN/A hypervisorSymtab = new SymbolTable; 502567SN/A openbootSymtab = new SymbolTable; 512567SN/A 523584Ssaidi@eecs.umich.edu Port *rom_port; 533584Ssaidi@eecs.umich.edu rom_port = params()->rom->getPort("functional"); 543584Ssaidi@eecs.umich.edu funcRomPort.setPeer(rom_port); 553584Ssaidi@eecs.umich.edu rom_port->setPeer(&funcRomPort); 562567SN/A 572567SN/A /** 582567SN/A * Load the boot code, and hypervisor into memory. 592567SN/A */ 602567SN/A // Read the reset binary 613584Ssaidi@eecs.umich.edu reset = createObjectFile(params()->reset_bin, true); 622567SN/A if (reset == NULL) 632567SN/A fatal("Could not load reset binary %s", params()->reset_bin); 642567SN/A 652567SN/A // Read the openboot binary 663584Ssaidi@eecs.umich.edu openboot = createObjectFile(params()->openboot_bin, true); 672567SN/A if (openboot == NULL) 682567SN/A fatal("Could not load openboot bianry %s", params()->openboot_bin); 692567SN/A 702567SN/A // Read the hypervisor binary 713584Ssaidi@eecs.umich.edu hypervisor = createObjectFile(params()->hypervisor_bin, true); 722567SN/A if (hypervisor == NULL) 732567SN/A fatal("Could not load hypervisor binary %s", params()->hypervisor_bin); 742567SN/A 752567SN/A 762567SN/A // Load reset binary into memory 773584Ssaidi@eecs.umich.edu reset->setTextBase(params()->reset_addr); 783584Ssaidi@eecs.umich.edu reset->loadSections(&funcRomPort); 792567SN/A // Load the openboot binary 803584Ssaidi@eecs.umich.edu openboot->setTextBase(params()->openboot_addr); 813584Ssaidi@eecs.umich.edu openboot->loadSections(&funcRomPort); 822567SN/A // Load the hypervisor binary 833584Ssaidi@eecs.umich.edu hypervisor->setTextBase(params()->hypervisor_addr); 843584Ssaidi@eecs.umich.edu hypervisor->loadSections(&funcRomPort); 852567SN/A 862567SN/A // load symbols 873527Sgblack@eecs.umich.edu if (!reset->loadGlobalSymbols(resetSymtab)) 882567SN/A panic("could not load reset symbols\n"); 892567SN/A 902567SN/A if (!openboot->loadGlobalSymbols(openbootSymtab)) 912567SN/A panic("could not load openboot symbols\n"); 922567SN/A 932567SN/A if (!hypervisor->loadLocalSymbols(hypervisorSymtab)) 942567SN/A panic("could not load hypervisor symbols\n"); 952567SN/A 962567SN/A // load symbols into debug table 972567SN/A if (!reset->loadGlobalSymbols(debugSymbolTable)) 982567SN/A panic("could not load reset symbols\n"); 992567SN/A 1002567SN/A if (!openboot->loadGlobalSymbols(debugSymbolTable)) 1012567SN/A panic("could not load openboot symbols\n"); 1022567SN/A 1032567SN/A if (!hypervisor->loadLocalSymbols(debugSymbolTable)) 1042567SN/A panic("could not load hypervisor symbols\n"); 1052567SN/A 1062567SN/A 1072567SN/A // @todo any fixup code over writing data in binaries on setting break 1082567SN/A // events on functions should happen here. 1092567SN/A 1102567SN/A} 1112567SN/A 1122567SN/ASparcSystem::~SparcSystem() 1132567SN/A{ 1142567SN/A delete resetSymtab; 1152567SN/A delete hypervisorSymtab; 1162567SN/A delete openbootSymtab; 1172567SN/A delete reset; 1182567SN/A delete openboot; 1192567SN/A delete hypervisor; 1202567SN/A} 1212567SN/A 1222567SN/Abool 1232567SN/ASparcSystem::breakpoint() 1242567SN/A{ 1252567SN/A panic("Need to implement"); 1262567SN/A} 1272567SN/A 1282567SN/Avoid 1292567SN/ASparcSystem::serialize(std::ostream &os) 1302567SN/A{ 1312567SN/A System::serialize(os); 1322567SN/A resetSymtab->serialize("reset_symtab", os); 1332567SN/A hypervisorSymtab->serialize("hypervisor_symtab", os); 1342567SN/A openbootSymtab->serialize("openboot_symtab", os); 1352567SN/A} 1362567SN/A 1372567SN/A 1382567SN/Avoid 1392567SN/ASparcSystem::unserialize(Checkpoint *cp, const std::string §ion) 1402567SN/A{ 1412567SN/A System::unserialize(cp,section); 1422567SN/A resetSymtab->unserialize("reset_symtab", cp, section); 1432567SN/A hypervisorSymtab->unserialize("hypervisor_symtab", cp, section); 1442567SN/A openbootSymtab->unserialize("openboot_symtab", cp, section); 1452567SN/A} 1462567SN/A 1472567SN/A 1482567SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 1492567SN/A 1502567SN/A SimObjectParam<PhysicalMemory *> physmem; 1513584Ssaidi@eecs.umich.edu SimObjectParam<PhysicalMemory *> rom; 1522902Ssaidi@eecs.umich.edu SimpleEnumParam<System::MemoryMode> mem_mode; 1532567SN/A 1543584Ssaidi@eecs.umich.edu Param<Addr> reset_addr; 1553584Ssaidi@eecs.umich.edu Param<Addr> hypervisor_addr; 1563584Ssaidi@eecs.umich.edu Param<Addr> openboot_addr; 1573584Ssaidi@eecs.umich.edu 1582567SN/A Param<std::string> kernel; 1592567SN/A Param<std::string> reset_bin; 1602567SN/A Param<std::string> hypervisor_bin; 1612567SN/A Param<std::string> openboot_bin; 1622567SN/A 1633527Sgblack@eecs.umich.edu Param<Tick> boot_cpu_frequency; 1642567SN/A Param<std::string> boot_osflags; 1652567SN/A Param<std::string> readfile; 1662567SN/A Param<unsigned int> init_param; 1672567SN/A 1682567SN/AEND_DECLARE_SIM_OBJECT_PARAMS(SparcSystem) 1692567SN/A 1702567SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(SparcSystem) 1712567SN/A 1722567SN/A INIT_PARAM(physmem, "phsyical memory"), 1733584Ssaidi@eecs.umich.edu INIT_PARAM(rom, "ROM for boot code"), 1742902Ssaidi@eecs.umich.edu INIT_ENUM_PARAM(mem_mode, "Memory Mode, (1=atomic, 2=timing)", 1752902Ssaidi@eecs.umich.edu System::MemoryModeStrings), 1763584Ssaidi@eecs.umich.edu 1773584Ssaidi@eecs.umich.edu INIT_PARAM(reset_addr, "Address that reset should be loaded at"), 1783584Ssaidi@eecs.umich.edu INIT_PARAM(hypervisor_addr, "Address that hypervisor should be loaded at"), 1793584Ssaidi@eecs.umich.edu INIT_PARAM(openboot_addr, "Address that openboot should be loaded at"), 1803584Ssaidi@eecs.umich.edu 1812567SN/A INIT_PARAM(kernel, "file that contains the kernel code"), 1822567SN/A INIT_PARAM(reset_bin, "file that contains the reset code"), 1832567SN/A INIT_PARAM(hypervisor_bin, "file that contains the hypervisor code"), 1842567SN/A INIT_PARAM(openboot_bin, "file that contains the openboot code"), 1853527Sgblack@eecs.umich.edu INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"), 1862567SN/A INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", 1872567SN/A "a"), 1882567SN/A INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), 1893527Sgblack@eecs.umich.edu INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0) 1902567SN/A 1912567SN/AEND_INIT_SIM_OBJECT_PARAMS(SparcSystem) 1922567SN/A 1932567SN/ACREATE_SIM_OBJECT(SparcSystem) 1942567SN/A{ 1952567SN/A SparcSystem::Params *p = new SparcSystem::Params; 1962567SN/A p->name = getInstanceName(); 1972567SN/A p->boot_cpu_frequency = boot_cpu_frequency; 1982567SN/A p->physmem = physmem; 1993584Ssaidi@eecs.umich.edu p->rom = rom; 2002902Ssaidi@eecs.umich.edu p->mem_mode = mem_mode; 2012567SN/A p->kernel_path = kernel; 2023584Ssaidi@eecs.umich.edu p->reset_addr = reset_addr; 2033584Ssaidi@eecs.umich.edu p->hypervisor_addr = hypervisor_addr; 2043584Ssaidi@eecs.umich.edu p->openboot_addr = openboot_addr; 2052567SN/A p->reset_bin = reset_bin; 2062567SN/A p->hypervisor_bin = hypervisor_bin; 2072567SN/A p->openboot_bin = openboot_bin; 2082567SN/A p->boot_osflags = boot_osflags; 2092567SN/A p->init_param = init_param; 2102567SN/A p->readfile = readfile; 2112567SN/A return new SparcSystem(p); 2122567SN/A} 2132567SN/A 2142567SN/AREGISTER_SIM_OBJECT("SparcSystem", SparcSystem) 2152567SN/A 2162567SN/A 217