1 /* $OpenBSD: efiio.h,v 1.2 2024/10/22 21:50:02 jsg Exp $ */ 2 /*- 3 * Copyright (c) 2016 Netflix, Inc. 4 * Copyright (c) 2022 3mdeb <contact@3mdeb.com> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer 11 * in this position and unchanged. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef _DEV_EFI_EFIIO_H_ 29 #define _DEV_EFI_EFIIO_H_ 30 31 #include <sys/types.h> 32 #include <sys/ioccom.h> 33 #include <sys/uuid.h> 34 35 typedef uint16_t efi_char; 36 37 #define EFI_TABLE_ESRT \ 38 {0xb122a263,0x3661,0x4f68,0x99,0x29,{0x78,0xf8,0xb0,0xd6,0x21,0x80}} 39 40 struct efi_esrt_table { 41 uint32_t fw_resource_count; 42 uint32_t fw_resource_count_max; 43 uint64_t fw_resource_version; 44 #define ESRT_FIRMWARE_RESOURCE_VERSION 1 45 uint8_t entries[]; 46 }; 47 48 struct efi_esrt_entry_v1 { 49 struct uuid fw_class; 50 uint32_t fw_type; 51 uint32_t fw_version; 52 uint32_t lowest_supported_fw_version; 53 uint32_t capsule_flags; 54 uint32_t last_attempt_version; 55 uint32_t last_attempt_status; 56 }; 57 58 struct efi_get_table_ioc { 59 void *buf; /* Pointer to userspace buffer */ 60 struct uuid uuid; /* UUID to look up */ 61 size_t table_len; /* Table size */ 62 size_t buf_len; /* Size of the buffer */ 63 }; 64 65 struct efi_var_ioc { 66 uint16_t *name; /* User pointer to name, in UCS2 chars */ 67 size_t namesize; /* Number of *bytes* in the name including 68 terminator */ 69 struct uuid vendor; /* Vendor's UUID for variable */ 70 uint32_t attrib; /* Attributes */ 71 void *data; /* User pointer to value */ 72 size_t datasize; /* Number of *bytes* in the value */ 73 }; 74 75 #define EFIIOC_GET_TABLE _IOWR('E', 1, struct efi_get_table_ioc) 76 #define EFIIOC_VAR_GET _IOWR('E', 2, struct efi_var_ioc) 77 #define EFIIOC_VAR_NEXT _IOWR('E', 3, struct efi_var_ioc) 78 #define EFIIOC_VAR_SET _IOWR('E', 4, struct efi_var_ioc) 79 80 #endif /* _DEV_EFI_EFIIO_H_ */ 81