Skip to content

Commit 9b6d0d7

Browse files
[libc] Add UEFI headers (#127126)
Originated from #120687 This PR simply adds the necessary headers for UEFI which defines all the necessary types. This PR unlocks the ability to work on other PR's for UEFI support.
1 parent 43eb18e commit 9b6d0d7

30 files changed

+1167
-0
lines changed

libc/include/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,19 @@ add_header_macro(
724724
.llvm-libc-macros.poll-macros
725725
)
726726

727+
# UEFI spec references "Uefi.h" so we use that name for compatibility
728+
add_header_macro(
729+
uefi
730+
../libc/include/Uefi.yaml
731+
Uefi.h.def
732+
Uefi.h
733+
DEPENDS
734+
.llvm_libc_common_h
735+
.llvm-libc-types.EFI_GUID
736+
.llvm-libc-types.EFI_STATUS
737+
.llvm-libc-types.EFI_SYSTEM_TABLE
738+
)
739+
727740
if(NOT LLVM_LIBC_FULL_BUILD)
728741
# We don't install headers in non-fullbuild mode.
729742
return()

libc/include/Uefi.h.def

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//===-- UEFI header uefi.h --------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_UEFI_H
10+
#define LLVM_LIBC_UEFI_H
11+
12+
#include "__llvm-libc-common.h"
13+
14+
%%public_api()
15+
16+
#endif // LLVM_LIBC_UEFI_H

libc/include/Uefi.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
header: Uefi.h
2+
standards: UEFI
3+
macros: []
4+
types:
5+
- type_name: EFI_BOOT_SERVICES
6+
- type_name: EFI_GUID
7+
- type_name: EFI_STATUS
8+
- type_name: EFI_SYSTEM_TABLE
9+
enums: []
10+
functions: []
11+
objects:
12+
- object_name: efi_system_table
13+
object_type: EFI_SYSTEM_TABLE *
14+
- object_name: efi_image_handle
15+
object_type: EFI_HANDLE

libc/include/llvm-libc-macros/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,9 @@ add_macro_header(
337337
HDR
338338
poll-macros.h
339339
)
340+
341+
add_macro_header(
342+
EFIAPI_macros
343+
HDR
344+
EFIAPI-macros.h
345+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===-- Definition of EFIAPI macro ------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_MACROS_EFIAPI_MACROS_H
10+
#define LLVM_LIBC_MACROS_EFIAPI_MACROS_H
11+
12+
#if defined(__x86_64__) && !defined(__ILP32__)
13+
#define EFIAPI __attribute__((ms_abi))
14+
#else
15+
#define EFIAPI
16+
#endif
17+
18+
#endif // LLVM_LIBC_MACROS_EFIAPI_MACROS_H

libc/include/llvm-libc-types/CMakeLists.txt

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,127 @@ DEPENDS
157157
add_header(locale_t HDR locale_t.h)
158158
add_header(struct_lconv HDR struct_lconv.h)
159159
add_header(stdfix-types HDR stdfix-types.h)
160+
161+
# UEFI
162+
add_header(EFI_GUID HDR EFI_GUID.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
163+
add_header(EFI_CONFIGURATION_TABLE HDR EFI_CONFIGURATION_TABLE.h DEPENDS .EFI_GUID)
164+
165+
add_header(EFI_PHYSICAL_ADDRESS HDR EFI_PHYSICAL_ADDRESS.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
166+
add_header(EFI_VIRTUAL_ADDRESS HDR EFI_VIRTUAL_ADDRESS.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
167+
168+
add_header(EFI_MEMORY_DESCRIPTOR
169+
HDR
170+
EFI_MEMORY_DESCRIPTOR.h
171+
DEPENDS
172+
libc.include.llvm-libc-macros.stdint_macros
173+
.EFI_PHYSICAL_ADDRESS
174+
.EFI_VIRTUAL_ADDRESS
175+
)
176+
177+
add_header(EFI_ALLOCATE_TYPE HDR EFI_ALLOCATE_TYPE.h)
178+
add_header(EFI_EVENT HDR EFI_EVENT.h)
179+
add_header(EFI_INTERFACE_TYPE HDR EFI_INTERFACE_TYPE.h)
180+
add_header(EFI_LOCATE_SEARCH_TYPE HDR EFI_LOCATE_SEARCH_TYPE.h)
181+
add_header(EFI_MEMORY_TYPE HDR EFI_MEMORY_TYPE.h)
182+
add_header(EFI_HANDLE HDR EFI_HANDLE.h)
183+
add_header(EFI_TIME HDR EFI_TIME.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
184+
add_header(EFI_TIMER_DELAY HDR EFI_TIMER_DELAY.h)
185+
add_header(EFI_TPL HDR EFI_TPL.h DEPENDS .size_t)
186+
add_header(EFI_STATUS HDR EFI_STATUS.h DEPENDS .size_t)
187+
188+
add_header(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
189+
HDR
190+
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY.h
191+
DEPENDS
192+
libc.include.llvm-libc-macros.stdint_macros
193+
.EFI_HANDLE
194+
)
195+
196+
add_header(EFI_CAPSULE
197+
HDR
198+
EFI_CAPSULE.h
199+
DEPENDS
200+
libc.include.llvm-libc-macros.stdint_macros
201+
.EFI_GUID
202+
)
203+
204+
add_header(EFI_TABLE_HEADER
205+
HDR
206+
EFI_TABLE_HEADER.h
207+
DEPENDS
208+
libc.include.llvm-libc-macros.stdint_macros
209+
)
210+
211+
add_header(EFI_DEVICE_PATH_PROTOCOL
212+
HDR
213+
EFI_DEVICE_PATH_PROTOCOL.h
214+
DEPENDS
215+
libc.include.llvm-libc-macros.stdint_macros
216+
)
217+
218+
add_header(EFI_SIMPLE_TEXT_INPUT_PROTOCOL
219+
HDR
220+
EFI_SIMPLE_TEXT_INPUT_PROTOCOL.h
221+
DEPENDS
222+
libc.include.llvm-libc-macros.EFIAPI_macros
223+
libc.include.llvm-libc-macros.stdint_macros
224+
.EFI_EVENT
225+
.EFI_STATUS
226+
.char16_t
227+
)
228+
229+
add_header(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
230+
HDR
231+
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.h
232+
DEPENDS
233+
libc.include.llvm-libc-macros.stdint_macros
234+
.EFI_STATUS
235+
.size_t
236+
)
237+
238+
add_header(EFI_BOOT_SERVICES
239+
HDR
240+
EFI_BOOT_SERVICES.h
241+
DEPENDS
242+
libc.include.llvm-libc-macros.EFIAPI_macros
243+
.EFI_ALLOCATE_TYPE
244+
.EFI_DEVICE_PATH_PROTOCOL
245+
.EFI_EVENT
246+
.EFI_INTERFACE_TYPE
247+
.EFI_LOCATE_SEARCH_TYPE
248+
.EFI_MEMORY_DESCRIPTOR
249+
.EFI_MEMORY_TYPE
250+
.EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
251+
.EFI_PHYSICAL_ADDRESS
252+
.EFI_STATUS
253+
.EFI_TABLE_HEADER
254+
.EFI_TIMER_DELAY
255+
.EFI_TPL
256+
.char16_t
257+
)
258+
259+
add_header(EFI_RUNTIME_SERVICES
260+
HDR
261+
EFI_RUNTIME_SERVICES.h
262+
DEPENDS
263+
.EFI_CAPSULE
264+
.EFI_STATUS
265+
.EFI_TABLE_HEADER
266+
.EFI_TIME
267+
.char16_t
268+
)
269+
270+
add_header(EFI_SYSTEM_TABLE
271+
HDR
272+
EFI_SYSTEM_TABLE.h
273+
DEPENDS
274+
.EFI_BOOT_SERVICES
275+
.EFI_CONFIGURATION_TABLE
276+
.EFI_HANDLE
277+
.EFI_RUNTIME_SERVICES
278+
.EFI_SIMPLE_TEXT_INPUT_PROTOCOL
279+
.EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
280+
.EFI_STATUS
281+
.EFI_TABLE_HEADER
282+
.char16_t
283+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===-- Definition of EFI_ALLOCATE_TYPE type ------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_TYPES_EFI_ALLOCATE_TYPE_H
10+
#define LLVM_LIBC_TYPES_EFI_ALLOCATE_TYPE_H
11+
12+
typedef enum {
13+
AllocateAnyPages,
14+
AllocateMaxAddress,
15+
AllocateAddress,
16+
MaxAllocateType
17+
} EFI_ALLOCATE_TYPE;
18+
19+
#endif // LLVM_LIBC_TYPES_EFI_ALLOCATE_TYPE_H

0 commit comments

Comments
 (0)