6/01/2012

A code walkthrough of LK bootloader?

The following provides a walk through of the startup sequence function calls.


Startup Sequence
a.. arch/arm/crt0.S: _start (defined in arch/arm/system-onesegment.ld)
a.. Setup CPU
b.. Calls __cpu_early_init if necessary
c.. Relocate if necessary
d.. Setup stack
e.. Calls kmain()
a.. platform/<platform>/(arch_init.S): __cpu_early_init
a.. Platform-specific initialization sequence, e.g. for 8K targets
a.. kernel/main.c: kmain()
a.. arch_early_init()
b.. platform_early_init()
c.. target_early_init()
d.. call constructors defined by __ctor_list (which is nothing)
e.. init: heap, thread, dpc, timer
f.. create init thread: bootstrap2(), main thread goes to sleep
a.. kernel/main.c: bootstrap2()
a.. arch_init()
b.. platform_init()
c.. target_init()
d.. apps_init()
a.. arch/arm/arch.c: arch_early_init()
a.. disable cache
b.. set IRQ vector base
c.. init MMU
d.. MMU mapping
e.. enable cache
f.. init Neon
a.. platform/<platform>/(platform.c): platform_early_init()
a.. init UART
b.. init interrupts
c.. init timer
a.. target/init.c: target_early_init()
a.. Stub (weak references, can be overridden)
a.. arch/arm/arch.c: arch_init()
a.. Stub
a.. platform/<platform>/(platform.c): platform__init()
a.. init Apps CPU clock
b.. init MDDI/LCDC
c.. setup frame buffer
a.. target/<target>/(init.c): target_init()
a.. init keypad
b.. init flash partition table
c.. init flash
a.. app/init.c: apps_init()
a.. init apps that are defined using APP_START & APP_END macros, aboot_init() is called during this step
b.. run the app in a separate thread if it has .entry section
a.. app/aboot/aboot.c: aboot_init()
a.. fastboot (boot from USB) if key pressed
b.. boot from flash if key not pressed
Notes on file & directory names

a.. <...> match to the corresponding platform or target, e.g. msm7k, surf-qsd8250
b.. (...) are preferred name but not necessary enforced

[edit]Makefile include order
a.. /makefile includes /project/$PRJECTNAME.mk
b.. /project/$PRJECTNAME.mk includes /target/$TARGET/rules.mk
c.. /target/$TARGET/rules.mk includes /platform/$PLATFORM/rules.mk
a.. /project/$PRJECTNAME.mk specifies
a.. $TARGET
b.. modules to include (under /app)
a.. /target/$TARGET/rules.mk specifies
a.. $PLATFORM
b.. board-level settings: membase, memsize, linux_machinetype, gpio keypad
a.. /platform/$PLATFORM/rules.mk specifies
a.. CPU-level settings: ARCH, ARM_CPU, CPU

No comments:

Post a Comment