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*2fe85640SLakshman.Dd November 2, 2021 30503478afSKyle Evans.Dt EFIRT 9 31503478afSKyle Evans.Os 32503478afSKyle Evans.Sh NAME 33503478afSKyle Evans.Nm efirt , 34503478afSKyle Evans.Nm efi_rt_ok , 35503478afSKyle Evans.Nm efi_get_table , 36503478afSKyle Evans.Nm efi_get_time , 37503478afSKyle Evans.Nm efi_get_time_capabilities , 38503478afSKyle Evans.Nm efi_reset_system , 39503478afSKyle Evans.Nm efi_set_time , 40503478afSKyle Evans.Nm efi_var_get , 41503478afSKyle Evans.Nm efi_var_nextname , 42503478afSKyle Evans.Nm efi_var_set 43503478afSKyle Evans.Nd kernel access to UEFI runtime services 44503478afSKyle Evans.Sh SYNOPSIS 45503478afSKyle Evans.Cd "options EFIRT" 46503478afSKyle Evans.Pp 47503478afSKyle Evans.In sys/efi.h 48503478afSKyle Evans.Ft int 49503478afSKyle Evans.Fn efi_rt_ok "void" 50503478afSKyle Evans.Ft int 51503478afSKyle Evans.Fn efi_get_table "struct uuid *uuid" "void **ptr" 52503478afSKyle Evans.Ft int 53503478afSKyle Evans.Fn efi_get_time "struct efi_tm *tm" 54503478afSKyle Evans.Ft int 55503478afSKyle Evans.Fn efi_get_time_capabilities "struct efi_tmcap *tmcap" 56503478afSKyle Evans.Ft int 5726649bb5SConrad Meyer.Fn efi_reset_system "enum efi_reset type" 58503478afSKyle Evans.Ft int 59503478afSKyle Evans.Fn efi_set_time "struct efi_tm *tm" 60503478afSKyle Evans.Ft int 61503478afSKyle Evans.Fn efi_var_get "uint16_t *name" "struct uuid *vendor" "uint32_t *attrib" \ 62503478afSKyle Evans "size_t *datasize" "void *data" 63503478afSKyle Evans.Ft int 64503478afSKyle Evans.Fn efi_var_nextname "size_t *namesize" "uint16_t *name" "struct uuid *vendor" 65503478afSKyle Evans.Ft int 66*2fe85640SLakshman.Fn efi_var_set "uint16_t *name" "struct uuid *vendor" "uint32_t attrib" \ 67*2fe85640SLakshman "size_t datasize" "void *data" 68503478afSKyle Evans.Sh DESCRIPTION 69503478afSKyle EvansAll of the following calls will return 70503478afSKyle Evans.Dv ENXIO 71503478afSKyle Evansif UEFI runtime services are not available. 72503478afSKyle Evans.Nm 73503478afSKyle Evansis currently only available on amd64 and arm64. 74503478afSKyle Evans.Pp 75503478afSKyle EvansThe 76503478afSKyle Evans.Fn efi_rt_ok 77503478afSKyle EvansReturns 0 if UEFI runtime services are present and functional, or 78503478afSKyle Evans.Dv ENXIO 79503478afSKyle Evansif not. 80503478afSKyle Evans.Pp 81503478afSKyle EvansThe 82503478afSKyle Evans.Fn efi_get_table 83503478afSKyle Evansfunction gets a table by uuid from the UEFI system table. 84503478afSKyle EvansReturns 0 if the table was found and populates *ptr with the address. 85503478afSKyle EvansReturns 86503478afSKyle Evans.Dv ENXIO 87503478afSKyle Evansif the configuration table or system table are unset. 88503478afSKyle EvansReturns 89503478afSKyle Evans.Dv ENOENT 90503478afSKyle Evansif the requested table cannot be found. 91503478afSKyle Evans.Pp 92503478afSKyle EvansThe 93503478afSKyle Evans.Fn efi_get_time 94503478afSKyle Evansfunction gets the current time from the RTC, if available. 95503478afSKyle EvansReturns 0 and populates the 96503478afSKyle Evans.Vt struct efi_tm 97503478afSKyle Evanson success. 98503478afSKyle EvansReturns 99503478afSKyle Evans.Dv EINVAL 100503478afSKyle Evansif the 101503478afSKyle Evans.Vt struct efi_tm 102503478afSKyle Evansis 103503478afSKyle Evans.Dv NULL , 104503478afSKyle Evansor 105503478afSKyle Evans.Dv EIO 106503478afSKyle Evansif the time could not be retrieved due to a hardware error. 107503478afSKyle Evans.Pp 108503478afSKyle EvansThe 109503478afSKyle Evans.Fn efi_get_time_capabilities 110503478afSKyle Evansfunction gets the capabilities from the RTC. 111503478afSKyle EvansReturns 0 and populates the 112503478afSKyle Evans.Vt struct efi_tmcap 113503478afSKyle Evanson success. 114503478afSKyle EvansReturns 115503478afSKyle Evans.Dv EINVAL 116503478afSKyle Evansif the 117503478afSKyle Evans.Vt struct efi_tm 118503478afSKyle Evansis 119503478afSKyle Evans.Dv NULL , 120503478afSKyle Evansor 121503478afSKyle Evans.Dv EIO 122503478afSKyle Evansif the time could not be retrieved due to a hardware error. 123503478afSKyle Evans.Pp 124503478afSKyle EvansThe 125503478afSKyle Evans.Fn efi_reset_system 12626649bb5SConrad Meyerfunction requests a reset of the system. 12726649bb5SConrad MeyerThe 12826649bb5SConrad Meyer.Fa type 12926649bb5SConrad Meyerargument may be one of the 13026649bb5SConrad Meyer.Vt enum efi_reset 13126649bb5SConrad Meyervalues: 13226649bb5SConrad Meyer.Bl -tag -width ".Dv EFI_RESET_SHUTDOWN" 13326649bb5SConrad Meyer.It Dv EFI_RESET_COLD 13426649bb5SConrad MeyerPerform a cold reset of the system, and reboot. 13526649bb5SConrad Meyer.It Dv EFI_RESET_WARM 13626649bb5SConrad MeyerPerform a warm reset of the system, and reboot. 13726649bb5SConrad Meyer.It Dv EFI_RESET_SHUTDOWN 13826649bb5SConrad MeyerPower off the system. 13926649bb5SConrad Meyer.El 140503478afSKyle Evans.Pp 141503478afSKyle EvansThe 142503478afSKyle Evans.Fn efi_set_time 143503478afSKyle Evansfunction sets the time on the RTC to the time described by the 144503478afSKyle Evans.Vt struct efi_tm 145503478afSKyle Evanspassed in. 146503478afSKyle EvansReturns 0 on success, 147503478afSKyle Evans.Dv EINVAL 148503478afSKyle Evansif a time field is out of range, or 149503478afSKyle Evans.Dv EIO 150503478afSKyle Evansif the time could not be set due to a hardware error. 151503478afSKyle Evans.Pp 152503478afSKyle EvansThe 153503478afSKyle Evans.Fn efi_var_get 154503478afSKyle Evansfunction fetches the variable identified by 155503478afSKyle Evans.Fa vendor 156503478afSKyle Evansand 157503478afSKyle Evans.Fa name . 158503478afSKyle EvansReturns 0 and populates 159503478afSKyle Evans.Fa attrib , 160503478afSKyle Evans.Fa datasize , 161503478afSKyle Evansand 162503478afSKyle Evans.Fa data 163503478afSKyle Evanson success. 164503478afSKyle EvansOtherwise, one of the following errors are returned: 165503478afSKyle Evans.Bl -tag -width ".Dv EOVERFLOW" 166503478afSKyle Evans.It Dv ENOENT 167503478afSKyle EvansThe variable was not found. 168503478afSKyle Evans.It Dv EOVERFLOW 169503478afSKyle Evans.Fa datasize 170503478afSKyle Evansis not sufficient to hold the variable data. 171503478afSKyle Evans.Fa namesize 172503478afSKyle Evansis updated to reflect the size needed to complete the request. 173503478afSKyle Evans.It Dv EINVAL 174503478afSKyle EvansOne of 175503478afSKyle Evans.Fa name , 176503478afSKyle Evans.Fa vendor , 177503478afSKyle Evansor 178503478afSKyle Evans.Fa datasize 179503478afSKyle Evansare NULL. 180503478afSKyle EvansAlternatively, 181503478afSKyle Evans.Fa datasize 182503478afSKyle Evansis large enough to hold the response but 183503478afSKyle Evans.Fa data 184503478afSKyle Evansis NULL. 185503478afSKyle Evans.It Dv EIO 186503478afSKyle EvansThe variable could not be retrieved due to a hardware error. 187503478afSKyle Evans.It Dv EDOOFUS 188503478afSKyle EvansThe variable could not be retireved due to an authentication failure. 189503478afSKyle Evans.El 190503478afSKyle Evans.Pp 191503478afSKyle EvansThe 192503478afSKyle Evans.Fn efi_var_nextname 193503478afSKyle Evansfunction is used for enumeration of variables. 194503478afSKyle EvansOn the initial call to 195503478afSKyle Evans.Fn efi_var_nextname , 196503478afSKyle Evans.Fa name 197503478afSKyle Evansshould be an empty string. 198503478afSKyle EvansSubsequent calls should pass in the last 199503478afSKyle Evans.Fa name 200503478afSKyle Evansand 201503478afSKyle Evans.Fa vendor 202503478afSKyle Evansreturned until 203503478afSKyle Evans.Dv ENOENT 204503478afSKyle Evansis returned. 205503478afSKyle EvansReturns 0 and populates 206503478afSKyle Evans.Fa namesize , 207503478afSKyle Evans.Fa name , 208503478afSKyle Evansand 209503478afSKyle Evans.Fa vendor 210503478afSKyle Evanswith the next variable's data. 211503478afSKyle EvansOtherwise, returns one of the following errors: 212503478afSKyle Evans.Bl -tag -width ".Dv EOVERFLOW" 213503478afSKyle Evans.It Dv ENOENT 214503478afSKyle EvansThe next variable was not found. 215503478afSKyle Evans.It Dv EOVERFLOW 216503478afSKyle Evans.Fa datasize 217503478afSKyle Evansis not sufficient to hold the variable data. 218503478afSKyle Evans.Fa namesize 219503478afSKyle Evansis updated to reflect the size needed to complete the request. 220503478afSKyle Evans.It Dv EINVAL 221503478afSKyle EvansOne of 222503478afSKyle Evans.Fa name , 223503478afSKyle Evans.Fa vendor , 224503478afSKyle Evansor 225503478afSKyle Evans.Fa datasize 226503478afSKyle Evansare NULL. 227503478afSKyle Evans.It Dv EIO 228503478afSKyle EvansThe variable could not be retrieved due to a hardware error. 229503478afSKyle Evans.El 230503478afSKyle Evans.Pp 231503478afSKyle EvansThe 232503478afSKyle Evans.Fn efi_var_set 233503478afSKyle Evansfunction sets the variable described by 234503478afSKyle Evans.Fa name 235503478afSKyle Evansand 236503478afSKyle Evans.Fa vendor . 237503478afSKyle EvansReturns 0 if the variable has been successfully. 238503478afSKyle EvansOtherwise, returns one of the following errors: 239503478afSKyle Evans.Bl -tag -width ".Dv EOVERFLOW" 240503478afSKyle Evans.It Dv EINVAL 241503478afSKyle EvansEither 242503478afSKyle Evans.Fa attrib 243503478afSKyle Evanswas an invalid combination of attributes, 244503478afSKyle Evans.Fa datasize 245503478afSKyle Evansexceeds the maximum allowed size, or 246503478afSKyle Evans.Fa name 247503478afSKyle Evansis an empty Unicode stirng. 248503478afSKyle Evans.It Dv EAGAIN 249503478afSKyle EvansNot enough storage is available to hold the variable and its data. 250503478afSKyle Evans.It Dv EIO 251503478afSKyle EvansThe variable could not be saved due to a hardware error. 252503478afSKyle Evans.It Dv EROFS 253503478afSKyle EvansThe variable in question is read-only or may not be deleted. 254503478afSKyle Evans.It Dv EDOOFUS 25526649bb5SConrad MeyerThe variable could not be set due to an authentication failure. 256503478afSKyle Evans.It Dv ENOENT 257503478afSKyle EvansThe variable trying to be updated or deleted was not found. 258503478afSKyle Evans.El 259503478afSKyle Evans.Sh SEE ALSO 260503478afSKyle Evans.Xr efidev 4 261503478afSKyle Evans.Sh AUTHORS 262503478afSKyle EvansThis manual page was written by 263503478afSKyle Evans.An Kyle Evans Aq Mt kevans@FreeBSD.org . 264