gem5 arm cli args not working

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-06-16 01:00:00 +00:00
parent 1e170967d3
commit 7d32b26fde
4 changed files with 26 additions and 2 deletions

View File

@@ -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. 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
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. 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.

View File

@@ -29,6 +29,17 @@ _start:
/* Run main. */ /* Run main. */
mov r0, 0 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 bl main
/* If main returns, exit. */ /* If main returns, exit. */

View File

@@ -790,7 +790,9 @@ Incompatible archs are skipped.
# just too many, and gem5 does not allow selecting lower feature in general. # just too many, and gem5 does not allow selecting lower feature in general.
env['int_size'] = 4 env['int_size'] = 4
if env['arch'] == 'arm': 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['armv'] = 7
env['buildroot_toolchain_prefix'] = 'arm-buildroot-linux-gnueabihf' env['buildroot_toolchain_prefix'] = 'arm-buildroot-linux-gnueabihf'
env['crosstool_ng_toolchain_prefix'] = 'arm-unknown-eabi' env['crosstool_ng_toolchain_prefix'] = 'arm-unknown-eabi'

7
run
View File

@@ -494,7 +494,12 @@ Extra options to append at the end of the emulator command line.
argv_addr_data = [] argv_addr_data = []
argv_addr_cur = argv_data_addr argv_addr_cur = argv_data_addr
for arg in cli_args: 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 argv_addr_cur += len(arg) + 1
baremetal_cli_path = os.path.join(self.env['run_dir'], 'baremetal_cli.raw') baremetal_cli_path = os.path.join(self.env['run_dir'], 'baremetal_cli.raw')
with open(baremetal_cli_path, 'wb') as f: with open(baremetal_cli_path, 'wb') as f: