1503478afSKyle Evans.\"- 24d846d26SWarner Losh.\" SPDX-License-Identifier: BSD-2-Clause 3503478afSKyle Evans.\" 4503478afSKyle Evans.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org> 5503478afSKyle Evans.\" 6503478afSKyle Evans.\" Redistribution and use in source and binary forms, with or without 7503478afSKyle Evans.\" modification, are permitted provided that the following conditions 8503478afSKyle Evans.\" are met: 9503478afSKyle Evans.\" 1. Redistributions of source code must retain the above copyright 10503478afSKyle Evans.\" notice, this list of conditions and the following disclaimer. 11503478afSKyle Evans.\" 2. Redistributions in binary form must reproduce the above copyright 12503478afSKyle Evans.\" notice, this list of conditions and the following disclaimer in the 13503478afSKyle Evans.\" documentation and/or other materials provided with the distribution. 14503478afSKyle Evans.\" 15503478afSKyle Evans.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16503478afSKyle Evans.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17503478afSKyle Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18503478afSKyle Evans.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19503478afSKyle Evans.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20503478afSKyle Evans.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21503478afSKyle Evans.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22503478afSKyle Evans.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23503478afSKyle Evans.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24503478afSKyle Evans.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25503478afSKyle Evans.\" SUCH DAMAGE. 26503478afSKyle Evans.\" 27d12d651fSPavel Balaev.Dd June 18, 2021 28503478afSKyle Evans.Dt EFIDEV 4 29503478afSKyle Evans.Os 30503478afSKyle Evans.Sh NAME 31503478afSKyle Evans.Nm efidev , 32503478afSKyle Evans.Nm efirtc 33503478afSKyle Evans.Nd user-mode access to UEFI runtime services 34503478afSKyle Evans.Sh SYNOPSIS 35503478afSKyle EvansTo compile this driver into the kernel, place the following lines in your 36503478afSKyle Evanskernel configuration file: 37*c013ca2cSGraham Percival.Bd -ragged -offset indent 38503478afSKyle Evans.Cd "options EFIRT" 39503478afSKyle Evans.Ed 40503478afSKyle Evans.Pp 41503478afSKyle EvansAlternatively, to load the driver as a module at boot time, place the following 42503478afSKyle Evansline in 43503478afSKyle Evans.Xr loader.conf 5 : 44503478afSKyle Evans.Bd -literal -offset indent 45503478afSKyle Evansefirt_load="YES" 46503478afSKyle Evans.Ed 47503478afSKyle Evans.Pp 482f4146c5SMateusz PiotrowskiThe driver may be disabled by setting the 49503478afSKyle Evans.Xr loader 8 50503478afSKyle Evanstunable 51503478afSKyle Evans.Va efi.rt.disabled 522f4146c5SMateusz Piotrowskito 532f4146c5SMateusz Piotrowski.Dq Li 1 . 54503478afSKyle Evans.Sh DESCRIPTION 55503478afSKyle EvansThe 56503478afSKyle Evans.Nm 57503478afSKyle Evansdevice provides user-mode access to UEFI runtime services. 58503478afSKyle Evans.Nm 59503478afSKyle Evansalso includes a driver to provide a time-of-day clock using the UEFI 60503478afSKyle Evansreal time clock (RTC). 61503478afSKyle EvansHowever, the RTC may not always be available, based on the UEFI firmware. 62503478afSKyle EvansIf the RTC is not available, it will not be registered as a time-of-day clock 63503478afSKyle Evansand the time related ioctls below will not be functional. 64503478afSKyle Evans.Pp 65503478afSKyle Evans.Nm 66503478afSKyle Evansprovides the following ioctls defined in 67503478afSKyle Evans.In sys/efiio.h 68503478afSKyle Evanswith supplemental structures and constants defined in 69503478afSKyle Evans.In sys/efi.h : 702f4146c5SMateusz Piotrowski.Bl -tag -width indent 71503478afSKyle Evans.It Dv EFIIOC_GET_TABLE Pq Vt "struct efi_get_table_ioc" 72d12d651fSPavel BalaevCopy the UEFI table specified by the 73d12d651fSPavel Balaev.Va uuid 74d12d651fSPavel Balaevfield of the 75d12d651fSPavel Balaev.Vt struct efi_get_table_ioc 76d12d651fSPavel Balaevinto the 77d12d651fSPavel Balaev.Va buf 78d12d651fSPavel Balaevfield. 79d12d651fSPavel BalaevThe memory size for the buf field can be queried by passing 80d12d651fSPavel Balaev.Dv NULL 81d12d651fSPavel Balaevpointer as a buf value. 82d12d651fSPavel BalaevThe required size will be stored in the 83d12d651fSPavel Balaev.Va table_len 84d12d651fSPavel Balaevfield. 85d12d651fSPavel BalaevThe size of the allocated memory must be specified in the 86d12d651fSPavel Balaev.Va buf_len 87d12d651fSPavel Balaevfield. 882f4146c5SMateusz Piotrowski.Bd -literal -offset indent 89503478afSKyle Evansstruct efi_get_table_ioc { 90d12d651fSPavel Balaev void *buf; 91503478afSKyle Evans struct uuid uuid; 92d12d651fSPavel Balaev size_t table_len; 93d12d651fSPavel Balaev size_t buf_len; 94503478afSKyle Evans}; 95503478afSKyle Evans.Ed 96503478afSKyle Evans.It Dv EFIIOC_GET_TIME Pq Vt "struct efi_tm" 97503478afSKyle EvansGet the time from the RTC, if the RTC is available. 98503478afSKyle EvansThe 99503478afSKyle Evans.Vt struct efi_tm 100503478afSKyle Evanspassed is populated with the current time, unless an error occurs. 1012f4146c5SMateusz Piotrowski.Bd -literal -offset indent 102503478afSKyle Evansstruct efi_tm { 103503478afSKyle Evans uint16_t tm_year; 104503478afSKyle Evans uint8_t tm_mon 105503478afSKyle Evans uint8_t tm_mday 106503478afSKyle Evans uint8_t tm_hour; 107503478afSKyle Evans uint8_t tm_min; 108503478afSKyle Evans uint8_t tm_sec; 109503478afSKyle Evans uint8_t __pad1; 110503478afSKyle Evans uint32_t tm_nsec; 111503478afSKyle Evans int16_t tm_tz; 112503478afSKyle Evans uint8_t tm_dst; 113503478afSKyle Evans uint8_t __pad2; 114503478afSKyle Evans}; 115503478afSKyle Evans.Ed 116503478afSKyle Evans.It Dv EFIIOC_SET_TIME Pq Vt "struct efi_tm" 117503478afSKyle EvansSets the time stored by the RTC, if the RTC is available. 118503478afSKyle Evans.It Dv EFIIOC_VAR_GET Pq Vt "struct efi_var_ioc" 119503478afSKyle EvansGets data from the variable described by the vendor and name fields of the 120503478afSKyle Evans.Vt struct efi_var_ioc 1212f4146c5SMateusz Piotrowskiinto the 1222f4146c5SMateusz Piotrowski.Fa data 1232f4146c5SMateusz Piotrowskifield. 124503478afSKyle Evans.Dv EFIIOC_VAR_GET Pq Vt "struct efi_var_ioc" 1252f4146c5SMateusz Piotrowskiwill also populate the 1262f4146c5SMateusz Piotrowski.Fa attrib 1272f4146c5SMateusz Piotrowskifield. 128503478afSKyle Evans.Bd -literal 129503478afSKyle Evansstruct efi_var_ioc { 130503478afSKyle Evans efi_char *name; 131503478afSKyle Evans size_t namesize; 132503478afSKyle Evans struct uuid vendor; 133503478afSKyle Evans uint32_t attrib; 134503478afSKyle Evans void *data; 135503478afSKyle Evans size_t datasize; 136503478afSKyle Evans}; 137503478afSKyle Evans.Ed 138503478afSKyle Evans.It Dv EFIIOC_VAR_NEXT Pq Vt "struct efi_var_ioc" 139503478afSKyle EvansUsed for enumerating all UEFI variables. 140503478afSKyle EvansThe initial call should use an empty string for the name attribute. 141503478afSKyle EvansSubsequent calls should supply the vendor uuid and name of the last variable 142503478afSKyle Evansreturned. 143503478afSKyle Evans.It Dv EFIIOC_VAR_SET Pq Vt "struct efi_var_ioc" 144503478afSKyle EvansSets data and attributes for the variable described by the name and vendor in 145503478afSKyle Evansthe 146503478afSKyle Evans.Vt struct efi_var_ioc . 147503478afSKyle Evans.El 148503478afSKyle Evans.Sh FILES 149503478afSKyle Evans.Bl -tag -width /dev/efi 150503478afSKyle Evans.It Pa /dev/efi 151503478afSKyle Evans.El 152503478afSKyle Evans.Sh SEE ALSO 1532f4146c5SMateusz Piotrowski.Xr efivar 3 , 154503478afSKyle Evans.Xr efirt 9 155503478afSKyle Evans.Sh HISTORY 156503478afSKyle EvansA 157503478afSKyle Evans.Nm 158503478afSKyle Evansdevice first appeared in 159503478afSKyle Evans.Fx 11.1 . 1602f4146c5SMateusz Piotrowski.Sh BUGS 1612f4146c5SMateusz Piotrowski.Nm 1622f4146c5SMateusz Piotrowskiis currently only available on amd64 and arm64. 163