main.c

来自「该BSP是基于PXA270+WINCE的BSP」· C语言 代码 · 共 1,654 行 · 第 1/4 页

C
1,654
字号


setparameter:
	if(myselect == 0x0d) {
		EdbgOutputDebugString("\r\n  Set display args: ");
		EdbgOutputDebugString("\r\n------------------------------------------");
	
		EdbgOutputDebugString("\r\n	CxScreen: ");
		val=pEbootCFG->tDspRegVal.CxScreen;
		if(GetLongFromDebug(&val)) CxScreen=(unsigned short)val;
	
		EdbgOutputDebugString("\r\n	CyScreen: ");
		val=pEbootCFG->tDspRegVal.CyScreen;
		if(GetLongFromDebug(&val)) CyScreen=(unsigned short)val;
			
		EdbgOutputDebugString("\r\n	Bpp: ");
		val=pEbootCFG->tDspRegVal.Bpp;
		if(GetLongFromDebug(&val)) Bpp=(unsigned short)val;
			
		//LCCR0
		///-------------------			
		EdbgOutputDebugString("\r\n	LCCR0: ");
		val=pEbootCFG->tDspRegVal.LCCR0;
		if(GetLongFromDebug(&val)) LCCR0=(unsigned long)val;
			
		//LCCR1
		///--------------------------------------
		EdbgOutputDebugString("\r\n\r\n	LCCR1_HSW: ");
		val=pEbootCFG->tDspRegVal.HSW;
		if(GetLongFromDebug(&val)) HSW=(unsigned char)val;

		EdbgOutputDebugString("\r\n	LCCR1_BLW: ");
		val=pEbootCFG->tDspRegVal.BLW;
		if(GetLongFromDebug(&val)) BLW=(unsigned char)val;

		EdbgOutputDebugString("\r\n	LCCR1_ELW: ");
		val=pEbootCFG->tDspRegVal.ELW;
		if(GetLongFromDebug(&val)) ELW=(unsigned char)val;
			
		//LCCR2
		///--------------------------------------
		EdbgOutputDebugString("\r\n\r\n	LCCR2_VSW: ");
		val=pEbootCFG->tDspRegVal.VSW;
		if(GetLongFromDebug(&val)) VSW=(unsigned char)val;

		EdbgOutputDebugString("\r\n	LCCR2_BFW: ");
		val=pEbootCFG->tDspRegVal.BFW;
		if(GetLongFromDebug(&val)) BFW=(unsigned char)val;

		EdbgOutputDebugString("\r\n	LCCR2_EFW: ");
		val=pEbootCFG->tDspRegVal.EFW;
		if(GetLongFromDebug(&val)) EFW=(unsigned char)val;
			
		//LCCR3
		///---------------------------------------
		EdbgOutputDebugString("\r\n\r\n	LCCR3_PCD: ");
		val=pEbootCFG->tDspRegVal.PCD;
		if(GetLongFromDebug(&val)) PCD=(unsigned char)val;
			
		EdbgOutputDebugString("\r\n	LCCR3_OTHER(LCCR3-PCD-BPP): ");
		val=pEbootCFG->tDspRegVal.LCCR3_OTHER;
		if(GetLongFromDebug(&val)) LCCR3_OTHER=(unsigned long)val;

		EdbgOutputDebugString("\r\n\r\n	DoRotation(portrait vs landscape): ");
		val=pEbootCFG->tDspRegVal.DoRotation;
		if(GetLongFromDebug(&val)) 	DoRotation=(unsigned char)val;
		EdbgOutputDebugString("\r\n------------------------------------------\r\n");
	}//end of if(myselect == 0x0d)	

	pEbootCFG->tDspRegVal.CxScreen 		= CxScreen;
	pEbootCFG->tDspRegVal.CyScreen 		= CyScreen;
	pEbootCFG->tDspRegVal.Bpp 			= Bpp;
	pEbootCFG->tDspRegVal.LCCR0			= LCCR0;
	pEbootCFG->tDspRegVal.HSW			= HSW;
	pEbootCFG->tDspRegVal.BLW			= BLW;
	pEbootCFG->tDspRegVal.ELW			= ELW;
	pEbootCFG->tDspRegVal.VSW			= VSW;
	pEbootCFG->tDspRegVal.BFW			= BFW;
	pEbootCFG->tDspRegVal.EFW			= EFW;
	pEbootCFG->tDspRegVal.PCD			= PCD;
	pEbootCFG->tDspRegVal.LCCR3_OTHER	= LCCR3_OTHER;
	pEbootCFG->tDspRegVal.DoRotation	= DoRotation;//portrait vs landscape

