EFI Variables

Ganael Laplanche ganael.laplanche at corp.ovh.com
Wed Oct 28 06:34:05 UTC 2015


On Tuesday, October 27, 2015 07:24:23 PM Emmanuel Vadot wrote:

Hi Emmanuel,

>   I'm currently hacking around the loader.efi

Great :)

>   I've also added the list and get command to the not working "nvram"
> command.

I had myself posted a PR to fix that command as well as add a verbose switch 
and the ability to specify a variable name, see :

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202614

>   For the "set" subcommand I think that the best way to handle it is :
>   "nvram set myvar data" -> This will set the variable myvar to data with
> the freebsd guid (if there is any)
> 
>   and
> 
>   "nvram set myvar guid data" -> This will force the guid to <guid>

It can be useful to set variables containing *strings*, but will hardly handle 
binary stuff :/

I am not sure whether it should be the loader's job to set variables... I can 
think of changing the boot order, but it may be difficult to get it right by 
hand and would probably require an upper-level tool, such as efibootmgr on 
Linux.

>   I'll look tomorrow how to access efivars once the kernel is booted so
> we can set some from some userland tool (especially the boot related
> one).

Yes, this is interesting as the current kernel (amd64) does not provide access 
to EFI variables at all.

10.x/ia64 provided access to EFI variables through libefi(3) and io(4). It 
should be possible to import that code to other archs too, but you'll have to 
save the entry point to the Runtime Services Tables and maybe set a Virtual 
Address Map too (not sure about that point).

Best regards,

-- 
Ganaël LAPLANCHE <ganael.laplanche at corp.ovh.com>


More information about the freebsd-hackers mailing list