From: Gabe Black Date: Sun, 29 Mar 2020 10:30:05 +0000 (-0700) Subject: sparc,configs: Initialize ROMs directly, not with the workload. X-Git-Tag: v20.0.0.0~190 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c9cf3077e28d358eb95928ee228caea511b012eb;p=gem5.git sparc,configs: Initialize ROMs directly, not with the workload. This simplifies the SPARC FS workload significantly, and removes assumptions about what ROMs exist, where they go, etc. It removes other components from the loop which don't have anything to contribute as far as setting up the ROMs. One side effect of this is that there isn't specialized support for adding PC based events which would fire in the ROMs, but that was never done and the files that were being used were flat binary blobs with no symbols in the first place. This also necessitates building a unified image which goes into the single 8MB ROM that is located at address 0xfff0000000. That is simply done with the following commands: dd if=/dev/zero of=t1000_rom.bin bs=1024 count=8192 dd if=reset_new.bin of=t1000_rom.bin dd if=q_new.bin of=t1000_rom.bin bs=1024 seek=64 dd if=openboot_new.bin of=t1000_rom.bin bs=1024 seek=512 This results in an 8MB blob which can be loaded verbatim into the ROM. Alternatively, and with some extra effort, an ELF file could be constructed which had each of these components as segments, offset to the right location in the ELF header. That would be slightly more work to set up, but wouldn't waste space on regions of the image that are all zeroes. Change-Id: Id4e08f4e047e7bd36a416c197a36be841eba4a15 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27268 Reviewed-by: Gabe Black Maintainer: Gabe Black Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com> --- diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py index 41b70d710..376ae1a92 100644 --- a/configs/common/FSConfig.py +++ b/configs/common/FSConfig.py @@ -147,26 +147,20 @@ def makeSparcSystem(mem_mode, mdesc=None, cmdline=None): self.t1000.hvuart.pio_addr + uart_pio_size - 1) ] - workload = SparcFsWorkload( - reset_bin=binary('reset_new.bin'), - hypervisor_bin=binary('q_new.bin'), - openboot_bin=binary('openboot_new.bin'), - nvram_bin=binary('nvram1'), - hypervisor_desc_bin=binary('1up-hv.bin'), - partition_desc_bin=binary('1up-md.bin'), - ) + workload = SparcFsWorkload() # ROM for OBP/Reset/Hypervisor - self.rom = SimpleMemory(range=AddrRange(workload._rom_base, size='8MB')) + self.rom = SimpleMemory(image_file=binary('t1000_rom.bin'), + range=AddrRange(0xfff0000000, size='8MB')) # nvram - self.nvram = SimpleMemory( - range=AddrRange(workload._nvram_base, size='8kB')) + self.nvram = SimpleMemory(image_file=binary('nvram1'), + range=AddrRange(0x1f11000000, size='8kB')) # hypervisor description - self.hypervisor_desc = SimpleMemory( - range=AddrRange(workload._hypervisor_desc_base, size='8kB')) + self.hypervisor_desc = SimpleMemory(image_file=binary('1up-hv.bin'), + range=AddrRange(0x1f12080000, size='8kB')) # partition description - self.partition_desc = SimpleMemory( - range=AddrRange(workload._partition_desc_base, size='8kB')) + self.partition_desc = SimpleMemory(image_file=binary('1up-md.bin'), + range=AddrRange(0x1f12000000, size='8kB')) self.rom.port = self.membus.master self.nvram.port = self.membus.master diff --git a/src/arch/sparc/SparcFsWorkload.py b/src/arch/sparc/SparcFsWorkload.py index 7f4677e5f..6244882b9 100644 --- a/src/arch/sparc/SparcFsWorkload.py +++ b/src/arch/sparc/SparcFsWorkload.py @@ -26,7 +26,6 @@ from m5.params import * -from m5.objects.SimpleMemory import SimpleMemory from m5.objects.OsKernel import OsKernel class SparcFsWorkload(OsKernel): @@ -35,28 +34,3 @@ class SparcFsWorkload(OsKernel): cxx_class = 'SparcISA::FsWorkload' load_addr_mask = 0xffffffffff - - _rom_base = 0xfff0000000 - _nvram_base = 0x1f11000000 - _hypervisor_desc_base = 0x1f12080000 - _partition_desc_base = 0x1f12000000 - - reset_addr = Param.Addr(_rom_base, "Address to load ROM at") - hypervisor_addr = Param.Addr(Addr('64kB') + _rom_base, - "Address to load hypervisor at") - openboot_addr = Param.Addr(Addr('512kB') + _rom_base, - "Address to load openboot at") - nvram_addr = Param.Addr(_nvram_base, "Address to put the nvram") - hypervisor_desc_addr = Param.Addr(_hypervisor_desc_base, - "Address for the hypervisor description") - partition_desc_addr = Param.Addr(_partition_desc_base, - "Address for the partition description") - - reset_bin = Param.String("file that contains the reset code") - hypervisor_bin = Param.String("file that contains the hypervisor code") - openboot_bin = Param.String("file that contains the openboot code") - nvram_bin = Param.String("file that contains the contents of nvram") - hypervisor_desc_bin = Param.String( - "file that contains the hypervisor description") - partition_desc_bin = Param.String( - "file that contains the partition description") diff --git a/src/arch/sparc/fs_workload.cc b/src/arch/sparc/fs_workload.cc index 4174bd521..e0fa8e41a 100644 --- a/src/arch/sparc/fs_workload.cc +++ b/src/arch/sparc/fs_workload.cc @@ -29,110 +29,12 @@ #include "arch/sparc/fs_workload.hh" #include "arch/sparc/faults.hh" -#include "base/loader/object_file.hh" -#include "base/loader/symtab.hh" -#include "base/trace.hh" -#include "mem/physical.hh" #include "params/SparcFsWorkload.hh" -#include "sim/byteswap.hh" #include "sim/system.hh" -namespace -{ - -ObjectFile * -loadFirmwareImage(const std::string &fname, const std::string &name) -{ - ObjectFile *obj = createObjectFile(fname, true); - fatal_if(!obj, "Could not load %s %s.", name, fname); - return obj; -} - -void -writeFirmwareImage(ObjectFile *obj, Addr addr, const PortProxy &proxy) -{ - MemoryImage image = obj->buildImage(); - - // If the entry point isn't somewhere in the image, we assume we need to - // move where it's loaded so that it is. - if (addr < image.minAddr() || addr >= image.maxAddr()) { - // Move the image by the difference between the expected entry address, - // and the entry point in the object file. - image.offset(addr - obj->entryPoint()); - } - - image.write(proxy); -} - -} // anonymous namespace - namespace SparcISA { -FsWorkload::FsWorkload(Params *p) : OsKernel(*p) -{ - resetSymtab = new SymbolTable; - hypervisorSymtab = new SymbolTable; - openbootSymtab = new SymbolTable; - nvramSymtab = new SymbolTable; - hypervisorDescSymtab = new SymbolTable; - partitionDescSymtab = new SymbolTable; - - reset = loadFirmwareImage(params()->reset_bin, "reset binary"); - openboot = loadFirmwareImage(params()->openboot_bin, "openboot binary"); - hypervisor = loadFirmwareImage( - params()->hypervisor_bin, "hypervisor binary"); - nvram = loadFirmwareImage(params()->nvram_bin, "nvram image"); - hypervisor_desc = loadFirmwareImage( - params()->hypervisor_desc_bin, "hypervisor description image"); - partition_desc = loadFirmwareImage( - params()->partition_desc_bin, "partition description image"); - - // load symbols - panic_if(!reset->loadGlobalSymbols(resetSymtab), - "could not load reset symbols"); - - panic_if(!openboot->loadGlobalSymbols(openbootSymtab), - "could not load openboot symbols"); - - panic_if(!hypervisor->loadLocalSymbols(hypervisorSymtab), - "could not load hypervisor symbols"); - - panic_if(!nvram->loadLocalSymbols(nvramSymtab), - "could not load nvram symbols"); - - panic_if(!hypervisor_desc->loadLocalSymbols(hypervisorDescSymtab), - "could not load hypervisor description symbols"); - - panic_if(!partition_desc->loadLocalSymbols(partitionDescSymtab), - "could not load partition description symbols"); - - // load symbols into debug table - panic_if(!reset->loadGlobalSymbols(debugSymbolTable), - "could not load reset symbols"); - - panic_if(!openboot->loadGlobalSymbols(debugSymbolTable), - "could not load openboot symbols"); - - panic_if(!hypervisor->loadLocalSymbols(debugSymbolTable), - "could not load hypervisor symbols"); - - // Strip off the rom address so when the hypervisor is copied into memory - // we have symbols still - panic_if(!hypervisor->loadLocalSymbols(debugSymbolTable, 0, 0, 0xFFFFFF), - "could not load hypervisor symbols"); - - panic_if(!nvram->loadGlobalSymbols(debugSymbolTable), - "could not load reset symbols"); - - panic_if(!hypervisor_desc->loadGlobalSymbols(debugSymbolTable), - "could not load hypervisor description symbols"); - - panic_if(!partition_desc->loadLocalSymbols(debugSymbolTable), - "could not load partition description symbols"); - -} - void FsWorkload::initState() { @@ -145,56 +47,6 @@ FsWorkload::initState() auto *tc = system->threadContexts[0]; SparcISA::PowerOnReset().invoke(tc); tc->activate(); - - auto phys_proxy = system->physProxy; - - writeFirmwareImage(reset, params()->reset_addr, phys_proxy); - writeFirmwareImage(openboot, params()->openboot_addr, phys_proxy); - writeFirmwareImage(hypervisor, params()->hypervisor_addr, phys_proxy); - writeFirmwareImage(nvram, params()->nvram_addr, phys_proxy); - writeFirmwareImage( - hypervisor_desc, params()->hypervisor_desc_addr, phys_proxy); - writeFirmwareImage( - partition_desc, params()->partition_desc_addr, phys_proxy); -} - -FsWorkload::~FsWorkload() -{ - 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; -} - -void -FsWorkload::serializeSymtab(CheckpointOut &cp) const -{ - resetSymtab->serialize("reset_symtab", cp); - hypervisorSymtab->serialize("hypervisor_symtab", cp); - openbootSymtab->serialize("openboot_symtab", cp); - nvramSymtab->serialize("nvram_symtab", cp); - hypervisorDescSymtab->serialize("hypervisor_desc_symtab", cp); - partitionDescSymtab->serialize("partition_desc_symtab", cp); -} - - -void -FsWorkload::unserializeSymtab(CheckpointIn &cp) -{ - resetSymtab->unserialize("reset_symtab", cp); - hypervisorSymtab->unserialize("hypervisor_symtab", cp); - openbootSymtab->unserialize("openboot_symtab", cp); - nvramSymtab->unserialize("nvram_symtab", cp); - hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp); - partitionDescSymtab->unserialize("partition_desc_symtab", cp); } } // namespace SparcISA diff --git a/src/arch/sparc/fs_workload.hh b/src/arch/sparc/fs_workload.hh index a52f03d32..2ffc06a64 100644 --- a/src/arch/sparc/fs_workload.hh +++ b/src/arch/sparc/fs_workload.hh @@ -29,12 +29,8 @@ #ifndef __ARCH_SPARC_FS_WORKLOAD_HH__ #define __ARCH_SPARC_FS_WORKLOAD_HH__ -#include "base/loader/symtab.hh" -#include "cpu/pc_event.hh" -#include "kern/system_events.hh" #include "params/SparcFsWorkload.hh" #include "sim/os_kernel.hh" -#include "sim/sim_object.hh" namespace SparcISA { @@ -42,81 +38,8 @@ namespace SparcISA class FsWorkload : public OsKernel { public: - typedef SparcFsWorkloadParams Params; - FsWorkload(Params *p); - ~FsWorkload(); - + FsWorkload(SparcFsWorkloadParams *p) : OsKernel(*p) {} void initState() override; - -/** - * Serialization stuff - */ - public: - void serializeSymtab(CheckpointOut &cp) const override; - void unserializeSymtab(CheckpointIn &cp) override; - - /** reset binary symbol table */ - SymbolTable *resetSymtab; - - /** hypervison binary symbol table */ - SymbolTable *hypervisorSymtab; - - /** openboot symbol table */ - SymbolTable *openbootSymtab; - - /** nvram symbol table? */ - SymbolTable *nvramSymtab; - - /** hypervisor desc symbol table? */ - SymbolTable *hypervisorDescSymtab; - - /** partition desc symbol table? */ - SymbolTable *partitionDescSymtab; - - /** Object pointer for the reset binary */ - ObjectFile *reset; - - /** Object pointer for the hypervisor code */ - ObjectFile *hypervisor; - - /** Object pointer for the openboot code */ - ObjectFile *openboot; - - /** Object pointer for the nvram image */ - ObjectFile *nvram; - - /** Object pointer for the hypervisor description image */ - ObjectFile *hypervisor_desc; - - /** Object pointer for the partition description image */ - ObjectFile *partition_desc; - - protected: - const Params *params() const { return (const Params *)&_params; } - - /** Add a function-based event to reset binary. */ - template - T * - addResetFuncEvent(const char *lbl) - { - return addFuncEvent(resetSymtab, lbl); - } - - /** Add a function-based event to the hypervisor. */ - template - T * - addHypervisorFuncEvent(const char *lbl) - { - return addFuncEvent(hypervisorSymtab, lbl); - } - - /** Add a function-based event to the openboot. */ - template - T * - addOpenbootFuncEvent(const char *lbl) - { - return addFuncEvent(openbootSymtab, lbl); - } }; } // namespace SparcISA