nochange:
	;
}
//================================================================================

// Dummy routine for mainstoneii_usbfn_rndiskitl.lib
VOID ReInitKITL()
{
}

//------------------------------------------------------------------------------
//
//  Function:  main
//
//  Bootloader main routine.
//
void main(void)
{

    // Common boot loader (blcommon) main routine.
    //
    BootloaderMain();

    // Should never get here.
    //
    SpinForever();

}


//------------------------------------------------------------------------------
//
//  Function:  OEMDownloadFileNotify
//
//  This routine receives a download manifest from blcommon describing the .bin
//  and/or .nb0 file(s) being downloaded from the host.  It's purpose is to
//  assign an address (typically flash address) where the .nb0 file(s) should be
//  placed (since .nb0 files aren't self-describing like .bin files are) and to
//  display the manifest information to the user (over serial).
//
void OEMDownloadFileNotify(PDownloadManifest pInfo)
{
    DWORD dwCount;
    DWORD dwNumNB0Files = 0;

    if (!pInfo) return;

    EdbgOutputDebugString("\r\nDownload file information:\r\n");
    EdbgOutputDebugString("-------------------------------------------------------------------------------\r\n");

    for (dwCount = 0 ; dwCount < pInfo->dwNumRegions ; dwCount++)
    {

        EdbgOutputDebugString("[%d]: Address=0x%x  Length=0x%x  Name=%s\r\n", dwCount, 
                              pInfo->Region[dwCount].dwRegionStart, 
                              pInfo->Region[dwCount].dwRegionLength, 
                              pInfo->Region[dwCount].szFileName);

        // .nb0 files will have a start address of 0 because Platform Builder
        // won't know where to place them.  We'll support only one .nb0 file
        // download (this is an Image Update disk image).  If we need to
        // support more than one .nb0 file download in the future, we'll need
        // to differentiate them by filename.
        //
        if (pInfo->Region[dwCount].dwRegionStart == 0)
        {
            // We only support one raw binary file (disk image).
            if (dwNumNB0Files++)
            {
                EdbgOutputDebugString("ERROR: This bootloader doesn't support downloading a second .nb0 binary image.\r\n");
                SpinForever();
            }

            // The disk image .nb0 file should be placed immediately after the
            // bootloader image in flash (we'll assume that the disk image has the IPL prepended to it).
            pInfo->Region[dwCount].dwRegionStart = (DWORD)OALPAtoVA(IMAGE_BOOT_IPL_FLASH_PA_START, FALSE);

            EdbgOutputDebugString("INFO: Changed start address for %s to 0x%x.\r\n", pInfo->Region[dwCount].szFileName, 
                                                                                     pInfo->Region[dwCount].dwRegionStart);

        }
    }

    EdbgOutputDebugString("\r\n");

    return;
}


//------------------------------------------------------------------------------
//
//  Function:  OEMDebugInit
//
//  Initialize debug serial UART.
//
BOOL OEMDebugInit(void)
{
    // Check and initialize the BSP Args area
    //
    OALArgsInit((BSP_ARGS *) IMAGE_SHARE_ARGS_UA_START);

    // Initialize the flash interface (needed so we can determine which serial
    // port to use for bootloader and OS debug message output).
    //
    if (!FlashInit((UINT32) OALPAtoVA(MAINSTONEII_BASE_PA_BOOT_FLASH, FALSE), MAINSTONEII_SIZE_BOOT_FLASH))
    {
        // Load default bootloader configuration settings.
        //
        EdbgOutputDebugString("ERROR: flash initialization failed - loading bootloader defaults...\r\n");
        ResetDefaultEBootCFG(&g_EbootCFG);
    }
    else
    {
        // Load the bootloader configuration from flash (menu settings).
        //
        LoadEBootCFG(&g_EbootCFG);
    }

    // Initialize the debug UART.
    //
    InitDebugSerial(g_EbootCFG.dwDbgSerPhysAddr, FALSE);

    // Clear the hex LEDs.
    //
//---------------------------------------
//    OEMWriteDebugLED(0, 0);
//---------------------------------------

    // Set up optional bootloader function pointers.
    //
    g_pOEMVerifyMemory   = OEMVerifyMemory;
    g_pOEMMultiBINNotify = OEMDownloadFileNotify;

    return(TRUE);
}


