remove MPW ram init work-around

NTO boots clean, phew...
This commit is contained in:
bunnie 2025-08-10 01:51:12 +08:00
parent 7dd0ffaadd
commit 3eb0cf5891

View file

@ -20,56 +20,31 @@ pub extern "C" fn _start(_kernel_args: usize, loader_sig: usize) {
unsafe { unsafe {
#[rustfmt::skip] #[rustfmt::skip]
asm! ( asm! (
// test if ifram is cleared // Place the stack pointer at the end of RAM
"li t0, 0x50000000", "mv sp, {ram_top}",
"li t1, 0x50040000", // subtract four from sp to make room for a DMA "gutter"
"60:", "addi sp, sp, -4",
"lw t2, 0(t0)",
// if not 0, jump to clearing routine
"bne x0, t2, 30f",
"addi t0, t0, 4",
// loop if we haven't checked all of ifram
"bltu t0, t1, 60b",
// if we got here, all of ifram was 0, continue with boot
"j 50f",
// clear ifram // twiddle duart
"30:", "li t0, 0x40042000",
"sw x0, 0(t0)", // setup etuc
"addi t0, t0, 4", "sw x0, 0x4(t0)", // CR is 0
"bltu t0, t1, 30b", "li t1, 34", // tuned based on ringosc & oscope. not guaranteed to be precise
"sw t1, 0xc(t0)",
// clear main ram "li t1, 0x1",
"li t0, 0x61000000", "sw t1, 0x4(t0)", // CR is 1
"li t1, 0x61200000", // print 32 instances of 'Z' (0x5A) (provided to measure baud)
"20:", "li t2, 32",
"sw x0, 0(t0)", "li t1, 0x5A",
"addi t0, t0, 4", "10:",
"bltu t0, t1, 20b", "sw t1, 0x0(t0)",
"11:",
".word 0x500f", "lw t3, 0x8(t0)", // check SR
// reset the system "bne x0, t3, 11b", // wait for 0
"li t0, 0x40040080", "addi t2, t2, -1",
"li t1, 0x55aa", "bne x0, t2, 10b",
"70:",
"sw t1, 0(t0)",
"j 70b", // loop forever trying to trigger the reset
// Note that BMX access is unstable at this point in time due to the
// high number of parity errors that were flooding the system. Thus,
// the system has to go through a reset cycle before any further progress
// can be made.
// --------------------------------
// system should be rebooting at this point, code after this
// is unreachabale
// --------------------------------
// continue on boot // continue on boot
"50:",
);
}
unsafe {
#[rustfmt::skip]
asm! (
"li t0, 0xffffffff", "li t0, 0xffffffff",
"csrw mideleg, t0", "csrw mideleg, t0",
"csrw medeleg, t0", "csrw medeleg, t0",
@ -83,11 +58,6 @@ pub extern "C" fn _start(_kernel_args: usize, loader_sig: usize) {
"addi t0, t0, 4", "addi t0, t0, 4",
"bltu t0, t2, 100b", "bltu t0, t2, 100b",
// Place the stack pointer at the end of RAM
"mv sp, {ram_top}",
// subtract four from sp to make room for a DMA "gutter"
"addi sp, sp, -4",
// Install a machine mode trap handler // Install a machine mode trap handler
"la t0, abort", "la t0, abort",
"csrw mtvec, t0", "csrw mtvec, t0",