]> code.delx.au - refind/blob - EfiLib/legacy.h
0c6ca06d8ba5e1c00bdea98f12c390da41c3c53d
[refind] / EfiLib / legacy.h
1 /*
2 * EfiLib/legacy.h
3 * CSM/legacy boot support functions
4 *
5 * Taken from Tianocore source code (mostly IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BBSsupport.c)
6 *
7 * Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
8 * This program and the accompanying materials
9 * are licensed and made available under the terms and conditions of the BSD License
10 * which accompanies this distribution. The full text of the license may be found at
11 * http://opensource.org/licenses/bsd-license.php
12 *
13 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 *
16 */
17
18 #ifndef __LEGACY_H_
19 #define __LEGACY_H_
20
21 #define BBS_MEDIA_PRESENT 0x0800
22 #define BBS_MEDIA_MAYBE_PRESENT 0x0400
23
24 typedef UINT8 BBS_TYPE;
25
26 #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
27
28 #pragma pack(1)
29 ///
30 /// For each legacy boot option in BBS table, a corresponding Boot#### variables is created.
31 /// The structure saves the mapping relationship between #### and the index in the BBS table.
32 ///
33 typedef struct {
34 UINT16 BootOptionNumber;
35 UINT16 BbsIndex;
36 UINT16 BbsType;
37 } BOOT_OPTION_BBS_MAPPING;
38 #pragma pack()
39
40 #pragma pack(1)
41 typedef struct {
42 BBS_TYPE BbsType;
43 ///
44 /// Length = sizeof (UINT16) + sizeof (Data)
45 ///
46 UINT16 Length;
47 UINT16 Data[1];
48 } LEGACY_DEV_ORDER_ENTRY;
49 #pragma pack()
50
51 EFI_STATUS
52 EFIAPI
53 BdsAddNonExistingLegacyBootOptions (
54 VOID
55 );
56
57 /**
58 Delete all the invalid legacy boot options.
59
60 @retval EFI_SUCCESS All invalide legacy boot options are deleted.
61 @retval EFI_OUT_OF_RESOURCES Fail to allocate necessary memory.
62 @retval EFI_NOT_FOUND Fail to retrive variable of boot order.
63 **/
64 EFI_STATUS
65 EFIAPI
66 BdsDeleteAllInvalidLegacyBootOptions (
67 VOID
68 );
69
70 BOOLEAN
71 BdsIsLegacyBootOption (
72 IN UINT8 *BootOptionVar,
73 OUT BBS_TABLE **BbsEntry,
74 OUT UINT16 *BbsIndex
75 );
76
77 VOID
78 BdsBuildLegacyDevNameString (
79 IN BBS_TABLE *CurBBSEntry,
80 IN UINTN Index,
81 IN UINTN BufSize,
82 OUT CHAR16 *BootString
83 );
84
85 #endif