1*503478afSKyle Evans.\"- 2*503478afSKyle Evans.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*503478afSKyle Evans.\" 4*503478afSKyle Evans.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org> 5*503478afSKyle Evans.\" 6*503478afSKyle Evans.\" Redistribution and use in source and binary forms, with or without 7*503478afSKyle Evans.\" modification, are permitted provided that the following conditions 8*503478afSKyle Evans.\" are met: 9*503478afSKyle Evans.\" 1. Redistributions of source code must retain the above copyright 10*503478afSKyle Evans.\" notice, this list of conditions and the following disclaimer. 11*503478afSKyle Evans.\" 2. Redistributions in binary form must reproduce the above copyright 12*503478afSKyle Evans.\" notice, this list of conditions and the following disclaimer in the 13*503478afSKyle Evans.\" documentation and/or other materials provided with the distribution. 14*503478afSKyle Evans.\" 15*503478afSKyle Evans.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16*503478afSKyle Evans.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17*503478afSKyle Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18*503478afSKyle Evans.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19*503478afSKyle Evans.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20*503478afSKyle Evans.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21*503478afSKyle Evans.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22*503478afSKyle Evans.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23*503478afSKyle Evans.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24*503478afSKyle Evans.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25*503478afSKyle Evans.\" SUCH DAMAGE. 26*503478afSKyle Evans.\" 27*503478afSKyle Evans.\" $FreeBSD$ 28*503478afSKyle Evans.\" 29*503478afSKyle Evans.Dd August 12, 2018 30*503478afSKyle Evans.Dt EFIRT 9 31*503478afSKyle Evans.Os 32*503478afSKyle Evans.Sh NAME 33*503478afSKyle Evans.Nm efirt , 34*503478afSKyle Evans.Nm efi_rt_ok , 35*503478afSKyle Evans.Nm efi_get_table , 36*503478afSKyle Evans.Nm efi_get_time , 37*503478afSKyle Evans.Nm efi_get_time_capabilities , 38*503478afSKyle Evans.Nm efi_reset_system , 39*503478afSKyle Evans.Nm efi_set_time , 40*503478afSKyle Evans.Nm efi_var_get , 41*503478afSKyle Evans.Nm efi_var_nextname , 42*503478afSKyle Evans.Nm efi_var_set 43*503478afSKyle Evans.Nd kernel access to UEFI runtime services 44*503478afSKyle Evans.Sh SYNOPSIS 45*503478afSKyle Evans.Cd "options EFIRT" 46*503478afSKyle Evans.Pp 47*503478afSKyle Evans.In sys/efi.h 48*503478afSKyle Evans.Ft int 49*503478afSKyle Evans.Fn efi_rt_ok "void" 50*503478afSKyle Evans.Ft int 51*503478afSKyle Evans.Fn efi_get_table "struct uuid *uuid" "void **ptr" 52*503478afSKyle Evans.Ft int 53*503478afSKyle Evans.Fn efi_get_time "struct efi_tm *tm" 54*503478afSKyle Evans.Ft int 55*503478afSKyle Evans.Fn efi_get_time_capabilities "struct efi_tmcap *tmcap" 56*503478afSKyle Evans.Ft int 57*503478afSKyle Evans.Fn efi_reset_system "void" 58*503478afSKyle Evans.Ft int 59*503478afSKyle Evans.Fn efi_set_time "struct efi_tm *tm" 60*503478afSKyle Evans.Ft int 61*503478afSKyle Evans.Fn efi_var_get "uint16_t *name" "struct uuid *vendor" "uint32_t *attrib" \ 62*503478afSKyle Evans "size_t *datasize" "void *data" 63*503478afSKyle Evans.Ft int 64*503478afSKyle Evans.Fn efi_var_nextname "size_t *namesize" "uint16_t *name" "struct uuid *vendor" 65*503478afSKyle Evans.Ft int 66*503478afSKyle Evans.Fn efi_var_set "uint16_t *name" "struct uuid *vendor" "uint32_t *attrib" \ 67*503478afSKyle Evans "size_t *datasize" "void *data" 68*503478afSKyle Evans.Sh DESCRIPTION 69*503478afSKyle EvansAll of the following calls will return 70*503478afSKyle Evans.Dv ENXIO 71*503478afSKyle Evansif UEFI runtime services are not available. 72*503478afSKyle Evans.Nm 73*503478afSKyle Evansis currently only available on amd64 and arm64. 74*503478afSKyle Evans.Pp 75*503478afSKyle EvansThe 76*503478afSKyle Evans.Fn efi_rt_ok 77*503478afSKyle EvansReturns 0 if UEFI runtime services are present and functional, or 78*503478afSKyle Evans.Dv ENXIO 79*503478afSKyle Evansif not. 80*503478afSKyle Evans.Pp 81*503478afSKyle EvansThe 82*503478afSKyle Evans.Fn efi_get_table 83*503478afSKyle Evansfunction gets a table by uuid from the UEFI system table. 84*503478afSKyle EvansReturns 0 if the table was found and populates *ptr with the address. 85*503478afSKyle EvansReturns 86*503478afSKyle Evans.Dv ENXIO 87*503478afSKyle Evansif the configuration table or system table are unset. 88*503478afSKyle EvansReturns 89*503478afSKyle Evans.Dv ENOENT 90*503478afSKyle Evansif the requested table cannot be found. 91*503478afSKyle Evans.Pp 92*503478afSKyle EvansThe 93*503478afSKyle Evans.Fn efi_get_time 94*503478afSKyle Evansfunction gets the current time from the RTC, if available. 95*503478afSKyle EvansReturns 0 and populates the 96*503478afSKyle Evans.Vt struct efi_tm 97*503478afSKyle Evanson success. 98*503478afSKyle EvansReturns 99*503478afSKyle Evans.Dv EINVAL 100*503478afSKyle Evansif the 101*503478afSKyle Evans.Vt struct efi_tm 102*503478afSKyle Evansis 103*503478afSKyle Evans.Dv NULL , 104*503478afSKyle Evansor 105*503478afSKyle Evans.Dv EIO 106*503478afSKyle Evansif the time could not be retrieved due to a hardware error. 107*503478afSKyle Evans.Pp 108*503478afSKyle EvansThe 109*503478afSKyle Evans.Fn efi_get_time_capabilities 110*503478afSKyle Evansfunction gets the capabilities from the RTC. 111*503478afSKyle EvansReturns 0 and populates the 112*503478afSKyle Evans.Vt struct efi_tmcap 113*503478afSKyle Evanson success. 114*503478afSKyle EvansReturns 115*503478afSKyle Evans.Dv EINVAL 116*503478afSKyle Evansif the 117*503478afSKyle Evans.Vt struct efi_tm 118*503478afSKyle Evansis 119*503478afSKyle Evans.Dv NULL , 120*503478afSKyle Evansor 121*503478afSKyle Evans.Dv EIO 122*503478afSKyle Evansif the time could not be retrieved due to a hardware error. 123*503478afSKyle Evans.Pp 124*503478afSKyle EvansThe 125*503478afSKyle Evans.Fn efi_reset_system 126*503478afSKyle Evansfunction requests a warm reset and reboot of the system. 127*503478afSKyle Evans.Pp 128*503478afSKyle EvansThe 129*503478afSKyle Evans.Fn efi_set_time 130*503478afSKyle Evansfunction sets the time on the RTC to the time described by the 131*503478afSKyle Evans.Vt struct efi_tm 132*503478afSKyle Evanspassed in. 133*503478afSKyle EvansReturns 0 on success, 134*503478afSKyle Evans.Dv EINVAL 135*503478afSKyle Evansif a time field is out of range, or 136*503478afSKyle Evans.Dv EIO 137*503478afSKyle Evansif the time could not be set due to a hardware error. 138*503478afSKyle Evans.Pp 139*503478afSKyle EvansThe 140*503478afSKyle Evans.Fn efi_var_get 141*503478afSKyle Evansfunction fetches the variable identified by 142*503478afSKyle Evans.Fa vendor 143*503478afSKyle Evansand 144*503478afSKyle Evans.Fa name . 145*503478afSKyle EvansReturns 0 and populates 146*503478afSKyle Evans.Fa attrib , 147*503478afSKyle Evans.Fa datasize , 148*503478afSKyle Evansand 149*503478afSKyle Evans.Fa data 150*503478afSKyle Evanson success. 151*503478afSKyle EvansOtherwise, one of the following errors are returned: 152*503478afSKyle Evans.Bl -tag -width ".Dv EOVERFLOW" 153*503478afSKyle Evans.It Dv ENOENT 154*503478afSKyle EvansThe variable was not found. 155*503478afSKyle Evans.It Dv EOVERFLOW 156*503478afSKyle Evans.Fa datasize 157*503478afSKyle Evansis not sufficient to hold the variable data. 158*503478afSKyle Evans.Fa namesize 159*503478afSKyle Evansis updated to reflect the size needed to complete the request. 160*503478afSKyle Evans.It Dv EINVAL 161*503478afSKyle EvansOne of 162*503478afSKyle Evans.Fa name , 163*503478afSKyle Evans.Fa vendor , 164*503478afSKyle Evansor 165*503478afSKyle Evans.Fa datasize 166*503478afSKyle Evansare NULL. 167*503478afSKyle EvansAlternatively, 168*503478afSKyle Evans.Fa datasize 169*503478afSKyle Evansis large enough to hold the response but 170*503478afSKyle Evans.Fa data 171*503478afSKyle Evansis NULL. 172*503478afSKyle Evans.It Dv EIO 173*503478afSKyle EvansThe variable could not be retrieved due to a hardware error. 174*503478afSKyle Evans.It Dv EDOOFUS 175*503478afSKyle EvansThe variable could not be retireved due to an authentication failure. 176*503478afSKyle Evans.El 177*503478afSKyle Evans.Pp 178*503478afSKyle EvansThe 179*503478afSKyle Evans.Fn efi_var_nextname 180*503478afSKyle Evansfunction is used for enumeration of variables. 181*503478afSKyle EvansOn the initial call to 182*503478afSKyle Evans.Fn efi_var_nextname , 183*503478afSKyle Evans.Fa name 184*503478afSKyle Evansshould be an empty string. 185*503478afSKyle EvansSubsequent calls should pass in the last 186*503478afSKyle Evans.Fa name 187*503478afSKyle Evansand 188*503478afSKyle Evans.Fa vendor 189*503478afSKyle Evansreturned until 190*503478afSKyle Evans.Dv ENOENT 191*503478afSKyle Evansis returned. 192*503478afSKyle EvansReturns 0 and populates 193*503478afSKyle Evans.Fa namesize , 194*503478afSKyle Evans.Fa name , 195*503478afSKyle Evansand 196*503478afSKyle Evans.Fa vendor 197*503478afSKyle Evanswith the next variable's data. 198*503478afSKyle EvansOtherwise, returns one of the following errors: 199*503478afSKyle Evans.Bl -tag -width ".Dv EOVERFLOW" 200*503478afSKyle Evans.It Dv ENOENT 201*503478afSKyle EvansThe next variable was not found. 202*503478afSKyle Evans.It Dv EOVERFLOW 203*503478afSKyle Evans.Fa datasize 204*503478afSKyle Evansis not sufficient to hold the variable data. 205*503478afSKyle Evans.Fa namesize 206*503478afSKyle Evansis updated to reflect the size needed to complete the request. 207*503478afSKyle Evans.It Dv EINVAL 208*503478afSKyle EvansOne of 209*503478afSKyle Evans.Fa name , 210*503478afSKyle Evans.Fa vendor , 211*503478afSKyle Evansor 212*503478afSKyle Evans.Fa datasize 213*503478afSKyle Evansare NULL. 214*503478afSKyle Evans.It Dv EIO 215*503478afSKyle EvansThe variable could not be retrieved due to a hardware error. 216*503478afSKyle Evans.El 217*503478afSKyle Evans.Pp 218*503478afSKyle EvansThe 219*503478afSKyle Evans.Fn efi_var_set 220*503478afSKyle Evansfunction sets the variable described by 221*503478afSKyle Evans.Fa name 222*503478afSKyle Evansand 223*503478afSKyle Evans.Fa vendor . 224*503478afSKyle EvansReturns 0 if the variable has been successfully. 225*503478afSKyle EvansOtherwise, returns one of the following errors: 226*503478afSKyle Evans.Bl -tag -width ".Dv EOVERFLOW" 227*503478afSKyle Evans.It Dv EINVAL 228*503478afSKyle EvansEither 229*503478afSKyle Evans.Fa attrib 230*503478afSKyle Evanswas an invalid combination of attributes, 231*503478afSKyle Evans.Fa datasize 232*503478afSKyle Evansexceeds the maximum allowed size, or 233*503478afSKyle Evans.Fa name 234*503478afSKyle Evansis an empty Unicode stirng. 235*503478afSKyle Evans.It Dv EAGAIN 236*503478afSKyle EvansNot enough storage is available to hold the variable and its data. 237*503478afSKyle Evans.It Dv EIO 238*503478afSKyle EvansThe variable could not be saved due to a hardware error. 239*503478afSKyle Evans.It Dv EROFS 240*503478afSKyle EvansThe variable in question is read-only or may not be deleted. 241*503478afSKyle Evans.It Dv EDOOFUS 242*503478afSKyle EvansThe varialbe could not be set due to an authentication failure. 243*503478afSKyle Evans.It Dv ENOENT 244*503478afSKyle EvansThe variable trying to be updated or deleted was not found. 245*503478afSKyle Evans.El 246*503478afSKyle Evans.Sh SEE ALSO 247*503478afSKyle Evans.Xr efidev 4 248*503478afSKyle Evans.Sh AUTHORS 249*503478afSKyle EvansThis manual page was written by 250*503478afSKyle Evans.An Kyle Evans Aq Mt kevans@FreeBSD.org . 251