Analysis of AM33X WEC7 Eboot main.c file

TI Sitara Cortex-A8 MPU and it's companion boards
Post Reply
esky-sh
Posts: 1449
Joined: Sat Dec 20, 2008 4:21 am

Analysis of AM33X WEC7 Eboot main.c file

Post by esky-sh » Thu May 03, 2012 10:44 pm

1. Main entry of Eboot was called from startup.s

Code: Select all

;;       ;---------------------------------------------------------------
;;       ; Check r9 for HS flag
;;       ;---------------------------------------------------------------
;;       
;;        cmp     r9, #OEM_HIGH_SECURITY_HS
;;        moveq   r0, #OEM_HIGH_SECURITY_HS
;;        movne   r0, #OEM_HIGH_SECURITY_GP
;
;
;    ;---------------------------------------------------------------
;    ; Jump to BootMain
;    ;---------------------------------------------------------------
;
;    ldr     sp, =(IMAGE_EBOOT_STACK_CA + IMAGE_EBOOT_STACK_SIZE)
;	
;    ; Jump to the C entrypoint.
;    ;
;    b      main					; Jump to main.c::main(), never to return...
;
;    
;        ENTRY_END 
;
;        ; Include memory configuration file with g_oalAddressTable
;        INCLUDE addrtab_cfg.inc
;
;        END
;
2. And then Eboot will jump into a WEC7 blcommon framework function BootlaoderMain().

Code: Select all

void main()
{
    
    /* hard coded to AM33x, run time detection can be added later */
    g_CPUFamily = CPU_FAMILY_AM33X;
    
    /* setup pinmux and clocks for Debug UART */
    EnableDeviceClocks(BSPGetDebugUARTConfig()->dev,TRUE);
    
    BootloaderMain();
}

BOOL OEMPlatformInit()
//  This function provide platform initialization functions. It is called
//  from boot loader after OEMDebugInit is called.  Note that boot loader
//  BootloaderMain is called from  s/init.s code which is run after reset.
{
    AM3XX_GPTIMER_REGS* pTimerRegs = OALPAtoUA(AM33X_GPTIMER2_REGS_PA);

    static UCHAR allocationPool[512];
    
    OALLocalAllocInit(allocationPool,sizeof(allocationPool));
    
    /* add board detection logic here */
    OALI2CInit(AM_DEVICE_I2C0);    
    detect_board_id_and_profile_info(); 

    configure_evm_pin_mux();

	EnableDeviceClocks(AM_DEVICE_TIMER2, TRUE);    
    /* Select the Master osc 24 MHZ as Timer2 clock source */
    OUTREG32(OALPAtoUA(CLKSEL_TIMER2_CLK), 0x1);

    OALLogSetZones( (1<<OAL_LOG_VERBOSE)|(1<<OAL_LOG_INFO)|(1<<OAL_LOG_ERROR)|
                    /*(1<<OAL_LOG_WARN)   |(1<<OAL_LOG_FUNC)|*/(1<<OAL_LOG_IO)     );

    OALLog(L"\r\nTexas Instruments Windows CE EBOOT for AM33x, "
			L"Built %S at %S\r\n", __DATE__, __TIME__);

    OALLog(L"EBOOT Version %d.%d.%d, BSP " BSP_VERSION_STRING L"\r\n", 
			EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR, EBOOT_VERSION_BUILD);

	// TIMER_1
    OUTREG32(&pTimerRegs->TCLR, 0);						// stop timer
    OUTREG32(&pTimerRegs->TIOCP, GPTIMER_TIOCP_SOFTRESET);	    // Soft reset GPTIMER
	while ((INREG32(&pTimerRegs->TIOCP) & GPTIMER_TIOCP_SOFTRESET) != 0);	// While until done
    OUTREG32(&pTimerRegs->TSICR, GPTIMER_TSICR_POSTED);	// Enable posted mode
    // Start timer
    OUTREG32(&pTimerRegs->TCLR, GPTIMER_TCLR_AR|GPTIMER_TCLR_ST);
    while ((INREG32(&pTimerRegs->TWPS) & GPTIMER_TWPS_TCLR) != 0); // Wait until write is done

    // Enable device clocks used by the bootloader
    EnableDeviceClocks(AM_DEVICE_GPIO0,TRUE);

    // configure i2c devices
    //OALI2CInit(OMAP_DEVICE_I2C2);
    //OALI2CInit(OMAP_DEVICE_I2C3);

    GPIOInit();
    
    OALLog(L"\r\nTI AM33X \r\n");  

	/* Initialize Device Prefix */
    gDevice_prefix = BSP_DEVICE_AM33x_PREFIX;
    g_ecctype = (UCHAR)dwEbootECCtype;
    OALLog(L"\r\necc type:%d		\r\n", g_ecctype);  
   
    // Done
    return TRUE;
}
3. Three functions will get called in sequence inside BootloaderMain()
static BOOL KernelRelocate (ROMHDR *const pTOC);
|
BOOL OEMDebugInit();
|
BOOL OEMPlatformInit();
|

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest