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>
This commit is contained in:
Michael Kubacki
2021-12-05 14:53:56 -08:00
committed by mergify[bot]
parent 731c67e1d7
commit e7108d0e96
106 changed files with 9242 additions and 7648 deletions

View File

@ -28,12 +28,15 @@ ValidateAndroidMediaDevicePath (
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;
}
@ -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
@ -88,10 +97,11 @@ AndroidBootAppEntryPoint (
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));

View File

@ -28,12 +28,16 @@ ParseAndroidBootImg (
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;
}
@ -48,13 +52,17 @@ ParseAndroidBootImg (
*RamdiskSize = Header->RamdiskSize;
if (Header->RamdiskSize != 0) {
*Ramdisk = (VOID *) (BootImgBytePtr
*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;
}

View File

@ -74,7 +74,7 @@ HandleGetVar (
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
@ -122,8 +122,12 @@ 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;
@ -214,6 +218,7 @@ HandleBoot (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed to boot downloaded image: %r\n", Status));
}
// We shouldn't get here
}
@ -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);
@ -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,
@ -374,12 +380,13 @@ DataReady (
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));
@ -427,14 +434,14 @@ FastbootAppEntryPoint (
Status = gBS->LocateProtocol (
&gAndroidFastbootTransportProtocolGuid,
NULL,
(VOID **) &mTransport
(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;
@ -491,7 +500,6 @@ FastbootAppEntryPoint (
);
ASSERT_EFI_ERROR (Status);
// Start listening for data
Status = mTransport->Start (
ReceiveEvent
@ -502,8 +510,10 @@ FastbootAppEntryPoint (
}
// 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;

View File

@ -44,7 +44,6 @@ STATIC CONST MEMORY_DEVICE_PATH MemoryDevicePathTemplate =
} // End
};
/**
Start an EFI Application from a Device Path
@ -62,16 +61,22 @@ StartEfiApplication (
IN EFI_HANDLE ParentImageHandle,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINTN LoadOptionsSize,
IN VOID* LoadOptions
IN VOID *LoadOptions
)
{
EFI_STATUS Status;
EFI_HANDLE ImageHandle;
EFI_LOADED_IMAGE_PROTOCOL* LoadedImage;
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,13 +87,17 @@ 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;
}
@ -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;

View File

@ -208,7 +208,7 @@ 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.
@ -224,7 +224,6 @@ DataReceived (
ASSERT_EFI_ERROR (Status);
}
/*
Event notify function to be called when we accept an incoming TCP connection.
*/
@ -240,13 +239,14 @@ ConnectionAccepted (
EFI_STATUS Status;
UINTN Index;
AcceptToken = (EFI_TCP4_LISTEN_TOKEN *) Context;
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
@ -282,7 +282,7 @@ ConnectionAccepted (
}
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
SubmitRecieveToken();
SubmitRecieveToken ();
}
}
@ -308,10 +308,16 @@ TcpFastbootTransportStart (
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"
},
@ -345,7 +351,7 @@ TcpFastbootTransportStart (
Status = gBS->OpenProtocol (
NetDeviceHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
(VOID **) &mTcpServiceBinding,
(VOID **)&mTcpServiceBinding,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -364,7 +370,7 @@ TcpFastbootTransportStart (
Status = gBS->OpenProtocol (
mTcpHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &mTcpListener,
(VOID **)&mTcpListener,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@ -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");
//
@ -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;
@ -540,7 +550,7 @@ DataSent (
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);
@ -591,7 +601,6 @@ TcpFastbootTransportSend (
return EFI_SUCCESS;
}
EFI_STATUS
TcpFastbootTransportReceive (
OUT UINTN *BufferSize,
@ -604,7 +613,7 @@ TcpFastbootTransportReceive (
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.
@ -635,11 +644,10 @@ TcpFastbootTransportEntryPoint (
{
EFI_STATUS Status;
Status = gBS->LocateProtocol(
Status = gBS->LocateProtocol (
&gEfiSimpleTextOutProtocolGuid,
NULL,
(VOID **) &mTextOut
(VOID **)&mTextOut
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Open Text Output Protocol: %r\n", Status));

View File

@ -40,26 +40,25 @@ typedef struct _FASTBOOT_USB_PACKET_LIST {
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
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
};
/*
@ -80,44 +79,44 @@ typedef struct {
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;
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;
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;
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;
sizeof (USB_ENDPOINT_DESCRIPTOR), // Length;
USB_DESC_TYPE_ENDPOINT, // DescriptorType;
1, // EndpointAddress;
0x2, // Attributes;
MAX_PACKET_SIZE_BULK, // MaxPacketSize;
16 // Interval;
}
};
@ -170,7 +169,7 @@ FastbootTransportUsbStart (
InitializeListHead (&mPacketList);
return mUsbDevice->Start (&mDeviceDescriptor, (VOID **) &Responses, DataReceived, DataSent);
return mUsbDevice->Start (&mDeviceDescriptor, (VOID **)&Responses, DataReceived, DataSent);
}
/*
@ -201,7 +200,7 @@ FastbootTransportUsbSend (
)
{
// Current USB protocol is blocking, so ignore FatalErrorEvent
return mUsbDevice->Send(1, BufferSize, Buffer);
return mUsbDevice->Send (1, BufferSize, Buffer);
}
/*
@ -230,7 +229,7 @@ FastbootTransportUsbReceive (
return EFI_NOT_READY;
}
Entry = (FASTBOOT_USB_PACKET_LIST *) GetFirstNode (&mPacketList);
Entry = (FASTBOOT_USB_PACKET_LIST *)GetFirstNode (&mPacketList);
*BufferSize = Entry->BufferSize;
*Buffer = Entry->Buffer;
@ -257,7 +256,7 @@ FastbootTransportUsbEntryPoint (
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;
}

View File

@ -40,8 +40,8 @@ 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,8 +50,8 @@ 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)
}
}
};
@ -69,27 +69,34 @@ InstallHiiPages (
EFI_HANDLE DriverHandle;
DriverHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverHandle,
&gEfiDevicePathProtocolGuid,
&mConsolePrefDxeVendorDevicePath,
NULL);
NULL
);
if (EFI_ERROR (Status)) {
return Status;
}
HiiHandle = HiiAddPackages (&gConsolePrefFormSetGuid,
HiiHandle = HiiAddPackages (
&gConsolePrefFormSetGuid,
DriverHandle,
ConsolePrefDxeStrings,
ConsolePrefHiiBin,
NULL);
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)
));
}
}
@ -137,8 +152,11 @@ RemoveSpcrTable (
EFI_ACPI_TABLE_VERSION TableVersion;
UINTN TableKey;
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
(VOID **)&AcpiTable);
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);
}
@ -186,18 +213,29 @@ OnReadyToBoot (
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;
}
@ -244,20 +285,32 @@ ConsolePrefDxeEntryPoint (
// 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
}
@ -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 ();

View File

@ -32,8 +32,8 @@ 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)
}
}
};
@ -59,27 +59,34 @@ InstallHiiPages (
EFI_HANDLE DriverHandle;
DriverHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverHandle,
&gEfiDevicePathProtocolGuid,
&mDtPlatformDxeVendorDevicePath,
NULL);
NULL
);
if (EFI_ERROR (Status)) {
return Status;
}
HiiHandle = HiiAddPackages (&gDtPlatformFormSetGuid,
HiiHandle = HiiAddPackages (
&gDtPlatformFormSetGuid,
DriverHandle,
DtPlatformDxeStrings,
DtPlatformHiiBin,
NULL);
NULL
);
if (HiiHandle == NULL) {
gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
gBS->UninstallMultipleProtocolInterfaces (
DriverHandle,
&gEfiDevicePathProtocolGuid,
&mDtPlatformDxeVendorDevicePath,
NULL);
NULL
);
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
@ -112,31 +119,48 @@ DtPlatformDxeEntryPoint (
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 {

View File

@ -46,6 +46,7 @@ GetNodeProperty (
if (PropSize != NULL) {
*PropSize = Len;
}
return EFI_SUCCESS;
}
@ -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;
}
@ -116,7 +120,7 @@ FindNextCompatibleNode (
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;
}
@ -201,16 +207,25 @@ 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;
}
@ -241,7 +256,7 @@ FindNextMemoryNodeReg (
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,15 +276,21 @@ 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;
}
@ -279,6 +300,7 @@ FindNextMemoryNodeReg (
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
@ -294,8 +316,15 @@ FindMemoryNodeReg (
OUT UINT32 *RegSize
)
{
return FindNextMemoryNodeReg (This, 0, Node, Reg, AddressCells, SizeCells,
RegSize);
return FindNextMemoryNodeReg (
This,
0,
Node,
Reg,
AddressCells,
SizeCells,
RegSize
);
}
STATIC
@ -385,14 +414,19 @@ InitializeFdtClientDxe (
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;
}

View File

@ -138,8 +138,13 @@ NonCoherentIoMmuMap (
return EFI_INVALID_PARAMETER;
}
return DmaMap (DmaOperation, HostAddress, NumberOfBytes,
DeviceAddress, Mapping);
return DmaMap (
DmaOperation,
HostAddress,
NumberOfBytes,
DeviceAddress,
Mapping
);
}
/**
@ -236,7 +241,6 @@ STATIC EDKII_IOMMU_PROTOCOL mNonCoherentIoMmuOps = {
NonCoherentIoMmuFreeBuffer,
};
EFI_STATUS
EFIAPI
NonCoherentIoMmuDxeEntryPoint (
@ -244,7 +248,10 @@ NonCoherentIoMmuDxeEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
&gEdkiiIoMmuProtocolGuid, &mNonCoherentIoMmuOps,
NULL);
return gBS->InstallMultipleProtocolInterfaces (
&ImageHandle,
&gEdkiiIoMmuProtocolGuid,
&mNonCoherentIoMmuOps,
NULL
);
}

View File

@ -22,12 +22,11 @@ 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,
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)VirtualKeyboardComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)VirtualKeyboardComponentNameGetControllerName,
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVirtualKeyboardDriverNameTable[] = {
{
"eng;en",

View File

@ -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.
@ -143,5 +142,4 @@ VirtualKeyboardComponentNameGetControllerName (
OUT CHAR16 **ControllerName
);
#endif

View File

@ -51,7 +51,7 @@ VirtualKeyboardDriverBindingSupported (
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,
@ -95,7 +96,7 @@ VirtualKeyboardDriverBindingStart (
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;
@ -162,6 +163,7 @@ VirtualKeyboardDriverBindingStart (
(VirtualKeyboardPrivate->SimpleTextIn).WaitForKey = NULL;
goto Done;
}
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
@ -222,6 +224,7 @@ VirtualKeyboardDriverBindingStart (
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.
@ -412,6 +415,7 @@ VirtualKeyboardFreeNotifyList (
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;
}
/**
@ -528,12 +535,12 @@ VirtualKeyboardWaitForKeyEx (
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.
@ -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;
@ -616,7 +624,6 @@ VirtualKeyboardResetEx (
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
/**
@ -643,6 +650,7 @@ KeyboardReadKeyStrokeWorker (
{
EFI_STATUS Status;
EFI_TPL OldTpl;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
}
@ -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);
}
}
@ -760,7 +770,6 @@ VirtualKeyboardReadKeyStrokeEx (
VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
return KeyboardReadKeyStrokeWorker (VirtualKeyboardPrivate, KeyData);
}
/**
@ -829,9 +838,10 @@ VirtualKeyboardRegisterKeyNotify (
LIST_ENTRY *Link;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
if (KeyData == NULL ||
NotifyHandle == NULL ||
KeyNotificationFunction == NULL) {
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,
@ -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;
@ -888,7 +899,6 @@ Exit:
//
gBS->RestoreTPL (OldTpl);
return Status;
}
/**
@ -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,
@ -1001,11 +1013,14 @@ 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;
@ -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,
@ -1072,7 +1088,7 @@ KeyNotifyProcessHandler (
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,7 +1138,7 @@ KeyNotifyProcessHandler (
**/
EFI_STATUS
EFIAPI
InitializeVirtualKeyboard(
InitializeVirtualKeyboard (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)

View File

@ -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>
@ -35,7 +34,6 @@ extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2;
//
// VIRTUAL Keyboard Defines
//
@ -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.
@ -301,10 +298,10 @@ VirtualKeyboardComponentNameGetControllerName (
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.

View File

@ -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;

View File

@ -17,34 +17,34 @@
//
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 }
// { 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),
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,
@ -70,12 +70,12 @@ UINTN gRegisterOffsets[] = {
0x00000F72,
0x00000F73,
0x00000FFF, // fps
OFFSET_OF(EFI_SYSTEM_CONTEXT_ARM, CPSR)
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
@ -140,12 +137,12 @@ FindPointerToRegister (
)
{
UINT8 *TempPtr;
ASSERT(gRegisterOffsets[RegNumber] < 0xF00);
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
@ -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
@ -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
@ -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,7 +252,8 @@ ReadGeneralRegisters (
@retval the pointer to the next character of the input buffer that can be used
**/
CHAR8
*BasicWriteRegister (
*
BasicWriteRegister (
IN EFI_SYSTEM_CONTEXT SystemContext,
IN UINTN RegNumber,
IN CHAR8 *InBufPtr
@ -290,11 +288,11 @@ CHAR8
NewValue += (TempValue << RegSize);
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
@ -317,6 +315,7 @@ WriteNthRegister (
while (*InBufPtr != '=') {
*RegNumBufPtr++ = *InBufPtr++;
}
*RegNumBufPtr = '\0';
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
@ -325,18 +324,17 @@ WriteNthRegister (
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;
}
@ -403,6 +401,7 @@ AddSingleStep (
// Currently don't support nesting
return;
}
mSingleStepActive = TRUE;
mSingleStepPC = SystemContext.SystemContextArm->PC;
@ -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.
@ -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.
@ -517,7 +513,7 @@ SearchBreakpointList (
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;
@ -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,7 +552,7 @@ 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
@ -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);
}
@ -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;
}
@ -629,7 +625,7 @@ RemoveBreakPoint (
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:

View File

@ -14,7 +14,6 @@
#include <GdbStubInternal.h>
#include <Protocol/DebugPort.h>
UINTN gMaxProcessorIndex = 0;
//
@ -38,8 +37,7 @@ 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'};
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
@ -50,7 +48,6 @@ GdbSymbolEventHandler (
{
}
/**
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) {
@ -135,6 +133,7 @@ GdbStubEntry (
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,7 +164,6 @@ GdbStubEntry (
);
ASSERT_EFI_ERROR (Status);
if (PcdGetBool (PcdGdbSerial)) {
GdbInitializeSerialConsole ();
}
@ -180,7 +178,6 @@ 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,
@ -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,7 +211,6 @@ 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,
@ -226,36 +222,35 @@ TransferFromMemToOutBufAndSend (
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
@ -286,7 +281,6 @@ SendPacket (
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;
}
@ -343,19 +337,20 @@ ReceivePacket (
ZeroMem (PacketData, PacketDataSize);
for (;;) {
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;
}
@ -363,6 +358,7 @@ ReceivePacket (
PacketData[Index] = Char;
CheckSum = CheckSum + Char;
}
PacketData[Index] = '\0';
if (Index == PacketDataSize) {
@ -386,10 +382,9 @@ ReceivePacket (
}
}
//return 0;
// return 0;
}
/**
Empties the given buffer
@param Buf pointer to the first element in buffer to be emptied
@ -402,7 +397,6 @@ EmptyBuffer (
*Buf = '\0';
}
/**
Converts an 8-bit Hex Char into a INTN.
@ -421,12 +415,13 @@ 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
// 'E' + the biggest error number is 255, so its 2 hex digits + buffer end
CHAR8 *gError = "E__";
/** 'E NN'
@ -445,14 +440,12 @@ SendError (
//
// 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
@ -501,14 +492,14 @@ GdbSendTSignal (
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;
*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
@ -586,21 +574,20 @@ ConvertEFItoGDBtype (
{
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 (
@ -618,20 +605,21 @@ ReadFromMemory (
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;
}
@ -642,7 +630,6 @@ ReadFromMemory (
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
@ -670,6 +657,7 @@ WriteToMemory (
while (*InBufPtr != ',') {
*AddrBufPtr++ = *InBufPtr++;
}
*AddrBufPtr = '\0';
InBufPtr++; // this skips ',' in the buffer
@ -677,6 +665,7 @@ WriteToMemory (
while (*InBufPtr != ':') {
*LengthBufPtr++ = *InBufPtr++;
}
*LengthBufPtr = '\0';
InBufPtr++; // this skips ':' in the buffer
@ -686,14 +675,14 @@ WriteToMemory (
/* 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);
}
@ -742,41 +732,43 @@ ParseBreakpointPacket (
*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
@ -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
@ -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.
@ -884,19 +876,18 @@ PeCoffLoaderGetDebuggerInfo (
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 +
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
@ -930,7 +921,7 @@ PeCoffLoaderGetDebuggerInfo (
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);
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
@ -938,7 +929,7 @@ PeCoffLoaderGetDebuggerInfo (
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);
DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN)Pe32Data + DirectoryEntry->VirtualAddress);
}
if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
@ -949,22 +940,22 @@ PeCoffLoaderGetDebuggerInfo (
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) {
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));
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));
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));
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.
@ -1042,10 +1032,11 @@ QxferLibrary (
}
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
@ -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.
@ -1104,7 +1093,6 @@ GdbExceptionHandler (
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.

View File

@ -49,7 +49,6 @@ extern CONST CHAR8 mHexToStr[];
// the mask used to clear all the cache
#define TF_BIT 0x00000100
//
// GDB Signal definitions - generic names for interrupts
//
@ -59,7 +58,6 @@ extern CONST CHAR8 mHexToStr[];
#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
@ -76,7 +74,6 @@ extern CONST CHAR8 mHexToStr[];
#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
@ -122,16 +119,13 @@ typedef struct {
INTN OutFileDescriptor;
} GDB_SERIAL_DEV;
#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_ENTRY;
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
//
@ -141,15 +135,15 @@ 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;
} IA32_DR6;
@ -161,27 +155,27 @@ 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;
} IA32_DR7;
@ -189,11 +183,11 @@ typedef union {
#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;
@ -215,7 +209,6 @@ extern BOOLEAN gCtrlCBreakFlag;
//
extern BOOLEAN gProcessingFPacket;
// The offsets of registers SystemContext.
// The fields in the array are in the gdb ordering.
//
@ -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
@ -255,7 +246,6 @@ CheckIsa (
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
@ -281,7 +270,6 @@ ConvertEFItoGDBtype (
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.
@ -304,7 +291,6 @@ HexCharToInt (
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.
@ -318,7 +304,6 @@ SendError (
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
@ -415,7 +394,6 @@ WriteToMemory (
IN CHAR8 *PacketData
);
/** c [addr ]
Continue. addr is Address to resume. If addr is omitted, resume at current
Address.
@ -431,7 +409,6 @@ ContinueAtAddress (
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
@ -569,7 +540,6 @@ SendPacket (
IN CHAR8 *PacketData
);
/**
Receive a GDB Remote Serial Protocol Packet
@ -592,7 +562,6 @@ ReceivePacket (
IN UINTN PacketDataSize
);
/**
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.
@ -612,7 +581,6 @@ GdbRead (
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.

View File

@ -30,32 +30,30 @@ EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {
{ EXCEPT_IA32_MACHINE_CHECK, GDB_SIGEMT }
};
// The offsets of registers SystemContext.
// The fields in the array are in the gdb ordering.
//
//16 regs
// 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)
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
@ -73,7 +71,7 @@ PrintReg (
Print ((CHAR16 *)L"EFlags: %x\n", SystemContext.SystemContextIa32->Eflags);
}
//Debug only..
// Debug only..
VOID
PrintDRreg (
IN EFI_SYSTEM_CONTEXT SystemContext
@ -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
@ -147,11 +141,11 @@ FindPointerToRegister (
)
{
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
@ -175,10 +169,10 @@ BasicReadRegister (
*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
@ -198,7 +192,7 @@ ReadNthRegister (
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
@ -227,15 +220,15 @@ ReadGeneralRegisters (
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
@ -258,7 +251,7 @@ BasicWriteRegister (
NewValue = 0;
RegSize = 0;
while (RegSize < REG_SIZE) {
TempValue = HexCharToInt(*InBufPtr++);
TempValue = HexCharToInt (*InBufPtr++);
if (TempValue < 0) {
SendError (GDB_EBADMEMDATA);
@ -266,7 +259,7 @@ BasicWriteRegister (
}
NewValue += (TempValue << (RegSize+4));
TempValue = HexCharToInt(*InBufPtr++);
TempValue = HexCharToInt (*InBufPtr++);
if (TempValue < 0) {
SendError (GDB_EBADMEMDATA);
@ -276,11 +269,11 @@ BasicWriteRegister (
NewValue += (TempValue << RegSize);
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
@ -305,20 +298,21 @@ WriteNthRegister (
while (*InBufPtr != '=') {
*RegNumBufPtr++ = *InBufPtr++;
}
*RegNumBufPtr = '\0';
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
@ -337,8 +331,9 @@ WriteGeneralRegisters (
// 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.
@ -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.
@ -423,7 +414,6 @@ SingleStep (
AddSingleStep (SystemContext);
}
/**
Returns breakpoint data address from DR0-DR3 based on the input breakpoint number
@ -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.
@ -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
@ -511,24 +499,23 @@ GetBreakpointType (
)
{
IA32_DR7 Dr7;
BREAK_TYPE Type = NotSupported; //Default is NotSupported type
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.
@ -544,18 +531,21 @@ ConvertLengthData (
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.
@ -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,23 +605,24 @@ 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) {
@ -659,13 +649,12 @@ EnableDebugRegister (
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
@ -693,37 +682,42 @@ FindMatchingDebugRegister (
{
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.
@ -752,7 +745,7 @@ DisableDebugRegister (
IA32_DR7 Dr7;
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) {
@ -779,13 +772,12 @@ DisableDebugRegister (
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]
@ -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]
@ -900,7 +889,7 @@ RemoveBreakPoint (
EFI_STATUS Status;
UINTN ErrorCode;
//Parse breakpoint packet data
// 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
@ -984,4 +970,3 @@ ValidateException (
{
return TRUE;
}

View File

@ -35,7 +35,6 @@ BOOLEAN gProcessingFPacket = FALSE;
@param ErrNo Error information from the F reply packet or other source
**/
VOID
GdbCtrlCBreakMessage (
IN UINTN ErrNo
@ -45,11 +44,10 @@ GdbCtrlCBreakMessage (
// 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.
@ -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.
@ -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.
@ -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.
@ -416,7 +411,6 @@ GdbSerialWrite (
@retval EFI_TIMEOUT The data write was stopped due to a timeout.
**/
EFI_STATUS
EFIAPI
GdbSerialRead (
@ -442,7 +436,6 @@ GdbSerialRead (
return EFI_SUCCESS;
}
//
// Template used to initialize the GDB Serial IO protocols
//
@ -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.
@ -529,8 +521,10 @@ GdbInitializeSerialConsole (
// 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);
}

View File

@ -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)
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;
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
@ -142,14 +137,14 @@ BasicReadRegister (
RegSize = 0;
while (RegSize < 64) {
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
*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
@ -167,19 +162,18 @@ ReadNthRegister (
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
@ -196,15 +190,15 @@ ReadGeneralRegisters (
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
@ -227,7 +221,7 @@ BasicWriteRegister (
NewValue = 0;
RegSize = 0;
while (RegSize < 64) {
TempValue = HexCharToInt(*InBufPtr++);
TempValue = HexCharToInt (*InBufPtr++);
if (TempValue < 0) {
SendError (GDB_EBADMEMDATA);
@ -235,7 +229,7 @@ BasicWriteRegister (
}
NewValue += (TempValue << (RegSize+4));
TempValue = HexCharToInt(*InBufPtr++);
TempValue = HexCharToInt (*InBufPtr++);
if (TempValue < 0) {
SendError (GDB_EBADMEMDATA);
@ -245,11 +239,11 @@ BasicWriteRegister (
NewValue += (TempValue << RegSize);
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
@ -274,20 +268,21 @@ WriteNthRegister (
while (*InBufPtr != '=') {
*RegNumBufPtr++ = *InBufPtr++;
}
*RegNumBufPtr = '\0';
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
@ -306,8 +301,9 @@ WriteGeneralRegisters (
// 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.
@ -368,11 +360,10 @@ ContinueAtAddress (
)
{
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.
@ -393,7 +384,6 @@ SingleStep (
AddSingleStep (SystemContext);
}
/**
Returns breakpoint data address from DR0-DR3 based on the input breakpoint
number
@ -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;
@ -482,24 +472,23 @@ GetBreakpointType (
)
{
IA32_DR7 Dr7;
BREAK_TYPE Type = NotSupported; //Default is NotSupported type
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.
@ -515,18 +504,21 @@ ConvertLengthData (
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.
@ -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,23 +578,24 @@ 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) {
@ -630,13 +622,12 @@ EnableDebugRegister (
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
@ -664,37 +655,42 @@ FindMatchingDebugRegister (
{
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.
@ -723,7 +718,7 @@ DisableDebugRegister (
IA32_DR7 Dr7;
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) {
@ -750,7 +745,7 @@ DisableDebugRegister (
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;
@ -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]
@ -870,7 +862,7 @@ RemoveBreakPoint (
EFI_STATUS Status;
UINTN ErrorCode;
//Parse breakpoint packet data
// 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
@ -954,4 +943,3 @@ ValidateException (
{
return TRUE;
}

View File

@ -11,7 +11,6 @@
#include <Library/ExtractGuidedSectionLib.h>
//
// The GUID for this protocol mathes the Decompression scheme being used
// So for example LZMA would be gLzmaCustomDecompressGuid
@ -27,4 +26,3 @@ typedef struct {
} EXTRACT_SECTION_HOB;
#endif

View File

@ -10,7 +10,7 @@
#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 } \
}

View File

@ -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__

View File

@ -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__

View File

@ -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__

View File

@ -45,6 +45,7 @@ typedef struct {
/* 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))
/* 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) \

View File

@ -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

View File

@ -51,9 +51,6 @@ typedef enum {
MapOperationMaximum
} DMA_MAP_OPERATION;
/**
Provides the DMA controller-specific addresses needed to access system memory.
@ -84,9 +81,6 @@ DmaMap (
OUT VOID **Mapping
);
/**
Completes the DmaMapBusMasterRead, DmaMapBusMasterWrite, or DmaMapBusMasterCommonBuffer
operation and releases any corresponding resources.
@ -103,7 +97,6 @@ DmaUnmap (
IN VOID *Mapping
);
/**
Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer.
mapping.
@ -129,7 +122,6 @@ DmaAllocateBuffer (
OUT VOID **HostAddress
);
/**
Frees memory that was allocated with DmaAllocateBuffer().
@ -148,7 +140,6 @@ DmaFreeBuffer (
IN VOID *HostAddress
);
/**
Allocates pages that are suitable for an DmaMap() of type
MapOperationBusMasterCommonBuffer mapping, at the requested alignment.
@ -177,5 +168,4 @@ DmaAllocateAlignedBuffer (
OUT VOID **HostAddress
);
#endif

View File

@ -55,7 +55,6 @@ typedef enum {
EfiOpenMaxValue
} EFI_OPEN_FILE_TYPE;
/// Public information about the open file
typedef struct {
UINTN Version; // Common information
@ -97,10 +96,8 @@ typedef struct {
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
@ -158,7 +154,6 @@ EfiDeviceOpenByType (
IN UINTN Index
);
/**
Close a file handle opened by EfiOpen() and free all resources allocated by
EfiOpen().
@ -174,7 +169,6 @@ EfiClose (
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.
@ -191,7 +185,6 @@ EfiTell (
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
@ -220,7 +213,6 @@ EfiSeek (
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.
@ -244,7 +236,6 @@ EfiRead (
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.
@ -271,7 +262,6 @@ EfiReadAllocatePool (
OUT UINTN *BufferSize
);
/**
Write data back to the file.
@ -294,7 +284,6 @@ EfiWrite (
OUT UINTN *BufferSize
);
/**
Return the number of devices of the current type active in the system
@ -308,7 +297,6 @@ EfiGetDeviceCounts (
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.

View File

@ -6,11 +6,9 @@
**/
#ifndef __EFI_RESET_SYSTEM_LIB_H___
#define __EFI_RESET_SYSTEM_LIB_H___
/**
Resets the entire platform.
@ -31,8 +29,6 @@ LibResetSystem (
IN CHAR16 *ResetData OPTIONAL
);
/**
Initialize any infrastructure required for LibResetSystem () to function.

View File

@ -21,7 +21,7 @@
**/
EFI_STATUS
InstallFdtFromSemihosting (
IN CONST CHAR16* FileName
IN CONST CHAR16 *FileName
);
/**

View File

@ -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
@ -40,7 +38,6 @@ GdbSerialInit (
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.
@ -82,7 +78,6 @@ GdbPutChar (
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

View File

@ -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,13 +30,15 @@ LibMtcGetNextMonotonicCount (
OUT UINT64 *Count
);
VOID
LibVariableInitialize (
VOID
);
VOID
LibVariableInitialize (VOID);
VOID
LibVariableVirtualAddressChangeEvent (VOID);
LibVariableVirtualAddressChangeEvent (
VOID
);
EFI_STATUS
LibGetVariable (
@ -68,13 +73,15 @@ LibQueryVariableInfo (
OUT UINT64 *MaximumVariableSize
);
VOID
LibResetInitializeReset (
VOID
);
VOID
LibResetInitializeReset (VOID);
VOID
LibResetVirtualAddressChangeEvent (VOID);
LibResetVirtualAddressChangeEvent (
VOID
);
VOID
LibResetSystem (
@ -84,12 +91,15 @@ LibResetSystem (
IN CHAR16 *ResetData OPTIONAL
);
VOID
LibCapsuleInitialize (
VOID
);
VOID
LibCapsuleInitialize (VOID);
VOID
LibCapsuleVirtualAddressChangeEvent (VOID);
LibCapsuleVirtualAddressChangeEvent (
VOID
);
EFI_STATUS
LibUpdateCapsule (
@ -106,13 +116,15 @@ QueryCapsuleCapabilities (
OUT EFI_RESET_TYPE *ResetType
);
VOID
LibRtcInitialize (
VOID
);
VOID
LibRtcInitialize (VOID);
VOID
LibRtcVirtualAddressChangeEvent (VOID);
LibRtcVirtualAddressChangeEvent (
VOID
);
EFI_STATUS
LibGetTime (
@ -138,12 +150,15 @@ LibSetWakeupTime (
OUT EFI_TIME *Time
);
VOID
LibReportStatusCodeInitialize (
VOID
);
VOID
LibReportStatusCodeInitialize (VOID);
VOID
LibReportStatusCodeVirtualAddressChangeEvent (VOID);
LibReportStatusCodeVirtualAddressChangeEvent (
VOID
);
EFI_STATUS
LibReportStatusCode (
@ -154,6 +169,4 @@ LibReportStatusCode (
IN EFI_STATUS_CODE_DATA *Data OPTIONAL
);
#endif

View File

@ -34,10 +34,10 @@ typedef struct {
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 */
#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 */
@ -87,4 +87,5 @@ EFIAPI
NorFlashPrintInfo (
IN NOR_FLASH_INFO *Info
);
#endif

View File

@ -31,7 +31,6 @@ FfsFindNextVolume (
IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
);
/**
This service enables discovery of additional firmware files.
@ -53,7 +52,6 @@ FfsFindNextFile (
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
);
/**
This service enables discovery sections of a given type within a valid FFS file.
@ -74,7 +72,6 @@ FfsFindSectionData (
OUT VOID **SectionData
);
/**
Find a file in the volume by name
@ -101,7 +98,6 @@ FfsFindFileByName (
OUT EFI_PEI_FILE_HANDLE *FileHandle
);
/**
Get information about the file by name.
@ -125,7 +121,6 @@ FfsGetFileInfo (
OUT EFI_FV_FILE_INFO *FileInfo
);
/**
Get Information about the volume by name
@ -149,8 +144,6 @@ FfsGetVolumeInfo (
OUT EFI_FV_INFO *VolumeInfo
);
/**
Get Fv image from the FV type file, then add FV & FV2 Hob.
@ -166,7 +159,6 @@ FfsProcessFvFile (
IN EFI_PEI_FILE_HANDLE FvFileHandle
);
/**
Search through every FV until you find a file of type FileType
@ -186,7 +178,6 @@ FfsAnyFvFindFirstFile (
OUT EFI_PEI_FILE_HANDLE *FileHandle
);
/**
Get Fv image from the FV type file, then add FV & FV2 Hob.
@ -203,7 +194,6 @@ FfsProcessFvFile (
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.
@ -247,7 +236,6 @@ GetHobList (
VOID
);
/**
Updates the pointer to the HOB list.
@ -260,7 +248,7 @@ SetHobList (
IN VOID *HobList
);
EFI_HOB_HANDOFF_INFO_TABLE*
EFI_HOB_HANDOFF_INFO_TABLE *
HobConstructor (
IN VOID *EfiMemoryBegin,
IN UINTN EfiMemoryLength,
@ -284,7 +272,6 @@ CreateHob (
IN UINT16 HobLenght
);
/**
Returns the next instance of a HOB type from the starting HOB.
@ -371,7 +358,6 @@ GetFirstGuidHob (
IN CONST EFI_GUID *Guid
);
/**
Builds a HOB for a loaded PE32 module.
@ -511,7 +497,6 @@ BuildFvHobs (
IN EFI_RESOURCE_ATTRIBUTE_TYPE *ResourceAttribute OPTIONAL
);
/**
Builds a EFI_HOB_TYPE_FV2 HOB.
@ -605,7 +590,6 @@ UpdateStackHob (
IN UINT64 Length
);
/**
Builds a HOB for the BSP store.
@ -648,7 +632,6 @@ BuildMemoryAllocationHob (
IN EFI_MEMORY_TYPE MemoryType
);
VOID
EFIAPI
BuildExtractSectionHob (
@ -663,7 +646,6 @@ BuildPeCoffLoaderHob (
VOID
);
/**
Allocates one or more 4KB pages of type EfiBootServicesData.
@ -701,7 +683,6 @@ AllocatePool (
IN UINTN AllocationSize
);
/**
Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
@ -725,7 +706,6 @@ AllocateAlignedPages (
IN UINTN Alignment
);
EFI_STATUS
EFIAPI
LoadPeCoffImage (

View File

@ -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.
@ -50,7 +48,6 @@ LibSetTime (
IN EFI_TIME *Time
);
/**
Returns the current wakeup alarm clock setting.
@ -71,7 +68,6 @@ LibGetWakeupTime (
OUT EFI_TIME *Time
);
/**
Sets the system wakeup alarm clock time.
@ -92,8 +88,6 @@ LibSetWakeupTime (
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.
@ -111,7 +105,6 @@ LibRtcInitialize (
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
@ -127,6 +120,4 @@ LibRtcVirtualNotifyEvent (
IN VOID *Context
);
#endif

View File

@ -20,8 +20,8 @@
// 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 \

View File

@ -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;

View File

@ -19,14 +19,14 @@ typedef struct _ANDROID_BOOTIMG_PROTOCOL ANDROID_BOOTIMG_PROTOCOL;
//
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
);

View File

@ -60,7 +60,7 @@ EFI_STATUS
*/
typedef
EFI_STATUS
(* FASTBOOT_TRANSPORT_STOP) (
(*FASTBOOT_TRANSPORT_STOP) (
VOID
);

View File

@ -23,7 +23,6 @@
#ifndef __EMBEDDED_DEVICE_PROTOCOL_H__
#define __EMBEDDED_DEVICE_PROTOCOL_H__
//
// Protocol GUID
//
@ -32,8 +31,6 @@
#define EMBEDDED_DEVICE_PROTOCOL_GUID \
{ 0xbf4b9d10, 0x13ec, 0x43dd, { 0x88, 0x80, 0xe9, 0xb, 0x71, 0x8f, 0x27, 0xde } }
typedef struct {
UINT16 VendorId;
UINT16 DeviceId;
@ -48,5 +45,3 @@ typedef struct {
extern EFI_GUID gEmbeddedDeviceGuid;
#endif

View File

@ -24,12 +24,13 @@ typedef struct _EMBEDDED_EXTERNAL_DEVICE EMBEDDED_EXTERNAL_DEVICE;
//
typedef
EFI_STATUS
(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_READ) (
(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) (
(EFIAPI *EMBEDDED_EXTERNAL_DEVICE_WRITE)(
IN EMBEDDED_EXTERNAL_DEVICE *This,
IN UINTN Register,
IN UINTN Length,
IN VOID *Buffer
)
/*++
Routine Description:

View File

@ -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) (
(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) (
(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) (
(EFIAPI *EMBEDDED_GPIO_SET_PULL)(
IN EMBEDDED_GPIO *This,
IN EMBEDDED_GPIO_PIN Gpio,
IN EMBEDDED_GPIO_PULL Direction
);
/*++
Routine Description:
@ -147,8 +148,6 @@ Returns:
--*/
struct _EMBEDDED_GPIO {
EMBEDDED_GPIO_GET Get;
EMBEDDED_GPIO_SET Set;

View File

@ -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,7 +104,7 @@ 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
);

View File

@ -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,12 +134,11 @@ 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;
@ -160,5 +150,3 @@ struct _EFI_HARDWARE_INTERRUPT_PROTOCOL {
extern EFI_GUID gHardwareInterruptProtocolGuid;
#endif

View File

@ -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

View File

@ -96,63 +96,62 @@ typedef enum _MMC_STATE {
///
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;
@ -168,17 +167,15 @@ struct _EFI_MMC_HOST_PROTOCOL {
MMC_SETIOS SetIos;
MMC_ISMULTIBLOCK IsMultiBlock;
};
#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;
#endif

View File

@ -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,11 +202,10 @@ 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;
@ -227,9 +215,6 @@ struct _PE_COFF_LOADER_PROTOCOL {
PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage;
};
extern EFI_GUID gPeCoffLoaderProtocolGuid;
#endif

View File

@ -65,7 +65,7 @@ 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

View File

@ -25,25 +25,25 @@ struct _VIRTUAL_KBD_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
);

View File

@ -1,5 +1,6 @@
#ifndef _FDT_H
#define _FDT_H
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2006 David Gibson, IBM Corporation.

File diff suppressed because it is too large Load Diff

View File

@ -23,68 +23,142 @@ typedef UINT64 uint64_t;
typedef UINTN uintptr_t;
typedef UINTN size_t;
static inline uint16_t fdt16_to_cpu(fdt16_t x)
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)
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)
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) {
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) {
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);
}

View File

@ -31,7 +31,7 @@
**/
EFI_STATUS
LocateAndInstallAcpiFromFvConditional (
IN CONST EFI_GUID* AcpiFile,
IN CONST EFI_GUID *AcpiFile,
IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
)
{
@ -53,7 +53,7 @@ LocateAndInstallAcpiFromFvConditional (
Status = gBS->LocateProtocol (
&gEfiAcpiTableProtocolGuid,
NULL,
(VOID**)&AcpiProtocol
(VOID **)&AcpiProtocol
);
if (EFI_ERROR (Status)) {
return Status;
@ -83,7 +83,7 @@ LocateAndInstallAcpiFromFvConditional (
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareVolume2ProtocolGuid,
(VOID**) &FvInstance
(VOID **)&FvInstance
);
if (EFI_ERROR (Status)) {
goto FREE_HANDLE_BUFFER;
@ -99,20 +99,23 @@ LocateAndInstallAcpiFromFvConditional (
AcpiFile,
EFI_SECTION_RAW,
SectionInstance,
(VOID**) &AcpiTable,
(VOID **)&AcpiTable,
&SectionSize,
&FvStatus
);
if (!EFI_ERROR (Status)) {
AcpiTableKey = 0;
AcpiTableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) AcpiTable)->Length;
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) {
@ -165,7 +168,7 @@ FREE_HANDLE_BUFFER:
**/
EFI_STATUS
LocateAndInstallAcpiFromFv (
IN CONST EFI_GUID* AcpiFile
IN CONST EFI_GUID *AcpiFile
)
{
return LocateAndInstallAcpiFromFvConditional (AcpiFile, NULL);

View File

@ -116,10 +116,11 @@ AndroidBootImgLoadFile2 (
{
// 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;
}
@ -159,10 +161,14 @@ AndroidBootImgGetImgSize (
{
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;
}
@ -186,10 +192,14 @@ AndroidBootImgGetKernelInfo (
{
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;
}
@ -215,8 +225,12 @@ AndroidBootImgGetRamdiskInfo (
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,6 +243,7 @@ AndroidBootImgGetRamdiskInfo (
+ Header->PageSize
+ ALIGN_VALUE (Header->KernelSize, Header->PageSize));
}
return EFI_SUCCESS;
}
@ -243,8 +258,12 @@ AndroidBootImgGetSecondBootLoaderInfo (
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,6 +277,7 @@ AndroidBootImgGetSecondBootLoaderInfo (
+ ALIGN_VALUE (Header->KernelSize, Header->PageSize)
+ ALIGN_VALUE (Header->RamdiskSize, Header->PageSize));
}
return EFI_SUCCESS;
}
@ -269,9 +289,13 @@ AndroidBootImgGetKernelArgs (
{
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;
}
@ -309,13 +333,20 @@ AndroidBootImgUpdateArgs (
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;
}
@ -359,10 +390,12 @@ AndroidBootImgUninstallLoadFile2 (
);
mRamDiskLoadFileHandle = NULL;
}
return Status;
}
BOOLEAN AndroidBootImgAcpiSupported (
BOOLEAN
AndroidBootImgAcpiSupported (
VOID
)
{
@ -391,12 +424,17 @@ 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;
}
@ -409,12 +447,13 @@ AndroidBootImgGetChosenNode (
ChosenNode = fdt_subnode_offset ((CONST VOID *)UpdatedFdtBase, 0, "chosen");
if (ChosenNode < 0) {
ChosenNode = fdt_add_subnode((VOID *)UpdatedFdtBase, 0, "chosen");
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;
}
@ -430,19 +469,32 @@ AndroidBootImgSetProperty64 (
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));
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,6 +503,7 @@ AndroidBootImgSetProperty64 (
DEBUG ((DEBUG_ERROR, "Failed to set fdt Property %a\n", PropertyName));
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
@ -468,16 +521,23 @@ AndroidBootImgUpdateFdt (
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,
Status = AndroidBootImgSetProperty64 (
UpdatedFdtBase,
ChosenNode,
"linux,initrd-start",
(UINTN)RamdiskData);
(UINTN)RamdiskData
);
if (EFI_ERROR (Status)) {
goto Fdt_Exit;
}
Status = AndroidBootImgSetProperty64 (UpdatedFdtBase, ChosenNode,
Status = AndroidBootImgSetProperty64 (
UpdatedFdtBase,
ChosenNode,
"linux,initrd-end",
(UINTN)RamdiskData + RamdiskSize);
(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
@ -552,8 +619,11 @@ AndroidBootImgBoot (
NewKernelArg = NULL;
ImageHandle = NULL;
Status = gBS->LocateProtocol (&gAndroidBootImgProtocolGuid, NULL,
(VOID **) &mAndroidBootImg);
Status = gBS->LocateProtocol (
&gAndroidBootImgProtocolGuid,
NULL,
(VOID **)&mAndroidBootImg
);
if (EFI_ERROR (Status)) {
goto Exit;
}
@ -607,23 +677,32 @@ 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,
Status = gBS->LoadImage (
TRUE,
gImageHandle,
(EFI_DEVICE_PATH *)&KernelDevicePath,
(VOID*)(UINTN)Kernel, KernelSize, &ImageHandle);
(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->LoadOptionsSize = StrLen (NewKernelArg) * sizeof (CHAR16);
@ -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;
}

View File

@ -12,7 +12,6 @@
#include <Library/DmaLib.h>
#include <Library/MemoryAllocationLib.h>
STATIC
PHYSICAL_ADDRESS
HostToDeviceAddress (
@ -52,18 +51,19 @@ DmaMap (
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;
return EFI_SUCCESS;
}
/**
Completes the DmaMapBusMasterRead(), DmaMapBusMasterWrite(), or DmaMapBusMasterCommonBuffer()
operation and releases any corresponding resources.
@ -111,7 +111,6 @@ DmaAllocateBuffer (
return DmaAllocateAlignedBuffer (MemoryType, Pages, 0, HostAddress);
}
/**
Allocates pages that are suitable for an DmaMap() of type
MapOperationBusMasterCommonBuffer mapping, at the requested alignment.
@ -144,8 +143,9 @@ DmaAllocateAlignedBuffer (
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().
@ -192,4 +192,3 @@ DmaFreeBuffer (
FreePages (HostAddress, Pages);
return EFI_SUCCESS;
}

View File

@ -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 (
)
{
}

View File

@ -36,8 +36,13 @@ DtPlatformLoadDtb (
VOID *CopyDtb;
UINTN OrigDtbSize;
Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid,
EFI_SECTION_RAW, 0, &OrigDtb, &OrigDtbSize);
Status = GetSectionFromAnyFv (
&gDtPlatformDefaultDtbFileGuid,
EFI_SECTION_RAW,
0,
&OrigDtb,
&OrigDtbSize
);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}

View File

@ -55,18 +55,25 @@
#include "libfdt_internal.h"
int fdt_check_header(const void *fdt)
int
fdt_check_header (
const void *fdt
)
{
if (fdt_magic(fdt) == FDT_MAGIC) {
if (fdt_magic (fdt) == FDT_MAGIC) {
/* Complete tree */
if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
if (fdt_version (fdt) < FDT_FIRST_SUPPORTED_VERSION) {
return -FDT_ERR_BADVERSION;
if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)
}
if (fdt_last_comp_version (fdt) > FDT_LAST_SUPPORTED_VERSION) {
return -FDT_ERR_BADVERSION;
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
}
} else if (fdt_magic (fdt) == FDT_SW_MAGIC) {
/* Unfinished sequential-write blob */
if (fdt_size_dt_struct(fdt) == 0)
if (fdt_size_dt_struct (fdt) == 0) {
return -FDT_ERR_BADSTATE;
}
} else {
return -FDT_ERR_BADMAGIC;
}
@ -74,24 +81,39 @@ int fdt_check_header(const void *fdt)
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);
unsigned absoffset = offset + fdt_off_dt_struct (fdt);
if ((absoffset < offset)
if ( (absoffset < offset)
|| ((absoffset + len) < absoffset)
|| (absoffset + len) > fdt_totalsize(fdt))
|| ((absoffset + len) > fdt_totalsize (fdt)))
{
return NULL;
}
if (fdt_version(fdt) >= 0x11)
if (((offset + len) < offset)
|| ((offset + len) > fdt_size_dt_struct(fdt)))
if (fdt_version (fdt) >= 0x11) {
if ( ((offset + len) < offset)
|| ((offset + len) > fdt_size_dt_struct (fdt)))
{
return NULL;
}
}
return _fdt_offset_ptr(fdt, offset);
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;
@ -99,10 +121,12 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
const char *p;
*nextoffset = -FDT_ERR_TRUNCATED;
tagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE);
if (!tagp)
tagp = fdt_offset_ptr (fdt, offset, FDT_TAGSIZE);
if (!tagp) {
return FDT_END; /* premature end */
tag = fdt32_to_cpu(*tagp);
}
tag = fdt32_to_cpu (*tagp);
offset += FDT_TAGSIZE;
*nextoffset = -FDT_ERR_BADSTRUCTURE;
@ -110,19 +134,24 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
case FDT_BEGIN_NODE:
/* skip name */
do {
p = fdt_offset_ptr(fdt, offset++, 1);
p = fdt_offset_ptr (fdt, offset++, 1);
} while (p && (*p != '\0'));
if (!p)
if (!p) {
return FDT_END; /* premature end */
}
break;
case FDT_PROP:
lenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp));
if (!lenp)
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);
offset += sizeof (struct fdt_property) - FDT_TAGSIZE
+ fdt32_to_cpu (*lenp);
break;
case FDT_END:
@ -134,43 +163,63 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
return FDT_END;
}
if (!fdt_offset_ptr(fdt, startoffset, offset - startoffset))
if (!fdt_offset_ptr (fdt, startoffset, offset - startoffset)) {
return FDT_END; /* premature end */
}
*nextoffset = FDT_TAGALIGN(offset);
*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))
if ( (offset < 0) || (offset % FDT_TAGSIZE)
|| (fdt_next_tag (fdt, offset, &offset) != FDT_BEGIN_NODE))
{
return -FDT_ERR_BADOFFSET;
}
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))
if ( (offset < 0) || (offset % FDT_TAGSIZE)
|| (fdt_next_tag (fdt, offset, &offset) != FDT_PROP))
{
return -FDT_ERR_BADOFFSET;
}
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)
if (offset >= 0) {
if ((nextoffset = _fdt_check_node_offset (fdt, offset)) < 0) {
return nextoffset;
}
}
do {
offset = nextoffset;
tag = fdt_next_tag(fdt, offset, &nextoffset);
tag = fdt_next_tag (fdt, offset, &nextoffset);
switch (tag) {
case FDT_PROP:
@ -178,39 +227,54 @@ int fdt_next_node(const void *fdt, int offset, int *depth)
break;
case FDT_BEGIN_NODE:
if (depth)
if (depth) {
(*depth)++;
}
break;
case FDT_END_NODE:
if (depth && ((--(*depth)) < 0))
if (depth && ((--(*depth)) < 0)) {
return nextoffset;
}
break;
case FDT_END:
if ((nextoffset >= 0)
if ( (nextoffset >= 0)
|| ((nextoffset == -FDT_ERR_TRUNCATED) && !depth))
{
return -FDT_ERR_NOTFOUND;
else
} 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;
offset = fdt_next_node(fdt, offset, &depth);
if (offset < 0 || depth != 1)
offset = fdt_next_node (fdt, offset, &depth);
if ((offset < 0) || (depth != 1)) {
return -FDT_ERR_NOTFOUND;
}
return offset;
}
int fdt_next_subnode(const void *fdt, int offset)
int
fdt_next_subnode (
const void *fdt,
int offset
)
{
int depth = 1;
@ -219,33 +283,48 @@ int fdt_next_subnode(const void *fdt, int offset)
* the same as the last.
*/
do {
offset = fdt_next_node(fdt, offset, &depth);
if (offset < 0 || depth < 1)
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;
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)
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)
if (fdt_totalsize (fdt) > bufsize) {
return -FDT_ERR_NOSPACE;
}
memmove(buf, fdt, fdt_totalsize(fdt));
memmove (buf, fdt, fdt_totalsize (fdt));
return 0;
}

View File

@ -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;
ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
if (!ac)
ac = fdt_getprop (fdt, nodeoffset, "#address-cells", &len);
if (!ac) {
return 2;
}
if (len != sizeof(*ac))
if (len != sizeof (*ac)) {
return -FDT_ERR_BADNCELLS;
}
val = fdt32_to_cpu(*ac);
if ((val <= 0) || (val > FDT_MAX_NCELLS))
val = fdt32_to_cpu (*ac);
if ((val <= 0) || (val > FDT_MAX_NCELLS)) {
return -FDT_ERR_BADNCELLS;
}
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;
sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len);
if (!sc)
sc = fdt_getprop (fdt, nodeoffset, "#size-cells", &len);
if (!sc) {
return 2;
}
if (len != sizeof(*sc))
if (len != sizeof (*sc)) {
return -FDT_ERR_BADNCELLS;
}
val = fdt32_to_cpu(*sc);
if ((val < 0) || (val > FDT_MAX_NCELLS))
val = fdt32_to_cpu (*sc);
if ((val < 0) || (val > FDT_MAX_NCELLS)) {
return -FDT_ERR_BADNCELLS;
}
return val;
}

View File

@ -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;
err = fdt_create(buf, bufsize);
if (err)
err = fdt_create (buf, bufsize);
if (err) {
return err;
}
err = fdt_finish_reservemap(buf);
if (err)
err = fdt_finish_reservemap (buf);
if (err) {
return err;
}
err = fdt_begin_node(buf, "");
if (err)
err = fdt_begin_node (buf, "");
if (err) {
return err;
}
err = fdt_end_node(buf);
if (err)
err = fdt_end_node (buf);
if (err) {
return err;
}
err = fdt_finish(buf);
if (err)
err = fdt_finish (buf);
if (err) {
return err;
}
return fdt_open_into(buf, buf, bufsize);
return fdt_open_into (buf, buf, bufsize);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -55,29 +55,45 @@
#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);
FDT_CHECK_HEADER (fdt);
if (fdt_version(fdt) < 17)
if (fdt_version (fdt) < 17) {
return -FDT_ERR_BADVERSION;
if (_fdt_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry),
fdt_size_dt_struct(fdt)))
}
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);
}
if (fdt_version (fdt) > 17) {
fdt_set_version (fdt, 17);
}
return 0;
}
@ -89,263 +105,390 @@ static int _fdt_rw_check_header(void *fdt)
return __err; \
}
static inline int _fdt_data_size(void *fdt)
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);
char *end = (char *)fdt + _fdt_data_size (fdt);
if (((p + oldlen) < p) || ((p + oldlen) > end))
if (((p + oldlen) < p) || ((p + oldlen) > end)) {
return -FDT_ERR_BADOFFSET;
if ((p < (char *)fdt) || ((end - oldlen + newlen) < (char *)fdt))
}
if ((p < (char *)fdt) || ((end - oldlen + newlen) < (char *)fdt)) {
return -FDT_ERR_BADOFFSET;
if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize(fdt)))
}
if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize (fdt))) {
return -FDT_ERR_NOSPACE;
memmove(p + newlen, p + oldlen, end - p - oldlen);
}
memmove (p + newlen, p + oldlen, end - p - oldlen);
return 0;
}
static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
int oldn, int newn)
static int
_fdt_splice_mem_rsv (
void *fdt,
struct fdt_reserve_entry *p,
int oldn,
int newn
)
{
int delta = (newn - oldn) * sizeof(*p);
int delta = (newn - oldn) * sizeof (*p);
int err;
err = _fdt_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
if (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);
}
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_splice_struct(void *fdt, void *p,
int oldlen, int newlen)
static int
_fdt_splice_struct (
void *fdt,
void *p,
int oldlen,
int newlen
)
{
int delta = newlen - oldlen;
int err;
if ((err = _fdt_splice(fdt, p, oldlen, newlen)))
if ((err = _fdt_splice (fdt, p, oldlen, newlen))) {
return err;
}
fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);
fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
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;
}
static int _fdt_splice_string(void *fdt, int newlen)
static int
_fdt_splice_string (
void *fdt,
int newlen
)
{
void *p = (char *)fdt
+ fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
+ fdt_off_dt_strings (fdt) + fdt_size_dt_strings (fdt);
int err;
if ((err = _fdt_splice(fdt, p, 0, newlen)))
if ((err = _fdt_splice (fdt, p, 0, newlen))) {
return err;
}
fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);
fdt_set_size_dt_strings (fdt, fdt_size_dt_strings (fdt) + newlen);
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_off_dt_strings(fdt);
char *strtab = (char *)fdt + fdt_off_dt_strings (fdt);
const char *p;
char *new;
int len = strlen(s) + 1;
int len = strlen (s) + 1;
int err;
p = _fdt_find_string(strtab, fdt_size_dt_strings(fdt), s);
if (p)
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)
new = strtab + fdt_size_dt_strings (fdt);
err = _fdt_splice_string (fdt, len);
if (err) {
return err;
}
memcpy(new, s, len);
memcpy (new, s, len);
return (new - strtab);
}
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
)
{
struct fdt_reserve_entry *re;
int err;
FDT_RW_CHECK_HEADER(fdt);
FDT_RW_CHECK_HEADER (fdt);
re = _fdt_mem_rsv_w(fdt, fdt_num_mem_rsv(fdt));
err = _fdt_splice_mem_rsv(fdt, re, 0, 1);
if (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;
}
re->address = cpu_to_fdt64(address);
re->size = cpu_to_fdt64(size);
re->address = cpu_to_fdt64 (address);
re->size = cpu_to_fdt64 (size);
return 0;
}
int fdt_del_mem_rsv(void *fdt, int n)
int
fdt_del_mem_rsv (
void *fdt,
int n
)
{
struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
struct fdt_reserve_entry *re = _fdt_mem_rsv_w (fdt, n);
FDT_RW_CHECK_HEADER(fdt);
FDT_RW_CHECK_HEADER (fdt);
if (n >= fdt_num_mem_rsv(fdt))
if (n >= fdt_num_mem_rsv (fdt)) {
return -FDT_ERR_NOTFOUND;
}
return _fdt_splice_mem_rsv(fdt, re, 1, 0);
return _fdt_splice_mem_rsv (fdt, re, 1, 0);
}
static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
int len, struct fdt_property **prop)
static int
_fdt_resize_property (
void *fdt,
int nodeoffset,
const char *name,
int len,
struct fdt_property **prop
)
{
int oldlen;
int err;
*prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
if (!*prop)
*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))))
if ((err = _fdt_splice_struct (
fdt,
(*prop)->data,
FDT_TAGALIGN (oldlen),
FDT_TAGALIGN (len)
)))
{
return err;
}
(*prop)->len = cpu_to_fdt32(len);
(*prop)->len = cpu_to_fdt32 (len);
return 0;
}
static int _fdt_add_property(void *fdt, int nodeoffset, const char *name,
int len, struct fdt_property **prop)
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)
if ((nextoffset = _fdt_check_node_offset (fdt, nodeoffset)) < 0) {
return nextoffset;
}
namestroff = _fdt_find_add_string(fdt, name);
if (namestroff < 0)
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);
*prop = _fdt_offset_ptr_w (fdt, nextoffset);
proplen = sizeof (**prop) + FDT_TAGALIGN (len);
err = _fdt_splice_struct(fdt, *prop, 0, proplen);
if (err)
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);
(*prop)->tag = cpu_to_fdt32 (FDT_PROP);
(*prop)->nameoff = cpu_to_fdt32 (namestroff);
(*prop)->len = cpu_to_fdt32 (len);
return 0;
}
int fdt_set_name(void *fdt, int nodeoffset, const char *name)
int
fdt_set_name (
void *fdt,
int nodeoffset,
const char *name
)
{
char *namep;
int oldlen, newlen;
int err;
FDT_RW_CHECK_HEADER(fdt);
FDT_RW_CHECK_HEADER (fdt);
namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);
if (!namep)
namep = (char *)(uintptr_t)fdt_get_name (fdt, nodeoffset, &oldlen);
if (!namep) {
return oldlen;
}
newlen = strlen(name);
newlen = strlen (name);
err = _fdt_splice_struct(fdt, namep, FDT_TAGALIGN(oldlen+1),
FDT_TAGALIGN(newlen+1));
if (err)
err = _fdt_splice_struct (
fdt,
namep,
FDT_TAGALIGN (oldlen+1),
FDT_TAGALIGN (newlen+1)
);
if (err) {
return err;
}
memcpy(namep, name, newlen+1);
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;
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);
if (err)
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;
}
*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;
err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);
if (err)
err = fdt_setprop_placeholder (fdt, nodeoffset, name, len, &prop_data);
if (err) {
return err;
}
if (len) {
memcpy (prop_data, val, len);
}
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);
FDT_RW_CHECK_HEADER (fdt);
prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
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)
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);
}
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;
FDT_RW_CHECK_HEADER(fdt);
FDT_RW_CHECK_HEADER (fdt);
prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
if (!prop)
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;
@ -354,119 +497,153 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
uint32_t tag;
fdt32_t *endtag;
FDT_RW_CHECK_HEADER(fdt);
FDT_RW_CHECK_HEADER (fdt);
offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen);
if (offset >= 0)
offset = fdt_subnode_offset_namelen (fdt, parentoffset, name, namelen);
if (offset >= 0) {
return -FDT_ERR_EXISTS;
else if (offset != -FDT_ERR_NOTFOUND)
} 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 */
fdt_next_tag (fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
do {
offset = nextoffset;
tag = fdt_next_tag(fdt, 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;
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)
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);
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);
*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;
FDT_RW_CHECK_HEADER(fdt);
FDT_RW_CHECK_HEADER (fdt);
endoffset = _fdt_node_end_offset(fdt, nodeoffset);
if (endoffset < 0)
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);
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 + 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 + 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));
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);
const char *fdtend = fdtstart + fdt_totalsize (fdt);
char *tmp;
FDT_CHECK_HEADER(fdt);
FDT_CHECK_HEADER (fdt);
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
* sizeof(struct fdt_reserve_entry);
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);
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;
while (fdt_next_tag (fdt, struct_size, &struct_size) != FDT_END) {
}
if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) {
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)
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);
}
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);
newsize = FDT_ALIGN (sizeof (struct fdt_header), 8) + mem_rsv_size
+ struct_size + fdt_size_dt_strings (fdt);
if (bufsize < newsize)
if (bufsize < newsize) {
return -FDT_ERR_NOSPACE;
}
/* First attempt to build converted tree at beginning of buffer */
tmp = buf;
@ -474,32 +651,36 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
/* Try right after the old tree instead */
tmp = (char *)(uintptr_t)fdtend;
if ((tmp + newsize) > ((char *)buf + bufsize))
if ((tmp + newsize) > ((char *)buf + bufsize)) {
return -FDT_ERR_NOSPACE;
}
}
_fdt_packblocks(fdt, tmp, mem_rsv_size, struct_size);
memmove(buf, tmp, newsize);
_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));
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;
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;
}

