大家好,请教一个有关sleep和wakeup的问题。
我们知道,在系统进入睡眠的时候,会调用OEMPowerOff(),在这里面,系统会关闭外设电源,保存寄存器,然后sleep,当外部中断发生的时候,会从睡眠的地方起来。但小弟,这里有个疑问,请教大家了。我把代码贴出来,各位大侠帮忙看看:(注:以下代码来自于三星芯片)
stepldr/startup.s
STARTUPTEXT
LEAF_ENTRY StartUp
b ResetHandler
b .
...
ResetHandler
ldr r0, =WTCON ; disable the watchdog timer.
ldr r1, =0x0
str r1, [r0]
ldr r0, =INTMSK ; mask all first-level interrupts.
ldr r1, =0xffffffff
str r1, [r0]
......
......
; :::::::::::::::::::::::::::::::::::::::::::::
; BEGIN: Power Management
; - - - - - - - - - - - - - - - - - - - - - - -
ldr r1, =GSTATUS2 ; Determine Booting Mode
ldr r10, [r1]
tst r10, #0x2
beq %F2 ;如果不是wakup唤醒,则跳过下面的执行语句
str r10, [r1] ; Clear Test
......
......
mov r1, #256
loop11
subs r1, r1, #1 ; wait until the SelfRefresh is released.
bne loop11
ldr r2, =0x201000 ; offset into the RAM
add r2, r2, #0x30000000 ; add physical base
mov pc, r2 ;如果是wakeup事件,则跳转到0x30201000地址
......
......
OAL/startup.s
LEAF_ENTRY CPUPowerOff ;此函数由OEMPowerOff()调用,完成sleep和唤醒所做的工作
; 1. Push SVC state onto our stack ;C语言进入此处,压栈
stmdb sp!, {r4-r12}
stmdb sp!, {lr}
; 2. Save MMU & CPU Register to RAM
ldr r3, =SLEEPDATA_BASE_VIRTUAL ; base of Sleep mode storage
ldr r2, =Awake_address ; store Virtual return address
str r2, [r3], #4
......
......
ldr r4, =vCLKCON
ldr r5, =0x7fff8 ; 设置CPU进入sleep模式
; 8. Jump to real Power-Off Address
ldr r6, =0x80000000 ; make address to 0x8020 1020
add r6, r6, #0x200000 ;
add r6, r6, #0x1000 ;
add r6, r6, #0x20 ;
mov pc, r6 ;这里的代码看上去像是醒了后执行的,那么这个0x80201020是什么地址,为什么比stepldr/startup.s里面的地址多了0x20空间出来?
; This point is called from EBOOT's startup code(MMU is enabled)
; in this routine, left information(REGs, INTMSK, INTSUBMSK ...)
Awake_address
; 1. Recover CPU Registers
ldr r3, =SLEEPDATA_BASE_VIRTUAL ; Sleep mode information data structure
add r2, r3, #SleepState_FIQ_SPSR
mov r1, #Mode_FIQ:OR:I_Bit:OR:F_Bit ; Enter FIQ mode, no interrupts - also FIQ
msr cpsr, r1
ldr r0, [r2], #4
msr spsr, r0
ldr r8, [r2], #4
ldr r9, [r2], #4
ldr r10, [r2], #4
ldr r11, [r2], #4
ldr r12, [r2], #4
ldr sp, [r2], #4
ldr lr, [r2], #4
...
...
; 2. Recover Last mode's REG's, & go back to caller of CPUPowerOff()
ldr sp, [r3, #SleepState_SVC_SP]
ldr lr, [sp], #4
ldmia sp!, {r4-r12}
mov pc, lr ; and now back to our sponsors,回到off.c文件里面去。
现在我有几个问题:
1,stepldr/startup.s里面的跳转地址是0x30201000,那么这个地址到底指向了哪里?是Awake_address还是上面的注释8处?那么系统是如何把这个地址定位成0x30201000的呢?是config.bib?是?但我在config.bib里面没有找到这个值啊。
2,上面的那个问题,为什么注释8处弄出来个0x80201020,为什么比30201000多0x20个地址空间?这是做什么用的?
谢谢。