📄 starto.s.bak1
字号:
####################################### Jump to normal BIOS startup code ####################################### nop# FLASH_LED(0x07) FLASH_GPIO(0x07) li a0, 0x04000000 la a3, initmips jr a3 nop1: bal 1b j start .end start####################################### Fatal Exception Handler Entry ####################################### .globl fatalException .ent fatalExceptionfatalException:#if 0 mfc0 a0, C0_EPC mfc0 a1, C0_CAUSE move a2, ra mfc0 a3, C0_BADADDR jal printfEPC#else mfc0 a0, C0_CAUSE srl a0, a0, 2 and a0, a0, 0x3f bal __led_display#endif1: bal 1b # Endless Jump to itself .end fatalException################################################### copyExcVec Function Entry ## ## Params: ## a0 = Src ExcVec Start Addr ## a1 = Src ExcVec End Addr ## a2 = Dst ExcVec Addr ## Volatile: ## a0, a1 ################################################### .globl copyExcVec .ent copyExcVeccopyExcVec: or t0, a0, K1BASE # Force a0&a1 to K1 Seg or t1, a1, K1BASE or a2, K1BASE 1: lr v0, (t0) sr v0, (a2) addu t0, REGSZ addu a2, REGSZ bltu t0, t1, 1b j ra .end copyExcVec####################################### General Exception Handler Entry ####################################### .globl excHandler .ent excHandler#if __mips >= 3 .align 3#endifexcHandler: .set noat MFC0 k0, C0_CAUSE li k1, 0 and k0, CAUSE_EXCMASK or k1, CEXC_RI beq k0, k1, rsvdInstException nop li k1, 0 or k1, CEXC_INT beq k0, k1, 1f nop la k0, fatalException j k0 nop1: li a0, 0x99 bal __led_display nop ereteExcHandler: # End of General Exception Handler .set at .end excHandler####################################### RsvdInst Exception Handler Entry ####################################### .globl rsvdInstException .ent rsvdInstExceptionrsvdInstException: .set noat SAVE_ALL # Context save .set at move a0, sp # re-reset SP pointer for delay slot HALT #jal doRI # Outside reservtion instruction routine .set noat RESTORE_ALL # Context restore .set at eret # Recover from exeception .end rsvdInstException#if 0#define com1port_cmd (PCI_IO_SPACE + UART0_PORT)#define com1port_stat (PCI_IO_SPACE + UART0_STATPORT)#define TXWAIT 10000LEAF(tgt_putchar) li t0,TXWAIT # timeout1: lbu t1,PA_TO_KVA1(com1port_stat) # get LSR and t1,0x20 # tx ready? bnez t1,1f nop # yup - go and write subu t0,1 # continue until timeout bnez t0,1b nop1: sb a0,PA_TO_KVA1(com1port_cmd) # write data j ra nopEND(tgt_putchar)#else#define TXWAIT (0x13)#define __TXWAIT (0x12)#define com1port_cmd (PCI_IO_SPACE + UART0_PORT)#define com1port_stat (PCI_IO_SPACE + UART0_STATPORT)LEAF(tgt_putchar) li t0, TXWAIT # timeout1: lbu t1, PA_TO_KVA1(com1port_stat) # get LSR and t1, 0x20 # tx ready? bnez t1, 1f # can write2: li t1, __TXWAIT # Wait a while3: subu t1, 1 bnez t1, 3b subu t0, 1 # continue until timeout bnez t0, 1b1: sb a0, PA_TO_KVA1(com1port_cmd) # write data j ra nopEND(tgt_putchar)#endif####################################### Test SDRAM Module #######################################LEAF(doMemTestX) .set macro .set noreorder#if 1#define MEM_BOT (0xA0000000) /* 64MB */#define MEM_TOP (0xA4000000) /* 64MB */#define MEM_STEP (0x04)#else#define MEM_BOT (0xA0000000) /* 64MB */#define MEM_TOP (0xA1000000) /* 64MB */#define MEM_STEP (0x02000)#endif move t9, ra FLASH_GPIO(0x00)/* Store data into SDRAM */ UART_OUTCH('\r') UART_OUTCH('\n') UART_OUTCH('S') UART_OUTCH('D') UART_OUTCH('R') UART_OUTCH('A') UART_OUTCH('M') UART_OUTCH(' ') UART_OUTCH('T') UART_OUTCH('e') UART_OUTCH('s') UART_OUTCH('t') UART_OUTCH('i') UART_OUTCH('n') UART_OUTCH('g') UART_OUTCH('.') UART_OUTCH('.') UART_OUTCH('.') li t5, 0x0 nop111: move t4, t5 li t2, MEM_BOT li t3, MEM_TOP1: sw t4, (t2) nop move t7, t4 and t7, 0x0000ffff bnez t7, 11f nop nop UART_OUTCH('\r') UART_OUTCH('\n') move a0, t4 nop bal print nop11: addiu t2, MEM_STEP addiu t4, 0x1 bne t2, t3, 1b nop/* Check data in SDRAM */ UART_OUTCH('\r') UART_OUTCH('\n') UART_OUTCH('C') UART_OUTCH('h') UART_OUTCH('e') UART_OUTCH('c') UART_OUTCH('k') UART_OUTCH('i') UART_OUTCH('n') UART_OUTCH('g') UART_OUTCH('.') UART_OUTCH('.') UART_OUTCH('.') li t2, MEM_BOT li t3, MEM_TOP2: lw t4, (t2) bne t4, t5, 3f nop112: addiu t2, MEM_STEP addiu t5, 0x1 bne t2, t3, 2b nop bne t5, 0xffffffff, 111b nop UART_OUTCH('\r') UART_OUTCH('\n') UART_OUTCH('T') UART_OUTCH('e') UART_OUTCH('s') UART_OUTCH('t') UART_OUTCH(' ') UART_OUTCH('e') UART_OUTCH('n') UART_OUTCH('d') UART_OUTCH('.') UART_OUTCH('\r') UART_OUTCH('\n') move ra, t9 j ra nop######################### some error occured ! #########################3: UART_OUTCH('\r') UART_OUTCH('\n') move a0, t2 nop bal print nop UART_OUTCH(' ') UART_OUTCH(' ') UART_OUTCH(' ') nop move a0, t5 nop bal print nop UART_OUTCH(' ') UART_OUTCH(' ') UART_OUTCH(' ') move a0, t4 nop bal print nop b 112b nop .set reorderEND(doMemTestX)####################################### Print 32bit Integer in reg a0 #######################################LEAF(print) .set noreorder move t9, ra move t6, a0 li t7, 82: and a0, 0x0F blt a0, 0x0A, 3f nop subu a0, 0x0a addu a0, 'A' j 4f nop3: addu a0, '0'4: bal tgt_putchar nop srl t6, 4 move a0, t6 subu t7, 1 bnez t7, 2b nop move ra, t9 j ra nop .set reorderEND(print)##################### flash_gpio entry #####################LEAF(__flash_gpio) li t1, 0xb4013802 li t0, 0x550 sh t0, (t1) subu t1, t1, 2 move t0, a0 sll t0, 2 sb t0, (t1) MK_LAT(GPIO_LOOP) j raEND(__flash_gpio)############################### led display##############################LEAF(__led_display) li t0, 0xb80000f0 sb a0, (t0) li t0, 20009: subu t0, 1 bne t0, 0, 9b nop j raEND(__led_display)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -