[lib][uefi] Update protocol headers from upstream
Copied from https://cs.android.com/android/kernel/superproject/+/common-android-mainline:bootable/libbootloader/gbl/libefi_types/defs/protocols/
This commit is contained in:
committed by
Kelvin Zhang
parent
5c1bc61e11
commit
72c92b5d81
4
lib/uefi/.clang-format
Normal file
4
lib/uefi/.clang-format
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 2
|
||||
@@ -23,12 +23,18 @@
|
||||
#include <uefi/types.h>
|
||||
|
||||
#include "io_stack.h"
|
||||
#include "memory_protocols.h"
|
||||
#include "switch_stack.h"
|
||||
#include "uefi_platform.h"
|
||||
|
||||
namespace {
|
||||
|
||||
struct EfiBlockIoInterface {
|
||||
EfiBlockIoProtocol protocol;
|
||||
void *dev;
|
||||
EfiBlockIoMedia media;
|
||||
void *io_stack;
|
||||
};
|
||||
|
||||
EfiStatus read_blocks(EfiBlockIoProtocol *self, uint32_t media_id, uint64_t lba,
|
||||
size_t buffer_size, void *buffer) {
|
||||
auto interface = reinterpret_cast<EfiBlockIoInterface *>(self);
|
||||
|
||||
@@ -162,13 +162,6 @@ void restore_tpl(EfiTpl old_tpl) {
|
||||
printf("%s is called %zu\n", __FUNCTION__, old_tpl);
|
||||
}
|
||||
|
||||
EfiStatus get_verify_partitions(struct GblEfiImageLoadingProtocol *self,
|
||||
size_t *NumberOfPartitions,
|
||||
GblEfiPartitionName *Partitions) {
|
||||
printf("%s is called\n", __FUNCTION__);
|
||||
return EFI_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
EfiStatus open_protocol(EfiHandle handle, const EfiGuid *protocol, void **intf,
|
||||
EfiHandle agent_handle, EfiHandle controller_handle,
|
||||
EfiOpenProtocolAttributes attr) {
|
||||
@@ -243,7 +236,6 @@ EfiStatus open_protocol(EfiHandle handle, const EfiGuid *protocol, void **intf,
|
||||
}
|
||||
image_loading->revision = GBL_EFI_IMAGE_LOADING_PROTOCOL_REVISION;
|
||||
image_loading->get_buffer = get_buffer;
|
||||
image_loading->get_verify_partitions = get_verify_partitions;
|
||||
*intf = reinterpret_cast<void *>(image_loading);
|
||||
return EFI_STATUS_SUCCESS;
|
||||
} else if (guid_eq(protocol, EFI_TIMESTAMP_PROTOCOL_GUID)) {
|
||||
@@ -361,6 +353,7 @@ EfiStatus stall(size_t microseconds) {
|
||||
}
|
||||
|
||||
EfiStatus free_pages(EfiPhysicalAddr memory, size_t pages) {
|
||||
// NOLINTNEXTLINE(performance-no-int-to-ptr)
|
||||
return ::free_pages(reinterpret_cast<void *>(memory), pages);
|
||||
}
|
||||
|
||||
|
||||
@@ -161,8 +161,6 @@ struct EFI_LOADED_IMAGE_PROTOCOL {
|
||||
EFI_IMAGE_UNLOAD Unload;
|
||||
};
|
||||
|
||||
static constexpr size_t EFI_LOADED_IMAGE_PROTOCOL_REVISION = 0x1000;
|
||||
|
||||
// This function would be called from GBL before jumping into android kernel
|
||||
// LK provides a default no-op implementation that is weakly linked,
|
||||
// different platforms can override with their own implementation.
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
|
||||
#include "debug_support.h"
|
||||
|
||||
#include <lib/cksum.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <lib/cksum.h>
|
||||
#include <uefi/boot_service.h>
|
||||
#include <uefi/protocols/loaded_image_protocol.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
#include "boot_service_provider.h"
|
||||
#include "memory_protocols.h"
|
||||
#include "uefi_platform.h"
|
||||
|
||||
struct EFI_DEVICE_PATH_FILE_PATH_PROTOCOL {
|
||||
|
||||
@@ -13,14 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#ifndef __BLOCK_IO2_PROTOCOL_H__
|
||||
#define __BLOCK_IO2_PROTOCOL_H__
|
||||
|
||||
#include <uefi/types.h>
|
||||
|
||||
#include "block_io_protocol.h"
|
||||
#include "types.h"
|
||||
|
||||
typedef struct EfiBlockIoMedia EfiBlockIoMedia;
|
||||
typedef struct EfiBlockIo2Protocol EfiBlockIo2Protocol;
|
||||
@@ -43,4 +50,4 @@ struct EfiBlockIo2Protocol {
|
||||
EfiBlockIo2Token* token);
|
||||
};
|
||||
|
||||
#endif //__BLOCK_IO2_PROTOCOL_H__
|
||||
#endif //__BLOCK_IO2_PROTOCOL_H__
|
||||
|
||||
@@ -13,16 +13,28 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#include <uefi/types.h>
|
||||
|
||||
#ifndef __BLOCK_IO_PROTOCOL_H__
|
||||
#define __BLOCK_IO_PROTOCOL_H__
|
||||
|
||||
#include "gbl_protocol_utils.h"
|
||||
#include "types.h"
|
||||
|
||||
typedef struct EfiBlockIoMedia EfiBlockIoMedia;
|
||||
typedef struct EfiBlockIoProtocol EfiBlockIoProtocol;
|
||||
|
||||
static const uint64_t EFI_BLOCK_IO_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(2, 31);
|
||||
|
||||
struct EfiBlockIoProtocol {
|
||||
uint64_t revision;
|
||||
EfiBlockIoMedia *media;
|
||||
@@ -30,8 +42,7 @@ struct EfiBlockIoProtocol {
|
||||
EfiStatus (*read_blocks)(EfiBlockIoProtocol *self, uint32_t media_id,
|
||||
uint64_t lba, size_t buffer_size, void *buffer);
|
||||
EfiStatus (*write_blocks)(EfiBlockIoProtocol *self, uint32_t media_id,
|
||||
uint64_t lba, size_t buffer_size,
|
||||
const void *buffer);
|
||||
uint64_t lba, size_t buffer_size, const void *buffer);
|
||||
EfiStatus (*flush_blocks)(EfiBlockIoProtocol *self);
|
||||
};
|
||||
|
||||
@@ -55,11 +66,4 @@ struct EfiBlockIoMedia {
|
||||
uint32_t optimal_transfer_length_granularity;
|
||||
};
|
||||
|
||||
struct EfiBlockIoInterface {
|
||||
EfiBlockIoProtocol protocol;
|
||||
void *dev;
|
||||
EfiBlockIoMedia media;
|
||||
void *io_stack;
|
||||
};
|
||||
|
||||
#endif //__BLOCK_IO_PROTOCOL_H__
|
||||
|
||||
@@ -48,7 +48,8 @@ static const uint8_t EFI_DEVICE_PATH_TYPE_END_OF_HARDWARE_DEVICE_PATH = 0x7F;
|
||||
|
||||
static const uint8_t EFI_DEVICE_PATH_TYPE_MEDIA_DEVICE_PATH = 0x04;
|
||||
|
||||
static const uint8_t EFI_END_OF_HARDWARE_DEVICE_PATH_SUB_TYPE_END_ENTIRE_DEVICE_PATH = 0xFF;
|
||||
static const uint8_t
|
||||
EFI_END_OF_HARDWARE_DEVICE_PATH_SUB_TYPE_END_ENTIRE_DEVICE_PATH = 0xFF;
|
||||
|
||||
static const uint8_t EFI_MEDIA_DEVICE_PATH_SUB_TYPE_VENDOR = 0x03;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
* Copyright (C) 2024-2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,28 +13,35 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
// This is a protocol proposed by U-boot and being used by Kernel UEFI stub.
|
||||
// This is a protocol proposed by Heinrich Schuchardt and already being used by
|
||||
// the Kernel UEFI stub.
|
||||
// https://github.com/U-Boot-EFI/EFI_DT_FIXUP_PROTOCOL
|
||||
// https://github.com/u-boot/u-boot/blob/master/include/efi_dt_fixup.h
|
||||
|
||||
#ifndef __EFI_DT_FIXUP_PROTOCOL_H__
|
||||
#define __EFI_DT_FIXUP_PROTOCOL_H__
|
||||
|
||||
#include <uefi/types.h>
|
||||
#include "gbl_protocol_utils.h"
|
||||
#include "types.h"
|
||||
|
||||
constexpr uint64_t EFI_DT_FIXUP_PROTOCOL_REVISION = 0x00010000;
|
||||
static const uint64_t EFI_DT_FIXUP_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(1, 0);
|
||||
|
||||
// Add nodes and update properties
|
||||
constexpr uint32_t EFI_DT_APPLY_FIXUPS = 0x00000001;
|
||||
static const uint32_t EFI_DT_APPLY_FIXUPS = 0x00000001;
|
||||
// Reserve memory according to the /reserved-memory node and the memory
|
||||
// reservation block
|
||||
constexpr uint32_t EFI_DT_RESERVE_MEMORY = 0x00000002;
|
||||
// Install the device-tree as configuration table
|
||||
constexpr uint32_t EFI_DT_INSTALL_TABLE = 0x00000004;
|
||||
constexpr uint32_t EFI_DT_ALL =
|
||||
EFI_DT_APPLY_FIXUPS | EFI_DT_RESERVE_MEMORY | EFI_DT_INSTALL_TABLE;
|
||||
static const uint32_t EFI_DT_RESERVE_MEMORY = 0x00000002;
|
||||
static const uint32_t EFI_DT_ALL = EFI_DT_APPLY_FIXUPS | EFI_DT_RESERVE_MEMORY;
|
||||
|
||||
typedef struct EfiDtFixupProtocol {
|
||||
uint64_t revision;
|
||||
|
||||
@@ -26,9 +26,11 @@
|
||||
#ifndef __ERASE_BLOCK_PROTOCOL_H__
|
||||
#define __ERASE_BLOCK_PROTOCOL_H__
|
||||
|
||||
#include "gbl_protocol_utils.h"
|
||||
#include "types.h"
|
||||
|
||||
static const uint64_t EFI_ERASE_BLOCK_PROTOCOL_REVISION = ((2<<16) | (60));
|
||||
static const uint64_t EFI_ERASE_BLOCK_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(2, 60);
|
||||
|
||||
typedef struct EfiEraseBlockProtocol EfiEraseBlockProtocol;
|
||||
|
||||
|
||||
@@ -81,9 +81,7 @@ typedef struct GblEfiABSlotProtocol {
|
||||
/* out */ GblEfiSlotInfo* info);
|
||||
EfiStatus (*get_current_slot)(struct GblEfiABSlotProtocol* self,
|
||||
/* out */ GblEfiSlotInfo* info);
|
||||
EfiStatus (*get_next_slot)(struct GblEfiABSlotProtocol* self,
|
||||
/* in */ bool mark_boot_attempt,
|
||||
/* out */ GblEfiSlotInfo* info);
|
||||
void *_reserved;
|
||||
// Slot metadata manipulation methods
|
||||
EfiStatus (*set_active_slot)(struct GblEfiABSlotProtocol* self,
|
||||
/* in */ uint8_t index);
|
||||
|
||||
143
lib/uefi/include/uefi/protocols/gbl_efi_avb_protocol.h
Normal file
143
lib/uefi/include/uefi/protocols/gbl_efi_avb_protocol.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2024 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
// This is a custom protocol introduced by GBL.
|
||||
// See gbl/docs/gbl_efi_avb_protocol.md for details.
|
||||
|
||||
#ifndef __GBL_AVB_PROTOCOL_H__
|
||||
#define __GBL_AVB_PROTOCOL_H__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
static const uint64_t GBL_EFI_AVB_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(0, 3);
|
||||
|
||||
typedef uint64_t GblEfiAvbDeviceStatus;
|
||||
// Indicates device is unlocked.
|
||||
static const GblEfiAvbDeviceStatus GBL_EFI_AVB_DEVICE_STATUS_UNLOCKED = 0x1
|
||||
<< 0;
|
||||
// Indecated dm-verity error is occurred.
|
||||
static const GblEfiAvbDeviceStatus GBL_EFI_AVB_DEVICE_STATUS_DM_VERITY_FAILED =
|
||||
0x1 << 1;
|
||||
|
||||
// Os boot state color flags.
|
||||
//
|
||||
// https://source.android.com/docs/security/features/verifiedboot/boot-flow#communicating-verified-boot-state-to-users
|
||||
typedef uint64_t GblEfiAvbBootColor;
|
||||
static const GblEfiAvbBootColor GBL_EFI_AVB_BOOT_COLOR_RED = 0x1 << 0;
|
||||
static const GblEfiAvbBootColor GBL_EFI_AVB_BOOT_COLOR_ORANGE = 0x1 << 1;
|
||||
static const GblEfiAvbBootColor GBL_EFI_AVB_BOOT_COLOR_YELLOW = 0x1 << 2;
|
||||
static const GblEfiAvbBootColor GBL_EFI_AVB_BOOT_COLOR_GREEN = 0x1 << 3;
|
||||
static const GblEfiAvbBootColor GBL_EFI_AVB_BOOT_COLOR_RED_EIO = 0x1 << 4;
|
||||
|
||||
// Vbmeta key validation status.
|
||||
//
|
||||
// https://source.android.com/docs/security/features/verifiedboot/boot-flow#locked-devices-with-custom-root-of-trust
|
||||
EFI_ENUM(GBL_EFI_AVB_KEY_VALIDATION_STATUS, GblEfiAvbKeyValidationStatus,
|
||||
uint32_t, GBL_EFI_AVB_KEY_VALIDATION_STATUS_INVALID,
|
||||
GBL_EFI_AVB_KEY_VALIDATION_STATUS_VALID_CUSTOM_KEY,
|
||||
GBL_EFI_AVB_KEY_VALIDATION_STATUS_VALID);
|
||||
|
||||
typedef struct {
|
||||
// On input - `base_name` buffer size
|
||||
// On output - actual `base_name` length
|
||||
size_t base_name_len;
|
||||
uint8_t *base_name;
|
||||
} GblEfiAvbPartition;
|
||||
|
||||
typedef struct {
|
||||
// UTF-8, null terminated
|
||||
const uint8_t *base_name;
|
||||
size_t data_size;
|
||||
const uint8_t *data;
|
||||
} GblEfiAvbLoadedPartition;
|
||||
|
||||
typedef struct {
|
||||
// UTF-8, null terminated
|
||||
const uint8_t *base_partition_name;
|
||||
// UTF-8, null terminated
|
||||
const uint8_t *key;
|
||||
// Excluding null terminator
|
||||
size_t value_size;
|
||||
const uint8_t *value;
|
||||
} GblEfiAvbProperty;
|
||||
|
||||
typedef struct {
|
||||
GblEfiAvbBootColor color_flags;
|
||||
// Pointer to nul-terminated ASCII hex digest calculated by libavb. May be
|
||||
// null in case of verification failed (RED boot state color).
|
||||
const uint8_t *digest;
|
||||
size_t num_loaded_partitions;
|
||||
const GblEfiAvbLoadedPartition *loaded_partitions;
|
||||
size_t num_properties;
|
||||
const GblEfiAvbProperty *properties;
|
||||
uint64_t reserved[8];
|
||||
} GblEfiAvbVerificationResult;
|
||||
|
||||
typedef struct GblEfiAvbProtocol {
|
||||
uint64_t revision;
|
||||
|
||||
EfiStatus (*read_partitions_to_verify)(
|
||||
struct GblEfiAvbProtocol *self,
|
||||
/* in-out */ size_t *num_partitions,
|
||||
/* in-out */ GblEfiAvbPartition *partitions);
|
||||
|
||||
EfiStatus (*read_device_status)(
|
||||
struct GblEfiAvbProtocol *self,
|
||||
/* out */ GblEfiAvbDeviceStatus *status_flags);
|
||||
|
||||
EfiStatus (*validate_vbmeta_public_key)(
|
||||
struct GblEfiAvbProtocol *self,
|
||||
/* in */ size_t public_key_length,
|
||||
/* in */ const uint8_t *public_key_data,
|
||||
/* in */ size_t public_key_metadata_length,
|
||||
/* in */ const uint8_t *public_key_metadata,
|
||||
/* out */ GblEfiAvbKeyValidationStatus *validation_status);
|
||||
|
||||
EfiStatus (*read_rollback_index)(struct GblEfiAvbProtocol *self,
|
||||
/* in */ size_t index_location,
|
||||
/* out */ uint64_t *rollback_index);
|
||||
|
||||
EfiStatus (*write_rollback_index)(struct GblEfiAvbProtocol *self,
|
||||
/* in */ size_t index_location,
|
||||
/* in */ uint64_t rollback_index);
|
||||
|
||||
EfiStatus (*read_persistent_value)(struct GblEfiAvbProtocol *self,
|
||||
/* in */ const uint8_t *name,
|
||||
/* in-out */ size_t *value_size,
|
||||
/* out */ uint8_t *value);
|
||||
|
||||
EfiStatus (*write_persistent_value)(struct GblEfiAvbProtocol *self,
|
||||
/* in */ const uint8_t *name,
|
||||
/* in */ size_t value_size,
|
||||
/* in */ const uint8_t *value);
|
||||
|
||||
EfiStatus (*handle_verification_result)(
|
||||
struct GblEfiAvbProtocol *self,
|
||||
/* in */ const GblEfiAvbVerificationResult *result);
|
||||
|
||||
} GblEfiAvbProtocol;
|
||||
|
||||
#endif //__GBL_AVB_PROTOCOL_H__
|
||||
51
lib/uefi/include/uefi/protocols/gbl_efi_avf_protocol.h
Normal file
51
lib/uefi/include/uefi/protocols/gbl_efi_avf_protocol.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
// This is a custom protocol introduced by GBL.
|
||||
// See gbl/docs/gbl_efi_avf_protocol.md for details.
|
||||
|
||||
#ifndef __GBL_AVF_PROTOCOL_H__
|
||||
#define __GBL_AVF_PROTOCOL_H__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
static const uint64_t GBL_EFI_AVF_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(0, 1);
|
||||
|
||||
typedef struct GblEfiAvfProtocol {
|
||||
uint64_t revision;
|
||||
|
||||
EfiStatus (*read_vendor_dice_handover)(struct GblEfiAvfProtocol *self,
|
||||
/* in-out */ size_t *handover_size,
|
||||
/* out */ uint8_t *handover);
|
||||
|
||||
EfiStatus (*read_secretkeeper_public_key)(
|
||||
struct GblEfiAvfProtocol *self,
|
||||
/* in-out */ size_t *public_key_size,
|
||||
/* out */ uint8_t *public_key);
|
||||
|
||||
} GblEfiAvfProtocol;
|
||||
|
||||
#endif //__GBL_AVF_PROTOCOL_H__
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#ifndef __GBL_EFI_BOOT_MEMORY_PROTOCOL_H__
|
||||
#define __GBL_EFI_BOOT_MEMORY_PROTOCOL_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
static const uint64_t GBL_EFI_BOOT_MEMORY_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(0, 1);
|
||||
|
||||
EFI_ENUM(GBL_EFI_BOOT_BUFFER_TYPE, GblEfiBootBufferType, uint32_t,
|
||||
GBL_EFI_BOOT_BUFFER_TYPE_GENERAL_LOAD, GBL_EFI_BOOT_BUFFER_TYPE_KERNEL,
|
||||
GBL_EFI_BOOT_BUFFER_TYPE_RAMDISK, GBL_EFI_BOOT_BUFFER_TYPE_FDT,
|
||||
GBL_EFI_BOOT_BUFFER_TYPE_PVMFW_DATA,
|
||||
GBL_EFI_BOOT_BUFFER_TYPE_FASTBOOT_DOWNLOAD);
|
||||
|
||||
EFI_ENUM(GBL_EFI_PARTITION_BUFFER_FLAG, GblEfiPartitionBufferFlag, uint32_t,
|
||||
GBL_EFI_PARTITION_BUFFER_FLAG_PRELOADED = 1 << 0);
|
||||
|
||||
typedef struct GblEfiBootMemoryProtocol {
|
||||
uint64_t revision;
|
||||
EfiStatus (*get_partition_buffer)(struct GblEfiBootMemoryProtocol *self,
|
||||
/* in */ const uint8_t *base_name,
|
||||
/* out */ size_t *size,
|
||||
/* out */ void **addr,
|
||||
/* out */ GblEfiPartitionBufferFlag *flag);
|
||||
EfiStatus (*sync_partition_buffer)(struct GblEfiBootMemoryProtocol *self,
|
||||
/* in */ bool sync_preloaded);
|
||||
EfiStatus (*get_boot_buffer)(struct GblEfiBootMemoryProtocol *self,
|
||||
/* in */ GblEfiBootBufferType buf_type,
|
||||
/* out */ size_t *size,
|
||||
/* out */ void **addr);
|
||||
} GblEfiBootMemoryProtocol;
|
||||
|
||||
#endif //__GBL_EFI_BOOT_MEMORY_PROTOCOL_H__
|
||||
41
lib/uefi/include/uefi/protocols/gbl_efi_debug_protocol.h
Normal file
41
lib/uefi/include/uefi/protocols/gbl_efi_debug_protocol.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#ifndef __GBL_EFI_DEBUG_PROTOCOL_H__
|
||||
#define __GBL_EFI_DEBUG_PROTOCOL_H__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
static const uint64_t GBL_EFI_DEBUG_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(0, 1);
|
||||
|
||||
typedef struct GblEfiDebugProtocol {
|
||||
uint64_t revision;
|
||||
|
||||
EfiStatus (*fatal_error)(struct GblEfiDebugProtocol *self,
|
||||
const void *frame_ptr);
|
||||
} GblEfiDebugProtocol;
|
||||
|
||||
#endif // __GBL_EFI_DEBUG_PROTOCOL_H__ */
|
||||
@@ -62,7 +62,7 @@ EFI_ENUM(GBL_EFI_FASTBOOT_ERASE_ACTION, GblEfiFastbootEraseAction, uint32_t,
|
||||
typedef struct GblEfiFastbootProtocol {
|
||||
uint64_t revision;
|
||||
// Null-terminated UTF-8 encoded string
|
||||
char8_t serial_number[GBL_EFI_FASTBOOT_SERIAL_NUMBER_MAX_LEN_UTF8];
|
||||
uint8_t serial_number[GBL_EFI_FASTBOOT_SERIAL_NUMBER_MAX_LEN_UTF8];
|
||||
|
||||
// Fastboot variable methods
|
||||
EfiStatus (*get_var)(struct GblEfiFastbootProtocol* self,
|
||||
@@ -89,9 +89,9 @@ typedef struct GblEfiFastbootProtocol {
|
||||
bool* out_lock);
|
||||
|
||||
// Misc methods
|
||||
EfiStatus (*vendor_erase)(struct GblEfiFastbootProtocol* self,
|
||||
const char8_t* part_name, size_t part_name_len,
|
||||
GblEfiFastbootEraseAction* action);
|
||||
EfiStatus (*vendor_erase)(struct GblEfiFastbootProtocol *self,
|
||||
const uint8_t *part_name, size_t part_name_len,
|
||||
GblEfiFastbootEraseAction *action);
|
||||
bool (*should_stop_in_fastboot)(struct GblEfiFastbootProtocol* self);
|
||||
EfiStatus (*is_command_allowed)(struct GblEfiFastbootProtocol* self,
|
||||
size_t num_args, const char* const* args,
|
||||
|
||||
@@ -13,15 +13,25 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#ifndef __GBL_EFI_IMAGE_LOADING_PROTOCOL_H__
|
||||
#define __GBL_EFI_IMAGE_LOADING_PROTOCOL_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
static constexpr uint64_t GBL_EFI_IMAGE_LOADING_PROTOCOL_REVISION = 0x00010000;
|
||||
#include "types.h"
|
||||
|
||||
static const uint64_t GBL_EFI_IMAGE_LOADING_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(0, 1);
|
||||
|
||||
#define PARTITION_NAME_LEN_U16 36
|
||||
|
||||
@@ -30,6 +40,12 @@ static constexpr uint64_t GBL_EFI_IMAGE_LOADING_PROTOCOL_REVISION = 0x00010000;
|
||||
//******************************************************
|
||||
// Buffer for loading, verifying and fixing up OS images.
|
||||
#define GBL_IMAGE_TYPE_OS_LOAD L"os_load"
|
||||
// Buffer for use as finalized kernel load buffer.
|
||||
#define GBL_IMAGE_TYPE_KERNEL_LOAD L"kernel_load"
|
||||
// Buffer for use as finalized ramdisk load buffer.
|
||||
#define GBL_IMAGE_TYPE_RAMDISK_LOAD L"ramdisk_load"
|
||||
// Buffer for use as finalized fdt load buffer.
|
||||
#define GBL_IMAGE_TYPE_FDT_LOAD L"fdt_load"
|
||||
// Buffer for use as fastboot download buffer.
|
||||
#define GBL_IMAGE_TYPE_FASTBOOT L"fastboot"
|
||||
// Buffer reserved for pvmfw binary and configuration (must be 4KiB-aligned).
|
||||
@@ -45,18 +61,11 @@ typedef struct GblEfiImageBuffer {
|
||||
size_t SizeBytes;
|
||||
} GblEfiImageBuffer;
|
||||
|
||||
typedef struct GblEfiPartitionName {
|
||||
char16_t StrUtf16[PARTITION_NAME_LEN_U16];
|
||||
} GblEfiPartitionName;
|
||||
|
||||
typedef struct GblEfiImageLoadingProtocol {
|
||||
uint64_t revision;
|
||||
EfiStatus (*get_buffer)(struct GblEfiImageLoadingProtocol* self,
|
||||
const GblEfiImageInfo* ImageInfo,
|
||||
GblEfiImageBuffer* Buffer);
|
||||
EfiStatus (*get_verify_partitions)(struct GblEfiImageLoadingProtocol* self,
|
||||
size_t* NumberOfPartitions,
|
||||
GblEfiPartitionName* Partitions);
|
||||
EfiStatus (*get_buffer)(struct GblEfiImageLoadingProtocol *self,
|
||||
const GblEfiImageInfo *ImageInfo,
|
||||
GblEfiImageBuffer *Buffer);
|
||||
} GblEfiImageLoadingProtocol;
|
||||
|
||||
#endif //__GBL_EFI_IMAGE_LOADING_PROTOCOL_H__
|
||||
#endif //__GBL_EFI_IMAGE_LOADING_PROTOCOL_H__
|
||||
|
||||
@@ -76,14 +76,21 @@ typedef struct GblEfiOsConfigurationProtocol {
|
||||
uint64_t revision;
|
||||
|
||||
// Generates fixups for the bootconfig built by GBL.
|
||||
EfiStatus (*fixup_bootconfig)(struct GblEfiOsConfigurationProtocol* self,
|
||||
const char8_t* bootconfig, size_t size,
|
||||
char8_t* fixup, size_t* fixup_buffer_size);
|
||||
EfiStatus (*fixup_bootconfig)(struct GblEfiOsConfigurationProtocol *self,
|
||||
const uint8_t *bootconfig, size_t size,
|
||||
uint8_t *fixup, size_t *fixup_buffer_size);
|
||||
|
||||
// Selects which device trees and overlays to use from those loaded by GBL.
|
||||
EfiStatus (*select_device_trees)(struct GblEfiOsConfigurationProtocol* self,
|
||||
GblEfiVerifiedDeviceTree* device_trees,
|
||||
size_t num_device_trees);
|
||||
|
||||
// Selects FIT configuration to be used.
|
||||
EfiStatus (*select_fit_configuration)(struct GblEfiOsConfigurationProtocol *self,
|
||||
size_t fit_size, const uint8_t *fit,
|
||||
size_t metadata_size, const uint8_t *metadata,
|
||||
size_t *selected_configuration_offset);
|
||||
|
||||
} GblEfiOsConfigurationProtocol;
|
||||
|
||||
#endif //__GBL_OS_CONFIGURATION_PROTOCOL_H__
|
||||
|
||||
62
lib/uefi/include/uefi/protocols/hash2_protocol.h
Normal file
62
lib/uefi/include/uefi/protocols/hash2_protocol.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#ifndef __HASH2_PROTOCOL_H__
|
||||
#define __HASH2_PROTOCOL_H__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct EfiHash2Protocol EfiHash2Protocol;
|
||||
|
||||
typedef uint8_t EfiMd5Hash2[16];
|
||||
typedef uint8_t EfiSha1Hash2[20];
|
||||
typedef uint8_t EfiSha224Hash2[28];
|
||||
typedef uint8_t EfiSha256Hash2[32];
|
||||
typedef uint8_t EfiSha384Hash2[48];
|
||||
typedef uint8_t EfiSha512Hash2[64];
|
||||
|
||||
typedef union {
|
||||
EfiMd5Hash2 md5_hash;
|
||||
EfiSha1Hash2 sha1_hash;
|
||||
EfiSha224Hash2 sha224_hash;
|
||||
EfiSha256Hash2 sha256_hash;
|
||||
EfiSha384Hash2 sha384_hash;
|
||||
EfiSha512Hash2 sha512_hash;
|
||||
} EfiHash2Output;
|
||||
|
||||
struct EfiHash2Protocol {
|
||||
EfiStatus (*get_hash_size)(const EfiHash2Protocol* self,
|
||||
EfiGuid* hash_algorithm, size_t* hash_size);
|
||||
EfiStatus (*hash)(const EfiHash2Protocol* self, const EfiGuid* hash_algorithm,
|
||||
const uint8_t* message, size_t message_size,
|
||||
EfiHash2Output* out);
|
||||
EfiStatus (*hash_init)(const EfiHash2Protocol* self,
|
||||
const EfiGuid* hash_algorithm);
|
||||
EfiStatus (*hash_update)(const EfiHash2Protocol* self, const uint8_t* message,
|
||||
size_t message_size);
|
||||
EfiStatus (*hash_final)(const EfiHash2Protocol* self, EfiHash2Output* hash);
|
||||
};
|
||||
|
||||
#endif // __HASH2_PROTOCOL_H__
|
||||
@@ -13,12 +13,27 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#ifndef __LOADED_IMAGE_PROTOCOL_H__
|
||||
#define __LOADED_IMAGE_PROTOCOL_H__
|
||||
|
||||
#include <uefi/gbl_protocol_utils.h>
|
||||
#include <uefi/protocols/device_path_protocol.h>
|
||||
#include <uefi/system_table.h>
|
||||
#include <uefi/protocols/system_table.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
static const uint32_t EFI_LOADED_IMAGE_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(1, 0);
|
||||
|
||||
typedef struct {
|
||||
uint32_t revision;
|
||||
EfiHandle parent_handle;
|
||||
@@ -35,3 +50,5 @@ typedef struct {
|
||||
|
||||
EfiStatus (*unload)(EfiHandle img);
|
||||
} EfiLoadedImageProtocol;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#ifndef __RANDOM_NUMBER_GENERATOR_PROTOCOL__
|
||||
#define __RANDOM_NUMBER_GENERATOR_PROTOCOL__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef EfiGuid EfiRngAlgorithm;
|
||||
typedef struct EfiRngProtocol EfiRngProtocol;
|
||||
|
||||
struct EfiRngProtocol {
|
||||
EfiStatus (*get_info)(EfiRngProtocol* self, size_t* rng_algorithm_list_size,
|
||||
EfiRngAlgorithm* rng_algorithm_list);
|
||||
EfiStatus (*get_rng)(EfiRngProtocol* self,
|
||||
const EfiRngAlgorithm* rng_algorithm,
|
||||
size_t rng_value_length, uint8_t* rng_value);
|
||||
};
|
||||
|
||||
#endif // __RANDOM_NUMBER_GENERATOR_PROTOCOL__
|
||||
@@ -28,13 +28,18 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "gbl_protocol_utils.h"
|
||||
#include "types.h"
|
||||
|
||||
static const uint64_t EFI_RISCV_BOOT_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(1, 0);
|
||||
|
||||
// Source: https://github.com/riscv-non-isa/riscv-uefi
|
||||
struct EfiRiscvBootProtocol {
|
||||
uint64_t revision;
|
||||
|
||||
EfiStatus (*get_boot_hartid)(struct EfiRiscvBootProtocol* self, size_t* boot_hartid);
|
||||
EfiStatus (*get_boot_hartid)(struct EfiRiscvBootProtocol* self,
|
||||
size_t* boot_hartid);
|
||||
};
|
||||
|
||||
#endif // __RISCV_EFI_BOOT_PROTOCOL_H__
|
||||
|
||||
40
lib/uefi/include/uefi/protocols/service_binding_protocol.h
Normal file
40
lib/uefi/include/uefi/protocols/service_binding_protocol.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2025 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
#ifndef __SERVICE_BINDING_PROTOCOL_H__
|
||||
#define __SERVICE_BINDING_PROTOCOL_H__
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct EfiServiceBindingProtocol EfiServiceBindingProtocol;
|
||||
|
||||
struct EfiServiceBindingProtocol {
|
||||
EfiStatus (*create_child)(EfiServiceBindingProtocol* self,
|
||||
EfiHandle* child_handle);
|
||||
EfiStatus (*destroy_child)(EfiServiceBindingProtocol* self,
|
||||
EfiHandle child_handle);
|
||||
};
|
||||
|
||||
#endif // __SERVICE_BINDING_PROTOCOL_H__
|
||||
@@ -31,9 +31,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "gbl_protocol_utils.h"
|
||||
#include "types.h"
|
||||
|
||||
#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
|
||||
#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
|
||||
@@ -42,6 +42,9 @@
|
||||
|
||||
#define MAX_MCAST_FILTER_CNT 16
|
||||
|
||||
static const uint64_t EFI_SIMPLE_NETWORK_PROTOCOL_REVISION =
|
||||
GBL_PROTOCOL_REVISION(1, 0);
|
||||
|
||||
typedef struct {
|
||||
uint8_t addr[32];
|
||||
} EfiMacAddress;
|
||||
@@ -115,27 +118,36 @@ typedef struct EfiSimpleNetworkProtocol {
|
||||
uint64_t revision;
|
||||
EfiStatus (*start)(struct EfiSimpleNetworkProtocol* self);
|
||||
EfiStatus (*stop)(struct EfiSimpleNetworkProtocol* self);
|
||||
EfiStatus (*initialize)(struct EfiSimpleNetworkProtocol* self, size_t extra_rx_buffer_size,
|
||||
EfiStatus (*initialize)(struct EfiSimpleNetworkProtocol* self,
|
||||
size_t extra_rx_buffer_size,
|
||||
size_t extra_tx_buffer_size);
|
||||
EfiStatus (*reset)(struct EfiSimpleNetworkProtocol* self, bool extended_verification);
|
||||
EfiStatus (*reset)(struct EfiSimpleNetworkProtocol* self,
|
||||
bool extended_verification);
|
||||
EfiStatus (*shutdown)(struct EfiSimpleNetworkProtocol* self);
|
||||
EfiStatus (*receive_filters)(struct EfiSimpleNetworkProtocol* self, uint32_t enable,
|
||||
uint32_t disable, bool reset_mcast_filter, size_t mcast_filter_count,
|
||||
EfiStatus (*receive_filters)(struct EfiSimpleNetworkProtocol* self,
|
||||
uint32_t enable, uint32_t disable,
|
||||
bool reset_mcast_filter,
|
||||
size_t mcast_filter_count,
|
||||
EfiMacAddress* mcast_filter);
|
||||
EfiStatus (*station_address)(struct EfiSimpleNetworkProtocol* self, bool reset,
|
||||
EfiMacAddress* new_addr);
|
||||
EfiStatus (*statistics)(struct EfiSimpleNetworkProtocol* self, bool reset, size_t* stats_size,
|
||||
EfiStatus (*station_address)(struct EfiSimpleNetworkProtocol* self,
|
||||
bool reset, EfiMacAddress* new_addr);
|
||||
EfiStatus (*statistics)(struct EfiSimpleNetworkProtocol* self, bool reset,
|
||||
size_t* stats_size,
|
||||
EfiNetworkStatistics* stats_table);
|
||||
EfiStatus (*m_cast_ip_to_mac)(struct EfiSimpleNetworkProtocol* self, bool ipv6, EfiIpAddr* ip,
|
||||
EfiMacAddress* mac);
|
||||
EfiStatus (*nv_data)(struct EfiSimpleNetworkProtocol* self, bool read_write, size_t offset,
|
||||
size_t buf_size, void* buf);
|
||||
EfiStatus (*get_status)(struct EfiSimpleNetworkProtocol* self, uint32_t* interrupt_status,
|
||||
void** tx_buf);
|
||||
EfiStatus (*transmit)(struct EfiSimpleNetworkProtocol* self, size_t header_size, size_t buf_size,
|
||||
void* buf, EfiMacAddress* src, EfiMacAddress* dest, uint16_t* protocol);
|
||||
EfiStatus (*receive)(struct EfiSimpleNetworkProtocol* self, size_t* header_size, size_t* buf_size,
|
||||
void* buf, EfiMacAddress* src, EfiMacAddress* dest, uint16_t* protocol);
|
||||
EfiStatus (*m_cast_ip_to_mac)(struct EfiSimpleNetworkProtocol* self,
|
||||
bool ipv6, EfiIpAddr* ip, EfiMacAddress* mac);
|
||||
EfiStatus (*nv_data)(struct EfiSimpleNetworkProtocol* self, bool read_write,
|
||||
size_t offset, size_t buf_size, void* buf);
|
||||
EfiStatus (*get_status)(struct EfiSimpleNetworkProtocol* self,
|
||||
uint32_t* interrupt_status, void** tx_buf);
|
||||
EfiStatus (*transmit)(struct EfiSimpleNetworkProtocol* self,
|
||||
size_t header_size, size_t buf_size, void* buf,
|
||||
EfiMacAddress* src, EfiMacAddress* dest,
|
||||
uint16_t* protocol);
|
||||
EfiStatus (*receive)(struct EfiSimpleNetworkProtocol* self,
|
||||
size_t* header_size, size_t* buf_size, void* buf,
|
||||
EfiMacAddress* src, EfiMacAddress* dest,
|
||||
uint16_t* protocol);
|
||||
|
||||
EfiEvent wait_for_packet;
|
||||
EfiSimpleNetworkMode* mode;
|
||||
|
||||
@@ -12,21 +12,30 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause-Patent
|
||||
*
|
||||
* You may choose to use or redistribute this file under
|
||||
* (a) the Apache License, Version 2.0, or
|
||||
* (b) the BSD 2-Clause Patent license.
|
||||
*
|
||||
* Unless you expressly elect the BSD-2-Clause-Patent terms, the Apache-2.0
|
||||
* terms apply by default.
|
||||
*/
|
||||
|
||||
// Reference:
|
||||
// https://uefi.org/specs/UEFI/2.10/39_Micellaneous_Protocols.html#efi-timestamp-protocol
|
||||
#ifndef __TIMESTAMP_PROTOCOL_H__
|
||||
#define __TIMESTAMP_PROTOCOL_H__
|
||||
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
|
||||
#include <uefi/types.h>
|
||||
|
||||
typedef struct EfiTimestampProperties {
|
||||
typedef struct {
|
||||
uint64_t frequency;
|
||||
uint64_t end_value;
|
||||
} EfiTimestampProperties;
|
||||
|
||||
typedef struct EfiTimestampProtocol {
|
||||
uint64_t (*get_timestamp)();
|
||||
EfiStatus (*get_properties)(EfiTimestampProperties *properties);
|
||||
} EfiTimestampProtocol;
|
||||
struct EfiTimestampProtocol {
|
||||
uint64_t (*get_timestamp)(void);
|
||||
EfiStatus (*get_properties)(EfiTimestampProperties*);
|
||||
};
|
||||
|
||||
#endif //__TIMESTAMP_PROTOCOL_H__
|
||||
@@ -26,10 +26,10 @@
|
||||
#ifndef __SYSTEM_TABLE_H__
|
||||
#define __SYSTEM_TABLE_H__
|
||||
|
||||
#include "boot_service.h"
|
||||
#include "protocols/simple_text_output_protocol.h"
|
||||
#include "runtime_service.h"
|
||||
#include "types.h"
|
||||
#include <uefi/boot_service.h>
|
||||
#include <uefi/protocols/simple_text_output_protocol.h>
|
||||
#include <uefi/runtime_service.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
typedef struct EfiConfigurationTable {
|
||||
EfiGuid vendor_guid;
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
struct EfiEventImpl;
|
||||
|
||||
typedef void* EfiHandle;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wc++20-compat"
|
||||
#if __cplusplus < 202002L
|
||||
typedef uint8_t char8_t;
|
||||
#endif
|
||||
#pragma GCC diagnostic pop
|
||||
typedef EfiEventImpl* EfiEvent;
|
||||
typedef uint64_t EfiPhysicalAddr;
|
||||
typedef uint64_t EfiVirtualAddr;
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
|
||||
#define LOCAL_TRACE 0
|
||||
|
||||
__WEAK EFI_STATUS efi_dt_fixup(struct EfiDtFixupProtocol *self, void *fdt,
|
||||
size_t *buffer_size, uint32_t flags) {
|
||||
__WEAK EFI_STATUS efi_dt_fixup(struct EfiDtFixupProtocol* self, void* fdt,
|
||||
size_t* buffer_size, uint32_t flags) {
|
||||
auto offset = fdt_subnode_offset(fdt, 0, "chosen");
|
||||
if (offset < 0) {
|
||||
printf("Failed to find chosen node %d\n", offset);
|
||||
@@ -49,13 +49,13 @@ __WEAK EFI_STATUS efi_dt_fixup(struct EfiDtFixupProtocol *self, void *fdt,
|
||||
printf("Failed to find chosen/bootargs prop\n");
|
||||
return EFI_STATUS_SUCCESS;
|
||||
}
|
||||
char *new_prop_data = reinterpret_cast<char *>(malloc(length));
|
||||
char* new_prop_data = reinterpret_cast<char*>(malloc(length));
|
||||
DEFER {
|
||||
free(new_prop_data);
|
||||
new_prop_data = nullptr;
|
||||
};
|
||||
auto prop_length = strnlen(prop->data, length);
|
||||
static constexpr auto &&to_add =
|
||||
static constexpr auto&& to_add =
|
||||
"console=ttyAMA0 earlycon=pl011,mmio32,0x9000000 ";
|
||||
memset(new_prop_data, 0, length);
|
||||
memcpy(new_prop_data, to_add, sizeof(to_add) - 1);
|
||||
@@ -68,12 +68,12 @@ __WEAK EFI_STATUS efi_dt_fixup(struct EfiDtFixupProtocol *self, void *fdt,
|
||||
}
|
||||
|
||||
// Generates fixups for the bootconfig built by GBL.
|
||||
__WEAK EfiStatus fixup_bootconfig(struct GblEfiOsConfigurationProtocol *self,
|
||||
const char8_t *bootconfig, size_t size,
|
||||
char8_t *fixup, size_t *fixup_buffer_size) {
|
||||
__WEAK EfiStatus fixup_bootconfig(struct GblEfiOsConfigurationProtocol* self,
|
||||
const uint8_t* bootconfig, size_t size,
|
||||
uint8_t* fixup, size_t* fixup_buffer_size) {
|
||||
printf("%s(%p, %s, %lu, %lu)\n", __FUNCTION__, self,
|
||||
reinterpret_cast<const char*>(bootconfig), size, *fixup_buffer_size);
|
||||
constexpr auto &&to_add =
|
||||
constexpr auto&& to_add =
|
||||
"\nandroidboot.fstab_suffix=cf.f2fs."
|
||||
"hctr2\nandroidboot.boot_devices=4010000000.pcie";
|
||||
const auto final_len = sizeof(to_add);
|
||||
@@ -88,8 +88,8 @@ __WEAK EfiStatus fixup_bootconfig(struct GblEfiOsConfigurationProtocol *self,
|
||||
}
|
||||
|
||||
// Selects which device trees and overlays to use from those loaded by GBL.
|
||||
__WEAK EfiStatus select_device_trees(struct GblEfiOsConfigurationProtocol *self,
|
||||
GblEfiVerifiedDeviceTree *device_trees,
|
||||
__WEAK EfiStatus select_device_trees(struct GblEfiOsConfigurationProtocol* self,
|
||||
GblEfiVerifiedDeviceTree* device_trees,
|
||||
size_t num_device_trees) {
|
||||
printf("%s(%p, %p %lu)\n", __FUNCTION__, self, device_trees,
|
||||
num_device_trees);
|
||||
@@ -101,16 +101,14 @@ __WEAK EfiStatus exit_boot_services(EfiHandle image_handle, size_t map_key) {
|
||||
return EFI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
__WEAK EfiStatus platform_setup_system_table(EfiSystemTable *table) {
|
||||
__WEAK EfiStatus platform_setup_system_table(EfiSystemTable* table) {
|
||||
printf("%s is called\n", __FUNCTION__);
|
||||
return EFI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
__WEAK uint64_t get_timestamp() {
|
||||
return ARM64_READ_SYSREG(cntpct_el0);
|
||||
}
|
||||
__WEAK uint64_t get_timestamp() { return ARM64_READ_SYSREG(cntpct_el0); }
|
||||
|
||||
__WEAK EfiStatus get_timestamp_properties(EfiTimestampProperties *properties) {
|
||||
__WEAK EfiStatus get_timestamp_properties(EfiTimestampProperties* properties) {
|
||||
if (properties == nullptr) {
|
||||
return EFI_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
@@ -134,7 +132,8 @@ __END_CDECLS
|
||||
|
||||
__WEAK EfiStatus set_watchdog_timer(size_t timeout, uint64_t watchdog_code,
|
||||
size_t data_size, uint16_t* watchdog_data) {
|
||||
if (platform_watchdog_init == nullptr || platform_watchdog_set_enabled == nullptr) {
|
||||
if (platform_watchdog_init == nullptr ||
|
||||
platform_watchdog_set_enabled == nullptr) {
|
||||
TRACEF(
|
||||
"unimplemented: platform_watchdog_init = %p "
|
||||
"platform_watchdog_set_enabled = %p\n",
|
||||
@@ -161,7 +160,7 @@ __WEAK EfiStatus set_watchdog_timer(size_t timeout, uint64_t watchdog_code,
|
||||
|
||||
namespace {
|
||||
|
||||
const char *GetImageType(const char16_t *ImageType) {
|
||||
const char* GetImageType(const char16_t* ImageType) {
|
||||
if (memcmp(ImageType, GBL_IMAGE_TYPE_OS_LOAD,
|
||||
sizeof(GBL_IMAGE_TYPE_OS_LOAD)) == 0) {
|
||||
return "os_load";
|
||||
@@ -174,7 +173,8 @@ const char *GetImageType(const char16_t *ImageType) {
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
template <typename T> T clamp(T n, T lower, T upper) {
|
||||
template <typename T>
|
||||
T clamp(T n, T lower, T upper) {
|
||||
if (n < lower) {
|
||||
return lower;
|
||||
}
|
||||
@@ -217,11 +217,11 @@ EfiStatus erase_blocks(EfiEraseBlockProtocol* self, uint32_t media_id,
|
||||
return EFI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
__WEAK EfiStatus get_buffer(struct GblEfiImageLoadingProtocol *self,
|
||||
const GblEfiImageInfo *ImageInfo,
|
||||
GblEfiImageBuffer *Buffer) {
|
||||
__WEAK EfiStatus get_buffer(struct GblEfiImageLoadingProtocol* self,
|
||||
const GblEfiImageInfo* ImageInfo,
|
||||
GblEfiImageBuffer* Buffer) {
|
||||
printf("%s(%s, %lu)\n", __FUNCTION__, GetImageType(ImageInfo->ImageType),
|
||||
ImageInfo->SizeBytes);
|
||||
|
||||
@@ -253,9 +253,9 @@ EfiStatus open_efi_erase_block_protocol(const EfiHandle handle, void** intf) {
|
||||
memset(p, 0, sizeof(*p));
|
||||
p->dev = bio_open(device_name);
|
||||
p->protocol = {
|
||||
.revision = EFI_ERASE_BLOCK_PROTOCOL_REVISION,
|
||||
.erase_length_granularity = 1, // Erase block size == 1 filesystem block
|
||||
.erase_blocks = erase_blocks,
|
||||
.revision = EFI_ERASE_BLOCK_PROTOCOL_REVISION,
|
||||
.erase_length_granularity = 1, // Erase block size == 1 filesystem block
|
||||
.erase_blocks = erase_blocks,
|
||||
};
|
||||
*intf = p;
|
||||
return EFI_STATUS_SUCCESS;
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#define __GBL_OS_CONFIGURATION_
|
||||
|
||||
#include <arch/defines.h>
|
||||
#include <uefi/protocols/efi_timestamp_protocol.h>
|
||||
#include <uefi/protocols/gbl_efi_image_loading_protocol.h>
|
||||
#include <uefi/protocols/gbl_efi_os_configuration_protocol.h>
|
||||
#include <uefi/protocols/timestamp.h>
|
||||
#include <uefi/system_table.h>
|
||||
#include <uefi/types.h>
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
EFI_STATUS efi_dt_fixup(struct EfiDtFixupProtocol *self, void *fdt,
|
||||
size_t *buffer_size, uint32_t flags);
|
||||
|
||||
EfiStatus fixup_bootconfig(struct GblEfiOsConfigurationProtocol *self,
|
||||
const char8_t *bootconfig, size_t size,
|
||||
char8_t *fixup, size_t *fixup_buffer_size);
|
||||
EfiStatus fixup_bootconfig(struct GblEfiOsConfigurationProtocol* self,
|
||||
const uint8_t* bootconfig, size_t size,
|
||||
uint8_t* fixup, size_t* fixup_buffer_size);
|
||||
|
||||
EfiStatus select_device_trees(struct GblEfiOsConfigurationProtocol *self,
|
||||
GblEfiVerifiedDeviceTree *device_trees,
|
||||
|
||||
Reference in New Issue
Block a user