1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
//**********************************************************************
//**********************************************************************
//** **
//** (C)Copyright 1985-2012, American Megatrends, Inc. **
//** **
//** All Rights Reserved. **
//** **
//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
//** **
//** Phone: (770)-246-8600 **
//** **
//**********************************************************************
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/Projects/Intel/Haswell/LynxPoint_SharkBay-DT_Crb_1AQQW/Include/BootOptions.h 2 10/30/13 6:49a Ireneyang $
//
// $Revision: 2 $
//
// $Date: 10/30/13 6:49a $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/Projects/Intel/Haswell/LynxPoint_SharkBay-DT_Crb_1AQQW/Include/BootOptions.h $
//
// 2 10/30/13 6:49a Ireneyang
// - Fix Setup menu erroneously shows multiple instances of
// the same bootable device for EIP139412
//
// 6 5/20/13 4:35p Artems
// [TAG] EIP N/A
// [Category] Improvement
// [Description] Implement ORPHAN_BOOT_POLICY_KEEP for legacy groups
// [Files] BootOptions.h BootOptions.c BdsBoard.c
//
// 5 7/19/12 4:10p Felixp
// Enhancement:
// AMI_BOOT_OPTION_SIGNATURE macro is updated to start with a couple of
// zeroes.
// Some EFI applications (for example UEFI Shell) treats optional data
// as a command line string.
// These applications will treat a signature constructed by the
// AMI_BOOT_OPTION_SIGNATURE macro
// as an empty Unicode string.
//
// 4 5/23/12 4:08p Artems
// [TAG] EIP N/A
// [Category] Improvement
// [Description] Added AMI-style header and footer
// [Files] bootoptions.h
//
//
//**********************************************************************
//<AMI_FHDR_START>
//
// Name: <BootOptions.h>
//
// Description: Boot options infrastructure definitions
//
//<AMI_FHDR_END>
//**********************************************************************
#ifndef __BOOT_OPTIONS_H__
#define __BOOT_OPTIONS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <Token.h>
#include <AmiDxeLib.h>
#include <Pci.h>
#include <Protocol/SimpleFileSystem.h>
#include <Protocol/LoadFile.h>
#include <Protocol/BlockIo.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/DevicePath.h>
#ifdef CSM_SUPPORT
#include <Protocol/LegacyBios.h>
#endif
#ifndef CSM_SUPPORT
typedef VOID BBS_TABLE;
#endif
typedef struct{
DLINK Link;
UINT32 Attributes;
CHAR16 *Description;
EFI_DEVICE_PATH_PROTOCOL *FilePathList;
UINTN FilePathListLength;
UINT8 *OptionalData;
UINTN OptionalDataSize;
UINT16 BootOptionNumber;
UINT32 Priority;
UINT32 Tag; // Just a number. Devices with the same number have something in common;
// Can be used as a sort key.
EFI_HANDLE DeviceHandle;
UINT16 BbsIndex;
BBS_TABLE *BbsEntry;
BOOLEAN FwBootOption;
BOOLEAN GroupHeader;
} BOOT_OPTION;
typedef struct{
DLINK Link;
EFI_HANDLE DeviceHandle;
UINT16 BbsIndex;
BBS_TABLE *BbsEntry;
} BOOT_DEVICE;
typedef BOOLEAN (DEVICE_PATH_TO_DEVICE_MATCH_TEST)(
EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath, BOOT_DEVICE *Device
);
typedef BOOLEAN (BOOT_OPTION_TO_DEVICE_MATCH_TEST)(
BOOT_OPTION *Option, BOOT_DEVICE *Device
);
typedef BOOLEAN (FILTER_BOOT_DEVICE_TEST)(BOOT_DEVICE *Device);
typedef UINTN (CONSTRUCT_BOOT_OPTION_NAME)(
BOOT_OPTION *Option, CHAR16 *Name, UINTN NameSize
);
typedef UINT16 (GET_BBS_ENTRY_DEVICE_TYPE)(BBS_TABLE *BbsEntry);
typedef BOOLEAN (BUILD_BOOT_OPTION_FILE_PATH_LIST)(BOOT_OPTION *Option);
#pragma pack(push,1)
typedef struct{
UINT32 Signature;
UINT32 Size;
EFI_LOAD_OPTION Option;
} NESTED_BOOT_OPTION;
typedef struct{
// Guid = AMI_BBS_DEVICE_PATH_GUID
VENDOR_DEVICE_PATH Header;
UINT8 Bus;
UINT8 Device;
UINT8 Function;
UINT8 Class;
UINT8 SubClass;
UINT8 Instance;
}AMI_BBS_DEVICE_PATH;
typedef struct{
// Guid = AMI_DEVICE_NAME_DEVICE_PATH_GUID
VENDOR_DEVICE_PATH Header;
// UINT8 DeviceName[n]
// n = <node length from the header> - sizeof(AMI_DEVICE_NAME_DEVICE_PATH)
}AMI_DEVICE_NAME_DEVICE_PATH;
#pragma pack(pop)
typedef INT32 ( *COMPARE_FUNCTION ) (DLINK *p, DLINK *q);
typedef VOID (BDS_CONTROL_FLOW_FUNCTION)();
#define INVALID_HANDLE NULL
#define INVALID_BBS_INDEX 0xFFFF
#define INVALID_BOOT_OPTION_NUMBER 0xFFFF
#define LOWEST_BOOT_OPTION_PRIORITY 0xFFFFFFFF
#define UNASSIGNED_LOWEST_TAG 0
#define UNASSIGNED_HIGHEST_TAG 0xFFFFFFFF
#define INVALID_STR_TOKEN 0xFFFF
// The upper two bytes of the signature must be zeroes.
// Some EFI applications (for example UEFI Shell) treats optional data
// as a command line string.
// These applications will treat this signature as an empty Unicode string.
#define AMI_BOOT_OPTION_SIGNATURE(Letter) (('O'<<24)+((Letter)<<16))
#define GetBaseTag(Tag) ((Tag)&0xFFFF)
#define BootOptionTag(BaseTag,Priority) ((BaseTag)|((Priority)<<16))
#define AMI_SIMPLE_BOOT_OPTION_SIGNATURE AMI_BOOT_OPTION_SIGNATURE('B')//'AMBO'
#define AMI_GROUP_BOOT_OPTION_SIGNATURE AMI_BOOT_OPTION_SIGNATURE('G')//'AMGO'
#define AMI_NESTED_BOOT_OPTION_SIGNATURE AMI_BOOT_OPTION_SIGNATURE('N')//'AMNO'
#define AMI_NESTED_BOOT_OPTION_HEADER_SIZE EFI_FIELD_OFFSET(NESTED_BOOT_OPTION,Option)
#define STARTING_BOOT_OPTION_PRIORITY 0x100
#define DEFAULT_PRIORITY_INCREMENT 0x100
#define GetNextBootOptionPriority(CurrentPriority) ((CurrentPriority)+DEFAULT_PRIORITY_INCREMENT)
#define IndexToBootPriority(Index) (STARTING_BOOT_OPTION_PRIORITY+(Index)*DEFAULT_PRIORITY_INCREMENT)
#define IsLegacyBootOption(Option) (\
((Option)->FilePathList==NULL) ? (Option)->BbsEntry!=NULL : (Option)->FilePathList->Type==BBS_DEVICE_PATH\
)
#define IsBootOptionWithDevice(Option) ((Option)->BbsEntry!=NULL || (Option)->DeviceHandle!=INVALID_HANDLE)
#define BOOT_VARIABLE_ATTRIBUTES \
(EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
#define AMI_BBS_DEVICE_PATH_GUID \
{ 0x1db184ae, 0x81f5, 0x4e72, { 0x85, 0x44, 0x2b, 0xab, 0xc, 0x2c, 0xac, 0x5c } }
#define AMI_MASKED_DEVICE_PATH_GUID \
{ 0x99e275e7, 0x75a0, 0x4b37, { 0xa2, 0xe6, 0xc5, 0x38, 0x5e, 0x6c, 0x0, 0xcb } }
#define AMI_DEVICE_NAME_DEVICE_PATH_GUID \
{ 0x2d6447ef, 0x3bc9, 0x41a0, { 0xac, 0x19, 0x4d, 0x51, 0xd0, 0x1b, 0x4c, 0xe6 } }
#define SHELL_GUID \
{0Xc57ad6b7,0X0515,0X40a8,{0X9d,0X21,0X55,0X16,0X52,0X85,0X4e,0X37}}
#define AMI_MEDIA_DEVICE_PATH_GUID \
{ 0x5023b95c, 0xdb26, 0x429b, { 0xa6, 0x48, 0xbd, 0x47, 0x66, 0x4c, 0x80, 0x12 } }
#define FOR_EACH_LIST_ELEMENT(FirstLinkPtr,LinkPtr,ElementPtr,ELEMENT_TYPE)\
for( LinkPtr=(FirstLinkPtr)\
; LinkPtr!=NULL\
&& (ElementPtr=OUTTER(LinkPtr,Link,ELEMENT_TYPE),LinkPtr=LinkPtr->pNext,TRUE)\
;\
)
#define FOR_EACH_BOOT_OPTION(List,Link,Element)\
FOR_EACH_LIST_ELEMENT((List)->pHead,Link,Element,BOOT_OPTION)
#define FOR_EACH_BOOT_DEVICE(List,Link,Element)\
FOR_EACH_LIST_ELEMENT((List)->pHead,Link,Element,BOOT_DEVICE)
#define NUMBER_OF_BBS_DEVICE_TYPES 8
#define BBS_DEVICE_TYPE_TO_INDEX(DeviceType)\
( (DeviceType)<=BBS_EMBED_NETWORK && (DeviceType)!=0\
? (DeviceType)-1\
: (DeviceType)==BBS_BEV_DEVICE\
? NUMBER_OF_BBS_DEVICE_TYPES-2\
: NUMBER_OF_BBS_DEVICE_TYPES-1\
)
#ifdef EFI_DEBUG
#define DUMP_BOOT_OPTION_LIST(List,Caption) DumpBootOptionList(List,Caption)
#else
#define DUMP_BOOT_OPTION_LIST(List,Caption)
#endif
#define ORPHAN_BOOT_OPTIONS_POLICY_KEEP 0
#define ORPHAN_BOOT_OPTIONS_POLICY_DELETE 1
#define ORPHAN_BOOT_OPTIONS_POLICY_DISABLE 2
#define ORPHAN_BOOT_OPTIONS_POLICY_HIDE 3
extern EFI_GUID EfiVariableGuid;
extern EFI_GUID AmiBbsDevicePathGuid;
extern EFI_GUID AmiMaskedDevicePathGuid;
extern DEVICE_PATH_TO_DEVICE_MATCH_TEST *DpMatchingFunction[];
extern BOOT_OPTION_TO_DEVICE_MATCH_TEST *MatchingFunction[];
extern FILTER_BOOT_DEVICE_TEST *FilteringFunction[];
extern CONSTRUCT_BOOT_OPTION_NAME *BuildNameFunctions[];
extern BUILD_BOOT_OPTION_FILE_PATH_LIST *BuildFilePathFunctions[];
extern EFI_HII_HANDLE HiiHandle;
extern const STRING_REF UnknownDeviceToken;
extern CONSTRUCT_BOOT_OPTION_NAME *ConstructBootOptionNamePrefix;
extern CONSTRUCT_BOOT_OPTION_NAME *ConstructBootOptionNameSuffix;
extern GET_BBS_ENTRY_DEVICE_TYPE *GetBbsEntryDeviceType;
extern BOOLEAN NormalizeBootOptionName;
extern BOOLEAN NormalizeBootOptionDevicePath;
extern DLIST *BootOptionList;
extern DLIST *BootDeviceList;
#ifdef CSM_SUPPORT
#define LEGACY_DEV_ORDER_GUID \
{ 0xA56074DB, 0x65FE, 0x45F7, 0xBD, 0x21, 0x2D, 0x2B, 0xDD, 0x8E, 0x96, 0x52 }
typedef struct{
UINT32 Type;
UINT16 Length;
UINT16 Device[1];
} LEGACY_DEVICE_ORDER;
extern EFI_GUID LegacyDevOrderGuid;
#endif
//defined in BootOptions.c
VOID SortList(DLIST *List, COMPARE_FUNCTION Compare);
INT32 CompareTagThenPriority(DLINK *Link1, DLINK *Link2);
INT32 ComparePriorityThenBootOptionNumber(DLINK *Link1, DLINK *Link2);
BOOT_OPTION* CreateBootOption(DLIST *BootOptionList);
VOID DeleteBootOption(DLIST *BootOptionList, BOOT_OPTION *Option);
BOOT_DEVICE* CreateBootDevice(
DLIST *BootDeviceList, EFI_HANDLE DeviceHandle,
UINT16 BbsIndex, BBS_TABLE *BbsEntry
);
VOID DeleteBootDevice(DLIST *BootDeviceList, BOOT_DEVICE* Device);
VOID UpdateBootOptionWithBootDeviceInfo(
BOOT_OPTION *Option, BOOT_DEVICE* Device
);
BOOLEAN IsUefiHddBootDevice(BOOT_DEVICE *Device);
BOOLEAN IsGroupOrphan(BOOT_OPTION *Option);
BOOLEAN LocateDevicePathTest(
EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath, BOOT_DEVICE *Device
);
BOOLEAN PartitionDevicePathTest(
EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath, BOOT_DEVICE *Device
);
#ifdef CSM_SUPPORT
BOOLEAN BbsDevicePathTest(
EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath, BOOT_DEVICE *Device
);
BOOLEAN AmiBbsDevicePathTest(
EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath, BOOT_DEVICE *Device
);
#endif
UINTN ConstructBootOptionNameByHandle(
BOOT_OPTION *Option, CHAR16 *Name, UINTN NameSize
);
#ifdef CSM_SUPPORT
UINTN ConstructBootOptionNameByBbsDescription(
BOOT_OPTION *Option, CHAR16 *Name, UINTN NameSize
);
VOID BuildLegacyDevOrderBuffer(
LEGACY_DEVICE_ORDER **DevOrderBuffer, UINTN *BufferSize
);
#endif
UINTN ConstructBootOptionNameByHandleDevicePath(
BOOT_OPTION *Option, CHAR16 *Name, UINTN NameSize
);
UINTN ConstructBootOptionNameByFilePathList(
BOOT_OPTION *Option, CHAR16 *Name, UINTN NameSize
);
UINTN ConstructBootOptionName(BOOT_OPTION *Option);
BOOLEAN BuildLegacyFilePath(BOOT_OPTION *Option);
BOOLEAN BuildEfiFilePath(BOOT_OPTION *Option);
BOOLEAN BuildBootOptionFilePath(BOOT_OPTION *Option);
VOID DumpBootOptionList(DLIST *BootOptionList, CHAR8 *ListCaption);
VOID MaskFilePathList(BOOT_OPTION *Option);
//defined in BdsBoard.c
UINT16 GetLegacyDevOrderType(BOOT_OPTION *Option);
STRING_REF DevicePathNodeToStrRef(EFI_DEVICE_PATH_PROTOCOL *Dp);
VOID ApplyOrphanBootOptionPolicy(
DLIST *BootOptionList, BOOT_OPTION *Option, const int Policy
);
/****** DO NOT WRITE BELOW THIS LINE *******/
#ifdef __cplusplus
}
#endif
#endif
//**********************************************************************
//**********************************************************************
//** **
//** (C)Copyright 1985-2012, American Megatrends, Inc. **
//** **
//** All Rights Reserved. **
//** **
//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
//** **
//** Phone: (770)-246-8600 **
//** **
//**********************************************************************
//**********************************************************************
|