Compare commits
	
		
			No commits in common. "a908bcc0e4285ea464f738762f16dabc5efc7cbc" and "c70be3fe1f95ed931fb3bc009010cad8cfed0f02" have entirely different histories.
		
	
	
		
			a908bcc0e4
			...
			c70be3fe1f
		
	
		
							
								
								
									
										35
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								src/main.rs
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -39,21 +39,8 @@ unsafe extern "C" fn _enter() -> ! {
 | 
			
		|||
        // set the stack pointer
 | 
			
		||||
        "la sp, _init_stack_top",
 | 
			
		||||
 | 
			
		||||
        // We use mret here so that the mstatus register
 | 
			
		||||
        // is properly updated.
 | 
			
		||||
        "li t0, (0b11 << 11) | (1 << 7) | (1 << 3)",
 | 
			
		||||
        "csrw mstatus, t0",
 | 
			
		||||
        
 | 
			
		||||
        // Set mtvec to the location of our trap handler function
 | 
			
		||||
        "la t1, {trap_vector}",
 | 
			
		||||
        "csrw mtvec, t1",
 | 
			
		||||
 | 
			
		||||
        // Set MSIE, MTIE, and MEIE on machine interrupt enable CSR:
 | 
			
		||||
        //   MSIE to enable machine-/M-mode software interrupts
 | 
			
		||||
        //   MTIE to enable M-mode timer interrupts
 | 
			
		||||
        //   MEIE to enable M-mode external interrupts
 | 
			
		||||
        "li t2, (1 << 3) | (1 << 7) | (1 << 11)",
 | 
			
		||||
        "csrw mie, t2",
 | 
			
		||||
        "la t2, {trap_vector}",
 | 
			
		||||
        "csrw mtvec, t2",
 | 
			
		||||
 | 
			
		||||
        // clear the BSS
 | 
			
		||||
        "la t0, _bss_start",
 | 
			
		||||
| 
						 | 
				
			
			@ -109,24 +96,12 @@ extern "C" fn start() -> ! {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[no_mangle]
 | 
			
		||||
extern "C" fn eh_personality() {}
 | 
			
		||||
 | 
			
		||||
#[panic_handler]
 | 
			
		||||
fn panic(info: &PanicInfo) -> ! {
 | 
			
		||||
    // print panic info and abort
 | 
			
		||||
fn on_panic(info: &PanicInfo) -> ! {
 | 
			
		||||
    // print panic info and hang
 | 
			
		||||
    println!("{}", info);
 | 
			
		||||
    abort();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[no_mangle]
 | 
			
		||||
extern "C" fn abort() -> ! {
 | 
			
		||||
    use core::arch::asm;
 | 
			
		||||
    loop {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            asm!("wfi");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    loop {}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO unit testing
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue