Raspberry Pi Model 3B Timer Initialization
I’m emulating an RPi 3B on QEMU and trying to write an embedded OS but getting stuck trying to enable timers and interrupts. Reading the least and most significant bits of the timer at locations 0x4000001C and 0x40000020, respectively, doesn’t give me any data at all.
/*
**
BCM2837 Timer Setup
**
*/
.equ TimerAddress, 0x40000000
.equ TimerCtrlVal, 0x300
.equ TimerPrescalerAddr, 0x40000008
.equ TimerPrescalerVal, (1 << 32)
.equ TimerRWLSBAddr, 0x4000001C
.equ TimerRWMSBAddr, 0x40000020
.equ CoreTimerIntAddr, 0x40000040
.equ CoreTimerIntVal, 0x00000003
.equ Core0Mailbox0, 0x400000C0
.equ AxiCounter, 0x4000002C
.equ LocalTimerCtrlAddr, 0x40000034
.equ LocalTimerCtrlVal, 0x3F000000
.equ LocalIntRoutingAddr, 0x40000024
.equ LocalIntRoutingVal, 0x00000000
.equ LocalTimerClearAddr, 0x40000038
.equ LocalTimerClearVal, 0xC0000000
.global _enable_timer
_enable_timer:
ldr x0, =TimerAddress
ldr x1, =TimerCtrlVal
str w1, [x0]
ldr x0, =TimerPrescalerAddr
ldr x1, =TimerPrescalerVal
str w1, [x0]
ldr x0, =CoreTimerIntAddr
ldr x1, =CoreTimerIntVal
str w1, [x0]
ldr x0, =LocalTimerCtrlAddr
ldr x1, =LocalTimerCtrlVal
str w1, [x0]
ldr x0, =LocalIntRoutingAddr
ldr x1, =LocalIntRoutingVal
str w1, [x0]
ldr x0, =LocalTimerClearAddr
ldr x1, =LocalTimerClearVal
str w1, [x0]
ret
I’ve been able to verify the code is running and drop myself into a basic for {} loop in assembly to watch for incoming interrupts. This is all running in EL3 and no interrupts are provided by the timer.
How do I enable interrupts from the arm_timer?
0 Replies