From patchwork Mon Feb 6 09:06:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick DELAUNAY X-Patchwork-Id: 724386 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3vH1pb1GjPz9s2s for ; Mon, 6 Feb 2017 20:08:07 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8AC204B5B1; Mon, 6 Feb 2017 10:08:04 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qs8rg48dkCEN; Mon, 6 Feb 2017 10:08:04 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 08D164B578; Mon, 6 Feb 2017 10:07:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 382C44AAD2 for ; Mon, 6 Feb 2017 10:07:23 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E1wBgsDnWpSW for ; Mon, 6 Feb 2017 10:07:22 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [62.209.51.94]) by theia.denx.de (Postfix) with ESMTPS id 0FF264A99B for ; Mon, 6 Feb 2017 10:07:18 +0100 (CET) Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id v1691xjl003265; Mon, 6 Feb 2017 10:07:12 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-.pphosted.com with ESMTP id 28d5a20nwt-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 06 Feb 2017 10:07:12 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EF45D31; Mon, 6 Feb 2017 09:07:06 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 695AC2686; Mon, 6 Feb 2017 09:07:06 +0000 (GMT) Received: from localhost (10.201.23.85) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 6 Feb 2017 10:07:06 +0100 From: Patrick Delaunay To: Date: Mon, 6 Feb 2017 10:06:42 +0100 Message-ID: <1486372016-10654-3-git-send-email-patrick.delaunay@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486372016-10654-1-git-send-email-patrick.delaunay@st.com> References: <1486372016-10654-1-git-send-email-patrick.delaunay@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.85] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-06_03:, , signatures=0 Cc: Franck Albesa , Christophe Kerello , Patrick Delaunay , Gerald Baeza , Patrick Delaunay Subject: [U-Boot] [RFC PATCH v3 02/16] disk: part: refactor part_print_efi to prepare GPT over MTD X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" split part_print_efi : create sub-functions part_print_gpt() Signed-off-by: Patrick Delaunay Reviewed-by: Christophe KERELLO --- Changes in v3: None Changes in v2: None disk/part_efi.c | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index b5928e5..9f044d5 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -172,35 +172,13 @@ static void prepare_backup_gpt_header(gpt_header *gpt_h) } #if CONFIG_IS_ENABLED(EFI_PARTITION) -/* - * Public Functions (include/part.h) - */ - -void part_print_efi(struct blk_desc *dev_desc) +static void part_print_gpt(gpt_header *gpt_head, + gpt_entry *gpt_pte) { - ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz); - gpt_entry *gpt_pte = NULL; int i = 0; char uuid[37]; unsigned char *uuid_bin; - /* This function validates AND fills in the GPT header and PTE */ - if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, - gpt_head, &gpt_pte) != 1) { - printf("%s: *** ERROR: Invalid GPT ***\n", __func__); - if (is_gpt_valid(dev_desc, (dev_desc->lba - 1), - gpt_head, &gpt_pte) != 1) { - printf("%s: *** ERROR: Invalid Backup GPT ***\n", - __func__); - return; - } else { - printf("%s: *** Using Backup GPT ***\n", - __func__); - } - } - - debug("%s: gpt-entry at %p\n", __func__, gpt_pte); - printf("Part\tStart LBA\tEnd LBA\t\tName\n"); printf("\tAttributes\n"); printf("\tType GUID\n"); @@ -227,10 +205,37 @@ void part_print_efi(struct blk_desc *dev_desc) uuid_bin_to_str(uuid_bin, uuid, UUID_STR_FORMAT_GUID); printf("\tguid:\t%s\n", uuid); } +} + +/* + * Public Functions (include/part.h) + */ +void part_print_efi(struct blk_desc *dev_desc) +{ + ALLOC_CACHE_ALIGN_BUFFER_PAD(gpt_header, gpt_head, 1, dev_desc->blksz); + gpt_entry *gpt_pte = NULL; + + /* This function validates AND fills in the GPT header and PTE */ + if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, + gpt_head, &gpt_pte) != 1) { + printf("%s: *** ERROR: Invalid GPT ***\n", __func__); + if (is_gpt_valid(dev_desc, (dev_desc->lba - 1), + gpt_head, &gpt_pte) != 1) { + printf("%s: *** ERROR: Invalid Backup GPT ***\n", + __func__); + return; + } else { + printf("%s: *** Using Backup GPT ***\n", + __func__); + } + } + + debug("%s: gpt-entry at %p\n", __func__, gpt_pte); + + part_print_gpt(gpt_head, gpt_pte); /* Remember to free pte */ free(gpt_pte); - return; } int part_get_info_efi(struct blk_desc *dev_desc, int part,