123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- #include <asm-offsets.h>
- #include <config.h>
- #include <asm/ptrace.h>
- #include <asm/sysreg.h>
- #define SYSREG_MMUCR_I_OFFSET 2
- #define SYSREG_MMUCR_S_OFFSET 4
- #define SR_INIT (SYSREG_BIT(GM) | SYSREG_BIT(EM) | SYSREG_BIT(M0))
- #define CPUCR_INIT ((SYSREG_BIT(BI) | SYSREG_BIT(BE) \
- | SYSREG_BIT(RE) | SYSREG_BIT(IBE) \
- | SYSREG_BIT(IEE)) & ~SYSREG_BIT(FE))
-
- .section .exception.text, "ax", @progbits
- .global _start
- .global _evba
- .type _start, @function
- .type _evba, @function
- _start:
- .size _start, 0
- _evba:
- .org 0x00
- rjmp unknown_exception
- .org 0x04
- rjmp unknown_exception
- .org 0x08
- rjmp unknown_exception
- .org 0x0c
- rjmp unknown_exception
- .org 0x10
- rjmp unknown_exception
- .org 0x14
- rjmp unknown_exception
- .org 0x18
- rjmp unknown_exception
- .org 0x1c
- rjmp unknown_exception
- .org 0x20
- rjmp unknown_exception
- .org 0x24
- rjmp unknown_exception
- .org 0x28
- rjmp unknown_exception
- .org 0x2c
- rjmp unknown_exception
- .org 0x30
- rjmp unknown_exception
- .org 0x34
- rjmp unknown_exception
- .org 0x38
- rjmp unknown_exception
- .org 0x3c
- rjmp unknown_exception
- .org 0x40
- rjmp unknown_exception
- .org 0x44
- rjmp unknown_exception
- .org 0x50
- pushm r8-r12,lr
- rjmp 1f
- .org 0x60
- pushm r8-r12,lr
- rjmp 1f
- .org 0x70
- pushm r8-r12,lr
- 1: mov r12, sp
- rcall mmu_handle_tlb_miss
- popm r8-r12,lr
- brne unknown_exception
- rete
- .size _evba, . - _evba
- .align 2
- .type unknown_exception, @function
- unknown_exception:
-
- csrfcz SYSREG_M1_OFFSET
- brcc at32ap_cpu_bootstrap
-
- pushm r0-r12
- sub r8, sp, REG_R12 - REG_R0 - 4
- mov r9, lr
- mfsr r10, SYSREG_RAR_EX
- mfsr r11, SYSREG_RSR_EX
- pushm r8-r11
- mfsr r12, SYSREG_ECR
- mov r11, sp
- rcall do_unknown_exception
- 1: rjmp 1b
-
- .global timer_interrupt_handler
- .type timer_interrupt_handler,@function
- .align 2
- timer_interrupt_handler:
-
- lda.w r8, timer_overflow
- ld.w r9, r8[0]
- mov r10, -1
- mtsr SYSREG_COMPARE, r10
- sub r9, -1
- st.w r8[0], r9
- rete
-
- .section .text.at32ap_cpu_bootstrap, "ax", @progbits
- .global at32ap_cpu_bootstrap
- .weak at32ap_cpu_bootstrap
- .type at32ap_cpu_bootstrap, @function
- .align 2
- at32ap_cpu_bootstrap:
-
- mov r0, lo(SR_INIT)
- orh r0, hi(SR_INIT)
- mtsr SYSREG_SR, r0
-
- mov r2, CPUCR_INIT
- mtsr SYSREG_CPUCR, r2
-
- mov r1, 0
- cache r1[4], 8
- cache r1[0], 0
- sync 0
-
- mov r0, SYSREG_BIT(MMUCR_S) | SYSREG_BIT(MMUCR_I)
- mtsr SYSREG_MMUCR, r0
-
-
- lddpc pc, 1f
- .align 2
- 1: .long at32ap_low_level_init
- .size _start, . - _start
-
- .section .text.avr32ap_low_level_init, "ax", @progbits
- .global at32ap_low_level_init
- .type at32ap_low_level_init, @function
- .align 2
- at32ap_low_level_init:
- lddpc sp, sp_init
-
- lddpc r6, got_init
- 3: rsub r6, pc
-
- rjmp board_init_f
- .align 2
- .type sp_init,@object
- sp_init:
- .long CONFIG_SYS_INIT_SP_ADDR
- got_init:
- .long 3b - _GLOBAL_OFFSET_TABLE_
-
- .section .text.relocate_code,"ax",@progbits
- .global relocate_code
- .type relocate_code,@function
- relocate_code:
- mov sp, r12
- mov r12, r11
- mov r11, r10
-
- lda.w r8, _text
- lda.w r9, _etext
- sub lr, r10, r8
- 1: ldm r8++, r0-r3
- stm r10, r0-r3
- sub r10, -16
- ldm r8++, r0-r3
- stm r10, r0-r3
- sub r10, -16
- cp.w r8, r9
- cache r10[-4], 0x0d
- cache r10[-4], 0x01
- brlt 1b
-
- sync 0
-
- lda.w r9, _edata
- 1: ld.d r0, r8++
- st.d r10++, r0
- cp.w r8, r9
- brlt 1b
-
- mov r0, 0
- mov r1, 0
- lda.w r9, __bss_end
- sub r9, r8
- 1: st.d r10++, r0
- sub r9, 8
- brgt 1b
-
- sub r0, pc, . - in_ram
- add pc, r0, lr
- .align 2
- in_ram:
-
- lddpc r6, got_init_reloc
- 3: rsub r6, pc
- mov r8, r6
- lda.w r9, _egot
- lda.w r10, _got
- sub r9, r10
- 1: ld.w r0, r8[0]
- add r0, lr
- st.w r8++, r0
- sub r9, 4
- brgt 1b
-
- mfsr r2, SYSREG_EVBA
- add r2, lr
- mtsr SYSREG_EVBA, r2
-
- call board_init_r
- .align 2
- got_init_reloc:
- .long 3b - _GLOBAL_OFFSET_TABLE_
- .size relocate_code, . - relocate_code
|