mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
gem5 arm cli args not working
This commit is contained in:
@@ -22095,6 +22095,12 @@ This works by:
|
||||
|
||||
It is worth noting that e.g. ARM has a <<semihosting>> mechanism for loading CLI arguments through `SYS_GET_CMDLINE`, but our mechanism works in principle for any ISA.
|
||||
|
||||
==== gem5 baremetal arm CLI args
|
||||
|
||||
Currently not supported, so we just hardcode argc 0 on the <<baremetal-bootloaders,arm baremetal bootloader>>.
|
||||
|
||||
I think we have to keep the CLI args below 32 GiB, otherwise argc cannot be correctly setup. But currently the gem5 text segment is exactly at 32 GiB, and we always place the CLI args higher in the <<baremetal-linker-script>>.
|
||||
|
||||
=== Semihosting
|
||||
|
||||
Semihosting is a publicly documented interface specified by ARM Holdings that allows us to do some magic operations very useful in development, such as writting to the terminal or reading and writing host files.
|
||||
|
||||
@@ -29,6 +29,17 @@ _start:
|
||||
|
||||
/* Run main. */
|
||||
mov r0, 0
|
||||
|
||||
#if 0
|
||||
/* Just turn CLI args off for now since not supported.
|
||||
* https://cirosantilli.com/linux-kernel-module-cheat#gem5-baremetal-arm-cli-args */
|
||||
ldr r0, =lkmc_argc
|
||||
ldr r0, [r0]
|
||||
ldr r1, =lkmc_argv
|
||||
#else
|
||||
/* Run main. */
|
||||
mov r0, 0
|
||||
#endif
|
||||
bl main
|
||||
|
||||
/* If main returns, exit. */
|
||||
|
||||
@@ -790,7 +790,9 @@ Incompatible archs are skipped.
|
||||
# just too many, and gem5 does not allow selecting lower feature in general.
|
||||
env['int_size'] = 4
|
||||
if env['arch'] == 'arm':
|
||||
env['address_size'] = 4
|
||||
# TODO this shoud be 4. But that blows up running all gem5 arm 32-bit examples.
|
||||
# https://cirosantilli.com/linux-kernel-module-cheat#gem5-baremetal-arm-cli-args
|
||||
env['address_size'] = 8
|
||||
env['armv'] = 7
|
||||
env['buildroot_toolchain_prefix'] = 'arm-buildroot-linux-gnueabihf'
|
||||
env['crosstool_ng_toolchain_prefix'] = 'arm-unknown-eabi'
|
||||
|
||||
7
run
7
run
@@ -494,7 +494,12 @@ Extra options to append at the end of the emulator command line.
|
||||
argv_addr_data = []
|
||||
argv_addr_cur = argv_data_addr
|
||||
for arg in cli_args:
|
||||
argv_addr_data.append(struct.pack('<{}'.format(self.python_struct_int_format(self.env['address_size'])), argv_addr_cur))
|
||||
argv_addr_data.append(struct.pack(
|
||||
'<{}'.format(
|
||||
self.python_struct_int_format(self.env['address_size'])
|
||||
),
|
||||
argv_addr_cur
|
||||
))
|
||||
argv_addr_cur += len(arg) + 1
|
||||
baremetal_cli_path = os.path.join(self.env['run_dir'], 'baremetal_cli.raw')
|
||||
with open(baremetal_cli_path, 'wb') as f:
|
||||
|
||||
Reference in New Issue
Block a user