1485b5cf8SAlexander von Gluck IV // Copyright 2016 The Fuchsia Authors. All rights reserved. 2485b5cf8SAlexander von Gluck IV // Use of this source code is governed by a BSD-style license that can be 3485b5cf8SAlexander von Gluck IV // found in the LICENSE file. 4485b5cf8SAlexander von Gluck IV 5485b5cf8SAlexander von Gluck IV #pragma once 6485b5cf8SAlexander von Gluck IV 7485b5cf8SAlexander von Gluck IV #include <efi/types.h> 8485b5cf8SAlexander von Gluck IV #include <efi/boot-services.h> 9485b5cf8SAlexander von Gluck IV 10485b5cf8SAlexander von Gluck IV #define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552 11485b5cf8SAlexander von Gluck IV #define EFI_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_VERSION 12485b5cf8SAlexander von Gluck IV 13485b5cf8SAlexander von Gluck IV #define EFI_VARIABLE_NON_VOLATILE 0x00000001 14485b5cf8SAlexander von Gluck IV #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 15485b5cf8SAlexander von Gluck IV #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 16485b5cf8SAlexander von Gluck IV #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 17485b5cf8SAlexander von Gluck IV #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 18485b5cf8SAlexander von Gluck IV #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020 19485b5cf8SAlexander von Gluck IV #define EFI_VARIABLE_APPEND_WRITE 0x00000040 20485b5cf8SAlexander von Gluck IV 21485b5cf8SAlexander von Gluck IV // TODO: implement the win_certificate structs if we need them 22485b5cf8SAlexander von Gluck IV //typedef struct { 23485b5cf8SAlexander von Gluck IV // uint64_t MonotonicCount; 24485b5cf8SAlexander von Gluck IV // win_certificate_uefi_guid AuthInfo; 25485b5cf8SAlexander von Gluck IV //} efi_variable_authentication; 26485b5cf8SAlexander von Gluck IV // 27485b5cf8SAlexander von Gluck IV //typedef struct { 28485b5cf8SAlexander von Gluck IV // efi_time TimeStamp; 29485b5cf8SAlexander von Gluck IV // win_certificate_uefi_guid AuthInfo; 30485b5cf8SAlexander von Gluck IV //} efi_variable_authentication_2; 31485b5cf8SAlexander von Gluck IV 32485b5cf8SAlexander von Gluck IV #define EFI_HARDWARE_ERROR_VARIABLE \ 33485b5cf8SAlexander von Gluck IV {0x414e6bdd, 0xe47b, 0x47cc, {0xb2, 0x44, 0xbb, 0x61, 0x02, 0x0c, 0xf5, 0x16}} 34485b5cf8SAlexander von Gluck IV 35*7b124be0SX512 #define EFI_GLOBAL_VARIABLE \ 36*7b124be0SX512 {0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C}} 37*7b124be0SX512 38485b5cf8SAlexander von Gluck IV typedef struct { 39485b5cf8SAlexander von Gluck IV uint16_t Year; 40485b5cf8SAlexander von Gluck IV uint8_t Month; 41485b5cf8SAlexander von Gluck IV uint8_t Day; 42485b5cf8SAlexander von Gluck IV uint8_t Hour; 43485b5cf8SAlexander von Gluck IV uint8_t Minute; 44485b5cf8SAlexander von Gluck IV uint8_t Second; 45485b5cf8SAlexander von Gluck IV uint8_t Pad1; 46485b5cf8SAlexander von Gluck IV uint32_t Nanosecond; 47485b5cf8SAlexander von Gluck IV int16_t TimeZone; 48485b5cf8SAlexander von Gluck IV uint8_t Daylight; 49485b5cf8SAlexander von Gluck IV uint8_t Pad2; 50485b5cf8SAlexander von Gluck IV } efi_time; 51485b5cf8SAlexander von Gluck IV 52485b5cf8SAlexander von Gluck IV #define EFI_TIME_ADJUST_DAYLIGHT 0x01 53485b5cf8SAlexander von Gluck IV #define EFI_TIME_IN_DAYLIGHT 0x02 54485b5cf8SAlexander von Gluck IV 55485b5cf8SAlexander von Gluck IV #define EFI_UNSPECIFIED_TIMEZONE 0x07FF 56485b5cf8SAlexander von Gluck IV 57485b5cf8SAlexander von Gluck IV typedef struct { 58485b5cf8SAlexander von Gluck IV uint32_t Resolution; 59485b5cf8SAlexander von Gluck IV uint32_t Accuracy; 60485b5cf8SAlexander von Gluck IV bool SetsToZero; 61485b5cf8SAlexander von Gluck IV } efi_time_capabilities; 62485b5cf8SAlexander von Gluck IV 63485b5cf8SAlexander von Gluck IV #define EFI_OPTIONAL_PTR 0x00000001 64485b5cf8SAlexander von Gluck IV 65485b5cf8SAlexander von Gluck IV typedef enum { 66485b5cf8SAlexander von Gluck IV EfiResetCold, 67485b5cf8SAlexander von Gluck IV EfiResetWarm, 68485b5cf8SAlexander von Gluck IV EfiResetShutdown, 69485b5cf8SAlexander von Gluck IV EfiResetPlatformSpecific 70485b5cf8SAlexander von Gluck IV } efi_reset_type; 71485b5cf8SAlexander von Gluck IV 72485b5cf8SAlexander von Gluck IV typedef struct { 73485b5cf8SAlexander von Gluck IV uint64_t Length; 74485b5cf8SAlexander von Gluck IV union { 75485b5cf8SAlexander von Gluck IV efi_physical_addr DataBlock; 76485b5cf8SAlexander von Gluck IV efi_physical_addr ContinuationPointer; 77485b5cf8SAlexander von Gluck IV } Union; 78485b5cf8SAlexander von Gluck IV } efi_capsule_block_descriptor; 79485b5cf8SAlexander von Gluck IV 80485b5cf8SAlexander von Gluck IV typedef struct { 81485b5cf8SAlexander von Gluck IV efi_guid CapsuleGuid; 82485b5cf8SAlexander von Gluck IV uint32_t HeaderSize; 83485b5cf8SAlexander von Gluck IV uint32_t Flags; 84485b5cf8SAlexander von Gluck IV uint32_t CapsuleImageSize; 85485b5cf8SAlexander von Gluck IV } efi_capsule_header; 86485b5cf8SAlexander von Gluck IV 87485b5cf8SAlexander von Gluck IV #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 88485b5cf8SAlexander von Gluck IV #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 89485b5cf8SAlexander von Gluck IV #define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 90485b5cf8SAlexander von Gluck IV 91485b5cf8SAlexander von Gluck IV #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001 92485b5cf8SAlexander von Gluck IV #define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002 93485b5cf8SAlexander von Gluck IV #define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED 0x0000000000000004 94485b5cf8SAlexander von Gluck IV #define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED 0x0000000000000008 95485b5cf8SAlexander von Gluck IV #define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED 0x0000000000000010 96485b5cf8SAlexander von Gluck IV #define EFI_OS_INDICATIONS_START_OS_RECOVERY 0x0000000000000020 97485b5cf8SAlexander von Gluck IV #define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY 0x0000000000000040 98485b5cf8SAlexander von Gluck IV 99485b5cf8SAlexander von Gluck IV #define EFI_CAPSULE_REPORT_GUID \ 100485b5cf8SAlexander von Gluck IV {0x39b68c46, 0xf7fb, 0x441b, {0xb6, 0xec, 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3}} 101485b5cf8SAlexander von Gluck IV 102485b5cf8SAlexander von Gluck IV typedef struct { 103485b5cf8SAlexander von Gluck IV uint32_t VariableTotalSize; 104485b5cf8SAlexander von Gluck IV uint32_t Reserved; 105485b5cf8SAlexander von Gluck IV efi_guid CapsuleGuid; 106485b5cf8SAlexander von Gluck IV efi_time CapsuleProcessed; 107485b5cf8SAlexander von Gluck IV efi_status CapsuleStatus; 108485b5cf8SAlexander von Gluck IV } efi_capsule_result_variable_header; 109485b5cf8SAlexander von Gluck IV 110485b5cf8SAlexander von Gluck IV typedef struct { 111485b5cf8SAlexander von Gluck IV efi_table_header Hdr; 112485b5cf8SAlexander von Gluck IV 113485b5cf8SAlexander von Gluck IV efi_status (*GetTime) (efi_time* time, efi_time_capabilities* capabilities) EFIAPI; 114485b5cf8SAlexander von Gluck IV 115485b5cf8SAlexander von Gluck IV efi_status (*SetTime) (efi_time* time) EFIAPI; 116485b5cf8SAlexander von Gluck IV 117485b5cf8SAlexander von Gluck IV efi_status (*GetWakeupTime) (bool* enabled, bool* pending, efi_time* time) EFIAPI; 118485b5cf8SAlexander von Gluck IV 119485b5cf8SAlexander von Gluck IV efi_status (*SetWakeupTime) (bool enable, efi_time* time) EFIAPI; 120485b5cf8SAlexander von Gluck IV 121485b5cf8SAlexander von Gluck IV efi_status (*SetVirtualAddressMap) (size_t memory_map_size, size_t desc_size, 122485b5cf8SAlexander von Gluck IV uint32_t desc_version, 123485b5cf8SAlexander von Gluck IV efi_memory_descriptor* virtual_map) EFIAPI; 124485b5cf8SAlexander von Gluck IV 125485b5cf8SAlexander von Gluck IV efi_status (*ConvertPointer) (size_t debug_disposition, void** addr) EFIAPI; 126485b5cf8SAlexander von Gluck IV 127485b5cf8SAlexander von Gluck IV efi_status (*GetVariable) (char16_t* var_name, efi_guid* vendor_guid, 128485b5cf8SAlexander von Gluck IV uint32_t* attributes, size_t* data_size, void* data) EFIAPI; 129485b5cf8SAlexander von Gluck IV 130485b5cf8SAlexander von Gluck IV efi_status (*GetNextVariableName) (size_t* var_name_size, char16_t* var_name, 131485b5cf8SAlexander von Gluck IV efi_guid* vendor_guid) EFIAPI; 132485b5cf8SAlexander von Gluck IV 133485b5cf8SAlexander von Gluck IV efi_status (*SetVariable) (char16_t* var_name, efi_guid* vendor_guid, 134485b5cf8SAlexander von Gluck IV uint32_t attributes, size_t data_size, void* data) EFIAPI; 135485b5cf8SAlexander von Gluck IV 136485b5cf8SAlexander von Gluck IV efi_status (*GetNextHighMonotonicCount) (uint32_t* high_count) EFIAPI; 137485b5cf8SAlexander von Gluck IV 138485b5cf8SAlexander von Gluck IV efi_status (*ResetSystem) (efi_reset_type reset_type, efi_status reset_status, 139485b5cf8SAlexander von Gluck IV size_t data_size, void* reset_data) EFIAPI; 140485b5cf8SAlexander von Gluck IV 141485b5cf8SAlexander von Gluck IV efi_status (*UpdateCapsule) (efi_capsule_header** capsule_header_array, 142485b5cf8SAlexander von Gluck IV size_t capsule_count, 143485b5cf8SAlexander von Gluck IV efi_physical_addr scatter_gather_list) EFIAPI; 144485b5cf8SAlexander von Gluck IV 145485b5cf8SAlexander von Gluck IV efi_status (*QueryCapsuleCapabilities) (efi_capsule_header** capsule_header_array, 146485b5cf8SAlexander von Gluck IV size_t capsule_count, 147485b5cf8SAlexander von Gluck IV uint64_t* max_capsule_size, 148485b5cf8SAlexander von Gluck IV efi_reset_type* reset_type) EFIAPI; 149485b5cf8SAlexander von Gluck IV 150485b5cf8SAlexander von Gluck IV efi_status (*QueryVariableInfo) (uint32_t attributes, 151485b5cf8SAlexander von Gluck IV uint64_t* max_var_storage_size, 152485b5cf8SAlexander von Gluck IV uint64_t* remaining_var_storage_size, 153485b5cf8SAlexander von Gluck IV uint64_t* max_var_size) EFIAPI; 154485b5cf8SAlexander von Gluck IV } efi_runtime_services; 155