VirtualBox

Ignore:
Timestamp:
Oct 29, 2015 4:30:44 AM (9 years ago)
Author:
vboxsync
Message:

EFI/Firmware: Merged in the svn:eol-style, svn:mime-type and trailing whitespace cleanup that was done after the initial UDK2014.SP1 import: svn merge /vendor/edk2/UDK2014.SP1 /vendor/edk2/current .

Location:
trunk/src/VBox/Devices/EFI/Firmware
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware

  • trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BasePeCoffLib/Arm/PeCoffLoaderEx.c

    r48674 r58466  
    1919
    2020/**
    21   Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and 
     21  Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and
    2222  return the immediate data encoded in the instruction.
    2323
     
    3434  UINT32  Movt;
    3535  UINT16  Address;
    36  
     36
    3737  // Thumb2 is two 16-bit instructions working together. Not a single 32-bit instruction
    3838  // Example MOVT R0, #0 is 0x0000f2c0 or 0xf2c0 0x0000
    39   Movt = (*Instruction << 16) | (*(Instruction + 1)); 
     39  Movt = (*Instruction << 16) | (*(Instruction + 1));
    4040
    4141  // imm16 = imm4:i:imm3:imm8
     
    6666
    6767  // First 16-bit chunk of instruciton
    68   Patch  = ((Address >> 12) & 0x000f);            // imm4 
     68  Patch  = ((Address >> 12) & 0x000f);            // imm4
    6969  Patch |= (((Address & BIT11) != 0) ? BIT10 : 0); // i
    7070  // Mask out instruction bits and or in address
     
    8282
    8383/**
    84   Pass in a pointer to an ARM MOVW/MOVT instruciton pair and 
     84  Pass in a pointer to an ARM MOVW/MOVT instruciton pair and
    8585  return the immediate data encoded in the two` instruction.
    8686
     
    9797  UINT16  *Word;
    9898  UINT16  *Top;
    99  
     99
    100100  Word = Instructions;  // MOVW
    101101  Top  = Word + 2;      // MOVT
    102  
     102
    103103  return (ThumbMovtImmediateAddress (Top) << 16) + ThumbMovtImmediateAddress (Word);
    104104}
     
    119119  UINT16  *Word;
    120120  UINT16  *Top;
    121  
     121
    122122  Word = Instructions;  // MOVW
    123123  Top  = Word + 2;      // MOVT
     
    126126  ThumbMovtImmediatePatch (Top, (UINT16)(Address >> 16));
    127127}
    128  
    129  
     128
     129
    130130
    131131/**
     
    155155
    156156  switch ((*Reloc) >> 12) {
    157  
     157
    158158  case EFI_IMAGE_REL_BASED_ARM_MOV32T:
    159159    FixupVal = ThumbMovwMovtImmediateAddress (Fixup16) + (UINT32)Adjust;
     
    162162    if (*FixupData != NULL) {
    163163      *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
    164       // Fixup16 is not aligned so we must copy it. Thumb instructions are streams of 16 bytes. 
     164      // Fixup16 is not aligned so we must copy it. Thumb instructions are streams of 16 bytes.
    165165      CopyMem (*FixupData, Fixup16, sizeof (UINT64));
    166166      *FixupData = *FixupData + sizeof(UINT64);
    167167    }
    168168    break;
    169  
     169
    170170  case EFI_IMAGE_REL_BASED_ARM_MOV32A:
    171171     ASSERT (FALSE);
     
    183183  loading and relocating of the image type. It's up to the caller to support
    184184  the entry point.
    185  
     185
    186186  @param  Machine   Machine type from the PE Header.
    187187
     
    195195{
    196196  if ((Machine == IMAGE_FILE_MACHINE_ARMTHUMB_MIXED) || (Machine ==  IMAGE_FILE_MACHINE_EBC)) {
    197     return TRUE; 
     197    return TRUE;
    198198  }
    199199
     
    236236    }
    237237    break;
    238  
     238
    239239  case EFI_IMAGE_REL_BASED_ARM_MOV32A:
    240240    ASSERT (FALSE);
     
    244244    return RETURN_UNSUPPORTED;
    245245  }
    246  
     246
    247247  return RETURN_SUCCESS;
    248248}
  • trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BasePeCoffLib/BasePeCoff.c

    r58459 r58466  
    6262{
    6363  //
    64   // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value 
    65   //       in the PE/COFF Header.  If the MachineType is Itanium(IA64) and the 
     64  // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value
     65  //       in the PE/COFF Header.  If the MachineType is Itanium(IA64) and the
    6666  //       Magic value in the OptionalHeader is  EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
    6767  //       then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
     
    7878
    7979/**
    80   Retrieves the PE or TE Header from a PE/COFF or TE image. 
     80  Retrieves the PE or TE Header from a PE/COFF or TE image.
    8181
    8282  Caution: This function may receive untrusted input.
    83   PE/COFF image is external input, so this routine will 
    84   also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader, 
    85   SizeOfHeader, Section Data Region and Security Data Region be in PE image range. 
     83  PE/COFF image is external input, so this routine will
     84  also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader,
     85  SizeOfHeader, Section Data Region and Security Data Region be in PE image range.
    8686
    8787  @param  ImageContext    The context of the image being loaded.
     
    212212    //
    213213    // TE Image Data Directory Entry size is non-zero, but the Data Directory Virtual Address is zero.
    214     // This case is not a valid TE image. 
     214    // This case is not a valid TE image.
    215215    //
    216216    if ((Hdr.Te->DataDirectory[0].Size != 0 && Hdr.Te->DataDirectory[0].VirtualAddress == 0) ||
     
    236236      //
    237237      // 2. Check the FileHeader.SizeOfOptionalHeader field.
    238       // OptionalHeader.NumberOfRvaAndSizes is not bigger than 16, so 
     238      // OptionalHeader.NumberOfRvaAndSizes is not bigger than 16, so
    239239      // OptionalHeader.NumberOfRvaAndSizes * sizeof (EFI_IMAGE_DATA_DIRECTORY) will not overflow.
    240240      //
     
    350350      //
    351351      // 2. Check the FileHeader.SizeOfOptionalHeader field.
    352       // OptionalHeader.NumberOfRvaAndSizes is not bigger than 16, so 
     352      // OptionalHeader.NumberOfRvaAndSizes is not bigger than 16, so
    353353      // OptionalHeader.NumberOfRvaAndSizes * sizeof (EFI_IMAGE_DATA_DIRECTORY) will not overflow.
    354354      //
     
    514514      // Section data should bigger than the Pe header.
    515515      //
    516       if (SectionHeader.VirtualAddress < ImageContext->SizeOfHeaders || 
     516      if (SectionHeader.VirtualAddress < ImageContext->SizeOfHeaders ||
    517517          SectionHeader.PointerToRawData < ImageContext->SizeOfHeaders) {
    518518        ImageContext->ImageError = IMAGE_ERROR_UNSUPPORTED;
     
    562562  Retrieves information about a PE/COFF image.
    563563
    564   Computes the PeCoffHeaderOffset, IsTeImage, ImageType, ImageAddress, ImageSize, 
    565   DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and 
    566   DebugDirectoryEntryRva fields of the ImageContext structure. 
    567   If ImageContext is NULL, then return RETURN_INVALID_PARAMETER. 
    568   If the PE/COFF image accessed through the ImageRead service in the ImageContext 
    569   structure is not a supported PE/COFF image type, then return RETURN_UNSUPPORTED. 
    570   If any errors occur while computing the fields of ImageContext, 
    571   then the error status is returned in the ImageError field of ImageContext. 
     564  Computes the PeCoffHeaderOffset, IsTeImage, ImageType, ImageAddress, ImageSize,
     565  DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and
     566  DebugDirectoryEntryRva fields of the ImageContext structure.
     567  If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
     568  If the PE/COFF image accessed through the ImageRead service in the ImageContext
     569  structure is not a supported PE/COFF image type, then return RETURN_UNSUPPORTED.
     570  If any errors occur while computing the fields of ImageContext,
     571  then the error status is returned in the ImageError field of ImageContext.
    572572  If the image is a TE image, then SectionAlignment is set to 0.
    573   The ImageRead and Handle fields of ImageContext structure must be valid prior 
     573  The ImageRead and Handle fields of ImageContext structure must be valid prior
    574574  to invoking this service.
    575575
    576576  Caution: This function may receive untrusted input.
    577   PE/COFF image is external input, so this routine will 
    578   also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader, 
    579   SizeOfHeader, Section Data Region and Security Data Region be in PE image range. 
     577  PE/COFF image is external input, so this routine will
     578  also done many checks in PE image to make sure PE image DosHeader, PeOptionHeader,
     579  SizeOfHeader, Section Data Region and Security Data Region be in PE image range.
    580580
    581581  @param  ImageContext              The pointer to the image context structure that describes the PE/COFF
     
    832832      // values for the corresponding sections. So the ImageSize can be determined
    833833      // by the RVA and the VirtualSize of the last section header in the
    834       // Section Table. 
     834      // Section Table.
    835835      //
    836836      if ((++Index) == (UINTN)Hdr.Te->NumberOfSections) {
     
    887887PeCoffLoaderImageAddress (
    888888  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT          *ImageContext,
    889   IN     UINTN                                 Address, 
     889  IN     UINTN                                 Address,
    890890  IN     UINTN                                 TeStrippedOffset
    891891  )
     
    909909  of ImageContext as the relocation base address.  The caller must allocate the relocation
    910910  fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
    911  
    912   The ImageRead, Handle, PeCoffHeaderOffset,  IsTeImage, Machine, ImageType, ImageAddress, 
    913   ImageSize, DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, 
    914   DebugDirectoryEntryRva, EntryPoint, FixupDataSize, CodeView, PdbPointer, and FixupData of 
     911
     912  The ImageRead, Handle, PeCoffHeaderOffset,  IsTeImage, Machine, ImageType, ImageAddress,
     913  ImageSize, DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders,
     914  DebugDirectoryEntryRva, EntryPoint, FixupDataSize, CodeView, PdbPointer, and FixupData of
    915915  the ImageContext structure must be valid prior to invoking this service.
    916    
     916
    917917  If ImageContext is NULL, then ASSERT().
    918918
     
    969969  //
    970970  if (ImageContext->RelocationsStripped) {
    971     // Applies additional environment specific actions to relocate fixups 
     971    // Applies additional environment specific actions to relocate fixups
    972972    // to a PE/COFF image if needed
    973     PeCoffLoaderRelocateImageExtraAction (ImageContext); 
     973    PeCoffLoaderRelocateImageExtraAction (ImageContext);
    974974    return RETURN_SUCCESS;
    975975  }
     
    10511051    // Set base and end to bypass processing below.
    10521052    //
    1053     RelocBase = RelocBaseEnd = NULL;   
     1053    RelocBase = RelocBaseEnd = NULL;
    10541054  }
    10551055  RelocBaseOrg = RelocBase;
     
    10871087        ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
    10881088        return RETURN_LOAD_ERROR;
    1089       } 
     1089      }
    10901090
    10911091      //
     
    11741174    }
    11751175  }
    1176  
    1177   // Applies additional environment specific actions to relocate fixups 
     1176
     1177  // Applies additional environment specific actions to relocate fixups
    11781178  // to a PE/COFF image if needed
    11791179  PeCoffLoaderRelocateImageExtraAction (ImageContext);
    1180  
     1180
    11811181  return RETURN_SUCCESS;
    11821182}
     
    11891189  the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
    11901190  The EntryPoint, FixupDataSize, CodeView, PdbPointer and HiiResourceData fields of ImageContext are computed.
    1191   The ImageRead, Handle, PeCoffHeaderOffset,  IsTeImage,  Machine, ImageType, ImageAddress, ImageSize, 
    1192   DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva 
     1191  The ImageRead, Handle, PeCoffHeaderOffset,  IsTeImage,  Machine, ImageType, ImageAddress, ImageSize,
     1192  DestinationAddress, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
    11931193  fields of the ImageContext structure must be valid prior to invoking this service.
    1194  
     1194
    11951195  If ImageContext is NULL, then ASSERT().
    11961196
     
    15041504
    15051505    if (TempDebugEntryRva != 0) {
    1506       ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva, TeStrippedOffset); 
     1506      ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva, TeStrippedOffset);
    15071507      if (ImageContext->CodeView == NULL) {
    15081508        ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
     
    15861586      if (Base != NULL) {
    15871587        ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;
    1588         Offset = sizeof (EFI_IMAGE_RESOURCE_DIRECTORY) + sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY) * 
     1588        Offset = sizeof (EFI_IMAGE_RESOURCE_DIRECTORY) + sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY) *
    15891589               (ResourceDirectory->NumberOfNamedEntries + ResourceDirectory->NumberOfIdEntries);
    15901590        if (Offset > DirectoryEntry->Size) {
     
    16221622                }
    16231623                ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
    1624                 Offset = ResourceDirectoryEntry->u2.s.OffsetToDirectory + sizeof (EFI_IMAGE_RESOURCE_DIRECTORY) + 
     1624                Offset = ResourceDirectoryEntry->u2.s.OffsetToDirectory + sizeof (EFI_IMAGE_RESOURCE_DIRECTORY) +
    16251625                         sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY) * (ResourceDirectory->NumberOfNamedEntries + ResourceDirectory->NumberOfIdEntries);
    16261626                if (Offset > DirectoryEntry->Size) {
     
    16391639                  }
    16401640                  ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
    1641                   Offset = ResourceDirectoryEntry->u2.s.OffsetToDirectory + sizeof (EFI_IMAGE_RESOURCE_DIRECTORY) + 
     1641                  Offset = ResourceDirectoryEntry->u2.s.OffsetToDirectory + sizeof (EFI_IMAGE_RESOURCE_DIRECTORY) +
    16421642                           sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY) * (ResourceDirectory->NumberOfNamedEntries + ResourceDirectory->NumberOfIdEntries);
    16431643                  if (Offset > DirectoryEntry->Size) {
     
    16681668    }
    16691669  }
    1670  
     1670
    16711671  return Status;
    16721672}
     
    16751675/**
    16761676  Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
    1677   runtime. 
    1678  
    1679   This function reapplies relocation fixups to the PE/COFF image specified by ImageBase 
    1680   and ImageSize so the image will execute correctly when the PE/COFF image is mapped 
    1681   to the address specified by VirtualImageBase.  RelocationData must be identical 
    1682   to the FiuxupData buffer from the PE_COFF_LOADER_IMAGE_CONTEXT structure 
     1677  runtime.
     1678
     1679  This function reapplies relocation fixups to the PE/COFF image specified by ImageBase
     1680  and ImageSize so the image will execute correctly when the PE/COFF image is mapped
     1681  to the address specified by VirtualImageBase.  RelocationData must be identical
     1682  to the FiuxupData buffer from the PE_COFF_LOADER_IMAGE_CONTEXT structure
    16831683  after this PE/COFF image was relocated with PeCoffLoaderRelocateImage().
    16841684
     
    16871687  prior to transferring control to a PE/COFF image that is loaded using this library.
    16881688
    1689   @param  ImageBase          The base address of a PE/COFF image that has been loaded 
     1689  @param  ImageBase          The base address of a PE/COFF image that has been loaded
    16901690                             and relocated into system memory.
    16911691  @param  VirtImageBase      The request virtual address that the PE/COFF image is to
    16921692                             be fixed up for.
    16931693  @param  ImageSize          The size, in bytes, of the PE/COFF image.
    1694   @param  RelocationData     A pointer to the relocation data that was collected when the PE/COFF 
     1694  @param  RelocationData     A pointer to the relocation data that was collected when the PE/COFF
    16951695                             image was relocated using PeCoffLoaderRelocateImage().
    1696  
     1696
    16971697**/
    16981698VOID
     
    17871787    return ;
    17881788  }
    1789  
     1789
    17901790  //
    17911791  // ASSERT for the invalid image when RelocBase and RelocBaseEnd are both NULL.
     
    18891889/**
    18901890  Reads contents of a PE/COFF image from a buffer in system memory.
    1891    
    1892   This is the default implementation of a PE_COFF_LOADER_READ_FILE function 
    1893   that assumes FileHandle pointer to the beginning of a PE/COFF image.   
    1894   This function reads contents of the PE/COFF image that starts at the system memory 
    1895   address specified by FileHandle.  The read operation copies ReadSize bytes from the 
    1896   PE/COFF image starting at byte offset FileOffset into the buffer specified by Buffer. 
     1891
     1892  This is the default implementation of a PE_COFF_LOADER_READ_FILE function
     1893  that assumes FileHandle pointer to the beginning of a PE/COFF image.
     1894  This function reads contents of the PE/COFF image that starts at the system memory
     1895  address specified by FileHandle.  The read operation copies ReadSize bytes from the
     1896  PE/COFF image starting at byte offset FileOffset into the buffer specified by Buffer.
    18971897  The size of the buffer actually read is returned in ReadSize.
    1898  
     1898
    18991899  The caller must make sure the FileOffset and ReadSize within the file scope.
    19001900
     
    19051905  @param  FileHandle        The pointer to base of the input stream
    19061906  @param  FileOffset        Offset into the PE/COFF image to begin the read operation.
    1907   @param  ReadSize          On input, the size in bytes of the requested read operation. 
     1907  @param  ReadSize          On input, the size in bytes of the requested read operation.
    19081908                            On output, the number of bytes actually read.
    19091909  @param  Buffer            Output buffer that contains the data read from the PE/COFF image.
    19101910
    1911   @retval RETURN_SUCCESS    Data is read from FileOffset from the Handle into 
     1911  @retval RETURN_SUCCESS    Data is read from FileOffset from the Handle into
    19121912                            the buffer.
    19131913**/
     
    19311931/**
    19321932  Unloads a loaded PE/COFF image from memory and releases its taken resource.
    1933   Releases any environment specific resources that were allocated when the image 
    1934   specified by ImageContext was loaded using PeCoffLoaderLoadImage(). 
    1935  
     1933  Releases any environment specific resources that were allocated when the image
     1934  specified by ImageContext was loaded using PeCoffLoaderLoadImage().
     1935
    19361936  For NT32 emulator, the PE/COFF image loaded by system needs to release.
    1937   For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded, 
     1937  For real platform, the PE/COFF image loaded by Core doesn't needs to be unloaded,
    19381938  this function can simply return RETURN_SUCCESS.
    1939  
     1939
    19401940  If ImageContext is NULL, then ASSERT().
    1941  
     1941
    19421942  @param  ImageContext              The pointer to the image context structure that describes the PE/COFF
    19431943                                    image to be unloaded.
     
    19521952{
    19531953  //
    1954   // Applies additional environment specific actions to unload a 
     1954  // Applies additional environment specific actions to unload a
    19551955  // PE/COFF image if needed
    19561956  //
  • trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf

    r58459 r58466  
    3030  MODULE_TYPE                    = BASE
    3131  VERSION_STRING                 = 1.0
    32   LIBRARY_CLASS                  = PeCoffLib 
     32  LIBRARY_CLASS                  = PeCoffLib
    3333
    3434
  • trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BasePeCoffLib/Ipf/PeCoffLoaderEx.c

    r48674 r58466  
    219219  does not mean the image can be executed it means the PE/COFF loader supports
    220220  loading and relocating of the image type. It's up to the caller to support
    221   the entry point. 
    222  
     221  the entry point.
     222
    223223  The itanium version PE/COFF loader/relocater supports itanium and EBC image.
    224224
  • trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/BasePeCoffLib/PeCoffLoaderEx.c

    r48674 r58466  
    4444  loading and relocating of the image type. It's up to the caller to support
    4545  the entry point.
    46  
     46
    4747  The IA32/X64 version PE/COFF loader/relocater both support IA32, X64 and EBC images.
    4848
     
    5757  )
    5858{
    59   if ((Machine == IMAGE_FILE_MACHINE_I386) || (Machine == IMAGE_FILE_MACHINE_X64) || 
     59  if ((Machine == IMAGE_FILE_MACHINE_I386) || (Machine == IMAGE_FILE_MACHINE_X64) ||
    6060      (Machine ==  IMAGE_FILE_MACHINE_EBC)) {
    61     return TRUE; 
     61    return TRUE;
    6262  }
    6363
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette