1 // Copyright 2016 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <efi/types.h> 8 #include <efi/boot-services.h> 9 10 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 11 #define EFI_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_VERSION 12 13 #define EFI_VARIABLE_NON_VOLATILE 0x00000001 14 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 15 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 16 #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 17 #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 18 #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020 19 #define EFI_VARIABLE_APPEND_WRITE 0x00000040 20 21 // TODO: implement the win_certificate structs if we need them 22 //typedef struct { 23 // uint64_t MonotonicCount; 24 // win_certificate_uefi_guid AuthInfo; 25 //} efi_variable_authentication; 26 // 27 //typedef struct { 28 // efi_time TimeStamp; 29 // win_certificate_uefi_guid AuthInfo; 30 //} efi_variable_authentication_2; 31 32 #define EFI_HARDWARE_ERROR_VARIABLE \ 33 {0x414e6bdd, 0xe47b, 0x47cc, {0xb2, 0x44, 0xbb, 0x61, 0x02, 0x0c, 0xf5, 0x16}} 34 35 typedef struct { 36 uint16_t Year; 37 uint8_t Month; 38 uint8_t Day; 39 uint8_t Hour; 40 uint8_t Minute; 41 uint8_t Second; 42 uint8_t Pad1; 43 uint32_t Nanosecond; 44 int16_t TimeZone; 45 uint8_t Daylight; 46 uint8_t Pad2; 47 } efi_time; 48 49 #define EFI_TIME_ADJUST_DAYLIGHT 0x01 50 #define EFI_TIME_IN_DAYLIGHT 0x02 51 52 #define EFI_UNSPECIFIED_TIMEZONE 0x07FF 53 54 typedef struct { 55 uint32_t Resolution; 56 uint32_t Accuracy; 57 bool SetsToZero; 58 } efi_time_capabilities; 59 60 #define EFI_OPTIONAL_PTR 0x00000001 61 62 typedef enum { 63 EfiResetCold, 64 EfiResetWarm, 65 EfiResetShutdown, 66 EfiResetPlatformSpecific 67 } efi_reset_type; 68 69 typedef struct { 70 uint64_t Length; 71 union { 72 efi_physical_addr DataBlock; 73 efi_physical_addr ContinuationPointer; 74 } Union; 75 } efi_capsule_block_descriptor; 76 77 typedef struct { 78 efi_guid CapsuleGuid; 79 uint32_t HeaderSize; 80 uint32_t Flags; 81 uint32_t CapsuleImageSize; 82 } efi_capsule_header; 83 84 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 85 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 86 #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 87 88 #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001 89 #define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002 90 #define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED 0x0000000000000004 91 #define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED 0x0000000000000008 92 #define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED 0x0000000000000010 93 #define EFI_OS_INDICATIONS_START_OS_RECOVERY 0x0000000000000020 94 #define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY 0x0000000000000040 95 96 #define EFI_CAPSULE_REPORT_GUID \ 97 {0x39b68c46, 0xf7fb, 0x441b, {0xb6, 0xec, 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3}} 98 99 typedef struct { 100 uint32_t VariableTotalSize; 101 uint32_t Reserved; 102 efi_guid CapsuleGuid; 103 efi_time CapsuleProcessed; 104 efi_status CapsuleStatus; 105 } efi_capsule_result_variable_header; 106 107 typedef struct { 108 efi_table_header Hdr; 109 110 efi_status (*GetTime) (efi_time* time, efi_time_capabilities* capabilities) EFIAPI; 111 112 efi_status (*SetTime) (efi_time* time) EFIAPI; 113 114 efi_status (*GetWakeupTime) (bool* enabled, bool* pending, efi_time* time) EFIAPI; 115 116 efi_status (*SetWakeupTime) (bool enable, efi_time* time) EFIAPI; 117 118 efi_status (*SetVirtualAddressMap) (size_t memory_map_size, size_t desc_size, 119 uint32_t desc_version, 120 efi_memory_descriptor* virtual_map) EFIAPI; 121 122 efi_status (*ConvertPointer) (size_t debug_disposition, void** addr) EFIAPI; 123 124 efi_status (*GetVariable) (char16_t* var_name, efi_guid* vendor_guid, 125 uint32_t* attributes, size_t* data_size, void* data) EFIAPI; 126 127 efi_status (*GetNextVariableName) (size_t* var_name_size, char16_t* var_name, 128 efi_guid* vendor_guid) EFIAPI; 129 130 efi_status (*SetVariable) (char16_t* var_name, efi_guid* vendor_guid, 131 uint32_t attributes, size_t data_size, void* data) EFIAPI; 132 133 efi_status (*GetNextHighMonotonicCount) (uint32_t* high_count) EFIAPI; 134 135 efi_status (*ResetSystem) (efi_reset_type reset_type, efi_status reset_status, 136 size_t data_size, void* reset_data) EFIAPI; 137 138 efi_status (*UpdateCapsule) (efi_capsule_header** capsule_header_array, 139 size_t capsule_count, 140 efi_physical_addr scatter_gather_list) EFIAPI; 141 142 efi_status (*QueryCapsuleCapabilities) (efi_capsule_header** capsule_header_array, 143 size_t capsule_count, 144 uint64_t* max_capsule_size, 145 efi_reset_type* reset_type) EFIAPI; 146 147 efi_status (*QueryVariableInfo) (uint32_t attributes, 148 uint64_t* max_var_storage_size, 149 uint64_t* remaining_var_storage_size, 150 uint64_t* max_var_size) EFIAPI; 151 } efi_runtime_services; 152