📄 menu.c
字号:
g_DownloadImage = FALSE;
goto exitMenu;
break;
default:
break;
}
}
exitMenu:
return bCFGChanged;
}
BOOL BLMenu()
{
BOOL bCFGChanged = FALSE;
UINT32 Selection;
KeyPadInit();
DisplayStartUpScreen();
// Check for SD card with image
//
if (BLDownloadFromSDCard())
{
g_BootFromSD = TRUE;
g_DownloadImage = FALSE;
g_EbootCFG.KITLEnabled = FALSE;
goto exitMenu;
}
Selection = BLAutoBootDelay(&bCFGChanged);
switch (Selection)
{
case 0x00: // fall through if nothing typed
case 0x0d: // user canceled wait
if (g_EbootCFG.autoDownloadImage)
{
KITLOutputDebugString ( "\r\nStarting auto download ... \r\n");
}
else
{
KITLOutputDebugString ( "\r\nLaunching flash image ... \r\n");
}
break;
case 0x20:
// Display boot menu over serial debug output and wait for user input
bCFGChanged = BLMenuSerial();
break;
}
exitMenu:
if (bCFGChanged == TRUE)
{
StoreEBootCFG(&g_EbootCFG);
}
if (g_DownloadImage)
{
DisplayDebugString("Waiting for PB connection...");
}
return(TRUE);
}
//------------------------------------------------------------------------------
static void SetMAC(unsigned char macdata[6])
{
BOOLEAN bSuccess = TRUE;
int idx;
int macidx;
unsigned char val;
unsigned char cnt;
char szDottedD[20]; // The string used to collect the dotted decimal IP address
WORD cwNumChars = 0;
UINT16 InChar = 0;
KITLOutputDebugString ( "\r\nEnter RDNIS MAC address: ");
while (!((InChar == 0x0d) || (InChar == 0x0a)))
{
InChar = OEMReadDebugByte();
if (InChar != OEM_DEBUG_COM_ERROR && InChar != OEM_DEBUG_READ_NODATA)
{
// If it's a number or a period, add it to the string
if (InChar == '-' ||
(InChar >= '0' && InChar <= '9') ||
(InChar >= 'a' && InChar <= 'f') ||
(InChar >= 'A' && InChar <= 'F'))
{
if (cwNumChars < 20)
{
szDottedD[cwNumChars++] = (char)InChar;
OEMWriteDebugByte((BYTE)InChar);
}
}
// If it's a backspace, back up
else if (InChar == 8)
{
if (cwNumChars > 0)
{
cwNumChars--;
OEMWriteDebugByte((BYTE)InChar);
}
}
}
}
// If it's a carriage return with an empty string, don't change anything.
if (cwNumChars)
{
szDottedD[cwNumChars] = '-';
szDottedD[cwNumChars+1] = '\0';
idx = 0;
macidx = 0;
val = 0;
cnt = 0;
while ((szDottedD[idx] != 0) && (idx < 20))
{
if (szDottedD[idx] >= '0' && szDottedD[idx] <= '9')
{
val <<= 4;
val |= szDottedD[idx] - 0x30;
cnt++;
}
else if (szDottedD[idx] >= 'a' && szDottedD[idx] <= 'f')
{
val <<= 4;
val |= szDottedD[idx] - 0x57;
cnt++;
}
else if (szDottedD[idx] >= 'A' && szDottedD[idx] <= 'F')
{
val <<= 4;
val |= szDottedD[idx] - 0x37;
cnt++;
}
else
{
macdata[macidx] = val;
macidx++;
val = 0;
cnt = 0;
}
idx++;
if (cnt > 2)
{
KITLOutputDebugString("Invalid MAC Address format\r\n");
bSuccess = FALSE;
idx = 20;
}
} // endwhile
}
if (!bSuccess)
{
for (macidx = 0; macidx < 6; macidx++)
{
macdata[macidx] = 0;
}
}
}
static void SetIP(EBOOT_CFG *pEbootCFG)
{
char szDottedD[16]; // The string used to collect the dotted decimal IP address
WORD cwNumChars = 0;
UINT16 InChar = 0;
KITLOutputDebugString ( "\r\nEnter new IP address: ");
while (!((InChar == 0x0d) || (InChar == 0x0a)))
{
InChar = OEMReadDebugByte();
if (InChar != OEM_DEBUG_COM_ERROR && InChar != OEM_DEBUG_READ_NODATA)
{
// If it's a number or a period, add it to the string
if (InChar == '.' || (InChar >= '0' && InChar <= '9'))
{
if (cwNumChars < 16)
{
szDottedD[cwNumChars++] = (char)InChar;
OEMWriteDebugByte((BYTE)InChar);
}
}
// If it's a backspace, back up
else if (InChar == 8)
{
if (cwNumChars > 0)
{
cwNumChars--;
OEMWriteDebugByte((BYTE)InChar);
}
}
}
}
// If it's a carriage return with an empty string, don't change anything.
if (cwNumChars)
{
szDottedD[cwNumChars] = '\0';
pEbootCFG->IP = inet_addr( szDottedD );
}
}
static void SetMask(EBOOT_CFG *pEbootCFG)
{
char szDottedD[16]; // The string used to collect the dotted masks
WORD cwNumChars = 0;
UINT16 InChar = 0;
KITLOutputDebugString ( "\r\nEnter new subnet mask: ");
while (!((InChar == 0x0d) || (InChar == 0x0a)))
{
InChar = OEMReadDebugByte();
if (InChar != OEM_DEBUG_COM_ERROR && InChar != OEM_DEBUG_READ_NODATA)
{
// If it's a number or a period, add it to the string
if (InChar == '.' || (InChar >= '0' && InChar <= '9'))
{
if (cwNumChars < 16)
{
szDottedD[cwNumChars++] = (char)InChar;
OEMWriteDebugByte((BYTE)InChar);
}
}
// If it's a backspace, back up
else if (InChar == 8)
{
if (cwNumChars > 0)
{
cwNumChars--;
OEMWriteDebugByte((BYTE)InChar);
}
}
}
}
// If it's a carriage return with an empty string, don't change anything.
if (cwNumChars)
{
szDottedD[cwNumChars] = '\0';
pEbootCFG->subnetMask = inet_addr( szDottedD );
}
}
static void SetBootMe(EBOOT_CFG *pEbootCFG)
{
char szCount[16];
WORD cwNumChars = 0;
UINT16 InChar = 0;
KITLOutputDebugString ( "\r\nUse 0 for continuous boot me packets. \r\n");
KITLOutputDebugString ( "Enter maximum number of boot me packets to send [0-255]: ");
while (!((InChar == 0x0d) || (InChar == 0x0a)))
{
InChar = OEMReadDebugByte();
if (InChar != OEM_DEBUG_COM_ERROR && InChar != OEM_DEBUG_READ_NODATA)
{
// If it's a number or a period, add it to the string
if ((InChar >= '0' && InChar <= '9'))
{
if (cwNumChars < 16)
{
szCount[cwNumChars++] = (char)InChar;
OEMWriteDebugByte((BYTE)InChar);
}
}
// If it's a backspace, back up
else if (InChar == 8)
{
if (cwNumChars > 0)
{
cwNumChars--;
OEMWriteDebugByte((BYTE)InChar);
}
}
}
}
// If it's a carriage return with an empty string, don't change anything.
if (cwNumChars)
{
szCount[cwNumChars] = '\0';
pEbootCFG->numBootMe = atoi(szCount);
if (pEbootCFG->numBootMe > 255)
{
pEbootCFG->numBootMe = 255;
}
else if (pEbootCFG->numBootMe < 0)
{
pEbootCFG->numBootMe = 1;
}
}
}
static void SetDelay(EBOOT_CFG *pEbootCFG)
{
char szCount[16];
WORD cwNumChars = 0;
UINT16 InChar = 0;
KITLOutputDebugString ( "\r\nEnter maximum number of seconds to delay [1-255]: ");
while (!((InChar == 0x0d) || (InChar == 0x0a)))
{
InChar = OEMReadDebugByte();
if (InChar != OEM_DEBUG_COM_ERROR && InChar != OEM_DEBUG_READ_NODATA)
{
// If it's a number or a period, add it to the string
if ((InChar >= '0' && InChar <= '9'))
{
if (cwNumChars < 16)
{
szCount[cwNumChars++] = (char)InChar;
OEMWriteDebugByte((BYTE)InChar);
}
}
// If it's a backspace, back up
else if (InChar == 8)
{
if (cwNumChars > 0)
{
cwNumChars--;
OEMWriteDebugByte((BYTE)InChar);
}
}
}
}
// If it's a carriage return with an empty string, don't change anything.
if (cwNumChars)
{
szCount[cwNumChars] = '\0';
pEbootCFG->delay = atoi(szCount);
if (pEbootCFG->delay > 255)
{
pEbootCFG->delay = 255;
}
else if (pEbootCFG->delay < 1)
{
pEbootCFG->delay = 1;
}
}
}
static ULONG bstrtoul(PUCHAR pStr, UCHAR nBase)
{
UCHAR nPos=0;
BYTE c;
ULONG nVal = 0;
UCHAR nCnt=0;
ULONG n=0;
// fulllibc doesn't implement isctype or iswctype, which are needed by
// strtoul, rather than including coredll code, here's our own simple strtoul.
if (pStr == NULL)
return(0);
for (nPos=0 ; nPos < strlen(pStr) ; nPos++)
{
c = tolower(*(pStr + strlen(pStr) - 1 - nPos));
if (c >= '0' && c <= '9')
c -= '0';
else if (c >= 'a' && c <= 'f')
{
c -= 'a';
c = (0xa + c);
}
for (nCnt = 0, n = 1 ; nCnt < nPos ; nCnt++)
{
n *= nBase;
}
nVal += (n * c);
}
return(nVal);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -