init.c
来自「Next BIOS Source code : Extensible Firmw」· C语言 代码 · 共 555 行 · 第 1/2 页
C
555 行
/*++
Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.
Module Name:
init.c
Abstract:
init file for boot maintenance menu option of boot manager.
Revision History
--*/
#include "menu.h"
EFI_MENU MainMenu = {
MENU_SIGNATURE, NULL,
4, FILE_UNSELECTED, FILE_ACTIVE_SELECTION,
TRUE, 10,
L"%EMain Menu. Select an Operation\n\n",
NULL, 3,
NULL, NULL, NULL, NULL, NULL, FALSE, 0, MENU_ENTRY_FORMAT
};
EFI_MENU FileSystemMenu = {
MENU_SIGNATURE, NULL,
4, FILE_UNSELECTED, FILE_ACTIVE_SELECTION,
TRUE, 10,
// L"%ESelect a volume\n\n",
NULL,
NULL, 2,
NULL, NULL, NULL, NULL, NULL, FALSE, 0, MENU_ENTRY_FORMAT
};
EFI_MENU DirMenu = {
MENU_SIGNATURE, NULL,
4, FILE_UNSELECTED, FILE_ACTIVE_SELECTION,
TRUE, 10,
L"%ESelect file or change to new directory:\n",
NULL, 2,
NULL, NULL, NULL, NULL, NULL, FALSE, 0, MENU_ENTRY_FORMAT
};
VOID
FreeFileSystemMenu (
IN EFI_MENU *Menu
);
EFI_STATUS
Bmnt_DisplayWarmReset ();
EFI_STATUS
Bmnt_DisplayColdReset ();
VOID
InitializeMainMenuFooter();
VOID
FreeMainMenuFooter();
VOID
AddLegacyBootOption (
IN UINT16 BbsType,
IN UINT16 BbsFlag,
IN UINT8 *BbsString,
IN UINT16 *String,
IN BOOLEAN Removable
);
FILE_MENU_CONTEXT *
AllocateSpecialFileMenuOption (
IN EFI_MENU *Menu,
IN CHAR16 *String,
IN UINTN Attribute,
IN UINTN Option
);
VOID
FreeSpecificFileMenuOption (
IN EFI_MENU *Menu,
IN FILE_MENU_CONTEXT *Context
);
//
//
//
EFI_STATUS
InitializeBootMaintenance (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
//
//
//
EFI_HANDLE GlobalImageHandle;
EFI_DRIVER_ENTRY_POINT(InitializeBootMaintenance)
EFI_STATUS
InitializeBootMaintenance (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
MENU_PICK MenuPick;
UINTN PreviousAttribute;
EFI_INPUT_KEY Key;
//
// Initialize EFI library
//
InitializeLib (ImageHandle, SystemTable);
//
// Disable the watchdog timer
//
BS->SetWatchdogTimer ( 0x0000, 0x0000, 0x0000, NULL );
GlobalImageHandle = ImageHandle;
PreviousAttribute = ST->ConOut->Mode->Attribute;
//
// Init Boot Order menu to allow other menus to access the Boot variables
//
InitializeBootOrderMenuFromVariable ();
InitializeListHead (&MainMenu.Head);
AllocateMenuOption (&MainMenu, L" Boot from a File", FILE_UNSELECTED, Bmnt_DisplayFileSystemBootFromFsMenu);
AllocateMenuOption (&MainMenu, L" Add a Boot Option", FILE_UNSELECTED, Bmnt_DisplayBootMenuOption);
AllocateMenuOption (&MainMenu, L" Delete Boot Option(s)", FILE_UNSELECTED, Bmnt_DisplayDeleteBootMenu);
AllocateMenuOption (&MainMenu, L" Change Boot Order", FILE_UNSELECTED, Bmnt_DisplayBootOrderMenu);
SkipMenuLine(&MainMenu);
AllocateMenuOption (&MainMenu, L" Manage BootNext setting", FILE_UNSELECTED, Bmnt_DisplayBootNextMenu);
AllocateMenuOption (&MainMenu, L" Set Auto Boot TimeOut", FILE_UNSELECTED, Bmnt_DisplayBootTimeOut);
SkipMenuLine(&MainMenu);
AllocateMenuOption (&MainMenu, L" Select Active Console Output Devices", FILE_UNSELECTED, Bmnt_DisplayConsoleOutMenu);
AllocateMenuOption (&MainMenu, L" Select Active Console Input Devices", FILE_UNSELECTED, Bmnt_DisplayConsoleInMenu);
AllocateMenuOption (&MainMenu, L" Select Active Standard Error Devices", FILE_UNSELECTED, Bmnt_DisplayStdErrorMenu);
SkipMenuLine(&MainMenu);
// AllocateMenuOption (&MainMenu, L" Warm Reset", FILE_UNSELECTED, DisplayWarmReset);
AllocateMenuOption (&MainMenu, L" Cold Reset", FILE_UNSELECTED, Bmnt_DisplayColdReset);
AllocateMenuOption (&MainMenu, L" Exit", FILE_UNSELECTED, NULL);
MainMenu.Selection = NULL;
for (;;) {
//
// bugbug: Not the best way to update timeout on main menu screen
// Init main menu footer with SystemGuid and SerialNumber and Timeout value
//
InitializeMainMenuFooter ();
MenuPick = MenuDisplay (&MainMenu, &Key);
if (MenuPick == NULL) {
break;
}
if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
MenuPick();
}
//
// Free main menu footer
//
FreeMainMenuFooter ();
}
MenuFree (&MainMenu);
//
// Free Boot Order menu
//
FreeBootOrderMenuOfVariables();
ST->ConOut->SetAttribute (ST->ConOut, PreviousAttribute);
ST->ConOut->ClearScreen (ST->ConOut);
return EFI_SUCCESS;
}
EFI_STATUS
Bmnt_DisplayFileSystemBootFromFsMenu()
{
CHAR16 *Header = L"%EBoot From a File. Select a Volume\n\n";
//
// initialize header text
//
FileSystemMenu.Header = Header;
return DisplayFileSystemMenu (TRUE);
}
EFI_STATUS
Bmnt_DisplayBootMenuOption()
{
CHAR16 *Header = L"%EAdd a Boot Option. Select a Volume\n\n";
//
// initialize header text
//
FileSystemMenu.Header = Header;
return DisplayFileSystemMenu (FALSE);
}
EFI_STATUS
DisplayFileSystemMenu (
IN BOOLEAN BootFromAFileSystem
)
{
CHAR16 Buffer[MAX_CHAR];
UINTN Index;
UINTN NumberFsHandles;
EFI_HANDLE *FsHandles;
UINTN NumberBlkIoHandles;
EFI_HANDLE *BlkIoHandles;
UINTN NumberLoadFileHandles;
EFI_HANDLE *LoadFileHandles;
FILE_MENU_CONTEXT *ResultContext;
FILE_MENU_CONTEXT *Context;
CHAR16 *VolLabel;
EFI_INPUT_KEY Key;
EFI_BLOCK_IO *BlkIo;
EFI_STATUS Status;
CHAR16 *Str;
EFI_FILE_HANDLE FileHandle;
VOID *Interface;
InitializeListHead (&FileSystemMenu.Head);
//
// add filesystem devices
//
LibLocateHandle (ByProtocol, &FileSystemProtocol, NULL, &NumberFsHandles, &FsHandles);
FileSystemMenu.BottomOfPage = NULL;
for (Index = 0; Index < NumberFsHandles; Index++) {
Status = BS->HandleProtocol (FsHandles[Index], &BlockIoProtocol, &BlkIo);
//
// add searching of files for non-removable media only
// removable media has a fixed file path (\efi\boot) for searching
//
if(!EFI_ERROR(Status) && BlkIo->Media->RemovableMedia) {
if (!BootFromAFileSystem) {
continue;
}
}
FileHandle = LibOpenRoot(FsHandles[Index]);
if (FileHandle == NULL) {
continue;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?