From patchwork Fri Jun 21 07:43:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Harkin X-Patchwork-Id: 18035 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3F2C425A2B for ; Fri, 21 Jun 2013 07:43:55 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id c1sf9957970qcz.1 for ; Fri, 21 Jun 2013 00:43:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=JGvMg45KV1cAqkV/GE0y8miA/3cxUjANzdSOARw1PoM=; b=QAfPTyJ7KVdco7eAFNfhrYJjqARcw0Uu0VXHjNeNhaK7YFV4+e9lvxPTuqkcYtgcCE 4g8ZmP6SwzdWmduaCtQ9BNv1vx2sJSRAiiG0y7YWpNH14Gtipc680meziSkn9rdEdrAz wPHorbmpP8o+1Hc7eBYfjt7f3updaNk1pWGC9pDtsRTTvbLKzX+mds0Remc1JD1IWG4N i0jsvb+RAiv8Il5oTNo9Pf/gI7JBfll0hmh+F7qx/ydVg6z5tQbltCBd0tEXfacwmPgc PNoD7VyJqnzCXPvkrXB/XqfhzAcMbMTQTaJKgwkuAjX9qtyMQysRGN61IYJPtN29EkqT MMfA== X-Received: by 10.236.55.129 with SMTP id k1mr6328907yhc.1.1371800634857; Fri, 21 Jun 2013 00:43:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.47.17 with SMTP id z17ls162035qem.22.gmail; Fri, 21 Jun 2013 00:43:54 -0700 (PDT) X-Received: by 10.58.108.8 with SMTP id hg8mr5084123veb.6.1371800634700; Fri, 21 Jun 2013 00:43:54 -0700 (PDT) Received: from mail-vb0-x232.google.com (mail-vb0-x232.google.com [2607:f8b0:400c:c02::232]) by mx.google.com with ESMTPS id zw14si1204525veb.102.2013.06.21.00.43.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Jun 2013 00:43:54 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::232; Received: by mail-vb0-f50.google.com with SMTP id w16so5524827vbb.23 for ; Fri, 21 Jun 2013 00:43:54 -0700 (PDT) X-Received: by 10.58.251.144 with SMTP id zk16mr4944486vec.37.1371800634592; Fri, 21 Jun 2013 00:43:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.165.8 with SMTP id yu8csp51070veb; Fri, 21 Jun 2013 00:43:54 -0700 (PDT) X-Received: by 10.194.63.46 with SMTP id d14mr8376684wjs.81.1371800633514; Fri, 21 Jun 2013 00:43:53 -0700 (PDT) Received: from mail-we0-x236.google.com (mail-we0-x236.google.com [2a00:1450:400c:c03::236]) by mx.google.com with ESMTPS id w9si1523357wjx.25.2013.06.21.00.43.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Jun 2013 00:43:53 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::236 is neither permitted nor denied by best guess record for domain of ryan.harkin@linaro.org) client-ip=2a00:1450:400c:c03::236; Received: by mail-we0-f182.google.com with SMTP id p60so6231588wes.27 for ; Fri, 21 Jun 2013 00:43:53 -0700 (PDT) X-Received: by 10.194.104.199 with SMTP id gg7mr8338353wjb.56.1371800632983; Fri, 21 Jun 2013 00:43:52 -0700 (PDT) Received: from qpc.lan (82-69-54-187.dsl.in-addr.zen.co.uk. [82.69.54.187]) by mx.google.com with ESMTPSA id fu14sm5390574wic.0.2013.06.21.00.43.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Jun 2013 00:43:52 -0700 (PDT) From: Ryan Harkin To: ryan.harkin@linaro.org, edk2-devel@lists.sourceforge.net, edk2-buildtools-devel@lists.sourceforge.net, patches@linaro.org, boot-architecture@lists.linaro.org Subject: [PATCH 1/1] BaseTools: Apply ARM GenFv patch Date: Fri, 21 Jun 2013 08:43:38 +0100 Message-Id: <1371800618-14193-1-git-send-email-ryan.harkin@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQnDwcIgI+Pbloe4fPzNACfNajI9V9QitybuIWyhBN7XL5hvLhl7gVq02xNcJ+2fyvHYQqmP X-Original-Sender: ryan.harkin@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch is needed to fixup some builds, such as Versatile Express A5, otherwise they hang on boot due to the first instruction being zero. Signed-off-by: Ryan Harkin --- BaseTools/Source/C/GenFv/GenFv.c | 7 +--- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 48 +++++++++++---------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/BaseTools/Source/C/GenFv/GenFv.c b/BaseTools/Source/C/GenFv/GenFv.c index fa86d00..a68c7b8 100644 --- a/BaseTools/Source/C/GenFv/GenFv.c +++ b/BaseTools/Source/C/GenFv/GenFv.c @@ -623,12 +623,7 @@ Returns: ); } else { VerboseMsg ("Create Fv image and its map file"); - // - // Will take rebase action at below situation: - // 1. ForceRebase Flag specified to TRUE; - // 2. ForceRebase Flag not specified, BaseAddress greater than zero. - // - if (((mFvDataInfo.BaseAddress > 0) && (mFvDataInfo.ForceRebase == -1)) || (mFvDataInfo.ForceRebase == 1)) { + if (mFvDataInfo.BaseAddressSet) { VerboseMsg ("FvImage Rebase Address is 0x%llX", (unsigned long long) mFvDataInfo.BaseAddress); } // diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c index c01e504..d143040 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -506,6 +506,7 @@ Returns: EFI_STATUS AddPadFile ( + IN FV_INFO *FvInfo, IN OUT MEMORY_FILE *FvImage, IN UINT32 DataAlignment, IN VOID *FvEnd, @@ -537,6 +538,8 @@ Returns: { EFI_FFS_FILE_HEADER *PadFile; UINTN PadFileSize; + UINTN PadFileOffset; + UINTN ExtHeaderSize; // // Verify input parameters. @@ -559,32 +562,29 @@ Returns: // This is the earliest possible valid offset (current plus pad file header // plus the next file header) // - PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2); + // The padding is added into its own FFS file (which requires a header) added before the aligned file: + // | ... FV data before AlignedFile ... | Pad File FFS Header | Padding | AlignedFile FFS Header (+ ExtHeader) | AlignedData // - // Add whatever it takes to get to the next aligned address + // Calculate the Offset of the Pad File from the beginning of the FV file // - while ((PadFileSize % DataAlignment) != 0) { - PadFileSize++; - } - // - // Subtract the next file header size - // - PadFileSize -= sizeof (EFI_FFS_FILE_HEADER); - - // - // Subtract the starting offset to get size - // - PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage; + PadFileOffset = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage; // - // Append extension header size + // Get the size of the extension header if exists // if (ExtHeader != NULL) { - PadFileSize = PadFileSize + ExtHeader->ExtHeaderSize; + ExtHeaderSize = ExtHeader->ExtHeaderSize; + } else { + ExtHeaderSize = 0; } // + // Calculate the Size of the Padding to ensure the alignment of the data of the Next file + // + PadFileSize = DataAlignment - ((FvInfo->BaseAddress + PadFileOffset + sizeof (EFI_FFS_FILE_HEADER) + ExtHeaderSize) & (DataAlignment - 1)); + + // // Verify that we have enough space for the file header // if (((UINTN) FvImage->CurrentFilePointer + PadFileSize) > (UINTN) FvEnd) { @@ -1115,7 +1115,7 @@ Returns: // // Add pad file if necessary // - Status = AddPadFile (FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL); + Status = AddPadFile (FvInfo, FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL); if (EFI_ERROR (Status)) { Error (NULL, 0, 4002, "Resource", "FV space is full, could not add pad file for data alignment property."); free (FileBuffer); @@ -2304,7 +2304,7 @@ Returns: // // Add FV Extended Header contents to the FV as a PAD file // - AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, FvExtHeader); + AddPadFile (&mFvDataInfo, &FvImageMemoryFile, 4, VtfFileImage, FvExtHeader); // // Fv Extension header change update Fv Header Check sum @@ -2825,19 +2825,11 @@ Returns: PeFileBuffer = NULL; // - // Don't need to relocate image when BaseAddress is zero and no ForceRebase Flag specified. + // Don't need to relocate image when BaseAddress is not set. // - if ((FvInfo->BaseAddress == 0) && (FvInfo->ForceRebase == -1)) { + if (FvInfo->BaseAddressSet == FALSE) { return EFI_SUCCESS; } - - // - // If ForceRebase Flag specified to FALSE, will always not take rebase action. - // - if (FvInfo->ForceRebase == 0) { - return EFI_SUCCESS; - } - XipBase = FvInfo->BaseAddress + XipOffset;