summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:53:56 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commite7108d0e9655b1795c94ac372b0449f28dd907df (patch)
treeb153716589979b9e42e9b85281ff8b7511ba272f /EmbeddedPkg
parent731c67e1d77b7741a91762d17659fc9fbcb9e305 (diff)
downloadedk2-e7108d0e9655b1795c94ac372b0449f28dd907df.tar.gz
edk2-e7108d0e9655b1795c94ac372b0449f28dd907df.tar.bz2
edk2-e7108d0e9655b1795c94ac372b0449f28dd907df.zip
EmbeddedPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the EmbeddedPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Andrew Fish <afish@apple.com>
Diffstat (limited to 'EmbeddedPkg')
-rw-r--r--EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c41
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c42
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c138
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h16
-rw-r--r--EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c98
-rw-r--r--EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c228
-rw-r--r--EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c161
-rw-r--r--EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c223
-rw-r--r--EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.h8
-rw-r--r--EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c141
-rw-r--r--EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.h10
-rw-r--r--EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.c222
-rw-r--r--EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.c59
-rw-r--r--EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.c19
-rw-r--r--EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.h14
-rw-r--r--EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c251
-rw-r--r--EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.h98
-rw-r--r--EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c8
-rw-r--r--EmbeddedPkg/GdbStub/Arm/Processor.c250
-rw-r--r--EmbeddedPkg/GdbStub/GdbStub.c495
-rw-r--r--EmbeddedPkg/GdbStub/GdbStubInternal.h282
-rw-r--r--EmbeddedPkg/GdbStub/Ia32/Processor.c443
-rw-r--r--EmbeddedPkg/GdbStub/SerialIo.c159
-rw-r--r--EmbeddedPkg/GdbStub/X64/Processor.c438
-rw-r--r--EmbeddedPkg/Include/Guid/ConsolePrefFormSet.h2
-rw-r--r--EmbeddedPkg/Include/Guid/DtPlatformDefaultDtbFile.h2
-rw-r--r--EmbeddedPkg/Include/Guid/DtPlatformFormSet.h2
-rw-r--r--EmbeddedPkg/Include/Guid/ExtractSection.h10
-rw-r--r--EmbeddedPkg/Include/Guid/Fdt.h4
-rw-r--r--EmbeddedPkg/Include/Guid/FdtHob.h4
-rw-r--r--EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h3
-rw-r--r--EmbeddedPkg/Include/Guid/PlatformHasDeviceTree.h3
-rw-r--r--EmbeddedPkg/Include/Library/AcpiLib.h24
-rw-r--r--EmbeddedPkg/Include/Library/AndroidBootImgLib.h41
-rw-r--r--EmbeddedPkg/Include/Library/DebugAgentTimerLib.h6
-rw-r--r--EmbeddedPkg/Include/Library/DmaLib.h40
-rw-r--r--EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h4
-rw-r--r--EmbeddedPkg/Include/Library/EfiFileLib.h122
-rw-r--r--EmbeddedPkg/Include/Library/EfiResetSystemLib.h12
-rw-r--r--EmbeddedPkg/Include/Library/FdtLoadLib.h4
-rw-r--r--EmbeddedPkg/Include/Library/GdbSerialLib.h17
-rw-r--r--EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h123
-rw-r--r--EmbeddedPkg/Include/Library/NorFlashInfoLib.h49
-rw-r--r--EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h2
-rw-r--r--EmbeddedPkg/Include/Library/PrePiLib.h156
-rw-r--r--EmbeddedPkg/Include/Library/RealTimeClockLib.h29
-rw-r--r--EmbeddedPkg/Include/Library/TimeBaseLib.h16
-rw-r--r--EmbeddedPkg/Include/Ppi/EmbeddedGpio.h39
-rw-r--r--EmbeddedPkg/Include/Protocol/AndroidBootImg.h12
-rw-r--r--EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h28
-rw-r--r--EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h20
-rw-r--r--EmbeddedPkg/Include/Protocol/EmbeddedDevice.h23
-rw-r--r--EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h36
-rw-r--r--EmbeddedPkg/Include/Protocol/EmbeddedGpio.h95
-rw-r--r--EmbeddedPkg/Include/Protocol/FdtClient.h40
-rw-r--r--EmbeddedPkg/Include/Protocol/HardwareInterrupt.h36
-rw-r--r--EmbeddedPkg/Include/Protocol/HardwareInterrupt2.h22
-rw-r--r--EmbeddedPkg/Include/Protocol/MmcHost.h175
-rw-r--r--EmbeddedPkg/Include/Protocol/PeCoffLoader.h41
-rw-r--r--EmbeddedPkg/Include/Protocol/PlatformBootManager.h8
-rw-r--r--EmbeddedPkg/Include/Protocol/PlatformVirtualKeyboard.h28
-rw-r--r--EmbeddedPkg/Include/Protocol/UsbDevice.h26
-rw-r--r--EmbeddedPkg/Include/fdt.h71
-rw-r--r--EmbeddedPkg/Include/libfdt.h1881
-rw-r--r--EmbeddedPkg/Include/libfdt_env.h132
-rw-r--r--EmbeddedPkg/Library/AcpiLib/AcpiLib.c95
-rw-r--r--EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c385
-rw-r--r--EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c57
-rw-r--r--EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c4
-rw-r--r--EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c25
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt.c397
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_addresses.c66
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c45
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_overlay.c2041
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_ro.c1272
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_rw.c891
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_strerror.c68
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_strtoul.c35
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_sw.c445
-rw-r--r--EmbeddedPkg/Library/FdtLib/fdt_wip.c168
-rw-r--r--EmbeddedPkg/Library/FdtLib/libfdt_internal.h84
-rw-r--r--EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c32
-rw-r--r--EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c97
-rw-r--r--EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c290
-rw-r--r--EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.c229
-rw-r--r--EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c83
-rw-r--r--EmbeddedPkg/Library/PrePiHobLib/Hob.c202
-rw-r--r--EmbeddedPkg/Library/PrePiLib/FwVol.c375
-rw-r--r--EmbeddedPkg/Library/PrePiLib/PrePi.h5
-rw-r--r--EmbeddedPkg/Library/PrePiLib/PrePiLib.c85
-rw-r--r--EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c40
-rw-r--r--EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c30
-rw-r--r--EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c54
-rw-r--r--EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c97
-rw-r--r--EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c62
-rw-r--r--EmbeddedPkg/MetronomeDxe/Metronome.c14
-rw-r--r--EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c76
-rw-r--r--EmbeddedPkg/ResetRuntimeDxe/reset.c12
-rw-r--r--EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c498
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/ComponentName.c22
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Diagnostics.c114
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Mmc.c279
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/Mmc.h625
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c183
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcDebug.c107
-rwxr-xr-xEmbeddedPkg/Universal/MmcDxe/MmcIdentification.c347
106 files changed, 9431 insertions, 7837 deletions
diff --git a/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c b/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c
index 940738e0dd..5e3c9c587a 100644
--- a/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c
+++ b/EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.c
@@ -20,28 +20,31 @@
/* Validate the node is media hard drive type */
EFI_STATUS
ValidateAndroidMediaDevicePath (
- IN EFI_DEVICE_PATH *DevicePath
+ IN EFI_DEVICE_PATH *DevicePath
)
{
- EFI_DEVICE_PATH_PROTOCOL *Node, *NextNode;
+ EFI_DEVICE_PATH_PROTOCOL *Node, *NextNode;
NextNode = DevicePath;
while (NextNode != NULL) {
Node = NextNode;
- if (Node->Type == MEDIA_DEVICE_PATH &&
- Node->SubType == MEDIA_HARDDRIVE_DP) {
+ if ((Node->Type == MEDIA_DEVICE_PATH) &&
+ (Node->SubType == MEDIA_HARDDRIVE_DP))
+ {
return EFI_SUCCESS;
}
+
NextNode = NextDevicePathNode (Node);
}
+
return EFI_INVALID_PARAMETER;
}
EFI_STATUS
EFIAPI
AndroidBootAppEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -56,9 +59,12 @@ AndroidBootAppEntryPoint (
BootPathStr = (CHAR16 *)PcdGetPtr (PcdAndroidBootDevicePath);
ASSERT (BootPathStr != NULL);
- Status = gBS->LocateProtocol (&gEfiDevicePathFromTextProtocolGuid, NULL,
- (VOID **)&EfiDevicePathFromTextProtocol);
- ASSERT_EFI_ERROR(Status);
+ Status = gBS->LocateProtocol (
+ &gEfiDevicePathFromTextProtocolGuid,
+ NULL,
+ (VOID **)&EfiDevicePathFromTextProtocol
+ );
+ ASSERT_EFI_ERROR (Status);
DevicePath = (EFI_DEVICE_PATH *)EfiDevicePathFromTextProtocol->ConvertTextToDevicePath (BootPathStr);
ASSERT (DevicePath != NULL);
@@ -67,8 +73,11 @@ AndroidBootAppEntryPoint (
return Status;
}
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid,
- &DevicePath, &Handle);
+ Status = gBS->LocateDevicePath (
+ &gEfiDevicePathProtocolGuid,
+ &DevicePath,
+ &Handle
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -76,7 +85,7 @@ AndroidBootAppEntryPoint (
Status = gBS->OpenProtocol (
Handle,
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
+ (VOID **)&BlockIo,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -86,12 +95,13 @@ AndroidBootAppEntryPoint (
return Status;
}
- MediaId = BlockIo->Media->MediaId;
+ MediaId = BlockIo->Media->MediaId;
BlockSize = BlockIo->Media->BlockSize;
- Buffer = AllocatePages (EFI_SIZE_TO_PAGES (sizeof(ANDROID_BOOTIMG_HEADER)));
+ Buffer = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (ANDROID_BOOTIMG_HEADER)));
if (Buffer == NULL) {
return EFI_BUFFER_TOO_SMALL;
}
+
/* Load header of boot.img */
Status = BlockIo->ReadBlocks (
BlockIo,
@@ -105,8 +115,9 @@ AndroidBootAppEntryPoint (
DEBUG ((DEBUG_ERROR, "Failed to get AndroidBootImg Size: %r\n", Status));
return Status;
}
+
BootImgSize = ALIGN_VALUE (BootImgSize, BlockSize);
- FreePages (Buffer, EFI_SIZE_TO_PAGES (sizeof(ANDROID_BOOTIMG_HEADER)));
+ FreePages (Buffer, EFI_SIZE_TO_PAGES (sizeof (ANDROID_BOOTIMG_HEADER)));
/* Both PartitionStart and PartitionSize are counted as block size. */
Buffer = AllocatePages (EFI_SIZE_TO_PAGES (BootImgSize));
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
index 54b7bee162..8b224ed59f 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidBootImg.c
@@ -16,24 +16,28 @@
// present, but RamdiskSize will be set to 0.
EFI_STATUS
ParseAndroidBootImg (
- IN VOID *BootImg,
+ IN VOID *BootImg,
OUT VOID **Kernel,
- OUT UINTN *KernelSize,
+ OUT UINTN *KernelSize,
OUT VOID **Ramdisk,
- OUT UINTN *RamdiskSize,
- OUT CHAR8 *KernelArgs
+ OUT UINTN *RamdiskSize,
+ OUT CHAR8 *KernelArgs
)
{
- ANDROID_BOOTIMG_HEADER *Header;
- UINT8 *BootImgBytePtr;
+ ANDROID_BOOTIMG_HEADER *Header;
+ UINT8 *BootImgBytePtr;
// Cast to UINT8 so we can do pointer arithmetic
- BootImgBytePtr = (UINT8 *) BootImg;
+ BootImgBytePtr = (UINT8 *)BootImg;
- Header = (ANDROID_BOOTIMG_HEADER *) BootImg;
+ Header = (ANDROID_BOOTIMG_HEADER *)BootImg;
- if (AsciiStrnCmp ((CONST CHAR8 *)Header->BootMagic, ANDROID_BOOT_MAGIC,
- ANDROID_BOOT_MAGIC_LENGTH) != 0) {
+ if (AsciiStrnCmp (
+ (CONST CHAR8 *)Header->BootMagic,
+ ANDROID_BOOT_MAGIC,
+ ANDROID_BOOT_MAGIC_LENGTH
+ ) != 0)
+ {
return EFI_INVALID_PARAMETER;
}
@@ -43,18 +47,22 @@ ParseAndroidBootImg (
ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize));
- *KernelSize = Header->KernelSize;
- *Kernel = BootImgBytePtr + Header->PageSize;
+ *KernelSize = Header->KernelSize;
+ *Kernel = BootImgBytePtr + Header->PageSize;
*RamdiskSize = Header->RamdiskSize;
if (Header->RamdiskSize != 0) {
- *Ramdisk = (VOID *) (BootImgBytePtr
- + Header->PageSize
- + ALIGN_VALUE (Header->KernelSize, Header->PageSize));
+ *Ramdisk = (VOID *)(BootImgBytePtr
+ + Header->PageSize
+ + ALIGN_VALUE (Header->KernelSize, Header->PageSize));
}
- AsciiStrnCpyS (KernelArgs, ANDROID_BOOTIMG_KERNEL_ARGS_SIZE, Header->KernelArgs,
- ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
+ AsciiStrnCpyS (
+ KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE,
+ Header->KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
+ );
return EFI_SUCCESS;
}
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
index 32d5c755d7..b16478bea0 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.c
@@ -25,10 +25,10 @@
* FASTBOOT_PLATFORM_PROTOCOL to implement the Android Fastboot protocol.
*/
-STATIC FASTBOOT_TRANSPORT_PROTOCOL *mTransport;
-STATIC FASTBOOT_PLATFORM_PROTOCOL *mPlatform;
+STATIC FASTBOOT_TRANSPORT_PROTOCOL *mTransport;
+STATIC FASTBOOT_PLATFORM_PROTOCOL *mPlatform;
-STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
+STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
typedef enum {
ExpectCmdState,
@@ -36,45 +36,45 @@ typedef enum {
FastbootStateMax
} ANDROID_FASTBOOT_STATE;
-STATIC ANDROID_FASTBOOT_STATE mState = ExpectCmdState;
+STATIC ANDROID_FASTBOOT_STATE mState = ExpectCmdState;
// When in ExpectDataState, the number of bytes of data to expect:
-STATIC UINT64 mNumDataBytes;
+STATIC UINT64 mNumDataBytes;
// .. and the number of bytes so far received this data phase
-STATIC UINT64 mBytesReceivedSoFar;
+STATIC UINT64 mBytesReceivedSoFar;
// .. and the buffer to save data into
-STATIC UINT8 *mDataBuffer = NULL;
+STATIC UINT8 *mDataBuffer = NULL;
// Event notify functions, from which gBS->Exit shouldn't be called, can signal
// this event when the application should exit
-STATIC EFI_EVENT mFinishedEvent;
+STATIC EFI_EVENT mFinishedEvent;
-STATIC EFI_EVENT mFatalSendErrorEvent;
+STATIC EFI_EVENT mFatalSendErrorEvent;
// This macro uses sizeof - only use it on arrays (i.e. string literals)
-#define SEND_LITERAL(Str) mTransport->Send ( \
+#define SEND_LITERAL(Str) mTransport->Send ( \
sizeof (Str) - 1, \
Str, \
&mFatalSendErrorEvent \
)
-#define MATCH_CMD_LITERAL(Cmd, Buf) !AsciiStrnCmp (Cmd, Buf, sizeof (Cmd) - 1)
+#define MATCH_CMD_LITERAL(Cmd, Buf) !AsciiStrnCmp (Cmd, Buf, sizeof (Cmd) - 1)
-#define IS_LOWERCASE_ASCII(Char) (Char >= 'a' && Char <= 'z')
+#define IS_LOWERCASE_ASCII(Char) (Char >= 'a' && Char <= 'z')
-#define FASTBOOT_STRING_MAX_LENGTH 256
-#define FASTBOOT_COMMAND_MAX_LENGTH 64
+#define FASTBOOT_STRING_MAX_LENGTH 256
+#define FASTBOOT_COMMAND_MAX_LENGTH 64
STATIC
VOID
HandleGetVar (
- IN CHAR8 *CmdArg
+ IN CHAR8 *CmdArg
)
{
- CHAR8 Response[FASTBOOT_COMMAND_MAX_LENGTH + 1] = "OKAY";
- EFI_STATUS Status;
+ CHAR8 Response[FASTBOOT_COMMAND_MAX_LENGTH + 1] = "OKAY";
+ EFI_STATUS Status;
// Respond to getvar:version with 0.4 (version of Fastboot protocol)
- if (!AsciiStrnCmp ("version", CmdArg, sizeof ("version") - 1 )) {
+ if (!AsciiStrnCmp ("version", CmdArg, sizeof ("version") - 1)) {
SEND_LITERAL ("OKAY" ANDROID_FASTBOOT_VERSION);
} else {
// All other variables are assumed to be platform specific
@@ -90,11 +90,11 @@ HandleGetVar (
STATIC
VOID
HandleDownload (
- IN CHAR8 *NumBytesString
+ IN CHAR8 *NumBytesString
)
{
- CHAR8 Response[13];
- CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
+ CHAR8 Response[13];
+ CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
// Argument is 8-character ASCII string hex representation of number of bytes
// that will be sent in the data phase.
@@ -122,11 +122,15 @@ HandleDownload (
SEND_LITERAL ("FAILNot enough memory");
} else {
ZeroMem (Response, sizeof Response);
- AsciiSPrint (Response, sizeof Response, "DATA%x",
- (UINT32)mNumDataBytes);
+ AsciiSPrint (
+ Response,
+ sizeof Response,
+ "DATA%x",
+ (UINT32)mNumDataBytes
+ );
mTransport->Send (sizeof Response - 1, Response, &mFatalSendErrorEvent);
- mState = ExpectDataState;
+ mState = ExpectDataState;
mBytesReceivedSoFar = 0;
}
}
@@ -134,7 +138,7 @@ HandleDownload (
STATIC
VOID
HandleFlash (
- IN CHAR8 *PartitionName
+ IN CHAR8 *PartitionName
)
{
EFI_STATUS Status;
@@ -171,7 +175,7 @@ HandleFlash (
STATIC
VOID
HandleErase (
- IN CHAR8 *PartitionName
+ IN CHAR8 *PartitionName
)
{
EFI_STATUS Status;
@@ -196,7 +200,7 @@ HandleBoot (
VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
mTextOut->OutputString (mTextOut, L"Booting downloaded image\r\n");
@@ -214,13 +218,14 @@ HandleBoot (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed to boot downloaded image: %r\n", Status));
}
+
// We shouldn't get here
}
STATIC
VOID
HandleOemCommand (
- IN CHAR8 *Command
+ IN CHAR8 *Command
)
{
EFI_STATUS Status;
@@ -241,10 +246,10 @@ STATIC
VOID
AcceptCmd (
IN UINTN Size,
- IN CONST CHAR8 *Data
+ IN CONST CHAR8 *Data
)
{
- CHAR8 Command[FASTBOOT_COMMAND_MAX_LENGTH + 1];
+ CHAR8 Command[FASTBOOT_COMMAND_MAX_LENGTH + 1];
// Max command size is 64 bytes
if (Size > FASTBOOT_COMMAND_MAX_LENGTH) {
@@ -282,6 +287,7 @@ AcceptCmd (
// Here we just reboot normally.
SEND_LITERAL ("INFOreboot-bootloader not supported, rebooting normally.");
}
+
SEND_LITERAL ("OKAY");
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
@@ -313,12 +319,12 @@ STATIC
VOID
AcceptData (
IN UINTN Size,
- IN VOID *Data
+ IN VOID *Data
)
{
- UINT32 RemainingBytes = mNumDataBytes - mBytesReceivedSoFar;
- CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
- STATIC UINTN Count = 0;
+ UINT32 RemainingBytes = mNumDataBytes - mBytesReceivedSoFar;
+ CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
+ STATIC UINTN Count = 0;
// Protocol doesn't say anything about sending extra data so just ignore it.
if (Size > RemainingBytes) {
@@ -331,7 +337,7 @@ AcceptData (
// Show download progress. Don't do it for every packet as outputting text
// might be time consuming - do it on the last packet and on every 32nd packet
- if ((Count++ % 32) == 0 || Size == RemainingBytes) {
+ if (((Count++ % 32) == 0) || (Size == RemainingBytes)) {
// (Note no newline in format string - it will overwrite the line each time)
UnicodeSPrint (
OutputString,
@@ -363,23 +369,24 @@ STATIC
VOID
DataReady (
IN EFI_EVENT Event,
- IN VOID *Context
+ IN VOID *Context
)
{
UINTN Size;
- VOID *Data;
+ VOID *Data;
EFI_STATUS Status;
do {
Status = mTransport->Receive (&Size, &Data);
if (!EFI_ERROR (Status)) {
if (mState == ExpectCmdState) {
- AcceptCmd (Size, (CHAR8 *) Data);
+ AcceptCmd (Size, (CHAR8 *)Data);
} else if (mState == ExpectDataState) {
AcceptData (Size, Data);
} else {
ASSERT (FALSE);
}
+
FreePool (Data);
}
} while (!EFI_ERROR (Status));
@@ -401,7 +408,7 @@ STATIC
VOID
FatalErrorNotify (
IN EFI_EVENT Event,
- IN VOID *Context
+ IN VOID *Context
)
{
mTextOut->OutputString (mTextOut, L"Fatal error sending command response. Exiting.\r\n");
@@ -411,30 +418,30 @@ FatalErrorNotify (
EFI_STATUS
EFIAPI
FastbootAppEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_EVENT ReceiveEvent;
EFI_EVENT WaitEventArray[2];
UINTN EventIndex;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
EFI_INPUT_KEY Key;
mDataBuffer = NULL;
Status = gBS->LocateProtocol (
- &gAndroidFastbootTransportProtocolGuid,
- NULL,
- (VOID **) &mTransport
- );
+ &gAndroidFastbootTransportProtocolGuid,
+ NULL,
+ (VOID **)&mTransport
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Fastboot Transport Protocol: %r\n", Status));
return Status;
}
- Status = gBS->LocateProtocol (&gAndroidFastbootPlatformProtocolGuid, NULL, (VOID **) &mPlatform);
+ Status = gBS->LocateProtocol (&gAndroidFastbootPlatformProtocolGuid, NULL, (VOID **)&mPlatform);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Fastboot Platform Protocol: %r\n", Status));
return Status;
@@ -446,15 +453,17 @@ FastbootAppEntryPoint (
return Status;
}
- Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **) &mTextOut);
+ Status = gBS->LocateProtocol (&gEfiSimpleTextOutProtocolGuid, NULL, (VOID **)&mTextOut);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "Fastboot: Couldn't open Text Output Protocol: %r\n", Status
+ DEBUG ((
+ DEBUG_ERROR,
+ "Fastboot: Couldn't open Text Output Protocol: %r\n",
+ Status
));
return Status;
}
- Status = gBS->LocateProtocol (&gEfiSimpleTextInProtocolGuid, NULL, (VOID **) &TextIn);
+ Status = gBS->LocateProtocol (&gEfiSimpleTextInProtocolGuid, NULL, (VOID **)&TextIn);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't open Text Input Protocol: %r\n", Status));
return Status;
@@ -483,27 +492,28 @@ FastbootAppEntryPoint (
// Create event to pass to FASTBOOT_TRANSPORT_PROTOCOL.Send, signalling a
// fatal error
Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- FatalErrorNotify,
- NULL,
- &mFatalSendErrorEvent
- );
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ FatalErrorNotify,
+ NULL,
+ &mFatalSendErrorEvent
+ );
ASSERT_EFI_ERROR (Status);
-
// Start listening for data
Status = mTransport->Start (
- ReceiveEvent
- );
+ ReceiveEvent
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Couldn't start transport: %r\n", Status));
return Status;
}
// Talk to the user
- mTextOut->OutputString (mTextOut,
- L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press RETURN or SPACE key to quit.\r\n");
+ mTextOut->OutputString (
+ mTextOut,
+ L"Android Fastboot mode - version " ANDROID_FASTBOOT_VERSION ". Press RETURN or SPACE key to quit.\r\n"
+ );
// Quit when the user presses any key, or mFinishedEvent is signalled
WaitEventArray[0] = mFinishedEvent;
@@ -513,7 +523,8 @@ FastbootAppEntryPoint (
Status = TextIn->ReadKeyStroke (gST->ConIn, &Key);
if (Key.ScanCode == SCAN_NULL) {
if ((Key.UnicodeChar == CHAR_CARRIAGE_RETURN) ||
- (Key.UnicodeChar == L' ')) {
+ (Key.UnicodeChar == L' '))
+ {
break;
}
}
@@ -523,6 +534,7 @@ FastbootAppEntryPoint (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Warning: Fastboot Transport Stop: %r\n", Status));
}
+
mPlatform->UnInit ();
return EFI_SUCCESS;
diff --git a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
index 88720f9648..3923c03428 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
+++ b/EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.h
@@ -14,24 +14,24 @@
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
-#define BOOTIMG_KERNEL_ARGS_SIZE 512
+#define BOOTIMG_KERNEL_ARGS_SIZE 512
-#define ANDROID_FASTBOOT_VERSION "0.4"
+#define ANDROID_FASTBOOT_VERSION "0.4"
EFI_STATUS
BootAndroidBootImg (
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
EFI_STATUS
ParseAndroidBootImg (
- IN VOID *BootImg,
+ IN VOID *BootImg,
OUT VOID **Kernel,
- OUT UINTN *KernelSize,
+ OUT UINTN *KernelSize,
OUT VOID **Ramdisk,
- OUT UINTN *RamdiskSize,
- OUT CHAR8 *KernelArgs
+ OUT UINTN *RamdiskSize,
+ OUT CHAR8 *KernelArgs
);
#endif //ifdef __ANDROID_FASTBOOT_APP_H__
diff --git a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
index c9b885b073..163ac7ecc9 100644
--- a/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
+++ b/EmbeddedPkg/Application/AndroidFastboot/Arm/BootAndroidBootImg.c
@@ -18,12 +18,12 @@
// Device Path representing an image in memory
#pragma pack(1)
typedef struct {
- MEMMAP_DEVICE_PATH Node1;
- EFI_DEVICE_PATH_PROTOCOL End;
+ MEMMAP_DEVICE_PATH Node1;
+ EFI_DEVICE_PATH_PROTOCOL End;
} MEMORY_DEVICE_PATH;
#pragma pack()
-STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
+STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
{
{
{
@@ -44,7 +44,6 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
} // End
};
-
/**
Start an EFI Application from a Device Path
@@ -59,19 +58,25 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
STATIC
EFI_STATUS
StartEfiApplication (
- IN EFI_HANDLE ParentImageHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN UINTN LoadOptionsSize,
- IN VOID* LoadOptions
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN UINTN LoadOptionsSize,
+ IN VOID *LoadOptions
)
{
- EFI_STATUS Status;
- EFI_HANDLE ImageHandle;
- EFI_LOADED_IMAGE_PROTOCOL* LoadedImage;
+ EFI_STATUS Status;
+ EFI_HANDLE ImageHandle;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
// Load the image from the device path with Boot Services function
- Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, NULL, 0,
- &ImageHandle);
+ Status = gBS->LoadImage (
+ TRUE,
+ ParentImageHandle,
+ DevicePath,
+ NULL,
+ 0,
+ &ImageHandle
+ );
if (EFI_ERROR (Status)) {
//
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
@@ -82,19 +87,23 @@ StartEfiApplication (
if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (ImageHandle);
}
+
return Status;
}
// Passed LoadOptions to the EFI Application
if (LoadOptionsSize != 0) {
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage);
+ Status = gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- LoadedImage->LoadOptionsSize = LoadOptionsSize;
- LoadedImage->LoadOptions = LoadOptions;
+ LoadedImage->LoadOptionsSize = LoadOptionsSize;
+ LoadedImage->LoadOptions = LoadOptions;
}
// Before calling the image, enable the Watchdog Timer for the 5 Minute period
@@ -109,27 +118,27 @@ StartEfiApplication (
EFI_STATUS
BootAndroidBootImg (
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
- VOID *Kernel;
- UINTN KernelSize;
- VOID *Ramdisk;
- UINTN RamdiskSize;
- MEMORY_DEVICE_PATH KernelDevicePath;
- CHAR16 *LoadOptions, *NewLoadOptions;
+ EFI_STATUS Status;
+ CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
+ VOID *Kernel;
+ UINTN KernelSize;
+ VOID *Ramdisk;
+ UINTN RamdiskSize;
+ MEMORY_DEVICE_PATH KernelDevicePath;
+ CHAR16 *LoadOptions, *NewLoadOptions;
Status = ParseAndroidBootImg (
- Buffer,
- &Kernel,
- &KernelSize,
- &Ramdisk,
- &RamdiskSize,
- KernelArgs
- );
+ Buffer,
+ &Kernel,
+ &KernelSize,
+ &Ramdisk,
+ &RamdiskSize,
+ KernelArgs
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -138,8 +147,8 @@ BootAndroidBootImg (
// Have to cast to UINTN before casting to EFI_PHYSICAL_ADDRESS in order to
// appease GCC.
- KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel;
- KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel + KernelSize;
+ KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Kernel;
+ KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Kernel + KernelSize;
// Initialize Linux command line
LoadOptions = CatSPrint (NULL, L"%a", KernelArgs);
@@ -148,19 +157,26 @@ BootAndroidBootImg (
}
if (RamdiskSize != 0) {
- NewLoadOptions = CatSPrint (LoadOptions, L" initrd=0x%x,0x%x",
- (UINTN)Ramdisk, RamdiskSize);
+ NewLoadOptions = CatSPrint (
+ LoadOptions,
+ L" initrd=0x%x,0x%x",
+ (UINTN)Ramdisk,
+ RamdiskSize
+ );
FreePool (LoadOptions);
if (NewLoadOptions == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
LoadOptions = NewLoadOptions;
}
- Status = StartEfiApplication (gImageHandle,
- (EFI_DEVICE_PATH_PROTOCOL *) &KernelDevicePath,
+ Status = StartEfiApplication (
+ gImageHandle,
+ (EFI_DEVICE_PATH_PROTOCOL *)&KernelDevicePath,
StrSize (LoadOptions),
- LoadOptions);
+ LoadOptions
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Couldn't Boot Linux: %d\n", Status));
Status = EFI_DEVICE_ERROR;
diff --git a/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c b/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c
index 0cf884b350..97c1a4599b 100644
--- a/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c
+++ b/EmbeddedPkg/Drivers/AndroidFastbootTransportTcpDxe/FastbootTransportTcp.c
@@ -22,7 +22,7 @@
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiRuntimeServicesTableLib.h>
-#define IP4_ADDR_TO_STRING(IpAddr, IpAddrString) UnicodeSPrint ( \
+#define IP4_ADDR_TO_STRING(IpAddr, IpAddrString) UnicodeSPrint ( \
IpAddrString, \
16 * 2, \
L"%d.%d.%d.%d", \
@@ -37,49 +37,49 @@
// (This isn't actually a packet size - it's just the size of the buffers we
// pass to the TCP driver to fill with received data.)
// We can achieve much better performance by doing this in larger chunks.
-#define RX_FRAGMENT_SIZE 2048
+#define RX_FRAGMENT_SIZE 2048
-STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
+STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
-STATIC EFI_TCP4_PROTOCOL *mTcpConnection;
-STATIC EFI_TCP4_PROTOCOL *mTcpListener;
+STATIC EFI_TCP4_PROTOCOL *mTcpConnection;
+STATIC EFI_TCP4_PROTOCOL *mTcpListener;
-STATIC EFI_EVENT mReceiveEvent;
+STATIC EFI_EVENT mReceiveEvent;
-STATIC EFI_SERVICE_BINDING_PROTOCOL *mTcpServiceBinding;
+STATIC EFI_SERVICE_BINDING_PROTOCOL *mTcpServiceBinding;
STATIC EFI_HANDLE mTcpHandle = NULL;
// We only ever use one IO token for receive and one for transmit. To save
// repeatedly allocating and freeing, just allocate statically and re-use.
-#define NUM_RX_TOKENS 16
-#define TOKEN_NEXT(Index) (((Index) + 1) % NUM_RX_TOKENS)
-
-STATIC UINTN mNextSubmitIndex;
-STATIC UINTN mNextReceiveIndex;
-STATIC EFI_TCP4_IO_TOKEN mReceiveToken[NUM_RX_TOKENS];
-STATIC EFI_TCP4_RECEIVE_DATA mRxData[NUM_RX_TOKENS];
-STATIC EFI_TCP4_IO_TOKEN mTransmitToken;
-STATIC EFI_TCP4_TRANSMIT_DATA mTxData;
+#define NUM_RX_TOKENS 16
+#define TOKEN_NEXT(Index) (((Index) + 1) % NUM_RX_TOKENS)
+
+STATIC UINTN mNextSubmitIndex;
+STATIC UINTN mNextReceiveIndex;
+STATIC EFI_TCP4_IO_TOKEN mReceiveToken[NUM_RX_TOKENS];
+STATIC EFI_TCP4_RECEIVE_DATA mRxData[NUM_RX_TOKENS];
+STATIC EFI_TCP4_IO_TOKEN mTransmitToken;
+STATIC EFI_TCP4_TRANSMIT_DATA mTxData;
// We also reuse the accept token
-STATIC EFI_TCP4_LISTEN_TOKEN mAcceptToken;
+STATIC EFI_TCP4_LISTEN_TOKEN mAcceptToken;
// .. and the close token
-STATIC EFI_TCP4_CLOSE_TOKEN mCloseToken;
+STATIC EFI_TCP4_CLOSE_TOKEN mCloseToken;
// List type for queued received packets
typedef struct _FASTBOOT_TCP_PACKET_LIST {
- LIST_ENTRY Link;
- VOID *Buffer;
- UINTN BufferSize;
+ LIST_ENTRY Link;
+ VOID *Buffer;
+ UINTN BufferSize;
} FASTBOOT_TCP_PACKET_LIST;
-STATIC LIST_ENTRY mPacketListHead;
+STATIC LIST_ENTRY mPacketListHead;
STATIC
VOID
EFIAPI
DataReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/*
@@ -91,8 +91,8 @@ SubmitRecieveToken (
VOID
)
{
- EFI_STATUS Status;
- VOID *FragmentBuffer;
+ EFI_STATUS Status;
+ VOID *FragmentBuffer;
Status = EFI_SUCCESS;
@@ -103,12 +103,12 @@ SubmitRecieveToken (
return EFI_OUT_OF_RESOURCES;
}
- mRxData[mNextSubmitIndex].DataLength = RX_FRAGMENT_SIZE;
+ mRxData[mNextSubmitIndex].DataLength = RX_FRAGMENT_SIZE;
mRxData[mNextSubmitIndex].FragmentTable[0].FragmentLength = RX_FRAGMENT_SIZE;
mRxData[mNextSubmitIndex].FragmentTable[0].FragmentBuffer = FragmentBuffer;
Status = mTcpConnection->Receive (mTcpConnection, &mReceiveToken[mNextSubmitIndex]);
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "TCP Receive: %r\n", Status));
FreePool (FragmentBuffer);
}
@@ -125,10 +125,10 @@ STATIC
VOID
ConnectionClosed (
IN EFI_EVENT Event,
- IN VOID *Context
+ IN VOID *Context
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
// Possible bug in EDK2 TCP4 driver: closing a connection doesn't remove its
// PCB from the list of live connections. Subsequent attempts to Configure()
@@ -150,7 +150,7 @@ CloseReceiveEvents (
VOID
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
gBS->CloseEvent (mReceiveToken[Index].CompletionToken.Event);
@@ -164,11 +164,11 @@ STATIC
VOID
EFIAPI
DataReceived (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
FASTBOOT_TCP_PACKET_LIST *NewEntry;
EFI_TCP4_IO_TOKEN *ReceiveToken;
@@ -208,11 +208,11 @@ DataReceived (
= ReceiveToken->Packet.RxData->FragmentTable[0].FragmentLength;
// Prepare to receive more data
- SubmitRecieveToken();
+ SubmitRecieveToken ();
} else {
// Fatal receive error. Put an entry with NULL in the queue, signifying
// to return EFI_DEVICE_ERROR from TcpFastbootTransportReceive.
- NewEntry->Buffer = NULL;
+ NewEntry->Buffer = NULL;
NewEntry->BufferSize = 0;
DEBUG ((DEBUG_ERROR, "\nTCP Fastboot Receive error: %r\n", Status));
@@ -224,7 +224,6 @@ DataReceived (
ASSERT_EFI_ERROR (Status);
}
-
/*
Event notify function to be called when we accept an incoming TCP connection.
*/
@@ -232,21 +231,22 @@ STATIC
VOID
EFIAPI
ConnectionAccepted (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_TCP4_LISTEN_TOKEN *AcceptToken;
+ EFI_TCP4_LISTEN_TOKEN *AcceptToken;
EFI_STATUS Status;
UINTN Index;
- AcceptToken = (EFI_TCP4_LISTEN_TOKEN *) Context;
- Status = AcceptToken->CompletionToken.Status;
+ AcceptToken = (EFI_TCP4_LISTEN_TOKEN *)Context;
+ Status = AcceptToken->CompletionToken.Status;
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "TCP Fastboot: Connection Error: %r\n", Status));
return;
}
+
DEBUG ((DEBUG_ERROR, "TCP Fastboot: Connection Received.\n"));
//
@@ -257,7 +257,7 @@ ConnectionAccepted (
Status = gBS->OpenProtocol (
AcceptToken->NewChildHandle,
&gEfiTcp4ProtocolGuid,
- (VOID **) &mTcpConnection,
+ (VOID **)&mTcpConnection,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -267,7 +267,7 @@ ConnectionAccepted (
return;
}
- mNextSubmitIndex = 0;
+ mNextSubmitIndex = 0;
mNextReceiveIndex = 0;
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
@@ -282,7 +282,7 @@ ConnectionAccepted (
}
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
- SubmitRecieveToken();
+ SubmitRecieveToken ();
}
}
@@ -292,26 +292,32 @@ ConnectionAccepted (
*/
EFI_STATUS
TcpFastbootTransportStart (
- EFI_EVENT ReceiveEvent
+ EFI_EVENT ReceiveEvent
)
{
- EFI_STATUS Status;
- EFI_HANDLE NetDeviceHandle;
- EFI_HANDLE *HandleBuffer;
- EFI_IP4_MODE_DATA Ip4ModeData;
- UINTN NumHandles;
- CHAR16 IpAddrString[16];
- UINTN Index;
-
- EFI_TCP4_CONFIG_DATA TcpConfigData = {
+ EFI_STATUS Status;
+ EFI_HANDLE NetDeviceHandle;
+ EFI_HANDLE *HandleBuffer;
+ EFI_IP4_MODE_DATA Ip4ModeData;
+ UINTN NumHandles;
+ CHAR16 IpAddrString[16];
+ UINTN Index;
+
+ EFI_TCP4_CONFIG_DATA TcpConfigData = {
0x00, // IPv4 Type of Service
255, // IPv4 Time to Live
{ // AccessPoint:
TRUE, // Use default address
- { {0, 0, 0, 0} }, // IP Address (ignored - use default)
- { {0, 0, 0, 0} }, // Subnet mask (ignored - use default)
+ {
+ { 0, 0, 0, 0 }
+ }, // IP Address (ignored - use default)
+ {
+ { 0, 0, 0, 0 }
+ }, // Subnet mask (ignored - use default)
FixedPcdGet32 (PcdAndroidFastbootTcpPort), // Station port
- { {0, 0, 0, 0} }, // Remote address: accept any
+ {
+ { 0, 0, 0, 0 }
+ }, // Remote address: accept any
0, // Remote Port: accept any
FALSE // ActiveFlag: be a "server"
},
@@ -343,13 +349,13 @@ TcpFastbootTransportStart (
NetDeviceHandle = HandleBuffer[0];
Status = gBS->OpenProtocol (
- NetDeviceHandle,
- &gEfiTcp4ServiceBindingProtocolGuid,
- (VOID **) &mTcpServiceBinding,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ NetDeviceHandle,
+ &gEfiTcp4ServiceBindingProtocolGuid,
+ (VOID **)&mTcpServiceBinding,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Open TCP Service Binding: %r\n", Status));
return Status;
@@ -362,13 +368,13 @@ TcpFastbootTransportStart (
}
Status = gBS->OpenProtocol (
- mTcpHandle,
- &gEfiTcp4ProtocolGuid,
- (VOID **) &mTcpListener,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ mTcpHandle,
+ &gEfiTcp4ProtocolGuid,
+ (VOID **)&mTcpListener,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Open TCP Protocol: %r\n", Status));
}
@@ -378,14 +384,14 @@ TcpFastbootTransportStart (
//
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
- mRxData[Index].UrgentFlag = FALSE;
- mRxData[Index].FragmentCount = 1;
+ mRxData[Index].UrgentFlag = FALSE;
+ mRxData[Index].FragmentCount = 1;
mReceiveToken[Index].Packet.RxData = &mRxData[Index];
}
- mTxData.Push = TRUE;
- mTxData.Urgent = FALSE;
- mTxData.FragmentCount = 1;
+ mTxData.Push = TRUE;
+ mTxData.Urgent = FALSE;
+ mTxData.FragmentCount = 1;
mTransmitToken.Packet.TxData = &mTxData;
Status = gBS->CreateEvent (
@@ -414,13 +420,17 @@ TcpFastbootTransportStart (
if (Status == EFI_NO_MAPPING) {
// Wait until the IP configuration process (probably DHCP) has finished
do {
- Status = mTcpListener->GetModeData (mTcpListener,
- NULL, NULL,
+ Status = mTcpListener->GetModeData (
+ mTcpListener,
+ NULL,
+ NULL,
&Ip4ModeData,
- NULL, NULL
+ NULL,
+ NULL
);
ASSERT_EFI_ERROR (Status);
} while (!Ip4ModeData.IsConfigured);
+
Status = mTcpListener->Configure (mTcpListener, &TcpConfigData);
} else if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "TCP Configure: %r\n", Status));
@@ -434,7 +444,7 @@ TcpFastbootTransportStart (
mTextOut->OutputString (mTextOut, L"TCP Fastboot transport configured.");
mTextOut->OutputString (mTextOut, L"\r\nIP address: ");
- mTextOut->OutputString (mTextOut ,IpAddrString);
+ mTextOut->OutputString (mTextOut, IpAddrString);
mTextOut->OutputString (mTextOut, L"\r\n");
//
@@ -462,8 +472,8 @@ TcpFastbootTransportStop (
EFI_TCP4_CLOSE_TOKEN CloseToken;
EFI_STATUS Status;
UINTN EventIndex;
- FASTBOOT_TCP_PACKET_LIST *Entry;
- FASTBOOT_TCP_PACKET_LIST *NextEntry;
+ FASTBOOT_TCP_PACKET_LIST *Entry;
+ FASTBOOT_TCP_PACKET_LIST *NextEntry;
// Close any existing TCP connection, blocking until it's done.
if (mTcpConnection != NULL) {
@@ -494,7 +504,6 @@ TcpFastbootTransportStop (
ASSERT_EFI_ERROR (Status);
}
-
gBS->CloseEvent (mAcceptToken.CompletionToken.Event);
// Stop listening for connections.
@@ -506,14 +515,15 @@ TcpFastbootTransportStop (
Status = mTcpServiceBinding->DestroyChild (mTcpServiceBinding, mTcpHandle);
// Free any data the user didn't pick up
- Entry = (FASTBOOT_TCP_PACKET_LIST *) GetFirstNode (&mPacketListHead);
+ Entry = (FASTBOOT_TCP_PACKET_LIST *)GetFirstNode (&mPacketListHead);
while (!IsNull (&mPacketListHead, &Entry->Link)) {
- NextEntry = (FASTBOOT_TCP_PACKET_LIST *) GetNextNode (&mPacketListHead, &Entry->Link);
+ NextEntry = (FASTBOOT_TCP_PACKET_LIST *)GetNextNode (&mPacketListHead, &Entry->Link);
RemoveEntryList (&Entry->Link);
if (Entry->Buffer) {
FreePool (Entry->Buffer);
}
+
FreePool (Entry);
Entry = NextEntry;
@@ -531,16 +541,16 @@ TcpFastbootTransportStop (
STATIC
VOID
DataSent (
- EFI_EVENT Event,
- VOID *Context
+ EFI_EVENT Event,
+ VOID *Context
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = mTransmitToken.CompletionToken.Status;
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "TCP Fastboot transmit result: %r\n", Status));
- gBS->SignalEvent (*(EFI_EVENT *) Context);
+ gBS->SignalEvent (*(EFI_EVENT *)Context);
}
FreePool (mTransmitToken.Packet.TxData->FragmentTable[0].FragmentBuffer);
@@ -549,11 +559,11 @@ DataSent (
EFI_STATUS
TcpFastbootTransportSend (
IN UINTN BufferSize,
- IN CONST VOID *Buffer,
- IN EFI_EVENT *FatalErrorEvent
+ IN CONST VOID *Buffer,
+ IN EFI_EVENT *FatalErrorEvent
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (BufferSize > 512) {
return EFI_INVALID_PARAMETER;
@@ -578,9 +588,9 @@ TcpFastbootTransportSend (
mTxData.FragmentTable[0].FragmentLength = BufferSize;
mTxData.FragmentTable[0].FragmentBuffer = AllocateCopyPool (
- BufferSize,
- Buffer
- );
+ BufferSize,
+ Buffer
+ );
Status = mTcpConnection->Transmit (mTcpConnection, &mTransmitToken);
if (EFI_ERROR (Status)) {
@@ -591,27 +601,26 @@ TcpFastbootTransportSend (
return EFI_SUCCESS;
}
-
EFI_STATUS
TcpFastbootTransportReceive (
OUT UINTN *BufferSize,
- OUT VOID **Buffer
+ OUT VOID **Buffer
)
{
- FASTBOOT_TCP_PACKET_LIST *Entry;
+ FASTBOOT_TCP_PACKET_LIST *Entry;
if (IsListEmpty (&mPacketListHead)) {
return EFI_NOT_READY;
}
- Entry = (FASTBOOT_TCP_PACKET_LIST *) GetFirstNode (&mPacketListHead);
+ Entry = (FASTBOOT_TCP_PACKET_LIST *)GetFirstNode (&mPacketListHead);
if (Entry->Buffer == NULL) {
// There was an error receiving this packet.
return EFI_DEVICE_ERROR;
}
- *Buffer = Entry->Buffer;
+ *Buffer = Entry->Buffer;
*BufferSize = Entry->BufferSize;
RemoveEntryList (&Entry->Link);
@@ -620,7 +629,7 @@ TcpFastbootTransportReceive (
return EFI_SUCCESS;
}
-FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
+FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
TcpFastbootTransportStart,
TcpFastbootTransportStop,
TcpFastbootTransportSend,
@@ -630,17 +639,16 @@ FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
EFI_STATUS
TcpFastbootTransportEntryPoint (
IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
-
+ EFI_STATUS Status;
- Status = gBS->LocateProtocol(
- &gEfiSimpleTextOutProtocolGuid,
- NULL,
- (VOID **) &mTextOut
- );
+ Status = gBS->LocateProtocol (
+ &gEfiSimpleTextOutProtocolGuid,
+ NULL,
+ (VOID **)&mTextOut
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Open Text Output Protocol: %r\n", Status));
return Status;
diff --git a/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c b/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c
index 97e56b6e3d..fe934cce59 100644
--- a/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c
+++ b/EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsb.c
@@ -21,45 +21,44 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
-STATIC USB_DEVICE_PROTOCOL *mUsbDevice;
+STATIC USB_DEVICE_PROTOCOL *mUsbDevice;
// Configuration attributes:
// bit 7 reserved and must be 1, bit 6 means self-powered.
-#define CONFIG_DESC_ATTRIBUTES (BIT7 | BIT6)
+#define CONFIG_DESC_ATTRIBUTES (BIT7 | BIT6)
-#define MAX_PACKET_SIZE_BULK 512
+#define MAX_PACKET_SIZE_BULK 512
STATIC USB_DEVICE_PROTOCOL *mUsbDevice;
-STATIC EFI_EVENT mReceiveEvent = NULL;
-STATIC LIST_ENTRY mPacketList;
+STATIC EFI_EVENT mReceiveEvent = NULL;
+STATIC LIST_ENTRY mPacketList;
// List type for queued received packets
typedef struct _FASTBOOT_USB_PACKET_LIST {
- LIST_ENTRY Link;
- VOID *Buffer;
- UINTN BufferSize;
+ LIST_ENTRY Link;
+ VOID *Buffer;
+ UINTN BufferSize;
} FASTBOOT_USB_PACKET_LIST;
-
/*
No string descriptors - all string descriptor members are set to 0
*/
-STATIC USB_DEVICE_DESCRIPTOR mDeviceDescriptor = {
- sizeof (USB_DEVICE_DESCRIPTOR), //Length
- USB_DESC_TYPE_DEVICE, //DescriptorType
- 0x0200, //BcdUSB
- 0xFF, //DeviceClass
- 0, //DeviceSubClass
- 0, //DeviceProtocol
- 64, //MaxPacketSize0
- FixedPcdGet32 (PcdAndroidFastbootUsbVendorId), //IdVendor
- FixedPcdGet32 (PcdAndroidFastbootUsbProductId), //IdProduct
- 0, //BcdDevice
- 0, //StrManufacturer
- 0, //StrProduct
- 0, //StrSerialNumber
- 1 //NumConfigurations
+STATIC USB_DEVICE_DESCRIPTOR mDeviceDescriptor = {
+ sizeof (USB_DEVICE_DESCRIPTOR), // Length
+ USB_DESC_TYPE_DEVICE, // DescriptorType
+ 0x0200, // BcdUSB
+ 0xFF, // DeviceClass
+ 0, // DeviceSubClass
+ 0, // DeviceProtocol
+ 64, // MaxPacketSize0
+ FixedPcdGet32 (PcdAndroidFastbootUsbVendorId), // IdVendor
+ FixedPcdGet32 (PcdAndroidFastbootUsbProductId), // IdProduct
+ 0, // BcdDevice
+ 0, // StrManufacturer
+ 0, // StrProduct
+ 0, // StrSerialNumber
+ 1 // NumConfigurations
};
/*
@@ -71,69 +70,69 @@ STATIC USB_DEVICE_DESCRIPTOR mDeviceDescriptor = {
#pragma pack(1)
typedef struct {
- USB_CONFIG_DESCRIPTOR ConfigDescriptor;
- USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- USB_ENDPOINT_DESCRIPTOR EndpointDescriptor1;
- USB_ENDPOINT_DESCRIPTOR EndpointDescriptor2;
+ USB_CONFIG_DESCRIPTOR ConfigDescriptor;
+ USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
+ USB_ENDPOINT_DESCRIPTOR EndpointDescriptor1;
+ USB_ENDPOINT_DESCRIPTOR EndpointDescriptor2;
} GET_CONFIG_DESCRIPTOR_RESPONSE;
#pragma pack()
-STATIC GET_CONFIG_DESCRIPTOR_RESPONSE mGetConfigDescriptorResponse = {
- { // USB_CONFIG_DESCRIPTOR
- sizeof (USB_CONFIG_DESCRIPTOR), //Length;
- USB_DESC_TYPE_CONFIG, //DescriptorType;
- sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE), //TotalLength;
- 1, //NumInterfaces;
- 1, //ConfigurationValue;
- 0, //Configuration;
- CONFIG_DESC_ATTRIBUTES, //Attributes;
- 0 //MaxPower;
+STATIC GET_CONFIG_DESCRIPTOR_RESPONSE mGetConfigDescriptorResponse = {
+ { // USB_CONFIG_DESCRIPTOR
+ sizeof (USB_CONFIG_DESCRIPTOR), // Length;
+ USB_DESC_TYPE_CONFIG, // DescriptorType;
+ sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE), // TotalLength;
+ 1, // NumInterfaces;
+ 1, // ConfigurationValue;
+ 0, // Configuration;
+ CONFIG_DESC_ATTRIBUTES, // Attributes;
+ 0 // MaxPower;
},
- { // USB_INTERFACE_DESCRIPTOR
- sizeof (USB_INTERFACE_DESCRIPTOR), //Length;
- USB_DESC_TYPE_INTERFACE, //DescriptorType;
- 0, //InterfaceNumber;
- 0, //AlternateSetting;
- 2, //NumEndpoints;
- 0xFF, //InterfaceClass;
+ { // USB_INTERFACE_DESCRIPTOR
+ sizeof (USB_INTERFACE_DESCRIPTOR), // Length;
+ USB_DESC_TYPE_INTERFACE, // DescriptorType;
+ 0, // InterfaceNumber;
+ 0, // AlternateSetting;
+ 2, // NumEndpoints;
+ 0xFF, // InterfaceClass;
// Vendor specific interface subclass and protocol codes.
// I found these values in the Fastboot code
// (in match_fastboot_with_serial in fastboot.c).
- 0x42, //InterfaceSubClass;
- 0x03, //InterfaceProtocol;
- 0 //Interface;
+ 0x42, // InterfaceSubClass;
+ 0x03, // InterfaceProtocol;
+ 0 // Interface;
},
- { // USB_ENDPOINT_DESCRIPTOR (In Endpoint)
- sizeof (USB_ENDPOINT_DESCRIPTOR), //Length;
- USB_DESC_TYPE_ENDPOINT, //DescriptorType;
- 1 | BIT7, //EndpointAddress;
- 0x2, //Attributes;
- MAX_PACKET_SIZE_BULK, //MaxPacketSize;
- 16 //Interval;
+ { // USB_ENDPOINT_DESCRIPTOR (In Endpoint)
+ sizeof (USB_ENDPOINT_DESCRIPTOR), // Length;
+ USB_DESC_TYPE_ENDPOINT, // DescriptorType;
+ 1 | BIT7, // EndpointAddress;
+ 0x2, // Attributes;
+ MAX_PACKET_SIZE_BULK, // MaxPacketSize;
+ 16 // Interval;
},
- { // STATIC USB_ENDPOINT_DESCRIPTOR (Out Endpoint)
- sizeof (USB_ENDPOINT_DESCRIPTOR), //Length;
- USB_DESC_TYPE_ENDPOINT, //DescriptorType;
- 1, //EndpointAddress;
- 0x2, //Attributes;
- MAX_PACKET_SIZE_BULK, //MaxPacketSize;
- 16 //Interval;
+ { // STATIC USB_ENDPOINT_DESCRIPTOR (Out Endpoint)
+ sizeof (USB_ENDPOINT_DESCRIPTOR), // Length;
+ USB_DESC_TYPE_ENDPOINT, // DescriptorType;
+ 1, // EndpointAddress;
+ 0x2, // Attributes;
+ MAX_PACKET_SIZE_BULK, // MaxPacketSize;
+ 16 // Interval;
}
};
STATIC
VOID
DataReceived (
- IN UINTN Size,
- IN VOID *Buffer
+ IN UINTN Size,
+ IN VOID *Buffer
)
{
- FASTBOOT_USB_PACKET_LIST *NewEntry;
+ FASTBOOT_USB_PACKET_LIST *NewEntry;
NewEntry = AllocatePool (sizeof (*NewEntry));
ASSERT (NewEntry != NULL);
- NewEntry->Buffer = Buffer;
+ NewEntry->Buffer = Buffer;
NewEntry->BufferSize = Size;
InsertTailList (&mPacketList, &NewEntry->Link);
@@ -146,7 +145,7 @@ DataReceived (
STATIC
VOID
DataSent (
- IN UINT8 EndpointIndex
+ IN UINT8 EndpointIndex
)
{
// Don't care.
@@ -158,7 +157,7 @@ DataSent (
*/
EFI_STATUS
FastbootTransportUsbStart (
- EFI_EVENT ReceiveEvent
+ EFI_EVENT ReceiveEvent
)
{
GET_CONFIG_DESCRIPTOR_RESPONSE *Responses;
@@ -166,11 +165,11 @@ FastbootTransportUsbStart (
mReceiveEvent = ReceiveEvent;
mGetConfigDescriptorResponse.ConfigDescriptor.TotalLength = sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE);
- Responses = &mGetConfigDescriptorResponse;
+ Responses = &mGetConfigDescriptorResponse;
InitializeListHead (&mPacketList);
- return mUsbDevice->Start (&mDeviceDescriptor, (VOID **) &Responses, DataReceived, DataSent);
+ return mUsbDevice->Start (&mDeviceDescriptor, (VOID **)&Responses, DataReceived, DataSent);
}
/*
@@ -196,12 +195,12 @@ FastbootTransportUsbStop (
EFI_STATUS
FastbootTransportUsbSend (
IN UINTN BufferSize,
- IN CONST VOID *Buffer,
- IN EFI_EVENT *FatalErrorEvent
+ IN CONST VOID *Buffer,
+ IN EFI_EVENT *FatalErrorEvent
)
{
// Current USB protocol is blocking, so ignore FatalErrorEvent
- return mUsbDevice->Send(1, BufferSize, Buffer);
+ return mUsbDevice->Send (1, BufferSize, Buffer);
}
/*
@@ -221,19 +220,19 @@ FastbootTransportUsbSend (
EFI_STATUS
FastbootTransportUsbReceive (
OUT UINTN *BufferSize,
- OUT VOID **Buffer
+ OUT VOID **Buffer
)
{
- FASTBOOT_USB_PACKET_LIST *Entry;
+ FASTBOOT_USB_PACKET_LIST *Entry;
if (IsListEmpty (&mPacketList)) {
return EFI_NOT_READY;
}
- Entry = (FASTBOOT_USB_PACKET_LIST *) GetFirstNode (&mPacketList);
+ Entry = (FASTBOOT_USB_PACKET_LIST *)GetFirstNode (&mPacketList);
*BufferSize = Entry->BufferSize;
- *Buffer = Entry->Buffer;
+ *Buffer = Entry->Buffer;
RemoveEntryList (&Entry->Link);
FreePool (Entry);
@@ -241,7 +240,7 @@ FastbootTransportUsbReceive (
return EFI_SUCCESS;
}
-STATIC FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
+STATIC FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
FastbootTransportUsbStart,
FastbootTransportUsbStop,
FastbootTransportUsbSend,
@@ -251,13 +250,13 @@ STATIC FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
EFI_STATUS
FastbootTransportUsbEntryPoint (
IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
// Assume there's only one USB peripheral controller.
- Status = gBS->LocateProtocol (&gUsbDeviceProtocolGuid, NULL, (VOID **) &mUsbDevice);
+ Status = gBS->LocateProtocol (&gUsbDeviceProtocolGuid, NULL, (VOID **)&mUsbDevice);
if (EFI_ERROR (Status)) {
return Status;
}
diff --git a/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c b/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c
index 08bba1bbf1..07b82892eb 100644
--- a/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c
+++ b/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.c
@@ -24,24 +24,24 @@
#include "ConsolePrefDxe.h"
-#define SPCR_SIG EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
+#define SPCR_SIG EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
-extern UINT8 ConsolePrefHiiBin[];
-extern UINT8 ConsolePrefDxeStrings[];
+extern UINT8 ConsolePrefHiiBin[];
+extern UINT8 ConsolePrefDxeStrings[];
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
-STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
+STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
CONSOLE_PREF_FORMSET_GUID
@@ -50,13 +50,13 @@ STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
-STATIC EFI_EVENT mReadyToBootEvent;
+STATIC EFI_EVENT mReadyToBootEvent;
STATIC
EFI_STATUS
@@ -64,32 +64,39 @@ InstallHiiPages (
VOID
)
{
- EFI_STATUS Status;
- EFI_HII_HANDLE HiiHandle;
- EFI_HANDLE DriverHandle;
+ EFI_STATUS Status;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_HANDLE DriverHandle;
DriverHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mConsolePrefDxeVendorDevicePath,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mConsolePrefDxeVendorDevicePath,
+ NULL
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- HiiHandle = HiiAddPackages (&gConsolePrefFormSetGuid,
- DriverHandle,
- ConsolePrefDxeStrings,
- ConsolePrefHiiBin,
- NULL);
+ HiiHandle = HiiAddPackages (
+ &gConsolePrefFormSetGuid,
+ DriverHandle,
+ ConsolePrefDxeStrings,
+ ConsolePrefHiiBin,
+ NULL
+ );
if (HiiHandle == NULL) {
- gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
+ gBS->UninstallMultipleProtocolInterfaces (
+ DriverHandle,
&gEfiDevicePathProtocolGuid,
&mConsolePrefDxeVendorDevicePath,
- NULL);
+ NULL
+ );
return EFI_OUT_OF_RESOURCES;
}
+
return EFI_SUCCESS;
}
@@ -97,7 +104,7 @@ STATIC
VOID
RemoveDtStdoutPath (
VOID
-)
+ )
{
VOID *Dtb;
INT32 Node;
@@ -106,8 +113,12 @@ RemoveDtStdoutPath (
Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &Dtb);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO, "%a: could not retrieve DT blob - %r\n", __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: could not retrieve DT blob - %r\n",
+ __FUNCTION__,
+ Status
+ ));
return;
}
@@ -118,8 +129,12 @@ RemoveDtStdoutPath (
Error = fdt_delprop (Dtb, Node, "stdout-path");
if (Error) {
- DEBUG ((DEBUG_INFO, "%a: Failed to delete 'stdout-path' property: %a\n",
- __FUNCTION__, fdt_strerror (Error)));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: Failed to delete 'stdout-path' property: %a\n",
+ __FUNCTION__,
+ fdt_strerror (Error)
+ ));
}
}
@@ -129,16 +144,19 @@ RemoveSpcrTable (
VOID
)
{
- EFI_ACPI_SDT_PROTOCOL *Sdt;
- EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
- EFI_STATUS Status;
- UINTN TableIndex;
- EFI_ACPI_SDT_HEADER *TableHeader;
- EFI_ACPI_TABLE_VERSION TableVersion;
- UINTN TableKey;
-
- Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
- (VOID **)&AcpiTable);
+ EFI_ACPI_SDT_PROTOCOL *Sdt;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
+ EFI_STATUS Status;
+ UINTN TableIndex;
+ EFI_ACPI_SDT_HEADER *TableHeader;
+ EFI_ACPI_TABLE_VERSION TableVersion;
+ UINTN TableKey;
+
+ Status = gBS->LocateProtocol (
+ &gEfiAcpiTableProtocolGuid,
+ NULL,
+ (VOID **)&AcpiTable
+ );
if (EFI_ERROR (Status)) {
return;
}
@@ -153,8 +171,12 @@ RemoveSpcrTable (
TableHeader = NULL;
do {
- Status = Sdt->GetAcpiTable (TableIndex++, &TableHeader, &TableVersion,
- &TableKey);
+ Status = Sdt->GetAcpiTable (
+ TableIndex++,
+ &TableHeader,
+ &TableVersion,
+ &TableKey
+ );
if (EFI_ERROR (Status)) {
break;
}
@@ -165,9 +187,14 @@ RemoveSpcrTable (
Status = AcpiTable->UninstallAcpiTable (AcpiTable, TableKey);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN, "%a: failed to uninstall SPCR table - %r\n",
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: failed to uninstall SPCR table - %r\n",
+ __FUNCTION__,
+ Status
+ ));
}
+
break;
} while (TRUE);
}
@@ -180,24 +207,35 @@ OnReadyToBoot (
IN VOID *Context
)
{
- CONSOLE_PREF_VARSTORE_DATA ConsolePref;
- UINTN BufferSize;
- EFI_STATUS Status;
- VOID *Gop;
+ CONSOLE_PREF_VARSTORE_DATA ConsolePref;
+ UINTN BufferSize;
+ EFI_STATUS Status;
+ VOID *Gop;
BufferSize = sizeof (ConsolePref);
- Status = gRT->GetVariable (CONSOLE_PREF_VARIABLE_NAME,
- &gConsolePrefFormSetGuid, NULL, &BufferSize, &ConsolePref);
+ Status = gRT->GetVariable (
+ CONSOLE_PREF_VARIABLE_NAME,
+ &gConsolePrefFormSetGuid,
+ NULL,
+ &BufferSize,
+ &ConsolePref
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: variable '%s' could not be read - bailing!\n", __FUNCTION__,
- CONSOLE_PREF_VARIABLE_NAME));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: variable '%s' could not be read - bailing!\n",
+ __FUNCTION__,
+ CONSOLE_PREF_VARIABLE_NAME
+ ));
return;
}
if (ConsolePref.Console == CONSOLE_PREF_SERIAL) {
- DEBUG ((DEBUG_INFO,
- "%a: serial console preferred - doing nothing\n", __FUNCTION__));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: serial console preferred - doing nothing\n",
+ __FUNCTION__
+ ));
return;
}
@@ -206,9 +244,12 @@ OnReadyToBoot (
//
Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, &Gop);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO,
- "%a: no GOP instances found - doing nothing (%r)\n", __FUNCTION__,
- Status));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: no GOP instances found - doing nothing (%r)\n",
+ __FUNCTION__,
+ Status
+ ));
return;
}
@@ -232,34 +273,46 @@ OnReadyToBoot (
EFI_STATUS
EFIAPI
ConsolePrefDxeEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- CONSOLE_PREF_VARSTORE_DATA ConsolePref;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ CONSOLE_PREF_VARSTORE_DATA ConsolePref;
+ UINTN BufferSize;
//
// Get the current console preference from the ConsolePref variable.
//
BufferSize = sizeof (ConsolePref);
- Status = gRT->GetVariable (CONSOLE_PREF_VARIABLE_NAME,
- &gConsolePrefFormSetGuid, NULL, &BufferSize, &ConsolePref);
+ Status = gRT->GetVariable (
+ CONSOLE_PREF_VARIABLE_NAME,
+ &gConsolePrefFormSetGuid,
+ NULL,
+ &BufferSize,
+ &ConsolePref
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO,
+ DEBUG ((
+ DEBUG_INFO,
"%a: no console preference found, defaulting to graphical\n",
- __FUNCTION__));
+ __FUNCTION__
+ ));
ConsolePref.Console = CONSOLE_PREF_GRAPHICAL;
}
if (!EFI_ERROR (Status) &&
- ConsolePref.Console != CONSOLE_PREF_GRAPHICAL &&
- ConsolePref.Console != CONSOLE_PREF_SERIAL) {
- DEBUG ((DEBUG_WARN, "%a: invalid value for %s, defaulting to graphical\n",
- __FUNCTION__, CONSOLE_PREF_VARIABLE_NAME));
+ (ConsolePref.Console != CONSOLE_PREF_GRAPHICAL) &&
+ (ConsolePref.Console != CONSOLE_PREF_SERIAL))
+ {
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: invalid value for %s, defaulting to graphical\n",
+ __FUNCTION__,
+ CONSOLE_PREF_VARIABLE_NAME
+ ));
ConsolePref.Console = CONSOLE_PREF_GRAPHICAL;
- Status = EFI_INVALID_PARAMETER; // trigger setvar below
+ Status = EFI_INVALID_PARAMETER; // trigger setvar below
}
//
@@ -267,21 +320,33 @@ ConsolePrefDxeEntryPoint (
//
if (EFI_ERROR (Status)) {
ZeroMem (&ConsolePref.Reserved, sizeof (ConsolePref.Reserved));
- Status = gRT->SetVariable (CONSOLE_PREF_VARIABLE_NAME,
+ Status = gRT->SetVariable (
+ CONSOLE_PREF_VARIABLE_NAME,
&gConsolePrefFormSetGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (ConsolePref), &ConsolePref);
+ sizeof (ConsolePref),
+ &ConsolePref
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: gRT->SetVariable () failed - %r\n",
- __FUNCTION__, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: gRT->SetVariable () failed - %r\n",
+ __FUNCTION__,
+ Status
+ ));
return Status;
}
}
- Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
- OnReadyToBoot, NULL, &gEfiEventReadyToBootGuid,
- &mReadyToBootEvent);
+ Status = gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ OnReadyToBoot,
+ NULL,
+ &gEfiEventReadyToBootGuid,
+ &mReadyToBootEvent
+ );
ASSERT_EFI_ERROR (Status);
return InstallHiiPages ();
diff --git a/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.h b/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.h
index a1d3f41e40..a3b952f01a 100644
--- a/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.h
+++ b/EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.h
@@ -12,14 +12,14 @@
#include <Guid/HiiPlatformSetupFormset.h>
#include <Guid/ConsolePrefFormSet.h>
-#define CONSOLE_PREF_GRAPHICAL 0x0
-#define CONSOLE_PREF_SERIAL 0x1
+#define CONSOLE_PREF_GRAPHICAL 0x0
+#define CONSOLE_PREF_SERIAL 0x1
#define CONSOLE_PREF_VARIABLE_NAME L"ConsolePref"
typedef struct {
- UINT8 Console;
- UINT8 Reserved[3];
+ UINT8 Console;
+ UINT8 Reserved[3];
} CONSOLE_PREF_VARSTORE_DATA;
#endif
diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c
index a6ac30c32a..7f7e8c446c 100644
--- a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c
+++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c
@@ -18,22 +18,22 @@
#include "DtPlatformDxe.h"
-extern UINT8 DtPlatformHiiBin[];
-extern UINT8 DtPlatformDxeStrings[];
+extern UINT8 DtPlatformHiiBin[];
+extern UINT8 DtPlatformDxeStrings[];
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
-STATIC HII_VENDOR_DEVICE_PATH mDtPlatformDxeVendorDevicePath = {
+STATIC HII_VENDOR_DEVICE_PATH mDtPlatformDxeVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
DT_PLATFORM_FORMSET_GUID
@@ -42,8 +42,8 @@ STATIC HII_VENDOR_DEVICE_PATH mDtPlatformDxeVendorDevicePath = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
@@ -54,32 +54,39 @@ InstallHiiPages (
VOID
)
{
- EFI_STATUS Status;
- EFI_HII_HANDLE HiiHandle;
- EFI_HANDLE DriverHandle;
+ EFI_STATUS Status;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_HANDLE DriverHandle;
DriverHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mDtPlatformDxeVendorDevicePath,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mDtPlatformDxeVendorDevicePath,
+ NULL
+ );
if (EFI_ERROR (Status)) {
return Status;
}
- HiiHandle = HiiAddPackages (&gDtPlatformFormSetGuid,
- DriverHandle,
- DtPlatformDxeStrings,
- DtPlatformHiiBin,
- NULL);
+ HiiHandle = HiiAddPackages (
+ &gDtPlatformFormSetGuid,
+ DriverHandle,
+ DtPlatformDxeStrings,
+ DtPlatformHiiBin,
+ NULL
+ );
if (HiiHandle == NULL) {
- gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mDtPlatformDxeVendorDevicePath,
- NULL);
+ gBS->UninstallMultipleProtocolInterfaces (
+ DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mDtPlatformDxeVendorDevicePath,
+ NULL
+ );
return EFI_OUT_OF_RESOURCES;
}
+
return EFI_SUCCESS;
}
@@ -99,44 +106,61 @@ InstallHiiPages (
EFI_STATUS
EFIAPI
DtPlatformDxeEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- DT_ACPI_VARSTORE_DATA DtAcpiPref;
- UINTN BufferSize;
- VOID *Dtb;
- UINTN DtbSize;
+ EFI_STATUS Status;
+ DT_ACPI_VARSTORE_DATA DtAcpiPref;
+ UINTN BufferSize;
+ VOID *Dtb;
+ UINTN DtbSize;
- Dtb = NULL;
+ Dtb = NULL;
Status = DtPlatformLoadDtb (&Dtb, &DtbSize);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN,
+ DEBUG ((
+ DEBUG_WARN,
"%a: no DTB blob could be loaded, defaulting to ACPI (Status == %r)\n",
- __FUNCTION__, Status));
+ __FUNCTION__,
+ Status
+ ));
DtAcpiPref.Pref = DT_ACPI_SELECT_ACPI;
} else {
//
// Get the current DT/ACPI preference from the DtAcpiPref variable.
//
BufferSize = sizeof (DtAcpiPref);
- Status = gRT->GetVariable(DT_ACPI_VARIABLE_NAME, &gDtPlatformFormSetGuid,
- NULL, &BufferSize, &DtAcpiPref);
+ Status = gRT->GetVariable (
+ DT_ACPI_VARIABLE_NAME,
+ &gDtPlatformFormSetGuid,
+ NULL,
+ &BufferSize,
+ &DtAcpiPref
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN, "%a: no DT/ACPI preference found, defaulting to %a\n",
- __FUNCTION__, PcdGetBool (PcdDefaultDtPref) ? "DT" : "ACPI"));
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: no DT/ACPI preference found, defaulting to %a\n",
+ __FUNCTION__,
+ PcdGetBool (PcdDefaultDtPref) ? "DT" : "ACPI"
+ ));
DtAcpiPref.Pref = PcdGetBool (PcdDefaultDtPref) ? DT_ACPI_SELECT_DT
: DT_ACPI_SELECT_ACPI;
}
}
if (!EFI_ERROR (Status) &&
- DtAcpiPref.Pref != DT_ACPI_SELECT_ACPI &&
- DtAcpiPref.Pref != DT_ACPI_SELECT_DT) {
- DEBUG ((DEBUG_WARN, "%a: invalid value for %s, defaulting to %a\n",
- __FUNCTION__, DT_ACPI_VARIABLE_NAME,
- PcdGetBool (PcdDefaultDtPref) ? "DT" : "ACPI"));
+ (DtAcpiPref.Pref != DT_ACPI_SELECT_ACPI) &&
+ (DtAcpiPref.Pref != DT_ACPI_SELECT_DT))
+ {
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: invalid value for %s, defaulting to %a\n",
+ __FUNCTION__,
+ DT_ACPI_VARIABLE_NAME,
+ PcdGetBool (PcdDefaultDtPref) ? "DT" : "ACPI"
+ ));
DtAcpiPref.Pref = PcdGetBool (PcdDefaultDtPref) ? DT_ACPI_SELECT_DT
: DT_ACPI_SELECT_ACPI;
Status = EFI_INVALID_PARAMETER; // trigger setvar below
@@ -146,9 +170,13 @@ DtPlatformDxeEntryPoint (
// Write the newly selected default value back to the variable store.
//
if (EFI_ERROR (Status)) {
- Status = gRT->SetVariable(DT_ACPI_VARIABLE_NAME, &gDtPlatformFormSetGuid,
+ Status = gRT->SetVariable (
+ DT_ACPI_VARIABLE_NAME,
+ &gDtPlatformFormSetGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (DtAcpiPref), &DtAcpiPref);
+ sizeof (DtAcpiPref),
+ &DtAcpiPref
+ );
if (EFI_ERROR (Status)) {
goto FreeDtb;
}
@@ -159,12 +187,18 @@ DtPlatformDxeEntryPoint (
// ACPI was selected: install the gEdkiiPlatformHasAcpiGuid GUID as a
// NULL protocol to unlock dispatch of ACPI related drivers.
//
- Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
- &gEdkiiPlatformHasAcpiGuid, NULL, NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEdkiiPlatformHasAcpiGuid,
+ NULL,
+ NULL
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"%a: failed to install gEdkiiPlatformHasAcpiGuid as a protocol\n",
- __FUNCTION__));
+ __FUNCTION__
+ ));
goto FreeDtb;
}
} else if (DtAcpiPref.Pref == DT_ACPI_SELECT_DT) {
@@ -174,8 +208,11 @@ DtPlatformDxeEntryPoint (
//
Status = gBS->InstallConfigurationTable (&gFdtTableGuid, Dtb);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to install FDT configuration table\n",
- __FUNCTION__));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: failed to install FDT configuration table\n",
+ __FUNCTION__
+ ));
goto FreeDtb;
}
} else {
diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.h b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.h
index 89e631e6cd..d6e9f43d72 100644
--- a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.h
+++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.h
@@ -12,14 +12,14 @@
#include <Guid/HiiPlatformSetupFormset.h>
#include <Guid/DtPlatformFormSet.h>
-#define DT_ACPI_SELECT_DT 0x0
-#define DT_ACPI_SELECT_ACPI 0x1
+#define DT_ACPI_SELECT_DT 0x0
+#define DT_ACPI_SELECT_ACPI 0x1
-#define DT_ACPI_VARIABLE_NAME L"DtAcpiPref"
+#define DT_ACPI_VARIABLE_NAME L"DtAcpiPref"
typedef struct {
- UINT8 Pref;
- UINT8 Reserved[3];
+ UINT8 Pref;
+ UINT8 Reserved[3];
} DT_ACPI_VARSTORE_DATA;
#endif
diff --git a/EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.c b/EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.c
index 45bed5e776..b182c77d19 100644
--- a/EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.c
+++ b/EmbeddedPkg/Drivers/FdtClientDxe/FdtClientDxe.c
@@ -26,14 +26,14 @@ STATIC
EFI_STATUS
EFIAPI
GetNodeProperty (
- IN FDT_CLIENT_PROTOCOL *This,
- IN INT32 Node,
- IN CONST CHAR8 *PropertyName,
- OUT CONST VOID **Prop,
- OUT UINT32 *PropSize OPTIONAL
+ IN FDT_CLIENT_PROTOCOL *This,
+ IN INT32 Node,
+ IN CONST CHAR8 *PropertyName,
+ OUT CONST VOID **Prop,
+ OUT UINT32 *PropSize OPTIONAL
)
{
- INT32 Len;
+ INT32 Len;
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Prop != NULL);
@@ -46,6 +46,7 @@ GetNodeProperty (
if (PropSize != NULL) {
*PropSize = Len;
}
+
return EFI_SUCCESS;
}
@@ -53,14 +54,14 @@ STATIC
EFI_STATUS
EFIAPI
SetNodeProperty (
- IN FDT_CLIENT_PROTOCOL *This,
- IN INT32 Node,
- IN CONST CHAR8 *PropertyName,
- IN CONST VOID *Prop,
- IN UINT32 PropSize
+ IN FDT_CLIENT_PROTOCOL *This,
+ IN INT32 Node,
+ IN CONST CHAR8 *PropertyName,
+ IN CONST VOID *Prop,
+ IN UINT32 PropSize
)
{
- INT32 Ret;
+ INT32 Ret;
ASSERT (mDeviceTreeBase != NULL);
@@ -75,11 +76,11 @@ SetNodeProperty (
STATIC
BOOLEAN
IsNodeEnabled (
- INT32 Node
+ INT32 Node
)
{
- CONST CHAR8 *NodeStatus;
- INT32 Len;
+ CONST CHAR8 *NodeStatus;
+ INT32 Len;
//
// A missing status property implies 'ok' so ignore any errors that
@@ -90,12 +91,15 @@ IsNodeEnabled (
if (NodeStatus == NULL) {
return TRUE;
}
- if (Len >= 5 && AsciiStrCmp (NodeStatus, "okay") == 0) {
+
+ if ((Len >= 5) && (AsciiStrCmp (NodeStatus, "okay") == 0)) {
return TRUE;
}
- if (Len >= 3 && AsciiStrCmp (NodeStatus, "ok") == 0) {
+
+ if ((Len >= 3) && (AsciiStrCmp (NodeStatus, "ok") == 0)) {
return TRUE;
}
+
return FALSE;
}
@@ -103,20 +107,20 @@ STATIC
EFI_STATUS
EFIAPI
FindNextCompatibleNode (
- IN FDT_CLIENT_PROTOCOL *This,
- IN CONST CHAR8 *CompatibleString,
- IN INT32 PrevNode,
- OUT INT32 *Node
+ IN FDT_CLIENT_PROTOCOL *This,
+ IN CONST CHAR8 *CompatibleString,
+ IN INT32 PrevNode,
+ OUT INT32 *Node
)
{
- INT32 Prev, Next;
- CONST CHAR8 *Type, *Compatible;
- INT32 Len;
+ INT32 Prev, Next;
+ CONST CHAR8 *Type, *Compatible;
+ INT32 Len;
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Node != NULL);
- for (Prev = PrevNode;; Prev = Next) {
+ for (Prev = PrevNode; ; Prev = Next) {
Next = fdt_next_node (mDeviceTreeBase, Prev, NULL);
if (Next < 0) {
break;
@@ -136,13 +140,15 @@ FindNextCompatibleNode (
// compatible strings so check each one
//
for (Compatible = Type; Compatible < Type + Len && *Compatible;
- Compatible += 1 + AsciiStrLen (Compatible)) {
+ Compatible += 1 + AsciiStrLen (Compatible))
+ {
if (AsciiStrCmp (CompatibleString, Compatible) == 0) {
*Node = Next;
return EFI_SUCCESS;
}
}
}
+
return EFI_NOT_FOUND;
}
@@ -150,9 +156,9 @@ STATIC
EFI_STATUS
EFIAPI
FindCompatibleNode (
- IN FDT_CLIENT_PROTOCOL *This,
- IN CONST CHAR8 *CompatibleString,
- OUT INT32 *Node
+ IN FDT_CLIENT_PROTOCOL *This,
+ IN CONST CHAR8 *CompatibleString,
+ OUT INT32 *Node
)
{
return FindNextCompatibleNode (This, CompatibleString, 0, Node);
@@ -162,15 +168,15 @@ STATIC
EFI_STATUS
EFIAPI
FindCompatibleNodeProperty (
- IN FDT_CLIENT_PROTOCOL *This,
- IN CONST CHAR8 *CompatibleString,
- IN CONST CHAR8 *PropertyName,
- OUT CONST VOID **Prop,
- OUT UINT32 *PropSize OPTIONAL
+ IN FDT_CLIENT_PROTOCOL *This,
+ IN CONST CHAR8 *CompatibleString,
+ IN CONST CHAR8 *PropertyName,
+ OUT CONST VOID **Prop,
+ OUT UINT32 *PropSize OPTIONAL
)
{
- EFI_STATUS Status;
- INT32 Node;
+ EFI_STATUS Status;
+ INT32 Node;
Status = FindCompatibleNode (This, CompatibleString, &Node);
if (EFI_ERROR (Status)) {
@@ -184,15 +190,15 @@ STATIC
EFI_STATUS
EFIAPI
FindCompatibleNodeReg (
- IN FDT_CLIENT_PROTOCOL *This,
- IN CONST CHAR8 *CompatibleString,
- OUT CONST VOID **Reg,
- OUT UINTN *AddressCells,
- OUT UINTN *SizeCells,
- OUT UINT32 *RegSize
+ IN FDT_CLIENT_PROTOCOL *This,
+ IN CONST CHAR8 *CompatibleString,
+ OUT CONST VOID **Reg,
+ OUT UINTN *AddressCells,
+ OUT UINTN *SizeCells,
+ OUT UINT32 *RegSize
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (RegSize != NULL);
@@ -201,21 +207,30 @@ FindCompatibleNodeReg (
// 8 byte quantities for base and size, respectively.
// TODO use #cells root properties instead
//
- Status = FindCompatibleNodeProperty (This, CompatibleString, "reg", Reg,
- RegSize);
+ Status = FindCompatibleNodeProperty (
+ This,
+ CompatibleString,
+ "reg",
+ Reg,
+ RegSize
+ );
if (EFI_ERROR (Status)) {
return Status;
}
if ((*RegSize % 16) != 0) {
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"%a: '%a' compatible node has invalid 'reg' property (size == 0x%x)\n",
- __FUNCTION__, CompatibleString, *RegSize));
+ __FUNCTION__,
+ CompatibleString,
+ *RegSize
+ ));
return EFI_NOT_FOUND;
}
*AddressCells = 2;
- *SizeCells = 2;
+ *SizeCells = 2;
return EFI_SUCCESS;
}
@@ -224,24 +239,24 @@ STATIC
EFI_STATUS
EFIAPI
FindNextMemoryNodeReg (
- IN FDT_CLIENT_PROTOCOL *This,
- IN INT32 PrevNode,
- OUT INT32 *Node,
- OUT CONST VOID **Reg,
- OUT UINTN *AddressCells,
- OUT UINTN *SizeCells,
- OUT UINT32 *RegSize
+ IN FDT_CLIENT_PROTOCOL *This,
+ IN INT32 PrevNode,
+ OUT INT32 *Node,
+ OUT CONST VOID **Reg,
+ OUT UINTN *AddressCells,
+ OUT UINTN *SizeCells,
+ OUT UINT32 *RegSize
)
{
- INT32 Prev, Next;
- CONST CHAR8 *DeviceType;
- INT32 Len;
- EFI_STATUS Status;
+ INT32 Prev, Next;
+ CONST CHAR8 *DeviceType;
+ INT32 Len;
+ EFI_STATUS Status;
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Node != NULL);
- for (Prev = PrevNode;; Prev = Next) {
+ for (Prev = PrevNode; ; Prev = Next) {
Next = fdt_next_node (mDeviceTreeBase, Prev, NULL);
if (Next < 0) {
break;
@@ -253,7 +268,7 @@ FindNextMemoryNodeReg (
}
DeviceType = fdt_getprop (mDeviceTreeBase, Next, "device_type", &Len);
- if (DeviceType != NULL && AsciiStrCmp (DeviceType, "memory") == 0) {
+ if ((DeviceType != NULL) && (AsciiStrCmp (DeviceType, "memory") == 0)) {
//
// Get the 'reg' property of this memory node. For now, we will assume
// 8 byte quantities for base and size, respectively.
@@ -261,24 +276,31 @@ FindNextMemoryNodeReg (
//
Status = GetNodeProperty (This, Next, "reg", Reg, RegSize);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN,
+ DEBUG ((
+ DEBUG_WARN,
"%a: ignoring memory node with no 'reg' property\n",
- __FUNCTION__));
+ __FUNCTION__
+ ));
continue;
}
+
if ((*RegSize % 16) != 0) {
- DEBUG ((DEBUG_WARN,
+ DEBUG ((
+ DEBUG_WARN,
"%a: ignoring memory node with invalid 'reg' property (size == 0x%x)\n",
- __FUNCTION__, *RegSize));
+ __FUNCTION__,
+ *RegSize
+ ));
continue;
}
- *Node = Next;
+ *Node = Next;
*AddressCells = 2;
- *SizeCells = 2;
+ *SizeCells = 2;
return EFI_SUCCESS;
}
}
+
return EFI_NOT_FOUND;
}
@@ -286,27 +308,34 @@ STATIC
EFI_STATUS
EFIAPI
FindMemoryNodeReg (
- IN FDT_CLIENT_PROTOCOL *This,
- OUT INT32 *Node,
- OUT CONST VOID **Reg,
- OUT UINTN *AddressCells,
- OUT UINTN *SizeCells,
- OUT UINT32 *RegSize
+ IN FDT_CLIENT_PROTOCOL *This,
+ OUT INT32 *Node,
+ OUT CONST VOID **Reg,
+ OUT UINTN *AddressCells,
+ OUT UINTN *SizeCells,
+ OUT UINT32 *RegSize
)
{
- return FindNextMemoryNodeReg (This, 0, Node, Reg, AddressCells, SizeCells,
- RegSize);
+ return FindNextMemoryNodeReg (
+ This,
+ 0,
+ Node,
+ Reg,
+ AddressCells,
+ SizeCells,
+ RegSize
+ );
}
STATIC
EFI_STATUS
EFIAPI
GetOrInsertChosenNode (
- IN FDT_CLIENT_PROTOCOL *This,
- OUT INT32 *Node
+ IN FDT_CLIENT_PROTOCOL *This,
+ OUT INT32 *Node
)
{
- INT32 NewNode;
+ INT32 NewNode;
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Node != NULL);
@@ -325,7 +354,7 @@ GetOrInsertChosenNode (
return EFI_SUCCESS;
}
-STATIC FDT_CLIENT_PROTOCOL mFdtClientProtocol = {
+STATIC FDT_CLIENT_PROTOCOL mFdtClientProtocol = {
GetNodeProperty,
SetNodeProperty,
FindCompatibleNode,
@@ -341,13 +370,13 @@ STATIC
VOID
EFIAPI
OnPlatformHasDeviceTree (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- VOID *Interface;
- VOID *DeviceTreeBase;
+ EFI_STATUS Status;
+ VOID *Interface;
+ VOID *DeviceTreeBase;
Status = gBS->LocateProtocol (
&gEdkiiPlatformHasDeviceTreeGuid,
@@ -374,25 +403,30 @@ OnPlatformHasDeviceTree (
EFI_STATUS
EFIAPI
InitializeFdtClientDxe (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- VOID *Hob;
- VOID *DeviceTreeBase;
- EFI_STATUS Status;
- EFI_EVENT PlatformHasDeviceTreeEvent;
- VOID *Registration;
+ VOID *Hob;
+ VOID *DeviceTreeBase;
+ EFI_STATUS Status;
+ EFI_EVENT PlatformHasDeviceTreeEvent;
+ VOID *Registration;
Hob = GetFirstGuidHob (&gFdtHobGuid);
- if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64)) {
+ if ((Hob == NULL) || (GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64))) {
return EFI_NOT_FOUND;
}
+
DeviceTreeBase = (VOID *)(UINTN)*(UINT64 *)GET_GUID_HOB_DATA (Hob);
if (fdt_check_header (DeviceTreeBase) != 0) {
- DEBUG ((DEBUG_ERROR, "%a: No DTB found @ 0x%p\n", __FUNCTION__,
- DeviceTreeBase));
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: No DTB found @ 0x%p\n",
+ __FUNCTION__,
+ DeviceTreeBase
+ ));
return EFI_NOT_FOUND;
}
diff --git a/EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.c b/EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.c
index d7ed8c9ebc..4e7a5698c1 100644
--- a/EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.c
+++ b/EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.c
@@ -107,15 +107,15 @@ STATIC
EFI_STATUS
EFIAPI
NonCoherentIoMmuMap (
- IN EDKII_IOMMU_PROTOCOL *This,
- IN EDKII_IOMMU_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN EDKII_IOMMU_PROTOCOL *This,
+ IN EDKII_IOMMU_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
)
{
- DMA_MAP_OPERATION DmaOperation;
+ DMA_MAP_OPERATION DmaOperation;
switch (Operation) {
case EdkiiIoMmuOperationBusMasterRead:
@@ -138,8 +138,13 @@ NonCoherentIoMmuMap (
return EFI_INVALID_PARAMETER;
}
- return DmaMap (DmaOperation, HostAddress, NumberOfBytes,
- DeviceAddress, Mapping);
+ return DmaMap (
+ DmaOperation,
+ HostAddress,
+ NumberOfBytes,
+ DeviceAddress,
+ Mapping
+ );
}
/**
@@ -158,8 +163,8 @@ STATIC
EFI_STATUS
EFIAPI
NonCoherentIoMmuUnmap (
- IN EDKII_IOMMU_PROTOCOL *This,
- IN VOID *Mapping
+ IN EDKII_IOMMU_PROTOCOL *This,
+ IN VOID *Mapping
)
{
return DmaUnmap (Mapping);
@@ -191,12 +196,12 @@ STATIC
EFI_STATUS
EFIAPI
NonCoherentIoMmuAllocateBuffer (
- IN EDKII_IOMMU_PROTOCOL *This,
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- IN OUT VOID **HostAddress,
- IN UINT64 Attributes
+ IN EDKII_IOMMU_PROTOCOL *This,
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN OUT VOID **HostAddress,
+ IN UINT64 Attributes
)
{
return DmaAllocateBuffer (MemoryType, Pages, HostAddress);
@@ -219,9 +224,9 @@ STATIC
EFI_STATUS
EFIAPI
NonCoherentIoMmuFreeBuffer (
- IN EDKII_IOMMU_PROTOCOL *This,
- IN UINTN Pages,
- IN VOID *HostAddress
+ IN EDKII_IOMMU_PROTOCOL *This,
+ IN UINTN Pages,
+ IN VOID *HostAddress
)
{
return DmaFreeBuffer (Pages, HostAddress);
@@ -236,15 +241,17 @@ STATIC EDKII_IOMMU_PROTOCOL mNonCoherentIoMmuOps = {
NonCoherentIoMmuFreeBuffer,
};
-
EFI_STATUS
EFIAPI
NonCoherentIoMmuDxeEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- return gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
- &gEdkiiIoMmuProtocolGuid, &mNonCoherentIoMmuOps,
- NULL);
+ return gBS->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEdkiiIoMmuProtocolGuid,
+ &mNonCoherentIoMmuOps,
+ NULL
+ );
}
diff --git a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.c b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.c
index 53d62e2c47..7159c0e817 100644
--- a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.c
+++ b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.c
@@ -21,14 +21,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardCompo
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) VirtualKeyboardComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) VirtualKeyboardComponentNameGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)VirtualKeyboardComponentNameGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)VirtualKeyboardComponentNameGetControllerName,
"en"
};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVirtualKeyboardDriverNameTable[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVirtualKeyboardDriverNameTable[] = {
{
"eng;en",
L"Virtual Keyboard Driver"
@@ -170,11 +169,11 @@ VirtualKeyboardComponentNameGetDriverName (
EFI_STATUS
EFIAPI
VirtualKeyboardComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
diff --git a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.h b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.h
index 7ca28a7f15..7650e53821 100644
--- a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.h
+++ b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/ComponentName.h
@@ -10,13 +10,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _VIRTUAL_KEYBOARD_COMPONENT_NAME_H_
#define _VIRTUAL_KEYBOARD_COMPONENT_NAME_H_
-
extern EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2;
//
// EFI Component Name Functions
//
+
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -64,7 +64,6 @@ VirtualKeyboardComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -136,12 +135,11 @@ VirtualKeyboardComponentNameGetDriverName (
EFI_STATUS
EFIAPI
VirtualKeyboardComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-
#endif
diff --git a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c
index e9d0b72ee6..4bbc3ead2c 100644
--- a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c
+++ b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.c
@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// RAM Keyboard Driver Binding Protocol Instance
//
-EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding = {
VirtualKeyboardDriverBindingSupported,
VirtualKeyboardDriverBindingStart,
VirtualKeyboardDriverBindingStop,
@@ -45,13 +45,13 @@ VirtualKeyboardDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
+ EFI_STATUS Status;
+ PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
Status = gBS->OpenProtocol (
Controller,
&gPlatformVirtualKeyboardProtocolGuid,
- (VOID **) &PlatformVirtual,
+ (VOID **)&PlatformVirtual,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -59,6 +59,7 @@ VirtualKeyboardDriverBindingSupported (
if (EFI_ERROR (Status)) {
return Status;
}
+
gBS->CloseProtocol (
Controller,
&gPlatformVirtualKeyboardProtocolGuid,
@@ -88,14 +89,14 @@ VirtualKeyboardDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
- PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
+ EFI_STATUS Status;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
Status = gBS->OpenProtocol (
Controller,
&gPlatformVirtualKeyboardProtocolGuid,
- (VOID **) &PlatformVirtual,
+ (VOID **)&PlatformVirtual,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -107,7 +108,7 @@ VirtualKeyboardDriverBindingStart (
//
// Allocate the private device structure
//
- VirtualKeyboardPrivate = (VIRTUAL_KEYBOARD_DEV *) AllocateZeroPool (sizeof (VIRTUAL_KEYBOARD_DEV));
+ VirtualKeyboardPrivate = (VIRTUAL_KEYBOARD_DEV *)AllocateZeroPool (sizeof (VIRTUAL_KEYBOARD_DEV));
if (VirtualKeyboardPrivate == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
@@ -116,20 +117,20 @@ VirtualKeyboardDriverBindingStart (
//
// Initialize the private device structure
//
- VirtualKeyboardPrivate->Signature = VIRTUAL_KEYBOARD_DEV_SIGNATURE;
- VirtualKeyboardPrivate->Handle = Controller;
- VirtualKeyboardPrivate->PlatformVirtual = PlatformVirtual;
- VirtualKeyboardPrivate->Queue.Front = 0;
- VirtualKeyboardPrivate->Queue.Rear = 0;
- VirtualKeyboardPrivate->QueueForNotify.Front = 0;
- VirtualKeyboardPrivate->QueueForNotify.Rear = 0;
+ VirtualKeyboardPrivate->Signature = VIRTUAL_KEYBOARD_DEV_SIGNATURE;
+ VirtualKeyboardPrivate->Handle = Controller;
+ VirtualKeyboardPrivate->PlatformVirtual = PlatformVirtual;
+ VirtualKeyboardPrivate->Queue.Front = 0;
+ VirtualKeyboardPrivate->Queue.Rear = 0;
+ VirtualKeyboardPrivate->QueueForNotify.Front = 0;
+ VirtualKeyboardPrivate->QueueForNotify.Rear = 0;
VirtualKeyboardPrivate->SimpleTextIn.Reset = VirtualKeyboardReset;
VirtualKeyboardPrivate->SimpleTextIn.ReadKeyStroke = VirtualKeyboardReadKeyStroke;
- VirtualKeyboardPrivate->SimpleTextInputEx.Reset = VirtualKeyboardResetEx;
- VirtualKeyboardPrivate->SimpleTextInputEx.ReadKeyStrokeEx = VirtualKeyboardReadKeyStrokeEx;
- VirtualKeyboardPrivate->SimpleTextInputEx.SetState = VirtualKeyboardSetState;
+ VirtualKeyboardPrivate->SimpleTextInputEx.Reset = VirtualKeyboardResetEx;
+ VirtualKeyboardPrivate->SimpleTextInputEx.ReadKeyStrokeEx = VirtualKeyboardReadKeyStrokeEx;
+ VirtualKeyboardPrivate->SimpleTextInputEx.SetState = VirtualKeyboardSetState;
VirtualKeyboardPrivate->SimpleTextInputEx.RegisterKeyNotify = VirtualKeyboardRegisterKeyNotify;
VirtualKeyboardPrivate->SimpleTextInputEx.UnregisterKeyNotify = VirtualKeyboardUnregisterKeyNotify;
@@ -162,6 +163,7 @@ VirtualKeyboardDriverBindingStart (
(VirtualKeyboardPrivate->SimpleTextIn).WaitForKey = NULL;
goto Done;
}
+
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
@@ -215,13 +217,14 @@ VirtualKeyboardDriverBindingStart (
// Reset the keyboard device
//
Status = VirtualKeyboardPrivate->SimpleTextInputEx.Reset (
- &VirtualKeyboardPrivate->SimpleTextInputEx,
- FALSE
- );
+ &VirtualKeyboardPrivate->SimpleTextInputEx,
+ FALSE
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "[KBD]Reset Failed. Status - %r\n", Status));
goto Done;
}
+
//
// Install protocol interfaces for the keyboard device.
//
@@ -256,6 +259,7 @@ Done:
if (VirtualKeyboardPrivate->TimerEvent != NULL) {
gBS->CloseEvent (VirtualKeyboardPrivate->TimerEvent);
}
+
FreePool (VirtualKeyboardPrivate);
}
}
@@ -297,7 +301,6 @@ VirtualKeyboardDriverBindingStop (
return EFI_SUCCESS;
}
-
/**
Enqueue the key.
@@ -310,8 +313,8 @@ VirtualKeyboardDriverBindingStop (
**/
EFI_STATUS
Enqueue (
- IN SIMPLE_QUEUE *Queue,
- IN EFI_KEY_DATA *KeyData
+ IN SIMPLE_QUEUE *Queue,
+ IN EFI_KEY_DATA *KeyData
)
{
if ((Queue->Rear + 1) % QUEUE_MAX_COUNT == Queue->Front) {
@@ -336,8 +339,8 @@ Enqueue (
**/
EFI_STATUS
Dequeue (
- IN SIMPLE_QUEUE *Queue,
- IN EFI_KEY_DATA *KeyData
+ IN SIMPLE_QUEUE *Queue,
+ IN EFI_KEY_DATA *KeyData
)
{
if (Queue->Front == Queue->Rear) {
@@ -345,7 +348,7 @@ Dequeue (
}
CopyMem (KeyData, &Queue->Buffer[Queue->Front], sizeof (EFI_KEY_DATA));
- Queue->Front = (Queue->Front + 1) % QUEUE_MAX_COUNT;
+ Queue->Front = (Queue->Front + 1) % QUEUE_MAX_COUNT;
return EFI_SUCCESS;
}
@@ -361,7 +364,7 @@ Dequeue (
**/
EFI_STATUS
CheckQueue (
- IN SIMPLE_QUEUE *Queue
+ IN SIMPLE_QUEUE *Queue
)
{
if (Queue->Front == Queue->Rear) {
@@ -386,7 +389,7 @@ VirtualKeyboardCheckForKey (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
)
{
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
@@ -404,14 +407,15 @@ VirtualKeyboardCheckForKey (
**/
EFI_STATUS
VirtualKeyboardFreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
+ IN OUT LIST_ENTRY *ListHead
)
{
- VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
+ VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
if (ListHead == NULL) {
return EFI_INVALID_PARAMETER;
}
+
while (!IsListEmpty (ListHead)) {
NotifyNode = CR (
ListHead->ForwardLink,
@@ -450,7 +454,8 @@ IsKeyRegistered (
ASSERT (RegsiteredData != NULL && InputData != NULL);
if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
- (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
+ (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
+ {
return FALSE;
}
@@ -459,16 +464,18 @@ IsKeyRegistered (
// these state could be ignored.
//
if ((RegsiteredData->KeyState.KeyShiftState != 0) &&
- (RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState)) {
+ (RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState))
+ {
return FALSE;
}
+
if ((RegsiteredData->KeyState.KeyToggleState != 0) &&
- (RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState)) {
+ (RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState))
+ {
return FALSE;
}
return TRUE;
-
}
/**
@@ -482,8 +489,8 @@ IsKeyRegistered (
VOID
EFIAPI
VirtualKeyboardWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -519,21 +526,21 @@ VirtualKeyboardWaitForKey (
VOID
EFIAPI
VirtualKeyboardWaitForKeyEx (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (Context);
VirtualKeyboardWaitForKey (Event, &VirtualKeyboardPrivate->SimpleTextIn);
-
}
//
// EFI Simple Text In Protocol Functions
//
+
/**
Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE)
then do some extra keyboard validations.
@@ -553,9 +560,9 @@ VirtualKeyboardReset (
IN BOOLEAN ExtendedVerification
)
{
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
@@ -565,7 +572,8 @@ VirtualKeyboardReset (
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
if (VirtualKeyboardPrivate->PlatformVirtual &&
- VirtualKeyboardPrivate->PlatformVirtual->Reset) {
+ VirtualKeyboardPrivate->PlatformVirtual->Reset)
+ {
Status = VirtualKeyboardPrivate->PlatformVirtual->Reset ();
} else {
Status = EFI_INVALID_PARAMETER;
@@ -597,16 +605,16 @@ VirtualKeyboardResetEx (
IN BOOLEAN ExtendedVerification
)
{
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
Status = VirtualKeyboardPrivate->SimpleTextIn.Reset (
- &VirtualKeyboardPrivate->SimpleTextIn,
- ExtendedVerification
- );
+ &VirtualKeyboardPrivate->SimpleTextIn,
+ ExtendedVerification
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -616,7 +624,6 @@ VirtualKeyboardResetEx (
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
-
}
/**
@@ -638,11 +645,12 @@ VirtualKeyboardResetEx (
EFI_STATUS
KeyboardReadKeyStrokeWorker (
IN VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate,
- OUT EFI_KEY_DATA *KeyData
+ OUT EFI_KEY_DATA *KeyData
)
{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_TPL OldTpl;
+
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -700,9 +708,9 @@ VirtualKeyboardReadKeyStroke (
OUT EFI_INPUT_KEY *Key
)
{
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
- EFI_STATUS Status;
- EFI_KEY_DATA KeyData;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ EFI_STATUS Status;
+ EFI_KEY_DATA KeyData;
VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
@@ -715,12 +723,14 @@ VirtualKeyboardReadKeyStroke (
// Convert the Ctrl+[a-z] to Ctrl+[1-26]
//
if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
- if (KeyData.Key.UnicodeChar >= L'a' &&
- KeyData.Key.UnicodeChar <= L'z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'a' + 1);
- } else if (KeyData.Key.UnicodeChar >= L'A' &&
- KeyData.Key.UnicodeChar <= L'Z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'A' + 1);
+ if ((KeyData.Key.UnicodeChar >= L'a') &&
+ (KeyData.Key.UnicodeChar <= L'z'))
+ {
+ KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'a' + 1);
+ } else if ((KeyData.Key.UnicodeChar >= L'A') &&
+ (KeyData.Key.UnicodeChar <= L'Z'))
+ {
+ KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'A' + 1);
}
}
@@ -747,11 +757,11 @@ VirtualKeyboardReadKeyStroke (
EFI_STATUS
EFIAPI
VirtualKeyboardReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
)
{
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
@@ -760,7 +770,6 @@ VirtualKeyboardReadKeyStrokeEx (
VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
return KeyboardReadKeyStrokeWorker (VirtualKeyboardPrivate, KeyData);
-
}
/**
@@ -822,16 +831,17 @@ VirtualKeyboardRegisterKeyNotify (
OUT VOID **NotifyHandle
)
{
- EFI_STATUS Status;
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
- EFI_TPL OldTpl;
- VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
- LIST_ENTRY *Link;
- VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
-
- if (KeyData == NULL ||
- NotifyHandle == NULL ||
- KeyNotificationFunction == NULL) {
+ EFI_STATUS Status;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ EFI_TPL OldTpl;
+ VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
+ LIST_ENTRY *Link;
+ VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+
+ if ((KeyData == NULL) ||
+ (NotifyHandle == NULL) ||
+ (KeyNotificationFunction == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -848,7 +858,8 @@ VirtualKeyboardRegisterKeyNotify (
//
for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
Link != &VirtualKeyboardPrivate->NotifyList;
- Link = Link->ForwardLink) {
+ Link = Link->ForwardLink)
+ {
CurrentNotify = CR (
Link,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY,
@@ -858,7 +869,7 @@ VirtualKeyboardRegisterKeyNotify (
if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
*NotifyHandle = CurrentNotify;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
goto Exit;
}
}
@@ -868,7 +879,7 @@ VirtualKeyboardRegisterKeyNotify (
// Allocate resource to save the notification function
//
- NewNotify = (VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY));
+ NewNotify = (VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *)AllocateZeroPool (sizeof (VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY));
if (NewNotify == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
@@ -879,8 +890,8 @@ VirtualKeyboardRegisterKeyNotify (
CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));
InsertTailList (&VirtualKeyboardPrivate->NotifyList, &NewNotify->NotifyEntry);
- *NotifyHandle = NewNotify;
- Status = EFI_SUCCESS;
+ *NotifyHandle = NewNotify;
+ Status = EFI_SUCCESS;
Exit:
//
@@ -888,7 +899,6 @@ Exit:
//
gBS->RestoreTPL (OldTpl);
return Status;
-
}
/**
@@ -910,11 +920,11 @@ VirtualKeyboardUnregisterKeyNotify (
IN VOID *NotificationHandle
)
{
- EFI_STATUS Status;
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
- EFI_TPL OldTpl;
- LIST_ENTRY *Link;
- VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_STATUS Status;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ EFI_TPL OldTpl;
+ LIST_ENTRY *Link;
+ VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
//
// Check incoming notification handle
@@ -923,8 +933,9 @@ VirtualKeyboardUnregisterKeyNotify (
return EFI_INVALID_PARAMETER;
}
- if (((VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature !=
- VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {
+ if (((VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *)NotificationHandle)->Signature !=
+ VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE)
+ {
return EFI_INVALID_PARAMETER;
}
@@ -937,7 +948,8 @@ VirtualKeyboardUnregisterKeyNotify (
for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
Link != &VirtualKeyboardPrivate->NotifyList;
- Link = Link->ForwardLink) {
+ Link = Link->ForwardLink)
+ {
CurrentNotify = CR (
Link,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY,
@@ -982,8 +994,8 @@ Exit:
VOID
EFIAPI
VirtualKeyboardTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
EFI_TPL OldTpl;
@@ -1001,14 +1013,17 @@ VirtualKeyboardTimerHandler (
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
if (VirtualKeyboardPrivate->PlatformVirtual &&
- VirtualKeyboardPrivate->PlatformVirtual->Query) {
+ VirtualKeyboardPrivate->PlatformVirtual->Query)
+ {
if (VirtualKeyboardPrivate->PlatformVirtual->Query (&VirtualKey) ==
- FALSE) {
+ FALSE)
+ {
goto Exit;
}
+
// Found key
- KeyData.Key.ScanCode = VirtualKey.Key.ScanCode;
- KeyData.Key.UnicodeChar = VirtualKey.Key.UnicodeChar;
+ KeyData.Key.ScanCode = VirtualKey.Key.ScanCode;
+ KeyData.Key.UnicodeChar = VirtualKey.Key.UnicodeChar;
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
KeyData.KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
if (VirtualKeyboardPrivate->PlatformVirtual->Clear) {
@@ -1023,7 +1038,8 @@ VirtualKeyboardTimerHandler (
//
for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
Link != &VirtualKeyboardPrivate->NotifyList;
- Link = Link->ForwardLink) {
+ Link = Link->ForwardLink)
+ {
CurrentNotify = CR (
Link,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY,
@@ -1060,19 +1076,19 @@ Exit:
VOID
EFIAPI
KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
- EFI_KEY_DATA KeyData;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
+ EFI_KEY_DATA KeyData;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NotifyList;
+ VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
+ EFI_TPL OldTpl;
- VirtualKeyboardPrivate = (VIRTUAL_KEYBOARD_DEV *) Context;
+ VirtualKeyboardPrivate = (VIRTUAL_KEYBOARD_DEV *)Context;
//
// Invoke notification functions.
@@ -1091,10 +1107,13 @@ KeyNotifyProcessHandler (
if (EFI_ERROR (Status)) {
break;
}
+
for (Link = GetFirstNode (NotifyList);
!IsNull (NotifyList, Link);
- Link = GetNextNode (NotifyList, Link)) {
- CurrentNotify = CR (Link,
+ Link = GetNextNode (NotifyList, Link))
+ {
+ CurrentNotify = CR (
+ Link,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY,
NotifyEntry,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
@@ -1119,12 +1138,12 @@ KeyNotifyProcessHandler (
**/
EFI_STATUS
EFIAPI
-InitializeVirtualKeyboard(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+InitializeVirtualKeyboard (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install driver model protocol(s).
diff --git a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.h b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.h
index d77bfe0167..f72bd6f9c6 100644
--- a/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.h
+++ b/EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboard.h
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _VIRTUAL_KEYBOARD_H_
#define _VIRTUAL_KEYBOARD_H_
-
#include <Guid/StatusCodeDataTypeId.h>
#include <Protocol/DevicePath.h>
#include <Protocol/PlatformVirtualKeyboard.h>
@@ -31,70 +30,69 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Driver Binding Externs
//
-extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2;
-
+extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
+extern EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2;
//
// VIRTUAL Keyboard Defines
//
-#define CHAR_SCANCODE 0xe0
-#define CHAR_ESC 0x1b
+#define CHAR_SCANCODE 0xe0
+#define CHAR_ESC 0x1b
-#define KEYBOARD_TIMEOUT 65536 // 0.07s
-#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
-#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
-#define KEYBOARD_TIMER_INTERVAL 500000 // 0.5s
+#define KEYBOARD_TIMEOUT 65536 // 0.07s
+#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
+#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
+#define KEYBOARD_TIMER_INTERVAL 500000 // 0.5s
-#define QUEUE_MAX_COUNT 32
+#define QUEUE_MAX_COUNT 32
-#define KEYBOARD_SCAN_CODE_MAX_COUNT 32
+#define KEYBOARD_SCAN_CODE_MAX_COUNT 32
//
// VIRTUAL Keyboard Device Structure
//
-#define VIRTUAL_KEYBOARD_DEV_SIGNATURE SIGNATURE_32 ('V', 'K', 'B', 'D')
-#define VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('v', 'k', 'c', 'n')
+#define VIRTUAL_KEYBOARD_DEV_SIGNATURE SIGNATURE_32 ('V', 'K', 'B', 'D')
+#define VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('v', 'k', 'c', 'n')
typedef struct _VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY {
- UINTN Signature;
- EFI_KEY_DATA KeyData;
- EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
- LIST_ENTRY NotifyEntry;
+ UINTN Signature;
+ EFI_KEY_DATA KeyData;
+ EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
+ LIST_ENTRY NotifyEntry;
} VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY;
typedef struct {
- UINTN Front;
- UINTN Rear;
- EFI_KEY_DATA Buffer[QUEUE_MAX_COUNT];
+ UINTN Front;
+ UINTN Rear;
+ EFI_KEY_DATA Buffer[QUEUE_MAX_COUNT];
} SIMPLE_QUEUE;
typedef struct {
- UINT8 Buffer[KEYBOARD_SCAN_CODE_MAX_COUNT];
- UINTN Head;
- UINTN Tail;
+ UINT8 Buffer[KEYBOARD_SCAN_CODE_MAX_COUNT];
+ UINTN Head;
+ UINTN Tail;
} SCAN_CODE_QUEUE;
typedef struct {
- UINTN Signature;
- EFI_HANDLE Handle;
- PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInputEx;
+ UINTN Signature;
+ EFI_HANDLE Handle;
+ PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInputEx;
//
// Buffer storing EFI_KEY_DATA
//
- SIMPLE_QUEUE Queue;
- SIMPLE_QUEUE QueueForNotify;
+ SIMPLE_QUEUE Queue;
+ SIMPLE_QUEUE QueueForNotify;
//
// Notification Function List
//
- LIST_ENTRY NotifyList;
- EFI_EVENT KeyNotifyProcessEvent;
- EFI_EVENT TimerEvent;
+ LIST_ENTRY NotifyList;
+ EFI_EVENT KeyNotifyProcessEvent;
+ EFI_EVENT TimerEvent;
} VIRTUAL_KEYBOARD_DEV;
#define VIRTUAL_KEYBOARD_DEV_FROM_THIS(a) CR (a, VIRTUAL_KEYBOARD_DEV, SimpleTextIn, VIRTUAL_KEYBOARD_DEV_SIGNATURE)
@@ -108,7 +106,7 @@ typedef struct {
//
// Global Variables
//
-extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
+extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
//
// Driver Binding Protocol functions
@@ -222,7 +220,6 @@ VirtualKeyboardComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
-
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -294,17 +291,17 @@ VirtualKeyboardComponentNameGetDriverName (
EFI_STATUS
EFIAPI
VirtualKeyboardComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-
//
// Simple Text Input Protocol functions
//
+
/**
Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE) then do some extra keyboard validations.
@@ -406,6 +403,7 @@ VirtualKeyboardUnregisterKeyNotify (
//
// Private worker functions
//
+
/**
Free keyboard notify list.
@@ -417,7 +415,7 @@ VirtualKeyboardUnregisterKeyNotify (
**/
EFI_STATUS
VirtualKeyboardFreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
+ IN OUT LIST_ENTRY *ListHead
);
/**
@@ -478,8 +476,8 @@ VirtualKeyboardWaitForKeyEx (
VOID
EFIAPI
VirtualKeyboardTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -491,8 +489,8 @@ VirtualKeyboardTimerHandler (
VOID
EFIAPI
KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -530,8 +528,8 @@ VirtualKeyboardReadKeyStroke (
EFI_STATUS
EFIAPI
VirtualKeyboardReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
);
#endif /* _VIRTUAL_KEYBOARD_H_ */
diff --git a/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c b/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c
index 089b1f6942..8d5db6b277 100644
--- a/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c
+++ b/EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.c
@@ -15,7 +15,7 @@
#include <Protocol/MonotonicCounter.h>
-UINT64 gCurrentMonotonicCount = 0;
+UINT64 gCurrentMonotonicCount = 0;
EFI_STATUS
EFIAPI
@@ -48,7 +48,6 @@ GetNextHighMonotonicCount (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
MonotonicCounterDriverInitialize (
@@ -60,7 +59,7 @@ MonotonicCounterDriverInitialize (
EFI_HANDLE Handle = NULL;
// Make sure the Monotonic Counter Architectural Protocol is not already installed in the system
- ASSERT_PROTOCOL_ALREADY_INSTALLED(NULL, &gEfiMonotonicCounterArchProtocolGuid);
+ ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiMonotonicCounterArchProtocolGuid);
// Fill in the EFI Boot Services and EFI Runtime Services Monotonic Counter Fields
gBS->GetNextMonotonicCount = GetNextMonotonicCount;
@@ -69,7 +68,8 @@ MonotonicCounterDriverInitialize (
// Install the Monotonic Counter Architectural Protocol onto a new handle
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
- &gEfiMonotonicCounterArchProtocolGuid, NULL,
+ &gEfiMonotonicCounterArchProtocolGuid,
+ NULL,
NULL
);
return Status;
diff --git a/EmbeddedPkg/GdbStub/Arm/Processor.c b/EmbeddedPkg/GdbStub/Arm/Processor.c
index bb956b7e79..ec160903a5 100644
--- a/EmbeddedPkg/GdbStub/Arm/Processor.c
+++ b/EmbeddedPkg/GdbStub/Arm/Processor.c
@@ -15,67 +15,67 @@
// Array of exception types that need to be hooked by the debugger
// (efi, gdb) //efi number
//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
- { EXCEPT_ARM_SOFTWARE_INTERRUPT, GDB_SIGTRAP }
-// { EXCEPT_ARM_UNDEFINED_INSTRUCTION, GDB_SIGTRAP },
-// { EXCEPT_ARM_PREFETCH_ABORT, GDB_SIGTRAP },
-// { EXCEPT_ARM_DATA_ABORT, GDB_SIGEMT },
-// { EXCEPT_ARM_RESERVED, GDB_SIGILL }
+EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
+ { EXCEPT_ARM_SOFTWARE_INTERRUPT, GDB_SIGTRAP }
+ // { EXCEPT_ARM_UNDEFINED_INSTRUCTION, GDB_SIGTRAP },
+ // { EXCEPT_ARM_PREFETCH_ABORT, GDB_SIGTRAP },
+ // { EXCEPT_ARM_DATA_ABORT, GDB_SIGEMT },
+ // { EXCEPT_ARM_RESERVED, GDB_SIGILL }
};
// Shut up some annoying RVCT warnings
#ifdef __CC_ARM
-#pragma diag_suppress 1296
+ #pragma diag_suppress 1296
#endif
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R0),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R1),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R2),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R3),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R4),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R5),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R6),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R7),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R8),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R9),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R10),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R11),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, R12),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, SP),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, LR),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, PC),
- 0x00000F01, // f0
+UINTN gRegisterOffsets[] = {
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R0),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R1),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R2),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R3),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R4),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R5),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R6),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R7),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R8),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R9),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R10),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R11),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, R12),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, SP),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, LR),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, PC),
+ 0x00000F01, // f0
0x00000F02,
0x00000F03,
- 0x00000F11, // f1
+ 0x00000F11, // f1
0x00000F12,
0x00000F13,
- 0x00000F21, // f2
+ 0x00000F21, // f2
0x00000F22,
0x00000F23,
- 0x00000F31, // f3
+ 0x00000F31, // f3
0x00000F32,
0x00000F33,
- 0x00000F41, // f4
+ 0x00000F41, // f4
0x00000F42,
0x00000F43,
- 0x00000F51, // f5
+ 0x00000F51, // f5
0x00000F52,
0x00000F53,
- 0x00000F61, // f6
+ 0x00000F61, // f6
0x00000F62,
0x00000F63,
- 0x00000F71, // f7
+ 0x00000F71, // f7
0x00000F72,
0x00000F73,
- 0x00000FFF, // fps
- OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, CPSR)
+ 0x00000FFF, // fps
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_ARM, CPSR)
};
// restore warnings for RVCT
#ifdef __CC_ARM
-#pragma diag_default 1296
+ #pragma diag_default 1296
#endif
/**
@@ -91,7 +91,6 @@ MaxEfiException (
return sizeof (gExceptionType) / sizeof (EFI_EXCEPTION_TYPE_ENTRY);
}
-
/**
Return the number of entries in the gRegisters[]
@@ -105,7 +104,6 @@ MaxRegisterCount (
return sizeof (gRegisterOffsets) / sizeof (UINTN);
}
-
/**
Check to see if the ISA is supported.
ISA = Instruction Set Architecture
@@ -125,7 +123,6 @@ CheckIsa (
}
}
-
/**
This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
It is, by default, set to find the register pointer of the ARM member
@@ -135,17 +132,17 @@ CheckIsa (
**/
UINTN *
FindPointerToRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN RegNumber
)
{
- UINT8 *TempPtr;
- ASSERT(gRegisterOffsets[RegNumber] < 0xF00);
+ UINT8 *TempPtr;
+
+ ASSERT (gRegisterOffsets[RegNumber] < 0xF00);
TempPtr = ((UINT8 *)SystemContext.SystemContextArm) + gRegisterOffsets[RegNumber];
return (UINT32 *)TempPtr;
}
-
/**
Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
@param SystemContext Register content at time of the exception
@@ -160,8 +157,8 @@ BasicReadRegister (
IN CHAR8 *OutBufPtr
)
{
- UINTN RegSize;
- CHAR8 Char;
+ UINTN RegSize;
+ CHAR8 Char;
if (gRegisterOffsets[RegNumber] > 0xF00) {
AsciiSPrint (OutBufPtr, 9, "00000000");
@@ -175,20 +172,22 @@ BasicReadRegister (
if ((Char >= 'A') && (Char <= 'F')) {
Char = Char - 'A' + 'a';
}
+
*OutBufPtr++ = Char;
Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
if ((Char >= 'A') && (Char <= 'F')) {
Char = Char - 'A' + 'a';
}
+
*OutBufPtr++ = Char;
RegSize = RegSize + 8;
}
+
return OutBufPtr;
}
-
/**
Reads the n-th register's value into an output buffer and sends it as a packet
@param SystemContext Register content at time of the exception
@@ -200,9 +199,9 @@ ReadNthRegister (
IN CHAR8 *InBuffer
)
{
- UINTN RegNumber;
- CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
+ UINTN RegNumber;
+ CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
+ CHAR8 *OutBufPtr; // pointer to the output buffer
RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
@@ -218,7 +217,6 @@ ReadNthRegister (
SendPacket (OutBuffer);
}
-
/**
Reads the general registers into an output buffer and sends it as a packet
@param SystemContext Register content at time of the exception
@@ -226,13 +224,13 @@ ReadNthRegister (
VOID
EFIAPI
ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- UINTN Index;
- CHAR8 *OutBuffer;
- CHAR8 *OutBufPtr;
- UINTN RegisterCount = MaxRegisterCount ();
+ UINTN Index;
+ CHAR8 *OutBuffer;
+ CHAR8 *OutBufPtr;
+ UINTN RegisterCount = MaxRegisterCount ();
// It is not safe to allocate pool here....
OutBuffer = AllocatePool ((RegisterCount * 8) + 1); // 8 bytes per register in string format plus a null to terminate
@@ -246,7 +244,6 @@ ReadGeneralRegisters (
FreePool (OutBuffer);
}
-
/**
Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
@param SystemContext Register content at time of the exception
@@ -255,22 +252,23 @@ ReadGeneralRegisters (
@retval the pointer to the next character of the input buffer that can be used
**/
CHAR8
-*BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
+*
+BasicWriteRegister (
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN RegNumber,
+ IN CHAR8 *InBufPtr
)
{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT32 NewValue; // the new value of the RegNumber-th Register
+ UINTN RegSize;
+ UINTN TempValue; // the value transferred from a hex char
+ UINT32 NewValue; // the new value of the RegNumber-th Register
if (gRegisterOffsets[RegNumber] > 0xF00) {
return InBufPtr + 8;
}
NewValue = 0;
- RegSize = 0;
+ RegSize = 0;
while (RegSize < 32) {
TempValue = HexCharToInt (*InBufPtr++);
@@ -288,13 +286,13 @@ CHAR8
}
NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
+ RegSize = RegSize + 8;
}
+
*(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
return InBufPtr;
}
-
/** ‘P n...=r...’
Writes the new value of n-th register received into the input buffer to the n-th register
@param SystemContext Register content at time of the exception
@@ -302,41 +300,41 @@ CHAR8
**/
VOID
WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *InBuffer
)
{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
+ UINTN RegNumber;
+ CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
+ CHAR8 *RegNumBufPtr;
+ CHAR8 *InBufPtr; // pointer to the input buffer
// find the register number to write
- InBufPtr = &InBuffer[1];
+ InBufPtr = &InBuffer[1];
RegNumBufPtr = RegNumBuffer;
while (*InBufPtr != '=') {
*RegNumBufPtr++ = *InBufPtr++;
}
+
*RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
+ RegNumber = AsciiStrHexToUintn (RegNumBuffer);
// check if this is a valid Register Number
if (RegNumber >= MaxRegisterCount ()) {
SendError (GDB_EINVALIDREGNUM);
return;
}
+
InBufPtr++; // skips the '=' character
BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
+ SendSuccess ();
}
-
/** ‘G XX...’
Writes the new values received into the input buffer to the general registers
@param SystemContext Register content at time of the exception
@param InBuffer Pointer to the input buffer received from gdb server
**/
-
VOID
EFIAPI
WriteGeneralRegisters (
@@ -352,7 +350,7 @@ WriteGeneralRegisters (
MinLength = (RegisterCount * 8) + 1; // 'G' plus the registers in ASCII format
if (AsciiStrLen (InBuffer) < MinLength) {
- //Bad message. Message is not the right length
+ // Bad message. Message is not the right length
SendError (GDB_EBADBUFSIZE);
return;
}
@@ -370,21 +368,21 @@ WriteGeneralRegisters (
// What about Thumb?
// Use SWI 0xdbdbdb as the debug instruction
-#define GDB_ARM_BKPT 0xefdbdbdb
+#define GDB_ARM_BKPT 0xefdbdbdb
-BOOLEAN mSingleStepActive = FALSE;
-UINT32 mSingleStepPC;
-UINT32 mSingleStepData;
-UINTN mSingleStepDataSize;
+BOOLEAN mSingleStepActive = FALSE;
+UINT32 mSingleStepPC;
+UINT32 mSingleStepData;
+UINTN mSingleStepDataSize;
typedef struct {
- LIST_ENTRY Link;
- UINT64 Signature;
- UINT32 Address;
- UINT32 Instruction;
+ LIST_ENTRY Link;
+ UINT64 Signature;
+ UINT32 Address;
+ UINT32 Instruction;
} ARM_SOFTWARE_BREAKPOINT;
-#define ARM_SOFTWARE_BREAKPOINT_SIGNATURE SIGNATURE_64('A', 'R', 'M', 'B', 'R', 'K', 'P', 'T')
+#define ARM_SOFTWARE_BREAKPOINT_SIGNATURE SIGNATURE_64('A', 'R', 'M', 'B', 'R', 'K', 'P', 'T')
#define ARM_SOFTWARE_BREAKPOINT_FROM_LINK(a) CR(a, ARM_SOFTWARE_BREAKPOINT, Link, ARM_SOFTWARE_BREAKPOINT_SIGNATURE)
LIST_ENTRY BreakpointList;
@@ -396,19 +394,20 @@ LIST_ENTRY BreakpointList;
**/
VOID
AddSingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
if (mSingleStepActive) {
// Currently don't support nesting
return;
}
+
mSingleStepActive = TRUE;
mSingleStepPC = SystemContext.SystemContextArm->PC;
- mSingleStepDataSize = sizeof (UINT32);
- mSingleStepData = (*(UINT32 *)mSingleStepPC);
+ mSingleStepDataSize = sizeof (UINT32);
+ mSingleStepData = (*(UINT32 *)mSingleStepPC);
*(UINT32 *)mSingleStepPC = GDB_ARM_BKPT;
if (*(UINT32 *)mSingleStepPC != GDB_ARM_BKPT) {
// For some reason our breakpoint did not take
@@ -416,10 +415,9 @@ AddSingleStep (
}
InvalidateInstructionCacheRange ((VOID *)mSingleStepPC, mSingleStepDataSize);
- //DEBUG((DEBUG_ERROR, "AddSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, mSingleStepData, *(UINT32 *)mSingleStepPC));
+ // DEBUG((DEBUG_ERROR, "AddSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, mSingleStepData, *(UINT32 *)mSingleStepPC));
}
-
/**
Remove Single Step in the SystemContext
@@ -437,15 +435,14 @@ RemoveSingleStep (
if (mSingleStepDataSize == sizeof (UINT16)) {
*(UINT16 *)mSingleStepPC = (UINT16)mSingleStepData;
} else {
- //DEBUG((DEBUG_ERROR, "RemoveSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, *(UINT32 *)mSingleStepPC, mSingleStepData));
+ // DEBUG((DEBUG_ERROR, "RemoveSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, *(UINT32 *)mSingleStepPC, mSingleStepData));
*(UINT32 *)mSingleStepPC = mSingleStepData;
}
+
InvalidateInstructionCacheRange ((VOID *)mSingleStepPC, mSingleStepDataSize);
mSingleStepActive = FALSE;
}
-
-
/**
Continue. addr is Address to resume. If addr is omitted, resume at current
Address.
@@ -455,8 +452,8 @@ RemoveSingleStep (
VOID
EFIAPI
ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *PacketData
)
{
if (PacketData[1] != '\0') {
@@ -464,7 +461,6 @@ ContinueAtAddress (
}
}
-
/** ‘s [addr ]’
Single step. addr is the Address at which to resume. If addr is omitted, resume
at same Address.
@@ -474,8 +470,8 @@ ContinueAtAddress (
VOID
EFIAPI
SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *PacketData
)
{
SendNotSupported ();
@@ -512,12 +508,12 @@ SearchBreakpointList (
IN UINT32 Address
)
{
- LIST_ENTRY *Current;
- ARM_SOFTWARE_BREAKPOINT *Breakpoint;
+ LIST_ENTRY *Current;
+ ARM_SOFTWARE_BREAKPOINT *Breakpoint;
Current = GetFirstNode (&BreakpointList);
while (!IsNull (&BreakpointList, Current)) {
- Breakpoint = ARM_SOFTWARE_BREAKPOINT_FROM_LINK(Current);
+ Breakpoint = ARM_SOFTWARE_BREAKPOINT_FROM_LINK (Current);
if (Address == Breakpoint->Address) {
return Breakpoint;
@@ -531,10 +527,10 @@ SearchBreakpointList (
VOID
SetBreakpoint (
- IN UINT32 Address
+ IN UINT32 Address
)
{
- ARM_SOFTWARE_BREAKPOINT *Breakpoint;
+ ARM_SOFTWARE_BREAKPOINT *Breakpoint;
Breakpoint = SearchBreakpointList (Address);
@@ -543,7 +539,7 @@ SetBreakpoint (
}
// create and fill breakpoint structure
- Breakpoint = AllocatePool (sizeof(ARM_SOFTWARE_BREAKPOINT));
+ Breakpoint = AllocatePool (sizeof (ARM_SOFTWARE_BREAKPOINT));
Breakpoint->Signature = ARM_SOFTWARE_BREAKPOINT_SIGNATURE;
Breakpoint->Address = Address;
@@ -556,15 +552,15 @@ SetBreakpoint (
*(UINT32 *)Address = GDB_ARM_BKPT;
InvalidateInstructionCacheRange ((VOID *)Address, 4);
- //DEBUG((DEBUG_ERROR, "SetBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, Breakpoint->Instruction, *(UINT32 *)Address));
+ // DEBUG((DEBUG_ERROR, "SetBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, Breakpoint->Instruction, *(UINT32 *)Address));
}
VOID
ClearBreakpoint (
- IN UINT32 Address
+ IN UINT32 Address
)
{
- ARM_SOFTWARE_BREAKPOINT *Breakpoint;
+ ARM_SOFTWARE_BREAKPOINT *Breakpoint;
Breakpoint = SearchBreakpointList (Address);
@@ -579,7 +575,7 @@ ClearBreakpoint (
*(UINT32 *)Address = Breakpoint->Instruction;
InvalidateInstructionCacheRange ((VOID *)Address, 4);
- //DEBUG((DEBUG_ERROR, "ClearBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, GDB_ARM_BKPT, *(UINT32 *)Address));
+ // DEBUG((DEBUG_ERROR, "ClearBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, GDB_ARM_BKPT, *(UINT32 *)Address));
FreePool (Breakpoint);
}
@@ -588,13 +584,13 @@ VOID
EFIAPI
InsertBreakPoint (
IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN CHAR8 *PacketData
)
{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN ErrorCode;
+ UINTN Type;
+ UINTN Address;
+ UINTN Length;
+ UINTN ErrorCode;
ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
if (ErrorCode > 0) {
@@ -603,11 +599,11 @@ InsertBreakPoint (
}
switch (Type) {
- case 0: //Software breakpoint
+ case 0: // Software breakpoint
break;
- default :
- DEBUG((DEBUG_ERROR, "Insert breakpoint default: %x\n", Type));
+ default:
+ DEBUG ((DEBUG_ERROR, "Insert breakpoint default: %x\n", Type));
SendError (GDB_EINVALIDBRKPOINTTYPE);
return;
}
@@ -624,12 +620,12 @@ RemoveBreakPoint (
IN CHAR8 *PacketData
)
{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN ErrorCode;
+ UINTN Type;
+ UINTN Address;
+ UINTN Length;
+ UINTN ErrorCode;
- //Parse breakpoint packet data
+ // Parse breakpoint packet data
ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
if (ErrorCode > 0) {
SendError ((UINT8)ErrorCode);
@@ -637,7 +633,7 @@ RemoveBreakPoint (
}
switch (Type) {
- case 0: //Software breakpoint
+ case 0: // Software breakpoint
break;
default:
@@ -673,8 +669,8 @@ ValidateAddress (
BOOLEAN
ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
UINT32 ExceptionAddress;
diff --git a/EmbeddedPkg/GdbStub/GdbStub.c b/EmbeddedPkg/GdbStub/GdbStub.c
index dd035271a7..e6e07b87b6 100644
--- a/EmbeddedPkg/GdbStub/GdbStub.c
+++ b/EmbeddedPkg/GdbStub/GdbStub.c
@@ -14,43 +14,40 @@
#include <GdbStubInternal.h>
#include <Protocol/DebugPort.h>
-
-UINTN gMaxProcessorIndex = 0;
+UINTN gMaxProcessorIndex = 0;
//
// Buffers for basic gdb communication
//
-CHAR8 gInBuffer[MAX_BUF_SIZE];
-CHAR8 gOutBuffer[MAX_BUF_SIZE];
+CHAR8 gInBuffer[MAX_BUF_SIZE];
+CHAR8 gOutBuffer[MAX_BUF_SIZE];
// Assume gdb does a "qXfer:libraries:read::offset,length" when it connects so we can default
// this value to FALSE. Since gdb can reconnect its self a global default is not good enough
-BOOLEAN gSymbolTableUpdate = FALSE;
-EFI_EVENT gEvent;
-VOID *gGdbSymbolEventHandlerRegistration = NULL;
+BOOLEAN gSymbolTableUpdate = FALSE;
+EFI_EVENT gEvent;
+VOID *gGdbSymbolEventHandlerRegistration = NULL;
//
// Globals for returning XML from qXfer:libraries:read packet
//
-UINTN gPacketqXferLibraryOffset = 0;
-UINTN gEfiDebugImageTableEntry = 0;
-EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;
-EFI_DEBUG_IMAGE_INFO *gDebugTable = NULL;
-CHAR8 gXferLibraryBuffer[2000];
-
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexToStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+UINTN gPacketqXferLibraryOffset = 0;
+UINTN gEfiDebugImageTableEntry = 0;
+EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;
+EFI_DEBUG_IMAGE_INFO *gDebugTable = NULL;
+CHAR8 gXferLibraryBuffer[2000];
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexToStr[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
VOID
EFIAPI
GdbSymbolEventHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
}
-
/**
The user Entry Point for Application. The user code starts with this function
as the real entry point for the image goes into a library that calls this
@@ -103,7 +100,7 @@ GdbStubEntry (
Status = gBS->HandleProtocol (
Handles[HandleCount],
&gEfiDebugSupportProtocolGuid,
- (VOID **) &DebugSupport
+ (VOID **)&DebugSupport
);
if (!EFI_ERROR (Status)) {
if (CheckIsa (DebugSupport->Isa)) {
@@ -113,6 +110,7 @@ GdbStubEntry (
}
}
} while (HandleCount > 0);
+
FreePool (Handles);
if (!IsaSupported) {
@@ -132,9 +130,10 @@ GdbStubEntry (
for (Processor = 0; Processor <= gMaxProcessorIndex; Processor++) {
for (Index = 0; Index < MaxEfiException (); Index++) {
- Status = DebugSupport->RegisterExceptionCallback (DebugSupport, Processor, GdbExceptionHandler, gExceptionType[Index].Exception);
+ Status = DebugSupport->RegisterExceptionCallback (DebugSupport, Processor, GdbExceptionHandler, gExceptionType[Index].Exception);
ASSERT_EFI_ERROR (Status);
}
+
//
// Current edk2 DebugPort is not interrupt context safe so we can not use it
//
@@ -165,10 +164,9 @@ GdbStubEntry (
);
ASSERT_EFI_ERROR (Status);
-
- if (PcdGetBool (PcdGdbSerial)) {
- GdbInitializeSerialConsole ();
- }
+ if (PcdGetBool (PcdGdbSerial)) {
+ GdbInitializeSerialConsole ();
+ }
return EFI_SUCCESS;
}
@@ -180,16 +178,15 @@ GdbStubEntry (
@param *address the start address of the transferring/writing the memory
@param *new_data the new data to be written to memory
**/
-
VOID
TransferFromInBufToMem (
- IN UINTN Length,
- IN unsigned char *Address,
- IN CHAR8 *NewData
+ IN UINTN Length,
+ IN unsigned char *Address,
+ IN CHAR8 *NewData
)
{
- CHAR8 c1;
- CHAR8 c2;
+ CHAR8 c1;
+ CHAR8 c2;
while (Length-- > 0) {
c1 = (CHAR8)HexCharToInt (*NewData++);
@@ -200,13 +197,13 @@ TransferFromInBufToMem (
SendError (GDB_EBADMEMDATA);
return;
}
+
*Address++ = (UINT8)((c1 << 4) + c2);
}
- SendSuccess();
+ SendSuccess ();
}
-
/**
Transfer Length bytes of memory starting at Address to an output buffer, OutBuffer. This function will finally send the buffer
as a packet.
@@ -214,48 +211,46 @@ TransferFromInBufToMem (
@param Length the number of the bytes to be transferred/read
@param *address pointer to the start address of the transferring/reading the memory
**/
-
VOID
TransferFromMemToOutBufAndSend (
- IN UINTN Length,
- IN unsigned char *Address
+ IN UINTN Length,
+ IN unsigned char *Address
)
{
// there are Length bytes and every byte is represented as 2 hex chars
- CHAR8 OutBuffer[MAX_BUF_SIZE];
- CHAR8 *OutBufPtr; // pointer to the output buffer
- CHAR8 Char;
+ CHAR8 OutBuffer[MAX_BUF_SIZE];
+ CHAR8 *OutBufPtr; // pointer to the output buffer
+ CHAR8 Char;
- if (ValidateAddress(Address) == FALSE) {
- SendError(14);
+ if (ValidateAddress (Address) == FALSE) {
+ SendError (14);
return;
}
OutBufPtr = OutBuffer;
while (Length > 0) {
-
Char = mHexToStr[*Address >> 4];
if ((Char >= 'A') && (Char <= 'F')) {
Char = Char - 'A' + 'a';
}
+
*OutBufPtr++ = Char;
Char = mHexToStr[*Address & 0x0f];
if ((Char >= 'A') && (Char <= 'F')) {
Char = Char - 'A' + 'a';
}
+
*OutBufPtr++ = Char;
Address++;
Length--;
}
- *OutBufPtr = '\0' ; // the end of the buffer
+ *OutBufPtr = '\0'; // the end of the buffer
SendPacket (OutBuffer);
}
-
-
/**
Send a GDB Remote Serial Protocol Packet
@@ -273,20 +268,19 @@ TransferFromMemToOutBufAndSend (
**/
UINTN
SendPacket (
- IN CHAR8 *PacketData
+ IN CHAR8 *PacketData
)
{
- UINT8 CheckSum;
- UINTN Timeout;
- CHAR8 *Ptr;
- CHAR8 TestChar;
- UINTN Count;
+ UINT8 CheckSum;
+ UINTN Timeout;
+ CHAR8 *Ptr;
+ CHAR8 TestChar;
+ UINTN Count;
Timeout = PcdGet32 (PcdGdbMaxPacketRetryCount);
Count = 0;
do {
-
Ptr = PacketData;
if (Timeout-- == 0) {
@@ -297,7 +291,7 @@ SendPacket (
// Packet prefix
GdbPutChar ('$');
- for (CheckSum = 0, Count =0 ; *Ptr != '\0'; Ptr++, Count++) {
+ for (CheckSum = 0, Count = 0; *Ptr != '\0'; Ptr++, Count++) {
GdbPutChar (*Ptr);
CheckSum = CheckSum + *Ptr;
}
@@ -331,38 +325,40 @@ SendPacket (
**/
UINTN
ReceivePacket (
- OUT CHAR8 *PacketData,
- IN UINTN PacketDataSize
- )
+ OUT CHAR8 *PacketData,
+ IN UINTN PacketDataSize
+ )
{
- UINT8 CheckSum;
- UINTN Index;
- CHAR8 Char;
- CHAR8 SumString[3];
- CHAR8 TestChar;
+ UINT8 CheckSum;
+ UINTN Index;
+ CHAR8 Char;
+ CHAR8 SumString[3];
+ CHAR8 TestChar;
ZeroMem (PacketData, PacketDataSize);
- for (;;) {
- // wait for the start of a packet
+ for ( ; ;) {
+ // wait for the start of a packet
TestChar = GdbGetChar ();
while (TestChar != '$') {
TestChar = GdbGetChar ();
- };
+ }
- retry:
+retry:
for (Index = 0, CheckSum = 0; Index < (PacketDataSize - 1); Index++) {
Char = GdbGetChar ();
if (Char == '$') {
goto retry;
}
+
if (Char == '#') {
break;
}
PacketData[Index] = Char;
- CheckSum = CheckSum + Char;
+ CheckSum = CheckSum + Char;
}
+
PacketData[Index] = '\0';
if (Index == PacketDataSize) {
@@ -386,23 +382,21 @@ ReceivePacket (
}
}
- //return 0;
+ // return 0;
}
-
/**
Empties the given buffer
@param Buf pointer to the first element in buffer to be emptied
**/
VOID
EmptyBuffer (
- IN CHAR8 *Buf
+ IN CHAR8 *Buf
)
{
*Buf = '\0';
}
-
/**
Converts an 8-bit Hex Char into a INTN.
@@ -412,7 +406,7 @@ EmptyBuffer (
**/
INTN
HexCharToInt (
- IN CHAR8 Char
+ IN CHAR8 Char
)
{
if ((Char >= 'A') && (Char <= 'F')) {
@@ -421,13 +415,14 @@ HexCharToInt (
return Char - 'a' + 10;
} else if ((Char >= '0') && (Char <= '9')) {
return Char - '0';
- } else { // if not a hex value, return a negative value
+ } else {
+ // if not a hex value, return a negative value
return -1;
}
}
- // 'E' + the biggest error number is 255, so its 2 hex digits + buffer end
-CHAR8 *gError = "E__";
+// 'E' + the biggest error number is 255, so its 2 hex digits + buffer end
+CHAR8 *gError = "E__";
/** 'E NN'
Send an error with the given error number after converting to hex.
@@ -439,20 +434,18 @@ CHAR8 *gError = "E__";
VOID
EFIAPI
SendError (
- IN UINT8 ErrorNum
+ IN UINT8 ErrorNum
)
{
//
// Replace _, or old data, with current errno
//
- gError[1] = mHexToStr [ErrorNum >> 4];
- gError[2] = mHexToStr [ErrorNum & 0x0f];
+ gError[1] = mHexToStr[ErrorNum >> 4];
+ gError[2] = mHexToStr[ErrorNum & 0x0f];
SendPacket (gError); // send buffer
}
-
-
/**
Send 'OK' when the function is done executing successfully.
**/
@@ -465,7 +458,6 @@ SendSuccess (
SendPacket ("OK"); // send buffer
}
-
/**
Send empty packet to specify that particular command/functionality is not supported.
**/
@@ -478,7 +470,6 @@ SendNotSupported (
SendPacket ("");
}
-
/**
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints
@@ -491,24 +482,24 @@ GdbSendTSignal (
IN UINT8 GdbExceptionType
)
{
- CHAR8 TSignalBuffer[128];
- CHAR8 *TSignalPtr;
- UINTN BreakpointDetected;
- BREAK_TYPE BreakType;
- UINTN DataAddress;
- CHAR8 *WatchStrPtr = NULL;
- UINTN RegSize;
+ CHAR8 TSignalBuffer[128];
+ CHAR8 *TSignalPtr;
+ UINTN BreakpointDetected;
+ BREAK_TYPE BreakType;
+ UINTN DataAddress;
+ CHAR8 *WatchStrPtr = NULL;
+ UINTN RegSize;
TSignalPtr = &TSignalBuffer[0];
- //Construct TSignal packet
+ // Construct TSignal packet
*TSignalPtr++ = 'T';
//
// replace _, or previous value, with Exception type
//
- *TSignalPtr++ = mHexToStr [GdbExceptionType >> 4];
- *TSignalPtr++ = mHexToStr [GdbExceptionType & 0x0f];
+ *TSignalPtr++ = mHexToStr[GdbExceptionType >> 4];
+ *TSignalPtr++ = mHexToStr[GdbExceptionType & 0x0f];
if (GdbExceptionType == GDB_SIGTRAP) {
if (gSymbolTableUpdate) {
@@ -519,27 +510,25 @@ GdbSendTSignal (
while (*WatchStrPtr != '\0') {
*TSignalPtr++ = *WatchStrPtr++;
}
+
gSymbolTableUpdate = FALSE;
} else {
-
-
//
// possible n:r pairs
//
- //Retrieve the breakpoint number
+ // Retrieve the breakpoint number
BreakpointDetected = GetBreakpointDetected (SystemContext);
- //Figure out if the exception is happend due to watch, rwatch or awatch.
+ // Figure out if the exception is happend due to watch, rwatch or awatch.
BreakType = GetBreakpointType (SystemContext, BreakpointDetected);
- //INFO: rwatch is not supported due to the way IA32 debug registers work
+ // INFO: rwatch is not supported due to the way IA32 debug registers work
if ((BreakType == DataWrite) || (BreakType == DataRead) || (BreakType == DataReadWrite)) {
-
- //Construct n:r pair
+ // Construct n:r pair
DataAddress = GetBreakpointDataAddress (SystemContext, BreakpointDetected);
- //Assign appropriate buffer to print particular watchpoint type
+ // Assign appropriate buffer to print particular watchpoint type
if (BreakType == DataWrite) {
WatchStrPtr = "watch";
} else if (BreakType == DataRead) {
@@ -554,14 +543,14 @@ GdbSendTSignal (
*TSignalPtr++ = ':';
- //Set up series of bytes in big-endian byte order. "awatch" won't work with little-endian byte order.
+ // Set up series of bytes in big-endian byte order. "awatch" won't work with little-endian byte order.
RegSize = REG_SIZE;
while (RegSize > 0) {
- RegSize = RegSize-4;
+ RegSize = RegSize-4;
*TSignalPtr++ = mHexToStr[(UINT8)(DataAddress >> RegSize) & 0xf];
}
- //Always end n:r pair with ';'
+ // Always end n:r pair with ';'
*TSignalPtr++ = ';';
}
}
@@ -572,7 +561,6 @@ GdbSendTSignal (
SendPacket (TSignalBuffer);
}
-
/**
Translates the EFI mapping to GDB mapping
@@ -581,68 +569,67 @@ GdbSendTSignal (
**/
UINT8
ConvertEFItoGDBtype (
- IN EFI_EXCEPTION_TYPE EFIExceptionType
+ IN EFI_EXCEPTION_TYPE EFIExceptionType
)
{
- UINTN Index;
+ UINTN Index;
- for (Index = 0; Index < MaxEfiException () ; Index++) {
+ for (Index = 0; Index < MaxEfiException (); Index++) {
if (gExceptionType[Index].Exception == EFIExceptionType) {
return gExceptionType[Index].SignalNo;
}
}
+
return GDB_SIGTRAP; // this is a GDB trap
}
-
/** "m addr,length"
Find the Length of the area to read and the start address. Finally, pass them to
another function, TransferFromMemToOutBufAndSend, that will read from that memory space and
send it as a packet.
**/
-
VOID
EFIAPI
ReadFromMemory (
- CHAR8 *PacketData
+ CHAR8 *PacketData
)
{
- UINTN Address;
- UINTN Length;
- CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the address in hex chars
- CHAR8 *AddrBufPtr; // pointer to the address buffer
- CHAR8 *InBufPtr; /// pointer to the input buffer
+ UINTN Address;
+ UINTN Length;
+ CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the address in hex chars
+ CHAR8 *AddrBufPtr; // pointer to the address buffer
+ CHAR8 *InBufPtr; /// pointer to the input buffer
AddrBufPtr = AddressBuffer;
- InBufPtr = &PacketData[1];
+ InBufPtr = &PacketData[1];
while (*InBufPtr != ',') {
*AddrBufPtr++ = *InBufPtr++;
}
+
*AddrBufPtr = '\0';
InBufPtr++; // this skips ',' in the buffer
/* Error checking */
if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
- Print((CHAR16 *)L"Address is too long\n");
+ Print ((CHAR16 *)L"Address is too long\n");
SendError (GDB_EBADMEMADDRBUFSIZE);
return;
}
// 2 = 'm' + ','
if (AsciiStrLen (PacketData) - AsciiStrLen (AddressBuffer) - 2 >= MAX_LENGTH_SIZE) {
- Print((CHAR16 *)L"Length is too long\n");
+ Print ((CHAR16 *)L"Length is too long\n");
SendError (GDB_EBADMEMLENGTH);
return;
}
Address = AsciiStrHexToUintn (AddressBuffer);
- Length = AsciiStrHexToUintn (InBufPtr);
+ Length = AsciiStrHexToUintn (InBufPtr);
TransferFromMemToOutBufAndSend (Length, (unsigned char *)Address);
}
-
/** "M addr,length :XX..."
Find the Length of the area in bytes to write and the start address. Finally, pass them to
another function, TransferFromInBufToMem, that will write to that memory space the info in
@@ -651,25 +638,26 @@ ReadFromMemory (
VOID
EFIAPI
WriteToMemory (
- IN CHAR8 *PacketData
+ IN CHAR8 *PacketData
)
{
- UINTN Address;
- UINTN Length;
- UINTN MessageLength;
- CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the Address in hex chars
- CHAR8 LengthBuffer[MAX_LENGTH_SIZE]; // the buffer that will hold the Length in hex chars
- CHAR8 *AddrBufPtr; // pointer to the Address buffer
- CHAR8 *LengthBufPtr; // pointer to the Length buffer
- CHAR8 *InBufPtr; /// pointer to the input buffer
-
- AddrBufPtr = AddressBuffer;
+ UINTN Address;
+ UINTN Length;
+ UINTN MessageLength;
+ CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the Address in hex chars
+ CHAR8 LengthBuffer[MAX_LENGTH_SIZE]; // the buffer that will hold the Length in hex chars
+ CHAR8 *AddrBufPtr; // pointer to the Address buffer
+ CHAR8 *LengthBufPtr; // pointer to the Length buffer
+ CHAR8 *InBufPtr; /// pointer to the input buffer
+
+ AddrBufPtr = AddressBuffer;
LengthBufPtr = LengthBuffer;
- InBufPtr = &PacketData[1];
+ InBufPtr = &PacketData[1];
while (*InBufPtr != ',') {
*AddrBufPtr++ = *InBufPtr++;
}
+
*AddrBufPtr = '\0';
InBufPtr++; // this skips ',' in the buffer
@@ -677,23 +665,24 @@ WriteToMemory (
while (*InBufPtr != ':') {
*LengthBufPtr++ = *InBufPtr++;
}
+
*LengthBufPtr = '\0';
InBufPtr++; // this skips ':' in the buffer
Address = AsciiStrHexToUintn (AddressBuffer);
- Length = AsciiStrHexToUintn (LengthBuffer);
+ Length = AsciiStrHexToUintn (LengthBuffer);
/* Error checking */
- //Check if Address is not too long.
+ // Check if Address is not too long.
if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
Print ((CHAR16 *)L"Address too long..\n");
SendError (GDB_EBADMEMADDRBUFSIZE);
return;
}
- //Check if message length is not too long
+ // Check if message length is not too long
if (AsciiStrLen (LengthBuffer) >= MAX_LENGTH_SIZE) {
Print ((CHAR16 *)L"Length too long..\n");
SendError (GDB_EBADMEMLENGBUFSIZE);
@@ -704,10 +693,11 @@ WriteToMemory (
// 3 = 'M' + ',' + ':'
MessageLength = (AsciiStrLen (PacketData) - AsciiStrLen (AddressBuffer) - AsciiStrLen (LengthBuffer) - 3);
if (MessageLength != (2*Length)) {
- //Message too long/short. New data is not the right size.
+ // Message too long/short. New data is not the right size.
SendError (GDB_EBADMEMDATASIZE);
return;
}
+
TransferFromInBufToMem (Length, (unsigned char *)Address, InBufPtr);
}
@@ -727,72 +717,74 @@ WriteToMemory (
**/
UINTN
ParseBreakpointPacket (
- IN CHAR8 *PacketData,
- OUT UINTN *Type,
- OUT UINTN *Address,
- OUT UINTN *Length
+ IN CHAR8 *PacketData,
+ OUT UINTN *Type,
+ OUT UINTN *Address,
+ OUT UINTN *Length
)
{
- CHAR8 AddressBuffer[MAX_ADDR_SIZE];
- CHAR8 *AddressBufferPtr;
- CHAR8 *PacketDataPtr;
+ CHAR8 AddressBuffer[MAX_ADDR_SIZE];
+ CHAR8 *AddressBufferPtr;
+ CHAR8 *PacketDataPtr;
- PacketDataPtr = &PacketData[1];
+ PacketDataPtr = &PacketData[1];
AddressBufferPtr = AddressBuffer;
*Type = AsciiStrHexToUintn (PacketDataPtr);
- //Breakpoint/watchpoint type should be between 0 to 4
+ // Breakpoint/watchpoint type should be between 0 to 4
if (*Type > 4) {
Print ((CHAR16 *)L"Type is invalid\n");
- return 22; //EINVAL: Invalid argument.
+ return 22; // EINVAL: Invalid argument.
}
- //Skip ',' in the buffer.
- while (*PacketDataPtr++ != ',');
+ // Skip ',' in the buffer.
+ while (*PacketDataPtr++ != ',') {
+ }
- //Parse Address information
+ // Parse Address information
while (*PacketDataPtr != ',') {
*AddressBufferPtr++ = *PacketDataPtr++;
}
+
*AddressBufferPtr = '\0';
- //Check if Address is not too long.
+ // Check if Address is not too long.
if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
Print ((CHAR16 *)L"Address too long..\n");
- return 40; //EMSGSIZE: Message size too long.
+ return 40; // EMSGSIZE: Message size too long.
}
*Address = AsciiStrHexToUintn (AddressBuffer);
- PacketDataPtr++; //This skips , in the buffer
+ PacketDataPtr++; // This skips , in the buffer
- //Parse Length information
+ // Parse Length information
*Length = AsciiStrHexToUintn (PacketDataPtr);
- //Length should be 1, 2 or 4 bytes
+ // Length should be 1, 2 or 4 bytes
if (*Length > 4) {
Print ((CHAR16 *)L"Length is invalid\n");
- return 22; //EINVAL: Invalid argument
+ return 22; // EINVAL: Invalid argument
}
- return 0; //0 = No error
+ return 0; // 0 = No error
}
UINTN
gXferObjectReadResponse (
- IN CHAR8 Type,
- IN CHAR8 *Str
+ IN CHAR8 Type,
+ IN CHAR8 *Str
)
{
- CHAR8 *OutBufPtr; // pointer to the output buffer
- CHAR8 Char;
- UINTN Count;
+ CHAR8 *OutBufPtr; // pointer to the output buffer
+ CHAR8 Char;
+ UINTN Count;
// Response starts with 'm' or 'l' if it is the end
- OutBufPtr = gOutBuffer;
+ OutBufPtr = gOutBuffer;
*OutBufPtr++ = Type;
- Count = 1;
+ Count = 1;
// Binary data encoding
OutBufPtr = gOutBuffer;
@@ -804,17 +796,17 @@ gXferObjectReadResponse (
Char ^= 0x20;
}
+
*OutBufPtr++ = Char;
Count++;
}
- *OutBufPtr = '\0' ; // the end of the buffer
+ *OutBufPtr = '\0'; // the end of the buffer
SendPacket (gOutBuffer);
return Count;
}
-
/**
Note: This should be a library function. In the Apple case you have to add
the size of the PE/COFF header into the starting address to make things work
@@ -844,20 +836,20 @@ gXferObjectReadResponse (
VOID *
EFIAPI
PeCoffLoaderGetDebuggerInfo (
- IN VOID *Pe32Data,
- OUT VOID **DebugBase
+ IN VOID *Pe32Data,
+ OUT VOID **DebugBase
)
{
- EFI_IMAGE_DOS_HEADER *DosHdr;
- 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;
- UINT16 Magic;
- UINTN SizeOfHeaders;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ 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;
+ UINT16 Magic;
+ UINTN SizeOfHeaders;
ASSERT (Pe32Data != NULL);
@@ -872,7 +864,7 @@ PeCoffLoaderGetDebuggerInfo (
//
// DOS image header is present, so read the PE header after the DOS image header.
//
- Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + (UINTN)((DosHdr->e_lfanew) & 0x0ffff));
} else {
//
// DOS image header is not present, so PE header is at the image base.
@@ -882,91 +874,90 @@ PeCoffLoaderGetDebuggerInfo (
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);
+ 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);
}
+
SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
// __APPLE__ check this math...
*DebugBase = ((CHAR8 *)Pe32Data) - TEImageAdjust;
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
-
*DebugBase = Pe32Data;
-
//
// NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.
// It is due to backward-compatibility, for some system might
// generate PE32+ image with PE32 Magic.
//
switch (Hdr.Pe32->FileHeader.Machine) {
- case EFI_IMAGE_MACHINE_IA32:
- //
- // Assume PE32 image with IA32 Machine field.
- //
- Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
- break;
- case EFI_IMAGE_MACHINE_X64:
- case EFI_IMAGE_MACHINE_IA64:
- //
- // Assume PE32+ image with X64 or IPF Machine field
- //
- Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
- break;
- default:
- //
- // For unknown Machine field, use Magic in optional Header
- //
- Magic = Hdr.Pe32->OptionalHeader.Magic;
+ case EFI_IMAGE_MACHINE_IA32:
+ //
+ // Assume PE32 image with IA32 Machine field.
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ break;
+ case EFI_IMAGE_MACHINE_X64:
+ case EFI_IMAGE_MACHINE_IA64:
+ //
+ // Assume PE32+ image with X64 or IPF Machine field
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ break;
+ default:
+ //
+ // For unknown Machine field, use Magic in optional Header
+ //
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
}
if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
//
// Use PE32 offset get Debug Directory Entry
//
- SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
+ SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
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);
+ 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
//
- SizeOfHeaders = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;
+ SizeOfHeaders = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;
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);
+ 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;
+ DebugEntry = NULL;
}
} else {
return NULL;
}
- if (DebugEntry == NULL || DirectoryEntry == NULL) {
+ if ((DebugEntry == NULL) || (DirectoryEntry == NULL)) {
return NULL;
}
for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), 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));
- case CODEVIEW_SIGNATURE_MTOC:
- *DebugBase = (VOID *)(UINTN)((UINTN)DebugBase - SizeOfHeaders);
- return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
- default:
- break;
+ 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));
+ case CODEVIEW_SIGNATURE_MTOC:
+ *DebugBase = (VOID *)(UINTN)((UINTN)DebugBase - SizeOfHeaders);
+ return (VOID *)((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
+ default:
+ break;
}
}
}
@@ -976,7 +967,6 @@ PeCoffLoaderGetDebuggerInfo (
return NULL;
}
-
/**
Process "qXfer:object:read:annex:offset,length" request.
@@ -1012,13 +1002,13 @@ PeCoffLoaderGetDebuggerInfo (
**/
VOID
QxferLibrary (
- IN UINTN Offset,
- IN UINTN Length
+ IN UINTN Offset,
+ IN UINTN Length
)
{
- VOID *LoadAddress;
- CHAR8 *Pdb;
- UINTN Size;
+ VOID *LoadAddress;
+ CHAR8 *Pdb;
+ UINTN Size;
if (Offset != gPacketqXferLibraryOffset) {
SendError (GDB_EINVALIDARG);
@@ -1036,28 +1026,29 @@ QxferLibrary (
// The owner of the table may have had to ralloc it so grab a fresh copy every time
// we assume qXferLibrary will get called over and over again until the entire XML table is
// returned in a tight loop. Since we are in the debugger the table should not get updated
- gDebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;
+ gDebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;
gEfiDebugImageTableEntry = 0;
return;
}
if (gDebugTable != NULL) {
- for (; gEfiDebugImageTableEntry < gDebugImageTableHeader->TableSize; gEfiDebugImageTableEntry++, gDebugTable++) {
+ for ( ; gEfiDebugImageTableEntry < gDebugImageTableHeader->TableSize; gEfiDebugImageTableEntry++, gDebugTable++) {
if (gDebugTable->NormalImage != NULL) {
if ((gDebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
- (gDebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
+ (gDebugTable->NormalImage->LoadedImageProtocolInstance != NULL))
+ {
Pdb = PeCoffLoaderGetDebuggerInfo (
- gDebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase,
- &LoadAddress
- );
+ gDebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase,
+ &LoadAddress
+ );
if (Pdb != NULL) {
Size = AsciiSPrint (
- gXferLibraryBuffer,
- sizeof (gXferLibraryBuffer),
- " <library name=\"%a\"><segment address=\"0x%p\"/></library>\n",
- Pdb,
- LoadAddress
- );
+ gXferLibraryBuffer,
+ sizeof (gXferLibraryBuffer),
+ " <library name=\"%a\"><segment address=\"0x%p\"/></library>\n",
+ Pdb,
+ LoadAddress
+ );
if ((Size != 0) && (Size != (sizeof (gXferLibraryBuffer) - 1))) {
gPacketqXferLibraryOffset += gXferObjectReadResponse ('m', gXferLibraryBuffer);
@@ -1080,13 +1071,11 @@ QxferLibrary (
}
}
-
gXferObjectReadResponse ('l', "</library-list>\n");
gPacketqXferLibraryOffset = 0;
return;
}
-
/**
Exception Handler for GDB. It will be called for all exceptions
registered via the gExceptionType[] array.
@@ -1097,13 +1086,12 @@ QxferLibrary (
VOID
EFIAPI
GdbExceptionHandler (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
- UINT8 GdbExceptionType;
- CHAR8 *Ptr;
-
+ UINT8 GdbExceptionType;
+ CHAR8 *Ptr;
if (ValidateException (ExceptionType, SystemContext) == FALSE) {
return;
@@ -1114,7 +1102,7 @@ GdbExceptionHandler (
GdbExceptionType = ConvertEFItoGDBtype (ExceptionType);
GdbSendTSignal (SystemContext, GdbExceptionType);
- for( ; ; ) {
+ for ( ; ; ) {
ReceivePacket (gInBuffer, MAX_BUF_SIZE);
switch (gInBuffer[0]) {
@@ -1135,7 +1123,7 @@ GdbExceptionHandler (
break;
case 'H':
- //Return "OK" packet since we don't have more than one thread.
+ // Return "OK" packet since we don't have more than one thread.
SendSuccess ();
break;
@@ -1163,17 +1151,21 @@ GdbExceptionHandler (
} else if (AsciiStrnCmp (gInBuffer, "qXfer:libraries:read::", 22) == 0) {
// ‘qXfer:libraries:read::offset,length
// gInBuffer[22] is offset string, ++Ptr is length string’
- for (Ptr = &gInBuffer[22]; *Ptr != ','; Ptr++);
+ for (Ptr = &gInBuffer[22]; *Ptr != ','; Ptr++) {
+ }
// Not sure if multi-radix support is required. Currently only support decimal
QxferLibrary (AsciiStrHexToUintn (&gInBuffer[22]), AsciiStrHexToUintn (++Ptr));
- } if (AsciiStrnCmp (gInBuffer, "qOffsets", 10) == 0) {
+ }
+
+ if (AsciiStrnCmp (gInBuffer, "qOffsets", 10) == 0) {
AsciiSPrint (gOutBuffer, MAX_BUF_SIZE, "Text=1000;Data=f000;Bss=f000");
SendPacket (gOutBuffer);
} else {
- //Send empty packet
+ // Send empty packet
SendNotSupported ();
}
+
break;
case 's':
@@ -1189,14 +1181,13 @@ GdbExceptionHandler (
break;
default:
- //Send empty packet
+ // Send empty packet
SendNotSupported ();
break;
}
}
}
-
/**
Periodic callback for GDB. This function is used to catch a ctrl-c or other
break in type command from GDB.
@@ -1206,7 +1197,7 @@ GdbExceptionHandler (
VOID
EFIAPI
GdbPeriodicCallBack (
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
//
diff --git a/EmbeddedPkg/GdbStub/GdbStubInternal.h b/EmbeddedPkg/GdbStub/GdbStubInternal.h
index b08159302c..9c3929c812 100644
--- a/EmbeddedPkg/GdbStub/GdbStubInternal.h
+++ b/EmbeddedPkg/GdbStub/GdbStubInternal.h
@@ -28,54 +28,51 @@
#include <Guid/DebugImageInfoTable.h>
#include <IndustryStandard/PeImage.h>
-extern CONST CHAR8 mHexToStr[];
+extern CONST CHAR8 mHexToStr[];
// maximum size of input and output buffers
// This value came from the show remote command of the gdb we tested against
-#define MAX_BUF_SIZE 2000
+#define MAX_BUF_SIZE 2000
// maximum size of address buffer
-#define MAX_ADDR_SIZE 32
+#define MAX_ADDR_SIZE 32
// maximum size of register number buffer
-#define MAX_REG_NUM_BUF_SIZE 32
+#define MAX_REG_NUM_BUF_SIZE 32
// maximum size of length buffer
-#define MAX_LENGTH_SIZE 32
+#define MAX_LENGTH_SIZE 32
// maximum size of T signal members
-#define MAX_T_SIGNAL_SIZE 64
+#define MAX_T_SIGNAL_SIZE 64
// the mask used to clear all the cache
-#define TF_BIT 0x00000100
-
+#define TF_BIT 0x00000100
//
// GDB Signal definitions - generic names for interrupts
//
-#define GDB_SIGILL 4 // Illegal instruction
-#define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)
-#define GDB_SIGEMT 7 // Emulator Trap
-#define GDB_SIGFPE 8 // Floating point exception
-#define GDB_SIGSEGV 11 // Segment violation, page fault
-
+#define GDB_SIGILL 4 // Illegal instruction
+#define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)
+#define GDB_SIGEMT 7 // Emulator Trap
+#define GDB_SIGFPE 8 // Floating point exception
+#define GDB_SIGSEGV 11 // Segment violation, page fault
//
// GDB File I/O Error values, zero means no error
// Includes all general GDB Unix like error values
//
-#define GDB_EBADMEMADDRBUFSIZE 11 // the buffer that stores memory Address to be read from/written to is not the right size
-#define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size
-#define GDB_EBADMEMLENGTH 13 // Length, the given number of bytes to read or write, is not the right size
-#define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is less than 0
-#define GDB_EBADMEMDATASIZE 15 // the memory data, 'XX..', is too short or too long
-#define GDB_EBADBUFSIZE 21 // the buffer created is not the correct size
-#define GDB_EINVALIDARG 31 // argument is invalid
-#define GDB_ENOSPACE 41 //
-#define GDB_EINVALIDBRKPOINTTYPE 51 // the breakpoint type is not recognized
-#define GDB_EINVALIDREGNUM 61 // given register number is not valid: either <0 or >=Number of Registers
-#define GDB_EUNKNOWN 255 // unknown
-
+#define GDB_EBADMEMADDRBUFSIZE 11 // the buffer that stores memory Address to be read from/written to is not the right size
+#define GDB_EBADMEMLENGBUFSIZE 12 // the buffer that stores Length is not the right size
+#define GDB_EBADMEMLENGTH 13 // Length, the given number of bytes to read or write, is not the right size
+#define GDB_EBADMEMDATA 14 // one of the bytes or nibbles of the memory is less than 0
+#define GDB_EBADMEMDATASIZE 15 // the memory data, 'XX..', is too short or too long
+#define GDB_EBADBUFSIZE 21 // the buffer created is not the correct size
+#define GDB_EINVALIDARG 31 // argument is invalid
+#define GDB_ENOSPACE 41 //
+#define GDB_EINVALIDBRKPOINTTYPE 51 // the breakpoint type is not recognized
+#define GDB_EINVALIDREGNUM 61 // given register number is not valid: either <0 or >=Number of Registers
+#define GDB_EUNKNOWN 255 // unknown
//
// These devices are open by GDB so we can just read and write to them
@@ -85,7 +82,7 @@ extern CONST CHAR8 mHexToStr[];
#define GDB_STDERR 0x02
//
-//Define Register size for different architectures
+// Define Register size for different architectures
//
#if defined (MDE_CPU_IA32)
#define REG_SIZE 32
@@ -95,12 +92,12 @@ extern CONST CHAR8 mHexToStr[];
#define REG_SIZE 32
#endif
-#define GDB_SERIAL_DEV_SIGNATURE SIGNATURE_32 ('g', 'd', 'b', 's')
+#define GDB_SERIAL_DEV_SIGNATURE SIGNATURE_32 ('g', 'd', 'b', 's')
typedef struct {
- VENDOR_DEVICE_PATH VendorDevice;
- UINT32 Index; // Support more than one
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevice;
+ UINT32 Index; // Support more than one
+ EFI_DEVICE_PATH_PROTOCOL End;
} GDB_SERIAL_DEVICE_PATH;
//
@@ -113,25 +110,22 @@ typedef struct {
// DevicePath EFI_DEVICE_PATH_PROTOCOL *: Device path of the serial device
//
typedef struct {
- UINTN Signature;
- EFI_HANDLE Handle;
- EFI_SERIAL_IO_PROTOCOL SerialIo;
- EFI_SERIAL_IO_MODE SerialMode;
- GDB_SERIAL_DEVICE_PATH DevicePath;
- INTN InFileDescriptor;
- INTN OutFileDescriptor;
+ UINTN Signature;
+ EFI_HANDLE Handle;
+ EFI_SERIAL_IO_PROTOCOL SerialIo;
+ EFI_SERIAL_IO_MODE SerialMode;
+ GDB_SERIAL_DEVICE_PATH DevicePath;
+ INTN InFileDescriptor;
+ INTN OutFileDescriptor;
} GDB_SERIAL_DEV;
-
-#define GDB_SERIAL_DEV_FROM_THIS(a) CR (a, GDB_SERIAL_DEV, SerialIo, GDB_SERIAL_DEV_SIGNATURE)
-
+#define GDB_SERIAL_DEV_FROM_THIS(a) CR (a, GDB_SERIAL_DEV, SerialIo, GDB_SERIAL_DEV_SIGNATURE)
typedef struct {
- EFI_EXCEPTION_TYPE Exception;
- UINT8 SignalNo;
+ EFI_EXCEPTION_TYPE Exception;
+ UINT8 SignalNo;
} EFI_EXCEPTION_TYPE_ENTRY;
-
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
//
@@ -141,17 +135,17 @@ typedef struct {
//
typedef union {
struct {
- UINT32 B0:1; // Breakpoint condition detected
- UINT32 B1:1; // Breakpoint condition detected
- UINT32 B2:1; // Breakpoint condition detected
- UINT32 B3:1; // Breakpoint condition detected
- UINT32 Reserved_1:9; // Reserved
- UINT32 BD:1; // Debug register access detected
- UINT32 BS:1; // Single step
- UINT32 BT:1; // Task switch
- UINT32 Reserved_2:16; // Reserved
+ UINT32 B0 : 1; // Breakpoint condition detected
+ UINT32 B1 : 1; // Breakpoint condition detected
+ UINT32 B2 : 1; // Breakpoint condition detected
+ UINT32 B3 : 1; // Breakpoint condition detected
+ UINT32 Reserved_1 : 9; // Reserved
+ UINT32 BD : 1; // Debug register access detected
+ UINT32 BS : 1; // Single step
+ UINT32 BT : 1; // Task switch
+ UINT32 Reserved_2 : 16; // Reserved
} Bits;
- UINTN UintN;
+ UINTN UintN;
} IA32_DR6;
//
@@ -161,65 +155,64 @@ typedef union {
//
typedef union {
struct {
- UINT32 L0:1; // Local breakpoint enable
- UINT32 G0:1; // Global breakpoint enable
- UINT32 L1:1; // Local breakpoint enable
- UINT32 G1:1; // Global breakpoint enable
- UINT32 L2:1; // Local breakpoint enable
- UINT32 G2:1; // Global breakpoint enable
- UINT32 L3:1; // Local breakpoint enable
- UINT32 G3:1; // Global breakpoint enable
- UINT32 LE:1; // Local exact breakpoint enable
- UINT32 GE:1; // Global exact breakpoint enable
- UINT32 Reserved_1:3; // Reserved
- UINT32 GD:1; // Global detect enable
- UINT32 Reserved_2:2; // Reserved
- UINT32 RW0:2; // Read/Write field
- UINT32 LEN0:2; // Length field
- UINT32 RW1:2; // Read/Write field
- UINT32 LEN1:2; // Length field
- UINT32 RW2:2; // Read/Write field
- UINT32 LEN2:2; // Length field
- UINT32 RW3:2; // Read/Write field
- UINT32 LEN3:2; // Length field
+ UINT32 L0 : 1; // Local breakpoint enable
+ UINT32 G0 : 1; // Global breakpoint enable
+ UINT32 L1 : 1; // Local breakpoint enable
+ UINT32 G1 : 1; // Global breakpoint enable
+ UINT32 L2 : 1; // Local breakpoint enable
+ UINT32 G2 : 1; // Global breakpoint enable
+ UINT32 L3 : 1; // Local breakpoint enable
+ UINT32 G3 : 1; // Global breakpoint enable
+ UINT32 LE : 1; // Local exact breakpoint enable
+ UINT32 GE : 1; // Global exact breakpoint enable
+ UINT32 Reserved_1 : 3; // Reserved
+ UINT32 GD : 1; // Global detect enable
+ UINT32 Reserved_2 : 2; // Reserved
+ UINT32 RW0 : 2; // Read/Write field
+ UINT32 LEN0 : 2; // Length field
+ UINT32 RW1 : 2; // Read/Write field
+ UINT32 LEN1 : 2; // Length field
+ UINT32 RW2 : 2; // Read/Write field
+ UINT32 LEN2 : 2; // Length field
+ UINT32 RW3 : 2; // Read/Write field
+ UINT32 LEN3 : 2; // Length field
} Bits;
- UINTN UintN;
+ UINTN UintN;
} IA32_DR7;
#endif /* if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64) */
typedef enum {
- InstructionExecution, //Hardware breakpoint
- DataWrite, //watch
- DataRead, //rwatch
- DataReadWrite, //awatch
- SoftwareBreakpoint, //Software breakpoint
+ InstructionExecution, // Hardware breakpoint
+ DataWrite, // watch
+ DataRead, // rwatch
+ DataReadWrite, // awatch
+ SoftwareBreakpoint, // Software breakpoint
NotSupported
} BREAK_TYPE;
//
// Array of exception types that need to be hooked by the debugger
//
-extern EFI_EXCEPTION_TYPE_ENTRY gExceptionType[];
+extern EFI_EXCEPTION_TYPE_ENTRY gExceptionType[];
//
// Set TRUE if F Reply package signals a ctrl-c. We can not process the Ctrl-c
// here we need to wait for the periodic callback to do this.
//
-extern BOOLEAN gCtrlCBreakFlag;
+extern BOOLEAN gCtrlCBreakFlag;
//
// If the periodic callback is called while we are processing an F packet we need
// to let the callback know to not read from the serial stream as it could steal
// characters from the F response packet
//
-extern BOOLEAN gProcessingFPacket;
-
+extern BOOLEAN gProcessingFPacket;
// The offsets of registers SystemContext.
// The fields in the array are in the gdb ordering.
//
-extern UINTN gRegisterOffsets[];
+extern UINTN gRegisterOffsets[];
/**
Return the number of entries in the gExceptionType[]
@@ -231,7 +224,6 @@ MaxEfiException (
VOID
);
-
/**
Return the number of entries in the gRegisters[]
@@ -242,7 +234,6 @@ MaxRegisterCount (
VOID
);
-
/**
Check to see if the ISA is supported.
ISA = Instruction Set Architecture
@@ -252,10 +243,9 @@ MaxRegisterCount (
**/
BOOLEAN
CheckIsa (
- IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
+ IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa
);
-
/**
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints
@@ -269,7 +259,6 @@ GdbSendTSignal (
IN UINT8 GdbExceptionType
);
-
/**
Translates the EFI mapping to GDB mapping
@@ -278,10 +267,9 @@ GdbSendTSignal (
**/
UINT8
ConvertEFItoGDBtype (
- IN EFI_EXCEPTION_TYPE EFIExceptionType
+ IN EFI_EXCEPTION_TYPE EFIExceptionType
);
-
/**
Empties the given buffer
@param *Buf pointer to the first element in buffer to be emptied
@@ -291,7 +279,6 @@ EmptyBuffer (
IN CHAR8 *Buf
);
-
/**
Converts an 8-bit Hex Char into a INTN.
@@ -301,10 +288,9 @@ EmptyBuffer (
**/
INTN
HexCharToInt (
- IN CHAR8 Char
+ IN CHAR8 Char
);
-
/** 'E NN'
Send an error with the given error number after converting to hex.
The error number is put into the buffer in hex. '255' is the biggest errno we can send.
@@ -315,10 +301,9 @@ HexCharToInt (
VOID
EFIAPI
SendError (
- IN UINT8 ErrorNum
+ IN UINT8 ErrorNum
);
-
/**
Send 'OK' when the function is done executing successfully.
**/
@@ -328,7 +313,6 @@ SendSuccess (
VOID
);
-
/**
Send empty packet to specify that particular command/functionality is not supported.
**/
@@ -349,7 +333,6 @@ ReadNthRegister (
IN CHAR8 *InBuffer
);
-
/** ‘g’
Reads the general registers into an output buffer and sends it as a packet
@param SystemContext Register content at time of the exception
@@ -360,7 +343,6 @@ ReadGeneralRegisters (
IN EFI_SYSTEM_CONTEXT SystemContext
);
-
/** ‘P n...=r...’
Writes the new value of n-th register received into the input buffer to the n-th register
@param SystemContext Register content at time of the exception
@@ -373,7 +355,6 @@ WriteNthRegister (
IN CHAR8 *InBuffer
);
-
/** ‘G XX...’
Writes the new values received into the input buffer to the general registers
@param SystemContext Register content at time of the exception
@@ -387,7 +368,6 @@ WriteGeneralRegisters (
IN CHAR8 *InBuffer
);
-
/** ‘m addr,length ’
Find the Length of the area to read and the start address. Finally, pass them to
another function, TransferFromMemToOutBufAndSend, that will read from that memory space and
@@ -401,7 +381,6 @@ ReadFromMemory (
IN CHAR8 *PacketData
);
-
/** ‘M addr,length :XX...’
Find the Length of the area in bytes to write and the start address. Finally, pass them to
another function, TransferFromInBufToMem, that will write to that memory space the info in
@@ -412,10 +391,9 @@ ReadFromMemory (
VOID
EFIAPI
WriteToMemory (
- IN CHAR8 *PacketData
+ IN CHAR8 *PacketData
);
-
/** ‘c [addr ]’
Continue. addr is Address to resume. If addr is omitted, resume at current
Address.
@@ -427,11 +405,10 @@ WriteToMemory (
VOID
EFIAPI
ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *PacketData
);
-
/** ‘s [addr ]’
Single step. addr is the Address at which to resume. If addr is omitted, resume
at same Address.
@@ -466,7 +443,6 @@ RemoveSingleStep (
IN EFI_SYSTEM_CONTEXT SystemContext
);
-
/**
‘Z1, [addr], [length]’
‘Z2, [addr], [length]’
@@ -481,12 +457,11 @@ RemoveSingleStep (
**/
VOID
EFIAPI
-InsertBreakPoint(
+InsertBreakPoint (
IN EFI_SYSTEM_CONTEXT SystemContext,
IN CHAR8 *PacketData
);
-
/**
‘z1, [addr], [length]’
‘z2, [addr], [length]’
@@ -501,12 +476,11 @@ InsertBreakPoint(
**/
VOID
EFIAPI
-RemoveBreakPoint(
+RemoveBreakPoint (
IN EFI_SYSTEM_CONTEXT SystemContext,
IN CHAR8 *PacketData
);
-
/**
Exception Handler for GDB. It will be called for all exceptions
registered via the gExceptionType[] array.
@@ -522,7 +496,6 @@ GdbExceptionHandler (
IN OUT EFI_SYSTEM_CONTEXT SystemContext
);
-
/**
Periodic callback for GDB. This function is used to catch a ctrl-c or other
break in type command from GDB.
@@ -536,7 +509,6 @@ GdbPeriodicCallBack (
IN OUT EFI_SYSTEM_CONTEXT SystemContext
);
-
/**
Make two serial consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.
@@ -549,7 +521,6 @@ GdbInitializeSerialConsole (
VOID
);
-
/**
Send a GDB Remote Serial Protocol Packet
@@ -566,10 +537,9 @@ GdbInitializeSerialConsole (
**/
UINTN
SendPacket (
- IN CHAR8 *PacketData
+ IN CHAR8 *PacketData
);
-
/**
Receive a GDB Remote Serial Protocol Packet
@@ -588,10 +558,9 @@ SendPacket (
**/
UINTN
ReceivePacket (
- OUT CHAR8 *PacketData,
- IN UINTN PacketDataSize
- );
-
+ OUT CHAR8 *PacketData,
+ IN UINTN PacketDataSize
+ );
/**
Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates
@@ -607,12 +576,11 @@ ReceivePacket (
**/
INTN
GdbRead (
- IN INTN FileDescriptor,
- OUT VOID *Buffer,
- IN UINTN Count
+ IN INTN FileDescriptor,
+ OUT VOID *Buffer,
+ IN UINTN Count
);
-
/**
Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates
nothing was written. On error -1 is returned.
@@ -627,29 +595,29 @@ GdbRead (
**/
INTN
GdbWrite (
- IN INTN FileDescriptor,
- OUT CONST VOID *Buffer,
- IN UINTN Count
+ IN INTN FileDescriptor,
+ OUT CONST VOID *Buffer,
+ IN UINTN Count
);
UINTN *
FindPointerToRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN RegNumber
);
CHAR8 *
BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN RegNumber,
+ IN CHAR8 *OutBufPtr
);
VOID
TransferFromInBufToMem (
- IN UINTN Length,
- IN UINT8 *Address,
- IN CHAR8 *NewData
+ IN UINTN Length,
+ IN UINT8 *Address,
+ IN CHAR8 *NewData
);
VOID
@@ -660,22 +628,22 @@ TransferFromMemToOutBufAndSend (
CHAR8 *
BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN RegNumber,
+ IN CHAR8 *InBufPtr
);
VOID
PrintReg (
- EFI_SYSTEM_CONTEXT SystemContext
+ EFI_SYSTEM_CONTEXT SystemContext
);
UINTN
ParseBreakpointPacket (
- IN CHAR8 *PacketData,
- OUT UINTN *Type,
- OUT UINTN *Address,
- OUT UINTN *Length
+ IN CHAR8 *PacketData,
+ OUT UINTN *Type,
+ OUT UINTN *Address,
+ OUT UINTN *Length
);
UINTN
@@ -717,18 +685,18 @@ EnableDebugRegister (
EFI_STATUS
FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- );
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN Address,
+ IN UINTN Length,
+ IN UINTN Type,
+ OUT UINTN *Register
+ );
EFI_STATUS
DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- );
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN Register
+ );
VOID
InitializeProcessor (
@@ -742,8 +710,8 @@ ValidateAddress (
BOOLEAN
ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext
);
#endif
diff --git a/EmbeddedPkg/GdbStub/Ia32/Processor.c b/EmbeddedPkg/GdbStub/Ia32/Processor.c
index 8dc768f180..a3406b03f3 100644
--- a/EmbeddedPkg/GdbStub/Ia32/Processor.c
+++ b/EmbeddedPkg/GdbStub/Ia32/Processor.c
@@ -13,52 +13,50 @@
// Array of exception types that need to be hooked by the debugger
// {EFI mapping, GDB mapping}
//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
- { EXCEPT_IA32_DIVIDE_ERROR, GDB_SIGFPE },
- { EXCEPT_IA32_DEBUG, GDB_SIGTRAP },
- { EXCEPT_IA32_NMI, GDB_SIGEMT },
- { EXCEPT_IA32_BREAKPOINT, GDB_SIGTRAP },
- { EXCEPT_IA32_OVERFLOW, GDB_SIGSEGV },
- { EXCEPT_IA32_BOUND, GDB_SIGSEGV },
- { EXCEPT_IA32_INVALID_OPCODE, GDB_SIGILL },
- { EXCEPT_IA32_DOUBLE_FAULT, GDB_SIGEMT },
- { EXCEPT_IA32_STACK_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_GP_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_PAGE_FAULT, GDB_SIGSEGV },
- { EXCEPT_IA32_FP_ERROR, GDB_SIGEMT },
- { EXCEPT_IA32_ALIGNMENT_CHECK, GDB_SIGEMT },
- { EXCEPT_IA32_MACHINE_CHECK, GDB_SIGEMT }
+EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
+ { EXCEPT_IA32_DIVIDE_ERROR, GDB_SIGFPE },
+ { EXCEPT_IA32_DEBUG, GDB_SIGTRAP },
+ { EXCEPT_IA32_NMI, GDB_SIGEMT },
+ { EXCEPT_IA32_BREAKPOINT, GDB_SIGTRAP },
+ { EXCEPT_IA32_OVERFLOW, GDB_SIGSEGV },
+ { EXCEPT_IA32_BOUND, GDB_SIGSEGV },
+ { EXCEPT_IA32_INVALID_OPCODE, GDB_SIGILL },
+ { EXCEPT_IA32_DOUBLE_FAULT, GDB_SIGEMT },
+ { EXCEPT_IA32_STACK_FAULT, GDB_SIGSEGV },
+ { EXCEPT_IA32_GP_FAULT, GDB_SIGSEGV },
+ { EXCEPT_IA32_PAGE_FAULT, GDB_SIGSEGV },
+ { EXCEPT_IA32_FP_ERROR, GDB_SIGEMT },
+ { EXCEPT_IA32_ALIGNMENT_CHECK, GDB_SIGEMT },
+ { EXCEPT_IA32_MACHINE_CHECK, GDB_SIGEMT }
};
-
// The offsets of registers SystemContext.
// The fields in the array are in the gdb ordering.
//
-//16 regs
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eax),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ecx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Edx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ebx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Esp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ebp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Esi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Edi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eip),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Eflags),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Cs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ss),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Ds),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Es),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Fs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_IA32, Gs)
+// 16 regs
+UINTN gRegisterOffsets[] = {
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Eax),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Ecx),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Edx),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Ebx),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Esp),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Ebp),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Esi),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Edi),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Eip),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Eflags),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Cs),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Ss),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Ds),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Es),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Fs),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_IA32, Gs)
};
-
-//Debug only..
+// Debug only..
VOID
PrintReg (
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
Print ((CHAR16 *)L"EAX: %x ", SystemContext.SystemContextIa32->Eax);
@@ -73,10 +71,10 @@ PrintReg (
Print ((CHAR16 *)L"EFlags: %x\n", SystemContext.SystemContextIa32->Eflags);
}
-//Debug only..
+// Debug only..
VOID
PrintDRreg (
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
Print ((CHAR16 *)L"DR0: %x ", SystemContext.SystemContextIa32->Dr0);
@@ -87,7 +85,6 @@ PrintDRreg (
Print ((CHAR16 *)L"DR7: %x\n", SystemContext.SystemContextIa32->Dr7);
}
-
/**
Return the number of entries in the gExceptionType[]
@@ -101,7 +98,6 @@ MaxEfiException (
return sizeof (gExceptionType)/sizeof (EFI_EXCEPTION_TYPE_ENTRY);
}
-
/**
Return the number of entries in the gRegisters[]
@@ -115,7 +111,6 @@ MaxRegisterCount (
return sizeof (gRegisterOffsets)/sizeof (UINTN);
}
-
/**
Check to see if the ISA is supported.
ISA = Instruction Set Architecture
@@ -131,7 +126,6 @@ CheckIsa (
return (BOOLEAN)(Isa == IsaIa32);
}
-
/**
This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
It is, by default, set to find the register pointer of the IA32 member
@@ -146,12 +140,12 @@ FindPointerToRegister (
IN UINTN RegNumber
)
{
- UINT8 *TempPtr;
+ UINT8 *TempPtr;
+
TempPtr = ((UINT8 *)SystemContext.SystemContextIa32) + gRegisterOffsets[RegNumber];
return (UINTN *)TempPtr;
}
-
/**
Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
@@ -162,23 +156,23 @@ FindPointerToRegister (
**/
CHAR8 *
BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN RegNumber,
+ IN CHAR8 *OutBufPtr
)
{
- UINTN RegSize;
+ UINTN RegSize;
RegSize = 0;
while (RegSize < REG_SIZE) {
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
- RegSize = RegSize + 8;
+ RegSize = RegSize + 8;
}
+
return OutBufPtr;
}
-
/** ‘p n’
Reads the n-th register's value into an output buffer and sends it as a packet
@@ -188,17 +182,17 @@ BasicReadRegister (
VOID
EFIAPI
ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *InBuffer
)
{
- UINTN RegNumber;
- CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
+ UINTN RegNumber;
+ CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)
+ CHAR8 *OutBufPtr; // pointer to the output buffer
RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
+ if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount ())) {
SendError (GDB_EINVALIDREGNUM);
return;
}
@@ -207,10 +201,9 @@ ReadNthRegister (
OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
*OutBufPtr = '\0'; // the end of the buffer
- SendPacket(OutBuffer);
+ SendPacket (OutBuffer);
}
-
/** ‘g’
Reads the general registers into an output buffer and sends it as a packet
@@ -219,23 +212,23 @@ ReadNthRegister (
VOID
EFIAPI
ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- UINTN i;
- CHAR8 OutBuffer[129]; // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
+ UINTN i;
+ CHAR8 OutBuffer[129]; // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
+ CHAR8 *OutBufPtr; // pointer to the output buffer
OutBufPtr = OutBuffer;
- for (i = 0 ; i < MaxRegisterCount() ; i++) { // there are only 16 registers to read
+ for (i = 0; i < MaxRegisterCount (); i++) {
+ // there are only 16 registers to read
OutBufPtr = BasicReadRegister (SystemContext, i, OutBufPtr);
}
*OutBufPtr = '\0'; // the end of the buffer
- SendPacket(OutBuffer);
+ SendPacket (OutBuffer);
}
-
/**
Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
@@ -246,27 +239,27 @@ ReadGeneralRegisters (
**/
CHAR8 *
BasicWriteRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *InBufPtr
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN RegNumber,
+ IN CHAR8 *InBufPtr
)
{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT32 NewValue; // the new value of the RegNumber-th Register
+ UINTN RegSize;
+ UINTN TempValue; // the value transferred from a hex char
+ UINT32 NewValue; // the new value of the RegNumber-th Register
NewValue = 0;
- RegSize = 0;
+ RegSize = 0;
while (RegSize < REG_SIZE) {
- TempValue = HexCharToInt(*InBufPtr++);
+ TempValue = HexCharToInt (*InBufPtr++);
- if (TempValue < 0) {
+ if (TempValue < 0) {
SendError (GDB_EBADMEMDATA);
return NULL;
}
NewValue += (TempValue << (RegSize+4));
- TempValue = HexCharToInt(*InBufPtr++);
+ TempValue = HexCharToInt (*InBufPtr++);
if (TempValue < 0) {
SendError (GDB_EBADMEMDATA);
@@ -274,13 +267,13 @@ BasicWriteRegister (
}
NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
+ RegSize = RegSize + 8;
}
+
*(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
return InBufPtr;
}
-
/** ‘P n...=r...’
Writes the new value of n-th register received into the input buffer to the n-th register
@@ -290,35 +283,36 @@ BasicWriteRegister (
VOID
EFIAPI
WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *InBuffer
)
{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
+ UINTN RegNumber;
+ CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
+ CHAR8 *RegNumBufPtr;
+ CHAR8 *InBufPtr; // pointer to the input buffer
// find the register number to write
- InBufPtr = &InBuffer[1];
+ InBufPtr = &InBuffer[1];
RegNumBufPtr = RegNumBuffer;
while (*InBufPtr != '=') {
*RegNumBufPtr++ = *InBufPtr++;
}
+
*RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
+ RegNumber = AsciiStrHexToUintn (RegNumBuffer);
// check if this is a valid Register Number
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
+ if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount ())) {
SendError (GDB_EINVALIDREGNUM);
return;
}
+
InBufPtr++; // skips the '=' character
BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
+ SendSuccess ();
}
-
/** ‘G XX...’
Writes the new values received into the input buffer to the general registers
@@ -328,17 +322,18 @@ WriteNthRegister (
VOID
EFIAPI
WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *InBuffer
)
{
UINTN i;
- CHAR8 *InBufPtr; /// pointer to the input buffer
+ CHAR8 *InBufPtr; /// pointer to the input buffer
// check to see if the buffer is the right size which is
// 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 129
- if (AsciiStrLen(InBuffer) != 129) { // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
- //Bad message. Message is not the right length
+ if (AsciiStrLen (InBuffer) != 129) {
+ // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
+ // Bad message. Message is not the right length
SendError (GDB_EBADBUFSIZE);
return;
}
@@ -347,14 +342,14 @@ WriteGeneralRegisters (
// Read the new values for the registers from the input buffer to an array, NewValueArray.
// The values in the array are in the gdb ordering
- for (i=0; i < MaxRegisterCount(); i++) { // there are only 16 registers to write
+ for (i = 0; i < MaxRegisterCount (); i++) {
+ // there are only 16 registers to write
InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
}
- SendSuccess();
+ SendSuccess ();
}
-
/**
Insert Single Step in the SystemContext
@@ -365,10 +360,9 @@ AddSingleStep (
IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- SystemContext.SystemContextIa32->Eflags |= TF_BIT; //Setting the TF bit.
+ SystemContext.SystemContextIa32->Eflags |= TF_BIT; // Setting the TF bit.
}
-
/**
Remove Single Step in the SystemContext
@@ -382,8 +376,6 @@ RemoveSingleStep (
SystemContext.SystemContextIa32->Eflags &= ~TF_BIT; // clearing the TF bit.
}
-
-
/** ‘c [addr ]’
Continue. addr is Address to resume. If addr is omitted, resume at current
Address.
@@ -393,8 +385,8 @@ RemoveSingleStep (
VOID
EFIAPI
ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *PacketData
)
{
if (PacketData[1] != '\0') {
@@ -402,7 +394,6 @@ ContinueAtAddress (
}
}
-
/** ‘s [addr ]’
Single step. addr is the Address at which to resume. If addr is omitted, resume
at same Address.
@@ -412,8 +403,8 @@ ContinueAtAddress (
VOID
EFIAPI
SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *PacketData
)
{
if (PacketData[1] != '\0') {
@@ -423,7 +414,6 @@ SingleStep (
AddSingleStep (SystemContext);
}
-
/**
Returns breakpoint data address from DR0-DR3 based on the input breakpoint number
@@ -439,7 +429,7 @@ GetBreakpointDataAddress (
IN UINTN BreakpointNumber
)
{
- UINTN Address;
+ UINTN Address;
if (BreakpointNumber == 1) {
Address = SystemContext.SystemContextIa32->Dr0;
@@ -456,7 +446,6 @@ GetBreakpointDataAddress (
return Address;
}
-
/**
Returns currently detected breakpoint value based on the register DR6 B0-B3 field.
If no breakpoint is detected then it returns 0.
@@ -472,8 +461,8 @@ GetBreakpointDetected (
IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- IA32_DR6 Dr6;
- UINTN BreakpointNumber;
+ IA32_DR6 Dr6;
+ UINTN BreakpointNumber;
Dr6.UintN = SystemContext.SystemContextIa32->Dr6;
@@ -486,13 +475,12 @@ GetBreakpointDetected (
} else if (Dr6.Bits.B3 == 1) {
BreakpointNumber = 4;
} else {
- BreakpointNumber = 0; //No breakpoint detected
+ BreakpointNumber = 0; // No breakpoint detected
}
return BreakpointNumber;
}
-
/**
Returns Breakpoint type (InstructionExecution, DataWrite, DataRead or DataReadWrite)
based on the Breakpoint number
@@ -510,25 +498,24 @@ GetBreakpointType (
IN UINTN BreakpointNumber
)
{
- IA32_DR7 Dr7;
- BREAK_TYPE Type = NotSupported; //Default is NotSupported type
+ IA32_DR7 Dr7;
+ BREAK_TYPE Type = NotSupported; // Default is NotSupported type
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
if (BreakpointNumber == 1) {
- Type = (BREAK_TYPE) Dr7.Bits.RW0;
+ Type = (BREAK_TYPE)Dr7.Bits.RW0;
} else if (BreakpointNumber == 2) {
- Type = (BREAK_TYPE) Dr7.Bits.RW1;
+ Type = (BREAK_TYPE)Dr7.Bits.RW1;
} else if (BreakpointNumber == 3) {
- Type = (BREAK_TYPE) Dr7.Bits.RW2;
+ Type = (BREAK_TYPE)Dr7.Bits.RW2;
} else if (BreakpointNumber == 4) {
- Type = (BREAK_TYPE) Dr7.Bits.RW3;
+ Type = (BREAK_TYPE)Dr7.Bits.RW3;
}
return Type;
}
-
/**
Parses Length and returns the length which DR7 LENn field accepts.
For example: If we receive 1-Byte length then we should return 0.
@@ -541,21 +528,24 @@ GetBreakpointType (
**/
UINTN
ConvertLengthData (
- IN UINTN Length
+ IN UINTN Length
)
{
- if (Length == 1) { //1-Byte length
+ if (Length == 1) {
+ // 1-Byte length
return 0;
- } else if (Length == 2) { //2-Byte length
+ } else if (Length == 2) {
+ // 2-Byte length
return 1;
- } else if (Length == 4) { //4-Byte length
+ } else if (Length == 4) {
+ // 4-Byte length
return 3;
- } else { //Undefined or 8-byte length
+ } else {
+ // Undefined or 8-byte length
return 2;
}
}
-
/**
Finds the next free debug register. If all the registers are occupied then
EFI_OUT_OF_RESOURCES is returned.
@@ -572,7 +562,7 @@ FindNextFreeDebugRegister (
OUT UINTN *Register
)
{
- IA32_DR7 Dr7;
+ IA32_DR7 Dr7;
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
@@ -591,7 +581,6 @@ FindNextFreeDebugRegister (
return EFI_SUCCESS;
}
-
/**
Enables the debug register. Writes Address value to appropriate DR0-3 register.
Sets LENn, Gn, RWn bits in DR7 register.
@@ -616,56 +605,56 @@ EnableDebugRegister (
{
IA32_DR7 Dr7;
- //Convert length data
+ // Convert length data
Length = ConvertLengthData (Length);
- //For Instruction execution, length should be 0
- //(Ref. Intel reference manual 18.2.4)
+ // For Instruction execution, length should be 0
+ // (Ref. Intel reference manual 18.2.4)
if ((Type == 0) && (Length != 0)) {
return EFI_INVALID_PARAMETER;
}
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
+ // Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
+ // software breakpoint. We should send empty packet in both these cases.
if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
+ (Type == (BREAK_TYPE)SoftwareBreakpoint))
+ {
return EFI_UNSUPPORTED;
}
- //Read DR7 so appropriate Gn, RWn and LENn bits can be modified.
+ // Read DR7 so appropriate Gn, RWn and LENn bits can be modified.
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
if (Register == 0) {
SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 1;
- Dr7.Bits.RW0 = Type;
- Dr7.Bits.LEN0 = Length;
+ Dr7.Bits.G0 = 1;
+ Dr7.Bits.RW0 = Type;
+ Dr7.Bits.LEN0 = Length;
} else if (Register == 1) {
SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 1;
- Dr7.Bits.RW1 = Type;
- Dr7.Bits.LEN1 = Length;
+ Dr7.Bits.G1 = 1;
+ Dr7.Bits.RW1 = Type;
+ Dr7.Bits.LEN1 = Length;
} else if (Register == 2) {
SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 1;
- Dr7.Bits.RW2 = Type;
- Dr7.Bits.LEN2 = Length;
+ Dr7.Bits.G2 = 1;
+ Dr7.Bits.RW2 = Type;
+ Dr7.Bits.LEN2 = Length;
} else if (Register == 3) {
SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 1;
- Dr7.Bits.RW3 = Type;
- Dr7.Bits.LEN3 = Length;
+ Dr7.Bits.G3 = 1;
+ Dr7.Bits.RW3 = Type;
+ Dr7.Bits.LEN3 = Length;
} else {
return EFI_INVALID_PARAMETER;
}
- //Update Dr7 with appropriate Gn, RWn and LENn bits
+ // Update Dr7 with appropriate Gn, RWn and LENn bits
SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
return EFI_SUCCESS;
}
-
/**
Returns register number 0 - 3 for the matching debug register.
This function compares incoming Address, Type, Length and
@@ -684,46 +673,51 @@ EnableDebugRegister (
**/
EFI_STATUS
FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- )
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN Address,
+ IN UINTN Length,
+ IN UINTN Type,
+ OUT UINTN *Register
+ )
{
- IA32_DR7 Dr7;
+ IA32_DR7 Dr7;
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
+ // Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
+ // software breakpoint. We should send empty packet in both these cases.
if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
+ (Type == (BREAK_TYPE)SoftwareBreakpoint))
+ {
return EFI_UNSUPPORTED;
}
- //Convert length data
- Length = ConvertLengthData(Length);
+ // Convert length data
+ Length = ConvertLengthData (Length);
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
if ((Dr7.Bits.G0 == 1) &&
(Dr7.Bits.LEN0 == Length) &&
(Dr7.Bits.RW0 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr0)) {
+ (Address == SystemContext.SystemContextIa32->Dr0))
+ {
*Register = 0;
} else if ((Dr7.Bits.G1 == 1) &&
(Dr7.Bits.LEN1 == Length) &&
(Dr7.Bits.RW1 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr1)) {
+ (Address == SystemContext.SystemContextIa32->Dr1))
+ {
*Register = 1;
} else if ((Dr7.Bits.G2 == 1) &&
(Dr7.Bits.LEN2 == Length) &&
(Dr7.Bits.RW2 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr2)) {
+ (Address == SystemContext.SystemContextIa32->Dr2))
+ {
*Register = 2;
} else if ((Dr7.Bits.G3 == 1) &&
(Dr7.Bits.LEN3 == Length) &&
(Dr7.Bits.RW3 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr3)) {
+ (Address == SystemContext.SystemContextIa32->Dr3))
+ {
*Register = 3;
} else {
Print ((CHAR16 *)L"No match found..\n");
@@ -733,7 +727,6 @@ FindMatchingDebugRegister (
return EFI_SUCCESS;
}
-
/**
Disables the particular debug register.
@@ -745,47 +738,46 @@ FindMatchingDebugRegister (
**/
EFI_STATUS
DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- )
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN Register
+ )
{
IA32_DR7 Dr7;
- UINTN Address = 0;
+ UINTN Address = 0;
- //Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
+ // Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
if (Register == 0) {
SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 0;
- Dr7.Bits.RW0 = 0;
- Dr7.Bits.LEN0 = 0;
+ Dr7.Bits.G0 = 0;
+ Dr7.Bits.RW0 = 0;
+ Dr7.Bits.LEN0 = 0;
} else if (Register == 1) {
SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 0;
- Dr7.Bits.RW1 = 0;
- Dr7.Bits.LEN1 = 0;
+ Dr7.Bits.G1 = 0;
+ Dr7.Bits.RW1 = 0;
+ Dr7.Bits.LEN1 = 0;
} else if (Register == 2) {
SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 0;
- Dr7.Bits.RW2 = 0;
- Dr7.Bits.LEN2 = 0;
+ Dr7.Bits.G2 = 0;
+ Dr7.Bits.RW2 = 0;
+ Dr7.Bits.LEN2 = 0;
} else if (Register == 3) {
SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 0;
- Dr7.Bits.RW3 = 0;
- Dr7.Bits.LEN3 = 0;
+ Dr7.Bits.G3 = 0;
+ Dr7.Bits.RW3 = 0;
+ Dr7.Bits.LEN3 = 0;
} else {
return EFI_INVALID_PARAMETER;
}
- //Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
+ // Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
return EFI_SUCCESS;
}
-
/**
‘Z1, [addr], [length]’
‘Z2, [addr], [length]’
@@ -802,16 +794,16 @@ VOID
EFIAPI
InsertBreakPoint (
IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN CHAR8 *PacketData
)
{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- EFI_STATUS Status;
- BREAK_TYPE BreakType = NotSupported;
- UINTN ErrorCode;
+ UINTN Type;
+ UINTN Address;
+ UINTN Length;
+ UINTN Register;
+ EFI_STATUS Status;
+ BREAK_TYPE BreakType = NotSupported;
+ UINTN ErrorCode;
ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
if (ErrorCode > 0) {
@@ -820,28 +812,27 @@ InsertBreakPoint (
}
switch (Type) {
-
- case 0: //Software breakpoint
+ case 0: // Software breakpoint
BreakType = SoftwareBreakpoint;
break;
- case 1: //Hardware breakpoint
+ case 1: // Hardware breakpoint
BreakType = InstructionExecution;
break;
- case 2: //Write watchpoint
+ case 2: // Write watchpoint
BreakType = DataWrite;
break;
- case 3: //Read watchpoint
+ case 3: // Read watchpoint
BreakType = DataRead;
break;
- case 4: //Access watchpoint
+ case 4: // Access watchpoint
BreakType = DataReadWrite;
break;
- default :
+ default:
Print ((CHAR16 *)L"Insert breakpoint default: %x\n", Type);
SendError (GDB_EINVALIDBRKPOINTTYPE);
return;
@@ -849,7 +840,7 @@ InsertBreakPoint (
// Find next free debug register
Status = FindNextFreeDebugRegister (SystemContext, &Register);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
Print ((CHAR16 *)L"No space left on device\n");
SendError (GDB_ENOSPACE);
return;
@@ -857,8 +848,7 @@ InsertBreakPoint (
// Write Address, length data at particular DR register
Status = EnableDebugRegister (SystemContext, Register, Address, Length, (UINTN)BreakType);
- if (EFI_ERROR(Status)) {
-
+ if (EFI_ERROR (Status)) {
if (Status == EFI_UNSUPPORTED) {
Print ((CHAR16 *)L"Not supported\n");
SendNotSupported ();
@@ -873,7 +863,6 @@ InsertBreakPoint (
SendSuccess ();
}
-
/**
‘z1, [addr], [length]’
‘z2, [addr], [length]’
@@ -892,15 +881,15 @@ RemoveBreakPoint (
IN CHAR8 *PacketData
)
{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- BREAK_TYPE BreakType = NotSupported;
- EFI_STATUS Status;
- UINTN ErrorCode;
-
- //Parse breakpoint packet data
+ UINTN Type;
+ UINTN Address;
+ UINTN Length;
+ UINTN Register;
+ BREAK_TYPE BreakType = NotSupported;
+ EFI_STATUS Status;
+ UINTN ErrorCode;
+
+ // Parse breakpoint packet data
ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
if (ErrorCode > 0) {
SendError ((UINT8)ErrorCode);
@@ -908,36 +897,34 @@ RemoveBreakPoint (
}
switch (Type) {
-
- case 0: //Software breakpoint
+ case 0: // Software breakpoint
BreakType = SoftwareBreakpoint;
break;
- case 1: //Hardware breakpoint
+ case 1: // Hardware breakpoint
BreakType = InstructionExecution;
break;
- case 2: //Write watchpoint
+ case 2: // Write watchpoint
BreakType = DataWrite;
break;
- case 3: //Read watchpoint
+ case 3: // Read watchpoint
BreakType = DataRead;
break;
- case 4: //Access watchpoint
+ case 4: // Access watchpoint
BreakType = DataReadWrite;
break;
- default :
+ default:
SendError (GDB_EINVALIDBRKPOINTTYPE);
return;
}
- //Find matching debug register
+ // Find matching debug register
Status = FindMatchingDebugRegister (SystemContext, Address, Length, (UINTN)BreakType, &Register);
- if (EFI_ERROR(Status)) {
-
+ if (EFI_ERROR (Status)) {
if (Status == EFI_UNSUPPORTED) {
Print ((CHAR16 *)L"Not supported.\n");
SendNotSupported ();
@@ -949,9 +936,9 @@ RemoveBreakPoint (
return;
}
- //Remove breakpoint
+ // Remove breakpoint
Status = DisableDebugRegister (SystemContext, Register);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
Print ((CHAR16 *)L"Invalid argument.\n");
SendError (GDB_EINVALIDARG);
return;
@@ -960,7 +947,6 @@ RemoveBreakPoint (
SendSuccess ();
}
-
VOID
InitializeProcessor (
VOID
@@ -978,10 +964,9 @@ ValidateAddress (
BOOLEAN
ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return TRUE;
}
-
diff --git a/EmbeddedPkg/GdbStub/SerialIo.c b/EmbeddedPkg/GdbStub/SerialIo.c
index 08d1763c30..9970ab687e 100644
--- a/EmbeddedPkg/GdbStub/SerialIo.c
+++ b/EmbeddedPkg/GdbStub/SerialIo.c
@@ -18,14 +18,14 @@
// Set TRUE if F Reply package signals a ctrl-c. We can not process the Ctrl-c
// here we need to wait for the periodic callback to do this.
//
-BOOLEAN gCtrlCBreakFlag = FALSE;
+BOOLEAN gCtrlCBreakFlag = FALSE;
//
// If the periodic callback is called while we are processing an F packet we need
// to let the callback know to not read from the serial stream as it could steal
// characters from the F response packet
//
-BOOLEAN gProcessingFPacket = FALSE;
+BOOLEAN gProcessingFPacket = FALSE;
/**
Process a control-C break message.
@@ -35,21 +35,19 @@ BOOLEAN gProcessingFPacket = FALSE;
@param ErrNo Error information from the F reply packet or other source
**/
-
VOID
GdbCtrlCBreakMessage (
- IN UINTN ErrNo
+ IN UINTN ErrNo
)
{
// See D.10.5 of gdb.pdf
// This should look like a break message. Should look like SIGINT
/* TODO: Make sure if we should do anything with ErrNo */
- //Turn on the global Ctrl-C flag.
+ // Turn on the global Ctrl-C flag.
gCtrlCBreakFlag = TRUE;
}
-
/**
Parse the F reply packet and extract the return value and an ErrNo if it exists.
@@ -62,11 +60,11 @@ GdbCtrlCBreakMessage (
**/
INTN
GdbParseFReplyPacket (
- IN CHAR8 *Packet,
- OUT UINTN *ErrNo
+ IN CHAR8 *Packet,
+ OUT UINTN *ErrNo
)
{
- INTN RetCode;
+ INTN RetCode;
if (Packet[0] != 'F') {
// A valid response would be an F packet
@@ -76,7 +74,9 @@ GdbParseFReplyPacket (
RetCode = AsciiStrHexToUintn (&Packet[1]);
// Find 1st comma
- for (;*Packet != '\0' && *Packet != ','; Packet++);
+ for ( ; *Packet != '\0' && *Packet != ','; Packet++) {
+ }
+
if (*Packet == '\0') {
*ErrNo = 0;
return RetCode;
@@ -85,7 +85,9 @@ GdbParseFReplyPacket (
*ErrNo = AsciiStrHexToUintn (++Packet);
// Find 2nd comma
- for (;*Packet != '\0' && *Packet != ','; Packet++);
+ for ( ; *Packet != '\0' && *Packet != ','; Packet++) {
+ }
+
if (*Packet == '\0') {
return RetCode;
}
@@ -97,7 +99,6 @@ GdbParseFReplyPacket (
return RetCode;
}
-
/**
Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates
the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.
@@ -112,16 +113,16 @@ GdbParseFReplyPacket (
**/
INTN
GdbRead (
- IN INTN FileDescriptor,
- OUT VOID *Buffer,
- IN UINTN Count
+ IN INTN FileDescriptor,
+ OUT VOID *Buffer,
+ IN UINTN Count
)
{
- CHAR8 Packet[128];
- UINTN Size;
- INTN RetCode;
- UINTN ErrNo;
- BOOLEAN ReceiveDone = FALSE;
+ CHAR8 Packet[128];
+ UINTN Size;
+ INTN RetCode;
+ UINTN ErrNo;
+ BOOLEAN ReceiveDone = FALSE;
// Send:
// "Fread,XX,YYYYYYYY,XX
@@ -146,23 +147,23 @@ GdbRead (
// Process GDB commands
switch (Packet[0]) {
- //Write memory command.
- //M addr,length:XX...
+ // Write memory command.
+ // M addr,length:XX...
case 'M':
WriteToMemory (Packet);
break;
- //Fretcode, errno, Ctrl-C flag
- //retcode - Count read
+ // Fretcode, errno, Ctrl-C flag
+ // retcode - Count read
case 'F':
- //Once target receives F reply packet that means the previous
- //transactions are finished.
+ // Once target receives F reply packet that means the previous
+ // transactions are finished.
ReceiveDone = TRUE;
break;
- //Send empty buffer
- default :
- SendNotSupported();
+ // Send empty buffer
+ default:
+ SendNotSupported ();
break;
}
} while (ReceiveDone == FALSE);
@@ -171,7 +172,7 @@ GdbRead (
Print ((CHAR16 *)L"RetCode: %x..ErrNo: %x..\n", RetCode, ErrNo);
if (ErrNo > 0) {
- //Send error to the host if there is any.
+ // Send error to the host if there is any.
SendError ((UINT8)ErrNo);
}
@@ -180,7 +181,6 @@ GdbRead (
return RetCode;
}
-
/**
Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates
nothing was written. On error -1 is returned.
@@ -195,16 +195,16 @@ GdbRead (
**/
INTN
GdbWrite (
- IN INTN FileDescriptor,
- OUT CONST VOID *Buffer,
- IN UINTN Count
+ IN INTN FileDescriptor,
+ OUT CONST VOID *Buffer,
+ IN UINTN Count
)
{
- CHAR8 Packet[128];
- UINTN Size;
- INTN RetCode;
- UINTN ErrNo;
- BOOLEAN ReceiveDone = FALSE;
+ CHAR8 Packet[128];
+ UINTN Size;
+ INTN RetCode;
+ UINTN ErrNo;
+ BOOLEAN ReceiveDone = FALSE;
// Send:
// #Fwrite,XX,YYYYYYYY,XX$SS
@@ -228,23 +228,23 @@ GdbWrite (
// Process GDB commands
switch (Packet[0]) {
- //Read memory command.
- //m addr,length.
+ // Read memory command.
+ // m addr,length.
case 'm':
ReadFromMemory (Packet);
break;
- //Fretcode, errno, Ctrl-C flag
- //retcode - Count read
+ // Fretcode, errno, Ctrl-C flag
+ // retcode - Count read
case 'F':
- //Once target receives F reply packet that means the previous
- //transactions are finished.
+ // Once target receives F reply packet that means the previous
+ // transactions are finished.
ReceiveDone = TRUE;
break;
- //Send empty buffer
- default :
- SendNotSupported();
+ // Send empty buffer
+ default:
+ SendNotSupported ();
break;
}
} while (ReceiveDone == FALSE);
@@ -252,15 +252,14 @@ GdbWrite (
RetCode = GdbParseFReplyPacket (Packet, &ErrNo);
Print ((CHAR16 *)L"RetCode: %x..ErrNo: %x..\n", RetCode, ErrNo);
- //Send error to the host if there is any.
+ // Send error to the host if there is any.
if (ErrNo > 0) {
- SendError((UINT8)ErrNo);
+ SendError ((UINT8)ErrNo);
}
return RetCode;
}
-
/**
Reset the serial device.
@@ -279,7 +278,6 @@ GdbSerialReset (
return EFI_SUCCESS;
}
-
/**
Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,
data buts, and stop bits on a serial device.
@@ -321,7 +319,6 @@ GdbSerialSetAttributes (
return EFI_UNSUPPORTED;
}
-
/**
Set the control bits on a serial device
@@ -343,7 +340,6 @@ GdbSerialSetControl (
return EFI_UNSUPPORTED;
}
-
/**
Retrieves the status of the control bits on a serial device
@@ -364,7 +360,6 @@ GdbSerialGetControl (
return EFI_UNSUPPORTED;
}
-
/**
Writes data to a serial device.
@@ -387,7 +382,7 @@ GdbSerialWrite (
)
{
GDB_SERIAL_DEV *SerialDev;
- UINTN Return;
+ UINTN Return;
SerialDev = GDB_SERIAL_DEV_FROM_THIS (This);
@@ -416,7 +411,6 @@ GdbSerialWrite (
@retval EFI_TIMEOUT The data write was stopped due to a timeout.
**/
-
EFI_STATUS
EFIAPI
GdbSerialRead (
@@ -426,7 +420,7 @@ GdbSerialRead (
)
{
GDB_SERIAL_DEV *SerialDev;
- UINTN Return;
+ UINTN Return;
SerialDev = GDB_SERIAL_DEV_FROM_THIS (This);
@@ -442,11 +436,10 @@ GdbSerialRead (
return EFI_SUCCESS;
}
-
//
// Template used to initialize the GDB Serial IO protocols
//
-GDB_SERIAL_DEV gdbSerialDevTemplate = {
+GDB_SERIAL_DEV gdbSerialDevTemplate = {
GDB_SERIAL_DEV_SIGNATURE,
NULL,
@@ -460,14 +453,14 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
GdbSerialRead,
NULL
},
- { // SerialMode
- 0, // ControlMask
- 0, // Timeout
- 0, // BaudRate
- 1, // RceiveFifoDepth
- 0, // DataBits
- 0, // Parity
- 0 // StopBits
+ { // SerialMode
+ 0, // ControlMask
+ 0, // Timeout
+ 0, // BaudRate
+ 1, // RceiveFifoDepth
+ 0, // DataBits
+ 0, // Parity
+ 0 // StopBits
},
{
{
@@ -475,8 +468,8 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)) >> 8)
},
},
EFI_SERIAL_IO_PROTOCOL_GUID
@@ -486,8 +479,8 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL)),
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL) >> 8)
+ (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
+ (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL) >> 8)
}
},
},
@@ -495,7 +488,6 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
GDB_STDOUT
};
-
/**
Make two serial consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.
@@ -512,25 +504,27 @@ GdbInitializeSerialConsole (
GDB_SERIAL_DEV *StdErrSerialDev;
// Use the template to make a copy of the Serial Console private data structure.
- StdOutSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
+ StdOutSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
ASSERT (StdOutSerialDev != NULL);
// Fixup pointer after the copy
StdOutSerialDev->SerialIo.Mode = &StdOutSerialDev->SerialMode;
- StdErrSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
+ StdErrSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
ASSERT (StdErrSerialDev != NULL);
// Fixup pointer and modify stuff that is different for StdError
- StdErrSerialDev->SerialIo.Mode = &StdErrSerialDev->SerialMode;
- StdErrSerialDev->DevicePath.Index = 1;
+ StdErrSerialDev->SerialIo.Mode = &StdErrSerialDev->SerialMode;
+ StdErrSerialDev->DevicePath.Index = 1;
StdErrSerialDev->OutFileDescriptor = GDB_STDERR;
// Make a new handle with Serial IO protocol and its device path on it.
Status = gBS->InstallMultipleProtocolInterfaces (
&StdOutSerialDev->Handle,
- &gEfiSerialIoProtocolGuid, &StdOutSerialDev->SerialIo,
- &gEfiDevicePathProtocolGuid, &StdOutSerialDev->DevicePath,
+ &gEfiSerialIoProtocolGuid,
+ &StdOutSerialDev->SerialIo,
+ &gEfiDevicePathProtocolGuid,
+ &StdOutSerialDev->DevicePath,
NULL
);
ASSERT_EFI_ERROR (Status);
@@ -538,10 +532,11 @@ GdbInitializeSerialConsole (
// Make a new handle with Serial IO protocol and its device path on it.
Status = gBS->InstallMultipleProtocolInterfaces (
&StdErrSerialDev->Handle,
- &gEfiSerialIoProtocolGuid, &StdErrSerialDev->SerialIo,
- &gEfiDevicePathProtocolGuid, &StdErrSerialDev->DevicePath,
+ &gEfiSerialIoProtocolGuid,
+ &StdErrSerialDev->SerialIo,
+ &gEfiDevicePathProtocolGuid,
+ &StdErrSerialDev->DevicePath,
NULL
);
ASSERT_EFI_ERROR (Status);
}
-
diff --git a/EmbeddedPkg/GdbStub/X64/Processor.c b/EmbeddedPkg/GdbStub/X64/Processor.c
index c6599a2b2b..4ff79abe42 100644
--- a/EmbeddedPkg/GdbStub/X64/Processor.c
+++ b/EmbeddedPkg/GdbStub/X64/Processor.c
@@ -12,7 +12,7 @@
//
// Array of exception types that need to be hooked by the debugger
//
-EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
+EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
{ EXCEPT_X64_DIVIDE_ERROR, GDB_SIGFPE },
{ EXCEPT_X64_DEBUG, GDB_SIGTRAP },
{ EXCEPT_X64_NMI, GDB_SIGEMT },
@@ -29,39 +29,37 @@ EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
{ EXCEPT_X64_MACHINE_CHECK, GDB_SIGEMT }
};
-
// The offsets of registers SystemContextX64.
// The fields in the array are in the gdb ordering.
// HAVE TO DOUBLE-CHECK THE ORDER of the 24 regs
//
-UINTN gRegisterOffsets[] = {
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rax),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rcx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rdx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rbx),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rsp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rbp),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rsi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rdi),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rip),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Rflags),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Cs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Ss),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Ds),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Es),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Fs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, Gs),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R8),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R9),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R10),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R11),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R12),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R13),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R14),
- OFFSET_OF(EFI_SYSTEM_CONTEXT_X64, R15)
+UINTN gRegisterOffsets[] = {
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rax),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rcx),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rdx),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rbx),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rsp),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rbp),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rsi),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rdi),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rip),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Rflags),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Cs),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Ss),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Ds),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Es),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Fs),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, Gs),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, R8),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, R9),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, R10),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, R11),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, R12),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, R13),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, R14),
+ OFFSET_OF (EFI_SYSTEM_CONTEXT_X64, R15)
};
-
/**
Return the number of entries in the gExceptionType[]
@@ -75,7 +73,6 @@ MaxEfiException (
return sizeof (gExceptionType)/sizeof (EFI_EXCEPTION_TYPE_ENTRY);
}
-
/**
Return the number of entries in the gRegisters[]
@@ -89,7 +86,6 @@ MaxRegisterCount (
return sizeof (gRegisterOffsets)/sizeof (UINTN);
}
-
/**
Check to see if the ISA is supported.
ISA = Instruction Set Architecture
@@ -104,7 +100,6 @@ CheckIsa (
return (BOOLEAN)(Isa == IsaX64);
}
-
/**
This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering
It is, by default, set to find the register pointer of the X64 member
@@ -113,17 +108,17 @@ CheckIsa (
@retval the pointer to the RegNumber-th pointer
**/
UINTN *
-FindPointerToRegister(
+FindPointerToRegister (
IN EFI_SYSTEM_CONTEXT SystemContext,
IN UINTN RegNumber
)
{
- UINT8 *TempPtr;
+ UINT8 *TempPtr;
+
TempPtr = ((UINT8 *)SystemContext.SystemContextX64) + gRegisterOffsets[RegNumber];
return (UINTN *)TempPtr;
}
-
/**
Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
@param SystemContext Register content at time of the exception
@@ -133,23 +128,23 @@ FindPointerToRegister(
**/
CHAR8 *
BasicReadRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN RegNumber,
- IN CHAR8 *OutBufPtr
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN RegNumber,
+ IN CHAR8 *OutBufPtr
)
{
- UINTN RegSize;
+ UINTN RegSize;
RegSize = 0;
while (RegSize < 64) {
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
- *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
- RegSize = RegSize + 8;
+ *OutBufPtr++ = mHexToStr[((*FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
+ *OutBufPtr++ = mHexToStr[((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
+ RegSize = RegSize + 8;
}
+
return OutBufPtr;
}
-
/** ‘p n’
Reads the n-th register's value into an output buffer and sends it as a packet
@param SystemContext Register content at time of the exception
@@ -157,29 +152,28 @@ BasicReadRegister (
**/
VOID
ReadNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *InBuffer
)
{
- UINTN RegNumber;
- CHAR8 OutBuffer[17]; // 1 reg=16 hex chars, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
+ UINTN RegNumber;
+ CHAR8 OutBuffer[17]; // 1 reg=16 hex chars, and the end '\0' (escape seq)
+ CHAR8 *OutBufPtr; // pointer to the output buffer
RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
+ if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount ())) {
SendError (GDB_EINVALIDREGNUM);
return;
}
OutBufPtr = OutBuffer;
- OutBufPtr = BasicReadRegister(SystemContext, RegNumber, OutBufPtr);
+ OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
*OutBufPtr = '\0'; // the end of the buffer
SendPacket (OutBuffer);
}
-
/** ‘g’
Reads the general registers into an output buffer and sends it as a packet
@@ -188,23 +182,23 @@ ReadNthRegister (
VOID
EFIAPI
ReadGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- UINTN i;
- CHAR8 OutBuffer[385]; // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
- CHAR8 *OutBufPtr; // pointer to the output buffer
+ UINTN i;
+ CHAR8 OutBuffer[385]; // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
+ CHAR8 *OutBufPtr; // pointer to the output buffer
OutBufPtr = OutBuffer;
- for(i = 0 ; i < MaxRegisterCount() ; i++) { // there are only 24 registers to read
- OutBufPtr = BasicReadRegister(SystemContext, i, OutBufPtr);
+ for (i = 0; i < MaxRegisterCount (); i++) {
+ // there are only 24 registers to read
+ OutBufPtr = BasicReadRegister (SystemContext, i, OutBufPtr);
}
*OutBufPtr = '\0'; // the end of the buffer
SendPacket (OutBuffer);
}
-
/**
Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr
@@ -220,14 +214,14 @@ BasicWriteRegister (
IN CHAR8 *InBufPtr
)
{
- UINTN RegSize;
- UINTN TempValue; // the value transferred from a hex char
- UINT64 NewValue; // the new value of the RegNumber-th Register
+ UINTN RegSize;
+ UINTN TempValue; // the value transferred from a hex char
+ UINT64 NewValue; // the new value of the RegNumber-th Register
NewValue = 0;
- RegSize = 0;
+ RegSize = 0;
while (RegSize < 64) {
- TempValue = HexCharToInt(*InBufPtr++);
+ TempValue = HexCharToInt (*InBufPtr++);
if (TempValue < 0) {
SendError (GDB_EBADMEMDATA);
@@ -235,21 +229,21 @@ BasicWriteRegister (
}
NewValue += (TempValue << (RegSize+4));
- TempValue = HexCharToInt(*InBufPtr++);
+ TempValue = HexCharToInt (*InBufPtr++);
if (TempValue < 0) {
SendError (GDB_EBADMEMDATA);
return NULL;
- }
+ }
NewValue += (TempValue << RegSize);
- RegSize = RegSize + 8;
+ RegSize = RegSize + 8;
}
- *(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
+
+ *(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
return InBufPtr;
}
-
/** ‘P n...=r...’
Writes the new value of n-th register received into the input buffer to the n-th register
@@ -259,35 +253,36 @@ BasicWriteRegister (
VOID
EFIAPI
WriteNthRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *InBuffer
)
{
- UINTN RegNumber;
- CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
- CHAR8 *RegNumBufPtr;
- CHAR8 *InBufPtr; // pointer to the input buffer
+ UINTN RegNumber;
+ CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE]; // put the 'n..' part of the message into this array
+ CHAR8 *RegNumBufPtr;
+ CHAR8 *InBufPtr; // pointer to the input buffer
// find the register number to write
- InBufPtr = &InBuffer[1];
+ InBufPtr = &InBuffer[1];
RegNumBufPtr = RegNumBuffer;
while (*InBufPtr != '=') {
*RegNumBufPtr++ = *InBufPtr++;
}
+
*RegNumBufPtr = '\0';
- RegNumber = AsciiStrHexToUintn (RegNumBuffer);
+ RegNumber = AsciiStrHexToUintn (RegNumBuffer);
// check if this is a valid Register Number
- if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount())) {
+ if ((RegNumber < 0) || (RegNumber >= MaxRegisterCount ())) {
SendError (GDB_EINVALIDREGNUM);
return;
}
+
InBufPtr++; // skips the '=' character
BasicWriteRegister (SystemContext, RegNumber, InBufPtr);
- SendSuccess();
+ SendSuccess ();
}
-
/** ‘G XX...’
Writes the new values received into the input buffer to the general registers
@@ -297,17 +292,18 @@ WriteNthRegister (
VOID
EFIAPI
WriteGeneralRegisters (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *InBuffer
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *InBuffer
)
{
UINTN i;
- CHAR8 *InBufPtr; /// pointer to the input buffer
+ CHAR8 *InBufPtr; /// pointer to the input buffer
// check to see if the buffer is the right size which is
// 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 385
- if (AsciiStrLen(InBuffer) != 385) { // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
- //Bad message. Message is not the right length
+ if (AsciiStrLen (InBuffer) != 385) {
+ // 24 regs, 16 hex chars each, and the end '\0' (escape seq)
+ // Bad message. Message is not the right length
SendError (GDB_EBADBUFSIZE);
return;
}
@@ -316,29 +312,27 @@ WriteGeneralRegisters (
// Read the new values for the registers from the input buffer to an array, NewValueArray.
// The values in the array are in the gdb ordering
- for(i=0; i < MaxRegisterCount(); i++) { // there are only 16 registers to write
- InBufPtr = BasicWriteRegister(SystemContext, i, InBufPtr);
+ for (i = 0; i < MaxRegisterCount (); i++) {
+ // there are only 16 registers to write
+ InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
}
- SendSuccess();
+ SendSuccess ();
}
+/**
+Insert Single Step in the SystemContext
- /**
- Insert Single Step in the SystemContext
-
- @param SystemContext Register content at time of the exception
- **/
+@param SystemContext Register content at time of the exception
+**/
VOID
AddSingleStep (
IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- SystemContext.SystemContextX64->Rflags |= TF_BIT; //Setting the TF bit.
+ SystemContext.SystemContextX64->Rflags |= TF_BIT; // Setting the TF bit.
}
-
-
/**
Remove Single Step in the SystemContext
@@ -352,8 +346,6 @@ RemoveSingleStep (
SystemContext.SystemContextX64->Rflags &= ~TF_BIT; // clearing the TF bit.
}
-
-
/** ‘c [addr ]’
Continue. addr is Address to resume. If addr is omitted, resume at current
Address.
@@ -363,16 +355,15 @@ RemoveSingleStep (
VOID
EFIAPI
ContinueAtAddress (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *PacketData
)
{
if (PacketData[1] != '\0') {
- SystemContext.SystemContextX64->Rip = AsciiStrHexToUintn(&PacketData[1]);
+ SystemContext.SystemContextX64->Rip = AsciiStrHexToUintn (&PacketData[1]);
}
}
-
/** ‘s [addr ]’
Single step. addr is the Address at which to resume. If addr is omitted, resume
at same Address.
@@ -382,8 +373,8 @@ ContinueAtAddress (
VOID
EFIAPI
SingleStep (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN CHAR8 *PacketData
)
{
if (PacketData[1] != '\0') {
@@ -393,7 +384,6 @@ SingleStep (
AddSingleStep (SystemContext);
}
-
/**
Returns breakpoint data address from DR0-DR3 based on the input breakpoint
number
@@ -411,7 +401,7 @@ GetBreakpointDataAddress (
IN UINTN BreakpointNumber
)
{
- UINTN Address;
+ UINTN Address;
if (BreakpointNumber == 1) {
Address = SystemContext.SystemContextIa32->Dr0;
@@ -444,8 +434,8 @@ GetBreakpointDetected (
IN EFI_SYSTEM_CONTEXT SystemContext
)
{
- IA32_DR6 Dr6;
- UINTN BreakpointNumber;
+ IA32_DR6 Dr6;
+ UINTN BreakpointNumber;
Dr6.UintN = SystemContext.SystemContextIa32->Dr6;
@@ -458,7 +448,7 @@ GetBreakpointDetected (
} else if (Dr6.Bits.B3 == 1) {
BreakpointNumber = 4;
} else {
- BreakpointNumber = 0; //No breakpoint detected
+ BreakpointNumber = 0; // No breakpoint detected
}
return BreakpointNumber;
@@ -481,25 +471,24 @@ GetBreakpointType (
IN UINTN BreakpointNumber
)
{
- IA32_DR7 Dr7;
- BREAK_TYPE Type = NotSupported; //Default is NotSupported type
+ IA32_DR7 Dr7;
+ BREAK_TYPE Type = NotSupported; // Default is NotSupported type
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
if (BreakpointNumber == 1) {
- Type = (BREAK_TYPE) Dr7.Bits.RW0;
+ Type = (BREAK_TYPE)Dr7.Bits.RW0;
} else if (BreakpointNumber == 2) {
- Type = (BREAK_TYPE) Dr7.Bits.RW1;
+ Type = (BREAK_TYPE)Dr7.Bits.RW1;
} else if (BreakpointNumber == 3) {
- Type = (BREAK_TYPE) Dr7.Bits.RW2;
+ Type = (BREAK_TYPE)Dr7.Bits.RW2;
} else if (BreakpointNumber == 4) {
- Type = (BREAK_TYPE) Dr7.Bits.RW3;
+ Type = (BREAK_TYPE)Dr7.Bits.RW3;
}
return Type;
}
-
/**
Parses Length and returns the length which DR7 LENn field accepts.
For example: If we receive 1-Byte length then we should return 0.
@@ -512,21 +501,24 @@ GetBreakpointType (
**/
UINTN
ConvertLengthData (
- IN UINTN Length
+ IN UINTN Length
)
{
- if (Length == 1) { //1-Byte length
+ if (Length == 1) {
+ // 1-Byte length
return 0;
- } else if (Length == 2) { //2-Byte length
+ } else if (Length == 2) {
+ // 2-Byte length
return 1;
- } else if (Length == 4) { //4-Byte length
+ } else if (Length == 4) {
+ // 4-Byte length
return 3;
- } else { //Undefined or 8-byte length
+ } else {
+ // Undefined or 8-byte length
return 2;
}
}
-
/**
Finds the next free debug register. If all the registers are occupied then
EFI_OUT_OF_RESOURCES is returned.
@@ -543,7 +535,7 @@ FindNextFreeDebugRegister (
OUT UINTN *Register
)
{
- IA32_DR7 Dr7;
+ IA32_DR7 Dr7;
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
@@ -562,7 +554,6 @@ FindNextFreeDebugRegister (
return EFI_SUCCESS;
}
-
/**
Enables the debug register. Writes Address value to appropriate DR0-3 register.
Sets LENn, Gn, RWn bits in DR7 register.
@@ -587,56 +578,56 @@ EnableDebugRegister (
{
IA32_DR7 Dr7;
- //Convert length data
+ // Convert length data
Length = ConvertLengthData (Length);
- //For Instruction execution, length should be 0
- //(Ref. Intel reference manual 18.2.4)
+ // For Instruction execution, length should be 0
+ // (Ref. Intel reference manual 18.2.4)
if ((Type == 0) && (Length != 0)) {
return EFI_INVALID_PARAMETER;
}
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
+ // Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
+ // software breakpoint. We should send empty packet in both these cases.
if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
+ (Type == (BREAK_TYPE)SoftwareBreakpoint))
+ {
return EFI_UNSUPPORTED;
}
- //Read DR7 so appropriate Gn, RWn and LENn bits can be modified.
+ // Read DR7 so appropriate Gn, RWn and LENn bits can be modified.
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
if (Register == 0) {
SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 1;
- Dr7.Bits.RW0 = Type;
- Dr7.Bits.LEN0 = Length;
+ Dr7.Bits.G0 = 1;
+ Dr7.Bits.RW0 = Type;
+ Dr7.Bits.LEN0 = Length;
} else if (Register == 1) {
SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 1;
- Dr7.Bits.RW1 = Type;
- Dr7.Bits.LEN1 = Length;
+ Dr7.Bits.G1 = 1;
+ Dr7.Bits.RW1 = Type;
+ Dr7.Bits.LEN1 = Length;
} else if (Register == 2) {
SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 1;
- Dr7.Bits.RW2 = Type;
- Dr7.Bits.LEN2 = Length;
+ Dr7.Bits.G2 = 1;
+ Dr7.Bits.RW2 = Type;
+ Dr7.Bits.LEN2 = Length;
} else if (Register == 3) {
SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 1;
- Dr7.Bits.RW3 = Type;
- Dr7.Bits.LEN3 = Length;
+ Dr7.Bits.G3 = 1;
+ Dr7.Bits.RW3 = Type;
+ Dr7.Bits.LEN3 = Length;
} else {
return EFI_INVALID_PARAMETER;
}
- //Update Dr7 with appropriate Gn, RWn and LENn bits
+ // Update Dr7 with appropriate Gn, RWn and LENn bits
SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
return EFI_SUCCESS;
}
-
/**
Returns register number 0 - 3 for the matching debug register.
This function compares incoming Address, Type, Length and
@@ -655,46 +646,51 @@ EnableDebugRegister (
**/
EFI_STATUS
FindMatchingDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Address,
- IN UINTN Length,
- IN UINTN Type,
- OUT UINTN *Register
- )
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN Address,
+ IN UINTN Length,
+ IN UINTN Type,
+ OUT UINTN *Register
+ )
{
- IA32_DR7 Dr7;
+ IA32_DR7 Dr7;
- //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
- //software breakpoint. We should send empty packet in both these cases.
+ // Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle
+ // software breakpoint. We should send empty packet in both these cases.
if ((Type == (BREAK_TYPE)DataRead) ||
- (Type == (BREAK_TYPE)SoftwareBreakpoint)) {
+ (Type == (BREAK_TYPE)SoftwareBreakpoint))
+ {
return EFI_UNSUPPORTED;
}
- //Convert length data
- Length = ConvertLengthData(Length);
+ // Convert length data
+ Length = ConvertLengthData (Length);
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
if ((Dr7.Bits.G0 == 1) &&
(Dr7.Bits.LEN0 == Length) &&
(Dr7.Bits.RW0 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr0)) {
+ (Address == SystemContext.SystemContextIa32->Dr0))
+ {
*Register = 0;
} else if ((Dr7.Bits.G1 == 1) &&
(Dr7.Bits.LEN1 == Length) &&
(Dr7.Bits.RW1 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr1)) {
+ (Address == SystemContext.SystemContextIa32->Dr1))
+ {
*Register = 1;
} else if ((Dr7.Bits.G2 == 1) &&
(Dr7.Bits.LEN2 == Length) &&
(Dr7.Bits.RW2 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr2)) {
+ (Address == SystemContext.SystemContextIa32->Dr2))
+ {
*Register = 2;
} else if ((Dr7.Bits.G3 == 1) &&
(Dr7.Bits.LEN3 == Length) &&
(Dr7.Bits.RW3 == Type) &&
- (Address == SystemContext.SystemContextIa32->Dr3)) {
+ (Address == SystemContext.SystemContextIa32->Dr3))
+ {
*Register = 3;
} else {
Print ((CHAR16 *)L"No match found..\n");
@@ -704,7 +700,6 @@ FindMatchingDebugRegister (
return EFI_SUCCESS;
}
-
/**
Disables the particular debug register.
@@ -716,41 +711,41 @@ FindMatchingDebugRegister (
**/
EFI_STATUS
DisableDebugRegister (
- IN EFI_SYSTEM_CONTEXT SystemContext,
- IN UINTN Register
- )
+ IN EFI_SYSTEM_CONTEXT SystemContext,
+ IN UINTN Register
+ )
{
IA32_DR7 Dr7;
- UINTN Address = 0;
+ UINTN Address = 0;
- //Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
+ // Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
if (Register == 0) {
SystemContext.SystemContextIa32->Dr0 = Address;
- Dr7.Bits.G0 = 0;
- Dr7.Bits.RW0 = 0;
- Dr7.Bits.LEN0 = 0;
+ Dr7.Bits.G0 = 0;
+ Dr7.Bits.RW0 = 0;
+ Dr7.Bits.LEN0 = 0;
} else if (Register == 1) {
SystemContext.SystemContextIa32->Dr1 = Address;
- Dr7.Bits.G1 = 0;
- Dr7.Bits.RW1 = 0;
- Dr7.Bits.LEN1 = 0;
+ Dr7.Bits.G1 = 0;
+ Dr7.Bits.RW1 = 0;
+ Dr7.Bits.LEN1 = 0;
} else if (Register == 2) {
SystemContext.SystemContextIa32->Dr2 = Address;
- Dr7.Bits.G2 = 0;
- Dr7.Bits.RW2 = 0;
- Dr7.Bits.LEN2 = 0;
+ Dr7.Bits.G2 = 0;
+ Dr7.Bits.RW2 = 0;
+ Dr7.Bits.LEN2 = 0;
} else if (Register == 3) {
SystemContext.SystemContextIa32->Dr3 = Address;
- Dr7.Bits.G3 = 0;
- Dr7.Bits.RW3 = 0;
- Dr7.Bits.LEN3 = 0;
+ Dr7.Bits.G3 = 0;
+ Dr7.Bits.RW3 = 0;
+ Dr7.Bits.LEN3 = 0;
} else {
return EFI_INVALID_PARAMETER;
}
- //Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
+ // Update DR7 register so appropriate Gn, RWn and LENn bits can be turned off.
SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
return EFI_SUCCESS;
@@ -772,16 +767,16 @@ VOID
EFIAPI
InsertBreakPoint (
IN EFI_SYSTEM_CONTEXT SystemContext,
- IN CHAR8 *PacketData
+ IN CHAR8 *PacketData
)
{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- EFI_STATUS Status;
- BREAK_TYPE BreakType = NotSupported;
- UINTN ErrorCode;
+ UINTN Type;
+ UINTN Address;
+ UINTN Length;
+ UINTN Register;
+ EFI_STATUS Status;
+ BREAK_TYPE BreakType = NotSupported;
+ UINTN ErrorCode;
ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
if (ErrorCode > 0) {
@@ -790,28 +785,27 @@ InsertBreakPoint (
}
switch (Type) {
-
- case 0: //Software breakpoint
+ case 0: // Software breakpoint
BreakType = SoftwareBreakpoint;
break;
- case 1: //Hardware breakpoint
+ case 1: // Hardware breakpoint
BreakType = InstructionExecution;
break;
- case 2: //Write watchpoint
+ case 2: // Write watchpoint
BreakType = DataWrite;
break;
- case 3: //Read watchpoint
+ case 3: // Read watchpoint
BreakType = DataRead;
break;
- case 4: //Access watchpoint
+ case 4: // Access watchpoint
BreakType = DataReadWrite;
break;
- default :
+ default:
Print ((CHAR16 *)L"Insert breakpoint default: %x\n", Type);
SendError (GDB_EINVALIDBRKPOINTTYPE);
return;
@@ -819,7 +813,7 @@ InsertBreakPoint (
// Find next free debug register
Status = FindNextFreeDebugRegister (SystemContext, &Register);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
Print ((CHAR16 *)L"No space left on device\n");
SendError (GDB_ENOSPACE);
return;
@@ -827,11 +821,10 @@ InsertBreakPoint (
// Write Address, length data at particular DR register
Status = EnableDebugRegister (SystemContext, Register, Address, Length, (UINTN)BreakType);
- if (EFI_ERROR(Status)) {
-
+ if (EFI_ERROR (Status)) {
if (Status == EFI_UNSUPPORTED) {
Print ((CHAR16 *)L"Not supported\n");
- SendNotSupported();
+ SendNotSupported ();
return;
}
@@ -843,7 +836,6 @@ InsertBreakPoint (
SendSuccess ();
}
-
/**
‘z1, [addr], [length]’
‘z2, [addr], [length]’
@@ -862,15 +854,15 @@ RemoveBreakPoint (
IN CHAR8 *PacketData
)
{
- UINTN Type;
- UINTN Address;
- UINTN Length;
- UINTN Register;
- BREAK_TYPE BreakType = NotSupported;
- EFI_STATUS Status;
- UINTN ErrorCode;
-
- //Parse breakpoint packet data
+ UINTN Type;
+ UINTN Address;
+ UINTN Length;
+ UINTN Register;
+ BREAK_TYPE BreakType = NotSupported;
+ EFI_STATUS Status;
+ UINTN ErrorCode;
+
+ // Parse breakpoint packet data
ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
if (ErrorCode > 0) {
SendError ((UINT8)ErrorCode);
@@ -878,39 +870,37 @@ RemoveBreakPoint (
}
switch (Type) {
-
- case 0: //Software breakpoint
+ case 0: // Software breakpoint
BreakType = SoftwareBreakpoint;
break;
- case 1: //Hardware breakpoint
+ case 1: // Hardware breakpoint
BreakType = InstructionExecution;
break;
- case 2: //Write watchpoint
+ case 2: // Write watchpoint
BreakType = DataWrite;
break;
- case 3: //Read watchpoint
+ case 3: // Read watchpoint
BreakType = DataRead;
break;
- case 4: //Access watchpoint
+ case 4: // Access watchpoint
BreakType = DataReadWrite;
break;
- default :
+ default:
SendError (GDB_EINVALIDBRKPOINTTYPE);
return;
}
- //Find matching debug register
+ // Find matching debug register
Status = FindMatchingDebugRegister (SystemContext, Address, Length, (UINTN)BreakType, &Register);
- if (EFI_ERROR(Status)) {
-
+ if (EFI_ERROR (Status)) {
if (Status == EFI_UNSUPPORTED) {
Print ((CHAR16 *)L"Not supported.\n");
- SendNotSupported();
+ SendNotSupported ();
return;
}
@@ -919,9 +909,9 @@ RemoveBreakPoint (
return;
}
- //Remove breakpoint
- Status = DisableDebugRegister(SystemContext, Register);
- if (EFI_ERROR(Status)) {
+ // Remove breakpoint
+ Status = DisableDebugRegister (SystemContext, Register);
+ if (EFI_ERROR (Status)) {
Print ((CHAR16 *)L"Invalid argument.\n");
SendError (GDB_EINVALIDARG);
return;
@@ -930,7 +920,6 @@ RemoveBreakPoint (
SendSuccess ();
}
-
VOID
InitializeProcessor (
VOID
@@ -948,10 +937,9 @@ ValidateAddress (
BOOLEAN
ValidateException (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN OUT EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext
)
{
return TRUE;
}
-
diff --git a/EmbeddedPkg/Include/Guid/ConsolePrefFormSet.h b/EmbeddedPkg/Include/Guid/ConsolePrefFormSet.h
index daa208f8a6..2f1174c2b0 100644
--- a/EmbeddedPkg/Include/Guid/ConsolePrefFormSet.h
+++ b/EmbeddedPkg/Include/Guid/ConsolePrefFormSet.h
@@ -12,6 +12,6 @@
#define CONSOLE_PREF_FORMSET_GUID \
{ 0x2d2358b4, 0xe96c, 0x484d, { 0xb2, 0xdd, 0x7c, 0x2e, 0xdf, 0xc7, 0xd5, 0x6f } }
-extern EFI_GUID gConsolePrefFormSetGuid;
+extern EFI_GUID gConsolePrefFormSetGuid;
#endif
diff --git a/EmbeddedPkg/Include/Guid/DtPlatformDefaultDtbFile.h b/EmbeddedPkg/Include/Guid/DtPlatformDefaultDtbFile.h
index cd21900a20..d95863066e 100644
--- a/EmbeddedPkg/Include/Guid/DtPlatformDefaultDtbFile.h
+++ b/EmbeddedPkg/Include/Guid/DtPlatformDefaultDtbFile.h
@@ -12,6 +12,6 @@
#define DT_PLATFORM_DEFAULT_DTB_FILE_GUID \
{ 0x25462cda, 0x221f, 0x47df, { 0xac, 0x1d, 0x25, 0x9c, 0xfa, 0xa4, 0xe3, 0x26 } }
-extern EFI_GUID gDtPlatformDefaultDtbFileGuid;
+extern EFI_GUID gDtPlatformDefaultDtbFileGuid;
#endif
diff --git a/EmbeddedPkg/Include/Guid/DtPlatformFormSet.h b/EmbeddedPkg/Include/Guid/DtPlatformFormSet.h
index 1bafe8441a..5d751bbd96 100644
--- a/EmbeddedPkg/Include/Guid/DtPlatformFormSet.h
+++ b/EmbeddedPkg/Include/Guid/DtPlatformFormSet.h
@@ -12,6 +12,6 @@
#define DT_PLATFORM_FORMSET_GUID \
{ 0x2b7a240d, 0xd5ad, 0x4fd6, { 0xbe, 0x1c, 0xdf, 0xa4, 0x41, 0x5f, 0x55, 0x26 } }
-extern EFI_GUID gDtPlatformFormSetGuid;
+extern EFI_GUID gDtPlatformFormSetGuid;
#endif
diff --git a/EmbeddedPkg/Include/Guid/ExtractSection.h b/EmbeddedPkg/Include/Guid/ExtractSection.h
index f1781197e4..7346296fbc 100644
--- a/EmbeddedPkg/Include/Guid/ExtractSection.h
+++ b/EmbeddedPkg/Include/Guid/ExtractSection.h
@@ -11,20 +11,18 @@
#include <Library/ExtractGuidedSectionLib.h>
-
//
// The GUID for this protocol mathes the Decompression scheme being used
// So for example LZMA would be gLzmaCustomDecompressGuid
//
typedef struct {
- EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo;
- EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction;
+ EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo;
+ EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction;
} EXTRACT_SECTION_DATA;
typedef struct {
- EFI_HOB_GUID_TYPE Hob;
- EXTRACT_SECTION_DATA Data;
+ EFI_HOB_GUID_TYPE Hob;
+ EXTRACT_SECTION_DATA Data;
} EXTRACT_SECTION_HOB;
#endif
-
diff --git a/EmbeddedPkg/Include/Guid/Fdt.h b/EmbeddedPkg/Include/Guid/Fdt.h
index 3c719189ae..e009146829 100644
--- a/EmbeddedPkg/Include/Guid/Fdt.h
+++ b/EmbeddedPkg/Include/Guid/Fdt.h
@@ -12,11 +12,11 @@
#define FDT_TABLE_GUID \
{ 0xb1b621d5, 0xf19c, 0x41a5, { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }
-extern EFI_GUID gFdtTableGuid;
+extern EFI_GUID gFdtTableGuid;
#define FDT_VARIABLE_GUID \
{ 0x25a4fd4a, 0x9703, 0x4ba9, { 0xa1, 0x90, 0xb7, 0xc8, 0x4e, 0xfb, 0x3e, 0x57 } }
-extern EFI_GUID gFdtVariableGuid;
+extern EFI_GUID gFdtVariableGuid;
#endif /* __FDT_H__ */
diff --git a/EmbeddedPkg/Include/Guid/FdtHob.h b/EmbeddedPkg/Include/Guid/FdtHob.h
index f8719dbb94..2425a13ffe 100644
--- a/EmbeddedPkg/Include/Guid/FdtHob.h
+++ b/EmbeddedPkg/Include/Guid/FdtHob.h
@@ -10,11 +10,11 @@
#ifndef __FDT_HOB_H__
#define __FDT_HOB_H__
-#define FDT_HOB_GUID { \
+#define FDT_HOB_GUID {\
0x16958446, 0x19B7, 0x480B, \
{ 0xB0, 0x47, 0x74, 0x85, 0xAD, 0x3F, 0x71, 0x6D } \
}
-extern EFI_GUID gFdtHobGuid;
+extern EFI_GUID gFdtHobGuid;
#endif
diff --git a/EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h b/EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h
index 7728f9277f..96e1e91caf 100644
--- a/EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h
+++ b/EmbeddedPkg/Include/Guid/NvVarStoreFormatted.h
@@ -18,7 +18,6 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#ifndef __EDKII_NV_VAR_STORE_FORMATTED_H__
#define __EDKII_NV_VAR_STORE_FORMATTED_H__
@@ -28,6 +27,6 @@
{ 0x83, 0xcd, 0xdc, 0x2c, 0x29, 0xc8, 0x91, 0xa3 } \
}
-extern EFI_GUID gEdkiiNvVarStoreFormattedGuid;
+extern EFI_GUID gEdkiiNvVarStoreFormattedGuid;
#endif
diff --git a/EmbeddedPkg/Include/Guid/PlatformHasDeviceTree.h b/EmbeddedPkg/Include/Guid/PlatformHasDeviceTree.h
index 102a6b8cc3..d05f109039 100644
--- a/EmbeddedPkg/Include/Guid/PlatformHasDeviceTree.h
+++ b/EmbeddedPkg/Include/Guid/PlatformHasDeviceTree.h
@@ -14,7 +14,6 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
#ifndef __EDKII_PLATFORM_HAS_DEVICE_TREE_H__
#define __EDKII_PLATFORM_HAS_DEVICE_TREE_H__
@@ -24,6 +23,6 @@
{ 0xb2, 0xaf, 0x54, 0x1e, 0x1d, 0xce, 0x14, 0x8b } \
}
-extern EFI_GUID gEdkiiPlatformHasDeviceTreeGuid;
+extern EFI_GUID gEdkiiPlatformHasDeviceTreeGuid;
#endif
diff --git a/EmbeddedPkg/Include/Library/AcpiLib.h b/EmbeddedPkg/Include/Library/AcpiLib.h
index c142446d9d..4f2001bfc8 100644
--- a/EmbeddedPkg/Include/Library/AcpiLib.h
+++ b/EmbeddedPkg/Include/Library/AcpiLib.h
@@ -17,11 +17,11 @@
//
// Macros for the Generic Address Space
//
-#define NULL_GAS { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_ACPI_5_0_UNDEFINED, 0L }
-#define ARM_GAS8(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 8, 0, EFI_ACPI_5_0_BYTE, Address }
-#define ARM_GAS16(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 16, 0, EFI_ACPI_5_0_WORD, Address }
-#define ARM_GAS32(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 32, 0, EFI_ACPI_5_0_DWORD, Address }
-#define ARM_GASN(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_ACPI_5_0_DWORD, Address }
+#define NULL_GAS { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_ACPI_5_0_UNDEFINED, 0L }
+#define ARM_GAS8(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 8, 0, EFI_ACPI_5_0_BYTE, Address }
+#define ARM_GAS16(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 16, 0, EFI_ACPI_5_0_WORD, Address }
+#define ARM_GAS32(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 32, 0, EFI_ACPI_5_0_DWORD, Address }
+#define ARM_GASN(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_ACPI_5_0_DWORD, Address }
//
// Macros for the Multiple APIC Description Table (MADT)
@@ -48,7 +48,7 @@
// Note the parking protocol is configured by UEFI if required
#define EFI_ACPI_5_1_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq, \
- GicBase, GicVBase, GicHBase, GsivId, GicRBase) \
+ GicBase, GicVBase, GicHBase, GsivId, GicRBase) \
{ \
EFI_ACPI_5_1_GIC, sizeof (EFI_ACPI_5_1_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase, \
@@ -56,7 +56,7 @@
}
#define EFI_ACPI_6_0_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq, \
- GicBase, GicVBase, GicHBase, GsivId, GicRBase, Efficiency) \
+ GicBase, GicVBase, GicHBase, GsivId, GicRBase, Efficiency) \
{ \
EFI_ACPI_6_0_GIC, sizeof (EFI_ACPI_6_0_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase, \
@@ -65,7 +65,7 @@
}
#define EFI_ACPI_6_3_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq, \
- GicBase, GicVBase, GicHBase, GsivId, GicRBase, Efficiency, SpeOvflIrq) \
+ GicBase, GicVBase, GicHBase, GsivId, GicRBase, Efficiency, SpeOvflIrq) \
{ \
EFI_ACPI_6_0_GIC, sizeof (EFI_ACPI_6_3_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase, \
@@ -82,7 +82,7 @@
// SBSA Generic Watchdog
//
#define EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT(RefreshFramePhysicalAddress, \
- ControlFramePhysicalAddress, WatchdogTimerGSIV, WatchdogTimerFlags) \
+ ControlFramePhysicalAddress, WatchdogTimerGSIV, WatchdogTimerFlags) \
{ \
EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG, sizeof(EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE), \
EFI_ACPI_RESERVED_BYTE, RefreshFramePhysicalAddress, ControlFramePhysicalAddress, \
@@ -91,7 +91,7 @@
typedef
BOOLEAN
-(EFIAPI *EFI_LOCATE_ACPI_CHECK) (
+(EFIAPI *EFI_LOCATE_ACPI_CHECK)(
IN EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader
);
@@ -109,7 +109,7 @@ BOOLEAN
**/
EFI_STATUS
LocateAndInstallAcpiFromFvConditional (
- IN CONST EFI_GUID* AcpiFile,
+ IN CONST EFI_GUID *AcpiFile,
IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
);
@@ -125,7 +125,7 @@ LocateAndInstallAcpiFromFvConditional (
**/
EFI_STATUS
LocateAndInstallAcpiFromFv (
- IN CONST EFI_GUID* AcpiFile
+ IN CONST EFI_GUID *AcpiFile
);
#endif // __ACPI_LIB_H__
diff --git a/EmbeddedPkg/Include/Library/AndroidBootImgLib.h b/EmbeddedPkg/Include/Library/AndroidBootImgLib.h
index 5fb3339048..d58a4d2d32 100644
--- a/EmbeddedPkg/Include/Library/AndroidBootImgLib.h
+++ b/EmbeddedPkg/Include/Library/AndroidBootImgLib.h
@@ -19,32 +19,33 @@
#define ANDROID_BOOTIMG_KERNEL_ARGS_SIZE 512
-#define ANDROID_BOOT_MAGIC "ANDROID!"
-#define ANDROID_BOOT_MAGIC_LENGTH (sizeof (ANDROID_BOOT_MAGIC) - 1)
+#define ANDROID_BOOT_MAGIC "ANDROID!"
+#define ANDROID_BOOT_MAGIC_LENGTH (sizeof (ANDROID_BOOT_MAGIC) - 1)
// No documentation for this really - sizes of fields has been determined
// empirically.
#pragma pack(1)
/* https://android.googlesource.com/platform/system/core/+/master/mkbootimg/bootimg.h */
typedef struct {
- UINT8 BootMagic[ANDROID_BOOT_MAGIC_LENGTH];
- UINT32 KernelSize;
- UINT32 KernelAddress;
- UINT32 RamdiskSize;
- UINT32 RamdiskAddress;
- UINT32 SecondStageBootloaderSize;
- UINT32 SecondStageBootloaderAddress;
- UINT32 KernelTaggsAddress;
- UINT32 PageSize;
- UINT32 Reserved[2];
- CHAR8 ProductName[16];
- CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
- UINT32 Id[32];
+ UINT8 BootMagic[ANDROID_BOOT_MAGIC_LENGTH];
+ UINT32 KernelSize;
+ UINT32 KernelAddress;
+ UINT32 RamdiskSize;
+ UINT32 RamdiskAddress;
+ UINT32 SecondStageBootloaderSize;
+ UINT32 SecondStageBootloaderAddress;
+ UINT32 KernelTaggsAddress;
+ UINT32 PageSize;
+ UINT32 Reserved[2];
+ CHAR8 ProductName[16];
+ CHAR8 KernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
+ UINT32 Id[32];
} ANDROID_BOOTIMG_HEADER;
#pragma pack ()
/* Check Val (unsigned) is a power of 2 (has only one bit set) */
-#define IS_POWER_OF_2(Val) ((Val) != 0 && (((Val) & ((Val) - 1)) == 0))
+#define IS_POWER_OF_2(Val) ((Val) != 0 && (((Val) & ((Val) - 1)) == 0))
+
/* Android boot image page size is not specified, but it should be power of 2
* and larger than boot header */
#define IS_VALID_ANDROID_PAGE_SIZE(Val) \
@@ -52,14 +53,14 @@ typedef struct {
EFI_STATUS
AndroidBootImgGetImgSize (
- IN VOID *BootImg,
- OUT UINTN *ImgSize
+ IN VOID *BootImg,
+ OUT UINTN *ImgSize
);
EFI_STATUS
AndroidBootImgBoot (
- IN VOID *Buffer,
- IN UINTN BufferSize
+ IN VOID *Buffer,
+ IN UINTN BufferSize
);
#endif /* __ABOOTIMG_H__ */
diff --git a/EmbeddedPkg/Include/Library/DebugAgentTimerLib.h b/EmbeddedPkg/Include/Library/DebugAgentTimerLib.h
index eb499dbc1b..d6f3b67d45 100644
--- a/EmbeddedPkg/Include/Library/DebugAgentTimerLib.h
+++ b/EmbeddedPkg/Include/Library/DebugAgentTimerLib.h
@@ -12,8 +12,6 @@
#ifndef __GDB_TIMER_LIB__
#define __GDB_TIMER_LIB__
-
-
/**
Setup all the hardware needed for the debug agents timer.
@@ -26,7 +24,6 @@ DebugAgentTimerIntialize (
VOID
);
-
/**
Set the period for the debug agent timer. Zero means disable the timer.
@@ -39,7 +36,6 @@ DebugAgentTimerSetPeriod (
IN UINT32 TimerPeriodMilliseconds
);
-
/**
Perform End Of Interrupt for the debug agent timer. This is called in the
interrupt handler after the interrupt has been processed.
@@ -52,5 +48,3 @@ DebugAgentTimerEndOfInterrupt (
);
#endif
-
-
diff --git a/EmbeddedPkg/Include/Library/DmaLib.h b/EmbeddedPkg/Include/Library/DmaLib.h
index 9f6e7a9d28..44bc71a1f6 100644
--- a/EmbeddedPkg/Include/Library/DmaLib.h
+++ b/EmbeddedPkg/Include/Library/DmaLib.h
@@ -51,9 +51,6 @@ typedef enum {
MapOperationMaximum
} DMA_MAP_OPERATION;
-
-
-
/**
Provides the DMA controller-specific addresses needed to access system memory.
@@ -77,16 +74,13 @@ typedef enum {
EFI_STATUS
EFIAPI
DmaMap (
- IN DMA_MAP_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN DMA_MAP_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
);
-
-
-
/**
Completes the DmaMapBusMasterRead, DmaMapBusMasterWrite, or DmaMapBusMasterCommonBuffer
operation and releases any corresponding resources.
@@ -100,10 +94,9 @@ DmaMap (
EFI_STATUS
EFIAPI
DmaUnmap (
- IN VOID *Mapping
+ IN VOID *Mapping
);
-
/**
Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer.
mapping.
@@ -124,12 +117,11 @@ DmaUnmap (
EFI_STATUS
EFIAPI
DmaAllocateBuffer (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT VOID **HostAddress
);
-
/**
Frees memory that was allocated with DmaAllocateBuffer().
@@ -144,11 +136,10 @@ DmaAllocateBuffer (
EFI_STATUS
EFIAPI
DmaFreeBuffer (
- IN UINTN Pages,
- IN VOID *HostAddress
+ IN UINTN Pages,
+ IN VOID *HostAddress
);
-
/**
Allocates pages that are suitable for an DmaMap() of type
MapOperationBusMasterCommonBuffer mapping, at the requested alignment.
@@ -171,11 +162,10 @@ DmaFreeBuffer (
EFI_STATUS
EFIAPI
DmaAllocateAlignedBuffer (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- IN UINTN Alignment,
- OUT VOID **HostAddress
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN UINTN Alignment,
+ OUT VOID **HostAddress
);
-
#endif
diff --git a/EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h b/EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h
index 3beacf0b1e..1309d85186 100644
--- a/EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h
+++ b/EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h
@@ -26,8 +26,8 @@
EFI_STATUS
EFIAPI
DtPlatformLoadDtb (
- OUT VOID **Dtb,
- OUT UINTN *DtbSize
+ OUT VOID **Dtb,
+ OUT UINTN *DtbSize
);
#endif
diff --git a/EmbeddedPkg/Include/Library/EfiFileLib.h b/EmbeddedPkg/Include/Library/EfiFileLib.h
index 0544b6e200..bae19ec78a 100644
--- a/EmbeddedPkg/Include/Library/EfiFileLib.h
+++ b/EmbeddedPkg/Include/Library/EfiFileLib.h
@@ -42,7 +42,7 @@
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
-#define MAX_PATHNAME 0x200
+#define MAX_PATHNAME 0x200
/// Type of the file that has been opened
typedef enum {
@@ -55,52 +55,49 @@ typedef enum {
EfiOpenMaxValue
} EFI_OPEN_FILE_TYPE;
-
/// Public information about the open file
typedef struct {
- UINTN Version; // Common information
- EFI_OPEN_FILE_TYPE Type;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_STATUS LastError;
- EFI_HANDLE EfiHandle;
- CHAR8 *DeviceName;
- CHAR8 *FileName;
-
- UINT64 CurrentPosition; // Information for Seek
- UINT64 MaxPosition;
+ UINTN Version; // Common information
+ EFI_OPEN_FILE_TYPE Type;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS LastError;
+ EFI_HANDLE EfiHandle;
+ CHAR8 *DeviceName;
+ CHAR8 *FileName;
- UINTN BaseOffset; // Base offset for hexdump command
+ UINT64 CurrentPosition; // Information for Seek
+ UINT64 MaxPosition;
- UINTN Size; // Valid for all types other than l#:
- UINT8 *Buffer; // Information valid for A#:
+ UINTN BaseOffset; // Base offset for hexdump command
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; // Information valid for Fv#:
- EFI_GUID FvNameGuid;
- EFI_SECTION_TYPE FvSectionType;
- EFI_FV_FILETYPE FvType;
- EFI_FV_FILE_ATTRIBUTES FvAttributes;
+ UINTN Size; // Valid for all types other than l#:
+ UINT8 *Buffer; // Information valid for A#:
- EFI_PHYSICAL_ADDRESS FvStart;
- UINTN FvSize;
- UINTN FvHeaderSize;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; // Information valid for Fv#:
+ EFI_GUID FvNameGuid;
+ EFI_SECTION_TYPE FvSectionType;
+ EFI_FV_FILETYPE FvType;
+ EFI_FV_FILE_ATTRIBUTES FvAttributes;
- EFI_FILE *FsFileHandle; // Information valid for Fs#:
- EFI_FILE_SYSTEM_INFO *FsInfo;
- EFI_FILE_INFO *FsFileInfo;
- EFI_BLOCK_IO_MEDIA *FsBlockIoMedia; // Information valid for Fs#: or B#:
- EFI_BLOCK_IO_PROTOCOL *FsBlockIo; // Information valid for Fs#: or B#:
+ EFI_PHYSICAL_ADDRESS FvStart;
+ UINTN FvSize;
+ UINTN FvHeaderSize;
- UINTN DiskOffset; // Information valid for B#:
+ EFI_FILE *FsFileHandle; // Information valid for Fs#:
+ EFI_FILE_SYSTEM_INFO *FsInfo;
+ EFI_FILE_INFO *FsFileInfo;
+ EFI_BLOCK_IO_MEDIA *FsBlockIoMedia; // Information valid for Fs#: or B#:
+ EFI_BLOCK_IO_PROTOCOL *FsBlockIo; // Information valid for Fs#: or B#:
- EFI_LOAD_FILE_PROTOCOL *LoadFile; // Information valid for l#:
+ UINTN DiskOffset; // Information valid for B#:
- EFI_IP_ADDRESS ServerIp; // Information valid for t:
- BOOLEAN IsDirty;
- BOOLEAN IsBufferValid;
+ EFI_LOAD_FILE_PROTOCOL *LoadFile; // Information valid for l#:
+ EFI_IP_ADDRESS ServerIp; // Information valid for t:
+ BOOLEAN IsDirty;
+ BOOLEAN IsBufferValid;
} EFI_OPEN_FILE;
-
/// Type of Seek to perform
typedef enum {
EfiSeekStart,
@@ -109,7 +106,6 @@ typedef enum {
EfiSeekMax
} EFI_SEEK_TYPE;
-
/**
Open a device named by PathName. The PathName includes a device name and
path separated by a :. See file header for more details on the PathName
@@ -131,15 +127,15 @@ typedef enum {
**/
EFI_OPEN_FILE *
EfiOpen (
- IN CHAR8 *PathName,
- IN CONST UINT64 OpenMode,
- IN CONST EFI_SECTION_TYPE SectionType
+ IN CHAR8 *PathName,
+ IN CONST UINT64 OpenMode,
+ IN CONST EFI_SECTION_TYPE SectionType
);
EFI_STATUS
EfiCopyFile (
- IN CHAR8 *DestinationFile,
- IN CHAR8 *SourceFile
+ IN CHAR8 *DestinationFile,
+ IN CHAR8 *SourceFile
);
/**
@@ -154,11 +150,10 @@ EfiCopyFile (
**/
EFI_OPEN_FILE *
EfiDeviceOpenByType (
- IN EFI_OPEN_FILE_TYPE DeviceType,
- IN UINTN Index
+ IN EFI_OPEN_FILE_TYPE DeviceType,
+ IN UINTN Index
);
-
/**
Close a file handle opened by EfiOpen() and free all resources allocated by
EfiOpen().
@@ -171,10 +166,9 @@ EfiDeviceOpenByType (
**/
EFI_STATUS
EfiClose (
- IN EFI_OPEN_FILE *Stream
+ IN EFI_OPEN_FILE *Stream
);
-
/**
Return the size of the file represented by Stream. Also return the current
Seek position. Opening a file will enable a valid file size to be returned.
@@ -187,11 +181,10 @@ EfiClose (
**/
UINTN
EfiTell (
- IN EFI_OPEN_FILE *Stream,
- OUT UINT64 *CurrentPosition OPTIONAL
+ IN EFI_OPEN_FILE *Stream,
+ OUT UINT64 *CurrentPosition OPTIONAL
);
-
/**
Seek to the Offset location in the file. LoadFile and FV device types do
not support EfiSeek(). It is not possible to grow the file size using
@@ -215,12 +208,11 @@ EfiTell (
**/
EFI_STATUS
EfiSeek (
- IN EFI_OPEN_FILE *Stream,
- IN EFI_LBA Offset,
- IN EFI_SEEK_TYPE SeekType
+ IN EFI_OPEN_FILE *Stream,
+ IN EFI_LBA Offset,
+ IN EFI_SEEK_TYPE SeekType
);
-
/**
Read BufferSize bytes from the current location in the file. For load file
and FV case you must read the entire file.
@@ -239,12 +231,11 @@ EfiSeek (
**/
EFI_STATUS
EfiRead (
- IN EFI_OPEN_FILE *Stream,
- OUT VOID *Buffer,
- OUT UINTN *BufferSize
+ IN EFI_OPEN_FILE *Stream,
+ OUT VOID *Buffer,
+ OUT UINTN *BufferSize
);
-
/**
Read the entire file into a buffer. This routine allocates the buffer and
returns it to the user full of the read data.
@@ -266,12 +257,11 @@ EfiRead (
**/
EFI_STATUS
EfiReadAllocatePool (
- IN EFI_OPEN_FILE *Stream,
- OUT VOID **Buffer,
- OUT UINTN *BufferSize
+ IN EFI_OPEN_FILE *Stream,
+ OUT VOID **Buffer,
+ OUT UINTN *BufferSize
);
-
/**
Write data back to the file.
@@ -289,12 +279,11 @@ EfiReadAllocatePool (
**/
EFI_STATUS
EfiWrite (
- IN EFI_OPEN_FILE *Stream,
- OUT VOID *Buffer,
- OUT UINTN *BufferSize
+ IN EFI_OPEN_FILE *Stream,
+ OUT VOID *Buffer,
+ OUT UINTN *BufferSize
);
-
/**
Return the number of devices of the current type active in the system
@@ -305,10 +294,9 @@ EfiWrite (
**/
UINTN
EfiGetDeviceCounts (
- IN EFI_OPEN_FILE_TYPE Type
+ IN EFI_OPEN_FILE_TYPE Type
);
-
/**
Set the Current Working Directory (CWD). If a call is made to EfiOpen () and
the path does not contain a device name, The CWD is prepended to the path.
@@ -322,7 +310,7 @@ EfiGetDeviceCounts (
**/
EFI_STATUS
EfiSetCwd (
- IN CHAR8 *Cwd
+ IN CHAR8 *Cwd
);
/**
diff --git a/EmbeddedPkg/Include/Library/EfiResetSystemLib.h b/EmbeddedPkg/Include/Library/EfiResetSystemLib.h
index aa5ec40175..5bfebfc638 100644
--- a/EmbeddedPkg/Include/Library/EfiResetSystemLib.h
+++ b/EmbeddedPkg/Include/Library/EfiResetSystemLib.h
@@ -6,11 +6,9 @@
**/
-
#ifndef __EFI_RESET_SYSTEM_LIB_H___
#define __EFI_RESET_SYSTEM_LIB_H___
-
/**
Resets the entire platform.
@@ -25,14 +23,12 @@
EFI_STATUS
EFIAPI
LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData OPTIONAL
);
-
-
/**
Initialize any infrastructure required for LibResetSystem () to function.
diff --git a/EmbeddedPkg/Include/Library/FdtLoadLib.h b/EmbeddedPkg/Include/Library/FdtLoadLib.h
index a46469af5a..952dd8f751 100644
--- a/EmbeddedPkg/Include/Library/FdtLoadLib.h
+++ b/EmbeddedPkg/Include/Library/FdtLoadLib.h
@@ -21,7 +21,7 @@
**/
EFI_STATUS
InstallFdtFromSemihosting (
- IN CONST CHAR16* FileName
+ IN CONST CHAR16 *FileName
);
/**
@@ -36,7 +36,7 @@ InstallFdtFromSemihosting (
**/
EFI_STATUS
InstallFdtFromFv (
- IN CONST EFI_GUID *FileName
+ IN CONST EFI_GUID *FileName
);
#endif
diff --git a/EmbeddedPkg/Include/Library/GdbSerialLib.h b/EmbeddedPkg/Include/Library/GdbSerialLib.h
index b45645ae61..4845d6018c 100644
--- a/EmbeddedPkg/Include/Library/GdbSerialLib.h
+++ b/EmbeddedPkg/Include/Library/GdbSerialLib.h
@@ -10,8 +10,6 @@
#ifndef __GDB_SERIAL_LIB_H__
#define __GDB_SERIAL_LIB_H__
-
-
/**
Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,
data buts, and stop bits on a serial device. This call is optional as the serial
@@ -34,13 +32,12 @@
RETURN_STATUS
EFIAPI
GdbSerialInit (
- IN UINT64 BaudRate,
- IN UINT8 Parity,
- IN UINT8 DataBits,
- IN UINT8 StopBits
+ IN UINT64 BaudRate,
+ IN UINT8 Parity,
+ IN UINT8 DataBits,
+ IN UINT8 StopBits
);
-
/**
Check to see if a character is available from GDB. Do not read the character as that is
done via GdbGetChar().
@@ -67,7 +64,6 @@ GdbGetChar (
VOID
);
-
/**
Send a character to GDB. This function must be able to run in interrupt context.
@@ -79,10 +75,9 @@ GdbGetChar (
VOID
EFIAPI
GdbPutChar (
- IN CHAR8 Char
+ IN CHAR8 Char
);
-
/**
Send an ASCII string to GDB. This function must be able to run in interrupt context.
@@ -96,6 +91,4 @@ GdbPutString (
IN CHAR8 *String
);
-
#endif
-
diff --git a/EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h b/EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h
index 122541f686..be1c03bb10 100644
--- a/EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h
+++ b/EmbeddedPkg/Include/Library/HalRuntimeServicesLib.h
@@ -6,15 +6,18 @@
**/
-
#ifndef __RUNTIME_SERVICES_LIB_H__
#define __RUNTIME_SERVICES_LIB_H__
VOID
-LibMtcInitialize (VOID);
+LibMtcInitialize (
+ VOID
+ );
VOID
-LibMtcVirtualAddressChangeEvent (VOID);
+LibMtcVirtualAddressChangeEvent (
+ VOID
+ );
EFI_STATUS
EFIAPI
@@ -27,21 +30,23 @@ LibMtcGetNextMonotonicCount (
OUT UINT64 *Count
);
-
-
VOID
-LibVariableInitialize (VOID);
+LibVariableInitialize (
+ VOID
+ );
VOID
-LibVariableVirtualAddressChangeEvent (VOID);
+LibVariableVirtualAddressChangeEvent (
+ VOID
+ );
EFI_STATUS
LibGetVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- OUT UINT32 *Attributes OPTIONAL,
- IN OUT UINTN *DataSize,
- OUT VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
);
EFI_STATUS
@@ -53,49 +58,54 @@ LibGetNextVariableName (
EFI_STATUS
LibSetVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
);
EFI_STATUS
LibQueryVariableInfo (
- IN UINT32 Attributes,
- OUT UINT64 *MaximumVariableStorageSize,
- OUT UINT64 *RemainingVariableStorageSize,
- OUT UINT64 *MaximumVariableSize
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
);
-
-
VOID
-LibResetInitializeReset (VOID);
+LibResetInitializeReset (
+ VOID
+ );
VOID
-LibResetVirtualAddressChangeEvent (VOID);
+LibResetVirtualAddressChangeEvent (
+ VOID
+ );
VOID
LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData OPTIONAL
);
-
VOID
-LibCapsuleInitialize (VOID);
+LibCapsuleInitialize (
+ VOID
+ );
VOID
-LibCapsuleVirtualAddressChangeEvent (VOID);
+LibCapsuleVirtualAddressChangeEvent (
+ VOID
+ );
EFI_STATUS
LibUpdateCapsule (
- IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
- IN UINTN CapsuleCount,
- IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
+ IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
);
EFI_STATUS
@@ -106,13 +116,15 @@ QueryCapsuleCapabilities (
OUT EFI_RESET_TYPE *ResetType
);
-
-
VOID
-LibRtcInitialize (VOID);
+LibRtcInitialize (
+ VOID
+ );
VOID
-LibRtcVirtualAddressChangeEvent (VOID);
+LibRtcVirtualAddressChangeEvent (
+ VOID
+ );
EFI_STATUS
LibGetTime (
@@ -122,38 +134,39 @@ LibGetTime (
EFI_STATUS
LibSetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
);
EFI_STATUS
LibGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
);
EFI_STATUS
LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
+ IN BOOLEAN Enabled,
+ OUT EFI_TIME *Time
);
-
VOID
-LibReportStatusCodeInitialize (VOID);
+LibReportStatusCodeInitialize (
+ VOID
+ );
VOID
-LibReportStatusCodeVirtualAddressChangeEvent (VOID);
+LibReportStatusCodeVirtualAddressChangeEvent (
+ VOID
+ );
EFI_STATUS
LibReportStatusCode (
- IN EFI_STATUS_CODE_TYPE CodeType,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN EFI_GUID *CallerId,
- IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
);
-
#endif
-
diff --git a/EmbeddedPkg/Include/Library/NorFlashInfoLib.h b/EmbeddedPkg/Include/Library/NorFlashInfoLib.h
index e19039d870..9a26159d19 100644
--- a/EmbeddedPkg/Include/Library/NorFlashInfoLib.h
+++ b/EmbeddedPkg/Include/Library/NorFlashInfoLib.h
@@ -11,45 +11,45 @@
#include <Uefi/UefiBaseType.h>
-#define NOR_FLASH_MAX_ID_LEN 6
+#define NOR_FLASH_MAX_ID_LEN 6
typedef struct {
/* Device name */
- UINT16 *Name;
+ UINT16 *Name;
/*
* JEDEC ID
*/
- UINT8 Id[NOR_FLASH_MAX_ID_LEN];
- UINT8 IdLen;
+ UINT8 Id[NOR_FLASH_MAX_ID_LEN];
+ UINT8 IdLen;
- UINT16 PageSize;
+ UINT16 PageSize;
/*
* Below parameters can be referred as BlockSize
* and BlockCount, when treating the NorFlash as
* block device.
*/
- UINT32 SectorSize;
- UINT32 SectorCount;
-
- UINT16 Flags;
-#define NOR_FLASH_ERASE_4K (1 << 0) /* Use 4 KB erase blocks and CMD_ERASE_4K */
-#define NOR_FLASH_ERASE_32K (1 << 1) /* Use 32 KB erase blocks and CMD_ERASE_32K */
-#define NOR_FLASH_WRITE_FSR (1 << 2) /* Use flag status register for write */
-#define NOR_FLASH_4B_ADDR (1 << 3) /* Use 4B addressing */
+ UINT32 SectorSize;
+ UINT32 SectorCount;
+
+ UINT16 Flags;
+ #define NOR_FLASH_ERASE_4K (1 << 0) /* Use 4 KB erase blocks and CMD_ERASE_4K */
+ #define NOR_FLASH_ERASE_32K (1 << 1) /* Use 32 KB erase blocks and CMD_ERASE_32K */
+ #define NOR_FLASH_WRITE_FSR (1 << 2) /* Use flag status register for write */
+ #define NOR_FLASH_4B_ADDR (1 << 3) /* Use 4B addressing */
} NOR_FLASH_INFO;
/* Vendor IDs */
-#define NOR_FLASH_ID_ATMEL 0x1f
-#define NOR_FLASH_ID_EON 0x1c
-#define NOR_FLASH_ID_GIGADEVICE 0xc8
-#define NOR_FLASH_ID_ISSI 0x9d
-#define NOR_FLASH_ID_MACRONIX 0xc2
-#define NOR_FLASH_ID_SPANSION 0x01
-#define NOR_FLASH_ID_STMICRO 0x20
-#define NOR_FLASH_ID_SST 0xbf
-#define NOR_FLASH_ID_WINDBOND 0xef
+#define NOR_FLASH_ID_ATMEL 0x1f
+#define NOR_FLASH_ID_EON 0x1c
+#define NOR_FLASH_ID_GIGADEVICE 0xc8
+#define NOR_FLASH_ID_ISSI 0x9d
+#define NOR_FLASH_ID_MACRONIX 0xc2
+#define NOR_FLASH_ID_SPANSION 0x01
+#define NOR_FLASH_ID_STMICRO 0x20
+#define NOR_FLASH_ID_SST 0xbf
+#define NOR_FLASH_ID_WINDBOND 0xef
/**
Return an allocated copy pool of the NOR flash information structure.
@@ -70,9 +70,9 @@ typedef struct {
EFI_STATUS
EFIAPI
NorFlashGetInfo (
- IN UINT8 *Id,
+ IN UINT8 *Id,
IN OUT NOR_FLASH_INFO **FlashInfo,
- IN BOOLEAN AllocateForRuntime
+ IN BOOLEAN AllocateForRuntime
);
/**
@@ -87,4 +87,5 @@ EFIAPI
NorFlashPrintInfo (
IN NOR_FLASH_INFO *Info
);
+
#endif
diff --git a/EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h b/EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h
index cf26f08c05..a05ee8fd6b 100644
--- a/EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h
+++ b/EmbeddedPkg/Include/Library/PrePiHobListPointerLib.h
@@ -32,7 +32,7 @@ PrePeiGetHobList (
EFI_STATUS
EFIAPI
PrePeiSetHobList (
- IN VOID *HobList
+ IN VOID *HobList
);
#endif
diff --git a/EmbeddedPkg/Include/Library/PrePiLib.h b/EmbeddedPkg/Include/Library/PrePiLib.h
index 399a8d59a9..7b2cea296f 100644
--- a/EmbeddedPkg/Include/Library/PrePiLib.h
+++ b/EmbeddedPkg/Include/Library/PrePiLib.h
@@ -27,11 +27,10 @@
EFI_STATUS
EFIAPI
FfsFindNextVolume (
- IN UINTN Instance,
- IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
+ IN UINTN Instance,
+ IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
);
-
/**
This service enables discovery of additional firmware files.
@@ -48,12 +47,11 @@ FfsFindNextVolume (
EFI_STATUS
EFIAPI
FfsFindNextFile (
- IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
);
-
/**
This service enables discovery sections of a given type within a valid FFS file.
@@ -69,12 +67,11 @@ FfsFindNextFile (
EFI_STATUS
EFIAPI
FfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT VOID **SectionData
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData
);
-
/**
Find a file in the volume by name
@@ -96,12 +93,11 @@ FfsFindSectionData (
EFI_STATUS
EFIAPI
FfsFindFileByName (
- IN CONST EFI_GUID *FileName,
- IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN CONST EFI_GUID *FileName,
+ IN CONST EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
);
-
/**
Get information about the file by name.
@@ -121,11 +117,10 @@ FfsFindFileByName (
EFI_STATUS
EFIAPI
FfsGetFileInfo (
- IN CONST EFI_PEI_FILE_HANDLE FileHandle,
- OUT EFI_FV_FILE_INFO *FileInfo
+ IN CONST EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO *FileInfo
);
-
/**
Get Information about the volume by name
@@ -145,12 +140,10 @@ FfsGetFileInfo (
EFI_STATUS
EFIAPI
FfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_FV_INFO *VolumeInfo
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_FV_INFO *VolumeInfo
);
-
-
/**
Get Fv image from the FV type file, then add FV & FV2 Hob.
@@ -163,10 +156,9 @@ FfsGetVolumeInfo (
EFI_STATUS
EFIAPI
FfsProcessFvFile (
- IN EFI_PEI_FILE_HANDLE FvFileHandle
+ IN EFI_PEI_FILE_HANDLE FvFileHandle
);
-
/**
Search through every FV until you find a file of type FileType
@@ -181,12 +173,11 @@ FfsProcessFvFile (
EFI_STATUS
EFIAPI
FfsAnyFvFindFirstFile (
- IN EFI_FV_FILETYPE FileType,
- OUT EFI_PEI_FV_HANDLE *VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN EFI_FV_FILETYPE FileType,
+ OUT EFI_PEI_FV_HANDLE *VolumeHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
);
-
/**
Get Fv image from the FV type file, then add FV & FV2 Hob.
@@ -200,10 +191,9 @@ FfsAnyFvFindFirstFile (
EFI_STATUS
EFIAPI
FfsProcessFvFile (
- IN EFI_PEI_FILE_HANDLE FvFileHandle
+ IN EFI_PEI_FILE_HANDLE FvFileHandle
);
-
/**
This service enables PEIMs to ascertain the present value of the boot mode.
@@ -217,7 +207,6 @@ GetBootMode (
VOID
);
-
/**
This service enables PEIMs to update the boot mode variable.
@@ -229,7 +218,7 @@ GetBootMode (
EFI_STATUS
EFIAPI
SetBootMode (
- IN EFI_BOOT_MODE BootMode
+ IN EFI_BOOT_MODE BootMode
);
/**
@@ -247,7 +236,6 @@ GetHobList (
VOID
);
-
/**
Updates the pointer to the HOB list.
@@ -257,10 +245,10 @@ GetHobList (
EFI_STATUS
EFIAPI
SetHobList (
- IN VOID *HobList
+ IN VOID *HobList
);
-EFI_HOB_HANDOFF_INFO_TABLE*
+EFI_HOB_HANDOFF_INFO_TABLE *
HobConstructor (
IN VOID *EfiMemoryBegin,
IN UINTN EfiMemoryLength,
@@ -280,11 +268,10 @@ HobConstructor (
**/
VOID *
CreateHob (
- IN UINT16 HobType,
- IN UINT16 HobLenght
+ IN UINT16 HobType,
+ IN UINT16 HobLenght
);
-
/**
Returns the next instance of a HOB type from the starting HOB.
@@ -304,8 +291,8 @@ CreateHob (
VOID *
EFIAPI
GetNextHob (
- IN UINT16 Type,
- IN CONST VOID *HobStart
+ IN UINT16 Type,
+ IN CONST VOID *HobStart
);
/**
@@ -322,7 +309,7 @@ GetNextHob (
VOID *
EFIAPI
GetFirstHob (
- IN UINT16 Type
+ IN UINT16 Type
);
/**
@@ -347,8 +334,8 @@ GetFirstHob (
VOID *
EFIAPI
GetNextGuidHob (
- IN CONST EFI_GUID *Guid,
- IN CONST VOID *HobStart
+ IN CONST EFI_GUID *Guid,
+ IN CONST VOID *HobStart
);
/**
@@ -368,10 +355,9 @@ GetNextGuidHob (
VOID *
EFIAPI
GetFirstGuidHob (
- IN CONST EFI_GUID *Guid
+ IN CONST EFI_GUID *Guid
);
-
/**
Builds a HOB for a loaded PE32 module.
@@ -390,10 +376,10 @@ GetFirstGuidHob (
VOID
EFIAPI
BuildModuleHob (
- IN CONST EFI_GUID *ModuleName,
- IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
- IN UINT64 ModuleLength,
- IN EFI_PHYSICAL_ADDRESS EntryPoint
+ IN CONST EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
);
/**
@@ -440,8 +426,8 @@ BuildResourceDescriptorHob (
VOID *
EFIAPI
BuildGuidHob (
- IN CONST EFI_GUID *Guid,
- IN UINTN DataLength
+ IN CONST EFI_GUID *Guid,
+ IN UINTN DataLength
);
/**
@@ -467,9 +453,9 @@ BuildGuidHob (
VOID *
EFIAPI
BuildGuidDataHob (
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN UINTN DataLength
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
);
/**
@@ -487,8 +473,8 @@ BuildGuidDataHob (
VOID
EFIAPI
BuildFvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
);
/**
@@ -511,7 +497,6 @@ BuildFvHobs (
IN EFI_RESOURCE_ATTRIBUTE_TYPE *ResourceAttribute OPTIONAL
);
-
/**
Builds a EFI_HOB_TYPE_FV2 HOB.
@@ -529,10 +514,10 @@ BuildFvHobs (
VOID
EFIAPI
BuildFv2Hob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN CONST EFI_GUID *FvName,
- IN CONST EFI_GUID *FileName
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN CONST EFI_GUID *FvName,
+ IN CONST EFI_GUID *FileName
);
/**
@@ -550,8 +535,8 @@ BuildFv2Hob (
VOID
EFIAPI
BuildCvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
);
/**
@@ -569,8 +554,8 @@ BuildCvHob (
VOID
EFIAPI
BuildCpuHob (
- IN UINT8 SizeOfMemorySpace,
- IN UINT8 SizeOfIoSpace
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
);
/**
@@ -588,8 +573,8 @@ BuildCpuHob (
VOID
EFIAPI
BuildStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
);
/**
@@ -601,11 +586,10 @@ BuildStackHob (
**/
VOID
UpdateStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
);
-
/**
Builds a HOB for the BSP store.
@@ -622,9 +606,9 @@ UpdateStackHob (
VOID
EFIAPI
BuildBspStoreHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN EFI_MEMORY_TYPE MemoryType
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
);
/**
@@ -643,18 +627,17 @@ BuildBspStoreHob (
VOID
EFIAPI
BuildMemoryAllocationHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN EFI_MEMORY_TYPE MemoryType
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
);
-
VOID
EFIAPI
BuildExtractSectionHob (
- IN EFI_GUID *Guid,
- IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo,
- IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction
+ IN EFI_GUID *Guid,
+ IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo,
+ IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction
);
VOID
@@ -663,7 +646,6 @@ BuildPeCoffLoaderHob (
VOID
);
-
/**
Allocates one or more 4KB pages of type EfiBootServicesData.
@@ -680,7 +662,7 @@ BuildPeCoffLoaderHob (
VOID *
EFIAPI
AllocatePages (
- IN UINTN Pages
+ IN UINTN Pages
);
/**
@@ -701,7 +683,6 @@ AllocatePool (
IN UINTN AllocationSize
);
-
/**
Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
@@ -725,14 +706,13 @@ AllocateAlignedPages (
IN UINTN Alignment
);
-
EFI_STATUS
EFIAPI
LoadPeCoffImage (
- IN VOID *PeCoffImage,
- OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
- OUT UINT64 *ImageSize,
- OUT EFI_PHYSICAL_ADDRESS *EntryPoint
+ IN VOID *PeCoffImage,
+ OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
+ OUT UINT64 *ImageSize,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint
);
EFI_STATUS
diff --git a/EmbeddedPkg/Include/Library/RealTimeClockLib.h b/EmbeddedPkg/Include/Library/RealTimeClockLib.h
index 948f0890ae..9cc26c40a8 100644
--- a/EmbeddedPkg/Include/Library/RealTimeClockLib.h
+++ b/EmbeddedPkg/Include/Library/RealTimeClockLib.h
@@ -12,7 +12,6 @@
#ifndef __REAL_TIME_CLOCK_LIB__
#define __REAL_TIME_CLOCK_LIB__
-
/**
Returns the current time and date information, and the time-keeping capabilities
of the hardware platform.
@@ -33,7 +32,6 @@ LibGetTime (
OUT EFI_TIME_CAPABILITIES *Capabilities
);
-
/**
Sets the current local time and date information.
@@ -47,10 +45,9 @@ LibGetTime (
EFI_STATUS
EFIAPI
LibSetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
);
-
/**
Returns the current wakeup alarm clock setting.
@@ -66,12 +63,11 @@ LibSetTime (
EFI_STATUS
EFIAPI
LibGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
);
-
/**
Sets the system wakeup alarm clock time.
@@ -88,12 +84,10 @@ LibGetWakeupTime (
EFI_STATUS
EFIAPI
LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
+ IN BOOLEAN Enabled,
+ OUT EFI_TIME *Time
);
-
-
/**
This is the declaration of an EFI image entry point. This can be the entry point to an application
written to this specification, an EFI boot service driver, or an EFI runtime driver.
@@ -107,11 +101,10 @@ LibSetWakeupTime (
EFI_STATUS
EFIAPI
LibRtcInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
);
-
/**
Fixup internal data so that EFI can be call in virtual mode.
Call the passed in Child Notify event and convert any pointers in
@@ -123,10 +116,8 @@ LibRtcInitialize (
VOID
EFIAPI
LibRtcVirtualNotifyEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
-
#endif
-
diff --git a/EmbeddedPkg/Include/Library/TimeBaseLib.h b/EmbeddedPkg/Include/Library/TimeBaseLib.h
index 10700d1a64..320a695b27 100644
--- a/EmbeddedPkg/Include/Library/TimeBaseLib.h
+++ b/EmbeddedPkg/Include/Library/TimeBaseLib.h
@@ -20,13 +20,13 @@
// in which case __DATE__ is defined as a "Mmm dd yyyy" 11 chars string,
// but add an explicit filter for compilers that have been validated.
//
-#if (defined(__GNUC__) || defined(_MSC_VER) || defined(__clang__))
-#define TIME_BUILD_YEAR (__DATE__[7] == '?' ? 1900 \
+#if (defined (__GNUC__) || defined (_MSC_VER) || defined (__clang__))
+#define TIME_BUILD_YEAR (__DATE__[7] == '?' ? 1900\
: (((__DATE__[7] - '0') * 1000 ) \
+ (__DATE__[8] - '0') * 100 \
+ (__DATE__[9] - '0') * 10 \
+ __DATE__[10] - '0'))
-#define TIME_BUILD_MONTH ( __DATE__ [2] == '?' ? 1 \
+#define TIME_BUILD_MONTH ( __DATE__ [2] == '?' ? 1 \
: __DATE__ [2] == 'n' ? ( \
__DATE__ [1] == 'a' ? 1 : 6) \
: __DATE__ [2] == 'b' ? 2 \
@@ -39,19 +39,19 @@
: __DATE__ [2] == 't' ? 10 \
: __DATE__ [2] == 'v' ? 11 \
: 12)
-#define TIME_BUILD_DAY ( __DATE__[4] == '?' ? 1 \
+#define TIME_BUILD_DAY ( __DATE__[4] == '?' ? 1 \
: ((__DATE__[4] == ' ' ? 0 : \
((__DATE__[4] - '0') * 10)) \
+ __DATE__[5] - '0'))
#endif
// Define EPOCH (1970-JANUARY-01) in the Julian Date representation
-#define EPOCH_JULIAN_DATE 2440588
+#define EPOCH_JULIAN_DATE 2440588
// Seconds per unit
-#define SEC_PER_MIN ((UINTN) 60)
-#define SEC_PER_HOUR ((UINTN) 3600)
-#define SEC_PER_DAY ((UINTN) 86400)
+#define SEC_PER_MIN ((UINTN) 60)
+#define SEC_PER_HOUR ((UINTN) 3600)
+#define SEC_PER_DAY ((UINTN) 86400)
/**
Check if it is a leap year.
diff --git a/EmbeddedPkg/Include/Ppi/EmbeddedGpio.h b/EmbeddedPkg/Include/Ppi/EmbeddedGpio.h
index 03e512b888..b0d1b3703f 100644
--- a/EmbeddedPkg/Include/Ppi/EmbeddedGpio.h
+++ b/EmbeddedPkg/Include/Ppi/EmbeddedGpio.h
@@ -13,27 +13,27 @@
//
// Protocol interface structure
//
-typedef struct _EMBEDDED_GPIO_PPI EMBEDDED_GPIO_PPI;
+typedef struct _EMBEDDED_GPIO_PPI EMBEDDED_GPIO_PPI;
//
// Data Types
//
typedef UINTN EMBEDDED_GPIO_PIN;
-#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))
-#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))
-#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))
+#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))
+#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))
+#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))
typedef enum {
- GPIO_MODE_INPUT = 0x00,
- GPIO_MODE_OUTPUT_0 = 0x0E,
- GPIO_MODE_OUTPUT_1 = 0x0F,
- GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,
- GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,
- GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,
- GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,
- GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,
- GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07
+ GPIO_MODE_INPUT = 0x00,
+ GPIO_MODE_OUTPUT_0 = 0x0E,
+ GPIO_MODE_OUTPUT_1 = 0x0F,
+ GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,
+ GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,
+ GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,
+ GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,
+ GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,
+ GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07
} EMBEDDED_GPIO_MODE;
typedef enum {
@@ -61,7 +61,7 @@ typedef enum {
**/
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_GPIO_GET) (
+(EFIAPI *EMBEDDED_GPIO_GET)(
IN EMBEDDED_GPIO_PPI *This,
IN EMBEDDED_GPIO_PIN Gpio,
OUT UINTN *Value
@@ -82,13 +82,12 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_GPIO_SET) (
+(EFIAPI *EMBEDDED_GPIO_SET)(
IN EMBEDDED_GPIO_PPI *This,
IN EMBEDDED_GPIO_PIN Gpio,
IN EMBEDDED_GPIO_MODE Mode
);
-
/**
Gets the mode (function) of a GPIO pin
@@ -104,13 +103,12 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_GPIO_GET_MODE) (
+(EFIAPI *EMBEDDED_GPIO_GET_MODE)(
IN EMBEDDED_GPIO_PPI *This,
IN EMBEDDED_GPIO_PIN Gpio,
OUT EMBEDDED_GPIO_MODE *Mode
);
-
/**
Sets the pull-up / pull-down resistor of a GPIO pin
@@ -126,13 +124,12 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_GPIO_SET_PULL) (
+(EFIAPI *EMBEDDED_GPIO_SET_PULL)(
IN EMBEDDED_GPIO_PPI *This,
IN EMBEDDED_GPIO_PIN Gpio,
IN EMBEDDED_GPIO_PULL Direction
);
-
struct _EMBEDDED_GPIO_PPI {
EMBEDDED_GPIO_GET Get;
EMBEDDED_GPIO_SET Set;
@@ -140,6 +137,6 @@ struct _EMBEDDED_GPIO_PPI {
EMBEDDED_GPIO_SET_PULL SetPull;
};
-extern EFI_GUID gEmbeddedGpioPpiGuid;
+extern EFI_GUID gEmbeddedGpioPpiGuid;
#endif
diff --git a/EmbeddedPkg/Include/Protocol/AndroidBootImg.h b/EmbeddedPkg/Include/Protocol/AndroidBootImg.h
index 37a895119a..128a5d8f0d 100644
--- a/EmbeddedPkg/Include/Protocol/AndroidBootImg.h
+++ b/EmbeddedPkg/Include/Protocol/AndroidBootImg.h
@@ -12,30 +12,30 @@
//
// Protocol interface structure
//
-typedef struct _ANDROID_BOOTIMG_PROTOCOL ANDROID_BOOTIMG_PROTOCOL;
+typedef struct _ANDROID_BOOTIMG_PROTOCOL ANDROID_BOOTIMG_PROTOCOL;
//
// Function Prototypes
//
typedef
EFI_STATUS
-(EFIAPI *ANDROID_BOOTIMG_APPEND_KERNEL_ARGS) (
+(EFIAPI *ANDROID_BOOTIMG_APPEND_KERNEL_ARGS)(
IN CHAR16 *Args,
IN UINTN Size
);
typedef
EFI_STATUS
-(EFIAPI *ANDROID_BOOTIMG_UPDATE_DTB) (
+(EFIAPI *ANDROID_BOOTIMG_UPDATE_DTB)(
IN EFI_PHYSICAL_ADDRESS OrigDtbBase,
OUT EFI_PHYSICAL_ADDRESS *NewDtbBase
);
struct _ANDROID_BOOTIMG_PROTOCOL {
- ANDROID_BOOTIMG_APPEND_KERNEL_ARGS AppendArgs;
- ANDROID_BOOTIMG_UPDATE_DTB UpdateDtb;
+ ANDROID_BOOTIMG_APPEND_KERNEL_ARGS AppendArgs;
+ ANDROID_BOOTIMG_UPDATE_DTB UpdateDtb;
};
-extern EFI_GUID gAndroidBootImgProtocolGuid;
+extern EFI_GUID gAndroidBootImgProtocolGuid;
#endif /* __ANDROID_BOOTIMG_PROTOCOL_H__ */
diff --git a/EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h b/EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h
index ec15a35264..e3e51ebefd 100644
--- a/EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h
+++ b/EmbeddedPkg/Include/Protocol/AndroidFastbootPlatform.h
@@ -9,7 +9,7 @@
#ifndef __ANDROID_FASTBOOT_PLATFORM_H__
#define __ANDROID_FASTBOOT_PLATFORM_H__
-extern EFI_GUID gAndroidFastbootPlatformProtocolGuid;
+extern EFI_GUID gAndroidFastbootPlatformProtocolGuid;
/*
Protocol for platform-specific operations initiated by Android Fastboot.
@@ -58,9 +58,9 @@ VOID
typedef
EFI_STATUS
(*FASTBOOT_PLATFORM_FLASH) (
- IN CHAR8 *PartitionName,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN CHAR8 *PartitionName,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
/*
@@ -74,7 +74,7 @@ EFI_STATUS
typedef
EFI_STATUS
(*FASTBOOT_PLATFORM_ERASE) (
- IN CHAR8 *PartitionName
+ IN CHAR8 *PartitionName
);
/*
@@ -98,8 +98,8 @@ EFI_STATUS
typedef
EFI_STATUS
(*FASTBOOT_PLATFORM_GETVAR) (
- IN CHAR8 *Name,
- OUT CHAR8 *Value
+ IN CHAR8 *Name,
+ OUT CHAR8 *Value
);
/*
@@ -124,16 +124,16 @@ EFI_STATUS
typedef
EFI_STATUS
(*FASTBOOT_PLATFORM_OEM_COMMAND) (
- IN CHAR8 *Command
+ IN CHAR8 *Command
);
typedef struct _FASTBOOT_PLATFORM_PROTOCOL {
- FASTBOOT_PLATFORM_INIT Init;
- FASTBOOT_PLATFORM_UN_INIT UnInit;
- FASTBOOT_PLATFORM_FLASH FlashPartition;
- FASTBOOT_PLATFORM_ERASE ErasePartition;
- FASTBOOT_PLATFORM_GETVAR GetVar;
- FASTBOOT_PLATFORM_OEM_COMMAND DoOemCommand;
+ FASTBOOT_PLATFORM_INIT Init;
+ FASTBOOT_PLATFORM_UN_INIT UnInit;
+ FASTBOOT_PLATFORM_FLASH FlashPartition;
+ FASTBOOT_PLATFORM_ERASE ErasePartition;
+ FASTBOOT_PLATFORM_GETVAR GetVar;
+ FASTBOOT_PLATFORM_OEM_COMMAND DoOemCommand;
} FASTBOOT_PLATFORM_PROTOCOL;
#endif
diff --git a/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h b/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h
index dc19158878..b90d491d4a 100644
--- a/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h
+++ b/EmbeddedPkg/Include/Protocol/AndroidFastbootTransport.h
@@ -15,7 +15,7 @@
#ifndef __ANDROID_FASTBOOT_TRANSPORT_H__
#define __ANDROID_FASTBOOT_TRANSPORT_H__
-extern EFI_GUID gAndroidFastbootTransportProtocolGuid;
+extern EFI_GUID gAndroidFastbootTransportProtocolGuid;
/*
Set up the transport system for use by Fastboot.
@@ -43,7 +43,7 @@ extern EFI_GUID gAndroidFastbootTransportProtocolGuid;
typedef
EFI_STATUS
(*FASTBOOT_TRANSPORT_START) (
- IN EFI_EVENT ReceiveEvent
+ IN EFI_EVENT ReceiveEvent
);
/*
@@ -60,7 +60,7 @@ EFI_STATUS
*/
typedef
EFI_STATUS
-(* FASTBOOT_TRANSPORT_STOP) (
+(*FASTBOOT_TRANSPORT_STOP) (
VOID
);
@@ -87,8 +87,8 @@ typedef
EFI_STATUS
(*FASTBOOT_TRANSPORT_SEND) (
IN UINTN BufferSize,
- IN CONST VOID *Buffer,
- IN EFI_EVENT *FatalErrorEvent
+ IN CONST VOID *Buffer,
+ IN EFI_EVENT *FatalErrorEvent
);
/*
@@ -112,14 +112,14 @@ typedef
EFI_STATUS
(*FASTBOOT_TRANSPORT_RECEIVE) (
OUT UINTN *BufferSize,
- OUT VOID **Buffer
+ OUT VOID **Buffer
);
typedef struct _FASTBOOT_TRANSPORT_PROTOCOL {
- FASTBOOT_TRANSPORT_START Start;
- FASTBOOT_TRANSPORT_STOP Stop;
- FASTBOOT_TRANSPORT_SEND Send;
- FASTBOOT_TRANSPORT_RECEIVE Receive;
+ FASTBOOT_TRANSPORT_START Start;
+ FASTBOOT_TRANSPORT_STOP Stop;
+ FASTBOOT_TRANSPORT_SEND Send;
+ FASTBOOT_TRANSPORT_RECEIVE Receive;
} FASTBOOT_TRANSPORT_PROTOCOL;
#endif
diff --git a/EmbeddedPkg/Include/Protocol/EmbeddedDevice.h b/EmbeddedPkg/Include/Protocol/EmbeddedDevice.h
index b84f55bc8a..e6a1fdc2a1 100644
--- a/EmbeddedPkg/Include/Protocol/EmbeddedDevice.h
+++ b/EmbeddedPkg/Include/Protocol/EmbeddedDevice.h
@@ -23,7 +23,6 @@
#ifndef __EMBEDDED_DEVICE_PROTOCOL_H__
#define __EMBEDDED_DEVICE_PROTOCOL_H__
-
//
// Protocol GUID
//
@@ -32,21 +31,17 @@
#define EMBEDDED_DEVICE_PROTOCOL_GUID \
{ 0xbf4b9d10, 0x13ec, 0x43dd, { 0x88, 0x80, 0xe9, 0xb, 0x71, 0x8f, 0x27, 0xde } }
-
-
typedef struct {
- UINT16 VendorId;
- UINT16 DeviceId;
- UINT16 RevisionId;
- UINT16 SubsystemId;
- UINT16 SubsystemVendorId;
- UINT8 ClassCode[3];
- UINT8 HeaderSize;
- UINTN BaseAddress;
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT16 RevisionId;
+ UINT16 SubsystemId;
+ UINT16 SubsystemVendorId;
+ UINT8 ClassCode[3];
+ UINT8 HeaderSize;
+ UINTN BaseAddress;
} EMBEDDED_DEVICE_PROTOCOL;
-extern EFI_GUID gEmbeddedDeviceGuid;
+extern EFI_GUID gEmbeddedDeviceGuid;
#endif
-
-
diff --git a/EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h b/EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h
index a197c572e7..52c7fb6723 100644
--- a/EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h
+++ b/EmbeddedPkg/Include/Protocol/EmbeddedExternalDevice.h
@@ -12,7 +12,7 @@
//
// Protocol GUID
//
-#define EMBEDDED_EXTERNAL_DEVICE_PROTOCOL_GUID { 0x735F8C64, 0xD696, 0x44D0, { 0xBD, 0xF2, 0x44, 0x7F, 0xD0, 0x5A, 0x54, 0x06 }}
+#define EMBEDDED_EXTERNAL_DEVICE_PROTOCOL_GUID { 0x735F8C64, 0xD696, 0x44D0, { 0xBD, 0xF2, 0x44, 0x7F, 0xD0, 0x5A, 0x54, 0x06 }}
//
// Protocol interface structure
@@ -24,12 +24,13 @@ typedef struct _EMBEDDED_EXTERNAL_DEVICE EMBEDDED_EXTERNAL_DEVICE;
//
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_READ) (
- IN EMBEDDED_EXTERNAL_DEVICE *This,
- IN UINTN Register,
- IN UINTN Length,
- OUT VOID *Buffer
- )
+(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_READ)(
+ IN EMBEDDED_EXTERNAL_DEVICE *This,
+ IN UINTN Register,
+ IN UINTN Length,
+ OUT VOID *Buffer
+ )
+
/*++
Routine Description:
@@ -52,12 +53,13 @@ Returns:
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_WRITE) (
- IN EMBEDDED_EXTERNAL_DEVICE *This,
- IN UINTN Register,
- IN UINTN Length,
- IN VOID *Buffer
- )
+(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_WRITE)(
+ IN EMBEDDED_EXTERNAL_DEVICE *This,
+ IN UINTN Register,
+ IN UINTN Length,
+ IN VOID *Buffer
+ )
+
/*++
Routine Description:
@@ -79,10 +81,10 @@ Returns:
;
struct _EMBEDDED_EXTERNAL_DEVICE {
- EMBEDDED_EXTERNAL_DEVICE_READ Read;
- EMBEDDED_EXTERNAL_DEVICE_WRITE Write;
+ EMBEDDED_EXTERNAL_DEVICE_READ Read;
+ EMBEDDED_EXTERNAL_DEVICE_WRITE Write;
};
-extern EFI_GUID gEmbeddedExternalDeviceProtocolGuid;
+extern EFI_GUID gEmbeddedExternalDeviceProtocolGuid;
-#endif // __EMBEDDED_EXTERNAL_DEVICE_H__
+#endif // __EMBEDDED_EXTERNAL_DEVICE_H__
diff --git a/EmbeddedPkg/Include/Protocol/EmbeddedGpio.h b/EmbeddedPkg/Include/Protocol/EmbeddedGpio.h
index 83854fc286..3cd5b74a48 100644
--- a/EmbeddedPkg/Include/Protocol/EmbeddedGpio.h
+++ b/EmbeddedPkg/Include/Protocol/EmbeddedGpio.h
@@ -12,27 +12,27 @@
//
// Protocol interface structure
//
-typedef struct _EMBEDDED_GPIO EMBEDDED_GPIO;
+typedef struct _EMBEDDED_GPIO EMBEDDED_GPIO;
//
// Data Types
//
typedef UINTN EMBEDDED_GPIO_PIN;
-#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))
-#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))
-#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))
+#define GPIO(Port, Pin) ((EMBEDDED_GPIO_PIN)(((Port) << (16)) | (Pin)))
+#define GPIO_PIN(x) ((EMBEDDED_GPIO_PIN)(x) & (0xFFFF))
+#define GPIO_PORT(x) ((EMBEDDED_GPIO_PIN)(x) >> (16))
typedef enum {
- GPIO_MODE_INPUT = 0x00,
- GPIO_MODE_OUTPUT_0 = 0x0E,
- GPIO_MODE_OUTPUT_1 = 0x0F,
- GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,
- GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,
- GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,
- GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,
- GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,
- GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07
+ GPIO_MODE_INPUT = 0x00,
+ GPIO_MODE_OUTPUT_0 = 0x0E,
+ GPIO_MODE_OUTPUT_1 = 0x0F,
+ GPIO_MODE_SPECIAL_FUNCTION_2 = 0x02,
+ GPIO_MODE_SPECIAL_FUNCTION_3 = 0x03,
+ GPIO_MODE_SPECIAL_FUNCTION_4 = 0x04,
+ GPIO_MODE_SPECIAL_FUNCTION_5 = 0x05,
+ GPIO_MODE_SPECIAL_FUNCTION_6 = 0x06,
+ GPIO_MODE_SPECIAL_FUNCTION_7 = 0x07
} EMBEDDED_GPIO_MODE;
typedef enum {
@@ -46,11 +46,12 @@ typedef enum {
//
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_GPIO_GET) (
+(EFIAPI *EMBEDDED_GPIO_GET)(
IN EMBEDDED_GPIO *This,
IN EMBEDDED_GPIO_PIN Gpio,
OUT UINTN *Value
);
+
/*++
Routine Description:
@@ -69,14 +70,14 @@ Returns:
--*/
-
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_GPIO_SET) (
- IN EMBEDDED_GPIO *This,
- IN EMBEDDED_GPIO_PIN Gpio,
- IN EMBEDDED_GPIO_MODE Mode
- );
+(EFIAPI *EMBEDDED_GPIO_SET)(
+ IN EMBEDDED_GPIO *This,
+ IN EMBEDDED_GPIO_PIN Gpio,
+ IN EMBEDDED_GPIO_MODE Mode
+ );
+
/*++
Routine Description:
@@ -95,14 +96,14 @@ Returns:
--*/
-
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_GPIO_GET_MODE) (
- IN EMBEDDED_GPIO *This,
- IN EMBEDDED_GPIO_PIN Gpio,
- OUT EMBEDDED_GPIO_MODE *Mode
- );
+(EFIAPI *EMBEDDED_GPIO_GET_MODE)(
+ IN EMBEDDED_GPIO *This,
+ IN EMBEDDED_GPIO_PIN Gpio,
+ OUT EMBEDDED_GPIO_MODE *Mode
+ );
+
/*++
Routine Description:
@@ -121,14 +122,14 @@ Returns:
--*/
-
typedef
EFI_STATUS
-(EFIAPI *EMBEDDED_GPIO_SET_PULL) (
- IN EMBEDDED_GPIO *This,
- IN EMBEDDED_GPIO_PIN Gpio,
- IN EMBEDDED_GPIO_PULL Direction
- );
+(EFIAPI *EMBEDDED_GPIO_SET_PULL)(
+ IN EMBEDDED_GPIO *This,
+ IN EMBEDDED_GPIO_PIN Gpio,
+ IN EMBEDDED_GPIO_PULL Direction
+ );
+
/*++
Routine Description:
@@ -147,32 +148,30 @@ Returns:
--*/
-
-
struct _EMBEDDED_GPIO {
- EMBEDDED_GPIO_GET Get;
- EMBEDDED_GPIO_SET Set;
- EMBEDDED_GPIO_GET_MODE GetMode;
- EMBEDDED_GPIO_SET_PULL SetPull;
+ EMBEDDED_GPIO_GET Get;
+ EMBEDDED_GPIO_SET Set;
+ EMBEDDED_GPIO_GET_MODE GetMode;
+ EMBEDDED_GPIO_SET_PULL SetPull;
};
-extern EFI_GUID gEmbeddedGpioProtocolGuid;
+extern EFI_GUID gEmbeddedGpioProtocolGuid;
-typedef struct _GPIO_CONTROLLER GPIO_CONTROLLER;
-typedef struct _PLATFORM_GPIO_CONTROLLER PLATFORM_GPIO_CONTROLLER;
+typedef struct _GPIO_CONTROLLER GPIO_CONTROLLER;
+typedef struct _PLATFORM_GPIO_CONTROLLER PLATFORM_GPIO_CONTROLLER;
struct _GPIO_CONTROLLER {
- UINTN RegisterBase;
- UINTN GpioIndex;
- UINTN InternalGpioCount;
+ UINTN RegisterBase;
+ UINTN GpioIndex;
+ UINTN InternalGpioCount;
};
struct _PLATFORM_GPIO_CONTROLLER {
- UINTN GpioCount;
- UINTN GpioControllerCount;
- GPIO_CONTROLLER *GpioController;
+ UINTN GpioCount;
+ UINTN GpioControllerCount;
+ GPIO_CONTROLLER *GpioController;
};
-extern EFI_GUID gPlatformGpioProtocolGuid;
+extern EFI_GUID gPlatformGpioProtocolGuid;
#endif
diff --git a/EmbeddedPkg/Include/Protocol/FdtClient.h b/EmbeddedPkg/Include/Protocol/FdtClient.h
index 08eb49639b..723be88cfc 100644
--- a/EmbeddedPkg/Include/Protocol/FdtClient.h
+++ b/EmbeddedPkg/Include/Protocol/FdtClient.h
@@ -12,7 +12,7 @@
#ifndef __FDT_CLIENT_H__
#define __FDT_CLIENT_H__
-#define FDT_CLIENT_PROTOCOL_GUID { \
+#define FDT_CLIENT_PROTOCOL_GUID {\
0xE11FACA0, 0x4710, 0x4C8E, {0xA7, 0xA2, 0x01, 0xBA, 0xA2, 0x59, 0x1B, 0x4C} \
}
@@ -23,7 +23,7 @@ typedef struct _FDT_CLIENT_PROTOCOL FDT_CLIENT_PROTOCOL;
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_GET_NODE_PROPERTY) (
+(EFIAPI *FDT_CLIENT_GET_NODE_PROPERTY)(
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 Node,
IN CONST CHAR8 *PropertyName,
@@ -33,7 +33,7 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_SET_NODE_PROPERTY) (
+(EFIAPI *FDT_CLIENT_SET_NODE_PROPERTY)(
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 Node,
IN CONST CHAR8 *PropertyName,
@@ -43,7 +43,7 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_FIND_COMPATIBLE_NODE) (
+(EFIAPI *FDT_CLIENT_FIND_COMPATIBLE_NODE)(
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
OUT INT32 *Node
@@ -51,7 +51,7 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_FIND_NEXT_COMPATIBLE_NODE) (
+(EFIAPI *FDT_CLIENT_FIND_NEXT_COMPATIBLE_NODE)(
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
IN INT32 PrevNode,
@@ -60,7 +60,7 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_FIND_COMPATIBLE_NODE_PROPERTY) (
+(EFIAPI *FDT_CLIENT_FIND_COMPATIBLE_NODE_PROPERTY)(
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
IN CONST CHAR8 *PropertyName,
@@ -70,7 +70,7 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_FIND_COMPATIBLE_NODE_REG) (
+(EFIAPI *FDT_CLIENT_FIND_COMPATIBLE_NODE_REG)(
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
OUT CONST VOID **Reg,
@@ -81,7 +81,7 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_FIND_NEXT_MEMORY_NODE_REG) (
+(EFIAPI *FDT_CLIENT_FIND_NEXT_MEMORY_NODE_REG)(
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 PrevNode,
OUT INT32 *Node,
@@ -93,7 +93,7 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_FIND_MEMORY_NODE_REG) (
+(EFIAPI *FDT_CLIENT_FIND_MEMORY_NODE_REG)(
IN FDT_CLIENT_PROTOCOL *This,
OUT INT32 *Node,
OUT CONST VOID **Reg,
@@ -104,26 +104,26 @@ EFI_STATUS
typedef
EFI_STATUS
-(EFIAPI *FDT_CLIENT_GET_OR_INSERT_CHOSEN_NODE) (
+(EFIAPI *FDT_CLIENT_GET_OR_INSERT_CHOSEN_NODE)(
IN FDT_CLIENT_PROTOCOL *This,
OUT INT32 *Node
);
struct _FDT_CLIENT_PROTOCOL {
- FDT_CLIENT_GET_NODE_PROPERTY GetNodeProperty;
- FDT_CLIENT_SET_NODE_PROPERTY SetNodeProperty;
+ FDT_CLIENT_GET_NODE_PROPERTY GetNodeProperty;
+ FDT_CLIENT_SET_NODE_PROPERTY SetNodeProperty;
- FDT_CLIENT_FIND_COMPATIBLE_NODE FindCompatibleNode;
- FDT_CLIENT_FIND_NEXT_COMPATIBLE_NODE FindNextCompatibleNode;
- FDT_CLIENT_FIND_COMPATIBLE_NODE_PROPERTY FindCompatibleNodeProperty;
- FDT_CLIENT_FIND_COMPATIBLE_NODE_REG FindCompatibleNodeReg;
+ FDT_CLIENT_FIND_COMPATIBLE_NODE FindCompatibleNode;
+ FDT_CLIENT_FIND_NEXT_COMPATIBLE_NODE FindNextCompatibleNode;
+ FDT_CLIENT_FIND_COMPATIBLE_NODE_PROPERTY FindCompatibleNodeProperty;
+ FDT_CLIENT_FIND_COMPATIBLE_NODE_REG FindCompatibleNodeReg;
- FDT_CLIENT_FIND_MEMORY_NODE_REG FindMemoryNodeReg;
- FDT_CLIENT_FIND_NEXT_MEMORY_NODE_REG FindNextMemoryNodeReg;
+ FDT_CLIENT_FIND_MEMORY_NODE_REG FindMemoryNodeReg;
+ FDT_CLIENT_FIND_NEXT_MEMORY_NODE_REG FindNextMemoryNodeReg;
- FDT_CLIENT_GET_OR_INSERT_CHOSEN_NODE GetOrInsertChosenNode;
+ FDT_CLIENT_GET_OR_INSERT_CHOSEN_NODE GetOrInsertChosenNode;
};
-extern EFI_GUID gFdtClientProtocolGuid;
+extern EFI_GUID gFdtClientProtocolGuid;
#endif
diff --git a/EmbeddedPkg/Include/Protocol/HardwareInterrupt.h b/EmbeddedPkg/Include/Protocol/HardwareInterrupt.h
index ca95fa93c4..412e99b6d1 100644
--- a/EmbeddedPkg/Include/Protocol/HardwareInterrupt.h
+++ b/EmbeddedPkg/Include/Protocol/HardwareInterrupt.h
@@ -20,7 +20,6 @@
#include <Protocol/DebugSupport.h>
-
//
// Protocol GUID
//
@@ -29,13 +28,10 @@
#define EFI_HARDWARE_INTERRUPT_PROTOCOL_GGUID \
{ 0x2890B3EA, 0x053D, 0x1643, { 0xAD, 0x0C, 0xD6, 0x48, 0x08, 0xDA, 0x3F, 0xF1 } }
-
typedef struct _EFI_HARDWARE_INTERRUPT_PROTOCOL EFI_HARDWARE_INTERRUPT_PROTOCOL;
-
typedef UINTN HARDWARE_INTERRUPT_SOURCE;
-
/**
C Interrupt Handler calledin the interrupt context when Source interrupt is active.
@@ -48,12 +44,11 @@ typedef UINTN HARDWARE_INTERRUPT_SOURCE;
**/
typedef
VOID
-(EFIAPI *HARDWARE_INTERRUPT_HANDLER) (
+(EFIAPI *HARDWARE_INTERRUPT_HANDLER)(
IN HARDWARE_INTERRUPT_SOURCE Source,
IN EFI_SYSTEM_CONTEXT SystemContext
);
-
/**
Register Handler for the specified interrupt source.
@@ -67,13 +62,12 @@ VOID
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_REGISTER) (
+(EFIAPI *HARDWARE_INTERRUPT_REGISTER)(
IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
IN HARDWARE_INTERRUPT_HANDLER Handler
);
-
/**
Enable interrupt source Source.
@@ -86,13 +80,11 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_ENABLE) (
+(EFIAPI *HARDWARE_INTERRUPT_ENABLE)(
IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source
);
-
-
/**
Disable interrupt source Source.
@@ -105,12 +97,11 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_DISABLE) (
+(EFIAPI *HARDWARE_INTERRUPT_DISABLE)(
IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source
);
-
/**
Return current state of interrupt source Source.
@@ -124,7 +115,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_INTERRUPT_STATE) (
+(EFIAPI *HARDWARE_INTERRUPT_INTERRUPT_STATE)(
IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
IN BOOLEAN *InterruptState
@@ -143,22 +134,19 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT_END_OF_INTERRUPT) (
+(EFIAPI *HARDWARE_INTERRUPT_END_OF_INTERRUPT)(
IN EFI_HARDWARE_INTERRUPT_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source
);
-
struct _EFI_HARDWARE_INTERRUPT_PROTOCOL {
- HARDWARE_INTERRUPT_REGISTER RegisterInterruptSource;
- HARDWARE_INTERRUPT_ENABLE EnableInterruptSource;
- HARDWARE_INTERRUPT_DISABLE DisableInterruptSource;
- HARDWARE_INTERRUPT_INTERRUPT_STATE GetInterruptSourceState;
- HARDWARE_INTERRUPT_END_OF_INTERRUPT EndOfInterrupt;
+ HARDWARE_INTERRUPT_REGISTER RegisterInterruptSource;
+ HARDWARE_INTERRUPT_ENABLE EnableInterruptSource;
+ HARDWARE_INTERRUPT_DISABLE DisableInterruptSource;
+ HARDWARE_INTERRUPT_INTERRUPT_STATE GetInterruptSourceState;
+ HARDWARE_INTERRUPT_END_OF_INTERRUPT EndOfInterrupt;
};
-extern EFI_GUID gHardwareInterruptProtocolGuid;
+extern EFI_GUID gHardwareInterruptProtocolGuid;
#endif
-
-
diff --git a/EmbeddedPkg/Include/Protocol/HardwareInterrupt2.h b/EmbeddedPkg/Include/Protocol/HardwareInterrupt2.h
index 2b1cb5f28e..d017a9e21f 100644
--- a/EmbeddedPkg/Include/Protocol/HardwareInterrupt2.h
+++ b/EmbeddedPkg/Include/Protocol/HardwareInterrupt2.h
@@ -25,7 +25,7 @@ typedef enum {
} EFI_HARDWARE_INTERRUPT2_TRIGGER_TYPE;
typedef struct _EFI_HARDWARE_INTERRUPT2_PROTOCOL \
- EFI_HARDWARE_INTERRUPT2_PROTOCOL;
+ EFI_HARDWARE_INTERRUPT2_PROTOCOL;
/**
Register Handler for the specified interrupt source.
@@ -40,13 +40,12 @@ typedef struct _EFI_HARDWARE_INTERRUPT2_PROTOCOL \
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT2_REGISTER) (
+(EFIAPI *HARDWARE_INTERRUPT2_REGISTER)(
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
IN HARDWARE_INTERRUPT_HANDLER Handler
);
-
/**
Enable interrupt source Source.
@@ -59,12 +58,11 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT2_ENABLE) (
+(EFIAPI *HARDWARE_INTERRUPT2_ENABLE)(
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source
);
-
/**
Disable interrupt source Source.
@@ -77,12 +75,11 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT2_DISABLE) (
+(EFIAPI *HARDWARE_INTERRUPT2_DISABLE)(
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source
);
-
/**
Return current state of interrupt source Source.
@@ -96,7 +93,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT2_INTERRUPT_STATE) (
+(EFIAPI *HARDWARE_INTERRUPT2_INTERRUPT_STATE)(
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
IN BOOLEAN *InterruptState
@@ -115,7 +112,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT2_END_OF_INTERRUPT) (
+(EFIAPI *HARDWARE_INTERRUPT2_END_OF_INTERRUPT)(
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source
);
@@ -133,13 +130,12 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT2_GET_TRIGGER_TYPE) (
+(EFIAPI *HARDWARE_INTERRUPT2_GET_TRIGGER_TYPE)(
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
OUT EFI_HARDWARE_INTERRUPT2_TRIGGER_TYPE *TriggerType
);
-
/**
Configure the trigger type for an interrupt source
@@ -153,7 +149,7 @@ EFI_STATUS
**/
typedef
EFI_STATUS
-(EFIAPI *HARDWARE_INTERRUPT2_SET_TRIGGER_TYPE) (
+(EFIAPI *HARDWARE_INTERRUPT2_SET_TRIGGER_TYPE)(
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
IN EFI_HARDWARE_INTERRUPT2_TRIGGER_TYPE TriggerType
@@ -171,6 +167,6 @@ struct _EFI_HARDWARE_INTERRUPT2_PROTOCOL {
HARDWARE_INTERRUPT2_SET_TRIGGER_TYPE SetTriggerType;
};
-extern EFI_GUID gHardwareInterrupt2ProtocolGuid;
+extern EFI_GUID gHardwareInterrupt2ProtocolGuid;
#endif
diff --git a/EmbeddedPkg/Include/Protocol/MmcHost.h b/EmbeddedPkg/Include/Protocol/MmcHost.h
index 4772528cf1..881ae5e3d1 100644
--- a/EmbeddedPkg/Include/Protocol/MmcHost.h
+++ b/EmbeddedPkg/Include/Protocol/MmcHost.h
@@ -16,169 +16,166 @@
#define EMBEDDED_MMC_HOST_PROTOCOL_GUID \
{ 0x3e591c00, 0x9e4a, 0x11df, {0x92, 0x44, 0x00, 0x02, 0xA5, 0xD5, 0xC5, 0x1B } }
-#define MMC_RESPONSE_TYPE_R1 0
-#define MMC_RESPONSE_TYPE_R1b 0
-#define MMC_RESPONSE_TYPE_R2 1
-#define MMC_RESPONSE_TYPE_R3 0
-#define MMC_RESPONSE_TYPE_R6 0
-#define MMC_RESPONSE_TYPE_R7 0
-#define MMC_RESPONSE_TYPE_OCR 0
-#define MMC_RESPONSE_TYPE_CID 1
-#define MMC_RESPONSE_TYPE_CSD 1
-#define MMC_RESPONSE_TYPE_RCA 0
-
-typedef UINT32 MMC_RESPONSE_TYPE;
+#define MMC_RESPONSE_TYPE_R1 0
+#define MMC_RESPONSE_TYPE_R1b 0
+#define MMC_RESPONSE_TYPE_R2 1
+#define MMC_RESPONSE_TYPE_R3 0
+#define MMC_RESPONSE_TYPE_R6 0
+#define MMC_RESPONSE_TYPE_R7 0
+#define MMC_RESPONSE_TYPE_OCR 0
+#define MMC_RESPONSE_TYPE_CID 1
+#define MMC_RESPONSE_TYPE_CSD 1
+#define MMC_RESPONSE_TYPE_RCA 0
+
+typedef UINT32 MMC_RESPONSE_TYPE;
typedef UINT32 MMC_CMD;
-#define MMC_CMD_WAIT_RESPONSE (1 << 16)
-#define MMC_CMD_LONG_RESPONSE (1 << 17)
-#define MMC_CMD_NO_CRC_RESPONSE (1 << 18)
+#define MMC_CMD_WAIT_RESPONSE (1 << 16)
+#define MMC_CMD_LONG_RESPONSE (1 << 17)
+#define MMC_CMD_NO_CRC_RESPONSE (1 << 18)
#define MMC_INDX(Index) ((Index) & 0xFFFF)
#define MMC_GET_INDX(MmcCmd) ((MmcCmd) & 0xFFFF)
-#define MMC_CMD0 (MMC_INDX(0) | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD1 (MMC_INDX(1) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD2 (MMC_INDX(2) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)
-#define MMC_CMD3 (MMC_INDX(3) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD5 (MMC_INDX(5) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD6 (MMC_INDX(6) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD7 (MMC_INDX(7) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD8 (MMC_INDX(8) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD9 (MMC_INDX(9) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)
-#define MMC_CMD11 (MMC_INDX(11) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD12 (MMC_INDX(12) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD13 (MMC_INDX(13) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD16 (MMC_INDX(16) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD17 (MMC_INDX(17) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD18 (MMC_INDX(18) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD20 (MMC_INDX(20) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD23 (MMC_INDX(23) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD24 (MMC_INDX(24) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD25 (MMC_INDX(25) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD55 (MMC_INDX(55) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_ACMD41 (MMC_INDX(41) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_ACMD51 (MMC_INDX(51) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD0 (MMC_INDX(0) | MMC_CMD_NO_CRC_RESPONSE)
+#define MMC_CMD1 (MMC_INDX(1) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
+#define MMC_CMD2 (MMC_INDX(2) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)
+#define MMC_CMD3 (MMC_INDX(3) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD5 (MMC_INDX(5) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
+#define MMC_CMD6 (MMC_INDX(6) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD7 (MMC_INDX(7) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD8 (MMC_INDX(8) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD9 (MMC_INDX(9) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)
+#define MMC_CMD11 (MMC_INDX(11) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD12 (MMC_INDX(12) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD13 (MMC_INDX(13) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD16 (MMC_INDX(16) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD17 (MMC_INDX(17) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD18 (MMC_INDX(18) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD20 (MMC_INDX(20) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD23 (MMC_INDX(23) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD24 (MMC_INDX(24) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD25 (MMC_INDX(25) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_CMD55 (MMC_INDX(55) | MMC_CMD_WAIT_RESPONSE)
+#define MMC_ACMD41 (MMC_INDX(41) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
+#define MMC_ACMD51 (MMC_INDX(51) | MMC_CMD_WAIT_RESPONSE)
// Valid responses for CMD1 in eMMC
-#define EMMC_CMD1_CAPACITY_LESS_THAN_2GB 0x00FF8080 // Capacity <= 2GB, byte addressing used
-#define EMMC_CMD1_CAPACITY_GREATER_THAN_2GB 0x40FF8080 // Capacity > 2GB, 512-byte sector addressing used
+#define EMMC_CMD1_CAPACITY_LESS_THAN_2GB 0x00FF8080 // Capacity <= 2GB, byte addressing used
+#define EMMC_CMD1_CAPACITY_GREATER_THAN_2GB 0x40FF8080 // Capacity > 2GB, 512-byte sector addressing used
-#define MMC_STATUS_APP_CMD (1 << 5)
+#define MMC_STATUS_APP_CMD (1 << 5)
typedef enum _MMC_STATE {
- MmcInvalidState = 0,
- MmcHwInitializationState,
- MmcIdleState,
- MmcReadyState,
- MmcIdentificationState,
- MmcStandByState,
- MmcTransferState,
- MmcSendingDataState,
- MmcReceiveDataState,
- MmcProgrammingState,
- MmcDisconnectState,
+ MmcInvalidState = 0,
+ MmcHwInitializationState,
+ MmcIdleState,
+ MmcReadyState,
+ MmcIdentificationState,
+ MmcStandByState,
+ MmcTransferState,
+ MmcSendingDataState,
+ MmcReceiveDataState,
+ MmcProgrammingState,
+ MmcDisconnectState,
} MMC_STATE;
-#define EMMCBACKWARD (0)
-#define EMMCHS26 (1 << 0) // High-Speed @26MHz at rated device voltages
-#define EMMCHS52 (1 << 1) // High-Speed @52MHz at rated device voltages
-#define EMMCHS52DDR1V8 (1 << 2) // High-Speed Dual Data Rate @52MHz 1.8V or 3V I/O
-#define EMMCHS52DDR1V2 (1 << 3) // High-Speed Dual Data Rate @52MHz 1.2V I/O
-#define EMMCHS200SDR1V8 (1 << 4) // HS200 Single Data Rate @200MHz 1.8V I/O
-#define EMMCHS200SDR1V2 (1 << 5) // HS200 Single Data Rate @200MHz 1.2V I/O
-#define EMMCHS400DDR1V8 (1 << 6) // HS400 Dual Data Rate @400MHz 1.8V I/O
-#define EMMCHS400DDR1V2 (1 << 7) // HS400 Dual Data Rate @400MHz 1.2V I/O
+#define EMMCBACKWARD (0)
+#define EMMCHS26 (1 << 0) // High-Speed @26MHz at rated device voltages
+#define EMMCHS52 (1 << 1) // High-Speed @52MHz at rated device voltages
+#define EMMCHS52DDR1V8 (1 << 2) // High-Speed Dual Data Rate @52MHz 1.8V or 3V I/O
+#define EMMCHS52DDR1V2 (1 << 3) // High-Speed Dual Data Rate @52MHz 1.2V I/O
+#define EMMCHS200SDR1V8 (1 << 4) // HS200 Single Data Rate @200MHz 1.8V I/O
+#define EMMCHS200SDR1V2 (1 << 5) // HS200 Single Data Rate @200MHz 1.2V I/O
+#define EMMCHS400DDR1V8 (1 << 6) // HS400 Dual Data Rate @400MHz 1.8V I/O
+#define EMMCHS400DDR1V2 (1 << 7) // HS400 Dual Data Rate @400MHz 1.2V I/O
///
/// Forward declaration for EFI_MMC_HOST_PROTOCOL
///
-typedef struct _EFI_MMC_HOST_PROTOCOL EFI_MMC_HOST_PROTOCOL;
+typedef struct _EFI_MMC_HOST_PROTOCOL EFI_MMC_HOST_PROTOCOL;
-typedef BOOLEAN (EFIAPI *MMC_ISCARDPRESENT) (
+typedef BOOLEAN (EFIAPI *MMC_ISCARDPRESENT)(
IN EFI_MMC_HOST_PROTOCOL *This
);
-typedef BOOLEAN (EFIAPI *MMC_ISREADONLY) (
+typedef BOOLEAN (EFIAPI *MMC_ISREADONLY)(
IN EFI_MMC_HOST_PROTOCOL *This
);
-typedef EFI_STATUS (EFIAPI *MMC_BUILDDEVICEPATH) (
+typedef EFI_STATUS (EFIAPI *MMC_BUILDDEVICEPATH)(
IN EFI_MMC_HOST_PROTOCOL *This,
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
-typedef EFI_STATUS (EFIAPI *MMC_NOTIFYSTATE) (
+typedef EFI_STATUS (EFIAPI *MMC_NOTIFYSTATE)(
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_STATE State
);
-typedef EFI_STATUS (EFIAPI *MMC_SENDCOMMAND) (
+typedef EFI_STATUS (EFIAPI *MMC_SENDCOMMAND)(
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_CMD Cmd,
IN UINT32 Argument
);
-typedef EFI_STATUS (EFIAPI *MMC_RECEIVERESPONSE) (
+typedef EFI_STATUS (EFIAPI *MMC_RECEIVERESPONSE)(
IN EFI_MMC_HOST_PROTOCOL *This,
IN MMC_RESPONSE_TYPE Type,
IN UINT32 *Buffer
);
-typedef EFI_STATUS (EFIAPI *MMC_READBLOCKDATA) (
+typedef EFI_STATUS (EFIAPI *MMC_READBLOCKDATA)(
IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Length,
OUT UINT32 *Buffer
);
-typedef EFI_STATUS (EFIAPI *MMC_WRITEBLOCKDATA) (
+typedef EFI_STATUS (EFIAPI *MMC_WRITEBLOCKDATA)(
IN EFI_MMC_HOST_PROTOCOL *This,
IN EFI_LBA Lba,
IN UINTN Length,
IN UINT32 *Buffer
);
-typedef EFI_STATUS (EFIAPI *MMC_SETIOS) (
+typedef EFI_STATUS (EFIAPI *MMC_SETIOS)(
IN EFI_MMC_HOST_PROTOCOL *This,
IN UINT32 BusClockFreq,
IN UINT32 BusWidth,
IN UINT32 TimingMode
);
-typedef BOOLEAN (EFIAPI *MMC_ISMULTIBLOCK) (
+typedef BOOLEAN (EFIAPI *MMC_ISMULTIBLOCK)(
IN EFI_MMC_HOST_PROTOCOL *This
);
struct _EFI_MMC_HOST_PROTOCOL {
+ UINT32 Revision;
+ MMC_ISCARDPRESENT IsCardPresent;
+ MMC_ISREADONLY IsReadOnly;
+ MMC_BUILDDEVICEPATH BuildDevicePath;
- UINT32 Revision;
- MMC_ISCARDPRESENT IsCardPresent;
- MMC_ISREADONLY IsReadOnly;
- MMC_BUILDDEVICEPATH BuildDevicePath;
+ MMC_NOTIFYSTATE NotifyState;
- MMC_NOTIFYSTATE NotifyState;
+ MMC_SENDCOMMAND SendCommand;
+ MMC_RECEIVERESPONSE ReceiveResponse;
- MMC_SENDCOMMAND SendCommand;
- MMC_RECEIVERESPONSE ReceiveResponse;
-
- MMC_READBLOCKDATA ReadBlockData;
- MMC_WRITEBLOCKDATA WriteBlockData;
-
- MMC_SETIOS SetIos;
- MMC_ISMULTIBLOCK IsMultiBlock;
+ MMC_READBLOCKDATA ReadBlockData;
+ MMC_WRITEBLOCKDATA WriteBlockData;
+ MMC_SETIOS SetIos;
+ MMC_ISMULTIBLOCK IsMultiBlock;
};
-#define MMC_HOST_PROTOCOL_REVISION 0x00010002 // 1.2
+#define MMC_HOST_PROTOCOL_REVISION 0x00010002 // 1.2
-#define MMC_HOST_HAS_SETIOS(Host) (Host->Revision >= MMC_HOST_PROTOCOL_REVISION && \
+#define MMC_HOST_HAS_SETIOS(Host) (Host->Revision >= MMC_HOST_PROTOCOL_REVISION &&\
Host->SetIos != NULL)
-#define MMC_HOST_HAS_ISMULTIBLOCK(Host) (Host->Revision >= MMC_HOST_PROTOCOL_REVISION && \
+#define MMC_HOST_HAS_ISMULTIBLOCK(Host) (Host->Revision >= MMC_HOST_PROTOCOL_REVISION &&\
Host->IsMultiBlock != NULL)
-extern EFI_GUID gEmbeddedMmcHostProtocolGuid;
+extern EFI_GUID gEmbeddedMmcHostProtocolGuid;
#endif
-
diff --git a/EmbeddedPkg/Include/Protocol/PeCoffLoader.h b/EmbeddedPkg/Include/Protocol/PeCoffLoader.h
index 56557901b0..08738e9927 100644
--- a/EmbeddedPkg/Include/Protocol/PeCoffLoader.h
+++ b/EmbeddedPkg/Include/Protocol/PeCoffLoader.h
@@ -16,11 +16,8 @@
#define PE_COFF_LOADER_PROTOCOL_GUID \
{ 0xB323179B, 0x97FB, 0x477E, { 0xB0, 0xFE, 0xD8, 0x85, 0x91, 0xFA, 0x11, 0xAB } }
-
typedef struct _PE_COFF_LOADER_PROTOCOL PE_COFF_LOADER_PROTOCOL;
-
-
/**
Retrieves information about a PE/COFF image.
@@ -46,11 +43,10 @@ typedef struct _PE_COFF_LOADER_PROTOCOL PE_COFF_LOADER_PROTOCOL;
**/
typedef
RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_GET_IMAGE_INFO) (
+(EFIAPI *PE_COFF_LOADER_GET_IMAGE_INFO)(
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
-
/**
Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
@@ -83,11 +79,10 @@ RETURN_STATUS
**/
typedef
RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_RELOCATE_IMAGE) (
+(EFIAPI *PE_COFF_LOADER_RELOCATE_IMAGE)(
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
-
/**
Loads a PE/COFF image into memory.
@@ -121,12 +116,10 @@ RETURN_STATUS
**/
typedef
RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_LOAD_IMAGE) (
+(EFIAPI *PE_COFF_LOADER_LOAD_IMAGE)(
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
-
-
/**
Reads contents of a PE/COFF image from a buffer in system memory.
@@ -152,15 +145,13 @@ RETURN_STATUS
**/
typedef
RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_READ_FROM_MEMORY) (
+(EFIAPI *PE_COFF_LOADER_READ_FROM_MEMORY)(
IN VOID *FileHandle,
IN UINTN FileOffset,
IN OUT UINTN *ReadSize,
OUT VOID *Buffer
);
-
-
/**
Reapply fixups on a fixed up PE32/PE32+ image to allow virtual calling at EFI
runtime.
@@ -186,15 +177,13 @@ RETURN_STATUS
**/
typedef
VOID
-(EFIAPI *PE_COFF_LOADER_RELOCATE_IMAGE_FOR_RUNTIME) (
+(EFIAPI *PE_COFF_LOADER_RELOCATE_IMAGE_FOR_RUNTIME)(
IN PHYSICAL_ADDRESS ImageBase,
IN PHYSICAL_ADDRESS VirtImageBase,
IN UINTN ImageSize,
IN VOID *RelocationData
);
-
-
/**
Unloads a loaded PE/COFF image from memory and releases its taken resource.
Releases any environment specific resources that were allocated when the image
@@ -213,23 +202,19 @@ VOID
**/
typedef
RETURN_STATUS
-(EFIAPI *PE_COFF_LOADER_UNLOAD_IMAGE) (
+(EFIAPI *PE_COFF_LOADER_UNLOAD_IMAGE)(
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
-
struct _PE_COFF_LOADER_PROTOCOL {
- PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo;
- PE_COFF_LOADER_LOAD_IMAGE LoadImage;
- PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage;
- PE_COFF_LOADER_READ_FROM_MEMORY ReadFromMemory;
- PE_COFF_LOADER_RELOCATE_IMAGE_FOR_RUNTIME RelocateImageForRuntime;
- PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage;
+ PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo;
+ PE_COFF_LOADER_LOAD_IMAGE LoadImage;
+ PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage;
+ PE_COFF_LOADER_READ_FROM_MEMORY ReadFromMemory;
+ PE_COFF_LOADER_RELOCATE_IMAGE_FOR_RUNTIME RelocateImageForRuntime;
+ PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage;
};
-
-extern EFI_GUID gPeCoffLoaderProtocolGuid;
-
+extern EFI_GUID gPeCoffLoaderProtocolGuid;
#endif
-
diff --git a/EmbeddedPkg/Include/Protocol/PlatformBootManager.h b/EmbeddedPkg/Include/Protocol/PlatformBootManager.h
index 0167f4b35c..f1790d9742 100644
--- a/EmbeddedPkg/Include/Protocol/PlatformBootManager.h
+++ b/EmbeddedPkg/Include/Protocol/PlatformBootManager.h
@@ -12,7 +12,7 @@
//
// Protocol interface structure
//
-typedef struct _PLATFORM_BOOT_MANAGER_PROTOCOL PLATFORM_BOOT_MANAGER_PROTOCOL;
+typedef struct _PLATFORM_BOOT_MANAGER_PROTOCOL PLATFORM_BOOT_MANAGER_PROTOCOL;
//
// Function Prototypes
@@ -65,16 +65,16 @@ typedef struct _PLATFORM_BOOT_MANAGER_PROTOCOL PLATFORM_BOOT_MANAGER_PROTOCOL
*/
typedef
EFI_STATUS
-(EFIAPI *GET_PLATFORM_BOOT_OPTIONS_AND_KEYS) (
+(EFIAPI *GET_PLATFORM_BOOT_OPTIONS_AND_KEYS)(
OUT UINTN *Count,
OUT EFI_BOOT_MANAGER_LOAD_OPTION **BootOptions,
OUT EFI_INPUT_KEY **BootKeys
);
struct _PLATFORM_BOOT_MANAGER_PROTOCOL {
- GET_PLATFORM_BOOT_OPTIONS_AND_KEYS GetPlatformBootOptionsAndKeys;
+ GET_PLATFORM_BOOT_OPTIONS_AND_KEYS GetPlatformBootOptionsAndKeys;
};
-extern EFI_GUID gPlatformBootManagerProtocolGuid;
+extern EFI_GUID gPlatformBootManagerProtocolGuid;
#endif /* __PLATFORM_BOOT_MANAGER_PROTOCOL_H__ */
diff --git a/EmbeddedPkg/Include/Protocol/PlatformVirtualKeyboard.h b/EmbeddedPkg/Include/Protocol/PlatformVirtualKeyboard.h
index fc0ea09340..2123d3bc2e 100644
--- a/EmbeddedPkg/Include/Protocol/PlatformVirtualKeyboard.h
+++ b/EmbeddedPkg/Include/Protocol/PlatformVirtualKeyboard.h
@@ -12,48 +12,48 @@
//
// Protocol interface structure
//
-typedef struct _PLATFORM_VIRTUAL_KBD_PROTOCOL PLATFORM_VIRTUAL_KBD_PROTOCOL;
+typedef struct _PLATFORM_VIRTUAL_KBD_PROTOCOL PLATFORM_VIRTUAL_KBD_PROTOCOL;
-typedef struct _VIRTUAL_KBD_KEY VIRTUAL_KBD_KEY;
+typedef struct _VIRTUAL_KBD_KEY VIRTUAL_KBD_KEY;
-#define VIRTUAL_KEYBOARD_KEY_SIGNATURE SIGNATURE_32 ('v', 'k', 'b', 'd')
+#define VIRTUAL_KEYBOARD_KEY_SIGNATURE SIGNATURE_32 ('v', 'k', 'b', 'd')
struct _VIRTUAL_KBD_KEY {
- UINTN Signature;
- EFI_INPUT_KEY Key;
+ UINTN Signature;
+ EFI_INPUT_KEY Key;
};
typedef
EFI_STATUS
-(EFIAPI *PLATFORM_VIRTUAL_KBD_REGISTER) (
+(EFIAPI *PLATFORM_VIRTUAL_KBD_REGISTER)(
IN VOID
);
typedef
EFI_STATUS
-(EFIAPI *PLATFORM_VIRTUAL_KBD_RESET) (
+(EFIAPI *PLATFORM_VIRTUAL_KBD_RESET)(
IN VOID
);
typedef
BOOLEAN
-(EFIAPI *PLATFORM_VIRTUAL_KBD_QUERY) (
+(EFIAPI *PLATFORM_VIRTUAL_KBD_QUERY)(
IN VIRTUAL_KBD_KEY *VirtualKey
);
typedef
EFI_STATUS
-(EFIAPI *PLATFORM_VIRTUAL_KBD_CLEAR) (
+(EFIAPI *PLATFORM_VIRTUAL_KBD_CLEAR)(
IN VIRTUAL_KBD_KEY *VirtualKey
);
struct _PLATFORM_VIRTUAL_KBD_PROTOCOL {
- PLATFORM_VIRTUAL_KBD_REGISTER Register;
- PLATFORM_VIRTUAL_KBD_RESET Reset;
- PLATFORM_VIRTUAL_KBD_QUERY Query;
- PLATFORM_VIRTUAL_KBD_CLEAR Clear;
+ PLATFORM_VIRTUAL_KBD_REGISTER Register;
+ PLATFORM_VIRTUAL_KBD_RESET Reset;
+ PLATFORM_VIRTUAL_KBD_QUERY Query;
+ PLATFORM_VIRTUAL_KBD_CLEAR Clear;
};
-extern EFI_GUID gPlatformVirtualKeyboardProtocolGuid;
+extern EFI_GUID gPlatformVirtualKeyboardProtocolGuid;
#endif /* __PLATFORM_VIRTUAL_KEYBOARD_H__ */
diff --git a/EmbeddedPkg/Include/Protocol/UsbDevice.h b/EmbeddedPkg/Include/Protocol/UsbDevice.h
index 5936fb5e4c..b299ee10a7 100644
--- a/EmbeddedPkg/Include/Protocol/UsbDevice.h
+++ b/EmbeddedPkg/Include/Protocol/UsbDevice.h
@@ -11,7 +11,7 @@
#include <IndustryStandard/Usb.h>
-extern EFI_GUID gUsbDeviceProtocolGuid;
+extern EFI_GUID gUsbDeviceProtocolGuid;
/*
* Note: This Protocol is just the bare minimum for Android Fastboot. It
@@ -30,8 +30,8 @@ extern EFI_GUID gUsbDeviceProtocolGuid;
typedef
VOID
(*USB_DEVICE_RX_CALLBACK) (
- IN UINTN Size,
- IN VOID *Buffer
+ IN UINTN Size,
+ IN VOID *Buffer
);
/*
@@ -46,7 +46,7 @@ VOID
typedef
VOID
(*USB_DEVICE_TX_CALLBACK) (
- IN UINT8 EndpointIndex
+ IN UINT8 EndpointIndex
);
/*
@@ -64,9 +64,9 @@ VOID
typedef
EFI_STATUS
(*USB_DEVICE_SEND) (
- IN UINT8 EndpointIndex,
- IN UINTN Size,
- IN CONST VOID *Buffer
+ IN UINT8 EndpointIndex,
+ IN UINTN Size,
+ IN CONST VOID *Buffer
);
/*
@@ -96,15 +96,15 @@ EFI_STATUS
typedef
EFI_STATUS
(*USB_DEVICE_START) (
- IN USB_DEVICE_DESCRIPTOR *DeviceDescriptor,
- IN VOID **Descriptors,
- IN USB_DEVICE_RX_CALLBACK RxCallback,
- IN USB_DEVICE_TX_CALLBACK TxCallback
+ IN USB_DEVICE_DESCRIPTOR *DeviceDescriptor,
+ IN VOID **Descriptors,
+ IN USB_DEVICE_RX_CALLBACK RxCallback,
+ IN USB_DEVICE_TX_CALLBACK TxCallback
);
struct _USB_DEVICE_PROTOCOL {
- USB_DEVICE_START Start;
- USB_DEVICE_SEND Send;
+ USB_DEVICE_START Start;
+ USB_DEVICE_SEND Send;
};
typedef struct _USB_DEVICE_PROTOCOL USB_DEVICE_PROTOCOL;
diff --git a/EmbeddedPkg/Include/fdt.h b/EmbeddedPkg/Include/fdt.h
index 0187749f19..120dbc8bc6 100644
--- a/EmbeddedPkg/Include/fdt.h
+++ b/EmbeddedPkg/Include/fdt.h
@@ -1,5 +1,6 @@
#ifndef _FDT_H
#define _FDT_H
+
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -55,57 +56,57 @@
#ifndef __ASSEMBLY__
struct fdt_header {
- fdt32_t magic; /* magic word FDT_MAGIC */
- fdt32_t totalsize; /* total size of DT block */
- fdt32_t off_dt_struct; /* offset to structure */
- fdt32_t off_dt_strings; /* offset to strings */
- fdt32_t off_mem_rsvmap; /* offset to memory reserve map */
- fdt32_t version; /* format version */
- fdt32_t last_comp_version; /* last compatible version */
+ fdt32_t magic; /* magic word FDT_MAGIC */
+ fdt32_t totalsize; /* total size of DT block */
+ fdt32_t off_dt_struct; /* offset to structure */
+ fdt32_t off_dt_strings; /* offset to strings */
+ fdt32_t off_mem_rsvmap; /* offset to memory reserve map */
+ fdt32_t version; /* format version */
+ fdt32_t last_comp_version; /* last compatible version */
- /* version 2 fields below */
- fdt32_t boot_cpuid_phys; /* Which physical CPU id we're
- booting on */
- /* version 3 fields below */
- fdt32_t size_dt_strings; /* size of the strings block */
+ /* version 2 fields below */
+ fdt32_t boot_cpuid_phys; /* Which physical CPU id we're
+ booting on */
+ /* version 3 fields below */
+ fdt32_t size_dt_strings; /* size of the strings block */
- /* version 17 fields below */
- fdt32_t size_dt_struct; /* size of the structure block */
+ /* version 17 fields below */
+ fdt32_t size_dt_struct; /* size of the structure block */
};
struct fdt_reserve_entry {
- fdt64_t address;
- fdt64_t size;
+ fdt64_t address;
+ fdt64_t size;
};
struct fdt_node_header {
- fdt32_t tag;
- char name[0];
+ fdt32_t tag;
+ char name[0];
};
struct fdt_property {
- fdt32_t tag;
- fdt32_t len;
- fdt32_t nameoff;
- char data[0];
+ fdt32_t tag;
+ fdt32_t len;
+ fdt32_t nameoff;
+ char data[0];
};
#endif /* !__ASSEMBLY */
-#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
-#define FDT_TAGSIZE sizeof(fdt32_t)
+#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
+#define FDT_TAGSIZE sizeof(fdt32_t)
-#define FDT_BEGIN_NODE 0x1 /* Start node: full name */
-#define FDT_END_NODE 0x2 /* End node */
-#define FDT_PROP 0x3 /* Property: name off,
- size, content */
-#define FDT_NOP 0x4 /* nop */
-#define FDT_END 0x9
+#define FDT_BEGIN_NODE 0x1 /* Start node: full name */
+#define FDT_END_NODE 0x2 /* End node */
+#define FDT_PROP 0x3 /* Property: name off,
+ size, content */
+#define FDT_NOP 0x4 /* nop */
+#define FDT_END 0x9
-#define FDT_V1_SIZE (7*sizeof(fdt32_t))
-#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t))
-#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t))
-#define FDT_V16_SIZE FDT_V3_SIZE
-#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
+#define FDT_V1_SIZE (7*sizeof(fdt32_t))
+#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t))
+#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t))
+#define FDT_V16_SIZE FDT_V3_SIZE
+#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t))
#endif /* _FDT_H */
diff --git a/EmbeddedPkg/Include/libfdt.h b/EmbeddedPkg/Include/libfdt.h
index 141ecb579b..6105b9c075 100644
--- a/EmbeddedPkg/Include/libfdt.h
+++ b/EmbeddedPkg/Include/libfdt.h
@@ -1,5 +1,6 @@
#ifndef _LIBFDT_H
#define _LIBFDT_H
+
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -54,119 +55,160 @@
#include <libfdt_env.h>
#include <fdt.h>
-#define FDT_FIRST_SUPPORTED_VERSION 0x10
-#define FDT_LAST_SUPPORTED_VERSION 0x11
+#define FDT_FIRST_SUPPORTED_VERSION 0x10
+#define FDT_LAST_SUPPORTED_VERSION 0x11
/* Error codes: informative error codes */
-#define FDT_ERR_NOTFOUND 1
- /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
-#define FDT_ERR_EXISTS 2
- /* FDT_ERR_EXISTS: Attempted to create a node or property which
- * already exists */
-#define FDT_ERR_NOSPACE 3
- /* FDT_ERR_NOSPACE: Operation needed to expand the device
- * tree, but its buffer did not have sufficient space to
- * contain the expanded tree. Use fdt_open_into() to move the
- * device tree to a buffer with more space. */
+#define FDT_ERR_NOTFOUND 1
+/* FDT_ERR_NOTFOUND: The requested node or property does not exist */
+#define FDT_ERR_EXISTS 2
+
+/* FDT_ERR_EXISTS: Attempted to create a node or property which
+ * already exists */
+#define FDT_ERR_NOSPACE 3
+
+/* FDT_ERR_NOSPACE: Operation needed to expand the device
+ * tree, but its buffer did not have sufficient space to
+ * contain the expanded tree. Use fdt_open_into() to move the
+ * device tree to a buffer with more space. */
/* Error codes: codes for bad parameters */
-#define FDT_ERR_BADOFFSET 4
- /* FDT_ERR_BADOFFSET: Function was passed a structure block
- * offset which is out-of-bounds, or which points to an
- * unsuitable part of the structure for the operation. */
-#define FDT_ERR_BADPATH 5
- /* FDT_ERR_BADPATH: Function was passed a badly formatted path
- * (e.g. missing a leading / for a function which requires an
- * absolute path) */
-#define FDT_ERR_BADPHANDLE 6
- /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle.
- * This can be caused either by an invalid phandle property
- * length, or the phandle value was either 0 or -1, which are
- * not permitted. */
-#define FDT_ERR_BADSTATE 7
- /* FDT_ERR_BADSTATE: Function was passed an incomplete device
- * tree created by the sequential-write functions, which is
- * not sufficiently complete for the requested operation. */
+#define FDT_ERR_BADOFFSET 4
+
+/* FDT_ERR_BADOFFSET: Function was passed a structure block
+ * offset which is out-of-bounds, or which points to an
+ * unsuitable part of the structure for the operation. */
+#define FDT_ERR_BADPATH 5
+
+/* FDT_ERR_BADPATH: Function was passed a badly formatted path
+ * (e.g. missing a leading / for a function which requires an
+ * absolute path) */
+#define FDT_ERR_BADPHANDLE 6
+
+/* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle.
+ * This can be caused either by an invalid phandle property
+ * length, or the phandle value was either 0 or -1, which are
+ * not permitted. */
+#define FDT_ERR_BADSTATE 7
+
+/* FDT_ERR_BADSTATE: Function was passed an incomplete device
+ * tree created by the sequential-write functions, which is
+ * not sufficiently complete for the requested operation. */
/* Error codes: codes for bad device tree blobs */
-#define FDT_ERR_TRUNCATED 8
- /* FDT_ERR_TRUNCATED: Structure block of the given device tree
- * ends without an FDT_END tag. */
-#define FDT_ERR_BADMAGIC 9
- /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a
- * device tree at all - it is missing the flattened device
- * tree magic number. */
-#define FDT_ERR_BADVERSION 10
- /* FDT_ERR_BADVERSION: Given device tree has a version which
- * can't be handled by the requested operation. For
- * read-write functions, this may mean that fdt_open_into() is
- * required to convert the tree to the expected version. */
-#define FDT_ERR_BADSTRUCTURE 11
- /* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt
- * structure block or other serious error (e.g. misnested
- * nodes, or subnodes preceding properties). */
-#define FDT_ERR_BADLAYOUT 12
- /* FDT_ERR_BADLAYOUT: For read-write functions, the given
- * device tree has it's sub-blocks in an order that the
- * function can't handle (memory reserve map, then structure,
- * then strings). Use fdt_open_into() to reorganize the tree
- * into a form suitable for the read-write operations. */
+#define FDT_ERR_TRUNCATED 8
+
+/* FDT_ERR_TRUNCATED: Structure block of the given device tree
+ * ends without an FDT_END tag. */
+#define FDT_ERR_BADMAGIC 9
+
+/* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a
+ * device tree at all - it is missing the flattened device
+ * tree magic number. */
+#define FDT_ERR_BADVERSION 10
+
+/* FDT_ERR_BADVERSION: Given device tree has a version which
+ * can't be handled by the requested operation. For
+ * read-write functions, this may mean that fdt_open_into() is
+ * required to convert the tree to the expected version. */
+#define FDT_ERR_BADSTRUCTURE 11
+
+/* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt
+ * structure block or other serious error (e.g. misnested
+ * nodes, or subnodes preceding properties). */
+#define FDT_ERR_BADLAYOUT 12
+
+/* FDT_ERR_BADLAYOUT: For read-write functions, the given
+ * device tree has it's sub-blocks in an order that the
+ * function can't handle (memory reserve map, then structure,
+ * then strings). Use fdt_open_into() to reorganize the tree
+ * into a form suitable for the read-write operations. */
/* "Can't happen" error indicating a bug in libfdt */
-#define FDT_ERR_INTERNAL 13
- /* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.
- * Should never be returned, if it is, it indicates a bug in
- * libfdt itself. */
+#define FDT_ERR_INTERNAL 13
+
+/* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.
+ * Should never be returned, if it is, it indicates a bug in
+ * libfdt itself. */
/* Errors in device tree content */
-#define FDT_ERR_BADNCELLS 14
- /* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells
- * or similar property with a bad format or value */
+#define FDT_ERR_BADNCELLS 14
+
+/* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells
+ * or similar property with a bad format or value */
-#define FDT_ERR_BADVALUE 15
- /* FDT_ERR_BADVALUE: Device tree has a property with an unexpected
- * value. For example: a property expected to contain a string list
- * is not NUL-terminated within the length of its value. */
+#define FDT_ERR_BADVALUE 15
-#define FDT_ERR_BADOVERLAY 16
- /* FDT_ERR_BADOVERLAY: The device tree overlay, while
- * correctly structured, cannot be applied due to some
- * unexpected or missing value, property or node. */
+/* FDT_ERR_BADVALUE: Device tree has a property with an unexpected
+ * value. For example: a property expected to contain a string list
+ * is not NUL-terminated within the length of its value. */
-#define FDT_ERR_NOPHANDLES 17
- /* FDT_ERR_NOPHANDLES: The device tree doesn't have any
- * phandle available anymore without causing an overflow */
+#define FDT_ERR_BADOVERLAY 16
-#define FDT_ERR_MAX 17
+/* FDT_ERR_BADOVERLAY: The device tree overlay, while
+ * correctly structured, cannot be applied due to some
+ * unexpected or missing value, property or node. */
+
+#define FDT_ERR_NOPHANDLES 17
+
+/* FDT_ERR_NOPHANDLES: The device tree doesn't have any
+ * phandle available anymore without causing an overflow */
+
+#define FDT_ERR_MAX 17
/**********************************************************************/
/* Low-level functions (you probably don't need these) */
/**********************************************************************/
#ifndef SWIG /* This function is not useful in Python */
-const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
+const void *
+fdt_offset_ptr (
+ const void *fdt,
+ int offset,
+ unsigned int checklen
+ );
+
#endif
-static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
+static inline void *
+fdt_offset_ptr_w (
+ void *fdt,
+ int offset,
+ int checklen
+ )
{
- return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
+ return (void *)(uintptr_t)fdt_offset_ptr (fdt, offset, checklen);
}
-uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
+uint32_t
+fdt_next_tag (
+ const void *fdt,
+ int offset,
+ int *nextoffset
+ );
/**********************************************************************/
/* Traversal functions */
/**********************************************************************/
-int fdt_next_node(const void *fdt, int offset, int *depth);
+int
+fdt_next_node (
+ const void *fdt,
+ int offset,
+ int *depth
+ );
/**
* fdt_first_subnode() - get offset of first direct subnode
*
- * @fdt: FDT blob
- * @offset: Offset of node to check
+ * @fdt: FDT blob
+ * @offset: Offset of node to check
* @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none
*/
-int fdt_first_subnode(const void *fdt, int offset);
+int
+fdt_first_subnode (
+ const void *fdt,
+ int offset
+ );
/**
* fdt_next_subnode() - get offset of next direct subnode
@@ -174,73 +216,77 @@ int fdt_first_subnode(const void *fdt, int offset);
* After first calling fdt_first_subnode(), call this function repeatedly to
* get direct subnodes of a parent node.
*
- * @fdt: FDT blob
- * @offset: Offset of previous subnode
+ * @fdt: FDT blob
+ * @offset: Offset of previous subnode
* @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
* subnodes
*/
-int fdt_next_subnode(const void *fdt, int offset);
+int
+fdt_next_subnode (
+ const void *fdt,
+ int offset
+ );
/**
* fdt_for_each_subnode - iterate over all subnodes of a parent
*
- * @node: child node (int, lvalue)
- * @fdt: FDT blob (const void *)
- * @parent: parent node (int)
+ * @node: child node (int, lvalue)
+ * @fdt: FDT blob (const void *)
+ * @parent: parent node (int)
*
* This is actually a wrapper around a for loop and would be used like so:
*
- * fdt_for_each_subnode(node, fdt, parent) {
- * Use node
- * ...
- * }
+ * fdt_for_each_subnode(node, fdt, parent) {
+ * Use node
+ * ...
+ * }
*
- * if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {
- * Error handling
- * }
+ * if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {
+ * Error handling
+ * }
*
* Note that this is implemented as a macro and @node is used as
* iterator in the loop. The parent variable be constant or even a
* literal.
*
*/
-#define fdt_for_each_subnode(node, fdt, parent) \
- for (node = fdt_first_subnode(fdt, parent); \
- node >= 0; \
- node = fdt_next_subnode(fdt, node))
+#define fdt_for_each_subnode(node, fdt, parent) \
+ for (node = fdt_first_subnode(fdt, parent); \
+ node >= 0; \
+ node = fdt_next_subnode(fdt, node))
/**********************************************************************/
/* General functions */
/**********************************************************************/
#define fdt_get_header(fdt, field) \
- (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
-#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
-#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
-#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
-#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
-#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
-#define fdt_version(fdt) (fdt_get_header(fdt, version))
-#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
-#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
-#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
-#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
+ (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
+#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
+#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize))
+#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct))
+#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings))
+#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap))
+#define fdt_version(fdt) (fdt_get_header(fdt, version))
+#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version))
+#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys))
+#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings))
+#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct))
#define __fdt_set_hdr(name) \
- static inline void fdt_set_##name(void *fdt, uint32_t val) \
- { \
- struct fdt_header *fdth = (struct fdt_header *)fdt; \
- fdth->name = cpu_to_fdt32(val); \
- }
-__fdt_set_hdr(magic);
-__fdt_set_hdr(totalsize);
-__fdt_set_hdr(off_dt_struct);
-__fdt_set_hdr(off_dt_strings);
-__fdt_set_hdr(off_mem_rsvmap);
-__fdt_set_hdr(version);
-__fdt_set_hdr(last_comp_version);
-__fdt_set_hdr(boot_cpuid_phys);
-__fdt_set_hdr(size_dt_strings);
-__fdt_set_hdr(size_dt_struct);
+ static inline void fdt_set_##name(void *fdt, uint32_t val) \
+ { \
+ struct fdt_header *fdth = (struct fdt_header *)fdt; \
+ fdth->name = cpu_to_fdt32(val); \
+ }
+__fdt_set_hdr (magic);
+__fdt_set_hdr (totalsize);
+__fdt_set_hdr (off_dt_struct);
+__fdt_set_hdr (off_dt_strings);
+__fdt_set_hdr (off_mem_rsvmap);
+__fdt_set_hdr (version);
+__fdt_set_hdr (last_comp_version);
+__fdt_set_hdr (boot_cpuid_phys);
+__fdt_set_hdr (size_dt_strings);
+__fdt_set_hdr (size_dt_struct);
#undef __fdt_set_hdr
/**
@@ -257,7 +303,10 @@ __fdt_set_hdr(size_dt_struct);
* -FDT_ERR_BADVERSION,
* -FDT_ERR_BADSTATE, standard meanings, as above
*/
-int fdt_check_header(const void *fdt);
+int
+fdt_check_header (
+ const void *fdt
+ );
/**
* fdt_move - move a device tree around in memory
@@ -278,7 +327,12 @@ int fdt_check_header(const void *fdt);
* -FDT_ERR_BADVERSION,
* -FDT_ERR_BADSTATE, standard meanings
*/
-int fdt_move(const void *fdt, void *buf, int bufsize);
+int
+fdt_move (
+ const void *fdt,
+ void *buf,
+ int bufsize
+ );
/**********************************************************************/
/* Read-only functions */
@@ -296,7 +350,11 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
* a pointer to the string, on success
* NULL, if stroffset is out of bounds
*/
-const char *fdt_string(const void *fdt, int stroffset);
+const char *
+fdt_string (
+ const void *fdt,
+ int stroffset
+ );
/**
* fdt_get_max_phandle - retrieves the highest phandle in a tree
@@ -311,7 +369,10 @@ const char *fdt_string(const void *fdt, int stroffset);
* 0, if no phandle was found in the device tree
* -1, if an error occurred
*/
-uint32_t fdt_get_max_phandle(const void *fdt);
+uint32_t
+fdt_get_max_phandle (
+ const void *fdt
+ );
/**
* fdt_num_mem_rsv - retrieve the number of memory reserve map entries
@@ -324,7 +385,10 @@ uint32_t fdt_get_max_phandle(const void *fdt);
* returns:
* the number of entries
*/
-int fdt_num_mem_rsv(const void *fdt);
+int
+fdt_num_mem_rsv (
+ const void *fdt
+ );
/**
* fdt_get_mem_rsv - retrieve one memory reserve map entry
@@ -341,7 +405,13 @@ int fdt_num_mem_rsv(const void *fdt);
* -FDT_ERR_BADVERSION,
* -FDT_ERR_BADSTATE, standard meanings
*/
-int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
+int
+fdt_get_mem_rsv (
+ const void *fdt,
+ int n,
+ uint64_t *address,
+ uint64_t *size
+ );
/**
* fdt_subnode_offset_namelen - find a subnode based on substring
@@ -356,9 +426,16 @@ int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
* such as a full path.
*/
#ifndef SWIG /* Not available in Python */
-int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
- const char *name, int namelen);
+int
+fdt_subnode_offset_namelen (
+ const void *fdt,
+ int parentoffset,
+ const char *name,
+ int namelen
+ );
+
#endif
+
/**
* fdt_subnode_offset - find a subnode of a given node
* @fdt: pointer to the device tree blob
@@ -373,17 +450,22 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
* whose name excluding unit address matches the given name.
*
* returns:
- * structure block offset of the requested subnode (>=0), on success
- * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
- * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
- * tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
+ * structure block offset of the requested subnode (>=0), on success
+ * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
+ * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
+ * tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
*/
-int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
+int
+fdt_subnode_offset (
+ const void *fdt,
+ int parentoffset,
+ const char *name
+ );
/**
* fdt_path_offset_namelen - find a tree node by its full path
@@ -395,7 +477,13 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
* characters of path as the path name.
*/
#ifndef SWIG /* Not available in Python */
-int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
+int
+fdt_path_offset_namelen (
+ const void *fdt,
+ const char *path,
+ int namelen
+ );
+
#endif
/**
@@ -411,17 +499,21 @@ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
* address).
*
* returns:
- * structure block offset of the node with the requested path (>=0), on
- * success
- * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid
- * -FDT_ERR_NOTFOUND, if the requested node does not exist
+ * structure block offset of the node with the requested path (>=0), on
+ * success
+ * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid
+ * -FDT_ERR_NOTFOUND, if the requested node does not exist
* -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
*/
-int fdt_path_offset(const void *fdt, const char *path);
+int
+fdt_path_offset (
+ const void *fdt,
+ const char *path
+ );
/**
* fdt_get_name - retrieve the name of a given node
@@ -435,18 +527,23 @@ int fdt_path_offset(const void *fdt, const char *path);
* pointed to by lenp.
*
* returns:
- * pointer to the node's name, on success
- * If lenp is non-NULL, *lenp contains the length of that name
- * (>=0)
- * NULL, on error
- * if lenp is non-NULL *lenp contains an error code (<0):
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
- * tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE, standard meanings
- */
-const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
+ * pointer to the node's name, on success
+ * If lenp is non-NULL, *lenp contains the length of that name
+ * (>=0)
+ * NULL, on error
+ * if lenp is non-NULL *lenp contains an error code (<0):
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
+ * tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE, standard meanings
+ */
+const char *
+fdt_get_name (
+ const void *fdt,
+ int nodeoffset,
+ int *lenp
+ );
/**
* fdt_first_property_offset - find the offset of a node's first property
@@ -457,16 +554,20 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
* the given structure block offset.
*
* returns:
- * structure block offset of the property (>=0), on success
- * -FDT_ERR_NOTFOUND, if the requested node has no properties
- * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag
+ * structure block offset of the property (>=0), on success
+ * -FDT_ERR_NOTFOUND, if the requested node has no properties
+ * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag
* -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
*/
-int fdt_first_property_offset(const void *fdt, int nodeoffset);
+int
+fdt_first_property_offset (
+ const void *fdt,
+ int nodeoffset
+ );
/**
* fdt_next_property_offset - step through a node's properties
@@ -478,43 +579,47 @@ int fdt_first_property_offset(const void *fdt, int nodeoffset);
* of the same node as the given property.
*
* returns:
- * structure block offset of the next property (>=0), on success
- * -FDT_ERR_NOTFOUND, if the given property is the last in its node
- * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag
+ * structure block offset of the next property (>=0), on success
+ * -FDT_ERR_NOTFOUND, if the given property is the last in its node
+ * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag
* -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
*/
-int fdt_next_property_offset(const void *fdt, int offset);
+int
+fdt_next_property_offset (
+ const void *fdt,
+ int offset
+ );
/**
* fdt_for_each_property_offset - iterate over all properties of a node
*
- * @property_offset: property offset (int, lvalue)
- * @fdt: FDT blob (const void *)
- * @node: node offset (int)
+ * @property_offset: property offset (int, lvalue)
+ * @fdt: FDT blob (const void *)
+ * @node: node offset (int)
*
* This is actually a wrapper around a for loop and would be used like so:
*
- * fdt_for_each_property_offset(property, fdt, node) {
- * Use property
- * ...
- * }
+ * fdt_for_each_property_offset(property, fdt, node) {
+ * Use property
+ * ...
+ * }
*
- * if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) {
- * Error handling
- * }
+ * if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) {
+ * Error handling
+ * }
*
* Note that this is implemented as a macro and property is used as
* iterator in the loop. The node variable can be constant or even a
* literal.
*/
-#define fdt_for_each_property_offset(property, fdt, node) \
- for (property = fdt_first_property_offset(fdt, node); \
- property >= 0; \
- property = fdt_next_property_offset(fdt, property))
+#define fdt_for_each_property_offset(property, fdt, node) \
+ for (property = fdt_first_property_offset(fdt, node); \
+ property >= 0; \
+ property = fdt_next_property_offset(fdt, property))
/**
* fdt_get_property_by_offset - retrieve the property at a given offset
@@ -528,21 +633,24 @@ int fdt_next_property_offset(const void *fdt, int offset);
* also returned, in the integer pointed to by lenp.
*
* returns:
- * pointer to the structure representing the property
- * if lenp is non-NULL, *lenp contains the length of the property
- * value (>=0)
- * NULL, on error
- * if lenp is non-NULL, *lenp contains an error code (<0):
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
- int offset,
- int *lenp);
+ * pointer to the structure representing the property
+ * if lenp is non-NULL, *lenp contains the length of the property
+ * value (>=0)
+ * NULL, on error
+ * if lenp is non-NULL, *lenp contains an error code (<0):
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+const struct fdt_property *
+fdt_get_property_by_offset (
+ const void *fdt,
+ int offset,
+ int *lenp
+ );
/**
* fdt_get_property_namelen - find a property based on substring
@@ -556,10 +664,15 @@ const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
* characters of name for matching the property name.
*/
#ifndef SWIG /* Not available in Python */
-const struct fdt_property *fdt_get_property_namelen(const void *fdt,
- int nodeoffset,
- const char *name,
- int namelen, int *lenp);
+const struct fdt_property *
+fdt_get_property_namelen (
+ const void *fdt,
+ int nodeoffset,
+ const char *name,
+ int namelen,
+ int *lenp
+ );
+
#endif
/**
@@ -576,28 +689,38 @@ const struct fdt_property *fdt_get_property_namelen(const void *fdt,
* integer pointed to by lenp.
*
* returns:
- * pointer to the structure representing the property
- * if lenp is non-NULL, *lenp contains the length of the property
- * value (>=0)
- * NULL, on error
- * if lenp is non-NULL, *lenp contains an error code (<0):
- * -FDT_ERR_NOTFOUND, node does not have named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
- * tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,
- const char *name, int *lenp);
-static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
- const char *name,
- int *lenp)
+ * pointer to the structure representing the property
+ * if lenp is non-NULL, *lenp contains the length of the property
+ * value (>=0)
+ * NULL, on error
+ * if lenp is non-NULL, *lenp contains an error code (<0):
+ * -FDT_ERR_NOTFOUND, node does not have named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
+ * tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+const struct fdt_property *
+fdt_get_property (
+ const void *fdt,
+ int nodeoffset,
+ const char *name,
+ int *lenp
+ );
+
+static inline struct fdt_property *
+fdt_get_property_w (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int *lenp
+ )
{
- return (struct fdt_property *)(uintptr_t)
- fdt_get_property(fdt, nodeoffset, name, lenp);
+ return (struct fdt_property *)(uintptr_t)
+ fdt_get_property (fdt, nodeoffset, name, lenp);
}
/**
@@ -617,23 +740,29 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
* block, not a new copy of the name).
*
* returns:
- * pointer to the property's value
- * if lenp is non-NULL, *lenp contains the length of the property
- * value (>=0)
- * if namep is non-NULL *namep contiains a pointer to the property
- * name.
- * NULL, on error
- * if lenp is non-NULL, *lenp contains an error code (<0):
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * pointer to the property's value
+ * if lenp is non-NULL, *lenp contains the length of the property
+ * value (>=0)
+ * if namep is non-NULL *namep contiains a pointer to the property
+ * name.
+ * NULL, on error
+ * if lenp is non-NULL, *lenp contains an error code (<0):
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
#ifndef SWIG /* This function is not useful in Python */
-const void *fdt_getprop_by_offset(const void *fdt, int offset,
- const char **namep, int *lenp);
+const void *
+fdt_getprop_by_offset (
+ const void *fdt,
+ int offset,
+ const char **namep,
+ int *lenp
+ );
+
#endif
/**
@@ -648,15 +777,33 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
* characters of name for matching the property name.
*/
#ifndef SWIG /* Not available in Python */
-const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
- const char *name, int namelen, int *lenp);
-static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
- const char *name, int namelen,
- int *lenp)
+const void *
+fdt_getprop_namelen (
+ const void *fdt,
+ int nodeoffset,
+ const char *name,
+ int namelen,
+ int *lenp
+ );
+
+static inline void *
+fdt_getprop_namelen_w (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int namelen,
+ int *lenp
+ )
{
- return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
- namelen, lenp);
+ return (void *)(uintptr_t)fdt_getprop_namelen (
+ fdt,
+ nodeoffset,
+ name,
+ namelen,
+ lenp
+ );
}
+
#endif
/**
@@ -673,26 +820,37 @@ static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
* returned, in the integer pointed to by lenp.
*
* returns:
- * pointer to the property's value
- * if lenp is non-NULL, *lenp contains the length of the property
- * value (>=0)
- * NULL, on error
- * if lenp is non-NULL, *lenp contains an error code (<0):
- * -FDT_ERR_NOTFOUND, node does not have named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
- * tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-const void *fdt_getprop(const void *fdt, int nodeoffset,
- const char *name, int *lenp);
-static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
- const char *name, int *lenp)
+ * pointer to the property's value
+ * if lenp is non-NULL, *lenp contains the length of the property
+ * value (>=0)
+ * NULL, on error
+ * if lenp is non-NULL, *lenp contains an error code (<0):
+ * -FDT_ERR_NOTFOUND, node does not have named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE
+ * tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+const void *
+fdt_getprop (
+ const void *fdt,
+ int nodeoffset,
+ const char *name,
+ int *lenp
+ );
+
+static inline void *
+fdt_getprop_w (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int *lenp
+ )
{
- return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
+ return (void *)(uintptr_t)fdt_getprop (fdt, nodeoffset, name, lenp);
}
/**
@@ -704,10 +862,14 @@ static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
* structure block offset nodeoffset.
*
* returns:
- * the phandle of the node at nodeoffset, on success (!= 0, != -1)
- * 0, if the node has no phandle, or another error occurs
+ * the phandle of the node at nodeoffset, on success (!= 0, != -1)
+ * 0, if the node has no phandle, or another error occurs
*/
-uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
+uint32_t
+fdt_get_phandle (
+ const void *fdt,
+ int nodeoffset
+ );
/**
* fdt_get_alias_namelen - get alias based on substring
@@ -719,8 +881,13 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
* characters of name for matching the alias name.
*/
#ifndef SWIG /* Not available in Python */
-const char *fdt_get_alias_namelen(const void *fdt,
- const char *name, int namelen);
+const char *
+fdt_get_alias_namelen (
+ const void *fdt,
+ const char *name,
+ int namelen
+ );
+
#endif
/**
@@ -732,10 +899,14 @@ const char *fdt_get_alias_namelen(const void *fdt,
* value of the property named 'name' in the node /aliases.
*
* returns:
- * a pointer to the expansion of the alias named 'name', if it exists
- * NULL, if the given alias or the /aliases node does not exist
+ * a pointer to the expansion of the alias named 'name', if it exists
+ * NULL, if the given alias or the /aliases node does not exist
*/
-const char *fdt_get_alias(const void *fdt, const char *name);
+const char *
+fdt_get_alias (
+ const void *fdt,
+ const char *name
+ );
/**
* fdt_get_path - determine the full path of a node
@@ -751,18 +922,24 @@ const char *fdt_get_alias(const void *fdt, const char *name);
* structure from the start to nodeoffset.
*
* returns:
- * 0, on success
- * buf contains the absolute path of the node at
- * nodeoffset, as a NUL-terminated string.
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)
- * characters and will not fit in the given buffer.
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
+ * 0, on success
+ * buf contains the absolute path of the node at
+ * nodeoffset, as a NUL-terminated string.
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)
+ * characters and will not fit in the given buffer.
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
*/
-int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
+int
+fdt_get_path (
+ const void *fdt,
+ int nodeoffset,
+ char *buf,
+ int buflen
+ );
/**
* fdt_supernode_atdepth_offset - find a specific ancestor of a node
@@ -774,28 +951,33 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);
* fdt_supernode_atdepth_offset() finds an ancestor of the given node
* at a specific depth from the root (where the root itself has depth
* 0, its immediate subnodes depth 1 and so forth). So
- * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL);
+ * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL);
* will always return 0, the offset of the root node. If the node at
* nodeoffset has depth D, then:
- * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL);
+ * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL);
* will return nodeoffset itself.
*
* NOTE: This function is expensive, as it must scan the device tree
* structure from the start to nodeoffset.
*
* returns:
- * structure block offset of the node at node offset's ancestor
- * of depth supernodedepth (>=0), on success
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of
- * nodeoffset
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
+ * structure block offset of the node at node offset's ancestor
+ * of depth supernodedepth (>=0), on success
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of
+ * nodeoffset
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
*/
-int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
- int supernodedepth, int *nodedepth);
+int
+fdt_supernode_atdepth_offset (
+ const void *fdt,
+ int nodeoffset,
+ int supernodedepth,
+ int *nodedepth
+ );
/**
* fdt_node_depth - find the depth of a given node
@@ -809,14 +991,18 @@ int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
* structure from the start to nodeoffset.
*
* returns:
- * depth of the node at nodeoffset (>=0), on success
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
+ * depth of the node at nodeoffset (>=0), on success
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
*/
-int fdt_node_depth(const void *fdt, int nodeoffset);
+int
+fdt_node_depth (
+ const void *fdt,
+ int nodeoffset
+ );
/**
* fdt_parent_offset - find the parent of a given node
@@ -831,15 +1017,19 @@ int fdt_node_depth(const void *fdt, int nodeoffset);
* structure from the start to nodeoffset, *twice*.
*
* returns:
- * structure block offset of the parent of the node at nodeoffset
- * (>=0), on success
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
+ * structure block offset of the parent of the node at nodeoffset
+ * (>=0), on success
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
*/
-int fdt_parent_offset(const void *fdt, int nodeoffset);
+int
+fdt_parent_offset (
+ const void *fdt,
+ int nodeoffset
+ );
/**
* fdt_node_offset_by_prop_value - find nodes with a given property value
@@ -856,32 +1046,37 @@ int fdt_parent_offset(const void *fdt, int nodeoffset);
*
* To iterate through all nodes matching the criterion, the following
* idiom can be used:
- * offset = fdt_node_offset_by_prop_value(fdt, -1, propname,
- * propval, proplen);
- * while (offset != -FDT_ERR_NOTFOUND) {
- * // other code here
- * offset = fdt_node_offset_by_prop_value(fdt, offset, propname,
- * propval, proplen);
- * }
+ * offset = fdt_node_offset_by_prop_value(fdt, -1, propname,
+ * propval, proplen);
+ * while (offset != -FDT_ERR_NOTFOUND) {
+ * // other code here
+ * offset = fdt_node_offset_by_prop_value(fdt, offset, propname,
+ * propval, proplen);
+ * }
*
* Note the -1 in the first call to the function, if 0 is used here
* instead, the function will never locate the root node, even if it
* matches the criterion.
*
* returns:
- * structure block offset of the located node (>= 0, >startoffset),
- * on success
- * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
- * tree after startoffset
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
+ * structure block offset of the located node (>= 0, >startoffset),
+ * on success
+ * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
+ * tree after startoffset
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
*/
-int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
- const char *propname,
- const void *propval, int proplen);
+int
+fdt_node_offset_by_prop_value (
+ const void *fdt,
+ int startoffset,
+ const char *propname,
+ const void *propval,
+ int proplen
+ );
/**
* fdt_node_offset_by_phandle - find the node with a given phandle
@@ -894,15 +1089,19 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
* undefined.
*
* returns:
- * structure block offset of the located node (>= 0), on success
- * -FDT_ERR_NOTFOUND, no node with that phandle exists
- * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
+ * structure block offset of the located node (>= 0), on success
+ * -FDT_ERR_NOTFOUND, no node with that phandle exists
+ * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
*/
-int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
+int
+fdt_node_offset_by_phandle (
+ const void *fdt,
+ uint32_t phandle
+ );
/**
* fdt_node_check_compatible: check a node's compatible property
@@ -916,18 +1115,22 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
* it returns non-zero otherwise, or on error.
*
* returns:
- * 0, if the node has a 'compatible' property listing the given string
- * 1, if the node has a 'compatible' property, but it does not list
- * the given string
- * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property
- * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
+ * 0, if the node has a 'compatible' property listing the given string
+ * 1, if the node has a 'compatible' property, but it does not list
+ * the given string
+ * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property
+ * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
*/
-int fdt_node_check_compatible(const void *fdt, int nodeoffset,
- const char *compatible);
+int
+fdt_node_check_compatible (
+ const void *fdt,
+ int nodeoffset,
+ const char *compatible
+ );
/**
* fdt_node_offset_by_compatible - find nodes with a given 'compatible' value
@@ -942,29 +1145,33 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
*
* To iterate through all nodes matching the criterion, the following
* idiom can be used:
- * offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
- * while (offset != -FDT_ERR_NOTFOUND) {
- * // other code here
- * offset = fdt_node_offset_by_compatible(fdt, offset, compatible);
- * }
+ * offset = fdt_node_offset_by_compatible(fdt, -1, compatible);
+ * while (offset != -FDT_ERR_NOTFOUND) {
+ * // other code here
+ * offset = fdt_node_offset_by_compatible(fdt, offset, compatible);
+ * }
*
* Note the -1 in the first call to the function, if 0 is used here
* instead, the function will never locate the root node, even if it
* matches the criterion.
*
* returns:
- * structure block offset of the located node (>= 0, >startoffset),
- * on success
- * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
- * tree after startoffset
- * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE, standard meanings
+ * structure block offset of the located node (>= 0, >startoffset),
+ * on success
+ * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the
+ * tree after startoffset
+ * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE, standard meanings
*/
-int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
- const char *compatible);
+int
+fdt_node_offset_by_compatible (
+ const void *fdt,
+ int startoffset,
+ const char *compatible
+ );
/**
* fdt_stringlist_contains - check a string list property for a string
@@ -978,7 +1185,12 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
*
* @return: 1 if the string is found in the list, 0 not found, or invalid list
*/
-int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
+int
+fdt_stringlist_contains (
+ const char *strlist,
+ int listlen,
+ const char *str
+ );
/**
* fdt_stringlist_count - count the number of strings in a string list
@@ -990,7 +1202,12 @@ int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
* -FDT_ERR_BADVALUE if the property value is not NUL-terminated
* -FDT_ERR_NOTFOUND if the property does not exist
*/
-int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property);
+int
+fdt_stringlist_count (
+ const void *fdt,
+ int nodeoffset,
+ const char *property
+ );
/**
* fdt_stringlist_search - find a string in a string list and return its index
@@ -1011,8 +1228,13 @@ int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property);
* -FDT_ERR_NOTFOUND if the property does not exist or does not contain
* the given string
*/
-int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,
- const char *string);
+int
+fdt_stringlist_search (
+ const void *fdt,
+ int nodeoffset,
+ const char *property,
+ const char *string
+ );
/**
* fdt_stringlist_get() - obtain the string at a given index in a string list
@@ -1038,9 +1260,14 @@ int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,
* -FDT_ERR_BADVALUE if the property value is not NUL-terminated
* -FDT_ERR_NOTFOUND if the property does not exist
*/
-const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
- const char *property, int index,
- int *lenp);
+const char *
+fdt_stringlist_get (
+ const void *fdt,
+ int nodeoffset,
+ const char *property,
+ int index,
+ int *lenp
+ );
/**********************************************************************/
/* Read-only functions (addressing related) */
@@ -1055,7 +1282,7 @@ const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
* Implementations may support larger values, but in practice higher
* values aren't used.
*/
-#define FDT_MAX_NCELLS 4
+#define FDT_MAX_NCELLS 4
/**
* fdt_address_cells - retrieve address size for a bus represented in the tree
@@ -1065,17 +1292,21 @@ const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
* When the node has a valid #address-cells property, returns its value.
*
* returns:
- * 0 <= n < FDT_MAX_NCELLS, on success
+ * 0 <= n < FDT_MAX_NCELLS, on success
* 2, if the node has no #address-cells property
* -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
- * #address-cells property
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * #address-cells property
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
-int fdt_address_cells(const void *fdt, int nodeoffset);
+int
+fdt_address_cells (
+ const void *fdt,
+ int nodeoffset
+ );
/**
* fdt_size_cells - retrieve address range size for a bus represented in the
@@ -1086,18 +1317,21 @@ int fdt_address_cells(const void *fdt, int nodeoffset);
* When the node has a valid #size-cells property, returns its value.
*
* returns:
- * 0 <= n < FDT_MAX_NCELLS, on success
+ * 0 <= n < FDT_MAX_NCELLS, on success
* 2, if the node has no #address-cells property
* -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
- * #size-cells property
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * #size-cells property
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
-int fdt_size_cells(const void *fdt, int nodeoffset);
-
+int
+fdt_size_cells (
+ const void *fdt,
+ int nodeoffset
+ );
/**********************************************************************/
/* Write-in-place functions */
@@ -1120,10 +1354,17 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
* an array and you have a string that doesn't end with \0.
*/
#ifndef SWIG /* Not available in Python */
-int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
- const char *name, int namelen,
- uint32_t idx, const void *val,
- int len);
+int
+fdt_setprop_inplace_namelen_partial (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int namelen,
+ uint32_t idx,
+ const void *val,
+ int len
+ );
+
#endif
/**
@@ -1144,19 +1385,26 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
* of the tree.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, if len is not equal to the property's current length
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOSPACE, if len is not equal to the property's current length
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
#ifndef SWIG /* Not available in Python */
-int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
- const void *val, int len);
+int
+fdt_setprop_inplace (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ const void *val,
+ int len
+ );
+
#endif
/**
@@ -1177,21 +1425,27 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
* of the tree.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, if the property's length is not equal to 4
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
- const char *name, uint32_t val)
+ * 0, on success
+ * -FDT_ERR_NOSPACE, if the property's length is not equal to 4
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int
+fdt_setprop_inplace_u32 (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint32_t val
+ )
{
- fdt32_t tmp = cpu_to_fdt32(val);
- return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+ fdt32_t tmp = cpu_to_fdt32 (val);
+
+ return fdt_setprop_inplace (fdt, nodeoffset, name, &tmp, sizeof (tmp));
}
/**
@@ -1212,21 +1466,27 @@ static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,
* of the tree.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, if the property's length is not equal to 8
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
- const char *name, uint64_t val)
+ * 0, on success
+ * -FDT_ERR_NOSPACE, if the property's length is not equal to 8
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int
+fdt_setprop_inplace_u64 (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint64_t val
+ )
{
- fdt64_t tmp = cpu_to_fdt64(val);
- return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+ fdt64_t tmp = cpu_to_fdt64 (val);
+
+ return fdt_setprop_inplace (fdt, nodeoffset, name, &tmp, sizeof (tmp));
}
/**
@@ -1234,10 +1494,15 @@ static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
*
* This is an alternative name for fdt_setprop_inplace_u32()
*/
-static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
- const char *name, uint32_t val)
+static inline int
+fdt_setprop_inplace_cell (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint32_t val
+ )
{
- return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);
+ return fdt_setprop_inplace_u32 (fdt, nodeoffset, name, val);
}
/**
@@ -1255,16 +1520,21 @@ static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
* tree.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
-int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
+int
+fdt_nop_property (
+ void *fdt,
+ int nodeoffset,
+ const char *name
+ );
/**
* fdt_nop_node - replace a node (subtree) with nop tags
@@ -1280,39 +1550,95 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
* move any other part of the tree.
*
* returns:
- * 0, on success
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
-int fdt_nop_node(void *fdt, int nodeoffset);
+int
+fdt_nop_node (
+ void *fdt,
+ int nodeoffset
+ );
/**********************************************************************/
/* Sequential write functions */
/**********************************************************************/
-int fdt_create(void *buf, int bufsize);
-int fdt_resize(void *fdt, void *buf, int bufsize);
-int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
-int fdt_finish_reservemap(void *fdt);
-int fdt_begin_node(void *fdt, const char *name);
-int fdt_property(void *fdt, const char *name, const void *val, int len);
-static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)
+int
+fdt_create (
+ void *buf,
+ int bufsize
+ );
+
+int
+fdt_resize (
+ void *fdt,
+ void *buf,
+ int bufsize
+ );
+
+int
+fdt_add_reservemap_entry (
+ void *fdt,
+ uint64_t addr,
+ uint64_t size
+ );
+
+int
+fdt_finish_reservemap (
+ void *fdt
+ );
+
+int
+fdt_begin_node (
+ void *fdt,
+ const char *name
+ );
+
+int
+fdt_property (
+ void *fdt,
+ const char *name,
+ const void *val,
+ int len
+ );
+
+static inline int
+fdt_property_u32 (
+ void *fdt,
+ const char *name,
+ uint32_t val
+ )
{
- fdt32_t tmp = cpu_to_fdt32(val);
- return fdt_property(fdt, name, &tmp, sizeof(tmp));
+ fdt32_t tmp = cpu_to_fdt32 (val);
+
+ return fdt_property (fdt, name, &tmp, sizeof (tmp));
}
-static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)
+
+static inline int
+fdt_property_u64 (
+ void *fdt,
+ const char *name,
+ uint64_t val
+ )
{
- fdt64_t tmp = cpu_to_fdt64(val);
- return fdt_property(fdt, name, &tmp, sizeof(tmp));
+ fdt64_t tmp = cpu_to_fdt64 (val);
+
+ return fdt_property (fdt, name, &tmp, sizeof (tmp));
}
-static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
+
+static inline int
+fdt_property_cell (
+ void *fdt,
+ const char *name,
+ uint32_t val
+ )
{
- return fdt_property_u32(fdt, name, val);
+ return fdt_property_u32 (fdt, name, val);
}
/**
@@ -1324,24 +1650,51 @@ static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
* @valp: returns a pointer to where where the value should be placed
*
* returns:
- * 0, on success
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_NOSPACE, standard meanings
+ * 0, on success
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_NOSPACE, standard meanings
*/
-int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp);
+int
+fdt_property_placeholder (
+ void *fdt,
+ const char *name,
+ int len,
+ void **valp
+ );
#define fdt_property_string(fdt, name, str) \
- fdt_property(fdt, name, str, strlen(str)+1)
-int fdt_end_node(void *fdt);
-int fdt_finish(void *fdt);
+ fdt_property(fdt, name, str, strlen(str)+1)
+int
+fdt_end_node (
+ void *fdt
+ );
+
+int
+fdt_finish (
+ void *fdt
+ );
/**********************************************************************/
/* Read-write functions */
/**********************************************************************/
-int fdt_create_empty_tree(void *buf, int bufsize);
-int fdt_open_into(const void *fdt, void *buf, int bufsize);
-int fdt_pack(void *fdt);
+int
+fdt_create_empty_tree (
+ void *buf,
+ int bufsize
+ );
+
+int
+fdt_open_into (
+ const void *fdt,
+ void *buf,
+ int bufsize
+ );
+
+int
+fdt_pack (
+ void *fdt
+ );
/**
* fdt_add_mem_rsv - add one memory reserve map entry
@@ -1355,17 +1708,22 @@ int fdt_pack(void *fdt);
* therefore change the indexes of some entries in the table.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new reservation entry
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new reservation entry
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
-int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);
+int
+fdt_add_mem_rsv (
+ void *fdt,
+ uint64_t address,
+ uint64_t size
+ );
/**
* fdt_del_mem_rsv - remove a memory reserve map entry
@@ -1379,17 +1737,21 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);
* therefore change the indexes of some entries in the table.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there
- * are less than n+1 reserve map entries)
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there
+ * are less than n+1 reserve map entries)
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
-int fdt_del_mem_rsv(void *fdt, int n);
+int
+fdt_del_mem_rsv (
+ void *fdt,
+ int n
+ );
/**
* fdt_set_name - change the name of a given node
@@ -1407,15 +1769,20 @@ int fdt_del_mem_rsv(void *fdt, int n);
* therefore change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob
- * to contain the new name
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob
+ * to contain the new name
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE, standard meanings
*/
-int fdt_set_name(void *fdt, int nodeoffset, const char *name);
+int
+fdt_set_name (
+ void *fdt,
+ int nodeoffset,
+ const char *name
+ );
/**
* fdt_setprop - create or change a property
@@ -1433,20 +1800,26 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name);
* therefore change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_setprop(void *fdt, int nodeoffset, const char *name,
- const void *val, int len);
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int
+fdt_setprop (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ const void *val,
+ int len
+ );
/**
* fdt_setprop _placeholder - allocate space for a property
@@ -1464,20 +1837,26 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
* therefore change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
- int len, void **prop_data);
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int
+fdt_setprop_placeholder (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int len,
+ void **prop_data
+ );
/**
* fdt_setprop_u32 - set a property to a 32-bit integer
@@ -1495,23 +1874,29 @@ int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
* therefore change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
- uint32_t val)
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int
+fdt_setprop_u32 (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint32_t val
+ )
{
- fdt32_t tmp = cpu_to_fdt32(val);
- return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+ fdt32_t tmp = cpu_to_fdt32 (val);
+
+ return fdt_setprop (fdt, nodeoffset, name, &tmp, sizeof (tmp));
}
/**
@@ -1530,23 +1915,29 @@ static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,
* therefore change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
- uint64_t val)
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int
+fdt_setprop_u64 (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint64_t val
+ )
{
- fdt64_t tmp = cpu_to_fdt64(val);
- return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+ fdt64_t tmp = cpu_to_fdt64 (val);
+
+ return fdt_setprop (fdt, nodeoffset, name, &tmp, sizeof (tmp));
}
/**
@@ -1554,10 +1945,15 @@ static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
*
* This is an alternative name for fdt_setprop_u32()
*/
-static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
- uint32_t val)
+static inline int
+fdt_setprop_cell (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint32_t val
+ )
{
- return fdt_setprop_u32(fdt, nodeoffset, name, val);
+ return fdt_setprop_u32 (fdt, nodeoffset, name, val);
}
/**
@@ -1576,21 +1972,20 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
* therefore change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
#define fdt_setprop_string(fdt, nodeoffset, name, str) \
- fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
-
+ fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
/**
* fdt_setprop_empty - set a property to an empty value
@@ -1606,20 +2001,20 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
* therefore change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
#define fdt_setprop_empty(fdt, nodeoffset, name) \
- fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)
+ fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)
/**
* fdt_appendprop - append to or create a property
@@ -1636,20 +2031,26 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
* change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
- const void *val, int len);
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int
+fdt_appendprop (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ const void *val,
+ int len
+ );
/**
* fdt_appendprop_u32 - append a 32-bit integer value to a property
@@ -1667,23 +2068,29 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
* change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
- const char *name, uint32_t val)
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int
+fdt_appendprop_u32 (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint32_t val
+ )
{
- fdt32_t tmp = cpu_to_fdt32(val);
- return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+ fdt32_t tmp = cpu_to_fdt32 (val);
+
+ return fdt_appendprop (fdt, nodeoffset, name, &tmp, sizeof (tmp));
}
/**
@@ -1702,23 +2109,29 @@ static inline int fdt_appendprop_u32(void *fdt, int nodeoffset,
* change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
- const char *name, uint64_t val)
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+static inline int
+fdt_appendprop_u64 (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint64_t val
+ )
{
- fdt64_t tmp = cpu_to_fdt64(val);
- return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));
+ fdt64_t tmp = cpu_to_fdt64 (val);
+
+ return fdt_appendprop (fdt, nodeoffset, name, &tmp, sizeof (tmp));
}
/**
@@ -1726,10 +2139,15 @@ static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
*
* This is an alternative name for fdt_appendprop_u32()
*/
-static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
- const char *name, uint32_t val)
+static inline int
+fdt_appendprop_cell (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ uint32_t val
+ )
{
- return fdt_appendprop_u32(fdt, nodeoffset, name, val);
+ return fdt_appendprop_u32 (fdt, nodeoffset, name, val);
}
/**
@@ -1747,20 +2165,20 @@ static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
* change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
- * contain the new property value
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ * contain the new property value
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
#define fdt_appendprop_string(fdt, nodeoffset, name, str) \
- fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
+ fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
/**
* fdt_delprop - delete a property
@@ -1774,17 +2192,22 @@ static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
* change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOTFOUND, node does not have the named property
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_NOTFOUND, node does not have the named property
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
-int fdt_delprop(void *fdt, int nodeoffset, const char *name);
+int
+fdt_delprop (
+ void *fdt,
+ int nodeoffset,
+ const char *name
+ );
/**
* fdt_add_subnode_namelen - creates a new node based on substring
@@ -1799,8 +2222,14 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name);
* full path.
*/
#ifndef SWIG /* Not available in Python */
-int fdt_add_subnode_namelen(void *fdt, int parentoffset,
- const char *name, int namelen);
+int
+fdt_add_subnode_namelen (
+ void *fdt,
+ int parentoffset,
+ const char *name,
+ int namelen
+ );
+
#endif
/**
@@ -1817,24 +2246,29 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
* change the offsets of some existing nodes.
* returns:
- * structure block offset of the created nodeequested subnode (>=0), on
- * success
- * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
- * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
- * tag
- * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of
- * the given name
- * -FDT_ERR_NOSPACE, if there is insufficient free space in the
- * blob to contain the new node
- * -FDT_ERR_NOSPACE
- * -FDT_ERR_BADLAYOUT
+ * structure block offset of the created nodeequested subnode (>=0), on
+ * success
+ * -FDT_ERR_NOTFOUND, if the requested subnode does not exist
+ * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
+ * tag
+ * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of
+ * the given name
+ * -FDT_ERR_NOSPACE, if there is insufficient free space in the
+ * blob to contain the new node
+ * -FDT_ERR_NOSPACE
+ * -FDT_ERR_BADLAYOUT
* -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings.
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings.
*/
-int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
+int
+fdt_add_subnode (
+ void *fdt,
+ int parentoffset,
+ const char *name
+ );
/**
* fdt_del_node - delete a node (subtree)
@@ -1848,16 +2282,20 @@ int fdt_add_subnode(void *fdt, int parentoffset, const char *name);
* change the offsets of some existing nodes.
*
* returns:
- * 0, on success
- * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_TRUNCATED, standard meanings
+ * 0, on success
+ * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_TRUNCATED, standard meanings
*/
-int fdt_del_node(void *fdt, int nodeoffset);
+int
+fdt_del_node (
+ void *fdt,
+ int nodeoffset
+ );
/**
* fdt_overlay_apply - Applies a DT overlay on a base DT
@@ -1871,29 +2309,36 @@ int fdt_del_node(void *fdt, int nodeoffset);
* returns an error.
*
* returns:
- * 0, on success
- * -FDT_ERR_NOSPACE, there's not enough space in the base device tree
- * -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
- * properties in the base DT
- * -FDT_ERR_BADPHANDLE,
- * -FDT_ERR_BADOVERLAY,
- * -FDT_ERR_NOPHANDLES,
- * -FDT_ERR_INTERNAL,
- * -FDT_ERR_BADLAYOUT,
- * -FDT_ERR_BADMAGIC,
- * -FDT_ERR_BADOFFSET,
- * -FDT_ERR_BADPATH,
- * -FDT_ERR_BADVERSION,
- * -FDT_ERR_BADSTRUCTURE,
- * -FDT_ERR_BADSTATE,
- * -FDT_ERR_TRUNCATED, standard meanings
- */
-int fdt_overlay_apply(void *fdt, void *fdto);
+ * 0, on success
+ * -FDT_ERR_NOSPACE, there's not enough space in the base device tree
+ * -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
+ * properties in the base DT
+ * -FDT_ERR_BADPHANDLE,
+ * -FDT_ERR_BADOVERLAY,
+ * -FDT_ERR_NOPHANDLES,
+ * -FDT_ERR_INTERNAL,
+ * -FDT_ERR_BADLAYOUT,
+ * -FDT_ERR_BADMAGIC,
+ * -FDT_ERR_BADOFFSET,
+ * -FDT_ERR_BADPATH,
+ * -FDT_ERR_BADVERSION,
+ * -FDT_ERR_BADSTRUCTURE,
+ * -FDT_ERR_BADSTATE,
+ * -FDT_ERR_TRUNCATED, standard meanings
+ */
+int
+fdt_overlay_apply (
+ void *fdt,
+ void *fdto
+ );
/**********************************************************************/
/* Debugging / informational functions */
/**********************************************************************/
-const char *fdt_strerror(int errval);
+const char *
+fdt_strerror (
+ int errval
+ );
#endif /* _LIBFDT_H */
diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_env.h
index c35ac73970..dfd3bac01f 100644
--- a/EmbeddedPkg/Include/libfdt_env.h
+++ b/EmbeddedPkg/Include/libfdt_env.h
@@ -12,79 +12,153 @@
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
-typedef UINT16 fdt16_t;
-typedef UINT32 fdt32_t;
-typedef UINT64 fdt64_t;
-
-typedef UINT8 uint8_t;
-typedef UINT16 uint16_t;
-typedef UINT32 uint32_t;
-typedef UINT64 uint64_t;
-typedef UINTN uintptr_t;
-typedef UINTN size_t;
-
-static inline uint16_t fdt16_to_cpu(fdt16_t x)
+typedef UINT16 fdt16_t;
+typedef UINT32 fdt32_t;
+typedef UINT64 fdt64_t;
+
+typedef UINT8 uint8_t;
+typedef UINT16 uint16_t;
+typedef UINT32 uint32_t;
+typedef UINT64 uint64_t;
+typedef UINTN uintptr_t;
+typedef UINTN size_t;
+
+static inline uint16_t
+fdt16_to_cpu (
+ fdt16_t x
+ )
{
return SwapBytes16 (x);
}
-#define cpu_to_fdt16(x) fdt16_to_cpu(x)
-static inline uint32_t fdt32_to_cpu(fdt32_t x)
+#define cpu_to_fdt16(x) fdt16_to_cpu(x)
+
+static inline uint32_t
+fdt32_to_cpu (
+ fdt32_t x
+ )
{
return SwapBytes32 (x);
}
-#define cpu_to_fdt32(x) fdt32_to_cpu(x)
-static inline uint64_t fdt64_to_cpu(fdt64_t x)
+#define cpu_to_fdt32(x) fdt32_to_cpu(x)
+
+static inline uint64_t
+fdt64_to_cpu (
+ fdt64_t x
+ )
{
return SwapBytes64 (x);
}
-#define cpu_to_fdt64(x) fdt64_to_cpu(x)
-static inline void* memcpy(void* dest, const void* src, size_t len) {
+#define cpu_to_fdt64(x) fdt64_to_cpu(x)
+
+static inline void *
+memcpy (
+ void *dest,
+ const void *src,
+ size_t len
+ )
+{
return CopyMem (dest, src, len);
}
-static inline void *memmove(void *dest, const void *src, size_t n) {
+static inline void *
+memmove (
+ void *dest,
+ const void *src,
+ size_t n
+ )
+{
return CopyMem (dest, src, n);
}
-static inline void *memset(void *s, int c, size_t n) {
+static inline void *
+memset (
+ void *s,
+ int c,
+ size_t n
+ )
+{
return SetMem (s, n, c);
}
-static inline int memcmp(const void* dest, const void* src, int len) {
+static inline int
+memcmp (
+ const void *dest,
+ const void *src,
+ int len
+ )
+{
return CompareMem (dest, src, len);
}
-static inline void *memchr(const void *s, int c, size_t n) {
+static inline void *
+memchr (
+ const void *s,
+ int c,
+ size_t n
+ )
+{
return ScanMem8 (s, n, c);
}
-static inline size_t strlen (const char* str) {
+static inline size_t
+strlen (
+ const char *str
+ )
+{
return AsciiStrLen (str);
}
-static inline char *strchr(const char *s, int c) {
- char pattern[2];
+static inline char *
+strchr (
+ const char *s,
+ int c
+ )
+{
+ char pattern[2];
+
pattern[0] = c;
pattern[1] = 0;
return AsciiStrStr (s, pattern);
}
-static inline size_t strnlen (const char* str, size_t strsz ) {
+static inline size_t
+strnlen (
+ const char *str,
+ size_t strsz
+ )
+{
return AsciiStrnLenS (str, strsz);
}
-static inline size_t strcmp (const char* str1, const char* str2) {
+static inline size_t
+strcmp (
+ const char *str1,
+ const char *str2
+ )
+{
return AsciiStrCmp (str1, str2);
}
-static inline size_t strncmp (const char* str1, const char* str2, size_t strsz ) {
+static inline size_t
+strncmp (
+ const char *str1,
+ const char *str2,
+ size_t strsz
+ )
+{
return AsciiStrnCmp (str1, str2, strsz);
}
-static inline size_t strncpy (char* dest, const char* source, size_t dest_max) {
+static inline size_t
+strncpy (
+ char *dest,
+ const char *source,
+ size_t dest_max
+ )
+{
return AsciiStrCpyS (dest, dest_max, source);
}
diff --git a/EmbeddedPkg/Library/AcpiLib/AcpiLib.c b/EmbeddedPkg/Library/AcpiLib/AcpiLib.c
index c2bde4ad8e..740872ac3e 100644
--- a/EmbeddedPkg/Library/AcpiLib/AcpiLib.c
+++ b/EmbeddedPkg/Library/AcpiLib/AcpiLib.c
@@ -31,29 +31,29 @@
**/
EFI_STATUS
LocateAndInstallAcpiFromFvConditional (
- IN CONST EFI_GUID* AcpiFile,
+ IN CONST EFI_GUID *AcpiFile,
IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
)
{
- EFI_STATUS Status;
- EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol;
- EFI_HANDLE *HandleBuffer;
- UINTN NumberOfHandles;
- UINT32 FvStatus;
- UINTN Index;
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
- INTN SectionInstance;
- UINTN SectionSize;
- EFI_ACPI_COMMON_HEADER *AcpiTable;
- UINTN AcpiTableSize;
- UINTN AcpiTableKey;
- BOOLEAN Valid;
+ EFI_STATUS Status;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINT32 FvStatus;
+ UINTN Index;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
+ INTN SectionInstance;
+ UINTN SectionSize;
+ EFI_ACPI_COMMON_HEADER *AcpiTable;
+ UINTN AcpiTableSize;
+ UINTN AcpiTableKey;
+ BOOLEAN Valid;
// Ensure the ACPI Table is present
Status = gBS->LocateProtocol (
&gEfiAcpiTableProtocolGuid,
NULL,
- (VOID**)&AcpiProtocol
+ (VOID **)&AcpiProtocol
);
if (EFI_ERROR (Status)) {
return Status;
@@ -64,12 +64,12 @@ LocateAndInstallAcpiFromFvConditional (
// Locate all the Firmware Volume protocols.
Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiFirmwareVolume2ProtocolGuid,
- NULL,
- &NumberOfHandles,
- &HandleBuffer
- );
+ ByProtocol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
if (EFI_ERROR (Status)) {
return Status;
}
@@ -81,10 +81,10 @@ LocateAndInstallAcpiFromFvConditional (
// This should not fail because of LocateHandleBuffer
//
Status = gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiFirmwareVolume2ProtocolGuid,
- (VOID**) &FvInstance
- );
+ HandleBuffer[Index],
+ &gEfiFirmwareVolume2ProtocolGuid,
+ (VOID **)&FvInstance
+ );
if (EFI_ERROR (Status)) {
goto FREE_HANDLE_BUFFER;
}
@@ -95,24 +95,27 @@ LocateAndInstallAcpiFromFvConditional (
// See if it has the ACPI storage file
Status = FvInstance->ReadSection (
- FvInstance,
- AcpiFile,
- EFI_SECTION_RAW,
- SectionInstance,
- (VOID**) &AcpiTable,
- &SectionSize,
- &FvStatus
- );
+ FvInstance,
+ AcpiFile,
+ EFI_SECTION_RAW,
+ SectionInstance,
+ (VOID **)&AcpiTable,
+ &SectionSize,
+ &FvStatus
+ );
if (!EFI_ERROR (Status)) {
- AcpiTableKey = 0;
- AcpiTableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Length;
+ AcpiTableKey = 0;
+ AcpiTableSize = ((EFI_ACPI_DESCRIPTION_HEADER *)AcpiTable)->Length;
ASSERT (SectionSize >= AcpiTableSize);
- DEBUG ((DEBUG_ERROR, "- Found '%c%c%c%c' ACPI Table\n",
- (((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature & 0xFF),
- ((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 8) & 0xFF),
- ((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 16) & 0xFF),
- ((((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Signature >> 24) & 0xFF)));
+ DEBUG ((
+ DEBUG_ERROR,
+ "- Found '%c%c%c%c' ACPI Table\n",
+ (((EFI_ACPI_DESCRIPTION_HEADER *)AcpiTable)->Signature & 0xFF),
+ ((((EFI_ACPI_DESCRIPTION_HEADER *)AcpiTable)->Signature >> 8) & 0xFF),
+ ((((EFI_ACPI_DESCRIPTION_HEADER *)AcpiTable)->Signature >> 16) & 0xFF),
+ ((((EFI_ACPI_DESCRIPTION_HEADER *)AcpiTable)->Signature >> 24) & 0xFF)
+ ));
// Is the ACPI table valid?
if (CheckAcpiTableFunction) {
@@ -124,11 +127,11 @@ LocateAndInstallAcpiFromFvConditional (
// Install the ACPI Table
if (Valid) {
Status = AcpiProtocol->InstallAcpiTable (
- AcpiProtocol,
- AcpiTable,
- AcpiTableSize,
- &AcpiTableKey
- );
+ AcpiProtocol,
+ AcpiTable,
+ AcpiTableSize,
+ &AcpiTableKey
+ );
}
// Free memory allocated by ReadSection
@@ -165,7 +168,7 @@ FREE_HANDLE_BUFFER:
**/
EFI_STATUS
LocateAndInstallAcpiFromFv (
- IN CONST EFI_GUID* AcpiFile
+ IN CONST EFI_GUID *AcpiFile
)
{
return LocateAndInstallAcpiFromFvConditional (AcpiFile, NULL);
diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index cc39fef489..1359a66db2 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -20,24 +20,24 @@
#include <Guid/LinuxEfiInitrdMedia.h>
-#define FDT_ADDITIONAL_ENTRIES_SIZE 0x400
+#define FDT_ADDITIONAL_ENTRIES_SIZE 0x400
typedef struct {
- MEMMAP_DEVICE_PATH Node1;
- EFI_DEVICE_PATH_PROTOCOL End;
+ MEMMAP_DEVICE_PATH Node1;
+ EFI_DEVICE_PATH_PROTOCOL End;
} MEMORY_DEVICE_PATH;
typedef struct {
- VENDOR_DEVICE_PATH VendorMediaNode;
- EFI_DEVICE_PATH_PROTOCOL EndNode;
+ VENDOR_DEVICE_PATH VendorMediaNode;
+ EFI_DEVICE_PATH_PROTOCOL EndNode;
} RAMDISK_DEVICE_PATH;
-STATIC ANDROID_BOOTIMG_PROTOCOL *mAndroidBootImg;
-STATIC VOID *mRamdiskData = NULL;
-STATIC UINTN mRamdiskSize = 0;
-STATIC EFI_HANDLE mRamDiskLoadFileHandle = NULL;
+STATIC ANDROID_BOOTIMG_PROTOCOL *mAndroidBootImg;
+STATIC VOID *mRamdiskData = NULL;
+STATIC UINTN mRamdiskSize = 0;
+STATIC EFI_HANDLE mRamDiskLoadFileHandle = NULL;
-STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
+STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
{
{
{
@@ -58,13 +58,13 @@ STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
} // End
};
-STATIC CONST RAMDISK_DEVICE_PATH mRamdiskDevicePath =
+STATIC CONST RAMDISK_DEVICE_PATH mRamdiskDevicePath =
{
{
{
MEDIA_DEVICE_PATH,
MEDIA_VENDOR_DP,
- { sizeof (VENDOR_DEVICE_PATH), 0 }
+ { sizeof (VENDOR_DEVICE_PATH), 0 }
},
LINUX_EFI_INITRD_MEDIA_GUID
},
@@ -107,19 +107,20 @@ STATIC CONST RAMDISK_DEVICE_PATH mRamdiskDevicePath =
EFI_STATUS
EFIAPI
AndroidBootImgLoadFile2 (
- IN EFI_LOAD_FILE2_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN BOOLEAN BootPolicy,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer OPTIONAL
+ IN EFI_LOAD_FILE2_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN BOOLEAN BootPolicy,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer OPTIONAL
)
{
// Verify if the valid parameters
- if (This == NULL ||
- BufferSize == NULL ||
- FilePath == NULL ||
- !IsDevicePathValid (FilePath, 0)) {
+ if ((This == NULL) ||
+ (BufferSize == NULL) ||
+ (FilePath == NULL) ||
+ !IsDevicePathValid (FilePath, 0))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -132,7 +133,8 @@ AndroidBootImgLoadFile2 (
if (mRamdiskSize == 0) {
return EFI_NOT_FOUND;
}
- if (Buffer == NULL || *BufferSize < mRamdiskSize) {
+
+ if ((Buffer == NULL) || (*BufferSize < mRamdiskSize)) {
*BufferSize = mRamdiskSize;
return EFI_BUFFER_TOO_SMALL;
}
@@ -153,16 +155,20 @@ STATIC EFI_LOAD_FILE2_PROTOCOL mAndroidBootImgLoadFile2 = {
EFI_STATUS
AndroidBootImgGetImgSize (
- IN VOID *BootImg,
- OUT UINTN *ImgSize
+ IN VOID *BootImg,
+ OUT UINTN *ImgSize
)
{
- ANDROID_BOOTIMG_HEADER *Header;
+ ANDROID_BOOTIMG_HEADER *Header;
- Header = (ANDROID_BOOTIMG_HEADER *) BootImg;
+ Header = (ANDROID_BOOTIMG_HEADER *)BootImg;
- if (AsciiStrnCmp ((CONST CHAR8 *)Header->BootMagic, ANDROID_BOOT_MAGIC,
- ANDROID_BOOT_MAGIC_LENGTH) != 0) {
+ if (AsciiStrnCmp (
+ (CONST CHAR8 *)Header->BootMagic,
+ ANDROID_BOOT_MAGIC,
+ ANDROID_BOOT_MAGIC_LENGTH
+ ) != 0)
+ {
return EFI_INVALID_PARAMETER;
}
@@ -179,17 +185,21 @@ AndroidBootImgGetImgSize (
EFI_STATUS
AndroidBootImgGetKernelInfo (
- IN VOID *BootImg,
+ IN VOID *BootImg,
OUT VOID **Kernel,
- OUT UINTN *KernelSize
+ OUT UINTN *KernelSize
)
{
- ANDROID_BOOTIMG_HEADER *Header;
+ ANDROID_BOOTIMG_HEADER *Header;
- Header = (ANDROID_BOOTIMG_HEADER *) BootImg;
+ Header = (ANDROID_BOOTIMG_HEADER *)BootImg;
- if (AsciiStrnCmp ((CONST CHAR8 *)Header->BootMagic, ANDROID_BOOT_MAGIC,
- ANDROID_BOOT_MAGIC_LENGTH) != 0) {
+ if (AsciiStrnCmp (
+ (CONST CHAR8 *)Header->BootMagic,
+ ANDROID_BOOT_MAGIC,
+ ANDROID_BOOT_MAGIC_LENGTH
+ ) != 0)
+ {
return EFI_INVALID_PARAMETER;
}
@@ -200,23 +210,27 @@ AndroidBootImgGetKernelInfo (
ASSERT (IS_VALID_ANDROID_PAGE_SIZE (Header->PageSize));
*KernelSize = Header->KernelSize;
- *Kernel = (VOID *)((UINTN)BootImg + Header->PageSize);
+ *Kernel = (VOID *)((UINTN)BootImg + Header->PageSize);
return EFI_SUCCESS;
}
EFI_STATUS
AndroidBootImgGetRamdiskInfo (
- IN VOID *BootImg,
+ IN VOID *BootImg,
OUT VOID **Ramdisk,
- OUT UINTN *RamdiskSize
+ OUT UINTN *RamdiskSize
)
{
- ANDROID_BOOTIMG_HEADER *Header;
+ ANDROID_BOOTIMG_HEADER *Header;
Header = (ANDROID_BOOTIMG_HEADER *)BootImg;
- if (AsciiStrnCmp ((CONST CHAR8 *)Header->BootMagic, ANDROID_BOOT_MAGIC,
- ANDROID_BOOT_MAGIC_LENGTH) != 0) {
+ if (AsciiStrnCmp (
+ (CONST CHAR8 *)Header->BootMagic,
+ ANDROID_BOOT_MAGIC,
+ ANDROID_BOOT_MAGIC_LENGTH
+ ) != 0)
+ {
return EFI_INVALID_PARAMETER;
}
@@ -229,22 +243,27 @@ AndroidBootImgGetRamdiskInfo (
+ Header->PageSize
+ ALIGN_VALUE (Header->KernelSize, Header->PageSize));
}
+
return EFI_SUCCESS;
}
EFI_STATUS
AndroidBootImgGetSecondBootLoaderInfo (
- IN VOID *BootImg,
+ IN VOID *BootImg,
OUT VOID **Second,
- OUT UINTN *SecondSize
+ OUT UINTN *SecondSize
)
{
- ANDROID_BOOTIMG_HEADER *Header;
+ ANDROID_BOOTIMG_HEADER *Header;
Header = (ANDROID_BOOTIMG_HEADER *)BootImg;
- if (AsciiStrnCmp ((CONST CHAR8 *)Header->BootMagic, ANDROID_BOOT_MAGIC,
- ANDROID_BOOT_MAGIC_LENGTH) != 0) {
+ if (AsciiStrnCmp (
+ (CONST CHAR8 *)Header->BootMagic,
+ ANDROID_BOOT_MAGIC,
+ ANDROID_BOOT_MAGIC_LENGTH
+ ) != 0)
+ {
return EFI_INVALID_PARAMETER;
}
@@ -258,32 +277,37 @@ AndroidBootImgGetSecondBootLoaderInfo (
+ ALIGN_VALUE (Header->KernelSize, Header->PageSize)
+ ALIGN_VALUE (Header->RamdiskSize, Header->PageSize));
}
+
return EFI_SUCCESS;
}
EFI_STATUS
AndroidBootImgGetKernelArgs (
- IN VOID *BootImg,
- OUT CHAR8 *KernelArgs
+ IN VOID *BootImg,
+ OUT CHAR8 *KernelArgs
)
{
- ANDROID_BOOTIMG_HEADER *Header;
+ ANDROID_BOOTIMG_HEADER *Header;
- Header = (ANDROID_BOOTIMG_HEADER *) BootImg;
- AsciiStrnCpyS (KernelArgs, ANDROID_BOOTIMG_KERNEL_ARGS_SIZE, Header->KernelArgs,
- ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
+ Header = (ANDROID_BOOTIMG_HEADER *)BootImg;
+ AsciiStrnCpyS (
+ KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE,
+ Header->KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
+ );
return EFI_SUCCESS;
}
EFI_STATUS
AndroidBootImgGetFdt (
- IN VOID *BootImg,
- IN VOID **FdtBase
+ IN VOID *BootImg,
+ IN VOID **FdtBase
)
{
- UINTN SecondLoaderSize;
- EFI_STATUS Status;
+ UINTN SecondLoaderSize;
+ EFI_STATUS Status;
/* Check whether FDT is located in second boot region as some vendor do so,
* because second loader is never used as far as I know. */
@@ -291,43 +315,50 @@ AndroidBootImgGetFdt (
BootImg,
FdtBase,
&SecondLoaderSize
- );
+ );
return Status;
}
EFI_STATUS
AndroidBootImgUpdateArgs (
- IN VOID *BootImg,
- OUT VOID *KernelArgs
+ IN VOID *BootImg,
+ OUT VOID *KernelArgs
)
{
- CHAR8 ImageKernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
- EFI_STATUS Status;
+ CHAR8 ImageKernelArgs[ANDROID_BOOTIMG_KERNEL_ARGS_SIZE];
+ EFI_STATUS Status;
// Get kernel arguments from Android boot image
Status = AndroidBootImgGetKernelArgs (BootImg, ImageKernelArgs);
if (EFI_ERROR (Status)) {
return Status;
}
- AsciiStrToUnicodeStrS (ImageKernelArgs, KernelArgs,
- ANDROID_BOOTIMG_KERNEL_ARGS_SIZE >> 1);
+
+ AsciiStrToUnicodeStrS (
+ ImageKernelArgs,
+ KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE >> 1
+ );
// Append platform kernel arguments
- if(mAndroidBootImg->AppendArgs) {
- Status = mAndroidBootImg->AppendArgs (KernelArgs,
- ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
+ if (mAndroidBootImg->AppendArgs) {
+ Status = mAndroidBootImg->AppendArgs (
+ KernelArgs,
+ ANDROID_BOOTIMG_KERNEL_ARGS_SIZE
+ );
}
+
return Status;
}
EFI_STATUS
AndroidBootImgInstallLoadFile2 (
- IN VOID *RamdiskData,
- IN UINTN RamdiskSize
+ IN VOID *RamdiskData,
+ IN UINTN RamdiskSize
)
{
mRamDiskLoadFileHandle = NULL;
- mRamdiskData = RamdiskData;
- mRamdiskSize = RamdiskSize;
+ mRamdiskData = RamdiskData;
+ mRamdiskSize = RamdiskSize;
return gBS->InstallMultipleProtocolInterfaces (
&mRamDiskLoadFileHandle,
&gEfiLoadFile2ProtocolGuid,
@@ -343,9 +374,9 @@ AndroidBootImgUninstallLoadFile2 (
VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
mRamdiskData = NULL;
mRamdiskSize = 0;
if (mRamDiskLoadFileHandle != NULL) {
@@ -359,15 +390,17 @@ AndroidBootImgUninstallLoadFile2 (
);
mRamDiskLoadFileHandle = NULL;
}
+
return Status;
}
-BOOLEAN AndroidBootImgAcpiSupported (
+BOOLEAN
+AndroidBootImgAcpiSupported (
VOID
)
{
EFI_STATUS Status;
- VOID *AcpiTable;
+ VOID *AcpiTable;
Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, &AcpiTable);
return !EFI_ERROR (Status);
@@ -375,12 +408,12 @@ BOOLEAN AndroidBootImgAcpiSupported (
EFI_STATUS
AndroidBootImgLocateFdt (
- IN VOID *BootImg,
- IN VOID **FdtBase
+ IN VOID *BootImg,
+ IN VOID **FdtBase
)
{
- INTN Err;
- EFI_STATUS Status;
+ INTN Err;
+ EFI_STATUS Status;
Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, FdtBase);
if (!EFI_ERROR (Status)) {
@@ -391,58 +424,77 @@ AndroidBootImgLocateFdt (
if (EFI_ERROR (Status)) {
return Status;
}
+
Err = fdt_check_header (*FdtBase);
if (Err != 0) {
- DEBUG ((DEBUG_ERROR, "ERROR: Device Tree header not valid (Err:%d)\n",
- Err));
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: Device Tree header not valid (Err:%d)\n",
+ Err
+ ));
return EFI_INVALID_PARAMETER;
}
+
return EFI_SUCCESS;
}
INTN
AndroidBootImgGetChosenNode (
- IN INTN UpdatedFdtBase
+ IN INTN UpdatedFdtBase
)
{
- INTN ChosenNode;
+ INTN ChosenNode;
ChosenNode = fdt_subnode_offset ((CONST VOID *)UpdatedFdtBase, 0, "chosen");
if (ChosenNode < 0) {
- ChosenNode = fdt_add_subnode((VOID *)UpdatedFdtBase, 0, "chosen");
- if (ChosenNode < 0) {
- DEBUG ((DEBUG_ERROR, "Fail to find fdt node chosen!\n"));
- return 0;
+ ChosenNode = fdt_add_subnode ((VOID *)UpdatedFdtBase, 0, "chosen");
+ if (ChosenNode < 0) {
+ DEBUG ((DEBUG_ERROR, "Fail to find fdt node chosen!\n"));
+ return 0;
}
}
+
return ChosenNode;
}
EFI_STATUS
AndroidBootImgSetProperty64 (
- IN INTN UpdatedFdtBase,
- IN INTN ChosenNode,
- IN CHAR8 *PropertyName,
- IN UINT64 Val
+ IN INTN UpdatedFdtBase,
+ IN INTN ChosenNode,
+ IN CHAR8 *PropertyName,
+ IN UINT64 Val
)
{
- INTN Err;
- struct fdt_property *Property;
- int Len;
-
- Property = fdt_get_property_w((VOID *)UpdatedFdtBase, ChosenNode,
- PropertyName, &Len);
- if (NULL == Property && Len == -FDT_ERR_NOTFOUND) {
- Val = cpu_to_fdt64(Val);
- Err = fdt_appendprop ((VOID *)UpdatedFdtBase, ChosenNode,
- PropertyName, &Val, sizeof (UINT64));
+ INTN Err;
+ struct fdt_property *Property;
+ int Len;
+
+ Property = fdt_get_property_w (
+ (VOID *)UpdatedFdtBase,
+ ChosenNode,
+ PropertyName,
+ &Len
+ );
+ if ((NULL == Property) && (Len == -FDT_ERR_NOTFOUND)) {
+ Val = cpu_to_fdt64 (Val);
+ Err = fdt_appendprop (
+ (VOID *)UpdatedFdtBase,
+ ChosenNode,
+ PropertyName,
+ &Val,
+ sizeof (UINT64)
+ );
if (Err) {
DEBUG ((DEBUG_ERROR, "fdt_appendprop() fail: %a\n", fdt_strerror (Err)));
return EFI_INVALID_PARAMETER;
}
} else if (Property != NULL) {
- Err = fdt_setprop_u64((VOID *)UpdatedFdtBase, ChosenNode,
- PropertyName, Val);
+ Err = fdt_setprop_u64 (
+ (VOID *)UpdatedFdtBase,
+ ChosenNode,
+ PropertyName,
+ Val
+ );
if (Err) {
DEBUG ((DEBUG_ERROR, "fdt_setprop_u64() fail: %a\n", fdt_strerror (Err)));
return EFI_INVALID_PARAMETER;
@@ -451,33 +503,41 @@ AndroidBootImgSetProperty64 (
DEBUG ((DEBUG_ERROR, "Failed to set fdt Property %a\n", PropertyName));
return EFI_INVALID_PARAMETER;
}
+
return EFI_SUCCESS;
}
EFI_STATUS
AndroidBootImgUpdateFdt (
- IN VOID *BootImg,
- IN VOID *FdtBase,
- IN VOID *RamdiskData,
- IN UINTN RamdiskSize
+ IN VOID *BootImg,
+ IN VOID *FdtBase,
+ IN VOID *RamdiskData,
+ IN UINTN RamdiskSize
)
{
- INTN ChosenNode, Err, NewFdtSize;
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS UpdatedFdtBase, NewFdtBase;
+ INTN ChosenNode, Err, NewFdtSize;
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS UpdatedFdtBase, NewFdtBase;
NewFdtSize = (UINTN)fdt_totalsize (FdtBase)
+ FDT_ADDITIONAL_ENTRIES_SIZE;
- Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData,
- EFI_SIZE_TO_PAGES (NewFdtSize), &UpdatedFdtBase);
+ Status = gBS->AllocatePages (
+ AllocateAnyPages,
+ EfiBootServicesData,
+ EFI_SIZE_TO_PAGES (NewFdtSize),
+ &UpdatedFdtBase
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN, "Warning: Failed to reallocate FDT, err %d.\n",
- Status));
+ DEBUG ((
+ DEBUG_WARN,
+ "Warning: Failed to reallocate FDT, err %d.\n",
+ Status
+ ));
return Status;
}
// Load the Original FDT tree into the new region
- Err = fdt_open_into(FdtBase, (VOID*)(INTN)UpdatedFdtBase, NewFdtSize);
+ Err = fdt_open_into (FdtBase, (VOID *)(INTN)UpdatedFdtBase, NewFdtSize);
if (Err) {
DEBUG ((DEBUG_ERROR, "fdt_open_into(): %a\n", fdt_strerror (Err)));
Status = EFI_INVALID_PARAMETER;
@@ -490,21 +550,27 @@ AndroidBootImgUpdateFdt (
goto Fdt_Exit;
}
} else {
- ChosenNode = AndroidBootImgGetChosenNode(UpdatedFdtBase);
+ ChosenNode = AndroidBootImgGetChosenNode (UpdatedFdtBase);
if (!ChosenNode) {
goto Fdt_Exit;
}
- Status = AndroidBootImgSetProperty64 (UpdatedFdtBase, ChosenNode,
- "linux,initrd-start",
- (UINTN)RamdiskData);
+ Status = AndroidBootImgSetProperty64 (
+ UpdatedFdtBase,
+ ChosenNode,
+ "linux,initrd-start",
+ (UINTN)RamdiskData
+ );
if (EFI_ERROR (Status)) {
goto Fdt_Exit;
}
- Status = AndroidBootImgSetProperty64 (UpdatedFdtBase, ChosenNode,
- "linux,initrd-end",
- (UINTN)RamdiskData + RamdiskSize);
+ Status = AndroidBootImgSetProperty64 (
+ UpdatedFdtBase,
+ ChosenNode,
+ "linux,initrd-end",
+ (UINTN)RamdiskData + RamdiskSize
+ );
if (EFI_ERROR (Status)) {
goto Fdt_Exit;
}
@@ -518,6 +584,7 @@ AndroidBootImgUpdateFdt (
} else {
NewFdtBase = UpdatedFdtBase;
}
+
Status = gBS->InstallConfigurationTable (
&gFdtTableGuid,
(VOID *)(UINTN)NewFdtBase
@@ -534,35 +601,38 @@ Fdt_Exit:
EFI_STATUS
AndroidBootImgBoot (
- IN VOID *Buffer,
- IN UINTN BufferSize
+ IN VOID *Buffer,
+ IN UINTN BufferSize
)
{
- EFI_STATUS Status;
- VOID *Kernel;
- UINTN KernelSize;
- MEMORY_DEVICE_PATH KernelDevicePath;
- EFI_HANDLE ImageHandle;
- VOID *NewKernelArg;
- EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
- VOID *RamdiskData;
- UINTN RamdiskSize;
- IN VOID *FdtBase;
+ EFI_STATUS Status;
+ VOID *Kernel;
+ UINTN KernelSize;
+ MEMORY_DEVICE_PATH KernelDevicePath;
+ EFI_HANDLE ImageHandle;
+ VOID *NewKernelArg;
+ EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
+ VOID *RamdiskData;
+ UINTN RamdiskSize;
+ IN VOID *FdtBase;
NewKernelArg = NULL;
- ImageHandle = NULL;
+ ImageHandle = NULL;
- Status = gBS->LocateProtocol (&gAndroidBootImgProtocolGuid, NULL,
- (VOID **) &mAndroidBootImg);
+ Status = gBS->LocateProtocol (
+ &gAndroidBootImgProtocolGuid,
+ NULL,
+ (VOID **)&mAndroidBootImg
+ );
if (EFI_ERROR (Status)) {
goto Exit;
}
Status = AndroidBootImgGetKernelInfo (
- Buffer,
- &Kernel,
- &KernelSize
- );
+ Buffer,
+ &Kernel,
+ &KernelSize
+ );
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -580,10 +650,10 @@ AndroidBootImgBoot (
}
Status = AndroidBootImgGetRamdiskInfo (
- Buffer,
- &RamdiskData,
- &RamdiskSize
- );
+ Buffer,
+ &RamdiskData,
+ &RamdiskSize
+ );
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -607,24 +677,33 @@ AndroidBootImgBoot (
KernelDevicePath = mMemoryDevicePathTemplate;
- KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel;
- KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Kernel
+ KernelDevicePath.Node1.StartingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Kernel;
+ KernelDevicePath.Node1.EndingAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Kernel
+ KernelSize;
- Status = gBS->LoadImage (TRUE, gImageHandle,
- (EFI_DEVICE_PATH *)&KernelDevicePath,
- (VOID*)(UINTN)Kernel, KernelSize, &ImageHandle);
+ Status = gBS->LoadImage (
+ TRUE,
+ gImageHandle,
+ (EFI_DEVICE_PATH *)&KernelDevicePath,
+ (VOID *)(UINTN)Kernel,
+ KernelSize,
+ &ImageHandle
+ );
if (EFI_ERROR (Status)) {
goto Exit;
}
// Set kernel arguments
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
- (VOID **) &ImageInfo);
+ Status = gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&ImageInfo
+ );
if (EFI_ERROR (Status)) {
goto Exit;
}
- ImageInfo->LoadOptions = NewKernelArg;
+
+ ImageInfo->LoadOptions = NewKernelArg;
ImageInfo->LoadOptionsSize = StrLen (NewKernelArg) * sizeof (CHAR16);
// Before calling the image, enable the Watchdog Timer for the 5 Minute period
@@ -635,17 +714,19 @@ AndroidBootImgBoot (
gBS->SetWatchdogTimer (0, 0x10000, 0, NULL);
Exit:
- //Unload image as it will not be used anymore
+ // Unload image as it will not be used anymore
if (ImageHandle != NULL) {
gBS->UnloadImage (ImageHandle);
ImageHandle = NULL;
}
+
if (EFI_ERROR (Status)) {
if (NewKernelArg != NULL) {
FreePool (NewKernelArg);
NewKernelArg = NULL;
}
}
+
AndroidBootImgUninstallLoadFile2 ();
return Status;
}
diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
index 9c21d748db..7466543664 100644
--- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
+++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c
@@ -12,11 +12,10 @@
#include <Library/DmaLib.h>
#include <Library/MemoryAllocationLib.h>
-
STATIC
PHYSICAL_ADDRESS
HostToDeviceAddress (
- IN VOID *Address
+ IN VOID *Address
)
{
return (PHYSICAL_ADDRESS)(UINTN)Address + PcdGet64 (PcdDmaDeviceOffset);
@@ -45,25 +44,26 @@ HostToDeviceAddress (
EFI_STATUS
EFIAPI
DmaMap (
- IN DMA_MAP_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN DMA_MAP_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
)
{
- if (HostAddress == NULL ||
- NumberOfBytes == NULL ||
- DeviceAddress == NULL ||
- Mapping == NULL ) {
+ if ((HostAddress == NULL) ||
+ (NumberOfBytes == NULL) ||
+ (DeviceAddress == NULL) ||
+ (Mapping == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
+
*DeviceAddress = HostToDeviceAddress (HostAddress);
- *Mapping = NULL;
+ *Mapping = NULL;
return EFI_SUCCESS;
}
-
/**
Completes the DmaMapBusMasterRead(), DmaMapBusMasterWrite(), or DmaMapBusMasterCommonBuffer()
operation and releases any corresponding resources.
@@ -77,7 +77,7 @@ DmaMap (
EFI_STATUS
EFIAPI
DmaUnmap (
- IN VOID *Mapping
+ IN VOID *Mapping
)
{
return EFI_SUCCESS;
@@ -103,15 +103,14 @@ DmaUnmap (
EFI_STATUS
EFIAPI
DmaAllocateBuffer (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT VOID **HostAddress
)
{
return DmaAllocateAlignedBuffer (MemoryType, Pages, 0, HostAddress);
}
-
/**
Allocates pages that are suitable for an DmaMap() of type
MapOperationBusMasterCommonBuffer mapping, at the requested alignment.
@@ -134,18 +133,19 @@ DmaAllocateBuffer (
EFI_STATUS
EFIAPI
DmaAllocateAlignedBuffer (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- IN UINTN Alignment,
- OUT VOID **HostAddress
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN UINTN Alignment,
+ OUT VOID **HostAddress
)
{
if (Alignment == 0) {
Alignment = EFI_PAGE_SIZE;
}
- if (HostAddress == NULL ||
- (Alignment & (Alignment - 1)) != 0) {
+ if ((HostAddress == NULL) ||
+ ((Alignment & (Alignment - 1)) != 0))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -163,10 +163,10 @@ DmaAllocateAlignedBuffer (
if (*HostAddress == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
return EFI_SUCCESS;
}
-
/**
Frees memory that was allocated with DmaAllocateBuffer().
@@ -181,15 +181,14 @@ DmaAllocateAlignedBuffer (
EFI_STATUS
EFIAPI
DmaFreeBuffer (
- IN UINTN Pages,
- IN VOID *HostAddress
+ IN UINTN Pages,
+ IN VOID *HostAddress
)
{
if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
+ return EFI_INVALID_PARAMETER;
}
FreePages (HostAddress, Pages);
return EFI_SUCCESS;
}
-
diff --git a/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c b/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c
index 2841689796..63a8c7b4bf 100644
--- a/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c
+++ b/EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLib.c
@@ -11,7 +11,6 @@
**/
-
/**
Setup all the hardware needed for the debug agents timer.
@@ -26,7 +25,6 @@ DebugAgentTimerIntialize (
{
}
-
/**
Set the period for the debug agent timer. Zero means disable the timer.
@@ -41,7 +39,6 @@ DebugAgentTimerSetPeriod (
{
}
-
/**
Perform End Of Interrupt for the debug agent timer. This is called in the
interrupt handler after the interrupt has been processed.
@@ -54,4 +51,3 @@ DebugAgentTimerEndOfInterrupt (
)
{
}
-
diff --git a/EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c b/EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
index 87a9cd25e1..851223c168 100644
--- a/EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
+++ b/EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.c
@@ -27,17 +27,22 @@
EFI_STATUS
EFIAPI
DtPlatformLoadDtb (
- OUT VOID **Dtb,
- OUT UINTN *DtbSize
+ OUT VOID **Dtb,
+ OUT UINTN *DtbSize
)
{
- EFI_STATUS Status;
- VOID *OrigDtb;
- VOID *CopyDtb;
- UINTN OrigDtbSize;
-
- Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid,
- EFI_SECTION_RAW, 0, &OrigDtb, &OrigDtbSize);
+ EFI_STATUS Status;
+ VOID *OrigDtb;
+ VOID *CopyDtb;
+ UINTN OrigDtbSize;
+
+ Status = GetSectionFromAnyFv (
+ &gDtPlatformDefaultDtbFileGuid,
+ EFI_SECTION_RAW,
+ 0,
+ &OrigDtb,
+ &OrigDtbSize
+ );
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
@@ -47,7 +52,7 @@ DtPlatformLoadDtb (
return EFI_OUT_OF_RESOURCES;
}
- *Dtb = CopyDtb;
+ *Dtb = CopyDtb;
*DtbSize = OrigDtbSize;
return EFI_SUCCESS;
diff --git a/EmbeddedPkg/Library/FdtLib/fdt.c b/EmbeddedPkg/Library/FdtLib/fdt.c
index 29756a8795..56a9787cd0 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt.c
@@ -55,197 +55,276 @@
#include "libfdt_internal.h"
-int fdt_check_header(const void *fdt)
+int
+fdt_check_header (
+ const void *fdt
+ )
{
- if (fdt_magic(fdt) == FDT_MAGIC) {
- /* Complete tree */
- if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
- return -FDT_ERR_BADVERSION;
- if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)
- return -FDT_ERR_BADVERSION;
- } else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
- /* Unfinished sequential-write blob */
- if (fdt_size_dt_struct(fdt) == 0)
- return -FDT_ERR_BADSTATE;
- } else {
- return -FDT_ERR_BADMAGIC;
- }
-
- return 0;
+ if (fdt_magic (fdt) == FDT_MAGIC) {
+ /* Complete tree */
+ if (fdt_version (fdt) < FDT_FIRST_SUPPORTED_VERSION) {
+ return -FDT_ERR_BADVERSION;
+ }
+
+ if (fdt_last_comp_version (fdt) > FDT_LAST_SUPPORTED_VERSION) {
+ return -FDT_ERR_BADVERSION;
+ }
+ } else if (fdt_magic (fdt) == FDT_SW_MAGIC) {
+ /* Unfinished sequential-write blob */
+ if (fdt_size_dt_struct (fdt) == 0) {
+ return -FDT_ERR_BADSTATE;
+ }
+ } else {
+ return -FDT_ERR_BADMAGIC;
+ }
+
+ return 0;
}
-const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
+const void *
+fdt_offset_ptr (
+ const void *fdt,
+ int offset,
+ unsigned int len
+ )
{
- unsigned absoffset = offset + fdt_off_dt_struct(fdt);
-
- if ((absoffset < offset)
- || ((absoffset + len) < absoffset)
- || (absoffset + len) > fdt_totalsize(fdt))
- return NULL;
-
- if (fdt_version(fdt) >= 0x11)
- if (((offset + len) < offset)
- || ((offset + len) > fdt_size_dt_struct(fdt)))
- return NULL;
-
- return _fdt_offset_ptr(fdt, offset);
+ unsigned absoffset = offset + fdt_off_dt_struct (fdt);
+
+ if ( (absoffset < offset)
+ || ((absoffset + len) < absoffset)
+ || ((absoffset + len) > fdt_totalsize (fdt)))
+ {
+ return NULL;
+ }
+
+ if (fdt_version (fdt) >= 0x11) {
+ if ( ((offset + len) < offset)
+ || ((offset + len) > fdt_size_dt_struct (fdt)))
+ {
+ return NULL;
+ }
+ }
+
+ return _fdt_offset_ptr (fdt, offset);
}
-uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
+uint32_t
+fdt_next_tag (
+ const void *fdt,
+ int startoffset,
+ int *nextoffset
+ )
{
- const fdt32_t *tagp, *lenp;
- uint32_t tag;
- int offset = startoffset;
- const char *p;
-
- *nextoffset = -FDT_ERR_TRUNCATED;
- tagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE);
- if (!tagp)
- return FDT_END; /* premature end */
- tag = fdt32_to_cpu(*tagp);
- offset += FDT_TAGSIZE;
-
- *nextoffset = -FDT_ERR_BADSTRUCTURE;
- switch (tag) {
- case FDT_BEGIN_NODE:
- /* skip name */
- do {
- p = fdt_offset_ptr(fdt, offset++, 1);
- } while (p && (*p != '\0'));
- if (!p)
- return FDT_END; /* premature end */
- break;
-
- case FDT_PROP:
- lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp));
- if (!lenp)
- return FDT_END; /* premature end */
- /* skip-name offset, length and value */
- offset += sizeof(struct fdt_property) - FDT_TAGSIZE
- + fdt32_to_cpu(*lenp);
- break;
-
- case FDT_END:
- case FDT_END_NODE:
- case FDT_NOP:
- break;
-
- default:
- return FDT_END;
- }
-
- if (!fdt_offset_ptr(fdt, startoffset, offset - startoffset))
- return FDT_END; /* premature end */
-
- *nextoffset = FDT_TAGALIGN(offset);
- return tag;
+ const fdt32_t *tagp, *lenp;
+ uint32_t tag;
+ int offset = startoffset;
+ const char *p;
+
+ *nextoffset = -FDT_ERR_TRUNCATED;
+ tagp = fdt_offset_ptr (fdt, offset, FDT_TAGSIZE);
+ if (!tagp) {
+ return FDT_END; /* premature end */
+ }
+
+ tag = fdt32_to_cpu (*tagp);
+ offset += FDT_TAGSIZE;
+
+ *nextoffset = -FDT_ERR_BADSTRUCTURE;
+ switch (tag) {
+ case FDT_BEGIN_NODE:
+ /* skip name */
+ do {
+ p = fdt_offset_ptr (fdt, offset++, 1);
+ } while (p && (*p != '\0'));
+
+ if (!p) {
+ return FDT_END; /* premature end */
+ }
+
+ break;
+
+ case FDT_PROP:
+ lenp = fdt_offset_ptr (fdt, offset, sizeof (*lenp));
+ if (!lenp) {
+ return FDT_END; /* premature end */
+ }
+
+ /* skip-name offset, length and value */
+ offset += sizeof (struct fdt_property) - FDT_TAGSIZE
+ + fdt32_to_cpu (*lenp);
+ break;
+
+ case FDT_END:
+ case FDT_END_NODE:
+ case FDT_NOP:
+ break;
+
+ default:
+ return FDT_END;
+ }
+
+ if (!fdt_offset_ptr (fdt, startoffset, offset - startoffset)) {
+ return FDT_END; /* premature end */
+ }
+
+ *nextoffset = FDT_TAGALIGN (offset);
+ return tag;
}
-int _fdt_check_node_offset(const void *fdt, int offset)
+int
+_fdt_check_node_offset (
+ const void *fdt,
+ int offset
+ )
{
- if ((offset < 0) || (offset % FDT_TAGSIZE)
- || (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE))
- return -FDT_ERR_BADOFFSET;
+ if ( (offset < 0) || (offset % FDT_TAGSIZE)
+ || (fdt_next_tag (fdt, offset, &offset) != FDT_BEGIN_NODE))
+ {
+ return -FDT_ERR_BADOFFSET;
+ }
- return offset;
+ return offset;
}
-int _fdt_check_prop_offset(const void *fdt, int offset)
+int
+_fdt_check_prop_offset (
+ const void *fdt,
+ int offset
+ )
{
- if ((offset < 0) || (offset % FDT_TAGSIZE)
- || (fdt_next_tag(fdt, offset, &offset) != FDT_PROP))
- return -FDT_ERR_BADOFFSET;
+ if ( (offset < 0) || (offset % FDT_TAGSIZE)
+ || (fdt_next_tag (fdt, offset, &offset) != FDT_PROP))
+ {
+ return -FDT_ERR_BADOFFSET;
+ }
- return offset;
+ return offset;
}
-int fdt_next_node(const void *fdt, int offset, int *depth)
+int
+fdt_next_node (
+ const void *fdt,
+ int offset,
+ int *depth
+ )
{
- int nextoffset = 0;
- uint32_t tag;
-
- if (offset >= 0)
- if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0)
- return nextoffset;
-
- do {
- offset = nextoffset;
- tag = fdt_next_tag(fdt, offset, &nextoffset);
-
- switch (tag) {
- case FDT_PROP:
- case FDT_NOP:
- break;
-
- case FDT_BEGIN_NODE:
- if (depth)
- (*depth)++;
- break;
-
- case FDT_END_NODE:
- if (depth && ((--(*depth)) < 0))
- return nextoffset;
- break;
-
- case FDT_END:
- if ((nextoffset >= 0)
- || ((nextoffset == -FDT_ERR_TRUNCATED) && !depth))
- return -FDT_ERR_NOTFOUND;
- else
- return nextoffset;
- }
- } while (tag != FDT_BEGIN_NODE);
-
- return offset;
+ int nextoffset = 0;
+ uint32_t tag;
+
+ if (offset >= 0) {
+ if ((nextoffset = _fdt_check_node_offset (fdt, offset)) < 0) {
+ return nextoffset;
+ }
+ }
+
+ do {
+ offset = nextoffset;
+ tag = fdt_next_tag (fdt, offset, &nextoffset);
+
+ switch (tag) {
+ case FDT_PROP:
+ case FDT_NOP:
+ break;
+
+ case FDT_BEGIN_NODE:
+ if (depth) {
+ (*depth)++;
+ }
+
+ break;
+
+ case FDT_END_NODE:
+ if (depth && ((--(*depth)) < 0)) {
+ return nextoffset;
+ }
+
+ break;
+
+ case FDT_END:
+ if ( (nextoffset >= 0)
+ || ((nextoffset == -FDT_ERR_TRUNCATED) && !depth))
+ {
+ return -FDT_ERR_NOTFOUND;
+ } else {
+ return nextoffset;
+ }
+ }
+ } while (tag != FDT_BEGIN_NODE);
+
+ return offset;
}
-int fdt_first_subnode(const void *fdt, int offset)
+int
+fdt_first_subnode (
+ const void *fdt,
+ int offset
+ )
{
- int depth = 0;
+ int depth = 0;
- offset = fdt_next_node(fdt, offset, &depth);
- if (offset < 0 || depth != 1)
- return -FDT_ERR_NOTFOUND;
+ offset = fdt_next_node (fdt, offset, &depth);
+ if ((offset < 0) || (depth != 1)) {
+ return -FDT_ERR_NOTFOUND;
+ }
- return offset;
+ return offset;
}
-int fdt_next_subnode(const void *fdt, int offset)
+int
+fdt_next_subnode (
+ const void *fdt,
+ int offset
+ )
{
- int depth = 1;
-
- /*
- * With respect to the parent, the depth of the next subnode will be
- * the same as the last.
- */
- do {
- offset = fdt_next_node(fdt, offset, &depth);
- if (offset < 0 || depth < 1)
- return -FDT_ERR_NOTFOUND;
- } while (depth > 1);
-
- return offset;
+ int depth = 1;
+
+ /*
+ * With respect to the parent, the depth of the next subnode will be
+ * the same as the last.
+ */
+ do {
+ offset = fdt_next_node (fdt, offset, &depth);
+ if ((offset < 0) || (depth < 1)) {
+ return -FDT_ERR_NOTFOUND;
+ }
+ } while (depth > 1);
+
+ return offset;
}
-const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
+const char *
+_fdt_find_string (
+ const char *strtab,
+ int tabsize,
+ const char *s
+ )
{
- int len = strlen(s) + 1;
- const char *last = strtab + tabsize - len;
- const char *p;
-
- for (p = strtab; p <= last; p++)
- if (memcmp(p, s, len) == 0)
- return p;
- return NULL;
+ int len = strlen (s) + 1;
+ const char *last = strtab + tabsize - len;
+ const char *p;
+
+ for (p = strtab; p <= last; p++) {
+ if (memcmp (p, s, len) == 0) {
+ return p;
+ }
+ }
+
+ return NULL;
}
-int fdt_move(const void *fdt, void *buf, int bufsize)
+int
+fdt_move (
+ const void *fdt,
+ void *buf,
+ int bufsize
+ )
{
- FDT_CHECK_HEADER(fdt);
+ FDT_CHECK_HEADER (fdt);
- if (fdt_totalsize(fdt) > bufsize)
- return -FDT_ERR_NOSPACE;
+ if (fdt_totalsize (fdt) > bufsize) {
+ return -FDT_ERR_NOSPACE;
+ }
- memmove(buf, fdt, fdt_totalsize(fdt));
- return 0;
+ memmove (buf, fdt, fdt_totalsize (fdt));
+ return 0;
}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_addresses.c b/EmbeddedPkg/Library/FdtLib/fdt_addresses.c
index f48da28f06..a0f531aac9 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_addresses.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_addresses.c
@@ -55,42 +55,56 @@
#include "libfdt_internal.h"
-int fdt_address_cells(const void *fdt, int nodeoffset)
+int
+fdt_address_cells (
+ const void *fdt,
+ int nodeoffset
+ )
{
- const fdt32_t *ac;
- int val;
- int len;
+ const fdt32_t *ac;
+ int val;
+ int len;
- ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
- if (!ac)
- return 2;
+ ac = fdt_getprop (fdt, nodeoffset, "#address-cells", &len);
+ if (!ac) {
+ return 2;
+ }
- if (len != sizeof(*ac))
- return -FDT_ERR_BADNCELLS;
+ if (len != sizeof (*ac)) {
+ return -FDT_ERR_BADNCELLS;
+ }
- val = fdt32_to_cpu(*ac);
- if ((val <= 0) || (val > FDT_MAX_NCELLS))
- return -FDT_ERR_BADNCELLS;
+ val = fdt32_to_cpu (*ac);
+ if ((val <= 0) || (val > FDT_MAX_NCELLS)) {
+ return -FDT_ERR_BADNCELLS;
+ }
- return val;
+ return val;
}
-int fdt_size_cells(const void *fdt, int nodeoffset)
+int
+fdt_size_cells (
+ const void *fdt,
+ int nodeoffset
+ )
{
- const fdt32_t *sc;
- int val;
- int len;
+ const fdt32_t *sc;
+ int val;
+ int len;
- sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len);
- if (!sc)
- return 2;
+ sc = fdt_getprop (fdt, nodeoffset, "#size-cells", &len);
+ if (!sc) {
+ return 2;
+ }
- if (len != sizeof(*sc))
- return -FDT_ERR_BADNCELLS;
+ if (len != sizeof (*sc)) {
+ return -FDT_ERR_BADNCELLS;
+ }
- val = fdt32_to_cpu(*sc);
- if ((val < 0) || (val > FDT_MAX_NCELLS))
- return -FDT_ERR_BADNCELLS;
+ val = fdt32_to_cpu (*sc);
+ if ((val < 0) || (val > FDT_MAX_NCELLS)) {
+ return -FDT_ERR_BADNCELLS;
+ }
- return val;
+ return val;
}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c b/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c
index 634b436f52..65a128f2b8 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_empty_tree.c
@@ -55,29 +55,38 @@
#include "libfdt_internal.h"
-int fdt_create_empty_tree(void *buf, int bufsize)
+int
+fdt_create_empty_tree (
+ void *buf,
+ int bufsize
+ )
{
- int err;
+ int err;
- err = fdt_create(buf, bufsize);
- if (err)
- return err;
+ err = fdt_create (buf, bufsize);
+ if (err) {
+ return err;
+ }
- err = fdt_finish_reservemap(buf);
- if (err)
- return err;
+ err = fdt_finish_reservemap (buf);
+ if (err) {
+ return err;
+ }
- err = fdt_begin_node(buf, "");
- if (err)
- return err;
+ err = fdt_begin_node (buf, "");
+ if (err) {
+ return err;
+ }
- err = fdt_end_node(buf);
- if (err)
- return err;
+ err = fdt_end_node (buf);
+ if (err) {
+ return err;
+ }
- err = fdt_finish(buf);
- if (err)
- return err;
+ err = fdt_finish (buf);
+ if (err) {
+ return err;
+ }
- return fdt_open_into(buf, buf, bufsize);
+ return fdt_open_into (buf, buf, bufsize);
}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_overlay.c b/EmbeddedPkg/Library/FdtLib/fdt_overlay.c
index 804852c6c2..0e6b8715e4 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_overlay.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_overlay.c
@@ -1,914 +1,1127 @@
-/*
- * libfdt - Flat Device Tree manipulation
- * Copyright (C) 2016 Free Electrons
- * Copyright (C) 2016 NextThing Co.
- *
- * libfdt is dual licensed: you can use it either under the terms of
- * the GPL, or the BSD license, at your option.
- *
- * a) This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- * MA 02110-1301 USA
- *
- * Alternatively,
- *
- * b) Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "libfdt_env.h"
-
-#include <fdt.h>
-#include <libfdt.h>
-
-#include "libfdt_internal.h"
-
-/**
- * overlay_get_target_phandle - retrieves the target phandle of a fragment
- * @fdto: pointer to the device tree overlay blob
- * @fragment: node offset of the fragment in the overlay
- *
- * overlay_get_target_phandle() retrieves the target phandle of an
- * overlay fragment when that fragment uses a phandle (target
- * property) instead of a path (target-path property).
- *
- * returns:
- * the phandle pointed by the target property
- * 0, if the phandle was not found
- * -1, if the phandle was malformed
- */
-static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
-{
- const fdt32_t *val;
- int len;
-
- val = fdt_getprop(fdto, fragment, "target", &len);
- if (!val)
- return 0;
-
- if ((len != sizeof(*val)) || (fdt32_to_cpu(*val) == (uint32_t)-1))
- return (uint32_t)-1;
-
- return fdt32_to_cpu(*val);
-}
-
-/**
- * overlay_get_target - retrieves the offset of a fragment's target
- * @fdt: Base device tree blob
- * @fdto: Device tree overlay blob
- * @fragment: node offset of the fragment in the overlay
- * @pathp: pointer which receives the path of the target (or NULL)
- *
- * overlay_get_target() retrieves the target offset in the base
- * device tree of a fragment, no matter how the actual targetting is
- * done (through a phandle or a path)
- *
- * returns:
- * the targetted node offset in the base device tree
- * Negative error code on error
- */
-static int overlay_get_target(const void *fdt, const void *fdto,
- int fragment, char const **pathp)
-{
- uint32_t phandle;
- const char *path = NULL;
- int path_len = 0, ret;
-
- /* Try first to do a phandle based lookup */
- phandle = overlay_get_target_phandle(fdto, fragment);
- if (phandle == (uint32_t)-1)
- return -FDT_ERR_BADPHANDLE;
-
- /* no phandle, try path */
- if (!phandle) {
- /* And then a path based lookup */
- path = fdt_getprop(fdto, fragment, "target-path", &path_len);
- if (path)
- ret = fdt_path_offset(fdt, path);
- else
- ret = path_len;
- } else
- ret = fdt_node_offset_by_phandle(fdt, phandle);
-
- /*
- * If we haven't found either a target or a
- * target-path property in a node that contains a
- * __overlay__ subnode (we wouldn't be called
- * otherwise), consider it a improperly written
- * overlay
- */
- if (ret < 0 && path_len == -FDT_ERR_NOTFOUND)
- ret = -FDT_ERR_BADOVERLAY;
-
- /* return on error */
- if (ret < 0)
- return ret;
-
- /* return pointer to path (if available) */
- if (pathp)
- *pathp = path ? path : NULL;
-
- return ret;
-}
-
-/**
- * overlay_phandle_add_offset - Increases a phandle by an offset
- * @fdt: Base device tree blob
- * @node: Device tree overlay blob
- * @name: Name of the property to modify (phandle or linux,phandle)
- * @delta: offset to apply
- *
- * overlay_phandle_add_offset() increments a node phandle by a given
- * offset.
- *
- * returns:
- * 0 on success.
- * Negative error code on error
- */
-static int overlay_phandle_add_offset(void *fdt, int node,
- const char *name, uint32_t delta)
-{
- const fdt32_t *val;
- uint32_t adj_val;
- int len;
-
- val = fdt_getprop(fdt, node, name, &len);
- if (!val)
- return len;
-
- if (len != sizeof(*val))
- return -FDT_ERR_BADPHANDLE;
-
- adj_val = fdt32_to_cpu(*val);
- if ((adj_val + delta) < adj_val)
- return -FDT_ERR_NOPHANDLES;
-
- adj_val += delta;
- if (adj_val == (uint32_t)-1)
- return -FDT_ERR_NOPHANDLES;
-
- return fdt_setprop_inplace_u32(fdt, node, name, adj_val);
-}
-
-/**
- * overlay_adjust_node_phandles - Offsets the phandles of a node
- * @fdto: Device tree overlay blob
- * @node: Offset of the node we want to adjust
- * @delta: Offset to shift the phandles of
- *
- * overlay_adjust_node_phandles() adds a constant to all the phandles
- * of a given node. This is mainly use as part of the overlay
- * application process, when we want to update all the overlay
- * phandles to not conflict with the overlays of the base device tree.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_adjust_node_phandles(void *fdto, int node,
- uint32_t delta)
-{
- int child;
- int ret;
-
- ret = overlay_phandle_add_offset(fdto, node, "phandle", delta);
- if (ret && ret != -FDT_ERR_NOTFOUND)
- return ret;
-
- ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta);
- if (ret && ret != -FDT_ERR_NOTFOUND)
- return ret;
-
- fdt_for_each_subnode(child, fdto, node) {
- ret = overlay_adjust_node_phandles(fdto, child, delta);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
-/**
- * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
- * @fdto: Device tree overlay blob
- * @delta: Offset to shift the phandles of
- *
- * overlay_adjust_local_phandles() adds a constant to all the
- * phandles of an overlay. This is mainly use as part of the overlay
- * application process, when we want to update all the overlay
- * phandles to not conflict with the overlays of the base device tree.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
-{
- /*
- * Start adjusting the phandles from the overlay root
- */
- return overlay_adjust_node_phandles(fdto, 0, delta);
-}
-
-/**
- * overlay_update_local_node_references - Adjust the overlay references
- * @fdto: Device tree overlay blob
- * @tree_node: Node offset of the node to operate on
- * @fixup_node: Node offset of the matching local fixups node
- * @delta: Offset to shift the phandles of
- *
- * overlay_update_local_nodes_references() update the phandles
- * pointing to a node within the device tree overlay by adding a
- * constant delta.
- *
- * This is mainly used as part of a device tree application process,
- * where you want the device tree overlays phandles to not conflict
- * with the ones from the base device tree before merging them.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_update_local_node_references(void *fdto,
- int tree_node,
- int fixup_node,
- uint32_t delta)
-{
- int fixup_prop;
- int fixup_child;
- int ret;
-
- fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
- const fdt32_t *fixup_val;
- const char *tree_val;
- const char *name;
- int fixup_len;
- int tree_len;
- int i;
-
- fixup_val = fdt_getprop_by_offset(fdto, fixup_prop,
- &name, &fixup_len);
- if (!fixup_val)
- return fixup_len;
-
- if (fixup_len % sizeof(uint32_t))
- return -FDT_ERR_BADOVERLAY;
-
- tree_val = fdt_getprop(fdto, tree_node, name, &tree_len);
- if (!tree_val) {
- if (tree_len == -FDT_ERR_NOTFOUND)
- return -FDT_ERR_BADOVERLAY;
-
- return tree_len;
- }
-
- for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) {
- fdt32_t adj_val;
- uint32_t poffset;
-
- poffset = fdt32_to_cpu(fixup_val[i]);
-
- /*
- * phandles to fixup can be unaligned.
- *
- * Use a memcpy for the architectures that do
- * not support unaligned accesses.
- */
- memcpy(&adj_val, tree_val + poffset, sizeof(adj_val));
-
- adj_val = cpu_to_fdt32(fdt32_to_cpu(adj_val) + delta);
-
- ret = fdt_setprop_inplace_namelen_partial(fdto,
- tree_node,
- name,
- strlen(name),
- poffset,
- &adj_val,
- sizeof(adj_val));
- if (ret == -FDT_ERR_NOSPACE)
- return -FDT_ERR_BADOVERLAY;
-
- if (ret)
- return ret;
- }
- }
-
- fdt_for_each_subnode(fixup_child, fdto, fixup_node) {
- const char *fixup_child_name = fdt_get_name(fdto, fixup_child,
- NULL);
- int tree_child;
-
- tree_child = fdt_subnode_offset(fdto, tree_node,
- fixup_child_name);
- if (tree_child == -FDT_ERR_NOTFOUND)
- return -FDT_ERR_BADOVERLAY;
- if (tree_child < 0)
- return tree_child;
-
- ret = overlay_update_local_node_references(fdto,
- tree_child,
- fixup_child,
- delta);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
-/**
- * overlay_update_local_references - Adjust the overlay references
- * @fdto: Device tree overlay blob
- * @delta: Offset to shift the phandles of
- *
- * overlay_update_local_references() update all the phandles pointing
- * to a node within the device tree overlay by adding a constant
- * delta to not conflict with the base overlay.
- *
- * This is mainly used as part of a device tree application process,
- * where you want the device tree overlays phandles to not conflict
- * with the ones from the base device tree before merging them.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_update_local_references(void *fdto, uint32_t delta)
-{
- int fixups;
-
- fixups = fdt_path_offset(fdto, "/__local_fixups__");
- if (fixups < 0) {
- /* There's no local phandles to adjust, bail out */
- if (fixups == -FDT_ERR_NOTFOUND)
- return 0;
-
- return fixups;
- }
-
- /*
- * Update our local references from the root of the tree
- */
- return overlay_update_local_node_references(fdto, 0, fixups,
- delta);
-}
-
-/**
- * overlay_fixup_one_phandle - Set an overlay phandle to the base one
- * @fdt: Base Device Tree blob
- * @fdto: Device tree overlay blob
- * @symbols_off: Node offset of the symbols node in the base device tree
- * @path: Path to a node holding a phandle in the overlay
- * @path_len: number of path characters to consider
- * @name: Name of the property holding the phandle reference in the overlay
- * @name_len: number of name characters to consider
- * @poffset: Offset within the overlay property where the phandle is stored
- * @label: Label of the node referenced by the phandle
- *
- * overlay_fixup_one_phandle() resolves an overlay phandle pointing to
- * a node in the base device tree.
- *
- * This is part of the device tree overlay application process, when
- * you want all the phandles in the overlay to point to the actual
- * base dt nodes.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_fixup_one_phandle(void *fdt, void *fdto,
- int symbols_off,
- const char *path, uint32_t path_len,
- const char *name, uint32_t name_len,
- int poffset, const char *label)
-{
- const char *symbol_path;
- uint32_t phandle;
- fdt32_t phandle_prop;
- int symbol_off, fixup_off;
- int prop_len;
-
- if (symbols_off < 0)
- return symbols_off;
-
- symbol_path = fdt_getprop(fdt, symbols_off, label,
- &prop_len);
- if (!symbol_path)
- return prop_len;
-
- symbol_off = fdt_path_offset(fdt, symbol_path);
- if (symbol_off < 0)
- return symbol_off;
-
- phandle = fdt_get_phandle(fdt, symbol_off);
- if (!phandle)
- return -FDT_ERR_NOTFOUND;
-
- fixup_off = fdt_path_offset_namelen(fdto, path, path_len);
- if (fixup_off == -FDT_ERR_NOTFOUND)
- return -FDT_ERR_BADOVERLAY;
- if (fixup_off < 0)
- return fixup_off;
-
- phandle_prop = cpu_to_fdt32(phandle);
- return fdt_setprop_inplace_namelen_partial(fdto, fixup_off,
- name, name_len, poffset,
- &phandle_prop,
- sizeof(phandle_prop));
-};
-
-unsigned long strtoul(const char *nptr, char **endptr, int base);
-
-/**
- * overlay_fixup_phandle - Set an overlay phandle to the base one
- * @fdt: Base Device Tree blob
- * @fdto: Device tree overlay blob
- * @symbols_off: Node offset of the symbols node in the base device tree
- * @property: Property offset in the overlay holding the list of fixups
- *
- * overlay_fixup_phandle() resolves all the overlay phandles pointed
- * to in a __fixups__ property, and updates them to match the phandles
- * in use in the base device tree.
- *
- * This is part of the device tree overlay application process, when
- * you want all the phandles in the overlay to point to the actual
- * base dt nodes.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
- int property)
-{
- const char *value;
- const char *label;
- int len;
-
- value = fdt_getprop_by_offset(fdto, property,
- &label, &len);
- if (!value) {
- if (len == -FDT_ERR_NOTFOUND)
- return -FDT_ERR_INTERNAL;
-
- return len;
- }
-
- do {
- const char *path, *name, *fixup_end;
- const char *fixup_str = value;
- uint32_t path_len, name_len;
- uint32_t fixup_len;
- char *sep, *endptr;
- int poffset, ret;
-
- fixup_end = memchr(value, '\0', len);
- if (!fixup_end)
- return -FDT_ERR_BADOVERLAY;
- fixup_len = fixup_end - fixup_str;
-
- len -= fixup_len + 1;
- value += fixup_len + 1;
-
- path = fixup_str;
- sep = memchr(fixup_str, ':', fixup_len);
- if (!sep || *sep != ':')
- return -FDT_ERR_BADOVERLAY;
-
- path_len = sep - path;
- if (path_len == (fixup_len - 1))
- return -FDT_ERR_BADOVERLAY;
-
- fixup_len -= path_len + 1;
- name = sep + 1;
- sep = memchr(name, ':', fixup_len);
- if (!sep || *sep != ':')
- return -FDT_ERR_BADOVERLAY;
-
- name_len = sep - name;
- if (!name_len)
- return -FDT_ERR_BADOVERLAY;
-
- poffset = strtoul(sep + 1, &endptr, 10);
- if ((*endptr != '\0') || (endptr <= (sep + 1)))
- return -FDT_ERR_BADOVERLAY;
-
- ret = overlay_fixup_one_phandle(fdt, fdto, symbols_off,
- path, path_len, name, name_len,
- poffset, label);
- if (ret)
- return ret;
- } while (len > 0);
-
- return 0;
-}
-
-/**
- * overlay_fixup_phandles - Resolve the overlay phandles to the base
- * device tree
- * @fdt: Base Device Tree blob
- * @fdto: Device tree overlay blob
- *
- * overlay_fixup_phandles() resolves all the overlay phandles pointing
- * to nodes in the base device tree.
- *
- * This is one of the steps of the device tree overlay application
- * process, when you want all the phandles in the overlay to point to
- * the actual base dt nodes.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_fixup_phandles(void *fdt, void *fdto)
-{
- int fixups_off, symbols_off;
- int property;
-
- /* We can have overlays without any fixups */
- fixups_off = fdt_path_offset(fdto, "/__fixups__");
- if (fixups_off == -FDT_ERR_NOTFOUND)
- return 0; /* nothing to do */
- if (fixups_off < 0)
- return fixups_off;
-
- /* And base DTs without symbols */
- symbols_off = fdt_path_offset(fdt, "/__symbols__");
- if ((symbols_off < 0 && (symbols_off != -FDT_ERR_NOTFOUND)))
- return symbols_off;
-
- fdt_for_each_property_offset(property, fdto, fixups_off) {
- int ret;
-
- ret = overlay_fixup_phandle(fdt, fdto, symbols_off, property);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
-/**
- * overlay_apply_node - Merges a node into the base device tree
- * @fdt: Base Device Tree blob
- * @target: Node offset in the base device tree to apply the fragment to
- * @fdto: Device tree overlay blob
- * @node: Node offset in the overlay holding the changes to merge
- *
- * overlay_apply_node() merges a node into a target base device tree
- * node pointed.
- *
- * This is part of the final step in the device tree overlay
- * application process, when all the phandles have been adjusted and
- * resolved and you just have to merge overlay into the base device
- * tree.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_apply_node(void *fdt, int target,
- void *fdto, int node)
-{
- int property;
- int subnode;
-
- fdt_for_each_property_offset(property, fdto, node) {
- const char *name;
- const void *prop;
- int prop_len;
- int ret;
-
- prop = fdt_getprop_by_offset(fdto, property, &name,
- &prop_len);
- if (prop_len == -FDT_ERR_NOTFOUND)
- return -FDT_ERR_INTERNAL;
- if (prop_len < 0)
- return prop_len;
-
- ret = fdt_setprop(fdt, target, name, prop, prop_len);
- if (ret)
- return ret;
- }
-
- fdt_for_each_subnode(subnode, fdto, node) {
- const char *name = fdt_get_name(fdto, subnode, NULL);
- int nnode;
- int ret;
-
- nnode = fdt_add_subnode(fdt, target, name);
- if (nnode == -FDT_ERR_EXISTS) {
- nnode = fdt_subnode_offset(fdt, target, name);
- if (nnode == -FDT_ERR_NOTFOUND)
- return -FDT_ERR_INTERNAL;
- }
-
- if (nnode < 0)
- return nnode;
-
- ret = overlay_apply_node(fdt, nnode, fdto, subnode);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
-/**
- * overlay_merge - Merge an overlay into its base device tree
- * @fdt: Base Device Tree blob
- * @fdto: Device tree overlay blob
- *
- * overlay_merge() merges an overlay into its base device tree.
- *
- * This is the next to last step in the device tree overlay application
- * process, when all the phandles have been adjusted and resolved and
- * you just have to merge overlay into the base device tree.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_merge(void *fdt, void *fdto)
-{
- int fragment;
-
- fdt_for_each_subnode(fragment, fdto, 0) {
- int overlay;
- int target;
- int ret;
-
- /*
- * Each fragments will have an __overlay__ node. If
- * they don't, it's not supposed to be merged
- */
- overlay = fdt_subnode_offset(fdto, fragment, "__overlay__");
- if (overlay == -FDT_ERR_NOTFOUND)
- continue;
-
- if (overlay < 0)
- return overlay;
-
- target = overlay_get_target(fdt, fdto, fragment, NULL);
- if (target < 0)
- return target;
-
- ret = overlay_apply_node(fdt, target, fdto, overlay);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
-static int get_path_len(const void *fdt, int nodeoffset)
-{
- int len = 0, namelen;
- const char *name;
-
- FDT_CHECK_HEADER(fdt);
-
- for (;;) {
- name = fdt_get_name(fdt, nodeoffset, &namelen);
- if (!name)
- return namelen;
-
- /* root? we're done */
- if (namelen == 0)
- break;
-
- nodeoffset = fdt_parent_offset(fdt, nodeoffset);
- if (nodeoffset < 0)
- return nodeoffset;
- len += namelen + 1;
- }
-
- /* in case of root pretend it's "/" */
- if (len == 0)
- len++;
- return len;
-}
-
-/**
- * overlay_symbol_update - Update the symbols of base tree after a merge
- * @fdt: Base Device Tree blob
- * @fdto: Device tree overlay blob
- *
- * overlay_symbol_update() updates the symbols of the base tree with the
- * symbols of the applied overlay
- *
- * This is the last step in the device tree overlay application
- * process, allowing the reference of overlay symbols by subsequent
- * overlay operations.
- *
- * returns:
- * 0 on success
- * Negative error code on failure
- */
-static int overlay_symbol_update(void *fdt, void *fdto)
-{
- int root_sym, ov_sym, prop, path_len, fragment, target;
- int len, frag_name_len, ret, rel_path_len;
- const char *s, *e;
- const char *path;
- const char *name;
- const char *frag_name;
- const char *rel_path;
- const char *target_path;
- char *buf;
- void *p;
-
- ov_sym = fdt_subnode_offset(fdto, 0, "__symbols__");
-
- /* if no overlay symbols exist no problem */
- if (ov_sym < 0)
- return 0;
-
- root_sym = fdt_subnode_offset(fdt, 0, "__symbols__");
-
- /* it no root symbols exist we should create them */
- if (root_sym == -FDT_ERR_NOTFOUND)
- root_sym = fdt_add_subnode(fdt, 0, "__symbols__");
-
- /* any error is fatal now */
- if (root_sym < 0)
- return root_sym;
-
- /* iterate over each overlay symbol */
- fdt_for_each_property_offset(prop, fdto, ov_sym) {
- path = fdt_getprop_by_offset(fdto, prop, &name, &path_len);
- if (!path)
- return path_len;
-
- /* verify it's a string property (terminated by a single \0) */
- if (path_len < 1 || memchr(path, '\0', path_len) != &path[path_len - 1])
- return -FDT_ERR_BADVALUE;
-
- /* keep end marker to avoid strlen() */
- e = path + path_len;
-
- /* format: /<fragment-name>/__overlay__/<relative-subnode-path> */
-
- if (*path != '/')
- return -FDT_ERR_BADVALUE;
-
- /* get fragment name first */
- s = strchr(path + 1, '/');
- if (!s)
- return -FDT_ERR_BADOVERLAY;
-
- frag_name = path + 1;
- frag_name_len = s - path - 1;
-
- /* verify format; safe since "s" lies in \0 terminated prop */
- len = sizeof("/__overlay__/") - 1;
- if ((e - s) < len || memcmp(s, "/__overlay__/", len))
- return -FDT_ERR_BADOVERLAY;
-
- rel_path = s + len;
- rel_path_len = e - rel_path;
-
- /* find the fragment index in which the symbol lies */
- ret = fdt_subnode_offset_namelen(fdto, 0, frag_name,
- frag_name_len);
- /* not found? */
- if (ret < 0)
- return -FDT_ERR_BADOVERLAY;
- fragment = ret;
-
- /* an __overlay__ subnode must exist */
- ret = fdt_subnode_offset(fdto, fragment, "__overlay__");
- if (ret < 0)
- return -FDT_ERR_BADOVERLAY;
-
- /* get the target of the fragment */
- ret = overlay_get_target(fdt, fdto, fragment, &target_path);
- if (ret < 0)
- return ret;
- target = ret;
-
- /* if we have a target path use */
- if (!target_path) {
- ret = get_path_len(fdt, target);
- if (ret < 0)
- return ret;
- len = ret;
- } else {
- len = strlen(target_path);
- }
-
- ret = fdt_setprop_placeholder(fdt, root_sym, name,
- len + (len > 1) + rel_path_len + 1, &p);
- if (ret < 0)
- return ret;
-
- if (!target_path) {
- /* again in case setprop_placeholder changed it */
- ret = overlay_get_target(fdt, fdto, fragment, &target_path);
- if (ret < 0)
- return ret;
- target = ret;
- }
-
- buf = p;
- if (len > 1) { /* target is not root */
- if (!target_path) {
- ret = fdt_get_path(fdt, target, buf, len + 1);
- if (ret < 0)
- return ret;
- } else
- memcpy(buf, target_path, len + 1);
-
- } else
- len--;
-
- buf[len] = '/';
- memcpy(buf + len + 1, rel_path, rel_path_len);
- buf[len + 1 + rel_path_len] = '\0';
- }
-
- return 0;
-}
-
-int fdt_overlay_apply(void *fdt, void *fdto)
-{
- uint32_t delta = fdt_get_max_phandle(fdt);
- int ret;
-
- FDT_CHECK_HEADER(fdt);
- FDT_CHECK_HEADER(fdto);
-
- ret = overlay_adjust_local_phandles(fdto, delta);
- if (ret)
- goto err;
-
- ret = overlay_update_local_references(fdto, delta);
- if (ret)
- goto err;
-
- ret = overlay_fixup_phandles(fdt, fdto);
- if (ret)
- goto err;
-
- ret = overlay_merge(fdt, fdto);
- if (ret)
- goto err;
-
- ret = overlay_symbol_update(fdt, fdto);
- if (ret)
- goto err;
-
- /*
- * The overlay has been damaged, erase its magic.
- */
- fdt_set_magic(fdto, ~0);
-
- return 0;
-
-err:
- /*
- * The overlay might have been damaged, erase its magic.
- */
- fdt_set_magic(fdto, ~0);
-
- /*
- * The base device tree might have been damaged, erase its
- * magic.
- */
- fdt_set_magic(fdt, ~0);
-
- return ret;
-}
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2016 Free Electrons
+ * Copyright (C) 2016 NextThing Co.
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ * a) This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ * b) Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "libfdt_env.h"
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "libfdt_internal.h"
+
+/**
+ * overlay_get_target_phandle - retrieves the target phandle of a fragment
+ * @fdto: pointer to the device tree overlay blob
+ * @fragment: node offset of the fragment in the overlay
+ *
+ * overlay_get_target_phandle() retrieves the target phandle of an
+ * overlay fragment when that fragment uses a phandle (target
+ * property) instead of a path (target-path property).
+ *
+ * returns:
+ * the phandle pointed by the target property
+ * 0, if the phandle was not found
+ * -1, if the phandle was malformed
+ */
+static uint32_t
+overlay_get_target_phandle (
+ const void *fdto,
+ int fragment
+ )
+{
+ const fdt32_t *val;
+ int len;
+
+ val = fdt_getprop (fdto, fragment, "target", &len);
+ if (!val) {
+ return 0;
+ }
+
+ if ((len != sizeof (*val)) || (fdt32_to_cpu (*val) == (uint32_t)-1)) {
+ return (uint32_t)-1;
+ }
+
+ return fdt32_to_cpu (*val);
+}
+
+/**
+ * overlay_get_target - retrieves the offset of a fragment's target
+ * @fdt: Base device tree blob
+ * @fdto: Device tree overlay blob
+ * @fragment: node offset of the fragment in the overlay
+ * @pathp: pointer which receives the path of the target (or NULL)
+ *
+ * overlay_get_target() retrieves the target offset in the base
+ * device tree of a fragment, no matter how the actual targetting is
+ * done (through a phandle or a path)
+ *
+ * returns:
+ * the targetted node offset in the base device tree
+ * Negative error code on error
+ */
+static int
+overlay_get_target (
+ const void *fdt,
+ const void *fdto,
+ int fragment,
+ char const **pathp
+ )
+{
+ uint32_t phandle;
+ const char *path = NULL;
+ int path_len = 0, ret;
+
+ /* Try first to do a phandle based lookup */
+ phandle = overlay_get_target_phandle (fdto, fragment);
+ if (phandle == (uint32_t)-1) {
+ return -FDT_ERR_BADPHANDLE;
+ }
+
+ /* no phandle, try path */
+ if (!phandle) {
+ /* And then a path based lookup */
+ path = fdt_getprop (fdto, fragment, "target-path", &path_len);
+ if (path) {
+ ret = fdt_path_offset (fdt, path);
+ } else {
+ ret = path_len;
+ }
+ } else {
+ ret = fdt_node_offset_by_phandle (fdt, phandle);
+ }
+
+ /*
+ * If we haven't found either a target or a
+ * target-path property in a node that contains a
+ * __overlay__ subnode (we wouldn't be called
+ * otherwise), consider it a improperly written
+ * overlay
+ */
+ if ((ret < 0) && (path_len == -FDT_ERR_NOTFOUND)) {
+ ret = -FDT_ERR_BADOVERLAY;
+ }
+
+ /* return on error */
+ if (ret < 0) {
+ return ret;
+ }
+
+ /* return pointer to path (if available) */
+ if (pathp) {
+ *pathp = path ? path : NULL;
+ }
+
+ return ret;
+}
+
+/**
+ * overlay_phandle_add_offset - Increases a phandle by an offset
+ * @fdt: Base device tree blob
+ * @node: Device tree overlay blob
+ * @name: Name of the property to modify (phandle or linux,phandle)
+ * @delta: offset to apply
+ *
+ * overlay_phandle_add_offset() increments a node phandle by a given
+ * offset.
+ *
+ * returns:
+ * 0 on success.
+ * Negative error code on error
+ */
+static int
+overlay_phandle_add_offset (
+ void *fdt,
+ int node,
+ const char *name,
+ uint32_t delta
+ )
+{
+ const fdt32_t *val;
+ uint32_t adj_val;
+ int len;
+
+ val = fdt_getprop (fdt, node, name, &len);
+ if (!val) {
+ return len;
+ }
+
+ if (len != sizeof (*val)) {
+ return -FDT_ERR_BADPHANDLE;
+ }
+
+ adj_val = fdt32_to_cpu (*val);
+ if ((adj_val + delta) < adj_val) {
+ return -FDT_ERR_NOPHANDLES;
+ }
+
+ adj_val += delta;
+ if (adj_val == (uint32_t)-1) {
+ return -FDT_ERR_NOPHANDLES;
+ }
+
+ return fdt_setprop_inplace_u32 (fdt, node, name, adj_val);
+}
+
+/**
+ * overlay_adjust_node_phandles - Offsets the phandles of a node
+ * @fdto: Device tree overlay blob
+ * @node: Offset of the node we want to adjust
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_adjust_node_phandles() adds a constant to all the phandles
+ * of a given node. This is mainly use as part of the overlay
+ * application process, when we want to update all the overlay
+ * phandles to not conflict with the overlays of the base device tree.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_adjust_node_phandles (
+ void *fdto,
+ int node,
+ uint32_t delta
+ )
+{
+ int child;
+ int ret;
+
+ ret = overlay_phandle_add_offset (fdto, node, "phandle", delta);
+ if (ret && (ret != -FDT_ERR_NOTFOUND)) {
+ return ret;
+ }
+
+ ret = overlay_phandle_add_offset (fdto, node, "linux,phandle", delta);
+ if (ret && (ret != -FDT_ERR_NOTFOUND)) {
+ return ret;
+ }
+
+ fdt_for_each_subnode (child, fdto, node) {
+ ret = overlay_adjust_node_phandles (fdto, child, delta);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
+ * @fdto: Device tree overlay blob
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_adjust_local_phandles() adds a constant to all the
+ * phandles of an overlay. This is mainly use as part of the overlay
+ * application process, when we want to update all the overlay
+ * phandles to not conflict with the overlays of the base device tree.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_adjust_local_phandles (
+ void *fdto,
+ uint32_t delta
+ )
+{
+ /*
+ * Start adjusting the phandles from the overlay root
+ */
+ return overlay_adjust_node_phandles (fdto, 0, delta);
+}
+
+/**
+ * overlay_update_local_node_references - Adjust the overlay references
+ * @fdto: Device tree overlay blob
+ * @tree_node: Node offset of the node to operate on
+ * @fixup_node: Node offset of the matching local fixups node
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_update_local_nodes_references() update the phandles
+ * pointing to a node within the device tree overlay by adding a
+ * constant delta.
+ *
+ * This is mainly used as part of a device tree application process,
+ * where you want the device tree overlays phandles to not conflict
+ * with the ones from the base device tree before merging them.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_update_local_node_references (
+ void *fdto,
+ int tree_node,
+ int fixup_node,
+ uint32_t delta
+ )
+{
+ int fixup_prop;
+ int fixup_child;
+ int ret;
+
+ fdt_for_each_property_offset (fixup_prop, fdto, fixup_node) {
+ const fdt32_t *fixup_val;
+ const char *tree_val;
+ const char *name;
+ int fixup_len;
+ int tree_len;
+ int i;
+
+ fixup_val = fdt_getprop_by_offset (
+ fdto,
+ fixup_prop,
+ &name,
+ &fixup_len
+ );
+ if (!fixup_val) {
+ return fixup_len;
+ }
+
+ if (fixup_len % sizeof (uint32_t)) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ tree_val = fdt_getprop (fdto, tree_node, name, &tree_len);
+ if (!tree_val) {
+ if (tree_len == -FDT_ERR_NOTFOUND) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ return tree_len;
+ }
+
+ for (i = 0; i < (fixup_len / sizeof (uint32_t)); i++) {
+ fdt32_t adj_val;
+ uint32_t poffset;
+
+ poffset = fdt32_to_cpu (fixup_val[i]);
+
+ /*
+ * phandles to fixup can be unaligned.
+ *
+ * Use a memcpy for the architectures that do
+ * not support unaligned accesses.
+ */
+ memcpy (&adj_val, tree_val + poffset, sizeof (adj_val));
+
+ adj_val = cpu_to_fdt32 (fdt32_to_cpu (adj_val) + delta);
+
+ ret = fdt_setprop_inplace_namelen_partial (
+ fdto,
+ tree_node,
+ name,
+ strlen (name),
+ poffset,
+ &adj_val,
+ sizeof (adj_val)
+ );
+ if (ret == -FDT_ERR_NOSPACE) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ if (ret) {
+ return ret;
+ }
+ }
+ }
+
+ fdt_for_each_subnode (fixup_child, fdto, fixup_node) {
+ const char *fixup_child_name = fdt_get_name (
+ fdto,
+ fixup_child,
+ NULL
+ );
+ int tree_child;
+
+ tree_child = fdt_subnode_offset (
+ fdto,
+ tree_node,
+ fixup_child_name
+ );
+ if (tree_child == -FDT_ERR_NOTFOUND) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ if (tree_child < 0) {
+ return tree_child;
+ }
+
+ ret = overlay_update_local_node_references (
+ fdto,
+ tree_child,
+ fixup_child,
+ delta
+ );
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * overlay_update_local_references - Adjust the overlay references
+ * @fdto: Device tree overlay blob
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_update_local_references() update all the phandles pointing
+ * to a node within the device tree overlay by adding a constant
+ * delta to not conflict with the base overlay.
+ *
+ * This is mainly used as part of a device tree application process,
+ * where you want the device tree overlays phandles to not conflict
+ * with the ones from the base device tree before merging them.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_update_local_references (
+ void *fdto,
+ uint32_t delta
+ )
+{
+ int fixups;
+
+ fixups = fdt_path_offset (fdto, "/__local_fixups__");
+ if (fixups < 0) {
+ /* There's no local phandles to adjust, bail out */
+ if (fixups == -FDT_ERR_NOTFOUND) {
+ return 0;
+ }
+
+ return fixups;
+ }
+
+ /*
+ * Update our local references from the root of the tree
+ */
+ return overlay_update_local_node_references (
+ fdto,
+ 0,
+ fixups,
+ delta
+ );
+}
+
+/**
+ * overlay_fixup_one_phandle - Set an overlay phandle to the base one
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ * @symbols_off: Node offset of the symbols node in the base device tree
+ * @path: Path to a node holding a phandle in the overlay
+ * @path_len: number of path characters to consider
+ * @name: Name of the property holding the phandle reference in the overlay
+ * @name_len: number of name characters to consider
+ * @poffset: Offset within the overlay property where the phandle is stored
+ * @label: Label of the node referenced by the phandle
+ *
+ * overlay_fixup_one_phandle() resolves an overlay phandle pointing to
+ * a node in the base device tree.
+ *
+ * This is part of the device tree overlay application process, when
+ * you want all the phandles in the overlay to point to the actual
+ * base dt nodes.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_fixup_one_phandle (
+ void *fdt,
+ void *fdto,
+ int symbols_off,
+ const char *path,
+ uint32_t path_len,
+ const char *name,
+ uint32_t name_len,
+ int poffset,
+ const char *label
+ )
+{
+ const char *symbol_path;
+ uint32_t phandle;
+ fdt32_t phandle_prop;
+ int symbol_off, fixup_off;
+ int prop_len;
+
+ if (symbols_off < 0) {
+ return symbols_off;
+ }
+
+ symbol_path = fdt_getprop (
+ fdt,
+ symbols_off,
+ label,
+ &prop_len
+ );
+ if (!symbol_path) {
+ return prop_len;
+ }
+
+ symbol_off = fdt_path_offset (fdt, symbol_path);
+ if (symbol_off < 0) {
+ return symbol_off;
+ }
+
+ phandle = fdt_get_phandle (fdt, symbol_off);
+ if (!phandle) {
+ return -FDT_ERR_NOTFOUND;
+ }
+
+ fixup_off = fdt_path_offset_namelen (fdto, path, path_len);
+ if (fixup_off == -FDT_ERR_NOTFOUND) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ if (fixup_off < 0) {
+ return fixup_off;
+ }
+
+ phandle_prop = cpu_to_fdt32 (phandle);
+ return fdt_setprop_inplace_namelen_partial (
+ fdto,
+ fixup_off,
+ name,
+ name_len,
+ poffset,
+ &phandle_prop,
+ sizeof (phandle_prop)
+ );
+}
+
+unsigned long
+strtoul (
+ const char *nptr,
+ char **endptr,
+ int base
+ );
+
+/**
+ * overlay_fixup_phandle - Set an overlay phandle to the base one
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ * @symbols_off: Node offset of the symbols node in the base device tree
+ * @property: Property offset in the overlay holding the list of fixups
+ *
+ * overlay_fixup_phandle() resolves all the overlay phandles pointed
+ * to in a __fixups__ property, and updates them to match the phandles
+ * in use in the base device tree.
+ *
+ * This is part of the device tree overlay application process, when
+ * you want all the phandles in the overlay to point to the actual
+ * base dt nodes.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_fixup_phandle (
+ void *fdt,
+ void *fdto,
+ int symbols_off,
+ int property
+ )
+{
+ const char *value;
+ const char *label;
+ int len;
+
+ value = fdt_getprop_by_offset (
+ fdto,
+ property,
+ &label,
+ &len
+ );
+ if (!value) {
+ if (len == -FDT_ERR_NOTFOUND) {
+ return -FDT_ERR_INTERNAL;
+ }
+
+ return len;
+ }
+
+ do {
+ const char *path, *name, *fixup_end;
+ const char *fixup_str = value;
+ uint32_t path_len, name_len;
+ uint32_t fixup_len;
+ char *sep, *endptr;
+ int poffset, ret;
+
+ fixup_end = memchr (value, '\0', len);
+ if (!fixup_end) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ fixup_len = fixup_end - fixup_str;
+
+ len -= fixup_len + 1;
+ value += fixup_len + 1;
+
+ path = fixup_str;
+ sep = memchr (fixup_str, ':', fixup_len);
+ if (!sep || (*sep != ':')) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ path_len = sep - path;
+ if (path_len == (fixup_len - 1)) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ fixup_len -= path_len + 1;
+ name = sep + 1;
+ sep = memchr (name, ':', fixup_len);
+ if (!sep || (*sep != ':')) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ name_len = sep - name;
+ if (!name_len) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ poffset = strtoul (sep + 1, &endptr, 10);
+ if ((*endptr != '\0') || (endptr <= (sep + 1))) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ ret = overlay_fixup_one_phandle (
+ fdt,
+ fdto,
+ symbols_off,
+ path,
+ path_len,
+ name,
+ name_len,
+ poffset,
+ label
+ );
+ if (ret) {
+ return ret;
+ }
+ } while (len > 0);
+
+ return 0;
+}
+
+/**
+ * overlay_fixup_phandles - Resolve the overlay phandles to the base
+ * device tree
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ *
+ * overlay_fixup_phandles() resolves all the overlay phandles pointing
+ * to nodes in the base device tree.
+ *
+ * This is one of the steps of the device tree overlay application
+ * process, when you want all the phandles in the overlay to point to
+ * the actual base dt nodes.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_fixup_phandles (
+ void *fdt,
+ void *fdto
+ )
+{
+ int fixups_off, symbols_off;
+ int property;
+
+ /* We can have overlays without any fixups */
+ fixups_off = fdt_path_offset (fdto, "/__fixups__");
+ if (fixups_off == -FDT_ERR_NOTFOUND) {
+ return 0; /* nothing to do */
+ }
+
+ if (fixups_off < 0) {
+ return fixups_off;
+ }
+
+ /* And base DTs without symbols */
+ symbols_off = fdt_path_offset (fdt, "/__symbols__");
+ if (((symbols_off < 0) && (symbols_off != -FDT_ERR_NOTFOUND))) {
+ return symbols_off;
+ }
+
+ fdt_for_each_property_offset (property, fdto, fixups_off) {
+ int ret;
+
+ ret = overlay_fixup_phandle (fdt, fdto, symbols_off, property);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * overlay_apply_node - Merges a node into the base device tree
+ * @fdt: Base Device Tree blob
+ * @target: Node offset in the base device tree to apply the fragment to
+ * @fdto: Device tree overlay blob
+ * @node: Node offset in the overlay holding the changes to merge
+ *
+ * overlay_apply_node() merges a node into a target base device tree
+ * node pointed.
+ *
+ * This is part of the final step in the device tree overlay
+ * application process, when all the phandles have been adjusted and
+ * resolved and you just have to merge overlay into the base device
+ * tree.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_apply_node (
+ void *fdt,
+ int target,
+ void *fdto,
+ int node
+ )
+{
+ int property;
+ int subnode;
+
+ fdt_for_each_property_offset (property, fdto, node) {
+ const char *name;
+ const void *prop;
+ int prop_len;
+ int ret;
+
+ prop = fdt_getprop_by_offset (
+ fdto,
+ property,
+ &name,
+ &prop_len
+ );
+ if (prop_len == -FDT_ERR_NOTFOUND) {
+ return -FDT_ERR_INTERNAL;
+ }
+
+ if (prop_len < 0) {
+ return prop_len;
+ }
+
+ ret = fdt_setprop (fdt, target, name, prop, prop_len);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ fdt_for_each_subnode (subnode, fdto, node) {
+ const char *name = fdt_get_name (fdto, subnode, NULL);
+ int nnode;
+ int ret;
+
+ nnode = fdt_add_subnode (fdt, target, name);
+ if (nnode == -FDT_ERR_EXISTS) {
+ nnode = fdt_subnode_offset (fdt, target, name);
+ if (nnode == -FDT_ERR_NOTFOUND) {
+ return -FDT_ERR_INTERNAL;
+ }
+ }
+
+ if (nnode < 0) {
+ return nnode;
+ }
+
+ ret = overlay_apply_node (fdt, nnode, fdto, subnode);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * overlay_merge - Merge an overlay into its base device tree
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ *
+ * overlay_merge() merges an overlay into its base device tree.
+ *
+ * This is the next to last step in the device tree overlay application
+ * process, when all the phandles have been adjusted and resolved and
+ * you just have to merge overlay into the base device tree.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_merge (
+ void *fdt,
+ void *fdto
+ )
+{
+ int fragment;
+
+ fdt_for_each_subnode (fragment, fdto, 0) {
+ int overlay;
+ int target;
+ int ret;
+
+ /*
+ * Each fragments will have an __overlay__ node. If
+ * they don't, it's not supposed to be merged
+ */
+ overlay = fdt_subnode_offset (fdto, fragment, "__overlay__");
+ if (overlay == -FDT_ERR_NOTFOUND) {
+ continue;
+ }
+
+ if (overlay < 0) {
+ return overlay;
+ }
+
+ target = overlay_get_target (fdt, fdto, fragment, NULL);
+ if (target < 0) {
+ return target;
+ }
+
+ ret = overlay_apply_node (fdt, target, fdto, overlay);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int
+get_path_len (
+ const void *fdt,
+ int nodeoffset
+ )
+{
+ int len = 0, namelen;
+ const char *name;
+
+ FDT_CHECK_HEADER (fdt);
+
+ for ( ; ;) {
+ name = fdt_get_name (fdt, nodeoffset, &namelen);
+ if (!name) {
+ return namelen;
+ }
+
+ /* root? we're done */
+ if (namelen == 0) {
+ break;
+ }
+
+ nodeoffset = fdt_parent_offset (fdt, nodeoffset);
+ if (nodeoffset < 0) {
+ return nodeoffset;
+ }
+
+ len += namelen + 1;
+ }
+
+ /* in case of root pretend it's "/" */
+ if (len == 0) {
+ len++;
+ }
+
+ return len;
+}
+
+/**
+ * overlay_symbol_update - Update the symbols of base tree after a merge
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ *
+ * overlay_symbol_update() updates the symbols of the base tree with the
+ * symbols of the applied overlay
+ *
+ * This is the last step in the device tree overlay application
+ * process, allowing the reference of overlay symbols by subsequent
+ * overlay operations.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int
+overlay_symbol_update (
+ void *fdt,
+ void *fdto
+ )
+{
+ int root_sym, ov_sym, prop, path_len, fragment, target;
+ int len, frag_name_len, ret, rel_path_len;
+ const char *s, *e;
+ const char *path;
+ const char *name;
+ const char *frag_name;
+ const char *rel_path;
+ const char *target_path;
+ char *buf;
+ void *p;
+
+ ov_sym = fdt_subnode_offset (fdto, 0, "__symbols__");
+
+ /* if no overlay symbols exist no problem */
+ if (ov_sym < 0) {
+ return 0;
+ }
+
+ root_sym = fdt_subnode_offset (fdt, 0, "__symbols__");
+
+ /* it no root symbols exist we should create them */
+ if (root_sym == -FDT_ERR_NOTFOUND) {
+ root_sym = fdt_add_subnode (fdt, 0, "__symbols__");
+ }
+
+ /* any error is fatal now */
+ if (root_sym < 0) {
+ return root_sym;
+ }
+
+ /* iterate over each overlay symbol */
+ fdt_for_each_property_offset (prop, fdto, ov_sym) {
+ path = fdt_getprop_by_offset (fdto, prop, &name, &path_len);
+ if (!path) {
+ return path_len;
+ }
+
+ /* verify it's a string property (terminated by a single \0) */
+ if ((path_len < 1) || (memchr (path, '\0', path_len) != &path[path_len - 1])) {
+ return -FDT_ERR_BADVALUE;
+ }
+
+ /* keep end marker to avoid strlen() */
+ e = path + path_len;
+
+ /* format: /<fragment-name>/__overlay__/<relative-subnode-path> */
+
+ if (*path != '/') {
+ return -FDT_ERR_BADVALUE;
+ }
+
+ /* get fragment name first */
+ s = strchr (path + 1, '/');
+ if (!s) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ frag_name = path + 1;
+ frag_name_len = s - path - 1;
+
+ /* verify format; safe since "s" lies in \0 terminated prop */
+ len = sizeof ("/__overlay__/") - 1;
+ if (((e - s) < len) || memcmp (s, "/__overlay__/", len)) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ rel_path = s + len;
+ rel_path_len = e - rel_path;
+
+ /* find the fragment index in which the symbol lies */
+ ret = fdt_subnode_offset_namelen (
+ fdto,
+ 0,
+ frag_name,
+ frag_name_len
+ );
+ /* not found? */
+ if (ret < 0) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ fragment = ret;
+
+ /* an __overlay__ subnode must exist */
+ ret = fdt_subnode_offset (fdto, fragment, "__overlay__");
+ if (ret < 0) {
+ return -FDT_ERR_BADOVERLAY;
+ }
+
+ /* get the target of the fragment */
+ ret = overlay_get_target (fdt, fdto, fragment, &target_path);
+ if (ret < 0) {
+ return ret;
+ }
+
+ target = ret;
+
+ /* if we have a target path use */
+ if (!target_path) {
+ ret = get_path_len (fdt, target);
+ if (ret < 0) {
+ return ret;
+ }
+
+ len = ret;
+ } else {
+ len = strlen (target_path);
+ }
+
+ ret = fdt_setprop_placeholder (
+ fdt,
+ root_sym,
+ name,
+ len + (len > 1) + rel_path_len + 1,
+ &p
+ );
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (!target_path) {
+ /* again in case setprop_placeholder changed it */
+ ret = overlay_get_target (fdt, fdto, fragment, &target_path);
+ if (ret < 0) {
+ return ret;
+ }
+
+ target = ret;
+ }
+
+ buf = p;
+ if (len > 1) {
+ /* target is not root */
+ if (!target_path) {
+ ret = fdt_get_path (fdt, target, buf, len + 1);
+ if (ret < 0) {
+ return ret;
+ }
+ } else {
+ memcpy (buf, target_path, len + 1);
+ }
+ } else {
+ len--;
+ }
+
+ buf[len] = '/';
+ memcpy (buf + len + 1, rel_path, rel_path_len);
+ buf[len + 1 + rel_path_len] = '\0';
+ }
+
+ return 0;
+}
+
+int
+fdt_overlay_apply (
+ void *fdt,
+ void *fdto
+ )
+{
+ uint32_t delta = fdt_get_max_phandle (fdt);
+ int ret;
+
+ FDT_CHECK_HEADER (fdt);
+ FDT_CHECK_HEADER (fdto);
+
+ ret = overlay_adjust_local_phandles (fdto, delta);
+ if (ret) {
+ goto err;
+ }
+
+ ret = overlay_update_local_references (fdto, delta);
+ if (ret) {
+ goto err;
+ }
+
+ ret = overlay_fixup_phandles (fdt, fdto);
+ if (ret) {
+ goto err;
+ }
+
+ ret = overlay_merge (fdt, fdto);
+ if (ret) {
+ goto err;
+ }
+
+ ret = overlay_symbol_update (fdt, fdto);
+ if (ret) {
+ goto err;
+ }
+
+ /*
+ * The overlay has been damaged, erase its magic.
+ */
+ fdt_set_magic (fdto, ~0);
+
+ return 0;
+
+err:
+
+ /*
+ * The overlay might have been damaged, erase its magic.
+ */
+ fdt_set_magic (fdto, ~0);
+
+ /*
+ * The base device tree might have been damaged, erase its
+ * magic.
+ */
+ fdt_set_magic (fdt, ~0);
+
+ return ret;
+}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_ro.c b/EmbeddedPkg/Library/FdtLib/fdt_ro.c
index 9413f50a11..30aac37958 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_ro.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_ro.c
@@ -55,649 +55,909 @@
#include "libfdt_internal.h"
-static int _fdt_nodename_eq(const void *fdt, int offset,
- const char *s, int len)
+static int
+_fdt_nodename_eq (
+ const void *fdt,
+ int offset,
+ const char *s,
+ int len
+ )
{
- const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
+ const char *p = fdt_offset_ptr (fdt, offset + FDT_TAGSIZE, len+1);
- if (!p)
- /* short match */
- return 0;
+ if (!p) {
+ /* short match */
+ return 0;
+ }
- if (memcmp(p, s, len) != 0)
- return 0;
+ if (memcmp (p, s, len) != 0) {
+ return 0;
+ }
- if (p[len] == '\0')
- return 1;
- else if (!memchr(s, '@', len) && (p[len] == '@'))
- return 1;
- else
- return 0;
+ if (p[len] == '\0') {
+ return 1;
+ } else if (!memchr (s, '@', len) && (p[len] == '@')) {
+ return 1;
+ } else {
+ return 0;
+ }
}
-const char *fdt_string(const void *fdt, int stroffset)
+const char *
+fdt_string (
+ const void *fdt,
+ int stroffset
+ )
{
- return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
+ return (const char *)fdt + fdt_off_dt_strings (fdt) + stroffset;
}
-static int _fdt_string_eq(const void *fdt, int stroffset,
- const char *s, int len)
+static int
+_fdt_string_eq (
+ const void *fdt,
+ int stroffset,
+ const char *s,
+ int len
+ )
{
- const char *p = fdt_string(fdt, stroffset);
+ const char *p = fdt_string (fdt, stroffset);
- return (strlen(p) == len) && (memcmp(p, s, len) == 0);
+ return (strlen (p) == len) && (memcmp (p, s, len) == 0);
}
-uint32_t fdt_get_max_phandle(const void *fdt)
+uint32_t
+fdt_get_max_phandle (
+ const void *fdt
+ )
{
- uint32_t max_phandle = 0;
- int offset;
+ uint32_t max_phandle = 0;
+ int offset;
- for (offset = fdt_next_node(fdt, -1, NULL);;
- offset = fdt_next_node(fdt, offset, NULL)) {
- uint32_t phandle;
+ for (offset = fdt_next_node (fdt, -1, NULL); ;
+ offset = fdt_next_node (fdt, offset, NULL))
+ {
+ uint32_t phandle;
- if (offset == -FDT_ERR_NOTFOUND)
- return max_phandle;
+ if (offset == -FDT_ERR_NOTFOUND) {
+ return max_phandle;
+ }
- if (offset < 0)
- return (uint32_t)-1;
+ if (offset < 0) {
+ return (uint32_t)-1;
+ }
- phandle = fdt_get_phandle(fdt, offset);
- if (phandle == (uint32_t)-1)
- continue;
+ phandle = fdt_get_phandle (fdt, offset);
+ if (phandle == (uint32_t)-1) {
+ continue;
+ }
- if (phandle > max_phandle)
- max_phandle = phandle;
- }
+ if (phandle > max_phandle) {
+ max_phandle = phandle;
+ }
+ }
- return 0;
+ return 0;
}
-int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
+int
+fdt_get_mem_rsv (
+ const void *fdt,
+ int n,
+ uint64_t *address,
+ uint64_t *size
+ )
{
- FDT_CHECK_HEADER(fdt);
- *address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address);
- *size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size);
- return 0;
+ FDT_CHECK_HEADER (fdt);
+ *address = fdt64_to_cpu (_fdt_mem_rsv (fdt, n)->address);
+ *size = fdt64_to_cpu (_fdt_mem_rsv (fdt, n)->size);
+ return 0;
}
-int fdt_num_mem_rsv(const void *fdt)
+int
+fdt_num_mem_rsv (
+ const void *fdt
+ )
{
- int i = 0;
+ int i = 0;
- while (fdt64_to_cpu(_fdt_mem_rsv(fdt, i)->size) != 0)
- i++;
- return i;
-}
-
-static int _nextprop(const void *fdt, int offset)
-{
- uint32_t tag;
- int nextoffset;
-
- do {
- tag = fdt_next_tag(fdt, offset, &nextoffset);
-
- switch (tag) {
- case FDT_END:
- if (nextoffset >= 0)
- return -FDT_ERR_BADSTRUCTURE;
- else
- return nextoffset;
+ while (fdt64_to_cpu (_fdt_mem_rsv (fdt, i)->size) != 0) {
+ i++;
+ }
- case FDT_PROP:
- return offset;
- }
- offset = nextoffset;
- } while (tag == FDT_NOP);
-
- return -FDT_ERR_NOTFOUND;
+ return i;
}
-int fdt_subnode_offset_namelen(const void *fdt, int offset,
- const char *name, int namelen)
+static int
+_nextprop (
+ const void *fdt,
+ int offset
+ )
{
- int depth;
-
- FDT_CHECK_HEADER(fdt);
-
- for (depth = 0;
- (offset >= 0) && (depth >= 0);
- offset = fdt_next_node(fdt, offset, &depth))
- if ((depth == 1)
- && _fdt_nodename_eq(fdt, offset, name, namelen))
- return offset;
-
- if (depth < 0)
- return -FDT_ERR_NOTFOUND;
- return offset; /* error */
-}
-
-int fdt_subnode_offset(const void *fdt, int parentoffset,
- const char *name)
-{
- return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name));
-}
-
-int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
-{
- const char *end = path + namelen;
- const char *p = path;
- int offset = 0;
-
- FDT_CHECK_HEADER(fdt);
-
- /* see if we have an alias */
- if (*path != '/') {
- const char *q = memchr(path, '/', end - p);
+ uint32_t tag;
+ int nextoffset;
- if (!q)
- q = end;
+ do {
+ tag = fdt_next_tag (fdt, offset, &nextoffset);
- p = fdt_get_alias_namelen(fdt, p, q - p);
- if (!p)
- return -FDT_ERR_BADPATH;
- offset = fdt_path_offset(fdt, p);
+ switch (tag) {
+ case FDT_END:
+ if (nextoffset >= 0) {
+ return -FDT_ERR_BADSTRUCTURE;
+ } else {
+ return nextoffset;
+ }
- p = q;
- }
+ case FDT_PROP:
+ return offset;
+ }
- while (p < end) {
- const char *q;
+ offset = nextoffset;
+ } while (tag == FDT_NOP);
- while (*p == '/') {
- p++;
- if (p == end)
- return offset;
- }
- q = memchr(p, '/', end - p);
- if (! q)
- q = end;
-
- offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
- if (offset < 0)
- return offset;
-
- p = q;
- }
-
- return offset;
+ return -FDT_ERR_NOTFOUND;
}
-int fdt_path_offset(const void *fdt, const char *path)
+int
+fdt_subnode_offset_namelen (
+ const void *fdt,
+ int offset,
+ const char *name,
+ int namelen
+ )
{
- return fdt_path_offset_namelen(fdt, path, strlen(path));
-}
+ int depth;
-const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
-{
- const struct fdt_node_header *nh = _fdt_offset_ptr(fdt, nodeoffset);
- int err;
+ FDT_CHECK_HEADER (fdt);
- if (((err = fdt_check_header(fdt)) != 0)
- || ((err = _fdt_check_node_offset(fdt, nodeoffset)) < 0))
- goto fail;
+ for (depth = 0;
+ (offset >= 0) && (depth >= 0);
+ offset = fdt_next_node (fdt, offset, &depth))
+ {
+ if ( (depth == 1)
+ && _fdt_nodename_eq (fdt, offset, name, namelen))
+ {
+ return offset;
+ }
+ }
- if (len)
- *len = strlen(nh->name);
+ if (depth < 0) {
+ return -FDT_ERR_NOTFOUND;
+ }
- return nh->name;
-
- fail:
- if (len)
- *len = err;
- return NULL;
+ return offset; /* error */
}
-int fdt_first_property_offset(const void *fdt, int nodeoffset)
+int
+fdt_subnode_offset (
+ const void *fdt,
+ int parentoffset,
+ const char *name
+ )
{
- int offset;
-
- if ((offset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
- return offset;
-
- return _nextprop(fdt, offset);
+ return fdt_subnode_offset_namelen (fdt, parentoffset, name, strlen (name));
}
-int fdt_next_property_offset(const void *fdt, int offset)
+int
+fdt_path_offset_namelen (
+ const void *fdt,
+ const char *path,
+ int namelen
+ )
{
- if ((offset = _fdt_check_prop_offset(fdt, offset)) < 0)
- return offset;
+ const char *end = path + namelen;
+ const char *p = path;
+ int offset = 0;
- return _nextprop(fdt, offset);
-}
+ FDT_CHECK_HEADER (fdt);
-const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
- int offset,
- int *lenp)
-{
- int err;
- const struct fdt_property *prop;
-
- if ((err = _fdt_check_prop_offset(fdt, offset)) < 0) {
- if (lenp)
- *lenp = err;
- return NULL;
- }
+ /* see if we have an alias */
+ if (*path != '/') {
+ const char *q = memchr (path, '/', end - p);
- prop = _fdt_offset_ptr(fdt, offset);
+ if (!q) {
+ q = end;
+ }
- if (lenp)
- *lenp = fdt32_to_cpu(prop->len);
+ p = fdt_get_alias_namelen (fdt, p, q - p);
+ if (!p) {
+ return -FDT_ERR_BADPATH;
+ }
- return prop;
-}
+ offset = fdt_path_offset (fdt, p);
-const struct fdt_property *fdt_get_property_namelen(const void *fdt,
- int offset,
- const char *name,
- int namelen, int *lenp)
-{
- for (offset = fdt_first_property_offset(fdt, offset);
- (offset >= 0);
- (offset = fdt_next_property_offset(fdt, offset))) {
- const struct fdt_property *prop;
+ p = q;
+ }
- if (!(prop = fdt_get_property_by_offset(fdt, offset, lenp))) {
- offset = -FDT_ERR_INTERNAL;
- break;
- }
- if (_fdt_string_eq(fdt, fdt32_to_cpu(prop->nameoff),
- name, namelen))
- return prop;
- }
+ while (p < end) {
+ const char *q;
- if (lenp)
- *lenp = offset;
- return NULL;
-}
+ while (*p == '/') {
+ p++;
+ if (p == end) {
+ return offset;
+ }
+ }
-const struct fdt_property *fdt_get_property(const void *fdt,
- int nodeoffset,
- const char *name, int *lenp)
-{
- return fdt_get_property_namelen(fdt, nodeoffset, name,
- strlen(name), lenp);
-}
+ q = memchr (p, '/', end - p);
+ if (!q) {
+ q = end;
+ }
-const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
- const char *name, int namelen, int *lenp)
-{
- const struct fdt_property *prop;
+ offset = fdt_subnode_offset_namelen (fdt, offset, p, q-p);
+ if (offset < 0) {
+ return offset;
+ }
- prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp);
- if (!prop)
- return NULL;
+ p = q;
+ }
- return prop->data;
+ return offset;
}
-const void *fdt_getprop_by_offset(const void *fdt, int offset,
- const char **namep, int *lenp)
+int
+fdt_path_offset (
+ const void *fdt,
+ const char *path
+ )
{
- const struct fdt_property *prop;
-
- prop = fdt_get_property_by_offset(fdt, offset, lenp);
- if (!prop)
- return NULL;
- if (namep)
- *namep = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
- return prop->data;
+ return fdt_path_offset_namelen (fdt, path, strlen (path));
}
-const void *fdt_getprop(const void *fdt, int nodeoffset,
- const char *name, int *lenp)
+const char *
+fdt_get_name (
+ const void *fdt,
+ int nodeoffset,
+ int *len
+ )
{
- return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp);
-}
+ const struct fdt_node_header *nh = _fdt_offset_ptr (fdt, nodeoffset);
+ int err;
-uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
-{
- const fdt32_t *php;
- int len;
+ if ( ((err = fdt_check_header (fdt)) != 0)
+ || ((err = _fdt_check_node_offset (fdt, nodeoffset)) < 0))
+ {
+ goto fail;
+ }
- /* FIXME: This is a bit sub-optimal, since we potentially scan
- * over all the properties twice. */
- php = fdt_getprop(fdt, nodeoffset, "phandle", &len);
- if (!php || (len != sizeof(*php))) {
- php = fdt_getprop(fdt, nodeoffset, "linux,phandle", &len);
- if (!php || (len != sizeof(*php)))
- return 0;
- }
+ if (len) {
+ *len = strlen (nh->name);
+ }
- return fdt32_to_cpu(*php);
-}
+ return nh->name;
-const char *fdt_get_alias_namelen(const void *fdt,
- const char *name, int namelen)
-{
- int aliasoffset;
+fail:
+ if (len) {
+ *len = err;
+ }
- aliasoffset = fdt_path_offset(fdt, "/aliases");
- if (aliasoffset < 0)
- return NULL;
-
- return fdt_getprop_namelen(fdt, aliasoffset, name, namelen, NULL);
-}
-
-const char *fdt_get_alias(const void *fdt, const char *name)
-{
- return fdt_get_alias_namelen(fdt, name, strlen(name));
+ return NULL;
}
-int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
+int
+fdt_first_property_offset (
+ const void *fdt,
+ int nodeoffset
+ )
{
- int pdepth = 0, p = 0;
- int offset, depth, namelen;
- const char *name;
+ int offset;
- FDT_CHECK_HEADER(fdt);
+ if ((offset = _fdt_check_node_offset (fdt, nodeoffset)) < 0) {
+ return offset;
+ }
- if (buflen < 2)
- return -FDT_ERR_NOSPACE;
-
- for (offset = 0, depth = 0;
- (offset >= 0) && (offset <= nodeoffset);
- offset = fdt_next_node(fdt, offset, &depth)) {
- while (pdepth > depth) {
- do {
- p--;
- } while (buf[p-1] != '/');
- pdepth--;
- }
-
- if (pdepth >= depth) {
- name = fdt_get_name(fdt, offset, &namelen);
- if (!name)
- return namelen;
- if ((p + namelen + 1) <= buflen) {
- memcpy(buf + p, name, namelen);
- p += namelen;
- buf[p++] = '/';
- pdepth++;
- }
- }
-
- if (offset == nodeoffset) {
- if (pdepth < (depth + 1))
- return -FDT_ERR_NOSPACE;
-
- if (p > 1) /* special case so that root path is "/", not "" */
- p--;
- buf[p] = '\0';
- return 0;
- }
- }
-
- if ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0))
- return -FDT_ERR_BADOFFSET;
- else if (offset == -FDT_ERR_BADOFFSET)
- return -FDT_ERR_BADSTRUCTURE;
-
- return offset; /* error from fdt_next_node() */
+ return _nextprop (fdt, offset);
}
-int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
- int supernodedepth, int *nodedepth)
+int
+fdt_next_property_offset (
+ const void *fdt,
+ int offset
+ )
{
- int offset, depth;
- int supernodeoffset = -FDT_ERR_INTERNAL;
-
- FDT_CHECK_HEADER(fdt);
-
- if (supernodedepth < 0)
- return -FDT_ERR_NOTFOUND;
+ if ((offset = _fdt_check_prop_offset (fdt, offset)) < 0) {
+ return offset;
+ }
- for (offset = 0, depth = 0;
- (offset >= 0) && (offset <= nodeoffset);
- offset = fdt_next_node(fdt, offset, &depth)) {
- if (depth == supernodedepth)
- supernodeoffset = offset;
-
- if (offset == nodeoffset) {
- if (nodedepth)
- *nodedepth = depth;
-
- if (supernodedepth > depth)
- return -FDT_ERR_NOTFOUND;
- else
- return supernodeoffset;
- }
- }
-
- if ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0))
- return -FDT_ERR_BADOFFSET;
- else if (offset == -FDT_ERR_BADOFFSET)
- return -FDT_ERR_BADSTRUCTURE;
-
- return offset; /* error from fdt_next_node() */
-}
-
-int fdt_node_depth(const void *fdt, int nodeoffset)
-{
- int nodedepth;
- int err;
-
- err = fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, &nodedepth);
- if (err)
- return (err < 0) ? err : -FDT_ERR_INTERNAL;
- return nodedepth;
+ return _nextprop (fdt, offset);
}
-int fdt_parent_offset(const void *fdt, int nodeoffset)
+const struct fdt_property *
+fdt_get_property_by_offset (
+ const void *fdt,
+ int offset,
+ int *lenp
+ )
{
- int nodedepth = fdt_node_depth(fdt, nodeoffset);
+ int err;
+ const struct fdt_property *prop;
- if (nodedepth < 0)
- return nodedepth;
- return fdt_supernode_atdepth_offset(fdt, nodeoffset,
- nodedepth - 1, NULL);
-}
+ if ((err = _fdt_check_prop_offset (fdt, offset)) < 0) {
+ if (lenp) {
+ *lenp = err;
+ }
-int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
- const char *propname,
- const void *propval, int proplen)
-{
- int offset;
- const void *val;
- int len;
+ return NULL;
+ }
- FDT_CHECK_HEADER(fdt);
+ prop = _fdt_offset_ptr (fdt, offset);
- /* FIXME: The algorithm here is pretty horrible: we scan each
- * property of a node in fdt_getprop(), then if that didn't
- * find what we want, we scan over them again making our way
- * to the next node. Still it's the easiest to implement
- * approach; performance can come later. */
- for (offset = fdt_next_node(fdt, startoffset, NULL);
- offset >= 0;
- offset = fdt_next_node(fdt, offset, NULL)) {
- val = fdt_getprop(fdt, offset, propname, &len);
- if (val && (len == proplen)
- && (memcmp(val, propval, len) == 0))
- return offset;
- }
+ if (lenp) {
+ *lenp = fdt32_to_cpu (prop->len);
+ }
- return offset; /* error from fdt_next_node() */
+ return prop;
}
-int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
+const struct fdt_property *
+fdt_get_property_namelen (
+ const void *fdt,
+ int offset,
+ const char *name,
+ int namelen,
+ int *lenp
+ )
{
- int offset;
+ for (offset = fdt_first_property_offset (fdt, offset);
+ (offset >= 0);
+ (offset = fdt_next_property_offset (fdt, offset)))
+ {
+ const struct fdt_property *prop;
- if ((phandle == 0) || (phandle == -1))
- return -FDT_ERR_BADPHANDLE;
+ if (!(prop = fdt_get_property_by_offset (fdt, offset, lenp))) {
+ offset = -FDT_ERR_INTERNAL;
+ break;
+ }
- FDT_CHECK_HEADER(fdt);
+ if (_fdt_string_eq (
+ fdt,
+ fdt32_to_cpu (prop->nameoff),
+ name,
+ namelen
+ ))
+ {
+ return prop;
+ }
+ }
- /* FIXME: The algorithm here is pretty horrible: we
- * potentially scan each property of a node in
- * fdt_get_phandle(), then if that didn't find what
- * we want, we scan over them again making our way to the next
- * node. Still it's the easiest to implement approach;
- * performance can come later. */
- for (offset = fdt_next_node(fdt, -1, NULL);
- offset >= 0;
- offset = fdt_next_node(fdt, offset, NULL)) {
- if (fdt_get_phandle(fdt, offset) == phandle)
- return offset;
- }
+ if (lenp) {
+ *lenp = offset;
+ }
- return offset; /* error from fdt_next_node() */
+ return NULL;
}
-int fdt_stringlist_contains(const char *strlist, int listlen, const char *str)
+const struct fdt_property *
+fdt_get_property (
+ const void *fdt,
+ int nodeoffset,
+ const char *name,
+ int *lenp
+ )
{
- int len = strlen(str);
- const char *p;
-
- while (listlen >= len) {
- if (memcmp(str, strlist, len+1) == 0)
- return 1;
- p = memchr(strlist, '\0', listlen);
- if (!p)
- return 0; /* malformed strlist.. */
- listlen -= (p-strlist) + 1;
- strlist = p + 1;
- }
- return 0;
+ return fdt_get_property_namelen (
+ fdt,
+ nodeoffset,
+ name,
+ strlen (name),
+ lenp
+ );
}
-int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property)
+const void *
+fdt_getprop_namelen (
+ const void *fdt,
+ int nodeoffset,
+ const char *name,
+ int namelen,
+ int *lenp
+ )
{
- const char *list, *end;
- int length, count = 0;
-
- list = fdt_getprop(fdt, nodeoffset, property, &length);
- if (!list)
- return length;
+ const struct fdt_property *prop;
- end = list + length;
+ prop = fdt_get_property_namelen (fdt, nodeoffset, name, namelen, lenp);
+ if (!prop) {
+ return NULL;
+ }
- while (list < end) {
- length = strnlen(list, end - list) + 1;
-
- /* Abort if the last string isn't properly NUL-terminated. */
- if (list + length > end)
- return -FDT_ERR_BADVALUE;
+ return prop->data;
+}
+
+const void *
+fdt_getprop_by_offset (
+ const void *fdt,
+ int offset,
+ const char **namep,
+ int *lenp
+ )
+{
+ const struct fdt_property *prop;
+
+ prop = fdt_get_property_by_offset (fdt, offset, lenp);
+ if (!prop) {
+ return NULL;
+ }
+
+ if (namep) {
+ *namep = fdt_string (fdt, fdt32_to_cpu (prop->nameoff));
+ }
+
+ return prop->data;
+}
+
+const void *
+fdt_getprop (
+ const void *fdt,
+ int nodeoffset,
+ const char *name,
+ int *lenp
+ )
+{
+ return fdt_getprop_namelen (fdt, nodeoffset, name, strlen (name), lenp);
+}
+
+uint32_t
+fdt_get_phandle (
+ const void *fdt,
+ int nodeoffset
+ )
+{
+ const fdt32_t *php;
+ int len;
+
+ /* FIXME: This is a bit sub-optimal, since we potentially scan
+ * over all the properties twice. */
+ php = fdt_getprop (fdt, nodeoffset, "phandle", &len);
+ if (!php || (len != sizeof (*php))) {
+ php = fdt_getprop (fdt, nodeoffset, "linux,phandle", &len);
+ if (!php || (len != sizeof (*php))) {
+ return 0;
+ }
+ }
+
+ return fdt32_to_cpu (*php);
+}
+
+const char *
+fdt_get_alias_namelen (
+ const void *fdt,
+ const char *name,
+ int namelen
+ )
+{
+ int aliasoffset;
+
+ aliasoffset = fdt_path_offset (fdt, "/aliases");
+ if (aliasoffset < 0) {
+ return NULL;
+ }
+
+ return fdt_getprop_namelen (fdt, aliasoffset, name, namelen, NULL);
+}
+
+const char *
+fdt_get_alias (
+ const void *fdt,
+ const char *name
+ )
+{
+ return fdt_get_alias_namelen (fdt, name, strlen (name));
+}
+
+int
+fdt_get_path (
+ const void *fdt,
+ int nodeoffset,
+ char *buf,
+ int buflen
+ )
+{
+ int pdepth = 0, p = 0;
+ int offset, depth, namelen;
+ const char *name;
+
+ FDT_CHECK_HEADER (fdt);
+
+ if (buflen < 2) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ for (offset = 0, depth = 0;
+ (offset >= 0) && (offset <= nodeoffset);
+ offset = fdt_next_node (fdt, offset, &depth))
+ {
+ while (pdepth > depth) {
+ do {
+ p--;
+ } while (buf[p-1] != '/');
+
+ pdepth--;
+ }
+
+ if (pdepth >= depth) {
+ name = fdt_get_name (fdt, offset, &namelen);
+ if (!name) {
+ return namelen;
+ }
+
+ if ((p + namelen + 1) <= buflen) {
+ memcpy (buf + p, name, namelen);
+ p += namelen;
+ buf[p++] = '/';
+ pdepth++;
+ }
+ }
+
+ if (offset == nodeoffset) {
+ if (pdepth < (depth + 1)) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ if (p > 1) {
+ /* special case so that root path is "/", not "" */
+ p--;
+ }
+
+ buf[p] = '\0';
+ return 0;
+ }
+ }
+
+ if ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0)) {
+ return -FDT_ERR_BADOFFSET;
+ } else if (offset == -FDT_ERR_BADOFFSET) {
+ return -FDT_ERR_BADSTRUCTURE;
+ }
+
+ return offset; /* error from fdt_next_node() */
+}
+
+int
+fdt_supernode_atdepth_offset (
+ const void *fdt,
+ int nodeoffset,
+ int supernodedepth,
+ int *nodedepth
+ )
+{
+ int offset, depth;
+ int supernodeoffset = -FDT_ERR_INTERNAL;
+
+ FDT_CHECK_HEADER (fdt);
+
+ if (supernodedepth < 0) {
+ return -FDT_ERR_NOTFOUND;
+ }
+
+ for (offset = 0, depth = 0;
+ (offset >= 0) && (offset <= nodeoffset);
+ offset = fdt_next_node (fdt, offset, &depth))
+ {
+ if (depth == supernodedepth) {
+ supernodeoffset = offset;
+ }
+
+ if (offset == nodeoffset) {
+ if (nodedepth) {
+ *nodedepth = depth;
+ }
+
+ if (supernodedepth > depth) {
+ return -FDT_ERR_NOTFOUND;
+ } else {
+ return supernodeoffset;
+ }
+ }
+ }
+
+ if ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0)) {
+ return -FDT_ERR_BADOFFSET;
+ } else if (offset == -FDT_ERR_BADOFFSET) {
+ return -FDT_ERR_BADSTRUCTURE;
+ }
+
+ return offset; /* error from fdt_next_node() */
+}
+
+int
+fdt_node_depth (
+ const void *fdt,
+ int nodeoffset
+ )
+{
+ int nodedepth;
+ int err;
+
+ err = fdt_supernode_atdepth_offset (fdt, nodeoffset, 0, &nodedepth);
+ if (err) {
+ return (err < 0) ? err : -FDT_ERR_INTERNAL;
+ }
+
+ return nodedepth;
+}
+
+int
+fdt_parent_offset (
+ const void *fdt,
+ int nodeoffset
+ )
+{
+ int nodedepth = fdt_node_depth (fdt, nodeoffset);
+
+ if (nodedepth < 0) {
+ return nodedepth;
+ }
+
+ return fdt_supernode_atdepth_offset (
+ fdt,
+ nodeoffset,
+ nodedepth - 1,
+ NULL
+ );
+}
+
+int
+fdt_node_offset_by_prop_value (
+ const void *fdt,
+ int startoffset,
+ const char *propname,
+ const void *propval,
+ int proplen
+ )
+{
+ int offset;
+ const void *val;
+ int len;
+
+ FDT_CHECK_HEADER (fdt);
+
+ /* FIXME: The algorithm here is pretty horrible: we scan each
+ * property of a node in fdt_getprop(), then if that didn't
+ * find what we want, we scan over them again making our way
+ * to the next node. Still it's the easiest to implement
+ * approach; performance can come later. */
+ for (offset = fdt_next_node (fdt, startoffset, NULL);
+ offset >= 0;
+ offset = fdt_next_node (fdt, offset, NULL))
+ {
+ val = fdt_getprop (fdt, offset, propname, &len);
+ if ( val && (len == proplen)
+ && (memcmp (val, propval, len) == 0))
+ {
+ return offset;
+ }
+ }
+
+ return offset; /* error from fdt_next_node() */
+}
+
+int
+fdt_node_offset_by_phandle (
+ const void *fdt,
+ uint32_t phandle
+ )
+{
+ int offset;
+
+ if ((phandle == 0) || (phandle == -1)) {
+ return -FDT_ERR_BADPHANDLE;
+ }
+
+ FDT_CHECK_HEADER (fdt);
+
+ /* FIXME: The algorithm here is pretty horrible: we
+ * potentially scan each property of a node in
+ * fdt_get_phandle(), then if that didn't find what
+ * we want, we scan over them again making our way to the next
+ * node. Still it's the easiest to implement approach;
+ * performance can come later. */
+ for (offset = fdt_next_node (fdt, -1, NULL);
+ offset >= 0;
+ offset = fdt_next_node (fdt, offset, NULL))
+ {
+ if (fdt_get_phandle (fdt, offset) == phandle) {
+ return offset;
+ }
+ }
+
+ return offset; /* error from fdt_next_node() */
+}
+
+int
+fdt_stringlist_contains (
+ const char *strlist,
+ int listlen,
+ const char *str
+ )
+{
+ int len = strlen (str);
+ const char *p;
+
+ while (listlen >= len) {
+ if (memcmp (str, strlist, len+1) == 0) {
+ return 1;
+ }
+
+ p = memchr (strlist, '\0', listlen);
+ if (!p) {
+ return 0; /* malformed strlist.. */
+ }
+
+ listlen -= (p-strlist) + 1;
+ strlist = p + 1;
+ }
+
+ return 0;
+}
+
+int
+fdt_stringlist_count (
+ const void *fdt,
+ int nodeoffset,
+ const char *property
+ )
+{
+ const char *list, *end;
+ int length, count = 0;
+
+ list = fdt_getprop (fdt, nodeoffset, property, &length);
+ if (!list) {
+ return length;
+ }
+
+ end = list + length;
+
+ while (list < end) {
+ length = strnlen (list, end - list) + 1;
+
+ /* Abort if the last string isn't properly NUL-terminated. */
+ if (list + length > end) {
+ return -FDT_ERR_BADVALUE;
+ }
- list += length;
- count++;
- }
+ list += length;
+ count++;
+ }
- return count;
+ return count;
}
-int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,
- const char *string)
+int
+fdt_stringlist_search (
+ const void *fdt,
+ int nodeoffset,
+ const char *property,
+ const char *string
+ )
{
- int length, len, idx = 0;
- const char *list, *end;
+ int length, len, idx = 0;
+ const char *list, *end;
- list = fdt_getprop(fdt, nodeoffset, property, &length);
- if (!list)
- return length;
+ list = fdt_getprop (fdt, nodeoffset, property, &length);
+ if (!list) {
+ return length;
+ }
- len = strlen(string) + 1;
- end = list + length;
+ len = strlen (string) + 1;
+ end = list + length;
- while (list < end) {
- length = strnlen(list, end - list) + 1;
+ while (list < end) {
+ length = strnlen (list, end - list) + 1;
- /* Abort if the last string isn't properly NUL-terminated. */
- if (list + length > end)
- return -FDT_ERR_BADVALUE;
+ /* Abort if the last string isn't properly NUL-terminated. */
+ if (list + length > end) {
+ return -FDT_ERR_BADVALUE;
+ }
- if (length == len && memcmp(list, string, length) == 0)
- return idx;
+ if ((length == len) && (memcmp (list, string, length) == 0)) {
+ return idx;
+ }
- list += length;
- idx++;
- }
+ list += length;
+ idx++;
+ }
- return -FDT_ERR_NOTFOUND;
+ return -FDT_ERR_NOTFOUND;
}
-const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
- const char *property, int idx,
- int *lenp)
+const char *
+fdt_stringlist_get (
+ const void *fdt,
+ int nodeoffset,
+ const char *property,
+ int idx,
+ int *lenp
+ )
{
- const char *list, *end;
- int length;
+ const char *list, *end;
+ int length;
- list = fdt_getprop(fdt, nodeoffset, property, &length);
- if (!list) {
- if (lenp)
- *lenp = length;
+ list = fdt_getprop (fdt, nodeoffset, property, &length);
+ if (!list) {
+ if (lenp) {
+ *lenp = length;
+ }
- return NULL;
- }
+ return NULL;
+ }
- end = list + length;
+ end = list + length;
- while (list < end) {
- length = strnlen(list, end - list) + 1;
+ while (list < end) {
+ length = strnlen (list, end - list) + 1;
- /* Abort if the last string isn't properly NUL-terminated. */
- if (list + length > end) {
- if (lenp)
- *lenp = -FDT_ERR_BADVALUE;
+ /* Abort if the last string isn't properly NUL-terminated. */
+ if (list + length > end) {
+ if (lenp) {
+ *lenp = -FDT_ERR_BADVALUE;
+ }
- return NULL;
- }
+ return NULL;
+ }
- if (idx == 0) {
- if (lenp)
- *lenp = length - 1;
+ if (idx == 0) {
+ if (lenp) {
+ *lenp = length - 1;
+ }
- return list;
- }
+ return list;
+ }
- list += length;
- idx--;
- }
+ list += length;
+ idx--;
+ }
- if (lenp)
- *lenp = -FDT_ERR_NOTFOUND;
+ if (lenp) {
+ *lenp = -FDT_ERR_NOTFOUND;
+ }
- return NULL;
+ return NULL;
}
-int fdt_node_check_compatible(const void *fdt, int nodeoffset,
- const char *compatible)
+int
+fdt_node_check_compatible (
+ const void *fdt,
+ int nodeoffset,
+ const char *compatible
+ )
{
- const void *prop;
- int len;
+ const void *prop;
+ int len;
+
+ prop = fdt_getprop (fdt, nodeoffset, "compatible", &len);
+ if (!prop) {
+ return len;
+ }
- prop = fdt_getprop(fdt, nodeoffset, "compatible", &len);
- if (!prop)
- return len;
-
- return !fdt_stringlist_contains(prop, len, compatible);
+ return !fdt_stringlist_contains (prop, len, compatible);
}
-int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
- const char *compatible)
+int
+fdt_node_offset_by_compatible (
+ const void *fdt,
+ int startoffset,
+ const char *compatible
+ )
{
- int offset, err;
-
- FDT_CHECK_HEADER(fdt);
+ int offset, err;
- /* FIXME: The algorithm here is pretty horrible: we scan each
- * property of a node in fdt_node_check_compatible(), then if
- * that didn't find what we want, we scan over them again
- * making our way to the next node. Still it's the easiest to
- * implement approach; performance can come later. */
- for (offset = fdt_next_node(fdt, startoffset, NULL);
- offset >= 0;
- offset = fdt_next_node(fdt, offset, NULL)) {
- err = fdt_node_check_compatible(fdt, offset, compatible);
- if ((err < 0) && (err != -FDT_ERR_NOTFOUND))
- return err;
- else if (err == 0)
- return offset;
- }
+ FDT_CHECK_HEADER (fdt);
- return offset; /* error from fdt_next_node() */
+ /* FIXME: The algorithm here is pretty horrible: we scan each
+ * property of a node in fdt_node_check_compatible(), then if
+ * that didn't find what we want, we scan over them again
+ * making our way to the next node. Still it's the easiest to
+ * implement approach; performance can come later. */
+ for (offset = fdt_next_node (fdt, startoffset, NULL);
+ offset >= 0;
+ offset = fdt_next_node (fdt, offset, NULL))
+ {
+ err = fdt_node_check_compatible (fdt, offset, compatible);
+ if ((err < 0) && (err != -FDT_ERR_NOTFOUND)) {
+ return err;
+ } else if (err == 0) {
+ return offset;
+ }
+ }
+
+ return offset; /* error from fdt_next_node() */
}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_rw.c b/EmbeddedPkg/Library/FdtLib/fdt_rw.c
index 863f2b2e0f..cb5088a3af 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_rw.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_rw.c
@@ -55,451 +55,632 @@
#include "libfdt_internal.h"
-static int _fdt_blocks_misordered(const void *fdt,
- int mem_rsv_size, int struct_size)
+static int
+_fdt_blocks_misordered (
+ const void *fdt,
+ int mem_rsv_size,
+ int struct_size
+ )
{
- return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8))
- || (fdt_off_dt_struct(fdt) <
- (fdt_off_mem_rsvmap(fdt) + mem_rsv_size))
- || (fdt_off_dt_strings(fdt) <
- (fdt_off_dt_struct(fdt) + struct_size))
- || (fdt_totalsize(fdt) <
- (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));
+ return (fdt_off_mem_rsvmap (fdt) < FDT_ALIGN (sizeof (struct fdt_header), 8))
+ || (fdt_off_dt_struct (fdt) <
+ (fdt_off_mem_rsvmap (fdt) + mem_rsv_size))
+ || (fdt_off_dt_strings (fdt) <
+ (fdt_off_dt_struct (fdt) + struct_size))
+ || (fdt_totalsize (fdt) <
+ (fdt_off_dt_strings (fdt) + fdt_size_dt_strings (fdt)));
}
-static int _fdt_rw_check_header(void *fdt)
+static int
+_fdt_rw_check_header (
+ void *fdt
+ )
{
- FDT_CHECK_HEADER(fdt);
-
- if (fdt_version(fdt) < 17)
- return -FDT_ERR_BADVERSION;
- if (_fdt_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry),
- fdt_size_dt_struct(fdt)))
- return -FDT_ERR_BADLAYOUT;
- if (fdt_version(fdt) > 17)
- fdt_set_version(fdt, 17);
-
- return 0;
+ FDT_CHECK_HEADER (fdt);
+
+ if (fdt_version (fdt) < 17) {
+ return -FDT_ERR_BADVERSION;
+ }
+
+ if (_fdt_blocks_misordered (
+ fdt,
+ sizeof (struct fdt_reserve_entry),
+ fdt_size_dt_struct (fdt)
+ ))
+ {
+ return -FDT_ERR_BADLAYOUT;
+ }
+
+ if (fdt_version (fdt) > 17) {
+ fdt_set_version (fdt, 17);
+ }
+
+ return 0;
}
#define FDT_RW_CHECK_HEADER(fdt) \
- { \
- int __err; \
- if ((__err = _fdt_rw_check_header(fdt)) != 0) \
- return __err; \
- }
-
-static inline int _fdt_data_size(void *fdt)
+ { \
+ int __err; \
+ if ((__err = _fdt_rw_check_header(fdt)) != 0) \
+ return __err; \
+ }
+
+static inline int
+_fdt_data_size (
+ void *fdt
+ )
{
- return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
+ return fdt_off_dt_strings (fdt) + fdt_size_dt_strings (fdt);
}
-static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
+static int
+_fdt_splice (
+ void *fdt,
+ void *splicepoint,
+ int oldlen,
+ int newlen
+ )
{
- char *p = splicepoint;
- char *end = (char *)fdt + _fdt_data_size(fdt);
-
- if (((p + oldlen) < p) || ((p + oldlen) > end))
- return -FDT_ERR_BADOFFSET;
- if ((p < (char *)fdt) || ((end - oldlen + newlen) < (char *)fdt))
- return -FDT_ERR_BADOFFSET;
- if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize(fdt)))
- return -FDT_ERR_NOSPACE;
- memmove(p + newlen, p + oldlen, end - p - oldlen);
- return 0;
-}
+ char *p = splicepoint;
+ char *end = (char *)fdt + _fdt_data_size (fdt);
-static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
- int oldn, int newn)
-{
- int delta = (newn - oldn) * sizeof(*p);
- int err;
- err = _fdt_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
- if (err)
- return err;
- fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta);
- fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
- return 0;
-}
+ if (((p + oldlen) < p) || ((p + oldlen) > end)) {
+ return -FDT_ERR_BADOFFSET;
+ }
-static int _fdt_splice_struct(void *fdt, void *p,
- int oldlen, int newlen)
-{
- int delta = newlen - oldlen;
- int err;
+ if ((p < (char *)fdt) || ((end - oldlen + newlen) < (char *)fdt)) {
+ return -FDT_ERR_BADOFFSET;
+ }
- if ((err = _fdt_splice(fdt, p, oldlen, newlen)))
- return err;
+ if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize (fdt))) {
+ return -FDT_ERR_NOSPACE;
+ }
- fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);
- fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
- return 0;
+ memmove (p + newlen, p + oldlen, end - p - oldlen);
+ return 0;
}
-static int _fdt_splice_string(void *fdt, int newlen)
+static int
+_fdt_splice_mem_rsv (
+ void *fdt,
+ struct fdt_reserve_entry *p,
+ int oldn,
+ int newn
+ )
{
- void *p = (char *)fdt
- + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
- int err;
+ int delta = (newn - oldn) * sizeof (*p);
+ int err;
- if ((err = _fdt_splice(fdt, p, 0, newlen)))
- return err;
+ err = _fdt_splice (fdt, p, oldn * sizeof (*p), newn * sizeof (*p));
+ if (err) {
+ return err;
+ }
- fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);
- return 0;
+ fdt_set_off_dt_struct (fdt, fdt_off_dt_struct (fdt) + delta);
+ fdt_set_off_dt_strings (fdt, fdt_off_dt_strings (fdt) + delta);
+ return 0;
}
-static int _fdt_find_add_string(void *fdt, const char *s)
+static int
+_fdt_splice_struct (
+ void *fdt,
+ void *p,
+ int oldlen,
+ int newlen
+ )
{
- char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
- const char *p;
- char *new;
- int len = strlen(s) + 1;
- int err;
-
- p = _fdt_find_string(strtab, fdt_size_dt_strings(fdt), s);
- if (p)
- /* found it */
- return (p - strtab);
-
- new = strtab + fdt_size_dt_strings(fdt);
- err = _fdt_splice_string(fdt, len);
- if (err)
- return err;
-
- memcpy(new, s, len);
- return (new - strtab);
-}
-
-int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
-{
- struct fdt_reserve_entry *re;
- int err;
-
- FDT_RW_CHECK_HEADER(fdt);
+ int delta = newlen - oldlen;
+ int err;
- re = _fdt_mem_rsv_w(fdt, fdt_num_mem_rsv(fdt));
- err = _fdt_splice_mem_rsv(fdt, re, 0, 1);
- if (err)
- return err;
+ if ((err = _fdt_splice (fdt, p, oldlen, newlen))) {
+ return err;
+ }
- re->address = cpu_to_fdt64(address);
- re->size = cpu_to_fdt64(size);
- return 0;
+ fdt_set_size_dt_struct (fdt, fdt_size_dt_struct (fdt) + delta);
+ fdt_set_off_dt_strings (fdt, fdt_off_dt_strings (fdt) + delta);
+ return 0;
}
-int fdt_del_mem_rsv(void *fdt, int n)
+static int
+_fdt_splice_string (
+ void *fdt,
+ int newlen
+ )
{
- struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
+ void *p = (char *)fdt
+ + fdt_off_dt_strings (fdt) + fdt_size_dt_strings (fdt);
+ int err;
- FDT_RW_CHECK_HEADER(fdt);
+ if ((err = _fdt_splice (fdt, p, 0, newlen))) {
+ return err;
+ }
- if (n >= fdt_num_mem_rsv(fdt))
- return -FDT_ERR_NOTFOUND;
+ fdt_set_size_dt_strings (fdt, fdt_size_dt_strings (fdt) + newlen);
+ return 0;
+}
- return _fdt_splice_mem_rsv(fdt, re, 1, 0);
+static int
+_fdt_find_add_string (
+ void *fdt,
+ const char *s
+ )
+{
+ char *strtab = (char *)fdt + fdt_off_dt_strings (fdt);
+ const char *p;
+ char *new;
+ int len = strlen (s) + 1;
+ int err;
+
+ p = _fdt_find_string (strtab, fdt_size_dt_strings (fdt), s);
+ if (p) {
+ /* found it */
+ return (p - strtab);
+ }
+
+ new = strtab + fdt_size_dt_strings (fdt);
+ err = _fdt_splice_string (fdt, len);
+ if (err) {
+ return err;
+ }
+
+ memcpy (new, s, len);
+ return (new - strtab);
}
-static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
- int len, struct fdt_property **prop)
+int
+fdt_add_mem_rsv (
+ void *fdt,
+ uint64_t address,
+ uint64_t size
+ )
{
- int oldlen;
- int err;
+ struct fdt_reserve_entry *re;
+ int err;
- *prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
- if (!*prop)
- return oldlen;
+ FDT_RW_CHECK_HEADER (fdt);
- if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
- FDT_TAGALIGN(len))))
- return err;
+ re = _fdt_mem_rsv_w (fdt, fdt_num_mem_rsv (fdt));
+ err = _fdt_splice_mem_rsv (fdt, re, 0, 1);
+ if (err) {
+ return err;
+ }
- (*prop)->len = cpu_to_fdt32(len);
- return 0;
+ re->address = cpu_to_fdt64 (address);
+ re->size = cpu_to_fdt64 (size);
+ return 0;
}
-static int _fdt_add_property(void *fdt, int nodeoffset, const char *name,
- int len, struct fdt_property **prop)
+int
+fdt_del_mem_rsv (
+ void *fdt,
+ int n
+ )
{
- int proplen;
- int nextoffset;
- int namestroff;
- int err;
-
- if ((nextoffset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
- return nextoffset;
+ struct fdt_reserve_entry *re = _fdt_mem_rsv_w (fdt, n);
- namestroff = _fdt_find_add_string(fdt, name);
- if (namestroff < 0)
- return namestroff;
+ FDT_RW_CHECK_HEADER (fdt);
- *prop = _fdt_offset_ptr_w(fdt, nextoffset);
- proplen = sizeof(**prop) + FDT_TAGALIGN(len);
+ if (n >= fdt_num_mem_rsv (fdt)) {
+ return -FDT_ERR_NOTFOUND;
+ }
- err = _fdt_splice_struct(fdt, *prop, 0, proplen);
- if (err)
- return err;
-
- (*prop)->tag = cpu_to_fdt32(FDT_PROP);
- (*prop)->nameoff = cpu_to_fdt32(namestroff);
- (*prop)->len = cpu_to_fdt32(len);
- return 0;
+ return _fdt_splice_mem_rsv (fdt, re, 1, 0);
}
-int fdt_set_name(void *fdt, int nodeoffset, const char *name)
+static int
+_fdt_resize_property (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int len,
+ struct fdt_property **prop
+ )
{
- char *namep;
- int oldlen, newlen;
- int err;
-
- FDT_RW_CHECK_HEADER(fdt);
-
- namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);
- if (!namep)
- return oldlen;
-
- newlen = strlen(name);
+ int oldlen;
+ int err;
+
+ *prop = fdt_get_property_w (fdt, nodeoffset, name, &oldlen);
+ if (!*prop) {
+ return oldlen;
+ }
+
+ if ((err = _fdt_splice_struct (
+ fdt,
+ (*prop)->data,
+ FDT_TAGALIGN (oldlen),
+ FDT_TAGALIGN (len)
+ )))
+ {
+ return err;
+ }
+
+ (*prop)->len = cpu_to_fdt32 (len);
+ return 0;
+}
- err = _fdt_splice_struct(fdt, namep, FDT_TAGALIGN(oldlen+1),
- FDT_TAGALIGN(newlen+1));
- if (err)
- return err;
+static int
+_fdt_add_property (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int len,
+ struct fdt_property **prop
+ )
+{
+ int proplen;
+ int nextoffset;
+ int namestroff;
+ int err;
+
+ if ((nextoffset = _fdt_check_node_offset (fdt, nodeoffset)) < 0) {
+ return nextoffset;
+ }
+
+ namestroff = _fdt_find_add_string (fdt, name);
+ if (namestroff < 0) {
+ return namestroff;
+ }
+
+ *prop = _fdt_offset_ptr_w (fdt, nextoffset);
+ proplen = sizeof (**prop) + FDT_TAGALIGN (len);
+
+ err = _fdt_splice_struct (fdt, *prop, 0, proplen);
+ if (err) {
+ return err;
+ }
+
+ (*prop)->tag = cpu_to_fdt32 (FDT_PROP);
+ (*prop)->nameoff = cpu_to_fdt32 (namestroff);
+ (*prop)->len = cpu_to_fdt32 (len);
+ return 0;
+}
- memcpy(namep, name, newlen+1);
- return 0;
+int
+fdt_set_name (
+ void *fdt,
+ int nodeoffset,
+ const char *name
+ )
+{
+ char *namep;
+ int oldlen, newlen;
+ int err;
+
+ FDT_RW_CHECK_HEADER (fdt);
+
+ namep = (char *)(uintptr_t)fdt_get_name (fdt, nodeoffset, &oldlen);
+ if (!namep) {
+ return oldlen;
+ }
+
+ newlen = strlen (name);
+
+ err = _fdt_splice_struct (
+ fdt,
+ namep,
+ FDT_TAGALIGN (oldlen+1),
+ FDT_TAGALIGN (newlen+1)
+ );
+ if (err) {
+ return err;
+ }
+
+ memcpy (namep, name, newlen+1);
+ return 0;
}
-int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
- int len, void **prop_data)
+int
+fdt_setprop_placeholder (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int len,
+ void **prop_data
+ )
{
- struct fdt_property *prop;
- int err;
+ struct fdt_property *prop;
+ int err;
+
+ FDT_RW_CHECK_HEADER (fdt);
- FDT_RW_CHECK_HEADER(fdt);
+ err = _fdt_resize_property (fdt, nodeoffset, name, len, &prop);
+ if (err == -FDT_ERR_NOTFOUND) {
+ err = _fdt_add_property (fdt, nodeoffset, name, len, &prop);
+ }
- err = _fdt_resize_property(fdt, nodeoffset, name, len, &prop);
- if (err == -FDT_ERR_NOTFOUND)
- err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
- if (err)
- return err;
+ if (err) {
+ return err;
+ }
- *prop_data = prop->data;
- return 0;
+ *prop_data = prop->data;
+ return 0;
}
-int fdt_setprop(void *fdt, int nodeoffset, const char *name,
- const void *val, int len)
+int
+fdt_setprop (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ const void *val,
+ int len
+ )
{
- void *prop_data;
- int err;
+ void *prop_data;
+ int err;
- err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);
- if (err)
- return err;
+ err = fdt_setprop_placeholder (fdt, nodeoffset, name, len, &prop_data);
+ if (err) {
+ return err;
+ }
- if (len)
- memcpy(prop_data, val, len);
- return 0;
+ if (len) {
+ memcpy (prop_data, val, len);
+ }
+
+ return 0;
}
-int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
- const void *val, int len)
+int
+fdt_appendprop (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ const void *val,
+ int len
+ )
{
- struct fdt_property *prop;
- int err, oldlen, newlen;
-
- FDT_RW_CHECK_HEADER(fdt);
-
- prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
- if (prop) {
- newlen = len + oldlen;
- err = _fdt_splice_struct(fdt, prop->data,
- FDT_TAGALIGN(oldlen),
- FDT_TAGALIGN(newlen));
- if (err)
- return err;
- prop->len = cpu_to_fdt32(newlen);
- memcpy(prop->data + oldlen, val, len);
- } else {
- err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
- if (err)
- return err;
- memcpy(prop->data, val, len);
- }
- return 0;
+ struct fdt_property *prop;
+ int err, oldlen, newlen;
+
+ FDT_RW_CHECK_HEADER (fdt);
+
+ prop = fdt_get_property_w (fdt, nodeoffset, name, &oldlen);
+ if (prop) {
+ newlen = len + oldlen;
+ err = _fdt_splice_struct (
+ fdt,
+ prop->data,
+ FDT_TAGALIGN (oldlen),
+ FDT_TAGALIGN (newlen)
+ );
+ if (err) {
+ return err;
+ }
+
+ prop->len = cpu_to_fdt32 (newlen);
+ memcpy (prop->data + oldlen, val, len);
+ } else {
+ err = _fdt_add_property (fdt, nodeoffset, name, len, &prop);
+ if (err) {
+ return err;
+ }
+
+ memcpy (prop->data, val, len);
+ }
+
+ return 0;
}
-int fdt_delprop(void *fdt, int nodeoffset, const char *name)
+int
+fdt_delprop (
+ void *fdt,
+ int nodeoffset,
+ const char *name
+ )
{
- struct fdt_property *prop;
- int len, proplen;
+ struct fdt_property *prop;
+ int len, proplen;
- FDT_RW_CHECK_HEADER(fdt);
+ FDT_RW_CHECK_HEADER (fdt);
- prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
- if (!prop)
- return len;
+ prop = fdt_get_property_w (fdt, nodeoffset, name, &len);
+ if (!prop) {
+ return len;
+ }
- proplen = sizeof(*prop) + FDT_TAGALIGN(len);
- return _fdt_splice_struct(fdt, prop, proplen, 0);
+ proplen = sizeof (*prop) + FDT_TAGALIGN (len);
+ return _fdt_splice_struct (fdt, prop, proplen, 0);
}
-int fdt_add_subnode_namelen(void *fdt, int parentoffset,
- const char *name, int namelen)
+int
+fdt_add_subnode_namelen (
+ void *fdt,
+ int parentoffset,
+ const char *name,
+ int namelen
+ )
{
- struct fdt_node_header *nh;
- int offset, nextoffset;
- int nodelen;
- int err;
- uint32_t tag;
- fdt32_t *endtag;
-
- FDT_RW_CHECK_HEADER(fdt);
-
- offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen);
- if (offset >= 0)
- return -FDT_ERR_EXISTS;
- else if (offset != -FDT_ERR_NOTFOUND)
- return offset;
-
- /* Try to place the new node after the parent's properties */
- fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
- do {
- offset = nextoffset;
- tag = fdt_next_tag(fdt, offset, &nextoffset);
- } while ((tag == FDT_PROP) || (tag == FDT_NOP));
-
- nh = _fdt_offset_ptr_w(fdt, offset);
- nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE;
-
- err = _fdt_splice_struct(fdt, nh, 0, nodelen);
- if (err)
- return err;
-
- nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
- memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
- memcpy(nh->name, name, namelen);
- endtag = (fdt32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
- *endtag = cpu_to_fdt32(FDT_END_NODE);
-
- return offset;
+ struct fdt_node_header *nh;
+ int offset, nextoffset;
+ int nodelen;
+ int err;
+ uint32_t tag;
+ fdt32_t *endtag;
+
+ FDT_RW_CHECK_HEADER (fdt);
+
+ offset = fdt_subnode_offset_namelen (fdt, parentoffset, name, namelen);
+ if (offset >= 0) {
+ return -FDT_ERR_EXISTS;
+ } else if (offset != -FDT_ERR_NOTFOUND) {
+ return offset;
+ }
+
+ /* Try to place the new node after the parent's properties */
+ fdt_next_tag (fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
+ do {
+ offset = nextoffset;
+ tag = fdt_next_tag (fdt, offset, &nextoffset);
+ } while ((tag == FDT_PROP) || (tag == FDT_NOP));
+
+ nh = _fdt_offset_ptr_w (fdt, offset);
+ nodelen = sizeof (*nh) + FDT_TAGALIGN (namelen+1) + FDT_TAGSIZE;
+
+ err = _fdt_splice_struct (fdt, nh, 0, nodelen);
+ if (err) {
+ return err;
+ }
+
+ nh->tag = cpu_to_fdt32 (FDT_BEGIN_NODE);
+ memset (nh->name, 0, FDT_TAGALIGN (namelen+1));
+ memcpy (nh->name, name, namelen);
+ endtag = (fdt32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
+ *endtag = cpu_to_fdt32 (FDT_END_NODE);
+
+ return offset;
}
-int fdt_add_subnode(void *fdt, int parentoffset, const char *name)
+int
+fdt_add_subnode (
+ void *fdt,
+ int parentoffset,
+ const char *name
+ )
{
- return fdt_add_subnode_namelen(fdt, parentoffset, name, strlen(name));
+ return fdt_add_subnode_namelen (fdt, parentoffset, name, strlen (name));
}
-int fdt_del_node(void *fdt, int nodeoffset)
+int
+fdt_del_node (
+ void *fdt,
+ int nodeoffset
+ )
{
- int endoffset;
+ int endoffset;
- FDT_RW_CHECK_HEADER(fdt);
+ FDT_RW_CHECK_HEADER (fdt);
- endoffset = _fdt_node_end_offset(fdt, nodeoffset);
- if (endoffset < 0)
- return endoffset;
+ endoffset = _fdt_node_end_offset (fdt, nodeoffset);
+ if (endoffset < 0) {
+ return endoffset;
+ }
- return _fdt_splice_struct(fdt, _fdt_offset_ptr_w(fdt, nodeoffset),
- endoffset - nodeoffset, 0);
+ return _fdt_splice_struct (
+ fdt,
+ _fdt_offset_ptr_w (fdt, nodeoffset),
+ endoffset - nodeoffset,
+ 0
+ );
}
-static void _fdt_packblocks(const char *old, char *new,
- int mem_rsv_size, int struct_size)
+static void
+_fdt_packblocks (
+ const char *old,
+ char *new,
+ int mem_rsv_size,
+ int struct_size
+ )
{
- int mem_rsv_off, struct_off, strings_off;
-
- mem_rsv_off = FDT_ALIGN(sizeof(struct fdt_header), 8);
- struct_off = mem_rsv_off + mem_rsv_size;
- strings_off = struct_off + struct_size;
-
- memmove(new + mem_rsv_off, old + fdt_off_mem_rsvmap(old), mem_rsv_size);
- fdt_set_off_mem_rsvmap(new, mem_rsv_off);
-
- memmove(new + struct_off, old + fdt_off_dt_struct(old), struct_size);
- fdt_set_off_dt_struct(new, struct_off);
- fdt_set_size_dt_struct(new, struct_size);
-
- memmove(new + strings_off, old + fdt_off_dt_strings(old),
- fdt_size_dt_strings(old));
- fdt_set_off_dt_strings(new, strings_off);
- fdt_set_size_dt_strings(new, fdt_size_dt_strings(old));
+ int mem_rsv_off, struct_off, strings_off;
+
+ mem_rsv_off = FDT_ALIGN (sizeof (struct fdt_header), 8);
+ struct_off = mem_rsv_off + mem_rsv_size;
+ strings_off = struct_off + struct_size;
+
+ memmove (new + mem_rsv_off, old + fdt_off_mem_rsvmap (old), mem_rsv_size);
+ fdt_set_off_mem_rsvmap (new, mem_rsv_off);
+
+ memmove (new + struct_off, old + fdt_off_dt_struct (old), struct_size);
+ fdt_set_off_dt_struct (new, struct_off);
+ fdt_set_size_dt_struct (new, struct_size);
+
+ memmove (
+ new + strings_off,
+ old + fdt_off_dt_strings (old),
+ fdt_size_dt_strings (old)
+ );
+ fdt_set_off_dt_strings (new, strings_off);
+ fdt_set_size_dt_strings (new, fdt_size_dt_strings (old));
}
-int fdt_open_into(const void *fdt, void *buf, int bufsize)
+int
+fdt_open_into (
+ const void *fdt,
+ void *buf,
+ int bufsize
+ )
{
- int err;
- int mem_rsv_size, struct_size;
- int newsize;
- const char *fdtstart = fdt;
- const char *fdtend = fdtstart + fdt_totalsize(fdt);
- char *tmp;
-
- FDT_CHECK_HEADER(fdt);
-
- mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
- * sizeof(struct fdt_reserve_entry);
-
- if (fdt_version(fdt) >= 17) {
- struct_size = fdt_size_dt_struct(fdt);
- } else {
- struct_size = 0;
- while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END)
- ;
- if (struct_size < 0)
- return struct_size;
- }
-
- if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) {
- /* no further work necessary */
- err = fdt_move(fdt, buf, bufsize);
- if (err)
- return err;
- fdt_set_version(buf, 17);
- fdt_set_size_dt_struct(buf, struct_size);
- fdt_set_totalsize(buf, bufsize);
- return 0;
- }
-
- /* Need to reorder */
- newsize = FDT_ALIGN(sizeof(struct fdt_header), 8) + mem_rsv_size
- + struct_size + fdt_size_dt_strings(fdt);
-
- if (bufsize < newsize)
- return -FDT_ERR_NOSPACE;
-
- /* First attempt to build converted tree at beginning of buffer */
- tmp = buf;
- /* But if that overlaps with the old tree... */
- if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
- /* Try right after the old tree instead */
- tmp = (char *)(uintptr_t)fdtend;
- if ((tmp + newsize) > ((char *)buf + bufsize))
- return -FDT_ERR_NOSPACE;
- }
-
- _fdt_packblocks(fdt, tmp, mem_rsv_size, struct_size);
- memmove(buf, tmp, newsize);
-
- fdt_set_magic(buf, FDT_MAGIC);
- fdt_set_totalsize(buf, bufsize);
- fdt_set_version(buf, 17);
- fdt_set_last_comp_version(buf, 16);
- fdt_set_boot_cpuid_phys(buf, fdt_boot_cpuid_phys(fdt));
-
- return 0;
+ int err;
+ int mem_rsv_size, struct_size;
+ int newsize;
+ const char *fdtstart = fdt;
+ const char *fdtend = fdtstart + fdt_totalsize (fdt);
+ char *tmp;
+
+ FDT_CHECK_HEADER (fdt);
+
+ mem_rsv_size = (fdt_num_mem_rsv (fdt)+1)
+ * sizeof (struct fdt_reserve_entry);
+
+ if (fdt_version (fdt) >= 17) {
+ struct_size = fdt_size_dt_struct (fdt);
+ } else {
+ struct_size = 0;
+ while (fdt_next_tag (fdt, struct_size, &struct_size) != FDT_END) {
+ }
+
+ if (struct_size < 0) {
+ return struct_size;
+ }
+ }
+
+ if (!_fdt_blocks_misordered (fdt, mem_rsv_size, struct_size)) {
+ /* no further work necessary */
+ err = fdt_move (fdt, buf, bufsize);
+ if (err) {
+ return err;
+ }
+
+ fdt_set_version (buf, 17);
+ fdt_set_size_dt_struct (buf, struct_size);
+ fdt_set_totalsize (buf, bufsize);
+ return 0;
+ }
+
+ /* Need to reorder */
+ newsize = FDT_ALIGN (sizeof (struct fdt_header), 8) + mem_rsv_size
+ + struct_size + fdt_size_dt_strings (fdt);
+
+ if (bufsize < newsize) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ /* First attempt to build converted tree at beginning of buffer */
+ tmp = buf;
+ /* But if that overlaps with the old tree... */
+ if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
+ /* Try right after the old tree instead */
+ tmp = (char *)(uintptr_t)fdtend;
+ if ((tmp + newsize) > ((char *)buf + bufsize)) {
+ return -FDT_ERR_NOSPACE;
+ }
+ }
+
+ _fdt_packblocks (fdt, tmp, mem_rsv_size, struct_size);
+ memmove (buf, tmp, newsize);
+
+ fdt_set_magic (buf, FDT_MAGIC);
+ fdt_set_totalsize (buf, bufsize);
+ fdt_set_version (buf, 17);
+ fdt_set_last_comp_version (buf, 16);
+ fdt_set_boot_cpuid_phys (buf, fdt_boot_cpuid_phys (fdt));
+
+ return 0;
}
-int fdt_pack(void *fdt)
+int
+fdt_pack (
+ void *fdt
+ )
{
- int mem_rsv_size;
+ int mem_rsv_size;
- FDT_RW_CHECK_HEADER(fdt);
+ FDT_RW_CHECK_HEADER (fdt);
- mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
- * sizeof(struct fdt_reserve_entry);
- _fdt_packblocks(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
- fdt_set_totalsize(fdt, _fdt_data_size(fdt));
+ mem_rsv_size = (fdt_num_mem_rsv (fdt)+1)
+ * sizeof (struct fdt_reserve_entry);
+ _fdt_packblocks (fdt, fdt, mem_rsv_size, fdt_size_dt_struct (fdt));
+ fdt_set_totalsize (fdt, _fdt_data_size (fdt));
- return 0;
+ return 0;
}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_strerror.c b/EmbeddedPkg/Library/FdtLib/fdt_strerror.c
index 3041e2ecfb..cb07f6166e 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_strerror.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_strerror.c
@@ -56,47 +56,51 @@
#include "libfdt_internal.h"
struct fdt_errtabent {
- const char *str;
+ const char *str;
};
#define FDT_ERRTABENT(val) \
- [(val)] = { .str = #val, }
+ [(val)] = { .str = #val, }
-static struct fdt_errtabent fdt_errtable[] = {
- FDT_ERRTABENT(FDT_ERR_NOTFOUND),
- FDT_ERRTABENT(FDT_ERR_EXISTS),
- FDT_ERRTABENT(FDT_ERR_NOSPACE),
+static struct fdt_errtabent fdt_errtable[] = {
+ FDT_ERRTABENT (FDT_ERR_NOTFOUND),
+ FDT_ERRTABENT (FDT_ERR_EXISTS),
+ FDT_ERRTABENT (FDT_ERR_NOSPACE),
- FDT_ERRTABENT(FDT_ERR_BADOFFSET),
- FDT_ERRTABENT(FDT_ERR_BADPATH),
- FDT_ERRTABENT(FDT_ERR_BADPHANDLE),
- FDT_ERRTABENT(FDT_ERR_BADSTATE),
+ FDT_ERRTABENT (FDT_ERR_BADOFFSET),
+ FDT_ERRTABENT (FDT_ERR_BADPATH),
+ FDT_ERRTABENT (FDT_ERR_BADPHANDLE),
+ FDT_ERRTABENT (FDT_ERR_BADSTATE),
- FDT_ERRTABENT(FDT_ERR_TRUNCATED),
- FDT_ERRTABENT(FDT_ERR_BADMAGIC),
- FDT_ERRTABENT(FDT_ERR_BADVERSION),
- FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),
- FDT_ERRTABENT(FDT_ERR_BADLAYOUT),
- FDT_ERRTABENT(FDT_ERR_INTERNAL),
- FDT_ERRTABENT(FDT_ERR_BADNCELLS),
- FDT_ERRTABENT(FDT_ERR_BADVALUE),
- FDT_ERRTABENT(FDT_ERR_BADOVERLAY),
- FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
+ FDT_ERRTABENT (FDT_ERR_TRUNCATED),
+ FDT_ERRTABENT (FDT_ERR_BADMAGIC),
+ FDT_ERRTABENT (FDT_ERR_BADVERSION),
+ FDT_ERRTABENT (FDT_ERR_BADSTRUCTURE),
+ FDT_ERRTABENT (FDT_ERR_BADLAYOUT),
+ FDT_ERRTABENT (FDT_ERR_INTERNAL),
+ FDT_ERRTABENT (FDT_ERR_BADNCELLS),
+ FDT_ERRTABENT (FDT_ERR_BADVALUE),
+ FDT_ERRTABENT (FDT_ERR_BADOVERLAY),
+ FDT_ERRTABENT (FDT_ERR_NOPHANDLES),
};
-#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
+#define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
-const char *fdt_strerror(int errval)
+const char *
+fdt_strerror (
+ int errval
+ )
{
- if (errval > 0)
- return "<valid offset/length>";
- else if (errval == 0)
- return "<no error>";
- else if (errval > -FDT_ERRTABSIZE) {
- const char *s = fdt_errtable[-errval].str;
+ if (errval > 0) {
+ return "<valid offset/length>";
+ } else if (errval == 0) {
+ return "<no error>";
+ } else if (errval > -FDT_ERRTABSIZE) {
+ const char *s = fdt_errtable[-errval].str;
- if (s)
- return s;
- }
+ if (s) {
+ return s;
+ }
+ }
- return "<unknown error>";
+ return "<unknown error>";
}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_strtoul.c b/EmbeddedPkg/Library/FdtLib/fdt_strtoul.c
index 3e60c27757..e615d6f4c0 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_strtoul.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_strtoul.c
@@ -9,24 +9,29 @@
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
-unsigned long strtoul(const char *nptr, char **endptr, int base)
+unsigned long
+strtoul (
+ const char *nptr,
+ char **endptr,
+ int base
+ )
{
- RETURN_STATUS Status;
- UINTN ReturnValue;
+ RETURN_STATUS Status;
+ UINTN ReturnValue;
- ASSERT (base == 10 || base == 16);
+ ASSERT (base == 10 || base == 16);
- if (base == 10) {
- Status = AsciiStrDecimalToUintnS (nptr, endptr, &ReturnValue);
- } else if (base == 16) {
- Status = AsciiStrHexToUintnS (nptr, endptr, &ReturnValue);
- } else {
- Status = RETURN_INVALID_PARAMETER;
- }
+ if (base == 10) {
+ Status = AsciiStrDecimalToUintnS (nptr, endptr, &ReturnValue);
+ } else if (base == 16) {
+ Status = AsciiStrHexToUintnS (nptr, endptr, &ReturnValue);
+ } else {
+ Status = RETURN_INVALID_PARAMETER;
+ }
- if (RETURN_ERROR (Status)) {
- return MAX_UINTN;
- }
+ if (RETURN_ERROR (Status)) {
+ return MAX_UINTN;
+ }
- return ReturnValue;
+ return ReturnValue;
}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_sw.c b/EmbeddedPkg/Library/FdtLib/fdt_sw.c
index 3c2c710186..6bcdd1fc7b 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_sw.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_sw.c
@@ -55,246 +55,321 @@
#include "libfdt_internal.h"
-static int _fdt_sw_check_header(void *fdt)
+static int
+_fdt_sw_check_header (
+ void *fdt
+ )
{
- if (fdt_magic(fdt) != FDT_SW_MAGIC)
- return -FDT_ERR_BADMAGIC;
- /* FIXME: should check more details about the header state */
- return 0;
+ if (fdt_magic (fdt) != FDT_SW_MAGIC) {
+ return -FDT_ERR_BADMAGIC;
+ }
+
+ /* FIXME: should check more details about the header state */
+ return 0;
}
#define FDT_SW_CHECK_HEADER(fdt) \
- { \
- int err; \
- if ((err = _fdt_sw_check_header(fdt)) != 0) \
- return err; \
- }
-
-static void *_fdt_grab_space(void *fdt, size_t len)
+ { \
+ int err; \
+ if ((err = _fdt_sw_check_header(fdt)) != 0) \
+ return err; \
+ }
+
+static void *
+_fdt_grab_space (
+ void *fdt,
+ size_t len
+ )
{
- int offset = fdt_size_dt_struct(fdt);
- int spaceleft;
+ int offset = fdt_size_dt_struct (fdt);
+ int spaceleft;
- spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt)
- - fdt_size_dt_strings(fdt);
+ spaceleft = fdt_totalsize (fdt) - fdt_off_dt_struct (fdt)
+ - fdt_size_dt_strings (fdt);
- if ((offset + len < offset) || (offset + len > spaceleft))
- return NULL;
+ if ((offset + len < offset) || (offset + len > spaceleft)) {
+ return NULL;
+ }
- fdt_set_size_dt_struct(fdt, offset + len);
- return _fdt_offset_ptr_w(fdt, offset);
+ fdt_set_size_dt_struct (fdt, offset + len);
+ return _fdt_offset_ptr_w (fdt, offset);
}
-int fdt_create(void *buf, int bufsize)
+int
+fdt_create (
+ void *buf,
+ int bufsize
+ )
{
- void *fdt = buf;
-
- if (bufsize < sizeof(struct fdt_header))
- return -FDT_ERR_NOSPACE;
-
- memset(buf, 0, bufsize);
-
- fdt_set_magic(fdt, FDT_SW_MAGIC);
- fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION);
- fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
- fdt_set_totalsize(fdt, bufsize);
-
- fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header),
- sizeof(struct fdt_reserve_entry)));
- fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt));
- fdt_set_off_dt_strings(fdt, bufsize);
-
- return 0;
+ void *fdt = buf;
+
+ if (bufsize < sizeof (struct fdt_header)) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ memset (buf, 0, bufsize);
+
+ fdt_set_magic (fdt, FDT_SW_MAGIC);
+ fdt_set_version (fdt, FDT_LAST_SUPPORTED_VERSION);
+ fdt_set_last_comp_version (fdt, FDT_FIRST_SUPPORTED_VERSION);
+ fdt_set_totalsize (fdt, bufsize);
+
+ fdt_set_off_mem_rsvmap (
+ fdt,
+ FDT_ALIGN (
+ sizeof (struct fdt_header),
+ sizeof (struct fdt_reserve_entry)
+ )
+ );
+ fdt_set_off_dt_struct (fdt, fdt_off_mem_rsvmap (fdt));
+ fdt_set_off_dt_strings (fdt, bufsize);
+
+ return 0;
}
-int fdt_resize(void *fdt, void *buf, int bufsize)
+int
+fdt_resize (
+ void *fdt,
+ void *buf,
+ int bufsize
+ )
{
- size_t headsize, tailsize;
- char *oldtail, *newtail;
+ size_t headsize, tailsize;
+ char *oldtail, *newtail;
- FDT_SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER (fdt);
- headsize = fdt_off_dt_struct(fdt);
- tailsize = fdt_size_dt_strings(fdt);
+ headsize = fdt_off_dt_struct (fdt);
+ tailsize = fdt_size_dt_strings (fdt);
- if ((headsize + tailsize) > bufsize)
- return -FDT_ERR_NOSPACE;
+ if ((headsize + tailsize) > bufsize) {
+ return -FDT_ERR_NOSPACE;
+ }
- oldtail = (char *)fdt + fdt_totalsize(fdt) - tailsize;
- newtail = (char *)buf + bufsize - tailsize;
+ oldtail = (char *)fdt + fdt_totalsize (fdt) - tailsize;
+ newtail = (char *)buf + bufsize - tailsize;
- /* Two cases to avoid clobbering data if the old and new
- * buffers partially overlap */
- if (buf <= fdt) {
- memmove(buf, fdt, headsize);
- memmove(newtail, oldtail, tailsize);
- } else {
- memmove(newtail, oldtail, tailsize);
- memmove(buf, fdt, headsize);
- }
+ /* Two cases to avoid clobbering data if the old and new
+ * buffers partially overlap */
+ if (buf <= fdt) {
+ memmove (buf, fdt, headsize);
+ memmove (newtail, oldtail, tailsize);
+ } else {
+ memmove (newtail, oldtail, tailsize);
+ memmove (buf, fdt, headsize);
+ }
- fdt_set_off_dt_strings(buf, bufsize);
- fdt_set_totalsize(buf, bufsize);
+ fdt_set_off_dt_strings (buf, bufsize);
+ fdt_set_totalsize (buf, bufsize);
- return 0;
+ return 0;
}
-int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
+int
+fdt_add_reservemap_entry (
+ void *fdt,
+ uint64_t addr,
+ uint64_t size
+ )
{
- struct fdt_reserve_entry *re;
- int offset;
+ struct fdt_reserve_entry *re;
+ int offset;
- FDT_SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER (fdt);
- if (fdt_size_dt_struct(fdt))
- return -FDT_ERR_BADSTATE;
+ if (fdt_size_dt_struct (fdt)) {
+ return -FDT_ERR_BADSTATE;
+ }
- offset = fdt_off_dt_struct(fdt);
- if ((offset + sizeof(*re)) > fdt_totalsize(fdt))
- return -FDT_ERR_NOSPACE;
+ offset = fdt_off_dt_struct (fdt);
+ if ((offset + sizeof (*re)) > fdt_totalsize (fdt)) {
+ return -FDT_ERR_NOSPACE;
+ }
- re = (struct fdt_reserve_entry *)((char *)fdt + offset);
- re->address = cpu_to_fdt64(addr);
- re->size = cpu_to_fdt64(size);
+ re = (struct fdt_reserve_entry *)((char *)fdt + offset);
+ re->address = cpu_to_fdt64 (addr);
+ re->size = cpu_to_fdt64 (size);
- fdt_set_off_dt_struct(fdt, offset + sizeof(*re));
+ fdt_set_off_dt_struct (fdt, offset + sizeof (*re));
- return 0;
+ return 0;
}
-int fdt_finish_reservemap(void *fdt)
+int
+fdt_finish_reservemap (
+ void *fdt
+ )
{
- return fdt_add_reservemap_entry(fdt, 0, 0);
+ return fdt_add_reservemap_entry (fdt, 0, 0);
}
-int fdt_begin_node(void *fdt, const char *name)
+int
+fdt_begin_node (
+ void *fdt,
+ const char *name
+ )
{
- struct fdt_node_header *nh;
- int namelen = strlen(name) + 1;
+ struct fdt_node_header *nh;
+ int namelen = strlen (name) + 1;
- FDT_SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER (fdt);
- nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
- if (! nh)
- return -FDT_ERR_NOSPACE;
+ nh = _fdt_grab_space (fdt, sizeof (*nh) + FDT_TAGALIGN (namelen));
+ if (!nh) {
+ return -FDT_ERR_NOSPACE;
+ }
- nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
- memcpy(nh->name, name, namelen);
- return 0;
+ nh->tag = cpu_to_fdt32 (FDT_BEGIN_NODE);
+ memcpy (nh->name, name, namelen);
+ return 0;
}
-int fdt_end_node(void *fdt)
+int
+fdt_end_node (
+ void *fdt
+ )
{
- fdt32_t *en;
+ fdt32_t *en;
- FDT_SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER (fdt);
- en = _fdt_grab_space(fdt, FDT_TAGSIZE);
- if (! en)
- return -FDT_ERR_NOSPACE;
+ en = _fdt_grab_space (fdt, FDT_TAGSIZE);
+ if (!en) {
+ return -FDT_ERR_NOSPACE;
+ }
- *en = cpu_to_fdt32(FDT_END_NODE);
- return 0;
+ *en = cpu_to_fdt32 (FDT_END_NODE);
+ return 0;
}
-static int _fdt_find_add_string(void *fdt, const char *s)
+static int
+_fdt_find_add_string (
+ void *fdt,
+ const char *s
+ )
{
- char *strtab = (char *)fdt + fdt_totalsize(fdt);
- const char *p;
- int strtabsize = fdt_size_dt_strings(fdt);
- int len = strlen(s) + 1;
- int struct_top, offset;
-
- p = _fdt_find_string(strtab - strtabsize, strtabsize, s);
- if (p)
- return p - strtab;
-
- /* Add it */
- offset = -strtabsize - len;
- struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
- if (fdt_totalsize(fdt) + offset < struct_top)
- return 0; /* no more room :( */
-
- memcpy(strtab + offset, s, len);
- fdt_set_size_dt_strings(fdt, strtabsize + len);
- return offset;
+ char *strtab = (char *)fdt + fdt_totalsize (fdt);
+ const char *p;
+ int strtabsize = fdt_size_dt_strings (fdt);
+ int len = strlen (s) + 1;
+ int struct_top, offset;
+
+ p = _fdt_find_string (strtab - strtabsize, strtabsize, s);
+ if (p) {
+ return p - strtab;
+ }
+
+ /* Add it */
+ offset = -strtabsize - len;
+ struct_top = fdt_off_dt_struct (fdt) + fdt_size_dt_struct (fdt);
+ if (fdt_totalsize (fdt) + offset < struct_top) {
+ return 0; /* no more room :( */
+ }
+
+ memcpy (strtab + offset, s, len);
+ fdt_set_size_dt_strings (fdt, strtabsize + len);
+ return offset;
}
-int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp)
+int
+fdt_property_placeholder (
+ void *fdt,
+ const char *name,
+ int len,
+ void **valp
+ )
{
- struct fdt_property *prop;
- int nameoff;
-
- FDT_SW_CHECK_HEADER(fdt);
-
- nameoff = _fdt_find_add_string(fdt, name);
- if (nameoff == 0)
- return -FDT_ERR_NOSPACE;
-
- prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
- if (! prop)
- return -FDT_ERR_NOSPACE;
-
- prop->tag = cpu_to_fdt32(FDT_PROP);
- prop->nameoff = cpu_to_fdt32(nameoff);
- prop->len = cpu_to_fdt32(len);
- *valp = prop->data;
- return 0;
+ struct fdt_property *prop;
+ int nameoff;
+
+ FDT_SW_CHECK_HEADER (fdt);
+
+ nameoff = _fdt_find_add_string (fdt, name);
+ if (nameoff == 0) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ prop = _fdt_grab_space (fdt, sizeof (*prop) + FDT_TAGALIGN (len));
+ if (!prop) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ prop->tag = cpu_to_fdt32 (FDT_PROP);
+ prop->nameoff = cpu_to_fdt32 (nameoff);
+ prop->len = cpu_to_fdt32 (len);
+ *valp = prop->data;
+ return 0;
}
-int fdt_property(void *fdt, const char *name, const void *val, int len)
+int
+fdt_property (
+ void *fdt,
+ const char *name,
+ const void *val,
+ int len
+ )
{
- void *ptr;
- int ret;
-
- ret = fdt_property_placeholder(fdt, name, len, &ptr);
- if (ret)
- return ret;
- memcpy(ptr, val, len);
- return 0;
+ void *ptr;
+ int ret;
+
+ ret = fdt_property_placeholder (fdt, name, len, &ptr);
+ if (ret) {
+ return ret;
+ }
+
+ memcpy (ptr, val, len);
+ return 0;
}
-int fdt_finish(void *fdt)
+int
+fdt_finish (
+ void *fdt
+ )
{
- char *p = (char *)fdt;
- fdt32_t *end;
- int oldstroffset, newstroffset;
- uint32_t tag;
- int offset, nextoffset;
-
- FDT_SW_CHECK_HEADER(fdt);
-
- /* Add terminator */
- end = _fdt_grab_space(fdt, sizeof(*end));
- if (! end)
- return -FDT_ERR_NOSPACE;
- *end = cpu_to_fdt32(FDT_END);
-
- /* Relocate the string table */
- oldstroffset = fdt_totalsize(fdt) - fdt_size_dt_strings(fdt);
- newstroffset = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
- memmove(p + newstroffset, p + oldstroffset, fdt_size_dt_strings(fdt));
- fdt_set_off_dt_strings(fdt, newstroffset);
-
- /* Walk the structure, correcting string offsets */
- offset = 0;
- while ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {
- if (tag == FDT_PROP) {
- struct fdt_property *prop =
- _fdt_offset_ptr_w(fdt, offset);
- int nameoff;
-
- nameoff = fdt32_to_cpu(prop->nameoff);
- nameoff += fdt_size_dt_strings(fdt);
- prop->nameoff = cpu_to_fdt32(nameoff);
- }
- offset = nextoffset;
- }
- if (nextoffset < 0)
- return nextoffset;
-
- /* Finally, adjust the header */
- fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));
- fdt_set_magic(fdt, FDT_MAGIC);
- return 0;
+ char *p = (char *)fdt;
+ fdt32_t *end;
+ int oldstroffset, newstroffset;
+ uint32_t tag;
+ int offset, nextoffset;
+
+ FDT_SW_CHECK_HEADER (fdt);
+
+ /* Add terminator */
+ end = _fdt_grab_space (fdt, sizeof (*end));
+ if (!end) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ *end = cpu_to_fdt32 (FDT_END);
+
+ /* Relocate the string table */
+ oldstroffset = fdt_totalsize (fdt) - fdt_size_dt_strings (fdt);
+ newstroffset = fdt_off_dt_struct (fdt) + fdt_size_dt_struct (fdt);
+ memmove (p + newstroffset, p + oldstroffset, fdt_size_dt_strings (fdt));
+ fdt_set_off_dt_strings (fdt, newstroffset);
+
+ /* Walk the structure, correcting string offsets */
+ offset = 0;
+ while ((tag = fdt_next_tag (fdt, offset, &nextoffset)) != FDT_END) {
+ if (tag == FDT_PROP) {
+ struct fdt_property *prop =
+ _fdt_offset_ptr_w (fdt, offset);
+ int nameoff;
+
+ nameoff = fdt32_to_cpu (prop->nameoff);
+ nameoff += fdt_size_dt_strings (fdt);
+ prop->nameoff = cpu_to_fdt32 (nameoff);
+ }
+
+ offset = nextoffset;
+ }
+
+ if (nextoffset < 0) {
+ return nextoffset;
+ }
+
+ /* Finally, adjust the header */
+ fdt_set_totalsize (fdt, newstroffset + fdt_size_dt_strings (fdt));
+ fdt_set_magic (fdt, FDT_MAGIC);
+ return 0;
}
diff --git a/EmbeddedPkg/Library/FdtLib/fdt_wip.c b/EmbeddedPkg/Library/FdtLib/fdt_wip.c
index 6e39807b87..8447706919 100644
--- a/EmbeddedPkg/Library/FdtLib/fdt_wip.c
+++ b/EmbeddedPkg/Library/FdtLib/fdt_wip.c
@@ -55,85 +55,135 @@
#include "libfdt_internal.h"
-int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
- const char *name, int namelen,
- uint32_t idx, const void *val,
- int len)
+int
+fdt_setprop_inplace_namelen_partial (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ int namelen,
+ uint32_t idx,
+ const void *val,
+ int len
+ )
{
- void *propval;
- int proplen;
-
- propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,
- &proplen);
- if (!propval)
- return proplen;
-
- if (proplen < (len + idx))
- return -FDT_ERR_NOSPACE;
-
- memcpy((char *)propval + idx, val, len);
- return 0;
+ void *propval;
+ int proplen;
+
+ propval = fdt_getprop_namelen_w (
+ fdt,
+ nodeoffset,
+ name,
+ namelen,
+ &proplen
+ );
+ if (!propval) {
+ return proplen;
+ }
+
+ if (proplen < (len + idx)) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ memcpy ((char *)propval + idx, val, len);
+ return 0;
}
-int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
- const void *val, int len)
+int
+fdt_setprop_inplace (
+ void *fdt,
+ int nodeoffset,
+ const char *name,
+ const void *val,
+ int len
+ )
{
- const void *propval;
- int proplen;
-
- propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
- if (!propval)
- return proplen;
-
- if (proplen != len)
- return -FDT_ERR_NOSPACE;
-
- return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,
- strlen(name), 0,
- val, len);
+ const void *propval;
+ int proplen;
+
+ propval = fdt_getprop (fdt, nodeoffset, name, &proplen);
+ if (!propval) {
+ return proplen;
+ }
+
+ if (proplen != len) {
+ return -FDT_ERR_NOSPACE;
+ }
+
+ return fdt_setprop_inplace_namelen_partial (
+ fdt,
+ nodeoffset,
+ name,
+ strlen (name),
+ 0,
+ val,
+ len
+ );
}
-static void _fdt_nop_region(void *start, int len)
+static void
+_fdt_nop_region (
+ void *start,
+ int len
+ )
{
- fdt32_t *p;
+ fdt32_t *p;
- for (p = start; (char *)p < ((char *)start + len); p++)
- *p = cpu_to_fdt32(FDT_NOP);
+ for (p = start; (char *)p < ((char *)start + len); p++) {
+ *p = cpu_to_fdt32 (FDT_NOP);
+ }
}
-int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
+int
+fdt_nop_property (
+ void *fdt,
+ int nodeoffset,
+ const char *name
+ )
{
- struct fdt_property *prop;
- int len;
+ struct fdt_property *prop;
+ int len;
- prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
- if (!prop)
- return len;
+ prop = fdt_get_property_w (fdt, nodeoffset, name, &len);
+ if (!prop) {
+ return len;
+ }
- _fdt_nop_region(prop, len + sizeof(*prop));
+ _fdt_nop_region (prop, len + sizeof (*prop));
- return 0;
+ return 0;
}
-int _fdt_node_end_offset(void *fdt, int offset)
+int
+_fdt_node_end_offset (
+ void *fdt,
+ int offset
+ )
{
- int depth = 0;
+ int depth = 0;
- while ((offset >= 0) && (depth >= 0))
- offset = fdt_next_node(fdt, offset, &depth);
+ while ((offset >= 0) && (depth >= 0)) {
+ offset = fdt_next_node (fdt, offset, &depth);
+ }
- return offset;
+ return offset;
}
-int fdt_nop_node(void *fdt, int nodeoffset)
+int
+fdt_nop_node (
+ void *fdt,
+ int nodeoffset
+ )
{
- int endoffset;
-
- endoffset = _fdt_node_end_offset(fdt, nodeoffset);
- if (endoffset < 0)
- return endoffset;
-
- _fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0),
- endoffset - nodeoffset);
- return 0;
+ int endoffset;
+
+ endoffset = _fdt_node_end_offset (fdt, nodeoffset);
+ if (endoffset < 0) {
+ return endoffset;
+ }
+
+ _fdt_nop_region (
+ fdt_offset_ptr_w (fdt, nodeoffset, 0),
+ endoffset - nodeoffset
+ );
+ return 0;
}
diff --git a/EmbeddedPkg/Library/FdtLib/libfdt_internal.h b/EmbeddedPkg/Library/FdtLib/libfdt_internal.h
index f82227a32c..f3c89581a8 100644
--- a/EmbeddedPkg/Library/FdtLib/libfdt_internal.h
+++ b/EmbeddedPkg/Library/FdtLib/libfdt_internal.h
@@ -1,5 +1,6 @@
#ifndef _LIBFDT_INTERNAL_H
#define _LIBFDT_INTERNAL_H
+
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -52,44 +53,81 @@
*/
#include <fdt.h>
-#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
-#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
+#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
+#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
#define FDT_CHECK_HEADER(fdt) \
- { \
- int __err; \
- if ((__err = fdt_check_header(fdt)) != 0) \
- return __err; \
- }
+ { \
+ int __err; \
+ if ((__err = fdt_check_header(fdt)) != 0) \
+ return __err; \
+ }
+
+int
+_fdt_check_node_offset (
+ const void *fdt,
+ int offset
+ );
+
+int
+_fdt_check_prop_offset (
+ const void *fdt,
+ int offset
+ );
-int _fdt_check_node_offset(const void *fdt, int offset);
-int _fdt_check_prop_offset(const void *fdt, int offset);
-const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
-int _fdt_node_end_offset(void *fdt, int nodeoffset);
+const char *
+_fdt_find_string (
+ const char *strtab,
+ int tabsize,
+ const char *s
+ );
-static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
+int
+_fdt_node_end_offset (
+ void *fdt,
+ int nodeoffset
+ );
+
+static inline const void *
+_fdt_offset_ptr (
+ const void *fdt,
+ int offset
+ )
{
- return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
+ return (const char *)fdt + fdt_off_dt_struct (fdt) + offset;
}
-static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
+static inline void *
+_fdt_offset_ptr_w (
+ void *fdt,
+ int offset
+ )
{
- return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
+ return (void *)(uintptr_t)_fdt_offset_ptr (fdt, offset);
}
-static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
+static inline const struct fdt_reserve_entry *
+_fdt_mem_rsv (
+ const void *fdt,
+ int n
+ )
{
- const struct fdt_reserve_entry *rsv_table =
- (const struct fdt_reserve_entry *)
- ((const char *)fdt + fdt_off_mem_rsvmap(fdt));
+ const struct fdt_reserve_entry *rsv_table =
+ (const struct fdt_reserve_entry *)
+ ((const char *)fdt + fdt_off_mem_rsvmap (fdt));
- return rsv_table + n;
+ return rsv_table + n;
}
-static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
+
+static inline struct fdt_reserve_entry *
+_fdt_mem_rsv_w (
+ void *fdt,
+ int n
+ )
{
- return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
+ return (void *)(uintptr_t)_fdt_mem_rsv (fdt, n);
}
-#define FDT_SW_MAGIC (~FDT_MAGIC)
+#define FDT_SW_MAGIC (~FDT_MAGIC)
#endif /* _LIBFDT_INTERNAL_H */
diff --git a/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c b/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c
index d2bafcf69b..d53a5fe47f 100644
--- a/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c
+++ b/EmbeddedPkg/Library/GdbSerialDebugPortLib/GdbSerialDebugPortLib.c
@@ -16,9 +16,8 @@
#include <Protocol/DebugPort.h>
-
EFI_DEBUGPORT_PROTOCOL *gDebugPort = NULL;
-UINTN gTimeOut = 0;
+UINTN gTimeOut = 0;
/**
The constructor function initializes the UART.
@@ -36,7 +35,7 @@ GdbSerialLibDebugPortConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **)&gDebugPort);
if (!EFI_ERROR (Status)) {
@@ -47,8 +46,6 @@ GdbSerialLibDebugPortConstructor (
return Status;
}
-
-
/**
Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,
data buts, and stop bits on a serial device. This call is optional as the serial
@@ -71,10 +68,10 @@ GdbSerialLibDebugPortConstructor (
RETURN_STATUS
EFIAPI
GdbSerialInit (
- IN UINT64 BaudRate,
- IN UINT8 Parity,
- IN UINT8 DataBits,
- IN UINT8 StopBits
+ IN UINT64 BaudRate,
+ IN UINT8 Parity,
+ IN UINT8 DataBits,
+ IN UINT8 StopBits
)
{
EFI_STATUS Status;
@@ -83,7 +80,6 @@ GdbSerialInit (
return Status;
}
-
/**
Check to see if a character is available from GDB. Do not read the character as that is
done via GdbGetChar().
@@ -105,7 +101,6 @@ GdbIsCharAvailable (
return (Status == EFI_SUCCESS ? TRUE : FALSE);
}
-
/**
Get a character from GDB. This function must be able to run in interrupt context.
@@ -124,13 +119,12 @@ GdbGetChar (
do {
BufferSize = sizeof (Char);
- Status = gDebugPort->Read (gDebugPort, gTimeOut, &BufferSize, &Char);
+ Status = gDebugPort->Read (gDebugPort, gTimeOut, &BufferSize, &Char);
} while (EFI_ERROR (Status) || BufferSize != sizeof (Char));
return Char;
}
-
/**
Send a character to GDB. This function must be able to run in interrupt context.
@@ -138,11 +132,10 @@ GdbGetChar (
@param Char Send a character to GDB
**/
-
VOID
EFIAPI
GdbPutChar (
- IN CHAR8 Char
+ IN CHAR8 Char
)
{
EFI_STATUS Status;
@@ -150,7 +143,7 @@ GdbPutChar (
do {
BufferSize = sizeof (Char);
- Status = gDebugPort->Write (gDebugPort, gTimeOut, &BufferSize, &Char);
+ Status = gDebugPort->Write (gDebugPort, gTimeOut, &BufferSize, &Char);
} while (EFI_ERROR (Status) || BufferSize != sizeof (Char));
return;
@@ -163,19 +156,14 @@ GdbPutChar (
@param String Send a string to GDB
**/
-
VOID
GdbPutString (
IN CHAR8 *String
)
{
- // We could performance enhance this function by calling gDebugPort->Write ()
+ // We could performance enhance this function by calling gDebugPort->Write ()
while (*String != '\0') {
GdbPutChar (*String);
String++;
}
}
-
-
-
-
diff --git a/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c b/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c
index 71452008ec..75e00773ec 100644
--- a/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c
+++ b/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c
@@ -13,38 +13,34 @@
#include <Library/IoLib.h>
#include <Library/DebugLib.h>
-
-//---------------------------------------------
+// ---------------------------------------------
// UART Register Offsets
-//---------------------------------------------
-#define BAUD_LOW_OFFSET 0x00
-#define BAUD_HIGH_OFFSET 0x01
-#define IER_OFFSET 0x01
-#define LCR_SHADOW_OFFSET 0x01
-#define FCR_SHADOW_OFFSET 0x02
-#define IR_CONTROL_OFFSET 0x02
-#define FCR_OFFSET 0x02
-#define EIR_OFFSET 0x02
-#define BSR_OFFSET 0x03
-#define LCR_OFFSET 0x03
-#define MCR_OFFSET 0x04
-#define LSR_OFFSET 0x05
-#define MSR_OFFSET 0x06
-
-//---------------------------------------------
+// ---------------------------------------------
+#define BAUD_LOW_OFFSET 0x00
+#define BAUD_HIGH_OFFSET 0x01
+#define IER_OFFSET 0x01
+#define LCR_SHADOW_OFFSET 0x01
+#define FCR_SHADOW_OFFSET 0x02
+#define IR_CONTROL_OFFSET 0x02
+#define FCR_OFFSET 0x02
+#define EIR_OFFSET 0x02
+#define BSR_OFFSET 0x03
+#define LCR_OFFSET 0x03
+#define MCR_OFFSET 0x04
+#define LSR_OFFSET 0x05
+#define MSR_OFFSET 0x06
+
+// ---------------------------------------------
// UART Register Bit Defines
-//---------------------------------------------
-#define LSR_TXRDY 0x20U
-#define LSR_RXDA 0x01U
-#define DLAB 0x01U
-#define ENABLE_FIFO 0x01U
-#define CLEAR_FIFOS 0x06U
-
-
+// ---------------------------------------------
+#define LSR_TXRDY 0x20U
+#define LSR_RXDA 0x01U
+#define DLAB 0x01U
+#define ENABLE_FIFO 0x01U
+#define CLEAR_FIFOS 0x06U
// IO Port Base for the UART
-UINTN gPort;
-
+UINTN gPort;
/**
The constructor function initializes the UART.
@@ -62,10 +58,10 @@ GdbSerialLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- UINT64 BaudRate;
- UINT8 DataBits;
- UINT8 Parity;
- UINT8 StopBits;
+ UINT64 BaudRate;
+ UINT8 DataBits;
+ UINT8 Parity;
+ UINT8 StopBits;
gPort = (UINTN)PcdGet32 (PcdGdbUartPort);
@@ -77,8 +73,6 @@ GdbSerialLibConstructor (
return GdbSerialInit (BaudRate, Parity, DataBits, StopBits);
}
-
-
/**
Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,
data buts, and stop bits on a serial device. This call is optional as the serial
@@ -101,16 +95,16 @@ GdbSerialLibConstructor (
RETURN_STATUS
EFIAPI
GdbSerialInit (
- IN UINT64 BaudRate,
- IN UINT8 Parity,
- IN UINT8 DataBits,
- IN UINT8 StopBits
+ IN UINT64 BaudRate,
+ IN UINT8 Parity,
+ IN UINT8 DataBits,
+ IN UINT8 StopBits
)
{
- UINTN Divisor;
- UINT8 OutputData;
- UINT8 Data;
- UINT8 BreakSet = 0;
+ UINTN Divisor;
+ UINT8 OutputData;
+ UINT8 Data;
+ UINT8 BreakSet = 0;
//
// We assume the UART has been turned on to decode gPort address range
@@ -119,7 +113,7 @@ GdbSerialInit (
//
// Map 5..8 to 0..3
//
- Data = (UINT8) (DataBits - (UINT8)5);
+ Data = (UINT8)(DataBits - (UINT8)5);
//
// Calculate divisor for baud generator
@@ -138,7 +132,6 @@ GdbSerialInit (
IoWrite8 (gPort + BAUD_HIGH_OFFSET, (UINT8)(Divisor >> 8));
IoWrite8 (gPort + BAUD_LOW_OFFSET, (UINT8)(Divisor & 0xff));
-
//
// Switch back to bank 0
//
@@ -149,12 +142,10 @@ GdbSerialInit (
// We probably need the FIFO enabled to not drop input
IoWrite8 (gPort + FCR_SHADOW_OFFSET, ENABLE_FIFO);
-
// Configure the UART hardware here
return RETURN_SUCCESS;
}
-
/**
Check to see if a character is available from GDB. Do not read the character as that is
done via GdbGetChar().
@@ -169,14 +160,13 @@ GdbIsCharAvailable (
VOID
)
{
- UINT8 Data;
+ UINT8 Data;
Data = IoRead8 (gPort + LSR_OFFSET);
return ((Data & LSR_RXDA) == LSR_RXDA);
}
-
/**
Get a character from GDB. This function must be able to run in interrupt context.
@@ -189,8 +179,8 @@ GdbGetChar (
VOID
)
{
- UINT8 Data;
- CHAR8 Char;
+ UINT8 Data;
+ CHAR8 Char;
// Wait for the serial port to be ready
do {
@@ -204,7 +194,6 @@ GdbGetChar (
return Char;
}
-
/**
Send a character to GDB. This function must be able to run in interrupt context.
@@ -212,14 +201,13 @@ GdbGetChar (
@param Char Send a character to GDB
**/
-
VOID
EFIAPI
GdbPutChar (
- IN CHAR8 Char
+ IN CHAR8 Char
)
{
- UINT8 Data;
+ UINT8 Data;
// Make this an DEBUG_INFO after we get everything debugged.
DEBUG ((DEBUG_ERROR, ">%c>", Char));
@@ -239,7 +227,6 @@ GdbPutChar (
@param String Send a string to GDB
**/
-
VOID
GdbPutString (
IN CHAR8 *String
diff --git a/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c b/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c
index 1aec86fffd..44a78c947e 100644
--- a/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c
+++ b/EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.c
@@ -22,30 +22,29 @@
#include <Protocol/Cpu.h>
typedef struct {
- EFI_PHYSICAL_ADDRESS HostAddress;
- VOID *BufferAddress;
- UINTN NumberOfBytes;
- DMA_MAP_OPERATION Operation;
- BOOLEAN DoubleBuffer;
+ EFI_PHYSICAL_ADDRESS HostAddress;
+ VOID *BufferAddress;
+ UINTN NumberOfBytes;
+ DMA_MAP_OPERATION Operation;
+ BOOLEAN DoubleBuffer;
} MAP_INFO_INSTANCE;
-
typedef struct {
- LIST_ENTRY Link;
- VOID *HostAddress;
- UINTN NumPages;
- UINT64 Attributes;
+ LIST_ENTRY Link;
+ VOID *HostAddress;
+ UINTN NumPages;
+ UINT64 Attributes;
} UNCACHED_ALLOCATION;
-STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;
-STATIC LIST_ENTRY UncachedAllocationList;
+STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;
+STATIC LIST_ENTRY UncachedAllocationList;
-STATIC PHYSICAL_ADDRESS mDmaHostAddressLimit;
+STATIC PHYSICAL_ADDRESS mDmaHostAddressLimit;
STATIC
PHYSICAL_ADDRESS
HostToDeviceAddress (
- IN VOID *Address
+ IN VOID *Address
)
{
return (PHYSICAL_ADDRESS)(UINTN)Address + PcdGet64 (PcdDmaDeviceOffset);
@@ -95,13 +94,14 @@ InternalAllocateAlignedPages (
if (Pages == 0) {
return NULL;
}
+
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page
// size.
//
- AlignmentMask = Alignment - 1;
- RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not
// overflow.
@@ -109,11 +109,16 @@ InternalAllocateAlignedPages (
ASSERT (RealPages > Pages);
Memory = mDmaHostAddressLimit;
- Status = gBS->AllocatePages (AllocateMaxAddress, MemoryType, RealPages,
- &Memory);
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ MemoryType,
+ RealPages,
+ &Memory
+ );
if (EFI_ERROR (Status)) {
return NULL;
}
+
AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
@@ -123,6 +128,7 @@ InternalAllocateAlignedPages (
Status = gBS->FreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
+
Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
@@ -137,13 +143,19 @@ InternalAllocateAlignedPages (
// Do not over-allocate pages in this case.
//
Memory = mDmaHostAddressLimit;
- Status = gBS->AllocatePages (AllocateMaxAddress, MemoryType, Pages,
- &Memory);
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ MemoryType,
+ Pages,
+ &Memory
+ );
if (EFI_ERROR (Status)) {
return NULL;
}
+
AlignedMemory = (UINTN)Memory;
}
+
return (VOID *)AlignedMemory;
}
@@ -177,23 +189,24 @@ InternalAllocateAlignedPages (
EFI_STATUS
EFIAPI
DmaMap (
- IN DMA_MAP_OPERATION Operation,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
+ IN DMA_MAP_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
)
{
- EFI_STATUS Status;
- MAP_INFO_INSTANCE *Map;
- VOID *Buffer;
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
- UINTN AllocSize;
-
- if (HostAddress == NULL ||
- NumberOfBytes == NULL ||
- DeviceAddress == NULL ||
- Mapping == NULL ) {
+ EFI_STATUS Status;
+ MAP_INFO_INSTANCE *Map;
+ VOID *Buffer;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
+ UINTN AllocSize;
+
+ if ((HostAddress == NULL) ||
+ (NumberOfBytes == NULL) ||
+ (DeviceAddress == NULL) ||
+ (Mapping == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -206,19 +219,20 @@ DmaMap (
// Remember range so we can flush on the other side
Map = AllocatePool (sizeof (MAP_INFO_INSTANCE));
if (Map == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ return EFI_OUT_OF_RESOURCES;
}
if (((UINTN)HostAddress + *NumberOfBytes) > mDmaHostAddressLimit) {
-
if (Operation == MapOperationBusMasterCommonBuffer) {
goto CommonBufferError;
}
- AllocSize = ALIGN_VALUE (*NumberOfBytes, mCpu->DmaBufferAlignment);
- Map->BufferAddress = InternalAllocateAlignedPages (EfiBootServicesData,
+ AllocSize = ALIGN_VALUE (*NumberOfBytes, mCpu->DmaBufferAlignment);
+ Map->BufferAddress = InternalAllocateAlignedPages (
+ EfiBootServicesData,
EFI_SIZE_TO_PAGES (AllocSize),
- mCpu->DmaBufferAlignment);
+ mCpu->DmaBufferAlignment
+ );
if (Map->BufferAddress == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeMapInfo;
@@ -227,17 +241,22 @@ DmaMap (
if (Operation == MapOperationBusMasterRead) {
CopyMem (Map->BufferAddress, (VOID *)(UINTN)HostAddress, *NumberOfBytes);
}
- mCpu->FlushDataCache (mCpu, (UINTN)Map->BufferAddress, AllocSize,
- EfiCpuFlushTypeWriteBack);
- *DeviceAddress = HostToDeviceAddress (Map->BufferAddress);
- } else if (Operation != MapOperationBusMasterRead &&
- ((((UINTN)HostAddress & (mCpu->DmaBufferAlignment - 1)) != 0) ||
- ((*NumberOfBytes & (mCpu->DmaBufferAlignment - 1)) != 0))) {
+ mCpu->FlushDataCache (
+ mCpu,
+ (UINTN)Map->BufferAddress,
+ AllocSize,
+ EfiCpuFlushTypeWriteBack
+ );
+ *DeviceAddress = HostToDeviceAddress (Map->BufferAddress);
+ } else if ((Operation != MapOperationBusMasterRead) &&
+ ((((UINTN)HostAddress & (mCpu->DmaBufferAlignment - 1)) != 0) ||
+ ((*NumberOfBytes & (mCpu->DmaBufferAlignment - 1)) != 0)))
+ {
// Get the cacheability of the region
Status = gDS->GetMemorySpaceDescriptor ((UINTN)HostAddress, &GcdDescriptor);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto FreeMapInfo;
}
@@ -259,15 +278,15 @@ DmaMap (
// we only have to add (alignment - 8) worth of padding.
//
Map->DoubleBuffer = TRUE;
- AllocSize = ALIGN_VALUE (*NumberOfBytes, mCpu->DmaBufferAlignment) +
- (mCpu->DmaBufferAlignment - 8);
+ AllocSize = ALIGN_VALUE (*NumberOfBytes, mCpu->DmaBufferAlignment) +
+ (mCpu->DmaBufferAlignment - 8);
Map->BufferAddress = AllocatePool (AllocSize);
if (Map->BufferAddress == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeMapInfo;
}
- Buffer = ALIGN_POINTER (Map->BufferAddress, mCpu->DmaBufferAlignment);
+ Buffer = ALIGN_POINTER (Map->BufferAddress, mCpu->DmaBufferAlignment);
*DeviceAddress = HostToDeviceAddress (Buffer);
//
@@ -275,13 +294,17 @@ DmaMap (
// prevents them from being written back unexpectedly, potentially
// overwriting the data we receive from the device.
//
- mCpu->FlushDataCache (mCpu, (UINTN)Buffer, *NumberOfBytes,
- EfiCpuFlushTypeWriteBack);
+ mCpu->FlushDataCache (
+ mCpu,
+ (UINTN)Buffer,
+ *NumberOfBytes,
+ EfiCpuFlushTypeWriteBack
+ );
} else {
- Map->DoubleBuffer = FALSE;
+ Map->DoubleBuffer = FALSE;
}
} else {
- Map->DoubleBuffer = FALSE;
+ Map->DoubleBuffer = FALSE;
DEBUG_CODE_BEGIN ();
@@ -293,17 +316,23 @@ DmaMap (
// that we are not trying to create a consistent mapping for cached memory.
//
Status = gDS->GetMemorySpaceDescriptor ((UINTN)HostAddress, &GcdDescriptor);
- ASSERT_EFI_ERROR(Status);
+ ASSERT_EFI_ERROR (Status);
- ASSERT (Operation != MapOperationBusMasterCommonBuffer ||
- (GcdDescriptor.Attributes & (EFI_MEMORY_WB | EFI_MEMORY_WT)) == 0);
+ ASSERT (
+ Operation != MapOperationBusMasterCommonBuffer ||
+ (GcdDescriptor.Attributes & (EFI_MEMORY_WB | EFI_MEMORY_WT)) == 0
+ );
DEBUG_CODE_END ();
// Flush the Data Cache (should not have any effect if the memory region is
// uncached)
- mCpu->FlushDataCache (mCpu, (UINTN)HostAddress, *NumberOfBytes,
- EfiCpuFlushTypeWriteBackInvalidate);
+ mCpu->FlushDataCache (
+ mCpu,
+ (UINTN)HostAddress,
+ *NumberOfBytes,
+ EfiCpuFlushTypeWriteBackInvalidate
+ );
}
Map->HostAddress = (UINTN)HostAddress;
@@ -315,10 +344,13 @@ DmaMap (
return EFI_SUCCESS;
CommonBufferError:
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"%a: Operation type 'MapOperationBusMasterCommonBuffer' is only "
"supported\non memory regions that were allocated using "
- "DmaAllocateBuffer ()\n", __FUNCTION__));
+ "DmaAllocateBuffer ()\n",
+ __FUNCTION__
+ ));
Status = EFI_UNSUPPORTED;
FreeMapInfo:
FreePool (Map);
@@ -326,7 +358,6 @@ FreeMapInfo:
return Status;
}
-
/**
Completes the DmaMapBusMasterRead(), DmaMapBusMasterWrite(), or
DmaMapBusMasterCommonBuffer() operation and releases any corresponding
@@ -344,13 +375,13 @@ FreeMapInfo:
EFI_STATUS
EFIAPI
DmaUnmap (
- IN VOID *Mapping
+ IN VOID *Mapping
)
{
- MAP_INFO_INSTANCE *Map;
- EFI_STATUS Status;
- VOID *Buffer;
- UINTN AllocSize;
+ MAP_INFO_INSTANCE *Map;
+ EFI_STATUS Status;
+ VOID *Buffer;
+ UINTN AllocSize;
if (Mapping == NULL) {
ASSERT (FALSE);
@@ -363,14 +394,21 @@ DmaUnmap (
if (((UINTN)Map->HostAddress + Map->NumberOfBytes) > mDmaHostAddressLimit) {
AllocSize = ALIGN_VALUE (Map->NumberOfBytes, mCpu->DmaBufferAlignment);
if (Map->Operation == MapOperationBusMasterWrite) {
- mCpu->FlushDataCache (mCpu, (UINTN)Map->BufferAddress, AllocSize,
- EfiCpuFlushTypeInvalidate);
- CopyMem ((VOID *)(UINTN)Map->HostAddress, Map->BufferAddress,
- Map->NumberOfBytes);
+ mCpu->FlushDataCache (
+ mCpu,
+ (UINTN)Map->BufferAddress,
+ AllocSize,
+ EfiCpuFlushTypeInvalidate
+ );
+ CopyMem (
+ (VOID *)(UINTN)Map->HostAddress,
+ Map->BufferAddress,
+ Map->NumberOfBytes
+ );
}
+
FreePages (Map->BufferAddress, EFI_SIZE_TO_PAGES (AllocSize));
} else if (Map->DoubleBuffer) {
-
ASSERT (Map->Operation == MapOperationBusMasterWrite);
if (Map->Operation != MapOperationBusMasterWrite) {
@@ -378,8 +416,12 @@ DmaUnmap (
} else {
Buffer = ALIGN_POINTER (Map->BufferAddress, mCpu->DmaBufferAlignment);
- mCpu->FlushDataCache (mCpu, (UINTN)Buffer, Map->NumberOfBytes,
- EfiCpuFlushTypeInvalidate);
+ mCpu->FlushDataCache (
+ mCpu,
+ (UINTN)Buffer,
+ Map->NumberOfBytes,
+ EfiCpuFlushTypeInvalidate
+ );
CopyMem ((VOID *)(UINTN)Map->HostAddress, Buffer, Map->NumberOfBytes);
@@ -390,8 +432,12 @@ DmaUnmap (
//
// Make sure we read buffer from uncached memory and not the cache
//
- mCpu->FlushDataCache (mCpu, Map->HostAddress, Map->NumberOfBytes,
- EfiCpuFlushTypeInvalidate);
+ mCpu->FlushDataCache (
+ mCpu,
+ Map->HostAddress,
+ Map->NumberOfBytes,
+ EfiCpuFlushTypeInvalidate
+ );
}
}
@@ -418,9 +464,9 @@ DmaUnmap (
EFI_STATUS
EFIAPI
DmaAllocateBuffer (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT VOID **HostAddress
)
{
return DmaAllocateAlignedBuffer (MemoryType, Pages, 0, HostAddress);
@@ -446,29 +492,31 @@ DmaAllocateBuffer (
EFI_STATUS
EFIAPI
DmaAllocateAlignedBuffer (
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- IN UINTN Alignment,
- OUT VOID **HostAddress
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN UINTN Alignment,
+ OUT VOID **HostAddress
)
{
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
- VOID *Allocation;
- UINT64 MemType;
- UNCACHED_ALLOCATION *Alloc;
- EFI_STATUS Status;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
+ VOID *Allocation;
+ UINT64 MemType;
+ UNCACHED_ALLOCATION *Alloc;
+ EFI_STATUS Status;
if (Alignment == 0) {
Alignment = EFI_PAGE_SIZE;
}
- if (HostAddress == NULL ||
- (Alignment & (Alignment - 1)) != 0) {
+ if ((HostAddress == NULL) ||
+ ((Alignment & (Alignment - 1)) != 0))
+ {
return EFI_INVALID_PARAMETER;
}
- if (MemoryType == EfiBootServicesData ||
- MemoryType == EfiRuntimeServicesData) {
+ if ((MemoryType == EfiBootServicesData) ||
+ (MemoryType == EfiRuntimeServicesData))
+ {
Allocation = InternalAllocateAlignedPages (MemoryType, Pages, Alignment);
} else {
return EFI_INVALID_PARAMETER;
@@ -480,7 +528,7 @@ DmaAllocateAlignedBuffer (
// Get the cacheability of the region
Status = gDS->GetMemorySpaceDescriptor ((UINTN)Allocation, &GcdDescriptor);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto FreeBuffer;
}
@@ -500,23 +548,27 @@ DmaAllocateAlignedBuffer (
}
Alloc->HostAddress = Allocation;
- Alloc->NumPages = Pages;
- Alloc->Attributes = GcdDescriptor.Attributes;
+ Alloc->NumPages = Pages;
+ Alloc->Attributes = GcdDescriptor.Attributes;
InsertHeadList (&UncachedAllocationList, &Alloc->Link);
// Remap the region with the new attributes
- Status = gDS->SetMemorySpaceAttributes ((PHYSICAL_ADDRESS)(UINTN)Allocation,
- EFI_PAGES_TO_SIZE (Pages),
- MemType);
+ Status = gDS->SetMemorySpaceAttributes (
+ (PHYSICAL_ADDRESS)(UINTN)Allocation,
+ EFI_PAGES_TO_SIZE (Pages),
+ MemType
+ );
if (EFI_ERROR (Status)) {
goto FreeAlloc;
}
- Status = mCpu->FlushDataCache (mCpu,
- (PHYSICAL_ADDRESS)(UINTN)Allocation,
- EFI_PAGES_TO_SIZE (Pages),
- EfiCpuFlushTypeInvalidate);
+ Status = mCpu->FlushDataCache (
+ mCpu,
+ (PHYSICAL_ADDRESS)(UINTN)Allocation,
+ EFI_PAGES_TO_SIZE (Pages),
+ EfiCpuFlushTypeInvalidate
+ );
if (EFI_ERROR (Status)) {
goto FreeAlloc;
}
@@ -534,7 +586,6 @@ FreeBuffer:
return Status;
}
-
/**
Frees memory that was allocated with DmaAllocateBuffer().
@@ -551,25 +602,25 @@ FreeBuffer:
EFI_STATUS
EFIAPI
DmaFreeBuffer (
- IN UINTN Pages,
- IN VOID *HostAddress
+ IN UINTN Pages,
+ IN VOID *HostAddress
)
{
- LIST_ENTRY *Link;
- UNCACHED_ALLOCATION *Alloc;
- BOOLEAN Found;
- EFI_STATUS Status;
+ LIST_ENTRY *Link;
+ UNCACHED_ALLOCATION *Alloc;
+ BOOLEAN Found;
+ EFI_STATUS Status;
if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
+ return EFI_INVALID_PARAMETER;
}
for (Link = GetFirstNode (&UncachedAllocationList), Found = FALSE;
!IsNull (&UncachedAllocationList, Link);
- Link = GetNextNode (&UncachedAllocationList, Link)) {
-
+ Link = GetNextNode (&UncachedAllocationList, Link))
+ {
Alloc = BASE_CR (Link, UNCACHED_ALLOCATION, Link);
- if (Alloc->HostAddress == HostAddress && Alloc->NumPages == Pages) {
+ if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages == Pages)) {
Found = TRUE;
break;
}
@@ -582,9 +633,11 @@ DmaFreeBuffer (
RemoveEntryList (&Alloc->Link);
- Status = gDS->SetMemorySpaceAttributes ((PHYSICAL_ADDRESS)(UINTN)HostAddress,
- EFI_PAGES_TO_SIZE (Pages),
- Alloc->Attributes);
+ Status = gDS->SetMemorySpaceAttributes (
+ (PHYSICAL_ADDRESS)(UINTN)HostAddress,
+ EFI_PAGES_TO_SIZE (Pages),
+ Alloc->Attributes
+ );
if (EFI_ERROR (Status)) {
goto FreeAlloc;
}
@@ -600,12 +653,11 @@ FreeAlloc:
return Status;
}
-
EFI_STATUS
EFIAPI
NonCoherentDmaLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
InitializeListHead (&UncachedAllocationList);
diff --git a/EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.c b/EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.c
index d05afcae36..e16c1c6a14 100644
--- a/EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.c
+++ b/EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.c
@@ -15,121 +15,121 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/NorFlashInfoLib.h>
-STATIC CONST NOR_FLASH_INFO NorFlashIds[] = {
+STATIC CONST NOR_FLASH_INFO NorFlashIds[] = {
/* ATMEL */
- {L"at45db011d", {0x1f, 0x22, 0x00}, 3, 256, 64 * 1024, 4, NOR_FLASH_ERASE_4K},
- {L"at45db021d", {0x1f, 0x23, 0x00}, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K},
- {L"at45db041d", {0x1f, 0x24, 0x00}, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K},
- {L"at45db081d", {0x1f, 0x25, 0x00}, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K},
- {L"at45db161d", {0x1f, 0x26, 0x00}, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K},
- {L"at45db321d", {0x1f, 0x27, 0x00}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"at45db641d", {0x1f, 0x28, 0x00}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"at25df321a", {0x1f, 0x47, 0x01}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"at25df321", {0x1f, 0x47, 0x00}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"at26df081a", {0x1f, 0x45, 0x01}, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K},
+ { L"at45db011d", { 0x1f, 0x22, 0x00 }, 3, 256, 64 * 1024, 4, NOR_FLASH_ERASE_4K },
+ { L"at45db021d", { 0x1f, 0x23, 0x00 }, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K },
+ { L"at45db041d", { 0x1f, 0x24, 0x00 }, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K },
+ { L"at45db081d", { 0x1f, 0x25, 0x00 }, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K },
+ { L"at45db161d", { 0x1f, 0x26, 0x00 }, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K },
+ { L"at45db321d", { 0x1f, 0x27, 0x00 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"at45db641d", { 0x1f, 0x28, 0x00 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"at25df321a", { 0x1f, 0x47, 0x01 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"at25df321", { 0x1f, 0x47, 0x00 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"at26df081a", { 0x1f, 0x45, 0x01 }, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K },
/* EON */
- {L"en25q32b", {0x1c, 0x30, 0x16}, 3, 256, 64 * 1024, 64, 0},
- {L"en25q64", {0x1c, 0x30, 0x17}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"en25q128b", {0x1c, 0x30, 0x18}, 3, 256, 64 * 1024, 256, 0},
- {L"en25s64", {0x1c, 0x38, 0x17}, 3, 256, 64 * 1024, 128, 0},
+ { L"en25q32b", { 0x1c, 0x30, 0x16 }, 3, 256, 64 * 1024, 64, 0 },
+ { L"en25q64", { 0x1c, 0x30, 0x17 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"en25q128b", { 0x1c, 0x30, 0x18 }, 3, 256, 64 * 1024, 256, 0 },
+ { L"en25s64", { 0x1c, 0x38, 0x17 }, 3, 256, 64 * 1024, 128, 0 },
/* GIGADEVICE */
- {L"gd25q64b", {0xc8, 0x40, 0x17}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"gd25lq32", {0xc8, 0x60, 0x16}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
+ { L"gd25q64b", { 0xc8, 0x40, 0x17 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"gd25lq32", { 0xc8, 0x60, 0x16 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
/* ISSI */
- {L"is25lp032", {0x9d, 0x60, 0x16}, 3, 256, 64 * 1024, 64, 0},
- {L"is25lp064", {0x9d, 0x60, 0x17}, 3, 256, 64 * 1024, 128, 0},
- {L"is25lp128", {0x9d, 0x60, 0x18}, 3, 256, 64 * 1024, 256, 0},
+ { L"is25lp032", { 0x9d, 0x60, 0x16 }, 3, 256, 64 * 1024, 64, 0 },
+ { L"is25lp064", { 0x9d, 0x60, 0x17 }, 3, 256, 64 * 1024, 128, 0 },
+ { L"is25lp128", { 0x9d, 0x60, 0x18 }, 3, 256, 64 * 1024, 256, 0 },
/* MACRONIX */
- {L"mx25l2006e", {0xc2, 0x20, 0x12}, 3, 256, 64 * 1024, 4, 0},
- {L"mx25l4005", {0xc2, 0x20, 0x13}, 3, 256, 64 * 1024, 8, 0},
- {L"mx25l8005", {0xc2, 0x20, 0x14}, 3, 256, 64 * 1024, 16, 0},
- {L"mx25l1605d", {0xc2, 0x20, 0x15}, 3, 256, 64 * 1024, 32, 0},
- {L"mx25l3205d", {0xc2, 0x20, 0x16}, 3, 256, 64 * 1024, 64, 0},
- {L"mx25l6405d", {0xc2, 0x20, 0x17}, 3, 256, 64 * 1024, 128, 0},
- {L"mx25l12805", {0xc2, 0x20, 0x18}, 3, 256, 64 * 1024, 256, 0},
- {L"mx25l25635f", {0xc2, 0x20, 0x19}, 3, 256, 64 * 1024, 512, 0},
- {L"mx25l51235f", {0xc2, 0x20, 0x1a}, 3, 256, 64 * 1024, 1024, 0},
- {L"mx25l12855e", {0xc2, 0x26, 0x18}, 3, 256, 64 * 1024, 256, 0},
- {L"mx66u51235f", {0xc2, 0x25, 0x3a}, 3, 256, 64 * 1024, 1024, 0},
- {L"mx66u1g45g", {0xc2, 0x25, 0x3b}, 3, 256, 64 * 1024, 2048, 0},
- {L"mx66l1g45g", {0xc2, 0x20, 0x1b}, 3, 256, 64 * 1024, 2048, 0},
+ { L"mx25l2006e", { 0xc2, 0x20, 0x12 }, 3, 256, 64 * 1024, 4, 0 },
+ { L"mx25l4005", { 0xc2, 0x20, 0x13 }, 3, 256, 64 * 1024, 8, 0 },
+ { L"mx25l8005", { 0xc2, 0x20, 0x14 }, 3, 256, 64 * 1024, 16, 0 },
+ { L"mx25l1605d", { 0xc2, 0x20, 0x15 }, 3, 256, 64 * 1024, 32, 0 },
+ { L"mx25l3205d", { 0xc2, 0x20, 0x16 }, 3, 256, 64 * 1024, 64, 0 },
+ { L"mx25l6405d", { 0xc2, 0x20, 0x17 }, 3, 256, 64 * 1024, 128, 0 },
+ { L"mx25l12805", { 0xc2, 0x20, 0x18 }, 3, 256, 64 * 1024, 256, 0 },
+ { L"mx25l25635f", { 0xc2, 0x20, 0x19 }, 3, 256, 64 * 1024, 512, 0 },
+ { L"mx25l51235f", { 0xc2, 0x20, 0x1a }, 3, 256, 64 * 1024, 1024, 0 },
+ { L"mx25l12855e", { 0xc2, 0x26, 0x18 }, 3, 256, 64 * 1024, 256, 0 },
+ { L"mx66u51235f", { 0xc2, 0x25, 0x3a }, 3, 256, 64 * 1024, 1024, 0 },
+ { L"mx66u1g45g", { 0xc2, 0x25, 0x3b }, 3, 256, 64 * 1024, 2048, 0 },
+ { L"mx66l1g45g", { 0xc2, 0x20, 0x1b }, 3, 256, 64 * 1024, 2048, 0 },
/* SPANSION */
- {L"s25fl008a", {0x01, 0x02, 0x13}, 3, 256, 64 * 1024, 16, 0},
- {L"s25fl016a", {0x01, 0x02, 0x14}, 3, 256, 64 * 1024, 32, 0},
- {L"s25fl032a", {0x01, 0x02, 0x15}, 3, 256, 64 * 1024, 64, 0},
- {L"s25fl064a", {0x01, 0x02, 0x16}, 3, 256, 64 * 1024, 128, 0},
- {L"s25fl116k", {0x01, 0x40, 0x15}, 3, 256, 64 * 1024, 128, 0},
- {L"s25fl164k", {0x01, 0x40, 0x17, 0x01, 0x40}, 5, 256, 64 * 1024, 128, 0},
- {L"s25fl128p_256k", {0x01, 0x20, 0x18, 0x03, 0x00}, 5, 256, 256 * 1024, 64, 0},
- {L"s25fl128p_64k", {0x01, 0x20, 0x18, 0x03, 0x01}, 5, 256, 64 * 1024, 256, 0},
- {L"s25fl032p", {0x01, 0x02, 0x15, 0x4d, 0x00}, 5, 256, 64 * 1024, 64, 0},
- {L"s25fl064p", {0x01, 0x02, 0x16, 0x4d, 0x00}, 5, 256, 64 * 1024, 128, 0},
- {L"s25fl128s_256k", {0x01, 0x20, 0x18, 0x4d, 0x00}, 5, 256, 256 * 1024, 64, 0},
- {L"s25fl128s_64k", {0x01, 0x20, 0x18, 0x4d, 0x01}, 5, 256, 64 * 1024, 256, 0},
- {L"s25fl256s_256k", {0x01, 0x02, 0x19, 0x4d, 0x00}, 5, 256, 256 * 1024, 128, 0},
- {L"s25fl256s_64k", {0x01, 0x02, 0x19, 0x4d, 0x01}, 5, 256, 64 * 1024, 512, 0},
- {L"s25fl512s_256k", {0x01, 0x02, 0x20, 0x4d, 0x00}, 5, 256, 256 * 1024, 256, 0},
- {L"s25fl512s_64k", {0x01, 0x02, 0x20, 0x4d, 0x01}, 5, 256, 64 * 1024, 1024, 0},
- {L"s25fl512s_512k", {0x01, 0x02, 0x20, 0x4f, 0x00}, 5, 256, 256 * 1024, 256, 0},
+ { L"s25fl008a", { 0x01, 0x02, 0x13 }, 3, 256, 64 * 1024, 16, 0 },
+ { L"s25fl016a", { 0x01, 0x02, 0x14 }, 3, 256, 64 * 1024, 32, 0 },
+ { L"s25fl032a", { 0x01, 0x02, 0x15 }, 3, 256, 64 * 1024, 64, 0 },
+ { L"s25fl064a", { 0x01, 0x02, 0x16 }, 3, 256, 64 * 1024, 128, 0 },
+ { L"s25fl116k", { 0x01, 0x40, 0x15 }, 3, 256, 64 * 1024, 128, 0 },
+ { L"s25fl164k", { 0x01, 0x40, 0x17, 0x01, 0x40}, 5, 256, 64 * 1024, 128, 0 },
+ { L"s25fl128p_256k", { 0x01, 0x20, 0x18, 0x03, 0x00}, 5, 256, 256 * 1024, 64, 0 },
+ { L"s25fl128p_64k", { 0x01, 0x20, 0x18, 0x03, 0x01}, 5, 256, 64 * 1024, 256, 0 },
+ { L"s25fl032p", { 0x01, 0x02, 0x15, 0x4d, 0x00}, 5, 256, 64 * 1024, 64, 0 },
+ { L"s25fl064p", { 0x01, 0x02, 0x16, 0x4d, 0x00}, 5, 256, 64 * 1024, 128, 0 },
+ { L"s25fl128s_256k", { 0x01, 0x20, 0x18, 0x4d, 0x00}, 5, 256, 256 * 1024, 64, 0 },
+ { L"s25fl128s_64k", { 0x01, 0x20, 0x18, 0x4d, 0x01}, 5, 256, 64 * 1024, 256, 0 },
+ { L"s25fl256s_256k", { 0x01, 0x02, 0x19, 0x4d, 0x00}, 5, 256, 256 * 1024, 128, 0 },
+ { L"s25fl256s_64k", { 0x01, 0x02, 0x19, 0x4d, 0x01}, 5, 256, 64 * 1024, 512, 0 },
+ { L"s25fl512s_256k", { 0x01, 0x02, 0x20, 0x4d, 0x00}, 5, 256, 256 * 1024, 256, 0 },
+ { L"s25fl512s_64k", { 0x01, 0x02, 0x20, 0x4d, 0x01}, 5, 256, 64 * 1024, 1024, 0 },
+ { L"s25fl512s_512k", { 0x01, 0x02, 0x20, 0x4f, 0x00}, 5, 256, 256 * 1024, 256, 0 },
/* STMICRO */
- {L"m25p10", {0x20, 0x20, 0x11}, 3, 256, 32 * 1024, 4, 0},
- {L"m25p20", {0x20, 0x20, 0x12}, 3, 256, 64 * 1024, 4, 0},
- {L"m25p40", {0x20, 0x20, 0x13}, 3, 256, 64 * 1024, 8, 0},
- {L"m25p80", {0x20, 0x20, 0x14}, 3, 256, 64 * 1024, 16, 0},
- {L"m25p16", {0x20, 0x20, 0x15}, 3, 256, 64 * 1024, 32, 0},
- {L"m25pE16", {0x20, 0x80, 0x15, 0x10, 0x00}, 5, 256, 64 * 1024, 32, 0},
- {L"m25pX16", {0x20, 0x71, 0x15, 0x10, 0x00}, 5, 256, 64 * 1024, 32, 0},
- {L"m25p32", {0x20, 0x20, 0x16}, 3, 256, 64 * 1024, 64, 0},
- {L"m25p64", {0x20, 0x20, 0x17}, 3, 256, 64 * 1024, 128, 0},
- {L"m25p128", {0x20, 0x20, 0x18}, 3, 256, 256 * 1024, 64, 0},
- {L"m25pX64", {0x20, 0x71, 0x17}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"n25q016a", {0x20, 0xbb, 0x15}, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K},
- {L"n25q32", {0x20, 0xba, 0x16}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"n25q32a", {0x20, 0xbb, 0x16}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"n25q64", {0x20, 0xba, 0x17}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"n25q64a", {0x20, 0xbb, 0x17}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"n25q128", {0x20, 0xba, 0x18}, 3, 256, 64 * 1024, 256, 0},
- {L"n25q128a", {0x20, 0xbb, 0x18}, 3, 256, 64 * 1024, 256, 0},
- {L"n25q256", {0x20, 0xba, 0x19}, 3, 256, 64 * 1024, 512, NOR_FLASH_ERASE_4K},
- {L"n25q256a", {0x20, 0xbb, 0x19}, 3, 256, 64 * 1024, 512, NOR_FLASH_ERASE_4K},
- {L"n25q512", {0x20, 0xba, 0x20}, 3, 256, 64 * 1024, 1024, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K},
- {L"n25q512a", {0x20, 0xbb, 0x20}, 3, 256, 64 * 1024, 1024, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K},
- {L"n25q1024", {0x20, 0xba, 0x21}, 3, 256, 64 * 1024, 2048, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K},
- {L"n25q1024a", {0x20, 0xbb, 0x21}, 3, 256, 64 * 1024, 2048, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K},
- {L"mt25qu02g", {0x20, 0xbb, 0x22}, 3, 256, 64 * 1024, 4096, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K},
- {L"mt25ql02g", {0x20, 0xba, 0x22}, 3, 256, 64 * 1024, 4096, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K},
+ { L"m25p10", { 0x20, 0x20, 0x11 }, 3, 256, 32 * 1024, 4, 0 },
+ { L"m25p20", { 0x20, 0x20, 0x12 }, 3, 256, 64 * 1024, 4, 0 },
+ { L"m25p40", { 0x20, 0x20, 0x13 }, 3, 256, 64 * 1024, 8, 0 },
+ { L"m25p80", { 0x20, 0x20, 0x14 }, 3, 256, 64 * 1024, 16, 0 },
+ { L"m25p16", { 0x20, 0x20, 0x15 }, 3, 256, 64 * 1024, 32, 0 },
+ { L"m25pE16", { 0x20, 0x80, 0x15, 0x10, 0x00}, 5, 256, 64 * 1024, 32, 0 },
+ { L"m25pX16", { 0x20, 0x71, 0x15, 0x10, 0x00}, 5, 256, 64 * 1024, 32, 0 },
+ { L"m25p32", { 0x20, 0x20, 0x16 }, 3, 256, 64 * 1024, 64, 0 },
+ { L"m25p64", { 0x20, 0x20, 0x17 }, 3, 256, 64 * 1024, 128, 0 },
+ { L"m25p128", { 0x20, 0x20, 0x18 }, 3, 256, 256 * 1024, 64, 0 },
+ { L"m25pX64", { 0x20, 0x71, 0x17 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"n25q016a", { 0x20, 0xbb, 0x15 }, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K },
+ { L"n25q32", { 0x20, 0xba, 0x16 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"n25q32a", { 0x20, 0xbb, 0x16 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"n25q64", { 0x20, 0xba, 0x17 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"n25q64a", { 0x20, 0xbb, 0x17 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"n25q128", { 0x20, 0xba, 0x18 }, 3, 256, 64 * 1024, 256, 0 },
+ { L"n25q128a", { 0x20, 0xbb, 0x18 }, 3, 256, 64 * 1024, 256, 0 },
+ { L"n25q256", { 0x20, 0xba, 0x19 }, 3, 256, 64 * 1024, 512, NOR_FLASH_ERASE_4K },
+ { L"n25q256a", { 0x20, 0xbb, 0x19 }, 3, 256, 64 * 1024, 512, NOR_FLASH_ERASE_4K },
+ { L"n25q512", { 0x20, 0xba, 0x20 }, 3, 256, 64 * 1024, 1024, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K },
+ { L"n25q512a", { 0x20, 0xbb, 0x20 }, 3, 256, 64 * 1024, 1024, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K },
+ { L"n25q1024", { 0x20, 0xba, 0x21 }, 3, 256, 64 * 1024, 2048, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K },
+ { L"n25q1024a", { 0x20, 0xbb, 0x21 }, 3, 256, 64 * 1024, 2048, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K },
+ { L"mt25qu02g", { 0x20, 0xbb, 0x22 }, 3, 256, 64 * 1024, 4096, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K },
+ { L"mt25ql02g", { 0x20, 0xba, 0x22 }, 3, 256, 64 * 1024, 4096, NOR_FLASH_WRITE_FSR | NOR_FLASH_ERASE_4K },
/* SST */
- {L"sst25vf040b", {0xbf, 0x25, 0x8d}, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K},
- {L"sst25vf080b", {0xbf, 0x25, 0x8e}, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K},
- {L"sst25vf016b", {0xbf, 0x25, 0x41}, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K},
- {L"sst25vf032b", {0xbf, 0x25, 0x4a}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"sst25vf064c", {0xbf, 0x25, 0x4b}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"sst25wf512", {0xbf, 0x25, 0x01}, 3, 256, 64 * 1024, 1, NOR_FLASH_ERASE_4K},
- {L"sst25wf010", {0xbf, 0x25, 0x02}, 3, 256, 64 * 1024, 2, NOR_FLASH_ERASE_4K},
- {L"sst25wf020", {0xbf, 0x25, 0x03}, 3, 256, 64 * 1024, 4, NOR_FLASH_ERASE_4K},
- {L"sst25wf040", {0xbf, 0x25, 0x04}, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K},
- {L"sst25wf040b", {0x62, 0x16, 0x13}, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K},
- {L"sst25wf080", {0xbf, 0x25, 0x05}, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K},
+ { L"sst25vf040b", { 0xbf, 0x25, 0x8d }, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K },
+ { L"sst25vf080b", { 0xbf, 0x25, 0x8e }, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K },
+ { L"sst25vf016b", { 0xbf, 0x25, 0x41 }, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K },
+ { L"sst25vf032b", { 0xbf, 0x25, 0x4a }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"sst25vf064c", { 0xbf, 0x25, 0x4b }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"sst25wf512", { 0xbf, 0x25, 0x01 }, 3, 256, 64 * 1024, 1, NOR_FLASH_ERASE_4K },
+ { L"sst25wf010", { 0xbf, 0x25, 0x02 }, 3, 256, 64 * 1024, 2, NOR_FLASH_ERASE_4K },
+ { L"sst25wf020", { 0xbf, 0x25, 0x03 }, 3, 256, 64 * 1024, 4, NOR_FLASH_ERASE_4K },
+ { L"sst25wf040", { 0xbf, 0x25, 0x04 }, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K },
+ { L"sst25wf040b", { 0x62, 0x16, 0x13 }, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K },
+ { L"sst25wf080", { 0xbf, 0x25, 0x05 }, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K },
/* WINBOND */
- {L"w25p80", {0xef, 0x20, 0x14}, 3, 256, 64 * 1024, 16, 0},
- {L"w25p16", {0xef, 0x20, 0x15}, 3, 256, 64 * 1024, 32, 0},
- {L"w25p32", {0xef, 0x20, 0x16}, 3, 256, 64 * 1024, 64, 0},
- {L"w25x40", {0xef, 0x30, 0x13}, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K},
- {L"w25x16", {0xef, 0x30, 0x15}, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K},
- {L"w25x32", {0xef, 0x30, 0x16}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"w25x64", {0xef, 0x30, 0x17}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"w25q80bl", {0xef, 0x40, 0x14}, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K},
- {L"w25q16cl", {0xef, 0x40, 0x15}, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K},
- {L"w25q32bv", {0xef, 0x40, 0x16}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"w25q64cv", {0xef, 0x40, 0x17}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"w25q128bv", {0xef, 0x40, 0x18}, 3, 256, 64 * 1024, 256, NOR_FLASH_ERASE_4K},
- {L"w25q256", {0xef, 0x40, 0x19}, 3, 256, 64 * 1024, 512, NOR_FLASH_ERASE_4K},
- {L"w25q80bw", {0xef, 0x50, 0x14}, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K},
- {L"w25q16dw", {0xef, 0x60, 0x15}, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K},
- {L"w25q32dw", {0xef, 0x60, 0x16}, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K},
- {L"w25q64dw", {0xef, 0x60, 0x17}, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K},
- {L"w25q128fw", {0xef, 0x60, 0x18}, 3, 256, 64 * 1024, 256, NOR_FLASH_ERASE_4K},
- {}, /* Empty entry to terminate the list */
+ { L"w25p80", { 0xef, 0x20, 0x14 }, 3, 256, 64 * 1024, 16, 0 },
+ { L"w25p16", { 0xef, 0x20, 0x15 }, 3, 256, 64 * 1024, 32, 0 },
+ { L"w25p32", { 0xef, 0x20, 0x16 }, 3, 256, 64 * 1024, 64, 0 },
+ { L"w25x40", { 0xef, 0x30, 0x13 }, 3, 256, 64 * 1024, 8, NOR_FLASH_ERASE_4K },
+ { L"w25x16", { 0xef, 0x30, 0x15 }, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K },
+ { L"w25x32", { 0xef, 0x30, 0x16 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"w25x64", { 0xef, 0x30, 0x17 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"w25q80bl", { 0xef, 0x40, 0x14 }, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K },
+ { L"w25q16cl", { 0xef, 0x40, 0x15 }, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K },
+ { L"w25q32bv", { 0xef, 0x40, 0x16 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"w25q64cv", { 0xef, 0x40, 0x17 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"w25q128bv", { 0xef, 0x40, 0x18 }, 3, 256, 64 * 1024, 256, NOR_FLASH_ERASE_4K },
+ { L"w25q256", { 0xef, 0x40, 0x19 }, 3, 256, 64 * 1024, 512, NOR_FLASH_ERASE_4K },
+ { L"w25q80bw", { 0xef, 0x50, 0x14 }, 3, 256, 64 * 1024, 16, NOR_FLASH_ERASE_4K },
+ { L"w25q16dw", { 0xef, 0x60, 0x15 }, 3, 256, 64 * 1024, 32, NOR_FLASH_ERASE_4K },
+ { L"w25q32dw", { 0xef, 0x60, 0x16 }, 3, 256, 64 * 1024, 64, NOR_FLASH_ERASE_4K },
+ { L"w25q64dw", { 0xef, 0x60, 0x17 }, 3, 256, 64 * 1024, 128, NOR_FLASH_ERASE_4K },
+ { L"w25q128fw", { 0xef, 0x60, 0x18 }, 3, 256, 64 * 1024, 256, NOR_FLASH_ERASE_4K },
+ { }, /* Empty entry to terminate the list */
};
/**
@@ -151,18 +151,18 @@ STATIC CONST NOR_FLASH_INFO NorFlashIds[] = {
EFI_STATUS
EFIAPI
NorFlashGetInfo (
- IN UINT8 *Id,
+ IN UINT8 *Id,
IN OUT NOR_FLASH_INFO **FlashInfo,
- IN BOOLEAN AllocateForRuntime
+ IN BOOLEAN AllocateForRuntime
)
{
- CONST NOR_FLASH_INFO *TmpInfo;
+ CONST NOR_FLASH_INFO *TmpInfo;
/*
* Iterate over NorFlashIds table, in order to find matching entry.
*/
TmpInfo = NorFlashIds;
- for (; TmpInfo->Name != NULL; TmpInfo++) {
+ for ( ; TmpInfo->Name != NULL; TmpInfo++) {
if (CompareMem (TmpInfo->Id, Id, TmpInfo->IdLen) == 0) {
break;
}
@@ -183,6 +183,7 @@ NorFlashGetInfo (
} else {
*FlashInfo = AllocateCopyPool (sizeof (NOR_FLASH_INFO), TmpInfo);
}
+
if (FlashInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -203,7 +204,7 @@ NorFlashPrintInfo (
IN NOR_FLASH_INFO *Info
)
{
- UINTN EraseSize;
+ UINTN EraseSize;
if (Info->Flags & NOR_FLASH_ERASE_4K) {
EraseSize = SIZE_4KB;
@@ -211,10 +212,12 @@ NorFlashPrintInfo (
EraseSize = Info->SectorSize;
}
- DEBUG ((DEBUG_ERROR,
+ DEBUG ((
+ DEBUG_ERROR,
"Detected %s SPI NOR flash with page size %d B, erase size %d KB, total %d MB\n",
Info->Name,
Info->PageSize,
EraseSize / 1024,
- (Info->SectorSize * Info->SectorCount) / 1024 / 1024));
+ (Info->SectorSize * Info->SectorCount) / 1024 / 1024
+ ));
}
diff --git a/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c b/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c
index 12885f4230..e6d72adfb0 100644
--- a/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c
+++ b/EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.c
@@ -13,13 +13,13 @@
#include <Library/PcdLib.h>
#include <Library/PrePiLib.h>
-#define PRE_PI_EXTRACT_GUIDED_SECTION_DATA_GUID { 0x385A982C, 0x2F49, 0x4043, { 0xA5, 0x1E, 0x49, 0x01, 0x02, 0x5C, 0x8B, 0x6B }}
+#define PRE_PI_EXTRACT_GUIDED_SECTION_DATA_GUID { 0x385A982C, 0x2F49, 0x4043, { 0xA5, 0x1E, 0x49, 0x01, 0x02, 0x5C, 0x8B, 0x6B }}
typedef struct {
- UINT32 NumberOfExtractHandler;
- GUID *ExtractHandlerGuidTable;
- EXTRACT_GUIDED_SECTION_DECODE_HANDLER *ExtractDecodeHandlerTable;
- EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *ExtractGetInfoHandlerTable;
+ UINT32 NumberOfExtractHandler;
+ GUID *ExtractHandlerGuidTable;
+ EXTRACT_GUIDED_SECTION_DECODE_HANDLER *ExtractDecodeHandlerTable;
+ EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *ExtractGetInfoHandlerTable;
} PRE_PI_EXTRACT_GUIDED_SECTION_DATA;
PRE_PI_EXTRACT_GUIDED_SECTION_DATA *
@@ -27,10 +27,10 @@ GetSavedData (
VOID
)
{
- EFI_HOB_GUID_TYPE *GuidHob;
- GUID SavedDataGuid = PRE_PI_EXTRACT_GUIDED_SECTION_DATA_GUID;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ GUID SavedDataGuid = PRE_PI_EXTRACT_GUIDED_SECTION_DATA_GUID;
- GuidHob = GetFirstGuidHob(&SavedDataGuid);
+ GuidHob = GetFirstGuidHob (&SavedDataGuid);
GuidHob++;
return (PRE_PI_EXTRACT_GUIDED_SECTION_DATA *)GuidHob;
@@ -46,6 +46,7 @@ ExtractGuidedSectionRegisterHandlers (
{
PRE_PI_EXTRACT_GUIDED_SECTION_DATA *SavedData;
UINT32 Index;
+
//
// Check input parameter.
//
@@ -53,12 +54,12 @@ ExtractGuidedSectionRegisterHandlers (
return RETURN_INVALID_PARAMETER;
}
- SavedData = GetSavedData();
+ SavedData = GetSavedData ();
//
// Search the match registered GetInfo handler for the input guided section.
//
- for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index ++) {
+ for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index++) {
if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], SectionGuid)) {
break;
}
@@ -68,8 +69,8 @@ ExtractGuidedSectionRegisterHandlers (
// If the guided handler has been registered before, only update its handler.
//
if (Index < SavedData->NumberOfExtractHandler) {
- SavedData->ExtractDecodeHandlerTable [Index] = DecodeHandler;
- SavedData->ExtractGetInfoHandlerTable [Index] = GetInfoHandler;
+ SavedData->ExtractDecodeHandlerTable[Index] = DecodeHandler;
+ SavedData->ExtractGetInfoHandlerTable[Index] = GetInfoHandler;
return RETURN_SUCCESS;
}
@@ -83,9 +84,9 @@ ExtractGuidedSectionRegisterHandlers (
//
// Register new Handler and guid value.
//
- CopyGuid (&SavedData->ExtractHandlerGuidTable [SavedData->NumberOfExtractHandler], SectionGuid);
- SavedData->ExtractDecodeHandlerTable [SavedData->NumberOfExtractHandler] = DecodeHandler;
- SavedData->ExtractGetInfoHandlerTable [SavedData->NumberOfExtractHandler++] = GetInfoHandler;
+ CopyGuid (&SavedData->ExtractHandlerGuidTable[SavedData->NumberOfExtractHandler], SectionGuid);
+ SavedData->ExtractDecodeHandlerTable[SavedData->NumberOfExtractHandler] = DecodeHandler;
+ SavedData->ExtractGetInfoHandlerTable[SavedData->NumberOfExtractHandler++] = GetInfoHandler;
return RETURN_SUCCESS;
}
@@ -98,9 +99,9 @@ ExtractGuidedSectionGetGuidList (
{
PRE_PI_EXTRACT_GUIDED_SECTION_DATA *SavedData;
- ASSERT(ExtractHandlerGuidTable != NULL);
+ ASSERT (ExtractHandlerGuidTable != NULL);
- SavedData = GetSavedData();
+ SavedData = GetSavedData ();
*ExtractHandlerGuidTable = SavedData->ExtractHandlerGuidTable;
return SavedData->NumberOfExtractHandler;
@@ -127,18 +128,18 @@ ExtractGuidedSectionGetInfo (
ASSERT (ScratchBufferSize != NULL);
ASSERT (SectionAttribute != NULL);
- SavedData = GetSavedData();
+ SavedData = GetSavedData ();
if (IS_SECTION2 (InputSection)) {
- SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
+ SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid);
} else {
- SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
+ SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid);
}
//
// Search the match registered GetInfo handler for the input guided section.
//
- for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index ++) {
+ for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index++) {
if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {
break;
}
@@ -154,12 +155,12 @@ ExtractGuidedSectionGetInfo (
//
// Call the match handler to getinfo for the input section data.
//
- return SavedData->ExtractGetInfoHandlerTable [Index] (
- InputSection,
- OutputBufferSize,
- ScratchBufferSize,
- SectionAttribute
- );
+ return SavedData->ExtractGetInfoHandlerTable[Index](
+ InputSection,
+ OutputBufferSize,
+ ScratchBufferSize,
+ SectionAttribute
+ );
}
RETURN_STATUS
@@ -182,18 +183,18 @@ ExtractGuidedSectionDecode (
ASSERT (OutputBuffer != NULL);
ASSERT (AuthenticationStatus != NULL);
- SavedData = GetSavedData();
+ SavedData = GetSavedData ();
if (IS_SECTION2 (InputSection)) {
- SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
+ SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid);
} else {
- SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
+ SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid);
}
//
// Search the match registered GetInfo handler for the input guided section.
//
- for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index ++) {
+ for (Index = 0; Index < SavedData->NumberOfExtractHandler; Index++) {
if (CompareGuid (&SavedData->ExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {
break;
}
@@ -209,12 +210,12 @@ ExtractGuidedSectionDecode (
//
// Call the match handler to getinfo for the input section data.
//
- return SavedData->ExtractDecodeHandlerTable [Index] (
- InputSection,
- OutputBuffer,
- ScratchBuffer,
- AuthenticationStatus
- );
+ return SavedData->ExtractDecodeHandlerTable[Index](
+ InputSection,
+ OutputBuffer,
+ ScratchBuffer,
+ AuthenticationStatus
+ );
}
RETURN_STATUS
@@ -229,17 +230,17 @@ ExtractGuidedSectionLibConstructor (
//
// Allocate global pool space to store the registered handler and its guid value.
//
- SavedData.ExtractHandlerGuidTable = (GUID *)AllocatePool(PcdGet32(PcdMaximumGuidedExtractHandler) * sizeof(GUID));
+ SavedData.ExtractHandlerGuidTable = (GUID *)AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (GUID));
if (SavedData.ExtractHandlerGuidTable == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
- SavedData.ExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *)AllocatePool(PcdGet32(PcdMaximumGuidedExtractHandler) * sizeof(EXTRACT_GUIDED_SECTION_DECODE_HANDLER));
+ SavedData.ExtractDecodeHandlerTable = (EXTRACT_GUIDED_SECTION_DECODE_HANDLER *)AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_DECODE_HANDLER));
if (SavedData.ExtractDecodeHandlerTable == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
- SavedData.ExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *)AllocatePool(PcdGet32(PcdMaximumGuidedExtractHandler) * sizeof(EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER));
+ SavedData.ExtractGetInfoHandlerTable = (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER *)AllocatePool (PcdGet32 (PcdMaximumGuidedExtractHandler) * sizeof (EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER));
if (SavedData.ExtractGetInfoHandlerTable == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
@@ -249,7 +250,7 @@ ExtractGuidedSectionLibConstructor (
//
SavedData.NumberOfExtractHandler = 0;
- BuildGuidDataHob(&HobGuid, &SavedData, sizeof(SavedData));
+ BuildGuidDataHob (&HobGuid, &SavedData, sizeof (SavedData));
return RETURN_SUCCESS;
}
diff --git a/EmbeddedPkg/Library/PrePiHobLib/Hob.c b/EmbeddedPkg/Library/PrePiHobLib/Hob.c
index 69d899e3c7..8eb175aa96 100644
--- a/EmbeddedPkg/Library/PrePiHobLib/Hob.c
+++ b/EmbeddedPkg/Library/PrePiHobLib/Hob.c
@@ -44,8 +44,6 @@ GetHobList (
return PrePeiGetHobList ();
}
-
-
/**
Updates the pointer to the HOB list.
@@ -55,7 +53,7 @@ GetHobList (
EFI_STATUS
EFIAPI
SetHobList (
- IN VOID *HobList
+ IN VOID *HobList
)
{
return PrePeiSetHobList (HobList);
@@ -65,7 +63,7 @@ SetHobList (
**/
-EFI_HOB_HANDOFF_INFO_TABLE*
+EFI_HOB_HANDOFF_INFO_TABLE *
HobConstructor (
IN VOID *EfiMemoryBegin,
IN UINTN EfiMemoryLength,
@@ -79,16 +77,16 @@ HobConstructor (
Hob = EfiFreeMemoryBottom;
HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
- Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
- Hob->Header.HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE);
- Hob->Header.Reserved = 0;
+ Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
+ Hob->Header.HobLength = sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
+ Hob->Header.Reserved = 0;
- HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
- HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
- HobEnd->Reserved = 0;
+ HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
+ HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
+ HobEnd->Reserved = 0;
- Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
- Hob->BootMode = BOOT_WITH_FULL_CONFIGURATION;
+ Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
+ Hob->BootMode = BOOT_WITH_FULL_CONFIGURATION;
Hob->EfiMemoryTop = (UINTN)EfiMemoryBegin + EfiMemoryLength;
Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
@@ -101,8 +99,8 @@ HobConstructor (
VOID *
CreateHob (
- IN UINT16 HobType,
- IN UINT16 HobLength
+ IN UINT16 HobType,
+ IN UINT16 HobLength
)
{
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
@@ -117,22 +115,22 @@ CreateHob (
FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob->EfiFreeMemoryBottom;
if (FreeMemory < HobLength) {
- return NULL;
+ return NULL;
}
- Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
- ((EFI_HOB_GENERIC_HEADER*) Hob)->HobType = HobType;
- ((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength = HobLength;
- ((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved = 0;
+ Hob = (VOID *)(UINTN)HandOffHob->EfiEndOfHobList;
+ ((EFI_HOB_GENERIC_HEADER *)Hob)->HobType = HobType;
+ ((EFI_HOB_GENERIC_HEADER *)Hob)->HobLength = HobLength;
+ ((EFI_HOB_GENERIC_HEADER *)Hob)->Reserved = 0;
- HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength);
- HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
+ HobEnd = (EFI_HOB_GENERIC_HEADER *)((UINTN)Hob + HobLength);
+ HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
- HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
+ HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->Reserved = 0;
HobEnd++;
- HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
+ HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
return Hob;
}
@@ -161,7 +159,7 @@ BuildResourceDescriptorHob (
EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
- ASSERT(Hob != NULL);
+ ASSERT (Hob != NULL);
Hob->ResourceType = ResourceType;
Hob->ResourceAttribute = ResourceAttribute;
@@ -177,8 +175,7 @@ BuildFvHobs (
IN EFI_RESOURCE_ATTRIBUTE_TYPE *ResourceAttribute
)
{
-
- EFI_RESOURCE_ATTRIBUTE_TYPE Resource;
+ EFI_RESOURCE_ATTRIBUTE_TYPE Resource;
BuildFvHob (PhysicalStart, NumberOfBytes);
@@ -213,15 +210,15 @@ BuildFvHobs (
VOID *
EFIAPI
GetNextHob (
- IN UINT16 Type,
- IN CONST VOID *HobStart
+ IN UINT16 Type,
+ IN CONST VOID *HobStart
)
{
EFI_PEI_HOB_POINTERS Hob;
ASSERT (HobStart != NULL);
- Hob.Raw = (UINT8 *) HobStart;
+ Hob.Raw = (UINT8 *)HobStart;
//
// Parse the HOB list until end of list or matching type is found.
//
@@ -229,13 +226,13 @@ GetNextHob (
if (Hob.Header->HobType == Type) {
return Hob.Raw;
}
+
Hob.Raw = GET_NEXT_HOB (Hob);
}
+
return NULL;
}
-
-
/**
Returns the first instance of a HOB type among the whole HOB list.
@@ -250,16 +247,15 @@ GetNextHob (
VOID *
EFIAPI
GetFirstHob (
- IN UINT16 Type
+ IN UINT16 Type
)
{
- VOID *HobList;
+ VOID *HobList;
HobList = GetHobList ();
return GetNextHob (Type, HobList);
}
-
/**
This function searches the first instance of a HOB from the starting HOB pointer.
Such HOB should satisfy two conditions:
@@ -282,22 +278,24 @@ GetFirstHob (
VOID *
EFIAPI
GetNextGuidHob (
- IN CONST EFI_GUID *Guid,
- IN CONST VOID *HobStart
- ){
+ IN CONST EFI_GUID *Guid,
+ IN CONST VOID *HobStart
+ )
+{
EFI_PEI_HOB_POINTERS GuidHob;
- GuidHob.Raw = (UINT8 *) HobStart;
+ GuidHob.Raw = (UINT8 *)HobStart;
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
break;
}
+
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
}
+
return GuidHob.Raw;
}
-
/**
This function searches the first instance of a HOB among the whole HOB list.
Such HOB should satisfy two conditions:
@@ -315,16 +313,15 @@ GetNextGuidHob (
VOID *
EFIAPI
GetFirstGuidHob (
- IN CONST EFI_GUID *Guid
+ IN CONST EFI_GUID *Guid
)
{
- VOID *HobList;
+ VOID *HobList;
HobList = GetHobList ();
return GetNextGuidHob (Guid, HobList);
}
-
/**
Get the Boot Mode from the HOB list.
@@ -348,7 +345,6 @@ GetBootMode (
return Hob.HandoffInformationTable->BootMode;
}
-
/**
Get the Boot Mode from the HOB list.
@@ -363,12 +359,12 @@ GetBootMode (
EFI_STATUS
EFIAPI
SetBootMode (
- IN EFI_BOOT_MODE BootMode
+ IN EFI_BOOT_MODE BootMode
)
{
EFI_PEI_HOB_POINTERS Hob;
- Hob.Raw = GetHobList ();
+ Hob.Raw = GetHobList ();
Hob.HandoffInformationTable->BootMode = BootMode;
return BootMode;
}
@@ -391,16 +387,18 @@ SetBootMode (
VOID
EFIAPI
BuildModuleHob (
- IN CONST EFI_GUID *ModuleName,
- IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
- IN UINT64 ModuleLength,
- IN EFI_PHYSICAL_ADDRESS EntryPoint
+ IN CONST EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
)
{
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
- ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
- ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
+ ASSERT (
+ ((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
+ ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)
+ );
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
@@ -439,23 +437,22 @@ BuildModuleHob (
VOID *
EFIAPI
BuildGuidHob (
- IN CONST EFI_GUID *Guid,
- IN UINTN DataLength
+ IN CONST EFI_GUID *Guid,
+ IN UINTN DataLength
)
{
- EFI_HOB_GUID_TYPE *Hob;
+ EFI_HOB_GUID_TYPE *Hob;
//
// Make sure that data length is not too long.
//
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
- Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));
+ Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));
CopyGuid (&Hob->Name, Guid);
return Hob + 1;
}
-
/**
Copies a data buffer to a newly-built HOB.
@@ -479,9 +476,9 @@ BuildGuidHob (
VOID *
EFIAPI
BuildGuidDataHob (
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN UINTN DataLength
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
)
{
VOID *HobData;
@@ -493,7 +490,6 @@ BuildGuidDataHob (
return CopyMem (HobData, Data, DataLength);
}
-
/**
Builds a Firmware Volume HOB.
@@ -509,8 +505,8 @@ BuildGuidDataHob (
VOID
EFIAPI
BuildFvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
)
{
EFI_HOB_FIRMWARE_VOLUME *Hob;
@@ -521,7 +517,6 @@ BuildFvHob (
Hob->Length = Length;
}
-
/**
Builds a EFI_HOB_TYPE_FV2 HOB.
@@ -539,10 +534,10 @@ BuildFvHob (
VOID
EFIAPI
BuildFv2Hob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN CONST EFI_GUID *FvName,
- IN CONST EFI_GUID *FileName
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN CONST EFI_GUID *FvName,
+ IN CONST EFI_GUID *FileName
)
{
EFI_HOB_FIRMWARE_VOLUME2 *Hob;
@@ -578,12 +573,12 @@ BuildFv2Hob (
VOID
EFIAPI
BuildFv3Hob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN UINT32 AuthenticationStatus,
- IN BOOLEAN ExtractedFv,
- IN CONST EFI_GUID *FvName OPTIONAL,
- IN CONST EFI_GUID *FileName OPTIONAL
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT32 AuthenticationStatus,
+ IN BOOLEAN ExtractedFv,
+ IN CONST EFI_GUID *FvName OPTIONAL,
+ IN CONST EFI_GUID *FileName OPTIONAL
)
{
EFI_HOB_FIRMWARE_VOLUME3 *Hob;
@@ -615,14 +610,13 @@ BuildFv3Hob (
VOID
EFIAPI
BuildCvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
)
{
ASSERT (FALSE);
}
-
/**
Builds a HOB for the CPU.
@@ -638,8 +632,8 @@ BuildCvHob (
VOID
EFIAPI
BuildCpuHob (
- IN UINT8 SizeOfMemorySpace,
- IN UINT8 SizeOfIoSpace
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
)
{
EFI_HOB_CPU *Hob;
@@ -655,7 +649,6 @@ BuildCpuHob (
ZeroMem (Hob->Reserved, sizeof (Hob->Reserved));
}
-
/**
Builds a HOB for the Stack.
@@ -671,14 +664,16 @@ BuildCpuHob (
VOID
EFIAPI
BuildStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
)
{
EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;
- ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
- ((Length & (EFI_PAGE_SIZE - 1)) == 0));
+ ASSERT (
+ ((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
+ ((Length & (EFI_PAGE_SIZE - 1)) == 0)
+ );
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));
@@ -693,7 +688,6 @@ BuildStackHob (
ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
}
-
/**
Update the Stack Hob if the stack has been moved
@@ -703,11 +697,11 @@ BuildStackHob (
**/
VOID
UpdateStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
)
{
- EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS Hob;
Hob.Raw = GetHobList ();
while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {
@@ -725,15 +719,14 @@ UpdateStackHob (
// Update the BSP Stack Hob to reflect the new stack info.
//
Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress = BaseAddress;
- Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length;
+ Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length;
break;
}
+
Hob.Raw = GET_NEXT_HOB (Hob);
}
}
-
-
/**
Builds a HOB for the memory allocation.
@@ -750,15 +743,17 @@ UpdateStackHob (
VOID
EFIAPI
BuildMemoryAllocationHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN EFI_MEMORY_TYPE MemoryType
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
)
{
EFI_HOB_MEMORY_ALLOCATION *Hob;
- ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
- ((Length & (EFI_PAGE_SIZE - 1)) == 0));
+ ASSERT (
+ ((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
+ ((Length & (EFI_PAGE_SIZE - 1)) == 0)
+ );
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
@@ -772,24 +767,22 @@ BuildMemoryAllocationHob (
ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
}
-
-
VOID
EFIAPI
BuildExtractSectionHob (
- IN EFI_GUID *Guid,
- IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo,
- IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction
+ IN EFI_GUID *Guid,
+ IN EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER SectionGetInfo,
+ IN EXTRACT_GUIDED_SECTION_DECODE_HANDLER SectionExtraction
)
{
- EXTRACT_SECTION_DATA Data;
+ EXTRACT_SECTION_DATA Data;
Data.SectionGetInfo = SectionGetInfo;
Data.SectionExtraction = SectionExtraction;
BuildGuidDataHob (Guid, &Data, sizeof (Data));
}
-PE_COFF_LOADER_PROTOCOL gPeCoffProtocol = {
+PE_COFF_LOADER_PROTOCOL gPeCoffProtocol = {
PeCoffLoaderGetImageInfo,
PeCoffLoaderLoadImage,
PeCoffLoaderRelocateImage,
@@ -798,8 +791,6 @@ PE_COFF_LOADER_PROTOCOL gPeCoffProtocol = {
PeCoffLoaderUnloadImage
};
-
-
VOID
EFIAPI
BuildPeCoffLoaderHob (
@@ -818,7 +809,7 @@ BuildMemoryTypeInformationHob (
VOID
)
{
- EFI_MEMORY_TYPE_INFORMATION Info[10];
+ EFI_MEMORY_TYPE_INFORMATION Info[10];
Info[0].Type = EfiACPIReclaimMemory;
Info[0].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory);
@@ -843,6 +834,5 @@ BuildMemoryTypeInformationHob (
Info[9].Type = EfiMaxMemoryType;
Info[9].NumberOfPages = 0;
-
BuildGuidDataHob (&gEfiMemoryTypeInformationGuid, &Info, sizeof (Info));
}
diff --git a/EmbeddedPkg/Library/PrePiLib/FwVol.c b/EmbeddedPkg/Library/PrePiLib/FwVol.c
index 7b9853bab7..92ae68f0d3 100644
--- a/EmbeddedPkg/Library/PrePiLib/FwVol.c
+++ b/EmbeddedPkg/Library/PrePiLib/FwVol.c
@@ -12,11 +12,9 @@
#include <PrePi.h>
#include <Library/ExtractGuidedSectionLib.h>
-
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
-
/**
Returns the highest bit set of the State field
@@ -30,7 +28,7 @@
**/
STATIC
EFI_FFS_FILE_STATE
-GetFileState(
+GetFileState (
IN UINT8 ErasePolarity,
IN EFI_FFS_FILE_HEADER *FfsHeader
)
@@ -41,7 +39,7 @@ GetFileState(
FileState = FfsHeader->State;
if (ErasePolarity != 0) {
- FileState = (EFI_FFS_FILE_STATE)~FileState;
+ FileState = (EFI_FFS_FILE_STATE) ~FileState;
}
HighestBit = 0x80;
@@ -52,7 +50,6 @@ GetFileState(
return HighestBit;
}
-
/**
Calculates the checksum of the header of a file.
The header is a zero byte checksum, so zero means header is good
@@ -68,21 +65,21 @@ CalculateHeaderChecksum (
IN EFI_FFS_FILE_HEADER *FileHeader
)
{
- UINT8 *Ptr;
- UINTN Index;
- UINT8 Sum;
+ UINT8 *Ptr;
+ UINTN Index;
+ UINT8 Sum;
Sum = 0;
Ptr = (UINT8 *)FileHeader;
- for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER) - 3; Index += 4) {
+ 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++) {
+ for ( ; Index < sizeof (EFI_FFS_FILE_HEADER); Index++) {
Sum = (UINT8)(Sum + Ptr[Index]);
}
@@ -98,7 +95,6 @@ CalculateHeaderChecksum (
return Sum;
}
-
/**
Given a FileHandle return the VolumeHandle
@@ -112,8 +108,8 @@ STATIC
BOOLEAN
EFIAPI
FileHandleToVolume (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT EFI_PEI_FV_HANDLE *VolumeHandle
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_PEI_FV_HANDLE *VolumeHandle
)
{
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
@@ -128,8 +124,9 @@ FileHandleToVolume (
Hob.Raw = GetNextHob (EFI_HOB_TYPE_FV, Hob.Raw);
if (Hob.Raw != NULL) {
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)(Hob.FirmwareVolume->BaseAddress);
- if (((UINT64) (UINTN) FileHandle > (UINT64) (UINTN) FwVolHeader ) && \
- ((UINT64) (UINTN) FileHandle <= ((UINT64) (UINTN) FwVolHeader + FwVolHeader->FvLength - 1))) {
+ if (((UINT64)(UINTN)FileHandle > (UINT64)(UINTN)FwVolHeader) && \
+ ((UINT64)(UINTN)FileHandle <= ((UINT64)(UINTN)FwVolHeader + FwVolHeader->FvLength - 1)))
+ {
*VolumeHandle = (EFI_PEI_FV_HANDLE)FwVolHeader;
return TRUE;
}
@@ -141,8 +138,6 @@ FileHandleToVolume (
return FALSE;
}
-
-
/**
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
@@ -155,22 +150,22 @@ FileHandleToVolume (
**/
EFI_STATUS
FindFileEx (
- IN CONST EFI_PEI_FV_HANDLE FvHandle,
- IN CONST EFI_GUID *FileName OPTIONAL,
- IN EFI_FV_FILETYPE SearchType,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN CONST EFI_PEI_FV_HANDLE FvHandle,
+ IN CONST EFI_GUID *FileName OPTIONAL,
+ IN EFI_FV_FILETYPE SearchType,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
{
- EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
- EFI_FFS_FILE_HEADER **FileHeader;
- EFI_FFS_FILE_HEADER *FfsFileHeader;
- EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
- UINT32 FileLength;
- UINT32 FileOccupiedSize;
- UINT32 FileOffset;
- UINT64 FvLength;
- UINT8 ErasePolarity;
- UINT8 FileState;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ EFI_FFS_FILE_HEADER **FileHeader;
+ EFI_FFS_FILE_HEADER *FfsFileHeader;
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
+ UINT32 FileLength;
+ UINT32 FileOccupiedSize;
+ UINT32 FileOffset;
+ UINT64 FvLength;
+ UINT8 ErasePolarity;
+ UINT8 FileState;
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvHandle;
FileHeader = (EFI_FFS_FILE_HEADER **)FileHandle;
@@ -191,22 +186,22 @@ FindFileEx (
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);
if (FwVolHeader->ExtHeaderOffset != 0) {
FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(((UINT8 *)FwVolHeader) + FwVolHeader->ExtHeaderOffset);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FwVolExHeaderInfo) + FwVolExHeaderInfo->ExtHeaderSize);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FwVolExHeaderInfo) + FwVolExHeaderInfo->ExtHeaderSize);
}
} 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;
+ FileLength = *(UINT32 *)(*FileHeader)->Size & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)*FileHeader + FileOccupiedSize);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)*FileHeader + FileOccupiedSize);
}
// FFS files begin with a header that is aligned on an 8-byte boundary
FfsFileHeader = ALIGN_POINTER (FfsFileHeader, 8);
- FileOffset = (UINT32) ((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader);
+ FileOffset = (UINT32)((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader);
ASSERT (FileOffset <= 0xFFFFFFFF);
while (FileOffset < (FvLength - sizeof (EFI_FFS_FILE_HEADER))) {
@@ -216,57 +211,55 @@ FindFileEx (
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) {
+ ASSERT (FALSE);
+ *FileHeader = NULL;
+ return EFI_NOT_FOUND;
+ }
- 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) {
- ASSERT (FALSE);
- *FileHeader = NULL;
- return EFI_NOT_FOUND;
- }
-
- FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
- FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
+ FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
+ FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
- if (FileName != NULL) {
- if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID*)FileName)) {
+ if (FileName != NULL) {
+ if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID *)FileName)) {
+ *FileHeader = FfsFileHeader;
+ return EFI_SUCCESS;
+ }
+ } else if (((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) &&
+ (FfsFileHeader->Type != EFI_FV_FILETYPE_FFS_PAD))
+ {
*FileHeader = FfsFileHeader;
return EFI_SUCCESS;
}
- } else if (((SearchType == FfsFileHeader->Type) || (SearchType == EFI_FV_FILETYPE_ALL)) &&
- (FfsFileHeader->Type != EFI_FV_FILETYPE_FFS_PAD)) {
- *FileHeader = FfsFileHeader;
- return EFI_SUCCESS;
- }
- FileOffset += FileOccupiedSize;
- FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
- break;
+ FileOffset += FileOccupiedSize;
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
+ 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;
+ 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:
- *FileHeader = NULL;
- return EFI_NOT_FOUND;
+ default:
+ *FileHeader = NULL;
+ return EFI_NOT_FOUND;
}
}
-
*FileHeader = NULL;
return EFI_NOT_FOUND;
}
-
/**
Go through the file to search SectionType section,
when meeting an encapsuled section.
@@ -286,20 +279,19 @@ FfsProcessSection (
OUT VOID **OutputBuffer
)
{
- EFI_STATUS Status;
- UINT32 SectionLength;
- UINT32 ParsedLength;
- EFI_COMPRESSION_SECTION *CompressionSection;
- EFI_COMPRESSION_SECTION2 *CompressionSection2;
- UINT32 DstBufferSize;
- VOID *ScratchBuffer;
- UINT32 ScratchBufferSize;
- VOID *DstBuffer;
- UINT16 SectionAttribute;
- UINT32 AuthenticationStatus;
- CHAR8 *CompressedData;
- UINTN CompressedDataLength;
-
+ EFI_STATUS Status;
+ UINT32 SectionLength;
+ UINT32 ParsedLength;
+ EFI_COMPRESSION_SECTION *CompressionSection;
+ EFI_COMPRESSION_SECTION2 *CompressionSection2;
+ UINT32 DstBufferSize;
+ VOID *ScratchBuffer;
+ UINT32 ScratchBufferSize;
+ VOID *DstBuffer;
+ UINT16 SectionAttribute;
+ UINT32 AuthenticationStatus;
+ CHAR8 *CompressedData;
+ UINTN CompressedDataLength;
*OutputBuffer = NULL;
ParsedLength = 0;
@@ -311,35 +303,34 @@ FfsProcessSection (
if (Section->Type == SectionType) {
if (IS_SECTION2 (Section)) {
- *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));
+ *OutputBuffer = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER2));
} else {
- *OutputBuffer = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));
+ *OutputBuffer = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER));
}
return EFI_SUCCESS;
} else if ((Section->Type == EFI_SECTION_COMPRESSION) || (Section->Type == EFI_SECTION_GUID_DEFINED)) {
-
if (Section->Type == EFI_SECTION_COMPRESSION) {
if (IS_SECTION2 (Section)) {
- CompressionSection2 = (EFI_COMPRESSION_SECTION2 *) Section;
+ CompressionSection2 = (EFI_COMPRESSION_SECTION2 *)Section;
SectionLength = SECTION2_SIZE (Section);
if (CompressionSection2->CompressionType != EFI_STANDARD_COMPRESSION) {
return EFI_UNSUPPORTED;
}
- CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION2 *) Section + 1);
- CompressedDataLength = (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION2);
+ CompressedData = (CHAR8 *)((EFI_COMPRESSION_SECTION2 *)Section + 1);
+ CompressedDataLength = (UINT32)SectionLength - sizeof (EFI_COMPRESSION_SECTION2);
} else {
- CompressionSection = (EFI_COMPRESSION_SECTION *) Section;
- SectionLength = SECTION_SIZE (Section);
+ CompressionSection = (EFI_COMPRESSION_SECTION *)Section;
+ SectionLength = SECTION_SIZE (Section);
if (CompressionSection->CompressionType != EFI_STANDARD_COMPRESSION) {
return EFI_UNSUPPORTED;
}
- CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1);
- CompressedDataLength = (UINT32) SectionLength - sizeof (EFI_COMPRESSION_SECTION);
+ CompressedData = (CHAR8 *)((EFI_COMPRESSION_SECTION *)Section + 1);
+ CompressedDataLength = (UINT32)SectionLength - sizeof (EFI_COMPRESSION_SECTION);
}
Status = UefiDecompressGetInfo (
@@ -364,6 +355,7 @@ FfsProcessSection (
DEBUG ((DEBUG_ERROR, "Decompress GetInfo Failed - %r\n", Status));
return EFI_NOT_FOUND;
}
+
//
// Allocate scratch buffer
//
@@ -371,6 +363,7 @@ FfsProcessSection (
if (ScratchBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// Allocate destination buffer, extra one page for adjustment
//
@@ -378,37 +371,39 @@ FfsProcessSection (
if (DstBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// DstBuffer still is one section. Adjust DstBuffer offset, skip EFI section header
// to make section data at page alignment.
//
- if (IS_SECTION2 (Section))
+ if (IS_SECTION2 (Section)) {
DstBuffer = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER2);
- else
+ } else {
DstBuffer = (UINT8 *)DstBuffer + EFI_PAGE_SIZE - sizeof (EFI_COMMON_SECTION_HEADER);
+ }
+
//
// Call decompress function
//
if (Section->Type == EFI_SECTION_COMPRESSION) {
if (IS_SECTION2 (Section)) {
- CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION2 *) Section + 1);
- }
- else {
- CompressedData = (CHAR8 *) ((EFI_COMPRESSION_SECTION *) Section + 1);
+ CompressedData = (CHAR8 *)((EFI_COMPRESSION_SECTION2 *)Section + 1);
+ } else {
+ CompressedData = (CHAR8 *)((EFI_COMPRESSION_SECTION *)Section + 1);
}
Status = UefiDecompress (
- CompressedData,
- DstBuffer,
- ScratchBuffer
- );
+ CompressedData,
+ DstBuffer,
+ ScratchBuffer
+ );
} else if (Section->Type == EFI_SECTION_GUID_DEFINED) {
Status = ExtractGuidedSectionDecode (
- Section,
- &DstBuffer,
- ScratchBuffer,
- &AuthenticationStatus
- );
+ Section,
+ &DstBuffer,
+ ScratchBuffer,
+ &AuthenticationStatus
+ );
}
if (EFI_ERROR (Status)) {
@@ -419,12 +414,12 @@ FfsProcessSection (
return EFI_NOT_FOUND;
} else {
return FfsProcessSection (
- SectionType,
- DstBuffer,
- DstBufferSize,
- OutputBuffer
- );
- }
+ SectionType,
+ DstBuffer,
+ DstBufferSize,
+ OutputBuffer
+ );
+ }
}
if (IS_SECTION2 (Section)) {
@@ -432,6 +427,7 @@ FfsProcessSection (
} else {
SectionLength = SECTION_SIZE (Section);
}
+
//
// SectionLength is adjusted it is 4 byte aligned.
// Go to the next section
@@ -439,14 +435,12 @@ FfsProcessSection (
SectionLength = GET_OCCUPIED_SIZE (SectionLength, 4);
ASSERT (SectionLength != 0);
ParsedLength += SectionLength;
- Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
+ Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
}
return EFI_NOT_FOUND;
}
-
-
/**
This service enables discovery sections of a given type within a valid FFS file.
@@ -462,14 +456,14 @@ FfsProcessSection (
EFI_STATUS
EFIAPI
FfsFindSectionData (
- IN EFI_SECTION_TYPE SectionType,
- IN EFI_PEI_FILE_HANDLE FileHandle,
- OUT VOID **SectionData
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData
)
{
- EFI_FFS_FILE_HEADER *FfsFileHeader;
- UINT32 FileSize;
- EFI_COMMON_SECTION_HEADER *Section;
+ EFI_FFS_FILE_HEADER *FfsFileHeader;
+ UINT32 FileSize;
+ EFI_COMMON_SECTION_HEADER *Section;
FfsFileHeader = (EFI_FFS_FILE_HEADER *)(FileHandle);
@@ -478,23 +472,18 @@ FfsFindSectionData (
// 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;
+ Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
+ FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
return FfsProcessSection (
- SectionType,
- Section,
- FileSize,
- SectionData
- );
+ SectionType,
+ Section,
+ FileSize,
+ SectionData
+ );
}
-
-
-
-
-
/**
This service enables discovery of additional firmware files.
@@ -511,15 +500,14 @@ FfsFindSectionData (
EFI_STATUS
EFIAPI
FfsFindNextFile (
- IN UINT8 SearchType,
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN UINT8 SearchType,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
{
return FindFileEx (VolumeHandle, NULL, SearchType, FileHandle);
}
-
/**
This service enables discovery of additional firmware volumes.
@@ -534,12 +522,11 @@ FfsFindNextFile (
EFI_STATUS
EFIAPI
FfsFindNextVolume (
- IN UINTN Instance,
- IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
+ IN UINTN Instance,
+ IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
)
{
- EFI_PEI_HOB_POINTERS Hob;
-
+ EFI_PEI_HOB_POINTERS Hob;
Hob.Raw = GetHobList ();
if (Hob.Raw == NULL) {
@@ -559,10 +546,8 @@ FfsFindNextVolume (
} while (Hob.Raw != NULL);
return EFI_NOT_FOUND;
-
}
-
/**
Find a file in the volume by name
@@ -584,25 +569,25 @@ FfsFindNextVolume (
EFI_STATUS
EFIAPI
FfsFindFileByName (
- IN CONST EFI_GUID *FileName,
- IN EFI_PEI_FV_HANDLE VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN CONST EFI_GUID *FileName,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
)
{
EFI_STATUS Status;
+
if ((VolumeHandle == NULL) || (FileName == NULL) || (FileHandle == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
Status = FindFileEx (VolumeHandle, FileName, 0, FileHandle);
if (Status == EFI_NOT_FOUND) {
*FileHandle = NULL;
}
+
return Status;
}
-
-
-
/**
Get information about the file by name.
@@ -626,10 +611,10 @@ FfsGetFileInfo (
OUT EFI_FV_FILE_INFO *FileInfo
)
{
- UINT8 FileState;
- UINT8 ErasePolarity;
- EFI_FFS_FILE_HEADER *FileHeader;
- EFI_PEI_FV_HANDLE VolumeHandle;
+ UINT8 FileState;
+ UINT8 ErasePolarity;
+ EFI_FFS_FILE_HEADER *FileHeader;
+ EFI_PEI_FV_HANDLE VolumeHandle;
if ((FileHandle == NULL) || (FileInfo == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -639,11 +624,11 @@ FfsGetFileInfo (
//
// Retrieve the FirmwareVolume which the file resides in.
//
- if (!FileHandleToVolume(FileHandle, &VolumeHandle)) {
+ if (!FileHandleToVolume (FileHandle, &VolumeHandle)) {
return EFI_INVALID_PARAMETER;
}
- if (((EFI_FIRMWARE_VOLUME_HEADER*)VolumeHandle)->Attributes & EFI_FVB2_ERASE_POLARITY) {
+ if (((EFI_FIRMWARE_VOLUME_HEADER *)VolumeHandle)->Attributes & EFI_FVB2_ERASE_POLARITY) {
ErasePolarity = 1;
} else {
ErasePolarity = 0;
@@ -652,7 +637,7 @@ FfsGetFileInfo (
//
// Get FileState which is the highest bit of the State
//
- FileState = GetFileState (ErasePolarity, (EFI_FFS_FILE_HEADER*)FileHandle);
+ FileState = GetFileState (ErasePolarity, (EFI_FFS_FILE_HEADER *)FileHandle);
switch (FileState) {
case EFI_FILE_DATA_VALID:
@@ -660,18 +645,17 @@ FfsGetFileInfo (
break;
default:
return EFI_INVALID_PARAMETER;
- }
+ }
FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle;
- CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));
- FileInfo->FileType = FileHeader->Type;
+ CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof (EFI_GUID));
+ FileInfo->FileType = FileHeader->Type;
FileInfo->FileAttributes = FileHeader->Attributes;
- FileInfo->BufferSize = ((*(UINT32 *)FileHeader->Size) & 0x00FFFFFF) - sizeof (EFI_FFS_FILE_HEADER);
- FileInfo->Buffer = (FileHeader + 1);
+ FileInfo->BufferSize = ((*(UINT32 *)FileHeader->Size) & 0x00FFFFFF) - sizeof (EFI_FFS_FILE_HEADER);
+ FileInfo->Buffer = (FileHeader + 1);
return EFI_SUCCESS;
}
-
/**
Get Information about the volume by name
@@ -695,8 +679,8 @@ FfsGetVolumeInfo (
OUT EFI_FV_INFO *VolumeInfo
)
{
- EFI_FIRMWARE_VOLUME_HEADER FwVolHeader;
- EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
+ EFI_FIRMWARE_VOLUME_HEADER FwVolHeader;
+ EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo;
if (VolumeInfo == NULL) {
return EFI_INVALID_PARAMETER;
@@ -714,20 +698,20 @@ FfsGetVolumeInfo (
if (FwVolHeader.Signature != EFI_FVH_SIGNATURE) {
return EFI_INVALID_PARAMETER;
}
+
VolumeInfo->FvAttributes = FwVolHeader.Attributes;
- VolumeInfo->FvStart = (VOID *) VolumeHandle;
- VolumeInfo->FvSize = FwVolHeader.FvLength;
- CopyMem (&VolumeInfo->FvFormat, &FwVolHeader.FileSystemGuid, sizeof(EFI_GUID));
+ VolumeInfo->FvStart = (VOID *)VolumeHandle;
+ VolumeInfo->FvSize = FwVolHeader.FvLength;
+ CopyMem (&VolumeInfo->FvFormat, &FwVolHeader.FileSystemGuid, sizeof (EFI_GUID));
if (FwVolHeader.ExtHeaderOffset != 0) {
- FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER*)(((UINT8 *)VolumeHandle) + FwVolHeader.ExtHeaderOffset);
- CopyMem (&VolumeInfo->FvName, &FwVolExHeaderInfo->FvName, sizeof(EFI_GUID));
+ FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(((UINT8 *)VolumeHandle) + FwVolHeader.ExtHeaderOffset);
+ CopyMem (&VolumeInfo->FvName, &FwVolExHeaderInfo->FvName, sizeof (EFI_GUID));
}
+
return EFI_SUCCESS;
}
-
-
/**
Search through every FV until you find a file of type FileType
@@ -742,13 +726,13 @@ FfsGetVolumeInfo (
EFI_STATUS
EFIAPI
FfsAnyFvFindFirstFile (
- IN EFI_FV_FILETYPE FileType,
- OUT EFI_PEI_FV_HANDLE *VolumeHandle,
- OUT EFI_PEI_FILE_HANDLE *FileHandle
+ IN EFI_FV_FILETYPE FileType,
+ OUT EFI_PEI_FV_HANDLE *VolumeHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
)
{
- EFI_STATUS Status;
- UINTN Instance;
+ EFI_STATUS Status;
+ UINTN Instance;
//
// Search every FV for the DXE Core
@@ -756,17 +740,14 @@ FfsAnyFvFindFirstFile (
Instance = 0;
*FileHandle = NULL;
- while (1)
- {
+ while (1) {
Status = FfsFindNextVolume (Instance++, VolumeHandle);
- if (EFI_ERROR (Status))
- {
+ if (EFI_ERROR (Status)) {
break;
}
Status = FfsFindNextFile (FileType, *VolumeHandle, FileHandle);
- if (!EFI_ERROR (Status))
- {
+ if (!EFI_ERROR (Status)) {
break;
}
}
@@ -774,8 +755,6 @@ FfsAnyFvFindFirstFile (
return Status;
}
-
-
/**
Get Fv image from the FV type file, then add FV & FV2 Hob.
@@ -789,7 +768,7 @@ FfsAnyFvFindFirstFile (
EFI_STATUS
EFIAPI
FfsProcessFvFile (
- IN EFI_PEI_FILE_HANDLE FvFileHandle
+ IN EFI_PEI_FILE_HANDLE FvFileHandle
)
{
EFI_STATUS Status;
@@ -799,8 +778,7 @@ FfsProcessFvFile (
VOID *FvBuffer;
EFI_PEI_HOB_POINTERS HobFv2;
- FvBuffer = NULL;
-
+ FvBuffer = NULL;
//
// Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
@@ -814,6 +792,7 @@ FfsProcessFvFile (
//
return EFI_SUCCESS;
}
+
HobFv2.Raw = GET_NEXT_HOB (HobFv2);
}
@@ -843,30 +822,30 @@ FfsProcessFvFile (
//
// Check FvImage
//
- if ((UINTN) FvImageInfo.FvStart % FvAlignment != 0) {
- FvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvImageInfo.FvSize), FvAlignment);
+ if ((UINTN)FvImageInfo.FvStart % FvAlignment != 0) {
+ FvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32)FvImageInfo.FvSize), FvAlignment);
if (FvBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- CopyMem (FvBuffer, FvImageInfo.FvStart, (UINTN) FvImageInfo.FvSize);
+
+ CopyMem (FvBuffer, FvImageInfo.FvStart, (UINTN)FvImageInfo.FvSize);
//
// Update FvImageInfo after reload FvImage to new aligned memory
//
- FfsGetVolumeInfo ((EFI_PEI_FV_HANDLE) FvBuffer, &FvImageInfo);
+ FfsGetVolumeInfo ((EFI_PEI_FV_HANDLE)FvBuffer, &FvImageInfo);
}
-
//
// Inform HOB consumer phase, i.e. DXE core, the existence of this FV
//
- BuildFvHob ((EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart, FvImageInfo.FvSize);
+ BuildFvHob ((EFI_PHYSICAL_ADDRESS)(UINTN)FvImageInfo.FvStart, FvImageInfo.FvSize);
//
// Makes the encapsulated volume show up in DXE phase to skip processing of
// encapsulated file again.
//
BuildFv2Hob (
- (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,
+ (EFI_PHYSICAL_ADDRESS)(UINTN)FvImageInfo.FvStart,
FvImageInfo.FvSize,
&FvImageInfo.FvName,
&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name)
diff --git a/EmbeddedPkg/Library/PrePiLib/PrePi.h b/EmbeddedPkg/Library/PrePiLib/PrePi.h
index 510322d144..a00c946512 100644
--- a/EmbeddedPkg/Library/PrePiLib/PrePi.h
+++ b/EmbeddedPkg/Library/PrePiLib/PrePi.h
@@ -26,7 +26,6 @@
#include <Guid/MemoryAllocationHob.h>
-
#define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)
#define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)
#define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))
@@ -35,7 +34,7 @@
//
// Get the data and data size field of GUID
//
-#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
-#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
+#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
+#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
#endif
diff --git a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c b/EmbeddedPkg/Library/PrePiLib/PrePiLib.c
index b9344ed865..a0c5d02deb 100644
--- a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c
+++ b/EmbeddedPkg/Library/PrePiLib/PrePiLib.c
@@ -16,21 +16,21 @@ EFI_STATUS
EFIAPI
SecWinNtPeiLoadFile (
- IN VOID *Pe32Data,
- IN EFI_PHYSICAL_ADDRESS *ImageAddress,
- IN UINT64 *ImageSize,
- IN EFI_PHYSICAL_ADDRESS *EntryPoint
+ IN VOID *Pe32Data,
+ IN EFI_PHYSICAL_ADDRESS *ImageAddress,
+ IN UINT64 *ImageSize,
+ IN EFI_PHYSICAL_ADDRESS *EntryPoint
);
STATIC
-VOID*
+VOID *
EFIAPI
AllocateCodePages (
- IN UINTN Pages
+ IN UINTN Pages
)
{
- VOID *Alloc;
- EFI_PEI_HOB_POINTERS Hob;
+ VOID *Alloc;
+ EFI_PEI_HOB_POINTERS Hob;
Alloc = AllocatePages (Pages);
if (Alloc == NULL) {
@@ -44,6 +44,7 @@ AllocateCodePages (
Hob.MemoryAllocation->AllocDescriptor.MemoryType = EfiBootServicesCode;
return Alloc;
}
+
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (Hob));
}
@@ -53,19 +54,18 @@ AllocateCodePages (
return NULL;
}
-
EFI_STATUS
EFIAPI
LoadPeCoffImage (
- IN VOID *PeCoffImage,
- OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
- OUT UINT64 *ImageSize,
- OUT EFI_PHYSICAL_ADDRESS *EntryPoint
+ IN VOID *PeCoffImage,
+ OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
+ OUT UINT64 *ImageSize,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint
)
{
RETURN_STATUS Status;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
- VOID *Buffer;
+ VOID *Buffer;
ZeroMem (&ImageContext, sizeof (ImageContext));
@@ -75,14 +75,12 @@ LoadPeCoffImage (
Status = PeCoffLoaderGetImageInfo (&ImageContext);
ASSERT_EFI_ERROR (Status);
-
//
// Allocate Memory for the image
//
- Buffer = AllocateCodePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSize));
+ Buffer = AllocateCodePages (EFI_SIZE_TO_PAGES ((UINT32)ImageContext.ImageSize));
ASSERT (Buffer != 0);
-
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
//
@@ -97,7 +95,6 @@ LoadPeCoffImage (
Status = PeCoffLoaderRelocateImage (&ImageContext);
ASSERT_EFI_ERROR (Status);
-
*ImageAddress = ImageContext.ImageAddress;
*ImageSize = ImageContext.ImageSize;
*EntryPoint = ImageContext.EntryPoint;
@@ -111,11 +108,9 @@ LoadPeCoffImage (
return Status;
}
-
-
typedef
VOID
-(EFIAPI *DXE_CORE_ENTRY_POINT) (
+(EFIAPI *DXE_CORE_ENTRY_POINT)(
IN VOID *HobStart
);
@@ -126,24 +121,23 @@ LoadDxeCoreFromFfsFile (
IN UINTN StackSize
)
{
- EFI_STATUS Status;
- VOID *PeCoffImage;
- EFI_PHYSICAL_ADDRESS ImageAddress;
- UINT64 ImageSize;
- EFI_PHYSICAL_ADDRESS EntryPoint;
- VOID *BaseOfStack;
- VOID *TopOfStack;
- VOID *Hob;
- EFI_FV_FILE_INFO FvFileInfo;
+ EFI_STATUS Status;
+ VOID *PeCoffImage;
+ EFI_PHYSICAL_ADDRESS ImageAddress;
+ UINT64 ImageSize;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
+ VOID *BaseOfStack;
+ VOID *TopOfStack;
+ VOID *Hob;
+ EFI_FV_FILE_INFO FvFileInfo;
Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
-
Status = LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
-// For NT32 Debug Status = SecWinNtPeiLoadFile (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
+ // For NT32 Debug Status = SecWinNtPeiLoadFile (PeCoffImage, &ImageAddress, &ImageSize, &EntryPoint);
ASSERT_EFI_ERROR (Status);
//
@@ -152,7 +146,7 @@ LoadDxeCoreFromFfsFile (
Status = FfsGetFileInfo (FileHandle, &FvFileInfo);
ASSERT_EFI_ERROR (Status);
- BuildModuleHob (&FvFileInfo.FileName, (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, EntryPoint);
+ BuildModuleHob (&FvFileInfo.FileName, (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32)ImageSize) * EFI_PAGE_SIZE, EntryPoint);
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading DxeCore at 0x%10p EntryPoint=0x%10p\n", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)EntryPoint));
@@ -160,9 +154,8 @@ LoadDxeCoreFromFfsFile (
if (StackSize == 0) {
// User the current stack
- ((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint) (Hob);
+ ((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint)(Hob);
} else {
-
//
// Allocate 128KB for the Stack
//
@@ -173,13 +166,13 @@ LoadDxeCoreFromFfsFile (
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
// for safety.
//
- TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (StackSize) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
+ TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (StackSize) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
//
// Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
//
- UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, StackSize);
+ UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, StackSize);
SwitchStack (
(SWITCH_STACK_ENTRY_POINT)(UINTN)EntryPoint,
@@ -187,7 +180,6 @@ LoadDxeCoreFromFfsFile (
NULL,
TopOfStack
);
-
}
// Should never get here as DXE Core does not return
@@ -197,8 +189,6 @@ LoadDxeCoreFromFfsFile (
return EFI_DEVICE_ERROR;
}
-
-
EFI_STATUS
EFIAPI
LoadDxeCoreFromFv (
@@ -206,9 +196,9 @@ LoadDxeCoreFromFv (
IN UINTN StackSize
)
{
- EFI_STATUS Status;
- EFI_PEI_FV_HANDLE VolumeHandle;
- EFI_PEI_FILE_HANDLE FileHandle = NULL;
+ EFI_STATUS Status;
+ EFI_PEI_FV_HANDLE VolumeHandle;
+ EFI_PEI_FILE_HANDLE FileHandle = NULL;
if (FvInstance != NULL) {
//
@@ -229,16 +219,15 @@ LoadDxeCoreFromFv (
return Status;
}
-
EFI_STATUS
EFIAPI
DecompressFirstFv (
VOID
)
{
- EFI_STATUS Status;
- EFI_PEI_FV_HANDLE VolumeHandle;
- EFI_PEI_FILE_HANDLE FileHandle;
+ EFI_STATUS Status;
+ EFI_PEI_FV_HANDLE VolumeHandle;
+ EFI_PEI_FILE_HANDLE FileHandle;
Status = FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, &VolumeHandle, &FileHandle);
if (!EFI_ERROR (Status)) {
diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
index bae6682c72..78f8da5e95 100644
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
@@ -14,8 +14,6 @@
#include <Library/PrePiLib.h>
#include <Library/DebugLib.h>
-
-
/**
Allocates one or more 4KB pages of type EfiBootServicesData.
@@ -32,11 +30,11 @@
VOID *
EFIAPI
AllocatePages (
- IN UINTN Pages
+ IN UINTN Pages
)
{
- EFI_PEI_HOB_POINTERS Hob;
- EFI_PHYSICAL_ADDRESS Offset;
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PHYSICAL_ADDRESS Offset;
Hob.Raw = GetHobList ();
@@ -65,15 +63,14 @@ AllocatePages (
// Create a memory allocation HOB.
//
BuildMemoryAllocationHob (
- Hob.HandoffInformationTable->EfiFreeMemoryTop,
- Pages * EFI_PAGE_SIZE,
- EfiBootServicesData
- );
+ Hob.HandoffInformationTable->EfiFreeMemoryTop,
+ Pages * EFI_PAGE_SIZE,
+ EfiBootServicesData
+ );
return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
}
}
-
/**
Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
@@ -97,8 +94,8 @@ AllocateAlignedPages (
IN UINTN Alignment
)
{
- VOID *Memory;
- UINTN AlignmentMask;
+ VOID *Memory;
+ UINTN AlignmentMask;
//
// Alignment must be a power of two or zero.
@@ -108,6 +105,7 @@ AllocateAlignedPages (
if (Pages == 0) {
return NULL;
}
+
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
@@ -121,9 +119,9 @@ AllocateAlignedPages (
} else {
AlignmentMask = Alignment - 1;
}
- return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask);
-}
+ return (VOID *)(UINTN)(((UINTN)Memory + AlignmentMask) & ~AlignmentMask);
+}
/**
Frees one or more 4KB pages that were previously allocated with one of the page allocation
@@ -171,11 +169,10 @@ AllocatePool (
IN UINTN AllocationSize
)
{
- EFI_HOB_MEMORY_POOL *Hob;
+ EFI_HOB_MEMORY_POOL *Hob;
Hob = GetHobList ();
-
//
// Verify that there is sufficient memory to satisfy the allocation
//
@@ -183,10 +180,11 @@ AllocatePool (
// Please call AllocatePages for big allocations
return 0;
} else {
-
- Hob = (EFI_HOB_MEMORY_POOL *)CreateHob (EFI_HOB_TYPE_MEMORY_POOL,
+ Hob = (EFI_HOB_MEMORY_POOL *)CreateHob (
+ EFI_HOB_TYPE_MEMORY_POOL,
(UINT16)(sizeof (EFI_HOB_MEMORY_POOL) +
- AllocationSize));
+ AllocationSize)
+ );
return (VOID *)(Hob + 1);
}
}
@@ -210,7 +208,7 @@ AllocateZeroPool (
IN UINTN AllocationSize
)
{
- VOID *Buffer;
+ VOID *Buffer;
Buffer = AllocatePool (AllocationSize);
if (Buffer == NULL) {
@@ -239,7 +237,7 @@ AllocateZeroPool (
VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
// Not implemented yet
diff --git a/EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c b/EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c
index d9f563315f..7e8aaf28f6 100644
--- a/EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c
+++ b/EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c
@@ -15,7 +15,6 @@
#include <Library/IoLib.h>
#include <Library/RealTimeClockLib.h>
-
/**
Returns the current time and date information, and the time-keeping capabilities
of the hardware platform.
@@ -42,7 +41,6 @@ LibGetTime (
return EFI_DEVICE_ERROR;
}
-
/**
Sets the current local time and date information.
@@ -56,7 +54,7 @@ LibGetTime (
EFI_STATUS
EFIAPI
LibSetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
{
//
@@ -65,7 +63,6 @@ LibSetTime (
return EFI_DEVICE_ERROR;
}
-
/**
Returns the current wakeup alarm clock setting.
@@ -81,16 +78,15 @@ LibSetTime (
EFI_STATUS
EFIAPI
LibGetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
)
{
// Not a required feature
return EFI_UNSUPPORTED;
}
-
/**
Sets the system wakeup alarm clock time.
@@ -107,16 +103,14 @@ LibGetWakeupTime (
EFI_STATUS
EFIAPI
LibSetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
+ IN BOOLEAN Enabled,
+ OUT EFI_TIME *Time
)
{
// Not a required feature
return EFI_UNSUPPORTED;
}
-
-
/**
This is the declaration of an EFI image entry point. This can be the entry point to an application
written to this specification, an EFI boot service driver, or an EFI runtime driver.
@@ -130,8 +124,8 @@ LibSetWakeupTime (
EFI_STATUS
EFIAPI
LibRtcInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
//
@@ -140,7 +134,6 @@ LibRtcInitialize (
return EFI_SUCCESS;
}
-
/**
Fixup internal data so that EFI can be call in virtual mode.
Call the passed in Child Notify event and convert any pointers in
@@ -152,8 +145,8 @@ LibRtcInitialize (
VOID
EFIAPI
LibRtcVirtualNotifyEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -164,6 +157,3 @@ LibRtcVirtualNotifyEvent (
//
return;
}
-
-
-
diff --git a/EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c b/EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
index bdf29ca17c..60bbaeb6a8 100644
--- a/EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
+++ b/EmbeddedPkg/Library/TemplateResetSystemLib/ResetSystemLib.c
@@ -10,14 +10,12 @@
**/
-
#include <PiDxe.h>
#include <Library/BaseLib.h>
#include <Library/IoLib.h>
#include <Library/EfiResetSystemLib.h>
-
/**
Resets the entire platform.
@@ -32,40 +30,39 @@
EFI_STATUS
EFIAPI
LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData OPTIONAL
)
{
- UINTN Address;
- UINT8 Data;
-
+ UINTN Address;
+ UINT8 Data;
switch (ResetType) {
- case EfiResetCold:
- // system power cycle
+ case EfiResetCold:
+ // system power cycle
- // Example using IoLib functions to do IO.
- Address = 0x12345678;
- Data = MmioRead8 (Address);
- MmioWrite8 (Address, Data | 0x01);
+ // Example using IoLib functions to do IO.
+ Address = 0x12345678;
+ Data = MmioRead8 (Address);
+ MmioWrite8 (Address, Data | 0x01);
- // Note this is a bad example asa MmioOr8 (Address, 0x01) does the same thing
- break;
+ // Note this is a bad example asa MmioOr8 (Address, 0x01) does the same thing
+ break;
- case EfiResetWarm:
- // not a full power cycle, maybe memory stays around.
- // if not support do the same thing as EfiResetCold.
- break;
+ case EfiResetWarm:
+ // not a full power cycle, maybe memory stays around.
+ // if not support do the same thing as EfiResetCold.
+ break;
- case EfiResetShutdown:
- // turn off the system.
- // if not support do the same thing as EfiResetCold.
- break;
+ case EfiResetShutdown:
+ // turn off the system.
+ // if not support do the same thing as EfiResetCold.
+ break;
- default:
- return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_INVALID_PARAMETER;
}
//
@@ -74,8 +71,6 @@ LibResetSystem (
return EFI_DEVICE_ERROR;
}
-
-
/**
Initialize any infrastructure required for LibResetSystem () to function.
@@ -94,4 +89,3 @@ LibInitializeResetSystem (
{
return EFI_SUCCESS;
}
-
diff --git a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c
index 210d0b2bf1..b03c23773a 100644
--- a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c
+++ b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c
@@ -27,22 +27,22 @@ EpochToEfiTime (
OUT EFI_TIME *Time
)
{
- UINTN a;
- UINTN b;
- UINTN c;
- UINTN d;
- UINTN g;
- UINTN j;
- UINTN m;
- UINTN y;
- UINTN da;
- UINTN db;
- UINTN dc;
- UINTN dg;
- UINTN hh;
- UINTN mm;
- UINTN ss;
- UINTN J;
+ UINTN a;
+ UINTN b;
+ UINTN c;
+ UINTN d;
+ UINTN g;
+ UINTN j;
+ UINTN m;
+ UINTN y;
+ UINTN da;
+ UINTN db;
+ UINTN dc;
+ UINTN dg;
+ UINTN hh;
+ UINTN mm;
+ UINTN ss;
+ UINTN J;
J = (EpochSeconds / 86400) + 2440588;
j = J + 32044;
@@ -65,14 +65,13 @@ EpochToEfiTime (
ss = EpochSeconds % 60;
a = (EpochSeconds - ss) / 60;
mm = a % 60;
- b = (a - mm) / 60;
+ b = (a - mm) / 60;
hh = b % 24;
- Time->Hour = (UINT8)hh;
- Time->Minute = (UINT8)mm;
- Time->Second = (UINT8)ss;
- Time->Nanosecond = 0;
-
+ Time->Hour = (UINT8)hh;
+ Time->Minute = (UINT8)mm;
+ Time->Second = (UINT8)ss;
+ Time->Nanosecond = 0;
}
/**
@@ -89,13 +88,13 @@ EfiGetEpochDays (
IN EFI_TIME *Time
)
{
- UINTN a;
- UINTN y;
- UINTN m;
- UINTN JulianDate; // Absolute Julian Date representation of the supplied Time
- UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY
+ UINTN a;
+ UINTN y;
+ UINTN m;
+ UINTN JulianDate; // Absolute Julian Date representation of the supplied Time
+ UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY
- a = (14 - Time->Month) / 12 ;
+ a = (14 - Time->Month) / 12;
y = Time->Year + 4800 - a;
m = Time->Month + (12*a) - 3;
@@ -121,8 +120,8 @@ EfiTimeToEpoch (
IN EFI_TIME *Time
)
{
- UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY
- UINTN EpochSeconds;
+ UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY
+ UINTN EpochSeconds;
EpochDays = EfiGetEpochDays (Time);
@@ -144,7 +143,7 @@ EfiTimeToWday (
IN EFI_TIME *Time
)
{
- UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY
+ UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY
EpochDays = EfiGetEpochDays (Time);
@@ -165,7 +164,7 @@ EfiTimeToWday (
BOOLEAN
EFIAPI
IsLeapYear (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
{
if (Time->Year % 4 == 0) {
@@ -198,12 +197,13 @@ IsDayValid (
IN EFI_TIME *Time
)
{
- STATIC CONST INTN DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+ STATIC CONST INTN DayOfMonth[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- if (Time->Day < 1 ||
- Time->Day > DayOfMonth[Time->Month - 1] ||
- (Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))
- ) {
+ if ((Time->Day < 1) ||
+ (Time->Day > DayOfMonth[Time->Month - 1]) ||
+ ((Time->Month == 2) && (!IsLeapYear (Time) && (Time->Day > 28)))
+ )
+ {
return FALSE;
}
@@ -267,21 +267,22 @@ IsValidDaylight (
BOOLEAN
EFIAPI
IsTimeValid (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
{
// Check the input parameters are within the range specified by UEFI
if ((Time->Year < 2000) ||
- (Time->Year > 2099) ||
- (Time->Month < 1 ) ||
- (Time->Month > 12 ) ||
- (!IsDayValid (Time) ) ||
- (Time->Hour > 23 ) ||
- (Time->Minute > 59 ) ||
- (Time->Second > 59 ) ||
- (Time->Nanosecond > 999999999) ||
- (!IsValidTimeZone(Time->TimeZone)) ||
- (!IsValidDaylight(Time->Daylight))) {
+ (Time->Year > 2099) ||
+ (Time->Month < 1) ||
+ (Time->Month > 12) ||
+ (!IsDayValid (Time)) ||
+ (Time->Hour > 23) ||
+ (Time->Minute > 59) ||
+ (Time->Second > 59) ||
+ (Time->Nanosecond > 999999999) ||
+ (!IsValidTimeZone (Time->TimeZone)) ||
+ (!IsValidDaylight (Time->Daylight)))
+ {
return FALSE;
}
diff --git a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
index c10c91bc75..fe963a315a 100644
--- a/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
+++ b/EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.c
@@ -23,9 +23,9 @@
#include <Library/TimeBaseLib.h>
#include <Library/UefiRuntimeLib.h>
-STATIC CONST CHAR16 mEpochVariableName[] = L"RtcEpochSeconds";
-STATIC CONST CHAR16 mTimeZoneVariableName[] = L"RtcTimeZone";
-STATIC CONST CHAR16 mDaylightVariableName[] = L"RtcDaylight";
+STATIC CONST CHAR16 mEpochVariableName[] = L"RtcEpochSeconds";
+STATIC CONST CHAR16 mTimeZoneVariableName[] = L"RtcTimeZone";
+STATIC CONST CHAR16 mDaylightVariableName[] = L"RtcDaylight";
/**
Returns the current time and date information, and the time-keeping capabilities
@@ -67,19 +67,19 @@ LibGetTime (
}
// Get the epoch time from non-volatile storage
- Size = sizeof (UINTN);
+ Size = sizeof (UINTN);
EpochSeconds = 0;
- Status = EfiGetVariable (
- (CHAR16 *)mEpochVariableName,
- &gEfiCallerIdGuid,
- NULL,
- &Size,
- (VOID *)&EpochSeconds
- );
+ Status = EfiGetVariable (
+ (CHAR16 *)mEpochVariableName,
+ &gEfiCallerIdGuid,
+ NULL,
+ &Size,
+ (VOID *)&EpochSeconds
+ );
// Fall back to compilation-time epoch if not set
if (EFI_ERROR (Status)) {
- ASSERT(Status != EFI_INVALID_PARAMETER);
- ASSERT(Status != EFI_BUFFER_TOO_SMALL);
+ ASSERT (Status != EFI_INVALID_PARAMETER);
+ ASSERT (Status != EFI_BUFFER_TOO_SMALL);
//
// The following is intended to produce a compilation error on build
// environments where BUILD_EPOCH can not be set from inline shell.
@@ -101,11 +101,12 @@ LibGetTime (
&EpochSeconds
);
}
- Counter = GetPerformanceCounter ();
+
+ Counter = GetPerformanceCounter ();
EpochSeconds += DivU64x64Remainder (Counter, Freq, &Remainder);
// Get the current time zone information from non-volatile storage
- Size = sizeof (TimeZone);
+ Size = sizeof (TimeZone);
Status = EfiGetVariable (
(CHAR16 *)mTimeZoneVariableName,
&gEfiCallerIdGuid,
@@ -115,8 +116,8 @@ LibGetTime (
);
if (EFI_ERROR (Status)) {
- ASSERT(Status != EFI_INVALID_PARAMETER);
- ASSERT(Status != EFI_BUFFER_TOO_SMALL);
+ ASSERT (Status != EFI_INVALID_PARAMETER);
+ ASSERT (Status != EFI_BUFFER_TOO_SMALL);
if (Status != EFI_NOT_FOUND) {
return Status;
@@ -146,8 +147,9 @@ LibGetTime (
Time->TimeZone = TimeZone;
// Check TimeZone bounds: -1440 to 1440 or 2047
- if (((Time->TimeZone < -1440) || (Time->TimeZone > 1440))
- && (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE)) {
+ if ( ((Time->TimeZone < -1440) || (Time->TimeZone > 1440))
+ && (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE))
+ {
Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;
}
@@ -158,18 +160,18 @@ LibGetTime (
}
// Get the current daylight information from non-volatile storage
- Size = sizeof (Daylight);
+ Size = sizeof (Daylight);
Status = EfiGetVariable (
(CHAR16 *)mDaylightVariableName,
&gEfiCallerIdGuid,
NULL,
&Size,
(VOID *)&Daylight
- );
+ );
if (EFI_ERROR (Status)) {
- ASSERT(Status != EFI_INVALID_PARAMETER);
- ASSERT(Status != EFI_BUFFER_TOO_SMALL);
+ ASSERT (Status != EFI_INVALID_PARAMETER);
+ ASSERT (Status != EFI_BUFFER_TOO_SMALL);
if (Status != EFI_NOT_FOUND) {
return Status;
@@ -253,14 +255,16 @@ LibSetTime (
EpochSeconds = EfiTimeToEpoch (Time);
// Adjust for the correct time zone, i.e. convert to UTC time zone
- if ((Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE)
- && (EpochSeconds > Time->TimeZone * SEC_PER_MIN)) {
+ if ( (Time->TimeZone != EFI_UNSPECIFIED_TIMEZONE)
+ && (EpochSeconds > Time->TimeZone * SEC_PER_MIN))
+ {
EpochSeconds -= Time->TimeZone * SEC_PER_MIN;
}
// Adjust for the correct period
- if (((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT)
- && (EpochSeconds > SEC_PER_HOUR)) {
+ if ( ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT)
+ && (EpochSeconds > SEC_PER_HOUR))
+ {
// Convert to un-adjusted time, i.e. fall back one hour
EpochSeconds -= SEC_PER_HOUR;
}
@@ -300,9 +304,9 @@ LibSetTime (
(CHAR16 *)mDaylightVariableName,
&gEfiCallerIdGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- sizeof(Time->Daylight),
+ sizeof (Time->Daylight),
(VOID *)&(Time->Daylight)
- );
+ );
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
diff --git a/EmbeddedPkg/MetronomeDxe/Metronome.c b/EmbeddedPkg/MetronomeDxe/Metronome.c
index 13db25168f..a089231582 100644
--- a/EmbeddedPkg/MetronomeDxe/Metronome.c
+++ b/EmbeddedPkg/MetronomeDxe/Metronome.c
@@ -49,12 +49,11 @@ WaitForTick (
installed. All consumers must treat this as a read-only field.
**/
-EFI_METRONOME_ARCH_PROTOCOL gMetronome = {
+EFI_METRONOME_ARCH_PROTOCOL gMetronome = {
WaitForTick,
FixedPcdGet32 (PcdMetronomeTickPeriod)
};
-
/**
The WaitForTick() function waits for the number of ticks specified by
TickNumber from a known time source in the platform. If TickNumber of
@@ -93,11 +92,8 @@ WaitForTick (
return EFI_SUCCESS;
}
-
EFI_HANDLE gMetronomeHandle = NULL;
-
-
/**
Initialize the state information for the CPU Architectural Protocol
@@ -112,8 +108,8 @@ EFI_HANDLE gMetronomeHandle = NULL;
EFI_STATUS
EFIAPI
MetronomeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -124,11 +120,11 @@ MetronomeInitialize (
Status = gBS->InstallMultipleProtocolInterfaces (
&gMetronomeHandle,
- &gEfiMetronomeArchProtocolGuid, &gMetronome,
+ &gEfiMetronomeArchProtocolGuid,
+ &gMetronome,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
-
diff --git a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
index 85650a6ede..308e8cfca4 100644
--- a/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
+++ b/EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
@@ -26,12 +26,12 @@ EFI_HANDLE mHandle = NULL;
// variable instead.
//
typedef struct {
- INT16 TimeZone;
- UINT8 Daylight;
+ INT16 TimeZone;
+ UINT8 Daylight;
} NON_VOLATILE_TIME_SETTINGS;
-STATIC CONST CHAR16 mTimeSettingsVariableName[] = L"RtcTimeSettings";
-STATIC NON_VOLATILE_TIME_SETTINGS mTimeSettings;
+STATIC CONST CHAR16 mTimeSettingsVariableName[] = L"RtcTimeSettings";
+STATIC NON_VOLATILE_TIME_SETTINGS mTimeSettings;
/**
Returns the current time and date information, and the time-keeping capabilities
@@ -49,8 +49,8 @@ STATIC NON_VOLATILE_TIME_SETTINGS mTimeSettings;
EFI_STATUS
EFIAPI
GetTime (
- OUT EFI_TIME *Time,
- OUT EFI_TIME_CAPABILITIES *Capabilities
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities
)
{
if (Time == NULL) {
@@ -67,8 +67,6 @@ GetTime (
return LibGetTime (Time, Capabilities);
}
-
-
/**
Sets the current local time and date information.
@@ -82,23 +80,23 @@ GetTime (
EFI_STATUS
EFIAPI
SetTime (
- IN EFI_TIME *Time
+ IN EFI_TIME *Time
)
{
- EFI_STATUS Status;
- BOOLEAN TimeSettingsChanged;
+ EFI_STATUS Status;
+ BOOLEAN TimeSettingsChanged;
- if (Time == NULL || !IsTimeValid (Time)) {
+ if ((Time == NULL) || !IsTimeValid (Time)) {
return EFI_INVALID_PARAMETER;
}
TimeSettingsChanged = FALSE;
- if (mTimeSettings.TimeZone != Time->TimeZone ||
- mTimeSettings.Daylight != Time->Daylight) {
-
+ if ((mTimeSettings.TimeZone != Time->TimeZone) ||
+ (mTimeSettings.Daylight != Time->Daylight))
+ {
mTimeSettings.TimeZone = Time->TimeZone;
mTimeSettings.Daylight = Time->Daylight;
- TimeSettingsChanged = TRUE;
+ TimeSettingsChanged = TRUE;
}
Status = LibSetTime (Time);
@@ -114,15 +112,16 @@ SetTime (
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (mTimeSettings),
- (VOID *)&mTimeSettings);
+ (VOID *)&mTimeSettings
+ );
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
}
+
return EFI_SUCCESS;
}
-
/**
Returns the current wakeup alarm clock setting.
@@ -138,12 +137,12 @@ SetTime (
EFI_STATUS
EFIAPI
GetWakeupTime (
- OUT BOOLEAN *Enabled,
- OUT BOOLEAN *Pending,
- OUT EFI_TIME *Time
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
)
{
- if (Time == NULL || Enabled == NULL || Pending == NULL) {
+ if ((Time == NULL) || (Enabled == NULL) || (Pending == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -157,7 +156,6 @@ GetWakeupTime (
return LibGetWakeupTime (Enabled, Pending, Time);
}
-
/**
Sets the system wakeup alarm clock time.
@@ -174,15 +172,13 @@ GetWakeupTime (
EFI_STATUS
EFIAPI
SetWakeupTime (
- IN BOOLEAN Enabled,
- OUT EFI_TIME *Time
+ IN BOOLEAN Enabled,
+ OUT EFI_TIME *Time
)
{
return LibSetWakeupTime (Enabled, Time);
}
-
-
/**
This is the declaration of an EFI image entry point. This can be the entry point to an application
written to this specification, an EFI boot service driver, or an EFI runtime driver.
@@ -196,8 +192,8 @@ SetWakeupTime (
EFI_STATUS
EFIAPI
InitializeRealTimeClock (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -208,14 +204,23 @@ InitializeRealTimeClock (
return Status;
}
- Size = sizeof (mTimeSettings);
- Status = EfiGetVariable ((CHAR16 *)mTimeSettingsVariableName,
- &gEfiCallerIdGuid, NULL, &Size, (VOID *)&mTimeSettings);
+ Size = sizeof (mTimeSettings);
+ Status = EfiGetVariable (
+ (CHAR16 *)mTimeSettingsVariableName,
+ &gEfiCallerIdGuid,
+ NULL,
+ &Size,
+ (VOID *)&mTimeSettings
+ );
if (EFI_ERROR (Status) ||
!IsValidTimeZone (mTimeSettings.TimeZone) ||
- !IsValidDaylight (mTimeSettings.Daylight)) {
- DEBUG ((DEBUG_WARN, "%a: using default timezone/daylight settings\n",
- __FUNCTION__));
+ !IsValidDaylight (mTimeSettings.Daylight))
+ {
+ DEBUG ((
+ DEBUG_WARN,
+ "%a: using default timezone/daylight settings\n",
+ __FUNCTION__
+ ));
mTimeSettings.TimeZone = EFI_UNSPECIFIED_TIMEZONE;
mTimeSettings.Daylight = 0;
@@ -235,4 +240,3 @@ InitializeRealTimeClock (
return Status;
}
-
diff --git a/EmbeddedPkg/ResetRuntimeDxe/reset.c b/EmbeddedPkg/ResetRuntimeDxe/reset.c
index d7e70d5d48..213963b519 100644
--- a/EmbeddedPkg/ResetRuntimeDxe/reset.c
+++ b/EmbeddedPkg/ResetRuntimeDxe/reset.c
@@ -13,7 +13,6 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/EfiResetSystemLib.h>
-
/**
Resets the entire platform.
@@ -28,18 +27,16 @@
VOID
EFIAPI
ResetSystemViaLib (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
LibResetSystem (ResetType, ResetStatus, DataSize, ResetData);
return;
}
-
-
EFI_STATUS
EFIAPI
InitializeReset (
@@ -65,4 +62,3 @@ InitializeReset (
return Status;
}
-
diff --git a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
index fc87115005..32944a8d9d 100644
--- a/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
+++ b/EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOut.c
@@ -65,30 +65,26 @@
#include <Protocol/SimpleTextOut.h>
#include <Protocol/DevicePath.h>
-
-#define MODE0_COLUMN_COUNT 80
-#define MODE0_ROW_COUNT 25
-
+#define MODE0_COLUMN_COUNT 80
+#define MODE0_ROW_COUNT 25
EFI_STATUS
EFIAPI
-TextInReset(
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+TextInReset (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
-
EFI_STATUS
EFIAPI
-ReadKeyStroke(
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
+ReadKeyStroke (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
);
-
EFI_STATUS
EFIAPI
-TextOutReset(
+TextOutReset (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
@@ -96,8 +92,8 @@ TextOutReset(
CHAR8 *
EFIAPI
SafeUnicodeStrToAsciiStr (
- IN CONST CHAR16 *Source,
- OUT CHAR8 *Destination
+ IN CONST CHAR16 *Source,
+ OUT CHAR8 *Destination
);
EFI_STATUS
@@ -107,7 +103,6 @@ OutputString (
IN CHAR16 *String
);
-
EFI_STATUS
EFIAPI
TestString (
@@ -115,7 +110,6 @@ TestString (
IN CHAR16 *String
);
-
EFI_STATUS
EFIAPI
QueryMode (
@@ -125,30 +119,26 @@ QueryMode (
OUT UINTN *Rows
);
-
EFI_STATUS
EFIAPI
-SetMode(
+SetMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber
);
-
EFI_STATUS
EFIAPI
-SetAttribute(
+SetAttribute (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
);
-
EFI_STATUS
EFIAPI
ClearScreen (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
);
-
EFI_STATUS
EFIAPI
SetCursorPosition (
@@ -157,7 +147,6 @@ SetCursorPosition (
IN UINTN Row
);
-
EFI_STATUS
EFIAPI
EnableCursor (
@@ -165,23 +154,22 @@ EnableCursor (
IN BOOLEAN Enable
);
-
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL mSimpleTextIn = {
+EFI_SIMPLE_TEXT_INPUT_PROTOCOL mSimpleTextIn = {
TextInReset,
ReadKeyStroke,
NULL
};
- EFI_SIMPLE_TEXT_OUTPUT_MODE mSimpleTextOutMode = {
+EFI_SIMPLE_TEXT_OUTPUT_MODE mSimpleTextOutMode = {
1,
0,
- EFI_TEXT_ATTR( EFI_LIGHTGRAY, EFI_BLACK ),
+ EFI_TEXT_ATTR (EFI_LIGHTGRAY,EFI_BLACK),
0,
0,
TRUE
};
-EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL mSimpleTextOut = {
+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL mSimpleTextOut = {
TextOutReset,
OutputString,
TestString,
@@ -194,36 +182,36 @@ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL mSimpleTextOut = {
&mSimpleTextOutMode
};
-EFI_HANDLE mInstallHandle = NULL;
+EFI_HANDLE mInstallHandle = NULL;
typedef struct {
- VENDOR_DEVICE_PATH Guid;
- UART_DEVICE_PATH Uart;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH Guid;
+ UART_DEVICE_PATH Uart;
+ EFI_DEVICE_PATH_PROTOCOL End;
} SIMPLE_TEXT_OUT_DEVICE_PATH;
-SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
+SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {
{
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0} },
+ { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0 }
+ },
EFI_CALLER_ID_GUID
},
{
- { MESSAGING_DEVICE_PATH, MSG_UART_DP, { sizeof (UART_DEVICE_PATH), 0} },
- 0, // Reserved
- FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
- FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
- FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)
- FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
+ { MESSAGING_DEVICE_PATH, MSG_UART_DP, { sizeof (UART_DEVICE_PATH), 0 }
+ },
+ 0, // Reserved
+ FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
+ FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
+ FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)
+ FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
},
- { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0} }
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+ }
};
-
-
-
BOOLEAN
TextOutIsValidAscii (
- IN CHAR16 Ascii
+ IN CHAR16 Ascii
)
{
//
@@ -236,59 +224,56 @@ TextOutIsValidAscii (
return FALSE;
}
-
BOOLEAN
TextOutIsValidEfiCntlChar (
- IN CHAR16 Char
+ IN CHAR16 Char
)
{
//
// only support four control characters.
//
- if (Char == CHAR_NULL ||
- Char == CHAR_BACKSPACE ||
- Char == CHAR_LINEFEED ||
- Char == CHAR_CARRIAGE_RETURN ||
- Char == CHAR_TAB ) {
+ if ((Char == CHAR_NULL) ||
+ (Char == CHAR_BACKSPACE) ||
+ (Char == CHAR_LINEFEED) ||
+ (Char == CHAR_CARRIAGE_RETURN) ||
+ (Char == CHAR_TAB))
+ {
return TRUE;
}
return FALSE;
}
-
VOID
EFIAPI
WaitForKeyEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- if (SerialPortPoll ()) {
+ if (SerialPortPoll ()) {
gBS->SignalEvent (Event);
}
}
-
EFI_STATUS
EFIAPI
TextInReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
ReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ OUT EFI_INPUT_KEY *Key
)
{
- CHAR8 Char;
+ CHAR8 Char;
if (!SerialPortPoll ()) {
return EFI_NOT_READY;
@@ -310,113 +295,114 @@ ReadKeyStroke (
if (Char == '[') {
SerialPortRead ((UINT8 *)&Char, 1);
switch (Char) {
- case 'A':
- Key->ScanCode = SCAN_UP;
- break;
- case 'B':
- Key->ScanCode = SCAN_DOWN;
- break;
- case 'C':
- Key->ScanCode = SCAN_RIGHT;
- break;
- case 'D':
- Key->ScanCode = SCAN_LEFT;
- break;
- case 'H':
- Key->ScanCode = SCAN_HOME;
- break;
- case 'K':
- case 'F': // PC ANSI
- Key->ScanCode = SCAN_END;
- break;
- case '@':
- case 'L':
- Key->ScanCode = SCAN_INSERT;
- break;
- case 'P':
- case 'X': // PC ANSI
- Key->ScanCode = SCAN_DELETE;
- break;
- case 'U':
- case '/':
- case 'G': // PC ANSI
- Key->ScanCode = SCAN_PAGE_DOWN;
- break;
- case 'V':
- case '?':
- case 'I': // PC ANSI
- Key->ScanCode = SCAN_PAGE_UP;
- break;
-
- // PCANSI that does not conflict with VT100
- case 'M':
- Key->ScanCode = SCAN_F1;
- break;
- case 'N':
- Key->ScanCode = SCAN_F2;
- break;
- case 'O':
- Key->ScanCode = SCAN_F3;
- break;
- case 'Q':
- Key->ScanCode = SCAN_F5;
- break;
- case 'R':
- Key->ScanCode = SCAN_F6;
- break;
- case 'S':
- Key->ScanCode = SCAN_F7;
- break;
- case 'T':
- Key->ScanCode = SCAN_F8;
- break;
-
- default:
- Key->UnicodeChar = Char;
- break;
+ case 'A':
+ Key->ScanCode = SCAN_UP;
+ break;
+ case 'B':
+ Key->ScanCode = SCAN_DOWN;
+ break;
+ case 'C':
+ Key->ScanCode = SCAN_RIGHT;
+ break;
+ case 'D':
+ Key->ScanCode = SCAN_LEFT;
+ break;
+ case 'H':
+ Key->ScanCode = SCAN_HOME;
+ break;
+ case 'K':
+ case 'F': // PC ANSI
+ Key->ScanCode = SCAN_END;
+ break;
+ case '@':
+ case 'L':
+ Key->ScanCode = SCAN_INSERT;
+ break;
+ case 'P':
+ case 'X': // PC ANSI
+ Key->ScanCode = SCAN_DELETE;
+ break;
+ case 'U':
+ case '/':
+ case 'G': // PC ANSI
+ Key->ScanCode = SCAN_PAGE_DOWN;
+ break;
+ case 'V':
+ case '?':
+ case 'I': // PC ANSI
+ Key->ScanCode = SCAN_PAGE_UP;
+ break;
+
+ // PCANSI that does not conflict with VT100
+ case 'M':
+ Key->ScanCode = SCAN_F1;
+ break;
+ case 'N':
+ Key->ScanCode = SCAN_F2;
+ break;
+ case 'O':
+ Key->ScanCode = SCAN_F3;
+ break;
+ case 'Q':
+ Key->ScanCode = SCAN_F5;
+ break;
+ case 'R':
+ Key->ScanCode = SCAN_F6;
+ break;
+ case 'S':
+ Key->ScanCode = SCAN_F7;
+ break;
+ case 'T':
+ Key->ScanCode = SCAN_F8;
+ break;
+
+ default:
+ Key->UnicodeChar = Char;
+ break;
}
} else if (Char == '0') {
SerialPortRead ((UINT8 *)&Char, 1);
switch (Char) {
- case 'P':
- Key->ScanCode = SCAN_F1;
- break;
- case 'Q':
- Key->ScanCode = SCAN_F2;
- break;
- case 'w':
- Key->ScanCode = SCAN_F3;
- break;
- case 'x':
- Key->ScanCode = SCAN_F4;
- break;
- case 't':
- Key->ScanCode = SCAN_F5;
- break;
- case 'u':
- Key->ScanCode = SCAN_F6;
- break;
- case 'q':
- Key->ScanCode = SCAN_F7;
- break;
- case 'r':
- Key->ScanCode = SCAN_F8;
- break;
- case 'p':
- Key->ScanCode = SCAN_F9;
- break;
- case 'm':
- Key->ScanCode = SCAN_F10;
- break;
- default :
- break;
+ case 'P':
+ Key->ScanCode = SCAN_F1;
+ break;
+ case 'Q':
+ Key->ScanCode = SCAN_F2;
+ break;
+ case 'w':
+ Key->ScanCode = SCAN_F3;
+ break;
+ case 'x':
+ Key->ScanCode = SCAN_F4;
+ break;
+ case 't':
+ Key->ScanCode = SCAN_F5;
+ break;
+ case 'u':
+ Key->ScanCode = SCAN_F6;
+ break;
+ case 'q':
+ Key->ScanCode = SCAN_F7;
+ break;
+ case 'r':
+ Key->ScanCode = SCAN_F8;
+ break;
+ case 'p':
+ Key->ScanCode = SCAN_F9;
+ break;
+ case 'm':
+ Key->ScanCode = SCAN_F10;
+ break;
+ default:
+ break;
}
}
} else if (Char < ' ') {
if ((Char == CHAR_BACKSPACE) ||
(Char == CHAR_TAB) ||
(Char == CHAR_LINEFEED) ||
- (Char == CHAR_CARRIAGE_RETURN)) {
+ (Char == CHAR_CARRIAGE_RETURN))
+ {
// Only let through EFI required control characters
Key->UnicodeChar = (CHAR16)Char;
}
@@ -429,7 +415,6 @@ ReadKeyStroke (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
TextOutReset (
@@ -437,12 +422,12 @@ TextOutReset (
IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- This->SetAttribute(
- This,
- EFI_TEXT_ATTR(This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK)
- );
+ This->SetAttribute (
+ This,
+ EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK)
+ );
Status = This->SetMode (This, 0);
@@ -452,11 +437,11 @@ TextOutReset (
CHAR8 *
EFIAPI
SafeUnicodeStrToAsciiStr (
- IN CONST CHAR16 *Source,
- OUT CHAR8 *Destination
+ IN CONST CHAR16 *Source,
+ OUT CHAR8 *Destination
)
{
- CHAR8 *ReturnValue;
+ CHAR8 *ReturnValue;
ASSERT (Destination != NULL);
@@ -469,9 +454,8 @@ SafeUnicodeStrToAsciiStr (
//
// Source and Destination should not overlap
//
- ASSERT ((UINTN) ((CHAR16 *) Destination - Source) > StrLen (Source));
- ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source));
-
+ ASSERT ((UINTN)((CHAR16 *)Destination - Source) > StrLen (Source));
+ ASSERT ((UINTN)((CHAR8 *)Source - Destination) > StrLen (Source));
ReturnValue = Destination;
while (*Source != '\0') {
@@ -479,11 +463,11 @@ SafeUnicodeStrToAsciiStr (
// If any non-ascii characters in Source then replace it with '?'.
//
if (*Source < 0x80) {
- *Destination = (CHAR8) *Source;
+ *Destination = (CHAR8)*Source;
} else {
*Destination = '?';
- //Surrogate pair check.
+ // Surrogate pair check.
if ((*Source >= 0xD800) && (*Source <= 0xDFFF)) {
Source++;
}
@@ -511,19 +495,19 @@ OutputString (
IN CHAR16 *String
)
{
- UINTN Size;
- CHAR8* OutputString;
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
- UINTN MaxColumn;
- UINTN MaxRow;
-
- Size = StrLen(String) + 1;
- OutputString = AllocatePool(Size);
-
- //If there is any non-ascii characters in String buffer then replace it with '?'
- //Eventually, UnicodeStrToAsciiStr API should be fixed.
- SafeUnicodeStrToAsciiStr(String, OutputString);
+ UINTN Size;
+ CHAR8 *OutputString;
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
+ UINTN MaxColumn;
+ UINTN MaxRow;
+
+ Size = StrLen (String) + 1;
+ OutputString = AllocatePool (Size);
+
+ // If there is any non-ascii characters in String buffer then replace it with '?'
+ // Eventually, UnicodeStrToAsciiStr API should be fixed.
+ SafeUnicodeStrToAsciiStr (String, OutputString);
SerialPortWrite ((UINT8 *)OutputString, Size - 1);
//
@@ -542,47 +526,49 @@ OutputString (
return Status;
}
- for (; *String != CHAR_NULL; String++) {
-
+ for ( ; *String != CHAR_NULL; String++) {
switch (*String) {
- case CHAR_BACKSPACE:
- if (Mode->CursorColumn > 0) {
- Mode->CursorColumn--;
- }
- break;
-
- case CHAR_LINEFEED:
- if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
- Mode->CursorRow++;
- }
- break;
+ case CHAR_BACKSPACE:
+ if (Mode->CursorColumn > 0) {
+ Mode->CursorColumn--;
+ }
- case CHAR_CARRIAGE_RETURN:
- Mode->CursorColumn = 0;
- break;
+ break;
- default:
- if (Mode->CursorColumn >= (INT32) (MaxColumn - 1)) {
- // Move the cursor as if we print CHAR_CARRIAGE_RETURN & CHAR_LINE_FEED
- // CHAR_LINEFEED
- if (Mode->CursorRow < (INT32) (MaxRow - 1)) {
+ case CHAR_LINEFEED:
+ if (Mode->CursorRow < (INT32)(MaxRow - 1)) {
Mode->CursorRow++;
}
- // CHAR_CARIAGE_RETURN
+
+ break;
+
+ case CHAR_CARRIAGE_RETURN:
Mode->CursorColumn = 0;
- } else {
- Mode->CursorColumn++;
- }
- break;
+ break;
+
+ default:
+ if (Mode->CursorColumn >= (INT32)(MaxColumn - 1)) {
+ // Move the cursor as if we print CHAR_CARRIAGE_RETURN & CHAR_LINE_FEED
+ // CHAR_LINEFEED
+ if (Mode->CursorRow < (INT32)(MaxRow - 1)) {
+ Mode->CursorRow++;
+ }
+
+ // CHAR_CARIAGE_RETURN
+ Mode->CursorColumn = 0;
+ } else {
+ Mode->CursorColumn++;
+ }
+
+ break;
}
}
- FreePool(OutputString);
+ FreePool (OutputString);
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
TestString (
@@ -590,7 +576,7 @@ TestString (
IN CHAR16 *String
)
{
- CHAR8 Character;
+ CHAR8 Character;
for ( ; *String != CHAR_NULL; String++) {
Character = (CHAR8)*String;
@@ -602,14 +588,13 @@ TestString (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
QueryMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber,
- OUT UINTN *Columns,
- OUT UINTN *Rows
+ OUT UINTN *Columns,
+ OUT UINTN *Rows
)
{
if (This->Mode->MaxMode > 1) {
@@ -617,20 +602,19 @@ QueryMode (
}
if (ModeNumber == 0) {
- *Columns = MODE0_COLUMN_COUNT;
- *Rows = MODE0_ROW_COUNT;
+ *Columns = MODE0_COLUMN_COUNT;
+ *Rows = MODE0_ROW_COUNT;
return EFI_SUCCESS;
}
return EFI_UNSUPPORTED;
}
-
EFI_STATUS
EFIAPI
SetMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN UINTN ModeNumber
)
{
if (ModeNumber != 0) {
@@ -642,54 +626,51 @@ SetMode (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
-SetAttribute(
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Attribute
+SetAttribute (
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN UINTN Attribute
)
{
This->Mode->Attribute = (INT32)Attribute;
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
ClearScreen (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = This->SetCursorPosition (This, 0, 0);
return Status;
}
-
EFI_STATUS
EFIAPI
SetCursorPosition (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Column,
- IN UINTN Row
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN UINTN Column,
+ IN UINTN Row
)
{
- EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
- EFI_STATUS Status;
- UINTN MaxColumn;
- UINTN MaxRow;
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
+ EFI_STATUS Status;
+ UINTN MaxColumn;
+ UINTN MaxRow;
Mode = This->Mode;
- Status = This->QueryMode(
- This,
- Mode->Mode,
- &MaxColumn,
- &MaxRow
- );
- if (EFI_ERROR(Status)) {
+ Status = This->QueryMode (
+ This,
+ Mode->Mode,
+ &MaxColumn,
+ &MaxRow
+ );
+ if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
@@ -698,12 +679,11 @@ SetCursorPosition (
}
Mode->CursorColumn = (INT32)Column;
- Mode->CursorRow = (INT32)Row;
+ Mode->CursorRow = (INT32)Row;
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
EnableCursor (
@@ -718,15 +698,14 @@ EnableCursor (
return EFI_SUCCESS;
}
-
EFI_STATUS
EFIAPI
SimpleTextInOutEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
@@ -737,16 +716,19 @@ SimpleTextInOutEntryPoint (
);
ASSERT_EFI_ERROR (Status);
- Status = gBS->InstallMultipleProtocolInterfaces(
+ Status = gBS->InstallMultipleProtocolInterfaces (
&mInstallHandle,
- &gEfiSimpleTextInProtocolGuid, &mSimpleTextIn,
- &gEfiSimpleTextOutProtocolGuid, &mSimpleTextOut,
- &gEfiDevicePathProtocolGuid, &mDevicePath,
+ &gEfiSimpleTextInProtocolGuid,
+ &mSimpleTextIn,
+ &gEfiSimpleTextOutProtocolGuid,
+ &mSimpleTextOut,
+ &gEfiDevicePathProtocolGuid,
+ &mDevicePath,
NULL
);
if (!EFI_ERROR (Status)) {
gST->ConOut = &mSimpleTextOut;
- gST->ConIn = &mSimpleTextIn;
+ gST->ConIn = &mSimpleTextIn;
}
return Status;
diff --git a/EmbeddedPkg/Universal/MmcDxe/ComponentName.c b/EmbeddedPkg/Universal/MmcDxe/ComponentName.c
index f5db121782..94ed690028 100644
--- a/EmbeddedPkg/Universal/MmcDxe/ComponentName.c
+++ b/EmbeddedPkg/Universal/MmcDxe/ComponentName.c
@@ -21,16 +21,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName = {
//
// EFI Component Name 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) MmcGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) MmcGetControllerName,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2 = {
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)MmcGetDriverName,
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)MmcGetControllerName,
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
-mMmcDriverNameTable[] = {
- {"eng;en", L"MMC/SD Card Interface Driver"},
- {NULL, NULL}
+ mMmcDriverNameTable[] = {
+ { "eng;en", L"MMC/SD Card Interface Driver" },
+ { NULL, NULL }
};
/**
@@ -145,11 +145,11 @@ MmcGetDriverName (
EFI_STATUS
EFIAPI
MmcGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
diff --git a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
index 54ab95dbd3..0b27f9dcda 100644
--- a/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
+++ b/EmbeddedPkg/Universal/MmcDxe/Diagnostics.c
@@ -17,29 +17,30 @@
#define DIAGNOSTIC_LOGBUFFER_MAXCHAR 1024
-CHAR16* mLogBuffer = NULL;
+CHAR16 *mLogBuffer = NULL;
UINTN mLogRemainChar = 0;
-CHAR16*
+CHAR16 *
DiagnosticInitLog (
- UINTN MaxBufferChar
+ UINTN MaxBufferChar
)
{
mLogRemainChar = MaxBufferChar;
- mLogBuffer = AllocatePool ((UINTN)MaxBufferChar * sizeof (CHAR16));
+ mLogBuffer = AllocatePool ((UINTN)MaxBufferChar * sizeof (CHAR16));
return mLogBuffer;
}
UINTN
DiagnosticLog (
- CONST CHAR16* Str
+ CONST CHAR16 *Str
)
{
- UINTN len = StrLen (Str);
+ UINTN len = StrLen (Str);
+
if (len < mLogRemainChar) {
StrCpyS (mLogBuffer, mLogRemainChar, Str);
mLogRemainChar -= len;
- mLogBuffer += len;
+ mLogBuffer += len;
return len;
} else {
return 0;
@@ -48,12 +49,12 @@ DiagnosticLog (
VOID
GenerateRandomBuffer (
- VOID* Buffer,
- UINTN BufferSize
+ VOID *Buffer,
+ UINTN BufferSize
)
{
UINT64 i;
- UINT64* Buffer64 = (UINT64*)Buffer;
+ UINT64 *Buffer64 = (UINT64 *)Buffer;
for (i = 0; i < (BufferSize >> 3); i++) {
*Buffer64 = i | LShiftU64 (~i, 32);
@@ -63,14 +64,14 @@ GenerateRandomBuffer (
BOOLEAN
CompareBuffer (
- VOID *BufferA,
- VOID *BufferB,
- UINTN BufferSize
+ VOID *BufferA,
+ VOID *BufferB,
+ UINTN BufferSize
)
{
- UINTN i;
- UINT64* BufferA64 = (UINT64*)BufferA;
- UINT64* BufferB64 = (UINT64*)BufferB;
+ UINTN i;
+ UINT64 *BufferA64 = (UINT64 *)BufferA;
+ UINT64 *BufferB64 = (UINT64 *)BufferB;
for (i = 0; i < (BufferSize >> 3); i++) {
if (*BufferA64 != *BufferB64) {
@@ -78,23 +79,25 @@ CompareBuffer (
DEBUG ((DEBUG_ERROR, "(0x%lX) != (0x%lX)\n", *BufferA64, *BufferB64));
return FALSE;
}
+
BufferA64++;
BufferB64++;
}
+
return TRUE;
}
EFI_STATUS
MmcReadWriteDataTest (
- MMC_HOST_INSTANCE *MmcHostInstance,
- EFI_LBA Lba,
- UINTN BufferSize
+ MMC_HOST_INSTANCE *MmcHostInstance,
+ EFI_LBA Lba,
+ UINTN BufferSize
)
{
- VOID *BackBuffer;
- VOID *WriteBuffer;
- VOID *ReadBuffer;
- EFI_STATUS Status;
+ VOID *BackBuffer;
+ VOID *WriteBuffer;
+ VOID *ReadBuffer;
+ EFI_STATUS Status;
// Check if a Media is Present
if (!MmcHostInstance->BlockIo.Media->MediaPresent) {
@@ -107,54 +110,54 @@ MmcReadWriteDataTest (
return EFI_NOT_READY;
}
- BackBuffer = AllocatePool (BufferSize);
+ BackBuffer = AllocatePool (BufferSize);
WriteBuffer = AllocatePool (BufferSize);
- ReadBuffer = AllocatePool (BufferSize);
+ ReadBuffer = AllocatePool (BufferSize);
// Read (and save) buffer at a specific location
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,BackBuffer);
+ Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, BackBuffer);
if (Status != EFI_SUCCESS) {
DiagnosticLog (L"ERROR: Fail to Read Block (1)\n");
return Status;
}
// Write buffer at the same location
- GenerateRandomBuffer (WriteBuffer,BufferSize);
- Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,WriteBuffer);
+ GenerateRandomBuffer (WriteBuffer, BufferSize);
+ Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, WriteBuffer);
if (Status != EFI_SUCCESS) {
DiagnosticLog (L"ERROR: Fail to Write Block (1)\n");
return Status;
}
// Read the buffer at the same location
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,ReadBuffer);
+ Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, ReadBuffer);
if (Status != EFI_SUCCESS) {
DiagnosticLog (L"ERROR: Fail to Read Block (2)\n");
return Status;
}
// Check that is conform
- if (!CompareBuffer (ReadBuffer,WriteBuffer,BufferSize)) {
+ if (!CompareBuffer (ReadBuffer, WriteBuffer, BufferSize)) {
DiagnosticLog (L"ERROR: Fail to Read/Write Block (1)\n");
return EFI_INVALID_PARAMETER;
}
// Restore content at the original location
- Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,BackBuffer);
+ Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, BackBuffer);
if (Status != EFI_SUCCESS) {
DiagnosticLog (L"ERROR: Fail to Write Block (2)\n");
return Status;
}
// Read the restored content
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId,Lba,BufferSize,ReadBuffer);
+ Status = MmcReadBlocks (&(MmcHostInstance->BlockIo), MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, ReadBuffer);
if (Status != EFI_SUCCESS) {
DiagnosticLog (L"ERROR: Fail to Read Block (3)\n");
return Status;
}
// Check the content is correct
- if (!CompareBuffer (ReadBuffer,BackBuffer,BufferSize)) {
+ if (!CompareBuffer (ReadBuffer, BackBuffer, BufferSize)) {
DiagnosticLog (L"ERROR: Fail to Read/Write Block (2)\n");
return EFI_INVALID_PARAMETER;
}
@@ -165,25 +168,26 @@ MmcReadWriteDataTest (
EFI_STATUS
EFIAPI
MmcDriverDiagnosticsRunDiagnostics (
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
- IN CHAR8 *Language,
- OUT EFI_GUID **ErrorType,
- OUT UINTN *BufferSize,
- OUT CHAR16 **Buffer
+ IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
+ IN CHAR8 *Language,
+ OUT EFI_GUID **ErrorType,
+ OUT UINTN *BufferSize,
+ OUT CHAR16 **Buffer
)
{
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_STATUS Status;
+ LIST_ENTRY *CurrentLink;
+ MMC_HOST_INSTANCE *MmcHostInstance;
+ EFI_STATUS Status;
if ((Language == NULL) ||
(ErrorType == NULL) ||
(Buffer == NULL) ||
(ControllerHandle == NULL) ||
- (BufferSize == NULL)) {
+ (BufferSize == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -192,28 +196,30 @@ MmcDriverDiagnosticsRunDiagnostics (
return EFI_UNSUPPORTED;
}
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
*ErrorType = NULL;
*BufferSize = DIAGNOSTIC_LOGBUFFER_MAXCHAR;
- *Buffer = DiagnosticInitLog (DIAGNOSTIC_LOGBUFFER_MAXCHAR);
+ *Buffer = DiagnosticInitLog (DIAGNOSTIC_LOGBUFFER_MAXCHAR);
DiagnosticLog (L"MMC Driver Diagnostics\n");
// Find the MMC Host instance on which we have been asked to run diagnostics
MmcHostInstance = NULL;
- CurrentLink = mMmcHostPool.ForwardLink;
+ CurrentLink = mMmcHostPool.ForwardLink;
while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
- ASSERT(MmcHostInstance != NULL);
+ MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
+ ASSERT (MmcHostInstance != NULL);
if (MmcHostInstance->MmcHandle == ControllerHandle) {
break;
}
+
CurrentLink = CurrentLink->ForwardLink;
}
// If we didn't find the controller, return EFI_UNSUPPORTED
- if ((MmcHostInstance == NULL)
- || (MmcHostInstance->MmcHandle != ControllerHandle)) {
+ if ( (MmcHostInstance == NULL)
+ || (MmcHostInstance->MmcHandle != ControllerHandle))
+ {
return EFI_UNSUPPORTED;
}
@@ -247,7 +253,7 @@ MmcDriverDiagnosticsRunDiagnostics (
//
// EFI Driver Diagnostics 2 Protocol
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2 = {
- (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) MmcDriverDiagnosticsRunDiagnostics,
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2 = {
+ (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS)MmcDriverDiagnosticsRunDiagnostics,
"en"
};
diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.c b/EmbeddedPkg/Universal/MmcDxe/Mmc.c
index d33f7f0a49..7f4df56fc8 100644
--- a/EmbeddedPkg/Universal/MmcDxe/Mmc.c
+++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.c
@@ -17,17 +17,17 @@
#include "Mmc.h"
-EFI_BLOCK_IO_MEDIA mMmcMediaTemplate = {
- SIGNATURE_32('m','m','c','o'), // MediaId
- TRUE, // RemovableMedia
- FALSE, // MediaPresent
- FALSE, // LogicalPartition
- FALSE, // ReadOnly
- FALSE, // WriteCaching
- 512, // BlockSize
- 4, // IoAlign
- 0, // Pad
- 0 // LastBlock
+EFI_BLOCK_IO_MEDIA mMmcMediaTemplate = {
+ SIGNATURE_32 ('m', 'm', 'c', 'o'), // MediaId
+ TRUE, // RemovableMedia
+ FALSE, // MediaPresent
+ FALSE, // LogicalPartition
+ FALSE, // ReadOnly
+ FALSE, // WriteCaching
+ 512, // BlockSize
+ 4, // IoAlign
+ 0, // Pad
+ 0 // LastBlock
};
//
@@ -41,7 +41,7 @@ LIST_ENTRY mMmcHostPool;
or if new ones have been plugged in
**/
-EFI_EVENT gCheckCardsEvent;
+EFI_EVENT gCheckCardsEvent;
/**
Initialize the MMC Host Pool to support multiple MMC devices
@@ -59,7 +59,7 @@ InitializeMmcHostPool (
**/
VOID
InsertMmcHost (
- IN MMC_HOST_INSTANCE *MmcHostInstance
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
InsertTailList (&mMmcHostPool, &(MmcHostInstance->Link));
@@ -70,20 +70,21 @@ InsertMmcHost (
*/
VOID
RemoveMmcHost (
- IN MMC_HOST_INSTANCE *MmcHostInstance
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
RemoveEntryList (&(MmcHostInstance->Link));
}
-MMC_HOST_INSTANCE* CreateMmcHostInstance (
- IN EFI_MMC_HOST_PROTOCOL* MmcHost
+MMC_HOST_INSTANCE *
+CreateMmcHostInstance (
+ IN EFI_MMC_HOST_PROTOCOL *MmcHost
)
{
- EFI_STATUS Status;
- MMC_HOST_INSTANCE* MmcHostInstance;
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ MMC_HOST_INSTANCE *MmcHostInstance;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
MmcHostInstance = AllocateZeroPool (sizeof (MMC_HOST_INSTANCE));
if (MmcHostInstance == NULL) {
@@ -94,14 +95,14 @@ MMC_HOST_INSTANCE* CreateMmcHostInstance (
MmcHostInstance->State = MmcHwInitializationState;
- MmcHostInstance->BlockIo.Media = AllocateCopyPool (sizeof(EFI_BLOCK_IO_MEDIA), &mMmcMediaTemplate);
+ MmcHostInstance->BlockIo.Media = AllocateCopyPool (sizeof (EFI_BLOCK_IO_MEDIA), &mMmcMediaTemplate);
if (MmcHostInstance->BlockIo.Media == NULL) {
goto FREE_INSTANCE;
}
- MmcHostInstance->BlockIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;
- MmcHostInstance->BlockIo.Reset = MmcReset;
- MmcHostInstance->BlockIo.ReadBlocks = MmcReadBlocks;
+ MmcHostInstance->BlockIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;
+ MmcHostInstance->BlockIo.Reset = MmcReset;
+ MmcHostInstance->BlockIo.ReadBlocks = MmcReadBlocks;
MmcHostInstance->BlockIo.WriteBlocks = MmcWriteBlocks;
MmcHostInstance->BlockIo.FlushBlocks = MmcFlushBlocks;
@@ -113,7 +114,7 @@ MMC_HOST_INSTANCE* CreateMmcHostInstance (
goto FREE_MEDIA;
}
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH);
if (DevicePath == NULL) {
goto FREE_MEDIA;
}
@@ -123,51 +124,58 @@ MMC_HOST_INSTANCE* CreateMmcHostInstance (
// Publish BlockIO protocol interface
Status = gBS->InstallMultipleProtocolInterfaces (
- &MmcHostInstance->MmcHandle,
- &gEfiBlockIoProtocolGuid,&MmcHostInstance->BlockIo,
- &gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
- NULL
- );
- if (EFI_ERROR(Status)) {
+ &MmcHostInstance->MmcHandle,
+ &gEfiBlockIoProtocolGuid,
+ &MmcHostInstance->BlockIo,
+ &gEfiDevicePathProtocolGuid,
+ MmcHostInstance->DevicePath,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
goto FREE_DEVICE_PATH;
}
return MmcHostInstance;
FREE_DEVICE_PATH:
- FreePool(DevicePath);
+ FreePool (DevicePath);
FREE_MEDIA:
- FreePool(MmcHostInstance->BlockIo.Media);
+ FreePool (MmcHostInstance->BlockIo.Media);
FREE_INSTANCE:
- FreePool(MmcHostInstance);
+ FreePool (MmcHostInstance);
return NULL;
}
-EFI_STATUS DestroyMmcHostInstance (
- IN MMC_HOST_INSTANCE* MmcHostInstance
+EFI_STATUS
+DestroyMmcHostInstance (
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
// Uninstall Protocol Interfaces
Status = gBS->UninstallMultipleProtocolInterfaces (
- MmcHostInstance->MmcHandle,
- &gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),
- &gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
- NULL
- );
+ MmcHostInstance->MmcHandle,
+ &gEfiBlockIoProtocolGuid,
+ &(MmcHostInstance->BlockIo),
+ &gEfiDevicePathProtocolGuid,
+ MmcHostInstance->DevicePath,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
// Free Memory allocated for the instance
if (MmcHostInstance->BlockIo.Media) {
- FreePool(MmcHostInstance->BlockIo.Media);
+ FreePool (MmcHostInstance->BlockIo.Media);
}
+
if (MmcHostInstance->CardInfo.ECSDData) {
FreePages (MmcHostInstance->CardInfo.ECSDData, EFI_SIZE_TO_PAGES (sizeof (ECSD)));
}
+
FreePool (MmcHostInstance);
return Status;
@@ -179,15 +187,15 @@ EFI_STATUS DestroyMmcHostInstance (
EFI_STATUS
EFIAPI
MmcDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- //EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- EFI_DEV_PATH_PTR Node;
+ EFI_STATUS Status;
+ // EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
+ EFI_DEV_PATH_PTR Node;
//
// Check RemainingDevicePath validation
@@ -203,10 +211,11 @@ MmcDriverBindingSupported (
// check its validation
//
Node.DevPath = RemainingDevicePath;
- if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||
- Node.DevPath->SubType != HW_VENDOR_DP ||
- DevicePathNodeLength(Node.DevPath) != sizeof(VENDOR_DEVICE_PATH)) {
- return EFI_UNSUPPORTED;
+ if ((Node.DevPath->Type != HARDWARE_DEVICE_PATH) ||
+ (Node.DevPath->SubType != HW_VENDOR_DP) ||
+ (DevicePathNodeLength (Node.DevPath) != sizeof (VENDOR_DEVICE_PATH)))
+ {
+ return EFI_UNSUPPORTED;
}
}
}
@@ -215,16 +224,17 @@ MmcDriverBindingSupported (
// Check if Mmc Host protocol is installed by platform
//
Status = gBS->OpenProtocol (
- Controller,
- &gEmbeddedMmcHostProtocolGuid,
- (VOID **) &MmcHost,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ Controller,
+ &gEmbeddedMmcHostProtocolGuid,
+ (VOID **)&MmcHost,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
+
if (EFI_ERROR (Status)) {
return Status;
}
@@ -233,11 +243,11 @@ MmcDriverBindingSupported (
// Close the Mmc Host used to perform the supported test
//
gBS->CloseProtocol (
- Controller,
- &gEmbeddedMmcHostProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEmbeddedMmcHostProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
return EFI_SUCCESS;
}
@@ -253,9 +263,9 @@ MmcDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
- EFI_STATUS Status;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
+ EFI_STATUS Status;
+ MMC_HOST_INSTANCE *MmcHostInstance;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
//
// Check RemainingDevicePath validation
@@ -274,21 +284,22 @@ MmcDriverBindingStart (
// Get the Mmc Host protocol
//
Status = gBS->OpenProtocol (
- Controller,
- &gEmbeddedMmcHostProtocolGuid,
- (VOID **) &MmcHost,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
+ Controller,
+ &gEmbeddedMmcHostProtocolGuid,
+ (VOID **)&MmcHost,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
if (EFI_ERROR (Status)) {
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
+
return Status;
}
- MmcHostInstance = CreateMmcHostInstance(MmcHost);
+ MmcHostInstance = CreateMmcHostInstance (MmcHost);
if (MmcHostInstance != NULL) {
// Add the handle to the pool
InsertMmcHost (MmcHostInstance);
@@ -308,31 +319,31 @@ MmcDriverBindingStart (
EFI_STATUS
EFIAPI
MmcDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE Controller,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE *ChildHandleBuffer
)
{
- EFI_STATUS Status = EFI_SUCCESS;
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
+ EFI_STATUS Status = EFI_SUCCESS;
+ LIST_ENTRY *CurrentLink;
+ MMC_HOST_INSTANCE *MmcHostInstance;
- MMC_TRACE("MmcDriverBindingStop()");
+ MMC_TRACE ("MmcDriverBindingStop()");
// For each MMC instance
CurrentLink = mMmcHostPool.ForwardLink;
while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
- ASSERT(MmcHostInstance != NULL);
+ MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
+ ASSERT (MmcHostInstance != NULL);
// Close gEmbeddedMmcHostProtocolGuid
Status = gBS->CloseProtocol (
- Controller,
- &gEmbeddedMmcHostProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ Controller,
+ &gEmbeddedMmcHostProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
// Remove MMC Host Instance from the pool
RemoveMmcHost (MmcHostInstance);
@@ -347,37 +358,37 @@ MmcDriverBindingStop (
VOID
EFIAPI
CheckCardsCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_STATUS Status;
+ LIST_ENTRY *CurrentLink;
+ MMC_HOST_INSTANCE *MmcHostInstance;
+ EFI_STATUS Status;
CurrentLink = mMmcHostPool.ForwardLink;
while (CurrentLink != NULL && CurrentLink != &mMmcHostPool) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK(CurrentLink);
- ASSERT(MmcHostInstance != NULL);
+ MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
+ ASSERT (MmcHostInstance != NULL);
if (MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost) == !MmcHostInstance->Initialized) {
- MmcHostInstance->State = MmcHwInitializationState;
+ MmcHostInstance->State = MmcHwInitializationState;
MmcHostInstance->BlockIo.Media->MediaPresent = !MmcHostInstance->Initialized;
- MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
+ MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
if (MmcHostInstance->BlockIo.Media->MediaPresent) {
InitializeMmcDevice (MmcHostInstance);
}
Status = gBS->ReinstallProtocolInterface (
- (MmcHostInstance->MmcHandle),
- &gEfiBlockIoProtocolGuid,
- &(MmcHostInstance->BlockIo),
- &(MmcHostInstance->BlockIo)
- );
-
- if (EFI_ERROR(Status)) {
- Print(L"MMC Card: Error reinstalling BlockIo interface\n");
+ (MmcHostInstance->MmcHandle),
+ &gEfiBlockIoProtocolGuid,
+ &(MmcHostInstance->BlockIo),
+ &(MmcHostInstance->BlockIo)
+ );
+
+ if (EFI_ERROR (Status)) {
+ Print (L"MMC Card: Error reinstalling BlockIo interface\n");
}
}
@@ -385,8 +396,7 @@ CheckCardsCallback (
}
}
-
-EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {
MmcDriverBindingSupported,
MmcDriverBindingStart,
MmcDriverBindingStop,
@@ -401,8 +411,8 @@ EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {
EFI_STATUS
EFIAPI
MmcDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -416,36 +426,39 @@ MmcDxeInitialize (
// Install driver model protocol(s).
//
Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gMmcDriverBinding,
- ImageHandle,
- &gMmcComponentName,
- &gMmcComponentName2
- );
+ ImageHandle,
+ SystemTable,
+ &gMmcDriverBinding,
+ ImageHandle,
+ &gMmcComponentName,
+ &gMmcComponentName2
+ );
ASSERT_EFI_ERROR (Status);
// Install driver diagnostics
Status = gBS->InstallMultipleProtocolInterfaces (
- &ImageHandle,
- &gEfiDriverDiagnostics2ProtocolGuid,&gMmcDriverDiagnostics2,
- NULL
- );
+ &ImageHandle,
+ &gEfiDriverDiagnostics2ProtocolGuid,
+ &gMmcDriverDiagnostics2,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
// Use a timer to detect if a card has been plugged in or removed
Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL | EVT_TIMER,
- TPL_CALLBACK,
- CheckCardsCallback,
- NULL,
- &gCheckCardsEvent);
+ EVT_NOTIFY_SIGNAL | EVT_TIMER,
+ TPL_CALLBACK,
+ CheckCardsCallback,
+ NULL,
+ &gCheckCardsEvent
+ );
ASSERT_EFI_ERROR (Status);
- Status = gBS->SetTimer(
- gCheckCardsEvent,
- TimerPeriodic,
- (UINT64)(10*1000*200)); // 200 ms
+ Status = gBS->SetTimer (
+ gCheckCardsEvent,
+ TimerPeriodic,
+ (UINT64)(10*1000*200)
+ ); // 200 ms
ASSERT_EFI_ERROR (Status);
return Status;
diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
index ad9804bb9a..23cabb7cf5 100644
--- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
+++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
@@ -23,327 +23,326 @@
#define MMC_TRACE(txt) DEBUG((DEBUG_BLKIO, "MMC: " txt "\n"))
-#define MMC_IOBLOCKS_READ 0
-#define MMC_IOBLOCKS_WRITE 1
+#define MMC_IOBLOCKS_READ 0
+#define MMC_IOBLOCKS_WRITE 1
-#define MMC_OCR_POWERUP 0x80000000
+#define MMC_OCR_POWERUP 0x80000000
-#define MMC_OCR_ACCESS_MASK 0x3 /* bit[30-29] */
-#define MMC_OCR_ACCESS_BYTE 0x1 /* bit[29] */
-#define MMC_OCR_ACCESS_SECTOR 0x2 /* bit[30] */
+#define MMC_OCR_ACCESS_MASK 0x3 /* bit[30-29] */
+#define MMC_OCR_ACCESS_BYTE 0x1 /* bit[29] */
+#define MMC_OCR_ACCESS_SECTOR 0x2 /* bit[30] */
-#define MMC_CSD_GET_CCC(Response) (Response[2] >> 20)
-#define MMC_CSD_GET_TRANSPEED(Response) (Response[3] & 0xFF)
-#define MMC_CSD_GET_READBLLEN(Response) ((Response[2] >> 16) & 0xF)
-#define MMC_CSD_GET_WRITEBLLEN(Response) ((Response[0] >> 22) & 0xF)
-#define MMC_CSD_GET_FILEFORMAT(Response) ((Response[0] >> 10) & 0x3)
+#define MMC_CSD_GET_CCC(Response) (Response[2] >> 20)
+#define MMC_CSD_GET_TRANSPEED(Response) (Response[3] & 0xFF)
+#define MMC_CSD_GET_READBLLEN(Response) ((Response[2] >> 16) & 0xF)
+#define MMC_CSD_GET_WRITEBLLEN(Response) ((Response[0] >> 22) & 0xF)
+#define MMC_CSD_GET_FILEFORMAT(Response) ((Response[0] >> 10) & 0x3)
#define MMC_CSD_GET_FILEFORMATGRP(Response) ((Response[0] >> 15) & 0x1)
-#define MMC_CSD_GET_DEVICESIZE(csd) (((Response[1] >> 30) & 0x3) | ((Response[2] & 0x3FF) << 2))
-#define HC_MMC_CSD_GET_DEVICESIZE(Response) ((Response[1] >> 16) | ((Response[2] & 0x40) << 16));
-#define MMC_CSD_GET_DEVICESIZEMULT(csd) ((Response[1] >> 15) & 0x7)
+#define MMC_CSD_GET_DEVICESIZE(csd) (((Response[1] >> 30) & 0x3) | ((Response[2] & 0x3FF) << 2))
+#define HC_MMC_CSD_GET_DEVICESIZE(Response) ((Response[1] >> 16) | ((Response[2] & 0x40) << 16));
+#define MMC_CSD_GET_DEVICESIZEMULT(csd) ((Response[1] >> 15) & 0x7)
-#define MMC_R0_READY_FOR_DATA (1 << 8)
+#define MMC_R0_READY_FOR_DATA (1 << 8)
-#define MMC_R0_CURRENTSTATE(Response) ((Response[0] >> 9) & 0xF)
+#define MMC_R0_CURRENTSTATE(Response) ((Response[0] >> 9) & 0xF)
-#define MMC_R0_STATE_IDLE 0
-#define MMC_R0_STATE_READY 1
-#define MMC_R0_STATE_IDENT 2
-#define MMC_R0_STATE_STDBY 3
-#define MMC_R0_STATE_TRAN 4
-#define MMC_R0_STATE_DATA 5
+#define MMC_R0_STATE_IDLE 0
+#define MMC_R0_STATE_READY 1
+#define MMC_R0_STATE_IDENT 2
+#define MMC_R0_STATE_STDBY 3
+#define MMC_R0_STATE_TRAN 4
+#define MMC_R0_STATE_DATA 5
-#define EMMC_CMD6_ARG_ACCESS(x) (((x) & 0x3) << 24)
-#define EMMC_CMD6_ARG_INDEX(x) (((x) & 0xFF) << 16)
-#define EMMC_CMD6_ARG_VALUE(x) (((x) & 0xFF) << 8)
-#define EMMC_CMD6_ARG_CMD_SET(x) (((x) & 0x7) << 0)
+#define EMMC_CMD6_ARG_ACCESS(x) (((x) & 0x3) << 24)
+#define EMMC_CMD6_ARG_INDEX(x) (((x) & 0xFF) << 16)
+#define EMMC_CMD6_ARG_VALUE(x) (((x) & 0xFF) << 8)
+#define EMMC_CMD6_ARG_CMD_SET(x) (((x) & 0x7) << 0)
-#define SWITCH_CMD_DATA_LENGTH 64
-#define SD_HIGH_SPEED_SUPPORTED 0x20000
-#define SD_DEFAULT_SPEED 25000000
-#define SD_HIGH_SPEED 50000000
-#define SWITCH_CMD_SUCCESS_MASK 0x0f000000
+#define SWITCH_CMD_DATA_LENGTH 64
+#define SD_HIGH_SPEED_SUPPORTED 0x20000
+#define SD_DEFAULT_SPEED 25000000
+#define SD_HIGH_SPEED 50000000
+#define SWITCH_CMD_SUCCESS_MASK 0x0f000000
-#define SD_CARD_CAPACITY 0x00000002
+#define SD_CARD_CAPACITY 0x00000002
-#define BUSWIDTH_4 4
+#define BUSWIDTH_4 4
typedef enum {
UNKNOWN_CARD,
- MMC_CARD, //MMC card
- MMC_CARD_HIGH, //MMC Card with High capacity
- EMMC_CARD, //eMMC 4.41 card
- SD_CARD, //SD 1.1 card
- SD_CARD_2, //SD 2.0 or above standard card
- SD_CARD_2_HIGH //SD 2.0 or above high capacity card
+ MMC_CARD, // MMC card
+ MMC_CARD_HIGH, // MMC Card with High capacity
+ EMMC_CARD, // eMMC 4.41 card
+ SD_CARD, // SD 1.1 card
+ SD_CARD_2, // SD 2.0 or above standard card
+ SD_CARD_2_HIGH // SD 2.0 or above high capacity card
} CARD_TYPE;
typedef struct {
- UINT32 Reserved0: 7; // 0
- UINT32 V170_V195: 1; // 1.70V - 1.95V
- UINT32 V200_V260: 7; // 2.00V - 2.60V
- UINT32 V270_V360: 9; // 2.70V - 3.60V
- UINT32 RESERVED_1: 5; // Reserved
- UINT32 AccessMode: 2; // 00b (byte mode), 10b (sector mode)
- UINT32 PowerUp: 1; // This bit is set to LOW if the card has not finished the power up routine
+ UINT32 Reserved0 : 7; // 0
+ UINT32 V170_V195 : 1; // 1.70V - 1.95V
+ UINT32 V200_V260 : 7; // 2.00V - 2.60V
+ UINT32 V270_V360 : 9; // 2.70V - 3.60V
+ UINT32 RESERVED_1 : 5; // Reserved
+ UINT32 AccessMode : 2; // 00b (byte mode), 10b (sector mode)
+ UINT32 PowerUp : 1; // This bit is set to LOW if the card has not finished the power up routine
} OCR;
typedef struct {
- UINT8 SD_SPEC: 4; // SD Memory Card - Spec. Version [59:56]
- UINT8 SCR_STRUCTURE: 4; // SCR Structure [63:60]
- UINT8 SD_BUS_WIDTHS: 4; // DAT Bus widths supported [51:48]
- UINT8 DATA_STAT_AFTER_ERASE: 1; // Data Status after erases [55]
- UINT8 SD_SECURITY: 3; // CPRM Security Support [54:52]
- UINT8 EX_SECURITY_1: 1; // Extended Security Support [43]
- UINT8 SD_SPEC4: 1; // Spec. Version 4.00 or higher [42]
- UINT8 RESERVED_1: 2; // Reserved [41:40]
- UINT8 SD_SPEC3: 1; // Spec. Version 3.00 or higher [47]
- UINT8 EX_SECURITY_2: 3; // Extended Security Support [46:44]
- UINT8 CMD_SUPPORT: 4; // Command Support bits [35:32]
- UINT8 RESERVED_2: 4; // Reserved [39:36]
- UINT32 RESERVED_3; // Manufacturer Usage [31:0]
+ UINT8 SD_SPEC : 4; // SD Memory Card - Spec. Version [59:56]
+ UINT8 SCR_STRUCTURE : 4; // SCR Structure [63:60]
+ UINT8 SD_BUS_WIDTHS : 4; // DAT Bus widths supported [51:48]
+ UINT8 DATA_STAT_AFTER_ERASE : 1; // Data Status after erases [55]
+ UINT8 SD_SECURITY : 3; // CPRM Security Support [54:52]
+ UINT8 EX_SECURITY_1 : 1; // Extended Security Support [43]
+ UINT8 SD_SPEC4 : 1; // Spec. Version 4.00 or higher [42]
+ UINT8 RESERVED_1 : 2; // Reserved [41:40]
+ UINT8 SD_SPEC3 : 1; // Spec. Version 3.00 or higher [47]
+ UINT8 EX_SECURITY_2 : 3; // Extended Security Support [46:44]
+ UINT8 CMD_SUPPORT : 4; // Command Support bits [35:32]
+ UINT8 RESERVED_2 : 4; // Reserved [39:36]
+ UINT32 RESERVED_3; // Manufacturer Usage [31:0]
} SCR;
typedef struct {
- UINT32 NOT_USED; // 1 [0:0]
- UINT32 CRC; // CRC7 checksum [7:1]
- UINT32 MDT; // Manufacturing date [19:8]
- UINT32 RESERVED_1; // Reserved [23:20]
- UINT32 PSN; // Product serial number [55:24]
- UINT8 PRV; // Product revision [63:56]
- UINT8 PNM[5]; // Product name [64:103]
- UINT16 OID; // OEM/Application ID [119:104]
- UINT8 MID; // Manufacturer ID [127:120]
+ UINT32 NOT_USED; // 1 [0:0]
+ UINT32 CRC; // CRC7 checksum [7:1]
+ UINT32 MDT; // Manufacturing date [19:8]
+ UINT32 RESERVED_1; // Reserved [23:20]
+ UINT32 PSN; // Product serial number [55:24]
+ UINT8 PRV; // Product revision [63:56]
+ UINT8 PNM[5]; // Product name [64:103]
+ UINT16 OID; // OEM/Application ID [119:104]
+ UINT8 MID; // Manufacturer ID [127:120]
} CID;
typedef struct {
- UINT8 NOT_USED: 1; // Not used, always 1 [0:0]
- UINT8 CRC: 7; // CRC [7:1]
-
- UINT8 RESERVED_1: 2; // Reserved [9:8]
- UINT8 FILE_FORMAT: 2; // File format [11:10]
- UINT8 TMP_WRITE_PROTECT: 1; // Temporary write protection [12:12]
- UINT8 PERM_WRITE_PROTECT: 1; // Permanent write protection [13:13]
- UINT8 COPY: 1; // Copy flag (OTP) [14:14]
- UINT8 FILE_FORMAT_GRP: 1; // File format group [15:15]
-
- UINT16 RESERVED_2: 5; // Reserved [20:16]
- UINT16 WRITE_BL_PARTIAL: 1; // Partial blocks for write allowed [21:21]
- UINT16 WRITE_BL_LEN: 4; // Max. write data block length [25:22]
- UINT16 R2W_FACTOR: 3; // Write speed factor [28:26]
- UINT16 RESERVED_3: 2; // Reserved [30:29]
- UINT16 WP_GRP_ENABLE: 1; // Write protect group enable [31:31]
-
- UINT32 WP_GRP_SIZE: 7; // Write protect group size [38:32]
- UINT32 SECTOR_SIZE: 7; // Erase sector size [45:39]
- UINT32 ERASE_BLK_EN: 1; // Erase single block enable [46:46]
- UINT32 C_SIZE_MULT: 3; // Device size multiplier [49:47]
- UINT32 VDD_W_CURR_MAX: 3; // Max. write current @ VDD max [52:50]
- UINT32 VDD_W_CURR_MIN: 3; // Max. write current @ VDD min [55:53]
- UINT32 VDD_R_CURR_MAX: 3; // Max. read current @ VDD max [58:56]
- UINT32 VDD_R_CURR_MIN: 3; // Max. read current @ VDD min [61:59]
- UINT32 C_SIZELow2: 2; // Device size [63:62]
-
- UINT32 C_SIZEHigh10: 10;// Device size [73:64]
- UINT32 RESERVED_4: 2; // Reserved [75:74]
- UINT32 DSR_IMP: 1; // DSR implemented [76:76]
- UINT32 READ_BLK_MISALIGN: 1; // Read block misalignment [77:77]
- UINT32 WRITE_BLK_MISALIGN: 1; // Write block misalignment [78:78]
- UINT32 READ_BL_PARTIAL: 1; // Partial blocks for read allowed [79:79]
- UINT32 READ_BL_LEN: 4; // Max. read data block length [83:80]
- UINT32 CCC: 12;// Card command classes [95:84]
-
- UINT8 TRAN_SPEED ; // Max. bus clock frequency [103:96]
- UINT8 NSAC ; // Data read access-time 2 in CLK cycles (NSAC*100) [111:104]
- UINT8 TAAC ; // Data read access-time 1 [119:112]
-
- UINT8 RESERVED_5: 2; // Reserved [121:120]
- UINT8 SPEC_VERS: 4; // System specification version [125:122]
- UINT8 CSD_STRUCTURE: 2; // CSD structure [127:126]
+ UINT8 NOT_USED : 1; // Not used, always 1 [0:0]
+ UINT8 CRC : 7; // CRC [7:1]
+
+ UINT8 RESERVED_1 : 2; // Reserved [9:8]
+ UINT8 FILE_FORMAT : 2; // File format [11:10]
+ UINT8 TMP_WRITE_PROTECT : 1; // Temporary write protection [12:12]
+ UINT8 PERM_WRITE_PROTECT : 1; // Permanent write protection [13:13]
+ UINT8 COPY : 1; // Copy flag (OTP) [14:14]
+ UINT8 FILE_FORMAT_GRP : 1; // File format group [15:15]
+
+ UINT16 RESERVED_2 : 5; // Reserved [20:16]
+ UINT16 WRITE_BL_PARTIAL : 1; // Partial blocks for write allowed [21:21]
+ UINT16 WRITE_BL_LEN : 4; // Max. write data block length [25:22]
+ UINT16 R2W_FACTOR : 3; // Write speed factor [28:26]
+ UINT16 RESERVED_3 : 2; // Reserved [30:29]
+ UINT16 WP_GRP_ENABLE : 1; // Write protect group enable [31:31]
+
+ UINT32 WP_GRP_SIZE : 7; // Write protect group size [38:32]
+ UINT32 SECTOR_SIZE : 7; // Erase sector size [45:39]
+ UINT32 ERASE_BLK_EN : 1; // Erase single block enable [46:46]
+ UINT32 C_SIZE_MULT : 3; // Device size multiplier [49:47]
+ UINT32 VDD_W_CURR_MAX : 3; // Max. write current @ VDD max [52:50]
+ UINT32 VDD_W_CURR_MIN : 3; // Max. write current @ VDD min [55:53]
+ UINT32 VDD_R_CURR_MAX : 3; // Max. read current @ VDD max [58:56]
+ UINT32 VDD_R_CURR_MIN : 3; // Max. read current @ VDD min [61:59]
+ UINT32 C_SIZELow2 : 2; // Device size [63:62]
+
+ UINT32 C_SIZEHigh10 : 10; // Device size [73:64]
+ UINT32 RESERVED_4 : 2; // Reserved [75:74]
+ UINT32 DSR_IMP : 1; // DSR implemented [76:76]
+ UINT32 READ_BLK_MISALIGN : 1; // Read block misalignment [77:77]
+ UINT32 WRITE_BLK_MISALIGN : 1; // Write block misalignment [78:78]
+ UINT32 READ_BL_PARTIAL : 1; // Partial blocks for read allowed [79:79]
+ UINT32 READ_BL_LEN : 4; // Max. read data block length [83:80]
+ UINT32 CCC : 12; // Card command classes [95:84]
+
+ UINT8 TRAN_SPEED; // Max. bus clock frequency [103:96]
+ UINT8 NSAC; // Data read access-time 2 in CLK cycles (NSAC*100) [111:104]
+ UINT8 TAAC; // Data read access-time 1 [119:112]
+
+ UINT8 RESERVED_5 : 2; // Reserved [121:120]
+ UINT8 SPEC_VERS : 4; // System specification version [125:122]
+ UINT8 CSD_STRUCTURE : 2; // CSD structure [127:126]
} CSD;
typedef struct {
- UINT8 RESERVED_1[16]; // Reserved [15:0]
- UINT8 SECURE_REMOVAL_TYPE; // Secure Removal Type [16:16]
- UINT8 PRODUCT_STATE_AWARENESS_ENABLEMENT; // Product state awareness enablement [17:17]
- UINT8 MAX_PRE_LOADING_DATA_SIZE[4]; // MAX pre loading data size [21:18]
- UINT8 PRE_LOADING_DATA_SIZE[4]; // Pre loading data size [25:22]
- UINT8 FFU_STATUS; // FFU Status [26:26]
- UINT8 RESERVED_2[2]; // Reserved [28:27]
- UINT8 MODE_OPERATION_CODES; // Mode operation codes [29:29]
- UINT8 MODE_CONFIG; // Mode config [30:30]
- UINT8 RESERVED_3; // Reserved [31:31]
- UINT8 FLUSH_CACHE; // Flushing of the cache [32:32]
- UINT8 CACHE_CTRL; // Control to turn the cache ON/OFF [33:33]
- UINT8 POWER_OFF_NOTIFICATION; // Power Off Notification [34:34]
- UINT8 PACKED_FAILURE_INDEX; // Packed command failure index [35:35]
- UINT8 PACKED_COMMAND_STATUS; // Packed command status [36:36]
- UINT8 CONTEXT_CONF[15]; // Context configuration [51:37]
- UINT8 EXT_PARTITIONS_ATTRIBUTE[2]; // Extended partitions attribute [53:52]
- UINT8 EXCEPTION_EVENTS_STATUS[2]; // Exception events status [55:54]
- UINT8 EXCEPTION_EVENTS_CTRL[2]; // Exception events control [57:56]
- UINT8 DYNCAP_NEEDED; // Number of addressed group to be released [58:58]
- UINT8 CLASS_6_CTRL; // Class 6 commands control [59:59]
- UINT8 INI_TIMEOUT_EMU; // 1st initialization after disabling sector size emulation [60:60]
- UINT8 DATA_SECTOR_SIZE; // Sector size [61:61]
- UINT8 USE_NATIVE_SECTOR; // Sector size emulation [62:62]
- UINT8 NATIVE_SECTOR_SIZE; // Native sector size [63:63]
- UINT8 VENDOR_SPECIFIC_FIELD[64]; // Vendor specific fields [127:64]
- UINT8 RESERVED_4[2]; // Reserved [129:128]
- UINT8 PROGRAM_CID_CSD_DDR_SUPPORT; // Program CID/CSD in DDR mode support [130:130]
- UINT8 PERIODIC_WAKEUP; // Periodic wake-up [131:131]
- UINT8 TCASE_SUPPORT; // Package case temperature is controlled [132:132]
- UINT8 PRODUCTION_STATE_AWARENESS; // Production state awareness [133:133]
- UINT8 SECTOR_BAD_BLK_MGMNT; // Bad block management mode [134:134]
- UINT8 RESERVED_5; // Reserved [135:135]
- UINT8 ENH_START_ADDR[4]; // Enhanced user data start address [139:136]
- UINT8 ENH_SIZE_MULT[3]; // Enhanced user data area size [142:140]
- UINT8 GP_SIZE_MULT[12]; // General purpose partition size [154:143]
- UINT8 PARTITION_SETTING_COMPLETED; // Partitioning setting [155:155]
- UINT8 PARTITIONS_ATTRIBUTE; // Partitions attribute [156:156]
- UINT8 MAX_ENH_SIZE_MULT[3]; // Max enhanced area size [159:157]
- UINT8 PARTITIONING_SUPPORT; // Partitioning [160:160]
- UINT8 HPI_MGMT; // HPI management [161:161]
- UINT8 RST_N_FUNCTION; // H/W reset function [162:162]
- UINT8 BKOPS_EN; // Enable background operations handshake [163:163]
- UINT8 BKOPS_START; // Manually start background operations [164:164]
- UINT8 SANITIZE_START; // Start sanitize operation [165:165]
- UINT8 WR_REL_PARAM; // Write reliability parameter register [166:166]
- UINT8 WR_REL_SET; // Write reliability setting register [167:167]
- UINT8 RPMB_SIZE_MULT; // RPMB size [168:168]
- UINT8 FW_CONFIG; // FW configuration [169:169]
- UINT8 RESERVED_6; // Reserved [170:170]
- UINT8 USER_WP; // User area write protection register [171:171]
- UINT8 RESERVED_7; // Reserved [172:172]
- UINT8 BOOT_WP; // Boot area write protection register [173:173]
- UINT8 BOOT_WP_STATUS; // Boot write protection register [174:174]
- UINT8 ERASE_GROUP_DEF; // High-density erase group definition [175:175]
- UINT8 RESERVED_8; // Reserved [176:176]
- UINT8 BOOT_BUS_CONDITIONS; // Boot bus conditions [177:177]
- UINT8 BOOT_CONFIG_PROT; // Boot config protection [178:178]
- UINT8 PARTITION_CONFIG; // Partition config [179:179]
- UINT8 RESERVED_9; // Reserved [180:180]
- UINT8 ERASED_MEM_CONT; // Erased memory content [181:181]
- UINT8 RESERVED_10; // Reserved [182:182]
- UINT8 BUS_WIDTH; // Bus width mode [183:183]
- UINT8 RESERVED_11; // Reserved [184:184]
- UINT8 HS_TIMING; // High-speed interface timing [185:185]
- UINT8 RESERVED_12; // Reserved [186:186]
- UINT8 POWER_CLASS; // Power class [187:187]
- UINT8 RESERVED_13; // Reserved [188:188]
- UINT8 CMD_SET_REV; // Command set revision [189:189]
- UINT8 RESERVED_14; // Reserved [190:190]
- UINT8 CMD_SET; // Command set [191:191]
- UINT8 EXT_CSD_REV; // Extended CSD revision [192:192]
- UINT8 RESERVED_15; // Reserved [193:193]
- UINT8 CSD_STRUCTURE; // CSD Structure [194:194]
- UINT8 RESERVED_16; // Reserved [195:195]
- UINT8 DEVICE_TYPE; // Device type [196:196]
- UINT8 DRIVER_STRENGTH; // I/O Driver strength [197:197]
- UINT8 OUT_OF_INTERRUPT_TIME; // Out-of-interrupt busy timing [198:198]
- UINT8 PARTITION_SWITCH_TIME; // Partition switching timing [199:199]
- UINT8 PWR_CL_52_195; // Power class for 52MHz at 1.95V 1 R [200:200]
- UINT8 PWR_CL_26_195; // Power class for 26MHz at 1.95V 1 R [201:201]
- UINT8 PWR_CL_52_360; // Power class for 52MHz at 3.6V 1 R [202:202]
- UINT8 PWR_CL_26_360; // Power class for 26MHz at 3.6V 1 R [203:203]
- UINT8 RESERVED_17; // Reserved [204:204]
- UINT8 MIN_PERF_R_4_26; // Minimum read performance for 4bit at 26MHz [205:205]
- UINT8 MIN_PERF_W_4_26; // Minimum write performance for 4bit at 26MHz [206:206]
- UINT8 MIN_PERF_R_8_26_4_52; // Minimum read performance for 8bit at 26MHz, for 4bit at 52MHz [207:207]
- UINT8 MIN_PERF_W_8_26_4_52; // Minimum write performance for 8bit at 26MHz, for 4bit at 52MHz [208:208]
- UINT8 MIN_PERF_R_8_52; // Minimum read performance for 8bit at 52MHz [209:209]
- UINT8 MIN_PERF_W_8_52; // Minimum write performance for 8bit at 52MHz [210:210]
- UINT8 RESERVED_18; // Reserved [211:211]
- UINT32 SECTOR_COUNT; // Sector count [215:212]
- UINT8 SLEEP_NOTIFICATION_TIME; // Sleep notification timeout [216:216]
- UINT8 S_A_TIMEOUT; // Sleep/awake timeout [217:217]
- UINT8 PRODUCTION_STATE_AWARENESS_TIMEOUT; // Production state awareness timeout [218:218]
- UINT8 S_C_VCCQ; // Sleep current (VCCQ) [219:219]
- UINT8 S_C_VCC; // Sleep current (VCC) [220:220]
- UINT8 HC_WP_GRP_SIZE; // High-capacity write protect group size [221:221]
- UINT8 REL_WR_SECTOR_C; // Reliable write sector count [222:222]
- UINT8 ERASE_TIMEOUT_MULT; // High-capacity erase timeout [223:223]
- UINT8 HC_ERASE_GRP_SIZE; // High-capacity erase unit size [224:224]
- UINT8 ACC_SIZE; // Access size [225:225]
- UINT8 BOOT_SIZE_MULTI; // Boot partition size [226:226]
- UINT8 RESERVED_19; // Reserved [227:227]
- UINT8 BOOT_INFO; // Boot information [228:228]
- UINT8 SECURE_TRIM_MULT; // Secure TRIM Multiplier [229:229]
- UINT8 SECURE_ERASE_MULT; // Secure Erase Multiplier [230:230]
- UINT8 SECURE_FEATURE_SUPPORT; // Secure Feature Support [231:231]
- UINT8 TRIM_MULT; // TRIM Multiplier [232:232]
- UINT8 RESERVED_20; // Reserved [233:233]
- UINT8 MIN_PREF_DDR_R_8_52; // Minimum read performance for 8bit at 52MHz in DDR mode [234:234]
- UINT8 MIN_PREF_DDR_W_8_52; // Minimum write performance for 8bit at 52MHz in DDR mode [235:235]
- UINT8 PWR_CL_200_130; // Power class for 200MHz at VCCQ=1.3V, VCC=3.6V [236:236]
- UINT8 PWR_CL_200_195; // Power class for 200MHz at VCCQ=1.95V, VCC=3.6V [237:237]
- UINT8 PWR_CL_DDR_52_195; // Power class for 52MHz, DDR at 1.95V [238:238]
- UINT8 PWR_CL_DDR_52_360; // Power class for 52Mhz, DDR at 3.6V [239:239]
- UINT8 RESERVED_21; // Reserved [240:240]
- UINT8 INI_TIMEOUT_AP; // 1st initialization time after partitioning [241:241]
- UINT8 CORRECTLY_PRG_SECTORS_NUM[4]; // Number of correctly programmed sectors [245:242]
- UINT8 BKOPS_STATUS; // Background operations status [246:246]
- UINT8 POWER_OFF_LONG_TIME; // Power off notification (long) timeout [247:247]
- UINT8 GENERIC_CMD6_TIME; // Generic CMD6 timeout [248:248]
- UINT8 CACHE_SIZE[4]; // Cache size [252:249]
- UINT8 PWR_CL_DDR_200_360; // Power class for 200MHz, DDR at VCC=3.6V [253:253]
- UINT8 FIRMWARE_VERSION[8]; // Firmware version [261:254]
- UINT8 DEVICE_VERSION[2]; // Device version [263:262]
- UINT8 OPTIMAL_TRIM_UNIT_SIZE; // Optimal trim unit size [264:264]
- UINT8 OPTIMAL_WRITE_SIZE; // Optimal write size [265:265]
- UINT8 OPTIMAL_READ_SIZE; // Optimal read size [266:266]
- UINT8 PRE_EOL_INFO; // Pre EOL information [267:267]
- UINT8 DEVICE_LIFE_TIME_EST_TYP_A; // Device life time estimation type A [268:268]
- UINT8 DEVICE_LIFE_TIME_EST_TYP_B; // Device life time estimation type B [269:269]
- UINT8 VENDOR_PROPRIETARY_HEALTH_REPORT[32]; // Vendor proprietary health report [301:270]
- UINT8 NUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED[4]; // Number of FW sectors correctly programmed [305:302]
- UINT8 RESERVED_22[181]; // Reserved [486:306]
- UINT8 FFU_ARG[4]; // FFU argument [490:487]
- UINT8 OPERATION_CODE_TIMEOUT; // Operation codes timeout [491:491]
- UINT8 FFU_FEATURES; // FFU features [492:492]
- UINT8 SUPPORTED_MODES; // Supported modes [493:493]
- UINT8 EXT_SUPPORT; // Extended partitions attribute support [494:494]
- UINT8 LARGE_UNIT_SIZE_M1; // Large unit size [495:495]
- UINT8 CONTEXT_CAPABILITIES; // Context management capabilities [496:496]
- UINT8 TAG_RES_SIZE; // Tag resource size [497:497]
- UINT8 TAG_UNIT_SIZE; // Tag unit size [498:498]
- UINT8 DATA_TAG_SUPPORT; // Data tag support [499:499]
- UINT8 MAX_PACKED_WRITES; // Max packed write commands [500:500]
- UINT8 MAX_PACKED_READS; // Max packed read commands [501:501]
- UINT8 BKOPS_SUPPORT; // Background operations support [502:502]
- UINT8 HPI_FEATURES; // HPI features [503:503]
- UINT8 S_CMD_SET; // Supported command sets [504:504]
- UINT8 EXT_SECURITY_ERR; // Extended security commands error [505:505]
- UINT8 RESERVED_23[6]; // Reserved [511:506]
+ UINT8 RESERVED_1[16]; // Reserved [15:0]
+ UINT8 SECURE_REMOVAL_TYPE; // Secure Removal Type [16:16]
+ UINT8 PRODUCT_STATE_AWARENESS_ENABLEMENT; // Product state awareness enablement [17:17]
+ UINT8 MAX_PRE_LOADING_DATA_SIZE[4]; // MAX pre loading data size [21:18]
+ UINT8 PRE_LOADING_DATA_SIZE[4]; // Pre loading data size [25:22]
+ UINT8 FFU_STATUS; // FFU Status [26:26]
+ UINT8 RESERVED_2[2]; // Reserved [28:27]
+ UINT8 MODE_OPERATION_CODES; // Mode operation codes [29:29]
+ UINT8 MODE_CONFIG; // Mode config [30:30]
+ UINT8 RESERVED_3; // Reserved [31:31]
+ UINT8 FLUSH_CACHE; // Flushing of the cache [32:32]
+ UINT8 CACHE_CTRL; // Control to turn the cache ON/OFF [33:33]
+ UINT8 POWER_OFF_NOTIFICATION; // Power Off Notification [34:34]
+ UINT8 PACKED_FAILURE_INDEX; // Packed command failure index [35:35]
+ UINT8 PACKED_COMMAND_STATUS; // Packed command status [36:36]
+ UINT8 CONTEXT_CONF[15]; // Context configuration [51:37]
+ UINT8 EXT_PARTITIONS_ATTRIBUTE[2]; // Extended partitions attribute [53:52]
+ UINT8 EXCEPTION_EVENTS_STATUS[2]; // Exception events status [55:54]
+ UINT8 EXCEPTION_EVENTS_CTRL[2]; // Exception events control [57:56]
+ UINT8 DYNCAP_NEEDED; // Number of addressed group to be released [58:58]
+ UINT8 CLASS_6_CTRL; // Class 6 commands control [59:59]
+ UINT8 INI_TIMEOUT_EMU; // 1st initialization after disabling sector size emulation [60:60]
+ UINT8 DATA_SECTOR_SIZE; // Sector size [61:61]
+ UINT8 USE_NATIVE_SECTOR; // Sector size emulation [62:62]
+ UINT8 NATIVE_SECTOR_SIZE; // Native sector size [63:63]
+ UINT8 VENDOR_SPECIFIC_FIELD[64]; // Vendor specific fields [127:64]
+ UINT8 RESERVED_4[2]; // Reserved [129:128]
+ UINT8 PROGRAM_CID_CSD_DDR_SUPPORT; // Program CID/CSD in DDR mode support [130:130]
+ UINT8 PERIODIC_WAKEUP; // Periodic wake-up [131:131]
+ UINT8 TCASE_SUPPORT; // Package case temperature is controlled [132:132]
+ UINT8 PRODUCTION_STATE_AWARENESS; // Production state awareness [133:133]
+ UINT8 SECTOR_BAD_BLK_MGMNT; // Bad block management mode [134:134]
+ UINT8 RESERVED_5; // Reserved [135:135]
+ UINT8 ENH_START_ADDR[4]; // Enhanced user data start address [139:136]
+ UINT8 ENH_SIZE_MULT[3]; // Enhanced user data area size [142:140]
+ UINT8 GP_SIZE_MULT[12]; // General purpose partition size [154:143]
+ UINT8 PARTITION_SETTING_COMPLETED; // Partitioning setting [155:155]
+ UINT8 PARTITIONS_ATTRIBUTE; // Partitions attribute [156:156]
+ UINT8 MAX_ENH_SIZE_MULT[3]; // Max enhanced area size [159:157]
+ UINT8 PARTITIONING_SUPPORT; // Partitioning [160:160]
+ UINT8 HPI_MGMT; // HPI management [161:161]
+ UINT8 RST_N_FUNCTION; // H/W reset function [162:162]
+ UINT8 BKOPS_EN; // Enable background operations handshake [163:163]
+ UINT8 BKOPS_START; // Manually start background operations [164:164]
+ UINT8 SANITIZE_START; // Start sanitize operation [165:165]
+ UINT8 WR_REL_PARAM; // Write reliability parameter register [166:166]
+ UINT8 WR_REL_SET; // Write reliability setting register [167:167]
+ UINT8 RPMB_SIZE_MULT; // RPMB size [168:168]
+ UINT8 FW_CONFIG; // FW configuration [169:169]
+ UINT8 RESERVED_6; // Reserved [170:170]
+ UINT8 USER_WP; // User area write protection register [171:171]
+ UINT8 RESERVED_7; // Reserved [172:172]
+ UINT8 BOOT_WP; // Boot area write protection register [173:173]
+ UINT8 BOOT_WP_STATUS; // Boot write protection register [174:174]
+ UINT8 ERASE_GROUP_DEF; // High-density erase group definition [175:175]
+ UINT8 RESERVED_8; // Reserved [176:176]
+ UINT8 BOOT_BUS_CONDITIONS; // Boot bus conditions [177:177]
+ UINT8 BOOT_CONFIG_PROT; // Boot config protection [178:178]
+ UINT8 PARTITION_CONFIG; // Partition config [179:179]
+ UINT8 RESERVED_9; // Reserved [180:180]
+ UINT8 ERASED_MEM_CONT; // Erased memory content [181:181]
+ UINT8 RESERVED_10; // Reserved [182:182]
+ UINT8 BUS_WIDTH; // Bus width mode [183:183]
+ UINT8 RESERVED_11; // Reserved [184:184]
+ UINT8 HS_TIMING; // High-speed interface timing [185:185]
+ UINT8 RESERVED_12; // Reserved [186:186]
+ UINT8 POWER_CLASS; // Power class [187:187]
+ UINT8 RESERVED_13; // Reserved [188:188]
+ UINT8 CMD_SET_REV; // Command set revision [189:189]
+ UINT8 RESERVED_14; // Reserved [190:190]
+ UINT8 CMD_SET; // Command set [191:191]
+ UINT8 EXT_CSD_REV; // Extended CSD revision [192:192]
+ UINT8 RESERVED_15; // Reserved [193:193]
+ UINT8 CSD_STRUCTURE; // CSD Structure [194:194]
+ UINT8 RESERVED_16; // Reserved [195:195]
+ UINT8 DEVICE_TYPE; // Device type [196:196]
+ UINT8 DRIVER_STRENGTH; // I/O Driver strength [197:197]
+ UINT8 OUT_OF_INTERRUPT_TIME; // Out-of-interrupt busy timing [198:198]
+ UINT8 PARTITION_SWITCH_TIME; // Partition switching timing [199:199]
+ UINT8 PWR_CL_52_195; // Power class for 52MHz at 1.95V 1 R [200:200]
+ UINT8 PWR_CL_26_195; // Power class for 26MHz at 1.95V 1 R [201:201]
+ UINT8 PWR_CL_52_360; // Power class for 52MHz at 3.6V 1 R [202:202]
+ UINT8 PWR_CL_26_360; // Power class for 26MHz at 3.6V 1 R [203:203]
+ UINT8 RESERVED_17; // Reserved [204:204]
+ UINT8 MIN_PERF_R_4_26; // Minimum read performance for 4bit at 26MHz [205:205]
+ UINT8 MIN_PERF_W_4_26; // Minimum write performance for 4bit at 26MHz [206:206]
+ UINT8 MIN_PERF_R_8_26_4_52; // Minimum read performance for 8bit at 26MHz, for 4bit at 52MHz [207:207]
+ UINT8 MIN_PERF_W_8_26_4_52; // Minimum write performance for 8bit at 26MHz, for 4bit at 52MHz [208:208]
+ UINT8 MIN_PERF_R_8_52; // Minimum read performance for 8bit at 52MHz [209:209]
+ UINT8 MIN_PERF_W_8_52; // Minimum write performance for 8bit at 52MHz [210:210]
+ UINT8 RESERVED_18; // Reserved [211:211]
+ UINT32 SECTOR_COUNT; // Sector count [215:212]
+ UINT8 SLEEP_NOTIFICATION_TIME; // Sleep notification timeout [216:216]
+ UINT8 S_A_TIMEOUT; // Sleep/awake timeout [217:217]
+ UINT8 PRODUCTION_STATE_AWARENESS_TIMEOUT; // Production state awareness timeout [218:218]
+ UINT8 S_C_VCCQ; // Sleep current (VCCQ) [219:219]
+ UINT8 S_C_VCC; // Sleep current (VCC) [220:220]
+ UINT8 HC_WP_GRP_SIZE; // High-capacity write protect group size [221:221]
+ UINT8 REL_WR_SECTOR_C; // Reliable write sector count [222:222]
+ UINT8 ERASE_TIMEOUT_MULT; // High-capacity erase timeout [223:223]
+ UINT8 HC_ERASE_GRP_SIZE; // High-capacity erase unit size [224:224]
+ UINT8 ACC_SIZE; // Access size [225:225]
+ UINT8 BOOT_SIZE_MULTI; // Boot partition size [226:226]
+ UINT8 RESERVED_19; // Reserved [227:227]
+ UINT8 BOOT_INFO; // Boot information [228:228]
+ UINT8 SECURE_TRIM_MULT; // Secure TRIM Multiplier [229:229]
+ UINT8 SECURE_ERASE_MULT; // Secure Erase Multiplier [230:230]
+ UINT8 SECURE_FEATURE_SUPPORT; // Secure Feature Support [231:231]
+ UINT8 TRIM_MULT; // TRIM Multiplier [232:232]
+ UINT8 RESERVED_20; // Reserved [233:233]
+ UINT8 MIN_PREF_DDR_R_8_52; // Minimum read performance for 8bit at 52MHz in DDR mode [234:234]
+ UINT8 MIN_PREF_DDR_W_8_52; // Minimum write performance for 8bit at 52MHz in DDR mode [235:235]
+ UINT8 PWR_CL_200_130; // Power class for 200MHz at VCCQ=1.3V, VCC=3.6V [236:236]
+ UINT8 PWR_CL_200_195; // Power class for 200MHz at VCCQ=1.95V, VCC=3.6V [237:237]
+ UINT8 PWR_CL_DDR_52_195; // Power class for 52MHz, DDR at 1.95V [238:238]
+ UINT8 PWR_CL_DDR_52_360; // Power class for 52Mhz, DDR at 3.6V [239:239]
+ UINT8 RESERVED_21; // Reserved [240:240]
+ UINT8 INI_TIMEOUT_AP; // 1st initialization time after partitioning [241:241]
+ UINT8 CORRECTLY_PRG_SECTORS_NUM[4]; // Number of correctly programmed sectors [245:242]
+ UINT8 BKOPS_STATUS; // Background operations status [246:246]
+ UINT8 POWER_OFF_LONG_TIME; // Power off notification (long) timeout [247:247]
+ UINT8 GENERIC_CMD6_TIME; // Generic CMD6 timeout [248:248]
+ UINT8 CACHE_SIZE[4]; // Cache size [252:249]
+ UINT8 PWR_CL_DDR_200_360; // Power class for 200MHz, DDR at VCC=3.6V [253:253]
+ UINT8 FIRMWARE_VERSION[8]; // Firmware version [261:254]
+ UINT8 DEVICE_VERSION[2]; // Device version [263:262]
+ UINT8 OPTIMAL_TRIM_UNIT_SIZE; // Optimal trim unit size [264:264]
+ UINT8 OPTIMAL_WRITE_SIZE; // Optimal write size [265:265]
+ UINT8 OPTIMAL_READ_SIZE; // Optimal read size [266:266]
+ UINT8 PRE_EOL_INFO; // Pre EOL information [267:267]
+ UINT8 DEVICE_LIFE_TIME_EST_TYP_A; // Device life time estimation type A [268:268]
+ UINT8 DEVICE_LIFE_TIME_EST_TYP_B; // Device life time estimation type B [269:269]
+ UINT8 VENDOR_PROPRIETARY_HEALTH_REPORT[32]; // Vendor proprietary health report [301:270]
+ UINT8 NUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED[4]; // Number of FW sectors correctly programmed [305:302]
+ UINT8 RESERVED_22[181]; // Reserved [486:306]
+ UINT8 FFU_ARG[4]; // FFU argument [490:487]
+ UINT8 OPERATION_CODE_TIMEOUT; // Operation codes timeout [491:491]
+ UINT8 FFU_FEATURES; // FFU features [492:492]
+ UINT8 SUPPORTED_MODES; // Supported modes [493:493]
+ UINT8 EXT_SUPPORT; // Extended partitions attribute support [494:494]
+ UINT8 LARGE_UNIT_SIZE_M1; // Large unit size [495:495]
+ UINT8 CONTEXT_CAPABILITIES; // Context management capabilities [496:496]
+ UINT8 TAG_RES_SIZE; // Tag resource size [497:497]
+ UINT8 TAG_UNIT_SIZE; // Tag unit size [498:498]
+ UINT8 DATA_TAG_SUPPORT; // Data tag support [499:499]
+ UINT8 MAX_PACKED_WRITES; // Max packed write commands [500:500]
+ UINT8 MAX_PACKED_READS; // Max packed read commands [501:501]
+ UINT8 BKOPS_SUPPORT; // Background operations support [502:502]
+ UINT8 HPI_FEATURES; // HPI features [503:503]
+ UINT8 S_CMD_SET; // Supported command sets [504:504]
+ UINT8 EXT_SECURITY_ERR; // Extended security commands error [505:505]
+ UINT8 RESERVED_23[6]; // Reserved [511:506]
} ECSD;
typedef struct {
- UINT16 RCA;
- CARD_TYPE CardType;
- OCR OCRData;
- CID CIDData;
- CSD CSDData;
- ECSD *ECSDData; // MMC V4 extended card specific
+ UINT16 RCA;
+ CARD_TYPE CardType;
+ OCR OCRData;
+ CID CIDData;
+ CSD CSDData;
+ ECSD *ECSDData; // MMC V4 extended card specific
} CARD_INFO;
typedef struct _MMC_HOST_INSTANCE {
- UINTN Signature;
- LIST_ENTRY Link;
- EFI_HANDLE MmcHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN Signature;
+ LIST_ENTRY Link;
+ EFI_HANDLE MmcHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- MMC_STATE State;
- EFI_BLOCK_IO_PROTOCOL BlockIo;
- CARD_INFO CardInfo;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
+ MMC_STATE State;
+ EFI_BLOCK_IO_PROTOCOL BlockIo;
+ CARD_INFO CardInfo;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
- BOOLEAN Initialized;
+ BOOLEAN Initialized;
} MMC_HOST_INSTANCE;
-#define MMC_HOST_INSTANCE_SIGNATURE SIGNATURE_32('m', 'm', 'c', 'h')
-#define MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS(a) CR (a, MMC_HOST_INSTANCE, BlockIo, MMC_HOST_INSTANCE_SIGNATURE)
-#define MMC_HOST_INSTANCE_FROM_LINK(a) CR (a, MMC_HOST_INSTANCE, Link, MMC_HOST_INSTANCE_SIGNATURE)
-
+#define MMC_HOST_INSTANCE_SIGNATURE SIGNATURE_32('m', 'm', 'c', 'h')
+#define MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS(a) CR (a, MMC_HOST_INSTANCE, BlockIo, MMC_HOST_INSTANCE_SIGNATURE)
+#define MMC_HOST_INSTANCE_FROM_LINK(a) CR (a, MMC_HOST_INSTANCE, Link, MMC_HOST_INSTANCE_SIGNATURE)
EFI_STATUS
EFIAPI
@@ -356,19 +355,19 @@ MmcGetDriverName (
EFI_STATUS
EFIAPI
MmcGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
);
-extern EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2;
+extern EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName;
+extern EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2;
-extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2;
+extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2;
-extern LIST_ENTRY mMmcHostPool;
+extern LIST_ENTRY mMmcHostPool;
/**
Reset the block device.
@@ -388,8 +387,8 @@ extern LIST_ENTRY mMmcHostPool;
EFI_STATUS
EFIAPI
MmcReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -419,11 +418,11 @@ MmcReset (
EFI_STATUS
EFIAPI
MmcReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
);
/**
@@ -454,11 +453,11 @@ MmcReadBlocks (
EFI_STATUS
EFIAPI
MmcWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
);
/**
@@ -479,45 +478,45 @@ MmcFlushBlocks (
EFI_STATUS
MmcNotifyState (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN MMC_STATE State
+ IN MMC_HOST_INSTANCE *MmcHostInstance,
+ IN MMC_STATE State
);
EFI_STATUS
InitializeMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHost
+ IN MMC_HOST_INSTANCE *MmcHost
);
VOID
EFIAPI
CheckCardsCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
VOID
PrintCSD (
- IN UINT32* Csd
+ IN UINT32 *Csd
);
VOID
PrintRCA (
- IN UINT32 Rca
+ IN UINT32 Rca
);
VOID
PrintOCR (
- IN UINT32 Ocr
+ IN UINT32 Ocr
);
VOID
PrintResponseR1 (
- IN UINT32 Response
+ IN UINT32 Response
);
VOID
PrintCID (
- IN UINT32* Cid
+ IN UINT32 *Cid
);
#endif
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index 7614ecdf0a..d695e25571 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -12,8 +12,8 @@
EFI_STATUS
MmcNotifyState (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN MMC_STATE State
+ IN MMC_HOST_INSTANCE *MmcHostInstance,
+ IN MMC_STATE State
)
{
MmcHostInstance->State = State;
@@ -23,23 +23,24 @@ MmcNotifyState (
EFI_STATUS
EFIAPI
MmcGetCardStatus (
- IN MMC_HOST_INSTANCE *MmcHostInstance
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
- EFI_STATUS Status;
- UINT32 Response[4];
- UINTN CmdArg;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
+ EFI_STATUS Status;
+ UINT32 Response[4];
+ UINTN CmdArg;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
MmcHost = MmcHostInstance->MmcHost;
- CmdArg = 0;
+ CmdArg = 0;
if (MmcHost == NULL) {
return EFI_INVALID_PARAMETER;
}
+
if (MmcHostInstance->State != MmcHwInitializationState) {
- //Get the Status of the card.
+ // Get the Status of the card.
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (EFI_ERROR (Status)) {
@@ -47,7 +48,7 @@ MmcGetCardStatus (
return Status;
}
- //Read Response
+ // Read Response
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
PrintResponseR1 (Response[0]);
}
@@ -58,11 +59,11 @@ MmcGetCardStatus (
EFI_STATUS
EFIAPI
MmcReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- MMC_HOST_INSTANCE *MmcHostInstance;
+ MMC_HOST_INSTANCE *MmcHostInstance;
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
@@ -91,7 +92,7 @@ MmcReset (
EFI_STATUS
MmcDetectCard (
- EFI_MMC_HOST_PROTOCOL *MmcHost
+ EFI_MMC_HOST_PROTOCOL *MmcHost
)
{
if (!MmcHost->IsCardPresent (MmcHost)) {
@@ -103,58 +104,61 @@ MmcDetectCard (
EFI_STATUS
MmcStopTransmission (
- EFI_MMC_HOST_PROTOCOL *MmcHost
+ EFI_MMC_HOST_PROTOCOL *MmcHost
)
{
- EFI_STATUS Status;
- UINT32 Response[4];
+ EFI_STATUS Status;
+ UINT32 Response[4];
+
// Command 12 - Stop transmission (ends read or write)
// Normally only needed for streaming transfers or after error.
Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
if (!EFI_ERROR (Status)) {
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response);
}
+
return Status;
}
-#define MMCI0_BLOCKLEN 512
-#define MMCI0_TIMEOUT 10000
+#define MMCI0_BLOCKLEN 512
+#define MMCI0_TIMEOUT 10000
STATIC
EFI_STATUS
MmcTransferBlock (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINTN Cmd,
- IN UINTN Transfer,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINTN Cmd,
+ IN UINTN Transfer,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- UINTN CmdArg;
- INTN Timeout;
- UINT32 Response[4];
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
+ EFI_STATUS Status;
+ UINTN CmdArg;
+ INTN Timeout;
+ UINT32 Response[4];
+ MMC_HOST_INSTANCE *MmcHostInstance;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
- MmcHost = MmcHostInstance->MmcHost;
+ MmcHost = MmcHostInstance->MmcHost;
if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
- //Set command argument based on the card capacity
- //if 0 : SDSC card
- //if 1 : SDXC/SDHC
+ // Set command argument based on the card capacity
+ // if 0 : SDSC card
+ // if 1 : SDXC/SDHC
if (MmcHostInstance->CardInfo.OCRData.AccessMode & SD_CARD_CAPACITY) {
CmdArg = Lba;
} else {
CmdArg = MultU64x32 (Lba, This->Media->BlockSize);
}
} else {
- //Set command argument based on the card access mode (Byte mode or Block mode)
+ // Set command argument based on the card access mode (Byte mode or Block mode)
if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
- MMC_OCR_ACCESS_SECTOR) {
+ MMC_OCR_ACCESS_SECTOR)
+ {
CmdArg = Lba;
} else {
CmdArg = MultU64x32 (Lba, This->Media->BlockSize);
@@ -175,6 +179,7 @@ MmcTransferBlock (
MmcStopTransmission (MmcHost);
return Status;
}
+
Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a() : Error MmcProgrammingState\n", __func__));
@@ -191,12 +196,13 @@ MmcTransferBlock (
}
// Command 13 - Read status and wait for programming to complete (return to tran)
- Timeout = MMCI0_TIMEOUT;
- CmdArg = MmcHostInstance->CardInfo.RCA << 16;
+ Timeout = MMCI0_TIMEOUT;
+ CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Response[0] = 0;
- while(!(Response[0] & MMC_R0_READY_FOR_DATA)
+ while ( !(Response[0] & MMC_R0_READY_FOR_DATA)
&& (MMC_R0_CURRENTSTATE (Response) != MMC_R0_STATE_TRAN)
- && Timeout--) {
+ && Timeout--)
+ {
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (!EFI_ERROR (Status)) {
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
@@ -211,6 +217,7 @@ MmcTransferBlock (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_BLKIO, "%a(): Error and Status:%r\n", __func__, Status));
}
+
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response);
}
@@ -219,33 +226,34 @@ MmcTransferBlock (
DEBUG ((DEBUG_ERROR, "MmcIoBlocks() : Error MmcTransferState\n"));
return Status;
}
+
return Status;
}
EFI_STATUS
MmcIoBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINTN Transfer,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINTN Transfer,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
- UINT32 Response[4];
- EFI_STATUS Status;
- UINTN CmdArg;
- INTN Timeout;
- UINTN Cmd;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- UINTN BytesRemainingToBeTransfered;
- UINTN BlockCount;
- UINTN ConsumeSize;
- UINT32 MaxBlock;
- UINTN RemainingBlock;
-
- BlockCount = 1;
+ UINT32 Response[4];
+ EFI_STATUS Status;
+ UINTN CmdArg;
+ INTN Timeout;
+ UINTN Cmd;
+ MMC_HOST_INSTANCE *MmcHostInstance;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
+ UINTN BytesRemainingToBeTransfered;
+ UINTN BlockCount;
+ UINTN ConsumeSize;
+ UINT32 MaxBlock;
+ UINTN RemainingBlock;
+
+ BlockCount = 1;
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
ASSERT (MmcHostInstance != NULL);
MmcHost = MmcHostInstance->MmcHost;
@@ -274,7 +282,7 @@ MmcIoBlocks (
return EFI_BAD_BUFFER_SIZE;
}
- if (MMC_HOST_HAS_ISMULTIBLOCK(MmcHost) && MmcHost->IsMultiBlock(MmcHost)) {
+ if (MMC_HOST_HAS_ISMULTIBLOCK (MmcHost) && MmcHost->IsMultiBlock (MmcHost)) {
BlockCount = BufferSize / This->Media->BlockSize;
}
@@ -293,11 +301,10 @@ MmcIoBlocks (
}
// Max block number in single cmd is 65535 blocks.
- MaxBlock = 0xFFFF;
- RemainingBlock = BlockCount;
+ MaxBlock = 0xFFFF;
+ RemainingBlock = BlockCount;
BytesRemainingToBeTransfered = BufferSize;
while (BytesRemainingToBeTransfered > 0) {
-
if (RemainingBlock <= MaxBlock) {
BlockCount = RemainingBlock;
} else {
@@ -305,12 +312,13 @@ MmcIoBlocks (
}
// Check if the Card is in Ready status
- CmdArg = MmcHostInstance->CardInfo.RCA << 16;
+ CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Response[0] = 0;
- Timeout = 20;
- while( (!(Response[0] & MMC_R0_READY_FOR_DATA))
+ Timeout = 20;
+ while ( (!(Response[0] & MMC_R0_READY_FOR_DATA))
&& (MMC_R0_CURRENTSTATE (Response) != MMC_R0_STATE_TRAN)
- && Timeout--) {
+ && Timeout--)
+ {
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
if (!EFI_ERROR (Status)) {
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
@@ -327,16 +335,16 @@ MmcIoBlocks (
// Read a single block
Cmd = MMC_CMD17;
} else {
- // Read multiple blocks
- Cmd = MMC_CMD18;
+ // Read multiple blocks
+ Cmd = MMC_CMD18;
}
} else {
if (BlockCount == 1) {
// Write a single block
Cmd = MMC_CMD24;
} else {
- // Write multiple blocks
- Cmd = MMC_CMD25;
+ // Write multiple blocks
+ Cmd = MMC_CMD25;
}
}
@@ -344,15 +352,16 @@ MmcIoBlocks (
if (BytesRemainingToBeTransfered < ConsumeSize) {
ConsumeSize = BytesRemainingToBeTransfered;
}
+
Status = MmcTransferBlock (This, Cmd, Transfer, MediaId, Lba, ConsumeSize, Buffer);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a(): Failed to transfer block and Status:%r\n", __func__, Status));
}
- RemainingBlock -= BlockCount;
+ RemainingBlock -= BlockCount;
BytesRemainingToBeTransfered -= ConsumeSize;
if (BytesRemainingToBeTransfered > 0) {
- Lba += BlockCount;
+ Lba += BlockCount;
Buffer = (UINT8 *)Buffer + ConsumeSize;
}
}
@@ -363,11 +372,11 @@ MmcIoBlocks (
EFI_STATUS
EFIAPI
MmcReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
)
{
return MmcIoBlocks (This, MMC_IOBLOCKS_READ, MediaId, Lba, BufferSize, Buffer);
@@ -376,11 +385,11 @@ MmcReadBlocks (
EFI_STATUS
EFIAPI
MmcWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
+ IN EFI_BLOCK_IO_PROTOCOL *This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
return MmcIoBlocks (This, MMC_IOBLOCKS_WRITE, MediaId, Lba, BufferSize, Buffer);
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c b/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c
index 3f23a13c8b..cf1b97fb9e 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcDebug.c
@@ -8,33 +8,36 @@
#include "Mmc.h"
-#if !defined(MDEPKG_NDEBUG)
-CONST CHAR8* mStrUnit[] = { "100kbit/s", "1Mbit/s", "10Mbit/s", "100MBit/s",
- "Unknown", "Unknown", "Unknown", "Unknown" };
-CONST CHAR8* mStrValue[] = { "1.0", "1.2", "1.3", "1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0",
- "Unknown", "Unknown", "Unknown", "Unknown" };
+#if !defined (MDEPKG_NDEBUG)
+CONST CHAR8 *mStrUnit[] = {
+ "100kbit/s", "1Mbit/s", "10Mbit/s", "100MBit/s",
+ "Unknown", "Unknown", "Unknown", "Unknown"
+};
+CONST CHAR8 *mStrValue[] = {
+ "1.0", "1.2", "1.3", "1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "5.0",
+ "Unknown", "Unknown", "Unknown", "Unknown"
+};
#endif
VOID
PrintCID (
- IN UINT32* Cid
+ IN UINT32 *Cid
)
{
DEBUG ((DEBUG_ERROR, "- PrintCID\n"));
DEBUG ((DEBUG_ERROR, "\t- Manufacturing date: %d/%d\n", (Cid[0] >> 8) & 0xF, (Cid[0] >> 12) & 0xFF));
DEBUG ((DEBUG_ERROR, "\t- Product serial number: 0x%X%X\n", Cid[1] & 0xFFFFFF, (Cid[0] >> 24) & 0xFF));
DEBUG ((DEBUG_ERROR, "\t- Product revision: %d\n", Cid[1] >> 24));
- //DEBUG ((DEBUG_ERROR, "\t- Product name: %s\n", (char*)(Cid + 2)));
+ // DEBUG ((DEBUG_ERROR, "\t- Product name: %s\n", (char*)(Cid + 2)));
DEBUG ((DEBUG_ERROR, "\t- OEM ID: %c%c\n", (Cid[3] >> 8) & 0xFF, (Cid[3] >> 16) & 0xFF));
}
-
VOID
PrintCSD (
- IN UINT32* Csd
+ IN UINT32 *Csd
)
{
- UINTN Value;
+ UINTN Value;
if (((Csd[2] >> 30) & 0x3) == 0) {
DEBUG ((DEBUG_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
@@ -45,9 +48,9 @@ PrintCSD (
}
DEBUG ((DEBUG_ERROR, "\t- Supported card command class: 0x%X\n", MMC_CSD_GET_CCC (Csd)));
- DEBUG ((DEBUG_ERROR, "\t- Speed: %a %a\n",mStrValue[(MMC_CSD_GET_TRANSPEED (Csd) >> 3) & 0xF],mStrUnit[MMC_CSD_GET_TRANSPEED (Csd) & 7]));
- DEBUG ((DEBUG_ERROR, "\t- Maximum Read Data Block: %d\n",2 << (MMC_CSD_GET_READBLLEN (Csd)-1)));
- DEBUG ((DEBUG_ERROR, "\t- Maximum Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN (Csd)-1)));
+ DEBUG ((DEBUG_ERROR, "\t- Speed: %a %a\n", mStrValue[(MMC_CSD_GET_TRANSPEED (Csd) >> 3) & 0xF], mStrUnit[MMC_CSD_GET_TRANSPEED (Csd) & 7]));
+ DEBUG ((DEBUG_ERROR, "\t- Maximum Read Data Block: %d\n", 2 << (MMC_CSD_GET_READBLLEN (Csd)-1)));
+ DEBUG ((DEBUG_ERROR, "\t- Maximum Write Data Block: %d\n", 2 << (MMC_CSD_GET_WRITEBLLEN (Csd)-1)));
if (!MMC_CSD_GET_FILEFORMATGRP (Csd)) {
Value = MMC_CSD_GET_FILEFORMAT (Csd);
@@ -67,7 +70,7 @@ PrintCSD (
VOID
PrintRCA (
- IN UINT32 Rca
+ IN UINT32 Rca
)
{
DEBUG ((DEBUG_ERROR, "- PrintRCA: 0x%X\n", Rca));
@@ -77,13 +80,13 @@ PrintRCA (
VOID
PrintOCR (
- IN UINT32 Ocr
+ IN UINT32 Ocr
)
{
- UINTN MinV;
- UINTN MaxV;
- UINTN Volts;
- UINTN Loop;
+ UINTN MinV;
+ UINTN MaxV;
+ UINTN Volts;
+ UINTN Loop;
MinV = 36; // 3.6
MaxV = 20; // 2.0
@@ -95,14 +98,16 @@ PrintOCR (
if (MinV > Volts) {
MinV = Volts;
}
+
if (MaxV < Volts) {
MaxV = Volts + 1;
}
}
+
Volts++;
}
- DEBUG ((DEBUG_ERROR, "- PrintOCR Ocr (0x%X)\n",Ocr));
+ DEBUG ((DEBUG_ERROR, "- PrintOCR Ocr (0x%X)\n", Ocr));
DEBUG ((DEBUG_ERROR, "\t- Card operating voltage: %d.%d to %d.%d\n", MinV/10, MinV % 10, MaxV/10, MaxV % 10));
if (((Ocr >> 29) & 3) == 0) {
DEBUG ((DEBUG_ERROR, "\t- AccessMode: Byte Mode\n"));
@@ -119,7 +124,7 @@ PrintOCR (
VOID
PrintResponseR1 (
- IN UINT32 Response
+ IN UINT32 Response
)
{
DEBUG ((DEBUG_INFO, "Response: 0x%X\n", Response));
@@ -128,35 +133,35 @@ PrintResponseR1 (
}
switch ((Response >> 9) & 0xF) {
- case 0:
- DEBUG ((DEBUG_INFO, "\t- State: Idle\n"));
- break;
- case 1:
- DEBUG ((DEBUG_INFO, "\t- State: Ready\n"));
- break;
- case 2:
- DEBUG ((DEBUG_INFO, "\t- State: Ident\n"));
- break;
- case 3:
- DEBUG ((DEBUG_INFO, "\t- State: StandBy\n"));
- break;
- case 4:
- DEBUG ((DEBUG_INFO, "\t- State: Tran\n"));
- break;
- case 5:
- DEBUG ((DEBUG_INFO, "\t- State: Data\n"));
- break;
- case 6:
- DEBUG ((DEBUG_INFO, "\t- State: Rcv\n"));
- break;
- case 7:
- DEBUG ((DEBUG_INFO, "\t- State: Prg\n"));
- break;
- case 8:
- DEBUG ((DEBUG_INFO, "\t- State: Dis\n"));
- break;
- default:
- DEBUG ((DEBUG_INFO, "\t- State: Reserved\n"));
- break;
+ case 0:
+ DEBUG ((DEBUG_INFO, "\t- State: Idle\n"));
+ break;
+ case 1:
+ DEBUG ((DEBUG_INFO, "\t- State: Ready\n"));
+ break;
+ case 2:
+ DEBUG ((DEBUG_INFO, "\t- State: Ident\n"));
+ break;
+ case 3:
+ DEBUG ((DEBUG_INFO, "\t- State: StandBy\n"));
+ break;
+ case 4:
+ DEBUG ((DEBUG_INFO, "\t- State: Tran\n"));
+ break;
+ case 5:
+ DEBUG ((DEBUG_INFO, "\t- State: Data\n"));
+ break;
+ case 6:
+ DEBUG ((DEBUG_INFO, "\t- State: Rcv\n"));
+ break;
+ case 7:
+ DEBUG ((DEBUG_INFO, "\t- State: Prg\n"));
+ break;
+ case 8:
+ DEBUG ((DEBUG_INFO, "\t- State: Dis\n"));
+ break;
+ default:
+ DEBUG ((DEBUG_INFO, "\t- State: Reserved\n"));
+ break;
}
}
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
index 0df948426f..86eb55800e 100755
--- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
@@ -13,38 +13,38 @@
#include "Mmc.h"
typedef union {
- UINT32 Raw;
- OCR Ocr;
+ UINT32 Raw;
+ OCR Ocr;
} OCR_RESPONSE;
-#define MAX_RETRY_COUNT 1000
-#define CMD_RETRY_COUNT 20
-#define RCA_SHIFT_OFFSET 16
-#define EMMC_CARD_SIZE 512
-#define EMMC_ECSD_SIZE_OFFSET 53
+#define MAX_RETRY_COUNT 1000
+#define CMD_RETRY_COUNT 20
+#define RCA_SHIFT_OFFSET 16
+#define EMMC_CARD_SIZE 512
+#define EMMC_ECSD_SIZE_OFFSET 53
-#define EXTCSD_BUS_WIDTH 183
-#define EXTCSD_HS_TIMING 185
+#define EXTCSD_BUS_WIDTH 183
+#define EXTCSD_HS_TIMING 185
-#define EMMC_TIMING_BACKWARD 0
-#define EMMC_TIMING_HS 1
-#define EMMC_TIMING_HS200 2
-#define EMMC_TIMING_HS400 3
+#define EMMC_TIMING_BACKWARD 0
+#define EMMC_TIMING_HS 1
+#define EMMC_TIMING_HS200 2
+#define EMMC_TIMING_HS400 3
-#define EMMC_BUS_WIDTH_1BIT 0
-#define EMMC_BUS_WIDTH_4BIT 1
-#define EMMC_BUS_WIDTH_8BIT 2
-#define EMMC_BUS_WIDTH_DDR_4BIT 5
-#define EMMC_BUS_WIDTH_DDR_8BIT 6
+#define EMMC_BUS_WIDTH_1BIT 0
+#define EMMC_BUS_WIDTH_4BIT 1
+#define EMMC_BUS_WIDTH_8BIT 2
+#define EMMC_BUS_WIDTH_DDR_4BIT 5
+#define EMMC_BUS_WIDTH_DDR_8BIT 6
-#define EMMC_SWITCH_ERROR (1 << 7)
+#define EMMC_SWITCH_ERROR (1 << 7)
-#define SD_BUS_WIDTH_1BIT (1 << 0)
-#define SD_BUS_WIDTH_4BIT (1 << 2)
+#define SD_BUS_WIDTH_1BIT (1 << 0)
+#define SD_BUS_WIDTH_4BIT (1 << 2)
-#define SD_CCC_SWITCH (1 << 10)
+#define SD_CCC_SWITCH (1 << 10)
-#define DEVICE_STATE(x) (((x) >> 9) & 0xf)
+#define DEVICE_STATE(x) (((x) >> 9) & 0xf)
typedef enum _EMMC_DEVICE_STATE {
EMMC_IDLE_STATE = 0,
EMMC_READY_STATE,
@@ -59,41 +59,44 @@ typedef enum _EMMC_DEVICE_STATE {
EMMC_SLP_STATE
} EMMC_DEVICE_STATE;
-UINT32 mEmmcRcaCount = 0;
+UINT32 mEmmcRcaCount = 0;
STATIC
EFI_STATUS
EFIAPI
EmmcGetDeviceState (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- OUT EMMC_DEVICE_STATE *State
+ IN MMC_HOST_INSTANCE *MmcHostInstance,
+ OUT EMMC_DEVICE_STATE *State
)
{
- EFI_MMC_HOST_PROTOCOL *Host;
- EFI_STATUS Status;
- UINT32 Data, RCA;
+ EFI_MMC_HOST_PROTOCOL *Host;
+ EFI_STATUS Status;
+ UINT32 Data, RCA;
if (State == NULL) {
return EFI_INVALID_PARAMETER;
}
- Host = MmcHostInstance->MmcHost;
- RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
+ Host = MmcHostInstance->MmcHost;
+ RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
Status = Host->SendCommand (Host, MMC_CMD13, RCA);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcGetDeviceState(): Failed to get card status, Status=%r.\n", Status));
return Status;
}
+
Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R1, &Data);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcGetDeviceState(): Failed to get response of CMD13, Status=%r.\n", Status));
return Status;
}
+
if (Data & EMMC_SWITCH_ERROR) {
DEBUG ((DEBUG_ERROR, "EmmcGetDeviceState(): Failed to switch expected mode, Status=%r.\n", Status));
return EFI_DEVICE_ERROR;
}
- *State = DEVICE_STATE(Data);
+
+ *State = DEVICE_STATE (Data);
return EFI_SUCCESS;
}
@@ -101,24 +104,25 @@ STATIC
EFI_STATUS
EFIAPI
EmmcSetEXTCSD (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- UINT32 ExtCmdIndex,
- UINT32 Value
+ IN MMC_HOST_INSTANCE *MmcHostInstance,
+ UINT32 ExtCmdIndex,
+ UINT32 Value
)
{
- EFI_MMC_HOST_PROTOCOL *Host;
- EMMC_DEVICE_STATE State;
- EFI_STATUS Status;
- UINT32 Argument;
-
- Host = MmcHostInstance->MmcHost;
- Argument = EMMC_CMD6_ARG_ACCESS(3) | EMMC_CMD6_ARG_INDEX(ExtCmdIndex) |
- EMMC_CMD6_ARG_VALUE(Value) | EMMC_CMD6_ARG_CMD_SET(1);
+ EFI_MMC_HOST_PROTOCOL *Host;
+ EMMC_DEVICE_STATE State;
+ EFI_STATUS Status;
+ UINT32 Argument;
+
+ Host = MmcHostInstance->MmcHost;
+ Argument = EMMC_CMD6_ARG_ACCESS (3) | EMMC_CMD6_ARG_INDEX (ExtCmdIndex) |
+ EMMC_CMD6_ARG_VALUE (Value) | EMMC_CMD6_ARG_CMD_SET (1);
Status = Host->SendCommand (Host, MMC_CMD6, Argument);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcSetEXTCSD(): Failed to send CMD6, Status=%r.\n", Status));
return Status;
}
+
// Make sure device exiting prog mode
do {
Status = EmmcGetDeviceState (MmcHostInstance, &State);
@@ -127,6 +131,7 @@ EmmcSetEXTCSD (
return Status;
}
} while (State == EMMC_PRG_STATE);
+
return EFI_SUCCESS;
}
@@ -134,15 +139,15 @@ STATIC
EFI_STATUS
EFIAPI
EmmcIdentificationMode (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN OCR_RESPONSE Response
+ IN MMC_HOST_INSTANCE *MmcHostInstance,
+ IN OCR_RESPONSE Response
)
{
- EFI_MMC_HOST_PROTOCOL *Host;
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
- EMMC_DEVICE_STATE State;
- UINT32 RCA;
+ EFI_MMC_HOST_PROTOCOL *Host;
+ EFI_BLOCK_IO_MEDIA *Media;
+ EFI_STATUS Status;
+ EMMC_DEVICE_STATE State;
+ UINT32 RCA;
Host = MmcHostInstance->MmcHost;
Media = MmcHostInstance->BlockIo.Media;
@@ -162,8 +167,8 @@ EmmcIdentificationMode (
// Assign a relative address value to the card
MmcHostInstance->CardInfo.RCA = ++mEmmcRcaCount; // TODO: might need a more sophisticated way of doing this
- RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
- Status = Host->SendCommand (Host, MMC_CMD3, RCA);
+ RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
+ Status = Host->SendCommand (Host, MMC_CMD3, RCA);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): RCA set error, Status=%r.\n", Status));
return Status;
@@ -188,7 +193,7 @@ EmmcIdentificationMode (
DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): Card selection error, Status=%r.\n", Status));
}
- if (MMC_HOST_HAS_SETIOS(Host)) {
+ if (MMC_HOST_HAS_SETIOS (Host)) {
// Set 1-bit bus width
Status = Host->SetIos (Host, 0, 1, EMMCBACKWARD);
if (EFI_ERROR (Status)) {
@@ -209,6 +214,7 @@ EmmcIdentificationMode (
if (MmcHostInstance->CardInfo.ECSDData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
Status = Host->SendCommand (Host, MMC_CMD8, 0);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): ECSD fetch error, Status=%r.\n", Status));
@@ -230,11 +236,11 @@ EmmcIdentificationMode (
} while (State == EMMC_DATA_STATE);
// Set up media
- Media->BlockSize = EMMC_CARD_SIZE; // 512-byte support is mandatory for eMMC cards
- Media->MediaId = MmcHostInstance->CardInfo.CIDData.PSN;
- Media->ReadOnly = MmcHostInstance->CardInfo.CSDData.PERM_WRITE_PROTECT;
+ Media->BlockSize = EMMC_CARD_SIZE; // 512-byte support is mandatory for eMMC cards
+ Media->MediaId = MmcHostInstance->CardInfo.CIDData.PSN;
+ Media->ReadOnly = MmcHostInstance->CardInfo.CSDData.PERM_WRITE_PROTECT;
Media->LogicalBlocksPerPhysicalBlock = 1;
- Media->IoAlign = 4;
+ Media->IoAlign = 4;
// Compute last block using bits [215:212] of the ECSD
Media->LastBlock = MmcHostInstance->CardInfo.ECSDData->SECTOR_COUNT - 1; // eMMC isn't supposed to report this for
// Cards <2GB in size, but the model does.
@@ -251,23 +257,25 @@ FreePageExit:
STATIC
EFI_STATUS
InitializeEmmcDevice (
- IN MMC_HOST_INSTANCE *MmcHostInstance
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
- EFI_MMC_HOST_PROTOCOL *Host;
- EFI_STATUS Status = EFI_SUCCESS;
- ECSD *ECSDData;
- UINT32 BusClockFreq, Idx, BusMode;
- UINT32 TimingMode[4] = {EMMCHS52DDR1V2, EMMCHS52DDR1V8, EMMCHS52, EMMCHS26};
+ EFI_MMC_HOST_PROTOCOL *Host;
+ EFI_STATUS Status = EFI_SUCCESS;
+ ECSD *ECSDData;
+ UINT32 BusClockFreq, Idx, BusMode;
+ UINT32 TimingMode[4] = { EMMCHS52DDR1V2, EMMCHS52DDR1V8, EMMCHS52, EMMCHS26 };
- Host = MmcHostInstance->MmcHost;
+ Host = MmcHostInstance->MmcHost;
ECSDData = MmcHostInstance->CardInfo.ECSDData;
- if (ECSDData->DEVICE_TYPE == EMMCBACKWARD)
+ if (ECSDData->DEVICE_TYPE == EMMCBACKWARD) {
return EFI_SUCCESS;
+ }
- if (!MMC_HOST_HAS_SETIOS(Host)) {
+ if (!MMC_HOST_HAS_SETIOS (Host)) {
return EFI_SUCCESS;
}
+
Status = EmmcSetEXTCSD (MmcHostInstance, EXTCSD_HS_TIMING, EMMC_TIMING_HS);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "InitializeEmmcDevice(): Failed to switch high speed mode, Status:%r.\n", Status));
@@ -276,52 +284,56 @@ InitializeEmmcDevice (
for (Idx = 0; Idx < 4; Idx++) {
switch (TimingMode[Idx]) {
- case EMMCHS52DDR1V2:
- case EMMCHS52DDR1V8:
- case EMMCHS52:
- BusClockFreq = 52000000;
- break;
- case EMMCHS26:
- BusClockFreq = 26000000;
- break;
- default:
- return EFI_UNSUPPORTED;
- }
- Status = Host->SetIos (Host, BusClockFreq, 8, TimingMode[Idx]);
- if (!EFI_ERROR (Status)) {
- switch (TimingMode[Idx]) {
case EMMCHS52DDR1V2:
case EMMCHS52DDR1V8:
- BusMode = EMMC_BUS_WIDTH_DDR_8BIT;
- break;
case EMMCHS52:
+ BusClockFreq = 52000000;
+ break;
case EMMCHS26:
- BusMode = EMMC_BUS_WIDTH_8BIT;
+ BusClockFreq = 26000000;
break;
default:
return EFI_UNSUPPORTED;
+ }
+
+ Status = Host->SetIos (Host, BusClockFreq, 8, TimingMode[Idx]);
+ if (!EFI_ERROR (Status)) {
+ switch (TimingMode[Idx]) {
+ case EMMCHS52DDR1V2:
+ case EMMCHS52DDR1V8:
+ BusMode = EMMC_BUS_WIDTH_DDR_8BIT;
+ break;
+ case EMMCHS52:
+ case EMMCHS26:
+ BusMode = EMMC_BUS_WIDTH_8BIT;
+ break;
+ default:
+ return EFI_UNSUPPORTED;
}
+
Status = EmmcSetEXTCSD (MmcHostInstance, EXTCSD_BUS_WIDTH, BusMode);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "InitializeEmmcDevice(): Failed to set EXTCSD bus width, Status:%r\n", Status));
}
+
return Status;
}
}
+
return Status;
}
STATIC
UINT32
CreateSwitchCmdArgument (
- IN UINT32 Mode,
- IN UINT8 Group,
- IN UINT8 Value
+ IN UINT32 Mode,
+ IN UINT8 Group,
+ IN UINT8 Value
)
{
- UINT32 Argument;
+ UINT32 Argument;
- Argument = Mode << 31 | 0x00FFFFFF;
+ Argument = Mode << 31 | 0x00FFFFFF;
Argument &= ~(0xF << (Group * 4));
Argument |= Value << (Group * 4);
@@ -331,51 +343,52 @@ CreateSwitchCmdArgument (
STATIC
EFI_STATUS
InitializeSdMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHostInstance
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
- UINT32 CmdArg;
- UINT32 Response[4];
- UINT32 Buffer[128];
- UINT32 Speed;
- UINTN BlockSize;
- UINTN CardSize;
- UINTN NumBlocks;
- BOOLEAN CccSwitch;
- SCR Scr;
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
-
- Speed = SD_DEFAULT_SPEED;
+ UINT32 CmdArg;
+ UINT32 Response[4];
+ UINT32 Buffer[128];
+ UINT32 Speed;
+ UINTN BlockSize;
+ UINTN CardSize;
+ UINTN NumBlocks;
+ BOOLEAN CccSwitch;
+ SCR Scr;
+ EFI_STATUS Status;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
+
+ Speed = SD_DEFAULT_SPEED;
MmcHost = MmcHostInstance->MmcHost;
// Send a command to get Card specific data
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "InitializeSdMmcDevice(MMC_CMD9): Error, Status=%r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeSdMmcDevice(MMC_CMD9): Error, Status=%r\n", Status));
return Status;
}
// Read Response
Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CSD, Response);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "InitializeSdMmcDevice(): Failed to receive CSD, Status=%r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeSdMmcDevice(): Failed to receive CSD, Status=%r\n", Status));
return Status;
}
+
PrintCSD (Response);
- if (MMC_CSD_GET_CCC(Response) & SD_CCC_SWITCH) {
+ if (MMC_CSD_GET_CCC (Response) & SD_CCC_SWITCH) {
CccSwitch = TRUE;
} else {
CccSwitch = FALSE;
}
if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
- CardSize = HC_MMC_CSD_GET_DEVICESIZE (Response);
+ CardSize = HC_MMC_CSD_GET_DEVICESIZE (Response);
NumBlocks = ((CardSize + 1) * 1024);
BlockSize = 1 << MMC_CSD_GET_READBLLEN (Response);
} else {
- CardSize = MMC_CSD_GET_DEVICESIZE (Response);
+ CardSize = MMC_CSD_GET_DEVICESIZE (Response);
NumBlocks = (CardSize + 1) * (1 << (MMC_CSD_GET_DEVICESIZEMULT (Response) + 2));
BlockSize = 1 << MMC_CSD_GET_READBLLEN (Response);
}
@@ -395,7 +408,7 @@ InitializeSdMmcDevice (
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "InitializeSdMmcDevice(MMC_CMD7): Error and Status = %r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeSdMmcDevice(MMC_CMD7): Error and Status = %r\n", Status));
return Status;
}
@@ -404,11 +417,13 @@ InitializeSdMmcDevice (
DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status = %r\n", __FUNCTION__, Status));
return Status;
}
+
Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status = %r\n", __FUNCTION__, Status));
return Status;
}
+
if ((Response[0] & MMC_STATUS_APP_CMD) == 0) {
return EFI_SUCCESS;
}
@@ -424,40 +439,42 @@ InitializeSdMmcDevice (
DEBUG ((DEBUG_ERROR, "%a(MMC_ACMD51): ReadBlockData Error and Status = %r\n", __func__, Status));
return Status;
}
+
CopyMem (&Scr, Buffer, 8);
if (Scr.SD_SPEC == 2) {
if (Scr.SD_SPEC3 == 1) {
- if (Scr.SD_SPEC4 == 1) {
+ if (Scr.SD_SPEC4 == 1) {
DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 4.xx\n"));
- } else {
+ } else {
DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 3.0x\n"));
- }
+ }
} else {
- if (Scr.SD_SPEC4 == 0) {
+ if (Scr.SD_SPEC4 == 0) {
DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 2.0\n"));
- } else {
- DEBUG ((DEBUG_ERROR, "Found invalid SD Card\n"));
- }
+ } else {
+ DEBUG ((DEBUG_ERROR, "Found invalid SD Card\n"));
+ }
}
} else {
if ((Scr.SD_SPEC3 == 0) && (Scr.SD_SPEC4 == 0)) {
if (Scr.SD_SPEC == 1) {
- DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.10\n"));
- } else {
- DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.0\n"));
- }
+ DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.10\n"));
+ } else {
+ DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.0\n"));
+ }
} else {
DEBUG ((DEBUG_ERROR, "Found invalid SD Card\n"));
}
}
}
+
if (CccSwitch) {
/* SD Switch, Mode:0, Group:0, Value:0 */
- CmdArg = CreateSwitchCmdArgument(0, 0, 0);
+ CmdArg = CreateSwitchCmdArgument (0, 0, 0);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): Error and Status = %r\n", __FUNCTION__, Status));
- return Status;
+ return Status;
} else {
Status = MmcHost->ReadBlockData (MmcHost, 0, SWITCH_CMD_DATA_LENGTH, Buffer);
if (EFI_ERROR (Status)) {
@@ -472,7 +489,7 @@ InitializeSdMmcDevice (
Speed = SD_HIGH_SPEED;
/* SD Switch, Mode:1, Group:0, Value:1 */
- CmdArg = CreateSwitchCmdArgument(1, 0, 1);
+ CmdArg = CreateSwitchCmdArgument (1, 0, 1);
Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a (MMC_CMD6): Error and Status = %r\n", __FUNCTION__, Status));
@@ -485,12 +502,13 @@ InitializeSdMmcDevice (
}
if ((Buffer[4] & SWITCH_CMD_SUCCESS_MASK) != 0x01000000) {
- DEBUG((DEBUG_ERROR, "Problem switching SD card into high-speed mode\n"));
+ DEBUG ((DEBUG_ERROR, "Problem switching SD card into high-speed mode\n"));
return Status;
}
}
}
}
+
if (Scr.SD_BUS_WIDTHS & SD_BUS_WIDTH_4BIT) {
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Status = MmcHost->SendCommand (MmcHost, MMC_CMD55, CmdArg);
@@ -498,6 +516,7 @@ InitializeSdMmcDevice (
DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status = %r\n", __FUNCTION__, Status));
return Status;
}
+
/* Width: 4 */
Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, 2);
if (EFI_ERROR (Status)) {
@@ -505,13 +524,15 @@ InitializeSdMmcDevice (
return Status;
}
}
- if (MMC_HOST_HAS_SETIOS(MmcHost)) {
+
+ if (MMC_HOST_HAS_SETIOS (MmcHost)) {
Status = MmcHost->SetIos (MmcHost, Speed, BUSWIDTH_4, EMMCBACKWARD);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a (SetIos): Error and Status = %r\n", __FUNCTION__, Status));
return Status;
}
}
+
return EFI_SUCCESS;
}
@@ -519,20 +540,20 @@ STATIC
EFI_STATUS
EFIAPI
MmcIdentificationMode (
- IN MMC_HOST_INSTANCE *MmcHostInstance
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
- EFI_STATUS Status;
- UINT32 Response[4];
- UINTN Timeout;
- UINTN CmdArg;
- BOOLEAN IsHCS;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- OCR_RESPONSE OcrResponse;
+ EFI_STATUS Status;
+ UINT32 Response[4];
+ UINTN Timeout;
+ UINTN CmdArg;
+ BOOLEAN IsHCS;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
+ OCR_RESPONSE OcrResponse;
MmcHost = MmcHostInstance->MmcHost;
- CmdArg = 0;
- IsHCS = FALSE;
+ CmdArg = 0;
+ IsHCS = FALSE;
if (MmcHost == NULL) {
return EFI_INVALID_PARAMETER;
@@ -553,6 +574,7 @@ MmcIdentificationMode (
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD0): Error, Status=%r.\n", Status));
return Status;
}
+
Status = MmcNotifyState (MmcHostInstance, MmcIdleState);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Error MmcIdleState, Status=%r.\n", Status));
@@ -564,30 +586,36 @@ MmcIdentificationMode (
Timeout = MAX_RETRY_COUNT;
do {
Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB);
- if (EFI_ERROR (Status))
+ if (EFI_ERROR (Status)) {
break;
+ }
+
Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, (UINT32 *)&OcrResponse);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
return Status;
}
+
Timeout--;
} while (!OcrResponse.Ocr.PowerUp && (Timeout > 0));
+
if (Status == EFI_SUCCESS) {
if (!OcrResponse.Ocr.PowerUp) {
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD1): Card initialisation failure, Status=%r.\n", Status));
return EFI_DEVICE_ERROR;
}
+
OcrResponse.Ocr.PowerUp = 0;
if (OcrResponse.Raw == EMMC_CMD1_CAPACITY_GREATER_THAN_2GB) {
MmcHostInstance->CardInfo.OCRData.AccessMode = BIT1;
- }
- else {
+ } else {
MmcHostInstance->CardInfo.OCRData.AccessMode = 0x0;
}
+
// Check whether MMC or eMMC
- if (OcrResponse.Raw == EMMC_CMD1_CAPACITY_GREATER_THAN_2GB ||
- OcrResponse.Raw == EMMC_CMD1_CAPACITY_LESS_THAN_2GB) {
+ if ((OcrResponse.Raw == EMMC_CMD1_CAPACITY_GREATER_THAN_2GB) ||
+ (OcrResponse.Raw == EMMC_CMD1_CAPACITY_LESS_THAN_2GB))
+ {
return EmmcIdentificationMode (MmcHostInstance, OcrResponse);
}
}
@@ -604,12 +632,13 @@ MmcIdentificationMode (
Status = MmcHost->SendCommand (MmcHost, MMC_CMD8, CmdArg);
if (Status == EFI_SUCCESS) {
DEBUG ((DEBUG_ERROR, "Card is SD2.0 => Supports high capacity\n"));
- IsHCS = TRUE;
+ IsHCS = TRUE;
Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R7, Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive response to CMD8, Status=%r.\n", Status));
return Status;
}
+
PrintResponseR1 (Response[0]);
// Check if it is valid response
if (Response[0] != CmdArg) {
@@ -634,10 +663,11 @@ MmcIdentificationMode (
}
// Note: The first time CmdArg will be zero
- CmdArg = ((UINTN *) &(MmcHostInstance->CardInfo.OCRData))[0];
+ CmdArg = ((UINTN *)&(MmcHostInstance->CardInfo.OCRData))[0];
if (IsHCS) {
CmdArg |= BIT30;
}
+
Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
if (!EFI_ERROR (Status)) {
Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
@@ -645,7 +675,8 @@ MmcIdentificationMode (
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
return Status;
}
- ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
+
+ ((UINT32 *)&(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
}
} else {
DEBUG ((DEBUG_INFO, "Card should be MMC\n"));
@@ -658,7 +689,8 @@ MmcIdentificationMode (
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
return Status;
}
- ((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
+
+ ((UINT32 *)&(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
}
}
@@ -671,6 +703,7 @@ MmcIdentificationMode (
MmcHostInstance->CardInfo.CardType = SD_CARD_2_HIGH;
DEBUG ((DEBUG_ERROR, "High capacity card.\n"));
}
+
break; // The MMC/SD card is ready. Continue the Identification Mode
}
} else {
@@ -697,6 +730,7 @@ MmcIdentificationMode (
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
return Status;
}
+
Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CID, Response);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive CID, Status=%r.\n", Status));
@@ -728,6 +762,7 @@ MmcIdentificationMode (
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive RCA, Status=%r.\n", Status));
return Status;
}
+
PrintRCA (Response[0]);
// For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
@@ -736,6 +771,7 @@ MmcIdentificationMode (
} else {
MmcHostInstance->CardInfo.RCA = CmdArg;
}
+
Status = MmcNotifyState (MmcHostInstance, MmcStandByState);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Error MmcStandByState\n"));
@@ -747,25 +783,25 @@ MmcIdentificationMode (
EFI_STATUS
InitializeMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHostInstance
+ IN MMC_HOST_INSTANCE *MmcHostInstance
)
{
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- UINTN BlockCount;
+ EFI_STATUS Status;
+ EFI_MMC_HOST_PROTOCOL *MmcHost;
+ UINTN BlockCount;
BlockCount = 1;
- MmcHost = MmcHostInstance->MmcHost;
+ MmcHost = MmcHostInstance->MmcHost;
Status = MmcIdentificationMode (MmcHostInstance);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "InitializeMmcDevice(): Error in Identification Mode, Status=%r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeMmcDevice(): Error in Identification Mode, Status=%r\n", Status));
return Status;
}
Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "InitializeMmcDevice(): Error MmcTransferState, Status=%r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeMmcDevice(): Error MmcTransferState, Status=%r\n", Status));
return Status;
}
@@ -774,6 +810,7 @@ InitializeMmcDevice (
} else {
Status = InitializeEmmcDevice (MmcHostInstance);
}
+
if (EFI_ERROR (Status)) {
return Status;
}
@@ -781,8 +818,12 @@ InitializeMmcDevice (
// Set Block Length
Status = MmcHost->SendCommand (MmcHost, MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "InitializeMmcDevice(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",
- MmcHostInstance->BlockIo.Media->BlockSize, Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "InitializeMmcDevice(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",
+ MmcHostInstance->BlockIo.Media->BlockSize,
+ Status
+ ));
return Status;
}
@@ -790,7 +831,7 @@ InitializeMmcDevice (
if (MmcHostInstance->CardInfo.CardType == MMC_CARD) {
Status = MmcHost->SendCommand (MmcHost, MMC_CMD23, BlockCount);
if (EFI_ERROR (Status)) {
- DEBUG((DEBUG_ERROR, "InitializeMmcDevice(MMC_CMD23): Error, Status=%r\n", Status));
+ DEBUG ((DEBUG_ERROR, "InitializeMmcDevice(MMC_CMD23): Error, Status=%r\n", Status));
return Status;
}
}