Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interrupt_vector_table:
- // ARM core does the following on interrupt:
- // 1) save cpsr into spsr
- // 2) set mode bits in current cpsr
- // 3) disable further interrupts of lower/same priority
- // 4) store return address in lr
- // 5) set pc to correct vector table entry below
- ldr pc, _reset_asm_handler // priority: 1st
- ldr pc, _undefined_instruction_asm_handler // priority: 6th
- ldr pc, _swi_asm_handler // priority: 6th
- ldr pc, _prefetch_abort_asm_handler // priority: 5th
- ldr pc, _data_abort_asm_handler // priority: 2nd
- ldr pc, _reset_asm_handler // priority: undefined
- ldr pc, _irq_asm_handler // priority: 4th
- ldr pc, _fiq_asm_handler // priority: 3rd
- /**
- * SOFT vector table that is loaded by install_vector_table ABOVE
- * interrupt_vector_table
- */
- // to make sure the addresses are aligned this must follow the
- // actual vector table above!
- _reset_asm_handler: .word reset_asm_handler
- _undefined_instruction_asm_handler: .word undefined_instruction_asm_handler
- _swi_asm_handler: .word swi_asm_handler
- _prefetch_abort_asm_handler: .word prefetch_abort_asm_handler
- _data_abort_asm_handler: .word data_abort_asm_handler
- _irq_asm_handler: .word irq_asm_handler
- _fiq_asm_handler: .word fiq_asm_handler
- /**
- * called to install the vector table at address 0x0
- */
- .global install_interrupt_table
- install_interrupt_table:
- copy the vector table into multiple registers
- copy the values of the vector table into the actual memory location
- do the same for soft vector table
- move lr into pc
- irq_asm_handler:
- push shit
- bl irq_c_handler
- pop shit
- cpsr/spsr somewhere inbetween
- //Everything restored
- movs pc, lr @ returns and sets flag like that thing you showed me
- reset_asm_handler:
- b _start // just reset the kernel
- /************************************************************
- * If you fall into one of these handlers something bad is
- * happening. bkpt will drop back into gdb so you can debug.
- ************************************************************/
- undefined_instruction_asm_handler:
- bkpt
- prefetch_abort_asm_handler:
- bkpt
- data_abort_asm_handler:
- bkpt
- fiq_asm_handler:
- bkpt
- /************************************************************/
- /* Initializes cpsr for user mode and jumps to user program */
- /************************************************************/
- .global enter_user_mode
- enter_user_mode:
- push {r0-r12}
- mrs r0, cpsr
- and r0, #0xffffff00
- add r0, #0xD0
- msr cpsr, r0
- ldr sp, =__user_stack_top
- bl __user_program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement