All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Safae Ouajih <souajih@baylibre.com>, sjg@chromium.org
Cc: u-boot@lists.denx.de, sean.anderson@seco.com,
	r.stratiienko@gmail.com, glaroque@baylibre.com,
	khilman@baylibre.com
Subject: Re: [PATCH v2 01/17] android: boot: rename andr_img_hdr -> andr_boot_img_hdr_v0
Date: Wed, 01 Feb 2023 09:27:11 +0100	[thread overview]
Message-ID: <878rhhkcyo.fsf@baylibre.com> (raw)
In-Reply-To: <20230126160506.1026643-2-souajih@baylibre.com>

On Thu, Jan 26, 2023 at 17:04, Safae Ouajih <souajih@baylibre.com> wrote:

> Android introduced boot header version 3 or 4.
> The header structure change with version 3 and 4 to support
> the new updates such as:
> - Introducing Vendor boot image: with a vendor ramdisk
> - Bootconfig feature (v4)
>
> To maintain support for version v0, v1 and v2 while introducing
> version 3 and 4, this struct name must change to refer to the header
> structure before v3.
>
> Signed-off-by: Safae Ouajih <souajih@baylibre.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>

> ---
>  boot/image-android.c      | 26 +++++++++++++-------------
>  boot/image-fdt.c          |  2 +-
>  cmd/abootimg.c            |  4 ++--
>  drivers/fastboot/fb_mmc.c |  8 ++++----
>  include/android_image.h   |  4 ++--
>  include/image.h           | 18 +++++++++---------
>  6 files changed, 31 insertions(+), 31 deletions(-)
>
> diff --git a/boot/image-android.c b/boot/image-android.c
> index 2628db3741..8c0a304cc0 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -18,7 +18,7 @@
>  
>  static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
>  
> -static ulong android_image_get_kernel_addr(const struct andr_img_hdr *hdr)
> +static ulong android_image_get_kernel_addr(const struct andr_boot_img_hdr_v0 *hdr)
>  {
>  	/*
>  	 * All the Android tools that generate a boot.img use this
> @@ -59,7 +59,7 @@ static ulong android_image_get_kernel_addr(const struct andr_img_hdr *hdr)
>   * Return: Zero, os start address and length on success,
>   *		otherwise on failure.
>   */
> -int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
> +int android_image_get_kernel(const struct andr_boot_img_hdr_v0 *hdr, int verify,
>  			     ulong *os_data, ulong *os_len)
>  {
>  	u32 kernel_addr = android_image_get_kernel_addr(hdr);
> @@ -122,12 +122,12 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
>  	return 0;
>  }
>  
> -int android_image_check_header(const struct andr_img_hdr *hdr)
> +int android_image_check_header(const struct andr_boot_img_hdr_v0 *hdr)
>  {
>  	return memcmp(ANDR_BOOT_MAGIC, hdr->magic, ANDR_BOOT_MAGIC_SIZE);
>  }
>  
> -ulong android_image_get_end(const struct andr_img_hdr *hdr)
> +ulong android_image_get_end(const struct andr_boot_img_hdr_v0 *hdr)
>  {
>  	ulong end;
>  
> @@ -150,12 +150,12 @@ ulong android_image_get_end(const struct andr_img_hdr *hdr)
>  	return end;
>  }
>  
> -ulong android_image_get_kload(const struct andr_img_hdr *hdr)
> +ulong android_image_get_kload(const struct andr_boot_img_hdr_v0 *hdr)
>  {
>  	return android_image_get_kernel_addr(hdr);
>  }
>  
> -ulong android_image_get_kcomp(const struct andr_img_hdr *hdr)
> +ulong android_image_get_kcomp(const struct andr_boot_img_hdr_v0 *hdr)
>  {
>  	const void *p = (void *)((uintptr_t)hdr + hdr->page_size);
>  
> @@ -167,7 +167,7 @@ ulong android_image_get_kcomp(const struct andr_img_hdr *hdr)
>  		return image_decomp_type(p, sizeof(u32));
>  }
>  
> -int android_image_get_ramdisk(const struct andr_img_hdr *hdr,
> +int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0 *hdr,
>  			      ulong *rd_data, ulong *rd_len)
>  {
>  	if (!hdr->ramdisk_size) {
> @@ -186,7 +186,7 @@ int android_image_get_ramdisk(const struct andr_img_hdr *hdr,
>  	return 0;
>  }
>  
> -int android_image_get_second(const struct andr_img_hdr *hdr,
> +int android_image_get_second(const struct andr_boot_img_hdr_v0 *hdr,
>  			      ulong *second_data, ulong *second_len)
>  {
>  	if (!hdr->second_size) {
> @@ -226,7 +226,7 @@ int android_image_get_second(const struct andr_img_hdr *hdr,
>   */
>  bool android_image_get_dtbo(ulong hdr_addr, ulong *addr, u32 *size)
>  {
> -	const struct andr_img_hdr *hdr;
> +	const struct andr_boot_img_hdr_v0 *hdr;
>  	ulong dtbo_img_addr;
>  	bool ret = true;
>  
> @@ -275,7 +275,7 @@ exit:
>   */
>  static bool android_image_get_dtb_img_addr(ulong hdr_addr, ulong *addr)
>  {
> -	const struct andr_img_hdr *hdr;
> +	const struct andr_boot_img_hdr_v0 *hdr;
>  	ulong dtb_img_addr;
>  	bool ret = true;
>  
> @@ -328,7 +328,7 @@ exit:
>  bool android_image_get_dtb_by_index(ulong hdr_addr, u32 index, ulong *addr,
>  				    u32 *size)
>  {
> -	const struct andr_img_hdr *hdr;
> +	const struct andr_boot_img_hdr_v0 *hdr;
>  	bool res;
>  	ulong dtb_img_addr;	/* address of DTB part in boot image */
>  	u32 dtb_img_size;	/* size of DTB payload in boot image */
> @@ -393,7 +393,7 @@ bool android_image_get_dtb_by_index(ulong hdr_addr, u32 index, ulong *addr,
>   * returns:
>   *     no returned results
>   */
> -void android_print_contents(const struct andr_img_hdr *hdr)
> +void android_print_contents(const struct andr_boot_img_hdr_v0 *hdr)
>  {
>  	const char * const p = IMAGE_INDENT_STRING;
>  	/* os_version = ver << 11 | lvl */
> @@ -485,7 +485,7 @@ static bool android_image_print_dtb_info(const struct fdt_header *fdt,
>   */
>  bool android_image_print_dtb_contents(ulong hdr_addr)
>  {
> -	const struct andr_img_hdr *hdr;
> +	const struct andr_boot_img_hdr_v0 *hdr;
>  	bool res;
>  	ulong dtb_img_addr;	/* address of DTB part in boot image */
>  	u32 dtb_img_size;	/* size of DTB payload in boot image */
> diff --git a/boot/image-fdt.c b/boot/image-fdt.c
> index b830a0ab41..1181cb60f0 100644
> --- a/boot/image-fdt.c
> +++ b/boot/image-fdt.c
> @@ -529,7 +529,7 @@ int boot_get_fdt(int flag, int argc, char *const argv[], uint8_t arch,
>  		}
>  #ifdef CONFIG_ANDROID_BOOT_IMAGE
>  	} else if (genimg_get_format(buf) == IMAGE_FORMAT_ANDROID) {
> -		struct andr_img_hdr *hdr = buf;
> +		struct andr_boot_img_hdr_v0 *hdr = buf;
>  		ulong		fdt_data, fdt_len;
>  		u32			fdt_size, dtb_idx;
>  		/*
> diff --git a/cmd/abootimg.c b/cmd/abootimg.c
> index f48a9dcb02..0262adb1e5 100644
> --- a/cmd/abootimg.c
> +++ b/cmd/abootimg.c
> @@ -18,7 +18,7 @@ static ulong _abootimg_addr = -1;
>  
>  static int abootimg_get_ver(int argc, char *const argv[])
>  {
> -	const struct andr_img_hdr *hdr;
> +	const struct andr_boot_img_hdr_v0 *hdr;
>  	int res = CMD_RET_SUCCESS;
>  
>  	if (argc > 1)
> @@ -65,7 +65,7 @@ static int abootimg_get_recovery_dtbo(int argc, char *const argv[])
>  
>  static int abootimg_get_dtb_load_addr(int argc, char *const argv[])
>  {
> -	const struct andr_img_hdr *hdr;
> +	const struct andr_boot_img_hdr_v0 *hdr;
>  	int res = CMD_RET_SUCCESS;
>  
>  	if (argc > 1)
> diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
> index 033c510bc0..6d0112fdf4 100644
> --- a/drivers/fastboot/fb_mmc.c
> +++ b/drivers/fastboot/fb_mmc.c
> @@ -287,7 +287,7 @@ static void fb_mmc_boot_ops(struct blk_desc *dev_desc, void *buffer,
>   */
>  static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,
>  				       struct disk_partition *info,
> -				       struct andr_img_hdr *hdr,
> +				       struct andr_boot_img_hdr_v0 *hdr,
>  				       char *response)
>  {
>  	ulong sector_size;		/* boot partition sector size */
> @@ -296,7 +296,7 @@ static lbaint_t fb_mmc_get_boot_header(struct blk_desc *dev_desc,
>  
>  	/* Calculate boot image sectors count */
>  	sector_size = info->blksz;
> -	hdr_sectors = DIV_ROUND_UP(sizeof(struct andr_img_hdr), sector_size);
> +	hdr_sectors = DIV_ROUND_UP(sizeof(struct andr_boot_img_hdr_v0), sector_size);
>  	if (hdr_sectors == 0) {
>  		pr_err("invalid number of boot sectors: 0\n");
>  		fastboot_fail("invalid number of boot sectors: 0", response);
> @@ -338,7 +338,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
>  				char *response)
>  {
>  	uintptr_t hdr_addr;			/* boot image header address */
> -	struct andr_img_hdr *hdr;		/* boot image header */
> +	struct andr_boot_img_hdr_v0 *hdr;		/* boot image header */
>  	lbaint_t hdr_sectors;			/* boot image header sectors */
>  	u8 *ramdisk_buffer;
>  	u32 ramdisk_sector_start;
> @@ -361,7 +361,7 @@ static int fb_mmc_update_zimage(struct blk_desc *dev_desc,
>  
>  	/* Put boot image header in fastboot buffer after downloaded zImage */
>  	hdr_addr = (uintptr_t)download_buffer + ALIGN(download_bytes, PAGE_SIZE);
> -	hdr = (struct andr_img_hdr *)hdr_addr;
> +	hdr = (struct andr_boot_img_hdr_v0 *)hdr_addr;
>  
>  	/* Read boot image header */
>  	hdr_sectors = fb_mmc_get_boot_header(dev_desc, &info, hdr, response);
> diff --git a/include/android_image.h b/include/android_image.h
> index 54d25af068..2bdcab9122 100644
> --- a/include/android_image.h
> +++ b/include/android_image.h
> @@ -20,9 +20,9 @@
>  #define ANDR_BOOT_ARGS_SIZE 512
>  #define ANDR_BOOT_EXTRA_ARGS_SIZE 1024
>  
> -/* The bootloader expects the structure of andr_img_hdr with header
> +/* The bootloader expects the structure of andr_boot_img_hdr_v0 with header
>   * version 0 to be as follows: */
> -struct andr_img_hdr {
> +struct andr_boot_img_hdr_v0 {
>      /* Must be ANDR_BOOT_MAGIC. */
>      char magic[ANDR_BOOT_MAGIC_SIZE];
>  
> diff --git a/include/image.h b/include/image.h
> index 7717a4c13d..bcb24d92de 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -1734,21 +1734,21 @@ int fit_image_cipher_get_algo(const void *fit, int noffset, char **algo);
>  
>  struct cipher_algo *image_get_cipher_algo(const char *full_name);
>  
> -struct andr_img_hdr;
> -int android_image_check_header(const struct andr_img_hdr *hdr);
> -int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
> +struct andr_boot_img_hdr_v0;
> +int android_image_check_header(const struct andr_boot_img_hdr_v0 *hdr);
> +int android_image_get_kernel(const struct andr_boot_img_hdr_v0 *hdr, int verify,
>  			     ulong *os_data, ulong *os_len);
> -int android_image_get_ramdisk(const struct andr_img_hdr *hdr,
> +int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0 *hdr,
>  			      ulong *rd_data, ulong *rd_len);
> -int android_image_get_second(const struct andr_img_hdr *hdr,
> +int android_image_get_second(const struct andr_boot_img_hdr_v0 *hdr,
>  			      ulong *second_data, ulong *second_len);
>  bool android_image_get_dtbo(ulong hdr_addr, ulong *addr, u32 *size);
>  bool android_image_get_dtb_by_index(ulong hdr_addr, u32 index, ulong *addr,
>  				    u32 *size);
> -ulong android_image_get_end(const struct andr_img_hdr *hdr);
> -ulong android_image_get_kload(const struct andr_img_hdr *hdr);
> -ulong android_image_get_kcomp(const struct andr_img_hdr *hdr);
> -void android_print_contents(const struct andr_img_hdr *hdr);
> +ulong android_image_get_end(const struct andr_boot_img_hdr_v0 *hdr);
> +ulong android_image_get_kload(const struct andr_boot_img_hdr_v0 *hdr);
> +ulong android_image_get_kcomp(const struct andr_boot_img_hdr_v0 *hdr);
> +void android_print_contents(const struct andr_boot_img_hdr_v0 *hdr);
>  bool android_image_print_dtb_contents(ulong hdr_addr);
>  
>  /**
> -- 
> 2.34.1

  parent reply	other threads:[~2023-02-01  8:27 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 16:04 [PATCH v2 00/17] Support android boot image v3/v4 Safae Ouajih
2023-01-26 16:04 ` [PATCH v2 01/17] android: boot: rename andr_img_hdr -> andr_boot_img_hdr_v0 Safae Ouajih
2023-01-27  0:54   ` Simon Glass
2023-02-01  8:27   ` Mattijs Korpershoek [this message]
2023-01-26 16:04 ` [PATCH v2 02/17] android: boot: support vendor boot image in abootimg Safae Ouajih
2023-01-27  0:54   ` Simon Glass
2023-02-01  8:32     ` Mattijs Korpershoek
2023-01-26 16:04 ` [PATCH v2 03/17] android: boot: replace android_image_check_header Safae Ouajih
2023-01-27  0:54   ` Simon Glass
2023-02-01  8:33     ` Mattijs Korpershoek
2023-01-26 16:04 ` [PATCH v2 04/17] android: boot: add boot image header v3 and v4 structures Safae Ouajih
2023-01-27  0:54   ` Simon Glass
2023-02-01  8:34     ` Mattijs Korpershoek
2023-01-26 16:04 ` [PATCH v2 05/17] android: boot: kcomp: support andr_image_data Safae Ouajih
2023-01-27  0:54   ` Simon Glass
2023-02-01  8:35     ` Mattijs Korpershoek
2023-01-26 16:04 ` [PATCH v2 06/17] android: boot: move to andr_image_data structure Safae Ouajih
2023-01-27  0:54   ` Simon Glass
2023-01-27 15:50     ` Safae Ouajih
2023-01-27 17:15       ` Simon Glass
2023-01-26 16:04 ` [PATCH v2 07/17] android: boot: content print is not supported for v3, v4 header version Safae Ouajih
2023-01-27  0:54   ` [PATCH v2 07/17] android: boot: content print is not supported for v3,v4 " Simon Glass
2023-01-27 15:50     ` Safae Ouajih
2023-01-27 17:15       ` Simon Glass
2023-02-01  8:36         ` Mattijs Korpershoek
2023-01-26 16:04 ` [PATCH v2 08/17] android: boot: boot image header v3, v4 do not support recovery DTBO Safae Ouajih
2023-01-27  0:54   ` [PATCH v2 08/17] android: boot: boot image header v3,v4 " Simon Glass
2023-02-01  8:37     ` Mattijs Korpershoek
2023-01-26 16:04 ` [PATCH v2 09/17] android: boot: add vendor boot image to prepare for v3, v4 support Safae Ouajih
2023-01-27  0:54   ` [PATCH v2 09/17] android: boot: add vendor boot image to prepare for v3,v4 support Simon Glass
2023-01-26 16:04 ` [PATCH v2 10/17] android: boot: update android_image_get_data to support v3, v4 Safae Ouajih
2023-01-27  0:54   ` [PATCH v2 10/17] android: boot: update android_image_get_data to support v3,v4 Simon Glass
2023-01-26 16:05 ` [PATCH v2 11/17] android: boot: ramdisk: support vendor ramdisk Safae Ouajih
2023-01-27  0:54   ` Simon Glass
2023-01-26 16:05 ` [PATCH v2 12/17] android: boot: support extra command line Safae Ouajih
2023-01-27  0:54   ` Simon Glass
2023-01-27 15:51     ` Safae Ouajih
2023-01-27 17:15       ` Simon Glass
2023-02-01  8:39         ` Mattijs Korpershoek
2023-01-26 16:05 ` [PATCH v2 13/17] android: boot: update android_image_get_dtb_img_addr to support v3, v4 Safae Ouajih
2023-01-27  0:55   ` [PATCH v2 13/17] android: boot: update android_image_get_dtb_img_addr to support v3,v4 Simon Glass
2023-02-01  8:42     ` Mattijs Korpershoek
2023-01-26 16:05 ` [PATCH v2 14/17] drivers: fastboot: zImage flashing is not supported for v3, v4 Safae Ouajih
2023-01-27  0:55   ` [PATCH v2 14/17] drivers: fastboot: zImage flashing is not supported for v3,v4 Simon Glass
2023-01-26 16:05 ` [PATCH v2 15/17] android: boot: support boot image header version 3 and 4 Safae Ouajih
2023-01-27  0:55   ` Simon Glass
2023-02-01  8:44     ` Mattijs Korpershoek
2023-02-02  9:54       ` Safae Ouajih
2023-01-26 16:05 ` [PATCH v2 16/17] android: boot: support bootconfig Safae Ouajih
2023-01-27  0:55   ` Simon Glass
2023-02-01  8:45     ` Mattijs Korpershoek
2023-01-26 16:05 ` [PATCH v2 17/17] test/py: android: extend abootimg test Safae Ouajih
2023-01-27  0:55   ` Simon Glass
2023-01-27 15:51     ` Safae Ouajih
2023-01-27 20:37       ` Tom Rini
2023-01-31 12:34         ` Safae Ouajih
2023-01-26 18:17 ` [PATCH v2 00/17] Support android boot image v3/v4 Roman Stratiienko
2023-01-27  9:19   ` Safae Ouajih
2023-02-01  8:26 ` Mattijs Korpershoek

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=878rhhkcyo.fsf@baylibre.com \
    --to=mkorpershoek@baylibre.com \
    --cc=glaroque@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=r.stratiienko@gmail.com \
    --cc=sean.anderson@seco.com \
    --cc=sjg@chromium.org \
    --cc=souajih@baylibre.com \
    --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.