diff options
| author | Prashanth Mundkur | 2018-06-22 15:16:33 -0700 |
|---|---|---|
| committer | Prashanth Mundkur | 2018-06-22 17:46:59 -0700 |
| commit | c3b10065d3918be2d63cf12612ac00b59b02640b (patch) | |
| tree | fe4064375189fcc05cc6daef7de5a6f8f8f02c8a /riscv | |
| parent | d50d0283aa85abf3911fc57fc9b3f2f1900e067a (diff) | |
Add cli options to riscv simulator to dump platform device-tree info.
Diffstat (limited to 'riscv')
| -rw-r--r-- | riscv/platform.ml | 7 | ||||
| -rw-r--r-- | riscv/platform_impl.ml | 11 | ||||
| -rw-r--r-- | riscv/platform_main.ml | 14 |
3 files changed, 28 insertions, 4 deletions
diff --git a/riscv/platform.ml b/riscv/platform.ml index 10c79faf..0aac4884 100644 --- a/riscv/platform.ml +++ b/riscv/platform.ml @@ -66,6 +66,13 @@ let make_rom start_pc = let dtb = P.make_dtb P.dts in let rom = reset_vec @ dtb in ( rom_size_ref := List.length rom; + (* + List.iteri (fun i c -> + Printf.eprintf "rom[0x%Lx] <- %x\n" + (Int64.add P.rom_base (Int64.of_int i)) + c + ) rom; + *) rom ) let rom_base () = bits_of_int64 P.rom_base diff --git a/riscv/platform_impl.ml b/riscv/platform_impl.ml index 0902877a..aab272f8 100644 --- a/riscv/platform_impl.ml +++ b/riscv/platform_impl.ml @@ -154,13 +154,18 @@ let rec term_read () = (* todo: handle nbytes == 0 *) Bytes.get buf 0 +(* Platform diagnostics *) + +let show_bytes s = + output_string stdout s + +let dump_dts () = show_bytes dts +let dump_dtb () = show_bytes (bytes_to_string (make_dtb dts)) + (* let save_string_to_file s fname = let out = open_out fname in output_string out s; close_out out;; -let _ = - save_string_to_file dts "/tmp/platform.dts"; - save_string_to_file (bytes_to_string (get_dtb dts)) "/tmp/platform.dtb"; *) diff --git a/riscv/platform_main.ml b/riscv/platform_main.ml index 6014e7a9..e0032bf8 100644 --- a/riscv/platform_main.ml +++ b/riscv/platform_main.ml @@ -51,18 +51,30 @@ open Elf_loader open Sail_lib open Riscv +module P = Platform_impl (* OCaml driver for generated RISC-V model. *) let opt_file_arguments = ref ([] : string list) -let options = Arg.align [] +let opt_dump_dts = ref false +let opt_dump_dtb = ref false + +let options = Arg.align ([("-dump-dts", + Arg.Set opt_dump_dts, + " dump the platform device-tree source to stdout"); + ("-dump-dtb", + Arg.Set opt_dump_dtb, + " dump the *binary* platform device-tree blob to stdout"); + ]) let usage_msg = "RISC-V platform options:" let elf_arg = Arg.parse options (fun s -> opt_file_arguments := !opt_file_arguments @ [s]) usage_msg; + if !opt_dump_dts then (P.dump_dts (); exit 0); + if !opt_dump_dtb then (P.dump_dtb (); exit 0); ( match !opt_file_arguments with | f :: _ -> prerr_endline ("Sail/RISC-V: running ELF file " ^ f); f | _ -> (prerr_endline "Please provide an ELF file."; exit 0) |
