📄 led_intvecs_a9.s
字号:
;******************************************************************************
; TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
;
; Property of Texas Instruments. For Unrestricted Internal Use Only.
; Unauthorized reproduction and/or distribution is strictly prohibited.
; This product is protected under copyright law and trade secret law
; as an unpublished work.
;
; Created 2002, (C) Copyright 2002 Texas Instruments. All rights reserved.
;
; Filename : led_intvecs2_a9.s
;
; Author : Dayo Adeyeye, xnc02191@ti.com
;
; Created : 10th of October, 2002, 9.00am
;
; Project : Helen2. OMAP1610 Production DFT Led Exec code
;
; Tools : ARM tools, ARM926EJ-S
;
; Description :
; Declare interrupt/exception vector sections readonly
; Declare entry and return label for interrupt handlers
;
;
;
;*******************************************************************************
CODE32
;; IMPORTED DATA/LABEL DECLARATION
IMPORT __main ; IMPORT __main = prog_entry
IMPORT EX_AbortD ; IMPORT EX_AbortD
IMPORT EX_Irq ; IMPORT EX_Irq
IMPORT EX_Fiq ; IMPORT EX_Fiq
IMPORT RES_Exception_LED ; LED exception Handler
;; EXPORTED DATA/LABEL DECLARATION
EXPORT _reset ; EXPORT _reset
EXPORT ledINT_Swi ; EXPORT ledINT_Swi
EXPORT ledINT_SetSupervisor ; EXPORT ledINT_SetSupervisor
EXPORT ledINT_SetUser ; EXPORT ledINT_SetUser
EXPORT ledINT_SetIRQBit ; EXPORT ledINT_SetIRQBit
EXPORT ledINT_ClearIRQBit ; EXPORT ledINT_ClearIRQBit
EXPORT ledINT_SetFIQBit ; EXPORT ledINT_SetFIQBit
EXPORT ledINT_ClearFIQBit ; EXPORT ledINT_ClearFIQBit
EXPORT DumpSPY_Results
;; DECLARE STACKS AREA, For TI tools stacks are allocated when needed.
AREA usr_stack,DATA,READWRITE
usr_stack_value
AREA svc_stack,DATA,READWRITE
svc_stack_value
AREA irq_stack,DATA,READWRITE
irq_stack_value
AREA fiq_stack,DATA,READWRITE
fiq_stack_value
AREA und_stack,DATA,READWRITE
und_stack_value
AREA abt_stack,DATA,READWRITE
abt_stack_value
;; INTERRUPT VECTORS SECTION START
;; Declare Interrupt vectors Branch Table code area
AREA |.int_tbl|,CODE,READONLY ; Named sections for int vector code area
CODE32
ENTRY
;; Interrupt Vectors Branch Table
_reset
b InitTest ; RESET INTERRUPT
undef_vector
b undef_handler ; UNDEFINED INSTRUCTION INTERRUPT
swi_vector
ldr pc, =ledINT_Swi ; SOFTWARE INTERRUPT HANDLER
abortI_vector
b abortI_handler ; ABORT (PREFETCH) INTERRUPT
abort_data_vector
b abortD_handler ; ABORT (DATA) INTERRUPT
reserved_vector
b reserved_handler ; RESERVED
irq_vector
b irq_handler ; IRQ INTERRUPT HANDLER
fiq_vector
b fiq_handler ; FIQ INTERRUPT HANDLER
;; Interrupt Vectors Handlers
irq_handler
stmfd sp!, {r0-r12,lr}
ldr r0,=EX_Irq ; IRQ INTERRUPT HANDLER
blx r0
ldmfd sp!, {r0-r12,lr}
subs pc, lr, #0x4
; ldr pc,=EX_Irq ; IRQ INTERRUPT HANDLER
fiq_handler
stmfd sp!, {r0-r12,lr}
ldr r0,=EX_Fiq ; FIQ INTERRUPT HANDLER
blx r0
ldmfd sp!, {r0-r12,lr}
subs pc, lr, #0x4
; ldr pc,=EX_Fiq ; FIQ INTERRUPT HANDLER
abortD_handler
stmfd sp!, {r0-r12,lr}
ldr r0,=EX_AbortD ; ABORT (DATA) INT HANDLER
blx r0
ldmfd sp!, {r0-r12,lr}
movs pc, lr
; ldr pc,=EX_AbortD ; ABORT (DATA) INT HANDLER
undef_handler
abortI_handler
reserved_handler
str lr, [sp] ; Save Undef LR b4 SVC mode
mrs r7, cpsr ; Take a copy of CPSR
bic r7,r7,#IMODE_MASK ; Clear all mode bits
orr r7,r7,#SVC_MODE ; Set Supervisor Mode bits for CPSR
msr cpsr_cxsf, r7 ; Write back the modified CPSR
add r7, pc, #0x1
bx r7
CODE16 ; CPU in Thumb state & supervisor mode for code density
bl RES_Exception_LED
dump32mode
b dump32mode
;; =============================================================================
;; =============================================================================
;; Thumb state Software Interrupt Handlers
AREA |.text|,CODE,READONLY
CODE16
; ledINT_SetSupervisor()
; Perform SWI to switch to supervisor mode
ledINT_SetSupervisor
mov r3, lr
swi 0xFA ; 0xFA : Enable ledINT_Swi
mov pc, r3
; ledINT_SetUser()
; Perform SWI to switch to User mode
ledINT_SetUser
mov r3, lr
swi 0xFB ; 0xFB : Enable ledINT_Swi
mov pc, r3
; ledINT_SetIRQBit, Set IRQ bit of PSR (Program Status Register)
; (Disable IRQ)
ledINT_SetIRQBit
mov r3, lr
swi 0xF0 ; 0xF0 : Set IRQ Bit of PSR
mov pc, r3
; ledINT_ClearIRQBit, Clear IRQ bit of PSR (Program Status Register)
; (Enable IRQ)
ledINT_ClearIRQBit
mov r3, lr
swi 0xF1 ; 0xF1 : Clear IRQ Bit of PSR
mov pc, r3
; ledINT_SetFIQBit, Set FIQ bit of PSR (Program Status Register)
; (Disable FIQ)
ledINT_SetFIQBit
mov r3, lr
swi 0xF2 ; 0xF2 : Set FIQ Bit of PSR
mov pc, r3
; ledINT_ClearFIQBit, Clear FIQ bit of PSR (Program Status Register)
; (Enable FIQ)
ledINT_ClearFIQBit
mov r3, lr
swi 0xF3 ; 0xF3 : Clear FIQ Bit of PSR
mov pc, r3
;; =============================================================================
;; =============================================================================
AREA |.swint|,CODE,READONLY ; Sections code area for TI tools
CODE32
; Software Interrupt Vector Handlers
; ledINT_Swi(unsigned stack, unsigned stackSize)
; R0 R1
; Enable exception and set up a stack (Don't use R3)
; Works only if called from 16-bit (THUMB) mode
ledINT_Swi
ldrh r4, [lr, #-2] ; retrieve SWI parameter
and r4, r4, #0xFF ; maskout all, keep argument only
cmp r4, #0xFB ; 0x1111_1011
beq SetUser ; Change to uP User mode
cmp r4, #0xFA ; 0x1111_1010
beq SetSupervisor ; Change to uP Supervisor mode
cmp r4, #0xF3 ; 0x1111_0011
beq ClearFIQBit ; Enable FIQ Interrupt
cmp r4, #0xF2 ; 0x1111_0010
beq SetFIQBit ; Disable FIQ interrupt
cmp r4, #0xF1 ; 0x1111_0001
beq ClearIRQBit ; Enable IRQ Interrupt
cmp r4, #0xF0 ; 0x1111_0000
beq SetIRQBit ; Disable IRQ interrupt
b ExitSwi ; not handled, Exit SWI
;; DEFINE/VAR DECLARATION
IRQ_MASK EQU 0x80 ; IRQ mask value, bit 7.
FIQ_MASK EQU 0x40 ; FIQ mask value, bit 6
MODE_MASK EQU 0x1F ; Processor Mode Mask bit 0 -> 4.
IMODE_MASK EQU 0x9F ; Int I and Mode Mask bit 0 -> 4 & 7.
USR_MODE EQU 0x10 ; User Mode
FIQ_MODE EQU 0x11 ; Fast Interrupt Mode (FIQ)
IRQ_MODE EQU 0x12 ; Interrupt Mode (IRQ)
SVC_MODE EQU 0x13 ; Supervisor Mode
ABORT_MODE EQU 0x17 ; Abort Mode
;UNDEF_MODE EQU 0x1B ; Undefined Instruction Mode
;SYSTEM_MODE EQU 0x1F ; Privileged System User Mode
CLEAR_BIT EQU 0x00 ; Clear Bit
SET_BIT EQU 0x01 ; Set Bit
SetSupervisor
mrs r7, spsr ; Take a copy of Saved PSR
bic r7,r7,#IMODE_MASK ; Clear all mode bits
orr r7,r7,#SVC_MODE ; Set Supervisor Mode bits for SPSR
msr spsr_cxsf, r7 ; Write back the modified SPSR
b ExitSwi ; not handled
SetUser
mrs r7, spsr ; Get copy of Saved PSR
bic r7,r7,#IMODE_MASK ; Clear all mode bits
orr r7,r7,#USR_MODE ; Set User Mode bits for SPSR
msr spsr_cxsf,r7 ; Write back the modified SPSR
b ExitSwi ; not handled
SetIRQBit
mov r5, #IRQ_MASK
mov r6, #SET_BIT
b SetClearFIQIRQ
ClearIRQBit
mov r5, #IRQ_MASK
mov r6, #CLEAR_BIT
b SetClearFIQIRQ
SetFIQBit
mov r5, #FIQ_MASK
mov r6, #SET_BIT
b SetClearFIQIRQ
ClearFIQBit
mov r5, #FIQ_MASK
mov r6, #CLEAR_BIT
b SetClearFIQIRQ
SetClearFIQIRQ
mrs r7, SPSR ; read saved PSR
bic r7, r7, r5 ; clear FIQ or IRQ bit of saved PSR
cmp r6, #CLEAR_BIT ; Test if to CLEAR or SET INTERRUPT Bits
beq STORE_SPSR ; do not set any bit of saved PSR
orr r7, r7, r5 ; set FIQ or IRQ bit of saved PSR
STORE_SPSR
msr spsr_cxsf, r7 ; store saved PSR to set or clear FIQ or IRQ bit
ExitSwi
movs pc, lr ; return from SWI, ldr pc, =lr
;; ====================================================================
;; ====================================================================
;; Execution BOOT CODE SECTION START
AREA |.execled|,CODE,READONLY
CODE32
InitTest
;; ARM 32bit State
; Basic Initializations and Testmode detection
;; Thumb 16bit State
; Sets up SVC Supervisor STACK = 0x20000A00
; Sets up Undefined Instruction stack = 0x20000144
; Sets up DATA ABORT stack = 0x20000804
; Sets up FIQ stack and enable FIQ = 0x20000900
; Sets up IRQ stack and enable IRQ = 0x200001C0
;; ARM 32bit State
; Flush & Invalidate all Icache & Dcache
; Flush & Invalidate all TLB
; Enable Instruction Cache Only
;; Thumb 16bit State
; Releases ARMPERRST
;; No Spy dump issues here as ULPD and DPLL are in bypass mode
; Sets ULPD to 19.2MHz instead of 12MHz, with 64*6 = 384 clk cycles timeout.
; Enable and Set DPLL to CK_REF, with 64 * 6 = 384 clk cycles timeout.
; EMIFF setups are not applicable to Helen2 LED DFT
; Enables all Idle select and wakeup
; Enables ARMPERCK and ARMXORCK, LCDCK, APICK and no DPLL OUT
; Enables T1CK and idle
; Store BOOTROM TLB MMU Translation Table in TestSRAM (Re-mapped later for Test)
; Store SPY Space TLB MMU Translation Table in TestSRAM
; Store FLASH Address TLB MMU Translation Table in TestSRAM
; Store TestSRAM Address TLB MMU Translation Table in TestSRAM
; Store all OMAP Rhea Address TLB MMU Translation Table in TestSRAM
; Enable abort generation on ARM public and private Rhea bridge
; Configure DMA for LCD reset only (TBD)
; Initialize/Reset to zero ARM926EJ-S internal registers.
;; ARM 32bit State
; Write TTB value to register = 0x20000000
; Write ARM WR DOMAIN Access permission REG
; Write Enable MMU and Dchache together
; Check User JTAG for atspeed test and Setup CFG initialization
;; Thumb 16bit State in C code
; Reset mode 1. 1st config hel2 IO's for non-multiplexed Address & GPIO with correct up/down's.
; Reset mode 0. No need to Configure EMIFS and GPIO IO pads
; Configure EMIFS CS1 & CS2 Async access and CS3 burst synchronous.
;; Thumb-ARM-Thumb 16bit State in C code
; Store CTE values in TESTSRAM CTE Space
; Test if the emifs configurration CTE parameter is set to 7, if set, config
; Reset the Helen2 Level 2 Interrupt control handlers.
; Setup gpio pins and registers from CTE parameters. (edge, execute and sync)
; Initialize and interrupt Sync pin handler from CTE parameter.
; Set Supervisor mode.
; Put ARM9 in Big Sleep idle mode and wait for GPIO sync pin interrupt.
; Set User mode.
;; DMA download for MGS3+ and ARM926
;
;
; Remap TLB MMU Translation Table in TestSRAM for virtual address 0x0 to 0x2ffc
;; INT_EndOfLoad(gpio_base_addr, execpin)
; Drain ARM926 Data Cache Write buffer
; Test, Clean and Invalidate all ARM926 Data cache, very important
; Disable ARM926 MMU, Dcache and Icache.
; Flush the instruction & Data cache and Invalidate all TLB.
; Re-enable Enable ARM MMU, Icache, Dcache and Alignment
; Jump to start address in TESTSRAM, which starts here
; clock tree initialization
; Set the synchronous scalable mode from fully synchronous mode
; Set clock divider: ARM=DSP=LCD run at DPLL1 freq, TC=PERI runs at DPLL/2.
; Enable the DSP_CK activation during reset, ARM inth run at ARM/2 clk.
; Sets DPLL ratio
;; Call
add lr, pc, #1
bx lr
CODE16
; Perform SWI to switch to User mode
swi 0xFB ; 0xFB : Enable ledINT_Swi
;; ==============================================================================
;; HELEN2 OMAP1610 DFT LED code execution start here
ldr r0, prog_entry ; load C handler address for LED BOOT
mov pc, r0 ; C routine RESET INTERRUPT
nop
nop
;; ==============================================================================
prog_entry DCD __main
;; ============== DO NOT REMOVE ======= USE FOR TDL GENERATION =================
CODE16 ; CPU in Thumb state & supervisor mode for code density
AREA |.exitsim|,CODE,READONLY
;===============================================================================
; DumpSPY_Results()
; gpio_base_addr ------> R0
; statuspin ------> R1
;
; Input : r0 = gpio base address. r1 = gpio Status pin.
; Output : None.
; The spy result location size is fixed at 256 bytes.
;===============================================================================
DumpSPY_Results
ldr r2, SPY_SPACE ; Ptr to spy result mem location is in r2
ldr r7, [r2] ; r7 contains pointer to first spy result
ldr r6, SPY_OUTPUT ; r6 contains pointer to spy component
; Stores error count in r4
ldrh r4, [r7, #4] ; spy pointer+2 as 1st & 2nd outputs are 5555, AAAA
;; Set the global result of the test on STATUS_PIN gpio(4) 1=OK or 0=fail
mov r5, #0x0 ; Sets r5 to zero
cmp r4, #0 ; If r4 == 0 (no error count)
bne dump_start
mov r5, #0x1 ; Sets r5 to one
lsl r5, r1 ; Sets r5 STATUS_PIN gpio(4) bit to one
dump_start
; Now r5 contains the value to be loaded at the address pointed by r0
; Loops until spy last address is reached
ldr r3, SPY_END ; r3 contains F1F1 (last spy value)
b loopstart ; Loops
dump_loop
strh r2, [r6] ; Puts r2 content into addr pnted by r6
add r7, #0x2 ; r7 is incrd, r7 points to next spy value
add r6, #0x2 ; r6 is incremented
loopstart ; r2 = 1st (0x5555) spy value
ldrh r2, [r7] ; Stores into r2 address pointer by r7
cmp r2, r3 ; If r2 != F1F1
bne dump_loop ; Loops
; Set the Status pin and Writes 0xFFFF to spy to end simulation
ldr r7, SPY_ENDSPACE
ldr r6, SPY_STOP
add r0, #0x30 ; r0 contains ptr on GPIO out space
strh r5, [r0] ; Sets GPIO_2 to its correct value
strh r6, [r7] ; Actually writes 0xFFFF
wait_forever
b wait_forever
;; DEFINE/VAR DECLARATION or DATA/LABEL DECLARATION
SPY_SPACE DCD 0x20000040
SPY_OUTPUT DCD 0x05000000
SPY_ENDSPACE DCD 0x050000FE
SPY_STOP DCD 0xFFFF
SPY_DATA DCD 0x5555
SPY_FAIL DCD 0xDEAD
SPY_END DCD 0xF1F1
END ; Terminate assembly
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -