diff options
| author | taitep <taitep@taitep.se> | 2025-12-23 19:56:42 +0100 |
|---|---|---|
| committer | taitep <taitep@taitep.se> | 2025-12-23 19:56:42 +0100 |
| commit | 8ed4845d587eff7ba0252bedf34f98de8802153d (patch) | |
| tree | 56c6140eaddffef52802461ca435aeda001348e4 /src/main.rs | |
| parent | 36faa1e39c8675a84d7b7762d17e14640e991907 (diff) | |
ADD ELF SUPPORT
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs index aeedcb2..26b6a2e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,25 +22,7 @@ use anyhow::{Result, bail}; use crate::basic_uart::BasicUart; -fn read_file_to_buffer(path: &str, buffer: &mut [u8]) -> io::Result<usize> { - let mut file = File::open(path)?; - let mut total_read = 0; - - while total_read < buffer.len() { - let n = file.read(&mut buffer[total_read..])?; - if n == 0 { - return Ok(total_read); - } - total_read += n; - } - - let mut tmp = [0u8; 1]; - if file.read(&mut tmp)? != 0 { - return Err(io::Error::other("RAM too small for file")); - } - - Ok(total_read) -} +mod execload; fn main() -> Result<()> { let mut ram = Ram::try_new(16 * 1024 * 1024 / 4096)?; @@ -53,7 +35,7 @@ fn main() -> Result<()> { bail!("Wrong number of arguments"); } - read_file_to_buffer(&args[1], buf)?; + let entry_point = execload::load(&args[1], buf, 0x8000_0000)?; let uart = BasicUart::new(); let uart = uart.spawn_poller(Duration::from_millis(10)); @@ -76,7 +58,7 @@ fn main() -> Result<()> { }; let mut core = Core::new(mem_cfg); - core.reset(0x8000_0000); + core.reset(entry_point); core.run(); Ok(()) |