//------------------------------------------------------------------------------
//
//  Function:  OEMPlatformInit
//
//  Initialize the Mainstone platform.
//
BOOL OEMPlatformInit(void)
{
    UINT32 AutoBootDelay = 0;
    BOOLEAN bXIPMode     = TRUE;
    BOOLEAN bCFGChanged  = FALSE;
    SYSTEMTIME SysTime;
    UINT32 StartTime, CurrTime, PrevTime;
    UINT32 Selection;
    UINT32 EthDevice;
    int i;
    UCHAR  rndis_mac[6] = {0,0,0,0,0,0};


    EdbgOutputDebugString("Microsoft Windows CE Ethernet Bootloader %d.%d for the Intel MainstoneIII Development Platform Built %s\r\n", \
                          EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR, __DATE__);

    // Initialize the global XLLP device handle for the PC Card interface.
    //
//---------------------------------
///    memset((void *) &strEbtPCCardSocketHandle, 0, sizeof(XLLP_PCCARDSOCKET_T));
///    strEbtPCCardSocketHandle.pstrGpioRegsHandle = (XLLP_GPIO_T *) OALPAtoVA(BULVERDE_BASE_REG_PA_GPIO, FALSE);
///    XllpPCCardConfigureGPIOs(&strEbtPCCardSocketHandle);
//---------------------------------
    // Get the Ehternet MAC address to use as RNDIS MAC address
    // Note: This only applies to Mainstone platform because it has Ehternet controller on it.
    //
    if (!g_EbootCFG.RNDISMac[0] && !g_EbootCFG.RNDISMac[1] && !g_EbootCFG.RNDISMac[2])
    {

    	//--------------------------------------------------------------------------------------
		#if 0
        if (LAN91CInit((UINT8 *) (((UINT32) OALPAtoVA(MAINSTONEII_BASE_REG_PA_SMSC_ETHERNET, FALSE)) + 0x300), 0, g_EbootCFG.RNDISMac))
        {
            bCFGChanged = TRUE;
        }
		#endif
    	//--------------------------------------------------------------------------------------
		#if 0	
//		if( DM9000AInit((UINT8 *) (((UINT32) OALPAtoVA(MAINSTONEII_BASE_REG_PA_SMSC_ETHERNET, FALSE)) + 0x300),
		if( DM9000AInit((UINT8 *) (((UINT32) OALPAtoVA(MAINSTONEII_BASE_REG_PA_SMSC_ETHERNET, FALSE))),
			 						0, 
			 						g_EbootCFG.RNDISMac) )
        {
            bCFGChanged = TRUE;
        }
		#endif
    	//--------------------------------------------------------------------------------------		
    }

    // Read the current wall-clock time.
    // NOTE: At reset, the RTC value is set to 1/1/1980 at 0:0:0.
    //
    OEMGetRealTime(&SysTime);

    // User menu code...
    //
    AutoBootDelay = g_EbootCFG.delay;
    if (g_EbootCFG.autoDownloadImage)
    {
        g_DownloadImage = TRUE;
        EdbgOutputDebugString ( "\r\nPress [ENTER] to download now or [SPACE] to cancel.\r\n");
        EdbgOutputDebugString ( "\r\nInitiating image download in %d seconds. ", AutoBootDelay--);
    }
    else
    {
        g_DownloadImage = FALSE;
        EdbgOutputDebugString ( "\r\nPress [ENTER] to launch image stored in flash or [SPACE] to cancel.\r\n");
        EdbgOutputDebugString ( "\r\nInitiating image launch in %d seconds. ", AutoBootDelay--);
    }


    // Get a snapshot of the RTC seconds count.
    //
    StartTime     = OEMEthGetSecs();
    PrevTime      = StartTime;
    CurrTime      = StartTime;
    Selection     = 0;

    // Allow the user an amount of time to halt the auto boot/download process.
    // Count down to 0 before proceeding with default operation.
    //
    while ((CurrTime - StartTime) < g_EbootCFG.delay)
    {
        UINT8 k=0;
        UINT8 j;
        UINT8 x,y,z;

        Selection = OEMReadDebugByte(); 
        if ((Selection == 0x20) || (Selection == 0x0d))
        {
            break;
        }
        CurrTime = OEMEthGetSecs();   
        if (CurrTime > PrevTime)
        {
            PrevTime = CurrTime;
            if (AutoBootDelay < 9)
                k = 11;
            else if (AutoBootDelay < 99)
                k = 12;
            else if (AutoBootDelay < 999)
                k = 13;

            for (j = 0; j < k; j++)
            {
                OEMWriteDebugByte((BYTE)0x08); // print back space
            }
            x = AutoBootDelay / 100;
            y = (AutoBootDelay % 100) / 10;
            z = ((AutoBootDelay % 100) % 10);
            OEMWriteDebugLED(0, ((x << 8) | (y << 4) | (z)));
            EdbgOutputDebugString ( "%d seconds. ", AutoBootDelay--);
        }

    }

    switch (Selection)
    {
    case 0x00: // fall through if nothing typed
    case 0x0d: // user canceled wait
        {
            if (g_EbootCFG.autoDownloadImage)
            {
                EdbgOutputDebugString ( "\r\nStarting auto download ... \r\n");
            }
            else
            {
                EdbgOutputDebugString ( "\r\nLaunching flash image  ... \r\n");
            }
            break;
        }
    case 0x20:
        {
            Selection = 0;
            while (1)
            {
                // Get the Ehternet MAC address to use as RNDIS MAC address
                // Note: This only applies to Mainstone platform because it has Ehternet controller on it.
                //

				if (!g_EbootCFG.RNDISMac[0] && !g_EbootCFG.RNDISMac[1] && !g_EbootCFG.RNDISMac[2])
                {
		    	//--------------------------------------------------------------------------------------
				#if 0
                    if (LAN91CInit((UINT8 *) (((UINT32) OALPAtoVA(MAINSTONEII_BASE_REG_PA_SMSC_ETHERNET, FALSE)) + 0x300), 0, g_EbootCFG.RNDISMac))
                    {
                        bCFGChanged = TRUE;
                    }

				#endif
		    	//--------------------------------------------------------------------------------------
				#if 0
//					if( DM9000AInit((UINT8 *) (((UINT32) OALPAtoVA(MAINSTONEII_BASE_REG_PA_SMSC_ETHERNET, FALSE)) + 0x300),
					if( DM9000AInit((UINT8 *) (((UINT32) OALPAtoVA(MAINSTONEII_BASE_REG_PA_SMSC_ETHERNET, FALSE))),
						 						0, 
					 							g_EbootCFG.RNDISMac) )
			        {
    	    		    bCFGChanged = TRUE;
			        }
				#endif	
		    	//--------------------------------------------------------------------------------------
					
                }
                
                // Show menu
                EdbgOutputDebugString ( "\r\n\r\nEBoot Loader Configuration:\r\n\r\n");

                EdbgOutputDebugString ( "0) IP address: %s\r\n",inet_ntoa(g_EbootCFG.IP));
                EdbgOutputDebugString ( "1) Subnet mask: %s\r\n", inet_ntoa(g_EbootCFG.subnetMask));
                EdbgOutputDebugString ( "2) Boot delay: %d seconds\r\n", g_EbootCFG.delay);
                EdbgOutputDebugString ( "3) DHCP: %s\r\n", (g_EbootCFG.DHCPEnable == TRUE?"(Enabled)":"(Disabled)"));
                EdbgOutputDebugString ( "4) Reset to factory default configuration\r\n");
//-----------------------------------------------------------------
//              EdbgOutputDebugString ( "5) RNDIS MAC address: %x-%x-%x-%x-%x-%x\r\n",(UCHAR) g_EbootCFG.RNDISMac[0], (UCHAR) (g_EbootCFG.RNDISMac[0]>>8), (UCHAR)g_EbootCFG.RNDISMac[1],
//                                           (UCHAR)(g_EbootCFG.RNDISMac[1]>>8), (UCHAR)g_EbootCFG.RNDISMac[2], (UCHAR)(g_EbootCFG.RNDISMac[2]>>8));
//-----------------------------------------------------------------
                EdbgOutputDebugString ( "5) Set MAC address: (now:%x-%x-%x-%x-%x-%x)\r\n",
                						(UCHAR) g_EbootCFG.RNDISMac[0], 
                						(UCHAR)(g_EbootCFG.RNDISMac[0]>>8), 
                						(UCHAR) g_EbootCFG.RNDISMac[1],
                                        (UCHAR)(g_EbootCFG.RNDISMac[1]>>8), 
                                        (UCHAR) g_EbootCFG.RNDISMac[2], 
                                        (UCHAR)(g_EbootCFG.RNDISMac[2]>>8));
//-----------------------------------------------------------------
                EdbgOutputDebugString ( "6) %s image at startup\r\n", g_EbootCFG.autoDownloadImage?"Download new":"Launch existing flash resident");
                EdbgOutputDebugString ( "7) Boot device order: ");
                {
                    if(g_EbootCFG.bootDeviceOrder >= NUM_BOOT_ORDERS)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?