self.console = binary('mips/console')
if not cmdline:
cmdline = 'root=/dev/hda1 console=ttyS0'
- self.workload = OsKernel(command_line=fillInCmdline(mdesc, cmdline))
+ self.workload = KernelWorkload(command_line=fillInCmdline(mdesc, cmdline))
self.system_port = self.membus.slave
from m5.params import *
from m5.options import *
from m5.SimObject import *
-from m5.objects.OsKernel import OsKernel
+from m5.objects.Workload import KernelWorkload
class ArmMachineType(Enum):
map = {
'DTOnly' : -1,
}
-class ArmFsWorkload(OsKernel):
+class ArmFsWorkload(KernelWorkload):
type = 'ArmFsWorkload'
cxx_header = "arch/arm/fs_workload.hh"
cxx_class = "ArmISA::FsWorkload"
// to do this permanently, for but early bootup work
// it is helpful.
if (params()->early_kernel_symbols) {
- obj->loadGlobalSymbols(symtab, 0, 0, loadAddrMask);
- obj->loadGlobalSymbols(debugSymbolTable, 0, 0, loadAddrMask);
+ kernelObj->loadGlobalSymbols(kernelSymtab, 0, 0, _loadAddrMask);
+ kernelObj->loadGlobalSymbols(debugSymbolTable, 0, 0, _loadAddrMask);
}
// Check if the kernel image has a symbol that tells us it supports
// device trees.
Addr addr;
- fatal_if(!symtab->findAddress("fdt_get_range", addr),
+ fatal_if(!kernelSymtab->findAddress("fdt_get_range", addr),
"Kernel must have fdt support.");
fatal_if(params()->dtb_filename == "", "dtb file is not specified.");
// Kernel supports flattened device tree and dtb file specified.
// Using Device Tree Blob to describe system configuration.
inform("Loading DTB file: %s at address %#x\n", params()->dtb_filename,
- params()->atags_addr + loadAddrOffset);
+ params()->atags_addr + _loadAddrOffset);
DtbFile *dtb_file = new DtbFile(params()->dtb_filename);
bootReleaseAddr = ra & ~ULL(0x7F);
dtb_file->buildImage().
- offset(params()->atags_addr + loadAddrOffset).
+ offset(params()->atags_addr + _loadAddrOffset).
write(system->physProxy);
delete dtb_file;
for (auto tc: system->threadContexts) {
tc->setIntReg(0, 0);
tc->setIntReg(1, params()->machine_type);
- tc->setIntReg(2, params()->atags_addr + loadAddrOffset);
+ tc->setIntReg(2, params()->atags_addr + _loadAddrOffset);
}
}
}
}
-FsWorkload::FsWorkload(Params *p)
- : OsKernel(*p),
- kernelEntry((entry & loadAddrMask) + loadAddrOffset)
+FsWorkload::FsWorkload(Params *p) : KernelWorkload(*p),
+ kernelEntry((kernelObj->entryPoint() & loadAddrMask()) + loadAddrOffset())
{
bootLoaders.reserve(p->boot_loader.size());
for (const auto &bl : p->boot_loader) {
bootLoaders.emplace_back(std::move(bl_obj));
}
- if (obj) {
- bootldr = getBootLoader(obj);
- } else if (!bootLoaders.empty()) {
- // No kernel specified, default to the first boot loader
- bootldr = bootLoaders[0].get();
- }
+ bootldr = getBootLoader(kernelObj);
fatal_if(!bootLoaders.empty() && !bootldr,
"Can't find a matching boot loader / kernel combination!");
- if (bootldr) {
+ if (bootldr)
bootldr->loadGlobalSymbols(debugSymbolTable);
-
- _highestELIs64 = (bootldr->getArch() == ObjectFile::Arm64);
- } else if (obj) {
- _highestELIs64 = (obj->getArch() == ObjectFile::Arm64);
- }
}
void
FsWorkload::initState()
{
- OsKernel::initState();
+ KernelWorkload::initState();
// Reset CP15?? What does that mean -- ali
} else {
// Set the initial PC to be at start of the kernel code
if (!arm_sys->highestELIs64())
- arm_sys->threadContexts[0]->pcState(entry);
+ arm_sys->threadContexts[0]->pcState(kernelObj->entryPoint());
}
}
ObjectFile *
FsWorkload::getBootLoader(ObjectFile *const obj)
{
- for (auto &bl : bootLoaders) {
- if (bl->getArch() == obj->getArch())
- return bl.get();
+ if (obj) {
+ for (auto &bl : bootLoaders) {
+ if (bl->getArch() == obj->getArch())
+ return bl.get();
+ }
+ } else if (!bootLoaders.empty()) {
+ return bootLoaders[0].get();
}
return nullptr;
}
-Addr
-FsWorkload::resetAddr() const
-{
- if (bootldr) {
- return bootldr->entryPoint();
- } else {
- return kernelEntry;
- }
-}
-
} // namespace ArmISA
ArmISA::FsWorkload *
#include "kern/linux/events.hh"
#include "params/ArmFsWorkload.hh"
-#include "sim/os_kernel.hh"
+#include "sim/kernel_workload.hh"
#include "sim/sim_object.hh"
namespace ArmISA
void returnFromFuncIn(ThreadContext *tc) override;
};
-class FsWorkload : public OsKernel
+class FsWorkload : public KernelWorkload
{
protected:
/** Bootloaders */
*/
ObjectFile *bootldr = nullptr;
- /**
- * Whether the highest exception level in software is 64 it.
- */
- bool _highestELIs64 = true;
-
/**
* This differs from entry since it takes into account where
* the kernel is loaded in memory (with loadAddrMask and
return dynamic_cast<const Params *>(&_params);
}
- FsWorkload(Params *p);
+ Addr
+ getEntry() const override
+ {
+ if (bootldr)
+ return bootldr->entryPoint();
+ else
+ return kernelEntry;
+ }
- void initState() override;
+ ObjectFile::Arch
+ getArch() const override
+ {
+ if (bootldr)
+ return bootldr->getArch();
+ else if (kernelObj)
+ return kernelObj->getArch();
+ else
+ return ObjectFile::Arm64;
+ }
- /**
- * Returns the reset address to be used by an ArmSystem.
- * It the workload is using a bootloader, it will return
- * the bootloader entry point.
- * @returns Arm reset address
- */
- Addr resetAddr() const;
+ FsWorkload(Params *p);
- bool highestELIs64() const { return _highestELIs64; }
+ void initState() override;
};
} // namespace ArmISA
// to do this permanently, for but early bootup work
// it is helpful.
if (params()->early_kernel_symbols) {
- obj->loadGlobalSymbols(symtab, 0, 0, loadAddrMask);
- obj->loadGlobalSymbols(debugSymbolTable, 0, 0, loadAddrMask);
+ kernelObj->loadGlobalSymbols(kernelSymtab, 0, 0, _loadAddrMask);
+ kernelObj->loadGlobalSymbols(debugSymbolTable, 0, 0, _loadAddrMask);
}
// Setup boot data structure
// Check if the kernel image has a symbol that tells us it supports
// device trees.
bool kernel_has_fdt_support =
- symtab->findAddress("unflatten_device_tree", addr);
+ kernelSymtab->findAddress("unflatten_device_tree", addr);
bool dtb_file_specified = params()->dtb_filename != "";
if (kernel_has_fdt_support && dtb_file_specified) {
// Kernel supports flattened device tree and dtb file specified.
// Using Device Tree Blob to describe system configuration.
inform("Loading DTB file: %s at address %#x\n", params()->dtb_filename,
- params()->atags_addr + loadAddrOffset);
+ params()->atags_addr + _loadAddrOffset);
DtbFile *dtb_file = new DtbFile(params()->dtb_filename);
}
dtb_file->buildImage().
- offset(params()->atags_addr + loadAddrOffset).
+ offset(params()->atags_addr + _loadAddrOffset).
write(system->physProxy);
delete dtb_file;
} else {
DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2);
DDUMP(Loader, boot_data, size << 2);
- system->physProxy.writeBlob(params()->atags_addr + loadAddrOffset,
+ system->physProxy.writeBlob(params()->atags_addr + _loadAddrOffset,
boot_data, size << 2);
delete[] boot_data;
for (auto tc: system->threadContexts) {
tc->setIntReg(0, 0);
tc->setIntReg(1, params()->machine_type);
- tc->setIntReg(2, params()->atags_addr + loadAddrOffset);
+ tc->setIntReg(2, params()->atags_addr + _loadAddrOffset);
}
}
{
FsWorkload::startup();
- auto *arm_sys = dynamic_cast<ArmSystem *>(system);
if (enableContextSwitchStatsDump) {
- if (!arm_sys->highestELIs64())
- dumpStats = addKernelFuncEvent<DumpStats>("__switch_to");
- else
+ if (getArch() == ObjectFile::Arm64)
dumpStats = addKernelFuncEvent<DumpStats64>("__switch_to");
+ else
+ dumpStats = addKernelFuncEvent<DumpStats>("__switch_to");
panic_if(!dumpStats, "dumpStats not created!");
std::string task_filename = "tasks.txt";
taskFile = simout.create(name() + "." + task_filename);
- for (const auto tc : arm_sys->threadContexts) {
+ for (const auto tc : system->threadContexts) {
uint32_t pid = tc->getCpuPtr()->getPid();
if (pid != BaseCPU::invldPid) {
mapPid(tc, pid);
"__const_udelay", "__const_udelay", 1000, 107374);
}
- if (highestELIs64()) {
+ if (getArch() == ObjectFile::Arm64) {
debugPrintk = addKernelFuncEvent<
DebugPrintk<SkipFuncLinux64>>("dprintk");
} else {
readSymbol(ThreadContext *tc, const std::string name)
{
PortProxy &vp = tc->getVirtProxy();
- SymbolTable *symtab = tc->getSystemPtr()->workload->symtab;
+ const SymbolTable *symtab = tc->getSystemPtr()->workload->symtab(tc);
Addr addr;
if (!symtab->findAddress(name, addr))
semihosting(p->semihosting),
multiProc(p->multi_proc)
{
- auto *arm_workload = dynamic_cast<ArmISA::FsWorkload *>(p->workload);
- panic_if(!arm_workload,
- "Workload was not the expected type (ArmISA::FsWorkload).");
-
if (p->auto_reset_addr) {
- _resetAddr = arm_workload->resetAddr();
+ _resetAddr = workload->getEntry();
} else {
_resetAddr = p->reset_addr;
- warn_if(arm_workload->resetAddr() != _resetAddr,
+ warn_if(workload->getEntry() != _resetAddr,
"Workload entry point %#x and reset address %#x are different",
- arm_workload->resetAddr(), _resetAddr);
+ workload->getEntry(), _resetAddr);
}
- if (arm_workload->highestELIs64() != _highestELIs64) {
+ bool wl_is_64 = (workload->getArch() == ObjectFile::Arm64);
+ if (wl_is_64 != _highestELIs64) {
warn("Highest ARM exception-level set to AArch%d but the workload "
"is for AArch%d. Assuming you wanted these to match.",
- _highestELIs64 ? 64 : 32,
- arm_workload->highestELIs64() ? 64 : 32);
- _highestELIs64 = arm_workload->highestELIs64();
+ _highestELIs64 ? 64 : 32, wl_is_64 ? 64 : 32);
+ _highestELIs64 = wl_is_64;
}
if (_highestELIs64 && (
get_data(const char *symbol, T &data)
{
Addr addr = 0;
- if (!sys->workload->symtab->findAddress(symbol, addr)) {
+ if (!sys->workload->symtab(tc)->findAddress(symbol, addr)) {
warn_once("Unable to find kernel symbol %s\n", symbol);
warn_once("Kernel not compiled with task_struct info; can't get "
"currently executing task/process/thread name/ids!\n");
from m5.params import *
from m5.objects.System import System
-from m5.objects.OsKernel import OsKernel
+from m5.objects.Workload import Workload
-class RiscvFsWorkload(OsKernel):
+class RiscvFsWorkload(Workload):
type = 'RiscvFsWorkload'
cxx_class = 'RiscvISA::FsWorkload'
cxx_header = 'arch/riscv/fs_workload.hh'
#include "arch/riscv/bare_metal/fs_workload.hh"
+#include "arch/riscv/faults.hh"
#include "base/loader/object_file.hh"
#include "sim/system.hh"
BareMetal::initState()
{
RiscvISA::FsWorkload::initState();
+
+ for (auto *tc: system->threadContexts) {
+ RiscvISA::Reset().invoke(tc);
+ tc->activate();
+ }
+
warn_if(!bootloader->buildImage().write(system->physProxy),
"Could not load sections to memory.");
}
~BareMetal();
void initState() override;
+
+ ObjectFile::Arch
+ getArch() const override
+ {
+ return bootloader->getArch();
+ }
+ const SymbolTable *
+ symtab(ThreadContext *tc) override
+ {
+ return bootloaderSymtab;
+ }
+ bool
+ insertSymbol(Addr address, const std::string &symbol) override
+ {
+ return bootloaderSymtab->insert(address, symbol);
+ }
};
} // namespace RiscvISA
+++ /dev/null
-/*
- * Copyright (c) 2018 TU Dresden
- * All rights reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "arch/riscv/bare_metal/system.hh"
-
-#include "arch/riscv/faults.hh"
-#include "base/loader/object_file.hh"
-
-BareMetalRiscvSystem::BareMetalRiscvSystem(Params *p)
- : RiscvSystem(p),
- bootloader(createObjectFile(p->bootloader))
-{
- if (bootloader == NULL) {
- fatal("Could not load bootloader file %s", p->bootloader);
- }
-
- _resetVect = bootloader->entryPoint();
-}
-
-BareMetalRiscvSystem::~BareMetalRiscvSystem()
-{
- delete bootloader;
-}
-
-void
-BareMetalRiscvSystem::initState()
-{
- // Call the initialisation of the super class
- RiscvSystem::initState();
-
- for (auto *tc: threadContexts) {
- RiscvISA::Reset().invoke(tc);
- tc->activate();
- }
-
- // load program sections into memory
- if (!bootloader->buildImage().write(physProxy)) {
- warn("could not load sections to memory");
- }
-}
-
-BareMetalRiscvSystem *
-BareMetalRiscvSystemParams::create()
-{
- return new BareMetalRiscvSystem(this);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2018 TU Dresden
- * All rights reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __ARCH_RISCV_BARE_METAL_SYSTEM_HH__
-#define __ARCH_RISCV_BARE_METAL_SYSTEM_HH__
-
-#include "arch/riscv/system.hh"
-#include "params/BareMetalRiscvSystem.hh"
-
-class BareMetalRiscvSystem : public RiscvSystem
-{
- protected:
- ObjectFile* bootloader;
-
- public:
- typedef BareMetalRiscvSystemParams Params;
- BareMetalRiscvSystem(Params *p);
- ~BareMetalRiscvSystem();
-
- // initialize the system
- virtual void initState();
-};
-
-#endif // __ARCH_RISCV_BARE_METAL_SYSTEM_HH__
-
#define __ARCH_RISCV_FS_WORKLOAD_HH__
#include "params/RiscvFsWorkload.hh"
-#include "sim/os_kernel.hh"
#include "sim/sim_object.hh"
+#include "sim/workload.hh"
namespace RiscvISA
{
-class FsWorkload : public OsKernel
+class FsWorkload : public Workload
{
protected:
// checker for bare metal application
Addr _resetVect;
public:
- FsWorkload(RiscvFsWorkloadParams *p) : OsKernel(*p),
+ FsWorkload(RiscvFsWorkloadParams *p) : Workload(p),
_isBareMetal(p->bare_metal), _resetVect(p->reset_vect)
{}
// return bare metal checker
bool isBareMetal() const { return _isBareMetal; }
+
+ Addr getEntry() const override { return _resetVect; }
};
} // namespace RiscvISA
from m5.params import *
-from m5.objects.OsKernel import OsKernel
+from m5.objects.Workload import Workload
-class SparcFsWorkload(OsKernel):
+class SparcFsWorkload(Workload):
type = 'SparcFsWorkload'
cxx_header = 'arch/sparc/fs_workload.hh'
cxx_class = 'SparcISA::FsWorkload'
-
- load_addr_mask = 0xffffffffff
void
FsWorkload::initState()
{
- OsKernel::initState();
+ Workload::initState();
if (system->threadContexts.empty())
return;
#ifndef __ARCH_SPARC_FS_WORKLOAD_HH__
#define __ARCH_SPARC_FS_WORKLOAD_HH__
+#include "arch/sparc/faults.hh"
#include "params/SparcFsWorkload.hh"
-#include "sim/os_kernel.hh"
+#include "sim/workload.hh"
namespace SparcISA
{
-class FsWorkload : public OsKernel
+class FsWorkload : public Workload
{
+ protected:
+ SymbolTable defaultSymtab;
+
public:
- FsWorkload(SparcFsWorkloadParams *p) : OsKernel(*p) {}
+ FsWorkload(SparcFsWorkloadParams *params) : Workload(params) {}
void initState() override;
+
+ Addr
+ getEntry() const override
+ {
+ Addr pc, npc;
+ getREDVector(0x001, pc, npc);
+ return pc;
+ }
+ ObjectFile::Arch getArch() const override { return ObjectFile::SPARC64; }
+
+ const SymbolTable *
+ symtab(ThreadContext *tc) override
+ {
+ return &defaultSymtab;
+ }
+
+ bool
+ insertSymbol(Addr address, const std::string &symbol) override
+ {
+ return defaultSymtab.insert(address, symbol);
+ }
};
} // namespace SparcISA
from m5.objects.SMBios import X86SMBiosSMBiosTable
from m5.objects.IntelMP import X86IntelMPFloatingPointer, X86IntelMPConfigTable
from m5.objects.ACPI import X86ACPIRSDP
-from m5.objects.OsKernel import OsKernel
+from m5.objects.Workload import KernelWorkload
-class X86FsWorkload(OsKernel):
+class X86FsWorkload(KernelWorkload):
type = 'X86FsWorkload'
cxx_header = 'arch/x86/fs_workload.hh'
cxx_class = 'X86ISA::FsWorkload'
namespace X86ISA
{
-FsWorkload::FsWorkload(Params *p) : OsKernel(*p),
+FsWorkload::FsWorkload(Params *p) : KernelWorkload(*p),
smbiosTable(p->smbios_table),
mpFloatingPointer(p->intel_mp_pointer),
mpConfigTable(p->intel_mp_table),
void
FsWorkload::initState()
{
- OsKernel::initState();
+ KernelWorkload::initState();
for (auto *tc: system->threadContexts) {
X86ISA::InitInterrupt(0).invoke(tc);
}
}
- fatal_if(!obj, "No kernel to load.");
+ fatal_if(!kernelObj, "No kernel to load.");
- fatal_if(obj->getArch() == ObjectFile::I386,
+ fatal_if(kernelObj->getArch() == ObjectFile::I386,
"Loading a 32 bit x86 kernel is not supported.");
ThreadContext *tc = system->threadContexts[0];
cr0.pg = 1;
tc->setMiscReg(MISCREG_CR0, cr0);
- tc->pcState(entry);
+ tc->pcState(kernelObj->entryPoint());
// We should now be in long mode. Yay!
#include "base/types.hh"
#include "cpu/thread_context.hh"
#include "params/X86FsWorkload.hh"
-#include "sim/os_kernel.hh"
+#include "sim/kernel_workload.hh"
namespace X86ISA
{
void installSegDesc(ThreadContext *tc, SegmentRegIndex seg,
SegDescriptor desc, bool longmode);
-class FsWorkload : public OsKernel
+class FsWorkload : public KernelWorkload
{
public:
typedef X86FsWorkloadParams Params;
readSymbol(ThreadContext *tc, const std::string name)
{
PortProxy &vp = tc->getVirtProxy();
- SymbolTable *symtab = tc->getSystemPtr()->workload->symtab;
+ const SymbolTable *symtab = tc->getSystemPtr()->workload->symtab(tc);
Addr addr;
if (!symtab->findAddress(name, addr))
StackTrace::dump()
{
StringWrap name(tc->getCpuPtr()->name());
- SymbolTable *symtab = tc->getSystemPtr()->workload->symtab;
+ const SymbolTable *symtab = tc->getSystemPtr()->workload->symtab(tc);
DPRINTFN("------ Stack ------\n");
if (cpu->params()->profile) {
profile = new FunctionProfile(
- cpu->params()->system->workload->symtab);
+ cpu->params()->system->workload->symtab(tc));
Callback *cb =
new MakeCallback<O3ThreadState,
&O3ThreadState::dumpFuncProfile>(this);
clearArchRegs();
if (baseCpu->params()->profile) {
- profile = new FunctionProfile(system->workload->symtab);
+ profile = new FunctionProfile(system->workload->symtab(this));
Callback *cb =
new MakeCallback<SimpleThread,
&SimpleThread::dumpFuncProfile>(this);
{
System *system = tc->getSystemPtr();
const ByteOrder bo = system->getGuestByteOrder();
- const SymbolTable *symtab = system->workload->symtab;
+ const SymbolTable *symtab = system->workload->symtab(tc);
PortProxy &proxy = tc->getVirtProxy();
Addr addr_lb = 0, addr_lb_len = 0, addr_first = 0, addr_next = 0;
+++ /dev/null
-# Copyright 2019 Google Inc.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met: redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer;
-# redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution;
-# neither the name of the copyright holders nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-from m5.params import *
-from m5.SimObject import SimObject
-
-from m5.objects.SimpleMemory import *
-
-class OsKernel(SimObject):
- type = 'OsKernel'
- cxx_header = "sim/os_kernel.hh"
-
- object_file = Param.String("", "File that contains the kernel code")
- extras = VectorParam.String([], "Additional object files to load")
- extras_addrs = VectorParam.Addr([],
- "Load addresses for additional object files")
-
- addr_check = Param.Bool(True,
- "whether to bounds check kernel addresses (disable for baremetal)")
- load_addr_mask = Param.UInt64(0xffffffffffffffff,
- "Mask to apply to kernel addresses. If zero, "
- "auto-calculated to be the most restrictive.")
- load_addr_offset = Param.UInt64(0, "Address to offset the kernel with")
-
- command_line = Param.String("a", "boot flags to pass to the kernel")
SimObject('ClockedObject.py')
SimObject('TickedObject.py')
-SimObject('OsKernel.py')
+SimObject('Workload.py')
SimObject('Root.py')
SimObject('ClockDomain.py')
SimObject('VoltageDomain.py')
Source('init.cc', add_tags='python')
Source('init_signals.cc')
Source('main.cc', tags='main')
-Source('os_kernel.cc')
+Source('workload.cc')
+Source('kernel_workload.cc')
Source('port.cc')
Source('python.cc', add_tags='python')
Source('redirect_path.cc')
work_cpus_ckpt_count = Param.Counter(0,
"create checkpoint when active cpu count value is reached")
- workload = Param.OsKernel(NULL, "Operating system kernel")
+ workload = Param.Workload(NULL, "Operating system kernel")
init_param = Param.UInt64(0, "numerical value to pass into simulator")
readfile = Param.String("", "file to read startup script from")
symbolfile = Param.String("", "file to get the symbols from")
--- /dev/null
+# Copyright 2019 Google Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from m5.params import *
+from m5.SimObject import SimObject
+
+from m5.objects.SimpleMemory import *
+
+class Workload(SimObject):
+ type = 'Workload'
+ cxx_header = "sim/workload.hh"
+ abstract = True
+
+class KernelWorkload(Workload):
+ type = 'KernelWorkload'
+ cxx_header = "sim/kernel_workload.hh"
+
+ object_file = Param.String("", "File that contains the kernel code")
+ extras = VectorParam.String([], "Additional object files to load")
+ extras_addrs = VectorParam.Addr([],
+ "Load addresses for additional object files")
+
+ addr_check = Param.Bool(True,
+ "whether to bounds check kernel addresses (disable for baremetal)")
+ load_addr_mask = Param.UInt64(0xffffffffffffffff,
+ "Mask to apply to kernel addresses. If zero, "
+ "auto-calculated to be the most restrictive.")
+ load_addr_offset = Param.UInt64(0, "Address to offset the kernel with")
+
+ command_line = Param.String("a", "boot flags to pass to the kernel")
#include "cpu/pc_event.hh"
#include "sim/eventq_impl.hh"
#include "sim/global_event.hh"
+#include "sim/kernel_workload.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
#include "sim/system.hh"
--- /dev/null
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "sim/kernel_workload.hh"
+
+#include "debug/Loader.hh"
+#include "params/KernelWorkload.hh"
+#include "sim/system.hh"
+
+KernelWorkload::KernelWorkload(const Params &p) : Workload(&p), _params(p),
+ _loadAddrMask(p.load_addr_mask), _loadAddrOffset(p.load_addr_offset),
+ kernelSymtab(new SymbolTable), commandLine(p.command_line)
+{
+ if (!debugSymbolTable)
+ debugSymbolTable = new SymbolTable;
+
+ kernelObj = createObjectFile(params().object_file);
+ inform("kernel located at: %s", params().object_file);
+
+ fatal_if(!kernelObj,
+ "Could not load kernel file %s", params().object_file);
+
+ image = kernelObj->buildImage();
+
+ _start = image.minAddr();
+ _end = image.maxAddr();
+
+ // If load_addr_mask is set to 0x0, then calculate the smallest mask to
+ // cover all kernel addresses so gem5 can relocate the kernel to a new
+ // offset.
+ if (_loadAddrMask == 0)
+ _loadAddrMask = mask(findMsbSet(_end - _start) + 1);
+
+ image.move([this](Addr a) {
+ return (a & _loadAddrMask) + _loadAddrOffset;
+ });
+
+ // load symbols
+ fatal_if(!kernelObj->loadGlobalSymbols(kernelSymtab),
+ "Could not load kernel symbols.");
+
+ fatal_if(!kernelObj->loadLocalSymbols(kernelSymtab),
+ "Could not load kernel local symbols.");
+
+ fatal_if(!kernelObj->loadGlobalSymbols(debugSymbolTable),
+ "Could not load kernel symbols.");
+
+ fatal_if(!kernelObj->loadLocalSymbols(debugSymbolTable),
+ "Could not load kernel local symbols.");
+
+ // Loading only needs to happen once and after memory system is
+ // connected so it will happen in initState()
+
+ std::vector<Addr> extras_addrs = p.extras_addrs;
+ if (extras_addrs.empty())
+ extras_addrs.resize(p.extras.size(), MaxAddr);
+ fatal_if(p.extras.size() != extras_addrs.size(),
+ "Additional kernel objects, not all load addresses specified\n");
+ for (int ker_idx = 0; ker_idx < p.extras.size(); ker_idx++) {
+ const std::string &obj_name = p.extras[ker_idx];
+ const bool raw = extras_addrs[ker_idx] != MaxAddr;
+ ObjectFile *obj = createObjectFile(obj_name, raw);
+ fatal_if(!obj, "Failed to build additional kernel object '%s'.\n",
+ obj_name);
+ extras.push_back(obj);
+ }
+}
+
+KernelWorkload::~KernelWorkload()
+{
+ delete kernelSymtab;
+}
+
+void
+KernelWorkload::initState()
+{
+ auto &phys_mem = system->physProxy;
+ /**
+ * Load the kernel code into memory.
+ */
+ auto mapper = [this](Addr a) {
+ return (a & _loadAddrMask) + _loadAddrOffset;
+ };
+ if (params().object_file != "") {
+ if (params().addr_check) {
+ // Validate kernel mapping before loading binary
+ fatal_if(!system->isMemAddr(mapper(_start)) ||
+ !system->isMemAddr(mapper(_end)),
+ "Kernel is mapped to invalid location (not memory). "
+ "start (%#x) - end (%#x) %#x:%#x\n",
+ _start, _end, mapper(_start), mapper(_end));
+ }
+ // Load program sections into memory
+ image.write(phys_mem);
+
+ DPRINTF(Loader, "Kernel start = %#x\n", _start);
+ DPRINTF(Loader, "Kernel end = %#x\n", _end);
+ DPRINTF(Loader, "Kernel entry = %#x\n", kernelObj->entryPoint());
+ DPRINTF(Loader, "Kernel loaded...\n");
+ }
+
+ std::vector<Addr> extras_addrs = params().extras_addrs;
+ if (extras_addrs.empty())
+ extras_addrs.resize(params().extras.size(), MaxAddr);
+ for (int idx = 0; idx < extras.size(); idx++) {
+ const Addr load_addr = extras_addrs[idx];
+ auto image = extras[idx]->buildImage();
+ if (load_addr != MaxAddr)
+ image = image.offset(load_addr);
+ else
+ image = image.move(mapper);
+ image.write(phys_mem);
+ }
+}
+
+void
+KernelWorkload::serialize(CheckpointOut &cp) const
+{
+ kernelSymtab->serialize("symtab", cp);
+}
+
+void
+KernelWorkload::unserialize(CheckpointIn &cp)
+{
+ kernelSymtab->unserialize("symtab", cp);
+}
+
+KernelWorkload *
+KernelWorkloadParams::create()
+{
+ return new KernelWorkload(*this);
+}
--- /dev/null
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __SIM_KERNEL_WORKLOAD_HH__
+#define __SIM_KERNEL_WORKLOAD_HH__
+
+#include <string>
+#include <vector>
+
+#include "base/loader/object_file.hh"
+#include "base/types.hh"
+#include "params/KernelWorkload.hh"
+#include "sim/workload.hh"
+
+class SymbolTable;
+class System;
+
+class KernelWorkload : public Workload
+{
+ public:
+ using Params = KernelWorkloadParams;
+
+ protected:
+ const Params &_params;
+
+ MemoryImage image;
+
+ /** Mask that should be anded for binary/symbol loading.
+ * This allows one two different OS requirements for the same ISA to be
+ * handled. Some OSes are compiled for a virtual address and need to be
+ * loaded into physical memory that starts at address 0, while other
+ * bare metal tools generate images that start at address 0.
+ */
+ Addr _loadAddrMask;
+
+ /** Offset that should be used for binary/symbol loading.
+ * This further allows more flexibility than the loadAddrMask allows alone
+ * in loading kernels and similar. The loadAddrOffset is applied after the
+ * loadAddrMask.
+ */
+ Addr _loadAddrOffset;
+
+ Addr _start, _end;
+
+ std::vector<ObjectFile *> extras;
+
+ ObjectFile *kernelObj = nullptr;
+ SymbolTable *kernelSymtab = nullptr;
+
+ const std::string commandLine;
+
+ public:
+ const Params ¶ms() const { return _params; }
+
+ Addr start() const { return _start; }
+ Addr end() const { return _end; }
+ Addr loadAddrMask() const { return _loadAddrMask; }
+ Addr loadAddrOffset() const { return _loadAddrOffset; }
+
+ KernelWorkload(const Params &p);
+ ~KernelWorkload();
+
+ Addr getEntry() const override { return kernelObj->entryPoint(); }
+ ObjectFile::Arch getArch() const override { return kernelObj->getArch(); }
+ const SymbolTable *
+ symtab(ThreadContext *tc) override
+ {
+ return kernelSymtab;
+ }
+
+ bool
+ insertSymbol(Addr address, const std::string &symbol)
+ {
+ return kernelSymtab->insert(address, symbol);
+ }
+
+ void initState() override;
+
+ void serialize(CheckpointOut &cp) const override;
+ void unserialize(CheckpointIn &cp) override;
+
+ /** @{ */
+ /**
+ * Add a function-based event to a kernel symbol.
+ *
+ * These functions work like their addFuncEvent() and
+ * addFuncEventOrPanic() counterparts. The only difference is that
+ * they automatically use the kernel symbol table. All arguments
+ * are forwarded to the underlying method.
+ *
+ * @see addFuncEvent()
+ * @see addFuncEventOrPanic()
+ *
+ * @param lbl Function to hook the event to.
+ * @param args Arguments to be passed to addFuncEvent
+ */
+ template <class T, typename... Args>
+ T *
+ addKernelFuncEvent(const char *lbl, Args... args)
+ {
+ return addFuncEvent<T>(kernelSymtab, lbl, std::forward<Args>(args)...);
+ }
+
+ template <class T, typename... Args>
+ T *
+ addKernelFuncEventOrPanic(const char *lbl, Args... args)
+ {
+ T *e = addFuncEvent<T>(kernelSymtab, lbl, std::forward<Args>(args)...);
+ panic_if(!e, "Failed to find kernel symbol '%s'", lbl);
+ return e;
+ }
+ /** @} */
+};
+
+#endif // __SIM_KERNEL_WORKLOAD_HH__
+++ /dev/null
-/*
- * Copyright 2019 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "sim/os_kernel.hh"
-
-#include "base/loader/object_file.hh"
-#include "base/loader/symtab.hh"
-#include "debug/Loader.hh"
-#include "params/OsKernel.hh"
-#include "sim/system.hh"
-
-OsKernel::OsKernel(const Params &p) : SimObject(&p), _params(p),
- commandLine(p.command_line), symtab(new SymbolTable),
- loadAddrMask(p.load_addr_mask), loadAddrOffset(p.load_addr_offset)
-{
- if (!debugSymbolTable)
- debugSymbolTable = new SymbolTable;
-
- if (params().object_file == "") {
- inform("No kernel set for full system simulation. "
- "Assuming you know what you're doing.");
- } else {
- obj = createObjectFile(params().object_file);
- inform("kernel located at: %s", params().object_file);
-
- fatal_if(!obj, "Could not load kernel file %s", params().object_file);
-
- image = obj->buildImage();
-
- start = image.minAddr();
- end = image.maxAddr();
- entry = obj->entryPoint();
-
- // If load_addr_mask is set to 0x0, then calculate the smallest mask to
- // cover all kernel addresses so gem5 can relocate the kernel to a new
- // offset.
- if (loadAddrMask == 0)
- loadAddrMask = mask(findMsbSet(end - start) + 1);
-
- image.move([this](Addr a) {
- return (a & loadAddrMask) + loadAddrOffset;
- });
-
- // load symbols
- fatal_if(!obj->loadGlobalSymbols(symtab),
- "Could not load kernel symbols.");
-
- fatal_if(!obj->loadLocalSymbols(symtab),
- "Could not load kernel local symbols.");
-
- fatal_if(!obj->loadGlobalSymbols(debugSymbolTable),
- "Could not load kernel symbols.");
-
- fatal_if(!obj->loadLocalSymbols(debugSymbolTable),
- "Could not load kernel local symbols.");
- }
-
- // Loading only needs to happen once and after memory system is
- // connected so it will happen in initState()
-
- std::vector<Addr> extras_addrs = p.extras_addrs;
- if (extras_addrs.empty())
- extras_addrs.resize(p.extras.size(), MaxAddr);
- fatal_if(p.extras.size() != extras_addrs.size(),
- "Additional kernel objects, not all load addresses specified\n");
- for (int ker_idx = 0; ker_idx < p.extras.size(); ker_idx++) {
- const std::string &obj_name = p.extras[ker_idx];
- const bool raw = extras_addrs[ker_idx] != MaxAddr;
- ObjectFile *obj = createObjectFile(obj_name, raw);
- fatal_if(!obj, "Failed to build additional kernel object '%s'.\n",
- obj_name);
- extras.push_back(obj);
- }
-}
-
-Addr
-OsKernel::fixFuncEventAddr(Addr addr)
-{
- return system->fixFuncEventAddr(addr);
-}
-
-OsKernel::~OsKernel()
-{
- delete symtab;
-}
-
-void
-OsKernel::initState()
-{
- auto &phys_mem = system->physProxy;
- /**
- * Load the kernel code into memory.
- */
- auto mapper = [this](Addr a) {
- return (a & loadAddrMask) + loadAddrOffset;
- };
- if (params().object_file != "") {
- if (params().addr_check) {
- // Validate kernel mapping before loading binary
- fatal_if(!system->isMemAddr(mapper(start)) ||
- !system->isMemAddr(mapper(end)),
- "Kernel is mapped to invalid location (not memory). "
- "start (%#x) - end (%#x) %#x:%#x\n",
- start, end, mapper(start), mapper(end));
- }
- // Load program sections into memory
- image.write(phys_mem);
-
- DPRINTF(Loader, "Kernel start = %#x\n", start);
- DPRINTF(Loader, "Kernel end = %#x\n", end);
- DPRINTF(Loader, "Kernel entry = %#x\n", entry);
- DPRINTF(Loader, "Kernel loaded...\n");
- }
-
- std::vector<Addr> extras_addrs = params().extras_addrs;
- if (extras_addrs.empty())
- extras_addrs.resize(params().extras.size(), MaxAddr);
- for (int idx = 0; idx < extras.size(); idx++) {
- const Addr load_addr = extras_addrs[idx];
- auto image = extras[idx]->buildImage();
- if (load_addr != MaxAddr)
- image = image.offset(load_addr);
- else
- image = image.move(mapper);
- image.write(phys_mem);
- }
-}
-
-void
-OsKernel::serialize(CheckpointOut &cp) const
-{
- symtab->serialize("symtab", cp);
- serializeSymtab(cp);
-}
-
-void
-OsKernel::unserialize(CheckpointIn &cp)
-{
- symtab->unserialize("symtab", cp);
- unserializeSymtab(cp);
-}
-
-OsKernel *
-OsKernelParams::create()
-{
- return new OsKernel(*this);
-}
+++ /dev/null
-/*
- * Copyright 2019 Google Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __SIM_OS_KERNEL_HH__
-#define __SIM_OS_KERNEL_HH__
-
-#include "base/loader/memory_image.hh"
-#include "base/loader/symtab.hh"
-#include "params/OsKernel.hh"
-#include "sim/sim_object.hh"
-
-class ObjectFile;
-class SymbolTable;
-class System;
-
-class OsKernel : public SimObject
-{
- public:
- using Params = OsKernelParams;
-
- protected:
- const Params &_params;
-
- Addr fixFuncEventAddr(Addr);
-
- public:
- OsKernel(const Params &p);
- ~OsKernel();
-
- const Params ¶ms() { return _params; }
-
- void initState() override;
-
- const std::string commandLine;
-
- void serialize(CheckpointOut &cp) const override;
- void unserialize(CheckpointIn &cp) override;
-
- System *system = nullptr;
-
- ObjectFile *obj = nullptr;
- SymbolTable *symtab = nullptr;
-
- MemoryImage image;
-
- Addr start = 0;
- Addr end = MaxAddr;
- Addr entry = 0;
-
- /** Mask that should be anded for binary/symbol loading.
- * This allows one two different OS requirements for the same ISA to be
- * handled. Some OSes are compiled for a virtual address and need to be
- * loaded into physical memory that starts at address 0, while other
- * bare metal tools generate images that start at address 0.
- */
- Addr loadAddrMask;
-
- /** Offset that should be used for binary/symbol loading.
- * This further allows more flexibility than the loadAddrMask allows alone
- * in loading kernels and similar. The loadAddrOffset is applied after the
- * loadAddrMask.
- */
- Addr loadAddrOffset;
-
- std::vector<ObjectFile *> extras;
-
- /** @{ */
- /**
- * Add a function-based event to the given function, to be looked
- * up in the specified symbol table.
- *
- * The ...OrPanic flavor of the method causes the simulator to
- * panic if the symbol can't be found.
- *
- * @param symtab Symbol table to use for look up.
- * @param lbl Function to hook the event to.
- * @param desc Description to be passed to the event.
- * @param args Arguments to be forwarded to the event constructor.
- */
- template <class T, typename... Args>
- T *
- addFuncEvent(const SymbolTable *symtab, const char *lbl,
- const std::string &desc, Args... args)
- {
- Addr addr M5_VAR_USED = 0; // initialize only to avoid compiler warning
-
- if (symtab->findAddress(lbl, addr)) {
- return new T(system, desc, fixFuncEventAddr(addr),
- std::forward<Args>(args)...);
- }
-
- return nullptr;
- }
-
- template <class T>
- T *
- addFuncEvent(const SymbolTable *symtab, const char *lbl)
- {
- return addFuncEvent<T>(symtab, lbl, lbl);
- }
-
- template <class T, typename... Args>
- T *
- addFuncEventOrPanic(const SymbolTable *symtab, const char *lbl,
- Args... args)
- {
- T *e = addFuncEvent<T>(symtab, lbl, std::forward<Args>(args)...);
- panic_if(!e, "Failed to find symbol '%s'", lbl);
- return e;
- }
- /** @} */
-
- /** @{ */
- /**
- * Add a function-based event to a kernel symbol.
- *
- * These functions work like their addFuncEvent() and
- * addFuncEventOrPanic() counterparts. The only difference is that
- * they automatically use the kernel symbol table. All arguments
- * are forwarded to the underlying method.
- *
- * @see addFuncEvent()
- * @see addFuncEventOrPanic()
- *
- * @param lbl Function to hook the event to.
- * @param args Arguments to be passed to addFuncEvent
- */
- template <class T, typename... Args>
- T *
- addKernelFuncEvent(const char *lbl, Args... args)
- {
- return addFuncEvent<T>(symtab, lbl, std::forward<Args>(args)...);
- }
-
- template <class T, typename... Args>
- T *
- addKernelFuncEventOrPanic(const char *lbl, Args... args)
- {
- T *e(addFuncEvent<T>(symtab, lbl, std::forward<Args>(args)...));
- if (!e)
- panic("Failed to find kernel symbol '%s'", lbl);
- return e;
- }
- /** @} */
-
- protected:
- /**
- * If needed, serialize additional symbol table entries for a
- * specific subclass of this system.
- *
- * @param os stream to serialize to
- */
- virtual void serializeSymtab(CheckpointOut &os) const {}
-
- /**
- * If needed, unserialize additional symbol table entries for a
- * specific subclass of this system.
- *
- * @param cp checkpoint to unserialize from
- * @param section relevant section in the checkpoint
- */
- virtual void unserializeSymtab(CheckpointIn &cp) {}
-};
-
-#endif // __SIM_OS_KERNEL_HH__
if (!to_number(address, addr))
continue;
- if (!tc->getSystemPtr()->workload->symtab->insert(addr, symbol))
+ if (!tc->getSystemPtr()->workload->insertSymbol(addr, symbol))
continue;
DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
- tc->getSystemPtr()->workload->symtab->insert(addr,symbol);
+ tc->getSystemPtr()->workload->insertSymbol(addr, symbol);
debugSymbolTable->insert(addr,symbol);
}
#include "mem/port_proxy.hh"
#include "params/System.hh"
#include "sim/futex_map.hh"
-#include "sim/os_kernel.hh"
#include "sim/redirect_path.hh"
#include "sim/se_signal.hh"
#include "sim/sim_object.hh"
+#include "sim/workload.hh"
class BaseRemoteGDB;
class KvmVM;
PortProxy physProxy;
/** OS kernel */
- OsKernel *workload = nullptr;
+ Workload *workload = nullptr;
public:
/**
--- /dev/null
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "sim/workload.hh"
+
+#include "params/Workload.hh"
+#include "sim/system.hh"
+
+Addr
+Workload::fixFuncEventAddr(Addr addr)
+{
+ return system->fixFuncEventAddr(addr);
+}
--- /dev/null
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __SIM_WORKLOAD_HH__
+#define __SIM_WORKLOAD_HH__
+
+#include "base/loader/object_file.hh"
+#include "base/loader/symtab.hh"
+#include "params/Workload.hh"
+#include "sim/sim_object.hh"
+
+class System;
+class ThreadContext;
+
+class Workload : public SimObject
+{
+ protected:
+ Addr fixFuncEventAddr(Addr);
+
+ public:
+ using SimObject::SimObject;
+
+ System *system = nullptr;
+
+ virtual Addr getEntry() const = 0;
+ virtual ObjectFile::Arch getArch() const = 0;
+
+ virtual const SymbolTable *symtab(ThreadContext *tc) = 0;
+ virtual bool insertSymbol(Addr address, const std::string &symbol) = 0;
+
+ /** @{ */
+ /**
+ * Add a function-based event to the given function, to be looked
+ * up in the specified symbol table.
+ *
+ * The ...OrPanic flavor of the method causes the simulator to
+ * panic if the symbol can't be found.
+ *
+ * @param symtab Symbol table to use for look up.
+ * @param lbl Function to hook the event to.
+ * @param desc Description to be passed to the event.
+ * @param args Arguments to be forwarded to the event constructor.
+ */
+ template <class T, typename... Args>
+ T *
+ addFuncEvent(const SymbolTable *symtab, const char *lbl,
+ const std::string &desc, Args... args)
+ {
+ Addr addr M5_VAR_USED = 0; // initialize only to avoid compiler warning
+
+ if (symtab->findAddress(lbl, addr)) {
+ return new T(system, desc, fixFuncEventAddr(addr),
+ std::forward<Args>(args)...);
+ }
+
+ return nullptr;
+ }
+
+ template <class T>
+ T *
+ addFuncEvent(const SymbolTable *symtab, const char *lbl)
+ {
+ return addFuncEvent<T>(symtab, lbl, lbl);
+ }
+
+ template <class T, typename... Args>
+ T *
+ addFuncEventOrPanic(const SymbolTable *symtab, const char *lbl,
+ Args... args)
+ {
+ T *e = addFuncEvent<T>(symtab, lbl, std::forward<Args>(args)...);
+ panic_if(!e, "Failed to find symbol '%s'", lbl);
+ return e;
+ }
+ /** @} */
+};
+
+#endif // __SIM_WORKLOAD_HH__