1d49a5dddSWarner Losh /*- 2d49a5dddSWarner Losh * Copyright (c) 2016 Netflix, Inc. 3d49a5dddSWarner Losh * All rights reserved. 4d49a5dddSWarner Losh * 5d49a5dddSWarner Losh * Redistribution and use in source and binary forms, with or without 6d49a5dddSWarner Losh * modification, are permitted provided that the following conditions 7d49a5dddSWarner Losh * are met: 8d49a5dddSWarner Losh * 1. Redistributions of source code must retain the above copyright 9*6decf2ccSEd Maste * notice, this list of conditions and the following disclaimer. 10d49a5dddSWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 11d49a5dddSWarner Losh * notice, this list of conditions and the following disclaimer in the 12d49a5dddSWarner Losh * documentation and/or other materials provided with the distribution. 13d49a5dddSWarner Losh * 14*6decf2ccSEd Maste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*6decf2ccSEd Maste * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*6decf2ccSEd Maste * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*6decf2ccSEd Maste * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*6decf2ccSEd Maste * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*6decf2ccSEd Maste * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*6decf2ccSEd Maste * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*6decf2ccSEd Maste * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*6decf2ccSEd Maste * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*6decf2ccSEd Maste * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*6decf2ccSEd Maste * SUCH DAMAGE. 25d49a5dddSWarner Losh * 26d49a5dddSWarner Losh * $FreeBSD$ 27d49a5dddSWarner Losh */ 28d49a5dddSWarner Losh 29d49a5dddSWarner Losh #ifndef _EFIVAR_H_ 30d49a5dddSWarner Losh #define _EFIVAR_H_ 31d49a5dddSWarner Losh 32d49a5dddSWarner Losh #include <uuid.h> 33d49a5dddSWarner Losh #include <sys/efi.h> 34d49a5dddSWarner Losh #include <sys/endian.h> 35d49a5dddSWarner Losh #include <stdint.h> 36d49a5dddSWarner Losh 37d49a5dddSWarner Losh /* Shoud these be elsewhere ? */ 38d49a5dddSWarner Losh #define EFI_VARIABLE_NON_VOLATILE 0x00000001 39d49a5dddSWarner Losh #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 40d49a5dddSWarner Losh #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 41d49a5dddSWarner Losh #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 42d49a5dddSWarner Losh #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 43d49a5dddSWarner Losh #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS \ 44d49a5dddSWarner Losh 0x00000020 45d49a5dddSWarner Losh #define EFI_VARIABLE_APPEND_WRITE 0x00000040 46d49a5dddSWarner Losh #if 0 /* todo */ 47d49a5dddSWarner Losh #define EFI_VARIABLE_HAS_AUTH_HEADER 48d49a5dddSWarner Losh #define EFI_VARIABLE_HAS_SIGNATURE 49d49a5dddSWarner Losh #endif 50d49a5dddSWarner Losh 51d49a5dddSWarner Losh 527270962aSWarner Losh #ifndef _EFIVAR_EFI_GUID_T_DEF 537270962aSWarner Losh #define _EFIVAR_EFI_GUID_T_DEF 54d49a5dddSWarner Losh typedef uuid_t efi_guid_t; 557270962aSWarner Losh #endif 567270962aSWarner Losh 57d49a5dddSWarner Losh #if BYTE_ORDER == LITTLE_ENDIAN 58d49a5dddSWarner Losh #define EFI_GUID(a, b, c, d, e0, e1, e2, e3, e4, e5) \ 59d49a5dddSWarner Losh ((efi_guid_t) {(a), (b), (c), (d) >> 8, (d) & 0xff, \ 60d49a5dddSWarner Losh { (e0), (e1), (e2), (e3), (e4), (e5) }}) 61d49a5dddSWarner Losh #else 62d49a5dddSWarner Losh #define EFI_GUID(a, b, c, d, e0, e1, e2, e3, e4, e5) \ 63d49a5dddSWarner Losh ((efi_guid_t) {(a), (b), (c), (d) & 0xff, (d) >> 8, \ 64d49a5dddSWarner Losh { (e0), (e1), (e2), (e3), (e4), (e5) }}) 65d49a5dddSWarner Losh #endif 66d49a5dddSWarner Losh 67d49a5dddSWarner Losh #define EFI_GLOBAL_GUID EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa0d, \ 68d49a5dddSWarner Losh 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c) 69d49a5dddSWarner Losh 70d49a5dddSWarner Losh int efi_append_variable(efi_guid_t guid, const char *name, 71d49a5dddSWarner Losh uint8_t *data, size_t data_size, uint32_t attributes); 72d49a5dddSWarner Losh int efi_del_variable(efi_guid_t guid, const char *name); 73d49a5dddSWarner Losh int efi_get_variable(efi_guid_t guid, const char *name, 74d49a5dddSWarner Losh uint8_t **data, size_t *data_size, uint32_t *attributes); 75d49a5dddSWarner Losh int efi_get_variable_attributes(efi_guid_t guid, const char *name, 76d49a5dddSWarner Losh uint32_t *attributes); 77d49a5dddSWarner Losh int efi_get_variable_size(efi_guid_t guid, const char *name, size_t *size); 78d49a5dddSWarner Losh int efi_get_next_variable_name(efi_guid_t **guid, char **name); 79d49a5dddSWarner Losh int efi_guid_cmp(const efi_guid_t *guid1, const efi_guid_t *guid2); 80d49a5dddSWarner Losh int efi_guid_is_zero(const efi_guid_t *guid1); 81d49a5dddSWarner Losh int efi_guid_to_name(efi_guid_t *guid, char **name); 82d49a5dddSWarner Losh int efi_guid_to_symbol(efi_guid_t *guid, char **symbol); 83d49a5dddSWarner Losh int efi_guid_to_str(const efi_guid_t *guid, char **sp); 84d49a5dddSWarner Losh int efi_name_to_guid(const char *name, efi_guid_t *guid); 85d49a5dddSWarner Losh int efi_set_variable(efi_guid_t guid, const char *name, 86831bec11SWarner Losh uint8_t *data, size_t data_size, uint32_t attributes); 87d49a5dddSWarner Losh int efi_str_to_guid(const char *s, efi_guid_t *guid); 88d49a5dddSWarner Losh int efi_variables_supported(void); 89d49a5dddSWarner Losh 90e1745513SWarner Losh /* FreeBSD extensions */ 91e1745513SWarner Losh struct uuid_table 92e1745513SWarner Losh { 93e1745513SWarner Losh const char *uuid_str; 94e1745513SWarner Losh const char *name; 95e1745513SWarner Losh efi_guid_t guid; 96e1745513SWarner Losh }; 97e1745513SWarner Losh 98e1745513SWarner Losh int efi_known_guid(struct uuid_table **); 99e1745513SWarner Losh 100d49a5dddSWarner Losh extern const efi_guid_t efi_guid_empty; 101d49a5dddSWarner Losh 102d49a5dddSWarner Losh #endif /* _EFIVAR_H_ */ 103