160 likes | 320 Views
ucosii porting on pxa270. 粘家華 R96922041 林育佳 R96922062. Demo on PXA270. Application demo.c (DEMO_HUHU()). boot head.s ( Platform Specific Code ). Drivers driver.c driver.h (Platform Specific Code). Software. Hardware. CPU. Timer. 7- segment. head.s. .vector ResetHandler reset_irq
E N D
ucosii porting on pxa270 • 粘家華 R96922041 • 林育佳 R96922062
Demo on PXA270 Application demo.c (DEMO_HUHU()) boothead.s(Platform Specific Code) Driversdriver.c driver.h(Platform Specific Code) Software Hardware CPU Timer 7-segment
head.s • .vector • ResetHandler • reset_irq • Initial GPIO, Mmory_Controller • enable APD • Set up a stack [for calling C code] • Create MMU tables • Enable MMU • InitStacks (IRQMode, FIQMode, SVC_MODE) • bl main
tools • Environment • Cygwin + WinXP • Compiler • GNU arm-elf-tools-cygwin v2.95.3 • Platform • PXA 270
Ucosii on PXA270 Application demo.c ( task1() task2() ) OS-IIOS_CORE.C OS_MBOX.C OS_MEM.C OS_Q.COS_SEM.C OS_TASK.C OS_TIME.C … etc (Processor Independent Code) Driversdriver.c driver.h(Platform Specific Code) OS-II PortOS_CPU.h OS_CPU_A.s OS_CPU_C.c(Processor Specific Code) boothead.s(Platform Specific Code) Software Hardware CPU Timer Serial I/O
Goal step • Step 1 : task1 can run correctly and display something on serial I/O. • OSTaskStkInit in OS_CPU_C.c • OSStartHighRdy in OS_CPU_A.s • Step 2 : task1 call delay function, task2 run • OS_TASK_SW in OS_CPU_A.s
OS_CPU_C.c void *OSTaskStkInit (void (*task)(void *pd), void *pdata, void *ptos, INT16U opt) { unsigned int *stk ; opt = opt; /* 'opt' is not used, prevent warning */ stk = (unsigned int *)ptos; /* Load stack pointer */ /* build a context for the new task */ *stk = (unsigned int) task; /* PC */ *--stk = 0; /* lr */ *--stk = 0; /* r12 */ *--stk = 0; /* r11 */ *--stk = 0; /* r10 */ *--stk = 0; /* r9 */ *--stk = 0; /* r8 */ *--stk = 0; /* r7 */ *--stk = 0; /* r6 */ *--stk = 0; /* r5 */ *--stk = 0; /* r4 */ *--stk = 0; /* r3 */ *--stk = 0; /* r2 */ *--stk = 0; /* r1 */ *--stk = (unsigned int) pdata; /* r0 */ *--stk = SVC32MODE; /* spsr YYY+ */ *--stk = SVC32MODE; /* psr */ return ((void *)stk); }
OS_CPU_A.s • OSStartHighRdy
OS_CPU_A.s • OS_TASK_SW
Goal step • Step 3 : interrupt handler can run correctly. • Initial_TIMER0 in driver.c • IrqHnd in head.s • Step 4 : task1 can resume • IrqHnd in head.s • OSIntCtxSw in OS_CPU_A.s • _IntCtxSw in OS_CPU_A.s
driver.c void Initial_TIMER0(void) { tick_on = UM; tick_ms = 0; tick_sec = 0; tick_min = 0; tick_hour = 0; OIER = 0; /* disable any timer interrupts */ OSCR = LATCH*2; /* push OSCR out of the way */ OSMR0 = LATCH; /* set initial match */ OSSR = 0xf; /* clear status on all timers */ OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */ OSCR = 0; /* initialize free-running timer */ }
head.s • IrqHnd • bl Chandler
OS_CPU_A.s • OSIntCtxSw • IntCtxSw
head.s • IrqHnd • IrqHnd: • STMFD sp!,{r0-r3,r12,lr} • bl OSIntEnter • bl OSTimeTick • bl OSIntExit • LDR r0,=OSIntCtxSwFlag • LDR r1,[r0] • CMP r1,#1 • BEQ _IntCtxSw • LDMFD sp!, {r0-r3,r12,lr} • SUBS pc, lr, #4
Thanks • 戴偉堯 • 涂堂訓 • EOS助教