Skip to content

[libc] Add UEFI headers #127126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,19 @@ add_header_macro(
.llvm-libc-macros.poll-macros
)

# UEFI spec references "Uefi.h" so we use that name for compatibility
add_header_macro(
uefi
../libc/include/Uefi.yaml
Uefi.h.def
Uefi.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.EFI_GUID
.llvm-libc-types.EFI_STATUS
.llvm-libc-types.EFI_SYSTEM_TABLE
)

if(NOT LLVM_LIBC_FULL_BUILD)
# We don't install headers in non-fullbuild mode.
return()
Expand Down
16 changes: 16 additions & 0 deletions libc/include/Uefi.h.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===-- UEFI header uefi.h --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_UEFI_H
#define LLVM_LIBC_UEFI_H

#include "__llvm-libc-common.h"

%%public_api()

#endif // LLVM_LIBC_UEFI_H
15 changes: 15 additions & 0 deletions libc/include/Uefi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
header: Uefi.h
standards: UEFI
macros: []
types:
- type_name: EFI_BOOT_SERVICES
- type_name: EFI_GUID
- type_name: EFI_STATUS
- type_name: EFI_SYSTEM_TABLE
enums: []
functions: []
objects:
- object_name: efi_system_table
object_type: EFI_SYSTEM_TABLE *
- object_name: efi_image_handle
object_type: EFI_HANDLE
6 changes: 6 additions & 0 deletions libc/include/llvm-libc-macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,9 @@ add_macro_header(
HDR
poll-macros.h
)

add_macro_header(
EFIAPI_macros
HDR
EFIAPI-macros.h
)
18 changes: 18 additions & 0 deletions libc/include/llvm-libc-macros/EFIAPI-macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//===-- Definition of EFIAPI macro ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===------------------------------------------------------------------===//

#ifndef LLVM_LIBC_MACROS_EFIAPI_MACROS_H
#define LLVM_LIBC_MACROS_EFIAPI_MACROS_H

#if defined(__x86_64__) && !defined(__ILP32__)
#define EFIAPI __attribute__((ms_abi))
#else
#define EFIAPI
#endif

#endif // LLVM_LIBC_MACROS_EFIAPI_MACROS_H
124 changes: 124 additions & 0 deletions libc/include/llvm-libc-types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,127 @@ DEPENDS
add_header(locale_t HDR locale_t.h)
add_header(struct_lconv HDR struct_lconv.h)
add_header(stdfix-types HDR stdfix-types.h)

# UEFI
add_header(EFI_GUID HDR EFI_GUID.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
add_header(EFI_CONFIGURATION_TABLE HDR EFI_CONFIGURATION_TABLE.h DEPENDS .EFI_GUID)

add_header(EFI_PHYSICAL_ADDRESS HDR EFI_PHYSICAL_ADDRESS.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
add_header(EFI_VIRTUAL_ADDRESS HDR EFI_VIRTUAL_ADDRESS.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)

add_header(EFI_MEMORY_DESCRIPTOR
HDR
EFI_MEMORY_DESCRIPTOR.h
DEPENDS
libc.include.llvm-libc-macros.stdint_macros
.EFI_PHYSICAL_ADDRESS
.EFI_VIRTUAL_ADDRESS
)

add_header(EFI_ALLOCATE_TYPE HDR EFI_ALLOCATE_TYPE.h)
add_header(EFI_EVENT HDR EFI_EVENT.h)
add_header(EFI_INTERFACE_TYPE HDR EFI_INTERFACE_TYPE.h)
add_header(EFI_LOCATE_SEARCH_TYPE HDR EFI_LOCATE_SEARCH_TYPE.h)
add_header(EFI_MEMORY_TYPE HDR EFI_MEMORY_TYPE.h)
add_header(EFI_HANDLE HDR EFI_HANDLE.h)
add_header(EFI_TIME HDR EFI_TIME.h DEPENDS libc.include.llvm-libc-macros.stdint_macros)
add_header(EFI_TIMER_DELAY HDR EFI_TIMER_DELAY.h)
add_header(EFI_TPL HDR EFI_TPL.h DEPENDS .size_t)
add_header(EFI_STATUS HDR EFI_STATUS.h DEPENDS .size_t)

add_header(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
HDR
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY.h
DEPENDS
libc.include.llvm-libc-macros.stdint_macros
.EFI_HANDLE
)

add_header(EFI_CAPSULE
HDR
EFI_CAPSULE.h
DEPENDS
libc.include.llvm-libc-macros.stdint_macros
.EFI_GUID
)

add_header(EFI_TABLE_HEADER
HDR
EFI_TABLE_HEADER.h
DEPENDS
libc.include.llvm-libc-macros.stdint_macros
)

add_header(EFI_DEVICE_PATH_PROTOCOL
HDR
EFI_DEVICE_PATH_PROTOCOL.h
DEPENDS
libc.include.llvm-libc-macros.stdint_macros
)

add_header(EFI_SIMPLE_TEXT_INPUT_PROTOCOL
HDR
EFI_SIMPLE_TEXT_INPUT_PROTOCOL.h
DEPENDS
libc.include.llvm-libc-macros.EFIAPI_macros
libc.include.llvm-libc-macros.stdint_macros
.EFI_EVENT
.EFI_STATUS
.char16_t
)

add_header(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
HDR
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.h
DEPENDS
libc.include.llvm-libc-macros.stdint_macros
.EFI_STATUS
.size_t
)

add_header(EFI_BOOT_SERVICES
HDR
EFI_BOOT_SERVICES.h
DEPENDS
libc.include.llvm-libc-macros.EFIAPI_macros
.EFI_ALLOCATE_TYPE
.EFI_DEVICE_PATH_PROTOCOL
.EFI_EVENT
.EFI_INTERFACE_TYPE
.EFI_LOCATE_SEARCH_TYPE
.EFI_MEMORY_DESCRIPTOR
.EFI_MEMORY_TYPE
.EFI_OPEN_PROTOCOL_INFORMATION_ENTRY
.EFI_PHYSICAL_ADDRESS
.EFI_STATUS
.EFI_TABLE_HEADER
.EFI_TIMER_DELAY
.EFI_TPL
.char16_t
)

add_header(EFI_RUNTIME_SERVICES
HDR
EFI_RUNTIME_SERVICES.h
DEPENDS
.EFI_CAPSULE
.EFI_STATUS
.EFI_TABLE_HEADER
.EFI_TIME
.char16_t
)

add_header(EFI_SYSTEM_TABLE
HDR
EFI_SYSTEM_TABLE.h
DEPENDS
.EFI_BOOT_SERVICES
.EFI_CONFIGURATION_TABLE
.EFI_HANDLE
.EFI_RUNTIME_SERVICES
.EFI_SIMPLE_TEXT_INPUT_PROTOCOL
.EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
.EFI_STATUS
.EFI_TABLE_HEADER
.char16_t
)
19 changes: 19 additions & 0 deletions libc/include/llvm-libc-types/EFI_ALLOCATE_TYPE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Definition of EFI_ALLOCATE_TYPE type ------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_TYPES_EFI_ALLOCATE_TYPE_H
#define LLVM_LIBC_TYPES_EFI_ALLOCATE_TYPE_H

typedef enum {
AllocateAnyPages,
AllocateMaxAddress,
AllocateAddress,
MaxAllocateType
} EFI_ALLOCATE_TYPE;

#endif // LLVM_LIBC_TYPES_EFI_ALLOCATE_TYPE_H
Loading