mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-29 08:34:07 +02:00
ARM Packages: Fixed coding style and typos
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14179 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
8274521330
commit
6f711615ba
@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
|
* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials
|
* This program and the accompanying materials
|
||||||
* are licensed and made available under the terms and conditions of the BSD License
|
* are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -77,14 +77,14 @@ BdsGetDeviceUsb (
|
|||||||
// Get all the UsbIo handles
|
// Get all the UsbIo handles
|
||||||
UsbIoHandleCount = 0;
|
UsbIoHandleCount = 0;
|
||||||
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiUsbIoProtocolGuid, NULL, &UsbIoHandleCount, &UsbIoBuffer);
|
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiUsbIoProtocolGuid, NULL, &UsbIoHandleCount, &UsbIoBuffer);
|
||||||
if (EFI_ERROR(Status) || (UsbIoHandleCount == 0)) {
|
if (EFI_ERROR (Status) || (UsbIoHandleCount == 0)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if one of the handles matches the USB description
|
// Check if one of the handles matches the USB description
|
||||||
for (Index = 0; Index < UsbIoHandleCount; Index++) {
|
for (Index = 0; Index < UsbIoHandleCount; Index++) {
|
||||||
Status = gBS->HandleProtocol (UsbIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **) &UsbIoDevicePath);
|
Status = gBS->HandleProtocol (UsbIoBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **) &UsbIoDevicePath);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
TmpDevicePath = UsbIoDevicePath;
|
TmpDevicePath = UsbIoDevicePath;
|
||||||
while (!IsDevicePathEnd (TmpDevicePath)) {
|
while (!IsDevicePathEnd (TmpDevicePath)) {
|
||||||
// Check if the Device Path node is a USB Removable device Path node
|
// Check if the Device Path node is a USB Removable device Path node
|
||||||
@ -94,11 +94,11 @@ BdsGetDeviceUsb (
|
|||||||
WwidDevicePath2 = (USB_WWID_DEVICE_PATH*)TmpDevicePath;
|
WwidDevicePath2 = (USB_WWID_DEVICE_PATH*)TmpDevicePath;
|
||||||
if ((WwidDevicePath1->VendorId == WwidDevicePath2->VendorId) &&
|
if ((WwidDevicePath1->VendorId == WwidDevicePath2->VendorId) &&
|
||||||
(WwidDevicePath1->ProductId == WwidDevicePath2->ProductId) &&
|
(WwidDevicePath1->ProductId == WwidDevicePath2->ProductId) &&
|
||||||
(CompareMem (WwidDevicePath1+1, WwidDevicePath2+1, DevicePathNodeLength(WwidDevicePath1)-sizeof(USB_WWID_DEVICE_PATH)) == 0))
|
(CompareMem (WwidDevicePath1+1, WwidDevicePath2+1, DevicePathNodeLength(WwidDevicePath1)-sizeof (USB_WWID_DEVICE_PATH)) == 0))
|
||||||
{
|
{
|
||||||
*DeviceHandle = UsbIoBuffer[Index];
|
*DeviceHandle = UsbIoBuffer[Index];
|
||||||
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path
|
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path
|
||||||
*NewDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePathNode(RemovableDevicePath));
|
*NewDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePathNode (RemovableDevicePath));
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -112,7 +112,7 @@ BdsGetDeviceUsb (
|
|||||||
{
|
{
|
||||||
*DeviceHandle = UsbIoBuffer[Index];
|
*DeviceHandle = UsbIoBuffer[Index];
|
||||||
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path
|
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path
|
||||||
*NewDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePathNode(RemovableDevicePath));
|
*NewDevicePath = AppendDevicePath (UsbIoDevicePath, NextDevicePathNode (RemovableDevicePath));
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ BdsIsRemovableHd (
|
|||||||
IN EFI_DEVICE_PATH* DevicePath
|
IN EFI_DEVICE_PATH* DevicePath
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return IS_DEVICE_PATH_NODE(DevicePath, MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP);
|
return IS_DEVICE_PATH_NODE (DevicePath, MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -153,14 +153,14 @@ BdsGetDeviceHd (
|
|||||||
// Get all the DiskIo handles
|
// Get all the DiskIo handles
|
||||||
PartitionHandleCount = 0;
|
PartitionHandleCount = 0;
|
||||||
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiDiskIoProtocolGuid, NULL, &PartitionHandleCount, &PartitionBuffer);
|
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiDiskIoProtocolGuid, NULL, &PartitionHandleCount, &PartitionBuffer);
|
||||||
if (EFI_ERROR(Status) || (PartitionHandleCount == 0)) {
|
if (EFI_ERROR (Status) || (PartitionHandleCount == 0)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if one of the handles matches the Hard Disk Description
|
// Check if one of the handles matches the Hard Disk Description
|
||||||
for (Index = 0; Index < PartitionHandleCount; Index++) {
|
for (Index = 0; Index < PartitionHandleCount; Index++) {
|
||||||
Status = gBS->HandleProtocol (PartitionBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **) &PartitionDevicePath);
|
Status = gBS->HandleProtocol (PartitionBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **) &PartitionDevicePath);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
TmpDevicePath = PartitionDevicePath;
|
TmpDevicePath = PartitionDevicePath;
|
||||||
while (!IsDevicePathEnd (TmpDevicePath)) {
|
while (!IsDevicePathEnd (TmpDevicePath)) {
|
||||||
// Check if the Device Path node is a HD Removable device Path node
|
// Check if the Device Path node is a HD Removable device Path node
|
||||||
@ -168,12 +168,12 @@ BdsGetDeviceHd (
|
|||||||
HardDriveDevicePath1 = (HARDDRIVE_DEVICE_PATH*)RemovableDevicePath;
|
HardDriveDevicePath1 = (HARDDRIVE_DEVICE_PATH*)RemovableDevicePath;
|
||||||
HardDriveDevicePath2 = (HARDDRIVE_DEVICE_PATH*)TmpDevicePath;
|
HardDriveDevicePath2 = (HARDDRIVE_DEVICE_PATH*)TmpDevicePath;
|
||||||
if ((HardDriveDevicePath1->SignatureType == HardDriveDevicePath2->SignatureType) &&
|
if ((HardDriveDevicePath1->SignatureType == HardDriveDevicePath2->SignatureType) &&
|
||||||
(CompareGuid ((EFI_GUID *)HardDriveDevicePath1->Signature,(EFI_GUID *)HardDriveDevicePath2->Signature) == TRUE) &&
|
(CompareGuid ((EFI_GUID *)HardDriveDevicePath1->Signature, (EFI_GUID *)HardDriveDevicePath2->Signature) == TRUE) &&
|
||||||
(HardDriveDevicePath1->PartitionNumber == HardDriveDevicePath2->PartitionNumber))
|
(HardDriveDevicePath1->PartitionNumber == HardDriveDevicePath2->PartitionNumber))
|
||||||
{
|
{
|
||||||
*DeviceHandle = PartitionBuffer[Index];
|
*DeviceHandle = PartitionBuffer[Index];
|
||||||
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path
|
// Add the additional original Device Path Nodes (eg: FilePath Device Path Node) to the new Device Path
|
||||||
*NewDevicePath = AppendDevicePath (PartitionDevicePath, NextDevicePathNode(RemovableDevicePath));
|
*NewDevicePath = AppendDevicePath (PartitionDevicePath, NextDevicePathNode (RemovableDevicePath));
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ BdsIsRemovableCdrom (
|
|||||||
IN EFI_DEVICE_PATH* DevicePath
|
IN EFI_DEVICE_PATH* DevicePath
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return IS_DEVICE_PATH_NODE(DevicePath, MEDIA_DEVICE_PATH, MEDIA_CDROM_DP);
|
return IS_DEVICE_PATH_NODE (DevicePath, MEDIA_DEVICE_PATH, MEDIA_CDROM_DP);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -239,8 +239,8 @@ IsRemovableDevice (
|
|||||||
|
|
||||||
TmpDevicePath = DevicePath;
|
TmpDevicePath = DevicePath;
|
||||||
while (!IsDevicePathEnd (TmpDevicePath)) {
|
while (!IsDevicePathEnd (TmpDevicePath)) {
|
||||||
for (Index = 0; Index < sizeof(RemovableDeviceSupport) / sizeof(BDS_REMOVABLE_DEVICE_SUPPORT); Index++) {
|
for (Index = 0; Index < sizeof (RemovableDeviceSupport) / sizeof (BDS_REMOVABLE_DEVICE_SUPPORT); Index++) {
|
||||||
if (RemovableDeviceSupport[Index].IsRemovable(TmpDevicePath)) {
|
if (RemovableDeviceSupport[Index].IsRemovable (TmpDevicePath)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,9 +271,9 @@ TryRemovableDevice (
|
|||||||
TmpDevicePath = DevicePath;
|
TmpDevicePath = DevicePath;
|
||||||
|
|
||||||
while (!IsDevicePathEnd (TmpDevicePath) && !RemovableFound) {
|
while (!IsDevicePathEnd (TmpDevicePath) && !RemovableFound) {
|
||||||
for (Index = 0; Index < sizeof(RemovableDeviceSupport) / sizeof(BDS_REMOVABLE_DEVICE_SUPPORT); Index++) {
|
for (Index = 0; Index < sizeof (RemovableDeviceSupport) / sizeof (BDS_REMOVABLE_DEVICE_SUPPORT); Index++) {
|
||||||
RemovableDevice = &RemovableDeviceSupport[Index];
|
RemovableDevice = &RemovableDeviceSupport[Index];
|
||||||
if (RemovableDevice->IsRemovable(TmpDevicePath)) {
|
if (RemovableDevice->IsRemovable (TmpDevicePath)) {
|
||||||
RemovableDevicePath = TmpDevicePath;
|
RemovableDevicePath = TmpDevicePath;
|
||||||
RemovableFound = TRUE;
|
RemovableFound = TRUE;
|
||||||
break;
|
break;
|
||||||
@ -338,7 +338,7 @@ BdsConnectDevicePath (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*// We need to check if RemainingDevicePath does not point on the last node. Otherwise, calling
|
/*// We need to check if RemainingDevicePath does not point on the last node. Otherwise, calling
|
||||||
// NextDevicePathNode() will return an undetermined Device Path Node
|
// NextDevicePathNode () will return an undetermined Device Path Node
|
||||||
if (!IsDevicePathEnd (RemainingDevicePath)) {
|
if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||||
RemainingDevicePath = NextDevicePathNode (RemainingDevicePath);
|
RemainingDevicePath = NextDevicePathNode (RemainingDevicePath);
|
||||||
}*/
|
}*/
|
||||||
@ -348,7 +348,7 @@ BdsConnectDevicePath (
|
|||||||
// Now, we have got the whole Device Path connected, call again ConnectController to ensure all the supported Driver
|
// Now, we have got the whole Device Path connected, call again ConnectController to ensure all the supported Driver
|
||||||
// Binding Protocol are connected (such as DiskIo and SimpleFileSystem)
|
// Binding Protocol are connected (such as DiskIo and SimpleFileSystem)
|
||||||
Remaining = DevicePath;
|
Remaining = DevicePath;
|
||||||
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid,&Remaining,Handle);
|
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &Remaining, Handle);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE);
|
Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -393,9 +393,9 @@ BdsFileSystemSupport (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FsProtocol;
|
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FsProtocol;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol (Handle,&gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol);
|
Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol);
|
||||||
|
|
||||||
return (!EFI_ERROR(Status) && IS_DEVICE_PATH_NODE(RemainingDevicePath,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP));
|
return (!EFI_ERROR (Status) && IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP));
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -416,32 +416,32 @@ BdsFileSystemLoadImage (
|
|||||||
EFI_FILE_PROTOCOL *File;
|
EFI_FILE_PROTOCOL *File;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
|
|
||||||
ASSERT (IS_DEVICE_PATH_NODE(RemainingDevicePath,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP));
|
ASSERT (IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP));
|
||||||
|
|
||||||
FilePathDevicePath = (FILEPATH_DEVICE_PATH*)RemainingDevicePath;
|
FilePathDevicePath = (FILEPATH_DEVICE_PATH*)RemainingDevicePath;
|
||||||
|
|
||||||
Status = gBS->HandleProtocol(Handle,&gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol);
|
Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FsProtocol);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to Open the volume and get root directory
|
// Try to Open the volume and get root directory
|
||||||
Status = FsProtocol->OpenVolume (FsProtocol, &Fs);
|
Status = FsProtocol->OpenVolume (FsProtocol, &Fs);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
File = NULL;
|
File = NULL;
|
||||||
Status = Fs->Open(Fs, &File, FilePathDevicePath->PathName, EFI_FILE_MODE_READ, 0);
|
Status = Fs->Open (Fs, &File, FilePathDevicePath->PathName, EFI_FILE_MODE_READ, 0);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size = 0;
|
Size = 0;
|
||||||
File->GetInfo(File, &gEfiFileInfoGuid, &Size, NULL);
|
File->GetInfo (File, &gEfiFileInfoGuid, &Size, NULL);
|
||||||
FileInfo = AllocatePool (Size);
|
FileInfo = AllocatePool (Size);
|
||||||
Status = File->GetInfo(File, &gEfiFileInfoGuid, &Size, FileInfo);
|
Status = File->GetInfo (File, &gEfiFileInfoGuid, &Size, FileInfo);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,14 +450,14 @@ BdsFileSystemLoadImage (
|
|||||||
if (ImageSize) {
|
if (ImageSize) {
|
||||||
*ImageSize = Size;
|
*ImageSize = Size;
|
||||||
}
|
}
|
||||||
FreePool(FileInfo);
|
FreePool (FileInfo);
|
||||||
|
|
||||||
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
|
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
|
||||||
// Try to allocate in any pages if failed to allocate memory at the defined location
|
// Try to allocate in any pages if failed to allocate memory at the defined location
|
||||||
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
|
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
|
||||||
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
|
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = File->Read (File, &Size, (VOID*)(UINTN)(*Image));
|
Status = File->Read (File, &Size, (VOID*)(UINTN)(*Image));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,8 +471,8 @@ BdsMemoryMapSupport (
|
|||||||
IN EFI_DEVICE_PATH *RemainingDevicePath
|
IN EFI_DEVICE_PATH *RemainingDevicePath
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return IS_DEVICE_PATH_NODE(DevicePath,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP) ||
|
return IS_DEVICE_PATH_NODE (DevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP) ||
|
||||||
IS_DEVICE_PATH_NODE(RemainingDevicePath,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP);
|
IS_DEVICE_PATH_NODE (RemainingDevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -489,10 +489,10 @@ BdsMemoryMapLoadImage (
|
|||||||
MEMMAP_DEVICE_PATH* MemMapPathDevicePath;
|
MEMMAP_DEVICE_PATH* MemMapPathDevicePath;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
|
|
||||||
if (IS_DEVICE_PATH_NODE(RemainingDevicePath,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP)) {
|
if (IS_DEVICE_PATH_NODE (RemainingDevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP)) {
|
||||||
MemMapPathDevicePath = (MEMMAP_DEVICE_PATH*)RemainingDevicePath;
|
MemMapPathDevicePath = (MEMMAP_DEVICE_PATH*)RemainingDevicePath;
|
||||||
} else {
|
} else {
|
||||||
ASSERT (IS_DEVICE_PATH_NODE(DevicePath,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP));
|
ASSERT (IS_DEVICE_PATH_NODE (DevicePath, HARDWARE_DEVICE_PATH, HW_MEMMAP_DP));
|
||||||
MemMapPathDevicePath = (MEMMAP_DEVICE_PATH*)DevicePath;
|
MemMapPathDevicePath = (MEMMAP_DEVICE_PATH*)DevicePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +506,7 @@ BdsMemoryMapLoadImage (
|
|||||||
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
|
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
|
||||||
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
|
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CopyMem ((VOID*)(UINTN)(*Image), (CONST VOID*)(UINTN)MemMapPathDevicePath->StartingAddress, Size);
|
CopyMem ((VOID*)(UINTN)(*Image), (CONST VOID*)(UINTN)MemMapPathDevicePath->StartingAddress, Size);
|
||||||
|
|
||||||
if (ImageSize != NULL) {
|
if (ImageSize != NULL) {
|
||||||
@ -524,7 +524,7 @@ BdsFirmwareVolumeSupport (
|
|||||||
IN EFI_DEVICE_PATH *RemainingDevicePath
|
IN EFI_DEVICE_PATH *RemainingDevicePath
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return IS_DEVICE_PATH_NODE(RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP);
|
return IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP);
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -546,10 +546,10 @@ BdsFirmwareVolumeLoadImage (
|
|||||||
UINT32 AuthenticationStatus;
|
UINT32 AuthenticationStatus;
|
||||||
VOID* ImageBuffer;
|
VOID* ImageBuffer;
|
||||||
|
|
||||||
ASSERT (IS_DEVICE_PATH_NODE(RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP));
|
ASSERT (IS_DEVICE_PATH_NODE (RemainingDevicePath, MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP));
|
||||||
|
|
||||||
Status = gBS->HandleProtocol(Handle,&gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FwVol);
|
Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolume2ProtocolGuid, (VOID **)&FwVol);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +576,7 @@ BdsFirmwareVolumeLoadImage (
|
|||||||
// In case the buffer has some address requirements, we must copy the buffer to a buffer following the requirements
|
// In case the buffer has some address requirements, we must copy the buffer to a buffer following the requirements
|
||||||
if (Type != AllocateAnyPages) {
|
if (Type != AllocateAnyPages) {
|
||||||
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize),Image);
|
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize),Image);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize);
|
CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize);
|
||||||
FreePool (ImageBuffer);
|
FreePool (ImageBuffer);
|
||||||
}
|
}
|
||||||
@ -588,7 +588,7 @@ BdsFirmwareVolumeLoadImage (
|
|||||||
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
|
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
|
||||||
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);
|
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize);
|
CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize);
|
||||||
FreePool (ImageBuffer);
|
FreePool (ImageBuffer);
|
||||||
}
|
}
|
||||||
@ -604,13 +604,13 @@ BdsFirmwareVolumeLoadImage (
|
|||||||
&Attrib,
|
&Attrib,
|
||||||
&AuthenticationStatus
|
&AuthenticationStatus
|
||||||
);
|
);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);
|
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);
|
||||||
// Try to allocate in any pages if failed to allocate memory at the defined location
|
// Try to allocate in any pages if failed to allocate memory at the defined location
|
||||||
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
|
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
|
||||||
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);
|
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);
|
||||||
}
|
}
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = FwVol->ReadFile (
|
Status = FwVol->ReadFile (
|
||||||
FwVol,
|
FwVol,
|
||||||
FvNameGuid,
|
FvNameGuid,
|
||||||
@ -636,7 +636,7 @@ BdsPxeSupport (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_PXE_BASE_CODE_PROTOCOL* PxeBcProtocol;
|
EFI_PXE_BASE_CODE_PROTOCOL* PxeBcProtocol;
|
||||||
|
|
||||||
if (!IsDevicePathEnd(RemainingDevicePath)) {
|
if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,12 +671,12 @@ BdsPxeLoadImage (
|
|||||||
Status = LoadFileProtocol->LoadFile (LoadFileProtocol, DevicePath, TRUE, &BufferSize, NULL);
|
Status = LoadFileProtocol->LoadFile (LoadFileProtocol, DevicePath, TRUE, &BufferSize, NULL);
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(BufferSize), Image);
|
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(BufferSize), Image);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = LoadFileProtocol->LoadFile (LoadFileProtocol, DevicePath, TRUE, &BufferSize, (VOID*)(UINTN)(*Image));
|
Status = LoadFileProtocol->LoadFile (LoadFileProtocol, DevicePath, TRUE, &BufferSize, (VOID*)(UINTN)(*Image));
|
||||||
if (!EFI_ERROR(Status) && (ImageSize != NULL)) {
|
if (!EFI_ERROR (Status) && (ImageSize != NULL)) {
|
||||||
*ImageSize = BufferSize;
|
*ImageSize = BufferSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -696,18 +696,18 @@ BdsTftpSupport (
|
|||||||
EFI_PXE_BASE_CODE_PROTOCOL *PxeBcProtocol;
|
EFI_PXE_BASE_CODE_PROTOCOL *PxeBcProtocol;
|
||||||
|
|
||||||
// Validate the Remaining Device Path
|
// Validate the Remaining Device Path
|
||||||
if (IsDevicePathEnd(RemainingDevicePath)) {
|
if (IsDevicePathEnd (RemainingDevicePath)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!IS_DEVICE_PATH_NODE(RemainingDevicePath,MESSAGING_DEVICE_PATH,MSG_IPv4_DP) &&
|
if (!IS_DEVICE_PATH_NODE (RemainingDevicePath, MESSAGING_DEVICE_PATH, MSG_IPv4_DP) &&
|
||||||
!IS_DEVICE_PATH_NODE(RemainingDevicePath,MESSAGING_DEVICE_PATH,MSG_IPv6_DP)) {
|
!IS_DEVICE_PATH_NODE (RemainingDevicePath, MESSAGING_DEVICE_PATH, MSG_IPv6_DP)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
NextDevicePath = NextDevicePathNode (RemainingDevicePath);
|
NextDevicePath = NextDevicePathNode (RemainingDevicePath);
|
||||||
if (IsDevicePathEnd(NextDevicePath)) {
|
if (IsDevicePathEnd (NextDevicePath)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!IS_DEVICE_PATH_NODE(NextDevicePath,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP)) {
|
if (!IS_DEVICE_PATH_NODE (NextDevicePath, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,18 +738,18 @@ BdsTftpLoadImage (
|
|||||||
FILEPATH_DEVICE_PATH* FilePathDevicePath;
|
FILEPATH_DEVICE_PATH* FilePathDevicePath;
|
||||||
EFI_IP_ADDRESS LocalIp;
|
EFI_IP_ADDRESS LocalIp;
|
||||||
|
|
||||||
ASSERT(IS_DEVICE_PATH_NODE(RemainingDevicePath,MESSAGING_DEVICE_PATH,MSG_IPv4_DP));
|
ASSERT(IS_DEVICE_PATH_NODE (RemainingDevicePath, MESSAGING_DEVICE_PATH, MSG_IPv4_DP));
|
||||||
|
|
||||||
IPv4DevicePathNode = (IPv4_DEVICE_PATH*)RemainingDevicePath;
|
IPv4DevicePathNode = (IPv4_DEVICE_PATH*)RemainingDevicePath;
|
||||||
FilePathDevicePath = (FILEPATH_DEVICE_PATH*)(IPv4DevicePathNode + 1);
|
FilePathDevicePath = (FILEPATH_DEVICE_PATH*)(IPv4DevicePathNode + 1);
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
Status = gBS->LocateProtocol (&gEfiPxeBaseCodeProtocolGuid, NULL, (VOID **)&Pxe);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Pxe->Start (Pxe, FALSE);
|
Status = Pxe->Start (Pxe, FALSE);
|
||||||
if (EFI_ERROR(Status) && (Status != EFI_ALREADY_STARTED)) {
|
if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,7 +759,7 @@ BdsTftpLoadImage (
|
|||||||
CopyMem (&LocalIp.v4, &IPv4DevicePathNode->LocalIpAddress, sizeof (EFI_IPv4_ADDRESS));
|
CopyMem (&LocalIp.v4, &IPv4DevicePathNode->LocalIpAddress, sizeof (EFI_IPv4_ADDRESS));
|
||||||
Status = Pxe->SetStationIp (Pxe, &LocalIp, NULL);
|
Status = Pxe->SetStationIp (Pxe, &LocalIp, NULL);
|
||||||
}
|
}
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,12 +777,12 @@ BdsTftpLoadImage (
|
|||||||
NULL,
|
NULL,
|
||||||
TRUE
|
TRUE
|
||||||
);
|
);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a buffer to hold the whole file.
|
// Allocate a buffer to hold the whole file.
|
||||||
TftpBuffer = AllocatePool(TftpBufferSize);
|
TftpBuffer = AllocatePool (TftpBufferSize);
|
||||||
if (TftpBuffer == NULL) {
|
if (TftpBuffer == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -799,8 +799,8 @@ BdsTftpLoadImage (
|
|||||||
NULL,
|
NULL,
|
||||||
FALSE
|
FALSE
|
||||||
);
|
);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
FreePool(TftpBuffer);
|
FreePool (TftpBuffer);
|
||||||
} else if (ImageSize != NULL) {
|
} else if (ImageSize != NULL) {
|
||||||
*ImageSize = (UINTN)TftpBufferSize;
|
*ImageSize = (UINTN)TftpBufferSize;
|
||||||
}
|
}
|
||||||
@ -874,20 +874,20 @@ BdsStartEfiApplication (
|
|||||||
|
|
||||||
// Find the nearest supported file loader
|
// Find the nearest supported file loader
|
||||||
Status = BdsLoadImage (DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize);
|
Status = BdsLoadImage (DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the image from the Buffer with Boot Services function
|
// Load the image from the Buffer with Boot Services function
|
||||||
Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, (VOID*)(UINTN)BinaryBuffer, BinarySize, &ImageHandle);
|
Status = gBS->LoadImage (TRUE, ParentImageHandle, DevicePath, (VOID*)(UINTN)BinaryBuffer, BinarySize, &ImageHandle);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Passed LoadOptions to the EFI Application
|
// Passed LoadOptions to the EFI Application
|
||||||
if (LoadOptionsSize != 0) {
|
if (LoadOptionsSize != 0) {
|
||||||
Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
|
Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ PrimaryMain (
|
|||||||
CreatePpiList (&PpiListSize, &PpiList);
|
CreatePpiList (&PpiListSize, &PpiList);
|
||||||
|
|
||||||
// Enable the GIC Distributor
|
// Enable the GIC Distributor
|
||||||
ArmGicEnableDistributor(PcdGet32(PcdGicDistributorBase));
|
ArmGicEnableDistributor (PcdGet32(PcdGicDistributorBase));
|
||||||
|
|
||||||
// If ArmVe has not been built as Standalone then we need to wake up the secondary cores
|
// If ArmVe has not been built as Standalone then we need to wake up the secondary cores
|
||||||
if (FeaturePcdGet (PcdSendSgiToBringUpSecondaryCores)) {
|
if (FeaturePcdGet (PcdSendSgiToBringUpSecondaryCores)) {
|
||||||
@ -155,5 +155,5 @@ PrimaryMain (
|
|||||||
SecCoreData.StackSize = (TemporaryRamBase + TemporaryRamSize) - (UINTN)SecCoreData.StackBase;
|
SecCoreData.StackSize = (TemporaryRamBase + TemporaryRamSize) - (UINTN)SecCoreData.StackBase;
|
||||||
|
|
||||||
// Jump to PEI core entry point
|
// Jump to PEI core entry point
|
||||||
(PeiCoreEntryPoint)(&SecCoreData, PpiList);
|
PeiCoreEntryPoint (&SecCoreData, PpiList);
|
||||||
}
|
}
|
||||||
|
@ -35,20 +35,20 @@ CEntryPoint (
|
|||||||
UINTN JumpAddress;
|
UINTN JumpAddress;
|
||||||
|
|
||||||
// Invalidate the data cache. Doesn't have to do the Data cache clean.
|
// Invalidate the data cache. Doesn't have to do the Data cache clean.
|
||||||
ArmInvalidateDataCache();
|
ArmInvalidateDataCache ();
|
||||||
|
|
||||||
// Invalidate Instruction Cache
|
// Invalidate Instruction Cache
|
||||||
ArmInvalidateInstructionCache();
|
ArmInvalidateInstructionCache ();
|
||||||
|
|
||||||
// Invalidate I & D TLBs
|
// Invalidate I & D TLBs
|
||||||
ArmInvalidateInstructionAndDataTlb();
|
ArmInvalidateInstructionAndDataTlb ();
|
||||||
|
|
||||||
// CPU specific settings
|
// CPU specific settings
|
||||||
ArmCpuSetup (MpId);
|
ArmCpuSetup (MpId);
|
||||||
|
|
||||||
// Enable Floating Point Coprocessor if supported by the platform
|
// Enable Floating Point Coprocessor if supported by the platform
|
||||||
if (FixedPcdGet32 (PcdVFPEnabled)) {
|
if (FixedPcdGet32 (PcdVFPEnabled)) {
|
||||||
ArmEnableVFP();
|
ArmEnableVFP ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize peripherals that must be done at the early stage
|
// Initialize peripherals that must be done at the early stage
|
||||||
@ -95,7 +95,7 @@ CEntryPoint (
|
|||||||
|
|
||||||
// Test if Trustzone is supported on this platform
|
// Test if Trustzone is supported on this platform
|
||||||
if (FixedPcdGetBool (PcdTrustzoneSupport)) {
|
if (FixedPcdGetBool (PcdTrustzoneSupport)) {
|
||||||
if (ArmIsMpCore()) {
|
if (ArmIsMpCore ()) {
|
||||||
// Setup SMP in Non Secure world
|
// Setup SMP in Non Secure world
|
||||||
ArmCpuSetupSmpNonSecure (GET_CORE_ID(MpId));
|
ArmCpuSetupSmpNonSecure (GET_CORE_ID(MpId));
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ MaxEfiException (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return sizeof (gExceptionType)/sizeof (EFI_EXCEPTION_TYPE_ENTRY);
|
return sizeof (gExceptionType) / sizeof (EFI_EXCEPTION_TYPE_ENTRY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ MaxRegisterCount (
|
|||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return sizeof (gRegisterOffsets)/sizeof (UINTN);
|
return sizeof (gRegisterOffsets) / sizeof (UINTN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ CheckIsa (
|
|||||||
@retval the pointer to the RegNumber-th pointer
|
@retval the pointer to the RegNumber-th pointer
|
||||||
**/
|
**/
|
||||||
UINTN *
|
UINTN *
|
||||||
FindPointerToRegister(
|
FindPointerToRegister (
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||||
IN UINTN RegNumber
|
IN UINTN RegNumber
|
||||||
)
|
)
|
||||||
@ -170,20 +170,20 @@ BasicReadRegister (
|
|||||||
CHAR8 Char;
|
CHAR8 Char;
|
||||||
|
|
||||||
if (gRegisterOffsets[RegNumber] > 0xF00) {
|
if (gRegisterOffsets[RegNumber] > 0xF00) {
|
||||||
AsciiSPrint(OutBufPtr, 9, "00000000");
|
AsciiSPrint (OutBufPtr, 9, "00000000");
|
||||||
OutBufPtr += 8;
|
OutBufPtr += 8;
|
||||||
return OutBufPtr;
|
return OutBufPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegSize = 0;
|
RegSize = 0;
|
||||||
while (RegSize < 32) {
|
while (RegSize < 32) {
|
||||||
Char = mHexToStr[(UINT8)((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
|
Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
|
||||||
if ((Char >= 'A') && (Char <= 'F')) {
|
if ((Char >= 'A') && (Char <= 'F')) {
|
||||||
Char = Char - 'A' + 'a';
|
Char = Char - 'A' + 'a';
|
||||||
}
|
}
|
||||||
*OutBufPtr++ = Char;
|
*OutBufPtr++ = Char;
|
||||||
|
|
||||||
Char = mHexToStr[(UINT8)((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
|
Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
|
||||||
if ((Char >= 'A') && (Char <= 'F')) {
|
if ((Char >= 'A') && (Char <= 'F')) {
|
||||||
Char = Char - 'A' + 'a';
|
Char = Char - 'A' + 'a';
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ ReadNthRegister (
|
|||||||
|
|
||||||
RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
|
RegNumber = AsciiStrHexToUintn (&InBuffer[1]);
|
||||||
|
|
||||||
if (RegNumber >= MaxRegisterCount()) {
|
if (RegNumber >= MaxRegisterCount ()) {
|
||||||
SendError (GDB_EINVALIDREGNUM);
|
SendError (GDB_EINVALIDREGNUM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ ReadNthRegister (
|
|||||||
OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
|
OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
|
||||||
|
|
||||||
*OutBufPtr = '\0'; // the end of the buffer
|
*OutBufPtr = '\0'; // the end of the buffer
|
||||||
SendPacket(OutBuffer);
|
SendPacket (OutBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -238,18 +238,18 @@ ReadGeneralRegisters (
|
|||||||
UINTN Index;
|
UINTN Index;
|
||||||
CHAR8 *OutBuffer;
|
CHAR8 *OutBuffer;
|
||||||
CHAR8 *OutBufPtr;
|
CHAR8 *OutBufPtr;
|
||||||
UINTN RegisterCount = MaxRegisterCount();
|
UINTN RegisterCount = MaxRegisterCount ();
|
||||||
|
|
||||||
// It is not safe to allocate pool here....
|
// It is not safe to allocate pool here....
|
||||||
OutBuffer = AllocatePool((RegisterCount * 8) + 1); // 8 bytes per register in string format plus a null to terminate
|
OutBuffer = AllocatePool ((RegisterCount * 8) + 1); // 8 bytes per register in string format plus a null to terminate
|
||||||
OutBufPtr = OutBuffer;
|
OutBufPtr = OutBuffer;
|
||||||
for (Index = 0; Index < RegisterCount; Index++) {
|
for (Index = 0; Index < RegisterCount; Index++) {
|
||||||
OutBufPtr = BasicReadRegister (SystemContext, Index, OutBufPtr);
|
OutBufPtr = BasicReadRegister (SystemContext, Index, OutBufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
*OutBufPtr = '\0';
|
*OutBufPtr = '\0';
|
||||||
SendPacket(OutBuffer);
|
SendPacket (OutBuffer);
|
||||||
FreePool(OutBuffer);
|
FreePool (OutBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ CHAR8
|
|||||||
NewValue = 0;
|
NewValue = 0;
|
||||||
RegSize = 0;
|
RegSize = 0;
|
||||||
while (RegSize < 32) {
|
while (RegSize < 32) {
|
||||||
TempValue = HexCharToInt(*InBufPtr++);
|
TempValue = HexCharToInt (*InBufPtr++);
|
||||||
|
|
||||||
if ((INTN)TempValue < 0) {
|
if ((INTN)TempValue < 0) {
|
||||||
SendError (GDB_EBADMEMDATA);
|
SendError (GDB_EBADMEMDATA);
|
||||||
@ -286,7 +286,7 @@ CHAR8
|
|||||||
}
|
}
|
||||||
|
|
||||||
NewValue += (TempValue << (RegSize+4));
|
NewValue += (TempValue << (RegSize+4));
|
||||||
TempValue = HexCharToInt(*InBufPtr++);
|
TempValue = HexCharToInt (*InBufPtr++);
|
||||||
|
|
||||||
if ((INTN)TempValue < 0) {
|
if ((INTN)TempValue < 0) {
|
||||||
SendError (GDB_EBADMEMDATA);
|
SendError (GDB_EBADMEMDATA);
|
||||||
@ -296,7 +296,7 @@ CHAR8
|
|||||||
NewValue += (TempValue << RegSize);
|
NewValue += (TempValue << RegSize);
|
||||||
RegSize = RegSize + 8;
|
RegSize = RegSize + 8;
|
||||||
}
|
}
|
||||||
*(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
|
*(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
|
||||||
return InBufPtr;
|
return InBufPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ WriteNthRegister (
|
|||||||
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
|
RegNumber = AsciiStrHexToUintn (RegNumBuffer);
|
||||||
|
|
||||||
// check if this is a valid Register Number
|
// check if this is a valid Register Number
|
||||||
if (RegNumber >= MaxRegisterCount()) {
|
if (RegNumber >= MaxRegisterCount ()) {
|
||||||
SendError (GDB_EINVALIDREGNUM);
|
SendError (GDB_EINVALIDREGNUM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -353,11 +353,11 @@ WriteGeneralRegisters (
|
|||||||
UINTN i;
|
UINTN i;
|
||||||
CHAR8 *InBufPtr; /// pointer to the input buffer
|
CHAR8 *InBufPtr; /// pointer to the input buffer
|
||||||
UINTN MinLength;
|
UINTN MinLength;
|
||||||
UINTN RegisterCount = MaxRegisterCount();
|
UINTN RegisterCount = MaxRegisterCount ();
|
||||||
|
|
||||||
MinLength = (RegisterCount * 8) + 1; // 'G' plus the registers in ASCII format
|
MinLength = (RegisterCount * 8) + 1; // 'G' plus the registers in ASCII format
|
||||||
|
|
||||||
if (AsciiStrLen(InBuffer) < MinLength) {
|
if (AsciiStrLen (InBuffer) < MinLength) {
|
||||||
//Bad message. Message is not the right length
|
//Bad message. Message is not the right length
|
||||||
SendError (GDB_EBADBUFSIZE);
|
SendError (GDB_EBADBUFSIZE);
|
||||||
return;
|
return;
|
||||||
@ -367,7 +367,7 @@ WriteGeneralRegisters (
|
|||||||
|
|
||||||
// Read the new values for the registers from the input buffer to an array, NewValueArray.
|
// 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
|
// The values in the array are in the gdb ordering
|
||||||
for(i = 0; i < RegisterCount; i++) {
|
for (i = 0; i < RegisterCount; i++) {
|
||||||
InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
|
InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +421,7 @@ AddSingleStep (
|
|||||||
mSingleStepActive = FALSE;
|
mSingleStepActive = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateInstructionCacheRange((VOID *)mSingleStepPC, mSingleStepDataSize);
|
InvalidateInstructionCacheRange ((VOID *)mSingleStepPC, mSingleStepDataSize);
|
||||||
//DEBUG((EFI_D_ERROR, "AddSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, mSingleStepData, *(UINT32 *)mSingleStepPC));
|
//DEBUG((EFI_D_ERROR, "AddSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, mSingleStepData, *(UINT32 *)mSingleStepPC));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ RemoveSingleStep (
|
|||||||
//DEBUG((EFI_D_ERROR, "RemoveSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, *(UINT32 *)mSingleStepPC, mSingleStepData));
|
//DEBUG((EFI_D_ERROR, "RemoveSingleStep at 0x%08x (was: 0x%08x is:0x%08x)\n", SystemContext.SystemContextArm->PC, *(UINT32 *)mSingleStepPC, mSingleStepData));
|
||||||
*(UINT32 *)mSingleStepPC = mSingleStepData;
|
*(UINT32 *)mSingleStepPC = mSingleStepData;
|
||||||
}
|
}
|
||||||
InvalidateInstructionCacheRange((VOID *)mSingleStepPC, mSingleStepDataSize);
|
InvalidateInstructionCacheRange ((VOID *)mSingleStepPC, mSingleStepDataSize);
|
||||||
mSingleStepActive = FALSE;
|
mSingleStepActive = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +466,7 @@ ContinueAtAddress (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (PacketData[1] != '\0') {
|
if (PacketData[1] != '\0') {
|
||||||
SystemContext.SystemContextArm->PC = AsciiStrHexToUintn(&PacketData[1]);
|
SystemContext.SystemContextArm->PC = AsciiStrHexToUintn (&PacketData[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ SingleStep (
|
|||||||
IN CHAR8 *PacketData
|
IN CHAR8 *PacketData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
SendNotSupported();
|
SendNotSupported ();
|
||||||
}
|
}
|
||||||
|
|
||||||
UINTN
|
UINTN
|
||||||
@ -521,15 +521,15 @@ SearchBreakpointList (
|
|||||||
LIST_ENTRY *Current;
|
LIST_ENTRY *Current;
|
||||||
ARM_SOFTWARE_BREAKPOINT *Breakpoint;
|
ARM_SOFTWARE_BREAKPOINT *Breakpoint;
|
||||||
|
|
||||||
Current = GetFirstNode(&BreakpointList);
|
Current = GetFirstNode (&BreakpointList);
|
||||||
while (!IsNull(&BreakpointList, Current)) {
|
while (!IsNull (&BreakpointList, Current)) {
|
||||||
Breakpoint = ARM_SOFTWARE_BREAKPOINT_FROM_LINK(Current);
|
Breakpoint = ARM_SOFTWARE_BREAKPOINT_FROM_LINK(Current);
|
||||||
|
|
||||||
if (Address == Breakpoint->Address) {
|
if (Address == Breakpoint->Address) {
|
||||||
return Breakpoint;
|
return Breakpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
Current = GetNextNode(&BreakpointList, Current);
|
Current = GetNextNode (&BreakpointList, Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -542,25 +542,25 @@ SetBreakpoint (
|
|||||||
{
|
{
|
||||||
ARM_SOFTWARE_BREAKPOINT *Breakpoint;
|
ARM_SOFTWARE_BREAKPOINT *Breakpoint;
|
||||||
|
|
||||||
Breakpoint = SearchBreakpointList(Address);
|
Breakpoint = SearchBreakpointList (Address);
|
||||||
|
|
||||||
if (Breakpoint != NULL) {
|
if (Breakpoint != NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create and fill breakpoint structure
|
// create and fill breakpoint structure
|
||||||
Breakpoint = AllocatePool(sizeof(ARM_SOFTWARE_BREAKPOINT));
|
Breakpoint = AllocatePool (sizeof(ARM_SOFTWARE_BREAKPOINT));
|
||||||
|
|
||||||
Breakpoint->Signature = ARM_SOFTWARE_BREAKPOINT_SIGNATURE;
|
Breakpoint->Signature = ARM_SOFTWARE_BREAKPOINT_SIGNATURE;
|
||||||
Breakpoint->Address = Address;
|
Breakpoint->Address = Address;
|
||||||
Breakpoint->Instruction = *(UINT32 *)Address;
|
Breakpoint->Instruction = *(UINT32 *)Address;
|
||||||
|
|
||||||
// Add it to the list
|
// Add it to the list
|
||||||
InsertTailList(&BreakpointList, &Breakpoint->Link);
|
InsertTailList (&BreakpointList, &Breakpoint->Link);
|
||||||
|
|
||||||
// Insert the software breakpoint
|
// Insert the software breakpoint
|
||||||
*(UINT32 *)Address = GDB_ARM_BKPT;
|
*(UINT32 *)Address = GDB_ARM_BKPT;
|
||||||
InvalidateInstructionCacheRange((VOID *)Address, 4);
|
InvalidateInstructionCacheRange ((VOID *)Address, 4);
|
||||||
|
|
||||||
//DEBUG((EFI_D_ERROR, "SetBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, Breakpoint->Instruction, *(UINT32 *)Address));
|
//DEBUG((EFI_D_ERROR, "SetBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, Breakpoint->Instruction, *(UINT32 *)Address));
|
||||||
}
|
}
|
||||||
@ -572,22 +572,22 @@ ClearBreakpoint (
|
|||||||
{
|
{
|
||||||
ARM_SOFTWARE_BREAKPOINT *Breakpoint;
|
ARM_SOFTWARE_BREAKPOINT *Breakpoint;
|
||||||
|
|
||||||
Breakpoint = SearchBreakpointList(Address);
|
Breakpoint = SearchBreakpointList (Address);
|
||||||
|
|
||||||
if (Breakpoint == NULL) {
|
if (Breakpoint == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add it to the list
|
// Add it to the list
|
||||||
RemoveEntryList(&Breakpoint->Link);
|
RemoveEntryList (&Breakpoint->Link);
|
||||||
|
|
||||||
// Restore the original instruction
|
// Restore the original instruction
|
||||||
*(UINT32 *)Address = Breakpoint->Instruction;
|
*(UINT32 *)Address = Breakpoint->Instruction;
|
||||||
InvalidateInstructionCacheRange((VOID *)Address, 4);
|
InvalidateInstructionCacheRange ((VOID *)Address, 4);
|
||||||
|
|
||||||
//DEBUG((EFI_D_ERROR, "ClearBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, GDB_ARM_BKPT, *(UINT32 *)Address));
|
//DEBUG((EFI_D_ERROR, "ClearBreakpoint at 0x%08x (was: 0x%08x is:0x%08x)\n", Address, GDB_ARM_BKPT, *(UINT32 *)Address));
|
||||||
|
|
||||||
FreePool(Breakpoint);
|
FreePool (Breakpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
@ -602,7 +602,7 @@ InsertBreakPoint (
|
|||||||
UINTN Length;
|
UINTN Length;
|
||||||
UINTN ErrorCode;
|
UINTN ErrorCode;
|
||||||
|
|
||||||
ErrorCode = ParseBreakpointPacket(PacketData, &Type, &Address, &Length);
|
ErrorCode = ParseBreakpointPacket (PacketData, &Type, &Address, &Length);
|
||||||
if (ErrorCode > 0) {
|
if (ErrorCode > 0) {
|
||||||
SendError ((UINT8)ErrorCode);
|
SendError ((UINT8)ErrorCode);
|
||||||
return;
|
return;
|
||||||
@ -618,7 +618,7 @@ InsertBreakPoint (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetBreakpoint(Address);
|
SetBreakpoint (Address);
|
||||||
|
|
||||||
SendSuccess ();
|
SendSuccess ();
|
||||||
}
|
}
|
||||||
@ -651,7 +651,7 @@ RemoveBreakPoint (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearBreakpoint(Address);
|
ClearBreakpoint (Address);
|
||||||
|
|
||||||
SendSuccess ();
|
SendSuccess ();
|
||||||
}
|
}
|
||||||
@ -662,7 +662,7 @@ InitializeProcessor (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Initialize breakpoint list
|
// Initialize breakpoint list
|
||||||
InitializeListHead(&BreakpointList);
|
InitializeListHead (&BreakpointList);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
@ -75,7 +75,6 @@ GdbStubEntry (
|
|||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;
|
EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;
|
||||||
@ -85,7 +84,6 @@ GdbStubEntry (
|
|||||||
UINTN Processor;
|
UINTN Processor;
|
||||||
BOOLEAN IsaSupported;
|
BOOLEAN IsaSupported;
|
||||||
|
|
||||||
|
|
||||||
Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader);
|
Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
gDebugImageTableHeader = NULL;
|
gDebugImageTableHeader = NULL;
|
||||||
@ -136,10 +134,9 @@ GdbStubEntry (
|
|||||||
DEBUG ((EFI_D_INFO, "Debug Support Protocol Processor Index %d\n", gMaxProcessorIndex));
|
DEBUG ((EFI_D_INFO, "Debug Support Protocol Processor Index %d\n", gMaxProcessorIndex));
|
||||||
|
|
||||||
// Call processor-specific init routine
|
// Call processor-specific init routine
|
||||||
InitializeProcessor();
|
InitializeProcessor ();
|
||||||
|
|
||||||
for (Processor = 0; Processor <= gMaxProcessorIndex; Processor++) {
|
for (Processor = 0; Processor <= gMaxProcessorIndex; Processor++) {
|
||||||
|
|
||||||
for (Index = 0; Index < MaxEfiException (); Index++) {
|
for (Index = 0; Index < MaxEfiException (); Index++) {
|
||||||
Status = DebugSupport->RegisterExceptionCallback (DebugSupport, Processor, GdbExceptionHandler, gExceptionType[Index].Exception);
|
Status = DebugSupport->RegisterExceptionCallback (DebugSupport, Processor, GdbExceptionHandler, gExceptionType[Index].Exception);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
@ -165,7 +162,7 @@ GdbStubEntry (
|
|||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register for protocol notifactions on this event
|
// Register for protocol notifications on this event
|
||||||
//
|
//
|
||||||
Status = gBS->RegisterProtocolNotify (
|
Status = gBS->RegisterProtocolNotify (
|
||||||
&gEfiLoadedImageProtocolGuid,
|
&gEfiLoadedImageProtocolGuid,
|
||||||
@ -182,8 +179,6 @@ GdbStubEntry (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Transfer length bytes of input buffer, starting at Address, to memory.
|
Transfer length bytes of input buffer, starting at Address, to memory.
|
||||||
|
|
||||||
@ -490,7 +485,6 @@ SendNotSupported (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints
|
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints
|
||||||
|
|
||||||
@ -596,11 +590,11 @@ ConvertEFItoGDBtype (
|
|||||||
IN EFI_EXCEPTION_TYPE EFIExceptionType
|
IN EFI_EXCEPTION_TYPE EFIExceptionType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN i;
|
UINTN Index;
|
||||||
|
|
||||||
for (i=0; i < MaxEfiException() ; i++) {
|
for (Index = 0; Index < MaxEfiException () ; Index++) {
|
||||||
if (gExceptionType[i].Exception == EFIExceptionType) {
|
if (gExceptionType[Index].Exception == EFIExceptionType) {
|
||||||
return gExceptionType[i].SignalNo;
|
return gExceptionType[Index].SignalNo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GDB_SIGTRAP; // this is a GDB trap
|
return GDB_SIGTRAP; // this is a GDB trap
|
||||||
@ -635,14 +629,14 @@ ReadFromMemory (
|
|||||||
InBufPtr++; // this skips ',' in the buffer
|
InBufPtr++; // this skips ',' in the buffer
|
||||||
|
|
||||||
/* Error checking */
|
/* Error checking */
|
||||||
if (AsciiStrLen(AddressBuffer) >= MAX_ADDR_SIZE) {
|
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);
|
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2 = 'm' + ','
|
// 2 = 'm' + ','
|
||||||
if (AsciiStrLen(PacketData) - AsciiStrLen(AddressBuffer) - 2 >= MAX_LENGTH_SIZE) {
|
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);
|
SendError (GDB_EBADMEMLENGTH);
|
||||||
return;
|
return;
|
||||||
@ -699,14 +693,14 @@ WriteToMemory (
|
|||||||
/* Error checking */
|
/* Error checking */
|
||||||
|
|
||||||
//Check if Address is not too long.
|
//Check if Address is not too long.
|
||||||
if (AsciiStrLen(AddressBuffer) >= MAX_ADDR_SIZE) {
|
if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
|
||||||
Print ((CHAR16 *)L"Address too long..\n");
|
Print ((CHAR16 *)L"Address too long..\n");
|
||||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if message length is not too long
|
//Check if message length is not too long
|
||||||
if (AsciiStrLen(LengthBuffer) >= MAX_LENGTH_SIZE) {
|
if (AsciiStrLen (LengthBuffer) >= MAX_LENGTH_SIZE) {
|
||||||
Print ((CHAR16 *)L"Length too long..\n");
|
Print ((CHAR16 *)L"Length too long..\n");
|
||||||
SendError (GDB_EBADMEMLENGBUFSIZE);
|
SendError (GDB_EBADMEMLENGBUFSIZE);
|
||||||
return;
|
return;
|
||||||
@ -714,7 +708,7 @@ WriteToMemory (
|
|||||||
|
|
||||||
// Check if Message is not too long/short.
|
// Check if Message is not too long/short.
|
||||||
// 3 = 'M' + ',' + ':'
|
// 3 = 'M' + ',' + ':'
|
||||||
MessageLength = (AsciiStrLen(PacketData) - AsciiStrLen(AddressBuffer) - AsciiStrLen(LengthBuffer) - 3);
|
MessageLength = (AsciiStrLen (PacketData) - AsciiStrLen (AddressBuffer) - AsciiStrLen (LengthBuffer) - 3);
|
||||||
if (MessageLength != (2*Length)) {
|
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);
|
SendError (GDB_EBADMEMDATASIZE);
|
||||||
@ -770,7 +764,7 @@ ParseBreakpointPacket (
|
|||||||
*AddressBufferPtr = '\0';
|
*AddressBufferPtr = '\0';
|
||||||
|
|
||||||
//Check if Address is not too long.
|
//Check if Address is not too long.
|
||||||
if (AsciiStrLen(AddressBuffer) >= MAX_ADDR_SIZE) {
|
if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
|
||||||
Print ((CHAR16 *)L"Address too long..\n");
|
Print ((CHAR16 *)L"Address too long..\n");
|
||||||
return 40; //EMSGSIZE: Message size too long.
|
return 40; //EMSGSIZE: Message size too long.
|
||||||
}
|
}
|
||||||
@ -801,7 +795,7 @@ gXferObjectReadResponse (
|
|||||||
CHAR8 Char;
|
CHAR8 Char;
|
||||||
UINTN Count;
|
UINTN Count;
|
||||||
|
|
||||||
// responce starts with 'm' or 'l' if it is the end
|
// Response starts with 'm' or 'l' if it is the end
|
||||||
OutBufPtr = gOutBuffer;
|
OutBufPtr = gOutBuffer;
|
||||||
*OutBufPtr++ = Type;
|
*OutBufPtr++ = Type;
|
||||||
Count = 1;
|
Count = 1;
|
||||||
@ -989,12 +983,11 @@ PeCoffLoaderGetDebuggerInfo (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Process "qXfer:object:read:annex:offset,length" request.
|
Process "qXfer:object:read:annex:offset,length" request.
|
||||||
|
|
||||||
Returns an XML document that contains loaded libraries. In our case it is
|
Returns an XML document that contains loaded libraries. In our case it is
|
||||||
infomration in the EFI Debug Inmage Table converted into an XML document.
|
information in the EFI Debug Image Table converted into an XML document.
|
||||||
|
|
||||||
GDB will call with an arbitrary length (it can't know the real length and
|
GDB will call with an arbitrary length (it can't know the real length and
|
||||||
will reply with chunks of XML that are easy for us to deal with. Gdb will
|
will reply with chunks of XML that are easy for us to deal with. Gdb will
|
||||||
@ -1006,12 +999,12 @@ PeCoffLoaderGetDebuggerInfo (
|
|||||||
<library name="/a/l/f/f.dll"><segment address="0x30000000"/></library>
|
<library name="/a/l/f/f.dll"><segment address="0x30000000"/></library>
|
||||||
</library-list>
|
</library-list>
|
||||||
|
|
||||||
Since we can not allocate memory in interupt context this module has
|
Since we can not allocate memory in interrupt context this module has
|
||||||
assumptions about how it will get called:
|
assumptions about how it will get called:
|
||||||
1) Length will generally be max remote packet size (big enough)
|
1) Length will generally be max remote packet size (big enough)
|
||||||
2) First Offset of an XML document read needs to be 0
|
2) First Offset of an XML document read needs to be 0
|
||||||
3) This code will return back small chunks of the XML document on every read.
|
3) This code will return back small chunks of the XML document on every read.
|
||||||
Each subseqent call will ask for the next availble part of the document.
|
Each subsequent call will ask for the next available part of the document.
|
||||||
|
|
||||||
Note: The only variable size element in the XML is:
|
Note: The only variable size element in the XML is:
|
||||||
" <library name=\"%s\"><segment address=\"%p\"/></library>\n" and it is
|
" <library name=\"%s\"><segment address=\"%p\"/></library>\n" and it is
|
||||||
@ -1039,6 +1032,7 @@ QxferLibrary (
|
|||||||
|
|
||||||
// Force a retry from the beginning
|
// Force a retry from the beginning
|
||||||
gPacketqXferLibraryOffset = 0;
|
gPacketqXferLibraryOffset = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1117,7 +1111,7 @@ GdbExceptionHandler (
|
|||||||
CHAR8 *Ptr;
|
CHAR8 *Ptr;
|
||||||
|
|
||||||
|
|
||||||
if (ValidateException(ExceptionType, SystemContext) == FALSE) {
|
if (ValidateException (ExceptionType, SystemContext) == FALSE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1254,7 +1248,7 @@ GdbPeriodicCallBack (
|
|||||||
if (gCtrlCBreakFlag) {
|
if (gCtrlCBreakFlag) {
|
||||||
//
|
//
|
||||||
// Update the context to force a single step trap when we exit the GDB
|
// Update the context to force a single step trap when we exit the GDB
|
||||||
// stub. This will trasfer control to GdbExceptionHandler () and let
|
// stub. This will transfer control to GdbExceptionHandler () and let
|
||||||
// us break into the program. We don't want to break into the GDB stub.
|
// us break into the program. We don't want to break into the GDB stub.
|
||||||
//
|
//
|
||||||
AddSingleStep (SystemContext);
|
AddSingleStep (SystemContext);
|
||||||
|
@ -63,7 +63,7 @@ extern CONST CHAR8 mHexToStr[];
|
|||||||
#define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)
|
#define GDB_SIGTRAP 5 // Trace Trap (Breakpoint and SingleStep)
|
||||||
#define GDB_SIGEMT 7 // Emulator Trap
|
#define GDB_SIGEMT 7 // Emulator Trap
|
||||||
#define GDB_SIGFPE 8 // Floating point exception
|
#define GDB_SIGFPE 8 // Floating point exception
|
||||||
#define GDB_SIGSEGV 11 // Setgment violation, page fault
|
#define GDB_SIGSEGV 11 // Segment violation, page fault
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -147,7 +147,7 @@ CheckIsa (
|
|||||||
@retval the pointer to the RegNumber-th pointer
|
@retval the pointer to the RegNumber-th pointer
|
||||||
**/
|
**/
|
||||||
UINTN *
|
UINTN *
|
||||||
FindPointerToRegister(
|
FindPointerToRegister (
|
||||||
IN EFI_SYSTEM_CONTEXT SystemContext,
|
IN EFI_SYSTEM_CONTEXT SystemContext,
|
||||||
IN UINTN RegNumber
|
IN UINTN RegNumber
|
||||||
)
|
)
|
||||||
@ -177,8 +177,8 @@ BasicReadRegister (
|
|||||||
|
|
||||||
RegSize = 0;
|
RegSize = 0;
|
||||||
while (RegSize < REG_SIZE) {
|
while (RegSize < REG_SIZE) {
|
||||||
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
|
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
|
||||||
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> RegSize) & 0xf)];
|
*OutBufPtr++ = mHexToStr[((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
|
||||||
RegSize = RegSize + 8;
|
RegSize = RegSize + 8;
|
||||||
}
|
}
|
||||||
return OutBufPtr;
|
return OutBufPtr;
|
||||||
@ -210,7 +210,7 @@ ReadNthRegister (
|
|||||||
}
|
}
|
||||||
|
|
||||||
OutBufPtr = OutBuffer;
|
OutBufPtr = OutBuffer;
|
||||||
OutBufPtr = BasicReadRegister(SystemContext, RegNumber, OutBufPtr);
|
OutBufPtr = BasicReadRegister (SystemContext, RegNumber, OutBufPtr);
|
||||||
|
|
||||||
*OutBufPtr = '\0'; // the end of the buffer
|
*OutBufPtr = '\0'; // the end of the buffer
|
||||||
SendPacket(OutBuffer);
|
SendPacket(OutBuffer);
|
||||||
@ -233,8 +233,8 @@ ReadGeneralRegisters (
|
|||||||
CHAR8 *OutBufPtr; // pointer to the output buffer
|
CHAR8 *OutBufPtr; // pointer to the output buffer
|
||||||
|
|
||||||
OutBufPtr = OutBuffer;
|
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 = BasicReadRegister (SystemContext, i, OutBufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
*OutBufPtr = '\0'; // the end of the buffer
|
*OutBufPtr = '\0'; // the end of the buffer
|
||||||
@ -282,7 +282,7 @@ BasicWriteRegister (
|
|||||||
NewValue += (TempValue << RegSize);
|
NewValue += (TempValue << RegSize);
|
||||||
RegSize = RegSize + 8;
|
RegSize = RegSize + 8;
|
||||||
}
|
}
|
||||||
*(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;
|
*(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
|
||||||
return InBufPtr;
|
return InBufPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,8 +353,8 @@ WriteGeneralRegisters (
|
|||||||
|
|
||||||
// Read the new values for the registers from the input buffer to an array, NewValueArray.
|
// 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
|
// 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);
|
InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
SendSuccess();
|
SendSuccess();
|
||||||
@ -867,7 +867,7 @@ InsertBreakPoint (
|
|||||||
|
|
||||||
if (Status == EFI_UNSUPPORTED) {
|
if (Status == EFI_UNSUPPORTED) {
|
||||||
Print ((CHAR16 *)L"Not supported\n");
|
Print ((CHAR16 *)L"Not supported\n");
|
||||||
SendNotSupported();
|
SendNotSupported ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,7 +946,7 @@ RemoveBreakPoint (
|
|||||||
|
|
||||||
if (Status == EFI_UNSUPPORTED) {
|
if (Status == EFI_UNSUPPORTED) {
|
||||||
Print ((CHAR16 *)L"Not supported.\n");
|
Print ((CHAR16 *)L"Not supported.\n");
|
||||||
SendNotSupported();
|
SendNotSupported ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,7 +956,7 @@ RemoveBreakPoint (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Remove breakpoint
|
//Remove breakpoint
|
||||||
Status = DisableDebugRegister(SystemContext, Register);
|
Status = DisableDebugRegister (SystemContext, Register);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
Print ((CHAR16 *)L"Invalid argument.\n");
|
Print ((CHAR16 *)L"Invalid argument.\n");
|
||||||
SendError (GDB_EINVALIDARG);
|
SendError (GDB_EINVALIDARG);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011-2012, ARM Limited. All rights reserved.
|
* Copyright (c) 2011-2013, ARM Limited. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials
|
* This program and the accompanying materials
|
||||||
* are licensed and made available under the terms and conditions of the BSD License
|
* are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -40,36 +40,36 @@ PrintOCR (
|
|||||||
IN UINT32 Ocr
|
IN UINT32 Ocr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN minv;
|
UINTN MinV;
|
||||||
UINTN maxv;
|
UINTN MaxV;
|
||||||
UINTN volts;
|
UINTN Volts;
|
||||||
UINTN loop;
|
UINTN Loop;
|
||||||
|
|
||||||
minv = 36; // 3.6
|
MinV = 36; // 3.6
|
||||||
maxv = 20; // 2.0
|
MaxV = 20; // 2.0
|
||||||
volts = 20; // 2.0
|
Volts = 20; // 2.0
|
||||||
|
|
||||||
// The MMC register bits [23:8] indicate the working range of the card
|
// The MMC register bits [23:8] indicate the working range of the card
|
||||||
for (loop = 8; loop < 24; loop++) {
|
for (Loop = 8; Loop < 24; Loop++) {
|
||||||
if (Ocr & (1 << loop)) {
|
if (Ocr & (1 << Loop)) {
|
||||||
if (minv > volts) minv = volts;
|
if (MinV > Volts) MinV = Volts;
|
||||||
if (maxv < volts) maxv = volts + 1;
|
if (MaxV < Volts) MaxV = Volts + 1;
|
||||||
}
|
}
|
||||||
volts = volts + 1;
|
Volts = Volts + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG((EFI_D_ERROR, "- PrintOCR Ocr (0x%X)\n",Ocr));
|
DEBUG ((EFI_D_ERROR, "- PrintOCR Ocr (0x%X)\n",Ocr));
|
||||||
DEBUG((EFI_D_ERROR, "\t- Card operating voltage: %d.%d to %d.%d\n", minv/10, minv % 10, maxv/10, maxv % 10));
|
DEBUG ((EFI_D_ERROR, "\t- Card operating voltage: %d.%d to %d.%d\n", MinV/10, MinV % 10, MaxV/10, MaxV % 10));
|
||||||
if (((Ocr >> 29) & 3) == 0) {
|
if (((Ocr >> 29) & 3) == 0) {
|
||||||
DEBUG((EFI_D_ERROR, "\t- AccessMode: Byte Mode\n"));
|
DEBUG ((EFI_D_ERROR, "\t- AccessMode: Byte Mode\n"));
|
||||||
} else {
|
} else {
|
||||||
DEBUG((EFI_D_ERROR, "\t- AccessMode: Block Mode (0x%X)\n",((Ocr >> 29) & 3)));
|
DEBUG ((EFI_D_ERROR, "\t- AccessMode: Block Mode (0x%X)\n", ((Ocr >> 29) & 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ocr & MMC_OCR_POWERUP) {
|
if (Ocr & MMC_OCR_POWERUP) {
|
||||||
DEBUG((EFI_D_ERROR, "\t- PowerUp\n"));
|
DEBUG ((EFI_D_ERROR, "\t- PowerUp\n"));
|
||||||
} else {
|
} else {
|
||||||
DEBUG((EFI_D_ERROR, "\t- Voltage Not Supported\n"));
|
DEBUG ((EFI_D_ERROR, "\t- Voltage Not Supported\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,17 +77,19 @@ VOID PrintCID (
|
|||||||
IN UINT32* Cid
|
IN UINT32* Cid
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DEBUG((EFI_D_ERROR, "- PrintCID\n"));
|
DEBUG ((EFI_D_ERROR, "- PrintCID\n"));
|
||||||
DEBUG((EFI_D_ERROR, "\t- Manufacturing date: %d/%d\n",(Cid[0] >> 8) & 0xF,(Cid[0] >> 12) & 0xFF));
|
DEBUG ((EFI_D_ERROR, "\t- Manufacturing date: %d/%d\n", (Cid[0] >> 8) & 0xF, (Cid[0] >> 12) & 0xFF));
|
||||||
DEBUG((EFI_D_ERROR, "\t- Product serial number: 0x%X%X\n",Cid[1] & 0xFFFFFF,(Cid[0] >> 24) & 0xFF));
|
DEBUG ((EFI_D_ERROR, "\t- Product serial number: 0x%X%X\n", Cid[1] & 0xFFFFFF, (Cid[0] >> 24) & 0xFF));
|
||||||
DEBUG((EFI_D_ERROR, "\t- Product revision: %d\n",Cid[1] >> 24));
|
DEBUG ((EFI_D_ERROR, "\t- Product revision: %d\n", Cid[1] >> 24));
|
||||||
//DEBUG((EFI_D_ERROR, "\t- Product name: %s\n",(char*)(Cid + 2)));
|
//DEBUG ((EFI_D_ERROR, "\t- Product name: %s\n", (char*)(Cid + 2)));
|
||||||
DEBUG((EFI_D_ERROR, "\t- OEM ID: %c%c\n",(Cid[3] >> 8) & 0xFF,(Cid[3] >> 16) & 0xFF));
|
DEBUG ((EFI_D_ERROR, "\t- OEM ID: %c%c\n", (Cid[3] >> 8) & 0xFF, (Cid[3] >> 16) & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(MDEPKG_NDEBUG)
|
#if !defined(MDEPKG_NDEBUG)
|
||||||
CONST CHAR8* mStrUnit[] = { "100kbit/s","1Mbit/s","10Mbit/s","100MBit/s","Unkbown","Unkbown","Unkbown","Unkbown" };
|
CONST CHAR8* mStrUnit[] = { "100kbit/s", "1Mbit/s", "10Mbit/s", "100MBit/s",
|
||||||
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" };
|
"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
|
#endif
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
@ -98,26 +100,26 @@ PrintCSD (
|
|||||||
UINTN Value;
|
UINTN Value;
|
||||||
|
|
||||||
if (((Csd[2] >> 30) & 0x3) == 0) {
|
if (((Csd[2] >> 30) & 0x3) == 0) {
|
||||||
DEBUG((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
|
DEBUG ((EFI_D_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
|
||||||
} else if (((Csd[2] >> 30) & 0x3) == 1) {
|
} else if (((Csd[2] >> 30) & 0x3) == 1) {
|
||||||
DEBUG((EFI_D_ERROR, "- PrintCSD Version 2.00/High Capacity\n"));
|
DEBUG ((EFI_D_ERROR, "- PrintCSD Version 2.00/High Capacity\n"));
|
||||||
} else {
|
} else {
|
||||||
DEBUG((EFI_D_ERROR, "- PrintCSD Version Higher than v3.3\n"));
|
DEBUG ((EFI_D_ERROR, "- PrintCSD Version Higher than v3.3\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG((EFI_D_ERROR, "\t- Supported card command class: 0x%X\n",MMC_CSD_GET_CCC(Csd)));
|
DEBUG ((EFI_D_ERROR, "\t- Supported card command class: 0x%X\n", MMC_CSD_GET_CCC(Csd)));
|
||||||
DEBUG((EFI_D_ERROR, "\t- Speed: %a %a\n",mStrValue[(MMC_CSD_GET_TRANSPEED(Csd) >> 3) & 0xF],mStrUnit[MMC_CSD_GET_TRANSPEED(Csd) & 7]));
|
DEBUG ((EFI_D_ERROR, "\t- Speed: %a %a\n",mStrValue[(MMC_CSD_GET_TRANSPEED(Csd) >> 3) & 0xF],mStrUnit[MMC_CSD_GET_TRANSPEED(Csd) & 7]));
|
||||||
DEBUG((EFI_D_ERROR, "\t- Maximum Read Data Block: %d\n",2 << (MMC_CSD_GET_READBLLEN(Csd)-1)));
|
DEBUG ((EFI_D_ERROR, "\t- Maximum Read Data Block: %d\n",2 << (MMC_CSD_GET_READBLLEN(Csd)-1)));
|
||||||
DEBUG((EFI_D_ERROR, "\t- Maximum Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN(Csd)-1)));
|
DEBUG ((EFI_D_ERROR, "\t- Maximum Write Data Block: %d\n",2 << (MMC_CSD_GET_WRITEBLLEN(Csd)-1)));
|
||||||
|
|
||||||
if (!MMC_CSD_GET_FILEFORMATGRP(Csd)) {
|
if (!MMC_CSD_GET_FILEFORMATGRP(Csd)) {
|
||||||
Value = MMC_CSD_GET_FILEFORMAT(Csd);
|
Value = MMC_CSD_GET_FILEFORMAT (Csd);
|
||||||
if (Value == 0) DEBUG((EFI_D_ERROR, "\t- Format(0): Hard disk-like file system with partition table\n"));
|
if (Value == 0) DEBUG ((EFI_D_ERROR, "\t- Format (0): Hard disk-like file system with partition table\n"));
|
||||||
else if (Value == 1) DEBUG((EFI_D_ERROR, "\t- Format(1): DOS FAT (floppy-like) with boot sector only (no partition table)\n"));
|
else if (Value == 1) DEBUG ((EFI_D_ERROR, "\t- Format (1): DOS FAT (floppy-like) with boot sector only (no partition table)\n"));
|
||||||
else if (Value == 2) DEBUG((EFI_D_ERROR, "\t- Format(2): Universal File Format\n"));
|
else if (Value == 2) DEBUG ((EFI_D_ERROR, "\t- Format (2): Universal File Format\n"));
|
||||||
else DEBUG((EFI_D_ERROR, "\t- Format(3): Others/Unknown\n"));
|
else DEBUG ((EFI_D_ERROR, "\t- Format (3): Others/Unknown\n"));
|
||||||
} else {
|
} else {
|
||||||
DEBUG((EFI_D_ERROR, "\t- Format: Reserved\n"));
|
DEBUG ((EFI_D_ERROR, "\t- Format: Reserved\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,9 +128,9 @@ PrintRCA (
|
|||||||
IN UINT32 Rca
|
IN UINT32 Rca
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DEBUG((EFI_D_ERROR, "- PrintRCA: 0x%X\n",Rca));
|
DEBUG ((EFI_D_ERROR, "- PrintRCA: 0x%X\n", Rca));
|
||||||
DEBUG((EFI_D_ERROR, "\t- Status: 0x%X\n",Rca & 0xFFFF));
|
DEBUG ((EFI_D_ERROR, "\t- Status: 0x%X\n", Rca & 0xFFFF));
|
||||||
DEBUG((EFI_D_ERROR, "\t- RCA: 0x%X\n",(Rca >> 16) & 0xFFFF));
|
DEBUG ((EFI_D_ERROR, "\t- RCA: 0x%X\n", (Rca >> 16) & 0xFFFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
@ -136,19 +138,21 @@ PrintResponseR1 (
|
|||||||
IN UINT32 Response
|
IN UINT32 Response
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DEBUG((EFI_D_INFO, "Response: 0x%X\n",Response));
|
DEBUG ((EFI_D_INFO, "Response: 0x%X\n", Response));
|
||||||
if (Response & MMC_R0_READY_FOR_DATA) DEBUG((EFI_D_INFO, "\t- READY_FOR_DATA\n"));
|
if (Response & MMC_R0_READY_FOR_DATA) {
|
||||||
|
DEBUG ((EFI_D_INFO, "\t- READY_FOR_DATA\n"));
|
||||||
|
}
|
||||||
|
|
||||||
if (((Response >> 9) & 0xF) == 0) DEBUG((EFI_D_INFO, "\t- State: Idle\n"));
|
if (((Response >> 9) & 0xF) == 0) DEBUG ((EFI_D_INFO, "\t- State: Idle\n"));
|
||||||
else if (((Response >> 9) & 0xF) == 1) DEBUG((EFI_D_INFO, "\t- State: Ready\n"));
|
else if (((Response >> 9) & 0xF) == 1) DEBUG ((EFI_D_INFO, "\t- State: Ready\n"));
|
||||||
else if (((Response >> 9) & 0xF) == 2) DEBUG((EFI_D_INFO, "\t- State: Ident\n"));
|
else if (((Response >> 9) & 0xF) == 2) DEBUG ((EFI_D_INFO, "\t- State: Ident\n"));
|
||||||
else if (((Response >> 9) & 0xF) == 3) DEBUG((EFI_D_INFO, "\t- State: StandBy\n"));
|
else if (((Response >> 9) & 0xF) == 3) DEBUG ((EFI_D_INFO, "\t- State: StandBy\n"));
|
||||||
else if (((Response >> 9) & 0xF) == 4) DEBUG((EFI_D_INFO, "\t- State: Tran\n"));
|
else if (((Response >> 9) & 0xF) == 4) DEBUG ((EFI_D_INFO, "\t- State: Tran\n"));
|
||||||
else if (((Response >> 9) & 0xF) == 5) DEBUG((EFI_D_INFO, "\t- State: Data\n"));
|
else if (((Response >> 9) & 0xF) == 5) DEBUG ((EFI_D_INFO, "\t- State: Data\n"));
|
||||||
else if (((Response >> 9) & 0xF) == 6) DEBUG((EFI_D_INFO, "\t- State: Rcv\n"));
|
else if (((Response >> 9) & 0xF) == 6) DEBUG ((EFI_D_INFO, "\t- State: Rcv\n"));
|
||||||
else if (((Response >> 9) & 0xF) == 7) DEBUG((EFI_D_INFO, "\t- State: Prg\n"));
|
else if (((Response >> 9) & 0xF) == 7) DEBUG ((EFI_D_INFO, "\t- State: Prg\n"));
|
||||||
else if (((Response >> 9) & 0xF) == 8) DEBUG((EFI_D_INFO, "\t- State: Dis\n"));
|
else if (((Response >> 9) & 0xF) == 8) DEBUG ((EFI_D_INFO, "\t- State: Dis\n"));
|
||||||
else DEBUG((EFI_D_INFO, "\t- State: Reserved\n"));
|
else DEBUG ((EFI_D_INFO, "\t- State: Reserved\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -173,14 +177,14 @@ MmcGetCardStatus(
|
|||||||
//Get the Status of the card.
|
//Get the Status of the card.
|
||||||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status));
|
DEBUG ((EFI_D_ERROR, "MmcGetCardStatus(MMC_CMD13): Error and Status = %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Read Response
|
//Read Response
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
|
||||||
PrintResponseR1(Response[0]);
|
PrintResponseR1 (Response[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
@ -211,28 +215,28 @@ MmcIdentificationMode (
|
|||||||
if (MmcHostInstance->State == MmcHwInitializationState) {
|
if (MmcHostInstance->State == MmcHwInitializationState) {
|
||||||
// Initialize the MMC Host HW
|
// Initialize the MMC Host HW
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcHwInitializationState);
|
Status = MmcNotifyState (MmcHostInstance, MmcHwInitializationState);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcHwInitializationState\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcHwInitializationState\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD0): Error\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcIdleState);
|
Status = MmcNotifyState (MmcHostInstance, MmcIdleState);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcIdleState\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcIdleState\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we using SDIO ?
|
// Are we using SDIO ?
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
|
||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported.\n"));
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,8 +246,8 @@ MmcIdentificationMode (
|
|||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
DEBUG ((EFI_D_ERROR, "Card is SD2.0 => Supports high capacity\n"));
|
DEBUG ((EFI_D_ERROR, "Card is SD2.0 => Supports high capacity\n"));
|
||||||
IsHCS = TRUE;
|
IsHCS = TRUE;
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R7,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R7, Response);
|
||||||
PrintResponseR1(Response[0]);
|
PrintResponseR1 (Response[0]);
|
||||||
//check if it is valid response
|
//check if it is valid response
|
||||||
if(Response[0] != CmdArg){
|
if(Response[0] != CmdArg){
|
||||||
DEBUG ((EFI_D_ERROR, "The Card is not usable\n"));
|
DEBUG ((EFI_D_ERROR, "The Card is not usable\n"));
|
||||||
@ -272,8 +276,8 @@ MmcIdentificationMode (
|
|||||||
CmdArg |= BIT30;
|
CmdArg |= BIT30;
|
||||||
}
|
}
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
|
||||||
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
|
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -281,15 +285,15 @@ MmcIdentificationMode (
|
|||||||
MmcHostInstance->CardInfo.CardType = MMC_CARD;
|
MmcHostInstance->CardInfo.CardType = MMC_CARD;
|
||||||
|
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
|
||||||
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
|
((UINT32 *) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
if (!MmcHostInstance->CardInfo.OCRData.PowerUp) {
|
if (!MmcHostInstance->CardInfo.OCRData.PowerUp) {
|
||||||
MicroSecondDelay(1);
|
MicroSecondDelay (1);
|
||||||
Timeout--;
|
Timeout--;
|
||||||
} else {
|
} else {
|
||||||
if ((MmcHostInstance->CardInfo.CardType == SD_CARD_2) && (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1)) {
|
if ((MmcHostInstance->CardInfo.CardType == SD_CARD_2) && (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1)) {
|
||||||
@ -299,35 +303,35 @@ MmcIdentificationMode (
|
|||||||
break; // The MMC/SD card is ready. Continue the Identification Mode
|
break; // The MMC/SD card is ready. Continue the Identification Mode
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MicroSecondDelay(1);
|
MicroSecondDelay (1);
|
||||||
Timeout--;
|
Timeout--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Timeout == 0) {
|
if (Timeout == 0) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(): No Card\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(): No Card\n"));
|
||||||
return EFI_NO_MEDIA;
|
return EFI_NO_MEDIA;
|
||||||
} else {
|
} else {
|
||||||
PrintOCR(Response[0]);
|
PrintOCR (Response[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcReadyState);
|
Status = MmcNotifyState (MmcHostInstance, MmcReadyState);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcReadyState\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcReadyState\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD2, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD2, 0);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CID,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CID, Response);
|
||||||
PrintCID(Response);
|
PrintCID(Response);
|
||||||
|
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcIdentificationState);
|
Status = MmcNotifyState (MmcHostInstance, MmcIdentificationState);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcIdentificationState\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcIdentificationState\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,13 +342,13 @@ MmcIdentificationMode (
|
|||||||
//
|
//
|
||||||
CmdArg = 1;
|
CmdArg = 1;
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_RCA,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_RCA, Response);
|
||||||
PrintRCA(Response[0]);
|
PrintRCA (Response[0]);
|
||||||
|
|
||||||
// For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
|
// For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
|
||||||
if (MmcHostInstance->CardInfo.CardType != MMC_CARD) {
|
if (MmcHostInstance->CardInfo.CardType != MMC_CARD) {
|
||||||
@ -354,8 +358,8 @@ MmcIdentificationMode (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcStandByState);
|
Status = MmcNotifyState (MmcHostInstance, MmcStandByState);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcStandByState\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcStandByState\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,27 +383,27 @@ EFI_STATUS InitializeMmcDevice (
|
|||||||
//Send a command to get Card specific data
|
//Send a command to get Card specific data
|
||||||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD9, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD9): Error, Status=%r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
//Read Response
|
//Read Response
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CSD,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CSD, Response);
|
||||||
PrintCSD(Response);
|
PrintCSD(Response);
|
||||||
|
|
||||||
if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
|
if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
|
||||||
CardSize = HC_MMC_CSD_GET_DEVICESIZE(Response);
|
CardSize = HC_MMC_CSD_GET_DEVICESIZE (Response);
|
||||||
NumBlocks = ((CardSize + 1) * 1024);
|
NumBlocks = ((CardSize + 1) * 1024);
|
||||||
BlockSize = 1 << MMC_CSD_GET_READBLLEN(Response);
|
BlockSize = 1 << MMC_CSD_GET_READBLLEN(Response);
|
||||||
} else {
|
} else {
|
||||||
CardSize = MMC_CSD_GET_DEVICESIZE(Response);
|
CardSize = MMC_CSD_GET_DEVICESIZE (Response);
|
||||||
NumBlocks = (CardSize + 1) * (1 << (MMC_CSD_GET_DEVICESIZEMULT(Response) + 2));
|
NumBlocks = (CardSize + 1) * (1 << (MMC_CSD_GET_DEVICESIZEMULT (Response) + 2));
|
||||||
BlockSize = 1 << MMC_CSD_GET_READBLLEN(Response);
|
BlockSize = 1 << MMC_CSD_GET_READBLLEN(Response);
|
||||||
}
|
}
|
||||||
|
|
||||||
//For >=2G card, BlockSize may be 1K, but the transfer size is 512 bytes.
|
//For >=2G card, BlockSize may be 1K, but the transfer size is 512 bytes.
|
||||||
if (BlockSize > 512) {
|
if (BlockSize > 512) {
|
||||||
NumBlocks = MultU64x32(NumBlocks, BlockSize/512);
|
NumBlocks = MultU64x32 (NumBlocks, BlockSize/512);
|
||||||
BlockSize = 512;
|
BlockSize = 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,21 +415,21 @@ EFI_STATUS InitializeMmcDevice (
|
|||||||
|
|
||||||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD7): Error and Status = %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
|
Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcTransferState\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Error MmcTransferState\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Block Length
|
// Set Block Length
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",MmcHostInstance->BlockIo.Media->BlockSize, Status));
|
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n", MmcHostInstance->BlockIo.Media->BlockSize, Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +450,7 @@ MmcReset (
|
|||||||
{
|
{
|
||||||
MMC_HOST_INSTANCE *MmcHostInstance;
|
MMC_HOST_INSTANCE *MmcHostInstance;
|
||||||
|
|
||||||
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS(This);
|
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
|
||||||
|
|
||||||
if (MmcHostInstance->MmcHost == NULL) {
|
if (MmcHostInstance->MmcHost == NULL) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
@ -506,10 +510,10 @@ MmcIoBlocks (
|
|||||||
UINTN BytesRemainingToBeTransfered;
|
UINTN BytesRemainingToBeTransfered;
|
||||||
UINTN BlockCount = 1;
|
UINTN BlockCount = 1;
|
||||||
|
|
||||||
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS(This);
|
MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
|
||||||
ASSERT(MmcHostInstance != 0);
|
ASSERT (MmcHostInstance != 0);
|
||||||
MmcHost = MmcHostInstance->MmcHost;
|
MmcHost = MmcHostInstance->MmcHost;
|
||||||
ASSERT(MmcHost);
|
ASSERT (MmcHost);
|
||||||
|
|
||||||
if ((MmcHost == 0)|| (Buffer == NULL)) {
|
if ((MmcHost == 0)|| (Buffer == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
@ -546,16 +550,16 @@ MmcIoBlocks (
|
|||||||
Response[0] = 0;
|
Response[0] = 0;
|
||||||
Timeout = 20;
|
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)
|
&& (MMC_R0_CURRENTSTATE (Response) != MMC_R0_STATE_TRAN)
|
||||||
&& Timeout--) {
|
&& Timeout--) {
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == Timeout) {
|
if (0 == Timeout) {
|
||||||
DEBUG((EFI_D_ERROR, "The Card is busy\n"));
|
DEBUG ((EFI_D_ERROR, "The Card is busy\n"));
|
||||||
return EFI_NOT_READY;
|
return EFI_NOT_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,46 +586,46 @@ MmcIoBlocks (
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIoBlocks(MMC_CMD%d): Error %r\n",Cmd, Status));
|
DEBUG ((EFI_D_ERROR, "MmcIoBlocks(MMC_CMD%d): Error %r\n", Cmd, Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Transfer == MMC_IOBLOCKS_READ) {
|
if (Transfer == MMC_IOBLOCKS_READ) {
|
||||||
#ifndef USE_STREAM
|
#ifndef USE_STREAM
|
||||||
// Read one block of Data
|
// Read one block of Data
|
||||||
Status = MmcHost->ReadBlockData (MmcHost, Lba,This->Media->BlockSize,Buffer);
|
Status = MmcHost->ReadBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_BLKIO, "MmcIoBlocks(): Error Read Block Data and Status = %r\n", Status));
|
DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Read Block Data and Status = %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
//TODO: Read a stream
|
//TODO: Read a stream
|
||||||
ASSERT(0);
|
ASSERT (0);
|
||||||
#endif
|
#endif
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState);
|
Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIoBlocks() : Error MmcProgrammingState\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIoBlocks() : Error MmcProgrammingState\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifndef USE_STREAM
|
#ifndef USE_STREAM
|
||||||
// Write one block of Data
|
// Write one block of Data
|
||||||
Status = MmcHost->WriteBlockData (MmcHost, Lba,This->Media->BlockSize,Buffer);
|
Status = MmcHost->WriteBlockData (MmcHost, Lba, This->Media->BlockSize, Buffer);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_BLKIO, "MmcIoBlocks(): Error Write Block Data and Status = %r\n", Status));
|
DEBUG ((EFI_D_BLKIO, "MmcIoBlocks(): Error Write Block Data and Status = %r\n", Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
//TODO: Write a stream
|
//TODO: Write a stream
|
||||||
ASSERT(0);
|
ASSERT (0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command 12 - Stop transmission (ends read)
|
// Command 12 - Stop transmission (ends read)
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b,Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command 13 - Read status and wait for programming to complete (return to tran)
|
// Command 13 - Read status and wait for programming to complete (return to tran)
|
||||||
@ -629,21 +633,21 @@ MmcIoBlocks (
|
|||||||
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
CmdArg = MmcHostInstance->CardInfo.RCA << 16;
|
||||||
Response[0] = 0;
|
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)
|
&& (MMC_R0_CURRENTSTATE (Response) != MMC_R0_STATE_TRAN)
|
||||||
&& Timeout--) {
|
&& Timeout--) {
|
||||||
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
Status = MmcHost->SendCommand (MmcHost, MMC_CMD13, CmdArg);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
|
MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
|
||||||
if ((Response[0] & MMC_R0_READY_FOR_DATA)) {
|
if ((Response[0] & MMC_R0_READY_FOR_DATA)) {
|
||||||
break; // Prevents delay once finished
|
break; // Prevents delay once finished
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NanoSecondDelay(100);
|
NanoSecondDelay (100);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
|
Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG((EFI_D_ERROR, "MmcIoBlocks() : Error MmcTransferState\n"));
|
DEBUG ((EFI_D_ERROR, "MmcIoBlocks() : Error MmcTransferState\n"));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,4 +693,3 @@ MmcFlushBlocks (
|
|||||||
{
|
{
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user