From 7ef0bba057d634f7596f94000233cd36ebdd2fff Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Thu, 21 Jun 2018 19:02:06 +0100 Subject: Add command line option support for Sail->C compiled models For example, the MIPS model can boot FreeBSD as ./mips_c --binary=0x100000,/path/to/kernel --image=/path/to/simboot.sailbin Or with short options as ./mips_c -b 0x100000,/path/to/kernel -i /path/to/simboot.sailbin The current options are: -e, --elf, which loads an elf file directly -n, --entry, which sets the entry point -i, --image, which loads an image file compiled by "sail -elf" using Linksem -b, --binary, which loads a plain binary image into memory at a specific address -l, --cyclelimit, which means the (new) cycle_count() builtin exits the model after a certain number of calls Also there are the default -? --help and --usage options. --- src/c_backend.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/c_backend.ml b/src/c_backend.ml index f58dd71f..450e5f5d 100644 --- a/src/c_backend.ml +++ b/src/c_backend.ml @@ -3374,8 +3374,8 @@ let compile_ast ctx (Defs defs) = let postamble = separate hardline (List.map string ( [ "int main(int argc, char *argv[])"; "{"; - " if (argc > 1) { load_image(argv[1]); }"; - " setup_rts();" ] + " setup_rts();"; + " if (process_arguments(argc, argv)) exit(EXIT_FAILURE);" ] @ fst exn_boilerplate @ startup cdefs @ List.concat (List.map (fun r -> fst (register_init_clear r)) regs) -- cgit v1.2.3