From patchwork Tue Dec 22 14:09:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 346637 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5358068jai; Tue, 22 Dec 2020 06:10:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhIrYe7F9RwSY0d5DnebkExE1qFQM/Xi8cEWSyY/IeorRJMl1HcLTtZ8KkjV4+DUx9vfHc X-Received: by 2002:a17:906:4705:: with SMTP id y5mr19918819ejq.112.1608646219928; Tue, 22 Dec 2020 06:10:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608646219; cv=none; d=google.com; s=arc-20160816; b=v5UzyuhAjgMKA0xHoi3XCm2pJ4ENaT1SccbPWRynBQAShqAcTLwzSrebQZDEFErXDV Omi8h37JJEwtlL6iy5l/yht/SO0MWbLdvcRtEa3iCIiHejEMFxbj/YDTlpGW7fb2TKwW 8MT5X649VWOy/pwBQc0UtHjuHipphgcjNqwTeqH979Hits0Oc9S7cikFD1OF1dtb1y8P mMiBZq/gJWpmVioslATP8jGAuiejCD0ns/POuov9HYWlmV/WZF2nsZEr8PGygN+VmnJF i7gRSCl2AY7CRu7dz/egwkJVXgEMx9kZT5FN+7Z1CTPiV14tBhXWbFyeG3Wz19mk34Cf QoiA== 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=GzxozJRt0YtkhSSdLQgEdwCxk2ky7RWvS/uB4hnnNVZ3jmHcaOu8ETtZYw9vl66rzg eJkRtk49wtqWiI509DIkM2eMu5IqvEwbubC+Hz3+fA5DF64SDrgm/qXSgEKzce676ZPJ pfNrdfW+PuCmn3eYw2N8pHFLZ+x0A/mfEYzkzNJSiFPcpSP6wblsZHDUWeBLu6bUbWBQ EdUFoDeobSeLLb6L/N42SmOaNN17aRKjaCWQ0A/rXnsT2w+3hSZXpzR/nREwvqdlGGKe x8PqXoI5VkJ5l4DmhWslTq3PzawdkpIZlfAtvICKnNPH/Tkk0YPdcxjt2gUvVukGoDZV BS4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=myA8skJw; 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 s2si11999095edw.5.2020.12.22.06.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 06:10:19 -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=myA8skJw; 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 9E8F482ACA; Tue, 22 Dec 2020 15:09:59 +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="myA8skJw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A208482ACC; Tue, 22 Dec 2020 15:09:53 +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 9A02F82A8E for ; Tue, 22 Dec 2020 15:09:49 +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 20201222140948euoutp018d96e2510255c63065dcdc6ac22786a4~TDy_P7suW2281922819euoutp01d for ; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201222140948euoutp018d96e2510255c63065dcdc6ac22786a4~TDy_P7suW2281922819euoutp01d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608646188; bh=1ODBY96fFBqFt8d2xGKeYGO05SitY939t1BYMg+dfjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=myA8skJwFD6CAaIFFOuRoO4Vpr8n69C26LJ11JEIzMBAAF9LF0kPiSXHUeI0xlRZR 4NJNmx06DLSSaZ87177xWRq3dJMGm44wkrCB9R5goPF+4z0Zc9+XLswoYiVWcUf77Q I1X9GombeZK5HiheO7FrcklZGP0pHykTaxJjlZ0Q= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201222140948eucas1p255e8d3d9cb31707cc3019d898d2cc16f~TDy_DiYLZ1827818278eucas1p2D; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 77.51.44805.C2EF1EF5; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201222140948eucas1p2186f51e41132913152cce081bdbdcdf5~TDy9hWDWV1618316183eucas1p29; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201222140948eusmtrp17867295eb02198187733fe6424ceea66~TDy9gxh8Q0854808548eusmtrp1P; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) X-AuditID: cbfec7f4-b4fff7000000af05-89-5fe1fe2c6684 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id FD.5A.21957.B2EF1EF5; Tue, 22 Dec 2020 14:09:47 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201222140947eusmtip11f4891534dde139ae860fce3ef1c55f3~TDy9Ffw6s0861208612eusmtip1C; Tue, 22 Dec 2020 14:09: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 v2 1/6] disk: dos: rename write_mbr_partition to write_mbr_sector Date: Tue, 22 Dec 2020 15:09:09 +0100 Message-Id: <20201222140914.9933-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222140914.9933-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djP87o6/x7GG9z6KG+xccZ6Vosbv9pY LZ6/u8xksfbIXXaLb1u2MVq83dvJbnF46gdGB3aP2Q0XWTzmzTrB4vHhY5zH2Ts7GD36tqxi DGCN4rJJSc3JLEst0rdL4Mro7bzOVtApUHHpxCW2BsYJvF2MnBwSAiYSe3+3sIDYQgIrGCVW X/PtYuQCsr8wSkzY+oYRwvnMKNHypZO9i5EDrKO3XRgivpxR4tG5eSxwHTfPfmcGGcUmYCjR 9baLDcQWEZCQ+NV/FWwSs8A/RomDvz6ygkwSFgiW+DCFFaSGRUBV4t/3ZUwgYV4BG4nNq9wh rpOXWL3hANhITgFbiWMv7jCDjJEQmMkhcW/BXRaIIheJf486oWxhiVfHt7BD2DISpyf3sEA0 NDNKPDy3lh3C6WGUuNw0gxGiylrizrlfbCCbmQU0Jdbv0ocIO0r8XvGVDeJjPokbbwVBwsxA 5qRt05khwrwSHW1CENVqErOOr4Nbe/DCJWYI20Oi+dYtVkjoTmCU2HuYcwKj/CyEXQsYGVcx iqeWFuempxYb5aWW6xUn5haX5qXrJefnbmIEJojT/45/2cG4/NVHvUOMTByMhxglOJiVRHjN pO7HC/GmJFZWpRblxxeV5qQWH2KU5mBREudN2rImXkggPbEkNTs1tSC1CCbLxMEp1cBU/bVG 87/0OlXdl7cXxXnr3V4nt7KH4cXpvac+MHRe2RwQ+2hLUKlMweYHIZ0F/3deCesrfVzmqLzz 5ts7L01aSk6F7lrZFOSputJNm/OJyWE9/Wd7vFduLrU1CQiMVXty07htRoeIZNbn6YKs+5W+ sFuyzld+K1N+/JXu5KeF4X3sxuaX+k6e/co17Sb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Swm O/FtOp/r9BtL1uuf6F719WwCN4dH4NXMrazCNsqXntr9V01yWbX9N3es//sT9wyiPRzYXK4c UDosYybyQLdc7cUFb4nsbTMSlViKMxINtZiLihMB3JhjAOACAAA= X-CMS-MailID: 20201222140948eucas1p2186f51e41132913152cce081bdbdcdf5 X-Msg-Generator: CA X-RootMTR: 20201222140948eucas1p2186f51e41132913152cce081bdbdcdf5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201222140948eucas1p2186f51e41132913152cce081bdbdcdf5 References: <20201222140914.9933-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 Tue Dec 22 14:09: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: 346636 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5357716jai; Tue, 22 Dec 2020 06:10:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4G0dHnxrUnUqcKWE7UnQMHhngJCqD9kjMfyNFLKt1J3fZk5tffN2aJMdgEnYoSuOpHrfw X-Received: by 2002:a50:8163:: with SMTP id 90mr20126238edc.142.1608646201308; Tue, 22 Dec 2020 06:10:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608646201; cv=none; d=google.com; s=arc-20160816; b=LAxJdgoCY1CsnFK77MkkY1xXkE8AA2FY0gBLBT/tKfqYBdBX4r+5h1TAgTfQ7W/dfG XiXCher/7/hG/dpPaRc5k7F3vT10CO6+p7RcJ9LG4WFzalWR4KpBQyUCDzOnOaX1XHGX TXfzK+2nlawc1+Clfnk68dcIxGeLY6tI6HrdUrSAzTPW1Sv7J3oaGVAC9WdLGiRDquVH MjsUDh9vpFn2HL89aSDDLeS3UWcSj6ujyR/vVCFE/MY9hQQagMoYhZ9dBEm76MVSg7md bxZMK6JepfIyp4fuS+4nn9KTvVqVjPDUlzv+lwIg330JAYC+vbhFv+RTEjL2qWZZfvGW ngFw== 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=qHwdqY+NdghOmAaUr+vv2wMa7GYR5d/V8op9zNEqpYV+J6dEORxBWlo9G7ta4uGRlg 81yYNHQuVnkKYFSF/e0wU5BQn72nP5AYMlDgamejdMmWS5EkyL7T4/38wfSop8gzsTev RWq+cb2ipduOIUXEv4R9iwq2dMvVo13eS6haB29JpUpSlwel0irtWtkDmKLrs7VKd+h9 DDyBSeGlkcDtjZ5+R/U+PZ6UVBXZ4O74eOKLAF6Mxgvkm8ZAO/wN93elGKdRNcHVIQ8/ 4IrkHNpn1l4oy311v1iTXZV7WP8dd38mk88xdmzv4/06JR6AqcIXSJO/tA52BomqeTWS m2Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=KtQXOdgN; 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 s23si10321166ejf.192.2020.12.22.06.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 06:10:01 -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=KtQXOdgN; 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 9F68A82A92; Tue, 22 Dec 2020 15:09:55 +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="KtQXOdgN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D3D3382ACE; Tue, 22 Dec 2020 15:09:52 +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 C7C4782A92 for ; Tue, 22 Dec 2020 15:09:49 +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 20201222140949euoutp019510096fa9234b6b029ee6ce89aae291~TDy_qqq322282222822euoutp01b for ; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201222140949euoutp019510096fa9234b6b029ee6ce89aae291~TDy_qqq322282222822euoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608646189; bh=Ugopsy/ZxytmB8ap3xn0lUro0TDiqP7g+knq07e92AU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KtQXOdgNtzqlq5wd3EwvZBfiJXB3NXRS0HrTV1NVadl7vJWUK4NqTFrBp0auZ/Apw c2MByPe58fmZm/21q143BhQpG8rYozt9am/WzGNStauGRLwbPMkoavDZfsf2b4TLGC 08yET/Po0EL2RiDSnnBGA2AOmUOMjmn981gV/U0g= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201222140948eucas1p1dddbaf0634049030a1fd07f3f6ff32f4~TDy_Q-rhg0660906609eucas1p1O; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id DC.C5.27958.C2EF1EF5; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201222140948eucas1p1cf6eb463b42c4f9c5c34e886e1c36b85~TDy925EjN0662506625eucas1p1E; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201222140948eusmtrp1257b214f939f398098f06e8ecf101c84~TDy9zr5Dj0854808548eusmtrp1R; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) X-AuditID: cbfec7f2-f15ff70000006d36-80-5fe1fe2ca5a2 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 63.37.16282.C2EF1EF5; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201222140947eusmtip11dad5c34cb41a8bb405f742faa55e64c~TDy9bIZgp0857608576eusmtip1F; Tue, 22 Dec 2020 14:09: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 v2 2/6] disk: dos: add some defines for the hardcoded numbers Date: Tue, 22 Dec 2020 15:09:10 +0100 Message-Id: <20201222140914.9933-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222140914.9933-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7djP87o6/x7GGzR26FtsnLGe1eLGrzZW i+fvLjNZrD1yl93i25ZtjBZv93ayWxye+oHRgd1jdsNFFo95s06weHz4GOdx9s4ORo++LasY A1ijuGxSUnMyy1KL9O0SuDLebFrNWNDJVfH15xbWBsa5HF2MnBwSAiYSXduaWbsYuTiEBFYw SvTffw3lfGGUmPTwBZTzmVFi77E+ZpiW9t3dLBCJ5YwSR14eZINrmTVjGSNIFZuAoUTX2y42 EFtEQELiV/9VRpAiZoF/jBIHf30EmsvBISzgL/H5QTlIDYuAqsTUrr1gG3gFbCS+LP3ABrFN XmL1hgNgcU4BW4ljL+4wg8yREJjJIXHr5zYmiCIXieYd8xghbGGJV8e3sEPYMhKnJ/ewQDQ0 M0o8PLeWHcLpYZS43DQDqsNa4s65X2wgFzELaEqs36UPEXaUOPrnM9ihEgJ8EjfeCoKEmYHM SdumM0OEeSU62oQgq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W3Ywrnz1Ue8QIxMH4yFGCQ5mJRFeM6n78UK8 KYmVValF+fFFpTmpxYcYTYHOmMgsJZqcD4yZvJJ4QzMDU0MTM0sDU0szYyVxXpMja+KFBNIT S1KzU1MLUotg+pg4OKUamKKqdERUOK5q3u70aLq+waxSnLX78huhf4dquo04HtofTZp1Nviy 98aI0wZ+8z5KLdz3XbNn/t+FmyZuWCfIdX3zBsmUxVMl2EOftp/K0njvtKAyeO3jqtWfj7kp ttu6FH5ctMuwYLuAsfL/py4ap6Q5F2476vhzvdjbna+CP6lMmn5O0XnnVS2+Xbu+PLNrD7mw tdR1od3M8/IpK6zWbBU/fd1p9v4lJ972aFSuL4l9Ye68hSvkclxPZP76YJ3v/hYH5+yXPPjf UWFNG/fiEsUQDgWVr3WqZX13fx1j3RwSpndyhbvly/vs+Qbcb5Z8YJwYIMWeGbVn0yr/sFc+ 6awiZ+uiTA69C4+f4y4uf1mJpTgj0VCLuag4EQDFuwuq4QIAAA== X-CMS-MailID: 20201222140948eucas1p1cf6eb463b42c4f9c5c34e886e1c36b85 X-Msg-Generator: CA X-RootMTR: 20201222140948eucas1p1cf6eb463b42c4f9c5c34e886e1c36b85 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201222140948eucas1p1cf6eb463b42c4f9c5c34e886e1c36b85 References: <20201222140914.9933-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 Tue Dec 22 14:09: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: 346640 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5358615jai; Tue, 22 Dec 2020 06:10:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQai4ngdfu20ysCA+xzX9UBjVzQ1KOQU/waOmTwyz40H0dyeixrpNhL/ClNrMTQJsiRR3j X-Received: by 2002:a17:906:a115:: with SMTP id t21mr19745074ejy.549.1608646252535; Tue, 22 Dec 2020 06:10:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608646252; cv=none; d=google.com; s=arc-20160816; b=iyHrIOFYfcThgwFFeGA6oElg0Yg5Uf/cLkceflTpHIEHzUhQoP0/cDk/vRAfKVH7i9 kQEK9WFHolcGEfN8Lt4ZNBTXFlatb51SmkYB/cLYfBxIKakDLxuYN1bGAI2sd0Y4fOD3 /grlkM3HSY6qZkstA4ul2vEjzAx+Pgpb8COn+uIs4bSNr3/2ABbnakr8fHXqAwQdh6gL O6wVIqyPXXOKs0qPXiqChXAgN91YdVoVpjhtdohbaigrKtbFyLg6b0JYd+KTuSLPUPQY OaKPlblw8+qaoEHDHK0xrx+wLjo49sUTsNNpVk4jkc0GNvjgQHOPIp4fKrc+O/RuA7pO zttQ== 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=xzHBcDYJ891E+4IKdcxvRnQFEgNb3FjG6Y3OFUyh2nteYt4R26bFwIlB9w3B+CYb01 +KUHu1Ynz+eCsc5GvwLaQ9ydLlsx0JmsNie5CEefXDje5Nfyjl19MLWfmksHaqZyvTSn 3/jN+yRmPv542FvhWA6BPlf54cIfDIqUCECvU/Rs9zcvjlZdkVMdSYAhVnqX2OXBVAT4 dOFrMwhhRATBnpgrzryYCsbwXuCZJvsDp005/uXfD45FfgsAjWHTrDqUDEgayXWdZJUY KrEjlYejf66AHLhWFW10wmeAnlh06eNuVm4hd1TypXUJSgloynxqeZAW31QXK6Xj1cDH +WtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=aniFWqdP; 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 k9si10171324ejz.703.2020.12.22.06.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 06:10:52 -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=aniFWqdP; 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 7609082ACA; Tue, 22 Dec 2020 15:10:30 +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="aniFWqdP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE9EF82AD6; Tue, 22 Dec 2020 15:10:00 +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 2A99982AC6 for ; Tue, 22 Dec 2020 15:09: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=m.szyprowski@samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201222140949euoutp01075a6e79b4ffe9d78b316e9979a4b098~TDy-BHLIa2159821598euoutp01f for ; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201222140949euoutp01075a6e79b4ffe9d78b316e9979a4b098~TDy-BHLIa2159821598euoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608646189; bh=F6V+qSwemnBQzCEmGI+kufqwnsfQVkuy9Ib33MTjCQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aniFWqdPO6TkJdqsFKEV/DaljjlhUkUh6Om72rnpSigLlJXxVDMXfMgMZ2OLeRgEy p2XzZa6RkM8hSGgP9XMaDWCmcCw5qUPKrBHDq11ZwmEU9DvhzKTkXGq6t45/ezP6oJ MjHch/MRsdck6OAcPsZ/iAOw6+A/dPoT5nzg3zOk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201222140949eucas1p274f2a1051cf62c5f1dd7f42407a941ba~TDy_pV73g1624516245eucas1p2-; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id DB.8D.45488.D2EF1EF5; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201222140948eucas1p1e3e38a2c34b4779297dbba74d6a1b781~TDy_PJ-fw2338623386eucas1p1K; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201222140948eusmtrp110d6c253938f7c249e2e83500e71b379~TDy_OmPZO0827608276eusmtrp1h; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) X-AuditID: cbfec7f5-c5fff7000000b1b0-f3-5fe1fe2de26a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 55.37.16282.C2EF1EF5; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201222140948eusmtip16323816e965b3fc310ced4e7d9083b73~TDy9xkIKT0861208612eusmtip1D; Tue, 22 Dec 2020 14:09:48 +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 v2 3/6] disk: dos: use generic macro for unaligned le32 access Date: Tue, 22 Dec 2020 15:09:11 +0100 Message-Id: <20201222140914.9933-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222140914.9933-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe0hTcRTH++3ebdfZ6jpFf9lDkizssZw9uOYqA8P7l0kFvdA58qKWm7Lr q6JcaWZD1rQk2cBKrcx3OqcMtJw2LZv5qoSU0lEza+VQK0dJzkv23+d7zvd7DhwOhgimUF8s UZ5KKeTSJH8ODzWY53q3bZsfkwQ1tLkRj4vr2MSwM5dN2L4NsoiazlEu8UNvAIS99TqX6Cia AmFcUqfsR8kSbTdKTjliSMtICyDV+koQxT7JE8dRSYnplGL7vlheglmlYqeYVme+qupGlKDa WwUwDOI7oW48XQV4mACvANBiaQaMmAGwU29iMWIawAFN84JwW0xk5xg5TOMhgE7DI+5SpLQ6 l+tycXARVNlV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ArNFBCQkfvVfZQSxmQWamCTW/gezhQX8JM4+uAU2iEVA VeLU3cdgC3gFbCS+7roCtUBeYvWGA8wgNqeArcSxF3eAbA6gZTYSZ/ZWT2DkW8DIsIpRJLW0 ODc9t9hIrzgxt7g0L10vOT93EyMwZLcd+7llB+PKVx/1DjEycTAeYpTgYFYS4TWTuh8vxJuS WFmVWpQfX1Sak1p8iNEU6IyJzFKiyfnAqMkriTc0MzA1NDGzNDC1NDNWEuc1ObImXkggPbEk NTs1tSC1CKaPiYNTqoEplH3NC9k0EcdrExmW3NmVVL1gq7ttq1mQ3aJamwt/5Wx+8c6f/eBg An9QsOfkLn6NtBvXpf9c1In1c2NJ7GH4sWnFWt5Juze15vBra05vNGfLlL+10ij8kOXSSm9G SVWDX3VrrkVuX1R/5tzzmaorpwep9DPvuKYh8uCj11NOk10zSxb1KjWv+lPZYbzVQ15q6cIV 09luXn+qIjQ/YeP1uG+64i0ORj2PPtZMOhruUjfZ/KfXFn/p0sNvF6UZf5vF/VdOYdrSgsfy J8w46pbcD2+5l3yZr820z81H1vzbSfcrX9becdui3FbftuuO1/pCq4fT6pw/6nFuWjvr2LY7 bVb/Z+eeK1Eoye4OsPFTYinOSDTUYi4qTgQAt8xJw+ICAAA= X-CMS-MailID: 20201222140948eucas1p1e3e38a2c34b4779297dbba74d6a1b781 X-Msg-Generator: CA X-RootMTR: 20201222140948eucas1p1e3e38a2c34b4779297dbba74d6a1b781 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201222140948eucas1p1e3e38a2c34b4779297dbba74d6a1b781 References: <20201222140914.9933-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 Tue Dec 22 14:09: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: 346638 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5358219jai; Tue, 22 Dec 2020 06:10:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwB4Dp0X8W3uEBDxdVdX/9WFxBLCPYFH4//m1TIy9QBX8yi5Viv6YHNw8m3hxaj3iCLI/Rb X-Received: by 2002:a17:906:eca9:: with SMTP id qh9mr2864459ejb.188.1608646228226; Tue, 22 Dec 2020 06:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608646228; cv=none; d=google.com; s=arc-20160816; b=EiPch15yz/NrgjsvtxfcfBkOaSbF7bkfWuaQdqk+bE7iLFU7MFUaWs4EzrhD07kGrp D9I4gqtLomfsIsYeaaCP2Cb4fqAx4gMZ0thzoxpdI8gXKv/TQp3mzVXlZG//6jjE3UqR Ingjl4bws8B3o8wGlEzQzE/Gaix4nf9fd6oIlKdCOGqmH2P7iOy1jRpBeh0qG8XFNtkN gWPrXgq9utjPZB6CeEyUCRAF8GN0UWmEG6tQW+PPBmos+M0wX9uCg8u9Fp/1UdXPUddo thx9C4GAjJ6ZpYzFLMBNdJNwaom6DOTu5fX+w+Jk5I/XwxxlQQfFunBkG9vlN7Pj4JQ4 BbGQ== 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=az3YK9n/5cqi/yf673RWc9SHyloWCyC7ZvpNt541rsjW/KZPw1LI510tEfUAJzrBVE ZQ+Q+KcSbQUTaqfa5EHplzaFZhHrIrC/cFEGaREnwTkygqfGb6liVi38ZO88MtWpeqZ/ RjwhnfpRGhcGfaFMwpG5uHq79Vfuo156RIRg5uuPhxSACgP9VXUbwJMplsPWACWYw+s0 S0pZ1OnTlrOm6559Yh8xpuSHpe4dsDZ/cXdMRZh8SK5o27cntF6WaqbZIWpHZfBwJEaK YXQ4wfOFB4xBa9gOuQtVjS7BHwHC1pLB6bwzL1f/Ww17eRZSaTyn5VabG5Gnx54kelf0 6zaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=GOTqC+tU; 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 by16si10269439ejb.105.2020.12.22.06.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 06:10:28 -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=GOTqC+tU; 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 DA22182ACB; Tue, 22 Dec 2020 15:10:16 +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="GOTqC+tU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 538DD82AD2; Tue, 22 Dec 2020 15:09:58 +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 9C51482AC9 for ; Tue, 22 Dec 2020 15:09: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=m.szyprowski@samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201222140950euoutp01506fa4a0bcc262a171e3fa21eab0fd9b~TDy-hvlWq2281922819euoutp01f for ; Tue, 22 Dec 2020 14:09:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201222140950euoutp01506fa4a0bcc262a171e3fa21eab0fd9b~TDy-hvlWq2281922819euoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608646190; bh=QVv/OpDO86vbjc8WTV2cueIe9E1CfauEIcaW529qV2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GOTqC+tUGCxu/Ar7mULKrObLtLVJhRBf5ho29v4symXjLdXXUpo/Mz9Wo+H2Gpi0Y avgyJmS3WjycmDql/kMFXCDWUrENtLNxb3Tt5QtkMJZBndgSOa6oWeVmcHE1MZo0dy g7bCN0/g485Oaep29Ut2RoD2GluIP1nGgB03aAGE= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201222140949eucas1p2774ebfdd4be83c0f472b2162734c66ef~TDy-NJ2Sl3183831838eucas1p2q; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5C.8D.45488.D2EF1EF5; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201222140949eucas1p2b1c1d67596275f488aad2136478ce677~TDy_pyC4o2496624966eucas1p2m; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201222140949eusmtrp1553d57d199eba7f23f4a048841c29c56~TDy_jk7mU0854808548eusmtrp1T; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) X-AuditID: cbfec7f5-c77ff7000000b1b0-f6-5fe1fe2d8f76 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 06.37.16282.D2EF1EF5; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201222140948eusmtip116726f63c1e74267010bee5a9b3561de~TDy_HG70O0857608576eusmtip1G; Tue, 22 Dec 2020 14:09:48 +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 v2 4/6] disk: dos: make some functions static Date: Tue, 22 Dec 2020 15:09:12 +0100 Message-Id: <20201222140914.9933-5-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222140914.9933-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRmVeSWpSXmKPExsWy7djPc7q6/x7GG7y4qWuxccZ6Vosbv9pY LZ6/u8xksfbIXXaLb1u2MVq83dvJbnF46gdGB3aP2Q0XWTzmzTrB4vHhY5zH2Ts7GD36tqxi DGCN4rJJSc3JLEst0rdL4MrYtvMKe8FU9oqpd++wNjD+Zu1i5OSQEDCR2Pf1OksXIxeHkMAK RolfS+8yQzhfGCWmHt/ACOF8ZpRYOO0ZO0xL+4ResHYhgeWMErvOR8N13Fi7jxkkwSZgKNH1 tosNxBYRkJD41X8VbBKzwD9GiYO/PoJ1CwvYSpx7sxisiEVAVeLE09eMIDavgI3EwwXPmCC2 yUus3nAAbCg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JLH2P5gtLGArce7NYrAaFgFV iRNPX4PFeQVsJB4ueMYEsUBeYvWGA8wgNidQ/bEXd4BsDqBlNhJn9lZPYORbwMiwilEktbQ4 Nz232EivODG3uDQvXS85P3cTIzBktx37uWUH48pXH/UOMTJxMB5ilOBgVhLhNZO6Hy/Em5JY WZValB9fVJqTWnyI0RTojInMUqLJ+cCoySuJNzQzMDU0MbM0MLU0M1YS5zU5siZeSCA9sSQ1 OzW1ILUIpo+Jg1OqgYnjyDfnZgP1yIyKvXy7RTs1Ni3YtC/kw4IfXT9vW8n8Wlfwi/+2+Lwn UfEe24Q4mNw1l5pKpfgs3fx829FP4X7r559cX+x59e8/s5k7AqyZ7l5gCThzquVDg/pjzRId A6XLj1r9RGesVL12+UqcBtejsqdl3u7l63SPMd7s79KrMPhtGvfoz2rnypd79E4tZ1QQEXDN n2WfYHr3ncvrdUckz645Jsm+dN6exCyz8nzf+RtW69cfY2Pp4NrxIXuVoIzt0t6fZyb4vr5k HPDs7bLY1k27n5w4frGavVWza0fF4oQzFQbWWn3vBV4lN39qX9L+ylA/TnzaFT3Dq90t4tPl E3rWS4uYXNhlGHrnkY0SS3FGoqEWc1FxIgBgqREM4gIAAA== X-CMS-MailID: 20201222140949eucas1p2b1c1d67596275f488aad2136478ce677 X-Msg-Generator: CA X-RootMTR: 20201222140949eucas1p2b1c1d67596275f488aad2136478ce677 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201222140949eucas1p2b1c1d67596275f488aad2136478ce677 References: <20201222140914.9933-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 Tue Dec 22 14:09: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: 346639 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5358384jai; Tue, 22 Dec 2020 06:10:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAMyLoxtnFju3wwNOZhte08TNGIQXSdK6JU7Bw1LiTVzv3ifj2iM7VKQtl2dTBh2Q32rp2 X-Received: by 2002:a17:906:65a:: with SMTP id t26mr13974922ejb.394.1608646240520; Tue, 22 Dec 2020 06:10:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608646240; cv=none; d=google.com; s=arc-20160816; b=YhOaDqh7wqkTZgZ2svowbJZOKkc9Wy1Zff6yzFJ1BOZIXNXyDrJj17tUJOvCKUo1zT TgW+CTyAyhjEPREiQWhISEJcYcCVVP7T749tonCPckL4O/bVuyq29ZeoLAIPHT4iLy9V kcgF0ex7AH8OfWF88HM4Vgd4+1qwfIBBQKhEakec9Msc63Wa7MZxpY7MRGpX7TWeEBd9 Q0ZSKavkkmyEimyphtPgFUWeEmBr+1xKThpbw28ItfVaz/jf7Bt4Nnsbcsy/k7Zf0OKy YYu0WeQHSH1Y/LZmrLjHoGsQRm8zSB9wVF1/l8/c/RhKV+R0wN9GRj9PXEdWlt+vWdJN Ut4Q== 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=tDFCjWKocLJWkA8qepdKzWD2NKv/q7ZbWXv1gpTOKOc=; b=SKmsjmjFG2Y9Tw6E6y9BT62g2v+DUJ7Tt2bLW+fPrDp18wbsn8AYJaUb5M5Ms2jEZo B5QOcSmKiV1WZZsCjmX1QcgpWkM++oOJiseD8obY9yA4AVT3AL0rKyRBDm8CIEucsl51 VMWu9QXepBZVYBybtuqQNCleUnQhgg9qFeSWpfVbjN8u7u+rcmxts4sYiHkLTBulAyGP fRuC2SmT5hruHlqBn9Kfh8yt3B1FYe9cyimP+bLHEsScuYr+So9aAVnS4ChyPPzlSWl5 J5UwnKgyRkJ9OAW5g1KPPBqS0TxavzxVZL6etqd623VTKu7V+ixe1Zd7oPmXjc6mX/yR LM0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=ZhdpZO9w; 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 lz11si10583508ejb.341.2020.12.22.06.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 06:10:40 -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=ZhdpZO9w; 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 63A1182ADA; Tue, 22 Dec 2020 15:10: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="ZhdpZO9w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 67FA582ACF; Tue, 22 Dec 2020 15:09:59 +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 C6E0E82ACA for ; Tue, 22 Dec 2020 15:09: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=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201222140950euoutp02e3b2f6c8d2f916a5eec03b7671159407~TDy-r_oNq1679716797euoutp02J for ; Tue, 22 Dec 2020 14:09:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201222140950euoutp02e3b2f6c8d2f916a5eec03b7671159407~TDy-r_oNq1679716797euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608646190; bh=tDFCjWKocLJWkA8qepdKzWD2NKv/q7ZbWXv1gpTOKOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZhdpZO9wmLekWduTEBlin04tDwbDdsgBiVbrRsGuzXBZxgDuQPab2P5xBv31vFy58 yVc2RfM66DCERozzARhgVO47CG22FOd2g5dIa+Oz4ntXofnjRJTOqDqnY561Yzk5vY 9R5Vjuf2xZiJ54X6KqF83ybpK0PMxaEdzlMxFHAI= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201222140950eucas1p273b4012e982b266d72a732c67a369045~TDy-fF0so0132001320eucas1p20; Tue, 22 Dec 2020 14:09:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id EC.8D.45488.E2EF1EF5; Tue, 22 Dec 2020 14:09:50 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201222140949eucas1p2cff5aaa0cc0e602762470b61d4e157aa~TDy_48N5U2496624966eucas1p2n; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201222140949eusmtrp12c4e0aaea5420375e451732fd2007801~TDy_4YksN0854808548eusmtrp1U; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) X-AuditID: cbfec7f5-c77ff7000000b1b0-f8-5fe1fe2ef0f9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 11.6A.21957.D2EF1EF5; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201222140949eusmtip161dfe821050075787b9cceddcd041550~TDy_e8MU50859208592eusmtip1D; Tue, 22 Dec 2020 14:09:49 +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 v2 5/6] disk: dos: add code for creating MBR partition layout Date: Tue, 22 Dec 2020 15:09:13 +0100 Message-Id: <20201222140914.9933-6-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222140914.9933-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHIsWRmVeSWpSXmKPExsWy7djPc7p6/x7GG1z7x2axccZ6Vosbv9pY LZ6/u8xksfbIXXaLb1u2MVq83dvJbnF46gdGB3aP2Q0XWTzmzTrB4vHhY5zH2Ts7GD36tqxi DGCN4rJJSc3JLEst0rdL4Mo4vv8WS0GDYcWS7z1sDYx9al2MnBwSAiYSX64dZe5i5OIQEljB KHH05ywmCOcLo8TxSbtYQKqEBD4zSlw+otTFyAHW8XSDG0TNckaJ/Sv2ssA13FrUygbSwCZg KNH1tgvMFhGQkPjVf5URpIhZ4B+jxMFfH1lBEsIC/hIHL30Fs1kEVCU6X69nBrF5BWwk1uz4 xgpxn7zE6g0HwOKcArYSx17cAbtVQmAmh8T3txdZIIpcJH6dfg7VICzx6vgWdghbRuL05B4W iIZmRomH59ayQzg9QP80zWCEqLKWuHPuFxvIc8wCmhLrd+lDhB0l9i9tY4P4mU/ixltBkDAz kDlp23RmiDCvREebEES1msSs4+vg1h68cIkZwvaQeNB4gRkSihMYJRZuMJjAKD8LYdcCRsZV jOKppcW56anFxnmp5XrFibnF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mZpYGppZmxkrivFvnrokXEkhP LEnNTk0tSC2C6WPi4JRqYKp+tfDv/XeOYm+YGm1nWB5IjDY023c6kP2EmPiTWem7dmSpfjwV kHFp48sJ8y5se2pUP2nZgYrNF64uiN6yUm11cVhk8pvLyV5uz78IrVow13hB0YpHC3xfnRQx rQ47siJ2YXGchds0Cza11EiWNhvzN4uOKRZO/jZf83q6fza77uEp0kl8/Xs2CEy5yqd0uXDO 662vA865/c7v+V6fspX/5tGIyeEzWHWvhF6YmPz1yWcltqNH3h3qLrjW9KnBcjGDyJSr3Eua fXh/5D57U29m6Mzdu6lX6J+JxKFbmn8m2s3bss5jSZ1vj+Qko+6fHxV33mvuXXjl8IkfeoxC Nk7bw983ndrVadkze7Gdw6lOJZbijERDLeai4kQAVVHjPuECAAA= X-CMS-MailID: 20201222140949eucas1p2cff5aaa0cc0e602762470b61d4e157aa X-Msg-Generator: CA X-RootMTR: 20201222140949eucas1p2cff5aaa0cc0e602762470b61d4e157aa X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201222140949eucas1p2cff5aaa0cc0e602762470b61d4e157aa References: <20201222140914.9933-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 Tue Dec 22 14:09: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: 346641 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5358818jai; Tue, 22 Dec 2020 06:11:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJz01CSRkRBpRHokQ+U0G4YlcJ5Uq1YXAC95H5znRvROUc8m3W2dhkjJTjwueYdLX+mpUKbN X-Received: by 2002:a17:906:9382:: with SMTP id l2mr20487442ejx.162.1608646264768; Tue, 22 Dec 2020 06:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608646264; cv=none; d=google.com; s=arc-20160816; b=vpn713LAJKwiH3ThnmD+2cDRAGrzeFQDgCXA5BtdR3FOITBXCTpSTXOTn8xKt4OF2J obSAObVoQGHx9OiVoLWbZGyUrfnpMbjd8HvdveC9Cyi+Y0TF9ah8pDzo4GoLDm1SZgGf gXZyqzx/lEmpzQymVP2KOFqQF332s+Km0XSbSS7LKWop90dg2MmCisqDozVICHgHANSo nRBZONdD5OrIqgmmx8vSOFGJX4dVSRm4T2ZZMM/kts6hDTmm565otP/e8HszYGAuyiLm lMc0llc2vHS+KQQk4yKdCddTs8JtO9suEgBpMCc/+glMZkEio5Duwwu9htMnsTKFKZqJ LhNg== 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=BJlLE2lFOJNAOf2plvGrZniyHqHHYkxXA3UOhXtmdC8=; b=kSMy6mN6Sjmfn6anIV2KvQJ6ZF0hZnm8br+nvnnIS+vuIqOcJTuVNaAo9zEvOP4Nd1 Ehu60T/YWYONVhHHcPjKsjgZpqxqIrghg7EtO5aeDf4Biel/bCHMgPwDf6jCsq0gPykD UBMQgc/tEemUjEiFC7elrQo+IZXSFT+IH9wK1mUlT/r1Tra4lsuN6J/WaRWwQOpNOTR7 cY88mAYUQ+avWXBzjKtaB4BrY+pkCiNjckb1teNBZ/uDYBufHKaiFXDntgmKdjF+6m5W 8FV/ZUg2BV+l1RbRTKQk0bgc78TF8aE2nLtB/lV/V24DVANQy32QYv5WQOESGRi6HrEW 7YMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=nMEYDNFf; 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 s16si8869858ejf.641.2020.12.22.06.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 06:11:04 -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=nMEYDNFf; 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 A111782AE8; Tue, 22 Dec 2020 15:10:33 +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="nMEYDNFf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F3C882ACB; Tue, 22 Dec 2020 15:10: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 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 25E2282ACB for ; Tue, 22 Dec 2020 15:09:51 +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 20201222140950euoutp01fe15a310671d1c60b9ebc7614a2aa899~TDy---imw2159821598euoutp01h for ; Tue, 22 Dec 2020 14:09:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201222140950euoutp01fe15a310671d1c60b9ebc7614a2aa899~TDy---imw2159821598euoutp01h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608646190; bh=BJlLE2lFOJNAOf2plvGrZniyHqHHYkxXA3UOhXtmdC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nMEYDNFfA7hz3xDqL18isx6afSDw2CA/1u//ovgZIFzzQZ29tYEuM0OXtTLt7eJJF 9cVoEx0FbAdHREIlR86Ccrs5Y3GgNdDB+FvDMQxrckvllxVe7qxQNQO7sez0CrFzVH HArgSOW/gRRNp+skfd14niWKcv25N8qX4/W+ssXI= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201222140950eucas1p2942c51cfa51bd893a171b0d6a8882633~TDy-w8XlQ3184531845eucas1p2I; Tue, 22 Dec 2020 14:09:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BD.8D.45488.E2EF1EF5; Tue, 22 Dec 2020 14:09:50 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201222140949eucas1p2b78da473484eb152426266c7ac7a11bb~TDy-N8u1N0132001320eucas1p2z; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201222140949eusmtrp269ac0b810dc153c4a70446bcbe4b20cc~TDy-NQNwb0701407014eusmtrp2z; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) X-AuditID: cbfec7f5-c77ff7000000b1b0-fa-5fe1fe2e6f08 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 77.37.16282.D2EF1EF5; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201222140949eusmtip12f8269b9b947ca9c8b6ae3b146164f55~TDy_0rzuQ0857608576eusmtip1H; Tue, 22 Dec 2020 14:09:49 +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 v2 6/6] cmd: Add MBR partition layout control utility Date: Tue, 22 Dec 2020 15:09:14 +0100 Message-Id: <20201222140914.9933-7-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222140914.9933-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSZ0wTYRjmu7u2B6Z6LUZeEDUUJwkroFbBLUn1h4p7gLXKyRCQ9EBBCUPZ IjOgLUQ0ziCIAxAxoq2EJYUi0qDWINEooBiQYgLRIueh/nveZ3zPmzcfiYuHCTsyODySVoYr QiV8K6K6YazN2cXcK3czvwHpvYsVPGn3eApP+vlbJyYtr38nkP6orEbSwSfpAunzgiG0ViA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Rqbx1oZmSrp29mkpOZklqUW6dsl6GVs +/yFqeBtasWZvfcZGxjn+3cxcnJICJhI9N3tZeli5OIQEljKKPFgxlJWiISMxMlpDVC2sMSf a11sEEWfGCXu/lzBApJgEzCU6HoLkuDkEBGQkPjVf5URxGYWaGKSWPsfzBYWcJX492U/mM0i oCqx/2ULWD2vgI3EvmcnGSEWyEus3nCAGcTmFLCVOPbiDpDNAbTMRuLM3uoJjHwLGBlWMYqk lhbnpucWG+kVJ+YWl+al6yXn525iBIbstmM/t+xgXPnqo94hRiYOxkOMEhzMSiK8ZlL344V4 UxIrq1KL8uOLSnNSiw8xmgKdMZFZSjQ5Hxg1eSXxhmYGpoYmZpYGppZmxkrivCZH1sQLCaQn lqRmp6YWpBbB9DFxcEo1MK3KKFn09GFR4Yp50rU8d9MTnhacrPK2+u3vuo3X4m3bpr6T1xa9 0BbZHJLy8/5pltK9Gr5TRBKMXDb/fbiNe8OBqB9zzfo5fh/Jz8pjaLkprnju9WHRqfMmT+Wt tbmR7lD8YP/cygcdWby333bOu/b8Z1/VXVHXT++vLi2zOtXXFmgy+azj9PeZTR//u286sevE 2bndr84muQoaNDHeWBn2VquZ9dXS1RHRN1NbtT1Ylt3d1KOy7ukqzi7GG8LyTOcdI1qzr4gE sE41OPhETO11oohBb4WiWvHnWYUKC2Yt3bdUdUdTdG/Q3RuWJuknosrnLdi0/l3wisvbsmYy Hbi/esNUm1v/JLxu3O1lvXNdiaU4I9FQi7moOBEAMlkZgeICAAA= X-CMS-MailID: 20201222140949eucas1p2b78da473484eb152426266c7ac7a11bb X-Msg-Generator: CA X-RootMTR: 20201222140949eucas1p2b78da473484eb152426266c7ac7a11bb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201222140949eucas1p2b78da473484eb152426266c7ac7a11bb References: <20201222140914.9933-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 | 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..ee27b00c75 --- /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 user to 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 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 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 + +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 | ++---+------------------------------+