[14] | 1 | ################################################################################# |
---|
| 2 | # File : reset.s |
---|
| 3 | # Author : Alain Greiner |
---|
| 4 | # Date : 15/09/2010 |
---|
| 5 | ################################################################################# |
---|
| 6 | # This is an improved boot code : |
---|
| 7 | # - It initializes the Status Register (SR) |
---|
| 8 | # - It defines the stack size and initializes the stack pointer ($29) |
---|
| 9 | # - It initializes the interrupt vector with two ISR addresses. |
---|
| 10 | # - It configurates the ICU : IRQ_IN[0] & IRQ_IN[1] activated. |
---|
| 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_data_base |
---|
| 18 | .extern main |
---|
| 19 | .extern _isr_tty_get |
---|
| 20 | .extern _isr_timer0 |
---|
| 21 | |
---|
| 22 | .globl reset # makes reset an external symbol |
---|
| 23 | .ent reset |
---|
| 24 | .align 2 |
---|
| 25 | |
---|
| 26 | reset: |
---|
| 27 | .set noreorder |
---|
| 28 | |
---|
| 29 | # initializes stack pointer |
---|
| 30 | la $29, seg_stack_base |
---|
| 31 | addiu $29, $29, 0x4000 |
---|
| 32 | |
---|
| 33 | # initializes interrupt vector |
---|
| 34 | la $26, _interrupt_vector # interrupt vector address |
---|
| 35 | la $27, _isr_timer # isr_timer address |
---|
| 36 | sw $27, 0($26) # interrupt_vector[0] <= _isr_timer0 |
---|
| 37 | la $27, _isr_tty_get # isr_tty_get address |
---|
| 38 | sw $27, 4($26) # interrupt_vector[1] <= _isr_tty_get |
---|
| 39 | |
---|
| 40 | # initializes ICU |
---|
| 41 | la $26, seg_icu_base |
---|
| 42 | li $27, 0x3 # IRQ_IN[0] & IRQ_IN[1] enabled |
---|
| 43 | sw $27, 8($26) # ICU_MASK_SET 0x3 |
---|
| 44 | |
---|
| 45 | # initializes SR register |
---|
| 46 | li $26, 0x0000FF13 # IRQ activation |
---|
| 47 | mtc0 $26, $12 |
---|
| 48 | |
---|
| 49 | # jump to main in user mode |
---|
| 50 | la $26, main |
---|
| 51 | mtc0 $26, $14 |
---|
| 52 | eret |
---|
| 53 | |
---|
| 54 | .end reset |
---|
| 55 | .size reset, .-reset |
---|
| 56 | |
---|
| 57 | .set reorder |
---|