The Startup.s file contains a startup entry function, which is the first entry for the eboot. This is the first function to be executed when the system is electrically or cold-booted. This function is written by assembly language, complete the initial initialization based on the hardware platform, that is, CPU related initialization, if necessary, can also be used to initialize the peripheral devices here. The function executes to the end and jumps to the C language entrance, typically the main function, or the Ebootmain function.
One more thing to say here is that there are two STARTUP.S files in the BSP, a eboot startup.s for Eboot itself, and OAL Startup.s for the wince kernel. In many cases, the tasks performed by the two startup.s are very similar, so they are generally merged into one STARTUP.S to complete the corresponding functions. For example, after you have completed the associated initialization in the STARTUP.S of Eboot, you will need to include eboot under STARTUP.S only in OAL Startup.s. Of course, these two startup.s may not be exactly the same, so whether it's true that there are two STARTUP.S files or a common Startup.s file, you may need to differentiate them in STARTUP.S by conditional compilation or by judging a variable's methods.
Here's what you should do in STARTUP.S:
1. When the system on the power or reset, the first CPU set to the correct mode below. The general CPU itself will have several modes, for example, for ARM, this time will generally be set to management mode.
2. Turn off all CPU interrupts.
3. Close the Memory management unit MMU and TLB.
4. Close write buffer and cache.
5. Initialize the memory controller.
6. Set the CPU PLL, set the clock.
7. Create the stack.
8. Set and open MMU and cache.
9. If necessary, copy eboot from Flash to ram.
10. Jump to C code, usually the main function or Ebootmain function.
Take arm, for example, to see a startup.s Template:
Startuptext
Leaf_entrystartup
; set arm's CPSR register to set arm as admin mode and block all interrupts
mov r0,# (SVC32Mode:OR:NoINTS)
MSR Cpsr_c,r0
; set up CP15 coprocessor, turn off MMU and cache
LDR R0,=cp15controlinit
Wrmmu_state R0
LDR R0,=cp15auxcontrolinit
Wrmmu_aux_state R0
; Refresh the TLB table and cache
mov r0, #0x0
WRMMU_FLUSHTB R0
WRCACHE_FLUSHIDC R0
; release Write Buffer
mov r0, #0
MCR p15,0,r0,c7,c10,4
Cpwait
; Create a temporary stack, using the head 32KB in SRAM
Ldr sp,= (cpu_sram0+sz_32k-4)
BL disableints; shielding external interrupts
BL Inituart; initialization serial port
BL initclocks; initialize system clock
BL Initstaticmem initialization Flash chip selection controller
BL Initsdram Initialization SDRAM Controller
BL Sizesdram; Returns the size of the SDRAM