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 F404FC00528 for ; Sun, 30 Jul 2023 17:20:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4D02786AD1; Sun, 30 Jul 2023 19:17:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UP7o97YX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 10DE786A55; Sun, 30 Jul 2023 19:17:29 +0200 (CEST) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (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 1151086990 for ; Sun, 30 Jul 2023 19:17:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3490ebe5286so4206495ab.1 for ; Sun, 30 Jul 2023 10:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690737444; x=1691342244; 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=nj8xamyGoQ9X1FhOSKhm2zkS9Edb8XQah2P4dwDiZjA=; b=UP7o97YXSznAO1VntYVsfNeppqxB6yC2O4uD0p8cxERh3QdjvjYvrmyfXkk9F0HiBP Im2da//PKkq//NpYsxmbT8k0QeQORuB+/x26R7/DY1gY9PPt7ABbKm3WoVKGThtHwFr/ 6gvtoeJlLNRZP6byO3Sf3tQASrSNeufSWsgEk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690737444; x=1691342244; 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=nj8xamyGoQ9X1FhOSKhm2zkS9Edb8XQah2P4dwDiZjA=; b=RdIN3ZX2yc9v9twzNsMYZl2PB2ZMbX8bQxYL6TXDeDVVft5l/dALpEmxMHuYjAvLAU 5JZJ64Y05ikazWfcvSR4xwI3JTJ8Pzq3tg9+wIK/fvUBLBGe5yipk+wtU7TEsruqNWTt RCfA1n+t9Xkui3IQaQWyuZKogB22ARaGSUyRaKSm4GTZOPbAkFtP+hs/6RHU5hrSxhH/ UIZj3EY7FqkZ8f6vWIhjuohN1sOwNep4sC2nspvvGVdT2Fdtxwcboqq+sJ1MYgcho9Vt Chyl/23brGf2CZpOjBpGNeULNIwiERlhoEoxBZUwabZ1zlpKRo2VexEsAlbWYsCHWFXL lmaw== X-Gm-Message-State: ABy/qLYWT7PVzLXh0f9NO3+oCasr5MVqthr5RvCHqD7K20r6NBska9C3 u4B8Be7VV6DsihJQvZyb2UOWOJYgit5HIvMTmkE= X-Google-Smtp-Source: APBJJlEL+To1aEN16rCXxIJDzkqOQqxVlT/uNAVdpTjuWDSUIM2kJjMaFejEWLhWys0oTI21ng+lZA== X-Received: by 2002:a05:6e02:dc8:b0:348:fe78:e9d0 with SMTP id l8-20020a056e020dc800b00348fe78e9d0mr5660130ilj.6.1690737444669; Sun, 30 Jul 2023 10:17:24 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id b24-20020a02a598000000b0041cd626ea0csm2537412jam.147.2023.07.30.10.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 10:17:24 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Bin Meng , Alper Nebi Yasak , Simon Glass Subject: [PATCH 12/16] bootstd: cros: Add a function to read a kernel Date: Sun, 30 Jul 2023 11:16:58 -0600 Message-ID: <20230730171709.917352-13-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230730171709.917352-1-sjg@chromium.org> References: <20230730171709.917352-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean The code to read the ChromiumOS information from the partition is currently all in one function. Create a new function which reads the kernel, assuming that the metadata has been parsed. For now this function is not used. Future work will plumb it in. Signed-off-by: Simon Glass --- boot/bootmeth_cros.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c index 82cbdcf2c93a..8728cd18e3c1 100644 --- a/boot/bootmeth_cros.c +++ b/boot/bootmeth_cros.c @@ -294,6 +294,45 @@ static int cros_read_info(struct bootflow *bflow, const char *uuid, return 0; } +static int cros_read_kernel(struct bootflow *bflow) +{ + struct blk_desc *desc = dev_get_uclass_plat(bflow->blk); + struct cros_priv *priv = bflow->bootmeth_priv; + ulong base, setup; + ulong num_blks; + void *buf; + int ret; + + bflow->size = priv->body_size; + + buf = memalign(SZ_1K, priv->body_size); + if (!buf) + return log_msg_ret("buf", -ENOMEM); + + /* Check that the header is not smaller than permitted */ + if (priv->body_offset < PROBE_SIZE) + return log_msg_ret("san", EFAULT); + + /* Read kernel body */ + num_blks = priv->body_size >> desc->log2blksz; + log_debug("Reading body to %lx, blk=%s, size=%lx, blocks=%lx\n", + (ulong)map_to_sysmem(buf), bflow->blk->name, priv->body_size, + num_blks); + ret = blk_read(bflow->blk, + priv->part_start + (priv->body_offset >> desc->log2blksz), + num_blks, buf); + if (ret != num_blks) + return log_msg_ret("inf", -EIO); + base = map_to_sysmem(buf) + priv->bootloader_address - + priv->body_load_address; + setup = base + X86_SETUP_OFFSET; + + bflow->buf = buf; + bflow->x86_setup = map_sysmem(setup, 0); + + return 0; +} + static int cros_read_bootflow(struct udevice *dev, struct bootflow *bflow) { struct blk_desc *desc = dev_get_uclass_plat(bflow->blk); -- 2.41.0.487.g6d72f3e995-goog