问题
I need memory to be setup in a given way immediately when simulation starts before any instructions are executed.
I understand that this is essentially what the ELF loader does to load the main executable, but trying to pass fs.py --kernel
multiple times appears to have no effect.
I could try to hack that data into my mail ELF executable with the linker script, but it would be much more convenient if I could avoid this and just provide either raw bytes on the CLI, or give a raw binary file to be loaded at a given address.
QEMU for example exposes this type of functionality with -device loader.
回答1:
Tested in gem5 f5f9ca46258ac2ded8f3402e5d271a18f8400183 (April 2020) I can achieve this with:
configs/example/fs.py \
--param 'system.workload.extras = "mydata.raw"' \
--param 'system.workload.extras_addrs = 0x83000000' \
where mydata.raw
contains the raw data to be loaded, and 0x83000000
is the base physical address to load to.
Both of those parameters are arrays, so you can load multiple raw binaries for example with:
configs/example/fs.py \
--param 'system.workload.extras = ["mydata.raw", "mydata2.raw"]' \
--param 'system.workload.extras_addrs = [0x83000000, 0x84000000]' \
This can be used for example to pass information to baremetal executables. For example, this could be used to implement baremetal command line arguments of a C program.
来源:https://stackoverflow.com/questions/60993870/how-to-preload-memory-with-given-raw-bytes-in-gem5-from-the-command-line-in-addi