From 90d7f45f0a5a631ad034a12c0617e1157781019d Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 18 Oct 2024 17:17:29 +0800 Subject: [PATCH] adjust locations of memory for USB loader and document the rationale --- loader/src/platform/cramium/usb/mod.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/loader/src/platform/cramium/usb/mod.rs b/loader/src/platform/cramium/usb/mod.rs index d2dd8346d..f50d835e4 100644 --- a/loader/src/platform/cramium/usb/mod.rs +++ b/loader/src/platform/cramium/usb/mod.rs @@ -6,10 +6,18 @@ pub use driver::*; pub use irq::*; pub use mass_storage::*; -// locate the "disk" at 1MiB -- middle of the SRAM region. This can be -// fine-tuned later. -const RAMDISK_ADDRESS: usize = utralib::HW_SRAM_MEM + 1024 * 1024; -const RAMDISK_LEN: usize = 512 * 1024; // 512k of RAM allocated to "disk" +// Locate the "disk" +// Memory layout is something like this: +// 0x6200_0000 regular stack grows down from here +// (fair bit of empty space - could grow RAM disk more) +// 0x6112_0000 RAM disk + 1MiB +// 0x6102_0000 RAM disk +// 0x6101_F000 scratch page (goes up one page from here) +// 0x6101_F000 exception stack (grows down) +// 0x6101_X000 "heap" would go here, except we don't have one +// 0x6100_0000 rw data for rust is at base of RAM +const RAMDISK_ADDRESS: usize = utralib::HW_SRAM_MEM + 128 * 1024; +const RAMDISK_LEN: usize = 1024 * 1024; // 1MiB of RAM allocated to "disk" const SECTOR_SIZE: u16 = 512; // Note that the trap handler is just placed one page below this, and it // needs to be manually updated in the assembly because we can't refer to