Example #1
0
EFI_STATUS
Print_Menu()
{

    UINTN                     index;
    EFI_INPUT_KEY             Key;

    
  ST->ConOut->QueryMode (
                ST->ConOut,
                ST->ConOut->Mode->Mode,
                &mCols,
                &mRows
                );
    //
    //disable cursor
    //
    ST->ConOut->EnableCursor(ST->ConOut,FALSE);
    ST->ConOut->SetAttribute(ST->ConOut,EFI_WHITE|EFI_BACKGROUND_BLACK);
    ST->ConOut->ClearScreen(ST->ConOut);
    //PrintXY(0,0,NULL,NULL,L"Test Menu %d * %d, mode = %d", mCols, mRows, ST->ConOut->Mode->Mode);
    
    PrintTittle();
    MenuHeader();
    ClearArea(0,2, 79, 23, EFI_WHITE|EFI_BACKGROUND_BLUE);
    
    PrintTail();

    while(TRUE){

        BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &index);
        ST->ConIn->ReadKeyStroke(ST->ConIn, &Key);
        switch(Key.ScanCode)
        {

            case SCAN_ESC:
            ST->ConOut->SetAttribute (ST->ConOut,EFI_WHITE|EFI_BACKGROUND_BLACK);
            ST->ConOut->ClearScreen (ST->ConOut);
            return EFI_SUCCESS;
            break;
            case SCAN_F1:
            PrintSubMenu();
            break;
            case SCAN_NULL:
            break;
            default:
            break;
        }

    }
    

}
Example #2
0
static
void
DebugSettingsComPort(
    void *pContext,
    handle_t hTerminal,
    void * pActionMenu
    )
{
    BootLoader_t *pLoader = pContext;
    enum_t ix;
    wchar_t key;
    UNREFERENCED_PARAMETER(pActionMenu);

    MenuHeader(hTerminal, L" Select Com Port\r\n");

    for(ix = 0; ix < 4; ix++)
    {
        BootTerminalPrintf(hTerminal, L" [%d] COM%d\r\n", ix + 1, ix + 1);
    }

    if (pLoader->comPort == 0)
    {
        BootTerminalPrintf(
            hTerminal, L"\r\n Selection (Disabled): "
            );
    }
    else
    {
        BootTerminalPrintf(
            hTerminal, L"\r\n Selection (actual COM%d): ",
            pLoader->comPort
            );
    }

    // Get selection
    do
    {
        key = BootTerminalReadChar(hTerminal);
        if (key == L'\0') continue;
    }
    while ((key < L'1') || (key > (L'4')));

    // Print out selection character
    BootTerminalPrintf(hTerminal, L"%c\r\n", key);

    ix = key - L'0';
    pLoader->comPort = (uint8_t)ix;

    if (pLoader->comPort == 0)
    {
        BootTerminalPrintf(
            hTerminal, L" Debug port disabled.\r\n"
            );
    }
    else
    {
        BootTerminalPrintf(
            hTerminal, L" Debug port set to COM%d.\r\n",
            pLoader->comPort
            );
    }

}
Example #3
0
static
void
DisplayMode(
    void *pContext,
    handle_t hTerminal,
    void * pActionMenu
    )
{
    BootLoader_t *pLoader = pContext;
    enum_t ix;
    wchar_t key;
    static struct {
        size_t width;
        size_t height;
    } const displayMode[] = {
        { 0, 0 }, { 176, 220 }, { 240, 240 }, { 240, 320 }, { 320, 240 },
        { 320, 320 }, { 400, 240 }, { 480, 640 }, { 480, 800 }, { 640, 480 }, { 640, 640 }, { 800, 480 }
    };
    UNREFERENCED_PARAMETER(pActionMenu);


    MenuHeader(hTerminal, L" Select Display Mode\r\n");

    for (ix = 0; ix < dimof(displayMode); ix++)
        {
        if (displayMode[ix].width == 0)
            {
            BootTerminalPrintf(hTerminal, L" [a] Full Screen\r\n");
            }
        else
            {
            key = L'a' + (wchar_t)ix;
            BootTerminalPrintf(
                hTerminal, L" [%c] %d x %d\r\n", ix + L'a', displayMode[ix].width,
                displayMode[ix].height
                );
            }
        }

    if (pLoader->displayLogicalWidth == 0)
        {
        BootTerminalPrintf(
            hTerminal, L"\r\n Selection (actual Full Screen): "
            );
        }
    else
        {
        BootTerminalPrintf(
            hTerminal, L"\r\n Selection (actual %d x %d): ",
            pLoader->displayLogicalWidth, pLoader->displayLogicalHeight
            );
        }

    // Get selection
    do
    {
        key = BootTerminalReadChar(hTerminal);
        if (key == L'\0') continue;
    }
    while ((key < L'a') || (key > (L'a' + dimof(displayMode) - 1)));

    // Print out selection character
    BootTerminalPrintf(hTerminal, L"%c\r\n", key);

    ix = key - L'a';
    pLoader->displayLogicalWidth = displayMode[ix].width;
    pLoader->displayLogicalHeight = displayMode[ix].height;

    if (pLoader->displayLogicalWidth == 0)
        {
        BootTerminalPrintf(
            hTerminal, L" Display mode set to Full Screen.\r\n"
            );
        }
    else
        {
        BootTerminalPrintf(
            hTerminal, L" Display mode set to %d x %d.\r\n",
            pLoader->displayLogicalWidth, pLoader->displayLogicalHeight
            );
        }

}
Example #4
0
static
void
DisplayResolution(
    void *pContext,
    handle_t hTerminal,
    void * pActionMenu
    )
{
    BootLoader_t *pLoader = pContext;
    handle_t hDisplay;
    enum_t mode, bppMode, resMode;
    wchar_t key;
    uint32_t width, height, bpp;
    uint32_t bppOptions[4] = {0,0,0,0};
    enum_t resOptions[20];
    UNREFERENCED_PARAMETER(pActionMenu);


    hDisplay = OEMBootCreateDriver(pContext, BOOT_DRIVER_CLASS_DISPLAY, 0);
    if (hDisplay == NULL) goto cleanUp;

    MenuHeader(hTerminal, L" Select Desired Bits Per Pixel\r\n");

    mode = bppMode = 0;
    while (BootDisplayModeQuery(hDisplay, &mode, &width, &height, &bpp) && (bppMode < 4))
        {
        // Only support four bpp modes (8, 16, 24, 32) currently, and 20 resolutions for each
        if (!((bpp == bppOptions[0]) || 
              (bpp == bppOptions[1]) || 
              (bpp == bppOptions[2]) || 
              (bpp == bppOptions[3])))
            {
            key = L'a' + (wchar_t)bppMode;
            BootTerminalPrintf(
                hTerminal, L" [%c] %2d\r\n",
                key, bpp
                );

            bppOptions[bppMode++] = bpp;
            }

        mode++;
        }

    BootTerminalPrintf(
        hTerminal, L"\r\n Selection (actual %d bpp): ",
        pLoader->displayBpp
        );

    // Get selection
    do
        {
        key = BootTerminalReadChar(hTerminal);
        if (key == L'\0') continue;
        }
    while ((key < L'a') || (key >= (L'a' + bppMode)));

    // Print out selection character
    BootTerminalPrintf(hTerminal, L"%c\r\n", key);

    // User choosed this mode...
    bppMode = key - 'a';


    MenuHeader(hTerminal, L" Select Display Resolution\r\n");

    mode = resMode = 0;
    while (BootDisplayModeQuery(hDisplay, &mode, &width, &height, &bpp) && (resMode < 12))
        {

        if (bpp == bppOptions[bppMode])
            {
            key = L'a' + (wchar_t)resMode;
            BootTerminalPrintf(
                hTerminal, L" [%c] %4d x %4d x %2d\r\n",
                key, width, height, bpp
                );

            resOptions[resMode++] = mode;
            }

        mode++;
        }

    BootTerminalPrintf(
        hTerminal, L"\r\n Selection (actual %d x %d x %d): ",
        pLoader->displayWidth, pLoader->displayHeight, pLoader->displayBpp
        );

    // Get selection
    do
        {
        key = BootTerminalReadChar(hTerminal);
        if (key == L'\0') continue;
        }
    while ((key < L'a') || (key >= (L'a' + resMode)));

    // Print out selection character
    BootTerminalPrintf(hTerminal, L"%c\r\n", key);

    // Use choosed this mode...
    resMode = key - 'a';
    mode = resOptions[resMode];
    BootDisplayModeQuery(hDisplay, &mode, &width, &height, &bpp);
    pLoader->displayWidth = width;
    pLoader->displayHeight = height;
    pLoader->displayBpp = bpp;
    BootTerminalPrintf(
        hTerminal, L" Display resolution set to %d x %d x %d\r\n",
        width, height, bpp
        );

cleanUp:
    BootDisplayDeinit(hDisplay);
}
Example #5
0
static
void
SelectDevice(
    BootLoader_t *pLoader,
    handle_t hTerminal,
    bool_t kitlDevice
    )
{
    DeviceLocation_t devLoc[9], actualDevLoc;
    enum_t ix, iy;
    wchar_t key;
    wcstring_t name;


    MenuHeader(
        hTerminal, L" Select %s Device\r\n", kitlDevice ? L"KITL" : L"Boot"
        );

    actualDevLoc = kitlDevice ? pLoader->kitlDevice : pLoader->bootDevice;

    ix = 0;
    for (iy = 0; iy < pLoader->devices; iy++)
        {
        const Device_t *pDevice = &pLoader->pDevices[iy];
        switch (pDevice->type)
            {
            case DeviceTypeEdbg:
                switch (pDevice->ifc)
                    {
                    case IfcTypePci:
                        {
                        BootPciLocation_t pciLoc;
                        pciLoc.logicalLoc = 0;
                        do
                            {
                            if (BootPciGetId(pciLoc) == pDevice->id)
                                {
                                devLoc[ix].type = DeviceTypeEdbg;
                                devLoc[ix].ifc = IfcTypePci;
                                devLoc[ix].busNumber = 0;
                                devLoc[ix].location = pciLoc.logicalLoc;
                                name = DevLocToString(pLoader, &devLoc[ix]);
                                BootTerminalPrintf(
                                    hTerminal, L" [%d] %s\r\n", ix + 1, name
                                    );
                                ix++;
                                }
                            BootPciNextLocation(&pciLoc);
                            if (ix >= dimof(devLoc)) break;
                            }                            
                        while (pciLoc.bus <= pLoader->pciLastBus);
                        }
                        break;
                    }
                break;
            case DeviceTypeStore:
                if (kitlDevice) break;
                devLoc[ix].type = DeviceTypeStore;
                devLoc[ix].ifc = (enum_t)IfcTypeUndefined;
                devLoc[ix].busNumber = 0;
                devLoc[ix].location = 0;
                name = DevLocToString(pLoader, &devLoc[ix]);
                BootTerminalPrintf(hTerminal, L" [%d] %s\r\n", ix + 1, name);
                ix++;
                break;
            }
        if (ix >= dimof(devLoc)) break;
        }

    BootTerminalPrintf(
        hTerminal, L"\r\n Selection (actual %s): ",
        DevLocToString(pLoader, &actualDevLoc)
        );

    // Get selection
    do
        {
        key = BootTerminalReadChar(hTerminal);
        if (key == L'\0') continue;
        }
    while ((key < L'1') || (key >= (L'1' + ix)));

    // Print out selection character
    BootTerminalPrintf(hTerminal, L"%c\r\n", key);

    // Save new device
    actualDevLoc = devLoc[key - L'1'];
    if (kitlDevice)
        {
        pLoader->kitlDevice = actualDevLoc;
        }
    else
        {
        pLoader->bootDevice = actualDevLoc;
        }

    // Print info...
    BootTerminalPrintf(
        hTerminal, L" %s Device is set to %s.\r\n",
        kitlDevice ? L"KITL" : L"Boot", DevLocToString(pLoader, &actualDevLoc)
        );
}
Example #6
0
static
void
DebugSettingsBaudRate(
    void *pContext,
    handle_t hTerminal,
    void * pActionMenu
    )
{
    BootLoader_t *pLoader = pContext;
    enum_t ix;
    wchar_t key;

    static struct
    {
        ULONG   ulRate;
        UCHAR   ucDivisor;
    }   
    const BaudTable[] = {
        { 9600,  12},
        { 19200,  6},
        { 38400,  3},
        { 57600,  2},
        { 115200, 1}
    };
    static enum_t numEntries = (sizeof(BaudTable) / sizeof(BaudTable[0]));

    UNREFERENCED_PARAMETER(pActionMenu);

    MenuHeader(hTerminal, L" Set Baud Rate\r\n");

    for(ix = 0; ix < numEntries; ix++)
    {
        BootTerminalPrintf(hTerminal, L" [%d] %d\r\n", ix + 1, BaudTable[ix]);
    }

    for (ix = 0; ix < numEntries; ix++)
    {
        if (pLoader->baudDivisor == BaudTable[ix].ucDivisor)
        {
            BootTerminalPrintf(
                hTerminal, L"\r\n Selection (%d): ", BaudTable[ix].ulRate
                );
        }
    }

    // Get selection
    do            
    {
        key = BootTerminalReadChar(hTerminal);
        if (key == L'\0') continue;
    }
    while ((key < L'1') || (key > (L'0' + numEntries)));

    // Print out selection character
    BootTerminalPrintf(hTerminal, L"%c\r\n", key);

    ix = key - L'1';

    pLoader->baudDivisor = BaudTable[ix].ucDivisor;
            
    for (ix = 0; ix < numEntries; ix++)
    {
        if (pLoader->baudDivisor == BaudTable[ix].ucDivisor)
        {
            BootTerminalPrintf(
                hTerminal, L" Baud rate set to %d.\r\n",
                BaudTable[ix].ulRate
                );
        }
    }
}