summaryrefslogtreecommitdiff
path: root/riscv/platform_impl.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_impl.ml
parent6eaf3159474aa62b9afee843b0983dcfb23a4157 (diff)
Add terminal output to riscv platform, with incomplete handling of input.
Diffstat (limited to 'riscv/platform_impl.ml')
-rw-r--r--riscv/platform_impl.ml11
1 files changed, 11 insertions, 0 deletions
diff --git a/riscv/platform_impl.ml b/riscv/platform_impl.ml
index 1d2037a6..9b063404 100644
--- a/riscv/platform_impl.ml
+++ b/riscv/platform_impl.ml
@@ -143,6 +143,17 @@ let make_dtb dts = (* Call the dtc compiler, assumed to be at /usr/bin/dtc *)
(Printf.printf "%s\n" ("Error executing dtc: " ^ fn ^ ": " ^ Unix.error_message e);
exit 1)
+(* Terminal I/O *)
+
+let term_write char =
+ ignore (Unix.write_substring Unix.stdout (String.make 1 char) 0 1)
+
+let rec term_read () =
+ let buf = Bytes.make 1 '\000' in
+ let nbytes = Unix.read Unix.stdin buf 0 1 in
+ (* todo: handle nbytes == 0 *)
+ buf.[0]
+
(*
let save_string_to_file s fname =
let out = open_out fname in