summaryrefslogtreecommitdiff
path: root/riscv/platform.ml
diff options
context:
space:
mode:
authorPrashanth Mundkur2018-06-07 11:03:58 -0700
committerPrashanth Mundkur2018-06-07 13:08:53 -0700
commit10a6c9a83405084092c26ce432051bbeae8f2f1a (patch)
tree3ee92bec8ee7191d432cb0ce42acadde56d3f525 /riscv/platform.ml
parent6eaf3159474aa62b9afee843b0983dcfb23a4157 (diff)
Add terminal output to riscv platform, with incomplete handling of input.
Diffstat (limited to 'riscv/platform.ml')
-rw-r--r--riscv/platform.ml9
1 files changed, 9 insertions, 0 deletions
diff --git a/riscv/platform.ml b/riscv/platform.ml
index 919900f4..485acb76 100644
--- a/riscv/platform.ml
+++ b/riscv/platform.ml
@@ -74,6 +74,15 @@ let rom_size () = bits_of_int !rom_size_ref
let dram_base () = bits_of_int64 P.dram_base
let dram_size () = bits_of_int64 P.dram_size
+(* terminal I/O *)
+let term_write char_bits =
+ let big_char = Big_int.bitwise_and (uint char_bits) (Big_int.of_int 255) in
+ P.term_write (char_of_int (Big_int.to_int big_char))
+
+let term_read () =
+ let c = P.term_read () in
+ bits_of_int (int_of_char c)
+
(* returns starting value for PC, i.e. start of reset vector *)
let init elf_file =
Elf.load_elf elf_file;