xref: /freebsd/share/man/man4/efidev.4 (revision d5b0e70f7e04d971691517ce1304d86a1e367e2e)
1.\"-
2.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3.\"
4.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
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.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
29.Dd June 18, 2021
30.Dt EFIDEV 4
31.Os
32.Sh NAME
33.Nm efidev ,
34.Nm efirtc
35.Nd user-mode access to UEFI runtime services
36.Sh SYNOPSIS
37To compile this driver into the kernel, place the following lines in your
38kernel configuration file:
39.Bd -ragged -offset -indent
40.Cd "options EFIRT"
41.Ed
42.Pp
43Alternatively, to load the driver as a module at boot time, place the following
44line in
45.Xr loader.conf 5 :
46.Bd -literal -offset indent
47efirt_load="YES"
48.Ed
49.Pp
50The driver may be disabled by setting the
51.Xr loader 8
52tunable
53.Va efi.rt.disabled
54to
55.Dq Li 1 .
56.Sh DESCRIPTION
57The
58.Nm
59device provides user-mode access to UEFI runtime services.
60.Nm
61also includes a driver to provide a time-of-day clock using the UEFI
62real time clock (RTC).
63However, the RTC may not always be available, based on the UEFI firmware.
64If the RTC is not available, it will not be registered as a time-of-day clock
65and the time related ioctls below will not be functional.
66.Pp
67.Nm
68provides the following ioctls defined in
69.In sys/efiio.h
70with supplemental structures and constants defined in
71.In sys/efi.h :
72.Bl -tag -width indent
73.It Dv EFIIOC_GET_TABLE Pq Vt "struct efi_get_table_ioc"
74Copy the UEFI table specified by the
75.Va uuid
76field of the
77.Vt struct efi_get_table_ioc
78into the
79.Va buf
80field.
81The memory size for the buf field can be queried by passing
82.Dv NULL
83pointer as a buf value.
84The required size will be stored in the
85.Va table_len
86field.
87The size of the allocated memory must be specified in the
88.Va buf_len
89field.
90.Bd -literal -offset indent
91struct efi_get_table_ioc {
92	void *buf;
93	struct uuid uuid;
94	size_t table_len;
95	size_t buf_len;
96};
97.Ed
98.It Dv EFIIOC_GET_TIME Pq Vt "struct efi_tm"
99Get the time from the RTC, if the RTC is available.
100The
101.Vt struct efi_tm
102passed is populated with the current time, unless an error occurs.
103.Bd -literal -offset indent
104struct efi_tm {
105	uint16_t	tm_year;
106	uint8_t		tm_mon
107	uint8_t		tm_mday
108	uint8_t		tm_hour;
109	uint8_t		tm_min;
110	uint8_t		tm_sec;
111	uint8_t		 __pad1;
112	uint32_t	tm_nsec;
113	int16_t		tm_tz;
114	uint8_t		tm_dst;
115	uint8_t		__pad2;
116};
117.Ed
118.It Dv EFIIOC_SET_TIME Pq Vt "struct efi_tm"
119Sets the time stored by the RTC, if the RTC is available.
120.It Dv EFIIOC_VAR_GET Pq Vt "struct efi_var_ioc"
121Gets data from the variable described by the vendor and name fields of the
122.Vt struct efi_var_ioc
123into the
124.Fa data
125field.
126.Dv EFIIOC_VAR_GET Pq Vt "struct efi_var_ioc"
127will also populate the
128.Fa attrib
129field.
130.Bd -literal
131struct efi_var_ioc {
132	efi_char	*name;
133	size_t		 namesize;
134	struct uuid	 vendor;
135	uint32_t	 attrib;
136	void		*data;
137	size_t		 datasize;
138};
139.Ed
140.It Dv EFIIOC_VAR_NEXT Pq Vt "struct efi_var_ioc"
141Used for enumerating all UEFI variables.
142The initial call should use an empty string for the name attribute.
143Subsequent calls should supply the vendor uuid and name of the last variable
144returned.
145.It Dv EFIIOC_VAR_SET Pq Vt "struct efi_var_ioc"
146Sets data and attributes for the variable described by the name and vendor in
147the
148.Vt struct efi_var_ioc .
149.El
150.Sh FILES
151.Bl -tag -width /dev/efi
152.It Pa /dev/efi
153.El
154.Sh SEE ALSO
155.Xr efivar 3 ,
156.Xr efirt 9
157.Sh HISTORY
158A
159.Nm
160device first appeared in
161.Fx 11.1 .
162.Sh BUGS
163.Nm
164is currently only available on amd64 and arm64.
165