1 /*- 2 * Copyright (c) 2016 Netflix, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer 9 * in this position and unchanged. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef _SYS_EFIIO_H_ 27 #define _SYS_EFIIO_H_ 28 29 #include <sys/ioccom.h> 30 #include <sys/uuid.h> 31 #include <sys/efi.h> 32 33 /* 34 * The EFI world chose not to use the typical uuid_t defines for its global 35 * universal identifiers. But the textual representation is the same, and we can 36 * use the uuid_* routines to parse and print them. However, all EFI interfaces 37 * for this need to be efi_guid_t so we can share code with EDK2, so the *_ioc 38 * structures in this file are converted to _ioctl structure to transition to 39 * this new requirement. This library is little used outside of FreeBSD and they 40 * will be dropped in 16. 41 */ 42 _Static_assert(sizeof(struct uuid) == sizeof(efi_guid_t), 43 "uuid_t and efi_guid_t are same bytes, but different elements"); 44 #if __FreeBSD_version < 1600000 && !defined(_KERNEL) 45 #define _WANT_EFI_IOC 46 #endif 47 48 struct efi_get_table_ioctl 49 { 50 void *buf; /* Pointer to userspace buffer */ 51 efi_guid_t guid; /* GUID to look up */ 52 size_t table_len; /* Table size */ 53 size_t buf_len; /* Size of the buffer */ 54 }; 55 56 struct efi_var_ioctl 57 { 58 efi_char *name; /* User pointer to name, in wide chars */ 59 size_t namesize; /* Number of wide characters in name */ 60 efi_guid_t vendor; /* Vendor's GUID for variable */ 61 uint32_t attrib; /* Attributes */ 62 void *data; /* User pointer to the data */ 63 size_t datasize; /* Number of *bytes* in the data */ 64 }; 65 66 struct efi_waketime_ioctl 67 { 68 struct efi_tm waketime; 69 uint8_t enabled; 70 uint8_t pending; 71 }; 72 73 #define EFIIOC_GET_TABLE _IOWR('E', 1, struct efi_get_table_ioctl) 74 #define EFIIOC_GET_TIME _IOR('E', 2, struct efi_tm) 75 #define EFIIOC_SET_TIME _IOW('E', 3, struct efi_tm) 76 #define EFIIOC_VAR_GET _IOWR('E', 4, struct efi_var_ioctl) 77 #define EFIIOC_VAR_NEXT _IOWR('E', 5, struct efi_var_ioctl) 78 #define EFIIOC_VAR_SET _IOWR('E', 6, struct efi_var_ioctl) 79 #define EFIIOC_GET_WAKETIME _IOR('E', 7, struct efi_waketime_ioctl) 80 #define EFIIOC_SET_WAKETIME _IOW('E', 8, struct efi_waketime_ioctl) 81 82 #ifdef _WANT_EFI_IOC 83 struct efi_get_table_ioc 84 { 85 void *buf; /* Pointer to userspace buffer */ 86 struct uuid uuid; /* GUID to look up */ 87 size_t table_len; /* Table size */ 88 size_t buf_len; /* Size of the buffer */ 89 }; 90 91 struct efi_var_ioc 92 { 93 efi_char *name; /* User pointer to name, in wide chars */ 94 size_t namesize; /* Number of wide characters in name */ 95 struct uuid vendor; /* Vendor's GUID for variable */ 96 uint32_t attrib; /* Attributes */ 97 void *data; /* User pointer to the data */ 98 size_t datasize; /* Number of *bytes* in the data */ 99 }; 100 101 _Static_assert(sizeof(struct efi_get_table_ioc) == sizeof(struct efi_get_table_ioctl), 102 "Old and new struct table defines must be the same size"); 103 _Static_assert(sizeof(struct efi_var_ioc) == sizeof(struct efi_var_ioctl), 104 "Old and new struct var defines must be the same size"); 105 #define efi_waketime_ioc efi_waketime_ioctl 106 #endif 107 108 #endif /* _SYS_EFIIO_H_ */ 109