diff options
author | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2018-06-07 11:03:58 -0700 |
---|---|---|
committer | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2018-06-07 13:08:53 -0700 |
commit | 74e93f67f90639cdc9ebead88a8562ff0e3b099c (patch) | |
tree | 730dfe7c84fa9cec273bfd0e1fef1bddb248a5e6 /platform_impl.ml | |
parent | 3e086cf13b3616b03ca6e33a94e79df901b3944c (diff) | |
download | sail-riscv-74e93f67f90639cdc9ebead88a8562ff0e3b099c.zip sail-riscv-74e93f67f90639cdc9ebead88a8562ff0e3b099c.tar.gz sail-riscv-74e93f67f90639cdc9ebead88a8562ff0e3b099c.tar.bz2 |
Add terminal output to riscv platform, with incomplete handling of input.
Diffstat (limited to 'platform_impl.ml')
-rw-r--r-- | platform_impl.ml | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/platform_impl.ml b/platform_impl.ml index 1d2037a..9b06340 100644 --- a/platform_impl.ml +++ b/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 |