View File

@ -63,40 +63,44 @@ struct fdt_errtabent {
[(val)] = { .str = #val, }
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_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]))
const char *fdt_strerror(int errval)
const char *
fdt_strerror (
int errval
)
{
if (errval > 0)
if (errval > 0) {
return "<valid offset/length>";
else if (errval == 0)
} else if (errval == 0) {
return "<no error>";
else if (errval > -FDT_ERRTABSIZE) {
} else if (errval > -FDT_ERRTABSIZE) {
const char *s = fdt_errtable[-errval].str;
if (s)
if (s) {
return s;
}
}
return "<unknown error>";
}

View File

@ -9,7 +9,12 @@
#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;

View File

@ -55,10 +55,15 @@
#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)
if (fdt_magic (fdt) != FDT_SW_MAGIC) {
return -FDT_ERR_BADMAGIC;
}
/* FIXME: should check more details about the header state */
return 0;
}
@ -70,191 +75,256 @@ static int _fdt_sw_check_header(void *fdt)
return err; \
}
static void *_fdt_grab_space(void *fdt, size_t len)
static void *
_fdt_grab_space (
void *fdt,
size_t len
)
{
int offset = fdt_size_dt_struct(fdt);
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))
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))
if (bufsize < sizeof (struct fdt_header)) {
return -FDT_ERR_NOSPACE;
}
memset(buf, 0, bufsize);
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_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);
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;
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)
if ((headsize + tailsize) > bufsize) {
return -FDT_ERR_NOSPACE;
}
oldtail = (char *)fdt + fdt_totalsize(fdt) - 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);
memmove (buf, fdt, headsize);
memmove (newtail, oldtail, tailsize);
} else {
memmove(newtail, oldtail, tailsize);
memmove(buf, fdt, headsize);
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;
}
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;
FDT_SW_CHECK_HEADER(fdt);
FDT_SW_CHECK_HEADER (fdt);
if (fdt_size_dt_struct(fdt))
if (fdt_size_dt_struct (fdt)) {
return -FDT_ERR_BADSTATE;
}
offset = fdt_off_dt_struct(fdt);
if ((offset + sizeof(*re)) > fdt_totalsize(fdt))
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->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;
}
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;
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)
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);
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;
FDT_SW_CHECK_HEADER(fdt);
FDT_SW_CHECK_HEADER (fdt);
en = _fdt_grab_space(fdt, FDT_TAGSIZE);
if (! en)
en = _fdt_grab_space (fdt, FDT_TAGSIZE);
if (!en) {
return -FDT_ERR_NOSPACE;
}
*en = cpu_to_fdt32(FDT_END_NODE);
*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);
char *strtab = (char *)fdt + fdt_totalsize (fdt);
const char *p;
int strtabsize = fdt_size_dt_strings(fdt);
int len = strlen(s) + 1;
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)
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)
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);
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);
FDT_SW_CHECK_HEADER (fdt);
nameoff = _fdt_find_add_string(fdt, name);
if (nameoff == 0)
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)
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);
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)
ret = fdt_property_placeholder (fdt, name, len, &ptr);
if (ret) {
return ret;
memcpy(ptr, val, len);
}
memcpy (ptr, val, len);
return 0;
}
int fdt_finish(void *fdt)
int
fdt_finish (
void *fdt
)
{
char *p = (char *)fdt;
fdt32_t *end;
@ -262,39 +332,44 @@ int fdt_finish(void *fdt)
uint32_t tag;
int offset, nextoffset;
FDT_SW_CHECK_HEADER(fdt);
FDT_SW_CHECK_HEADER (fdt);
/* Add terminator */
end = _fdt_grab_space(fdt, sizeof(*end));
if (! end)
end = _fdt_grab_space (fdt, sizeof (*end));
if (!end) {
return -FDT_ERR_NOSPACE;
*end = cpu_to_fdt32(FDT_END);
}
*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);
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) {
while ((tag = fdt_next_tag (fdt, offset, &nextoffset)) != FDT_END) {
if (tag == FDT_PROP) {
struct fdt_property *prop =
_fdt_offset_ptr_w(fdt, offset);
_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);
nameoff = fdt32_to_cpu (prop->nameoff);
nameoff += fdt_size_dt_strings (fdt);
prop->nameoff = cpu_to_fdt32 (nameoff);
}
offset = nextoffset;
}
if (nextoffset < 0)
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);
fdt_set_totalsize (fdt, newstroffset + fdt_size_dt_strings (fdt));
fdt_set_magic (fdt, FDT_MAGIC);
return 0;
}

