diff options
author | Adrian Herrera <adrian.herrera@arm.com> | 2019-11-14 20:41:50 +0000 |
---|---|---|
committer | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2019-12-18 09:15:32 +0000 |
commit | e4c7ea67b81af4a915868a4f7babc46a53d6194c (patch) | |
tree | d4a1964aa4da6b9d12542b2bc70125dc1a6c4fff /src | |
parent | 1a2dcccaee4c76a73378b4fd5ac910a818fff7af (diff) | |
download | gem5-e4c7ea67b81af4a915868a4f7babc46a53d6194c.tar.xz |
sim: kernelExtras optional load addresses
This patch provides a new "System" parameter named "kernel_extras_addrs".
This allows to optionally specify fixed load addresses for the
additional kernel objects. This is useful to load arbitrary blobs into
memory.
Change-Id: I4725763b86c29f72282d1c184d4284d90f9d3016
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23566
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/sim/System.py | 6 | ||||
-rw-r--r-- | src/sim/system.cc | 25 |
2 files changed, 23 insertions, 8 deletions
diff --git a/src/sim/System.py b/src/sim/System.py index 9928887b9..619b54ed1 100644 --- a/src/sim/System.py +++ b/src/sim/System.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 ARM Limited +# Copyright (c) 2017, 2019 ARM Limited # All rights reserved. # # The license below extends only to copyright in the software and shall @@ -107,7 +107,9 @@ class System(SimObject): 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") + kernel_extras = VectorParam.String([], "Additional object files to load") + kernel_extras_addrs = VectorParam.Addr([], + "Load addresses for additional object files") readfile = Param.String("", "file to read startup script from") symbolfile = Param.String("", "file to get the symbols from") load_addr_mask = Param.UInt64(0xffffffffffffffff, diff --git a/src/sim/system.cc b/src/sim/system.cc index 8c438086b..97ebd1d7c 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -192,10 +192,15 @@ System::System(Params *p) // 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", + if (p->kernel_extras_addrs.empty()) + p->kernel_extras_addrs.resize(p->kernel_extras.size(), MaxAddr); + fatal_if(p->kernel_extras.size() != p->kernel_extras_addrs.size(), + "Additional kernel objects, not all load addresses specified\n"); + for (int ker_idx = 0; ker_idx < p->kernel_extras.size(); ker_idx++) { + const std::string &obj_name = p->kernel_extras[ker_idx]; + const bool raw = p->kernel_extras_addrs[ker_idx] != MaxAddr; + ObjectFile *obj = createObjectFile(obj_name, raw); + fatal_if(!obj, "Failed to build additional kernel object '%s'.\n", obj_name); kernelExtras.push_back(obj); } @@ -360,8 +365,16 @@ System::initState() DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry); DPRINTF(Loader, "Kernel loaded...\n"); } - for (const auto &extra_kernel : kernelExtras) - extra_kernel->buildImage().move(mapper).write(physProxy); + std::function<Addr(Addr)> extra_mapper; + for (auto ker_idx = 0; ker_idx < kernelExtras.size(); ker_idx++) { + const Addr load_addr = params()->kernel_extras_addrs[ker_idx]; + auto image = kernelExtras[ker_idx]->buildImage(); + if (load_addr != MaxAddr) + image = image.offset(load_addr); + else + image = image.move(mapper); + image.write(physProxy); + } } } |