⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.c

📁 i.Mx31 bootloader(for WinCE6.0)
💻 C
📖 第 1 页 / 共 2 页
字号:
                        g_BootCFG.DHCPEnable = TRUE;
                    bCFGChanged=TRUE;
                    break;
                case '4':
                    ResetDefaultBootCFG(&g_BootCFG);
                    break;
                case '5':
                    switch(g_BootCFG.autoDownloadImage)
                    {
                    case BOOT_CFG_AUTODOWNLOAD_NONE:
                        g_BootCFG.autoDownloadImage = BOOT_CFG_AUTODOWNLOAD_NK_NOR;
                        break;
                    case BOOT_CFG_AUTODOWNLOAD_NK_NOR:
                        g_BootCFG.autoDownloadImage = BOOT_CFG_AUTODOWNLOAD_NK_NAND;
                        break;
                    case BOOT_CFG_AUTODOWNLOAD_NK_NAND:
                        g_BootCFG.autoDownloadImage = BOOT_CFG_AUTODOWNLOAD_IPL_NAND;
                        break;
                    default:
                        g_BootCFG.autoDownloadImage = BOOT_CFG_AUTODOWNLOAD_NONE;
                        break;                       
                    }
                    bCFGChanged=TRUE;
                    break;
                case '6':
                    SetMAC(&g_BootCFG);
                    bCFGChanged=TRUE;
                    break;
                case '7':
                    KITLOutputDebugString("\r\nWARNING:  Format of OS NAND region requested.\r\n");
                    KITLOutputDebugString("Do you want to continue (y/n)? ");
                    do {
                        Selection = tolower(OEMReadDebugByte());
                    } while ((Selection != 'y') && (Selection != 'n'));
                    KITLOutputDebugString("\r\n");
       
                    if (Selection == 'y')
                    {
                        NANDFormatNK();
                    }
                    break;
                case '8':
                    KITLOutputDebugString("\r\nWARNING:  Format of all NAND regions requested.\r\n");
                    KITLOutputDebugString("Boot loader and boot configuration regions will be erased!!!\r\n");
                    KITLOutputDebugString("Do you want to continue (y/n)? ");
                    do {
                        Selection = tolower(OEMReadDebugByte());
                    } while ((Selection != 'y') && (Selection != 'n'));
                    KITLOutputDebugString("\r\n");
                    
                    if (Selection == 'y')
                    {
                        NANDFormatAll();
                    }
                    break;
                case 'D':
                case 'd':
                    g_DownloadImage = TRUE;
                    goto exitMenu;
                    break;
                case 'L':
                case 'l':
                    if (g_BootCFG.autoDownloadImage == BOOT_CFG_AUTODOWNLOAD_NONE)
                    {
                        KITLOutputDebugString("\r\nWARNING:  You must select NOR/NAND/SD-MMC using Autoboot menu option.\r\n");
                    }
                    else
                    {
                        g_DownloadImage = FALSE;
                        goto exitMenu;
                    }
                    break;

                case 'S':
                case 's':
                    StoreBootCFG(&g_BootCFG);
                    bCFGChanged=FALSE;
                    break;

                default:
                    break;
                }
            }
        }
    }

exitMenu:

    if (bCFGChanged == TRUE)
    {
        StoreBootCFG(&g_BootCFG);
    }    
    
    // EEPROM on ADS does not have proper contents to allow CS8900 to automatically
    // read MAC address during initialization.  We must provide MAC from the Boot
    // configuration parameters previously loaded.
    memcpy(g_pBSPArgs->kitl.mac, g_BootCFG.mac, 6);

    // If active KITL is enabled at boot, or user selected the download option,
    // locate and initialize an Ethernet controller.
    //
    if ((!(g_pBSPArgs->kitl.flags & OAL_KITL_FLAGS_PASSIVE)) || g_DownloadImage)
    {
        // Make default Ethernet CS8900A.  Later we may want this to be configured with
        // the menu so we can support other download/KITL transports
        
        EthDevice = InitSpecifiedEthDevice(&g_pBSPArgs->kitl,  ETH_DEVICE_CS8900A);
        if (EthDevice == -1)
        {
            // No device was found ... 
            //
            KITLOutputDebugString("ERROR: Failed to detect and initialize Ethernet controller.\r\n");
            return(FALSE);
        }

        // Make sure MAC address has been programmed.
        //
        if (!g_pBSPArgs->kitl.mac[0] && !g_pBSPArgs->kitl.mac[1] && !g_pBSPArgs->kitl.mac[2])
        {
            KITLOutputDebugString("ERROR: Invalid Ethernet address read from Ethernet controller.\n");
            return(FALSE);
        }

        KITLOutputDebugString("INFO: MAC address: %x-%x-%x-%x-%x-%x\r\n",
            g_pBSPArgs->kitl.mac[0] & 0x00FF, g_pBSPArgs->kitl.mac[0] >> 8,
            g_pBSPArgs->kitl.mac[1] & 0x00FF, g_pBSPArgs->kitl.mac[1] >> 8,
            g_pBSPArgs->kitl.mac[2] & 0x00FF, g_pBSPArgs->kitl.mac[2] >> 8);
        
    }

    return(TRUE);
}


//------------------------------------------------------------------------------
//
//  Function:  SetIP
//
//  Allows user to set an IP address using the boot loader menu.
//
//  Parameters:
//      eBootCFG 
//          [out] Points to bootloader configuration that will be updated with
//          the IP address entered by the user.
//
//  Returns:
//      None.
//
//------------------------------------------------------------------------------
static void SetIP(BOOT_CFG *pBootCFG)
{
    char szDottedD[16]; // The string used to collect the dotted decimal IP address
    WORD cwNumChars = 0;
    UINT16 InChar = 0;
	INT32  dwCharRead = OEM_DEBUG_READ_NODATA;

    KITLOutputDebugString ( "\r\nEnter new IP address: ");

    while (!((InChar == 0x0d) || (InChar == 0x0a)))
    {
        dwCharRead = OEMReadDebugByte();
        if (dwCharRead != OEM_DEBUG_COM_ERROR && dwCharRead != OEM_DEBUG_READ_NODATA)
        {
			InChar = (UINT16)dwCharRead;
            // 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';
        pBootCFG->IP = inet_addr( szDottedD );
    }
}


//------------------------------------------------------------------------------
//
//  Function:  SetMask
//
//  Allows user to set a subnet mask using the boot loader menu.
//
//  Parameters:
//      eBootCFG 
//          [out] Points to bootloader configuration that will be updated with
//          the subnet mask entered by the user.
//
//  Returns:
//      None.
//
//------------------------------------------------------------------------------
static void SetMask(BOOT_CFG *pBootCFG)
{
    char szDottedD[16]; // The string used to collect the dotted masks
    WORD cwNumChars = 0;
    UINT16 InChar = 0;
    INT32  dwCharRead = OEM_DEBUG_READ_NODATA;

    KITLOutputDebugString ( "\r\nEnter new subnet mask: ");

    while (!((InChar == 0x0d) || (InChar == 0x0a)))
    {
        dwCharRead = OEMReadDebugByte();
        if (dwCharRead != OEM_DEBUG_COM_ERROR && dwCharRead != OEM_DEBUG_READ_NODATA)
        {
	    InChar = (UINT16)dwCharRead;
            // 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';
        pBootCFG->subnetMask = inet_addr( szDottedD );
    }
}

⌨️ 快捷键说明

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