View File

@ -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)
propval = fdt_getprop_namelen_w (
fdt,
nodeoffset,
name,
namelen,
&proplen
);
if (!propval) {
return proplen;
}
if (proplen < (len + idx))
if (proplen < (len + idx)) {
return -FDT_ERR_NOSPACE;
}
memcpy((char *)propval + idx, val, len);
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)
propval = fdt_getprop (fdt, nodeoffset, name, &proplen);
if (!propval) {
return proplen;
}
if (proplen != len)
if (proplen != len) {
return -FDT_ERR_NOSPACE;
}
return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,
strlen(name), 0,
val, len);
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;
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;
prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
if (!prop)
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;
}
int _fdt_node_end_offset(void *fdt, int offset)
int
_fdt_node_end_offset (
void *fdt,
int offset
)
{
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;
}
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)
endoffset = _fdt_node_end_offset (fdt, nodeoffset);
if (endoffset < 0) {
return endoffset;
}
_fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0),
endoffset - nodeoffset);
_fdt_nop_region (
fdt_offset_ptr_w (fdt, nodeoffset, 0),
endoffset - nodeoffset
);
return 0;
}

View File

@ -1,5 +1,6 @@
#ifndef _LIBFDT_INTERNAL_H
#define _LIBFDT_INTERNAL_H
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2006 David Gibson, IBM Corporation.
@ -62,32 +63,69 @@
return __err; \
}
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);
int
_fdt_check_node_offset (
const void *fdt,
int offset
);
static inline const void *_fdt_offset_ptr(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
);
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 char *)fdt + fdt_off_mem_rsvmap (fdt));
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)

