Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0DA0C4321E for ; Sat, 26 Nov 2022 17:19:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CD8388521D; Sat, 26 Nov 2022 18:18:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="x47qkQrE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BC80851AB; Sat, 26 Nov 2022 17:59:43 +0100 (CET) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 729988502C for ; Sat, 26 Nov 2022 17:59:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=souajih@baylibre.com Received: by mail-wm1-x336.google.com with SMTP id 83-20020a1c0256000000b003d03017c6efso7728147wmc.4 for ; Sat, 26 Nov 2022 08:59:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7+6a9euo1qJ8Vn/uIyVg0xD6ucJ5wN5vG6zSStrf9k4=; b=x47qkQrETOAKBbAWMyEm14jZbSBxnxB3B8oKINndGA/yLHmn2UTUnarJtSWKG79v5f D2YCqgNPkqIql+XwZFO0VIqpgOwuqGHqP2u/iI/dmJ9DJCGpnu34X/T16erLnM8BvhTN Oy9OCYttIzz+y+1K+mKjQ0lvpDLiyEFPVn0nUXxXkX21z7tOhcPKsvaoiSUrESXAprtl jdWPDjQd9qYAgVybl8hXV3sbwSdTRXO1W2Y+zD7ZcuWNy8vq+ScXw64TTqxZYzphgmjP ViaJriB83lIMQ763LLqWQ0jg+03v49TKrLAW2uEBcVI2dLDwCSX0baiORpjt9Et4Y8XF 0pKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7+6a9euo1qJ8Vn/uIyVg0xD6ucJ5wN5vG6zSStrf9k4=; b=mQ/awoqub3CzpF7+A0x1DsfQTOEfwf7+8dcApnxz8HrQCA9KEqv/ZiyhTPmjDHBjDQ E+IoemgDfhoOLKMBq+n6FbZMHOl+TSAGrvH0641ASHyfbFKIbGYBwFaErAX1EEmF20+O bRR7lAE6nps0VzhqSAqoI+qn8ZMHsiBTHu2nyIwvyYXvSlWdoRFHvSrqHB1WY+/qPziN HRhmv/4Z4RW1tpr57EsQrU0g5I/B3PyHeJcwga5NkPdD3Mz15/OQz3toWaRjrmwEAiMX XwL+AUsloR/hVLPeqKEAdnYjNy5Oum/fVgLfH9/If/EaHQq0z8wFLKjg9pIpr4p2ckNO By6w== X-Gm-Message-State: ANoB5pnhF1vMBDBs03AHzQS4VMJHAGhKK5uDn1I7xA2GIX53Pe4oZCgN wgyc9MzT/46Duf/rhw/TTg32qg== X-Google-Smtp-Source: AA0mqf7OJnBn5MlG2dvqq1rNJHWWOkHQplrnsgJWa1zMJxHI/6x84pOYBGlrr5ndXMC3rVdxGmzApg== X-Received: by 2002:a05:600c:a41:b0:3cf:895a:b22b with SMTP id c1-20020a05600c0a4100b003cf895ab22bmr19879751wmq.81.1669481980007; Sat, 26 Nov 2022 08:59:40 -0800 (PST) Received: from safae.baylibre.local ([2a04:cec0:11b5:4031:7588:eb2c:a5c2:aa6d]) by smtp.gmail.com with ESMTPSA id c15-20020adfe70f000000b00241e8d00b79sm7462408wrm.54.2022.11.26.08.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 08:59:39 -0800 (PST) From: Safae Ouajih To: sjg@chromium.org Cc: u-boot@lists.denx.de, sean.anderson@seco.com, r.stratiienko@gmail.com, mkorpershoek@baylibre.com, glaroque@baylibre.com, khilman@baylibre.com Subject: [PATCH 04/17] android: boot: add boot image header v3 and v4 structures Date: Sat, 26 Nov 2022 17:59:18 +0100 Message-Id: <20221126165931.197607-5-souajih@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221126165931.197607-1-souajih@baylibre.com> References: <20221126165931.197607-1-souajih@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Sat, 26 Nov 2022 18:18:14 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This adds support for v3/v4 boot image format by adding the following structures: - andr_boot_img_hdr_v3_v4 : describes boot image header - andr_vendor_boot_img_hdr_v3_v4 : describes vendor boot image header These definitions have been copied over from the AOSP documentation at [1] and [2] Boot arg sizes are taken from [3]: `35fb6262bc3fe2280c37047a92d79953789760e5` [1] https://source.android.com/docs/core/architecture/bootloader/boot-image-header [2] https://source.android.com/docs/core/architecture/bootloader/partitions/vendor-boot-partitions#vendor-boot-header [3] https://android.googlesource.com/platform/external/u-boot Signed-off-by: Safae Ouajih --- include/android_image.h | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/include/android_image.h b/include/android_image.h index bf9b8c6f0955..ec36e6512ad6 100644 --- a/include/android_image.h +++ b/include/android_image.h @@ -14,11 +14,58 @@ #include #include +#define ANDR_GKI_PAGE_SIZE 4096 #define ANDR_BOOT_MAGIC "ANDROID!" #define ANDR_BOOT_MAGIC_SIZE 8 #define ANDR_BOOT_NAME_SIZE 16 #define ANDR_BOOT_ARGS_SIZE 512 #define ANDR_BOOT_EXTRA_ARGS_SIZE 1024 +#define VENDOR_BOOT_MAGIC "VNDRBOOT" +#define ANDR_VENDOR_BOOT_MAGIC_SIZE 8 +#define ANDR_VENDOR_BOOT_ARGS_SIZE 2048 +#define ANDR_VENDOR_BOOT_NAME_SIZE 16 + +struct andr_boot_img_hdr_v3_v4 { + u8 magic[ANDR_BOOT_MAGIC_SIZE]; + + u32 kernel_size; /* size in bytes */ + u32 ramdisk_size; /* size in bytes */ + + u32 os_version; + + u32 header_size; /* size of boot image header in bytes */ + u32 reserved[4]; + u32 header_version; /* offset remains constant for version check */ + + u8 cmdline[ANDR_BOOT_ARGS_SIZE + ANDR_BOOT_EXTRA_ARGS_SIZE]; + /* for boot image header v4 only */ + u32 signature_size; /* size in bytes */ +}; + +struct andr_vendor_boot_img_hdr_v3_v4 { + u8 magic[ANDR_VENDOR_BOOT_MAGIC_SIZE]; + u32 header_version; + u32 page_size; /* flash page size we assume */ + + u32 kernel_addr; /* physical load addr */ + u32 ramdisk_addr; /* physical load addr */ + + u32 vendor_ramdisk_size; /* size in bytes */ + + u8 cmdline[ANDR_VENDOR_BOOT_ARGS_SIZE]; + + u32 tags_addr; /* physical addr for kernel tags */ + + u8 name[ANDR_VENDOR_BOOT_NAME_SIZE]; /* asciiz product name */ + u32 header_size; /* size of vendor boot image header in bytes */ + u32 dtb_size; /* size of dtb image */ + u64 dtb_addr; /* physical load address */ + /* for boot image header v4 only */ + u32 vendor_ramdisk_table_size; /* size in bytes for the vendor ramdisk table */ + u32 vendor_ramdisk_table_entry_num; /* number of entries in the vendor ramdisk table */ + u32 vendor_ramdisk_table_entry_size; /* size in bytes for a vendor ramdisk table entry */ + u32 bootconfig_size; /* size in bytes for the bootconfig section */ +}; /* The bootloader expects the structure of andr_boot_img_hdr_v0_v1_v2 with header * version 0 to be as follows: */ -- 2.25.1