summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md13
-rw-r--r--src/main.rs12
2 files changed, 19 insertions, 6 deletions
diff --git a/README.md b/README.md
index f5d0631..ef919ce 100644
--- a/README.md
+++ b/README.md
@@ -8,12 +8,17 @@ potentially more. No plans for RV32I or RV32/64E.
Currently, the emulator is nowhere near complete,
its not even at rv64i, but it does work for a subset of it.
-The emulator will load a raw binary image from the file `./img` into RAM,
-which starts at 0x80000000 and is currently 1MiB,
+The emulator will load a raw binary image from a file specified as a CLI argument into RAM,
+which starts at 0x80000000 and is currently 16MiB,
and start execution at the start of the image/ram.
There is also a debug out page starting at `0x00000000`-`0x00001000`.
Anything written to it will be logged out in hex.
-Currently there is no input, altho i might get around to making
-an early UART kinda soon.
+There is also a UART at `0x00001000`-`0x00002000`, the interface is quite simple:
+- byte `0`: Data. When written, writes out the character
+ When read, reads a character from the buffer, or 0 if empty.
+- byte `1`: Status. Read-only. Least significant bit is `TX_READY` and indicates whether
+ the UART is ready to be written to. Currently always 1.
+ Next least significant is `RX_READY`, indicates whether the read buffer
+ has any data to read.
diff --git a/src/main.rs b/src/main.rs
index cdaa6eb..67186bb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,6 +5,7 @@
// See LICENSE file in the project root for full license text.
use std::{
+ env,
error::Error,
fs::File,
io::{self, Read},
@@ -41,9 +42,16 @@ fn read_file_to_buffer(path: &str, buffer: &mut [u8]) -> io::Result<usize> {
}
fn main() -> Result<(), Box<dyn Error>> {
- let mut ram = Ram::try_new(1024 * 1024 / 4096)?;
+ let mut ram = Ram::try_new(16 * 1024 * 1024 / 4096)?;
let buf = ram.buf_mut();
- read_file_to_buffer("./img", buf)?;
+
+ let args: Vec<String> = env::args().collect();
+
+ if args.len() != 2 {
+ eprintln!("USAGE: trve <ram_image>")
+ }
+
+ read_file_to_buffer(&args[1], buf)?;
let uart = BasicUart::new();
let uart = uart.spawn_poller(Duration::from_millis(10));