Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA888C433E0 for ; Mon, 1 Mar 2021 12:08:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 369A064E31 for ; Mon, 1 Mar 2021 12:08:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 369A064E31 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kaod.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGhLl-00031k-0V for qemu-devel@archiver.kernel.org; Mon, 01 Mar 2021 07:08:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGhL2-0001tJ-QY; Mon, 01 Mar 2021 07:07:48 -0500 Received: from smtpout1.mo804.mail-out.ovh.net ([79.137.123.220]:39919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGhL0-0007E9-Tb; Mon, 01 Mar 2021 07:07:48 -0500 Received: from mxplan5.mail.ovh.net (unknown [10.108.1.114]) by mo804.mail-out.ovh.net (Postfix) with ESMTPS id D998B92B854A; Mon, 1 Mar 2021 13:07:43 +0100 (CET) Received: from kaod.org (37.59.142.95) by DAG4EX1.mxp5.local (172.16.2.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 1 Mar 2021 13:07:42 +0100 Authentication-Results: garm.ovh; auth=pass (GARM-95G001331e5c03-b6d9-4f68-9027-d827fe17b5ba, 79E354DF6B7F793720F6EA4F82BCB5A412373A8E) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Subject: Re: [PATCH v3 16/21] sd: emmc: Support boot area in emmc image To: Sai Pavan Boddu , Markus Armbruster , Kevin Wolf , Max Reitz , Vladimir Sementsov-Ogievskiy , Eric Blake , Joel Stanley , Vincent Palatin , "Dr. David Alan Gilbert" , Thomas Huth , Stefan Hajnoczi , Peter Maydell , Alistair Francis , "Edgar E. Iglesias" , Luc Michel , Paolo Bonzini References: <1614540807-30686-1-git-send-email-sai.pavan.boddu@xilinx.com> <1614540807-30686-17-git-send-email-sai.pavan.boddu@xilinx.com> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: <9096c6e9-bb84-7220-e780-7d5265464cbd@kaod.org> Date: Mon, 1 Mar 2021 13:07:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <1614540807-30686-17-git-send-email-sai.pavan.boddu@xilinx.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.95] X-ClientProxiedBy: DAG1EX2.mxp5.local (172.16.2.2) To DAG4EX1.mxp5.local (172.16.2.31) X-Ovh-Tracer-GUID: 80ad7066-cddd-4b64-bdc2-5fb631caf045 X-Ovh-Tracer-Id: 15640720033240877837 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrleekgdefhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkffgfgggjtgfgihesthekredttdefjeenucfhrhhomhepveorughrihgtpgfnvggpifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeejkeduueduveelgeduueegkeelffevledujeetffeivdelvdfgkeeufeduheehfeenucfkpheptddrtddrtddrtddpfeejrdehledrudegvddrleehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepmhigphhlrghnhedrmhgrihhlrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpegtlhhgsehkrghougdrohhrghdprhgtphhtthhopehsrghirdhprghvrghnrdgsohguughuseigihhlihhngidrtghomh Received-SPF: pass client-ip=79.137.123.220; envelope-from=clg@kaod.org; helo=smtpout1.mo804.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: saipava@xilinx.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 2/28/21 8:33 PM, Sai Pavan Boddu wrote: > From: Joel Stanley > > This assumes a specially constructued image: > > dd if=/dev/zero of=mmc-bootarea.img count=2 bs=1M > dd if=u-boot-spl.bin of=mmc-bootarea.img conv=notrunc > dd if=u-boot.bin of=mmc-bootarea.img conv=notrunc count=64 bs=1K > cat mmc-bootarea.img obmc-phosphor-image.wic > mmc.img > truncate --size 16GB mmc.img > truncate --size 128MB mmc-bootarea.img > > Signed-off-by: Joel Stanley > [clg: - changes on the definition names ] > Signed-off-by: Cédric Le Goater > [spb: use data_start property to access right emmc partition, > Clean up PARTITION_ENABLE support as incomplete, > Fix commit message to be generic.] > Signed-off-by: Sai Pavan Boddu > --- > hw/sd/sd.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index 08b77ad..d311477 100644 > --- a/hw/sd/sd.c > +++ b/hw/sd/sd.c > @@ -1044,6 +1044,34 @@ static void sd_lock_command(SDState *sd) > sd->card_status &= ~CARD_IS_LOCKED; > } > > +/* > + * This requires a disk image that has two boot partitions inserted at the > + * beginning of it. The size of the boot partitions are configured in the > + * ext_csd structure, which is hardcoded in qemu. They are currently set to > + * 1MB each. > + */ > +static uint32_t sd_bootpart_offset(SDState *sd) > +{ > + unsigned int access = sd->ext_csd[EXT_CSD_PART_CONFIG] & > + EXT_CSD_PART_CONFIG_ACC_MASK; > + unsigned int boot_capacity = sd->ext_csd[EXT_CSD_BOOT_MULT] << 17; > + > + if (!sd->emmc) { > + return 0; > + } > + > + switch (access) { > + case EXT_CSD_PART_CONFIG_ACC_DEFAULT: > + return boot_capacity * 2; > + case EXT_CSD_PART_CONFIG_ACC_BOOT0: > + return 0; > + case EXT_CSD_PART_CONFIG_ACC_BOOT0 + 1: > + return boot_capacity * 1; > + default: > + g_assert_not_reached(); > + } > +} > + > static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > { > uint32_t rca = 0x0000; > @@ -1359,6 +1387,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > return sd_r1; > } > > + if (sd->emmc) { > + addr += sd_bootpart_offset(sd); This could be a class handler. The default behavior would be to return 0. C. > + } > sd->state = sd_sendingdata_state; > sd->data_start = addr; > sd->data_offset = 0; > @@ -1378,6 +1409,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > return sd_r1; > } > > + if (sd->emmc) { > + addr += sd_bootpart_offset(sd); > + } > sd->state = sd_sendingdata_state; > sd->data_start = addr; > sd->data_offset = 0; > @@ -1434,6 +1468,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > return sd_r1; > } > > + if (sd->emmc) { > + addr += sd_bootpart_offset(sd); > + } > sd->state = sd_receivingdata_state; > sd->data_start = addr; > sd->data_offset = 0; > @@ -1464,6 +1501,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > return sd_r1; > } > > + if (sd->emmc) { > + addr += sd_bootpart_offset(sd); > + } > sd->state = sd_receivingdata_state; > sd->data_start = addr; > sd->data_offset = 0; >