⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 system.cc

📁 M5,一个功能强大的多处理器系统模拟器.很多针对处理器架构,性能的研究都使用它作为模拟平台
💻 CC
字号:
/* * Copyright (c) 2002, 2003, 2004, 2005, 2006 * The Regents of The University of Michigan * All Rights Reserved * * This code is part of the M5 simulator. * * Permission is granted to use, copy, create derivative works and * redistribute this software and such derivative works for any * purpose, so long as the copyright notice above, this grant of * permission, and the disclaimer below appear in all copies made; and * so long as the name of The University of Michigan is not used in * any advertising or publicity pertaining to the use or distribution * of this software without specific, written prior authorization. * * THIS SOFTWARE IS PROVIDED AS IS, WITHOUT REPRESENTATION FROM THE * UNIVERSITY OF MICHIGAN AS TO ITS FITNESS FOR ANY PURPOSE, AND * WITHOUT WARRANTY BY THE UNIVERSITY OF MICHIGAN OF ANY KIND, EITHER * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. THE REGENTS OF THE UNIVERSITY OF MICHIGAN SHALL NOT BE * LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, SPECIAL, INDIRECT, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WITH RESPECT TO ANY CLAIM * ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SOFTWARE, EVEN * IF IT HAS BEEN OR IS HEREAFTER ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES. * * Authors: Ali G. Saidi */#include "arch/sparc/system.hh"#include "arch/vtophys.hh"#include "base/remote_gdb.hh"#include "base/loader/object_file.hh"#include "base/loader/symtab.hh"#include "base/trace.hh"#include "mem/physical.hh"#include "params/SparcSystem.hh"#include "sim/byteswap.hh"using namespace BigEndianGuest;SparcSystem::SparcSystem(Params *p)    : System(p), sysTick(0),funcRomPort(p->name + "-fromport"),    funcNvramPort(p->name + "-fnvramport"),    funcHypDescPort(p->name + "-fhypdescport"),    funcPartDescPort(p->name + "-fpartdescport"){    resetSymtab = new SymbolTable;    hypervisorSymtab = new SymbolTable;    openbootSymtab = new SymbolTable;    nvramSymtab = new SymbolTable;    hypervisorDescSymtab = new SymbolTable;    partitionDescSymtab = new SymbolTable;    Port *rom_port;    rom_port = params()->rom->getPort("functional");    funcRomPort.setPeer(rom_port);    rom_port->setPeer(&funcRomPort);    rom_port = params()->nvram->getPort("functional");    funcNvramPort.setPeer(rom_port);    rom_port->setPeer(&funcNvramPort);    rom_port = params()->hypervisor_desc->getPort("functional");    funcHypDescPort.setPeer(rom_port);    rom_port->setPeer(&funcHypDescPort);    rom_port = params()->partition_desc->getPort("functional");    funcPartDescPort.setPeer(rom_port);    rom_port->setPeer(&funcPartDescPort);    /**     * Load the boot code, and hypervisor into memory.     */    // Read the reset binary    reset = createObjectFile(params()->reset_bin, true);    if (reset == NULL)        fatal("Could not load reset binary %s", params()->reset_bin);    // Read the openboot binary    openboot = createObjectFile(params()->openboot_bin, true);    if (openboot == NULL)        fatal("Could not load openboot bianry %s", params()->openboot_bin);    // Read the hypervisor binary    hypervisor = createObjectFile(params()->hypervisor_bin, true);    if (hypervisor == NULL)        fatal("Could not load hypervisor binary %s", params()->hypervisor_bin);    // Read the nvram image    nvram = createObjectFile(params()->nvram_bin, true);    if (nvram == NULL)        fatal("Could not load nvram image %s", params()->nvram_bin);    // Read the hypervisor description image    hypervisor_desc = createObjectFile(params()->hypervisor_desc_bin, true);    if (hypervisor_desc == NULL)        fatal("Could not load hypervisor description image %s",                params()->hypervisor_desc_bin);    // Read the partition description image    partition_desc = createObjectFile(params()->partition_desc_bin, true);    if (partition_desc == NULL)        fatal("Could not load partition description image %s",                params()->partition_desc_bin);    // Load reset binary into memory    reset->setTextBase(params()->reset_addr);    reset->loadSections(&funcRomPort);    // Load the openboot binary    openboot->setTextBase(params()->openboot_addr);    openboot->loadSections(&funcRomPort);    // Load the hypervisor binary    hypervisor->setTextBase(params()->hypervisor_addr);    hypervisor->loadSections(&funcRomPort);    // Load the nvram image    nvram->setTextBase(params()->nvram_addr);    nvram->loadSections(&funcNvramPort);    // Load the hypervisor description image    hypervisor_desc->setTextBase(params()->hypervisor_desc_addr);    hypervisor_desc->loadSections(&funcHypDescPort);    // Load the partition description image    partition_desc->setTextBase(params()->partition_desc_addr);    partition_desc->loadSections(&funcPartDescPort);    // load symbols    if (!reset->loadGlobalSymbols(resetSymtab))        panic("could not load reset symbols\n");    if (!openboot->loadGlobalSymbols(openbootSymtab))        panic("could not load openboot symbols\n");    if (!hypervisor->loadLocalSymbols(hypervisorSymtab))        panic("could not load hypervisor symbols\n");    if (!nvram->loadLocalSymbols(nvramSymtab))        panic("could not load nvram symbols\n");    if (!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab))        panic("could not load hypervisor description symbols\n");    if (!partition_desc->loadLocalSymbols(partitionDescSymtab))        panic("could not load partition description symbols\n");    // load symbols into debug table    if (!reset->loadGlobalSymbols(debugSymbolTable))        panic("could not load reset symbols\n");    if (!openboot->loadGlobalSymbols(debugSymbolTable))        panic("could not load openboot symbols\n");    if (!hypervisor->loadLocalSymbols(debugSymbolTable))        panic("could not load hypervisor symbols\n");    // Strip off the rom address so when the hypervisor is copied into memory we    // have symbols still    if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0xFFFFFF))        panic("could not load hypervisor symbols\n");    if (!nvram->loadGlobalSymbols(debugSymbolTable))        panic("could not load reset symbols\n");    if (!hypervisor_desc->loadGlobalSymbols(debugSymbolTable))        panic("could not load hypervisor description symbols\n");    if (!partition_desc->loadLocalSymbols(debugSymbolTable))        panic("could not load partition description symbols\n");    // @todo any fixup code over writing data in binaries on setting break    // events on functions should happen here.}SparcSystem::~SparcSystem(){    delete resetSymtab;    delete hypervisorSymtab;    delete openbootSymtab;    delete nvramSymtab;    delete hypervisorDescSymtab;    delete partitionDescSymtab;    delete reset;    delete openboot;    delete hypervisor;    delete nvram;    delete hypervisor_desc;    delete partition_desc;}voidSparcSystem::serialize(std::ostream &os){    System::serialize(os);    resetSymtab->serialize("reset_symtab", os);    hypervisorSymtab->serialize("hypervisor_symtab", os);    openbootSymtab->serialize("openboot_symtab", os);    nvramSymtab->serialize("nvram_symtab", os);    hypervisorDescSymtab->serialize("hypervisor_desc_symtab", os);    partitionDescSymtab->serialize("partition_desc_symtab", os);}voidSparcSystem::unserialize(Checkpoint *cp, const std::string &section){    System::unserialize(cp,section);    resetSymtab->unserialize("reset_symtab", cp, section);    hypervisorSymtab->unserialize("hypervisor_symtab", cp, section);    openbootSymtab->unserialize("openboot_symtab", cp, section);    nvramSymtab->unserialize("nvram_symtab", cp, section);    hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp, section);    partitionDescSymtab->unserialize("partition_desc_symtab", cp, section);}SparcSystem *SparcSystemParams::create(){    return new SparcSystem(this);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -