[RFC PATCH v3 1/9] FWU: Add FWU metadata structure and functions for accessing metadata
Masami Hiramatsu
masami.hiramatsu at linaro.org
Thu Jan 20 06:53:21 CET 2022
Hello Sughosh,
2022年1月20日(木) 3:56 Sughosh Ganu <sughosh.ganu at linaro.org>:
>
> In the FWU Multi Bank Update feature, the information about the
> updatable images is stored as part of the metadata, which is stored on
> a dedicated partition. Add the metadata structure, and functions to
> access the metadata. These are generic API's, and implementations can
> be added based on parameters like how the metadata partition is
> accessed and what type of storage device houses the metadata.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
> ---
>
> Changes since V2:
> * Use uint*_t types in fwu_mdata.h since the file is to be reused in
> other projects
> * Keep only the FWU metadata structures in fwu_mdata.h
> * Move all other function and macro declarations in fwu.h
> * Keep common implementations of fwu_update_active_index and
> fwu_revert_boot_index in fwu_mdata.c
> * Add a update_mdata function pointer in the fwu_mdata_ops structure
>
> include/fwu.h | 61 +++++++
> include/fwu_mdata.h | 67 ++++++++
> lib/fwu_updates/fwu_mdata.c | 329 ++++++++++++++++++++++++++++++++++++
> 3 files changed, 457 insertions(+)
> create mode 100644 include/fwu.h
> create mode 100644 include/fwu_mdata.h
> create mode 100644 lib/fwu_updates/fwu_mdata.c
>
> diff --git a/include/fwu.h b/include/fwu.h
> new file mode 100644
> index 0000000000..acba725bc8
> --- /dev/null
> +++ b/include/fwu.h
> @@ -0,0 +1,61 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (c) 2021, Linaro Limited
> + */
> +
> +#if !defined _FWU_H_
> +#define _FWU_H_
> +
> +#include <blk.h>
> +#include <efi.h>
> +
> +#include <linux/types.h>
> +
> +struct fwu_mdata;
> +
> +/**
> + * @get_active_index: get the current active_index value
> + * @get_image_alt_num: get the alt number to be used for the image
> + * @mdata_check: check the validity of the FWU metadata partitions
> + * @set_accept_image: set the accepted bit for the image
> + * @clear_accept_image: clear the accepted bit for the image
> + * @get_mdata() - Get a FWU metadata copy
> + * @update_mdata() - Update the FWU metadata copy
> + */
> +struct fwu_mdata_ops {
> + int (*get_active_index)(u32 *active_idx);
> +
> + int (*get_image_alt_num)(efi_guid_t image_type_id, u32 update_bank,
> + int *alt_num);
> +
> + int (*mdata_check)(void);
> +
> + int (*set_accept_image)(efi_guid_t *img_type_id, u32 bank);
> +
> + int (*clear_accept_image)(efi_guid_t *img_type_id, u32 bank);
> +
> + int (*get_mdata)(struct fwu_mdata **mdata);
> +
> + int (*update_mdata)(struct fwu_mdata *mdata);
> +};
We also can remove
- get_active_index
- set_accept_image
- clear_accept_image
from these operations, because those are just reading or modifying metadata.
Such functions can be written as below
ops()
{
op->get_mdata(&mdata);
do_some_operation(mdata);
if (updated)
op->update_mdata(mdata);
}
I'll make a series of patches on top of your series for DeveloperBox,
which does not use GPT.
Thank you,
--
Masami Hiramatsu
More information about the U-Boot
mailing list