From patchwork Mon May 5 18:39:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 29664 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 300E02055D for ; Mon, 5 May 2014 18:34:40 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf44355491iec.4 for ; Mon, 05 May 2014 11:34:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=cRMUJzeAMPWxtz/PFnu+G6O2Ydx2vAF35lXcl49UxAY=; b=EpKEGxcr1DVIyyQpgMF3tkRf22Y1wVhf/sAchxRDdp8ccfpx86oLsjd8HdZIV2oqBa VhLKRZtJkIH938VHpkmLVq5ZqGo9od1qb/Tq2fJNMUR8bPyU8XkLnO4+Ifb1zvMWWcXR AiSR8xpjJy06diHAmp9DPF/cIW0/1T6EFojl48fN+dSYbM+1lluYFZb4kqoeFajkNllC SOaEfxs2c5S7p86qiW9YQQ7dtmaoFif87STQRnIJZs4J/xjaxX7RJ21aSBvOi3KjtwDq WvYdHWQ7mODVklDOSz67ZUNJmnuJP0E6bLnQBk0/0XfwR6/idiqOScx/hkObe5F8Tkl0 Dvww== X-Gm-Message-State: ALoCoQl2YCF+HlAa1brnLUZ3rrXLkA9GnisO8DvBwXG+YixWLRk6Ih1qxkL2OQPKVACtndbIaLvp X-Received: by 10.182.75.193 with SMTP id e1mr17833246obw.1.1399314879603; Mon, 05 May 2014 11:34:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.105.229 with SMTP id c92ls985247qgf.49.gmail; Mon, 05 May 2014 11:34:39 -0700 (PDT) X-Received: by 10.58.179.115 with SMTP id df19mr1257942vec.41.1399314879420; Mon, 05 May 2014 11:34:39 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id tn6si1766173vcb.75.2014.05.05.11.34.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 May 2014 11:34:39 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id db11so4673610veb.29 for ; Mon, 05 May 2014 11:34:39 -0700 (PDT) X-Received: by 10.221.20.199 with SMTP id qp7mr3928495vcb.24.1399314879293; Mon, 05 May 2014 11:34:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp162450vcb; Mon, 5 May 2014 11:34:38 -0700 (PDT) X-Received: by 10.14.204.73 with SMTP id g49mr15930250eeo.2.1399314878385; Mon, 05 May 2014 11:34:38 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id t3si11011554eeg.31.2014.05.05.11.34.37 for ; Mon, 05 May 2014 11:34:38 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 832F04B970; Mon, 5 May 2014 20:34:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 NLPFnoeEr6NW; Mon, 5 May 2014 20:34:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EEA7A4B97C; Mon, 5 May 2014 20:34:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8D2C54B97C for ; Mon, 5 May 2014 20:34:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 Lin-PDcxiewT for ; Mon, 5 May 2014 20:34:27 +0200 (CEST) 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 mail-gw2-out.broadcom.com (mail-gw2-out.broadcom.com [216.31.210.63]) by theia.denx.de (Postfix) with ESMTP id 9EB3B4B970 for ; Mon, 5 May 2014 20:34:23 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.97,990,1389772800"; d="scan'208";a="27861683" Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw2-out.broadcom.com with ESMTP; 05 May 2014 12:00:29 -0700 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 5 May 2014 11:34:09 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Mon, 5 May 2014 11:34:22 -0700 Received: from mail.broadcom.com (lbrmn-vmlnx03.ric.broadcom.com [10.136.4.105]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id BEF1451E7D; Mon, 5 May 2014 11:34:20 -0700 (PDT) From: Steve Rae To: Date: Mon, 5 May 2014 11:39:29 -0700 Message-ID: <1399315169-25273-1-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 MIME-Version: 1.0 Cc: Tom Rini , Steve Rae , Przemyslaw Marczak Subject: [U-Boot] [PATCH v2] disk: part_efi: add support for the Secondary GPT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srae@broadcom.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Check the Secondary GPT table if the Primary GPT table is invalid. Signed-off-by: Steve Rae --- Changes in v2: - changed wording: "Alternate" to "Secondary" disk/part_efi.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 216a292..f909229 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc) if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, &gpt_pte) != 1) { printf("%s: *** ERROR: Invalid GPT ***\n", __func__); - return; + if (is_gpt_valid(dev_desc, (dev_desc->lba - 1), + gpt_head, &gpt_pte) != 1) { + printf("%s: *** ERROR: Invalid Secondary GPT ***\n", + __func__); + return; + } else { + printf("%s: *** Using Secondary GPT ***\n", + __func__); + } } debug("%s: gpt-entry at %p\n", __func__, gpt_pte); @@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA, gpt_head, &gpt_pte) != 1) { printf("%s: *** ERROR: Invalid GPT ***\n", __func__); - return -1; + if (is_gpt_valid(dev_desc, (dev_desc->lba - 1), + gpt_head, &gpt_pte) != 1) { + printf("%s: *** ERROR: Invalid Secondary GPT ***\n", + __func__); + return -1; + } else { + printf("%s: *** Using Secondary GPT ***\n", + __func__); + } } if (part > le32_to_cpu(gpt_head->num_partition_entries) ||