From patchwork Wed Dec 23 12:55:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 351446 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp6172259jai; Wed, 23 Dec 2020 04:55:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlxl7dI9RxQqD6yuznUGS5+KKSAA5kUOK97frh+llj+LI7lV/GtZai+w3FyyyEXnUWaXYm X-Received: by 2002:a17:906:a29a:: with SMTP id i26mr23651288ejz.45.1608728155817; Wed, 23 Dec 2020 04:55:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608728155; cv=none; d=google.com; s=arc-20160816; b=CoU5Npu9Ql9q+wwImHf77WH2mB9lvs1kp1QaEB5Bg8KvC176LzKXb/Zvfc6MXIPeFV 00UzTszhD9o6puDKktHdne/A6cz2Lq5GL1qO/QTmvIRhP3VNFuqKKSR1N0iDFUW5kC8U RfYQFqNhhGGqyEuS2ZW1zADfQmh6n5JZRc0qx3sK71zQJRgjuUoUWqKBEtHav55Oty5p kibwWlmRGYg9URAfBPsVXzSncGPI10qtEWUWtyR8wUVbfGw4TJ9wCWMhjAho1Bk+jl3L fx7aIYBB5rgmUt5KD5TCi+2A+oWqFdfuiLaMIhGFx2tlBMcjDmer4uU/C2G3gBbkgiD6 L8IA== 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=VaK2zP9Kg134+zT5u+Uqtwj6i2pr30ZHOZw99Qgi+y7WtNzIdqTnYf1FQzRUMbRqsC avjVw490HJMm+kHmoGoOtHCb8Nhp+DE2MTcqlYAiNu3F/vpwQJENKxgvoC7D2cCkKqR5 Uyn4wGKQrQByKNGfMqvHqBb7yBNTJtDaA41e5ECJiz5vbPAF4S+A/0YvgBSg/fQ6ltUc kMU+eII8W1eYcJ1hXDnGGy22INV8HhlUUP8Im4kCRSKSzEmSwtvkeApAHxjHYKIzKFW7 Nm0GYdErPNtcMif/5PbcExuMmH4lY2WT05yw+a5JoCi/QEno4Vh+1E3VW/zi7APErnFk y3CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Iut8QEuj; 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 gn38si11696357ejc.438.2020.12.23.04.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:55:55 -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=Iut8QEuj; 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 C8B488272E; Wed, 23 Dec 2020 13:55:43 +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="Iut8QEuj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 373FD8273C; Wed, 23 Dec 2020 13:55:39 +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 68ABD82727 for ; Wed, 23 Dec 2020 13:55:35 +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 20201223125534euoutp02024aa20867b43002fdcfc5ba940e4fea~TWbcEqmxb3096730967euoutp02O for ; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201223125534euoutp02024aa20867b43002fdcfc5ba940e4fea~TWbcEqmxb3096730967euoutp02O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608728134; bh=1ODBY96fFBqFt8d2xGKeYGO05SitY939t1BYMg+dfjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iut8QEujBKnbsaQWukrsHOWerDB2HQHKMb1U8GD1rNUYmYxQWpi7ZqIX/Nrt7Emu7 ZndfF/D9q1b3XaX1zZGuuZ1s0XtuDPvAkQ+icOvYbmWaGwq720vyAGMhpWcsPgDH0j 6GNNoTV6HABFS0GPl8wYkPoD5/Wkh5Gug/cLsCvU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201223125534eucas1p26265870046d5f2a2938c08c76316522a~TWbbwrmyT3008030080eucas1p2P; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 63.79.27958.64E33EF5; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201223125533eucas1p24c90762deb359fc4c73ddb717892c932~TWbbbHupD3008030080eucas1p2O; Wed, 23 Dec 2020 12:55:33 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201223125533eusmtrp2400780a2ae5ff425b1ee01c5e0135f05~TWbbahFPL0404504045eusmtrp2o; Wed, 23 Dec 2020 12:55:33 +0000 (GMT) X-AuditID: cbfec7f2-efdff70000006d36-09-5fe33e46fa6d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 88.BC.21957.54E33EF5; Wed, 23 Dec 2020 12:55:33 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201223125533eusmtip25a062b362a2c2a0a8d127fcec6d1bbe6~TWba_7DS02463824638eusmtip2i; Wed, 23 Dec 2020 12:55:33 +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 v3 1/6] disk: dos: rename write_mbr_partition to write_mbr_sector Date: Wed, 23 Dec 2020 13:55:10 +0100 Message-Id: <20201223125515.28865-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201223125515.28865-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7djPc7pudo/jDX59ZLXYOGM9q8WNX22s Fs/fXWayWHvkLrvFty3bGC3e7u1ktzg89QOjA7vH7IaLLB7zZp1g8fjwMc7j7J0djB59W1Yx BrBGcdmkpOZklqUW6dslcGX0dl5nK+gUqLh04hJbA+ME3i5GTg4JAROJd2eWsHcxcnEICaxg lNg4cQELhPOFUeLawnZGkCohgc+MEt83GHYxcoB1LD3oDlGznFHiwYNvCA0LfuxlBmlgEzCU 6HrbxQZiiwhISPzqv8oIUsQs8I9R4iDQZyAJYYFgibVLz4MVsQioSjQ9/c8EYvMK2ErM3TOb BeI+eYnVGw6ADeUUsJP4tqCDFWSQhMBMDonPB9ewQRS5SGy8vYkRwhaWeHV8CzuELSPxf+d8 JoiGZkaJh+fWskM4PYwSl5tmQHVYS9w594sN5DlmAU2J9bv0IcKOElMmnWOH+JlP4sZbQZAw M5A5adt0Zogwr0RHmxBEtZrErOPr4NYevHCJGcL2kHh54SArJIQmMkq8nbKQaQKj/CyEZQsY GVcxiqeWFuempxYb5qWW6xUn5haX5qXrJefnbmIEponT/45/2sE499VHvUOMTByMhxglOJiV RHgv8T+OF+JNSaysSi3Kjy8qzUktPsQozcGiJM67avaaeCGB9MSS1OzU1ILUIpgsEwenVAOT s2dAl6JAonPlysSrTEfZDKdkxB45qObaf0fm4ES1c21SLw2bNT1EF/Lv8Z0c68Pbm2/+fe3W d07WsUGJM6yfvmp51drE2PDqyJoDk/KvpF09y82RLMx7au+7nykXwqfwV7JMeZu8/O4VSd7M 3g2v56zsLtv/5rY1bxWnZoW5/F6dJ6w8HJV6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KxusHlqw53 hbR/vJCezLuRwWLFpOjv36NntZaKP/OL0WnN51nxZafwFcHqfqPHk90X+rlcfiusM9N/6qFd R14cYjdNWjRz6y731xLvsoU2KLEUZyQaajEXFScCACHZJ8fiAgAA X-CMS-MailID: 20201223125533eucas1p24c90762deb359fc4c73ddb717892c932 X-Msg-Generator: CA X-RootMTR: 20201223125533eucas1p24c90762deb359fc4c73ddb717892c932 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201223125533eucas1p24c90762deb359fc4c73ddb717892c932 References: <20201223125515.28865-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 Wed Dec 23 12:55:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 351447 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp6172371jai; Wed, 23 Dec 2020 04:56:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwExJ6CramLIfizn7/PEVtOXgt7f6fGtz+FtMQkVTxGcZCHD4jra6nPObCwVZgEJ0PzocHh X-Received: by 2002:a17:906:4756:: with SMTP id j22mr24561704ejs.353.1608728165578; Wed, 23 Dec 2020 04:56:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608728165; cv=none; d=google.com; s=arc-20160816; b=peknlV/70lnXK0zpN4Rd2ajBCXXDYEtkVouyz22n3e769v+XkucmZFszmq8DMMd82c oAdHgiH5r4FNFo+jvKO5S1ezWvM8RdVFC2qLdr9+b5MFE1FAg717ICR29AinQ5hcUgrv sNg+uGzcuL3ruYli7fxIXphut6qeljIUsKf19iN1iFvHkA8N/B3mOEU+hz0oE881pxcL y6XxjQwsPCvoUp8F7fg2Pr0L1OR/XyBkUdR38KTEpPQFO7YSHmE0138dz8rwuOe+Lwam k7DkMJGWTgr9Q1Z6QcBYACLKbCfrDpLFu/9oFLy5s4HUXHupiX5fdq8RKT1uzkH0q2oY LVJA== 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=rCfyvKVXpUQfp3UWlPVg5Jfkx5/acWiChrt2c4Kpi/OMJBU80IvpVAUn0yBFCoze80 iJl4iUUYPXQhIKh7MnQts8gbhqjfVOERl4/mi+3gADdtB12SKtvZHr7AytulJHmB6rX3 EW6xGMeKE18X78iPWJ4p8/RHGUHBwwzdp12LHjgfdG60W0lt/XXORZCJkW31+UvLGNGy y+RyiIg5iBtC+/n9n5xGIA9nF2uniaLu3/egxbi8OeM9YILq/NuD+VI98AOT7ETw+3uK rwKWPUOOyRPxyuvf8g8fBldCPlc2nVQ9ZkrdTATX+E3ndreEDrMlDcNlpr22uJ+Ur+zo vDpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=i56HKmN1; 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 g4si14345534edn.483.2020.12.23.04.56.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:56:05 -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=i56HKmN1; 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 2A2E282763; Wed, 23 Dec 2020 13:55:50 +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="i56HKmN1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8CE2082763; Wed, 23 Dec 2020 13:55:43 +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 1BADD8272D for ; Wed, 23 Dec 2020 13:55:36 +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 20201223125535euoutp02187700a61acb3028003de0d156328291~TWbdJc2da3178531785euoutp02d for ; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201223125535euoutp02187700a61acb3028003de0d156328291~TWbdJc2da3178531785euoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608728135; bh=Ugopsy/ZxytmB8ap3xn0lUro0TDiqP7g+knq07e92AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i56HKmN1cDQWn3AOJuzS0TNNJSzTrfVuxAlv+882bovMPQtobdHgaAL2IrETlc2vy t+6CCbveTkdrxKA22h90lshuTszmDBeiu2KmgT6l5uoZpAenI7HnDywRQ14iy8SRJQ PXKi8Us6wjNiN+HM2jOizlK0YR70b8xRzabB6VMI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201223125535eucas1p1d7ab629e8ca96db7b5e3d29691c2de08~TWbc5CqpQ1720517205eucas1p1I; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 76.D4.44805.74E33EF5; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201223125534eucas1p2388f9e307ba4fdb85ba1dfea6184e60f~TWbcZH3mf3007930079eucas1p2m; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201223125534eusmtrp1fc3bdda0e0b9f1c5221a0dc911f508e1~TWbcYdko82414524145eusmtrp1k; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) X-AuditID: cbfec7f4-b4fff7000000af05-0a-5fe33e4712d2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 81.E8.16282.54E33EF5; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201223125533eusmtip272ced7a62106ce7bd246aa64d2ee59e7~TWbbVie212198421984eusmtip2T; Wed, 23 Dec 2020 12:55:33 +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 v3 2/6] disk: dos: add some defines for the hardcoded numbers Date: Wed, 23 Dec 2020 13:55:11 +0100 Message-Id: <20201223125515.28865-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201223125515.28865-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSe0hTcRTmt3vvdh1cu66FJwuCtexF9qBo9NCGhqsIy17WH61lty2c03az h1BZkTmzLIevieI/Zi6nKcu0MpulRqUtp6hl2UPJIs2RrSapebtW/33nO98DDofEJIN4AHnI cIQxGjR6mVCMVzV6ny8KD/6gXpJ23VdRkVNOKDpHkgnFx0GXQGF79Fqk8NirkGKg1iRSPMwc QutEqrykF7iqwPIYVw2596qau6uR6rLdirYQe8RrDjD6Q0cZ4+LgfWLdl8obKN4kPv7dayeS UD6ZinxIoJdD3/A7YSoSkxL6OoJnnlYBPwwjMLnKJodvCCp68rG/lmspDsRhCV2MoP+t8p8j 0/texC2E9FJIHUgVclhKA4yktyNOhNFjCBwjboJbTKUjYDizZAKTJE7PAYv5TwFFr4Xe8TqC L5sFN24++MP70MHgKUwhuBygM0m43Zsv4rxAh8HFh0pePxU+N9lFPJ4JT81pOK8/h+Bdi03E D2kIXGdzEK9aDd0tI0IuCKPnQ/mdxTytBNfXFoLP94XOAT+OxiZgRlU2xtMUpCRLeHUgWJrK /tU6nK2Tt1KB1+GZPO9VBMW3mrEraJblf1khQlbkzySwsVqGXWZgjgWxmlg2waANio6LrUQT L/F0r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/X0yPLf1+3yzd6aXJ6u7XzP7Izk /90/Fve96v6jeqnhGvdqd/MLt7NMtQUXexXPW69ZVNP+QPXit3v6fybJ3VvmyWqpGnF1pdHX i141JUFbBTgv6vI+6gqS+K15LHpttcXvpj2NpZsY9slKySn7i5jyLOCYrblV2ea73Gdrf3eB H5e5uKrOTxSxlTDwX/Tuw0a/YuFCDvuNogk5arEbJi5sMmXsCJ/G8GjL41l8H9qeGLyVTj6h +Nb20/FbXzYFunoV7T2Z8/6OoTu3QPx35UTjCbE5s+NN39gplHwqm1v2/ILqKUfX9ckFS1z9 XIKeGZ5ujtj5ZEbaCYeXSizFGYmGWsxFxYkA33F3C+ICAAA= X-CMS-MailID: 20201223125534eucas1p2388f9e307ba4fdb85ba1dfea6184e60f X-Msg-Generator: CA X-RootMTR: 20201223125534eucas1p2388f9e307ba4fdb85ba1dfea6184e60f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201223125534eucas1p2388f9e307ba4fdb85ba1dfea6184e60f References: <20201223125515.28865-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 Wed Dec 23 12:55:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 351445 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp6172166jai; Wed, 23 Dec 2020 04:55:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDDHWnJtiJeYLhorRT6YGeTrUX6OvZI1Y4LH7e3tiLiLiBN67y4rdT6YWxVGC3aw3Ipg6V X-Received: by 2002:a05:6402:1c04:: with SMTP id ck4mr24263593edb.320.1608728145180; Wed, 23 Dec 2020 04:55:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608728145; cv=none; d=google.com; s=arc-20160816; b=Wr91v8IGGsMfoG7oAXBaw3uSfxTWPs7ZlTG2OK8rYiELPmH3zDp9GZoNNORbcux9Tu QqVOsEAZpEehBjdeDhj8KV3ni0Bdtecz1OJWQlcaXv1jFODy0TtxnkEiCglkh365ahN5 OvtbYHRLf8MZ6z5rtCOPGqNOXjEvHi9WRCBCXpOBT9CkoZjBdCr3y09xW/MnMMEFaov/ RAlIaZJTxaJ078aQgAPY1+1OzSDtTcwnX1nLkDdavB8eigNeLUWCyTM8eM8tL/2YVR1S LJPCyonis2fTNuL2XoTcA+73ufzzXkiojVmn71AnYUM0nMXPU8FvRbAelU3tsmz9fVrT 2Hng== 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=k3k/6Sv05Uy+nKmPULNJn+cYbbdIM4w3gK3MLrUFxhWw0zU7WOr29EN0D51Nc4UeCG sITWSrNHUwC7XcNFAnT6e32+5DrVGeiilG6KD+O4fBzotaSErlWyDoYVgwsWriKo6MRI kRgZwZkO/bsdLTRZXi8t7tNyOprFldSv3t2GAHUIYc0yTlXEPI5LXZ+sEvWIZTyX4U7n blFXnpos1fIcTBE9NkV9pEWd9/0jGTso+OZBClBODPo0IzmKN1EfMvj7Ojnisx4BAPN/ T2IJDqytVg30ORq4M8L6yqMaHbtZDguyyAVfe3gwzygC0kBkFfDQwET7Um6HIohLqppw 83MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=i0thcqNG; 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 o59si13397055edd.460.2020.12.23.04.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:55:45 -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=i0thcqNG; 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 116C48272A; Wed, 23 Dec 2020 13:55:41 +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="i0thcqNG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6C13C82736; Wed, 23 Dec 2020 13:55:39 +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 92A198272A for ; Wed, 23 Dec 2020 13:55:35 +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 20201223125535euoutp020508591773f7ed221b50decba9cf5306~TWbcoqXxb3096730967euoutp02P for ; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201223125535euoutp020508591773f7ed221b50decba9cf5306~TWbcoqXxb3096730967euoutp02P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608728135; bh=F6V+qSwemnBQzCEmGI+kufqwnsfQVkuy9Ib33MTjCQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0thcqNGQ02qwAWeC0NZ/F7BJ6DxZN6N92xeSuSpk3RAqlTO5w0lkRPJLXYMF2kXp u/j1IgnTIIGy4xSZRiwKepllaq6KapW38B9ASRQG2IvSZ4pXdeQFUgr+lO7jzdisBE /ouaYQ4Wgu48qPSIxvz10Rv4bXKJ8Npl2e4kCO/8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201223125534eucas1p245258553da0084e10192b953d19dba2b~TWbca9H2W3011430114eucas1p2J; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 3D.41.45488.64E33EF5; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201223125534eucas1p12cb4b6a480be29f0101e5cd953d1ce02~TWbcHNwYJ1010410104eucas1p1D; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201223125534eusmtrp1568c0fba116fde5182a8ce6b6e99b64e~TWbcGkXZs2414424144eusmtrp1j; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) X-AuditID: cbfec7f5-c77ff7000000b1b0-5f-5fe33e46080f Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 91.E8.16282.64E33EF5; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201223125534eusmtip217956245bce3710eeca27510994398f8~TWbbrBTAH2411424114eusmtip2k; Wed, 23 Dec 2020 12:55:34 +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 v3 3/6] disk: dos: use generic macro for unaligned le32 access Date: Wed, 23 Dec 2020 13:55:12 +0100 Message-Id: <20201223125515.28865-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201223125515.28865-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe0hTYRjG+XbOtqOxPM2ylyVJK8OKprGI0UU0QmZISCCkVnPmQVdO105m SdFSFJ3SbTMvs7L+cXm3zLzQxamboWlWw0U3bZQkbcy00kWS8yz77/c+3/PyPLx8BMZ34QJC kXGKUmfI04UcX7zNPDe0NSrcLgu77xBJWsqb2BKbu4AtmXC+Ykkaet9zJT9b25DE8aiIK+kp daEIrtSgGcGlNyv7calr6qj0+bt2JL3UWoti2Qm+u1OodMVpSh0anuSbZtZq2SrTmjPDdf2Y BtUHaJEPAeR2+D5jY2uRL8EnjQg0xW85zDCDoKPxKcYM0wichlH2v5UqjcG7UoPg8/ATtLTy orFi0cUht4HWoeV4eCUJ4L5sXTRh5DyCbvfUosmfjIWJb1aWh3EyGHoL5rge5pF7wFY/4I0L grpmTw8fwocMh5/VhV69ggB71xGG98HlzlKMYX+YtLRyGQ6EAV0J7gkGMg/B+FADlxlKELzK LUeMaxe8G3IvVCUW6m2Cps5QRo6Eiw3PcI8M5HKwOVZ4ZGwBr7WVYYzMg8ICPuPeCJWWxqXY 7hcvvXWkoNP0eG96FUH+XDl+BQVV/g+rRqgWraayaGUqRYszqGwRLVfSWRmpomOZynto4VMM zFt+tCPj5JT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fTVjiLPZi8wLJ3y3ne+ZVHj5lHH9uz Mab9y8uJs+Zev7KgJ2nPwVidpxOrxRq/v0w/mbG8N+n/0e4F9h/WmE67d9PIlOfnreYXJnyS Sut747+s/5bILvZw1YtPKpm3ZtkpZKX4TDKsu5O1acI1JsEjSU3OGfW9rVtzrixjK8ngal+4 Yu4y83/fzr22nT/D9PareBbVA6ItfpcPizE9yN1yIcTFqjtXaOGn0jKLhMTS68Gl3j3u7Dem z1Jp7dA4/k9TULgz/tJbjuUrV4a9tGhdz/bP/MwC/RuiGgKtZW9m7J028Tqr4su0lg+LO17W 7FGeMmfXbPcXWzl3zFh16oASS3FGoqEWc1FxIgAv1Khh4wIAAA== X-CMS-MailID: 20201223125534eucas1p12cb4b6a480be29f0101e5cd953d1ce02 X-Msg-Generator: CA X-RootMTR: 20201223125534eucas1p12cb4b6a480be29f0101e5cd953d1ce02 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201223125534eucas1p12cb4b6a480be29f0101e5cd953d1ce02 References: <20201223125515.28865-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 Wed Dec 23 12:55:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 351450 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp6172657jai; Wed, 23 Dec 2020 04:56:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjmhf2K3z14Ekgmu0cGVQwJpLjSEtUYDHPQpwQFbf0M3Wak5IlaKWa+Iuin7+HHYwAHKRR X-Received: by 2002:a17:906:ec9:: with SMTP id u9mr24531135eji.400.1608728198983; Wed, 23 Dec 2020 04:56:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608728198; cv=none; d=google.com; s=arc-20160816; b=LZ2fyx3no14Fti4vpS0ckRpoCrrnTQRc4uBPBt9/0eD5J2apD4Eb+CgSM4ZLl0kAn9 AQji1kX1PwFGQXaTMAboU3+FzI/DA/Y46LxB7HQYCMp6gmwauKu5GToOkEusEfUy6qV0 LjhOpNL5+TjY6SuAArDEL/0Hezs++ZleHBrwZJYdWRzyVRcLplVAkzWrTaoGagS3jZn6 Qerw5BG17bYsjQTRLxeuB+JLbtMakc6TSwnkmR2UPEWIb1bJaqHH+J2iSm0M/tcynLNf S1tcIAZgaTUAG4tWEOAq30w0Ybh0+JjtCAntpDsmD8ZasG8h0up/HsRgjNky47xkwTSk htbg== 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=xE0S9RfCE1H9EAXs9WGEK503Peixvwgc+pRYXfWhgIWnusaNc1YPFX/YA8YiPSKky1 O7E67lQeLzIZg0lVBUDp/FP9ryJtYvQjdCrRL9qln2Bl8WL6pZkVXdZ3b8zznLNxchZF rCKidGgc5mzCLjxHvs/I6M9FL98fb8bN3pB81rKZArmdhR5stC3IR8ISur24K58cGJkp +N90kyKuCCLux90wQjHLOWelyrAOXXC6VH8zqdw5T+Bjlf6rvt5+BYcZto1b4l5gnZVT uR4SCoLAY4WZ9MzjBqFiL4gx9CtBz8QiuaqX4L72INsLwWhU0wIOqSXYNlfR8Y0dn4hn vbwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=m2sWZOPT; 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 dn5si12453790ejc.533.2020.12.23.04.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:56:38 -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=m2sWZOPT; 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 522178279A; Wed, 23 Dec 2020 13:55:56 +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="m2sWZOPT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 60F058273F; Wed, 23 Dec 2020 13:55:44 +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 2B31882738 for ; Wed, 23 Dec 2020 13:55:36 +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 20201223125535euoutp02de4ab6c596cc801ef0080590e0e2635a~TWbdIjj4H3096730967euoutp02Q for ; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201223125535euoutp02de4ab6c596cc801ef0080590e0e2635a~TWbdIjj4H3096730967euoutp02Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608728135; bh=QVv/OpDO86vbjc8WTV2cueIe9E1CfauEIcaW529qV2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m2sWZOPTVv53C/Gh4EvNdHHagx15iLMGOwAEQCPZkGsJgLHOiUMNCyw1TPjho6iDJ R0dk+2FJ6d3l0R+h3jNt7MS4a9QRUYH+t/4uWnCAeXGTjQOjreejtAraJeI8lpL+qc Ci7WCrotS/72SAk2L7WxvnAnbWQ4VLCWldTzhXqs= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201223125535eucas1p2c89eb3c1ece9089b5a416dd78cc88a30~TWbcybJsr3008430084eucas1p23; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 04.79.27958.74E33EF5; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201223125534eucas1p17107d79af8457f52a5536084f9b903b9~TWbccbQ0n1720517205eucas1p1H; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201223125534eusmtrp201f62fe3ae88b0149d1bbfc542b55697~TWbcbrkAB0385303853eusmtrp2c; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) X-AuditID: cbfec7f2-efdff70000006d36-0b-5fe33e47d089 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 09.BC.21957.64E33EF5; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201223125534eusmtip2bfb07673ba2d03dd7cd7a8bb66ba3659~TWbcAvhVR2463824638eusmtip2j; Wed, 23 Dec 2020 12:55:34 +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 v3 4/6] disk: dos: make some functions static Date: Wed, 23 Dec 2020 13:55:13 +0100 Message-Id: <20201223125515.28865-5-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201223125515.28865-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRmVeSWpSXmKPExsWy7djPc7rudo/jDZ52cVhsnLGe1eLGrzZW i+fvLjNZrD1yl93i25ZtjBZv93ayWxye+oHRgd1jdsNFFo95s06weHz4GOdx9s4ORo++LasY A1ijuGxSUnMyy1KL9O0SuDK27bzCXjCVvWLq3TusDYy/WbsYOTkkBEwkdp5pY+9i5OIQEljB KLH8Ti+U84VR4t3zm4wQzmdGiSu/zzHDtNzYP50JxBYSWM4ocfmGLlxH9+VnLCAJNgFDia63 XWwgtoiAhMSv/qtgk5gF/jFKHPz1EWy5sICtxIY1G8CKWARUJY5t6gbbwAsUv3ltIxvENnmJ 1RsOgMU5Bewkvi3oYAUZJCEwkUPi2ZoJLBBFLhILpz1igrCFJV4d38IOYctI/N85nwmioZlR 4uG5tewQTg/Q3U0zGCGqrCXunPsFtI4D6D5NifW79CHCjhLLlv5kBQlLCPBJ3HgrCBJmBjIn bZvODBHmlehoE4KoVpOYdXwd3NqDFy5BQ8tD4sj/DiZICE1klNg9bw/TBEb5WQjLFjAyrmIU Ty0tzk1PLTbMSy3XK07MLS7NS9dLzs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nghgfTEktTs 1NSC1CKYPiYOTqkGph18TVZHfHInGe6zzxYL9nT++vaN14q+S2KLHxoqZex9mMFZHnSBjVuB 3XfPZ02xs/4fmlILVz97e2hLi5BMjvGVI2ub/vPNm2acpHrSbNvCr22GDc9XSYamnZeT6fO/ 4Nxvb+B75sGMGAWBpuCd5s3hxys3LhKxdV1T9P3eVzH7yTNSl9wK+zQlTy9/ke9x2V9aFdOL Hjs5VLBabZq+ISb2oEZ9tXdudN0zzU5m/QVr+8T0upfumj2Hae4jTuX7F5eHfTzmFezq/PPp K1u9mgLVPabbkxWmiSyqmbn6++eWrkveB83VPKa9u67k9DOQNXu3+BaVlNKjWwqFrS9MCl/5 KdZiU+Qsw5yH5+TPKbEUZyQaajEXFScCAI9UgaDjAgAA X-CMS-MailID: 20201223125534eucas1p17107d79af8457f52a5536084f9b903b9 X-Msg-Generator: CA X-RootMTR: 20201223125534eucas1p17107d79af8457f52a5536084f9b903b9 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201223125534eucas1p17107d79af8457f52a5536084f9b903b9 References: <20201223125515.28865-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 Wed Dec 23 12:55:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 351448 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp6172460jai; Wed, 23 Dec 2020 04:56:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsG/B8Tgjta9GKbpfvgAYRUDx9qqqErcl0mvfg+lIPwFhmBt9QHNxrk/QQIkv2KHru19iN X-Received: by 2002:a17:906:7a18:: with SMTP id d24mr24302261ejo.324.1608728176188; Wed, 23 Dec 2020 04:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608728176; cv=none; d=google.com; s=arc-20160816; b=Z/BEFKyJAkFQnRNtUMJCp/Na/go8d3oAGyCC1e+uEcNNSpDtgs0ZMo+m78M0M1kDyE 7bZZ4CTErFvMRzDbjSzICY8r7W7veNNL8bx/DJIrI1kdsq5qAmtNGTg3hf+I0yvFYjRb BWY9dbcbkorD5YB4RvqqlSpzT/aJd44KZ+erv3vSnjcYyVUgtaljetMohXQVmKVSACSR jxkWNqUiAUbTfkzJmkP3MbYABSNp/gXOqcsJS20JbgsbsVSeXN8pugCrXttgaV+0Yrrp rXhugdDMbbtlU71HYLNz90ph3ju8r7RRA0E9ur8tnX3KXJaHrSnJn6tCtlLRFTye3oMv 9dAg== 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=Qhm/BkhfU+p6aWLWR4Rjwms/rtZ3/awUuXnerqJptPfUukwPaWDOxohPAQplu4xfO2 pycI+51tVn8YGoxQLjSyHepIbEmG0uD7QiAzUHDERygZ8vWztjLx4vdOapbOVUXpDCnF PTv5DiG4vcykrvohBWV/k0QG/lCHnrTLktYtQQ3HdfQrfifKdgdmC7BynN+Qv8nj8wWi K9w82y2rR3slZlCfpDgbrksPfDgjJ34dKQ4TMgnMfDjrIBwxiM/M60spFDenU3H/Gske vhKB38maoMd0rd+PKUGTpqTPcWqwWZqrcEvQjYj1lQX/nb+SdAk/7tS7rC4q1Q75M2nV SKJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tgzAgLNu; 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 c35si13514970edf.522.2020.12.23.04.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:56:16 -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=tgzAgLNu; 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 0A3368273E; Wed, 23 Dec 2020 13:55:52 +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="tgzAgLNu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD90D82770; Wed, 23 Dec 2020 13:55:43 +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 552F48272E for ; Wed, 23 Dec 2020 13:55:36 +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 20201223125535euoutp0239a07892a6e1c7622d1eff00bb6655be~TWbdW0rIU3178531785euoutp02e for ; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201223125535euoutp0239a07892a6e1c7622d1eff00bb6655be~TWbdW0rIU3178531785euoutp02e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608728135; bh=k9oMBZwID77q6mtg2L5cpHL5kStBnaPFM2CjIM8gmj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tgzAgLNut+xfFD/GIMd2vE2+yp2FZwg8CgsBAEoBGVoer2Upf5CZbiW1y2s5jsIXg Z22QSLkFlNgbWHEtKirqw6tYY2T2emu+Ye90t4iYiYhKeQrpfpIEmih/wOw3ajUSGk jU/xZbPWrAEJty7jVe1TD48rI/fR8153H0hXqgYQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201223125535eucas1p2eb932cf4db93a6c845283571fc9f41ff~TWbdGIgli0881908819eucas1p2E; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FD.41.45488.74E33EF5; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201223125535eucas1p2358eef28313de969c15405450a5b9acf~TWbcxDeR_0881908819eucas1p2D; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201223125535eusmtrp1cf5b55962d9a7eb1ee0b65629372ae6d~TWbcwZp7S2414424144eusmtrp1k; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) X-AuditID: cbfec7f5-c5fff7000000b1b0-62-5fe33e47d44d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 82.E8.16282.74E33EF5; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201223125534eusmtip23fcb9a67bcea49d16ad8393f81c7fc7b~TWbcYimYq2192921929eusmtip28; Wed, 23 Dec 2020 12:55:34 +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 v3 5/6] disk: dos: add code for creating MBR partition layout Date: Wed, 23 Dec 2020 13:55:14 +0100 Message-Id: <20201223125515.28865-6-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201223125515.28865-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7djPc7rudo/jDVa1K1hsnLGe1eLGrzZW i+fvLjNZrD1yl93i25ZtjBZv93ayWxye+oHRgd1jdsNFFo95s06weHz4GOdx9s4ORo++LasY A1ijuGxSUnMyy1KL9O0SuDKOLT3MWNBgWLHkew9bA2OfWhcjJ4eEgInE/rMzGLsYuTiEBFYw SvROncYE4XxhlDh8ZBYbhPOZUaJz8i92mJavM79DtSwHStw5i9Cyt+8pK0gVm4ChRNfbLjYQ W0RAQuJX/1WwDmaBf4wSB399BCri4BAW8JdYtkILpIZFQFXi8cazYPW8ArYSq9ddY4LYJi+x esMBZhCbU8BO4tuCDlaQORICUzkk5q5+CFXkIvG88y4LhC0s8er4FqhTZSROT+5hgWhoZpR4 eG4tO4TTwyhxuQnkb5Aqa4k7536xgVzELKApsX6XPkTYUWL7ov+MIGEJAT6JG28FQcLMQOak bdOZIcK8Eh1tQhDVahKzjq+DW3vwwiWoEg+J85MjIeEzkVGiadsKlgmM8rMQdi1gZFzFKJ5a WpybnlpsnJdarlecmFtcmpeul5yfu4kRmCZO/zv+dQfjilcf9Q4xMnEwHmKU4GBWEuG9xP84 Xog3JbGyKrUoP76oNCe1+BCjNAeLkjjvrq1r4oUE0hNLUrNTUwtSi2CyTBycUg1MQd+3T+RS iJz74bH0LZZZDZvzqtIOSdgtDvo6yfpl1n0tJ22mzdGujMe2L27eulagd7PKReXZcxKbdu90 Kq679bU2/ADbxONidg3WPxUvlq6y7t2pcIxj/d09Yclah5hiNdaJSt1Mf+f4b3FO9ZWtQV94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T+iT3Uc+vza17cxMn/vZSMOZ93zQJ2t1lUyTpmMF duf0YoO0o/ucN8/1N19lW545OyOkuOYAk/H/GbXfDj+YVbJvknuFjXN1pkFWdRnHsm3LKqNT nvQJGr7ST0n2vnuHhX/NPiWW4oxEQy3mouJEAFH5h3TjAgAA X-CMS-MailID: 20201223125535eucas1p2358eef28313de969c15405450a5b9acf X-Msg-Generator: CA X-RootMTR: 20201223125535eucas1p2358eef28313de969c15405450a5b9acf X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201223125535eucas1p2358eef28313de969c15405450a5b9acf References: <20201223125515.28865-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 Wed Dec 23 12:55:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 351449 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp6172555jai; Wed, 23 Dec 2020 04:56:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNjjCuR1B3zJQiAqhp31A1mGHA63z/570Z6yFOyWkrE7SNkkD+TRsAjzUTLGnrOcf+wz5p X-Received: by 2002:aa7:ce16:: with SMTP id d22mr24371769edv.381.1608728187001; Wed, 23 Dec 2020 04:56:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608728186; cv=none; d=google.com; s=arc-20160816; b=bfx6h620EH57ucAKlJJEXTy1MS/MLihpWQCrdc6JtR+uHFEZyk8iV/fGl0IlHhRF2U hdo/894AAkRR3+ie+yWjjvFbOTU0/RsLisSULwKbjEQl8CLo9r+JbCgcGtCDSBFPKXQl 2r4TafUBzXj+9O/PadbsT/DOoKE1ZOYxvP+/vg/UhLOTMUa5u+p4Bcou1Z59LsOxiitN BU361wqIM+HkQzM0d/tjt39C7SxJFT4oCJzKKd79tEAcCArHGFVFX2c/KSoQeKp1NxqI 7G6CL8WUPkL3CMD+uoRmjUYSXIcHdZKBh7hW2A1TZXt5uUFj3+A/7Jzq9GTFxgqHmrw9 JRVQ== 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=YUeodYq328UOaGDmorIXBTVhQyce30ifgR+1xLeRAa8=; b=GL5x9/uAJx1X7uMJgTs8uIy6YxejdQeaJ5CkZ8Y9zeITnOoo45RvzXTQ8fhOX2LMP2 LW0ZNebwJFA/ojUNawozIOVnugdOffAPnNDOQQ0dQuQPR/6cveuhtMLZgv3ffEJzUJKG gMl4sZMamkQ7MuislzgZmlMDX3oYrP994VLUETULLs7ljN7zj7RaOTmVPjovnpQOSJns 4UqYpU4orl3RUiMIOdzCTJ6oSWVmjdclxL/MGcxBdhPm8ie65niF3J4t1Bglu4FLUneB L5G9ZmMSXM2jo34jDQXzSkj5c/aV3+YSY2bNcPfsQ9yGzW+1ebmkRefqlFDuA6XLsscS xyaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=sXlzAqtO; 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 e16si11888259ejd.747.2020.12.23.04.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:56:26 -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=sXlzAqtO; 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 1D3AC82784; Wed, 23 Dec 2020 13:55:54 +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="sXlzAqtO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2A56382743; Wed, 23 Dec 2020 13:55:44 +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 0289782731 for ; Wed, 23 Dec 2020 13:55:37 +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 20201223125536euoutp022411b18adb1e89a7fc6d72302852a3c3~TWbeB88513118931189euoutp02_ for ; Wed, 23 Dec 2020 12:55:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201223125536euoutp022411b18adb1e89a7fc6d72302852a3c3~TWbeB88513118931189euoutp02_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608728136; bh=YUeodYq328UOaGDmorIXBTVhQyce30ifgR+1xLeRAa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sXlzAqtOB89DzlNFFNMQTyJN+GwZvcmEvW/FP2yYUGhc6gFw9+9JPm+WbAvHJNUup kQQmImogQvuuDqVA6dooFdFafrso4gXE3UEDsq+mfeUvJ67osI5JvxYPynazgxTtUw MQwDhcEsIRDngNq9ppLGgDA4/lJB+RLsTUn0ZqpI= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201223125536eucas1p2f6c8204d32ca0c60f7aabc11189bfd34~TWbduLk2B0474004740eucas1p2V; Wed, 23 Dec 2020 12:55:36 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 05.79.27958.84E33EF5; Wed, 23 Dec 2020 12:55:36 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201223125535eucas1p12eefba574c1dad89834fa4e12ee35e56~TWbdPQON43267632676eucas1p1Z; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201223125535eusmtrp1c9cf7d7da5999521202f2dedae7caee6~TWbdOnX-N2521725217eusmtrp1B; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) X-AuditID: cbfec7f2-efdff70000006d36-0f-5fe33e48a5c2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 03.E8.16282.74E33EF5; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201223125535eusmtip2fd5a3547517734ad8cf70de40e14d4a4~TWbcuFHMq2463824638eusmtip2k; Wed, 23 Dec 2020 12:55:35 +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 v3 6/6] cmd: Add MBR partition layout control utility Date: Wed, 23 Dec 2020 13:55:15 +0100 Message-Id: <20201223125515.28865-7-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201223125515.28865-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIIsWRmVeSWpSXmKPExsWy7djP87oedo/jDU5f4LTYOGM9q8WNX22s Fs/fXWayWHvkLrvFty3bGC3e7u1ktzg89QOjA7vH7IaLLB7zZp1g8fjwMc7j7J0djB59W1Yx BrBGcdmkpOZklqUW6dslcGVcPrOZseBPasWdhZdZGhhX+3cxcnJICJhIfJ48n62LkYtDSGAF o0TDzh/sEM4XRokVDT2sEM5nRon29WfZYFrWX2yGqlrOKHH7yk02uJaGr8+YQarYBAwlut52 gXWICEhI/Oq/yghSxCzwj1Hi4K+PrCAJYQFXiT/PpjGB2CwCqhKND+aBNfAK2Eq82PKPCWKd vMTqDQfAhnIK2El8W9ABdpOEwEwOiY6F+1khilwk1sx5zAxhC0u8Or6FHcK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VeLHlHxPEfHmJ1RsOMIPYnAJ2Et8WdLBC7LKVmHVqHfMERr4FjAyrGEVS S4tz03OLjfSKE3OLS/PS9ZLzczcxAkN227GfW3Ywrnz1Ue8QIxMH4yFGCQ5mJRHeS/yP44V4 UxIrq1KL8uOLSnNSiw8xmgLdMZFZSjQ5Hxg1eSXxhmYGpoYmZpYGppZmxkrivCZH1sQLCaQn lqRmp6YWpBbB9DFxcEo1MDVO8MmrOMoX0Bb4LC/V1Txwz8srJTrGNiF9O4Ly9VW9VINPd5zc fXhryP//prM23JNa4PnSJ/G5cmvDzimO2U/eXbPPc2a1iOL/+Mv66r6uo+kzp/25cEpohrXg FZvlk77PLZX8fT2adxWv+IH85d53ryzcZLDu8NNO30gxH4nOg9KlkryG1+M/HJzgs9NR/9/H 2mNnA37ZOh7OURE/dnDK8nnzegNu/FXO4fprrSq75P15BeFPfUxT557M/fb4sHV7+NF5+z54 trm23PmyVEct/+6R7t2HvCJWpi/h9K5JmXC6rVxPSkHe1iaS+82N7oYJP8O6v6ucYNnsusF3 if+tp437Em938Hw/2esl+V6JpTgj0VCLuag4EQAoXagc4gIAAA== X-CMS-MailID: 20201223125535eucas1p12eefba574c1dad89834fa4e12ee35e56 X-Msg-Generator: CA X-RootMTR: 20201223125535eucas1p12eefba574c1dad89834fa4e12ee35e56 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201223125535eucas1p12eefba574c1dad89834fa4e12ee35e56 References: <20201223125515.28865-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 users create or verify MBR partition layout based on the provided text description. The partition layout is alternatively read from the '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 type). 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 an 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 | 314 ++++++++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + doc/usage/mbr.rst | 93 +++++++++++++ 5 files changed, 417 insertions(+) create mode 100644 cmd/mbr.c create mode 100644 doc/usage/mbr.rst -- 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..da2e3a4722 --- /dev/null +++ b/cmd/mbr.c @@ -0,0 +1,314 @@ +// 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 a value from the key=value pair list + * @str: pointer to string with key=values pairs + * @key: pointer to the key to search for + * + * The list of parameters is come separated, only a value for + * the given key is returend. + * + * Function allocates memory for the value, remember to free! + * + * 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() - Search for a key without a value in the parameter list + * @str: pointer to string with key + * @key: pointer to the key to search for + * + * The list of parameters is come separated. + * + * Return: True if key has been found. + */ +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_partitions(const char *str_part, int blksz, + 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 / blksz; + } + 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 / blksz; + 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 blksz = dev->blksz; + int count; + + if (str_to_partitions(str, blksz, &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 blksz = dev->blksz; + int count, i, ret = 1; + + if (str_to_partitions(str, blksz, &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" +); diff --git a/doc/usage/index.rst b/doc/usage/index.rst index fbb2c0481c..5869fba189 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -14,4 +14,5 @@ Shell commands bootefi bootmenu button + mbr pstore diff --git a/doc/usage/mbr.rst b/doc/usage/mbr.rst new file mode 100644 index 0000000000..2339162098 --- /dev/null +++ b/doc/usage/mbr.rst @@ -0,0 +1,93 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +mbr command +=========== + +Synopsis +-------- + +:: + + mbr verify [interface] [device no] [partition list] + mbr write [interface] [device no] [partition list] + +Description +----------- + +The mbr command lets users create or verify the MBR (Master Boot Record) +partition layout based on the provided text description. The partition +layout is alternatively read from the '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 partition 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) +* id (MBR partition type) + +If one wants to create more than 4 partitions, an 'Extended' primary +partition (with 0x05 ID) has to be explicitly provided as a one of the +first 4 entries. + +Here is an 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 + +To check if the layout on the MMC #0 storage device matches the provided +text description one has to issue following command (assuming that +mbr_parts environment variable is set): + +:: + + => mbr verify mmc 0 + +The verify sub-command is especially useful in the system update scripts: + +:: + => if mbr verify mmc 0; then + echo MBR layout needs to be updated + ... + fi + +The 'mbr write' command returns 0 on success write or 1 on failure. + +The 'mbr verify' returns 0 if the layout matches the one on the storage +device or 1 if not. + +Configuration +------------- + +To use the mbr command you must specify CONFIG_CMD_MBR=y. + +Return value +------------ + +The variable *$?* takes the following values + ++---+------------------------------+ +| 0 | mbr write was succesful | ++---+------------------------------+ +| 1 | mbr write failed | ++---+------------------------------+ +| 0 | mbr verify was succesful | ++---+------------------------------+ +| 1 | mbr verify was not succesful | ++---+------------------------------+ +|-1 | invalid arguments | ++---+------------------------------+