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 AE2C3C4321E for ; Sat, 26 Nov 2022 17:20:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BB86B852AE; Sat, 26 Nov 2022 18:18:44 +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="fHACF5uv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D43D85031; Sat, 26 Nov 2022 17:59:55 +0100 (CET) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 E0D7484494 for ; Sat, 26 Nov 2022 17:59:52 +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-x330.google.com with SMTP id l39-20020a05600c1d2700b003cf93c8156dso5501778wms.4 for ; Sat, 26 Nov 2022 08:59:52 -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=wbrCx5eTrmD0pm2grrgNzpWme251LqF5+MYDrCRvyGg=; b=fHACF5uvA4b25nGj5wUBPDABmHyGPfEd+MFqEE2fGGqSwJ9WclCdyguefUN8WnVIWL 6NiZXUC0zOdgY5plCSA7QLk5IjFTkAcUlLUsenNNdb5pKAtFZKCKbStBznjEsgUWsfeF p6z9aZViWq1Dt1zUkBzauP2UmJsI4sA6rokT3eLTJVaTYamiBkkcgegB16PHDTRR7anz rRwSkTj6e8NHQvBtGNhWxNPBqoKhzONrm7ciW1KGOTLczETH0yhp0RlPu10JYKiVZata 9CHKzBUlB/Nj3pQMvMm/zVYHIzWvzEAew09sfOYMntJVgfQtNhYaPdCoJ89d33kPl7tQ BwDg== 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=wbrCx5eTrmD0pm2grrgNzpWme251LqF5+MYDrCRvyGg=; b=kOCR1MOKE4iQhMD7i88GX4T/+daO82mfVx/NS6wRLoH3gUutL93R1BznqWJmrak6b1 5NjDcBcGCs32gROzr/2Ps6m6hIq3kRzdzZis7Yzv+DC5ukjiuBS/SmWvEwxzfqTLSSLZ vCgzJ07Y9Kka0Ji5mVQuVSI/4t08ugp6lTcF4VmIyL7o3l+h1infZtPDEDFLmlwpg9YD nwEv2T7mhByWYzUfPqAgQdLvlikGNBw3I0YdaKOMwbc7fAU/IN33btOPLNAVGCjjJrSs CYU4fOPyEzIeS+MwpdLUYzpYqB8X+kKkZ187Q2nEu7XuguTFvOQ8+g0S6HkrKVr7cnwU zqtQ== X-Gm-Message-State: ANoB5pn9X1+TsvjDa32hxdeZ9LygySt+Kd+rlUgWP80R60b+wFkot5Wi 2h2UBhbj+PrTvUyoU+rP5l5A8Q== X-Google-Smtp-Source: AA0mqf7YpJxaBsSqs+NM96X2NS/JoXnb296j3QwnfJRK3409uC9rOKx7FWa1mChcERI4EXg4w5V9EQ== X-Received: by 2002:a7b:cd94:0:b0:3cf:bfca:22db with SMTP id y20-20020a7bcd94000000b003cfbfca22dbmr26337361wmj.134.1669481992612; Sat, 26 Nov 2022 08:59:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 08:59:52 -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 12/17] android: boot: ramdisk: support vendor ramdisk Date: Sat, 26 Nov 2022 17:59:26 +0100 Message-Id: <20221126165931.197607-13-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 Version 3 and 4 of boot image header introduced vendor boot ramdisk: Please check include/android_image.h for details. The ramdisk is now split into a generic ramdisk in boot image and a vendor ramdisk in vendor boot image. Signed-off-by: Safae Ouajih --- boot/image-android.c | 13 +++++++++++-- include/image.h | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/boot/image-android.c b/boot/image-android.c index 5001b088f0fb..78bf708fed9f 100644 --- a/boot/image-android.c +++ b/boot/image-android.c @@ -25,6 +25,7 @@ static void android_boot_image_v3_v4_parse_hdr(const struct andr_boot_img_hdr_v3 data->kcmdline = hdr->cmdline; data->header_version = hdr->header_version; + data->ramdisk_ptr = env_get_ulong("ramdisk_addr_r", 16, 0); /* * The header takes a full page, the remaining components are aligned @@ -320,10 +321,11 @@ ulong android_image_get_kcomp(const struct andr_boot_img_hdr_v0_v1_v2 *hdr, return image_decomp_type(p, sizeof(u32)); } -int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0_v1_v2 *hdr, - const void *vendor_boot_img, ulong *rd_data, ulong *rd_len) +int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img, + ulong *rd_data, ulong *rd_len) { struct andr_image_data img_data = {0}; + ulong ramdisk_ptr; if (!android_image_get_data(hdr, vendor_boot_img, &img_data)) return -EINVAL; @@ -332,6 +334,13 @@ int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0_v1_v2 *hdr, *rd_data = *rd_len = 0; return -1; } + if (img_data.header_version > 2) { + ramdisk_ptr = img_data.ramdisk_ptr; + memcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr, + img_data.vendor_ramdisk_size); + memcpy((void *)(ramdisk_ptr + img_data.vendor_ramdisk_size), + (void *)img_data.ramdisk_ptr, img_data.boot_ramdisk_size); + } printf("RAM disk load addr 0x%08lx size %u KiB\n", img_data.ramdisk_ptr, DIV_ROUND_UP(img_data.ramdisk_size, 1024)); diff --git a/include/image.h b/include/image.h index c91502011500..461e30ae2ac8 100644 --- a/include/image.h +++ b/include/image.h @@ -1731,8 +1731,8 @@ struct andr_boot_img_hdr_v0_v1_v2; int android_image_get_kernel(const struct andr_boot_img_hdr_v0_v1_v2 *hdr, const void *vendor_boot_img, int verify, ulong *os_data, ulong *os_len); -int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0_v1_v2 *hdr, - const void *vendor_boot_img, ulong *rd_data, ulong *rd_len); +int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img, + ulong *rd_data, ulong *rd_len); int android_image_get_second(const struct andr_boot_img_hdr_v0_v1_v2 *hdr, ulong *second_data, ulong *second_len); bool android_image_get_dtbo(ulong hdr_addr, ulong *addr, u32 *size); -- 2.25.1