From patchwork Thu Dec 17 11:27:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 344924 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1077153jai; Thu, 17 Dec 2020 03:28:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFhcjQ6r9WMsDpe4saBVgdGTFEfAfi9Df53CgrGJ6O1GRM6ZSQ2di6bmC8tFMDK9HAgsYk X-Received: by 2002:a05:6402:3074:: with SMTP id bs20mr38065839edb.365.1608204530294; Thu, 17 Dec 2020 03:28:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608204530; cv=none; d=google.com; s=arc-20160816; b=MPpmidw5GSSRpMlbGpEpVGnjXlnimcN7LIrArCu5nayNom88aLAERvsslb2n9KsQjr xbo8X8Z7YR8HVXIUSUcy95be6MNu5UE14oUPRIVB2ZGYXlICwOooo+ROOfOTvy5/gWWP QwNJkuZs5nBKQB5N6Ixu57zR5B6Q7p6D1HITaIkw7g3s0JGopKolw/a9mOSAtNs38J92 fJ2AxhzMbAKxA5l8BgBrGdnfJgRJ1rIz37BUwKaSLIDCM6yQ9KVw5xgsm8w3vmX9ecOJ sXDqlz0IfSc6hvL3cF5o415Zs4QAhshK1ZXO/xBMDq3kRA11kVZnSgIJ9eWYMH5i+u3r VAvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=1ODBY96fFBqFt8d2xGKeYGO05SitY939t1BYMg+dfjI=; b=HfLjz8IrqkfHewR45/+i7WNGYm45TUpIqYHevKinrEz656hK6jxh/ODpHHipO6fpMn TTRaxD0E/AcOpbE2sTy85cJh6QnsHFzCaUNkGqrT3R10X/7+nvRQmEFM8DsWkxPnj0V5 U6e8Tr6kpib0EmTgWEKbpp58b31ltQn5xNQpXQ8s2Sj8WQWQBWU24Ezd0S5AF3AU4Y2C LkglDqPatPCW5jbBSnBqM7IUnsN1/GKrlB8/9J9fH2RQojjP+0A9MFccW/eFDV0hNJ6D MkiWVRMHmIZ9hHbmdOHIIRmYGQ93ZKScGGpOZRJrKHioNXqftkjGBJGHUx4d0gglXwji ScXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=OWpVEPmu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id fi11si2466705ejb.378.2020.12.17.03.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 03:28:50 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=OWpVEPmu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 147F482BAD; Thu, 17 Dec 2020 12:28:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com 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=samsung.com header.i=@samsung.com header.b="OWpVEPmu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA9EC82BAB; Thu, 17 Dec 2020 12:28:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5921D82BAA for ; Thu, 17 Dec 2020 12:28:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201217112755euoutp016d93fb2f3062c4ac416cdb135bf8cce4~RfXNANkCx1618916189euoutp010 for ; Thu, 17 Dec 2020 11:27:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201217112755euoutp016d93fb2f3062c4ac416cdb135bf8cce4~RfXNANkCx1618916189euoutp010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608204475; bh=1ODBY96fFBqFt8d2xGKeYGO05SitY939t1BYMg+dfjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OWpVEPmua5Ldurr4k/+OcpqRbjcINHDLp9NbMG1qXqri+Uvjty10kEntNj5/Clxi1 PciNER8+728E+0ZMkZqTGD2IZklBJbmzEYBU1uWNL1th3kuMxJKeXj+D/a3vZw/7Rn SCc4/PnkhyHlFr7kmseO+tYpiLlPuwjgFBGA5QlU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201217112746eucas1p10bf155710cef87351a262d038091866b~RfXD7uY1J1172811728eucas1p1u; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C0.41.27958.2B04BDF5; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201217112745eucas1p1119fe18d3b05e3f9555f9587c83d4a97~RfXDe6UbT1172811728eucas1p1t; Thu, 17 Dec 2020 11:27:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201217112745eusmtrp29a269ec7d2ab90c06f4a336671b1eba1~RfXDeSgFU2731127311eusmtrp2f; Thu, 17 Dec 2020 11:27:45 +0000 (GMT) X-AuditID: cbfec7f2-f15ff70000006d36-e0-5fdb40b284fb Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C7.F0.16282.1B04BDF5; Thu, 17 Dec 2020 11:27:45 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201217112745eusmtip2355bdee15ebbb1e1b553cf0556b5c563~RfXDFfI4A2844828448eusmtip2e; Thu, 17 Dec 2020 11:27:45 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Cc: Marek Szyprowski , Lukasz Majewski , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH 1/6] disk: dos: rename write_mbr_partition to write_mbr_sector Date: Thu, 17 Dec 2020 12:27:34 +0100 Message-Id: <20201217112739.5045-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217112739.5045-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7djPc7qbHG7HG3xfwGaxccZ6Vosbv9pY LZ6/u8xksfbIXXaLb1u2MVq83dvJbnF46gdGB3aP2Q0XWTzmzTrB4vHhY5zH2Ts7GD36tqxi DGCN4rJJSc3JLEst0rdL4Mro7bzOVtApUHHpxCW2BsYJvF2MnBwSAiYSO1fcY+li5OIQEljB KPHgyWRmCOcLo8T5mVOhnM+MEuu/bWCDaXndP4UZxBYSWM4ocb+rHK7jRNNtsASbgKFE19su sAYRAQmJX/1XGUGKmAX+MUoc/PWRFSQhLBAgsXz9MRYQm0VAVeJ2+zGwOK+AjcTbaTOYIbbJ S6zecADI5uDgFLCVWN5eBjJHQmAmh0TLg/eMEDUuErtm7oS6Tlji1fEt7BC2jMT/nfOZIBqa GSUenlvLDuH0MEpcbpoB1W0tcefcLzaQDcwCmhLrd+lDhB0lHj85zQ4SlhDgk7jxVhAkzAxk Tto2nRkizCvR0SYEUa0mMev4Ori1By9cgjrfQ2LXljWMkACawCixbu1D5gmM8rMQli1gZFzF KJ5aWpybnlpsmJdarlecmFtcmpeul5yfu4kRmCZO/zv+aQfj3Fcf9Q4xMnEwHmKU4GBWEuFN OHAzXog3JbGyKrUoP76oNCe1+BCjNAeLkjjvqtlr4oUE0hNLUrNTUwtSi2CyTBycUg1MGbNm tfFN2X9znvgiyXqp3paKNneGnb6a8/kmf1vNlvmgctraG6vZvm/f80v7hFDCvEJ3uaXebAc2 5cXO7pj9+Qejkam83M9MkctPj2u9l/kt1NJ3qPThrAMBnfHLwoqvZr7d1SmiFftwfnxOtz23 7T3Lh50lpw6s8nwqw2/+Xef6PX6dpAe903u0v/+J6eNPWV56atkOhfhWW6mm9TsXX+fvdpDZ meSmLqC3dJ3k6Wund7pGlLzdfv7hwXSp5CsL6hh1dL3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1+DdcJT1mPfmO8v5 265t377nTvEl8fy7W75mtSuxFGckGmoxFxUnAgDrafW14gIAAA== X-CMS-MailID: 20201217112745eucas1p1119fe18d3b05e3f9555f9587c83d4a97 X-Msg-Generator: CA X-RootMTR: 20201217112745eucas1p1119fe18d3b05e3f9555f9587c83d4a97 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201217112745eucas1p1119fe18d3b05e3f9555f9587c83d4a97 References: <20201217112739.5045-1-m.szyprowski@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean write_mbr_partition() function name is a bit misleading, so rename it to write_mbr_sector(). This is a preparation for adding code for writing a complete MBR partition layout. Signed-off-by: Marek Szyprowski --- disk/part_dos.c | 2 +- drivers/fastboot/fb_mmc.c | 2 +- include/part.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/disk/part_dos.c b/disk/part_dos.c index 04f53106f7..ef706fb59c 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -329,7 +329,7 @@ int is_valid_dos_buf(void *buf) return test_block_type(buf) == DOS_MBR ? 0 : -1; } -int write_mbr_partition(struct blk_desc *dev_desc, void *buf) +int write_mbr_sector(struct blk_desc *dev_desc, void *buf) { if (is_valid_dos_buf(buf)) return -1; diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c index ae8e8e512f..4e26cef941 100644 --- a/drivers/fastboot/fb_mmc.c +++ b/drivers/fastboot/fb_mmc.c @@ -508,7 +508,7 @@ void fastboot_mmc_flash_write(const char *cmd, void *download_buffer, fastboot_fail("invalid MBR partition", response); return; } - if (write_mbr_partition(dev_desc, download_buffer)) { + if (write_mbr_sector(dev_desc, download_buffer)) { printf("%s: writing MBR partition failed\n", __func__); fastboot_fail("writing MBR partition failed", response); diff --git a/include/part.h b/include/part.h index 55be724d20..67b8b2a5cc 100644 --- a/include/part.h +++ b/include/part.h @@ -465,14 +465,14 @@ int get_disk_guid(struct blk_desc *dev_desc, char *guid); int is_valid_dos_buf(void *buf); /** - * write_mbr_partition() - write DOS MBR + * write_mbr_sector() - write DOS MBR * * @param dev_desc - block device descriptor * @param buf - buffer which contains the MBR * * @return - '0' on success, otherwise error */ -int write_mbr_partition(struct blk_desc *dev_desc, void *buf); +int write_mbr_sector(struct blk_desc *dev_desc, void *buf); #endif From patchwork Thu Dec 17 11:27:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 344926 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1077386jai; Thu, 17 Dec 2020 03:29:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJygv6FOxaWjhHRA9XFU0RyS/GyfsrT9ehIFoQ7HpbP9JCdyAVjTe7GjVrHKGsYaGSDClU+u X-Received: by 2002:a17:906:94ca:: with SMTP id d10mr33250930ejy.62.1608204553318; Thu, 17 Dec 2020 03:29:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608204553; cv=none; d=google.com; s=arc-20160816; b=koh3/zsiA9FcIH6IWhVP5cUlNvX/1pvZvnnCL+fcl9p2bQRWgSPZ/lGPpA442NwEll DLuVGTN3h0/t3LBLZ/A8JRJb1bS7AgW/PtVmUC110pHESEnz28+wBOqERAt9uyFY2/4D 6h8GIyLpiDBNbWm0EQzVKrcS28OMOnswzXTm/2sjD+pZW5tiDkayEqJhQcnGWlSb1Uze KCUH+HvEpnPWaHTgwPp+Ut/B6UdhGev3N9P3JAvj6sTXr0Dz8ObvpTSM8eVFWw8GeJDd j6fGuXJzWmqRjQTcDVHJ/LRbNjp04mPMDVlZBl/KSq/GKM0If3CEB4Tf9xeEg4zQ2RvB Uvtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=Ugopsy/ZxytmB8ap3xn0lUro0TDiqP7g+knq07e92AU=; b=wiw76WTVo+ecF0EYK6Fy/X9KIUOiVwNtoBJI+u9FiWfytLuuuMvGvjXohediB+16S5 t8WHdLXqA3SS1qWPQNKP4IlrXrmEUNQ+2QSrXnTyhOGMJWVXokudFKS4fGoj3pFIzGrm /3Ar0yNqqmB0+X78za0BBYNqsdWySC4N2XduEaU61OD9ViFwyzyeNtoFo/p6JxES1Gkm 0OZ4O4AUWe+90RX+kKQSbhdremMw45IL5FGt3I5Fp2UULpo78rgYZojl/rppLt7smy8+ v3KqFw40WjudFVrd51vTylGL4GIFCiEC6e+QImfvx2Qftcm5QKN7nyuVZnIhNohA/veO sy+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=bai8TmLw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id v25si2481876ejx.201.2020.12.17.03.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 03:29:13 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=bai8TmLw; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91BFB82BB7; Thu, 17 Dec 2020 12:28:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com 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=samsung.com header.i=@samsung.com header.b="bai8TmLw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BA7D882BB7; Thu, 17 Dec 2020 12:28:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1923682BA9 for ; Thu, 17 Dec 2020 12:28:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201217112759euoutp02cba49467cf288efa86e33d4405baf10d~RfXQjbbB_2632826328euoutp02j for ; Thu, 17 Dec 2020 11:27:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201217112759euoutp02cba49467cf288efa86e33d4405baf10d~RfXQjbbB_2632826328euoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608204479; bh=Ugopsy/ZxytmB8ap3xn0lUro0TDiqP7g+knq07e92AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bai8TmLwJHqWSC8yPEp+xr/umqqqijT4KNxOcdZyBhOR2tWavdnRjeoYhni5529T/ PSRQpDS90VrD/jQGL97Pyly8IFtqpVIIOcIJMsAxf0va/C76qMTBdRVrLHLB5x1W1r CLcHHjjQndAooyoMR9Jo9fTIwSGKJ8Eafnq71nkw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201217112746eucas1p1db9462ab77f1880cae59da39bbab64fa~RfXEONUKf3084730847eucas1p1Z; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id E6.2B.44805.2B04BDF5; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201217112746eucas1p175764b65c7fedac5cf13ee4a29259fe3~RfXD0J0rq1609016090eucas1p1f; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201217112746eusmtrp2ac81e7fcc7bf5446501d15a50d7fe783~RfXDzd02J2732627326eusmtrp2E; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) X-AuditID: cbfec7f4-b4fff7000000af05-a1-5fdb40b2eeaf Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 78.F0.16282.1B04BDF5; Thu, 17 Dec 2020 11:27:45 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201217112745eusmtip280b7ed94a98ba4bb7ff954d408d854e3~RfXDa0bVv2634826348eusmtip2p; Thu, 17 Dec 2020 11:27:45 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Cc: Marek Szyprowski , Lukasz Majewski , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH 2/6] disk: dos: add some defines for the hardcoded numbers Date: Thu, 17 Dec 2020 12:27:35 +0100 Message-Id: <20201217112739.5045-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217112739.5045-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSa0xSYRj25RzgSOFOaPmtbCbTti5qVj/YslIzpbJlF7tYC6nO1KloHLGy WcyaAjolL9PJVCpNsygzZoWxlVZkNzNHdtHWvY0yJa0lUys6ZP+e2/s827ePwASD+EwiWZZJ yWXSVCGHh7feGe0KbAl7KVlUWectulR5kS165shjiz597WGJDLf6uaIfxlYQDZjVXFFH+RCE ccU6ZTcurqm6i4uH7LvFD/uugrjI2ASx7Hhe6D4qNTmLkgevSOAlfWk5Bxlq3sHvo0a2EqoJ DbgTiFyKfn5oxjXAIwRkIyDHu1cuMgKowDwEDBkGZDM95P47sVYoXUYDoNudb2HyZCJ3lOVM ccgQpBnQcJzYi0TIUWz9G8LICUA3HXa20/Ak16Lv+o6/tTgZgD42qnAn5pOh6LSu1zXni841 38A0QBDu5HLUkJ/l7EFkNYE67eO4U0dkJCodYDNxT2SzGF2nPujXtVoWkz8G6M0jA5chhYB6 ciuBSS1DfY8cHGcRRs5DF03BjByOzF0qNtPvgZ4NTHPK2B9Y0lqBMTIfqfI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NOHAz Xog3JbGyKrUoP76oNCe1+BCjKdAZE5mlRJPzgVGTVxJvaGZgamhiZmlgamlmrCTOa3JkTbyQ QHpiSWp2ampBahFMHxMHp1QDk01PnIjrugULOr7rRN/4t+vEv/OJ149rp3/7xG2/hdHA6cTn dSYTmG5IegeySK1cNcWz3/HKfN2r7g+ir17onqP4RfDHjm1sU9K+XctmihJSXXLtU2Pls9ea 99Kdeu7vnaE7O1mlMPyO1L+aTXfWGUa1q3XPUJjqJScmxClTcbXYcr12WtTBLRsO2a2Va2BS maSU37Hj2F+Z9bfe7E7YL76xJ9xzbupFFsefOlzGPFmpomYmR5/FCddM+8TqM1csp/bTdglj 95k3Ap8cPJw6fVG9N9vqNw4V92fNW3rx4ZX706PWL2t7JFCdP+XK1Ym83gfFrs6SOrU6+U3t uZVuvTlKMv55we1/J0gvEne9M12JpTgj0VCLuag4EQBo+/L24gIAAA== X-CMS-MailID: 20201217112746eucas1p175764b65c7fedac5cf13ee4a29259fe3 X-Msg-Generator: CA X-RootMTR: 20201217112746eucas1p175764b65c7fedac5cf13ee4a29259fe3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201217112746eucas1p175764b65c7fedac5cf13ee4a29259fe3 References: <20201217112739.5045-1-m.szyprowski@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Add some handy defines for some hardcoded magic numbers related to extended partition handling. Signed-off-by: Marek Szyprowski --- disk/part_dos.c | 6 +++--- disk/part_dos.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/disk/part_dos.c b/disk/part_dos.c index ef706fb59c..20d35dc9cd 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -42,9 +42,9 @@ static inline unsigned int le32_to_int(unsigned char *le32) static inline int is_extended(int part_type) { - return (part_type == 0x5 || - part_type == 0xf || - part_type == 0x85); + return (part_type == DOS_PART_TYPE_EXTENDED || + part_type == DOS_PART_TYPE_EXTENDED_LBA || + part_type == DOS_PART_TYPE_EXTENDED_LINUX); } static int get_bootable(dos_partition_t *p) diff --git a/disk/part_dos.h b/disk/part_dos.h index 434b021ae8..dd909a9317 100644 --- a/disk/part_dos.h +++ b/disk/part_dos.h @@ -15,6 +15,9 @@ #define DOS_PBR_MEDIA_TYPE_OFFSET 0x15 #define DOS_MBR 0 #define DOS_PBR 1 +#define DOS_PART_TYPE_EXTENDED 0x05 +#define DOS_PART_TYPE_EXTENDED_LBA 0x0F +#define DOS_PART_TYPE_EXTENDED_LINUX 0x85 typedef struct dos_partition { unsigned char boot_ind; /* 0x80 - active */ From patchwork Thu Dec 17 11:27:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 344923 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1077037jai; Thu, 17 Dec 2020 03:28:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwo6CK+Ykm37FCaw7G7aNP7beAeqVSCls+NKYlvu8gComlOml6wuZXs9XPSXsqw/+c/cOAY X-Received: by 2002:a17:906:417:: with SMTP id d23mr34851521eja.19.1608204519229; Thu, 17 Dec 2020 03:28:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608204519; cv=none; d=google.com; s=arc-20160816; b=ll+8eu3CTEv2MP914AebhsYE1H6ga16Fb/1HxUQIF+CWegnz16c1xhVSNw4gKxM1CD 1jdwv03Rea6xpF7WfnlHfy8R8n30LFGaFHKk3eLx9YRzEQptzjceqP0FsL4DEAngyWN/ fOiFkmJ6i38tl/EfPh5Yk2lYjUlqeTT0L8wADQuebFCgTbp+J/8WvDhYJfXmwZt0H+fw u8wMmfSS3eTeHapm19xBp9rbvVnXtIcRyPUxh6IGK4sQvz5x12DcX6+jpw7KbfT7ZSXJ IjM5FjAPmFDbOWrUjbjaZ0/NYB2y1aeo9jQ9/Q7kuYm10WlPkxdGUmFfEaYP0p5PU55f H03w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=F6V+qSwemnBQzCEmGI+kufqwnsfQVkuy9Ib33MTjCQw=; b=cdQS4RSrGduGOGDqnKaZXtKtwAXaYdLJzTCmy5XY16eO4rK9z6I0qXrMfMhpEymE09 sjRR11783hk2l4rm59KT0niBTy/LlYLqIVI6Xi54Nykns/cNXXFE6OtrVCqE9pqEbqoL r1exm3jRLe0veHU57WKVX2ImVHe+vP/mQrRQNlWp81U9mrc+16cG0z/MKFf76S/FUB88 RzSTOheP/WH4cev3Cnz2BbJH2y2OWnlHwBi47FjD7u/efyfW+nUy5qX7N+/gEf3aMsdX i+0sayZr0uO/DohvjGgsOmJchcSD6vFWHGxe3vfJ/2jrGQoA/mpXAAXkegCPNU8EqE2p M4ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=d8gESg0y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ga28si2537851ejc.221.2020.12.17.03.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 03:28:39 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=d8gESg0y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D693182BB3; Thu, 17 Dec 2020 12:28:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com 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=samsung.com header.i=@samsung.com header.b="d8gESg0y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ADE2C82BA6; Thu, 17 Dec 2020 12:28:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 93F98826A7 for ; Thu, 17 Dec 2020 12:28:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201217112752euoutp0289aa9def6e7d39a59b3781049d82c079~RfXJlj2tS2518325183euoutp02f for ; Thu, 17 Dec 2020 11:27:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201217112752euoutp0289aa9def6e7d39a59b3781049d82c079~RfXJlj2tS2518325183euoutp02f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608204472; bh=F6V+qSwemnBQzCEmGI+kufqwnsfQVkuy9Ib33MTjCQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d8gESg0ygmryu2a7sVImLzrjTLFhX+p+MK70s9eFAl0s0dzyFI6RbzZIArfIUM/Jp 9LlMa+2ep+lA0R9lMGdcLs+khK7wFZsite35wlUqlpVbLbMj4++MYTE2SFUex6eCZ9 17zKKnZCFpgYX5xSOk5chdPPMBe3swpyJFhvuYqg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201217112746eucas1p142f3266aac9681806833a64a158b36a0~RfXElV1yz1194011940eucas1p10; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 91.41.27958.2B04BDF5; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201217112746eucas1p28380ab10ea3b33a963dd4f73afecc43c~RfXEJuoH-0440704407eucas1p2l; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201217112746eusmtrp1e97b0de1c3e38848b146d41e9a7375b2~RfXEJIc6d0498804988eusmtrp1g; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) X-AuditID: cbfec7f2-f15ff70000006d36-e4-5fdb40b29e98 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 1D.73.21957.2B04BDF5; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201217112745eusmtip2af74e0343848c2721626289534c9b316~RfXDwHDAZ3162131621eusmtip2P; Thu, 17 Dec 2020 11:27:45 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Cc: Marek Szyprowski , Lukasz Majewski , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH 3/6] disk: dos: use generic macro for unaligned le32 access Date: Thu, 17 Dec 2020 12:27:36 +0100 Message-Id: <20201217112739.5045-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217112739.5045-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHIsWRmVeSWpSXmKPExsWy7djPc7qbHG7HGxzap2WxccZ6Vosbv9pY LZ6/u8xksfbIXXaLb1u2MVq83dvJbnF46gdGB3aP2Q0XWTzmzTrB4vHhY5zH2Ts7GD36tqxi DGCN4rJJSc3JLEst0rdL4Mo41tXFWnBIuuL86hPMDYxrxLoYOTkkBEwkrl29wt7FyMUhJLCC UWL6p8/MEM4XRom7EyawQDifGSUaP3xihGn5+fQCC4gtJLCcUeLIdUYIG6jj0B8hEJtNwFCi 620XG4gtIiAh8av/KiPIIGaBf4wSB399ZAVJCAt4S2z91gTWzCKgKvH/ex8ziM0rYCMx9/Ft dohl8hKrNxwAinNwcArYSixvLwOZIyEwk0Pi9MWTrBA1LhJ7LjxghrCFJV4d3wLVKyNxenIP C0RDM6PEw3Nr2SG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7G8vQwkLARU8uHsJsYJjHwLGBlWMYqk lhbnpucWG+oVJ+YWl+al6yXn525iBIbstmM/N+9gnPfqo94hRiYOxkOMEhzMSiK8CQduxgvx piRWVqUW5ccXleakFh9iNAU6YyKzlGhyPjBq8kriDc0MTA1NzCwNTC3NjJXEebfOXRMvJJCe WJKanZpakFoE08fEwSnVwBSgzaq+q+nKXdFbs2/tuX7pzgrbPOPuN+s1js/c1qpvXvbqi0Z5 xM4aNt09WUtv71J7fMhYZfkuJucJZcI+t+Vcen5eC8o/JrGzbctf7cSPKp0L2UwqXe8ZLnV/ YiB9bN7DqdtnZNx1+yN43/+3qqlA4oaPDBO/i9s+tg8Na3gWFP3AMq2l+9Xyc49PfTp09IvF Ivf6+S+uMR7ZND29alLSysq7TeqbDTls3TOvqO/gCP3AVGGQmXXfZ6ETx7S7XLemec1afkuI p1hhzq13U55rPJ1z3/mBqJuP4dSHfwVe6M0+fMYneYPiDjEZieVXd5oJ2pRWznhj+ePw9ZSW bVs3Hs/g2fkrZPk0c++KhTUySizFGYmGWsxFxYkA5WsIUuICAAA= X-CMS-MailID: 20201217112746eucas1p28380ab10ea3b33a963dd4f73afecc43c X-Msg-Generator: CA X-RootMTR: 20201217112746eucas1p28380ab10ea3b33a963dd4f73afecc43c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201217112746eucas1p28380ab10ea3b33a963dd4f73afecc43c References: <20201217112739.5045-1-m.szyprowski@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Use a generic helper for reading LE32 integers. Signed-off-by: Marek Szyprowski --- disk/part_dos.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/disk/part_dos.c b/disk/part_dos.c index 20d35dc9cd..3b79b9b1b8 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "part_dos.h" #include @@ -29,17 +30,6 @@ * to use large numbers of partitions */ #define MAX_EXT_PARTS 256 -/* Convert char[4] in little endian format to the host format integer - */ -static inline unsigned int le32_to_int(unsigned char *le32) -{ - return ((le32[3] << 24) + - (le32[2] << 16) + - (le32[1] << 8) + - le32[0] - ); -} - static inline int is_extended(int part_type) { return (part_type == DOS_PART_TYPE_EXTENDED || @@ -61,8 +51,8 @@ static int get_bootable(dos_partition_t *p) static void print_one_part(dos_partition_t *p, lbaint_t ext_part_sector, int part_num, unsigned int disksig) { - lbaint_t lba_start = ext_part_sector + le32_to_int (p->start4); - lbaint_t lba_size = le32_to_int (p->size4); + lbaint_t lba_start = ext_part_sector + get_unaligned_le32(p->start4); + lbaint_t lba_size = get_unaligned_le32(p->size4); printf("%3d\t%-10" LBAFlength "u\t%-10" LBAFlength "u\t%08x-%02x\t%02x%s%s\n", @@ -171,7 +161,7 @@ static void print_partition_extended(struct blk_desc *dev_desc, } if (!ext_part_sector) - disksig = le32_to_int(&buffer[DOS_PART_DISKSIG_OFFSET]); + disksig = get_unaligned_le32(&buffer[DOS_PART_DISKSIG_OFFSET]); /* Print all primary/logical partitions */ pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET); @@ -198,7 +188,7 @@ static void print_partition_extended(struct blk_desc *dev_desc, for (i = 0; i < 4; i++, pt++) { if (is_extended (pt->sys_ind)) { lbaint_t lba_start - = le32_to_int (pt->start4) + relative; + = get_unaligned_le32 (pt->start4) + relative; print_partition_extended(dev_desc, lba_start, ext_part_sector == 0 ? lba_start : relative, @@ -244,7 +234,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc, #if CONFIG_IS_ENABLED(PARTITION_UUIDS) if (!ext_part_sector) - disksig = le32_to_int(&buffer[DOS_PART_DISKSIG_OFFSET]); + disksig = get_unaligned_le32(&buffer[DOS_PART_DISKSIG_OFFSET]); #endif /* Print all primary/logical partitions */ @@ -260,8 +250,8 @@ static int part_get_info_extended(struct blk_desc *dev_desc, (ext_part_sector == 0 || is_extended(pt->sys_ind) == 0)) { info->blksz = DOS_PART_DEFAULT_SECTOR; info->start = (lbaint_t)(ext_part_sector + - le32_to_int(pt->start4)); - info->size = (lbaint_t)le32_to_int(pt->size4); + get_unaligned_le32(pt->start4)); + info->size = (lbaint_t)get_unaligned_le32(pt->size4); part_set_generic_name(dev_desc, part_num, (char *)info->name); /* sprintf(info->type, "%d, pt->sys_ind); */ @@ -286,7 +276,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc, for (i = 0; i < 4; i++, pt++) { if (is_extended (pt->sys_ind)) { lbaint_t lba_start - = le32_to_int (pt->start4) + relative; + = get_unaligned_le32 (pt->start4) + relative; return part_get_info_extended(dev_desc, lba_start, ext_part_sector == 0 ? lba_start : relative, From patchwork Thu Dec 17 11:27:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 344920 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1076719jai; Thu, 17 Dec 2020 03:28:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRpj47Y4WOXBTmZY5leZF3I0q23d/hYvFYKr77KNdzdVGbX+eLDIdGL1IzvrMMLhTxaDhk X-Received: by 2002:a50:d757:: with SMTP id i23mr38287702edj.116.1608204486734; Thu, 17 Dec 2020 03:28:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608204486; cv=none; d=google.com; s=arc-20160816; b=pibhCSDfUG2GS6xfFwV8kfa+y10CBO5qph3wfI9Zvcfu5R2rlKTYsRGXqiaicdfg8V cYJKdUzWTY5qNLmZxQzS/TV5JQALGDaR5p6fuCJgdxTp8cOfLVlgAB9AW0KJyxlh9MrP a81sfhxAuioO9VF9369DhcFc90c6kMWs8qLAGtaBw1kuGU9rugSzvR5QO6P9ilVvBS8N 68FVsnLp6+R1N6OjbvAzGbNmYhRnYQ0i4xOVKxHkHys47pRp4WmoYullAL6R33b+Q3kI GJVRdU6VJzwHQ2NkeBnQeonBwyaO9mWlRD8gQxQQA+cWyq3pUITbV4VR3lgB0WVcry5E fv5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=QVv/OpDO86vbjc8WTV2cueIe9E1CfauEIcaW529qV2w=; b=X1HOhnKk3beQ3tDjE39lTPvAmJGaEI/qagIgg+jRAml2Ap0T62DigZp7Kl2VKTD1Ua Sj+BBrq9NfsHs0xfzCF5MmWvIwmnKL78h1fBfH2ev4p6QKJjp3uP7T18g/BWcbyfkzcc /CCoqRoWoRmJg5iRvoQJkVuimK7KNP7Rh1f4Mc80o0iEkHK+FuIFbrxxwZWsn+lGcl0s zFcBS3TwNHAAq/PeZ+mqNo1i3c63rVtKteV5v1T/UHo868fAAjyixDFpV/x/KcX2zwIH x6yEgsCBXE0cyRVyklMx1siFuxjjLdhh+EagmGxmr75PYcll2WuWji996tkUc9b+Zn4M S1tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=l8UZBTFo; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id co1si4181498edb.571.2020.12.17.03.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 03:28:06 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=l8UZBTFo; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B8AA682BA1; Thu, 17 Dec 2020 12:28:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com 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=samsung.com header.i=@samsung.com header.b="l8UZBTFo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1F3AD82BA1; Thu, 17 Dec 2020 12:28:01 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 75EAF826A7 for ; Thu, 17 Dec 2020 12:27:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201217112747euoutp01f7fdc83189cf44847c80e8f67b009b95~RfXFMFGv_1619716197euoutp01p for ; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201217112747euoutp01f7fdc83189cf44847c80e8f67b009b95~RfXFMFGv_1619716197euoutp01p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608204467; bh=QVv/OpDO86vbjc8WTV2cueIe9E1CfauEIcaW529qV2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l8UZBTFovJCl4xUz1ZJpNzTFUvVTMRps6J7Fxg4xaumTJyItPOjoYYFAQtH7057Q4 YQzMIJafUlAnBPKCNW2Aic5IjdKpCs3f56d3R4QrWwejb2F7b6MIVd8L++O0O9TrYR +EAubuondkTMHG006igOWCRC40BIm5/Vzi1kgTPE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201217112747eucas1p13cd35af1e21044e762745d30938667d2~RfXE7RaOE3085230852eucas1p1h; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 87.2B.44805.3B04BDF5; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201217112746eucas1p219413adf54a50853ff6272b753452660~RfXEhEzBz0440304403eucas1p2g; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201217112746eusmtrp25d93c7c02c6ae4443ce8d7bc2d1dff3e~RfXEgf3rh2732627326eusmtrp2G; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) X-AuditID: cbfec7f4-b4fff7000000af05-a3-5fdb40b3a268 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A9.F0.16282.2B04BDF5; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201217112746eusmtip2910bba754a6fd8f97bd98c170f359752~RfXEFqKJN3181331813eusmtip2O; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Cc: Marek Szyprowski , Lukasz Majewski , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH 4/6] disk: dos: make some functions static Date: Thu, 17 Dec 2020 12:27:37 +0100 Message-Id: <20201217112739.5045-5-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217112739.5045-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7djPc7qbHW7HG3zbxWqxccZ6Vosbv9pY LZ6/u8xksfbIXXaLb1u2MVq83dvJbnF46gdGB3aP2Q0XWTzmzTrB4vHhY5zH2Ts7GD36tqxi DGCN4rJJSc3JLEst0rdL4MrYtvMKe8FU9oqpd++wNjD+Zu1i5OSQEDCRuDFvKpDNxSEksIJR ou/WHRYI5wujRNP8M2wQzmcgZ9ovRpiW1hW3oRLLGSWun37EBNeyZv1CsCo2AUOJrrddbCC2 iICExK/+q4wgRcwC/xglDv76CLZdWMBK4uoaiLEsAqoSGx+8B4vzCthIvDq2C+pCeYnVGw4w dzFycHAK2Eosby8DmSMhMJNDovPXLXaQuISAi8Sr1zUQ5cISr45vYYewZST+75zPBFHfzCjx 8Nxadginh1HictMMqH+sJe6c+8UGMohZQFNi/S59iLCjxLX7dxkh5vNJ3HgrCBJmBjInbZvO DBHmlehoE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MF4iFGCg1lJhDfhwM14Id6U xMqq1KL8+KLSnNTiQ4ymQGdMZJYSTc4HRk1eSbyhmYGpoYmZpYGppZmxkjivyZE18UIC6Ykl qdmpqQWpRTB9TBycUg1MSd9yOUqeT1z058CHcN7i4OS9U7vLc3OmyE/TW5ey7+OyCQK/3iUm FEVdaVpRdvMum/+Ud796f0xSzYqf7Kp2YXcue5u5e0Cg4hmzi/MvbQo4/2VvPUOpEc9Gx+PP Iup2Lf+/vSKx72VKVnNVTb0D/+uz8Rk3AxR+rg8z+Fu2/sNl+aycU25S346UxK159/ebbp2c pmC2XOfPN+3hzlsNd9ks3K7vtSfv6YGAed+Wf7Ku080J7j6wbnbR42q+h7MrhH/srLU4FbS6 vUXv+RIuzp1Lzq1geXOw99/vP3rW6+SeFPj/LKufsGP6h/yluyRmbdvx6EvO5Ss3N2RNFbkq fnLi1nDrhU93Kij++bNej0eJpTgj0VCLuag4EQDSeuRW4gIAAA== X-CMS-MailID: 20201217112746eucas1p219413adf54a50853ff6272b753452660 X-Msg-Generator: CA X-RootMTR: 20201217112746eucas1p219413adf54a50853ff6272b753452660 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201217112746eucas1p219413adf54a50853ff6272b753452660 References: <20201217112739.5045-1-m.szyprowski@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Make functions not used outside this file static. Signed-off-by: Marek Szyprowski --- disk/part_dos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/disk/part_dos.c b/disk/part_dos.c index 3b79b9b1b8..2c4ad0b6ba 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -302,13 +302,13 @@ static int part_get_info_extended(struct blk_desc *dev_desc, return -1; } -void part_print_dos(struct blk_desc *dev_desc) +static void part_print_dos(struct blk_desc *dev_desc) { printf("Part\tStart Sector\tNum Sectors\tUUID\t\tType\n"); print_partition_extended(dev_desc, 0, 0, 1, 0); } -int part_get_info_dos(struct blk_desc *dev_desc, int part, +static int part_get_info_dos(struct blk_desc *dev_desc, int part, struct disk_partition *info) { return part_get_info_extended(dev_desc, 0, 0, 1, part, info, 0); From patchwork Thu Dec 17 11:27:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 344921 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1076821jai; Thu, 17 Dec 2020 03:28:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdP23YE0RvhtED1ncWJTbeeD3qnMCM+7+eGf95aBSj3xVG0gyRworoLmQBqYmSyU1Ri+Ep X-Received: by 2002:a17:906:4544:: with SMTP id s4mr1988355ejq.366.1608204497295; Thu, 17 Dec 2020 03:28:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608204497; cv=none; d=google.com; s=arc-20160816; b=hBz8lVJY8KDcSlKeSY899BP9c7XT/2b693E/KEIWe5WmVd/vIvlQ/Zv/+T0Hc78wOS t1sdd7fop0G615QdzXL3D1vjhJafhE0N4JFYKG46V6/4NRkvMSR/PxBRSQej+E0tB55Q EXjeEgNJIpqszR6FHJQ8rTnaxMEScTFybcgVAzg2MdSYkGZ2lk2fkTJ5p9yQ8K0tQM4+ cnnvCV8Tr1xW6RgU8Ra0w7tM3BnUAk7n+MgGQ5bMat2MOW4Gnf1Zwn61ImSAUn3PbLDB 6wiuaVJzut7SIBMgIEEhPY9FRXiEr9raUOO+LheD70J0WCs/yY31IZ7vSJBrmeM5zj2p xPkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=k9oMBZwID77q6mtg2L5cpHL5kStBnaPFM2CjIM8gmj0=; b=0QNBX8HzmlGwU1ebCLxgisBK7OpS4SU00jJ6KeC5hL6BGqjWbahqbO/nabR+9EqCza jVjGuXfF37GjTeQABVy/6TRhmbXOUHwnOR37gvnF7Hpiomu7YgFdLGi6fik+L6tudMmR bbI28s83dbkzucSYtZdGj1RY/jN0QvQ4KqGyhKtETeanq1kx/CaJC9TVS5oCgeXonlmX QbwLae036UM+05Z80675++6O3Od9hCDwzSELnuAbZbPlRx53ThlM6WkG9otz7q3WwMZH xbNFjVVpKZr1HN+TI70HgMd7+FbMnVCONPE63RcLFFxCPyM4kYMP+y4XAksgyA3h4Mle SbYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ciZ8enUP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id n13si4210063eds.172.2020.12.17.03.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 03:28:17 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ciZ8enUP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C9C3B82B9F; Thu, 17 Dec 2020 12:28:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com 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=samsung.com header.i=@samsung.com header.b="ciZ8enUP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7E30482BA0; Thu, 17 Dec 2020 12:28:02 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9F28382B96 for ; Thu, 17 Dec 2020 12:27:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201217112747euoutp029be16fff6fd68f1f901d44c3777b7bb3~RfXFkzCFJ2518325183euoutp02d for ; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201217112747euoutp029be16fff6fd68f1f901d44c3777b7bb3~RfXFkzCFJ2518325183euoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608204467; bh=k9oMBZwID77q6mtg2L5cpHL5kStBnaPFM2CjIM8gmj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ciZ8enUPbuuTtcQY8eVnjpSxZmVwXVezJVUNhUHAQMMK9V4biuMNgedXnFoiGAqXM UaMFpu19yGD0NLQuSO2BMF3UF4FL1KcDf/rbEmolrDzwLKi/7UDYlP/pW0IKZlso5Y Oi4L6J4hFJ6l8lITSaadGVF67ym5+K8djPCWX7DI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201217112747eucas1p19ae7d5665e520857b947581c79cc9299~RfXFNRXit0731407314eucas1p17; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 28.2B.44805.3B04BDF5; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201217112747eucas1p2d701d716f010a08e19afb6c133432c0e~RfXE4yJlm0440704407eucas1p2m; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201217112747eusmtrp1cc4585efd676a8190da88bf02673fa50~RfXE4Ly_P0498804988eusmtrp1k; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) X-AuditID: cbfec7f4-b4fff7000000af05-a5-5fdb40b3391d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 5E.73.21957.3B04BDF5; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201217112746eusmtip2c555b0aa749741d858981bad6112ae09~RfXEdg4oY1639616396eusmtip2y; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Cc: Marek Szyprowski , Lukasz Majewski , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH 5/6] disk: dos: add code for creating MBR partition layout Date: Thu, 17 Dec 2020 12:27:38 +0100 Message-Id: <20201217112739.5045-6-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217112739.5045-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7djP87qbHW7HG0zslLHYOGM9q8WNX22s Fs/fXWayWHvkLrvFty3bGC3e7u1ktzg89QOjA7vH7IaLLB7zZp1g8fjwMc7j7J0djB59W1Yx BrBGcdmkpOZklqUW6dslcGUcW3qYsaDBsGLJ9x62BsY+tS5GTg4JAROJq+t+MncxcnEICaxg lDjY/JoRwvnCKHFm1h92COczo8TFc83MMC1fbt+DqlrOKPH50RsmuJaNm7+zglSxCRhKdL3t YgOxRQQkJH71XwXrYBb4B7Tk10ewImEBL4kn/XOBxnJwsAioSjzcmwsS5hWwkWi79hlqm7zE 6g0HwEo4BWwllreXgYyREJjJIfFt/lMmiBoXiX+njrFB2MISr45vYYewZSROT+5hgWhoZpR4 eG4tO4TTwyhxuWkGI0SVtcSdc7/YQDYwC2hKrN+lDxF2lJj2qQEsLCHAJ3HjrSBImBnInLRt OjNEmFeio00IolpNYtbxdXBrD164BHW+h8ST722skPCZwChx4OFFlgmM8rMQli1gZFzFKJ5a WpybnlpslJdarlecmFtcmpeul5yfu4kRmCZO/zv+ZQfj8lcf9Q4xMnEwHmKU4GBWEuFNOHAz Xog3JbGyKrUoP76oNCe1+BCjNAeLkjhv0p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939Pnl525fa26qS14hZXROxKvRo4 7F7qRT0w+v2EPSenUjXKvsdErPTs/KTJN3/PPmO2NlyA4dhBq2UVDgY3WI9/EbKxOVslqO8W 1LFQvEe7KWQrx7k1CipTrKfsnvyk7u2dj4ktcdGXYizNml8k3X5iNPPmrjUMmZwbmQ8lXprp uqFpO/e9VbufdhQ0a5QIz9zJzPM4LzLgcMYhceUv4SIXjYstfbSmuii4T2zbuO327FSF3RIp jPELHx8+mBP79mmz9f+Xri/NeLVvrHgzW9PtamXMmthLH21vrCyRXqzLdJtx2QWfyd+2G/QU dutmuJ1aMMtDbFfFv5ay4+1KLMUZiYZazEXFiQBTDKWc4QIAAA== X-CMS-MailID: 20201217112747eucas1p2d701d716f010a08e19afb6c133432c0e X-Msg-Generator: CA X-RootMTR: 20201217112747eucas1p2d701d716f010a08e19afb6c133432c0e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201217112747eucas1p2d701d716f010a08e19afb6c133432c0e References: <20201217112739.5045-1-m.szyprowski@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Add a code for creating and writing MBR partition layout. The code generates similar layout of EBRs (Exteneded Block Records) and logical volumes as Linux's fdisk utility. Signed-off-by: Marek Szyprowski --- disk/part_dos.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++ disk/part_dos.h | 2 + include/part.h | 5 ++ 3 files changed, 174 insertions(+) -- 2.17.1 diff --git a/disk/part_dos.c b/disk/part_dos.c index 2c4ad0b6ba..f77f927995 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -319,6 +319,173 @@ int is_valid_dos_buf(void *buf) return test_block_type(buf) == DOS_MBR ? 0 : -1; } +#if CONFIG_IS_ENABLED(CMD_MBR) +static void lba_to_chs(lbaint_t lba, unsigned char *rc, unsigned char *rh, + unsigned char *rs) +{ + unsigned int c, h, s; + /* use fixed CHS geometry */ + unsigned int sectpertrack = 63; + unsigned int heads = 255; + + c = (lba + 1) / sectpertrack / heads; + h = (lba + 1) / sectpertrack - c * heads; + s = (lba + 1) - (c * heads + h) * sectpertrack; + + if (c > 1023) { + c = 1023; + h = 254; + s = 63; + } + + *rc = c & 0xff; + *rh = h; + *rs = s + ((c & 0x300) >> 2); +} + +static void mbr_fill_pt_entry(dos_partition_t *pt, lbaint_t start, + lbaint_t relative, lbaint_t size, uchar sys_ind, bool bootable) +{ + pt->boot_ind = bootable ? 0x80 : 0x00; + pt->sys_ind = sys_ind; + lba_to_chs(start, &pt->cyl, &pt->head, &pt->sector); + lba_to_chs(start + size - 1, &pt->end_cyl, &pt->end_head, &pt->end_sector); + put_unaligned_le32(relative, &pt->start4); + put_unaligned_le32(size, &pt->size4); +} + +int write_mbr_partitions(struct blk_desc *dev, + struct disk_partition *p, int count, unsigned int disksig) +{ + ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev->blksz); + lbaint_t ext_part_start = 0, ext_part_size = 0, ext_part_sect = 0; + dos_partition_t *pt; + int i; + + memset(buffer, 0, dev->blksz); + buffer[DOS_PART_MAGIC_OFFSET] = 0x55; + buffer[DOS_PART_MAGIC_OFFSET + 1] = 0xaa; + put_unaligned_le32(disksig, &buffer[DOS_PART_DISKSIG_OFFSET]); + pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET); + + /* create all primary partitions */ + for (i = 0; i < 4 && i < count; i++, pt++) { + mbr_fill_pt_entry(pt, p[i].start, p[i].start, p[i].size, + p[i].sys_ind, p[i].bootable); + if (is_extended(p[i].sys_ind)) { + ext_part_start = p[i].start; + ext_part_size = p[i].size; + ext_part_sect = p[i].start; + } + } + + if (i < count && !ext_part_start) { + printf("%s: extended partition is needed for more than 4 partitions\n", + __func__); + return -1; + } + + /* write MBR */ + if (blk_dwrite(dev, 0, 1, buffer) != 1) { + printf("%s: failed writing 'MBR' (1 blks at 0x0)\n", + __func__); + return -1; + } + + /* create extended volumes */ + for (; i < count; i++) { + lbaint_t next_ebr = 0; + + memset(buffer, 0, dev->blksz); + buffer[DOS_PART_MAGIC_OFFSET] = 0x55; + buffer[DOS_PART_MAGIC_OFFSET + 1] = 0xaa; + pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET); + + mbr_fill_pt_entry(pt, p[i].start, p[i].start - ext_part_sect, + p[i].size, p[i].sys_ind, p[i].bootable); + + if (i + 1 < count) { + pt++; + next_ebr = p[i].start + p[i].size; + mbr_fill_pt_entry(pt, next_ebr, + next_ebr - ext_part_start, + p[i+1].start + p[i+1].size - next_ebr, + DOS_PART_TYPE_EXTENDED, 0); + } + + /* write EBR */ + if (blk_dwrite(dev, ext_part_sect, 1, buffer) != 1) { + printf("%s: failed writing 'EBR' (1 blks at 0x%lx)\n", + __func__, ext_part_sect); + return -1; + } + ext_part_sect = next_ebr; + } + + return 0; +} + +int layout_mbr_partitions(struct disk_partition *p, int count, + lbaint_t total_sectors) +{ + struct disk_partition *ext = NULL; + int i, j; + lbaint_t ext_vol_start; + + /* calculate primary partitions start and size if needed */ + if (!p[0].start) + p[0].start = DOS_PART_DEFAULT_GAP; + for (i = 0; i < 4 && i < count; i++) { + if (!p[i].start) + p[i].start = p[i - 1].start + p[i - 1].size; + if (!p[i].size) { + lbaint_t end = total_sectors; + lbaint_t allocated = 0; + + for (j = i + 1; j < 4 && j < count; j++) { + if (p[j].start) { + end = p[j].start; + break; + } + allocated += p[j].size; + } + p[i].size = end - allocated - p[i].start; + } + if (p[i].sys_ind == 0x05) + ext = &p[i]; + } + + if (i >= 4 && !ext) { + printf("%s: extended partition is needed for more than 4 partitions\n", + __func__); + return -1; + } + + /* calculate extended volumes start and size if needed */ + ext_vol_start = ext->start; + for (i = 4; i < count; i++) { + if (!p[i].start) + p[i].start = ext_vol_start + DOS_PART_DEFAULT_GAP; + if (!p[i].size) { + lbaint_t end = ext->start + ext->size; + lbaint_t allocated = 0; + + for (j = i + 1; j < count; j++) { + if (p[j].start) { + end = p[j].start - DOS_PART_DEFAULT_GAP; + break; + } + allocated += p[j].size + DOS_PART_DEFAULT_GAP; + } + p[i].size = end - allocated - p[i].start; + } + ext_vol_start = p[i].start + p[i].size; + } + + return 0; +} +#endif + int write_mbr_sector(struct blk_desc *dev_desc, void *buf) { if (is_valid_dos_buf(buf)) diff --git a/disk/part_dos.h b/disk/part_dos.h index dd909a9317..5055822422 100644 --- a/disk/part_dos.h +++ b/disk/part_dos.h @@ -19,6 +19,8 @@ #define DOS_PART_TYPE_EXTENDED_LBA 0x0F #define DOS_PART_TYPE_EXTENDED_LINUX 0x85 +#define DOS_PART_DEFAULT_GAP 2048 + typedef struct dos_partition { unsigned char boot_ind; /* 0x80 - active */ unsigned char head; /* starting head */ diff --git a/include/part.h b/include/part.h index 67b8b2a5cc..fac36364bd 100644 --- a/include/part.h +++ b/include/part.h @@ -474,6 +474,11 @@ int is_valid_dos_buf(void *buf); */ int write_mbr_sector(struct blk_desc *dev_desc, void *buf); +int write_mbr_partitions(struct blk_desc *dev, + struct disk_partition *p, int count, unsigned int disksig); +int layout_mbr_partitions(struct disk_partition *p, int count, + lbaint_t total_sectors); + #endif From patchwork Thu Dec 17 11:27:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 344922 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1076904jai; Thu, 17 Dec 2020 03:28:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHQz6MEsFUnkvIAxbXldHYxopfAvdU6XIKpg03pQa4yEzb1MEW8tSrsmEsZ3ZXtLKWrX/9 X-Received: by 2002:aa7:cd71:: with SMTP id ca17mr26355059edb.25.1608204507940; Thu, 17 Dec 2020 03:28:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608204507; cv=none; d=google.com; s=arc-20160816; b=a4pkS0BvvY9WCAEvA7wwheVatBK1MYxjd1WdUiIv4YjuwzF8X9DMuI8TbW8RDVG50i R25mr6uaBo+oEKwXpl+7hSXztMp/m8K0msrItiddpKLlqxCtWLP5hbHOhB8aE/sVWdbW QI0/fWm2XRLi5xuCH3EYaOa2BPy1Ng4tDR9P5VxC5szxby5Uqz3hq2QYpc7ek9Q6l+e3 bFvZBj5RJmUkNy5mNfovACk2Nyj6PSPOsT18lTqeXnYDdHfqPrFMmG+D9BAJQPBTSBge Ath81GKBdjDalgq+MSuYqf5iX7UGC25ySNVV2PwUPLZA+Zv/unlJHmslWXvyA/OrR5qA olhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=vvzlqatTFFzXKj1PaWakVqBkiUvGiCiyTy6vU9s2otE=; b=ri9KCcO6E2SSvvUvYVcu0rQrhZyLRKZ8jAVnlr/W3ewBfp/T+WToNqUjB8Dm6xSTRf rr1EVJ0v593nmvENbUmLtc7A6+ozYJhkw10yogLclL6kon9Fw0V7tx/9G1ANT/XFJaCQ 3lGFIzRO6H5m1ofJNhLglmMlSDVu3wcv1shwST11L0TikDZ45Cacy1IiRuR0SKEW1V5s lH3dxkNF8vADg5mQsL4a+5ysUqLkdSEnZA77wy2Mrb7CvDFJSIFwBFwOzewMWxNbj+ue d0Kv0efghQTV2HYCTkqMWpIdpyp/DzGlHb4ky9gSFMmh/l3e097A0iltRSTG/vk8TGYt V9Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=fwsHLY2x; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 11si4533378edv.53.2020.12.17.03.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 03:28:27 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=fwsHLY2x; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A50A82BB0; Thu, 17 Dec 2020 12:28:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com 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=samsung.com header.i=@samsung.com header.b="fwsHLY2x"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 44B7482BA6; Thu, 17 Dec 2020 12:28:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E734882B9F for ; Thu, 17 Dec 2020 12:27:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201217112748euoutp025d958d7dbcf06ddcc05b7deee84f80cf~RfXGK2JSE2566325663euoutp02E for ; Thu, 17 Dec 2020 11:27:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201217112748euoutp025d958d7dbcf06ddcc05b7deee84f80cf~RfXGK2JSE2566325663euoutp02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608204468; bh=vvzlqatTFFzXKj1PaWakVqBkiUvGiCiyTy6vU9s2otE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fwsHLY2xA4GwEnId92u2T/6yUzVAThBUwdojNcxv2JhcexOxb8kjCJ5qiJ7RCcKL2 aI3PuK365nq9yUE4vbcdoxxRRwN+RxZhtN2rtsr3AQG7iINxbIEhGtd3AcoJr/3x8z jPFIYQ0cOL7MRcKRmKSo4OhYuaZ7Y2tD5TRlU3Vk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201217112748eucas1p22e95b6e5621bb71c983eb9c44874c6e8~RfXFt9NCO0440704407eucas1p2p; Thu, 17 Dec 2020 11:27:48 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 42.49.45488.3B04BDF5; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201217112747eucas1p1cddfc0d3b072ceebb6e443c62a5d6d55~RfXFPeAsX3084730847eucas1p1b; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201217112747eusmtrp2adfb0ce58e65640bba84a8165e722714~RfXFO2fHm2732627326eusmtrp2I; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) X-AuditID: cbfec7f5-c5fff7000000b1b0-d6-5fdb40b3464c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 2B.F0.16282.3B04BDF5; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201217112747eusmtip2ad0d002e80094662257afcb24bbaa0fd~RfXEzLYcJ2746427464eusmtip2L; Thu, 17 Dec 2020 11:27:47 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Cc: Marek Szyprowski , Lukasz Majewski , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH 6/6] cmd: Add MBR partition layout control utility Date: Thu, 17 Dec 2020 12:27:39 +0100 Message-Id: <20201217112739.5045-7-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217112739.5045-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRmVeSWpSXmKPExsWy7djPc7qbHW7HG9z6aWWxccZ6Vosbv9pY LZ6/u8xksfbIXXaLb1u2MVq83dvJbnF46gdGB3aP2Q0XWTzmzTrB4vHhY5zH2Ts7GD36tqxi DGCN4rJJSc3JLEst0rdL4Mpoef2RtWCrd8X6CffYGxh3W3UxcnJICJhIHHl2gLGLkYtDSGAF o8SlzjfMEM4XRomdb3+zQDifGSWWPlvJCtMyd/9VNojEckaJOV//Ms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3UxcnJICJhIzN1/la2LkYtDSGApo8SS64tZIBIyEienNbBC2MIS f651QRV9YpRY/GQrE0iCTcBQoustSIKTQ0RAQuJX/1VGEJtZoIlJYu1/MFtYwEmi8fkLsHoW AVWJ2bt6wYbyCthIfH1+AmqBvMTqDQeYuxg5ODgFbCWWt5eBhIWASj6c3cQ4gZFvASPDKkaR 1NLi3PTcYiO94sTc4tK8dL3k/NxNjMCQ3Xbs55YdjCtffdQ7xMjEwXiIUYKDWUmEN+HAzXgh 3pTEyqrUovz4otKc1OJDjKZAZ0xklhJNzgdGTV5JvKGZgamhiZmlgamlmbGSOK/JkTXxQgLp iSWp2ampBalFMH1MHJxSDUxuLdEXfPXd69Z0SXI4b2P96uhzaHGIzsQNmVpCllXG637r3Nrt 8rNj00Rlr6DsG/sO3TZ4fLij4ipv6CPtrpV2Rf8cWU7OEbT8uSXwSv00M7+D7d9nCJ1eynwl 5bWo7RNOd2b9NVJPkkUDT8euc2JIFuBiedb3ry7oy4/9j2I/Vba7mXy5Z6iR03Iistb8mler l9Hcwzb93y5meq2aZ9Ys9Hqfwt3yIjYrvwV53xd1icTuW8BxKq1k+40dRnv0Xz7VPM/Dwdjw UG6Sgay0zLdDb9YwP4rYdH+VgiqvSYCDaJB8kOfyN/55JgYs74uN89+tK09LSjPWXD513zSD ilNHJ66xW/qYSe5IObeqqhJLcUaioRZzUXEiAMx+30HiAgAA X-CMS-MailID: 20201217112747eucas1p1cddfc0d3b072ceebb6e443c62a5d6d55 X-Msg-Generator: CA X-RootMTR: 20201217112747eucas1p1cddfc0d3b072ceebb6e443c62a5d6d55 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201217112747eucas1p1cddfc0d3b072ceebb6e443c62a5d6d55 References: <20201217112739.5045-1-m.szyprowski@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Add a 'mbr' command to let user create or verify MBR partition layout based on the provided text description. The partition layout is altearnatively read from 'mbr_parts' environment variable. This can be used in scripts to help system image flashing tools to ensure proper partition layout. The syntax of the text description of the partition list is similar to the one used by the 'gpt' command. Supported parameters are: name (currently ignored), start (partition start offset in bytes), size (in bytes or '-' to expand it to the whole free area), bootable (boolean flag) and id (MBR partition system ID). If one wants to create more than 4 partitions, an 'Extended' primary partition (with 0x05 ID) has to be explicitely provided as a one of the first 4 entries. Here is the example how to create a 6 partitions (3 on the 'extended volume'), some of the predefined sizes: > setenv mbr_parts 'name=boot,start=4M,size=128M,bootable,id=0x0e; name=rootfs,size=3072M,id=0x83; name=system-data,size=512M,id=0x83; name=[ext],size=-,id=0x05; name=user,size=-,id=0x83; name=modules,size=100M,id=0x83; name=ramdisk,size=8M,id=0x83' > mbr write mmc 0 Signed-off-by: Marek Szyprowski --- cmd/Kconfig | 8 ++ cmd/Makefile | 1 + cmd/mbr.c | 308 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 317 insertions(+) create mode 100644 cmd/mbr.c -- 2.17.1 diff --git a/cmd/Kconfig b/cmd/Kconfig index 1595de999b..2c3358e359 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1025,6 +1025,14 @@ config CMD_LSBLK Print list of available block device drivers, and for each, the list of known block devices. +config CMD_MBR + bool "MBR (Master Boot Record) command" + select DOS_PARTITION + select HAVE_BLOCK_DEVICE + help + Enable the 'mbr' command to ready and write MBR (Master Boot Record) + style partition tables. + config CMD_MISC bool "misc" depends on MISC diff --git a/cmd/Makefile b/cmd/Makefile index dd86675bf2..41379d9a0e 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -178,6 +178,7 @@ obj-$(CONFIG_CMD_ZFS) += zfs.o obj-$(CONFIG_CMD_DFU) += dfu.o obj-$(CONFIG_CMD_GPT) += gpt.o +obj-$(CONFIG_CMD_MBR) += mbr.o obj-$(CONFIG_CMD_ETHSW) += ethsw.o obj-$(CONFIG_CMD_AXI) += axi.o obj-$(CONFIG_CMD_PVBLOCK) += pvblock.o diff --git a/cmd/mbr.c b/cmd/mbr.c new file mode 100644 index 0000000000..25a3f694d3 --- /dev/null +++ b/cmd/mbr.c @@ -0,0 +1,308 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * cmd_mbr.c -- MBR (Master Boot Record) handling command + * + * Copyright (C) 2020 Samsung Electronics + * author: Marek Szyprowski + * + * based on the gpt command. + */ + +#include +#include +#include +#include +#include + +/** + * extract_val(): Extract value from a key=value pair list (comma separated). + * Only value for the given key is returend. + * Function allocates memory for the value, remember to free! + * + * @param str - pointer to string with key=values pairs + * @param key - pointer to the key to search for + * + * @return - pointer to allocated string with the value + */ +static char *extract_val(const char *str, const char *key) +{ + char *v, *k; + char *s, *strcopy; + char *new = NULL; + + strcopy = strdup(str); + if (strcopy == NULL) + return NULL; + + s = strcopy; + while (s) { + v = strsep(&s, ","); + if (!v) + break; + k = strsep(&v, "="); + if (!k) + break; + if (strcmp(k, key) == 0) { + new = strdup(v); + break; + } + } + + free(strcopy); + + return new; +} + +/** + * found_key(): Found key without value in parameter list (comma separated). + * + * @param str - pointer to string with key + * @param key - pointer to the key to search for + * + * @return - true on found key + */ +static bool found_key(const char *str, const char *key) +{ + char *k; + char *s, *strcopy; + bool result = false; + + strcopy = strdup(str); + if (!strcopy) + return NULL; + + s = strcopy; + while (s) { + k = strsep(&s, ","); + if (!k) + break; + if (strcmp(k, key) == 0) { + result = true; + break; + } + } + + free(strcopy); + + return result; +} + +static int str_to_partition_info(const char *str_part, unsigned long *disk_uuid, + struct disk_partition **partitions, int *parts_count) +{ + char *tok, *str, *s; + int i; + char *val, *p; + int p_count; + struct disk_partition *parts; + int errno = 0; + uint64_t size_ll, start_ll; + + if (str_part == NULL) + return -1; + + str = strdup(str_part); + if (str == NULL) + return -ENOMEM; + + /* extract disk guid */ + s = str; + val = extract_val(str, "uuid_disk"); + if (val) { + val = strsep(&val, ";"); + p = val; + *disk_uuid = ustrtoull(p, &p, 0); + free(val); + /* Move s to first partition */ + strsep(&s, ";"); + } + if (s == NULL) { + printf("Error: is the partitions string NULL-terminated?\n"); + return -EINVAL; + } + + /* remove the optional semicolon at the end of the string */ + i = strlen(s) - 1; + if (s[i] == ';') + s[i] = '\0'; + + /* calculate expected number of partitions */ + p_count = 1; + p = s; + while (*p) { + if (*p++ == ';') + p_count++; + } + + /* allocate memory for partitions */ + parts = calloc(sizeof(struct disk_partition), p_count); + if (parts == NULL) + return -ENOMEM; + + /* retrieve partitions data from string */ + for (i = 0; i < p_count; i++) { + tok = strsep(&s, ";"); + + if (tok == NULL) + break; + + /* size */ + val = extract_val(tok, "size"); + if (!val) { /* 'size' is mandatory */ + errno = -4; + goto err; + } + p = val; + if ((strcmp(p, "-") == 0)) { + /* auto extend the size */ + parts[i].size = 0; + } else { + size_ll = ustrtoull(p, &p, 0); + parts[i].size = size_ll / 512; + } + free(val); + + /* start address */ + val = extract_val(tok, "start"); + if (val) { /* start address is optional */ + p = val; + start_ll = ustrtoull(p, &p, 0); + parts[i].start = start_ll / 512; + free(val); + } + + /* system id */ + val = extract_val(tok, "id"); + if (!val) { /* '' is mandatory */ + errno = -4; + goto err; + } + p = val; + parts[i].sys_ind = ustrtoul(p, &p, 0); + free(val); + + /* bootable */ + if (found_key(tok, "bootable")) + parts[i].bootable = PART_BOOTABLE; + } + + *parts_count = p_count; + *partitions = parts; + free(str); + + return 0; +err: + free(str); + free(parts); + + return errno; +} + +static int do_write_mbr(struct blk_desc *dev, const char *str) +{ + unsigned long disk_uuid = 0; + struct disk_partition *partitions; + int count; + + if (str_to_partition_info(str, &disk_uuid, &partitions, &count)) { + printf("MBR: failed to setup partitions from \"%s\"\n", str); + return -1; + } + + if (layout_mbr_partitions(partitions, count, dev->lba)) { + printf("MBR: failed to layout partitions on the device\n"); + free(partitions); + return -1; + } + + if (write_mbr_partitions(dev, partitions, count, disk_uuid)) { + printf("MBR: failed to write partitions to the device\n"); + free(partitions); + return -1; + } + + return 0; +} + +static int do_verify_mbr(struct blk_desc *dev, const char *str) +{ + unsigned long disk_uuid = 0; + struct disk_partition *partitions; + int count, i, ret = 1; + + if (str_to_partition_info(str, &disk_uuid, &partitions, &count)) { + printf("MBR: failed to setup partitions from \"%s\"\n", str); + return -1; + } + + for (i = 0; i < count; i++) { + struct disk_partition p; + + if (part_get_info(dev, i+1, &p)) + goto fail; + + if ((partitions[i].size && p.size < partitions[i].size) || + (partitions[i].start && p.start < partitions[i].start) || + (p.sys_ind != partitions[i].sys_ind)) + goto fail; + } + ret = 0; +fail: + free(partitions); + return ret; +} + +static int do_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + const char *parts = NULL; + int ret = CMD_RET_SUCCESS; + int dev = 0; + char *ep; + struct blk_desc *blk_dev_desc = NULL; + + if (argc != 4 && argc != 5) + return CMD_RET_USAGE; + + dev = (int)simple_strtoul(argv[3], &ep, 10); + if (!ep || ep[0] != '\0') { + printf("'%s' is not a number\n", argv[3]); + return CMD_RET_USAGE; + } + blk_dev_desc = blk_get_dev(argv[2], dev); + if (!blk_dev_desc) { + printf("%s: %s dev %d NOT available\n", + __func__, argv[2], dev); + return CMD_RET_FAILURE; + } + + if ((strcmp(argv[1], "write") == 0)) { + parts = (argc == 5) ? argv[4] : env_get("mbr_parts"); + printf("MBR: write "); + ret = do_write_mbr(blk_dev_desc, parts); + } else if ((strcmp(argv[1], "verify") == 0)) { + printf("MBR: verify "); + parts = (argc == 5) ? argv[4] : env_get("mbr_parts"); + ret = do_verify_mbr(blk_dev_desc, parts); + } else { + return CMD_RET_USAGE; + } + + if (ret) { + printf("error!\n"); + return CMD_RET_FAILURE; + } + + printf("success!\n"); + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD(mbr, CONFIG_SYS_MAXARGS, 1, do_mbr, + "MBR (Master Boot Record)", + " \n" + " - MBR partition table restoration utility\n" + " Restore or check partition information on a device connected\n" + " to the given block interface\n" + " Example usage:\n" + " mbr write mmc 0 [\"${mbr_parts}\"]\n" + " mbr verify mmc 0 [\"${partitions}\"]\n" +);