diff options
author | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-02-13 11:12:05 +0000 |
---|---|---|
committer | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-02-13 11:12:05 +0000 |
commit | 0d49d8f681f213415c8e756b488692c83bcab62f (patch) | |
tree | 0aa3376d488bde051a267a7a96d7939740766096 /MdePkg | |
parent | f1ad92e867a0b4f3299a88de4c1c7e0844f699f3 (diff) | |
download | edk2-0d49d8f681f213415c8e756b488692c83bcab62f.zip edk2-0d49d8f681f213415c8e756b488692c83bcab62f.tar.gz edk2-0d49d8f681f213415c8e756b488692c83bcab62f.tar.bz2 |
1. Add two interfaces in PeCoffGetEntryPointLib.h
2. Fix the description of EfiTestChildHandle & EfiTestManagedDevice
3. Clean up BasePciLbPciCf8 & BasePciLibPciExpress to remove the dependency on DebugLib
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2387 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r-- | MdePkg/Include/Library/PeCoffGetEntryPointLib.h | 36 | ||||
-rw-r--r-- | MdePkg/Include/Library/PrintLib.h | 11 | ||||
-rw-r--r-- | MdePkg/Include/Library/UefiLib.h | 41 | ||||
-rw-r--r-- | MdePkg/Library/BasePciLibCf8/BasePciLibCf8.msa | 5 | ||||
-rw-r--r-- | MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.msa | 7 | ||||
-rw-r--r-- | MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c | 124 | ||||
-rw-r--r-- | MdePkg/Library/BasePrintLib/PrintLib.c | 21 | ||||
-rw-r--r-- | MdePkg/Library/UefiLib/UefiLib.c | 41 |
8 files changed, 224 insertions, 62 deletions
diff --git a/MdePkg/Include/Library/PeCoffGetEntryPointLib.h b/MdePkg/Include/Library/PeCoffGetEntryPointLib.h index 973a368..c1bc488 100644 --- a/MdePkg/Include/Library/PeCoffGetEntryPointLib.h +++ b/MdePkg/Include/Library/PeCoffGetEntryPointLib.h @@ -42,18 +42,46 @@ PeCoffLoaderGetEntryPoint ( );
/**
- Returns the machine type of PE/COFF image.
+ Returns the machine type of a PE/COFF image.
- @param Image Pointer to a PE/COFF header
+ Returns the machine type from the PE/COFF image specified by Pe32Data.
+ If Pe32Data is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
- @return Machine type or zero if not a valid iamge
+ @return Machine type or zero if not a valid iamge.
**/
UINT16
EFIAPI
PeCoffLoaderGetMachineType (
- IN VOID *Image
+ IN VOID *Pe32Data
);
+/**
+ Returns a pointer to the PDB file name for a PE/COFF image that has been
+ loaded into system memory with the PE/COFF Loader Library functions.
+
+ Returns the PDB file name for the PE/COFF image specified by Pe32Data. If
+ the PE/COFF image specified by Pe32Data is not a valid, then NULL is
+ returned. If the PE/COFF image specified by Pe32Data does not contain a
+ debug directory entry, then NULL is returned. If the debug directory entry
+ in the PE/COFF image specified by Pe32Data does not contain a PDB file name,
+ then NULL is returned.
+ If Pe32Data is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
+
+ @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
+ if it cannot be retrieved.
+
+**/
+VOID *
+EFIAPI
+PeCoffLoaderGetPdbPointer (
+ IN VOID *Pe32Data
+ );
#endif
diff --git a/MdePkg/Include/Library/PrintLib.h b/MdePkg/Include/Library/PrintLib.h index 412dc53..eb8a33b 100644 --- a/MdePkg/Include/Library/PrintLib.h +++ b/MdePkg/Include/Library/PrintLib.h @@ -35,7 +35,7 @@ /// /// Flags bitmask values use in UnicodeValueToString() and -/// AcsiiValueToString() +/// AsciiValueToString() /// #define LEFT_JUSTIFY 0x01 #define COMMA_TYPE 0x08 @@ -56,7 +56,9 @@ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT(). @@ -96,7 +98,9 @@ UnicodeVSPrint ( If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT(). @@ -136,6 +140,7 @@ UnicodeSPrint ( If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). If BufferSize > 1 and FormatString is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then @@ -177,6 +182,7 @@ UnicodeVSPrintAsciiFormat ( If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). If BufferSize > 1 and FormatString is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then @@ -229,6 +235,7 @@ UnicodeSPrintAsciiFormat ( add up to Width characters. If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If unsupported bits are set in Flags, then ASSERT(). If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() @@ -348,6 +355,7 @@ AsciiSPrint ( If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT(). @@ -389,6 +397,7 @@ AsciiVSPrintUnicodeFormat ( If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT(). diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h index a302c26..ef10f13 100644 --- a/MdePkg/Include/Library/UefiLib.h +++ b/MdePkg/Include/Library/UefiLib.h @@ -254,24 +254,26 @@ EfiReleaseLock ( );
/** - Tests whether a controller is managed by a specific driver. + Tests whether a controller handle is being managed by a specific driver. - This function tests whether a specific driver manages ControllerHandle by
- opening on DriverBindingHandle a protocol specified by ProtocolGuid with
- attribute EFI_OPEN_PROTOCOL_BY_DRIVER. This library function is used to
- implement the Component Name Protocol for EFI Drivers.
+ This function tests whether the driver specified by DriverBindingHandle is
+ currently managing the controller specified by ControllerHandle. This test
+ is performed by evaluating if the the protocol specified by ProtocolGuid is
+ present on ControllerHandle and is was opened by DriverBindingHandle with an
+ attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
If ProtocolGuid is NULL, then ASSERT().
@param ControllerHandle A handle for a controller to test. @param DriverBindingHandle Specifies the driver binding handle for the driver. - @param ProtocolGuid Supplies GUID for the protocol opened by the - driver on the controller. + @param ProtocolGuid Specifies the protocol that the driver specified + by DriverBindingHandle opens in its Start() + function. - @retval EFI_SUCCESS ControllerHandle is managed by the specific - driver. - @retval EFI_UNSUPPORTED ControllerHandle is not managed by the specific - driver. + @retval EFI_SUCCESS ControllerHandle is managed by the driver + specifed by DriverBindingHandle. + @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver + specifed by DriverBindingHandle. **/
EFI_STATUS
@@ -283,19 +285,18 @@ EfiTestManagedDevice ( );
/** - Tests whether a child handle is a children device of the controller. + Tests whether a child handle is a child device of the controller. - This function tests whether ChildHandle is one of the children of - ControllerHandle which are consuming a protocol specified by ProtocolGuid - with the attribute bit EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER set. This - library function is used to implement the Component Name Protocol for EFI - Drivers. - If ProtocolGuid is NULL, then ASSERT(). + This function tests whether ChildHandle is one of the children of
+ ControllerHandle. This test is performed by checking to see if the protocol
+ specified by ProtocolGuid is present on ControllerHandle and opened by
+ ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+ If ProtocolGuid is NULL, then ASSERT().
@param ControllerHandle A handle for a (parent) controller to test. @param ChildHandle A child handle to test. - @param ConsumsedGuid Supplies GUID for the protocol consumed by - children from controller. + @param ConsumsedGuid Supplies the protocol that the child controller + opens on its parent controller. @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. @retval EFI_UNSUPPORTED ChildHandle is not a child of the diff --git a/MdePkg/Library/BasePciLibCf8/BasePciLibCf8.msa b/MdePkg/Library/BasePciLibCf8/BasePciLibCf8.msa index e2b6c5b..85edbba 100644 --- a/MdePkg/Library/BasePciLibCf8/BasePciLibCf8.msa +++ b/MdePkg/Library/BasePciLibCf8/BasePciLibCf8.msa @@ -8,7 +8,7 @@ <Abstract>Component description file for PCI CF8 Base PCI Library</Abstract>
<Description>PCI Library that uses I/O ports 0xCF8 and 0xCFC to perform
PCI Configuration cycles. Layers on top of an I/O Library instance.</Description>
- <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -29,9 +29,6 @@ <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PciCf8Lib</Keyword>
</LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>DebugLib</Keyword>
- </LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>PciLib.c</Filename>
diff --git a/MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.msa b/MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.msa index 0472d32..b39faa8 100644 --- a/MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.msa +++ b/MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.msa @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?>
-<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsaHeader>
<ModuleName>BasePciLibPciExpress</ModuleName>
<ModuleType>BASE</ModuleType>
@@ -8,7 +8,7 @@ <Abstract>Component description file for PCI Express Base PCI Library.</Abstract>
<Description>PCI Library that uses the 256 MB PCI Express MMIO window to perform PCI
Configuration cycles. Layers on top of an I/O Library instance.</Description>
- <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>
+ <Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -29,9 +29,6 @@ <LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>PciExpressLib</Keyword>
</LibraryClass>
- <LibraryClass Usage="ALWAYS_CONSUMED">
- <Keyword>DebugLib</Keyword>
- </LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>PciLib.c</Filename>
diff --git a/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c index 001e043..d0a6746 100644 --- a/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c +++ b/MdePkg/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c @@ -1,7 +1,7 @@ /** @file
Tiano PE/COFF loader.
- Copyright (c) 2006, Intel Corporation<BR>
+ Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -69,17 +69,21 @@ PeCoffLoaderGetEntryPoint ( /**
- Returns the machine type of PE/COFF image.
+ Returns the machine type of a PE/COFF image.
- @param Image Pointer to a PE/COFF header
+ Returns the machine type from the PE/COFF image specified by Pe32Data.
+ If Pe32Data is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
- @return Machine type or zero if not a valid iamge
+ @return Machine type or zero if not a valid iamge.
**/
UINT16
EFIAPI
PeCoffLoaderGetMachineType (
- IN VOID *Pe32Data
+ IN VOID *Pe32Data
)
{
EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
@@ -99,4 +103,114 @@ PeCoffLoaderGetMachineType ( return 0x0000;
}
+/**
+ Returns a pointer to the PDB file name for a PE/COFF image that has been
+ loaded into system memory with the PE/COFF Loader Library functions.
+
+ Returns the PDB file name for the PE/COFF image specified by Pe32Data. If
+ the PE/COFF image specified by Pe32Data is not a valid, then NULL is
+ returned. If the PE/COFF image specified by Pe32Data does not contain a
+ debug directory entry, then NULL is returned. If the debug directory entry
+ in the PE/COFF image specified by Pe32Data does not contain a PDB file name,
+ then NULL is returned.
+ If Pe32Data is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
+
+ @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
+ if it cannot be retrieved.
+
+**/
+VOID *
+EFIAPI
+PeCoffLoaderGetPdbPointer (
+ IN VOID *Pe32Data
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHeader;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ UINTN DirCount;
+ VOID *CodeViewEntryPointer;
+ INTN TEImageAdjust;
+ UINT32 NumberOfRvaAndSizes;
+
+ ASSERT (Pe32Data != NULL);
+
+ TEImageAdjust = 0;
+ DirectoryEntry = NULL;
+ DebugEntry = NULL;
+ NumberOfRvaAndSizes = 0;
+
+ DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
+ }
+
+ if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
+ if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
+ DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
+ TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +
+ Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
+ TEImageAdjust);
+ }
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset get Debug Directory Entry
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
+ } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ //
+ // Use PE32+ offset get Debug Directory Entry
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
+ }
+
+ if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
+ DirectoryEntry = NULL;
+ DebugEntry = NULL;
+ }
+ } else {
+ return NULL;
+ }
+
+ if (DebugEntry == NULL || DirectoryEntry == NULL) {
+ return NULL;
+ }
+
+ for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) {
+ if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ if (DebugEntry->SizeOfData > 0) {
+ CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);
+ switch (* (UINT32 *) CodeViewEntryPointer) {
+ case CODEVIEW_SIGNATURE_NB10:
+ return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
+ case CODEVIEW_SIGNATURE_RSDS:
+ return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c index 5263dda..0272558 100644 --- a/MdePkg/Library/BasePrintLib/PrintLib.c +++ b/MdePkg/Library/BasePrintLib/PrintLib.c @@ -16,8 +16,9 @@ #include "PrintLibInternal.h" -#define WARNING_STATUS_NUMBER 4 -#define ERROR_STATUS_NUMBER 24 +#define WARNING_STATUS_NUMBER 4 +#define ERROR_STATUS_NUMBER 24 +#define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0) GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *StatusString [] = { "Success", // RETURN_SUCCESS = 0 @@ -613,7 +614,9 @@ BasePrintLibSPrint ( If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT(). @@ -640,6 +643,8 @@ UnicodeVSPrint ( IN VA_LIST Marker ) { + ASSERT_UNICODE_BUFFER(StartOfBuffer); + ASSERT_UNICODE_BUFFER(FormatString); return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker); } @@ -656,7 +661,9 @@ UnicodeVSPrint ( If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). If BufferSize > 1 and FormatString is NULL, then ASSERT(). + If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT(). @@ -702,6 +709,7 @@ UnicodeSPrint ( If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). If BufferSize > 1 and FormatString is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then @@ -729,6 +737,7 @@ UnicodeVSPrintAsciiFormat ( IN VA_LIST Marker ) { + ASSERT_UNICODE_BUFFER(StartOfBuffer); return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker); } @@ -746,6 +755,7 @@ UnicodeVSPrintAsciiFormat ( If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned. If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT(). + If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT(). If BufferSize > 1 and FormatString is NULL, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then @@ -804,6 +814,7 @@ UnicodeSPrintAsciiFormat ( add up to Width characters. If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). If Buffer is NULL, then ASSERT(). + If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If unsupported bits are set in Flags, then ASSERT(). If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT(). If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT() @@ -827,6 +838,7 @@ UnicodeValueToString ( IN UINTN Width ) { + ASSERT_UNICODE_BUFFER(Buffer); return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2); } @@ -935,6 +947,7 @@ AsciiSPrint ( If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT(). @@ -961,6 +974,7 @@ AsciiVSPrintUnicodeFormat ( IN VA_LIST Marker ) { + ASSERT_UNICODE_BUFFER (FormatString); return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker); } @@ -979,6 +993,7 @@ AsciiVSPrintUnicodeFormat ( If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT(). If BufferSize > 0 and FormatString is NULL, then ASSERT(). + If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT(). If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then ASSERT(). @@ -1060,6 +1075,6 @@ AsciiValueToString ( IN UINTN Width ) { - return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 1); + return BasePrintLibConvertValueToString (Buffer, Flags, Value, Width, 1); } diff --git a/MdePkg/Library/UefiLib/UefiLib.c b/MdePkg/Library/UefiLib/UefiLib.c index 765235c..f03b881 100644 --- a/MdePkg/Library/UefiLib/UefiLib.c +++ b/MdePkg/Library/UefiLib/UefiLib.c @@ -383,24 +383,26 @@ EfiReleaseLock ( }
/** - Tests whether a controller is managed by a specific driver. + Tests whether a controller handle is being managed by a specific driver. - This function tests whether a specific driver manages ControllerHandle by
- opening on DriverBindingHandle a protocol specified by ProtocolGuid with
- attribute EFI_OPEN_PROTOCOL_BY_DRIVER. This library function is used to
- implement the Component Name Protocol for EFI Drivers.
+ This function tests whether the driver specified by DriverBindingHandle is
+ currently managing the controller specified by ControllerHandle. This test
+ is performed by evaluating if the the protocol specified by ProtocolGuid is
+ present on ControllerHandle and is was opened by DriverBindingHandle with an
+ attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
If ProtocolGuid is NULL, then ASSERT().
@param ControllerHandle A handle for a controller to test. @param DriverBindingHandle Specifies the driver binding handle for the driver. - @param ProtocolGuid Supplies GUID for the protocol opened by the - driver on the controller. + @param ProtocolGuid Specifies the protocol that the driver specified + by DriverBindingHandle opens in its Start() + function. - @retval EFI_SUCCESS ControllerHandle is managed by the specific - driver. - @retval EFI_UNSUPPORTED ControllerHandle is not managed by the specific - driver. + @retval EFI_SUCCESS ControllerHandle is managed by the driver + specifed by DriverBindingHandle. + @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver + specifed by DriverBindingHandle. **/
EFI_STATUS
@@ -442,19 +444,18 @@ EfiTestManagedDevice ( }
/** - Tests whether a child handle is a children device of the controller. + Tests whether a child handle is a child device of the controller. - This function tests whether ChildHandle is one of the children of - ControllerHandle which are consuming a protocol specified by ProtocolGuid - with the attribute bit EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER set. This - library function is used to implement the Component Name Protocol for EFI - Drivers. - If ProtocolGuid is NULL, then ASSERT(). + This function tests whether ChildHandle is one of the children of
+ ControllerHandle. This test is performed by checking to see if the protocol
+ specified by ProtocolGuid is present on ControllerHandle and opened by
+ ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+ If ProtocolGuid is NULL, then ASSERT().
@param ControllerHandle A handle for a (parent) controller to test. @param ChildHandle A child handle to test. - @param ConsumsedGuid Supplies GUID for the protocol consumed by - children from controller. + @param ConsumsedGuid Supplies the protocol that the child controller + opens on its parent controller. @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle. @retval EFI_UNSUPPORTED ChildHandle is not a child of the |