2 This file include all platform action which can be customized
5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "PlatformBootManager.h"
17 #include "PlatformConsole.h"
20 Return the index of the load option in the load option array.
22 The function consider two load options are equal when the
23 OptionType, Attributes, Description, FilePath and OptionalData are equal.
25 @param Key Pointer to the load option to be found.
26 @param Array Pointer to the array of load options to be found.
27 @param Count Number of entries in the Array.
29 @retval -1 Key wasn't found in the Array.
30 @retval 0 ~ Count-1 The index of the Key in the Array.
33 PlatformFindLoadOption (
34 IN CONST EFI_BOOT_MANAGER_LOAD_OPTION
*Key
,
35 IN CONST EFI_BOOT_MANAGER_LOAD_OPTION
*Array
,
41 for (Index
= 0; Index
< Count
; Index
++) {
42 if ((Key
->OptionType
== Array
[Index
].OptionType
) &&
43 (Key
->Attributes
== Array
[Index
].Attributes
) &&
44 (StrCmp (Key
->Description
, Array
[Index
].Description
) == 0) &&
45 (CompareMem (Key
->FilePath
, Array
[Index
].FilePath
, GetDevicePathSize (Key
->FilePath
)) == 0) &&
46 (Key
->OptionalDataSize
== Array
[Index
].OptionalDataSize
) &&
47 (CompareMem (Key
->OptionalData
, Array
[Index
].OptionalData
, Key
->OptionalDataSize
) == 0)) {
56 Register a boot option using a file GUID in the FV.
58 @param FileGuid The file GUID name in FV.
59 @param Description The boot option description.
60 @param Attributes The attributes used for the boot option loading.
63 PlatformRegisterFvBootOption (
71 EFI_BOOT_MANAGER_LOAD_OPTION NewOption
;
72 EFI_BOOT_MANAGER_LOAD_OPTION
*BootOptions
;
73 UINTN BootOptionCount
;
74 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode
;
75 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
76 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
78 Status
= gBS
->HandleProtocol (gImageHandle
, &gEfiLoadedImageProtocolGuid
, (VOID
**) &LoadedImage
);
79 ASSERT_EFI_ERROR (Status
);
81 EfiInitializeFwVolDevicepathNode (&FileNode
, FileGuid
);
82 DevicePath
= AppendDevicePathNode (
83 DevicePathFromHandle (LoadedImage
->DeviceHandle
),
84 (EFI_DEVICE_PATH_PROTOCOL
*) &FileNode
87 Status
= EfiBootManagerInitializeLoadOption (
89 LoadOptionNumberUnassigned
,
97 if (!EFI_ERROR (Status
)) {
98 BootOptions
= EfiBootManagerGetLoadOptions (&BootOptionCount
, LoadOptionTypeBoot
);
100 OptionIndex
= PlatformFindLoadOption (&NewOption
, BootOptions
, BootOptionCount
);
102 if (OptionIndex
== -1) {
103 Status
= EfiBootManagerAddLoadOptionVariable (&NewOption
, (UINTN
) -1);
104 ASSERT_EFI_ERROR (Status
);
106 EfiBootManagerFreeLoadOption (&NewOption
);
107 EfiBootManagerFreeLoadOptions (BootOptions
, BootOptionCount
);
112 Do the platform specific action before the console is connected.
115 Update console variable;
116 Register new Driver#### or Boot####;
117 Signal ReadyToLock event.
121 PlatformBootManagerBeforeConsole (
127 EFI_BOOT_MANAGER_LOAD_OPTION BootOption
;
129 PlatformConsoleInit ();
132 // Register ENTER as CONTINUE key
134 Enter
.ScanCode
= SCAN_NULL
;
135 Enter
.UnicodeChar
= CHAR_CARRIAGE_RETURN
;
136 EfiBootManagerRegisterContinueKeyOption (0, &Enter
, NULL
);
139 // Map F2 to Boot Manager Menu
141 F2
.ScanCode
= SCAN_F2
;
142 F2
.UnicodeChar
= CHAR_NULL
;
143 EfiBootManagerGetBootManagerMenu (&BootOption
);
144 EfiBootManagerAddKeyOptionVariable (NULL
, (UINT16
) BootOption
.OptionNumber
, 0, &F2
, NULL
);
147 // Register UEFI Shell
149 PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile
), L
"UEFI Shell", LOAD_OPTION_ACTIVE
);
153 Do the platform specific action after the console is connected.
156 Dynamically switch output mode;
157 Signal console ready platform customized event;
158 Run diagnostics like memory testing;
159 Connect certain devices;
160 Dispatch aditional option roms.
164 PlatformBootManagerAfterConsole (
168 EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black
;
169 EFI_GRAPHICS_OUTPUT_BLT_PIXEL White
;
171 Black
.Blue
= Black
.Green
= Black
.Red
= Black
.Reserved
= 0;
172 White
.Blue
= White
.Green
= White
.Red
= White
.Reserved
= 0xFF;
174 EfiBootManagerConnectAll ();
175 EfiBootManagerRefreshAllBootOption ();
179 L
"F2 to enter Boot Manager Menu.\n"
180 L
"ENTER to boot directly.\n"
187 This function is called each second during the boot manager waits the timeout.
189 @param TimeoutRemain The remaining timeout.
193 PlatformBootManagerWaitCallback (