xref: /freebsd/share/man/man4/efidev.4 (revision d12d651f8692cfcaf6fd0a6e8264c29547f644c9)
1503478afSKyle Evans.\"-
2503478afSKyle Evans.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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.\"
27503478afSKyle Evans.\" $FreeBSD$
28503478afSKyle Evans.\"
29*d12d651fSPavel Balaev.Dd June 18, 2021
30503478afSKyle Evans.Dt EFIDEV 4
31503478afSKyle Evans.Os
32503478afSKyle Evans.Sh NAME
33503478afSKyle Evans.Nm efidev ,
34503478afSKyle Evans.Nm efirtc
35503478afSKyle Evans.Nd user-mode access to UEFI runtime services
36503478afSKyle Evans.Sh SYNOPSIS
37503478afSKyle EvansTo compile this driver into the kernel, place the following lines in your
38503478afSKyle Evanskernel configuration file:
39503478afSKyle Evans.Bd -ragged -offset -indent
40503478afSKyle Evans.Cd "options EFIRT"
41503478afSKyle Evans.Ed
42503478afSKyle Evans.Pp
43503478afSKyle EvansAlternatively, to load the driver as a module at boot time, place the following
44503478afSKyle Evansline in
45503478afSKyle Evans.Xr loader.conf 5 :
46503478afSKyle Evans.Bd -literal -offset indent
47503478afSKyle Evansefirt_load="YES"
48503478afSKyle Evans.Ed
49503478afSKyle Evans.Pp
502f4146c5SMateusz PiotrowskiThe driver may be disabled by setting the
51503478afSKyle Evans.Xr loader 8
52503478afSKyle Evanstunable
53503478afSKyle Evans.Va efi.rt.disabled
542f4146c5SMateusz Piotrowskito
552f4146c5SMateusz Piotrowski.Dq Li 1 .
56503478afSKyle Evans.Sh DESCRIPTION
57503478afSKyle EvansThe
58503478afSKyle Evans.Nm
59503478afSKyle Evansdevice provides user-mode access to UEFI runtime services.
60503478afSKyle Evans.Nm
61503478afSKyle Evansalso includes a driver to provide a time-of-day clock using the UEFI
62503478afSKyle Evansreal time clock (RTC).
63503478afSKyle EvansHowever, the RTC may not always be available, based on the UEFI firmware.
64503478afSKyle EvansIf the RTC is not available, it will not be registered as a time-of-day clock
65503478afSKyle Evansand the time related ioctls below will not be functional.
66503478afSKyle Evans.Pp
67503478afSKyle Evans.Nm
68503478afSKyle Evansprovides the following ioctls defined in
69503478afSKyle Evans.In sys/efiio.h
70503478afSKyle Evanswith supplemental structures and constants defined in
71503478afSKyle Evans.In sys/efi.h :
722f4146c5SMateusz Piotrowski.Bl -tag -width indent
73503478afSKyle Evans.It Dv EFIIOC_GET_TABLE Pq Vt "struct efi_get_table_ioc"
74*d12d651fSPavel BalaevCopy the UEFI table specified by the
75*d12d651fSPavel Balaev.Va uuid
76*d12d651fSPavel Balaevfield of the
77*d12d651fSPavel Balaev.Vt struct efi_get_table_ioc
78*d12d651fSPavel Balaevinto the
79*d12d651fSPavel Balaev.Va buf
80*d12d651fSPavel Balaevfield.
81*d12d651fSPavel BalaevThe memory size for the buf field can be queried by passing
82*d12d651fSPavel Balaev.Dv NULL
83*d12d651fSPavel Balaevpointer as a buf value.
84*d12d651fSPavel BalaevThe required size will be stored in the
85*d12d651fSPavel Balaev.Va table_len
86*d12d651fSPavel Balaevfield.
87*d12d651fSPavel BalaevThe size of the allocated memory must be specified in the
88*d12d651fSPavel Balaev.Va buf_len
89*d12d651fSPavel Balaevfield.
902f4146c5SMateusz Piotrowski.Bd -literal -offset indent
91503478afSKyle Evansstruct efi_get_table_ioc {
92*d12d651fSPavel Balaev	void *buf;
93503478afSKyle Evans	struct uuid uuid;
94*d12d651fSPavel Balaev	size_t table_len;
95*d12d651fSPavel Balaev	size_t buf_len;
96503478afSKyle Evans};
97503478afSKyle Evans.Ed
98503478afSKyle Evans.It Dv EFIIOC_GET_TIME Pq Vt "struct efi_tm"
99503478afSKyle EvansGet the time from the RTC, if the RTC is available.
100503478afSKyle EvansThe
101503478afSKyle Evans.Vt struct efi_tm
102503478afSKyle Evanspassed is populated with the current time, unless an error occurs.
1032f4146c5SMateusz Piotrowski.Bd -literal -offset indent
104503478afSKyle Evansstruct efi_tm {
105503478afSKyle Evans	uint16_t	tm_year;
106503478afSKyle Evans	uint8_t		tm_mon
107503478afSKyle Evans	uint8_t		tm_mday
108503478afSKyle Evans	uint8_t		tm_hour;
109503478afSKyle Evans	uint8_t		tm_min;
110503478afSKyle Evans	uint8_t		tm_sec;
111503478afSKyle Evans	uint8_t		 __pad1;
112503478afSKyle Evans	uint32_t	tm_nsec;
113503478afSKyle Evans	int16_t		tm_tz;
114503478afSKyle Evans	uint8_t		tm_dst;
115503478afSKyle Evans	uint8_t		__pad2;
116503478afSKyle Evans};
117503478afSKyle Evans.Ed
118503478afSKyle Evans.It Dv EFIIOC_SET_TIME Pq Vt "struct efi_tm"
119503478afSKyle EvansSets the time stored by the RTC, if the RTC is available.
120503478afSKyle Evans.It Dv EFIIOC_VAR_GET Pq Vt "struct efi_var_ioc"
121503478afSKyle EvansGets data from the variable described by the vendor and name fields of the
122503478afSKyle Evans.Vt struct efi_var_ioc
1232f4146c5SMateusz Piotrowskiinto the
1242f4146c5SMateusz Piotrowski.Fa data
1252f4146c5SMateusz Piotrowskifield.
126503478afSKyle Evans.Dv EFIIOC_VAR_GET Pq Vt "struct efi_var_ioc"
1272f4146c5SMateusz Piotrowskiwill also populate the
1282f4146c5SMateusz Piotrowski.Fa attrib
1292f4146c5SMateusz Piotrowskifield.
130503478afSKyle Evans.Bd -literal
131503478afSKyle Evansstruct efi_var_ioc {
132503478afSKyle Evans	efi_char	*name;
133503478afSKyle Evans	size_t		 namesize;
134503478afSKyle Evans	struct uuid	 vendor;
135503478afSKyle Evans	uint32_t	 attrib;
136503478afSKyle Evans	void		*data;
137503478afSKyle Evans	size_t		 datasize;
138503478afSKyle Evans};
139503478afSKyle Evans.Ed
140503478afSKyle Evans.It Dv EFIIOC_VAR_NEXT Pq Vt "struct efi_var_ioc"
141503478afSKyle EvansUsed for enumerating all UEFI variables.
142503478afSKyle EvansThe initial call should use an empty string for the name attribute.
143503478afSKyle EvansSubsequent calls should supply the vendor uuid and name of the last variable
144503478afSKyle Evansreturned.
145503478afSKyle Evans.It Dv EFIIOC_VAR_SET Pq Vt "struct efi_var_ioc"
146503478afSKyle EvansSets data and attributes for the variable described by the name and vendor in
147503478afSKyle Evansthe
148503478afSKyle Evans.Vt struct efi_var_ioc .
149503478afSKyle Evans.El
150503478afSKyle Evans.Sh FILES
151503478afSKyle Evans.Bl -tag -width /dev/efi
152503478afSKyle Evans.It Pa /dev/efi
153503478afSKyle Evans.El
154503478afSKyle Evans.Sh SEE ALSO
1552f4146c5SMateusz Piotrowski.Xr efivar 3 ,
156503478afSKyle Evans.Xr efirt 9
157503478afSKyle Evans.Sh HISTORY
158503478afSKyle EvansA
159503478afSKyle Evans.Nm
160503478afSKyle Evansdevice first appeared in
161503478afSKyle Evans.Fx 11.1 .
1622f4146c5SMateusz Piotrowski.Sh BUGS
1632f4146c5SMateusz Piotrowski.Nm
1642f4146c5SMateusz Piotrowskiis currently only available on amd64 and arm64.
165