1 | /** @file
|
---|
2 | * IPRT - EFI related utilities.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2021 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.alldomusa.eu.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_efi_h
|
---|
27 | #define IPRT_INCLUDED_efi_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <iprt/cdefs.h>
|
---|
33 | #include <iprt/types.h>
|
---|
34 | #include <iprt/time.h>
|
---|
35 | #include <iprt/vfs.h>
|
---|
36 |
|
---|
37 | #include <iprt/formats/efi-common.h>
|
---|
38 |
|
---|
39 |
|
---|
40 | RT_C_DECLS_BEGIN
|
---|
41 |
|
---|
42 | /** @defgroup grp_rt_efi RTEfi - EFI utilities
|
---|
43 | * @ingroup grp_rt
|
---|
44 | * @{
|
---|
45 | */
|
---|
46 |
|
---|
47 |
|
---|
48 | #ifdef IN_RING3
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Converts an EFI time to a time spec (UTC).
|
---|
52 | *
|
---|
53 | * @returns pTimeSpec on success.
|
---|
54 | * @returns NULL if the pEfiTime data is invalid.
|
---|
55 | * @param pTimeSpec Where to store the converted time.
|
---|
56 | * @param pEfiTime Pointer to the EFI time struct.
|
---|
57 | */
|
---|
58 | RTDECL(PRTTIMESPEC) RTEfiTimeToTimeSpec(PRTTIMESPEC pTimeSpec, PCEFI_TIME pEfiTime);
|
---|
59 |
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Converts a time spec (UTC) to an EFI time.
|
---|
63 | *
|
---|
64 | * @returns pEfiTime on success.
|
---|
65 | * @returns NULL if the pTimeSpec data is invalid.
|
---|
66 | * @param pEfiTime Pointer to the EFI time struct.
|
---|
67 | * @param pTimeSpec The time spec to convert.
|
---|
68 | */
|
---|
69 | RTDECL(PEFI_TIME) RTEfiTimeFromTimeSpec(PEFI_TIME pEfiTime, PCRTTIMESPEC pTimeSpec);
|
---|
70 |
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Converts the given EFI GUID to the IPRT UUID representation.
|
---|
74 | *
|
---|
75 | * @returns pUuid.
|
---|
76 | * @param pUuid Where to store the converted GUID.
|
---|
77 | * @param pEfiGuid The EFI GUID to convert.
|
---|
78 | */
|
---|
79 | RTDECL(PRTUUID) RTEfiGuidToUuid(PRTUUID pUuid, PCEFI_GUID pEfiGuid);
|
---|
80 |
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * Converts the given EFI GUID to the IPRT UUID representation.
|
---|
84 | *
|
---|
85 | * @returns pEfiGuid.
|
---|
86 | * @param pEfiGuid Where to store the converted UUID.
|
---|
87 | * @param pUuid The UUID to convert.
|
---|
88 | */
|
---|
89 | RTDECL(PEFI_GUID) RTEfiGuidFromUuid(PEFI_GUID pEfiGuid, PCRTUUID pUuid);
|
---|
90 |
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * Opens an EFI variable store.
|
---|
94 | *
|
---|
95 | * @returns IPRT status code.
|
---|
96 | * @param hVfsFileIn The file or device backing the store.
|
---|
97 | * @param fMntFlags RTVFSMNT_F_XXX.
|
---|
98 | * @param fVarStoreFlags Reserved, MBZ.
|
---|
99 | * @param phVfs Where to return the virtual file system handle.
|
---|
100 | * @param pErrInfo Where to return additional error information.
|
---|
101 | */
|
---|
102 | RTDECL(int) RTEfiVarStoreOpenAsVfs(RTVFSFILE hVfsFileIn, uint32_t fMntFlags, uint32_t fVarStoreFlags, PRTVFS phVfs, PRTERRINFO pErrInfo);
|
---|
103 |
|
---|
104 |
|
---|
105 | /** @name RTEFIVARSTORE_CREATE_F_XXX - RTEfiVarStoreCreate flags
|
---|
106 | * @{ */
|
---|
107 | /** Use default options. */
|
---|
108 | #define RTEFIVARSTORE_CREATE_F_DEFAULT UINT32_C(0)
|
---|
109 | /** Don't create a fault tolerant write working space.
|
---|
110 | * The default is to create one reducing the size of the variable store. */
|
---|
111 | #define RTEFIVARSTORE_CREATE_F_NO_FTW_WORKING_SPACE RT_BIT_32(0)
|
---|
112 | /** Mask containing all valid flags. */
|
---|
113 | #define RTEFIVARSTORE_CREATE_F_VALID_MASK UINT32_C(0x00000001)
|
---|
114 | /** @} */
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * Creates a new EFI variable store.
|
---|
118 | *
|
---|
119 | * @returns IRPT status code.
|
---|
120 | * @param hVfsFile The store file.
|
---|
121 | * @param offStore The offset into @a hVfsFile of the file.
|
---|
122 | * Typically 0.
|
---|
123 | * @param cbStore The size of the variable store. Pass 0 if the rest of
|
---|
124 | * hVfsFile should be used. The remaining space for variables
|
---|
125 | * will be less because of some metadata overhead.
|
---|
126 | * @param fFlags See RTEFIVARSTORE_F_XXX.
|
---|
127 | * @param cbBlock The logical block size.
|
---|
128 | * @param pErrInfo Additional error information, maybe. Optional.
|
---|
129 | */
|
---|
130 | RTDECL(int) RTEfiVarStoreCreate(RTVFSFILE hVfsFile, uint64_t offStore, uint64_t cbStore, uint32_t fFlags, uint32_t cbBlock,
|
---|
131 | PRTERRINFO pErrInfo);
|
---|
132 |
|
---|
133 | #endif /* IN_RING3 */
|
---|
134 |
|
---|
135 | /** @} */
|
---|
136 |
|
---|
137 | RT_C_DECLS_END
|
---|
138 |
|
---|
139 | #endif /* !IPRT_INCLUDED_efi_h */
|
---|
140 |
|
---|