EBOOT中在 startup.s中
VirtualStart
mov sp, #0x80000000
add sp, sp, #0x30000 ; arbitrary initial super-page stack pointer
ldr r0, =0x91600014;点亮LED 1100
mov r1, #0x60
str r1, [r0]
b main 执行到这里跳转
在 main函数中
void main(void)
{
unsigned long i = 0;
unsigned long dly = 30000;
volatile S3C2410X_IOPORT_REG *s2410IOP = (S3C2410X_IOPORT_REG *)OALPAtoVA(S3C2410X_BASE_REG_PA_IOPORT, FALSE);
s2410IOP->GPBDAT=0x7ff;
while (1)
{
for(dly = 30000; dly > 0; dly--)
{
;
}
s2410IOP->GPBDAT = (~(i<<5)); // 根据i的值,点亮LED1-4
if(++i == 16)
i = 0;
}
// Clear LEDs.
//
OEMWriteDebugLED(0, 0x0);
// Common boot loader (blcommon) main routine.
//
BootloaderMain();
// Should never get here.
//
SpinForever();
}
我在这里做了一个WHILE死循环,但是走到这里LED的灯不会变化,好像没有走到main函数中来,是怎么回事呢?
如果改成
;mov r1, #1
;mcr p15, 0, r1, c3, c0, 0 ; setup access to domain 0
;mcr p15, 0, r10, c2, c0, 0
;mcr p15, 0, r0, c8, c7, 0 ; flush I+D TLBs
;mov r1, #0x0071 ; Enable: MMU
;orr r1, r1, #0x0004 ; Enable the cache
;ldr r0, =VirtualStart
;cmp r0, #0 ; make sure no stall on "mov pc,r0" below
;mcr p15, 0, r1, c1, c0, 0
;mov pc, r0 ; & jump to new virtual address
;nop
; MMU & caches now enabled.
; (r10) = physcial address of 1st level page table
;
VirtualStart
;mov sp, #0x80000000
;add sp, sp, #0x30000 ; arbitrary initial super-page stack pointer
mov sp, #0x30000000
add sp, sp, #0x30000 ; arbitrary initial super-page stack pointer
;ldr r0, =0x91600014;点亮LED 1100
;mov r1, #0x60
;str r1, [r0]
b main
关闭MMU,后面GPB地址用实际物理地址,点灯,OK
后来开了mMU,到MAIN中后,直接给赋值volatile S3C2410X_IOPORT_REG *s2410IOP = 0x91600000;
这样可以了。为什么OALPAtoVA没有执行到吗?很奇怪。
ldr r0, =0x91600014;点亮LED 1100
mov r1, #0x60
str r1, [r0]
这里可以成功点LED,而且是我要的,说明GPBCON 配置正确。
void OEMWriteDebugLED(UINT16 Index, DWORD Pattern)
{
volatile S3C2410X_IOPORT_REG *s2410IOP = (S3C2410X_IOPORT_REG *)OALPAtoVA(S3C2410X_BASE_REG_PA_IOPORT, FALSE);
// The S24x0X01 Eval platform supports 4 LEDs..
//
s2410IOP->GPBDAT=(s2410IOP->GPBDAT & 0x61F) | ((Pattern & 0xf)<<5);
}