1 /** @file 2 Legacy boot maintenance Ui definition. 3 4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> 5 SPDX-License-Identifier: BSD-2-Clause-Patent 6 7 **/ 8 9 10 #ifndef _EFI_LEGACY_BOOT_OPTION_H_ 11 #define _EFI_LEGACY_BOOT_OPTION_H_ 12 13 #include <PiDxe.h> 14 15 16 #include <Guid/GlobalVariable.h> 17 #include <Guid/LegacyDevOrder.h> 18 #include <Guid/MdeModuleHii.h> 19 20 #include <Protocol/HiiConfigAccess.h> 21 #include <Protocol/HiiConfigRouting.h> 22 23 #include <Protocol/HiiDatabase.h> 24 #include <Protocol/LegacyBios.h> 25 26 #include <Library/UefiDriverEntryPoint.h> 27 #include <Library/UefiBootServicesTableLib.h> 28 #include <Library/UefiRuntimeServicesTableLib.h> 29 #include <Library/BaseLib.h> 30 #include <Library/DevicePathLib.h> 31 #include <Library/DebugLib.h> 32 #include <Library/HiiLib.h> 33 #include <Library/UefiBootManagerLib.h> 34 #include <Library/MemoryAllocationLib.h> 35 #include <Library/UefiLib.h> 36 #include <Library/PrintLib.h> 37 #include <Library/BaseMemoryLib.h> 38 39 #include "LegacyBootMaintUiVfr.h" 40 41 #define CONFIG_OPTION_OFFSET 0x1200 42 43 // 44 // VarOffset that will be used to create question 45 // all these values are computed from the structure 46 // defined below 47 // 48 #define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((LEGACY_BOOT_NV_DATA *) 0)->Field))) 49 50 // 51 // Question Id of Zero is invalid, so add an offset to it 52 // 53 #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET) 54 55 56 #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD) 57 #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD) 58 #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD) 59 #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET) 60 #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV) 61 62 63 // 64 // String Constant 65 // 66 #define STR_FLOPPY L"Floppy Drive #%02x" 67 #define STR_HARDDISK L"HardDisk Drive #%02x" 68 #define STR_CDROM L"ATAPI CDROM Drive #%02x" 69 #define STR_NET L"NET Drive #%02x" 70 #define STR_BEV L"BEV Drive #%02x" 71 72 #define STR_FLOPPY_HELP L"Select Floppy Drive #%02x" 73 #define STR_HARDDISK_HELP L"Select HardDisk Drive #%02x" 74 #define STR_CDROM_HELP L"Select ATAPI CDROM Drive #%02x" 75 #define STR_NET_HELP L"NET Drive #%02x" 76 #define STR_BEV_HELP L"BEV Drive #%02x" 77 78 #define STR_FLOPPY_TITLE L"Set Legacy Floppy Drive Order" 79 #define STR_HARDDISK_TITLE L"Set Legacy HardDisk Drive Order" 80 #define STR_CDROM_TITLE L"Set Legacy CDROM Drive Order" 81 #define STR_NET_TITLE L"Set Legacy NET Drive Order" 82 #define STR_BEV_TITLE L"Set Legacy BEV Drive Order" 83 84 // 85 // These are the VFR compiler generated data representing our VFR data. 86 // 87 extern UINT8 LegacyBootMaintUiVfrBin[]; 88 89 #pragma pack(1) 90 91 /// 92 /// HII specific Vendor Device Path definition. 93 /// 94 typedef struct { 95 VENDOR_DEVICE_PATH VendorDevicePath; 96 EFI_DEVICE_PATH_PROTOCOL End; 97 } HII_VENDOR_DEVICE_PATH; 98 99 100 101 // 102 // Variable created with this flag will be "Efi:...." 103 // 104 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE 105 106 107 #define LEGACY_BOOT_OPTION_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('L', 'G', 'C', 'B') 108 109 typedef struct { 110 UINTN Signature; 111 112 // 113 // HII relative handles 114 // 115 EFI_HII_HANDLE HiiHandle; 116 EFI_HANDLE DriverHandle; 117 118 // 119 // Produced protocols 120 // 121 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess; 122 123 // 124 // Maintain the data. 125 // 126 LEGACY_BOOT_MAINTAIN_DATA *MaintainMapData; 127 } LEGACY_BOOT_OPTION_CALLBACK_DATA; 128 129 // 130 // All of the signatures that will be used in list structure 131 // 132 #define LEGACY_MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u') 133 #define LEGACY_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r') 134 135 #define LEGACY_LEGACY_DEV_CONTEXT_SELECT 0x9 136 137 typedef struct { 138 UINTN Signature; 139 LIST_ENTRY Head; 140 UINTN MenuNumber; 141 } LEGACY_MENU_OPTION; 142 143 typedef struct { 144 UINT16 BbsIndex; 145 CHAR16 *Description; 146 } LEGACY_DEVICE_CONTEXT; 147 148 typedef struct { 149 UINTN Signature; 150 LIST_ENTRY Link; 151 UINTN OptionNumber; 152 UINT16 *DisplayString; 153 UINT16 *HelpString; 154 EFI_STRING_ID DisplayStringToken; 155 EFI_STRING_ID HelpStringToken; 156 VOID *VariableContext; 157 } LEGACY_MENU_ENTRY; 158 159 typedef struct { 160 UINT16 BbsIndex; 161 } LEGACY_BOOT_OPTION_BBS_DATA; 162 163 #pragma pack() 164 165 /** 166 This call back function is registered with Boot Manager formset. 167 When user selects a boot option, this call back function will 168 be triggered. The boot option is saved for later processing. 169 170 171 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. 172 @param Action Specifies the type of action taken by the browser. 173 @param QuestionId A unique value which is sent to the original exporting driver 174 so that it can identify the type of data to expect. 175 @param Type The type of value for the question. 176 @param Value A pointer to the data being sent to the original exporting driver. 177 @param ActionRequest On return, points to the action requested by the callback function. 178 179 @retval EFI_SUCCESS The callback successfully handled the action. 180 @retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters. 181 182 **/ 183 EFI_STATUS 184 EFIAPI 185 LegacyBootOptionCallback ( 186 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 187 IN EFI_BROWSER_ACTION Action, 188 IN EFI_QUESTION_ID QuestionId, 189 IN UINT8 Type, 190 IN EFI_IFR_TYPE_VALUE *Value, 191 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest 192 ); 193 194 /** 195 This function allows a caller to extract the current configuration for one 196 or more named elements from the target driver. 197 198 199 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. 200 @param Request - A null-terminated Unicode string in <ConfigRequest> format. 201 @param Progress - On return, points to a character in the Request string. 202 Points to the string's null terminator if request was successful. 203 Points to the most recent '&' before the first failing name/value 204 pair (or the beginning of the string if the failure is in the 205 first name/value pair) if the request was not successful. 206 @param Results - A null-terminated Unicode string in <ConfigAltResp> format which 207 has all values filled in for the names in the Request string. 208 String to be allocated by the called function. 209 210 @retval EFI_SUCCESS The Results is filled with the requested values. 211 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results. 212 @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name. 213 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver. 214 215 **/ 216 EFI_STATUS 217 EFIAPI 218 LegacyBootOptionExtractConfig ( 219 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 220 IN CONST EFI_STRING Request, 221 OUT EFI_STRING *Progress, 222 OUT EFI_STRING *Results 223 ); 224 225 /** 226 This function processes the results of changes in configuration. 227 228 229 @param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. 230 @param Configuration - A null-terminated Unicode string in <ConfigResp> format. 231 @param Progress - A pointer to a string filled in with the offset of the most 232 recent '&' before the first failing name/value pair (or the 233 beginning of the string if the failure is in the first 234 name/value pair) or the terminating NULL if all was successful. 235 236 @retval EFI_SUCCESS The Results is processed successfully. 237 @retval EFI_INVALID_PARAMETER Configuration is NULL. 238 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver. 239 240 **/ 241 EFI_STATUS 242 EFIAPI 243 LegacyBootOptionRouteConfig ( 244 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, 245 IN CONST EFI_STRING Configuration, 246 OUT EFI_STRING *Progress 247 ); 248 249 #endif 250