All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/7] env: save UEFI non-volatile variables in dedicated storage
Date: Tue, 11 Jun 2019 13:59:52 +0300	[thread overview]
Message-ID: <20190611105952.GA3633@apalos> (raw)
In-Reply-To: <20190604065211.15907-2-takahiro.akashi@linaro.org>

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?
> +	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

  parent reply	other threads:[~2019-06-11 10:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04  6:52 [U-Boot] [PATCH v3 0/7] efi_loader: non-volatile variables support AKASHI Takahiro
2019-06-04  6:52 ` [U-Boot] [PATCH v3 1/7] env: save UEFI non-volatile variables in dedicated storage AKASHI Takahiro
2019-06-04 21:09   ` Heinrich Schuchardt
2019-06-05  0:36     ` AKASHI Takahiro
2019-06-11 10:59   ` Ilias Apalodimas [this message]
2019-06-12  5:23     ` AKASHI Takahiro
2019-06-04  6:52 ` [U-Boot] [PATCH v3 2/7] efi_loader: variable: support non-volatile attribute AKASHI Takahiro
2019-06-04 21:15   ` Heinrich Schuchardt
2019-06-04  6:52 ` [U-Boot] [PATCH v3 3/7] efi_loader: variable: split UEFI variables from U-Boot environment AKASHI Takahiro
2019-06-04 21:31   ` Heinrich Schuchardt
2019-06-05  0:48     ` AKASHI Takahiro
2019-06-04  6:52 ` [U-Boot] [PATCH v3 4/7] efi_loader: load saved non-volatile variables at init AKASHI Takahiro
2019-06-04 21:38   ` Heinrich Schuchardt
2019-06-05  0:58     ` AKASHI Takahiro
2019-06-04  6:52 ` [U-Boot] [PATCH v3 5/7] efi_loader: bootmgr: make BootNext non-volatile AKASHI Takahiro
2019-06-04 21:46   ` Heinrich Schuchardt
2019-06-11 10:19   ` Ilias Apalodimas
2019-06-04  6:52 ` [U-Boot] [PATCH v3 6/7] cmd: efidebug: make some boot variables non-volatile AKASHI Takahiro
2019-06-04 21:45   ` Heinrich Schuchardt
2019-06-11 10:20   ` Ilias Apalodimas
2019-06-04  6:52 ` [U-Boot] [PATCH v3 7/7] cmd: env: add -nv option for UEFI non-volatile variable AKASHI Takahiro
2019-06-04 21:53   ` Heinrich Schuchardt
2019-06-25  6:47 ` [U-Boot] [PATCH v3 0/7] efi_loader: non-volatile variables support Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190611105952.GA3633@apalos \
    --to=ilias.apalodimas@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.