summaryrefslogtreecommitdiff
path: root/EmulatorPkg/Library
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2018-08-29 11:39:06 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2018-08-30 09:26:54 +0800
commit79e4f2a56ac7cee477c2f84ff65f766814cc1836 (patch)
tree1640996f68d818bc01720d718c21a0d9918997a5 /EmulatorPkg/Library
parenta07533fab100db41c04d9044503438ac00039d82 (diff)
downloadedk2-79e4f2a56ac7cee477c2f84ff65f766814cc1836.zip
edk2-79e4f2a56ac7cee477c2f84ff65f766814cc1836.tar.gz
edk2-79e4f2a56ac7cee477c2f84ff65f766814cc1836.tar.bz2
EmulatorPkg: formalize line endings
The patch is the result of running "BaseTools/Scripts/FormatDosFiles.py EmulatorPkg/" No functionality impact. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'EmulatorPkg/Library')
-rw-r--r--EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c2
-rw-r--r--EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf2
-rw-r--r--EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c2
-rw-r--r--EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf96
-rw-r--r--EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c2
-rw-r--r--EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c2
-rw-r--r--EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c12
-rw-r--r--EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf98
-rw-r--r--EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c12
-rw-r--r--EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c12
-rw-r--r--EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf2
-rw-r--r--EmulatorPkg/Library/SecPeiServicesLib/FwVol.c562
-rw-r--r--EmulatorPkg/Library/SecPpiListLib/PpiListLib.c34
-rw-r--r--EmulatorPkg/Library/SmbiosLib/SmbiosLib.c704
-rw-r--r--EmulatorPkg/Library/SmbiosLib/SmbiosLib.inf94
15 files changed, 818 insertions, 818 deletions
diff --git a/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c b/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
index 7478a5e..aa2066e 100644
--- a/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
+++ b/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.c
@@ -180,4 +180,4 @@ DevicePathToTextLibConstructor (
DevicePathFromTextAddFilter (L"EmuThread", DevPathFromTextEmuThread);
DevicePathFromTextAddFilter (L"EmuFs", DevPathFromTextEmuFs);
return EFI_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf b/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
index f572678..c484f8e 100644
--- a/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
+++ b/EmulatorPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
@@ -45,4 +45,4 @@
gEmuGraphicsWindowProtocolGuid
gEfiSimpleFileSystemProtocolGuid
gEmuBlockIoProtocolGuid
- gEmuThreadThunkProtocolGuid \ No newline at end of file
+ gEmuThreadThunkProtocolGuid
diff --git a/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c b/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
index 22f8da7..7dd2d49 100644
--- a/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
+++ b/EmulatorPkg/Library/DxeEmuLib/DxeEmuLib.c
@@ -85,4 +85,4 @@ GetIoThunkInstance (
}
return NULL;
-} \ No newline at end of file
+}
diff --git a/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf b/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf
index f79ebc7..682231b 100644
--- a/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf
+++ b/EmulatorPkg/Library/DxeEmuPeCoffExtraActionLib/DxeEmuPeCoffExtraActionLib.inf
@@ -1,48 +1,48 @@
-## @file
-# PeCoff extra action libary for DXE phase that run Emu emulator.
-#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# Portions copyright (c) 2011, Apple Inc. 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
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = DxeEmuPeCoffExtraActionLib
- FILE_GUID = 68FCD487-D230-6846-95B1-5E1F2EF942C4
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = PeCoffExtraActionLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
-
- CONSTRUCTOR = DxeEmuPeCoffLibExtraActionConstructor
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32
-#
-
-[Sources]
- DxeEmuPeCoffExtraActionLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmulatorPkg/EmulatorPkg.dec
-
-[LibraryClasses]
- DebugLib
- HobLib
- BaseMemoryLib
-
-[Protocols]
- gEmuThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
-
+## @file
+# PeCoff extra action libary for DXE phase that run Emu emulator.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Portions copyright (c) 2011, Apple Inc. 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
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeEmuPeCoffExtraActionLib
+ FILE_GUID = 68FCD487-D230-6846-95B1-5E1F2EF942C4
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PeCoffExtraActionLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
+
+ CONSTRUCTOR = DxeEmuPeCoffLibExtraActionConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32
+#
+
+[Sources]
+ DxeEmuPeCoffExtraActionLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ EmulatorPkg/EmulatorPkg.dec
+
+[LibraryClasses]
+ DebugLib
+ HobLib
+ BaseMemoryLib
+
+[Protocols]
+ gEmuThunkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+
diff --git a/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c b/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
index 00d9f19..6bd44bf 100644
--- a/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
+++ b/EmulatorPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
@@ -69,7 +69,7 @@ SerialPortWrite (
if (gEmuThunk == NULL) {
return NumberOfBytes;
}
-
+
return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
}
diff --git a/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c b/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
index e555026..b995266 100644
--- a/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
+++ b/EmulatorPkg/Library/KeyMapLibNull/KeyMapLibNull.c
@@ -47,4 +47,4 @@ KeyMapBreak (
)
{
return EFI_SUCCESS;
-} \ No newline at end of file
+}
diff --git a/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
index 06f995b..72b68c2 100644
--- a/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
+++ b/EmulatorPkg/Library/PeiCoreServicesTablePointerLib/PeiServicesTablePointer.c
@@ -89,16 +89,16 @@ PeiServicesTablePointerLibConstructor (
}
/**
- Perform CPU specific actions required to migrate the PEI Services Table
+ Perform CPU specific actions required to migrate the PEI Services Table
pointer from temporary RAM to permanent RAM.
- For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+ For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
- For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+ For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
- a dedicated CPU register. This means that there is no memory storage
- associated with storing the PEI Services Table pointer, so no additional
+ a dedicated CPU register. This means that there is no memory storage
+ associated with storing the PEI Services Table pointer, so no additional
migration actions are required for Itanium or ARM CPUs.
**/
@@ -109,7 +109,7 @@ MigratePeiServicesTablePointer (
)
{
//
- // PEI Services Table pointer is cached in the global variable. No additional
+ // PEI Services Table pointer is cached in the global variable. No additional
// migration actions are required.
//
return;
diff --git a/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf b/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf
index 9a757f7..fdaf19a 100644
--- a/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf
+++ b/EmulatorPkg/Library/PeiEmuPeCoffExtraActionLib/PeiEmuPeCoffExtraActionLib.inf
@@ -1,49 +1,49 @@
-## @file
-# PeCoff extra action libary for Pei phase that run Emu emulator.
-#
-# Lib to provide memory journal status code reporting Routines
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
-# Portions copyright (c) 2011, Apple Inc. 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
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = PeiEmuPeCoffExtraActionLib
- FILE_GUID = 79C4E72A-730B-F040-8129-95877B3A97A8
- MODULE_TYPE = PEIM
- VERSION_STRING = 1.0
- LIBRARY_CLASS = PeCoffExtraActionLib|PEI_CORE PEIM
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32
-#
-
-[Sources]
- PeiEmuPeCoffExtraActionLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmulatorPkg/EmulatorPkg.dec
-
-[LibraryClasses]
- BaseLib
- PeiServicesLib
- DebugLib
-
-[Ppis]
- gEmuThunkPpiGuid # PPI ALWAYS_CONSUMED
-
-[Pcd]
- gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage
+## @file
+# PeCoff extra action libary for Pei phase that run Emu emulator.
+#
+# Lib to provide memory journal status code reporting Routines
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Portions copyright (c) 2011, Apple Inc. 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
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiEmuPeCoffExtraActionLib
+ FILE_GUID = 79C4E72A-730B-F040-8129-95877B3A97A8
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PeCoffExtraActionLib|PEI_CORE PEIM
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32
+#
+
+[Sources]
+ PeiEmuPeCoffExtraActionLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ EmulatorPkg/EmulatorPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PeiServicesLib
+ DebugLib
+
+[Ppis]
+ gEmuThunkPpiGuid # PPI ALWAYS_CONSUMED
+
+[Pcd]
+ gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage
diff --git a/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
index 5aaf296..d796888 100644
--- a/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
+++ b/EmulatorPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
@@ -134,16 +134,16 @@ PeiServicesTablePointerLibConstructor (
}
/**
- Perform CPU specific actions required to migrate the PEI Services Table
+ Perform CPU specific actions required to migrate the PEI Services Table
pointer from temporary RAM to permanent RAM.
- For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+ For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
- For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+ For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
- a dedicated CPU register. This means that there is no memory storage
- associated with storing the PEI Services Table pointer, so no additional
+ a dedicated CPU register. This means that there is no memory storage
+ associated with storing the PEI Services Table pointer, so no additional
migration actions are required for Itanium or ARM CPUs.
**/
@@ -154,7 +154,7 @@ MigratePeiServicesTablePointer (
)
{
//
- // PEI Services Table pointer is cached in the global variable. No additional
+ // PEI Services Table pointer is cached in the global variable. No additional
// migration actions are required.
//
return;
diff --git a/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c b/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
index fa04ed3..383460b 100644
--- a/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
+++ b/EmulatorPkg/Library/PeiServicesTablePointerLibMagicPage/PeiServicesTablePointer.c
@@ -72,16 +72,16 @@ GetPeiServicesTablePointer (
}
/**
- Perform CPU specific actions required to migrate the PEI Services Table
+ Perform CPU specific actions required to migrate the PEI Services Table
pointer from temporary RAM to permanent RAM.
- For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
+ For IA32 CPUs, the PEI Services Table pointer is stored in the 4 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
- For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
+ For X64 CPUs, the PEI Services Table pointer is stored in the 8 bytes
immediately preceding the Interrupt Descriptor Table (IDT) in memory.
For Itanium and ARM CPUs, a the PEI Services Table Pointer is stored in
- a dedicated CPU register. This means that there is no memory storage
- associated with storing the PEI Services Table pointer, so no additional
+ a dedicated CPU register. This means that there is no memory storage
+ associated with storing the PEI Services Table pointer, so no additional
migration actions are required for Itanium or ARM CPUs.
**/
@@ -92,7 +92,7 @@ MigratePeiServicesTablePointer (
)
{
//
- // PEI Services Table pointer is cached in SRAM. No additional
+ // PEI Services Table pointer is cached in SRAM. No additional
// migration actions are required.
//
return;
diff --git a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf
index e473b52..0f23178 100644
--- a/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf
+++ b/EmulatorPkg/Library/PeiTimerLib/PeiTimerLib.inf
@@ -44,4 +44,4 @@
PeiServicesLib
[Ppis]
- gEmuThunkPpiGuid \ No newline at end of file
+ gEmuThunkPpiGuid
diff --git a/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c b/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
index 7fa4ddb..a48f2b5 100644
--- a/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
+++ b/EmulatorPkg/Library/SecPeiServicesLib/FwVol.c
@@ -1,281 +1,281 @@
-/*++ @file
- A simple FV stack so the SEC can extract the SEC Core from an
- FV.
-
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiPei.h>
-
-
-#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
- (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
-
-EFI_FFS_FILE_STATE
-GetFileState (
- IN UINT8 ErasePolarity,
- IN EFI_FFS_FILE_HEADER *FfsHeader
- )
-/*++
-
-Routine Description:
- Returns the highest bit set of the State field
-
-Arguments:
- ErasePolarity - Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY
- in the Attributes field.
- FfsHeader - Pointer to FFS File Header.
-
-Returns:
- Returns the highest bit in the State field
-
-**/
-{
- EFI_FFS_FILE_STATE FileState;
- EFI_FFS_FILE_STATE HighestBit;
-
- FileState = FfsHeader->State;
-
- if (ErasePolarity != 0) {
- FileState = (EFI_FFS_FILE_STATE)~FileState;
- }
-
- HighestBit = 0x80;
- while (HighestBit != 0 && (HighestBit & FileState) == 0) {
- HighestBit >>= 1;
- }
-
- return HighestBit;
-}
-
-UINT8
-CalculateHeaderChecksum (
- IN EFI_FFS_FILE_HEADER *FileHeader
- )
-/*++
-
-Routine Description:
- Calculates the checksum of the header of a file.
-
-Arguments:
- FileHeader - Pointer to FFS File Header.
-
-Returns:
- Checksum of the header.
-
-**/
-{
- UINT8 *ptr;
- UINTN Index;
- UINT8 Sum;
-
- Sum = 0;
- ptr = (UINT8 *) FileHeader;
-
- for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
- Sum = (UINT8) (Sum + ptr[Index]);
- Sum = (UINT8) (Sum + ptr[Index + 1]);
- Sum = (UINT8) (Sum + ptr[Index + 2]);
- Sum = (UINT8) (Sum + ptr[Index + 3]);
- }
-
- for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
- Sum = (UINT8) (Sum + ptr[Index]);
- }
- //
- // State field (since this indicates the different state of file).
- //
- Sum = (UINT8) (Sum - FileHeader->State);
- //
- // Checksum field of the file is not part of the header checksum.
- //
- Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
-
- return Sum;
-}
-
-EFI_STATUS
-SecFfsFindNextFile (
- IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE FvHandle,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
- )
-/*++
-
-Routine Description:
- Given the input file pointer, search for the next matching file in the
- FFS volume as defined by SearchType. The search starts from FileHeader inside
- the Firmware Volume defined by FwVolHeader.
-
-Arguments:
- SearchType - Filter to find only files of this type.
- Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
- FwVolHeader - Pointer to the FV header of the volume to search.
- This parameter must point to a valid FFS volume.
- FileHeader - Pointer to the current file from which to begin searching.
- This pointer will be updated upon return to reflect the file
- found.
-
-Returns:
- EFI_NOT_FOUND - No files matching the search criteria were found
- EFI_SUCCESS
-
-**/
-{
- EFI_FFS_FILE_HEADER *FfsFileHeader;
- UINT32 FileLength;
- UINT32 FileOccupiedSize;
- UINT32 FileOffset;
- UINT64 FvLength;
- UINT8 ErasePolarity;
- UINT8 FileState;
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
- EFI_FFS_FILE_HEADER **FileHeader;
-
- //
- // Convert the handle of FV to FV header for memory-mapped firmware volume
- //
- FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvHandle;
- FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
-
- FvLength = FwVolHeader->FvLength;
- if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
- ErasePolarity = 1;
- } else {
- ErasePolarity = 0;
- }
- //
- // If FileHeader is not specified (NULL) start with the first file in the
- // firmware volume. Otherwise, start from the FileHeader.
- //
- if (*FileHeader == NULL) {
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);
- } else {
- //
- // Length is 24 bits wide so mask upper 8 bits
- // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
- //
- FileLength = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);
- }
-
- FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);
-
- while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
- //
- // Get FileState which is the highest bit of the State
- //
- FileState = GetFileState (ErasePolarity, FfsFileHeader);
-
- switch (FileState) {
-
- case EFI_FILE_HEADER_INVALID:
- FileOffset += sizeof (EFI_FFS_FILE_HEADER);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
- break;
-
- case EFI_FILE_DATA_VALID:
- case EFI_FILE_MARKED_FOR_UPDATE:
- if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
- FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
-
- if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
-
- *FileHeader = FfsFileHeader;
-
- return EFI_SUCCESS;
- }
-
- FileOffset += FileOccupiedSize;
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
- } else {
- return EFI_NOT_FOUND;
- }
- break;
-
- case EFI_FILE_DELETED:
- FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
- FileOffset += FileOccupiedSize;
- FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
- break;
-
- default:
- return EFI_NOT_FOUND;
-
- }
- }
-
- return EFI_NOT_FOUND;
-}
-
-EFI_STATUS
-SecFfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_FFS_FILE_HEADER *FfsFileHeader,
- IN OUT VOID **SectionData
- )
-/*++
-
-Routine Description:
- Given the input file pointer, search for the next matching section in the
- FFS volume.
-
-Arguments:
- SearchType - Filter to find only sections of this type.
- FfsFileHeader - Pointer to the current file to search.
- SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
- NULL if section not found
-
-Returns:
- EFI_NOT_FOUND - No files matching the search criteria were found
- EFI_SUCCESS
-
-**/
-{
- UINT32 FileSize;
- EFI_COMMON_SECTION_HEADER *Section;
- UINT32 SectionLength;
- UINT32 ParsedLength;
-
- //
- // Size is 24 bits wide so mask upper 8 bits.
- // Does not include FfsFileHeader header size
- // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
- //
- Section = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
- FileSize = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
- FileSize -= sizeof (EFI_FFS_FILE_HEADER);
-
- *SectionData = NULL;
- ParsedLength = 0;
- while (ParsedLength < FileSize) {
- if (Section->Type == SectionType) {
- *SectionData = (VOID *) (Section + 1);
- return EFI_SUCCESS;
- }
- //
- // Size is 24 bits wide so mask upper 8 bits.
- // SectionLength is adjusted it is 4 byte aligned.
- // Go to the next section
- //
- SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;
- SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
-
- ParsedLength += SectionLength;
- Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
- }
-
- return EFI_NOT_FOUND;
-}
-
+/*++ @file
+ A simple FV stack so the SEC can extract the SEC Core from an
+ FV.
+
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiPei.h>
+
+
+#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
+ (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
+
+EFI_FFS_FILE_STATE
+GetFileState (
+ IN UINT8 ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+ Returns the highest bit set of the State field
+
+Arguments:
+ ErasePolarity - Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY
+ in the Attributes field.
+ FfsHeader - Pointer to FFS File Header.
+
+Returns:
+ Returns the highest bit in the State field
+
+**/
+{
+ EFI_FFS_FILE_STATE FileState;
+ EFI_FFS_FILE_STATE HighestBit;
+
+ FileState = FfsHeader->State;
+
+ if (ErasePolarity != 0) {
+ FileState = (EFI_FFS_FILE_STATE)~FileState;
+ }
+
+ HighestBit = 0x80;
+ while (HighestBit != 0 && (HighestBit & FileState) == 0) {
+ HighestBit >>= 1;
+ }
+
+ return HighestBit;
+}
+
+UINT8
+CalculateHeaderChecksum (
+ IN EFI_FFS_FILE_HEADER *FileHeader
+ )
+/*++
+
+Routine Description:
+ Calculates the checksum of the header of a file.
+
+Arguments:
+ FileHeader - Pointer to FFS File Header.
+
+Returns:
+ Checksum of the header.
+
+**/
+{
+ UINT8 *ptr;
+ UINTN Index;
+ UINT8 Sum;
+
+ Sum = 0;
+ ptr = (UINT8 *) FileHeader;
+
+ for (Index = 0; Index < sizeof (EFI_FFS_FILE_HEADER) - 3; Index += 4) {
+ Sum = (UINT8) (Sum + ptr[Index]);
+ Sum = (UINT8) (Sum + ptr[Index + 1]);
+ Sum = (UINT8) (Sum + ptr[Index + 2]);
+ Sum = (UINT8) (Sum + ptr[Index + 3]);
+ }
+
+ for (; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
+ Sum = (UINT8) (Sum + ptr[Index]);
+ }
+ //
+ // State field (since this indicates the different state of file).
+ //
+ Sum = (UINT8) (Sum - FileHeader->State);
+ //
+ // Checksum field of the file is not part of the header checksum.
+ //
+ Sum = (UINT8) (Sum - FileHeader->IntegrityCheck.Checksum.File);
+
+ return Sum;
+}
+
+EFI_STATUS
+SecFfsFindNextFile (
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching file in the
+ FFS volume as defined by SearchType. The search starts from FileHeader inside
+ the Firmware Volume defined by FwVolHeader.
+
+Arguments:
+ SearchType - Filter to find only files of this type.
+ Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
+ FwVolHeader - Pointer to the FV header of the volume to search.
+ This parameter must point to a valid FFS volume.
+ FileHeader - Pointer to the current file from which to begin searching.
+ This pointer will be updated upon return to reflect the file
+ found.
+
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+**/
+{
+ EFI_FFS_FILE_HEADER *FfsFileHeader;
+ UINT32 FileLength;
+ UINT32 FileOccupiedSize;
+ UINT32 FileOffset;
+ UINT64 FvLength;
+ UINT8 ErasePolarity;
+ UINT8 FileState;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ EFI_FFS_FILE_HEADER **FileHeader;
+
+ //
+ // Convert the handle of FV to FV header for memory-mapped firmware volume
+ //
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FvHandle;
+ FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
+
+ FvLength = FwVolHeader->FvLength;
+ if (FwVolHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
+ ErasePolarity = 1;
+ } else {
+ ErasePolarity = 0;
+ }
+ //
+ // If FileHeader is not specified (NULL) start with the first file in the
+ // firmware volume. Otherwise, start from the FileHeader.
+ //
+ if (*FileHeader == NULL) {
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FwVolHeader + FwVolHeader->HeaderLength);
+ } else {
+ //
+ // Length is 24 bits wide so mask upper 8 bits
+ // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
+ //
+ FileLength = *(UINT32 *) (*FileHeader)->Size & 0x00FFFFFF;
+ FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) *FileHeader + FileOccupiedSize);
+ }
+
+ FileOffset = (UINT32) ((UINT8 *) FfsFileHeader - (UINT8 *) FwVolHeader);
+
+ while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
+ //
+ // Get FileState which is the highest bit of the State
+ //
+ FileState = GetFileState (ErasePolarity, FfsFileHeader);
+
+ switch (FileState) {
+
+ case EFI_FILE_HEADER_INVALID:
+ FileOffset += sizeof (EFI_FFS_FILE_HEADER);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
+ break;
+
+ case EFI_FILE_DATA_VALID:
+ case EFI_FILE_MARKED_FOR_UPDATE:
+ if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
+ FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+ FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
+
+ if ((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) {
+
+ *FileHeader = FfsFileHeader;
+
+ return EFI_SUCCESS;
+ }
+
+ FileOffset += FileOccupiedSize;
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
+ } else {
+ return EFI_NOT_FOUND;
+ }
+ break;
+
+ case EFI_FILE_DELETED:
+ FileLength = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+ FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
+ FileOffset += FileOccupiedSize;
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *) ((UINT8 *) FfsFileHeader + FileOccupiedSize);
+ break;
+
+ default:
+ return EFI_NOT_FOUND;
+
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+SecFfsFindSectionData (
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching section in the
+ FFS volume.
+
+Arguments:
+ SearchType - Filter to find only sections of this type.
+ FfsFileHeader - Pointer to the current file to search.
+ SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
+ NULL if section not found
+
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+**/
+{
+ UINT32 FileSize;
+ EFI_COMMON_SECTION_HEADER *Section;
+ UINT32 SectionLength;
+ UINT32 ParsedLength;
+
+ //
+ // Size is 24 bits wide so mask upper 8 bits.
+ // Does not include FfsFileHeader header size
+ // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
+ //
+ Section = (EFI_COMMON_SECTION_HEADER *) (FfsFileHeader + 1);
+ FileSize = *(UINT32 *) (FfsFileHeader->Size) & 0x00FFFFFF;
+ FileSize -= sizeof (EFI_FFS_FILE_HEADER);
+
+ *SectionData = NULL;
+ ParsedLength = 0;
+ while (ParsedLength < FileSize) {
+ if (Section->Type == SectionType) {
+ *SectionData = (VOID *) (Section + 1);
+ return EFI_SUCCESS;
+ }
+ //
+ // Size is 24 bits wide so mask upper 8 bits.
+ // SectionLength is adjusted it is 4 byte aligned.
+ // Go to the next section
+ //
+ SectionLength = *(UINT32 *) Section->Size & 0x00FFFFFF;
+ SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
+
+ ParsedLength += SectionLength;
+ Section = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) Section + SectionLength);
+ }
+
+ return EFI_NOT_FOUND;
+}
+
diff --git a/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c b/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
index f9c0c3d..b8c5504 100644
--- a/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
+++ b/EmulatorPkg/Library/SecPpiListLib/PpiListLib.c
@@ -1,17 +1,17 @@
-/*++ @file
-
-Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiPei.h>
-
-CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList = NULL;
-
+/*++ @file
+
+Copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+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
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiPei.h>
+
+CONST EFI_PEI_PPI_DESCRIPTOR *gPpiList = NULL;
+
diff --git a/EmulatorPkg/Library/SmbiosLib/SmbiosLib.c b/EmulatorPkg/Library/SmbiosLib/SmbiosLib.c
index 3382d7d..7bdadb3 100644
--- a/EmulatorPkg/Library/SmbiosLib/SmbiosLib.c
+++ b/EmulatorPkg/Library/SmbiosLib/SmbiosLib.c
@@ -1,352 +1,352 @@
-/** @file
- Provides library functions for common SMBIOS operations. Only available to DXE
- and UEFI module types.
-
-
-Copyright (c) 2012, Apple Inc. All rights reserved.
-Portitions Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials are licensed and made available under
-the terms and conditions of the BSD License that accompanies this distribution.
-The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php.
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiDxe.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/SmbiosLib.h>
-
-
-EFI_SMBIOS_PROTOCOL *gSmbios = NULL;
-
-
-/**
- Create an initial SMBIOS Table from an array of SMBIOS_TEMPLATE_ENTRY
- entries. SMBIOS_TEMPLATE_ENTRY.NULL indicates the end of the table.
-
- @param Template Array of SMBIOS_TEMPLATE_ENTRY entries.
-
- @retval EFI_SUCCESS New SMBIOS tables were created.
- @retval EFI_OUT_OF_RESOURCES New SMBIOS tables were not created.
-**/
-EFI_STATUS
-EFIAPI
-SmbiosLibInitializeFromTemplate (
- IN SMBIOS_TEMPLATE_ENTRY *Template
- )
-{
- EFI_STATUS Status;
- UINTN Index;
-
- if (Template == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_SUCCESS;
-
- for (Index = 0; Template[Index].Entry != NULL; Index++) {
- Status = SmbiosLibCreateEntry (Template[Index].Entry, Template[Index].StringArray);
- }
-
- return Status;
-}
-
-
-
-/**
- Create SMBIOS record.
-
- Converts a fixed SMBIOS structure and an array of pointers to strings into
- an SMBIOS record where the strings are cat'ed on the end of the fixed record
- and terminated via a double NULL and add to SMBIOS table.
-
- SMBIOS_TABLE_TYPE32 gSmbiosType12 = {
- { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
- 1 // StringCount
- };
- CHAR8 *gSmbiosType12Strings[] = {
- "Not Found",
- NULL
- };
-
- ...
- CreateSmbiosEntry (
- (EFI_SMBIOS_TABLE_HEADER*)&gSmbiosType12,
- gSmbiosType12Strings
- );
-
- @param SmbiosEntry Fixed SMBIOS structure
- @param StringArray Array of strings to convert to an SMBIOS string pack.
- NULL is OK.
-
-**/
-EFI_STATUS
-EFIAPI
-SmbiosLibCreateEntry (
- IN SMBIOS_STRUCTURE *SmbiosEntry,
- IN CHAR8 **StringArray
- )
-{
- EFI_STATUS Status;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- EFI_SMBIOS_TABLE_HEADER *Record;
- UINTN Index;
- UINTN StringSize;
- UINTN Size;
- CHAR8 *Str;
-
- // Calculate the size of the fixed record and optional string pack
- Size = SmbiosEntry->Length;
- if (StringArray == NULL) {
- Size += 2; // Min string section is double null
- } else if (StringArray[0] == NULL) {
- Size += 2; // Min string section is double null
- } else {
- for (Index = 0; StringArray[Index] != NULL; Index++) {
- StringSize = AsciiStrSize (StringArray[Index]);
- Size += StringSize;
- }
- // Don't forget the terminating double null
- Size += 1;
- }
-
- // Copy over Template
- Record = (EFI_SMBIOS_TABLE_HEADER *)AllocateZeroPool (Size);
- if (Record == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- CopyMem (Record, SmbiosEntry, SmbiosEntry->Length);
-
- if (StringArray != NULL) {
- // Append string pack
- Str = ((CHAR8 *)Record) + Record->Length;
- for (Index = 0; StringArray[Index] != NULL; Index++) {
- StringSize = AsciiStrSize (StringArray[Index]);
- CopyMem (Str, StringArray[Index], StringSize);
- Str += StringSize;
- }
- *Str = 0;
- }
-
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = gSmbios->Add (
- gSmbios,
- gImageHandle,
- &SmbiosHandle,
- Record
- );
-
- FreePool (Record);
- return Status;
-}
-
-
-
-/**
- Update the string associated with an existing SMBIOS record.
-
- This function allows the update of specific SMBIOS strings. The number of valid strings for any
- SMBIOS record is defined by how many strings were present when Add() was called.
-
- @param[in] SmbiosHandle SMBIOS Handle of structure that will have its string updated.
- @param[in] StringNumber The non-zero string number of the string to update.
- @param[in] String Update the StringNumber string with String.
-
- @retval EFI_SUCCESS SmbiosHandle had its StringNumber String updated.
- @retval EFI_INVALID_PARAMETER SmbiosHandle does not exist. Or String is invalid.
- @retval EFI_UNSUPPORTED String was not added because it is longer than the SMBIOS Table supports.
- @retval EFI_NOT_FOUND The StringNumber.is not valid for this SMBIOS record.
-**/
-EFI_STATUS
-EFIAPI
-SmbiosLibUpdateString (
- IN EFI_SMBIOS_HANDLE SmbiosHandle,
- IN SMBIOS_TABLE_STRING StringNumber,
- IN CHAR8 *String
- )
-{
- UINTN StringIndex;
-
- if (String == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (*String == '\0') {
- // A string with no data is not legal in SMBIOS
- return EFI_INVALID_PARAMETER;
- }
-
- StringIndex = StringNumber;
- return gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, String);
-}
-
-
-/**
- Update the string associated with an existing SMBIOS record.
-
- This function allows the update of specific SMBIOS strings. The number of valid strings for any
- SMBIOS record is defined by how many strings were present when Add() was called.
-
- @param[in] SmbiosHandle SMBIOS Handle of structure that will have its string updated.
- @param[in] StringNumber The non-zero string number of the string to update.
- @param[in] String Update the StringNumber string with String.
-
- @retval EFI_SUCCESS SmbiosHandle had its StringNumber String updated.
- @retval EFI_INVALID_PARAMETER SmbiosHandle does not exist. Or String is invalid.
- @retval EFI_UNSUPPORTED String was not added because it is longer than the SMBIOS Table supports.
- @retval EFI_NOT_FOUND The StringNumber.is not valid for this SMBIOS record.
-**/
-EFI_STATUS
-EFIAPI
-SmbiosLibUpdateUnicodeString (
- IN EFI_SMBIOS_HANDLE SmbiosHandle,
- IN SMBIOS_TABLE_STRING StringNumber,
- IN CHAR16 *String
- )
-{
- EFI_STATUS Status;
- UINTN StringIndex;
- CHAR8 *Ascii;
-
- if (String == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (*String == '\0') {
- // A string with no data is not legal in SMBIOS
- return EFI_INVALID_PARAMETER;
- }
-
- Ascii = AllocateZeroPool (StrSize (String));
- if (Ascii == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- UnicodeStrToAsciiStr (String, Ascii);
-
- StringIndex = StringNumber;
- Status = gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, Ascii);
-
- FreePool (Ascii);
- return Status;
-}
-
-
-/**
- Allow caller to read a specific SMBIOS string
-
- @param[in] Header SMBIOS record that contains the string.
- @param[in[ StringNumber Instance of SMBIOS string 1 - N.
-
- @retval NULL Instance of Type SMBIOS string was not found.
- @retval Other Pointer to matching SMBIOS string.
-**/
-CHAR8 *
-EFIAPI
-SmbiosLibReadString (
- IN SMBIOS_STRUCTURE *Header,
- IN EFI_SMBIOS_STRING StringNumber
- )
-{
- CHAR8 *Data;
- UINTN Match;
-
- Data = (CHAR8 *)Header + Header->Length;
- for (Match = 1;!(*Data == 0 && *(Data+1) == 0); ) {
- if (StringNumber == Match) {
- return Data;
- }
- Data++;
- if (*(Data - 1) == '\0') {
- Match++;
- }
- }
-
- return NULL;
-}
-
-
-/**
- Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
-
- @param[in] Type Type of the next SMBIOS record to return.
- @param[in[ Instance Instance of SMBIOS record 0 - N-1.
- @param[out] SmbiosHandle Returns SMBIOS handle for the matching record.
-
- @retval NULL Instance of Type SMBIOS record was not found.
- @retval Other Pointer to matching SMBIOS record.
-**/
-SMBIOS_STRUCTURE *
-EFIAPI
-SmbiosLibGetRecord (
- IN EFI_SMBIOS_TYPE Type,
- IN UINTN Instance,
- OUT EFI_SMBIOS_HANDLE *SmbiosHandle
- )
-{
- EFI_STATUS Status;
- EFI_SMBIOS_TABLE_HEADER *Record;
- UINTN Match;
-
- Match = 0;
- *SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- do {
- Status = gSmbios->GetNext (gSmbios, SmbiosHandle, &Type, &Record, NULL);
- if (!EFI_ERROR (Status)) {
- if (Match == Instance) {
- return (SMBIOS_STRUCTURE *)Record;
- }
- Match++;
- }
- } while (!EFI_ERROR (Status));
-
- return NULL;
-}
-
-
-/**
- Remove an SMBIOS record.
-
- This function removes an SMBIOS record using the handle specified by SmbiosHandle.
-
- @param[in] SmbiosHandle The handle of the SMBIOS record to remove.
-
- @retval EFI_SUCCESS SMBIOS record was removed.
- @retval EFI_INVALID_PARAMETER SmbiosHandle does not specify a valid SMBIOS record.
-**/
-EFI_STATUS
-EFIAPI
-SmbiosLibRemove (
- OUT EFI_SMBIOS_HANDLE SmbiosHandle
- )
-{
- return gSmbios->Remove (gSmbios, SmbiosHandle);
-}
-
-
-
-/**
-
- @param ImageHandle ImageHandle of the loaded driver.
- @param SystemTable Pointer to the EFI System Table.
-
- @retval EFI_SUCCESS Register successfully.
- @retval EFI_OUT_OF_RESOURCES No enough memory to register this handler.
-**/
-EFI_STATUS
-EFIAPI
-SmbiosLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&gSmbios);
-}
-
+/** @file
+ Provides library functions for common SMBIOS operations. Only available to DXE
+ and UEFI module types.
+
+
+Copyright (c) 2012, Apple Inc. All rights reserved.
+Portitions Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiDxe.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/SmbiosLib.h>
+
+
+EFI_SMBIOS_PROTOCOL *gSmbios = NULL;
+
+
+/**
+ Create an initial SMBIOS Table from an array of SMBIOS_TEMPLATE_ENTRY
+ entries. SMBIOS_TEMPLATE_ENTRY.NULL indicates the end of the table.
+
+ @param Template Array of SMBIOS_TEMPLATE_ENTRY entries.
+
+ @retval EFI_SUCCESS New SMBIOS tables were created.
+ @retval EFI_OUT_OF_RESOURCES New SMBIOS tables were not created.
+**/
+EFI_STATUS
+EFIAPI
+SmbiosLibInitializeFromTemplate (
+ IN SMBIOS_TEMPLATE_ENTRY *Template
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+
+ if (Template == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_SUCCESS;
+
+ for (Index = 0; Template[Index].Entry != NULL; Index++) {
+ Status = SmbiosLibCreateEntry (Template[Index].Entry, Template[Index].StringArray);
+ }
+
+ return Status;
+}
+
+
+
+/**
+ Create SMBIOS record.
+
+ Converts a fixed SMBIOS structure and an array of pointers to strings into
+ an SMBIOS record where the strings are cat'ed on the end of the fixed record
+ and terminated via a double NULL and add to SMBIOS table.
+
+ SMBIOS_TABLE_TYPE32 gSmbiosType12 = {
+ { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
+ 1 // StringCount
+ };
+ CHAR8 *gSmbiosType12Strings[] = {
+ "Not Found",
+ NULL
+ };
+
+ ...
+ CreateSmbiosEntry (
+ (EFI_SMBIOS_TABLE_HEADER*)&gSmbiosType12,
+ gSmbiosType12Strings
+ );
+
+ @param SmbiosEntry Fixed SMBIOS structure
+ @param StringArray Array of strings to convert to an SMBIOS string pack.
+ NULL is OK.
+
+**/
+EFI_STATUS
+EFIAPI
+SmbiosLibCreateEntry (
+ IN SMBIOS_STRUCTURE *SmbiosEntry,
+ IN CHAR8 **StringArray
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ EFI_SMBIOS_TABLE_HEADER *Record;
+ UINTN Index;
+ UINTN StringSize;
+ UINTN Size;
+ CHAR8 *Str;
+
+ // Calculate the size of the fixed record and optional string pack
+ Size = SmbiosEntry->Length;
+ if (StringArray == NULL) {
+ Size += 2; // Min string section is double null
+ } else if (StringArray[0] == NULL) {
+ Size += 2; // Min string section is double null
+ } else {
+ for (Index = 0; StringArray[Index] != NULL; Index++) {
+ StringSize = AsciiStrSize (StringArray[Index]);
+ Size += StringSize;
+ }
+ // Don't forget the terminating double null
+ Size += 1;
+ }
+
+ // Copy over Template
+ Record = (EFI_SMBIOS_TABLE_HEADER *)AllocateZeroPool (Size);
+ if (Record == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyMem (Record, SmbiosEntry, SmbiosEntry->Length);
+
+ if (StringArray != NULL) {
+ // Append string pack
+ Str = ((CHAR8 *)Record) + Record->Length;
+ for (Index = 0; StringArray[Index] != NULL; Index++) {
+ StringSize = AsciiStrSize (StringArray[Index]);
+ CopyMem (Str, StringArray[Index], StringSize);
+ Str += StringSize;
+ }
+ *Str = 0;
+ }
+
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ Status = gSmbios->Add (
+ gSmbios,
+ gImageHandle,
+ &SmbiosHandle,
+ Record
+ );
+
+ FreePool (Record);
+ return Status;
+}
+
+
+
+/**
+ Update the string associated with an existing SMBIOS record.
+
+ This function allows the update of specific SMBIOS strings. The number of valid strings for any
+ SMBIOS record is defined by how many strings were present when Add() was called.
+
+ @param[in] SmbiosHandle SMBIOS Handle of structure that will have its string updated.
+ @param[in] StringNumber The non-zero string number of the string to update.
+ @param[in] String Update the StringNumber string with String.
+
+ @retval EFI_SUCCESS SmbiosHandle had its StringNumber String updated.
+ @retval EFI_INVALID_PARAMETER SmbiosHandle does not exist. Or String is invalid.
+ @retval EFI_UNSUPPORTED String was not added because it is longer than the SMBIOS Table supports.
+ @retval EFI_NOT_FOUND The StringNumber.is not valid for this SMBIOS record.
+**/
+EFI_STATUS
+EFIAPI
+SmbiosLibUpdateString (
+ IN EFI_SMBIOS_HANDLE SmbiosHandle,
+ IN SMBIOS_TABLE_STRING StringNumber,
+ IN CHAR8 *String
+ )
+{
+ UINTN StringIndex;
+
+ if (String == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (*String == '\0') {
+ // A string with no data is not legal in SMBIOS
+ return EFI_INVALID_PARAMETER;
+ }
+
+ StringIndex = StringNumber;
+ return gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, String);
+}
+
+
+/**
+ Update the string associated with an existing SMBIOS record.
+
+ This function allows the update of specific SMBIOS strings. The number of valid strings for any
+ SMBIOS record is defined by how many strings were present when Add() was called.
+
+ @param[in] SmbiosHandle SMBIOS Handle of structure that will have its string updated.
+ @param[in] StringNumber The non-zero string number of the string to update.
+ @param[in] String Update the StringNumber string with String.
+
+ @retval EFI_SUCCESS SmbiosHandle had its StringNumber String updated.
+ @retval EFI_INVALID_PARAMETER SmbiosHandle does not exist. Or String is invalid.
+ @retval EFI_UNSUPPORTED String was not added because it is longer than the SMBIOS Table supports.
+ @retval EFI_NOT_FOUND The StringNumber.is not valid for this SMBIOS record.
+**/
+EFI_STATUS
+EFIAPI
+SmbiosLibUpdateUnicodeString (
+ IN EFI_SMBIOS_HANDLE SmbiosHandle,
+ IN SMBIOS_TABLE_STRING StringNumber,
+ IN CHAR16 *String
+ )
+{
+ EFI_STATUS Status;
+ UINTN StringIndex;
+ CHAR8 *Ascii;
+
+ if (String == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (*String == '\0') {
+ // A string with no data is not legal in SMBIOS
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Ascii = AllocateZeroPool (StrSize (String));
+ if (Ascii == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ UnicodeStrToAsciiStr (String, Ascii);
+
+ StringIndex = StringNumber;
+ Status = gSmbios->UpdateString (gSmbios, &SmbiosHandle, &StringIndex, Ascii);
+
+ FreePool (Ascii);
+ return Status;
+}
+
+
+/**
+ Allow caller to read a specific SMBIOS string
+
+ @param[in] Header SMBIOS record that contains the string.
+ @param[in[ StringNumber Instance of SMBIOS string 1 - N.
+
+ @retval NULL Instance of Type SMBIOS string was not found.
+ @retval Other Pointer to matching SMBIOS string.
+**/
+CHAR8 *
+EFIAPI
+SmbiosLibReadString (
+ IN SMBIOS_STRUCTURE *Header,
+ IN EFI_SMBIOS_STRING StringNumber
+ )
+{
+ CHAR8 *Data;
+ UINTN Match;
+
+ Data = (CHAR8 *)Header + Header->Length;
+ for (Match = 1;!(*Data == 0 && *(Data+1) == 0); ) {
+ if (StringNumber == Match) {
+ return Data;
+ }
+ Data++;
+ if (*(Data - 1) == '\0') {
+ Match++;
+ }
+ }
+
+ return NULL;
+}
+
+
+/**
+ Allow the caller to discover a specific SMBIOS entry, and patch it if necissary.
+
+ @param[in] Type Type of the next SMBIOS record to return.
+ @param[in[ Instance Instance of SMBIOS record 0 - N-1.
+ @param[out] SmbiosHandle Returns SMBIOS handle for the matching record.
+
+ @retval NULL Instance of Type SMBIOS record was not found.
+ @retval Other Pointer to matching SMBIOS record.
+**/
+SMBIOS_STRUCTURE *
+EFIAPI
+SmbiosLibGetRecord (
+ IN EFI_SMBIOS_TYPE Type,
+ IN UINTN Instance,
+ OUT EFI_SMBIOS_HANDLE *SmbiosHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMBIOS_TABLE_HEADER *Record;
+ UINTN Match;
+
+ Match = 0;
+ *SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ do {
+ Status = gSmbios->GetNext (gSmbios, SmbiosHandle, &Type, &Record, NULL);
+ if (!EFI_ERROR (Status)) {
+ if (Match == Instance) {
+ return (SMBIOS_STRUCTURE *)Record;
+ }
+ Match++;
+ }
+ } while (!EFI_ERROR (Status));
+
+ return NULL;
+}
+
+
+/**
+ Remove an SMBIOS record.
+
+ This function removes an SMBIOS record using the handle specified by SmbiosHandle.
+
+ @param[in] SmbiosHandle The handle of the SMBIOS record to remove.
+
+ @retval EFI_SUCCESS SMBIOS record was removed.
+ @retval EFI_INVALID_PARAMETER SmbiosHandle does not specify a valid SMBIOS record.
+**/
+EFI_STATUS
+EFIAPI
+SmbiosLibRemove (
+ OUT EFI_SMBIOS_HANDLE SmbiosHandle
+ )
+{
+ return gSmbios->Remove (gSmbios, SmbiosHandle);
+}
+
+
+
+/**
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS Register successfully.
+ @retval EFI_OUT_OF_RESOURCES No enough memory to register this handler.
+**/
+EFI_STATUS
+EFIAPI
+SmbiosLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&gSmbios);
+}
+
diff --git a/EmulatorPkg/Library/SmbiosLib/SmbiosLib.inf b/EmulatorPkg/Library/SmbiosLib/SmbiosLib.inf
index 0593c47..8f4d4c6 100644
--- a/EmulatorPkg/Library/SmbiosLib/SmbiosLib.inf
+++ b/EmulatorPkg/Library/SmbiosLib/SmbiosLib.inf
@@ -1,47 +1,47 @@
-## @file
-# SMBIOS Library
-#
-# Copyright (c) 2012, Apple Inc. All rights reserved.
-# Portions copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
-#
-# 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
-# http://opensource.org/licenses/bsd-license.php
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SmbiosLib
- FILE_GUID = 881863A2-09FD-3E44-8D62-7AE038D03747
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = SmbiosLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVER
-
- CONSTRUCTOR = SmbiosLibConstructor
-
-
-[Sources]
- SmbiosLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmulatorPkg/EmulatorPkg.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- DebugLib
- MemoryAllocationLib
- UefiBootServicesTableLib
- UefiLib
-
-[Protocols]
- gEfiSmbiosProtocolGuid
-
-[Depex]
- gEfiSmbiosProtocolGuid \ No newline at end of file
+## @file
+# SMBIOS Library
+#
+# Copyright (c) 2012, Apple Inc. All rights reserved.
+# Portions copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+#
+# 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
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SmbiosLib
+ FILE_GUID = 881863A2-09FD-3E44-8D62-7AE038D03747
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SmbiosLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVER
+
+ CONSTRUCTOR = SmbiosLibConstructor
+
+
+[Sources]
+ SmbiosLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ EmulatorPkg/EmulatorPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
+ UefiLib
+
+[Protocols]
+ gEfiSmbiosProtocolGuid
+
+[Depex]
+ gEfiSmbiosProtocolGuid