[15] | 1 | ################################################################################# |
---|
| 2 | # File : reset.s |
---|
| 3 | # Author : Alain Greiner |
---|
| 4 | # Date : 15/09/2010 |
---|
| 5 | ################################################################################# |
---|
| 6 | # This is an improved boot code supporting IOC and DMA peripherals : |
---|
| 7 | # - It initializes the Status Register (SR) |
---|
| 8 | # - It defines the stack sizes and initializes the stack pointers ($29) |
---|
| 9 | # - It initializes the interrupt vector with 4 ISR addresses |
---|
| 10 | # (tty, timer,dma,block-device), and initialises the ICU. |
---|
| 11 | # - It initializes the EPC register, and jumps to the main in user mode. |
---|
| 12 | ################################################################################# |
---|
| 13 | |
---|
| 14 | .section .reset,"ax",@progbits |
---|
| 15 | |
---|
| 16 | .extern seg_stack_base |
---|
| 17 | .extern seg_icu_base |
---|
| 18 | .extern _interrupt_vector |
---|
| 19 | .extern _isr_tty_get |
---|
| 20 | .extern _isr_timer |
---|
| 21 | .extern _isr_dma |
---|
| 22 | .extern _isr_ioc |
---|
| 23 | .extern main |
---|
| 24 | |
---|
| 25 | .globl reset # makes reset an external symbol |
---|
| 26 | .ent reset |
---|
| 27 | .align 2 |
---|
| 28 | |
---|
| 29 | reset: |
---|
| 30 | .set noreorder |
---|
| 31 | |
---|
| 32 | # initializes stack pointers |
---|
| 33 | la $29, seg_stack_base |
---|
| 34 | li $26, 0x40000 |
---|
| 35 | addu $29, $29, $26 # stack size = 256 Kbytes |
---|
| 36 | |
---|
| 37 | # initializes interrupt vector |
---|
| 38 | la $26, _interrupt_vector # interrupt vector address |
---|
| 39 | la $27, _isr_timer # isr_timer0 address |
---|
| 40 | sw $27, 0($26) # interrupt_vector[0] <= _isr_timer |
---|
| 41 | la $27, _isr_tty_get # isr_tty_get address |
---|
| 42 | sw $27, 4($26) # interrupt_vector[1] <= _isr_tty_get |
---|
| 43 | la $27, _isr_ioc # isr_io address |
---|
| 44 | sw $27, 20($26) # interrupt_vector[5] <= _isr_ioc |
---|
| 45 | la $27, _isr_dma # isr_tty_get address |
---|
| 46 | sw $27, 24($26) # interrupt_vector[6] <= _isr_dma |
---|
| 47 | |
---|
| 48 | # initializes ICU |
---|
| 49 | la $26, seg_icu_base |
---|
| 50 | li $27, 0x63 # IRQ_IN[0] IRQ_IN[1] IRQ[5] IRQ[6] |
---|
| 51 | sw $27, 8($26) # ICU_MASK_SET 0x3 |
---|
| 52 | |
---|
| 53 | # initializes SR register |
---|
| 54 | li $26, 0x0000FF13 # Interrupt enabled |
---|
| 55 | mtc0 $26, $12 # SR <= 0xFF13 |
---|
| 56 | |
---|
| 57 | # jump to main in user mode |
---|
| 58 | la $26, main |
---|
| 59 | mtc0 $26, $14 |
---|
| 60 | eret |
---|
| 61 | |
---|
| 62 | .align 2 |
---|
| 63 | |
---|
| 64 | .end reset |
---|
| 65 | .size reset, .-reset |
---|
| 66 | |
---|
| 67 | .set reorder |
---|