mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
gem5 semihosting
This commit is contained in:
16
README.adoc
16
README.adoc
@@ -747,6 +747,7 @@ Alternatively, for the sake of tab completion, we also accept full paths inside
|
|||||||
To use gem5 instead of QEMU do:
|
To use gem5 instead of QEMU do:
|
||||||
|
|
||||||
....
|
....
|
||||||
|
patch -d "$(./getvar gem5_src_dir)" -p 1 < patches/manual/gem5-semihost.patch && \
|
||||||
./configure --baremetal --gem5 && \
|
./configure --baremetal --gem5 && \
|
||||||
./build-gem5 --arch arm && \
|
./build-gem5 --arch arm && \
|
||||||
./build-crosstool-ng --arch arm && \
|
./build-crosstool-ng --arch arm && \
|
||||||
@@ -761,10 +762,9 @@ and then <<qemu-buildroot-setup,as usual>> open a shell with:
|
|||||||
./gem5-shell
|
./gem5-shell
|
||||||
....
|
....
|
||||||
|
|
||||||
TODO:
|
TODO: the carriage returns are a bit different than in QEMU, see: <<gem5-baremetal-carriage-return>>.
|
||||||
|
|
||||||
* the carriage returns are a bit different than in QEMU, see: <<gem5-baremetal-carriage-return>>.
|
The semihosting patch is required to enable <<semihosting>>, on which base functionality such as `exit()` depends, see also: https://stackoverflow.com/questions/52475268/how-to-enable-arm-semihosting-in-gem5/52475269#52475269
|
||||||
* semihosting is disabled, and all examples that rely on it fail, including how to enable it? See <<gem5-semihosting>>
|
|
||||||
|
|
||||||
Note that `./build-baremetal` requires the `--gem5` option, and generates separate executable images for both, as can be seen from:
|
Note that `./build-baremetal` requires the `--gem5` option, and generates separate executable images for both, as can be seen from:
|
||||||
|
|
||||||
@@ -9821,16 +9821,6 @@ Bibliography:
|
|||||||
* https://stackoverflow.com/questions/31990487/how-to-cleanly-exit-qemu-after-executing-bare-metal-program-without-user-interve/40957928#40957928
|
* https://stackoverflow.com/questions/31990487/how-to-cleanly-exit-qemu-after-executing-bare-metal-program-without-user-interve/40957928#40957928
|
||||||
* https://balau82.wordpress.com/2010/11/04/qemu-arm-semihosting/
|
* https://balau82.wordpress.com/2010/11/04/qemu-arm-semihosting/
|
||||||
|
|
||||||
==== gem5 semihosting
|
|
||||||
|
|
||||||
TODO how to enable it? <<config-ini>> contains:
|
|
||||||
|
|
||||||
....
|
|
||||||
root.system.semihosting=Null
|
|
||||||
....
|
|
||||||
|
|
||||||
and there are no hits under `configs/`.
|
|
||||||
|
|
||||||
=== gem5 baremetal carriage return
|
=== gem5 baremetal carriage return
|
||||||
|
|
||||||
TODO: our example is printing newlines without automatic carriage return `\r` as in:
|
TODO: our example is printing newlines without automatic carriage return `\r` as in:
|
||||||
|
|||||||
10
baremetal/arch/aarch64/no_bootloader/semihost_exit.S
Normal file
10
baremetal/arch/aarch64/no_bootloader/semihost_exit.S
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.global mystart
|
||||||
|
mystart:
|
||||||
|
mov x1, #0x26
|
||||||
|
movk x1, #2, lsl #16
|
||||||
|
str x1, [sp,#0]
|
||||||
|
mov x0, #0
|
||||||
|
str x0, [sp,#8]
|
||||||
|
mov x1, sp
|
||||||
|
mov w0, #0x18
|
||||||
|
hlt 0xf000
|
||||||
1
baremetal/interactive/README.adoc
Normal file
1
baremetal/interactive/README.adoc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
This folder contains examples that are not very testable: either are supposed to return 0, or are interactive, etc.
|
||||||
6
baremetal/interactive/exit1.c
Normal file
6
baremetal/interactive/exit1.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
@@ -119,6 +119,14 @@ def main(args, extra_args=None):
|
|||||||
bootloader_obj=bootloader_obj,
|
bootloader_obj=bootloader_obj,
|
||||||
common_obj=common_obj,
|
common_obj=common_obj,
|
||||||
)
|
)
|
||||||
|
build_dir(
|
||||||
|
'interactive',
|
||||||
|
gcc=gcc,
|
||||||
|
cflags=cflags,
|
||||||
|
entry_address=entry_address,
|
||||||
|
bootloader_obj=bootloader_obj,
|
||||||
|
common_obj=common_obj,
|
||||||
|
)
|
||||||
arch_dir = os.path.join('arch', args.arch)
|
arch_dir = os.path.join('arch', args.arch)
|
||||||
if os.path.isdir(os.path.join(common.baremetal_src_dir, arch_dir)):
|
if os.path.isdir(os.path.join(common.baremetal_src_dir, arch_dir)):
|
||||||
build_dir(
|
build_dir(
|
||||||
|
|||||||
12
patches/manual/gem5-semihost.patch
Normal file
12
patches/manual/gem5-semihost.patch
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
diff --git a/configs/example/fs.py b/configs/example/fs.py
|
||||||
|
index 3997ed76c..43bebcd66 100644
|
||||||
|
--- a/configs/example/fs.py
|
||||||
|
+++ b/configs/example/fs.py
|
||||||
|
@@ -376,5 +376,7 @@ if buildEnv['TARGET_ISA'] == "arm" and options.generate_dtb:
|
||||||
|
sys = getattr(root, sysname)
|
||||||
|
sys.dtb_filename = create_dtb_for_system(sys, '%s.dtb' % sysname)
|
||||||
|
|
||||||
|
+from m5.objects import ArmSemihosting
|
||||||
|
+test_sys.semihosting = ArmSemihosting()
|
||||||
|
Simulation.setWorkCountOptions(test_sys, options)
|
||||||
|
Simulation.run(options, root, test_sys, FutureClass)
|
||||||
Reference in New Issue
Block a user