[U-Boot] [PATCH v3 1/7] env: save UEFI non-volatile variables in dedicated storage
AKASHI Takahiro
takahiro.akashi at linaro.org
Wed Jun 12 05:23:50 UTC 2019
Ilias,
On Tue, Jun 11, 2019 at 01:59:52PM +0300, Ilias Apalodimas wrote:
> Hi Akashi-san
>
> Thanks for doing this!
>
> [...]
> > + return 0;
> > +}
> > +
> > +int env_efi_save(void)
> > +{
> > +#ifdef CONFIG_ENV_IS_NOWHERE
> One of the 'features' we discussed is the ability to have CONFIG_ENV_IS_NOWHERE
> set (not allowing users to change the U-Boot ENV) and still be able to store
> UEFI variables. Doesn't this ifdef prevent that from happening?
Yeah, I don't forget this requirement, but it is not yet agreed that
"driver" framework be shared between U-Boot environment and
UEFI variables. As you can see, env/fat.c has some duplicated code
in my current implementation and more will be added for other devices.
So I will fix this issue depending on the discussion.
-Takahiro Akashi
> > + return 0;
> > +#else
> > + struct env_driver *drv = NULL;
> > + int ret;
> > +
> > + if (!efi_nv_var_htab.table)
> > + return 0;
> > +
> > + if (gd->env_efi_prio == -1) {
> > + pr_warn("No UEFI non-volatile variable storage\n");
> > + return -1;
> > + }
> > +
> > + drv = _env_driver_lookup(env_get_location(ENVOP_EFI, gd->env_efi_prio));
> > + if (!drv) {
> > + pr_warn("No UEFI non-volatile variable storage\n");
> > + return -1;
> > + }
> > +
> > + ret = drv->efi_save();
> > + if (ret)
> > + pr_err("Saving UEFI non-volatile variable failed\n");
> > +
> > + return ret;
> > +#endif
> > +}
> > +
> > +/* This function should be called only once at init */
> > +int env_efi_load(void)
> > +{
> > +#ifndef CONFIG_ENV_IS_NOWHERE
> ditto
> > + struct env_driver *drv;
> > + int prio;
> > + enum env_location loc;
> > +#endif
> > + int ret;
> > +
> > + /* volatile variables */
> > + if (!efi_var_htab.table) {
> > + ret = himport_r(&efi_var_htab, NULL, 0, '\0', 0, 0, 0, NULL);
> > + if (!ret) {
> > + pr_err("Creating UEFI volatile variables failed\n");
> > + return -1;
> > + }
> > + }
> > +
> > +#ifndef CONFIG_ENV_IS_NOWHERE
> ditto
> > + gd->env_efi_prio = -1;
> > +
> > + /* non-volatile variables */
> > + if (efi_nv_var_htab.table)
> > + return 0;
> > +
> > + for (drv = NULL, prio = 0; prio < ARRAY_SIZE(env_locations); prio++) {
> > + loc = env_get_location(ENVOP_EFI, prio);
> > + drv = _env_driver_lookup(loc);
> > + if (!drv)
> > + continue;
> > +
> > + if (drv->efi_load && drv->efi_save)
> > + break;
> > + }
> > + if (!drv || prio == ARRAY_SIZE(env_locations)) {
> > + pr_warn("No UEFI non-volatile variable storage\n");
> > + goto skip_load;
> > + }
> > +
> > + gd->env_efi_prio = prio;
> > +
> > + ret = drv->efi_load();
> > + if (ret) {
> > + pr_err("Loading UEFI non-volatile variables failed\n");
> > + return -1;
> > + }
> > +skip_load:
> > +#endif /* CONFIG_ENV_IS_NOWHERE */
> [...]
>
> Thanks
> /Ilias
More information about the U-Boot
mailing list