View File

@ -16,7 +16,6 @@
#include <Protocol/DebugPort.h>
EFI_DEBUGPORT_PROTOCOL *gDebugPort = NULL;
UINTN gTimeOut = 0;
@ -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
@ -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.
@ -130,7 +125,6 @@ GdbGetChar (
return Char;
}
/**
Send a character to GDB. This function must be able to run in interrupt context.
@ -138,7 +132,6 @@ GdbGetChar (
@param Char Send a character to GDB
**/
VOID
EFIAPI
GdbPutChar (
@ -163,7 +156,6 @@ GdbPutChar (
@param String Send a string to GDB
**/
VOID
GdbPutString (
IN CHAR8 *String
@ -175,7 +167,3 @@ GdbPutString (
String++;
}
}

View File

@ -13,10 +13,9 @@
#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
@ -31,21 +30,18 @@
#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
// IO Port Base for the UART
UINTN gPort;
/**
The constructor function initializes the UART.
@ -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
@ -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().
@ -176,7 +167,6 @@ GdbIsCharAvailable (
return ((Data & LSR_RXDA) == LSR_RXDA);
}
/**
Get a character from GDB. This function must be able to run in interrupt context.
@ -204,7 +194,6 @@ GdbGetChar (
return Char;
}
/**
Send a character to GDB. This function must be able to run in interrupt context.
@ -212,7 +201,6 @@ GdbGetChar (
@param Char Send a character to GDB
**/
VOID
EFIAPI
GdbPutChar (
@ -239,7 +227,6 @@ GdbPutChar (
@param String Send a string to GDB
**/
VOID
GdbPutString (
IN CHAR8 *String

View File

@ -29,7 +29,6 @@ typedef struct {
BOOLEAN DoubleBuffer;
} MAP_INFO_INSTANCE;
typedef struct {
LIST_ENTRY Link;
VOID *HostAddress;
@ -95,6 +94,7 @@ InternalAllocateAlignedPages (
if (Pages == 0) {
return NULL;
}
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page
@ -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;
}
@ -190,10 +202,11 @@ DmaMap (
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
UINTN AllocSize;
if (HostAddress == NULL ||
NumberOfBytes == NULL ||
DeviceAddress == NULL ||
Mapping == NULL ) {
if ((HostAddress == NULL) ||
(NumberOfBytes == NULL) ||
(DeviceAddress == NULL) ||
(Mapping == NULL))
{
return EFI_INVALID_PARAMETER;
}
@ -210,15 +223,16 @@ DmaMap (
}
if (((UINTN)HostAddress + *NumberOfBytes) > mDmaHostAddressLimit) {
if (Operation == MapOperationBusMasterCommonBuffer) {
goto CommonBufferError;
}
AllocSize = ALIGN_VALUE (*NumberOfBytes, mCpu->DmaBufferAlignment);
Map->BufferAddress = InternalAllocateAlignedPages (EfiBootServicesData,
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);
mCpu->FlushDataCache (
mCpu,
(UINTN)Map->BufferAddress,
AllocSize,
EfiCpuFlushTypeWriteBack
);
*DeviceAddress = HostToDeviceAddress (Map->BufferAddress);
} else if (Operation != MapOperationBusMasterRead &&
} else if ((Operation != MapOperationBusMasterRead) &&
((((UINTN)HostAddress & (mCpu->DmaBufferAlignment - 1)) != 0) ||
((*NumberOfBytes & (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;
}
@ -275,8 +294,12 @@ 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;
}
@ -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
@ -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
);
}
}
@ -462,13 +508,15 @@ DmaAllocateAlignedBuffer (
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;
}
@ -506,17 +554,21 @@ DmaAllocateAlignedBuffer (
InsertHeadList (&UncachedAllocationList, &Alloc->Link);
// Remap the region with the new attributes
Status = gDS->SetMemorySpaceAttributes ((PHYSICAL_ADDRESS)(UINTN)Allocation,
Status = gDS->SetMemorySpaceAttributes (
(PHYSICAL_ADDRESS)(UINTN)Allocation,
EFI_PAGES_TO_SIZE (Pages),
MemType);
MemType
);
if (EFI_ERROR (Status)) {
goto FreeAlloc;
}
Status = mCpu->FlushDataCache (mCpu,
Status = mCpu->FlushDataCache (
mCpu,
(PHYSICAL_ADDRESS)(UINTN)Allocation,
EFI_PAGES_TO_SIZE (Pages),
EfiCpuFlushTypeInvalidate);
EfiCpuFlushTypeInvalidate
);
if (EFI_ERROR (Status)) {
goto FreeAlloc;
}
@ -534,7 +586,6 @@ FreeBuffer:
return Status;
}
/**
Frees memory that was allocated with DmaAllocateBuffer().
@ -566,10 +617,10 @@ DmaFreeBuffer (
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,
Status = gDS->SetMemorySpaceAttributes (
(PHYSICAL_ADDRESS)(UINTN)HostAddress,
EFI_PAGES_TO_SIZE (Pages),
Alloc->Attributes);
Alloc->Attributes
);
if (EFI_ERROR (Status)) {
goto FreeAlloc;
}
@ -600,7 +653,6 @@ FreeAlloc:
return Status;
}
EFI_STATUS
EFIAPI
NonCoherentDmaLibConstructor (

View File

@ -17,119 +17,119 @@
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 */
};
/**
@ -162,7 +162,7 @@ NorFlashGetInfo (
* 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;
}
@ -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
));
}

View File

@ -30,7 +30,7 @@ GetSavedData (
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,7 +155,7 @@ ExtractGuidedSectionGetInfo (
//
// Call the match handler to getinfo for the input section data.
//
return SavedData->ExtractGetInfoHandlerTable [Index] (
return SavedData->ExtractGetInfoHandlerTable[Index](
InputSection,
OutputBufferSize,
ScratchBufferSize,
@ -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,7 +210,7 @@ ExtractGuidedSectionDecode (
//
// Call the match handler to getinfo for the input section data.
//
return SavedData->ExtractDecodeHandlerTable [Index] (
return SavedData->ExtractDecodeHandlerTable[Index](
InputSection,
OutputBuffer,
ScratchBuffer,
@ -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;
}

View File

@ -44,8 +44,6 @@ GetHobList (
return PrePeiGetHobList ();
}
/**
Updates the pointer to the HOB list.
@ -65,7 +63,7 @@ SetHobList (
**/
EFI_HOB_HANDOFF_INFO_TABLE*
EFI_HOB_HANDOFF_INFO_TABLE *
HobConstructor (
IN VOID *EfiMemoryBegin,
IN UINTN EfiMemoryLength,
@ -80,11 +78,11 @@ HobConstructor (
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.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->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->Reserved = 0;
Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
@ -120,19 +118,19 @@ CreateHob (
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,7 +175,6 @@ BuildFvHobs (
IN EFI_RESOURCE_ATTRIBUTE_TYPE *ResourceAttribute
)
{
EFI_RESOURCE_ATTRIBUTE_TYPE Resource;
BuildFvHob (PhysicalStart, NumberOfBytes);
@ -221,7 +218,7 @@ GetNextHob (
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.
@ -259,7 +256,6 @@ GetFirstHob (
return GetNextHob (Type, HobList);
}
/**
This function searches the first instance of a HOB from the starting HOB pointer.
Such HOB should satisfy two conditions:
@ -284,20 +280,22 @@ EFIAPI
GetNextGuidHob (
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:
@ -324,7 +322,6 @@ GetFirstGuidHob (
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.
@ -399,8 +395,10 @@ BuildModuleHob (
{
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));
@ -450,12 +448,11 @@ BuildGuidHob (
//
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.
@ -493,7 +490,6 @@ BuildGuidDataHob (
return CopyMem (HobData, Data, DataLength);
}
/**
Builds a Firmware Volume HOB.
@ -521,7 +517,6 @@ BuildFvHob (
Hob->Length = Length;
}
/**
Builds a EFI_HOB_TYPE_FV2 HOB.
@ -622,7 +617,6 @@ BuildCvHob (
ASSERT (FALSE);
}
/**
Builds a HOB for the CPU.
@ -655,7 +649,6 @@ BuildCpuHob (
ZeroMem (Hob->Reserved, sizeof (Hob->Reserved));
}
/**
Builds a HOB for the Stack.
@ -677,8 +670,10 @@ BuildStackHob (
{
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
@ -728,12 +722,11 @@ UpdateStackHob (
Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length;
break;
}
Hob.Raw = GET_NEXT_HOB (Hob);
}
}
/**
Builds a HOB for the memory allocation.
@ -757,8 +750,10 @@ BuildMemoryAllocationHob (
{
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,8 +767,6 @@ BuildMemoryAllocationHob (
ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
}
VOID
EFIAPI
BuildExtractSectionHob (
@ -798,8 +791,6 @@ PE_COFF_LOADER_PROTOCOL gPeCoffProtocol = {
PeCoffLoaderUnloadImage
};
VOID
EFIAPI
BuildPeCoffLoaderHob (
@ -843,6 +834,5 @@ BuildMemoryTypeInformationHob (
Info[9].Type = EfiMaxMemoryType;
Info[9].NumberOfPages = 0;
BuildGuidDataHob (&gEfiMemoryTypeInformationGuid, &Info, sizeof (Info));
}

View File

@ -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
@ -75,14 +72,14 @@ CalculateHeaderChecksum (
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
@ -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
@ -206,7 +201,7 @@ FindFileEx (
// 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,10 +211,9 @@ 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));
FileOffset += sizeof (EFI_FFS_FILE_HEADER);
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof (EFI_FFS_FILE_HEADER));
break;
case EFI_FILE_DATA_VALID:
@ -231,15 +225,16 @@ FindFileEx (
}
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
if (FileName != NULL) {
if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID*)FileName)) {
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)) {
(FfsFileHeader->Type != EFI_FV_FILETYPE_FFS_PAD))
{
*FileHeader = FfsFileHeader;
return EFI_SUCCESS;
}
@ -250,7 +245,7 @@ FindFileEx (
case EFI_FILE_DELETED:
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
FileOccupiedSize = GET_OCCUPIED_SIZE (FileLength, 8);
FileOffset += FileOccupiedSize;
FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
break;
@ -261,12 +256,10 @@ FindFileEx (
}
}
*FileHeader = NULL;
return EFI_NOT_FOUND;
}
/**
Go through the file to search SectionType section,
when meeting an encapsuled section.
@ -300,7 +293,6 @@ FfsProcessSection (
CHAR8 *CompressedData;
UINTN CompressedDataLength;
*OutputBuffer = NULL;
ParsedLength = 0;
Status = EFI_NOT_FOUND;
@ -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;
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,23 +371,25 @@ 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 (
@ -432,6 +427,7 @@ FfsProcessSection (
} else {
SectionLength = SECTION_SIZE (Section);
}
//
// SectionLength is adjusted it is 4 byte aligned.
// Go to the next section
@ -445,8 +441,6 @@ FfsProcessSection (
return EFI_NOT_FOUND;
}
/**
This service enables discovery sections of a given type within a valid FFS file.
@ -490,11 +484,6 @@ FfsFindSectionData (
);
}
/**
This service enables discovery of additional firmware files.
@ -519,7 +508,6 @@ FfsFindNextFile (
return FindFileEx (VolumeHandle, NULL, SearchType, FileHandle);
}
/**
This service enables discovery of additional firmware volumes.
@ -540,7 +528,6 @@ FfsFindNextVolume (
{
EFI_PEI_HOB_POINTERS Hob;
Hob.Raw = GetHobList ();
if (Hob.Raw == NULL) {
return EFI_NOT_FOUND;
@ -559,10 +546,8 @@ FfsFindNextVolume (
} while (Hob.Raw != NULL);
return EFI_NOT_FOUND;
}
/**
Find a file in the volume by name
@ -590,19 +575,19 @@ FfsFindFileByName (
)
{
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.
@ -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:
@ -663,7 +648,7 @@ FfsGetFileInfo (
}
FileHeader = (EFI_FFS_FILE_HEADER *)FileHandle;
CopyMem (&FileInfo->FileName, &FileHeader->Name, sizeof(EFI_GUID));
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);
@ -671,7 +656,6 @@ FfsGetFileInfo (
return EFI_SUCCESS;
}
/**
Get Information about the volume by name
@ -714,20 +698,20 @@ FfsGetVolumeInfo (
if (FwVolHeader.Signature != EFI_FVH_SIGNATURE) {
return EFI_INVALID_PARAMETER;
}
VolumeInfo->FvAttributes = FwVolHeader.Attributes;
VolumeInfo->FvStart = (VOID *) VolumeHandle;
VolumeInfo->FvStart = (VOID *)VolumeHandle;
VolumeInfo->FvSize = FwVolHeader.FvLength;
CopyMem (&VolumeInfo->FvFormat, &FwVolHeader.FileSystemGuid, sizeof(EFI_GUID));
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
@ -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.
@ -801,7 +780,6 @@ FfsProcessFvFile (
FvBuffer = NULL;
//
// Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already
// been extracted.
@ -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)

View File

@ -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))

View File

@ -23,7 +23,7 @@ SecWinNtPeiLoadFile (
);
STATIC
VOID*
VOID *
EFIAPI
AllocateCodePages (
IN UINTN Pages
@ -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,7 +54,6 @@ AllocateCodePages (
return NULL;
}
EFI_STATUS
EFIAPI
LoadPeCoffImage (
@ -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
);
@ -141,9 +136,8 @@ LoadDxeCoreFromFfsFile (
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 (
@ -229,7 +219,6 @@ LoadDxeCoreFromFv (
return Status;
}
EFI_STATUS
EFIAPI
DecompressFirstFv (

View File

@ -14,8 +14,6 @@
#include <Library/PrePiLib.h>
#include <Library/DebugLib.h>
/**
Allocates one or more 4KB pages of type EfiBootServicesData.
@ -73,7 +71,6 @@ AllocatePages (
}
}
/**
Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
@ -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
@ -175,7 +173,6 @@ AllocatePool (
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);
}
}

View File

@ -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.
@ -65,7 +63,6 @@ LibSetTime (
return EFI_DEVICE_ERROR;
}
/**
Returns the current wakeup alarm clock setting.
@ -90,7 +87,6 @@ LibGetWakeupTime (
return EFI_UNSUPPORTED;
}
/**
Sets the system wakeup alarm clock time.
@ -115,8 +111,6 @@ LibSetWakeupTime (
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.
@ -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
@ -164,6 +157,3 @@ LibRtcVirtualNotifyEvent (
//
return;
}

View File

@ -10,14 +10,12 @@
**/
#include <PiDxe.h>
#include <Library/BaseLib.h>
#include <Library/IoLib.h>
#include <Library/EfiResetSystemLib.h>
/**
Resets the entire platform.
@ -41,7 +39,6 @@ LibResetSystem (
UINTN Address;
UINT8 Data;
switch (ResetType) {
case EfiResetCold:
// system power cycle
@ -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;
}

View File

@ -72,7 +72,6 @@ EpochToEfiTime (
Time->Minute = (UINT8)mm;
Time->Second = (UINT8)ss;
Time->Nanosecond = 0;
}
/**
@ -95,7 +94,7 @@ EfiGetEpochDays (
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;
@ -200,10 +199,11 @@ IsDayValid (
{
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;
}
@ -273,15 +273,16 @@ IsTimeValid (
// 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->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))) {
(!IsValidTimeZone (Time->TimeZone)) ||
(!IsValidDaylight (Time->Daylight)))
{
return FALSE;
}

View File

@ -78,8 +78,8 @@ LibGetTime (
);
// 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,6 +101,7 @@ LibGetTime (
&EpochSeconds
);
}
Counter = GetPerformanceCounter ();
EpochSeconds += DivU64x64Remainder (Counter, Freq, &Remainder);
@ -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;
}
@ -168,8 +170,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;
@ -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,7 +304,7 @@ 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)) {

View File

@ -54,7 +54,6 @@ EFI_METRONOME_ARCH_PROTOCOL gMetronome = {
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
@ -124,11 +120,11 @@ MetronomeInitialize (
Status = gBS->InstallMultipleProtocolInterfaces (
&gMetronomeHandle,
&gEfiMetronomeArchProtocolGuid, &gMetronome,
&gEfiMetronomeArchProtocolGuid,
&gMetronome,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}

View File

@ -67,8 +67,6 @@ GetTime (
return LibGetTime (Time, Capabilities);
}
/**
Sets the current local time and date information.
@ -88,14 +86,14 @@ SetTime (
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;
@ -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.
@ -143,7 +142,7 @@ GetWakeupTime (
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.
@ -181,8 +179,6 @@ SetWakeupTime (
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.
@ -209,13 +205,22 @@ InitializeRealTimeClock (
}
Size = sizeof (mTimeSettings);
Status = EfiGetVariable ((CHAR16 *)mTimeSettingsVariableName,
&gEfiCallerIdGuid, NULL, &Size, (VOID *)&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;
}

View File

@ -13,7 +13,6 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/EfiResetSystemLib.h>
/**
Resets the entire platform.
@ -38,8 +37,6 @@ ResetSystemViaLib (
return;
}
EFI_STATUS
EFIAPI
InitializeReset (
@ -65,4 +62,3 @@ InitializeReset (
return Status;
}

View File

@ -65,30 +65,26 @@
#include <Protocol/SimpleTextOut.h>
#include <Protocol/DevicePath.h>
#define MODE0_COLUMN_COUNT 80
#define MODE0_ROW_COUNT 25
EFI_STATUS
EFIAPI
TextInReset(
TextInReset (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
EFI_STATUS
EFIAPI
ReadKeyStroke(
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
);
@ -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,17 +154,16 @@ 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
@ -204,23 +192,23 @@ typedef struct {
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} },
{ 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
@ -236,7 +224,6 @@ TextOutIsValidAscii (
return FALSE;
}
BOOLEAN
TextOutIsValidEfiCntlChar (
IN CHAR16 Char
@ -245,18 +232,18 @@ TextOutIsValidEfiCntlChar (
//
// 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 (
@ -269,7 +256,6 @@ WaitForKeyEvent (
}
}
EFI_STATUS
EFIAPI
TextInReset (
@ -280,7 +266,6 @@ TextInReset (
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
ReadKeyStroke (
@ -408,7 +393,7 @@ ReadKeyStroke (
case 'm':
Key->ScanCode = SCAN_F10;
break;
default :
default:
break;
}
}
@ -416,7 +401,8 @@ ReadKeyStroke (
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 (
@ -439,9 +424,9 @@ TextOutReset (
{
EFI_STATUS Status;
This->SetAttribute(
This->SetAttribute (
This,
EFI_TEXT_ATTR(This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK)
EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK)
);
Status = This->SetMode (This, 0);
@ -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++;
}
@ -512,18 +496,18 @@ OutputString (
)
{
UINTN Size;
CHAR8* OutputString;
CHAR8 *OutputString;
EFI_STATUS Status;
EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
UINTN MaxColumn;
UINTN MaxRow;
Size = StrLen(String) + 1;
OutputString = AllocatePool(Size);
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);
// 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,19 +526,20 @@ 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)) {
if (Mode->CursorRow < (INT32)(MaxRow - 1)) {
Mode->CursorRow++;
}
break;
case CHAR_CARRIAGE_RETURN:
@ -562,27 +547,28 @@ OutputString (
break;
default:
if (Mode->CursorColumn >= (INT32) (MaxColumn - 1)) {
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)) {
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 (
@ -602,7 +588,6 @@ TestString (
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
QueryMode (
@ -625,7 +610,6 @@ QueryMode (
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
SetMode (
@ -642,10 +626,9 @@ SetMode (
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
SetAttribute(
SetAttribute (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN Attribute
)
@ -654,7 +637,6 @@ SetAttribute(
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
ClearScreen (
@ -667,7 +649,6 @@ ClearScreen (
return Status;
}
EFI_STATUS
EFIAPI
SetCursorPosition (
@ -683,13 +664,13 @@ SetCursorPosition (
Mode = This->Mode;
Status = This->QueryMode(
Status = This->QueryMode (
This,
Mode->Mode,
&MaxColumn,
&MaxRow
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
@ -703,7 +684,6 @@ SetCursorPosition (
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
EnableCursor (
@ -718,7 +698,6 @@ EnableCursor (
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
SimpleTextInOutEntryPoint (
@ -737,11 +716,14 @@ 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)) {

View File

@ -22,15 +22,15 @@ 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,
(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 }
};
/**

View File

@ -17,10 +17,10 @@
#define DIAGNOSTIC_LOGBUFFER_MAXCHAR 1024
CHAR16* mLogBuffer = NULL;
CHAR16 *mLogBuffer = NULL;
UINTN mLogRemainChar = 0;
CHAR16*
CHAR16 *
DiagnosticInitLog (
UINTN MaxBufferChar
)
@ -32,10 +32,11 @@ DiagnosticInitLog (
UINTN
DiagnosticLog (
CONST CHAR16* Str
CONST CHAR16 *Str
)
{
UINTN len = StrLen (Str);
if (len < mLogRemainChar) {
StrCpyS (mLogBuffer, mLogRemainChar, Str);
mLogRemainChar -= len;
@ -48,12 +49,12 @@ DiagnosticLog (
VOID
GenerateRandomBuffer (
VOID* Buffer,
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);
@ -69,8 +70,8 @@ CompareBuffer (
)
{
UINTN i;
UINT64* BufferA64 = (UINT64*)BufferA;
UINT64* BufferB64 = (UINT64*)BufferB;
UINT64 *BufferA64 = (UINT64 *)BufferA;
UINT64 *BufferB64 = (UINT64 *)BufferB;
for (i = 0; i < (BufferSize >> 3); i++) {
if (*BufferA64 != *BufferB64) {
@ -78,9 +79,11 @@ CompareBuffer (
DEBUG ((DEBUG_ERROR, "(0x%lX) != (0x%lX)\n", *BufferA64, *BufferB64));
return FALSE;
}
BufferA64++;
BufferB64++;
}
return TRUE;
}
@ -112,49 +115,49 @@ MmcReadWriteDataTest (
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;
}
@ -183,7 +186,8 @@ MmcDriverDiagnosticsRunDiagnostics (
(ErrorType == NULL) ||
(Buffer == NULL) ||
(ControllerHandle == NULL) ||
(BufferSize == NULL)) {
(BufferSize == NULL))
{
return EFI_INVALID_PARAMETER;
}
@ -203,17 +207,19 @@ MmcDriverDiagnosticsRunDiagnostics (
MmcHostInstance = NULL;
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;
}
@ -248,6 +254,6 @@ MmcDriverDiagnosticsRunDiagnostics (
// EFI Driver Diagnostics 2 Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2 = {
(EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) MmcDriverDiagnosticsRunDiagnostics,
(EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS)MmcDriverDiagnosticsRunDiagnostics,
"en"
};

View File

@ -18,7 +18,7 @@
#include "Mmc.h"
EFI_BLOCK_IO_MEDIA mMmcMediaTemplate = {
SIGNATURE_32('m','m','c','o'), // MediaId
SIGNATURE_32 ('m', 'm', 'c', 'o'), // MediaId
TRUE, // RemovableMedia
FALSE, // MediaPresent
FALSE, // LogicalPartition
@ -76,12 +76,13 @@ RemoveMmcHost (
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;
MMC_HOST_INSTANCE *MmcHostInstance;
EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
@ -94,7 +95,7 @@ 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;
}
@ -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;
}
@ -124,30 +125,33 @@ MMC_HOST_INSTANCE* CreateMmcHostInstance (
// Publish BlockIO protocol interface
Status = gBS->InstallMultipleProtocolInterfaces (
&MmcHostInstance->MmcHandle,
&gEfiBlockIoProtocolGuid,&MmcHostInstance->BlockIo,
&gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
&gEfiBlockIoProtocolGuid,
&MmcHostInstance->BlockIo,
&gEfiDevicePathProtocolGuid,
MmcHostInstance->DevicePath,
NULL
);
if (EFI_ERROR(Status)) {
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;
@ -155,19 +159,23 @@ EFI_STATUS DestroyMmcHostInstance (
// Uninstall Protocol Interfaces
Status = gBS->UninstallMultipleProtocolInterfaces (
MmcHostInstance->MmcHandle,
&gEfiBlockIoProtocolGuid,&(MmcHostInstance->BlockIo),
&gEfiDevicePathProtocolGuid,MmcHostInstance->DevicePath,
&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;
@ -185,7 +193,7 @@ MmcDriverBindingSupported (
)
{
EFI_STATUS Status;
//EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
// EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
EFI_MMC_HOST_PROTOCOL *MmcHost;
EFI_DEV_PATH_PTR Node;
@ -203,9 +211,10 @@ 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)) {
if ((Node.DevPath->Type != HARDWARE_DEVICE_PATH) ||
(Node.DevPath->SubType != HW_VENDOR_DP) ||
(DevicePathNodeLength (Node.DevPath) != sizeof (VENDOR_DEVICE_PATH)))
{
return EFI_UNSUPPORTED;
}
}
@ -217,7 +226,7 @@ MmcDriverBindingSupported (
Status = gBS->OpenProtocol (
Controller,
&gEmbeddedMmcHostProtocolGuid,
(VOID **) &MmcHost,
(VOID **)&MmcHost,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@ -225,6 +234,7 @@ MmcDriverBindingSupported (
if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
if (EFI_ERROR (Status)) {
return Status;
}
@ -276,7 +286,7 @@ MmcDriverBindingStart (
Status = gBS->OpenProtocol (
Controller,
&gEmbeddedMmcHostProtocolGuid,
(VOID **) &MmcHost,
(VOID **)&MmcHost,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@ -285,10 +295,11 @@ MmcDriverBindingStart (
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);
@ -318,13 +329,13 @@ MmcDriverBindingStop (
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 (
@ -357,8 +368,8 @@ CheckCardsCallback (
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;
@ -376,8 +387,8 @@ CheckCardsCallback (
&(MmcHostInstance->BlockIo)
);
if (EFI_ERROR(Status)) {
Print(L"MMC Card: Error reinstalling BlockIo interface\n");
if (EFI_ERROR (Status)) {
Print (L"MMC Card: Error reinstalling BlockIo interface\n");
}
}
@ -385,7 +396,6 @@ CheckCardsCallback (
}
}
EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {
MmcDriverBindingSupported,
MmcDriverBindingStart,
@ -428,7 +438,8 @@ MmcDxeInitialize (
// Install driver diagnostics
Status = gBS->InstallMultipleProtocolInterfaces (
&ImageHandle,
&gEfiDriverDiagnostics2ProtocolGuid,&gMmcDriverDiagnostics2,
&gEfiDriverDiagnostics2ProtocolGuid,
&gMmcDriverDiagnostics2,
NULL
);
ASSERT_EFI_ERROR (Status);
@ -439,13 +450,15 @@ MmcDxeInitialize (
TPL_CALLBACK,
CheckCardsCallback,
NULL,
&gCheckCardsEvent);
&gCheckCardsEvent
);
ASSERT_EFI_ERROR (Status);
Status = gBS->SetTimer(
Status = gBS->SetTimer (
gCheckCardsEvent,
TimerPeriodic,
(UINT64)(10*1000*200)); // 200 ms
(UINT64)(10*1000*200)
); // 200 ms
ASSERT_EFI_ERROR (Status);
return Status;

View File

@ -70,37 +70,37 @@
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]
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;
@ -117,49 +117,49 @@ typedef struct {
} CID;
typedef struct {
UINT8 NOT_USED: 1; // Not used, always 1 [0:0]
UINT8 CRC: 7; // CRC [7:1]
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]
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]
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 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]
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 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 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 {
@ -344,7 +344,6 @@ typedef struct _MMC_HOST_INSTANCE {
#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
MmcGetDriverName (
@ -497,7 +496,7 @@ CheckCardsCallback (
VOID
PrintCSD (
IN UINT32* Csd
IN UINT32 *Csd
);
VOID
@ -517,7 +516,7 @@ PrintResponseR1 (
VOID
PrintCID (
IN UINT32* Cid
IN UINT32 *Cid
);
#endif

View File

@ -38,8 +38,9 @@ MmcGetCardStatus (
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]);
}
@ -108,12 +109,14 @@ MmcStopTransmission (
{
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;
}
@ -143,18 +146,19 @@ MmcTransferBlock (
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__));
@ -194,9 +199,10 @@ MmcTransferBlock (
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,6 +226,7 @@ MmcTransferBlock (
DEBUG ((DEBUG_ERROR, "MmcIoBlocks() : Error MmcTransferState\n"));
return Status;
}
return Status;
}
@ -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;
}
@ -297,7 +305,6 @@ MmcIoBlocks (
RemainingBlock = BlockCount;
BytesRemainingToBeTransfered = BufferSize;
while (BytesRemainingToBeTransfered > 0) {
if (RemainingBlock <= MaxBlock) {
BlockCount = RemainingBlock;
} else {
@ -308,9 +315,10 @@ MmcIoBlocks (
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
Response[0] = 0;
Timeout = 20;
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);
@ -344,6 +352,7 @@ 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));

View File

@ -8,30 +8,33 @@
#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;
@ -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);
@ -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"));

View File

@ -84,16 +84,19 @@ EmmcGetDeviceState (
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;
}
@ -112,13 +115,14 @@ EmmcSetEXTCSD (
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);
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;
}
@ -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));
@ -258,16 +264,18 @@ InitializeEmmcDevice (
EFI_STATUS Status = EFI_SUCCESS;
ECSD *ECSDData;
UINT32 BusClockFreq, Idx, BusMode;
UINT32 TimingMode[4] = {EMMCHS52DDR1V2, EMMCHS52DDR1V8, EMMCHS52, EMMCHS26};
UINT32 TimingMode[4] = { EMMCHS52DDR1V2, EMMCHS52DDR1V8, EMMCHS52, EMMCHS26 };
Host = MmcHostInstance->MmcHost;
ECSDData = MmcHostInstance->CardInfo.ECSDData;
if (ECSDData->DEVICE_TYPE == EMMCBACKWARD)
return EFI_SUCCESS;
if (!MMC_HOST_HAS_SETIOS(Host)) {
if (ECSDData->DEVICE_TYPE == EMMCBACKWARD) {
return EFI_SUCCESS;
}
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));
@ -287,6 +295,7 @@ InitializeEmmcDevice (
default:
return EFI_UNSUPPORTED;
}
Status = Host->SetIos (Host, BusClockFreq, 8, TimingMode[Idx]);
if (!EFI_ERROR (Status)) {
switch (TimingMode[Idx]) {
@ -301,13 +310,16 @@ InitializeEmmcDevice (
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;
}
@ -353,18 +365,19 @@ InitializeSdMmcDevice (
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;
@ -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,6 +439,7 @@ 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) {
@ -451,9 +467,10 @@ InitializeSdMmcDevice (
}
}
}
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));
@ -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;
}
@ -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);
}
}
@ -610,6 +638,7 @@ MmcIdentificationMode (
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"));
@ -759,13 +795,13 @@ InitializeMmcDevice (
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;
}
}