📄 main.c.bak
字号:
{
selection = OEMReadDebugByte();
if ((selection == 0x20) || (selection == 0x0d))
{
break;
}
if (!(v_pGPIOReg->GPLR_x & GPIO_0)) // On/Off button is not pressed
goto LAUNCHIMAGE;
dwCurrTime = OEMEthGetSecs();
if (dwCurrTime > dwPrevTime)
{
// 1 Second has elapsed
// Update the countdown timer
dwPrevTime = dwCurrTime;
if (delay < 9)
i = 11;
else if (delay < 99)
i = 12;
else if (delay < 999)
i = 13;
for(j = 0; j < i; j++)
{
OEMWriteDebugByte((BYTE)0x08); // print back space
}
EdbgOutputDebugString ( "%d seconds. ", delay--);
}
}
//selection = 0x20; // stop autodownload hjg
//selection = OEMReadDebugByte(); //add by hjg 2007.05.13
//EdbgOutputDebugString ( "\r\n"); //min by houjg 2007.05.13
switch(selection)
{
case 0x00: // fall through if nothing typed
case 0x0d: // user canceled wait
{
if (pEbootCFG->autoDownloadImage)
{
EdbgOutputDebugString ( "\r\nStarting auto download ... \r\n");
}
else
{
EdbgOutputDebugString ( "\r\nLaunching flash image ... \r\n");
}
break;
}
//case 0x76: //esc key hjg
case 0x20:
{
selection = 0;
while(1)
{
// Show menu
EdbgOutputDebugString ( "\r\n\r\nEthernet Boot Loader Configuration:\r\n\r\n");
EdbgOutputDebugString ( "0) IP address: %s\r\n",inet_ntoa(pEbootCFG->IP));
EdbgOutputDebugString ( "1) Subnet mask: %s\r\n", inet_ntoa(pEbootCFG->subnetMask));
EdbgOutputDebugString ( "2) # bootme's: %d\r\n", pEbootCFG->numBootMe);
EdbgOutputDebugString ( "3) Boot delay: %d seconds\r\n", pEbootCFG->delay);
EdbgOutputDebugString ( "4) DHCP: %s\r\n", (pEbootCFG->DHCPEnable == TRUE?"Enabled":"Disabled"));
EdbgOutputDebugString ( "5) Reset to factory default configuration\r\n");
EdbgOutputDebugString ( "6) %s image at startup\r\n", pEbootCFG->autoDownloadImage?"Download new":"Launch existing flash resident");
#if defined ( PLAT_LUBBOCK )
EdbgOutputDebugString ( "7) Boot device order: ");
switch (pEbootCFG->bootDeviceOrder)
{
case 0:
EdbgOutputDebugString ( "SMSC -> PCMCIA -> CF\r\n");
break;
case 1:
EdbgOutputDebugString ( "SMSC -> CF -> PCMCIA\r\n");
break;
case 2:
EdbgOutputDebugString ( "PCMCIA -> CF -> SMSC\r\n");
break;
case 3:
EdbgOutputDebugString ( "PCMCIA -> SMSC -> CF\r\n");
break;
case 4:
EdbgOutputDebugString ( "CF -> SMSC -> PCMCIA\r\n");
break;
case 5:
EdbgOutputDebugString ( "CF -> PCMCIA -> SMSC\r\n");
break;
default:
EdbgOutputDebugString ( "SMSC -> PCMCIA -> CF\r\n");
pEbootCFG->bootDeviceOrder = 0;
break;
}
EdbgOutputDebugString ( "8) Program SMSC MAC address\r\n");
#endif
#if defined ( RTECH_FLAG )
EdbgOutputDebugString ( "9) Monitor Program\r\n");
#endif
EdbgOutputDebugString ( "D) Download image now\r\n");
EdbgOutputDebugString ( "L) Launch existing flash resident image now\r\n");
EdbgOutputDebugString ( "\r\n\r\nEnter your selection: ");
selection = 0;
#if defined ( PLAT_LUBBOCK )
while (! ( ( (selection >= '0') && (selection <= '9') ) ||
( (selection == 'D') || (selection == 'd') ) ||
( (selection == 'L') || (selection == 'l') ) ))
#endif
#if defined ( PLAT_SANDGATE )
while (! ( ( (selection >= '0') && (selection <= '6') ) ||
( (selection == 'D') || (selection == 'd') ) ||
( (selection == 'L') || (selection == 'l') ) ))
#endif
{
selection = OEMReadDebugByte();
}
EdbgOutputDebugString ( "%c\r\n", selection);
switch(selection)
{
case '0':
SetIP(pEbootCFG);
MyAddr.dwIP = pEbootCFG->IP;
CFGChanged=TRUE;
break;
case '1':
SetMask(pEbootCFG);
dwSubnetMask = pEbootCFG->subnetMask;
CFGChanged=TRUE;
break;
case '2':
SetBootMe(pEbootCFG);
CFGChanged=TRUE;
break;
case '3':
SetDelay(pEbootCFG);
CFGChanged=TRUE;
break;
case '4':
if (pEbootCFG->DHCPEnable == TRUE)
{
pEbootCFG->DHCPEnable = FALSE;
}
else
{
pEbootCFG->DHCPEnable = TRUE;
}
CFGChanged=TRUE;
break;
case '5':
ResetFactoryDefaultCFG(pEbootCFG);
CFGChanged=TRUE;
break;
case '6':
if (pEbootCFG->autoDownloadImage == TRUE)
{
pEbootCFG->autoDownloadImage = FALSE;
}
else
{
pEbootCFG->autoDownloadImage = TRUE;
}
CFGChanged=TRUE;
break;
#if defined ( PLAT_LUBBOCK )
case '7':
pEbootCFG->bootDeviceOrder++;
if (pEbootCFG->bootDeviceOrder > 5)
pEbootCFG->bootDeviceOrder = 0;
CFGChanged=TRUE;
break;
case '8':
SetSMSCMACAddress();
break;
#endif
#if defined ( RTECH_FLAG )
case '9':
LaunchMonitor:
MonitorFlag = MonitorProgram();
switch (MonitorFlag)
{
case 1:
bEbootExternalDown = TRUE;
goto DOWNLOAD;
break;
case 2:
bEbootExternalDown = TRUE;
fileType = 0;
dwEBOOT_OFFSET = 0;
fileType |= ( NB0_FILE_TYPE | FLASHTARGET | BOOTLOADER );
goto FLASHIMAGE;
break;
case 3:
goto LAUNCHIMAGE;
break;
case 4:
goto DOWNLOAD;
break;
}
break;
#endif
case 'D':
case 'd':
if (CFGChanged == TRUE)
{
StoreEBootCFG(pEbootCFG);
}
goto DOWNLOAD;
break;
case 'L':
case 'l':
if (CFGChanged == TRUE)
{
StoreEBootCFG(pEbootCFG);
}
goto LAUNCHIMAGE;
break;
default:
break;
}
}
}
}
LAUNCHIMAGE:
#if defined ( RTECH_FLAG )
if ((pEbootCFG->autoDownloadImage == FALSE) || (selection == 'L') || (selection == 'l')|| (selection == '9'))
#else
if ((pEbootCFG->autoDownloadImage == FALSE) || (selection == 'L') || (selection == 'l'))
#endif
{
// Check for pTOC signature ("CECE") here, after image in place
if (*(DWORD*)((pEbootCFG->dwLaunchAddr - 0x1000)+ 64) == 0x43454345)
{
EdbgOutputDebugString("Found pTOC signature.\n");
EdbgOutputDebugString("Launching image at %Xh...\r\n",pEbootCFG->dwLaunchAddr);
msWait(100);
Launch2(pEbootCFG->dwLaunchAddr - BOOT_FLASH_BASE_C_VIRTUAL);
//==============================================//
} else
{
EdbgOutputDebugString("Image not found at 0x%X\r\n",pEbootCFG->dwLaunchAddr);
}
}
DOWNLOAD:
/*sddownload = 1;
v_pGPIOReg->GPDR_x &= ~GPIO_12;
v_pGPIOReg->GPDR_y &= ~GPIO_32;
v_pGPIOReg->GAFR0_y &= ~GPIO_50_AF3;
v_pGPIOReg->GAFR0_y &= ~GPIO_32_AF3;
if(SDdetect())
goto LaunchAtaImage;
EdbgOutputDebugString("sd download faild , and download from cf card!!\r\n");
sddownload = 0;*/
#if defined (PLAT_LUBBOCK)
// Try each of the boot devices in the specified order
ethernet_device = InitSpecifiedEthDevice(&MyAddr, bootOrder[(pEbootCFG->bootDeviceOrder * 3)]);
if (ethernet_device == NONE)
{
ethernet_device = InitSpecifiedEthDevice(&MyAddr, bootOrder[(pEbootCFG->bootDeviceOrder * 3) + 1]);
if (ethernet_device == NONE)
{
ethernet_device = InitSpecifiedEthDevice(&MyAddr, bootOrder[(pEbootCFG->bootDeviceOrder * 3) + 2]);
}
}
#if defined ( RTECH_FLAG )
// CF Memory card
if (ethernet_device == EDBG_ADAPTER_OEM)
goto LaunchAtaImage;
#endif
#endif
#if defined (PLAT_SANDGATE)
ethernet_device = InitSpecifiedEthDevice(&MyAddr, 0);
#endif
#endif // ndef SABINAL
#ifdef SABINAL
ethernet_device = InitSpecifiedEthDevice(&MyAddr, 2); // hard code SMSC
#endif
// No device was found ...
if (ethernet_device == NONE)
{
EdbgOutputDebugString("Failed to detect and initialize Ethernet controller.\r\n");
EdbgOutputDebugString("Eboot has halted.\r\n");
while(1);
}
// Make sure MAC address has been programmed
if (!MyAddr.wMAC[0] && !MyAddr.wMAC[1] && !MyAddr.wMAC[2]) {
EdbgOutputDebugString("Invalid Ethernet address read from Ethernet controller.\n");
goto FatalError;
}
// Device name based on platform ID and last word of MAC address
EdbgOutputDebugString("\r\nDevice identification: XSC1BD%d\n\n",ntohs(MyAddr.wMAC[2]));
// Set up TFTP server. Note that internally, we store port numbers in network byte order.
EbootInitTFtp( htons(EDBG_DOWNLOAD_PORT), htons(EDBG_DOWNLOAD_PORT));
EbootInitTFtpd();
if (EbootTFtpdServerRegister( EDBG_DOWNLOAD_FILENAME, EthDown ))
EdbgOutputDebugString( "Server Registration Failed\r\n" );
#ifndef SABINAL
// Initialize DHCP, and send out first request
if (pEbootCFG->DHCPEnable == TRUE)
{
if (EbootInitDHCP( &MyAddr ))
EdbgOutputDebugString( "Error On InitDHCP() Call\r\n" );
EdbgOutputDebugString ( "Waiting for DHCP assignment... ");
}
#else
if (EbootInitDHCP( &MyAddr )) EdbgOutputDebugString( "Error On InitDHCP() Call\r\n" );
EdbgOutputDebugString ( "Wait for DHCP, or enter new IP address: ");
dwStartTime = OEMEthGetSecs();
#endif
// Loop until we have an IP address and eshell tells us which services are
// configured for Ethernet
while (!fGotJumpimg) {
USHORT wLen, wDestPort, wSrcPort, wUDPDataLen, *pwUDPData;
// Once we get our IP address, periodically send BOOTME commands to eshell.
switch (dwIPState) {
case IPSTATE_NONE:
#ifndef SABINAL
if (pEbootCFG->DHCPEnable == TRUE)
{
// We haven't gotten an IP address yet. Call into DHCP to see if we
// need to retransmit request.
EbootDHCPRetransmit(&MyAddr,NULL,NULL);
} else
{
// Use the static IP already configured.
MyAddr.dwIP = pEbootCFG->IP;
dwSubnetMask = pEbootCFG->subnetMask;
dwIPState = IPSTATE_GOTIP;
EdbgFlags |= EDBG_FLAGS_STATIC_IP;
DHCPLeaseTime = DEFAULT_DHCP_LEASE;
}
#else
EbootDHCPRetransmit(&MyAddr,NULL,NULL);
if(EbootReadSerialIP(&MyAddr, &dwSubnetMask))
{
dwIPState = IPSTATE_GOTIP;
EdbgFlags |= EDBG_FLAGS_STATIC_IP;
DHCPLeaseTime = DEFAULT_DHCP_LEASE;
}
#endif
break;
case IPSTATE_GOTIP:
// Send a gratuitous ARP (an ARP of our new IP address) to verify that no other
// station is using our IP address.
if (!EbootGratuitousARP(&MyAddr, FrameBuffer)) {
dwIPState = IPSTATE_ARP;
dwNextBootme = OEMEthGetSecs(); // use dwNextBootme for ARP timeout
} else {
EdbgOutputDebugString("EbootGratuitousARP failed\r\n");
}
break;
case IPSTATE_ARP:
if ((OEMEthGetSecs() - dwNextBootme) >= ARP_RESPONSE_WAIT)
{
EdbgOutputDebugString("No ARP response in %d seconds, assuming ownership of %s\r\n",
ARP_RESPONSE_WAIT, inet_ntoa(MyAddr.dwIP));
dwIPState = IPSTATE_ARPED;
dwNextBootme = 0;
}
break;
case IPSTATE_ARPED:
#ifndef SABINAL
if (!bLinkEstablished)
{
if (((pEbootCFG->numBootMe == 0) && (OEMEthGetSecs() >= dwNextBootme)) ||
((BootmeCnt < pEbootCFG->numBootMe) && ((BootmeCnt == 0) || (OEMEthGetSecs() >= dwNextBootme))))
{
// Send broadcast BOOTME packet to Eshell. Pass in NULL for device
// name - it will be constructed from our platform name and the last
// word of our MAC address (e.g. Odo23).
EbootSendBootme(&MyAddr, EBOOT_VERSION_MAJOR, EBOOT_VERSION_MINOR,PLATFORM_STRING,NULL,EDBG_CPUID,0);
BootmeCnt++;
dwNextBootme = OEMEthGetSecs() + BOOTME_INTERVAL;
}
}
#else
if(!bLinkEstablished)
{
if((BootmeCnt < MAX_BOOTME_CNT) && ((BootmeCnt == 0) || (OEMEthGetSecs() >= dwNextBootme)))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -