From 45b6179e4c70997616fb1c5fb806b1e48ee2d220 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Tue, 12 Apr 2016 05:34:13 -0500 Subject: sim: Add an option to load additional kernel objects There are cases where it is desirable to load a kernel and a set of additional objects. This can, for example, be useful for testing where the bootstrap code can be loaded from one object (the kernel) and the test proper from another. This changeset adds this functionality by adding a kernel_extras vector parameter to the System class. Object files in this vector are loaded in order after the kernel when running in full system mode. Change-Id: I06f57c6a65a17b02eb4267bed0aa829f21bcfa3b Reviewed-on: https://gem5-review.googlesource.com/5703 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- src/sim/System.py | 1 + src/sim/system.cc | 12 ++++++++++++ src/sim/system.hh | 3 +++ 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/sim/System.py b/src/sim/System.py index 53377989d..68761384b 100644 --- a/src/sim/System.py +++ b/src/sim/System.py @@ -93,6 +93,7 @@ class System(MemObject): kernel = Param.String("", "file that contains the kernel code") kernel_addr_check = Param.Bool(True, "whether to address check on kernel (disable for baremetal)") + kernel_extras = VectorParam.String([],"Additional object files to load") readfile = Param.String("", "file to read startup script from") symbolfile = Param.String("", "file to get the symbols from") load_addr_mask = Param.UInt64(0xffffffffff, diff --git a/src/sim/system.cc b/src/sim/system.cc index 42cd5e720..9d0b919ca 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -174,6 +174,14 @@ System::System(Params *p) // Loading only needs to happen once and after memory system is // connected so it will happen in initState() } + + for (const auto &obj_name : p->kernel_extras) { + inform("Loading additional kernel object: %s", obj_name); + ObjectFile *obj = createObjectFile(obj_name); + fatal_if(!obj, "Failed to additional kernel object '%s'.\n", + obj_name); + kernelExtras.push_back(obj); + } } // increment the number of running systems @@ -312,6 +320,10 @@ System::initState() } // Load program sections into memory kernel->loadSections(physProxy, loadAddrMask, loadAddrOffset); + for (const auto &extra_kernel : kernelExtras) { + extra_kernel->loadSections(physProxy, loadAddrMask, + loadAddrOffset); + } DPRINTF(Loader, "Kernel start = %#x\n", kernelStart); DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd); diff --git a/src/sim/system.hh b/src/sim/system.hh index a656ab382..acd3108a0 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -229,6 +229,9 @@ class System : public MemObject /** Object pointer for the kernel code */ ObjectFile *kernel; + /** Additional object files */ + std::vector kernelExtras; + /** Beginning of kernel code */ Addr kernelStart; -- cgit v1.2.3