1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 // This is a custom protocol introduced by GBL. 19 // See gbl/docs/gbl_efi_os_configuration_protocol.md for details. 20 21 #ifndef __GBL_OS_CONFIGURATION_PROTOCOL_H__ 22 #define __GBL_OS_CONFIGURATION_PROTOCOL_H__ 23 24 #include "types.h" 25 26 typedef enum GBL_EFI_DEVICE_TREE_SOURCE { 27 BOOT, 28 VENDOR_BOOT, 29 DTBO, 30 DTB 31 } GblEfiDeviceTreeSource; 32 33 typedef struct { 34 // GblDeviceTreeSource 35 uint32_t source; 36 // Values are zeroed and must not be used in case of BOOT / VENDOR_BOOT source 37 uint32_t id; 38 uint32_t rev; 39 uint32_t custom[4]; 40 // Make sure GblDeviceTreeMetadata size is 8-bytes aligned. Also reserved for 41 // the future cases 42 uint32_t reserved; 43 } GblEfiDeviceTreeMetadata; 44 45 typedef struct { 46 GblEfiDeviceTreeMetadata metadata; 47 // Base device tree / overlay buffer (guaranteed to be 8-bytes aligned), 48 // cannot be NULL. Device tree size can be identified by the header totalsize 49 // field 50 const void* device_tree; 51 // Indicates whether this device tree (or overlay) must be included in the 52 // final device tree. Set to true by a FW if this component must be used 53 bool selected; 54 } GblEfiVerifiedDeviceTree; 55 56 // Warning: API is UNSTABLE 57 // Documentation: 58 // https://cs.android.com/android/platform/superproject/main/+/main:bootable/libbootloader/gbl/docs/gbl_os_configuration_protocol.md 59 typedef struct GblEfiOsConfigurationProtocol { 60 uint64_t revision; 61 62 // Generates fixups for the kernel command line built by GBL. 63 EfiStatus (*fixup_kernel_commandline)( 64 struct GblEfiOsConfigurationProtocol* self, const char8_t* command_line, 65 char8_t* fixup, size_t* fixup_buffer_size); 66 67 // Generates fixups for the bootconfig built by GBL. 68 EfiStatus (*fixup_bootconfig)(struct GblEfiOsConfigurationProtocol* self, 69 const char8_t* bootconfig, size_t size, 70 char8_t* fixup, size_t* fixup_buffer_size); 71 72 // Selects which device trees and overlays to use from those loaded by GBL. 73 EfiStatus (*select_device_trees)(struct GblEfiOsConfigurationProtocol* self, 74 GblEfiVerifiedDeviceTree* device_trees, 75 size_t num_device_trees); 76 } GblEfiOsConfigurationProtocol; 77 78 #endif //__GBL_OS_CONFIGURATION_PROTOCOL_H__ 79