MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg 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: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
committed by
mergify[bot]
parent
7c7184e201
commit
1436aea4d5
@ -60,7 +60,7 @@ PrintStringAt (
|
||||
&ScreenRows
|
||||
);
|
||||
|
||||
if (Column > (ScreenWidth - 1) || Row > (ScreenRows - 1)) {
|
||||
if ((Column > (ScreenWidth - 1)) || (Row > (ScreenRows - 1))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ PrintCharAt (
|
||||
&ScreenRows
|
||||
);
|
||||
|
||||
if (Column > (ScreenWidth - 1) || Row > (ScreenRows - 1)) {
|
||||
if ((Column > (ScreenWidth - 1)) || (Row > (ScreenRows - 1))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -164,11 +164,12 @@ GetLineWidth (
|
||||
//
|
||||
// Advance to the null-terminator or to the first width directive
|
||||
//
|
||||
for (;
|
||||
for ( ;
|
||||
(String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0);
|
||||
Index++, LineWidth = LineWidth + IncrementValue
|
||||
)
|
||||
;
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// We hit the null-terminator, we now have a count
|
||||
@ -176,6 +177,7 @@ GetLineWidth (
|
||||
if (String[Index] == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
|
||||
// and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
|
||||
@ -194,6 +196,7 @@ GetLineWidth (
|
||||
IncrementValue = 2;
|
||||
}
|
||||
} while (String[Index] != 0);
|
||||
|
||||
FreePool (String);
|
||||
}
|
||||
|
||||
@ -225,6 +228,7 @@ InitializeBootMenuScreen (
|
||||
if (BootMenuData == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Get maximum string width
|
||||
//
|
||||
@ -243,6 +247,7 @@ InitializeBootMenuScreen (
|
||||
StrWidth = GetLineWidth (BootMenuData->HelpToken[Index]);
|
||||
MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth;
|
||||
}
|
||||
|
||||
//
|
||||
// query current row and column to calculate boot menu location
|
||||
//
|
||||
@ -260,6 +265,7 @@ InitializeBootMenuScreen (
|
||||
} else {
|
||||
BootMenuData->MenuScreen.Width = MaxStrWidth + 8;
|
||||
}
|
||||
|
||||
if (BootMenuData->ItemCount + UnSelectableItmes > MaxPrintRows) {
|
||||
BootMenuData->MenuScreen.Height = MaxPrintRows;
|
||||
BootMenuData->ScrollBarControl.HasScrollBar = TRUE;
|
||||
@ -273,11 +279,13 @@ InitializeBootMenuScreen (
|
||||
BootMenuData->ScrollBarControl.FirstItem = 0;
|
||||
BootMenuData->ScrollBarControl.LastItem = BootMenuData->ItemCount - 1;
|
||||
}
|
||||
|
||||
BootMenuData->MenuScreen.StartCol = (Column - BootMenuData->MenuScreen.Width) / 2;
|
||||
BootMenuData->MenuScreen.StartRow = (Row - BootMenuData->MenuScreen.Height) / 2;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function uses check boot option is wheher setup application or no
|
||||
|
||||
@ -300,7 +308,7 @@ IsBootManagerMenu (
|
||||
EfiBootManagerFreeLoadOption (&BootManagerMenu);
|
||||
}
|
||||
|
||||
return (BOOLEAN) (!EFI_ERROR (Status) && (BootOption->OptionNumber == BootManagerMenu.OptionNumber));
|
||||
return (BOOLEAN)(!EFI_ERROR (Status) && (BootOption->OptionNumber == BootManagerMenu.OptionNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,7 +330,7 @@ IgnoreBootOption (
|
||||
//
|
||||
// Ignore myself.
|
||||
//
|
||||
Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **) &ImageDevicePath);
|
||||
Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **)&ImageDevicePath);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (CompareMem (BootOption->FilePath, ImageDevicePath, GetDevicePathSize (ImageDevicePath)) == 0) {
|
||||
return TRUE;
|
||||
@ -366,7 +374,7 @@ InitializeBootMenuData (
|
||||
UINTN Index;
|
||||
UINTN StrIndex;
|
||||
|
||||
if (BootOption == NULL || BootMenuData == NULL) {
|
||||
if ((BootOption == NULL) || (BootMenuData == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -431,9 +439,10 @@ BootMenuSelectItem (
|
||||
UINTN Index;
|
||||
BOOLEAN RePaintItems;
|
||||
|
||||
if (BootMenuData == NULL || WantSelectItem >= BootMenuData->ItemCount) {
|
||||
if ((BootMenuData == NULL) || (WantSelectItem >= BootMenuData->ItemCount)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ASSERT (BootMenuData->ItemCount != 0);
|
||||
SavedAttribute = gST->ConOut->Mode->Attribute;
|
||||
RePaintItems = FALSE;
|
||||
@ -443,9 +452,10 @@ BootMenuSelectItem (
|
||||
// print selectable items again and adjust scroll bar if need
|
||||
//
|
||||
if (BootMenuData->ScrollBarControl.HasScrollBar &&
|
||||
(WantSelectItem < BootMenuData->ScrollBarControl.FirstItem ||
|
||||
WantSelectItem > BootMenuData->ScrollBarControl.LastItem ||
|
||||
WantSelectItem == BootMenuData->SelectItem)) {
|
||||
((WantSelectItem < BootMenuData->ScrollBarControl.FirstItem) ||
|
||||
(WantSelectItem > BootMenuData->ScrollBarControl.LastItem) ||
|
||||
(WantSelectItem == BootMenuData->SelectItem)))
|
||||
{
|
||||
ItemCountPerScreen = BootMenuData->ScrollBarControl.ItemCountPerScreen;
|
||||
//
|
||||
// Set first item and last item
|
||||
@ -457,6 +467,7 @@ BootMenuSelectItem (
|
||||
BootMenuData->ScrollBarControl.FirstItem = WantSelectItem - ItemCountPerScreen + 1;
|
||||
BootMenuData->ScrollBarControl.LastItem = WantSelectItem;
|
||||
}
|
||||
|
||||
gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLUE);
|
||||
FirstItem = BootMenuData->ScrollBarControl.FirstItem;
|
||||
LastItem = BootMenuData->ScrollBarControl.LastItem;
|
||||
@ -466,31 +477,34 @@ BootMenuSelectItem (
|
||||
if ((FirstItem * ItemCountPerScreen) % BootMenuData->ItemCount != 0) {
|
||||
TopShadeNum++;
|
||||
}
|
||||
|
||||
PrintCol = StartCol + BootMenuData->MenuScreen.Width - 2;
|
||||
PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;
|
||||
for (Index = 0; Index < TopShadeNum; Index++, PrintRow++) {
|
||||
PrintCharAt (PrintCol, PrintRow, BLOCKELEMENT_LIGHT_SHADE);
|
||||
}
|
||||
}
|
||||
|
||||
LowShadeNum = 0;
|
||||
if (LastItem != BootMenuData->ItemCount - 1) {
|
||||
LowShadeNum = ((BootMenuData->ItemCount - 1 - LastItem) * ItemCountPerScreen) / BootMenuData->ItemCount;
|
||||
if (((BootMenuData->ItemCount - 1 - LastItem) * ItemCountPerScreen) % BootMenuData->ItemCount != 0) {
|
||||
LowShadeNum++;
|
||||
}
|
||||
|
||||
PrintCol = StartCol + BootMenuData->MenuScreen.Width - 2;
|
||||
PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + ItemCountPerScreen - LowShadeNum;
|
||||
for (Index = 0; Index < LowShadeNum; Index++, PrintRow++) {
|
||||
PrintCharAt (PrintCol, PrintRow, BLOCKELEMENT_LIGHT_SHADE);
|
||||
}
|
||||
}
|
||||
|
||||
PrintCol = StartCol + BootMenuData->MenuScreen.Width - 2;
|
||||
PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + TopShadeNum;
|
||||
for (Index = TopShadeNum; Index < ItemCountPerScreen - LowShadeNum; Index++, PrintRow++) {
|
||||
PrintCharAt (PrintCol, PrintRow, BLOCKELEMENT_FULL_BLOCK);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Clear selectable items first
|
||||
//
|
||||
@ -501,9 +515,11 @@ BootMenuSelectItem (
|
||||
for (Index = 0; Index < BootMenuData->MenuScreen.Width - 3; Index++) {
|
||||
String[Index] = 0x20;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < ItemCountPerScreen; Index++) {
|
||||
PrintStringAt (PrintCol, PrintRow + Index, String);
|
||||
}
|
||||
|
||||
FreePool (String);
|
||||
//
|
||||
// print selectable items
|
||||
@ -513,6 +529,7 @@ BootMenuSelectItem (
|
||||
PrintStringAt (PrintCol, PrintRow, String);
|
||||
FreePool (String);
|
||||
}
|
||||
|
||||
RePaintItems = TRUE;
|
||||
}
|
||||
|
||||
@ -521,7 +538,7 @@ BootMenuSelectItem (
|
||||
// items, clear select item
|
||||
//
|
||||
FirstItem = BootMenuData->ScrollBarControl.FirstItem;
|
||||
if (WantSelectItem != BootMenuData->SelectItem && !RePaintItems) {
|
||||
if ((WantSelectItem != BootMenuData->SelectItem) && !RePaintItems) {
|
||||
gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLUE);
|
||||
String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[BootMenuData->SelectItem], NULL);
|
||||
PrintCol = StartCol + 1;
|
||||
@ -587,6 +604,7 @@ DrawBootPopupMenu (
|
||||
for (Index = 1; Index < Width - 1; Index++) {
|
||||
PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);
|
||||
}
|
||||
|
||||
PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_DOWN_LEFT);
|
||||
|
||||
//
|
||||
@ -610,6 +628,7 @@ DrawBootPopupMenu (
|
||||
for (Index = 1; Index < Width - 1; Index++) {
|
||||
PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);
|
||||
}
|
||||
|
||||
PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT);
|
||||
|
||||
//
|
||||
@ -627,6 +646,7 @@ DrawBootPopupMenu (
|
||||
for (Index = 1; Index < Width - 1; Index++) {
|
||||
PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);
|
||||
}
|
||||
|
||||
PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT);
|
||||
|
||||
//
|
||||
@ -638,6 +658,7 @@ DrawBootPopupMenu (
|
||||
PrintStringAt (StartCol + 1, PrintRow, String);
|
||||
PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL);
|
||||
}
|
||||
|
||||
FreePool (String);
|
||||
|
||||
PrintRow++;
|
||||
@ -645,8 +666,8 @@ DrawBootPopupMenu (
|
||||
for (Index = 1; Index < Width - 1; Index++) {
|
||||
PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);
|
||||
}
|
||||
PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_UP_LEFT);
|
||||
|
||||
PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_UP_LEFT);
|
||||
|
||||
//
|
||||
// print title strings
|
||||
@ -778,7 +799,7 @@ BdsSetConsoleMode (
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
(VOID**)&GraphicsOutput
|
||||
(VOID **)&GraphicsOutput
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
GraphicsOutput = NULL;
|
||||
@ -787,7 +808,7 @@ BdsSetConsoleMode (
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiSimpleTextOutProtocolGuid,
|
||||
(VOID**)&SimpleTextOut
|
||||
(VOID **)&SimpleTextOut
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
SimpleTextOut = NULL;
|
||||
@ -839,15 +860,17 @@ BdsSetConsoleMode (
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if ((Info->HorizontalResolution == NewHorizontalResolution) &&
|
||||
(Info->VerticalResolution == NewVerticalResolution)) {
|
||||
(Info->VerticalResolution == NewVerticalResolution))
|
||||
{
|
||||
if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&
|
||||
(GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {
|
||||
(GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution))
|
||||
{
|
||||
//
|
||||
// Current resolution is same with required resolution, check if text mode need be set
|
||||
//
|
||||
Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (CurrentColumn == NewColumns && CurrentRow == NewRows) {
|
||||
if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
|
||||
//
|
||||
// If current text mode is same with required text mode. Do nothing
|
||||
//
|
||||
@ -859,7 +882,7 @@ BdsSetConsoleMode (
|
||||
//
|
||||
for (Index = 0; Index < MaxTextMode; Index++) {
|
||||
Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
|
||||
//
|
||||
// Required text mode is supported, set it.
|
||||
@ -878,6 +901,7 @@ BdsSetConsoleMode (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == MaxTextMode) {
|
||||
//
|
||||
// If required text mode is not supported, return error.
|
||||
@ -898,6 +922,7 @@ BdsSetConsoleMode (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (Info);
|
||||
}
|
||||
}
|
||||
@ -938,9 +963,11 @@ BdsSetConsoleMode (
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
||||
}
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
@ -984,7 +1011,7 @@ BootManagerMenuEntry (
|
||||
// Set Logo status invalid when boot manager menu is launched
|
||||
//
|
||||
BootLogo = NULL;
|
||||
Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);
|
||||
Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo);
|
||||
if (!EFI_ERROR (Status) && (BootLogo != NULL)) {
|
||||
Status = BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@ -1016,7 +1043,7 @@ BootManagerMenuEntry (
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
(VOID**)&GraphicsOutput
|
||||
(VOID **)&GraphicsOutput
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
GraphicsOutput = NULL;
|
||||
@ -1025,7 +1052,7 @@ BootManagerMenuEntry (
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiSimpleTextOutProtocolGuid,
|
||||
(VOID**)&SimpleTextOut
|
||||
(VOID **)&SimpleTextOut
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
SimpleTextOut = NULL;
|
||||
@ -1083,10 +1110,8 @@ BootManagerMenuEntry (
|
||||
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
switch (Key.UnicodeChar) {
|
||||
|
||||
case CHAR_NULL:
|
||||
switch (Key.ScanCode) {
|
||||
|
||||
case SCAN_UP:
|
||||
SelectItem = BootMenuData.SelectItem == 0 ? BootMenuData.ItemCount - 1 : BootMenuData.SelectItem - 1;
|
||||
BootMenuSelectItem (SelectItem, &BootMenuData);
|
||||
@ -1109,6 +1134,7 @@ BootManagerMenuEntry (
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case CHAR_CARRIAGE_RETURN:
|
||||
@ -1130,11 +1156,11 @@ BootManagerMenuEntry (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
|
||||
FreePool (BootMenuData.PtrTokens);
|
||||
|
||||
HiiRemovePackages (gStringPackHandle);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _BOOT_MANAGER_MENU_H_
|
||||
#define _BOOT_MANAGER_MENU_H_
|
||||
|
||||
@ -51,4 +50,3 @@ typedef struct _BOOT_MENU_POPUP_DATA {
|
||||
} BOOT_MENU_POPUP_DATA;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -29,9 +29,9 @@ GetArg (
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
(VOID**)&ShellParameters
|
||||
(VOID **)&ShellParameters
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ GetShellProtocol (
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiShellProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &mShellProtocol
|
||||
(VOID **)&mShellProtocol
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
mShellProtocol = NULL;
|
||||
@ -91,7 +91,7 @@ ReadFileToBuffer (
|
||||
UINTN TempBufferSize;
|
||||
VOID *TempBuffer;
|
||||
|
||||
ShellProtocol = GetShellProtocol();
|
||||
ShellProtocol = GetShellProtocol ();
|
||||
if (ShellProtocol == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -117,7 +117,7 @@ ReadFileToBuffer (
|
||||
return Status;
|
||||
}
|
||||
|
||||
TempBufferSize = (UINTN) FileSize;
|
||||
TempBufferSize = (UINTN)FileSize;
|
||||
TempBuffer = AllocateZeroPool (TempBufferSize);
|
||||
if (TempBuffer == NULL) {
|
||||
ShellProtocol->CloseFile (Handle);
|
||||
@ -168,7 +168,7 @@ WriteFileFromBuffer (
|
||||
EFI_FILE_INFO *FileInfo;
|
||||
UINTN TempBufferSize;
|
||||
|
||||
ShellProtocol = GetShellProtocol();
|
||||
ShellProtocol = GetShellProtocol ();
|
||||
if (ShellProtocol == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -209,6 +209,7 @@ WriteFileFromBuffer (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (FileInfo);
|
||||
|
||||
//
|
||||
@ -229,4 +230,3 @@ WriteFileFromBuffer (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -42,27 +42,29 @@ CreateBmpFmp (
|
||||
UINTN Height;
|
||||
UINTN Width;
|
||||
|
||||
Status = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&Gop);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"CapsuleApp: NO GOP is found.\n");
|
||||
Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&Gop);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"CapsuleApp: NO GOP is found.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Info = Gop->Mode->Info;
|
||||
Print(L"Current GOP: Mode - %d, ", Gop->Mode->Mode);
|
||||
Print(L"HorizontalResolution - %d, ", Info->HorizontalResolution);
|
||||
Print(L"VerticalResolution - %d\n", Info->VerticalResolution);
|
||||
Print (L"Current GOP: Mode - %d, ", Gop->Mode->Mode);
|
||||
Print (L"HorizontalResolution - %d, ", Info->HorizontalResolution);
|
||||
Print (L"VerticalResolution - %d\n", Info->VerticalResolution);
|
||||
// HorizontalResolution >= BMP_IMAGE_HEADER.PixelWidth
|
||||
// VerticalResolution >= BMP_IMAGE_HEADER.PixelHeight
|
||||
|
||||
if (Argc != 5) {
|
||||
Print(L"CapsuleApp: Incorrect parameter count.\n");
|
||||
Print (L"CapsuleApp: Incorrect parameter count.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (StrCmp(Argv[3], L"-O") != 0) {
|
||||
Print(L"CapsuleApp: NO output capsule name.\n");
|
||||
if (StrCmp (Argv[3], L"-O") != 0) {
|
||||
Print (L"CapsuleApp: NO output capsule name.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
OutputCapsuleName = Argv[4];
|
||||
|
||||
BmpBuffer = NULL;
|
||||
@ -70,9 +72,9 @@ CreateBmpFmp (
|
||||
FullCapsuleBuffer = NULL;
|
||||
|
||||
BmpName = Argv[2];
|
||||
Status = ReadFileToBuffer(BmpName, &FileSize, &BmpBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"CapsuleApp: BMP image (%s) is not found.\n", BmpName);
|
||||
Status = ReadFileToBuffer (BmpName, &FileSize, &BmpBuffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"CapsuleApp: BMP image (%s) is not found.\n", BmpName);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
@ -85,37 +87,40 @@ CreateBmpFmp (
|
||||
&Height,
|
||||
&Width
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"CapsuleApp: BMP image (%s) is not valid.\n", BmpName);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"CapsuleApp: BMP image (%s) is not valid.\n", BmpName);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (GopBlt != NULL) {
|
||||
FreePool (GopBlt);
|
||||
}
|
||||
Print(L"BMP image (%s), Width - %d, Height - %d\n", BmpName, Width, Height);
|
||||
|
||||
Print (L"BMP image (%s), Width - %d, Height - %d\n", BmpName, Width, Height);
|
||||
|
||||
if (Height > Info->VerticalResolution) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
Print(L"CapsuleApp: BMP image (%s) height is larger than current resolution.\n", BmpName);
|
||||
goto Done;
|
||||
}
|
||||
if (Width > Info->HorizontalResolution) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
Print(L"CapsuleApp: BMP image (%s) width is larger than current resolution.\n", BmpName);
|
||||
Print (L"CapsuleApp: BMP image (%s) height is larger than current resolution.\n", BmpName);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
FullCapsuleBufferSize = sizeof(EFI_DISPLAY_CAPSULE) + FileSize;
|
||||
FullCapsuleBuffer = AllocatePool(FullCapsuleBufferSize);
|
||||
if (Width > Info->HorizontalResolution) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
Print (L"CapsuleApp: BMP image (%s) width is larger than current resolution.\n", BmpName);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
FullCapsuleBufferSize = sizeof (EFI_DISPLAY_CAPSULE) + FileSize;
|
||||
FullCapsuleBuffer = AllocatePool (FullCapsuleBufferSize);
|
||||
if (FullCapsuleBuffer == NULL) {
|
||||
Print(L"CapsuleApp: Capsule Buffer size (0x%x) too big.\n", FullCapsuleBufferSize);
|
||||
Print (L"CapsuleApp: Capsule Buffer size (0x%x) too big.\n", FullCapsuleBufferSize);
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
DisplayCapsule = (EFI_DISPLAY_CAPSULE *)FullCapsuleBuffer;
|
||||
CopyGuid(&DisplayCapsule->CapsuleHeader.CapsuleGuid, &gWindowsUxCapsuleGuid);
|
||||
DisplayCapsule->CapsuleHeader.HeaderSize = sizeof(DisplayCapsule->CapsuleHeader);
|
||||
CopyGuid (&DisplayCapsule->CapsuleHeader.CapsuleGuid, &gWindowsUxCapsuleGuid);
|
||||
DisplayCapsule->CapsuleHeader.HeaderSize = sizeof (DisplayCapsule->CapsuleHeader);
|
||||
DisplayCapsule->CapsuleHeader.Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET;
|
||||
DisplayCapsule->CapsuleHeader.CapsuleImageSize = (UINT32)FullCapsuleBufferSize;
|
||||
|
||||
@ -140,26 +145,27 @@ CreateBmpFmp (
|
||||
(UINT32)(((3 * Info->VerticalResolution) - (2 * Height)) / 4)
|
||||
);
|
||||
|
||||
Print(L"BMP image (%s), OffsetX - %d, OffsetY - %d\n",
|
||||
Print (
|
||||
L"BMP image (%s), OffsetX - %d, OffsetY - %d\n",
|
||||
BmpName,
|
||||
DisplayCapsule->ImagePayload.OffsetX,
|
||||
DisplayCapsule->ImagePayload.OffsetY
|
||||
);
|
||||
|
||||
CopyMem((DisplayCapsule + 1), BmpBuffer, FileSize);
|
||||
CopyMem ((DisplayCapsule + 1), BmpBuffer, FileSize);
|
||||
|
||||
DisplayCapsule->ImagePayload.Checksum = CalculateCheckSum8(FullCapsuleBuffer, FullCapsuleBufferSize);
|
||||
DisplayCapsule->ImagePayload.Checksum = CalculateCheckSum8 (FullCapsuleBuffer, FullCapsuleBufferSize);
|
||||
|
||||
Status = WriteFileFromBuffer(OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);
|
||||
Print(L"CapsuleApp: Write %s %r\n", OutputCapsuleName, Status);
|
||||
Status = WriteFileFromBuffer (OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);
|
||||
Print (L"CapsuleApp: Write %s %r\n", OutputCapsuleName, Status);
|
||||
|
||||
Done:
|
||||
if (BmpBuffer != NULL) {
|
||||
FreePool(BmpBuffer);
|
||||
FreePool (BmpBuffer);
|
||||
}
|
||||
|
||||
if (FullCapsuleBuffer != NULL) {
|
||||
FreePool(FullCapsuleBuffer);
|
||||
FreePool (FullCapsuleBuffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
@ -186,6 +192,7 @@ GetCapsuleImageTypeId (
|
||||
if (FmpCapsuleHeader->PayloadItemCount == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[FmpCapsuleHeader->EmbeddedDriverCount]);
|
||||
return &ImageHeader->UpdateImageTypeId;
|
||||
}
|
||||
@ -210,12 +217,12 @@ GetEsrtFwType (
|
||||
//
|
||||
// Check ESRT
|
||||
//
|
||||
Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
ASSERT(Esrt != NULL);
|
||||
Status = EfiGetSystemConfigurationTable (&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ASSERT (Esrt != NULL);
|
||||
EsrtEntry = (VOID *)(Esrt + 1);
|
||||
for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) {
|
||||
if (CompareGuid(&EsrtEntry->FwClass, ImageTypeId)) {
|
||||
if (CompareGuid (&EsrtEntry->FwClass, ImageTypeId)) {
|
||||
return EsrtEntry->FwType;
|
||||
}
|
||||
}
|
||||
@ -245,12 +252,15 @@ IsValidCapsuleHeader (
|
||||
if (CapsuleSize < sizeof (EFI_CAPSULE_HEADER)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (CapsuleHeader->CapsuleImageSize != CapsuleSize) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (CapsuleHeader->HeaderSize > CapsuleHeader->CapsuleImageSize) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (CapsuleHeader->HeaderSize < sizeof (EFI_CAPSULE_HEADER)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -271,7 +281,7 @@ IsFmpCapsuleGuid (
|
||||
IN EFI_GUID *CapsuleGuid
|
||||
)
|
||||
{
|
||||
if (CompareGuid(&gEfiFmpCapsuleGuid, CapsuleGuid)) {
|
||||
if (CompareGuid (&gEfiFmpCapsuleGuid, CapsuleGuid)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -303,14 +313,15 @@ CreateNestedFmp (
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (Argc != 5) {
|
||||
Print(L"CapsuleApp: Incorrect parameter count.\n");
|
||||
Print (L"CapsuleApp: Incorrect parameter count.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (StrCmp(Argv[3], L"-O") != 0) {
|
||||
Print(L"CapsuleApp: NO output capsule name.\n");
|
||||
if (StrCmp (Argv[3], L"-O") != 0) {
|
||||
Print (L"CapsuleApp: NO output capsule name.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
OutputCapsuleName = Argv[4];
|
||||
|
||||
CapsuleBuffer = NULL;
|
||||
@ -318,69 +329,70 @@ CreateNestedFmp (
|
||||
FullCapsuleBuffer = NULL;
|
||||
|
||||
CapsuleName = Argv[2];
|
||||
Status = ReadFileToBuffer(CapsuleName, &FileSize, &CapsuleBuffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"CapsuleApp: Capsule image (%s) is not found.\n", CapsuleName);
|
||||
Status = ReadFileToBuffer (CapsuleName, &FileSize, &CapsuleBuffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"CapsuleApp: Capsule image (%s) is not found.\n", CapsuleName);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (!IsValidCapsuleHeader (CapsuleBuffer, FileSize)) {
|
||||
Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
|
||||
Print (L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (!IsFmpCapsuleGuid (&((EFI_CAPSULE_HEADER *) CapsuleBuffer)->CapsuleGuid)) {
|
||||
Print(L"CapsuleApp: Capsule image (%s) is not a FMP capsule.\n", CapsuleName);
|
||||
if (!IsFmpCapsuleGuid (&((EFI_CAPSULE_HEADER *)CapsuleBuffer)->CapsuleGuid)) {
|
||||
Print (L"CapsuleApp: Capsule image (%s) is not a FMP capsule.\n", CapsuleName);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
ImageTypeId = GetCapsuleImageTypeId(CapsuleBuffer);
|
||||
ImageTypeId = GetCapsuleImageTypeId (CapsuleBuffer);
|
||||
if (ImageTypeId == NULL) {
|
||||
Print(L"CapsuleApp: Capsule ImageTypeId is not found.\n");
|
||||
Print (L"CapsuleApp: Capsule ImageTypeId is not found.\n");
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
FwType = GetEsrtFwType(ImageTypeId);
|
||||
|
||||
FwType = GetEsrtFwType (ImageTypeId);
|
||||
if ((FwType != ESRT_FW_TYPE_SYSTEMFIRMWARE) && (FwType != ESRT_FW_TYPE_DEVICEFIRMWARE)) {
|
||||
Print(L"CapsuleApp: Capsule FwType is invalid.\n");
|
||||
Print (L"CapsuleApp: Capsule FwType is invalid.\n");
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
FullCapsuleBufferSize = NESTED_CAPSULE_HEADER_SIZE + FileSize;
|
||||
FullCapsuleBuffer = AllocatePool(FullCapsuleBufferSize);
|
||||
FullCapsuleBuffer = AllocatePool (FullCapsuleBufferSize);
|
||||
if (FullCapsuleBuffer == NULL) {
|
||||
Print(L"CapsuleApp: Capsule Buffer size (0x%x) too big.\n", FullCapsuleBufferSize);
|
||||
Print (L"CapsuleApp: Capsule Buffer size (0x%x) too big.\n", FullCapsuleBufferSize);
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
NestedCapsuleHeader = (EFI_CAPSULE_HEADER *)FullCapsuleBuffer;
|
||||
ZeroMem(NestedCapsuleHeader, NESTED_CAPSULE_HEADER_SIZE);
|
||||
CopyGuid(&NestedCapsuleHeader->CapsuleGuid, ImageTypeId);
|
||||
ZeroMem (NestedCapsuleHeader, NESTED_CAPSULE_HEADER_SIZE);
|
||||
CopyGuid (&NestedCapsuleHeader->CapsuleGuid, ImageTypeId);
|
||||
NestedCapsuleHeader->HeaderSize = NESTED_CAPSULE_HEADER_SIZE;
|
||||
NestedCapsuleHeader->Flags = (FwType == ESRT_FW_TYPE_SYSTEMFIRMWARE) ? SYSTEM_FIRMWARE_FLAG : DEVICE_FIRMWARE_FLAG;
|
||||
NestedCapsuleHeader->CapsuleImageSize = (UINT32)FullCapsuleBufferSize;
|
||||
|
||||
CopyMem((UINT8 *)NestedCapsuleHeader + NestedCapsuleHeader->HeaderSize, CapsuleBuffer, FileSize);
|
||||
CopyMem ((UINT8 *)NestedCapsuleHeader + NestedCapsuleHeader->HeaderSize, CapsuleBuffer, FileSize);
|
||||
|
||||
Status = WriteFileFromBuffer(OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);
|
||||
Print(L"CapsuleApp: Write %s %r\n", OutputCapsuleName, Status);
|
||||
Status = WriteFileFromBuffer (OutputCapsuleName, FullCapsuleBufferSize, FullCapsuleBuffer);
|
||||
Print (L"CapsuleApp: Write %s %r\n", OutputCapsuleName, Status);
|
||||
|
||||
Done:
|
||||
if (CapsuleBuffer != NULL) {
|
||||
FreePool(CapsuleBuffer);
|
||||
FreePool (CapsuleBuffer);
|
||||
}
|
||||
|
||||
if (FullCapsuleBuffer != NULL) {
|
||||
FreePool(FullCapsuleBuffer);
|
||||
FreePool (FullCapsuleBuffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear capsule status variable.
|
||||
|
||||
@ -397,13 +409,13 @@ ClearCapsuleStatusVariable (
|
||||
CHAR16 *TempVarName;
|
||||
BOOLEAN Found;
|
||||
|
||||
StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CapsuleVarName[0]), L"Capsule");
|
||||
StrCpyS (CapsuleVarName, sizeof (CapsuleVarName)/sizeof (CapsuleVarName[0]), L"Capsule");
|
||||
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
|
||||
Index = 0;
|
||||
|
||||
Found = FALSE;
|
||||
while (TRUE) {
|
||||
UnicodeSPrint (TempVarName, 5 * sizeof(CHAR16), L"%04x", Index);
|
||||
UnicodeSPrint (TempVarName, 5 * sizeof (CHAR16), L"%04x", Index);
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
CapsuleVarName,
|
||||
@ -418,6 +430,7 @@ ClearCapsuleStatusVariable (
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
Found = TRUE;
|
||||
|
||||
Print (L"Clear %s %r\n", CapsuleVarName, Status);
|
||||
@ -489,8 +502,8 @@ BuildGatherList (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ERREXIT;
|
||||
} else {
|
||||
Print (L"CapsuleApp: creating capsule descriptors at 0x%X\n", (UINTN) BlockDescriptors1);
|
||||
Print (L"CapsuleApp: capsule data starts at 0x%X with size 0x%X\n", (UINTN) CapsuleBuffer[Index], FileSize[Index]);
|
||||
Print (L"CapsuleApp: creating capsule descriptors at 0x%X\n", (UINTN)BlockDescriptors1);
|
||||
Print (L"CapsuleApp: capsule data starts at 0x%X with size 0x%X\n", (UINTN)CapsuleBuffer[Index], FileSize[Index]);
|
||||
}
|
||||
|
||||
//
|
||||
@ -501,7 +514,7 @@ BuildGatherList (
|
||||
}
|
||||
|
||||
if (BlockDescriptorPre != NULL) {
|
||||
BlockDescriptorPre->Union.ContinuationPointer = (UINTN) BlockDescriptors1;
|
||||
BlockDescriptorPre->Union.ContinuationPointer = (UINTN)BlockDescriptors1;
|
||||
BlockDescriptorPre->Length = 0;
|
||||
}
|
||||
|
||||
@ -524,9 +537,10 @@ BuildGatherList (
|
||||
} else {
|
||||
Size = SizeLeft;
|
||||
}
|
||||
|
||||
TempBlockPtr->Union.DataBlock = (UINTN)TempDataPtr;
|
||||
TempBlockPtr->Length = Size;
|
||||
Print (L"CapsuleApp: capsule block/size 0x%X/0x%X\n", (UINTN) TempDataPtr, Size);
|
||||
Print (L"CapsuleApp: capsule block/size 0x%X/0x%X\n", (UINTN)TempDataPtr, Size);
|
||||
SizeLeft -= Size;
|
||||
TempDataPtr += Size;
|
||||
TempBlockPtr++;
|
||||
@ -555,7 +569,7 @@ BuildGatherList (
|
||||
//
|
||||
// Point the first list's last element to point to this second list.
|
||||
//
|
||||
TempBlockPtr->Union.ContinuationPointer = (UINTN) BlockDescriptors2;
|
||||
TempBlockPtr->Union.ContinuationPointer = (UINTN)BlockDescriptors2;
|
||||
|
||||
TempBlockPtr->Length = 0;
|
||||
TempBlockPtr = BlockDescriptors2;
|
||||
@ -578,7 +592,7 @@ BuildGatherList (
|
||||
|
||||
TempBlockPtr->Union.DataBlock = (UINTN)TempDataPtr;
|
||||
TempBlockPtr->Length = Size;
|
||||
Print (L"CapsuleApp: capsule block/size 0x%X/0x%X\n", (UINTN) TempDataPtr, Size);
|
||||
Print (L"CapsuleApp: capsule block/size 0x%X/0x%X\n", (UINTN)TempDataPtr, Size);
|
||||
SizeLeft -= Size;
|
||||
TempDataPtr += Size;
|
||||
TempBlockPtr++;
|
||||
@ -605,11 +619,11 @@ BuildGatherList (
|
||||
|
||||
ERREXIT:
|
||||
if (BlockDescriptors1 != NULL) {
|
||||
FreePool(BlockDescriptors1);
|
||||
FreePool (BlockDescriptors1);
|
||||
}
|
||||
|
||||
if (BlockDescriptors2 != NULL) {
|
||||
FreePool(BlockDescriptors2);
|
||||
FreePool (BlockDescriptors2);
|
||||
}
|
||||
|
||||
return Status;
|
||||
@ -634,7 +648,7 @@ CleanGatherList (
|
||||
|
||||
if (BlockDescriptors != NULL) {
|
||||
TempBlockPtr1 = BlockDescriptors;
|
||||
while (1){
|
||||
while (1) {
|
||||
TempBlockPtr = TempBlockPtr1;
|
||||
for (Index = 0; Index < CapsuleNum; Index++) {
|
||||
if (TempBlockPtr[Index].Length == 0) {
|
||||
@ -646,8 +660,8 @@ CleanGatherList (
|
||||
break;
|
||||
}
|
||||
|
||||
TempBlockPtr2 = (VOID *) ((UINTN) TempBlockPtr[Index].Union.ContinuationPointer);
|
||||
FreePool(TempBlockPtr1);
|
||||
TempBlockPtr2 = (VOID *)((UINTN)TempBlockPtr[Index].Union.ContinuationPointer);
|
||||
FreePool (TempBlockPtr1);
|
||||
TempBlockPtr1 = TempBlockPtr2;
|
||||
}
|
||||
}
|
||||
@ -661,42 +675,42 @@ PrintUsage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
Print(L"CapsuleApp: usage\n");
|
||||
Print(L" CapsuleApp <Capsule...> [-NR] [-OD [FSx]]\n");
|
||||
Print(L" CapsuleApp -S\n");
|
||||
Print(L" CapsuleApp -C\n");
|
||||
Print(L" CapsuleApp -P\n");
|
||||
Print(L" CapsuleApp -E\n");
|
||||
Print(L" CapsuleApp -L\n");
|
||||
Print(L" CapsuleApp -L INFO\n");
|
||||
Print(L" CapsuleApp -F\n");
|
||||
Print(L" CapsuleApp -G <BMP> -O <Capsule>\n");
|
||||
Print(L" CapsuleApp -N <Capsule> -O <NestedCapsule>\n");
|
||||
Print(L" CapsuleApp -D <Capsule>\n");
|
||||
Print(L" CapsuleApp -P GET <ImageTypeId> <Index> -O <FileName>\n");
|
||||
Print(L"Parameter:\n");
|
||||
Print(L" -NR: No reset will be triggered for the capsule\n");
|
||||
Print(L" with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without CAPSULE_FLAGS_INITIATE_RESET.\n");
|
||||
Print(L" -OD: Delivery of Capsules via file on Mass Storage device.\n");
|
||||
Print(L" -S: Dump capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
|
||||
Print(L" which is defined in UEFI specification.\n");
|
||||
Print(L" -C: Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
|
||||
Print(L" which is defined in UEFI specification.\n");
|
||||
Print(L" -P: Dump UEFI FMP protocol info, or get image with specified\n");
|
||||
Print(L" ImageTypeId and Index (decimal format) to a file if 'GET'\n");
|
||||
Print(L" option is used.\n");
|
||||
Print(L" -E: Dump UEFI ESRT table info.\n");
|
||||
Print(L" -L: Dump provisioned capsule image information.\n");
|
||||
Print(L" -F: Dump all EFI System Partition.\n");
|
||||
Print(L" -G: Convert a BMP file to be an UX capsule,\n");
|
||||
Print(L" according to Windows Firmware Update document\n");
|
||||
Print(L" -N: Append a Capsule Header to an existing FMP capsule image\n");
|
||||
Print(L" with its ImageTypeId supported by the system,\n");
|
||||
Print(L" according to Windows Firmware Update document\n");
|
||||
Print(L" -O: Output new Capsule file name\n");
|
||||
Print(L" -D: Dump Capsule image header information, image payload\n");
|
||||
Print(L" information if it is an UX capsule and FMP header\n");
|
||||
Print(L" information if it is a FMP capsule.\n");
|
||||
Print (L"CapsuleApp: usage\n");
|
||||
Print (L" CapsuleApp <Capsule...> [-NR] [-OD [FSx]]\n");
|
||||
Print (L" CapsuleApp -S\n");
|
||||
Print (L" CapsuleApp -C\n");
|
||||
Print (L" CapsuleApp -P\n");
|
||||
Print (L" CapsuleApp -E\n");
|
||||
Print (L" CapsuleApp -L\n");
|
||||
Print (L" CapsuleApp -L INFO\n");
|
||||
Print (L" CapsuleApp -F\n");
|
||||
Print (L" CapsuleApp -G <BMP> -O <Capsule>\n");
|
||||
Print (L" CapsuleApp -N <Capsule> -O <NestedCapsule>\n");
|
||||
Print (L" CapsuleApp -D <Capsule>\n");
|
||||
Print (L" CapsuleApp -P GET <ImageTypeId> <Index> -O <FileName>\n");
|
||||
Print (L"Parameter:\n");
|
||||
Print (L" -NR: No reset will be triggered for the capsule\n");
|
||||
Print (L" with CAPSULE_FLAGS_PERSIST_ACROSS_RESET and without CAPSULE_FLAGS_INITIATE_RESET.\n");
|
||||
Print (L" -OD: Delivery of Capsules via file on Mass Storage device.\n");
|
||||
Print (L" -S: Dump capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
|
||||
Print (L" which is defined in UEFI specification.\n");
|
||||
Print (L" -C: Clear capsule report variable (EFI_CAPSULE_REPORT_GUID),\n");
|
||||
Print (L" which is defined in UEFI specification.\n");
|
||||
Print (L" -P: Dump UEFI FMP protocol info, or get image with specified\n");
|
||||
Print (L" ImageTypeId and Index (decimal format) to a file if 'GET'\n");
|
||||
Print (L" option is used.\n");
|
||||
Print (L" -E: Dump UEFI ESRT table info.\n");
|
||||
Print (L" -L: Dump provisioned capsule image information.\n");
|
||||
Print (L" -F: Dump all EFI System Partition.\n");
|
||||
Print (L" -G: Convert a BMP file to be an UX capsule,\n");
|
||||
Print (L" according to Windows Firmware Update document\n");
|
||||
Print (L" -N: Append a Capsule Header to an existing FMP capsule image\n");
|
||||
Print (L" with its ImageTypeId supported by the system,\n");
|
||||
Print (L" according to Windows Firmware Update document\n");
|
||||
Print (L" -O: Output new Capsule file name\n");
|
||||
Print (L" -D: Dump Capsule image header information, image payload\n");
|
||||
Print (L" information if it is an UX capsule and FMP header\n");
|
||||
Print (L" information if it is a FMP capsule.\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -742,50 +756,59 @@ UefiMain (
|
||||
MapFsStr = NULL;
|
||||
CapsuleNum = 0;
|
||||
|
||||
Status = GetArg();
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"Please use UEFI SHELL to run this application!\n", Status);
|
||||
Status = GetArg ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"Please use UEFI SHELL to run this application!\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Argc < 2) {
|
||||
PrintUsage();
|
||||
PrintUsage ();
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
if (StrCmp(Argv[1], L"-D") == 0) {
|
||||
|
||||
if (StrCmp (Argv[1], L"-D") == 0) {
|
||||
if (Argc != 3) {
|
||||
Print(L"CapsuleApp: Incorrect parameter count.\n");
|
||||
Print (L"CapsuleApp: Incorrect parameter count.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
Status = DumpCapsule(Argv[2]);
|
||||
|
||||
Status = DumpCapsule (Argv[2]);
|
||||
return Status;
|
||||
}
|
||||
if (StrCmp(Argv[1], L"-G") == 0) {
|
||||
Status = CreateBmpFmp();
|
||||
|
||||
if (StrCmp (Argv[1], L"-G") == 0) {
|
||||
Status = CreateBmpFmp ();
|
||||
return Status;
|
||||
}
|
||||
if (StrCmp(Argv[1], L"-N") == 0) {
|
||||
Status = CreateNestedFmp();
|
||||
|
||||
if (StrCmp (Argv[1], L"-N") == 0) {
|
||||
Status = CreateNestedFmp ();
|
||||
return Status;
|
||||
}
|
||||
if (StrCmp(Argv[1], L"-S") == 0) {
|
||||
Status = DumpCapsuleStatusVariable();
|
||||
|
||||
if (StrCmp (Argv[1], L"-S") == 0) {
|
||||
Status = DumpCapsuleStatusVariable ();
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
if (StrCmp(Argv[1], L"-C") == 0) {
|
||||
Status = ClearCapsuleStatusVariable();
|
||||
|
||||
if (StrCmp (Argv[1], L"-C") == 0) {
|
||||
Status = ClearCapsuleStatusVariable ();
|
||||
return Status;
|
||||
}
|
||||
if (StrCmp(Argv[1], L"-P") == 0) {
|
||||
|
||||
if (StrCmp (Argv[1], L"-P") == 0) {
|
||||
if (Argc == 2) {
|
||||
DumpFmpData();
|
||||
DumpFmpData ();
|
||||
}
|
||||
|
||||
if (Argc >= 3) {
|
||||
if (StrCmp(Argv[2], L"GET") != 0) {
|
||||
Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]);
|
||||
if (StrCmp (Argv[2], L"GET") != 0) {
|
||||
Print (L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]);
|
||||
return EFI_UNSUPPORTED;
|
||||
} else {
|
||||
if (Argc != 7) {
|
||||
Print(L"CapsuleApp: Incorrect parameter count.\n");
|
||||
Print (L"CapsuleApp: Incorrect parameter count.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -797,38 +820,42 @@ UefiMain (
|
||||
Print (L"Invalid ImageTypeId - %s\n", Argv[3]);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
ImageIndex = StrDecimalToUintn(Argv[4]);
|
||||
if (StrCmp(Argv[5], L"-O") != 0) {
|
||||
Print(L"CapsuleApp: NO output file name.\n");
|
||||
|
||||
ImageIndex = StrDecimalToUintn (Argv[4]);
|
||||
if (StrCmp (Argv[5], L"-O") != 0) {
|
||||
Print (L"CapsuleApp: NO output file name.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
DumpFmpImage(&ImageTypeId, ImageIndex, Argv[6]);
|
||||
|
||||
DumpFmpImage (&ImageTypeId, ImageIndex, Argv[6]);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (StrCmp(Argv[1], L"-E") == 0) {
|
||||
DumpEsrtData();
|
||||
if (StrCmp (Argv[1], L"-E") == 0) {
|
||||
DumpEsrtData ();
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (StrCmp(Argv[1], L"-L") == 0) {
|
||||
if (Argc >= 3 && StrCmp(Argv[2], L"INFO") == 0) {
|
||||
DumpProvisionedCapsule(TRUE);
|
||||
if (StrCmp (Argv[1], L"-L") == 0) {
|
||||
if ((Argc >= 3) && (StrCmp (Argv[2], L"INFO") == 0)) {
|
||||
DumpProvisionedCapsule (TRUE);
|
||||
} else {
|
||||
DumpProvisionedCapsule(FALSE);
|
||||
DumpProvisionedCapsule (FALSE);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (StrCmp(Argv[1], L"-F") == 0) {
|
||||
DumpAllEfiSysPartition();
|
||||
if (StrCmp (Argv[1], L"-F") == 0) {
|
||||
DumpAllEfiSysPartition ();
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (Argv[1][0] == L'-') {
|
||||
Print(L"CapsuleApp: Unrecognized option(%s).\n", Argv[1]);
|
||||
Print (L"CapsuleApp: Unrecognized option(%s).\n", Argv[1]);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -839,10 +866,10 @@ UefiMain (
|
||||
ParaNrIndex = 0;
|
||||
|
||||
for (Index = 1; Index < Argc; Index++) {
|
||||
if (StrCmp(Argv[Index], L"-OD") == 0) {
|
||||
if (StrCmp (Argv[Index], L"-OD") == 0) {
|
||||
ParaOdIndex = Index;
|
||||
CapsuleOnDisk = TRUE;
|
||||
} else if (StrCmp(Argv[Index], L"-NR") == 0) {
|
||||
} else if (StrCmp (Argv[Index], L"-NR") == 0) {
|
||||
ParaNrIndex = Index;
|
||||
NoReset = TRUE;
|
||||
}
|
||||
@ -886,37 +913,40 @@ UefiMain (
|
||||
CapsuleNum = CapsuleLastIndex - CapsuleFirstIndex + 1;
|
||||
|
||||
if (CapsuleFirstIndex > CapsuleLastIndex) {
|
||||
Print(L"CapsuleApp: NO capsule image.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
if (CapsuleNum > MAX_CAPSULE_NUM) {
|
||||
Print(L"CapsuleApp: Too many capsule images.\n");
|
||||
Print (L"CapsuleApp: NO capsule image.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ZeroMem(&CapsuleBuffer, sizeof(CapsuleBuffer));
|
||||
ZeroMem(&CapsuleBufferSize, sizeof(CapsuleBufferSize));
|
||||
if (CapsuleNum > MAX_CAPSULE_NUM) {
|
||||
Print (L"CapsuleApp: Too many capsule images.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ZeroMem (&CapsuleBuffer, sizeof (CapsuleBuffer));
|
||||
ZeroMem (&CapsuleBufferSize, sizeof (CapsuleBufferSize));
|
||||
BlockDescriptors = NULL;
|
||||
|
||||
for (Index = 0; Index < CapsuleNum; Index++) {
|
||||
CapsuleName = Argv[CapsuleFirstIndex + Index];
|
||||
Status = ReadFileToBuffer(CapsuleName, &CapsuleBufferSize[Index], &CapsuleBuffer[Index]);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"CapsuleApp: capsule image (%s) is not found.\n", CapsuleName);
|
||||
Status = ReadFileToBuffer (CapsuleName, &CapsuleBufferSize[Index], &CapsuleBuffer[Index]);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"CapsuleApp: capsule image (%s) is not found.\n", CapsuleName);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (!IsValidCapsuleHeader (CapsuleBuffer[Index], CapsuleBufferSize[Index])) {
|
||||
Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
|
||||
Print (L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CapsuleNames[Index] = CapsuleName;
|
||||
}
|
||||
|
||||
//
|
||||
// Every capsule use 2 descriptor 1 for data 1 for end
|
||||
//
|
||||
Status = BuildGatherList(CapsuleBuffer, CapsuleBufferSize, CapsuleNum, &BlockDescriptors);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = BuildGatherList (CapsuleBuffer, CapsuleBufferSize, CapsuleNum, &BlockDescriptors);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
@ -925,18 +955,19 @@ UefiMain (
|
||||
//
|
||||
NeedReset = FALSE;
|
||||
for (Index = 0; Index < CapsuleNum; Index++) {
|
||||
CapsuleHeaderArray[Index] = (EFI_CAPSULE_HEADER *) CapsuleBuffer[Index];
|
||||
CapsuleHeaderArray[Index] = (EFI_CAPSULE_HEADER *)CapsuleBuffer[Index];
|
||||
if ((CapsuleHeaderArray[Index]->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
|
||||
NeedReset = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
CapsuleHeaderArray[CapsuleNum] = NULL;
|
||||
|
||||
//
|
||||
// Inquire platform capability of UpdateCapsule.
|
||||
//
|
||||
Status = gRT->QueryCapsuleCapabilities (CapsuleHeaderArray, CapsuleNum, &MaxCapsuleSize, &ResetType);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"CapsuleApp: failed to query capsule capability - %r\n", Status);
|
||||
goto Done;
|
||||
}
|
||||
@ -970,11 +1001,12 @@ UefiMain (
|
||||
// Check whether the input capsule image has the flag of persist across system reset.
|
||||
//
|
||||
if (NeedReset) {
|
||||
Status = gRT->UpdateCapsule(CapsuleHeaderArray,CapsuleNum,(UINTN) BlockDescriptors);
|
||||
Status = gRT->UpdateCapsule (CapsuleHeaderArray, CapsuleNum, (UINTN)BlockDescriptors);
|
||||
if (Status != EFI_SUCCESS) {
|
||||
Print (L"CapsuleApp: failed to update capsule - %r\n", Status);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// For capsule with CAPSULE_FLAGS_PERSIST_ACROSS_RESET + CAPSULE_FLAGS_INITIATE_RESET,
|
||||
// a system reset should have been triggered by gRT->UpdateCapsule() calling above.
|
||||
@ -994,7 +1026,7 @@ UefiMain (
|
||||
// For capsule who has no reset flag, only call UpdateCapsule Service without a
|
||||
// system reset. The service will process the capsule immediately.
|
||||
//
|
||||
Status = gRT->UpdateCapsule (CapsuleHeaderArray,CapsuleNum,(UINTN) BlockDescriptors);
|
||||
Status = gRT->UpdateCapsule (CapsuleHeaderArray, CapsuleNum, (UINTN)BlockDescriptors);
|
||||
if (Status != EFI_SUCCESS) {
|
||||
Print (L"CapsuleApp: failed to update capsule - %r\n", Status);
|
||||
}
|
||||
@ -1009,7 +1041,7 @@ Done:
|
||||
}
|
||||
}
|
||||
|
||||
CleanGatherList(BlockDescriptors, CapsuleNum);
|
||||
CleanGatherList (BlockDescriptors, CapsuleNum);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _CAPSULE_APP_H_
|
||||
#define _CAPSULE_APP_H_
|
||||
|
||||
@ -81,7 +80,6 @@ GetShellProtocol (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Read a file.
|
||||
|
||||
@ -118,7 +116,6 @@ WriteFileFromBuffer (
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Dump capsule information
|
||||
|
||||
@ -193,7 +190,6 @@ DumpAllEfiSysPartition (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Get SimpleFileSystem from boot option file path.
|
||||
|
||||
@ -213,7 +209,6 @@ GetEfiSysPartitionFromBootOptionFilePath (
|
||||
OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Process Capsule On Disk.
|
||||
|
||||
@ -237,4 +232,3 @@ ProcessCapsuleOnDisk (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -37,22 +37,22 @@ DumpUxCapsule (
|
||||
)
|
||||
{
|
||||
EFI_DISPLAY_CAPSULE *DisplayCapsule;
|
||||
DisplayCapsule = (EFI_DISPLAY_CAPSULE *)CapsuleHeader;
|
||||
Print(L"[UxCapsule]\n");
|
||||
Print(L"CapsuleHeader:\n");
|
||||
Print(L" CapsuleGuid - %g\n", &DisplayCapsule->CapsuleHeader.CapsuleGuid);
|
||||
Print(L" HeaderSize - 0x%x\n", DisplayCapsule->CapsuleHeader.HeaderSize);
|
||||
Print(L" Flags - 0x%x\n", DisplayCapsule->CapsuleHeader.Flags);
|
||||
Print(L" CapsuleImageSize - 0x%x\n", DisplayCapsule->CapsuleHeader.CapsuleImageSize);
|
||||
Print(L"ImagePayload:\n");
|
||||
Print(L" Version - 0x%x\n", DisplayCapsule->ImagePayload.Version);
|
||||
Print(L" Checksum - 0x%x\n", DisplayCapsule->ImagePayload.Checksum);
|
||||
Print(L" ImageType - 0x%x\n", DisplayCapsule->ImagePayload.ImageType);
|
||||
Print(L" Mode - 0x%x\n", DisplayCapsule->ImagePayload.Mode);
|
||||
Print(L" OffsetX - 0x%x\n", DisplayCapsule->ImagePayload.OffsetX);
|
||||
Print(L" OffsetY - 0x%x\n", DisplayCapsule->ImagePayload.OffsetY);
|
||||
}
|
||||
|
||||
DisplayCapsule = (EFI_DISPLAY_CAPSULE *)CapsuleHeader;
|
||||
Print (L"[UxCapsule]\n");
|
||||
Print (L"CapsuleHeader:\n");
|
||||
Print (L" CapsuleGuid - %g\n", &DisplayCapsule->CapsuleHeader.CapsuleGuid);
|
||||
Print (L" HeaderSize - 0x%x\n", DisplayCapsule->CapsuleHeader.HeaderSize);
|
||||
Print (L" Flags - 0x%x\n", DisplayCapsule->CapsuleHeader.Flags);
|
||||
Print (L" CapsuleImageSize - 0x%x\n", DisplayCapsule->CapsuleHeader.CapsuleImageSize);
|
||||
Print (L"ImagePayload:\n");
|
||||
Print (L" Version - 0x%x\n", DisplayCapsule->ImagePayload.Version);
|
||||
Print (L" Checksum - 0x%x\n", DisplayCapsule->ImagePayload.Checksum);
|
||||
Print (L" ImageType - 0x%x\n", DisplayCapsule->ImagePayload.ImageType);
|
||||
Print (L" Mode - 0x%x\n", DisplayCapsule->ImagePayload.Mode);
|
||||
Print (L" OffsetX - 0x%x\n", DisplayCapsule->ImagePayload.OffsetX);
|
||||
Print (L" OffsetY - 0x%x\n", DisplayCapsule->ImagePayload.OffsetY);
|
||||
}
|
||||
|
||||
/**
|
||||
Dump a non-nested FMP capsule.
|
||||
@ -70,36 +70,36 @@ DumpFmpCapsule (
|
||||
UINTN Count;
|
||||
EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *FmpImageHeader;
|
||||
|
||||
Print(L"[FmpCapsule]\n");
|
||||
Print(L"CapsuleHeader:\n");
|
||||
Print(L" CapsuleGuid - %g\n", &CapsuleHeader->CapsuleGuid);
|
||||
Print(L" HeaderSize - 0x%x\n", CapsuleHeader->HeaderSize);
|
||||
Print(L" Flags - 0x%x\n", CapsuleHeader->Flags);
|
||||
Print(L" CapsuleImageSize - 0x%x\n", CapsuleHeader->CapsuleImageSize);
|
||||
Print (L"[FmpCapsule]\n");
|
||||
Print (L"CapsuleHeader:\n");
|
||||
Print (L" CapsuleGuid - %g\n", &CapsuleHeader->CapsuleGuid);
|
||||
Print (L" HeaderSize - 0x%x\n", CapsuleHeader->HeaderSize);
|
||||
Print (L" Flags - 0x%x\n", CapsuleHeader->Flags);
|
||||
Print (L" CapsuleImageSize - 0x%x\n", CapsuleHeader->CapsuleImageSize);
|
||||
|
||||
FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
|
||||
ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
|
||||
Print(L"FmpHeader:\n");
|
||||
Print(L" Version - 0x%x\n", FmpCapsuleHeader->Version);
|
||||
Print(L" EmbeddedDriverCount - 0x%x\n", FmpCapsuleHeader->EmbeddedDriverCount);
|
||||
Print(L" PayloadItemCount - 0x%x\n", FmpCapsuleHeader->PayloadItemCount);
|
||||
Print (L"FmpHeader:\n");
|
||||
Print (L" Version - 0x%x\n", FmpCapsuleHeader->Version);
|
||||
Print (L" EmbeddedDriverCount - 0x%x\n", FmpCapsuleHeader->EmbeddedDriverCount);
|
||||
Print (L" PayloadItemCount - 0x%x\n", FmpCapsuleHeader->PayloadItemCount);
|
||||
Count = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;
|
||||
for (Index = 0; Index < Count; Index++) {
|
||||
Print(L" Offset[%d] - 0x%x\n", Index, ItemOffsetList[Index]);
|
||||
Print (L" Offset[%d] - 0x%x\n", Index, ItemOffsetList[Index]);
|
||||
}
|
||||
|
||||
for (Index = FmpCapsuleHeader->EmbeddedDriverCount; Index < Count; Index++) {
|
||||
Print(L"FmpPayload[%d] ImageHeader:\n", Index);
|
||||
Print (L"FmpPayload[%d] ImageHeader:\n", Index);
|
||||
FmpImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
|
||||
Print(L" Version - 0x%x\n", FmpImageHeader->Version);
|
||||
Print(L" UpdateImageTypeId - %g\n", &FmpImageHeader->UpdateImageTypeId);
|
||||
Print(L" UpdateImageIndex - 0x%x\n", FmpImageHeader->UpdateImageIndex);
|
||||
Print(L" UpdateImageSize - 0x%x\n", FmpImageHeader->UpdateImageSize);
|
||||
Print(L" UpdateVendorCodeSize - 0x%x\n", FmpImageHeader->UpdateVendorCodeSize);
|
||||
Print (L" Version - 0x%x\n", FmpImageHeader->Version);
|
||||
Print (L" UpdateImageTypeId - %g\n", &FmpImageHeader->UpdateImageTypeId);
|
||||
Print (L" UpdateImageIndex - 0x%x\n", FmpImageHeader->UpdateImageIndex);
|
||||
Print (L" UpdateImageSize - 0x%x\n", FmpImageHeader->UpdateImageSize);
|
||||
Print (L" UpdateVendorCodeSize - 0x%x\n", FmpImageHeader->UpdateVendorCodeSize);
|
||||
if (FmpImageHeader->Version >= 2) {
|
||||
Print(L" UpdateHardwareInstance - 0x%lx\n", FmpImageHeader->UpdateHardwareInstance);
|
||||
Print (L" UpdateHardwareInstance - 0x%lx\n", FmpImageHeader->UpdateHardwareInstance);
|
||||
if (FmpImageHeader->Version >= EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
|
||||
Print(L" ImageCapsuleSupport - 0x%lx\n", FmpImageHeader->ImageCapsuleSupport);
|
||||
Print (L" ImageCapsuleSupport - 0x%lx\n", FmpImageHeader->ImageCapsuleSupport);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,12 +130,12 @@ IsNestedFmpCapsule (
|
||||
// Check ESRT
|
||||
//
|
||||
EsrtGuidFound = FALSE;
|
||||
Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = EfiGetSystemConfigurationTable (&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ASSERT (Esrt != NULL);
|
||||
EsrtEntry = (VOID *)(Esrt + 1);
|
||||
for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) {
|
||||
if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
|
||||
if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
|
||||
EsrtGuidFound = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -152,12 +152,14 @@ IsNestedFmpCapsule (
|
||||
//
|
||||
NestedCapsuleHeader = (EFI_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
|
||||
NestedCapsuleSize = (UINTN)CapsuleHeader + CapsuleHeader->CapsuleImageSize- (UINTN)NestedCapsuleHeader;
|
||||
if (NestedCapsuleSize < sizeof(EFI_CAPSULE_HEADER)) {
|
||||
if (NestedCapsuleSize < sizeof (EFI_CAPSULE_HEADER)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!CompareGuid(&NestedCapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
|
||||
if (!CompareGuid (&NestedCapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -180,41 +182,44 @@ DumpCapsule (
|
||||
EFI_STATUS Status;
|
||||
|
||||
Buffer = NULL;
|
||||
Status = ReadFileToBuffer(CapsuleName, &FileSize, &Buffer);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"CapsuleApp: Capsule (%s) is not found.\n", CapsuleName);
|
||||
Status = ReadFileToBuffer (CapsuleName, &FileSize, &Buffer);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"CapsuleApp: Capsule (%s) is not found.\n", CapsuleName);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (!IsValidCapsuleHeader (Buffer, FileSize)) {
|
||||
Print(L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
|
||||
Print (L"CapsuleApp: Capsule image (%s) is not a valid capsule.\n", CapsuleName);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
CapsuleHeader = Buffer;
|
||||
if (CompareGuid(&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
|
||||
DumpUxCapsule(CapsuleHeader);
|
||||
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
|
||||
DumpUxCapsule (CapsuleHeader);
|
||||
Status = EFI_SUCCESS;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (CompareGuid(&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
DumpFmpCapsule(CapsuleHeader);
|
||||
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
DumpFmpCapsule (CapsuleHeader);
|
||||
}
|
||||
if (IsNestedFmpCapsule(CapsuleHeader)) {
|
||||
Print(L"[NestedCapsule]\n");
|
||||
Print(L"CapsuleHeader:\n");
|
||||
Print(L" CapsuleGuid - %g\n", &CapsuleHeader->CapsuleGuid);
|
||||
Print(L" HeaderSize - 0x%x\n", CapsuleHeader->HeaderSize);
|
||||
Print(L" Flags - 0x%x\n", CapsuleHeader->Flags);
|
||||
Print(L" CapsuleImageSize - 0x%x\n", CapsuleHeader->CapsuleImageSize);
|
||||
DumpFmpCapsule((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize));
|
||||
|
||||
if (IsNestedFmpCapsule (CapsuleHeader)) {
|
||||
Print (L"[NestedCapsule]\n");
|
||||
Print (L"CapsuleHeader:\n");
|
||||
Print (L" CapsuleGuid - %g\n", &CapsuleHeader->CapsuleGuid);
|
||||
Print (L" HeaderSize - 0x%x\n", CapsuleHeader->HeaderSize);
|
||||
Print (L" Flags - 0x%x\n", CapsuleHeader->Flags);
|
||||
Print (L" CapsuleImageSize - 0x%x\n", CapsuleHeader->CapsuleImageSize);
|
||||
DumpFmpCapsule ((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize));
|
||||
}
|
||||
|
||||
Done:
|
||||
if (Buffer != NULL) {
|
||||
FreePool(Buffer);
|
||||
FreePool (Buffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -241,80 +246,81 @@ DumpCapsuleStatusVariable (
|
||||
CHAR16 *CapsuleFileName;
|
||||
CHAR16 *CapsuleTarget;
|
||||
|
||||
Status = GetVariable2(
|
||||
Status = GetVariable2 (
|
||||
L"CapsuleMax",
|
||||
&gEfiCapsuleReportGuid,
|
||||
(VOID **)&CapsuleIndex,
|
||||
NULL
|
||||
);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ASSERT (CapsuleIndex != NULL);
|
||||
CopyMem(CapsuleIndexData, CapsuleIndex, 11 * sizeof(CHAR16));
|
||||
CopyMem (CapsuleIndexData, CapsuleIndex, 11 * sizeof (CHAR16));
|
||||
CapsuleIndexData[11] = 0;
|
||||
Print(L"CapsuleMax - %s\n", CapsuleIndexData);
|
||||
FreePool(CapsuleIndex);
|
||||
Print (L"CapsuleMax - %s\n", CapsuleIndexData);
|
||||
FreePool (CapsuleIndex);
|
||||
}
|
||||
Status = GetVariable2(
|
||||
|
||||
Status = GetVariable2 (
|
||||
L"CapsuleLast",
|
||||
&gEfiCapsuleReportGuid,
|
||||
(VOID **)&CapsuleIndex,
|
||||
NULL
|
||||
);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ASSERT (CapsuleIndex != NULL);
|
||||
CopyMem(CapsuleIndexData, CapsuleIndex, 11 * sizeof(CHAR16));
|
||||
CopyMem (CapsuleIndexData, CapsuleIndex, 11 * sizeof (CHAR16));
|
||||
CapsuleIndexData[11] = 0;
|
||||
Print(L"CapsuleLast - %s\n", CapsuleIndexData);
|
||||
FreePool(CapsuleIndex);
|
||||
Print (L"CapsuleLast - %s\n", CapsuleIndexData);
|
||||
FreePool (CapsuleIndex);
|
||||
}
|
||||
|
||||
|
||||
StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CapsuleVarName[0]), L"Capsule");
|
||||
StrCpyS (CapsuleVarName, sizeof (CapsuleVarName)/sizeof (CapsuleVarName[0]), L"Capsule");
|
||||
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
|
||||
Index = 0;
|
||||
|
||||
while (TRUE) {
|
||||
UnicodeSPrint (TempVarName, 5 * sizeof(CHAR16), L"%04x", Index);
|
||||
UnicodeSPrint (TempVarName, 5 * sizeof (CHAR16), L"%04x", Index);
|
||||
|
||||
Status = GetVariable2 (
|
||||
CapsuleVarName,
|
||||
&gEfiCapsuleReportGuid,
|
||||
(VOID **) &CapsuleResult,
|
||||
(VOID **)&CapsuleResult,
|
||||
NULL
|
||||
);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
break;
|
||||
} else if (EFI_ERROR(Status)) {
|
||||
} else if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSERT (CapsuleResult != NULL);
|
||||
|
||||
//
|
||||
// display capsule process status
|
||||
//
|
||||
if (CapsuleResult->VariableTotalSize >= sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER)) {
|
||||
if (CapsuleResult->VariableTotalSize >= sizeof (EFI_CAPSULE_RESULT_VARIABLE_HEADER)) {
|
||||
Print (L"CapsuleName: %s\n", CapsuleVarName);
|
||||
Print (L" Capsule Guid: %g\n", &CapsuleResult->CapsuleGuid);
|
||||
Print (L" Capsule ProcessedTime: %t\n", &CapsuleResult->CapsuleProcessed);
|
||||
Print (L" Capsule Status: %r\n", CapsuleResult->CapsuleStatus);
|
||||
}
|
||||
|
||||
if (CompareGuid(&CapsuleResult->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
if (CapsuleResult->VariableTotalSize >= sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof(CHAR16) * 2) {
|
||||
if (CompareGuid (&CapsuleResult->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
if (CapsuleResult->VariableTotalSize >= sizeof (EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof (EFI_CAPSULE_RESULT_VARIABLE_FMP) + sizeof (CHAR16) * 2) {
|
||||
CapsuleResultFmp = (EFI_CAPSULE_RESULT_VARIABLE_FMP *)(CapsuleResult + 1);
|
||||
Print(L" Capsule FMP Version: 0x%x\n", CapsuleResultFmp->Version);
|
||||
Print(L" Capsule FMP PayloadIndex: 0x%x\n", CapsuleResultFmp->PayloadIndex);
|
||||
Print(L" Capsule FMP UpdateImageIndex: 0x%x\n", CapsuleResultFmp->UpdateImageIndex);
|
||||
Print(L" Capsule FMP UpdateImageTypeId: %g\n", &CapsuleResultFmp->UpdateImageTypeId);
|
||||
Print (L" Capsule FMP Version: 0x%x\n", CapsuleResultFmp->Version);
|
||||
Print (L" Capsule FMP PayloadIndex: 0x%x\n", CapsuleResultFmp->PayloadIndex);
|
||||
Print (L" Capsule FMP UpdateImageIndex: 0x%x\n", CapsuleResultFmp->UpdateImageIndex);
|
||||
Print (L" Capsule FMP UpdateImageTypeId: %g\n", &CapsuleResultFmp->UpdateImageTypeId);
|
||||
CapsuleFileName = (CHAR16 *)(CapsuleResultFmp + 1);
|
||||
Print(L" Capsule FMP CapsuleFileName: \"%s\"\n", CapsuleFileName);
|
||||
CapsuleFileNameSize = StrSize(CapsuleFileName);
|
||||
Print (L" Capsule FMP CapsuleFileName: \"%s\"\n", CapsuleFileName);
|
||||
CapsuleFileNameSize = StrSize (CapsuleFileName);
|
||||
CapsuleTarget = (CHAR16 *)((UINTN)CapsuleFileName + CapsuleFileNameSize);
|
||||
Print(L" Capsule FMP CapsuleTarget: \"%s\"\n", CapsuleTarget);
|
||||
Print (L" Capsule FMP CapsuleTarget: \"%s\"\n", CapsuleTarget);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool(CapsuleResult);
|
||||
FreePool (CapsuleResult);
|
||||
|
||||
Index++;
|
||||
if (Index > 0xFFFF) {
|
||||
@ -356,7 +362,7 @@ FwTypeToString (
|
||||
IN UINT32 FwType
|
||||
)
|
||||
{
|
||||
if (FwType < sizeof(mFwTypeString) / sizeof(mFwTypeString[0])) {
|
||||
if (FwType < sizeof (mFwTypeString) / sizeof (mFwTypeString[0])) {
|
||||
return mFwTypeString[FwType];
|
||||
} else {
|
||||
return "Invalid";
|
||||
@ -375,7 +381,7 @@ LastAttemptStatusToString (
|
||||
IN UINT32 LastAttemptStatus
|
||||
)
|
||||
{
|
||||
if (LastAttemptStatus < sizeof(mLastAttemptStatusString) / sizeof(mLastAttemptStatusString[0])) {
|
||||
if (LastAttemptStatus < sizeof (mLastAttemptStatusString) / sizeof (mLastAttemptStatusString[0])) {
|
||||
return mLastAttemptStatusString[LastAttemptStatus];
|
||||
} else {
|
||||
return "Error: Unknown";
|
||||
@ -392,13 +398,13 @@ DumpEsrtEntry (
|
||||
IN EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry
|
||||
)
|
||||
{
|
||||
Print(L" FwClass - %g\n", &EsrtEntry->FwClass);
|
||||
Print(L" FwType - 0x%x (%a)\n", EsrtEntry->FwType, FwTypeToString(EsrtEntry->FwType));
|
||||
Print(L" FwVersion - 0x%x\n", EsrtEntry->FwVersion);
|
||||
Print(L" LowestSupportedFwVersion - 0x%x\n", EsrtEntry->LowestSupportedFwVersion);
|
||||
Print(L" CapsuleFlags - 0x%x\n", EsrtEntry->CapsuleFlags);
|
||||
Print(L" LastAttemptVersion - 0x%x\n", EsrtEntry->LastAttemptVersion);
|
||||
Print(L" LastAttemptStatus - 0x%x (%a)\n", EsrtEntry->LastAttemptStatus, LastAttemptStatusToString(EsrtEntry->LastAttemptStatus));
|
||||
Print (L" FwClass - %g\n", &EsrtEntry->FwClass);
|
||||
Print (L" FwType - 0x%x (%a)\n", EsrtEntry->FwType, FwTypeToString (EsrtEntry->FwType));
|
||||
Print (L" FwVersion - 0x%x\n", EsrtEntry->FwVersion);
|
||||
Print (L" LowestSupportedFwVersion - 0x%x\n", EsrtEntry->LowestSupportedFwVersion);
|
||||
Print (L" CapsuleFlags - 0x%x\n", EsrtEntry->CapsuleFlags);
|
||||
Print (L" LastAttemptVersion - 0x%x\n", EsrtEntry->LastAttemptVersion);
|
||||
Print (L" LastAttemptStatus - 0x%x (%a)\n", EsrtEntry->LastAttemptStatus, LastAttemptStatusToString (EsrtEntry->LastAttemptStatus));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -415,18 +421,18 @@ DumpEsrt (
|
||||
EFI_SYSTEM_RESOURCE_ENTRY *EsrtEntry;
|
||||
|
||||
if (Esrt == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Print(L"EFI_SYSTEM_RESOURCE_TABLE:\n");
|
||||
Print(L"FwResourceCount - 0x%x\n", Esrt->FwResourceCount);
|
||||
Print(L"FwResourceCountMax - 0x%x\n", Esrt->FwResourceCountMax);
|
||||
Print(L"FwResourceVersion - 0x%lx\n", Esrt->FwResourceVersion);
|
||||
Print (L"EFI_SYSTEM_RESOURCE_TABLE:\n");
|
||||
Print (L"FwResourceCount - 0x%x\n", Esrt->FwResourceCount);
|
||||
Print (L"FwResourceCountMax - 0x%x\n", Esrt->FwResourceCountMax);
|
||||
Print (L"FwResourceVersion - 0x%lx\n", Esrt->FwResourceVersion);
|
||||
|
||||
EsrtEntry = (VOID *)(Esrt + 1);
|
||||
for (Index = 0; Index < Esrt->FwResourceCount; Index++) {
|
||||
Print(L"EFI_SYSTEM_RESOURCE_ENTRY (%d):\n", Index);
|
||||
DumpEsrtEntry(EsrtEntry);
|
||||
Print (L"EFI_SYSTEM_RESOURCE_ENTRY (%d):\n", Index);
|
||||
DumpEsrtEntry (EsrtEntry);
|
||||
EsrtEntry++;
|
||||
}
|
||||
}
|
||||
@ -442,19 +448,19 @@ DumpEsrtData (
|
||||
EFI_STATUS Status;
|
||||
EFI_SYSTEM_RESOURCE_TABLE *Esrt;
|
||||
|
||||
Print(L"##############\n");
|
||||
Print(L"# ESRT TABLE #\n");
|
||||
Print(L"##############\n");
|
||||
Print (L"##############\n");
|
||||
Print (L"# ESRT TABLE #\n");
|
||||
Print (L"##############\n");
|
||||
|
||||
Status = EfiGetSystemConfigurationTable (&gEfiSystemResourceTableGuid, (VOID **)&Esrt);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"ESRT - %r\n", Status);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"ESRT - %r\n", Status);
|
||||
return;
|
||||
}
|
||||
DumpEsrt(Esrt);
|
||||
Print(L"\n");
|
||||
}
|
||||
|
||||
DumpEsrt (Esrt);
|
||||
Print (L"\n");
|
||||
}
|
||||
|
||||
/**
|
||||
Dump capsule information from CapsuleHeader
|
||||
@ -477,6 +483,7 @@ DumpCapsuleFromBuffer (
|
||||
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
DumpFmpCapsule (CapsuleHeader);
|
||||
}
|
||||
|
||||
if (IsNestedFmpCapsule (CapsuleHeader)) {
|
||||
Print (L"[NestedCapusule]\n");
|
||||
Print (L"CapsuleHeader:\n");
|
||||
@ -507,7 +514,7 @@ UpperCaseString (
|
||||
CHAR16 *Cptr;
|
||||
|
||||
for (Cptr = Str; *Cptr != L'\0'; Cptr++) {
|
||||
if (L'a' <= *Cptr && *Cptr <= L'z') {
|
||||
if ((L'a' <= *Cptr) && (*Cptr <= L'z')) {
|
||||
*Cptr = *Cptr - L'a' + L'A';
|
||||
}
|
||||
}
|
||||
@ -533,6 +540,7 @@ GetSubStringBeforePeriod (
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Str[Index] != L'.' && Str[Index] != L'\0'; Index++) {
|
||||
SubStr[Index] = Str[Index];
|
||||
}
|
||||
@ -559,9 +567,10 @@ PadStrInTail (
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; StrBuf[Index] != L'\0'; Index++);
|
||||
for (Index = 0; StrBuf[Index] != L'\0'; Index++) {
|
||||
}
|
||||
|
||||
while(PadLen != 0) {
|
||||
while (PadLen != 0) {
|
||||
StrBuf[Index] = Character;
|
||||
Index++;
|
||||
PadLen--;
|
||||
@ -590,13 +599,14 @@ SplitFileNameExtension (
|
||||
UINTN Index;
|
||||
UINTN StringLen;
|
||||
|
||||
StringLen = StrLen(FileName);
|
||||
for (Index = StringLen; Index > 0 && FileName[Index] != L'.'; Index--);
|
||||
StringLen = StrLen (FileName);
|
||||
for (Index = StringLen; Index > 0 && FileName[Index] != L'.'; Index--) {
|
||||
}
|
||||
|
||||
//
|
||||
// No period exists. No FileName Extension
|
||||
//
|
||||
if (Index == 0 && FileName[Index] != L'.') {
|
||||
if ((Index == 0) && (FileName[Index] != L'.')) {
|
||||
FileNameExtension[0] = L'\0';
|
||||
Index = StringLen;
|
||||
} else {
|
||||
@ -639,8 +649,8 @@ CompareFileNameInAlphabet (
|
||||
UINTN SubStrLen2;
|
||||
INTN SubStrCmpResult;
|
||||
|
||||
FileInfo1 = (EFI_FILE_INFO *) (*(UINTN *)Left);
|
||||
FileInfo2 = (EFI_FILE_INFO *) (*(UINTN *)Right);
|
||||
FileInfo1 = (EFI_FILE_INFO *)(*(UINTN *)Left);
|
||||
FileInfo2 = (EFI_FILE_INFO *)(*(UINTN *)Right);
|
||||
|
||||
SplitFileNameExtension (FileInfo1->FileName, FileName1, FileExtension1);
|
||||
SplitFileNameExtension (FileInfo2->FileName, FileName2, FileExtension2);
|
||||
@ -656,7 +666,7 @@ CompareFileNameInAlphabet (
|
||||
// Substr in NewFileName is longer. Pad tail with SPACE
|
||||
//
|
||||
PadStrInTail (TempSubStr2, SubStrLen1 - SubStrLen2, L' ');
|
||||
} else if (SubStrLen1 < SubStrLen2){
|
||||
} else if (SubStrLen1 < SubStrLen2) {
|
||||
//
|
||||
// Substr in ListedFileName is longer. Pad tail with SPACE
|
||||
//
|
||||
@ -715,7 +725,7 @@ DumpCapsuleFromDisk (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE , 0);
|
||||
Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"Cannot open %s. Status = %r\n", EFI_CAPSULE_FILE_DIRECTORY, Status);
|
||||
goto Done;
|
||||
@ -726,7 +736,7 @@ DumpCapsuleFromDisk (
|
||||
//
|
||||
Status = FileHandleFindFirstFile (DirHandle, &FileInfo);
|
||||
do {
|
||||
if (EFI_ERROR (Status) || FileInfo == NULL) {
|
||||
if (EFI_ERROR (Status) || (FileInfo == NULL)) {
|
||||
Print (L"Get File Info Fail. Status = %r\n", Status);
|
||||
goto Done;
|
||||
}
|
||||
@ -753,6 +763,7 @@ DumpCapsuleFromDisk (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
NoFile = FALSE;
|
||||
|
||||
//
|
||||
@ -760,7 +771,7 @@ DumpCapsuleFromDisk (
|
||||
//
|
||||
Status = FileHandleFindFirstFile (DirHandle, &FileInfo);
|
||||
do {
|
||||
if (EFI_ERROR (Status) || FileInfo == NULL) {
|
||||
if (EFI_ERROR (Status) || (FileInfo == NULL)) {
|
||||
Print (L"Get File Info Fail. Status = %r\n", Status);
|
||||
goto Done;
|
||||
}
|
||||
@ -783,7 +794,7 @@ DumpCapsuleFromDisk (
|
||||
FileInfoBuffer,
|
||||
FileCount,
|
||||
sizeof (FileInfo),
|
||||
(SORT_COMPARE) CompareFileNameInAlphabet
|
||||
(SORT_COMPARE)CompareFileNameInAlphabet
|
||||
);
|
||||
|
||||
Print (L"The capsules will be performed by following order:\n");
|
||||
@ -797,7 +808,7 @@ DumpCapsuleFromDisk (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Print(L"The infomation of the capsules:\n");
|
||||
Print (L"The infomation of the capsules:\n");
|
||||
|
||||
for (Index = 0; Index < FileCount; Index++) {
|
||||
FileHandle = NULL;
|
||||
@ -806,7 +817,7 @@ DumpCapsuleFromDisk (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = FileHandleGetSize (FileHandle, (UINT64 *) &FileSize);
|
||||
Status = FileHandleGetSize (FileHandle, (UINT64 *)&FileSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"Cannot read file %s. Status = %r\n", FileInfoBuffer[Index]->FileName, Status);
|
||||
FileHandleClose (FileHandle);
|
||||
@ -830,7 +841,7 @@ DumpCapsuleFromDisk (
|
||||
Print (L"**************************\n");
|
||||
Print (L" %d.%s:\n", Index + 1, FileInfoBuffer[Index]->FileName);
|
||||
Print (L"**************************\n");
|
||||
DumpCapsuleFromBuffer ((EFI_CAPSULE_HEADER *) FileBuffer);
|
||||
DumpCapsuleFromBuffer ((EFI_CAPSULE_HEADER *)FileBuffer);
|
||||
FileHandleClose (FileHandle);
|
||||
FreePool (FileBuffer);
|
||||
}
|
||||
@ -842,6 +853,7 @@ Done:
|
||||
FreePool (FileInfoBuffer[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (FileInfoBuffer);
|
||||
}
|
||||
|
||||
@ -868,19 +880,21 @@ DumpBlockDescriptors (
|
||||
while (TRUE) {
|
||||
if (TempBlockPtr->Length != 0) {
|
||||
if (DumpCapsuleInfo) {
|
||||
Print(L"******************************************************\n");
|
||||
Print (L"******************************************************\n");
|
||||
}
|
||||
Print(L"Capsule data starts at 0x%08x with size 0x%08x\n", TempBlockPtr->Union.DataBlock, TempBlockPtr->Length);
|
||||
|
||||
Print (L"Capsule data starts at 0x%08x with size 0x%08x\n", TempBlockPtr->Union.DataBlock, TempBlockPtr->Length);
|
||||
if (DumpCapsuleInfo) {
|
||||
Print(L"******************************************************\n");
|
||||
DumpCapsuleFromBuffer ((EFI_CAPSULE_HEADER *) (UINTN) TempBlockPtr->Union.DataBlock);
|
||||
Print (L"******************************************************\n");
|
||||
DumpCapsuleFromBuffer ((EFI_CAPSULE_HEADER *)(UINTN)TempBlockPtr->Union.DataBlock);
|
||||
}
|
||||
|
||||
TempBlockPtr += 1;
|
||||
} else {
|
||||
if (TempBlockPtr->Union.ContinuationPointer == (UINTN)NULL) {
|
||||
break;
|
||||
} else {
|
||||
TempBlockPtr = (EFI_CAPSULE_BLOCK_DESCRIPTOR *) (UINTN) TempBlockPtr->Union.ContinuationPointer;
|
||||
TempBlockPtr = (EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)TempBlockPtr->Union.ContinuationPointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -916,7 +930,7 @@ DumpProvisionedCapsule (
|
||||
ShellProtocol = GetShellProtocol ();
|
||||
if (ShellProtocol == NULL) {
|
||||
Print (L"Get Shell Protocol Fail\n");
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -925,7 +939,7 @@ DumpProvisionedCapsule (
|
||||
Print (L"#########################\n");
|
||||
Print (L"### Capsule on Memory ###\n");
|
||||
Print (L"#########################\n");
|
||||
StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CHAR16), EFI_CAPSULE_VARIABLE_NAME);
|
||||
StrCpyS (CapsuleVarName, sizeof (CapsuleVarName)/sizeof (CHAR16), EFI_CAPSULE_VARIABLE_NAME);
|
||||
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
|
||||
while (TRUE) {
|
||||
if (Index > 0) {
|
||||
@ -941,19 +955,20 @@ DumpProvisionedCapsule (
|
||||
Status = GetVariable2 (
|
||||
CapsuleVarName,
|
||||
&gEfiCapsuleVendorGuid,
|
||||
(VOID **) &CapsuleDataPtr64,
|
||||
(VOID **)&CapsuleDataPtr64,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status) || CapsuleDataPtr64 == NULL) {
|
||||
if (EFI_ERROR (Status) || (CapsuleDataPtr64 == NULL)) {
|
||||
if (Index == 0) {
|
||||
Print (L"No data.\n");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Index++;
|
||||
Print (L"Capsule Description at 0x%08x\n", *CapsuleDataPtr64);
|
||||
DumpBlockDescriptors ((EFI_CAPSULE_BLOCK_DESCRIPTOR*) (UINTN) *CapsuleDataPtr64, DumpCapsuleInfo);
|
||||
DumpBlockDescriptors ((EFI_CAPSULE_BLOCK_DESCRIPTOR *)(UINTN)*CapsuleDataPtr64, DumpCapsuleInfo);
|
||||
}
|
||||
|
||||
//
|
||||
@ -965,10 +980,10 @@ DumpProvisionedCapsule (
|
||||
Status = GetVariable2 (
|
||||
L"BootNext",
|
||||
&gEfiGlobalVariableGuid,
|
||||
(VOID **) &BootNext,
|
||||
(VOID **)&BootNext,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status) || BootNext == NULL) {
|
||||
if (EFI_ERROR (Status) || (BootNext == NULL)) {
|
||||
Print (L"Get BootNext Variable Fail. Status = %r\n", Status);
|
||||
} else {
|
||||
UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", *BootNext);
|
||||
@ -978,9 +993,9 @@ DumpProvisionedCapsule (
|
||||
// Display description and device path
|
||||
//
|
||||
GetEfiSysPartitionFromBootOptionFilePath (BootNextOptionEntry.FilePath, &DevicePath, &Fs);
|
||||
if(!EFI_ERROR (Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Print (L"Capsules are provisioned on BootOption: %s\n", BootNextOptionEntry.Description);
|
||||
Print (L" %s %s\n", ShellProtocol->GetMapFromDevicePath (&DevicePath), ConvertDevicePathToText(DevicePath, TRUE, TRUE));
|
||||
Print (L" %s %s\n", ShellProtocol->GetMapFromDevicePath (&DevicePath), ConvertDevicePathToText (DevicePath, TRUE, TRUE));
|
||||
DumpCapsuleFromDisk (Fs, DumpCapsuleInfo);
|
||||
}
|
||||
}
|
||||
@ -1013,55 +1028,57 @@ DumpFmpImageInfo (
|
||||
UINTN Index;
|
||||
UINTN Index2;
|
||||
|
||||
Print(L" DescriptorVersion - 0x%x\n", DescriptorVersion);
|
||||
Print(L" DescriptorCount - 0x%x\n", DescriptorCount);
|
||||
Print(L" DescriptorSize - 0x%x\n", DescriptorSize);
|
||||
Print(L" PackageVersion - 0x%x\n", PackageVersion);
|
||||
Print(L" PackageVersionName - \"%s\"\n", PackageVersionName);
|
||||
Print (L" DescriptorVersion - 0x%x\n", DescriptorVersion);
|
||||
Print (L" DescriptorCount - 0x%x\n", DescriptorCount);
|
||||
Print (L" DescriptorSize - 0x%x\n", DescriptorSize);
|
||||
Print (L" PackageVersion - 0x%x\n", PackageVersion);
|
||||
Print (L" PackageVersionName - \"%s\"\n", PackageVersionName);
|
||||
CurrentImageInfo = ImageInfo;
|
||||
for (Index = 0; Index < DescriptorCount; Index++) {
|
||||
Print(L" ImageDescriptor (%d)\n", Index);
|
||||
Print(L" ImageIndex - 0x%x\n", CurrentImageInfo->ImageIndex);
|
||||
Print(L" ImageTypeId - %g\n", &CurrentImageInfo->ImageTypeId);
|
||||
Print(L" ImageId - 0x%lx\n", CurrentImageInfo->ImageId);
|
||||
Print(L" ImageIdName - \"%s\"\n", CurrentImageInfo->ImageIdName);
|
||||
Print(L" Version - 0x%x\n", CurrentImageInfo->Version);
|
||||
Print(L" VersionName - \"%s\"\n", CurrentImageInfo->VersionName);
|
||||
Print(L" Size - 0x%x\n", CurrentImageInfo->Size);
|
||||
Print(L" AttributesSupported - 0x%lx\n", CurrentImageInfo->AttributesSupported);
|
||||
Print(L" IMAGE_UPDATABLE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
|
||||
Print(L" RESET_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED);
|
||||
Print(L" AUTHENTICATION_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
|
||||
Print(L" IN_USE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_IN_USE);
|
||||
Print(L" UEFI_IMAGE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_UEFI_IMAGE);
|
||||
Print(L" AttributesSetting - 0x%lx\n", CurrentImageInfo->AttributesSetting);
|
||||
Print(L" IMAGE_UPDATABLE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
|
||||
Print(L" RESET_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED);
|
||||
Print(L" AUTHENTICATION_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
|
||||
Print(L" IN_USE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_IN_USE);
|
||||
Print(L" UEFI_IMAGE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_UEFI_IMAGE);
|
||||
Print(L" Compatibilities - 0x%lx\n", CurrentImageInfo->Compatibilities);
|
||||
Print(L" COMPATIB_CHECK_SUPPORTED - 0x%lx\n", CurrentImageInfo->Compatibilities & IMAGE_COMPATIBILITY_CHECK_SUPPORTED);
|
||||
Print (L" ImageDescriptor (%d)\n", Index);
|
||||
Print (L" ImageIndex - 0x%x\n", CurrentImageInfo->ImageIndex);
|
||||
Print (L" ImageTypeId - %g\n", &CurrentImageInfo->ImageTypeId);
|
||||
Print (L" ImageId - 0x%lx\n", CurrentImageInfo->ImageId);
|
||||
Print (L" ImageIdName - \"%s\"\n", CurrentImageInfo->ImageIdName);
|
||||
Print (L" Version - 0x%x\n", CurrentImageInfo->Version);
|
||||
Print (L" VersionName - \"%s\"\n", CurrentImageInfo->VersionName);
|
||||
Print (L" Size - 0x%x\n", CurrentImageInfo->Size);
|
||||
Print (L" AttributesSupported - 0x%lx\n", CurrentImageInfo->AttributesSupported);
|
||||
Print (L" IMAGE_UPDATABLE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
|
||||
Print (L" RESET_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED);
|
||||
Print (L" AUTHENTICATION_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
|
||||
Print (L" IN_USE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_IN_USE);
|
||||
Print (L" UEFI_IMAGE - 0x%lx\n", CurrentImageInfo->AttributesSupported & IMAGE_ATTRIBUTE_UEFI_IMAGE);
|
||||
Print (L" AttributesSetting - 0x%lx\n", CurrentImageInfo->AttributesSetting);
|
||||
Print (L" IMAGE_UPDATABLE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
|
||||
Print (L" RESET_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED);
|
||||
Print (L" AUTHENTICATION_REQUIRED - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
|
||||
Print (L" IN_USE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_IN_USE);
|
||||
Print (L" UEFI_IMAGE - 0x%lx\n", CurrentImageInfo->AttributesSetting & IMAGE_ATTRIBUTE_UEFI_IMAGE);
|
||||
Print (L" Compatibilities - 0x%lx\n", CurrentImageInfo->Compatibilities);
|
||||
Print (L" COMPATIB_CHECK_SUPPORTED - 0x%lx\n", CurrentImageInfo->Compatibilities & IMAGE_COMPATIBILITY_CHECK_SUPPORTED);
|
||||
if (DescriptorVersion > 1) {
|
||||
Print(L" LowestSupportedImageVersion - 0x%x\n", CurrentImageInfo->LowestSupportedImageVersion);
|
||||
Print (L" LowestSupportedImageVersion - 0x%x\n", CurrentImageInfo->LowestSupportedImageVersion);
|
||||
if (DescriptorVersion > 2) {
|
||||
Print(L" LastAttemptVersion - 0x%x\n", CurrentImageInfo->LastAttemptVersion);
|
||||
Print(L" LastAttemptStatus - 0x%x (%a)\n", CurrentImageInfo->LastAttemptStatus, LastAttemptStatusToString(CurrentImageInfo->LastAttemptStatus));
|
||||
Print(L" HardwareInstance - 0x%lx\n", CurrentImageInfo->HardwareInstance);
|
||||
Print (L" LastAttemptVersion - 0x%x\n", CurrentImageInfo->LastAttemptVersion);
|
||||
Print (L" LastAttemptStatus - 0x%x (%a)\n", CurrentImageInfo->LastAttemptStatus, LastAttemptStatusToString (CurrentImageInfo->LastAttemptStatus));
|
||||
Print (L" HardwareInstance - 0x%lx\n", CurrentImageInfo->HardwareInstance);
|
||||
if (DescriptorVersion > 3) {
|
||||
Print(L" Dependencies - ");
|
||||
Print (L" Dependencies - ");
|
||||
if (CurrentImageInfo->Dependencies == NULL) {
|
||||
Print(L"NULL\n");
|
||||
Print (L"NULL\n");
|
||||
} else {
|
||||
Index2 = 0;
|
||||
do {
|
||||
Print(L"%02x ", CurrentImageInfo->Dependencies->Dependencies[Index2]);
|
||||
} while (CurrentImageInfo->Dependencies->Dependencies[Index2 ++] != EFI_FMP_DEP_END);
|
||||
Print(L"\n");
|
||||
Print (L"%02x ", CurrentImageInfo->Dependencies->Dependencies[Index2]);
|
||||
} while (CurrentImageInfo->Dependencies->Dependencies[Index2++] != EFI_FMP_DEP_END);
|
||||
|
||||
Print (L"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Use DescriptorSize to move ImageInfo Pointer to stay compatible with different ImageInfo version
|
||||
//
|
||||
@ -1087,17 +1104,17 @@ DumpFmpPackageInfo (
|
||||
IN UINT64 AttributesSetting
|
||||
)
|
||||
{
|
||||
Print(L" PackageVersion - 0x%x\n", PackageVersion);
|
||||
Print(L" PackageVersionName - \"%s\"\n", PackageVersionName);
|
||||
Print(L" PackageVersionNameMaxLen - 0x%x\n", PackageVersionNameMaxLen);
|
||||
Print(L" AttributesSupported - 0x%lx\n", AttributesSupported);
|
||||
Print(L" IMAGE_UPDATABLE - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
|
||||
Print(L" RESET_REQUIRED - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED);
|
||||
Print(L" AUTHENTICATION_REQUIRED - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
|
||||
Print(L" AttributesSetting - 0x%lx\n", AttributesSetting);
|
||||
Print(L" IMAGE_UPDATABLE - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
|
||||
Print(L" RESET_REQUIRED - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED);
|
||||
Print(L" AUTHENTICATION_REQUIRED - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
|
||||
Print (L" PackageVersion - 0x%x\n", PackageVersion);
|
||||
Print (L" PackageVersionName - \"%s\"\n", PackageVersionName);
|
||||
Print (L" PackageVersionNameMaxLen - 0x%x\n", PackageVersionNameMaxLen);
|
||||
Print (L" AttributesSupported - 0x%lx\n", AttributesSupported);
|
||||
Print (L" IMAGE_UPDATABLE - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
|
||||
Print (L" RESET_REQUIRED - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED);
|
||||
Print (L" AUTHENTICATION_REQUIRED - 0x%lx\n", AttributesSupported & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
|
||||
Print (L" AttributesSetting - 0x%lx\n", AttributesSetting);
|
||||
Print (L" IMAGE_UPDATABLE - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_IMAGE_UPDATABLE);
|
||||
Print (L" RESET_REQUIRED - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED);
|
||||
Print (L" AUTHENTICATION_REQUIRED - 0x%lx\n", AttributesSetting & IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1124,9 +1141,9 @@ DumpFmpData (
|
||||
UINT64 AttributesSupported;
|
||||
UINT64 AttributesSetting;
|
||||
|
||||
Print(L"############\n");
|
||||
Print(L"# FMP DATA #\n");
|
||||
Print(L"############\n");
|
||||
Print (L"############\n");
|
||||
Print (L"# FMP DATA #\n");
|
||||
Print (L"############\n");
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiFirmwareManagementProtocolGuid,
|
||||
@ -1134,18 +1151,18 @@ DumpFmpData (
|
||||
&NumberOfHandles,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"FMP protocol - %r\n", EFI_NOT_FOUND);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"FMP protocol - %r\n", EFI_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < NumberOfHandles; Index++) {
|
||||
Status = gBS->HandleProtocol(
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiFirmwareManagementProtocolGuid,
|
||||
(VOID **)&Fmp
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1186,14 +1203,14 @@ DumpFmpData (
|
||||
//
|
||||
// If FMP GetInformation interface failed, skip this resource
|
||||
//
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"FMP (%d) ImageInfo - %r\n", Index, Status);
|
||||
FreePool(FmpImageInfoBuf);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"FMP (%d) ImageInfo - %r\n", Index, Status);
|
||||
FreePool (FmpImageInfoBuf);
|
||||
continue;
|
||||
}
|
||||
|
||||
Print(L"FMP (%d) ImageInfo:\n", Index);
|
||||
DumpFmpImageInfo(
|
||||
Print (L"FMP (%d) ImageInfo:\n", Index);
|
||||
DumpFmpImageInfo (
|
||||
ImageInfoSize, // ImageInfoSize
|
||||
FmpImageInfoBuf, // ImageInfo
|
||||
FmpImageInfoDescriptorVer, // DescriptorVersion
|
||||
@ -1204,9 +1221,10 @@ DumpFmpData (
|
||||
);
|
||||
|
||||
if (PackageVersionName != NULL) {
|
||||
FreePool(PackageVersionName);
|
||||
FreePool (PackageVersionName);
|
||||
}
|
||||
FreePool(FmpImageInfoBuf);
|
||||
|
||||
FreePool (FmpImageInfoBuf);
|
||||
|
||||
//
|
||||
// Get package info
|
||||
@ -1220,11 +1238,11 @@ DumpFmpData (
|
||||
&AttributesSupported, // AttributesSupported
|
||||
&AttributesSetting // AttributesSetting
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"FMP (%d) PackageInfo - %r\n", Index, Status);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"FMP (%d) PackageInfo - %r\n", Index, Status);
|
||||
} else {
|
||||
Print(L"FMP (%d) ImageInfo:\n", Index);
|
||||
DumpFmpPackageInfo(
|
||||
Print (L"FMP (%d) ImageInfo:\n", Index);
|
||||
DumpFmpPackageInfo (
|
||||
PackageVersion, // PackageVersion
|
||||
PackageVersionName, // PackageVersionName
|
||||
PackageVersionNameMaxLen, // PackageVersionNameMaxLen
|
||||
@ -1233,14 +1251,15 @@ DumpFmpData (
|
||||
);
|
||||
|
||||
if (PackageVersionName != NULL) {
|
||||
FreePool(PackageVersionName);
|
||||
FreePool (PackageVersionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Print(L"\n");
|
||||
|
||||
Print (L"\n");
|
||||
|
||||
EXIT:
|
||||
FreePool(HandleBuffer);
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1270,8 +1289,10 @@ IsThisFmpImageInfo (
|
||||
if (CompareGuid (&CurrentImageInfo->ImageTypeId, ImageTypeId)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CurrentImageInfo = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)((UINT8 *)CurrentImageInfo + DescriptorSize);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1308,19 +1329,19 @@ FindFmpFromImageTypeId (
|
||||
&NumberOfHandles,
|
||||
&HandleBuffer
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"FMP protocol - %r\n", EFI_NOT_FOUND);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"FMP protocol - %r\n", EFI_NOT_FOUND);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TargetFmp = NULL;
|
||||
for (Index = 0; Index < NumberOfHandles; Index++) {
|
||||
Status = gBS->HandleProtocol(
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiFirmwareManagementProtocolGuid,
|
||||
(VOID **)&Fmp
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1342,8 +1363,8 @@ FindFmpFromImageTypeId (
|
||||
FmpImageInfoBuf = NULL;
|
||||
FmpImageInfoBuf = AllocateZeroPool (ImageInfoSize);
|
||||
if (FmpImageInfoBuf == NULL) {
|
||||
FreePool(HandleBuffer);
|
||||
Print(L"Out of resource\n");
|
||||
FreePool (HandleBuffer);
|
||||
Print (L"Out of resource\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1362,24 +1383,26 @@ FindFmpFromImageTypeId (
|
||||
//
|
||||
// If FMP GetInformation interface failed, skip this resource
|
||||
//
|
||||
if (EFI_ERROR(Status)) {
|
||||
FreePool(FmpImageInfoBuf);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (FmpImageInfoBuf);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (PackageVersionName != NULL) {
|
||||
FreePool(PackageVersionName);
|
||||
FreePool (PackageVersionName);
|
||||
}
|
||||
|
||||
if (IsThisFmpImageInfo (FmpImageInfoBuf, FmpImageInfoCount, DescriptorSize, ImageTypeId)) {
|
||||
TargetFmp = Fmp;
|
||||
}
|
||||
FreePool(FmpImageInfoBuf);
|
||||
|
||||
FreePool (FmpImageInfoBuf);
|
||||
if (TargetFmp != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
FreePool(HandleBuffer);
|
||||
|
||||
FreePool (HandleBuffer);
|
||||
return TargetFmp;
|
||||
}
|
||||
|
||||
@ -1406,39 +1429,39 @@ DumpFmpImage (
|
||||
|
||||
Fmp = FindFmpFromImageTypeId (ImageTypeId);
|
||||
if (Fmp == NULL) {
|
||||
Print(L"No FMP include ImageTypeId %g\n", ImageTypeId);
|
||||
return ;
|
||||
Print (L"No FMP include ImageTypeId %g\n", ImageTypeId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ImageIndex > 0xFF) {
|
||||
Print(L"ImageIndex 0x%x too big\n", ImageIndex);
|
||||
return ;
|
||||
Print (L"ImageIndex 0x%x too big\n", ImageIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
Image = Fmp;
|
||||
ImageSize = 0;
|
||||
Status = Fmp->GetImage (Fmp, (UINT8)ImageIndex, Image, &ImageSize);
|
||||
if (Status != EFI_BUFFER_TOO_SMALL) {
|
||||
Print(L"Fmp->GetImage - %r\n", Status);
|
||||
return ;
|
||||
Print (L"Fmp->GetImage - %r\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
Image = AllocatePool (ImageSize);
|
||||
if (Image == NULL) {
|
||||
Print(L"Allocate FmpImage 0x%x - %r\n", ImageSize, EFI_OUT_OF_RESOURCES);
|
||||
return ;
|
||||
Print (L"Allocate FmpImage 0x%x - %r\n", ImageSize, EFI_OUT_OF_RESOURCES);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = Fmp->GetImage (Fmp, (UINT8)ImageIndex, Image, &ImageSize);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"Fmp->GetImage - %r\n", Status);
|
||||
return ;
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"Fmp->GetImage - %r\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = WriteFileFromBuffer(ImageName, ImageSize, Image);
|
||||
Print(L"CapsuleApp: Dump %g ImageIndex (0x%x) to %s %r\n", ImageTypeId, ImageIndex, ImageName, Status);
|
||||
Status = WriteFileFromBuffer (ImageName, ImageSize, Image);
|
||||
Print (L"CapsuleApp: Dump %g ImageIndex (0x%x) to %s %r\n", ImageTypeId, ImageIndex, ImageName, Status);
|
||||
|
||||
FreePool (Image);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
@ -8,7 +8,9 @@
|
||||
|
||||
#include "CapsuleApp.h"
|
||||
|
||||
EFI_GUID mCapsuleOnDiskBootOptionGuid = { 0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 } };
|
||||
EFI_GUID mCapsuleOnDiskBootOptionGuid = {
|
||||
0x4CC29BB7, 0x2413, 0x40A2, { 0xB0, 0x6D, 0x25, 0x3E, 0x37, 0x10, 0xF5, 0x32 }
|
||||
};
|
||||
|
||||
/**
|
||||
Get file name from file path.
|
||||
@ -83,12 +85,14 @@ IsEfiSysPartitionDevicePath (
|
||||
|
||||
while (!IsDevicePathEnd (TempDevicePath)) {
|
||||
if ((DevicePathType (TempDevicePath) == MEDIA_DEVICE_PATH) &&
|
||||
(DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP)) {
|
||||
(DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP))
|
||||
{
|
||||
Hd = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
|
||||
if (Hd->MBRType == MBR_TYPE_EFI_PARTITION_TABLE_HEADER) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TempDevicePath = NextDevicePathNode (TempDevicePath);
|
||||
}
|
||||
|
||||
@ -123,8 +127,8 @@ DumpAllEfiSysPartition (
|
||||
|
||||
ShellProtocol = GetShellProtocol ();
|
||||
if (ShellProtocol == NULL) {
|
||||
Print (L"Get Shell Protocol Fail\n");;
|
||||
return ;
|
||||
Print (L"Get Shell Protocol Fail\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Print (L"EFI System Partition list:\n");
|
||||
@ -141,12 +145,12 @@ DumpAllEfiSysPartition (
|
||||
DevicePath = DevicePathFromHandle (SimpleFileSystemHandles[Index]);
|
||||
if (IsEfiSysPartitionDevicePath (DevicePath)) {
|
||||
NumberEfiSystemPartitions++;
|
||||
Print(L" %s\n %s\n", ShellProtocol->GetMapFromDevicePath (&DevicePath), ConvertDevicePathToText (DevicePath, TRUE, TRUE));
|
||||
Print (L" %s\n %s\n", ShellProtocol->GetMapFromDevicePath (&DevicePath), ConvertDevicePathToText (DevicePath, TRUE, TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
if (NumberEfiSystemPartitions == 0) {
|
||||
Print(L" No ESP found.\n");
|
||||
Print (L" No ESP found.\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +171,7 @@ IsCapsuleProvisioned (
|
||||
UINTN DataSize;
|
||||
|
||||
OsIndication = 0;
|
||||
DataSize = sizeof(UINT64);
|
||||
DataSize = sizeof (UINT64);
|
||||
Status = gRT->GetVariable (
|
||||
L"OsIndications",
|
||||
&gEfiGlobalVariableGuid,
|
||||
@ -176,7 +180,8 @@ IsCapsuleProvisioned (
|
||||
&OsIndication
|
||||
);
|
||||
if (!EFI_ERROR (Status) &&
|
||||
(OsIndication & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) != 0) {
|
||||
((OsIndication & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) != 0))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -261,12 +266,14 @@ GetEfiSysPartitionFromDevPath (
|
||||
TempDevicePath = DevicePath;
|
||||
while (!IsDevicePathEnd (TempDevicePath)) {
|
||||
if ((DevicePathType (TempDevicePath) == MEDIA_DEVICE_PATH) &&
|
||||
(DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP)) {
|
||||
(DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP))
|
||||
{
|
||||
Hd = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
|
||||
if (Hd->MBRType == MBR_TYPE_EFI_PARTITION_TABLE_HEADER) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TempDevicePath = NextDevicePathNode (TempDevicePath);
|
||||
}
|
||||
|
||||
@ -340,10 +347,11 @@ GetEfiSysPartitionFromBootOptionFilePath (
|
||||
CHAR16 *DevicePathStr;
|
||||
|
||||
DevicePathStr = ConvertDevicePathToText (CurFullPath, TRUE, TRUE);
|
||||
if (DevicePathStr != NULL){
|
||||
if (DevicePathStr != NULL) {
|
||||
DEBUG ((DEBUG_INFO, "Full device path %s\n", DevicePathStr));
|
||||
FreePool (DevicePathStr);
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
Status = GetEfiSysPartitionFromDevPath (CurFullPath, &FsFullPath, Fs);
|
||||
@ -376,7 +384,7 @@ GetUpdateFileSystem (
|
||||
OUT UINT16 *BootNext,
|
||||
OUT EFI_SIMPLE_FILE_SYSTEM_PROTOCOL **Fs,
|
||||
OUT BOOLEAN *UpdateBootNext
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
CHAR16 BootOptionName[20];
|
||||
@ -396,7 +404,7 @@ GetUpdateFileSystem (
|
||||
|
||||
ShellProtocol = GetShellProtocol ();
|
||||
if (ShellProtocol == NULL) {
|
||||
Print (L"Get Shell Protocol Fail\n");;
|
||||
Print (L"Get Shell Protocol Fail\n");
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -404,14 +412,14 @@ GetUpdateFileSystem (
|
||||
// 1. If Fs is not assigned and there are capsule provisioned before,
|
||||
// Get EFI system partition from BootNext.
|
||||
//
|
||||
if (IsCapsuleProvisioned () && Map == NULL) {
|
||||
if (IsCapsuleProvisioned () && (Map == NULL)) {
|
||||
Status = GetVariable2 (
|
||||
L"BootNext",
|
||||
&gEfiGlobalVariableGuid,
|
||||
(VOID **)&BootNextData,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status) || BootNextData == NULL) {
|
||||
if (EFI_ERROR (Status) || (BootNextData == NULL)) {
|
||||
Print (L"Get Boot Next Data Fail. Status = %r\n", Status);
|
||||
return EFI_NOT_FOUND;
|
||||
} else {
|
||||
@ -422,8 +430,8 @@ GetUpdateFileSystem (
|
||||
Status = GetEfiSysPartitionFromBootOptionFilePath (DevicePath, &FullPath, Fs);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*UpdateBootNext = FALSE;
|
||||
Print(L"Get EFI system partition from BootNext : %s\n", BootNextOption.Description);
|
||||
Print(L"%s %s\n", ShellProtocol->GetMapFromDevicePath (&FullPath), ConvertDevicePathToText (FullPath, TRUE, TRUE));
|
||||
Print (L"Get EFI system partition from BootNext : %s\n", BootNextOption.Description);
|
||||
Print (L"%s %s\n", ShellProtocol->GetMapFromDevicePath (&FullPath), ConvertDevicePathToText (FullPath, TRUE, TRUE));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -436,10 +444,10 @@ GetUpdateFileSystem (
|
||||
if (Map != NULL) {
|
||||
MappedDevicePath = ShellProtocol->GetDevicePathFromMap (Map);
|
||||
if (MappedDevicePath == NULL) {
|
||||
Print(L"'%s' is not a valid mapping.\n", Map);
|
||||
Print (L"'%s' is not a valid mapping.\n", Map);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
} else if (!IsEfiSysPartitionDevicePath (DuplicateDevicePath (MappedDevicePath))) {
|
||||
Print(L"'%s' is not a EFI System Partition.\n", Map);
|
||||
Print (L"'%s' is not a EFI System Partition.\n", Map);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
@ -448,9 +456,10 @@ GetUpdateFileSystem (
|
||||
// 2. Get EFI system partition form boot options.
|
||||
//
|
||||
BootOptionBuffer = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
|
||||
if ( (BootOptionBuffer == NULL) ||
|
||||
(BootOptionCount == 0 && Map == NULL)
|
||||
) {
|
||||
if ((BootOptionBuffer == NULL) ||
|
||||
((BootOptionCount == 0) && (Map == NULL))
|
||||
)
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -463,8 +472,9 @@ GetUpdateFileSystem (
|
||||
//
|
||||
// Skip inactive or legacy boot options
|
||||
//
|
||||
if ((BootOptionBuffer[Index].Attributes & LOAD_OPTION_ACTIVE) == 0 ||
|
||||
DevicePathType (DevicePath) == BBS_DEVICE_PATH) {
|
||||
if (((BootOptionBuffer[Index].Attributes & LOAD_OPTION_ACTIVE) == 0) ||
|
||||
(DevicePathType (DevicePath) == BBS_DEVICE_PATH))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -472,18 +482,19 @@ GetUpdateFileSystem (
|
||||
CHAR16 *DevicePathStr;
|
||||
|
||||
DevicePathStr = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
|
||||
if (DevicePathStr != NULL){
|
||||
if (DevicePathStr != NULL) {
|
||||
DEBUG ((DEBUG_INFO, "Try BootOption %s\n", DevicePathStr));
|
||||
FreePool (DevicePathStr);
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO, "DevicePathToStr failed\n"));
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
Status = GetEfiSysPartitionFromBootOptionFilePath (DevicePath, &FullPath, Fs);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (Map == NULL) {
|
||||
*BootNext = (UINT16) BootOptionBuffer[Index].OptionNumber;
|
||||
*BootNext = (UINT16)BootOptionBuffer[Index].OptionNumber;
|
||||
*UpdateBootNext = TRUE;
|
||||
Print (L"Found EFI system partition on Boot%04x: %s\n", *BootNext, BootOptionBuffer[Index].Description);
|
||||
Print (L"%s %s\n", ShellProtocol->GetMapFromDevicePath (&FullPath), ConvertDevicePathToText (FullPath, TRUE, TRUE));
|
||||
@ -491,7 +502,7 @@ GetUpdateFileSystem (
|
||||
}
|
||||
|
||||
if (StrnCmp (Map, ShellProtocol->GetMapFromDevicePath (&FullPath), StrLen (Map)) == 0) {
|
||||
*BootNext = (UINT16) BootOptionBuffer[Index].OptionNumber;
|
||||
*BootNext = (UINT16)BootOptionBuffer[Index].OptionNumber;
|
||||
*UpdateBootNext = TRUE;
|
||||
Print (L"Found Boot Option on %s : %s\n", Map, BootOptionBuffer[Index].Description);
|
||||
return EFI_SUCCESS;
|
||||
@ -512,6 +523,7 @@ GetUpdateFileSystem (
|
||||
Print (L"Error: Cannot get EFI system partition from '%s' - %r\n", Map, Status);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
Print (L"Warning: Cannot find Boot Option on '%s'!\n", Map);
|
||||
} else {
|
||||
Status = GetEfiSysPartition (&DevicePath, Fs);
|
||||
@ -529,15 +541,16 @@ GetUpdateFileSystem (
|
||||
LOAD_OPTION_ACTIVE,
|
||||
L"UEFI Capsule On Disk",
|
||||
DevicePath,
|
||||
(UINT8 *) &mCapsuleOnDiskBootOptionGuid,
|
||||
sizeof(EFI_GUID)
|
||||
(UINT8 *)&mCapsuleOnDiskBootOptionGuid,
|
||||
sizeof (EFI_GUID)
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1); {
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
|
||||
{
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*UpdateBootNext = TRUE;
|
||||
*BootNext = (UINT16) NewOption.OptionNumber;
|
||||
Print (L" Boot%04x: %s\n", *BootNext, ConvertDevicePathToText(DevicePath, TRUE, TRUE));
|
||||
*BootNext = (UINT16)NewOption.OptionNumber;
|
||||
Print (L" Boot%04x: %s\n", *BootNext, ConvertDevicePathToText (DevicePath, TRUE, TRUE));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -569,7 +582,7 @@ WriteUpdateFile (
|
||||
IN CHAR16 **FileName,
|
||||
IN UINTN BufferNum,
|
||||
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_FILE *Root;
|
||||
@ -600,15 +613,16 @@ WriteUpdateFile (
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = Root->Open (Root, &DirHandle, L"\\EFI", EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print(L"Unable to create %s directory\n", L"\\EFI");
|
||||
Print (L"Unable to create %s directory\n", L"\\EFI");
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE , 0);
|
||||
|
||||
Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = Root->Open (Root, &DirHandle, EFI_CAPSULE_FILE_DIRECTORY, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, EFI_FILE_DIRECTORY);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print(L"Unable to create %s directory\n", EFI_CAPSULE_FILE_DIRECTORY);
|
||||
Print (L"Unable to create %s directory\n", EFI_CAPSULE_FILE_DIRECTORY);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
@ -688,7 +702,7 @@ SetCapsuleStatusVariable (
|
||||
UINTN DataSize;
|
||||
|
||||
OsIndication = 0;
|
||||
DataSize = sizeof(UINT64);
|
||||
DataSize = sizeof (UINT64);
|
||||
Status = gRT->GetVariable (
|
||||
L"OsIndications",
|
||||
&gEfiGlobalVariableGuid,
|
||||
@ -699,17 +713,18 @@ SetCapsuleStatusVariable (
|
||||
if (EFI_ERROR (Status)) {
|
||||
OsIndication = 0;
|
||||
}
|
||||
|
||||
if (SetCap) {
|
||||
OsIndication |= ((UINT64)EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
OsIndication &= ~((UINT64)EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED);
|
||||
}
|
||||
|
||||
Status = gRT->SetVariable (
|
||||
L"OsIndications",
|
||||
&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
sizeof(UINT64),
|
||||
sizeof (UINT64),
|
||||
&OsIndication
|
||||
);
|
||||
|
||||
@ -732,7 +747,7 @@ IsCapsuleOnDiskSupported (
|
||||
UINT64 OsIndicationsSupported;
|
||||
UINTN DataSize;
|
||||
|
||||
DataSize = sizeof(UINT64);
|
||||
DataSize = sizeof (UINT64);
|
||||
Status = gRT->GetVariable (
|
||||
L"OsIndicationsSupported",
|
||||
&gEfiGlobalVariableGuid,
|
||||
@ -802,7 +817,7 @@ ProcessCapsuleOnDisk (
|
||||
//
|
||||
// Get file name from file path
|
||||
//
|
||||
for (Index = 0; Index < CapsuleNum; Index ++) {
|
||||
for (Index = 0; Index < CapsuleNum; Index++) {
|
||||
FileName[Index] = GetFileNameFromPath (FilePath[Index]);
|
||||
}
|
||||
|
||||
@ -829,10 +844,10 @@ ProcessCapsuleOnDisk (
|
||||
L"BootNext",
|
||||
&gEfiGlobalVariableGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||
sizeof(UINT16),
|
||||
sizeof (UINT16),
|
||||
&BootNext
|
||||
);
|
||||
if (EFI_ERROR (Status)){
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"CapsuleApp: unable to set BootNext variable.\n");
|
||||
return Status;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
|
||||
#include <Protocol/UnicodeCollation.h>
|
||||
#include <Protocol/PiPcd.h>
|
||||
#include <Protocol/Pcd.h>
|
||||
@ -23,7 +22,6 @@
|
||||
#include <Protocol/ShellParameters.h>
|
||||
#include <Protocol/Shell.h>
|
||||
|
||||
|
||||
//
|
||||
// String token ID of help message text.
|
||||
// Shell supports to find help message in the resource section of an application image if
|
||||
@ -45,12 +43,11 @@ static GET_PCD_INFO_PROTOCOL *mPcdInfo = NULL;
|
||||
static CHAR16 *mTempPcdNameBuffer = NULL;
|
||||
static UINTN mTempPcdNameBufferSize = 0;
|
||||
|
||||
static CONST CHAR8 mHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
static CONST CHAR8 mHex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
|
||||
static UINTN Argc;
|
||||
static CHAR16 **Argv;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
This function parse application ARG.
|
||||
@ -69,9 +66,9 @@ GetArg (
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiShellParametersProtocolGuid,
|
||||
(VOID**)&ShellParameters
|
||||
(VOID **)&ShellParameters
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -148,8 +145,8 @@ DumpHex (
|
||||
TempByte = Data[Index];
|
||||
Val[Index * 3 + 0] = mHex[TempByte >> 4];
|
||||
Val[Index * 3 + 1] = mHex[TempByte & 0xF];
|
||||
Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
|
||||
Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
|
||||
Val[Index * 3 + 2] = (CHAR8)((Index == 7) ? '-' : ' ');
|
||||
Str[Index] = (CHAR8)((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
|
||||
}
|
||||
|
||||
Val[Index * 3] = 0;
|
||||
@ -162,7 +159,6 @@ DumpHex (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Safely append with automatic string resizing given length of Destination and
|
||||
desired length of copy from Source.
|
||||
@ -194,7 +190,7 @@ DumpHex (
|
||||
@return Destination return the resultant string.
|
||||
**/
|
||||
static
|
||||
CHAR16*
|
||||
CHAR16 *
|
||||
InternalStrnCatGrow (
|
||||
IN OUT CHAR16 **Destination,
|
||||
IN OUT UINTN *CurrentSize,
|
||||
@ -205,12 +201,12 @@ InternalStrnCatGrow (
|
||||
UINTN NewSize;
|
||||
UINTN SourceLen;
|
||||
|
||||
SourceLen = StrLen(Source);
|
||||
SourceLen = StrLen (Source);
|
||||
|
||||
//
|
||||
// ASSERTs
|
||||
//
|
||||
ASSERT(Destination != NULL);
|
||||
ASSERT (Destination != NULL);
|
||||
|
||||
//
|
||||
// If there's nothing to do then just return Destination
|
||||
@ -222,7 +218,7 @@ InternalStrnCatGrow (
|
||||
//
|
||||
// allow for un-initialized pointers, based on size being 0
|
||||
//
|
||||
if (CurrentSize != NULL && *CurrentSize == 0) {
|
||||
if ((CurrentSize != NULL) && (*CurrentSize == 0)) {
|
||||
*Destination = NULL;
|
||||
}
|
||||
|
||||
@ -230,9 +226,9 @@ InternalStrnCatGrow (
|
||||
// allow for NULL pointers address as Destination
|
||||
//
|
||||
if (*Destination != NULL) {
|
||||
ASSERT(CurrentSize != 0);
|
||||
DestinationStartSize = StrSize(*Destination);
|
||||
ASSERT(DestinationStartSize <= *CurrentSize);
|
||||
ASSERT (CurrentSize != 0);
|
||||
DestinationStartSize = StrSize (*Destination);
|
||||
ASSERT (DestinationStartSize <= *CurrentSize);
|
||||
} else {
|
||||
DestinationStartSize = 0;
|
||||
}
|
||||
@ -242,16 +238,17 @@ InternalStrnCatGrow (
|
||||
//
|
||||
if (CurrentSize != NULL) {
|
||||
NewSize = *CurrentSize;
|
||||
if (NewSize < DestinationStartSize + (SourceLen * sizeof(CHAR16))) {
|
||||
while (NewSize < (DestinationStartSize + (SourceLen*sizeof(CHAR16)))) {
|
||||
NewSize += 2 * SourceLen * sizeof(CHAR16);
|
||||
if (NewSize < DestinationStartSize + (SourceLen * sizeof (CHAR16))) {
|
||||
while (NewSize < (DestinationStartSize + (SourceLen*sizeof (CHAR16)))) {
|
||||
NewSize += 2 * SourceLen * sizeof (CHAR16);
|
||||
}
|
||||
*Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);
|
||||
|
||||
*Destination = ReallocatePool (*CurrentSize, NewSize, *Destination);
|
||||
*CurrentSize = NewSize;
|
||||
}
|
||||
} else {
|
||||
NewSize = (SourceLen + 1)*sizeof(CHAR16);
|
||||
*Destination = AllocateZeroPool(NewSize);
|
||||
NewSize = (SourceLen + 1)*sizeof (CHAR16);
|
||||
*Destination = AllocateZeroPool (NewSize);
|
||||
}
|
||||
|
||||
//
|
||||
@ -261,7 +258,7 @@ InternalStrnCatGrow (
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
StrnCatS(*Destination, NewSize/sizeof(CHAR16), Source, SourceLen);
|
||||
StrnCatS (*Destination, NewSize/sizeof (CHAR16), Source, SourceLen);
|
||||
return *Destination;
|
||||
}
|
||||
|
||||
@ -363,6 +360,7 @@ DumpPcdInfo (
|
||||
} else {
|
||||
Uint8 = mPiPcd->Get8 (TokenSpace, TokenNumber);
|
||||
}
|
||||
|
||||
Print (L" Token = 0x%08x - Type = %H%-17s%N - Size = 0x%x - Value = 0x%x\n", TokenNumber, RetString, PcdInfo->PcdSize, Uint8);
|
||||
break;
|
||||
case EFI_PCD_TYPE_16:
|
||||
@ -371,6 +369,7 @@ DumpPcdInfo (
|
||||
} else {
|
||||
Uint16 = mPiPcd->Get16 (TokenSpace, TokenNumber);
|
||||
}
|
||||
|
||||
Print (L" Token = 0x%08x - Type = %H%-17s%N - Size = 0x%x - Value = 0x%x\n", TokenNumber, RetString, PcdInfo->PcdSize, Uint16);
|
||||
break;
|
||||
case EFI_PCD_TYPE_32:
|
||||
@ -379,6 +378,7 @@ DumpPcdInfo (
|
||||
} else {
|
||||
Uint32 = mPiPcd->Get32 (TokenSpace, TokenNumber);
|
||||
}
|
||||
|
||||
Print (L" Token = 0x%08x - Type = %H%-17s%N - Size = 0x%x - Value = 0x%x\n", TokenNumber, RetString, PcdInfo->PcdSize, Uint32);
|
||||
break;
|
||||
case EFI_PCD_TYPE_64:
|
||||
@ -387,6 +387,7 @@ DumpPcdInfo (
|
||||
} else {
|
||||
Uint64 = mPiPcd->Get64 (TokenSpace, TokenNumber);
|
||||
}
|
||||
|
||||
Print (L" Token = 0x%08x - Type = %H%-17s%N - Size = 0x%x - Value = 0x%lx\n", TokenNumber, RetString, PcdInfo->PcdSize, Uint64);
|
||||
break;
|
||||
case EFI_PCD_TYPE_BOOL:
|
||||
@ -395,6 +396,7 @@ DumpPcdInfo (
|
||||
} else {
|
||||
Boolean = mPiPcd->GetBool (TokenSpace, TokenNumber);
|
||||
}
|
||||
|
||||
Print (L" Token = 0x%08x - Type = %H%-17s%N - Size = 0x%x - Value = %a\n", TokenNumber, RetString, PcdInfo->PcdSize, Boolean ? "TRUE" : "FALSE");
|
||||
break;
|
||||
case EFI_PCD_TYPE_PTR:
|
||||
@ -403,6 +405,7 @@ DumpPcdInfo (
|
||||
} else {
|
||||
PcdData = mPiPcd->GetPtr (TokenSpace, TokenNumber);
|
||||
}
|
||||
|
||||
Print (L" Token = 0x%08x - Type = %H%-17s%N - Size = 0x%x\n", TokenNumber, RetString, PcdInfo->PcdSize);
|
||||
DumpHex (2, 0, PcdInfo->PcdSize, PcdData);
|
||||
break;
|
||||
@ -413,6 +416,7 @@ DumpPcdInfo (
|
||||
if (RetString != NULL) {
|
||||
FreePool (RetString);
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
}
|
||||
|
||||
@ -451,7 +455,7 @@ ProcessPcd (
|
||||
TokenNumber = 0;
|
||||
do {
|
||||
Status = mPiPcd->GetNextToken (TokenSpace, &TokenNumber);
|
||||
if (!EFI_ERROR (Status) && TokenNumber != 0) {
|
||||
if (!EFI_ERROR (Status) && (TokenNumber != 0)) {
|
||||
if (TokenSpace == NULL) {
|
||||
//
|
||||
// PCD in default Token Space.
|
||||
@ -460,10 +464,12 @@ ProcessPcd (
|
||||
} else {
|
||||
mPiPcdInfo->GetInfo (TokenSpace, TokenNumber, &PcdInfo);
|
||||
}
|
||||
|
||||
if (InputPcdName != NULL) {
|
||||
if (PcdInfo.PcdName == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PcdNameSize = AsciiStrSize (PcdInfo.PcdName) * sizeof (CHAR16);
|
||||
if (mTempPcdNameBuffer == NULL) {
|
||||
mTempPcdNameBufferSize = PcdNameSize;
|
||||
@ -472,15 +478,18 @@ ProcessPcd (
|
||||
mTempPcdNameBuffer = ReallocatePool (mTempPcdNameBufferSize, PcdNameSize, mTempPcdNameBuffer);
|
||||
mTempPcdNameBufferSize = PcdNameSize;
|
||||
}
|
||||
|
||||
if (mTempPcdNameBuffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
AsciiStrToUnicodeStrS (PcdInfo.PcdName, mTempPcdNameBuffer, mTempPcdNameBufferSize / sizeof (CHAR16));
|
||||
//
|
||||
// Compare the input PCD name with the PCD name in PCD database.
|
||||
//
|
||||
if ((StrStr (mTempPcdNameBuffer, InputPcdName) != NULL) ||
|
||||
(mUnicodeCollation != NULL && mUnicodeCollation->MetaiMatch (mUnicodeCollation, mTempPcdNameBuffer, InputPcdName))) {
|
||||
((mUnicodeCollation != NULL) && mUnicodeCollation->MetaiMatch (mUnicodeCollation, mTempPcdNameBuffer, InputPcdName)))
|
||||
{
|
||||
//
|
||||
// Found matched PCD.
|
||||
//
|
||||
@ -493,7 +502,7 @@ ProcessPcd (
|
||||
}
|
||||
} while (!EFI_ERROR (Status) && TokenNumber != 0);
|
||||
|
||||
Status = mPiPcd->GetNextTokenSpace ((CONST EFI_GUID **) &TokenSpace);
|
||||
Status = mPiPcd->GetNextTokenSpace ((CONST EFI_GUID **)&TokenSpace);
|
||||
} while (!EFI_ERROR (Status) && TokenSpace != NULL);
|
||||
|
||||
if ((InputPcdName != NULL) && !Found) {
|
||||
@ -503,6 +512,7 @@ ProcessPcd (
|
||||
Print (L"%EError. %NNo matching PCD found: %s.\n", InputPcdName);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -531,30 +541,30 @@ DumpDynPcdMain (
|
||||
|
||||
InputPcdName = NULL;
|
||||
|
||||
Status = gBS->LocateProtocol(&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID **) &mUnicodeCollation);
|
||||
Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID **)&mUnicodeCollation);
|
||||
if (EFI_ERROR (Status)) {
|
||||
mUnicodeCollation = NULL;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **) &mPiPcd);
|
||||
Status = gBS->LocateProtocol (&gEfiPcdProtocolGuid, NULL, (VOID **)&mPiPcd);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"DumpDynPcd: %EError. %NPI PCD protocol is not present.\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **) &mPiPcdInfo);
|
||||
Status = gBS->LocateProtocol (&gEfiGetPcdInfoProtocolGuid, NULL, (VOID **)&mPiPcdInfo);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"DumpDynPcd: %EError. %NPI PCD info protocol is not present.\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **) &mPcd);
|
||||
Status = gBS->LocateProtocol (&gPcdProtocolGuid, NULL, (VOID **)&mPcd);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"DumpDynPcd: %EError. %NPCD protocol is not present.\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **) &mPcdInfo);
|
||||
Status = gBS->LocateProtocol (&gGetPcdInfoProtocolGuid, NULL, (VOID **)&mPcdInfo);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"DumpDynPcd: %EError. %NPCD info protocol is not present.\n");
|
||||
return Status;
|
||||
@ -563,33 +573,33 @@ DumpDynPcdMain (
|
||||
//
|
||||
// get the command line arguments
|
||||
//
|
||||
Status = GetArg();
|
||||
if (EFI_ERROR(Status)){
|
||||
Status = GetArg ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"DumpDynPcd: %EError. %NThe input parameters are not recognized.\n");
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Argc > 2){
|
||||
if (Argc > 2) {
|
||||
Print (L"DumpDynPcd: %EError. %NToo many arguments specified.\n");
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Argc == 1){
|
||||
if (Argc == 1) {
|
||||
Status = ProcessPcd (InputPcdName);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if ((StrCmp(Argv[1], L"-?") == 0)||(StrCmp(Argv[1], L"-h") == 0)||(StrCmp(Argv[1], L"-H") == 0)){
|
||||
if ((StrCmp (Argv[1], L"-?") == 0) || (StrCmp (Argv[1], L"-h") == 0) || (StrCmp (Argv[1], L"-H") == 0)) {
|
||||
ShowHelp ();
|
||||
goto Done;
|
||||
} else {
|
||||
if ((StrCmp(Argv[1], L"-v") == 0)||(StrCmp(Argv[1], L"-V") == 0)){
|
||||
if ((StrCmp (Argv[1], L"-v") == 0) || (StrCmp (Argv[1], L"-V") == 0)) {
|
||||
ShowVersion ();
|
||||
goto Done;
|
||||
} else {
|
||||
if (StrStr(Argv[1], L"-") != NULL){
|
||||
if (StrStr (Argv[1], L"-") != NULL) {
|
||||
Print (L"DumpDynPcd: %EError. %NThe argument '%B%s%N' is invalid.\n", Argv[1]);
|
||||
goto Done;
|
||||
}
|
||||
@ -599,7 +609,7 @@ DumpDynPcdMain (
|
||||
InputPcdName = Argv[1];
|
||||
Status = ProcessPcd (InputPcdName);
|
||||
|
||||
Done:
|
||||
Done:
|
||||
|
||||
if (mTempPcdNameBuffer != NULL) {
|
||||
FreePool (mTempPcdNameBuffer);
|
||||
@ -607,4 +617,3 @@ DumpDynPcdMain (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ UefiMain (
|
||||
// Three PCD type (FeatureFlag, UINT32 and String) are used as the sample.
|
||||
//
|
||||
if (FeaturePcdGet (PcdHelloWorldPrintEnable)) {
|
||||
for (Index = 0; Index < PcdGet32 (PcdHelloWorldPrintTimes); Index ++) {
|
||||
for (Index = 0; Index < PcdGet32 (PcdHelloWorldPrintTimes); Index++) {
|
||||
//
|
||||
// Use UefiLib Print API to print string to UEFI console
|
||||
//
|
||||
Print ((CHAR16*)PcdGetPtr (PcdHelloWorldPrintString));
|
||||
Print ((CHAR16 *)PcdGetPtr (PcdHelloWorldPrintString));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,30 +46,30 @@ typedef struct {
|
||||
} ACTION_STRING;
|
||||
|
||||
ACTION_STRING mExtActionString[] = {
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES, "Lib:AllocatePages"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES, "Lib:AllocateRuntimePages"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES, "Lib:AllocateReservedPages"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_FREE_PAGES, "Lib:FreePages"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES, "Lib:AllocateAlignedPages"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES, "Lib:AllocateAlignedRuntimePages"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RESERVED_PAGES, "Lib:AllocateAlignedReservedPages"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_FREE_ALIGNED_PAGES, "Lib:FreeAlignedPages"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL, "Lib:AllocatePool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL, "Lib:AllocateRuntimePool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_POOL, "Lib:AllocateReservedPool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_FREE_POOL, "Lib:FreePool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL, "Lib:AllocateZeroPool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL, "Lib:AllocateRuntimeZeroPool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL, "Lib:AllocateReservedZeroPool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL, "Lib:AllocateCopyPool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL, "Lib:AllocateRuntimeCopyPool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_COPY_POOL, "Lib:AllocateReservedCopyPool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL, "Lib:ReallocatePool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL, "Lib:ReallocateRuntimePool"},
|
||||
{MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL, "Lib:ReallocateReservedPool"},
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES, "Lib:AllocatePages" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES, "Lib:AllocateRuntimePages" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES, "Lib:AllocateReservedPages" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_FREE_PAGES, "Lib:FreePages" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES, "Lib:AllocateAlignedPages" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES, "Lib:AllocateAlignedRuntimePages" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RESERVED_PAGES, "Lib:AllocateAlignedReservedPages" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_FREE_ALIGNED_PAGES, "Lib:FreeAlignedPages" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL, "Lib:AllocatePool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL, "Lib:AllocateRuntimePool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_POOL, "Lib:AllocateReservedPool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_FREE_POOL, "Lib:FreePool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL, "Lib:AllocateZeroPool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL, "Lib:AllocateRuntimeZeroPool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL, "Lib:AllocateReservedZeroPool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL, "Lib:AllocateCopyPool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL, "Lib:AllocateRuntimeCopyPool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_COPY_POOL, "Lib:AllocateReservedCopyPool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL, "Lib:ReallocatePool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL, "Lib:ReallocateRuntimePool" },
|
||||
{ MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL, "Lib:ReallocateReservedPool" },
|
||||
};
|
||||
|
||||
CHAR8 mUserDefinedActionString[] = {"UserDefined-0x80000000"};
|
||||
CHAR8 mUserDefinedActionString[] = { "UserDefined-0x80000000" };
|
||||
|
||||
CHAR8 *mMemoryTypeString[] = {
|
||||
"EfiReservedMemoryType",
|
||||
@ -196,7 +196,9 @@ GetShortPdbFileName (
|
||||
AsciiStrnCpyS (AsciiBuffer, PROFILE_NAME_STRING_LENGTH + 1, " ", 1);
|
||||
} else {
|
||||
StartIndex = 0;
|
||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++);
|
||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) {
|
||||
}
|
||||
|
||||
for (IndexPdb = 0; PdbFileName[IndexPdb] != 0; IndexPdb++) {
|
||||
if ((PdbFileName[IndexPdb] == '\\') || (PdbFileName[IndexPdb] == '/')) {
|
||||
StartIndex = IndexPdb + 1;
|
||||
@ -244,7 +246,7 @@ GetDriverNameString (
|
||||
// Method 1: Get the name string from image PDB
|
||||
//
|
||||
if (DriverInfo->PdbStringOffset != 0) {
|
||||
GetShortPdbFileName ((CHAR8 *) ((UINTN) DriverInfo + DriverInfo->PdbStringOffset), mNameString);
|
||||
GetShortPdbFileName ((CHAR8 *)((UINTN)DriverInfo + DriverInfo->PdbStringOffset), mNameString);
|
||||
return mNameString;
|
||||
}
|
||||
|
||||
@ -258,7 +260,7 @@ GetDriverNameString (
|
||||
&DriverInfo->FileName,
|
||||
EFI_SECTION_USER_INTERFACE,
|
||||
0,
|
||||
(VOID **) &NameString,
|
||||
(VOID **)&NameString,
|
||||
&StringSize
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@ -268,6 +270,7 @@ GetDriverNameString (
|
||||
if (StrLen (NameString) > PROFILE_NAME_STRING_LENGTH) {
|
||||
NameString[PROFILE_NAME_STRING_LENGTH] = 0;
|
||||
}
|
||||
|
||||
UnicodeStrToAsciiStrS (NameString, mNameString, sizeof (mNameString));
|
||||
FreePool (NameString);
|
||||
return mNameString;
|
||||
@ -296,12 +299,12 @@ ProfileMemoryTypeToStr (
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
if ((UINT32) MemoryType >= 0x80000000) {
|
||||
if ((UINT32)MemoryType >= 0x80000000) {
|
||||
//
|
||||
// OS reserved memory type.
|
||||
//
|
||||
Index = EfiMaxMemoryType;
|
||||
} else if ((UINT32) MemoryType >= 0x70000000) {
|
||||
} else if ((UINT32)MemoryType >= 0x70000000) {
|
||||
//
|
||||
// OEM reserved memory type.
|
||||
//
|
||||
@ -343,18 +346,21 @@ ProfileActionToStr (
|
||||
ActionStringCount = ARRAY_SIZE (mActionString);
|
||||
}
|
||||
|
||||
if ((UINTN) (UINT32) Action < ActionStringCount) {
|
||||
if ((UINTN)(UINT32)Action < ActionStringCount) {
|
||||
return ActionString[Action];
|
||||
}
|
||||
|
||||
for (Index = 0; Index < ARRAY_SIZE (mExtActionString); Index++) {
|
||||
if (mExtActionString[Index].Action == Action) {
|
||||
return mExtActionString[Index].String;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Action & MEMORY_PROFILE_ACTION_USER_DEFINED_MASK) != 0) {
|
||||
if (UserDefinedActionString != NULL) {
|
||||
return UserDefinedActionString;
|
||||
}
|
||||
|
||||
AsciiSPrint (mUserDefinedActionString, sizeof (mUserDefinedActionString), "UserDefined-0x%08x", Action);
|
||||
return mUserDefinedActionString;
|
||||
}
|
||||
@ -389,7 +395,7 @@ DumpMemoryProfileAllocInfo (
|
||||
}
|
||||
|
||||
if (AllocInfo->ActionStringOffset != 0) {
|
||||
ActionString = (CHAR8 *) ((UINTN) AllocInfo + AllocInfo->ActionStringOffset);
|
||||
ActionString = (CHAR8 *)((UINTN)AllocInfo + AllocInfo->ActionStringOffset);
|
||||
} else {
|
||||
ActionString = NULL;
|
||||
}
|
||||
@ -398,14 +404,14 @@ DumpMemoryProfileAllocInfo (
|
||||
Print (L" Signature - 0x%08x\n", AllocInfo->Header.Signature);
|
||||
Print (L" Length - 0x%04x\n", AllocInfo->Header.Length);
|
||||
Print (L" Revision - 0x%04x\n", AllocInfo->Header.Revision);
|
||||
Print (L" CallerAddress - 0x%016lx (Offset: 0x%08x)\n", AllocInfo->CallerAddress, (UINTN) (AllocInfo->CallerAddress - DriverInfo->ImageBase));
|
||||
Print (L" CallerAddress - 0x%016lx (Offset: 0x%08x)\n", AllocInfo->CallerAddress, (UINTN)(AllocInfo->CallerAddress - DriverInfo->ImageBase));
|
||||
Print (L" SequenceId - 0x%08x\n", AllocInfo->SequenceId);
|
||||
Print (L" Action - 0x%08x (%a)\n", AllocInfo->Action, ProfileActionToStr (AllocInfo->Action, ActionString, IsForSmm));
|
||||
Print (L" MemoryType - 0x%08x (%a)\n", AllocInfo->MemoryType, ProfileMemoryTypeToStr (AllocInfo->MemoryType));
|
||||
Print (L" Buffer - 0x%016lx\n", AllocInfo->Buffer);
|
||||
Print (L" Size - 0x%016lx\n", AllocInfo->Size);
|
||||
|
||||
return (MEMORY_PROFILE_ALLOC_INFO *) ((UINTN) AllocInfo + AllocInfo->Header.Length);
|
||||
return (MEMORY_PROFILE_ALLOC_INFO *)((UINTN)AllocInfo + AllocInfo->Header.Length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -434,6 +440,7 @@ DumpMemoryProfileDriverInfo (
|
||||
if (DriverInfo->Header.Signature != MEMORY_PROFILE_DRIVER_INFO_SIGNATURE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Print (L" MEMORY_PROFILE_DRIVER_INFO (0x%x)\n", DriverIndex);
|
||||
Print (L" Signature - 0x%08x\n", DriverInfo->Header.Signature);
|
||||
Print (L" Length - 0x%04x\n", DriverInfo->Header.Length);
|
||||
@ -441,32 +448,36 @@ DumpMemoryProfileDriverInfo (
|
||||
NameString = GetDriverNameString (DriverInfo);
|
||||
Print (L" FileName - %a\n", NameString);
|
||||
if (DriverInfo->PdbStringOffset != 0) {
|
||||
Print (L" Pdb - %a\n", (CHAR8 *) ((UINTN) DriverInfo + DriverInfo->PdbStringOffset));
|
||||
Print (L" Pdb - %a\n", (CHAR8 *)((UINTN)DriverInfo + DriverInfo->PdbStringOffset));
|
||||
}
|
||||
|
||||
Print (L" ImageBase - 0x%016lx\n", DriverInfo->ImageBase);
|
||||
Print (L" ImageSize - 0x%016lx\n", DriverInfo->ImageSize);
|
||||
Print (L" EntryPoint - 0x%016lx\n", DriverInfo->EntryPoint);
|
||||
Print (L" ImageSubsystem - 0x%04x (%a)\n", DriverInfo->ImageSubsystem, mSubsystemString[(DriverInfo->ImageSubsystem < sizeof(mSubsystemString)/sizeof(mSubsystemString[0])) ? DriverInfo->ImageSubsystem : 0]);
|
||||
Print (L" FileType - 0x%02x (%a)\n", DriverInfo->FileType, mFileTypeString[(DriverInfo->FileType < sizeof(mFileTypeString)/sizeof(mFileTypeString[0])) ? DriverInfo->FileType : 0]);
|
||||
Print (L" ImageSubsystem - 0x%04x (%a)\n", DriverInfo->ImageSubsystem, mSubsystemString[(DriverInfo->ImageSubsystem < sizeof (mSubsystemString)/sizeof (mSubsystemString[0])) ? DriverInfo->ImageSubsystem : 0]);
|
||||
Print (L" FileType - 0x%02x (%a)\n", DriverInfo->FileType, mFileTypeString[(DriverInfo->FileType < sizeof (mFileTypeString)/sizeof (mFileTypeString[0])) ? DriverInfo->FileType : 0]);
|
||||
Print (L" CurrentUsage - 0x%016lx\n", DriverInfo->CurrentUsage);
|
||||
Print (L" PeakUsage - 0x%016lx\n", DriverInfo->PeakUsage);
|
||||
for (TypeIndex = 0; TypeIndex < sizeof (DriverInfo->CurrentUsageByType) / sizeof (DriverInfo->CurrentUsageByType[0]); TypeIndex++) {
|
||||
if ((DriverInfo->CurrentUsageByType[TypeIndex] != 0) ||
|
||||
(DriverInfo->PeakUsageByType[TypeIndex] != 0)) {
|
||||
(DriverInfo->PeakUsageByType[TypeIndex] != 0))
|
||||
{
|
||||
Print (L" CurrentUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, DriverInfo->CurrentUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]);
|
||||
Print (L" PeakUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, DriverInfo->PeakUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
Print (L" AllocRecordCount - 0x%08x\n", DriverInfo->AllocRecordCount);
|
||||
|
||||
AllocInfo = (MEMORY_PROFILE_ALLOC_INFO *) ((UINTN) DriverInfo + DriverInfo->Header.Length);
|
||||
AllocInfo = (MEMORY_PROFILE_ALLOC_INFO *)((UINTN)DriverInfo + DriverInfo->Header.Length);
|
||||
for (AllocIndex = 0; AllocIndex < DriverInfo->AllocRecordCount; AllocIndex++) {
|
||||
AllocInfo = DumpMemoryProfileAllocInfo (DriverInfo, AllocIndex, AllocInfo, IsForSmm);
|
||||
if (AllocInfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return (MEMORY_PROFILE_DRIVER_INFO *) AllocInfo;
|
||||
|
||||
return (MEMORY_PROFILE_DRIVER_INFO *)AllocInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -492,6 +503,7 @@ DumpMemoryProfileContext (
|
||||
if (Context->Header.Signature != MEMORY_PROFILE_CONTEXT_SIGNATURE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Print (L"MEMORY_PROFILE_CONTEXT\n");
|
||||
Print (L" Signature - 0x%08x\n", Context->Header.Signature);
|
||||
Print (L" Length - 0x%04x\n", Context->Header.Length);
|
||||
@ -500,23 +512,26 @@ DumpMemoryProfileContext (
|
||||
Print (L" PeakTotalUsage - 0x%016lx\n", Context->PeakTotalUsage);
|
||||
for (TypeIndex = 0; TypeIndex < sizeof (Context->CurrentTotalUsageByType) / sizeof (Context->CurrentTotalUsageByType[0]); TypeIndex++) {
|
||||
if ((Context->CurrentTotalUsageByType[TypeIndex] != 0) ||
|
||||
(Context->PeakTotalUsageByType[TypeIndex] != 0)) {
|
||||
(Context->PeakTotalUsageByType[TypeIndex] != 0))
|
||||
{
|
||||
Print (L" CurrentTotalUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, Context->CurrentTotalUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]);
|
||||
Print (L" PeakTotalUsage[0x%02x] - 0x%016lx (%a)\n", TypeIndex, Context->PeakTotalUsageByType[TypeIndex], mMemoryTypeString[TypeIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
Print (L" TotalImageSize - 0x%016lx\n", Context->TotalImageSize);
|
||||
Print (L" ImageCount - 0x%08x\n", Context->ImageCount);
|
||||
Print (L" SequenceCount - 0x%08x\n", Context->SequenceCount);
|
||||
|
||||
DriverInfo = (MEMORY_PROFILE_DRIVER_INFO *) ((UINTN) Context + Context->Header.Length);
|
||||
DriverInfo = (MEMORY_PROFILE_DRIVER_INFO *)((UINTN)Context + Context->Header.Length);
|
||||
for (DriverIndex = 0; DriverIndex < Context->ImageCount; DriverIndex++) {
|
||||
DriverInfo = DumpMemoryProfileDriverInfo (DriverIndex, DriverInfo, IsForSmm);
|
||||
if (DriverInfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return (VOID *) DriverInfo;
|
||||
|
||||
return (VOID *)DriverInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -537,6 +552,7 @@ DumpMemoryProfileDescriptor (
|
||||
if (Descriptor->Header.Signature != MEMORY_PROFILE_DESCRIPTOR_SIGNATURE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Print (L" MEMORY_PROFILE_DESCRIPTOR (0x%x)\n", DescriptorIndex);
|
||||
Print (L" Signature - 0x%08x\n", Descriptor->Header.Signature);
|
||||
Print (L" Length - 0x%04x\n", Descriptor->Header.Length);
|
||||
@ -544,7 +560,7 @@ DumpMemoryProfileDescriptor (
|
||||
Print (L" Address - 0x%016lx\n", Descriptor->Address);
|
||||
Print (L" Size - 0x%016lx\n", Descriptor->Size);
|
||||
|
||||
return (MEMORY_PROFILE_DESCRIPTOR *) ((UINTN) Descriptor + Descriptor->Header.Length);
|
||||
return (MEMORY_PROFILE_DESCRIPTOR *)((UINTN)Descriptor + Descriptor->Header.Length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -566,6 +582,7 @@ DumpMemoryProfileFreeMemory (
|
||||
if (FreeMemory->Header.Signature != MEMORY_PROFILE_FREE_MEMORY_SIGNATURE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Print (L"MEMORY_PROFILE_FREE_MEMORY\n");
|
||||
Print (L" Signature - 0x%08x\n", FreeMemory->Header.Signature);
|
||||
Print (L" Length - 0x%04x\n", FreeMemory->Header.Length);
|
||||
@ -573,7 +590,7 @@ DumpMemoryProfileFreeMemory (
|
||||
Print (L" TotalFreeMemoryPages - 0x%016lx\n", FreeMemory->TotalFreeMemoryPages);
|
||||
Print (L" FreeMemoryEntryCount - 0x%08x\n", FreeMemory->FreeMemoryEntryCount);
|
||||
|
||||
Descriptor = (MEMORY_PROFILE_DESCRIPTOR *) ((UINTN) FreeMemory + FreeMemory->Header.Length);
|
||||
Descriptor = (MEMORY_PROFILE_DESCRIPTOR *)((UINTN)FreeMemory + FreeMemory->Header.Length);
|
||||
for (DescriptorIndex = 0; DescriptorIndex < FreeMemory->FreeMemoryEntryCount; DescriptorIndex++) {
|
||||
Descriptor = DumpMemoryProfileDescriptor (DescriptorIndex, Descriptor);
|
||||
if (Descriptor == NULL) {
|
||||
@ -581,7 +598,7 @@ DumpMemoryProfileFreeMemory (
|
||||
}
|
||||
}
|
||||
|
||||
return (VOID *) Descriptor;
|
||||
return (VOID *)Descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -603,13 +620,14 @@ DumpMemoryProfileMemoryRange (
|
||||
if (MemoryRange->Header.Signature != MEMORY_PROFILE_MEMORY_RANGE_SIGNATURE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Print (L"MEMORY_PROFILE_MEMORY_RANGE\n");
|
||||
Print (L" Signature - 0x%08x\n", MemoryRange->Header.Signature);
|
||||
Print (L" Length - 0x%04x\n", MemoryRange->Header.Length);
|
||||
Print (L" Revision - 0x%04x\n", MemoryRange->Header.Revision);
|
||||
Print (L" MemoryRangeCount - 0x%08x\n", MemoryRange->MemoryRangeCount);
|
||||
|
||||
Descriptor = (MEMORY_PROFILE_DESCRIPTOR *) ((UINTN) MemoryRange + MemoryRange->Header.Length);
|
||||
Descriptor = (MEMORY_PROFILE_DESCRIPTOR *)((UINTN)MemoryRange + MemoryRange->Header.Length);
|
||||
for (DescriptorIndex = 0; DescriptorIndex < MemoryRange->MemoryRangeCount; DescriptorIndex++) {
|
||||
Descriptor = DumpMemoryProfileDescriptor (DescriptorIndex, Descriptor);
|
||||
if (Descriptor == NULL) {
|
||||
@ -617,7 +635,7 @@ DumpMemoryProfileMemoryRange (
|
||||
}
|
||||
}
|
||||
|
||||
return (VOID *) Descriptor;
|
||||
return (VOID *)Descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -640,20 +658,22 @@ ScanMemoryProfileBySignature (
|
||||
MEMORY_PROFILE_COMMON_HEADER *CommonHeader;
|
||||
UINTN ProfileEnd;
|
||||
|
||||
ProfileEnd = (UINTN) (ProfileBuffer + ProfileSize);
|
||||
CommonHeader = (MEMORY_PROFILE_COMMON_HEADER *) (UINTN) ProfileBuffer;
|
||||
while ((UINTN) CommonHeader < ProfileEnd) {
|
||||
ProfileEnd = (UINTN)(ProfileBuffer + ProfileSize);
|
||||
CommonHeader = (MEMORY_PROFILE_COMMON_HEADER *)(UINTN)ProfileBuffer;
|
||||
while ((UINTN)CommonHeader < ProfileEnd) {
|
||||
if (CommonHeader->Signature == Signature) {
|
||||
//
|
||||
// Found it.
|
||||
//
|
||||
return (VOID *) CommonHeader;
|
||||
return (VOID *)CommonHeader;
|
||||
}
|
||||
|
||||
if (CommonHeader->Length == 0) {
|
||||
ASSERT (FALSE);
|
||||
return NULL;
|
||||
}
|
||||
CommonHeader = (MEMORY_PROFILE_COMMON_HEADER *) ((UINTN) CommonHeader + CommonHeader->Length);
|
||||
|
||||
CommonHeader = (MEMORY_PROFILE_COMMON_HEADER *)((UINTN)CommonHeader + CommonHeader->Length);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -679,17 +699,17 @@ DumpMemoryProfile (
|
||||
MEMORY_PROFILE_FREE_MEMORY *FreeMemory;
|
||||
MEMORY_PROFILE_MEMORY_RANGE *MemoryRange;
|
||||
|
||||
Context = (MEMORY_PROFILE_CONTEXT *) ScanMemoryProfileBySignature (ProfileBuffer, ProfileSize, MEMORY_PROFILE_CONTEXT_SIGNATURE);
|
||||
Context = (MEMORY_PROFILE_CONTEXT *)ScanMemoryProfileBySignature (ProfileBuffer, ProfileSize, MEMORY_PROFILE_CONTEXT_SIGNATURE);
|
||||
if (Context != NULL) {
|
||||
DumpMemoryProfileContext (Context, IsForSmm);
|
||||
}
|
||||
|
||||
FreeMemory = (MEMORY_PROFILE_FREE_MEMORY *) ScanMemoryProfileBySignature (ProfileBuffer, ProfileSize, MEMORY_PROFILE_FREE_MEMORY_SIGNATURE);
|
||||
FreeMemory = (MEMORY_PROFILE_FREE_MEMORY *)ScanMemoryProfileBySignature (ProfileBuffer, ProfileSize, MEMORY_PROFILE_FREE_MEMORY_SIGNATURE);
|
||||
if (FreeMemory != NULL) {
|
||||
DumpMemoryProfileFreeMemory (FreeMemory);
|
||||
}
|
||||
|
||||
MemoryRange = (MEMORY_PROFILE_MEMORY_RANGE *) ScanMemoryProfileBySignature (ProfileBuffer, ProfileSize, MEMORY_PROFILE_MEMORY_RANGE_SIGNATURE);
|
||||
MemoryRange = (MEMORY_PROFILE_MEMORY_RANGE *)ScanMemoryProfileBySignature (ProfileBuffer, ProfileSize, MEMORY_PROFILE_MEMORY_RANGE_SIGNATURE);
|
||||
if (MemoryRange != NULL) {
|
||||
DumpMemoryProfileMemoryRange (MemoryRange);
|
||||
}
|
||||
@ -719,7 +739,8 @@ GetAllocSummaryInfoByCallerAddress (
|
||||
|
||||
for (AllocSummaryLink = AllocSummaryInfoList->ForwardLink;
|
||||
AllocSummaryLink != AllocSummaryInfoList;
|
||||
AllocSummaryLink = AllocSummaryLink->ForwardLink) {
|
||||
AllocSummaryLink = AllocSummaryLink->ForwardLink)
|
||||
{
|
||||
AllocSummaryInfoData = CR (
|
||||
AllocSummaryLink,
|
||||
MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA,
|
||||
@ -731,6 +752,7 @@ GetAllocSummaryInfoByCallerAddress (
|
||||
return AllocSummaryInfoData;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -772,19 +794,21 @@ CreateAllocSummaryInfo (
|
||||
AllocSummaryInfo->CallerAddress = AllocInfo->CallerAddress;
|
||||
AllocSummaryInfo->Action = AllocInfo->Action;
|
||||
if (AllocInfo->ActionStringOffset != 0) {
|
||||
AllocSummaryInfo->ActionString = (CHAR8 *) ((UINTN) AllocInfo + AllocInfo->ActionStringOffset);
|
||||
AllocSummaryInfo->ActionString = (CHAR8 *)((UINTN)AllocInfo + AllocInfo->ActionStringOffset);
|
||||
} else {
|
||||
AllocSummaryInfo->ActionString = NULL;
|
||||
}
|
||||
|
||||
AllocSummaryInfo->AllocateCount = 0;
|
||||
AllocSummaryInfo->TotalSize = 0;
|
||||
InsertTailList (DriverSummaryInfoData->AllocSummaryInfoList, &AllocSummaryInfoData->Link);
|
||||
}
|
||||
|
||||
AllocSummaryInfo = &AllocSummaryInfoData->AllocSummaryInfo;
|
||||
AllocSummaryInfo->AllocateCount ++;
|
||||
AllocSummaryInfo->AllocateCount++;
|
||||
AllocSummaryInfo->TotalSize += AllocInfo->Size;
|
||||
|
||||
return (MEMORY_PROFILE_ALLOC_INFO *) ((UINTN) AllocInfo + AllocInfo->Header.Length);
|
||||
return (MEMORY_PROFILE_ALLOC_INFO *)((UINTN)AllocInfo + AllocInfo->Header.Length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -815,20 +839,22 @@ CreateDriverSummaryInfo (
|
||||
if (DriverSummaryInfoData == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DriverSummaryInfoData->Signature = MEMORY_PROFILE_DRIVER_INFO_SIGNATURE;
|
||||
DriverSummaryInfoData->DriverInfo = DriverInfo;
|
||||
DriverSummaryInfoData->AllocSummaryInfoList = (LIST_ENTRY *) (DriverSummaryInfoData + 1);
|
||||
DriverSummaryInfoData->AllocSummaryInfoList = (LIST_ENTRY *)(DriverSummaryInfoData + 1);
|
||||
InitializeListHead (DriverSummaryInfoData->AllocSummaryInfoList);
|
||||
InsertTailList (ContextSummaryData->DriverSummaryInfoList, &DriverSummaryInfoData->Link);
|
||||
|
||||
AllocInfo = (MEMORY_PROFILE_ALLOC_INFO *) ((UINTN) DriverInfo + DriverInfo->Header.Length);
|
||||
AllocInfo = (MEMORY_PROFILE_ALLOC_INFO *)((UINTN)DriverInfo + DriverInfo->Header.Length);
|
||||
for (AllocIndex = 0; AllocIndex < DriverInfo->AllocRecordCount; AllocIndex++) {
|
||||
AllocInfo = CreateAllocSummaryInfo (DriverSummaryInfoData, AllocInfo);
|
||||
if (AllocInfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return (MEMORY_PROFILE_DRIVER_INFO *) AllocInfo;
|
||||
|
||||
return (MEMORY_PROFILE_DRIVER_INFO *)AllocInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -850,7 +876,7 @@ CreateContextSummaryData (
|
||||
MEMORY_PROFILE_DRIVER_INFO *DriverInfo;
|
||||
UINTN DriverIndex;
|
||||
|
||||
Context = (MEMORY_PROFILE_CONTEXT *) ScanMemoryProfileBySignature (ProfileBuffer, ProfileSize, MEMORY_PROFILE_CONTEXT_SIGNATURE);
|
||||
Context = (MEMORY_PROFILE_CONTEXT *)ScanMemoryProfileBySignature (ProfileBuffer, ProfileSize, MEMORY_PROFILE_CONTEXT_SIGNATURE);
|
||||
if (Context == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -859,7 +885,7 @@ CreateContextSummaryData (
|
||||
mMemoryProfileContextSummary.Context = Context;
|
||||
mMemoryProfileContextSummary.DriverSummaryInfoList = &mImageSummaryQueue;
|
||||
|
||||
DriverInfo = (MEMORY_PROFILE_DRIVER_INFO *) ((UINTN) Context + Context->Header.Length);
|
||||
DriverInfo = (MEMORY_PROFILE_DRIVER_INFO *)((UINTN)Context + Context->Header.Length);
|
||||
for (DriverIndex = 0; DriverIndex < Context->ImageCount; DriverIndex++) {
|
||||
DriverInfo = CreateDriverSummaryInfo (&mMemoryProfileContextSummary, DriverInfo);
|
||||
if (DriverInfo == NULL) {
|
||||
@ -895,7 +921,7 @@ DumpContextSummaryData (
|
||||
CHAR8 *NameString;
|
||||
|
||||
if (ContextSummaryData == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Print (L"\nSummary Data:\n");
|
||||
@ -903,7 +929,8 @@ DumpContextSummaryData (
|
||||
DriverSummaryInfoList = ContextSummaryData->DriverSummaryInfoList;
|
||||
for (DriverSummaryLink = DriverSummaryInfoList->ForwardLink;
|
||||
DriverSummaryLink != DriverSummaryInfoList;
|
||||
DriverSummaryLink = DriverSummaryLink->ForwardLink) {
|
||||
DriverSummaryLink = DriverSummaryLink->ForwardLink)
|
||||
{
|
||||
DriverSummaryInfoData = CR (
|
||||
DriverSummaryLink,
|
||||
MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA,
|
||||
@ -920,17 +947,19 @@ DumpContextSummaryData (
|
||||
}
|
||||
|
||||
if (DriverInfo->PdbStringOffset != 0) {
|
||||
Print (L" (Pdb - %a)\n", (CHAR8 *) ((UINTN) DriverInfo + DriverInfo->PdbStringOffset));
|
||||
Print (L" (Pdb - %a)\n", (CHAR8 *)((UINTN)DriverInfo + DriverInfo->PdbStringOffset));
|
||||
} else {
|
||||
Print (L"\n");
|
||||
}
|
||||
|
||||
Print (L"Caller List:\n");
|
||||
Print(L" Count Size RVA Action\n");
|
||||
Print(L"========== ================== ================== (================================)\n");
|
||||
Print (L" Count Size RVA Action\n");
|
||||
Print (L"========== ================== ================== (================================)\n");
|
||||
AllocSummaryInfoList = DriverSummaryInfoData->AllocSummaryInfoList;
|
||||
for (AllocSummaryLink = AllocSummaryInfoList->ForwardLink;
|
||||
AllocSummaryLink != AllocSummaryInfoList;
|
||||
AllocSummaryLink = AllocSummaryLink->ForwardLink) {
|
||||
AllocSummaryLink = AllocSummaryLink->ForwardLink)
|
||||
{
|
||||
AllocSummaryInfoData = CR (
|
||||
AllocSummaryLink,
|
||||
MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA,
|
||||
@ -939,7 +968,8 @@ DumpContextSummaryData (
|
||||
);
|
||||
AllocSummaryInfo = &AllocSummaryInfoData->AllocSummaryInfo;
|
||||
|
||||
Print(L"0x%08x 0x%016lx <== 0x%016lx",
|
||||
Print (
|
||||
L"0x%08x 0x%016lx <== 0x%016lx",
|
||||
AllocSummaryInfo->AllocateCount,
|
||||
AllocSummaryInfo->TotalSize,
|
||||
AllocSummaryInfo->CallerAddress - DriverInfo->ImageBase
|
||||
@ -947,7 +977,8 @@ DumpContextSummaryData (
|
||||
Print (L" (%a)\n", ProfileActionToStr (AllocSummaryInfo->Action, AllocSummaryInfo->ActionString, IsForSmm));
|
||||
}
|
||||
}
|
||||
return ;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -969,13 +1000,14 @@ DestroyContextSummaryData (
|
||||
LIST_ENTRY *AllocSummaryLink;
|
||||
|
||||
if (ContextSummaryData == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
DriverSummaryInfoList = ContextSummaryData->DriverSummaryInfoList;
|
||||
for (DriverSummaryLink = DriverSummaryInfoList->ForwardLink;
|
||||
DriverSummaryLink != DriverSummaryInfoList;
|
||||
) {
|
||||
)
|
||||
{
|
||||
DriverSummaryInfoData = CR (
|
||||
DriverSummaryLink,
|
||||
MEMORY_PROFILE_DRIVER_SUMMARY_INFO_DATA,
|
||||
@ -987,7 +1019,8 @@ DestroyContextSummaryData (
|
||||
AllocSummaryInfoList = DriverSummaryInfoData->AllocSummaryInfoList;
|
||||
for (AllocSummaryLink = AllocSummaryInfoList->ForwardLink;
|
||||
AllocSummaryLink != AllocSummaryInfoList;
|
||||
) {
|
||||
)
|
||||
{
|
||||
AllocSummaryInfoData = CR (
|
||||
AllocSummaryLink,
|
||||
MEMORY_PROFILE_ALLOC_SUMMARY_INFO_DATA,
|
||||
@ -1003,7 +1036,8 @@ DestroyContextSummaryData (
|
||||
RemoveEntryList (&DriverSummaryInfoData->Link);
|
||||
FreePool (DriverSummaryInfoData);
|
||||
}
|
||||
return ;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1025,7 +1059,7 @@ GetUefiMemoryProfileData (
|
||||
MEMORY_PROFILE_CONTEXT_SUMMARY_DATA *MemoryProfileContextSummaryData;
|
||||
BOOLEAN RecordingState;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEdkiiMemoryProfileGuid, NULL, (VOID **) &ProfileProtocol);
|
||||
Status = gBS->LocateProtocol (&gEdkiiMemoryProfileGuid, NULL, (VOID **)&ProfileProtocol);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "UefiMemoryProfile: Locate MemoryProfile protocol - %r\n", Status));
|
||||
return Status;
|
||||
@ -1052,7 +1086,7 @@ GetUefiMemoryProfileData (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Data = AllocateZeroPool ((UINTN) Size);
|
||||
Data = AllocateZeroPool ((UINTN)Size);
|
||||
if (Data == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
Print (L"UefiMemoryProfile: AllocateZeroPool (0x%x) - %r\n", Size, Status);
|
||||
@ -1069,15 +1103,14 @@ GetUefiMemoryProfileData (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
|
||||
Print (L"UefiMemoryProfileSize - 0x%x\n", Size);
|
||||
Print (L"======= UefiMemoryProfile begin =======\n");
|
||||
DumpMemoryProfile ((PHYSICAL_ADDRESS) (UINTN) Data, Size, FALSE);
|
||||
DumpMemoryProfile ((PHYSICAL_ADDRESS)(UINTN)Data, Size, FALSE);
|
||||
|
||||
//
|
||||
// Dump summary information
|
||||
//
|
||||
MemoryProfileContextSummaryData = CreateContextSummaryData ((PHYSICAL_ADDRESS) (UINTN) Data, Size);
|
||||
MemoryProfileContextSummaryData = CreateContextSummaryData ((PHYSICAL_ADDRESS)(UINTN)Data, Size);
|
||||
if (MemoryProfileContextSummaryData != NULL) {
|
||||
DumpContextSummaryData (MemoryProfileContextSummaryData, FALSE);
|
||||
DestroyContextSummaryData (MemoryProfileContextSummaryData);
|
||||
@ -1134,7 +1167,7 @@ GetSmramProfileData (
|
||||
|
||||
ProfileBuffer = NULL;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &SmmCommunication);
|
||||
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&SmmCommunication);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "SmramProfile: Locate SmmCommunication protocol - %r\n", Status));
|
||||
return Status;
|
||||
@ -1142,49 +1175,66 @@ GetSmramProfileData (
|
||||
|
||||
MinimalSizeNeeded = sizeof (EFI_GUID) +
|
||||
sizeof (UINTN) +
|
||||
MAX (sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO),
|
||||
MAX (sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET),
|
||||
sizeof (SMRAM_PROFILE_PARAMETER_RECORDING_STATE)));
|
||||
MinimalSizeNeeded += MAX (sizeof (MEMORY_PROFILE_CONTEXT),
|
||||
MAX (sizeof (MEMORY_PROFILE_DRIVER_INFO),
|
||||
MAX (sizeof (MEMORY_PROFILE_ALLOC_INFO),
|
||||
MAX (sizeof (MEMORY_PROFILE_DESCRIPTOR),
|
||||
MAX (sizeof (MEMORY_PROFILE_FREE_MEMORY),
|
||||
sizeof (MEMORY_PROFILE_MEMORY_RANGE))))));
|
||||
MAX (
|
||||
sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO),
|
||||
MAX (
|
||||
sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET),
|
||||
sizeof (SMRAM_PROFILE_PARAMETER_RECORDING_STATE)
|
||||
)
|
||||
);
|
||||
MinimalSizeNeeded += MAX (
|
||||
sizeof (MEMORY_PROFILE_CONTEXT),
|
||||
MAX (
|
||||
sizeof (MEMORY_PROFILE_DRIVER_INFO),
|
||||
MAX (
|
||||
sizeof (MEMORY_PROFILE_ALLOC_INFO),
|
||||
MAX (
|
||||
sizeof (MEMORY_PROFILE_DESCRIPTOR),
|
||||
MAX (
|
||||
sizeof (MEMORY_PROFILE_FREE_MEMORY),
|
||||
sizeof (MEMORY_PROFILE_MEMORY_RANGE)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gEdkiiPiSmmCommunicationRegionTableGuid,
|
||||
(VOID **) &PiSmmCommunicationRegionTable
|
||||
(VOID **)&PiSmmCommunicationRegionTable
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "SmramProfile: Get PiSmmCommunicationRegionTable - %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (PiSmmCommunicationRegionTable != NULL);
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *) (PiSmmCommunicationRegionTable + 1);
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
|
||||
Size = 0;
|
||||
for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
|
||||
if (Entry->Type == EfiConventionalMemory) {
|
||||
Size = EFI_PAGES_TO_SIZE ((UINTN) Entry->NumberOfPages);
|
||||
Size = EFI_PAGES_TO_SIZE ((UINTN)Entry->NumberOfPages);
|
||||
if (Size >= MinimalSizeNeeded) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||
}
|
||||
|
||||
ASSERT (Index < PiSmmCommunicationRegionTable->NumberOfEntries);
|
||||
CommBuffer = (UINT8 *) (UINTN) Entry->PhysicalStart;
|
||||
CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
|
||||
|
||||
//
|
||||
// Set recording state if needed.
|
||||
//
|
||||
RecordingState = MEMORY_PROFILE_RECORDING_DISABLE;
|
||||
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
|
||||
CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof (gEdkiiMemoryProfileGuid));
|
||||
CommHeader->MessageLength = sizeof (SMRAM_PROFILE_PARAMETER_RECORDING_STATE);
|
||||
|
||||
CommRecordingState = (SMRAM_PROFILE_PARAMETER_RECORDING_STATE *) &CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommRecordingState = (SMRAM_PROFILE_PARAMETER_RECORDING_STATE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommRecordingState->Header.Command = SMRAM_PROFILE_COMMAND_GET_RECORDING_STATE;
|
||||
CommRecordingState->Header.DataLength = sizeof (*CommRecordingState);
|
||||
CommRecordingState->Header.ReturnStatus = (UINT64)-1;
|
||||
@ -1201,13 +1251,14 @@ GetSmramProfileData (
|
||||
Print (L"SmramProfile: GetRecordingState - 0x%0x\n", CommRecordingState->Header.ReturnStatus);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
RecordingState = CommRecordingState->RecordingState;
|
||||
if (RecordingState == MEMORY_PROFILE_RECORDING_ENABLE) {
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
|
||||
CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof (gEdkiiMemoryProfileGuid));
|
||||
CommHeader->MessageLength = sizeof (SMRAM_PROFILE_PARAMETER_RECORDING_STATE);
|
||||
|
||||
CommRecordingState = (SMRAM_PROFILE_PARAMETER_RECORDING_STATE *) &CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommRecordingState = (SMRAM_PROFILE_PARAMETER_RECORDING_STATE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommRecordingState->Header.Command = SMRAM_PROFILE_COMMAND_SET_RECORDING_STATE;
|
||||
CommRecordingState->Header.DataLength = sizeof (*CommRecordingState);
|
||||
CommRecordingState->Header.ReturnStatus = (UINT64)-1;
|
||||
@ -1220,11 +1271,11 @@ GetSmramProfileData (
|
||||
//
|
||||
// Get Size
|
||||
//
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
|
||||
CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof (gEdkiiMemoryProfileGuid));
|
||||
CommHeader->MessageLength = sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO);
|
||||
|
||||
CommGetProfileInfo = (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO *) &CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommGetProfileInfo = (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommGetProfileInfo->Header.Command = SMRAM_PROFILE_COMMAND_GET_PROFILE_INFO;
|
||||
CommGetProfileInfo->Header.DataLength = sizeof (*CommGetProfileInfo);
|
||||
CommGetProfileInfo->Header.ReturnStatus = (UINT64)-1;
|
||||
@ -1240,7 +1291,7 @@ GetSmramProfileData (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
ProfileSize = (UINTN) CommGetProfileInfo->ProfileSize;
|
||||
ProfileSize = (UINTN)CommGetProfileInfo->ProfileSize;
|
||||
|
||||
//
|
||||
// Get Data
|
||||
@ -1252,28 +1303,29 @@ GetSmramProfileData (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];
|
||||
CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof(gEdkiiMemoryProfileGuid));
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
|
||||
CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof (gEdkiiMemoryProfileGuid));
|
||||
CommHeader->MessageLength = sizeof (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET);
|
||||
|
||||
CommGetProfileData = (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET *) &CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommGetProfileData = (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommGetProfileData->Header.Command = SMRAM_PROFILE_COMMAND_GET_PROFILE_DATA_BY_OFFSET;
|
||||
CommGetProfileData->Header.DataLength = sizeof (*CommGetProfileData);
|
||||
CommGetProfileData->Header.ReturnStatus = (UINT64)-1;
|
||||
|
||||
CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength;
|
||||
Buffer = (UINT8 *) CommHeader + CommSize;
|
||||
Buffer = (UINT8 *)CommHeader + CommSize;
|
||||
Size -= CommSize;
|
||||
|
||||
CommGetProfileData->ProfileBuffer = (PHYSICAL_ADDRESS) (UINTN) Buffer;
|
||||
CommGetProfileData->ProfileBuffer = (PHYSICAL_ADDRESS)(UINTN)Buffer;
|
||||
CommGetProfileData->ProfileOffset = 0;
|
||||
while (CommGetProfileData->ProfileOffset < ProfileSize) {
|
||||
Offset = (UINTN) CommGetProfileData->ProfileOffset;
|
||||
Offset = (UINTN)CommGetProfileData->ProfileOffset;
|
||||
if (Size <= (ProfileSize - CommGetProfileData->ProfileOffset)) {
|
||||
CommGetProfileData->ProfileSize = (UINT64) Size;
|
||||
CommGetProfileData->ProfileSize = (UINT64)Size;
|
||||
} else {
|
||||
CommGetProfileData->ProfileSize = (UINT64) (ProfileSize - CommGetProfileData->ProfileOffset);
|
||||
CommGetProfileData->ProfileSize = (UINT64)(ProfileSize - CommGetProfileData->ProfileOffset);
|
||||
}
|
||||
|
||||
Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
@ -1282,18 +1334,18 @@ GetSmramProfileData (
|
||||
Print (L"GetProfileData - 0x%x\n", CommGetProfileData->Header.ReturnStatus);
|
||||
goto Done;
|
||||
}
|
||||
CopyMem ((UINT8 *) ProfileBuffer + Offset, (VOID *) (UINTN) CommGetProfileData->ProfileBuffer, (UINTN) CommGetProfileData->ProfileSize);
|
||||
}
|
||||
|
||||
CopyMem ((UINT8 *)ProfileBuffer + Offset, (VOID *)(UINTN)CommGetProfileData->ProfileBuffer, (UINTN)CommGetProfileData->ProfileSize);
|
||||
}
|
||||
|
||||
Print (L"SmramProfileSize - 0x%x\n", ProfileSize);
|
||||
Print (L"======= SmramProfile begin =======\n");
|
||||
DumpMemoryProfile ((PHYSICAL_ADDRESS) (UINTN) ProfileBuffer, ProfileSize, TRUE);
|
||||
DumpMemoryProfile ((PHYSICAL_ADDRESS)(UINTN)ProfileBuffer, ProfileSize, TRUE);
|
||||
|
||||
//
|
||||
// Dump summary information
|
||||
//
|
||||
MemoryProfileContextSummaryData = CreateContextSummaryData ((PHYSICAL_ADDRESS) (UINTN) ProfileBuffer, ProfileSize);
|
||||
MemoryProfileContextSummaryData = CreateContextSummaryData ((PHYSICAL_ADDRESS)(UINTN)ProfileBuffer, ProfileSize);
|
||||
if (MemoryProfileContextSummaryData != NULL) {
|
||||
DumpContextSummaryData (MemoryProfileContextSummaryData, TRUE);
|
||||
DestroyContextSummaryData (MemoryProfileContextSummaryData);
|
||||
@ -1310,11 +1362,11 @@ Done:
|
||||
// Restore recording state if needed.
|
||||
//
|
||||
if (RecordingState == MEMORY_PROFILE_RECORDING_ENABLE) {
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *) &CommBuffer[0];
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
|
||||
CopyMem (&CommHeader->HeaderGuid, &gEdkiiMemoryProfileGuid, sizeof (gEdkiiMemoryProfileGuid));
|
||||
CommHeader->MessageLength = sizeof (SMRAM_PROFILE_PARAMETER_RECORDING_STATE);
|
||||
|
||||
CommRecordingState = (SMRAM_PROFILE_PARAMETER_RECORDING_STATE *) &CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommRecordingState = (SMRAM_PROFILE_PARAMETER_RECORDING_STATE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommRecordingState->Header.Command = SMRAM_PROFILE_COMMAND_SET_RECORDING_STATE;
|
||||
CommRecordingState->Header.DataLength = sizeof (*CommRecordingState);
|
||||
CommRecordingState->Header.ReturnStatus = (UINT64)-1;
|
||||
|
@ -41,6 +41,7 @@ InternalDumpData (
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < Size; Index++) {
|
||||
Print (L"%02x", (UINTN)Data[Index]);
|
||||
if ((Index + 1) != Size) {
|
||||
@ -53,7 +54,7 @@ InternalDumpData (
|
||||
Get SMI handler profile database.
|
||||
**/
|
||||
VOID
|
||||
GetSmiHandlerProfileDatabase(
|
||||
GetSmiHandlerProfileDatabase (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
@ -72,60 +73,63 @@ GetSmiHandlerProfileDatabase(
|
||||
UINTN Size;
|
||||
UINTN Offset;
|
||||
|
||||
Status = gBS->LocateProtocol(&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&SmmCommunication);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"SmiHandlerProfile: Locate SmmCommunication protocol - %r\n", Status);
|
||||
return ;
|
||||
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&SmmCommunication);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"SmiHandlerProfile: Locate SmmCommunication protocol - %r\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
MinimalSizeNeeded = EFI_PAGE_SIZE;
|
||||
|
||||
Status = EfiGetSystemConfigurationTable(
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gEdkiiPiSmmCommunicationRegionTableGuid,
|
||||
(VOID **)&PiSmmCommunicationRegionTable
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"SmiHandlerProfile: Get PiSmmCommunicationRegionTable - %r\n", Status);
|
||||
return ;
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"SmiHandlerProfile: Get PiSmmCommunicationRegionTable - %r\n", Status);
|
||||
return;
|
||||
}
|
||||
ASSERT(PiSmmCommunicationRegionTable != NULL);
|
||||
|
||||
ASSERT (PiSmmCommunicationRegionTable != NULL);
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
|
||||
Size = 0;
|
||||
for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
|
||||
if (Entry->Type == EfiConventionalMemory) {
|
||||
Size = EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages);
|
||||
Size = EFI_PAGES_TO_SIZE ((UINTN)Entry->NumberOfPages);
|
||||
if (Size >= MinimalSizeNeeded) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||
}
|
||||
ASSERT(Index < PiSmmCommunicationRegionTable->NumberOfEntries);
|
||||
|
||||
ASSERT (Index < PiSmmCommunicationRegionTable->NumberOfEntries);
|
||||
CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
|
||||
|
||||
//
|
||||
// Get Size
|
||||
//
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
|
||||
CopyMem(&CommHeader->HeaderGuid, &gSmiHandlerProfileGuid, sizeof(gSmiHandlerProfileGuid));
|
||||
CommHeader->MessageLength = sizeof(SMI_HANDLER_PROFILE_PARAMETER_GET_INFO);
|
||||
CopyMem (&CommHeader->HeaderGuid, &gSmiHandlerProfileGuid, sizeof (gSmiHandlerProfileGuid));
|
||||
CommHeader->MessageLength = sizeof (SMI_HANDLER_PROFILE_PARAMETER_GET_INFO);
|
||||
|
||||
CommGetInfo = (SMI_HANDLER_PROFILE_PARAMETER_GET_INFO *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommGetInfo = (SMI_HANDLER_PROFILE_PARAMETER_GET_INFO *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommGetInfo->Header.Command = SMI_HANDLER_PROFILE_COMMAND_GET_INFO;
|
||||
CommGetInfo->Header.DataLength = sizeof(*CommGetInfo);
|
||||
CommGetInfo->Header.DataLength = sizeof (*CommGetInfo);
|
||||
CommGetInfo->Header.ReturnStatus = (UINT64)-1;
|
||||
CommGetInfo->DataSize = 0;
|
||||
|
||||
CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
|
||||
Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
|
||||
if (EFI_ERROR(Status)) {
|
||||
Print(L"SmiHandlerProfile: SmmCommunication - %r\n", Status);
|
||||
return ;
|
||||
CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength;
|
||||
Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L"SmiHandlerProfile: SmmCommunication - %r\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CommGetInfo->Header.ReturnStatus != 0) {
|
||||
Print(L"SmiHandlerProfile: GetInfo - 0x%0x\n", CommGetInfo->Header.ReturnStatus);
|
||||
return ;
|
||||
Print (L"SmiHandlerProfile: GetInfo - 0x%0x\n", CommGetInfo->Header.ReturnStatus);
|
||||
return;
|
||||
}
|
||||
|
||||
mSmiHandlerProfileDatabaseSize = (UINTN)CommGetInfo->DataSize;
|
||||
@ -133,23 +137,23 @@ GetSmiHandlerProfileDatabase(
|
||||
//
|
||||
// Get Data
|
||||
//
|
||||
mSmiHandlerProfileDatabase = AllocateZeroPool(mSmiHandlerProfileDatabaseSize);
|
||||
mSmiHandlerProfileDatabase = AllocateZeroPool (mSmiHandlerProfileDatabaseSize);
|
||||
if (mSmiHandlerProfileDatabase == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
Print(L"SmiHandlerProfile: AllocateZeroPool (0x%x) for dump buffer - %r\n", mSmiHandlerProfileDatabaseSize, Status);
|
||||
return ;
|
||||
Print (L"SmiHandlerProfile: AllocateZeroPool (0x%x) for dump buffer - %r\n", mSmiHandlerProfileDatabaseSize, Status);
|
||||
return;
|
||||
}
|
||||
|
||||
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
|
||||
CopyMem(&CommHeader->HeaderGuid, &gSmiHandlerProfileGuid, sizeof(gSmiHandlerProfileGuid));
|
||||
CommHeader->MessageLength = sizeof(SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET);
|
||||
CopyMem (&CommHeader->HeaderGuid, &gSmiHandlerProfileGuid, sizeof (gSmiHandlerProfileGuid));
|
||||
CommHeader->MessageLength = sizeof (SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET);
|
||||
|
||||
CommGetData = (SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommGetData = (SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
|
||||
CommGetData->Header.Command = SMI_HANDLER_PROFILE_COMMAND_GET_DATA_BY_OFFSET;
|
||||
CommGetData->Header.DataLength = sizeof(*CommGetData);
|
||||
CommGetData->Header.DataLength = sizeof (*CommGetData);
|
||||
CommGetData->Header.ReturnStatus = (UINT64)-1;
|
||||
|
||||
CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader->MessageLength;
|
||||
CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader->MessageLength;
|
||||
Buffer = (UINT8 *)CommHeader + CommSize;
|
||||
Size -= CommSize;
|
||||
|
||||
@ -162,21 +166,23 @@ GetSmiHandlerProfileDatabase(
|
||||
} else {
|
||||
CommGetData->DataSize = (UINT64)(mSmiHandlerProfileDatabaseSize - CommGetData->DataOffset);
|
||||
}
|
||||
Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
|
||||
Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
if (CommGetData->Header.ReturnStatus != 0) {
|
||||
FreePool(mSmiHandlerProfileDatabase);
|
||||
FreePool (mSmiHandlerProfileDatabase);
|
||||
mSmiHandlerProfileDatabase = NULL;
|
||||
Print(L"SmiHandlerProfile: GetData - 0x%x\n", CommGetData->Header.ReturnStatus);
|
||||
return ;
|
||||
Print (L"SmiHandlerProfile: GetData - 0x%x\n", CommGetData->Header.ReturnStatus);
|
||||
return;
|
||||
}
|
||||
CopyMem((UINT8 *)mSmiHandlerProfileDatabase + Offset, (VOID *)(UINTN)CommGetData->DataBuffer, (UINTN)CommGetData->DataSize);
|
||||
|
||||
CopyMem ((UINT8 *)mSmiHandlerProfileDatabase + Offset, (VOID *)(UINTN)CommGetData->DataBuffer, (UINTN)CommGetData->DataSize);
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "SmiHandlerProfileSize - 0x%x\n", mSmiHandlerProfileDatabaseSize));
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,7 +214,9 @@ GetShortPdbFileName (
|
||||
AsciiStrnCpyS (AsciiBuffer, PROFILE_NAME_STRING_LENGTH + 1, " ", 1);
|
||||
} else {
|
||||
StartIndex = 0;
|
||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++);
|
||||
for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) {
|
||||
}
|
||||
|
||||
for (IndexPdb = 0; PdbFileName[IndexPdb] != 0; IndexPdb++) {
|
||||
if ((PdbFileName[IndexPdb] == '\\') || (PdbFileName[IndexPdb] == '/')) {
|
||||
StartIndex = IndexPdb + 1;
|
||||
@ -260,7 +268,7 @@ GetDriverNameString (
|
||||
// Method 1: Get the name string from image PDB
|
||||
//
|
||||
if (ImageStruct->PdbStringOffset != 0) {
|
||||
GetShortPdbFileName ((CHAR8 *) ((UINTN) ImageStruct + ImageStruct->PdbStringOffset), mNameString);
|
||||
GetShortPdbFileName ((CHAR8 *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset), mNameString);
|
||||
return mNameString;
|
||||
}
|
||||
|
||||
@ -274,7 +282,7 @@ GetDriverNameString (
|
||||
&ImageStruct->FileGuid,
|
||||
EFI_SECTION_USER_INTERFACE,
|
||||
0,
|
||||
(VOID **) &NameString,
|
||||
(VOID **)&NameString,
|
||||
&StringSize
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@ -284,6 +292,7 @@ GetDriverNameString (
|
||||
if (StrLen (NameString) > PROFILE_NAME_STRING_LENGTH) {
|
||||
NameString[PROFILE_NAME_STRING_LENGTH] = 0;
|
||||
}
|
||||
|
||||
UnicodeStrToAsciiStrS (NameString, mNameString, sizeof (mNameString));
|
||||
FreePool (NameString);
|
||||
return mNameString;
|
||||
@ -318,6 +327,7 @@ GetImageFromRef (
|
||||
return ImageStruct;
|
||||
}
|
||||
}
|
||||
|
||||
ImageStruct = (VOID *)((UINTN)ImageStruct + ImageStruct->Header.Length);
|
||||
}
|
||||
|
||||
@ -328,7 +338,7 @@ GetImageFromRef (
|
||||
Dump SMM loaded image information.
|
||||
**/
|
||||
VOID
|
||||
DumpSmmLoadedImage(
|
||||
DumpSmmLoadedImage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
@ -340,19 +350,21 @@ DumpSmmLoadedImage(
|
||||
while ((UINTN)ImageStruct < (UINTN)mSmiHandlerProfileDatabase + mSmiHandlerProfileDatabaseSize) {
|
||||
if (ImageStruct->Header.Signature == SMM_CORE_IMAGE_DATABASE_SIGNATURE) {
|
||||
NameString = GetDriverNameString (ImageStruct);
|
||||
Print(L" <Image Name=\"%a\"", NameString);
|
||||
Print(L" Base=\"0x%lx\" Size=\"0x%lx\"", ImageStruct->ImageBase, ImageStruct->ImageSize);
|
||||
Print (L" <Image Name=\"%a\"", NameString);
|
||||
Print (L" Base=\"0x%lx\" Size=\"0x%lx\"", ImageStruct->ImageBase, ImageStruct->ImageSize);
|
||||
if (ImageStruct->EntryPoint != 0) {
|
||||
Print(L" EntryPoint=\"0x%lx\"", ImageStruct->EntryPoint);
|
||||
Print (L" EntryPoint=\"0x%lx\"", ImageStruct->EntryPoint);
|
||||
}
|
||||
Print(L" FvFile=\"%g\"", &ImageStruct->FileGuid);
|
||||
Print(L" RefId=\"0x%x\"", ImageStruct->ImageRef);
|
||||
Print(L">\n");
|
||||
|
||||
Print (L" FvFile=\"%g\"", &ImageStruct->FileGuid);
|
||||
Print (L" RefId=\"0x%x\"", ImageStruct->ImageRef);
|
||||
Print (L">\n");
|
||||
if (ImageStruct->PdbStringOffset != 0) {
|
||||
PdbString = (CHAR8 *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset);
|
||||
Print(L" <Pdb>%a</Pdb>\n", PdbString);
|
||||
Print (L" <Pdb>%a</Pdb>\n", PdbString);
|
||||
}
|
||||
Print(L" </Image>\n");
|
||||
|
||||
Print (L" </Image>\n");
|
||||
}
|
||||
|
||||
ImageStruct = (VOID *)((UINTN)ImageStruct + ImageStruct->Header.Length);
|
||||
@ -382,10 +394,10 @@ SxTypeToString (
|
||||
IN EFI_SLEEP_TYPE Type
|
||||
)
|
||||
{
|
||||
if (Type >= 0 && Type < ARRAY_SIZE(mSxTypeString)) {
|
||||
if ((Type >= 0) && (Type < ARRAY_SIZE (mSxTypeString))) {
|
||||
return mSxTypeString[Type];
|
||||
} else {
|
||||
AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
|
||||
AsciiSPrint (mNameString, sizeof (mNameString), "0x%x", Type);
|
||||
return mNameString;
|
||||
}
|
||||
}
|
||||
@ -407,10 +419,10 @@ SxPhaseToString (
|
||||
IN EFI_SLEEP_PHASE Phase
|
||||
)
|
||||
{
|
||||
if (Phase >= 0 && Phase < ARRAY_SIZE(mSxPhaseString)) {
|
||||
if ((Phase >= 0) && (Phase < ARRAY_SIZE (mSxPhaseString))) {
|
||||
return mSxPhaseString[Phase];
|
||||
} else {
|
||||
AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
|
||||
AsciiSPrint (mNameString, sizeof (mNameString), "0x%x", Phase);
|
||||
return mNameString;
|
||||
}
|
||||
}
|
||||
@ -432,10 +444,10 @@ PowerButtonPhaseToString (
|
||||
IN EFI_POWER_BUTTON_PHASE Phase
|
||||
)
|
||||
{
|
||||
if (Phase >= 0 && Phase < ARRAY_SIZE(mPowerButtonPhaseString)) {
|
||||
if ((Phase >= 0) && (Phase < ARRAY_SIZE (mPowerButtonPhaseString))) {
|
||||
return mPowerButtonPhaseString[Phase];
|
||||
} else {
|
||||
AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
|
||||
AsciiSPrint (mNameString, sizeof (mNameString), "0x%x", Phase);
|
||||
return mNameString;
|
||||
}
|
||||
}
|
||||
@ -457,10 +469,10 @@ StandbyButtonPhaseToString (
|
||||
IN EFI_STANDBY_BUTTON_PHASE Phase
|
||||
)
|
||||
{
|
||||
if (Phase >= 0 && Phase < ARRAY_SIZE(mStandbyButtonPhaseString)) {
|
||||
if ((Phase >= 0) && (Phase < ARRAY_SIZE (mStandbyButtonPhaseString))) {
|
||||
return mStandbyButtonPhaseString[Phase];
|
||||
} else {
|
||||
AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
|
||||
AsciiSPrint (mNameString, sizeof (mNameString), "0x%x", Phase);
|
||||
return mNameString;
|
||||
}
|
||||
}
|
||||
@ -483,10 +495,10 @@ IoTrapTypeToString (
|
||||
IN EFI_SMM_IO_TRAP_DISPATCH_TYPE Type
|
||||
)
|
||||
{
|
||||
if (Type >= 0 && Type < ARRAY_SIZE(mIoTrapTypeString)) {
|
||||
if ((Type >= 0) && (Type < ARRAY_SIZE (mIoTrapTypeString))) {
|
||||
return mIoTrapTypeString[Type];
|
||||
} else {
|
||||
AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
|
||||
AsciiSPrint (mNameString, sizeof (mNameString), "0x%x", Type);
|
||||
return mNameString;
|
||||
}
|
||||
}
|
||||
@ -508,10 +520,10 @@ UsbTypeToString (
|
||||
IN EFI_USB_SMI_TYPE Type
|
||||
)
|
||||
{
|
||||
if (Type >= 0 && Type < ARRAY_SIZE(mUsbTypeString)) {
|
||||
if ((Type >= 0) && (Type < ARRAY_SIZE (mUsbTypeString))) {
|
||||
return mUsbTypeString[Type];
|
||||
} else {
|
||||
AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
|
||||
AsciiSPrint (mNameString, sizeof (mNameString), "0x%x", Type);
|
||||
return mNameString;
|
||||
}
|
||||
}
|
||||
@ -533,34 +545,34 @@ DumpSmiChildContext (
|
||||
CHAR16 *Str;
|
||||
|
||||
if (CompareGuid (HandlerType, &gEfiSmmSwDispatch2ProtocolGuid)) {
|
||||
Print(L" SwSmi=\"0x%lx\"", ((SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT *)Context)->SwSmiInputValue);
|
||||
Print (L" SwSmi=\"0x%lx\"", ((SMI_HANDLER_PROFILE_SW_REGISTER_CONTEXT *)Context)->SwSmiInputValue);
|
||||
} else if (CompareGuid (HandlerType, &gEfiSmmSxDispatch2ProtocolGuid)) {
|
||||
Print(L" SxType=\"%a\"", SxTypeToString(((EFI_SMM_SX_REGISTER_CONTEXT *)Context)->Type));
|
||||
Print(L" SxPhase=\"%a\"", SxPhaseToString(((EFI_SMM_SX_REGISTER_CONTEXT *)Context)->Phase));
|
||||
Print (L" SxType=\"%a\"", SxTypeToString (((EFI_SMM_SX_REGISTER_CONTEXT *)Context)->Type));
|
||||
Print (L" SxPhase=\"%a\"", SxPhaseToString (((EFI_SMM_SX_REGISTER_CONTEXT *)Context)->Phase));
|
||||
} else if (CompareGuid (HandlerType, &gEfiSmmPowerButtonDispatch2ProtocolGuid)) {
|
||||
Print(L" PowerButtonPhase=\"%a\"", PowerButtonPhaseToString(((EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *)Context)->Phase));
|
||||
Print (L" PowerButtonPhase=\"%a\"", PowerButtonPhaseToString (((EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT *)Context)->Phase));
|
||||
} else if (CompareGuid (HandlerType, &gEfiSmmStandbyButtonDispatch2ProtocolGuid)) {
|
||||
Print(L" StandbyButtonPhase=\"%a\"", StandbyButtonPhaseToString(((EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *)Context)->Phase));
|
||||
Print (L" StandbyButtonPhase=\"%a\"", StandbyButtonPhaseToString (((EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT *)Context)->Phase));
|
||||
} else if (CompareGuid (HandlerType, &gEfiSmmPeriodicTimerDispatch2ProtocolGuid)) {
|
||||
Print(L" PeriodicTimerPeriod=\"%ld\"", ((EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT *)Context)->Period);
|
||||
Print(L" PeriodicTimerSmiTickInterval=\"%ld\"", ((EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT *)Context)->SmiTickInterval);
|
||||
Print (L" PeriodicTimerPeriod=\"%ld\"", ((EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT *)Context)->Period);
|
||||
Print (L" PeriodicTimerSmiTickInterval=\"%ld\"", ((EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT *)Context)->SmiTickInterval);
|
||||
} else if (CompareGuid (HandlerType, &gEfiSmmGpiDispatch2ProtocolGuid)) {
|
||||
Print(L" GpiNum=\"0x%lx\"", ((EFI_SMM_GPI_REGISTER_CONTEXT *)Context)->GpiNum);
|
||||
Print (L" GpiNum=\"0x%lx\"", ((EFI_SMM_GPI_REGISTER_CONTEXT *)Context)->GpiNum);
|
||||
} else if (CompareGuid (HandlerType, &gEfiSmmIoTrapDispatch2ProtocolGuid)) {
|
||||
Print(L" IoTrapAddress=\"0x%x\"", ((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Address);
|
||||
Print(L" IoTrapLength=\"0x%x\"", ((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Length);
|
||||
Print(L" IoTrapType=\"%a\"", IoTrapTypeToString(((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Type));
|
||||
Print (L" IoTrapAddress=\"0x%x\"", ((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Address);
|
||||
Print (L" IoTrapLength=\"0x%x\"", ((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Length);
|
||||
Print (L" IoTrapType=\"%a\"", IoTrapTypeToString (((EFI_SMM_IO_TRAP_REGISTER_CONTEXT *)Context)->Type));
|
||||
} else if (CompareGuid (HandlerType, &gEfiSmmUsbDispatch2ProtocolGuid)) {
|
||||
Print(L" UsbType=\"0x%x\"", UsbTypeToString(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context)->Type));
|
||||
Str = ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE, TRUE);
|
||||
Print(L" UsbDevicePath=\"%s\"", Str);
|
||||
Print (L" UsbType=\"0x%x\"", UsbTypeToString (((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context)->Type));
|
||||
Str = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *)(((SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT *)Context) + 1), TRUE, TRUE);
|
||||
Print (L" UsbDevicePath=\"%s\"", Str);
|
||||
if (Str != NULL) {
|
||||
FreePool (Str);
|
||||
}
|
||||
} else {
|
||||
Print(L" Context=\"");
|
||||
Print (L" Context=\"");
|
||||
InternalDumpData (Context, ContextSize);
|
||||
Print(L"\"");
|
||||
Print (L"\"");
|
||||
}
|
||||
}
|
||||
|
||||
@ -570,7 +582,7 @@ DumpSmiChildContext (
|
||||
@param HandlerCategory SMI handler category
|
||||
**/
|
||||
VOID
|
||||
DumpSmiHandler(
|
||||
DumpSmiHandler (
|
||||
IN UINT32 HandlerCategory
|
||||
)
|
||||
{
|
||||
@ -584,39 +596,46 @@ DumpSmiHandler(
|
||||
while ((UINTN)SmiStruct < (UINTN)mSmiHandlerProfileDatabase + mSmiHandlerProfileDatabaseSize) {
|
||||
if ((SmiStruct->Header.Signature == SMM_CORE_SMI_DATABASE_SIGNATURE) && (SmiStruct->HandlerCategory == HandlerCategory)) {
|
||||
SmiHandlerStruct = (VOID *)(SmiStruct + 1);
|
||||
Print(L" <SmiEntry");
|
||||
Print (L" <SmiEntry");
|
||||
if (!IsZeroGuid (&SmiStruct->HandlerType)) {
|
||||
Print(L" HandlerType=\"%g\"", &SmiStruct->HandlerType);
|
||||
Print (L" HandlerType=\"%g\"", &SmiStruct->HandlerType);
|
||||
}
|
||||
Print(L">\n");
|
||||
|
||||
Print (L">\n");
|
||||
for (Index = 0; Index < SmiStruct->HandlerCount; Index++) {
|
||||
Print(L" <SmiHandler");
|
||||
Print (L" <SmiHandler");
|
||||
if (SmiHandlerStruct->ContextBufferSize != 0) {
|
||||
DumpSmiChildContext (&SmiStruct->HandlerType, (UINT8 *)SmiHandlerStruct + SmiHandlerStruct->ContextBufferOffset, SmiHandlerStruct->ContextBufferSize);
|
||||
}
|
||||
Print(L">\n");
|
||||
ImageStruct = GetImageFromRef((UINTN)SmiHandlerStruct->ImageRef);
|
||||
|
||||
Print (L">\n");
|
||||
ImageStruct = GetImageFromRef ((UINTN)SmiHandlerStruct->ImageRef);
|
||||
NameString = GetDriverNameString (ImageStruct);
|
||||
Print(L" <Module RefId=\"0x%x\" Name=\"%a\">\n", SmiHandlerStruct->ImageRef, NameString);
|
||||
Print (L" <Module RefId=\"0x%x\" Name=\"%a\">\n", SmiHandlerStruct->ImageRef, NameString);
|
||||
if ((ImageStruct != NULL) && (ImageStruct->PdbStringOffset != 0)) {
|
||||
Print(L" <Pdb>%a</Pdb>\n", (UINT8 *)ImageStruct + ImageStruct->PdbStringOffset);
|
||||
Print (L" <Pdb>%a</Pdb>\n", (UINT8 *)ImageStruct + ImageStruct->PdbStringOffset);
|
||||
}
|
||||
Print(L" </Module>\n");
|
||||
Print(L" <Handler Address=\"0x%lx\">\n", SmiHandlerStruct->Handler);
|
||||
|
||||
Print (L" </Module>\n");
|
||||
Print (L" <Handler Address=\"0x%lx\">\n", SmiHandlerStruct->Handler);
|
||||
if (ImageStruct != NULL) {
|
||||
Print(L" <RVA>0x%x</RVA>\n", (UINTN) (SmiHandlerStruct->Handler - ImageStruct->ImageBase));
|
||||
Print (L" <RVA>0x%x</RVA>\n", (UINTN)(SmiHandlerStruct->Handler - ImageStruct->ImageBase));
|
||||
}
|
||||
Print(L" </Handler>\n", SmiHandlerStruct->Handler);
|
||||
Print(L" <Caller Address=\"0x%lx\">\n", SmiHandlerStruct->CallerAddr);
|
||||
|
||||
Print (L" </Handler>\n", SmiHandlerStruct->Handler);
|
||||
Print (L" <Caller Address=\"0x%lx\">\n", SmiHandlerStruct->CallerAddr);
|
||||
if (ImageStruct != NULL) {
|
||||
Print(L" <RVA>0x%x</RVA>\n", (UINTN) (SmiHandlerStruct->CallerAddr - ImageStruct->ImageBase));
|
||||
Print (L" <RVA>0x%x</RVA>\n", (UINTN)(SmiHandlerStruct->CallerAddr - ImageStruct->ImageBase));
|
||||
}
|
||||
Print(L" </Caller>\n", SmiHandlerStruct->Handler);
|
||||
|
||||
Print (L" </Caller>\n", SmiHandlerStruct->Handler);
|
||||
SmiHandlerStruct = (VOID *)((UINTN)SmiHandlerStruct + SmiHandlerStruct->Length);
|
||||
Print(L" </SmiHandler>\n");
|
||||
Print (L" </SmiHandler>\n");
|
||||
}
|
||||
Print(L" </SmiEntry>\n");
|
||||
|
||||
Print (L" </SmiEntry>\n");
|
||||
}
|
||||
|
||||
SmiStruct = (VOID *)((UINTN)SmiStruct + SmiStruct->Header.Length);
|
||||
}
|
||||
|
||||
@ -639,7 +658,7 @@ SmiHandlerProfileInfoEntrypoint (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
GetSmiHandlerProfileDatabase();
|
||||
GetSmiHandlerProfileDatabase ();
|
||||
|
||||
if (mSmiHandlerProfileDatabase == NULL) {
|
||||
return EFI_SUCCESS;
|
||||
@ -648,38 +667,38 @@ SmiHandlerProfileInfoEntrypoint (
|
||||
//
|
||||
// Dump all image
|
||||
//
|
||||
Print(L"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
||||
Print(L"<SmiHandlerProfile>\n");
|
||||
Print(L"<ImageDatabase>\n");
|
||||
Print(L" <!-- SMM image loaded -->\n");
|
||||
DumpSmmLoadedImage();
|
||||
Print(L"</ImageDatabase>\n\n");
|
||||
Print (L"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
||||
Print (L"<SmiHandlerProfile>\n");
|
||||
Print (L"<ImageDatabase>\n");
|
||||
Print (L" <!-- SMM image loaded -->\n");
|
||||
DumpSmmLoadedImage ();
|
||||
Print (L"</ImageDatabase>\n\n");
|
||||
|
||||
//
|
||||
// Dump SMI Handler
|
||||
//
|
||||
Print(L"<SmiHandlerDatabase>\n");
|
||||
Print(L" <!-- SMI Handler registered -->\n\n");
|
||||
Print(L" <SmiHandlerCategory Name=\"RootSmi\">\n");
|
||||
Print(L" <!-- The root SMI Handler registered by SmmCore -->\n");
|
||||
DumpSmiHandler(SmmCoreSmiHandlerCategoryRootHandler);
|
||||
Print(L" </SmiHandlerCategory>\n\n");
|
||||
Print (L"<SmiHandlerDatabase>\n");
|
||||
Print (L" <!-- SMI Handler registered -->\n\n");
|
||||
Print (L" <SmiHandlerCategory Name=\"RootSmi\">\n");
|
||||
Print (L" <!-- The root SMI Handler registered by SmmCore -->\n");
|
||||
DumpSmiHandler (SmmCoreSmiHandlerCategoryRootHandler);
|
||||
Print (L" </SmiHandlerCategory>\n\n");
|
||||
|
||||
Print(L" <SmiHandlerCategory Name=\"GuidSmi\">\n");
|
||||
Print(L" <!-- The GUID SMI Handler registered by SmmCore -->\n");
|
||||
DumpSmiHandler(SmmCoreSmiHandlerCategoryGuidHandler);
|
||||
Print(L" </SmiHandlerCategory>\n\n");
|
||||
Print (L" <SmiHandlerCategory Name=\"GuidSmi\">\n");
|
||||
Print (L" <!-- The GUID SMI Handler registered by SmmCore -->\n");
|
||||
DumpSmiHandler (SmmCoreSmiHandlerCategoryGuidHandler);
|
||||
Print (L" </SmiHandlerCategory>\n\n");
|
||||
|
||||
Print(L" <SmiHandlerCategory Name=\"HardwareSmi\">\n");
|
||||
Print(L" <!-- The hardware SMI Handler registered by SmmChildDispatcher -->\n");
|
||||
DumpSmiHandler(SmmCoreSmiHandlerCategoryHardwareHandler);
|
||||
Print(L" </SmiHandlerCategory>\n\n");
|
||||
Print (L" <SmiHandlerCategory Name=\"HardwareSmi\">\n");
|
||||
Print (L" <!-- The hardware SMI Handler registered by SmmChildDispatcher -->\n");
|
||||
DumpSmiHandler (SmmCoreSmiHandlerCategoryHardwareHandler);
|
||||
Print (L" </SmiHandlerCategory>\n\n");
|
||||
|
||||
Print(L"</SmiHandlerDatabase>\n");
|
||||
Print(L"</SmiHandlerProfile>\n");
|
||||
Print (L"</SmiHandlerDatabase>\n");
|
||||
Print (L"</SmiHandlerProfile>\n");
|
||||
|
||||
if (mSmiHandlerProfileDatabase != NULL) {
|
||||
FreePool(mSmiHandlerProfileDatabase);
|
||||
FreePool (mSmiHandlerProfileDatabase);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -52,21 +52,22 @@ HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = {
|
||||
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)
|
||||
}
|
||||
},
|
||||
//
|
||||
// {8E6D99EE-7531-48f8-8745-7F6144468FF2}
|
||||
//
|
||||
{ 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 } }
|
||||
{ 0x8e6d99ee, 0x7531, 0x48f8, { 0x87, 0x45, 0x7f, 0x61, 0x44, 0x46, 0x8f, 0xf2 }
|
||||
}
|
||||
},
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -111,9 +112,10 @@ FakeExtractConfig (
|
||||
OUT EFI_STRING *Results
|
||||
)
|
||||
{
|
||||
if (Progress == NULL || Results == NULL) {
|
||||
if ((Progress == NULL) || (Results == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Progress = Request;
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -142,7 +144,7 @@ FakeRouteConfig (
|
||||
OUT EFI_STRING *Progress
|
||||
)
|
||||
{
|
||||
if (Configuration == NULL || Progress == NULL) {
|
||||
if ((Configuration == NULL) || (Progress == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -209,18 +211,18 @@ UpdateFrontPageForm (
|
||||
//
|
||||
// Create Hii Extend Label OpCode as the start opcode
|
||||
//
|
||||
StartGuidLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
|
||||
StartGuidLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
|
||||
StartGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
||||
StartGuidLabel->Number = LABEL_FRANTPAGE_INFORMATION;
|
||||
//
|
||||
// Create Hii Extend Label OpCode as the end opcode
|
||||
//
|
||||
EndGuidLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
|
||||
EndGuidLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
|
||||
EndGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
||||
EndGuidLabel->Number = LABEL_END;
|
||||
|
||||
//
|
||||
//Updata Front Page form
|
||||
// Updata Front Page form
|
||||
//
|
||||
UiCustomizeFrontPage (
|
||||
gFrontPagePrivate.HiiHandle,
|
||||
@ -253,10 +255,11 @@ InitializeFrontPage (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Locate Hii relative protocols
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &gFormBrowser2);
|
||||
Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&gFormBrowser2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -288,14 +291,14 @@ InitializeFrontPage (
|
||||
ASSERT (gFrontPagePrivate.HiiHandle != NULL);
|
||||
|
||||
//
|
||||
//Updata Front Page banner strings
|
||||
// Updata Front Page banner strings
|
||||
//
|
||||
UpdateFrontPageBannerStrings ();
|
||||
|
||||
//
|
||||
// Update front page menus.
|
||||
//
|
||||
UpdateFrontPageForm();
|
||||
UpdateFrontPageForm ();
|
||||
|
||||
return Status;
|
||||
}
|
||||
@ -348,11 +351,12 @@ CallFrontPage (
|
||||
|
||||
**/
|
||||
VOID
|
||||
FreeFrontPage(
|
||||
FreeFrontPage (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
gFrontPagePrivate.DriverHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
@ -395,12 +399,13 @@ ConvertProcessorToString (
|
||||
|
||||
if (Base10Exponent >= 6) {
|
||||
FreqMhz = ProcessorFrequency;
|
||||
for (Index = 0; Index < (UINT32) Base10Exponent - 6; Index++) {
|
||||
for (Index = 0; Index < (UINT32)Base10Exponent - 6; Index++) {
|
||||
FreqMhz *= 10;
|
||||
}
|
||||
} else {
|
||||
FreqMhz = 0;
|
||||
}
|
||||
|
||||
DestMax = 0x20 / sizeof (CHAR16);
|
||||
StringBuffer = AllocateZeroPool (0x20);
|
||||
ASSERT (StringBuffer != NULL);
|
||||
@ -415,11 +420,10 @@ ConvertProcessorToString (
|
||||
2
|
||||
);
|
||||
StrCatS (StringBuffer, DestMax, L" GHz");
|
||||
*String = (CHAR16 *) StringBuffer;
|
||||
return ;
|
||||
*String = (CHAR16 *)StringBuffer;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert Memory Size to a string.
|
||||
|
||||
@ -440,9 +444,9 @@ ConvertMemorySizeToString (
|
||||
UnicodeValueToStringS (StringBuffer, 0x24, LEFT_JUSTIFY, MemorySize, 10);
|
||||
StrCatS (StringBuffer, 0x24 / sizeof (CHAR16), L" MB RAM");
|
||||
|
||||
*String = (CHAR16 *) StringBuffer;
|
||||
*String = (CHAR16 *)StringBuffer;
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -492,7 +496,6 @@ GetOptionalStringByIndex (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Update the banner information for the Front Page based on Smbios information.
|
||||
@ -546,7 +549,7 @@ UpdateFrontPageBannerStrings (
|
||||
//
|
||||
// Update Front Page banner strings base on SmBios Table.
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **) &Smbios);
|
||||
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Smbios protocol not found, get the default value.
|
||||
@ -581,16 +584,16 @@ UpdateFrontPageBannerStrings (
|
||||
|
||||
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
|
||||
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
|
||||
while (!EFI_ERROR(Status)) {
|
||||
while (!EFI_ERROR (Status)) {
|
||||
if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {
|
||||
Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
|
||||
Type0Record = (SMBIOS_TABLE_TYPE0 *)Record;
|
||||
StrIndex = Type0Record->BiosVersion;
|
||||
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);
|
||||
GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);
|
||||
|
||||
FirmwareVersionString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);
|
||||
FirmwareVersionString = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);
|
||||
if (*FirmwareVersionString != 0x0000 ) {
|
||||
FreePool (NewString);
|
||||
NewString = (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString);
|
||||
NewString = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);
|
||||
UiCustomizeFrontPageBanner (3, TRUE, &NewString);
|
||||
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);
|
||||
} else {
|
||||
@ -601,27 +604,27 @@ UpdateFrontPageBannerStrings (
|
||||
}
|
||||
|
||||
if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {
|
||||
Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;
|
||||
Type1Record = (SMBIOS_TABLE_TYPE1 *)Record;
|
||||
StrIndex = Type1Record->ProductName;
|
||||
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);
|
||||
GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);
|
||||
UiCustomizeFrontPageBanner (1, TRUE, &NewString);
|
||||
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);
|
||||
FreePool (NewString);
|
||||
}
|
||||
|
||||
if ((Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {
|
||||
Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
|
||||
Type4Record = (SMBIOS_TABLE_TYPE4 *)Record;
|
||||
//
|
||||
// The information in the record should be only valid when the CPU Socket is populated.
|
||||
//
|
||||
if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) {
|
||||
StrIndex = Type4Record->ProcessorVersion;
|
||||
GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);
|
||||
GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);
|
||||
UiCustomizeFrontPageBanner (2, TRUE, &NewString);
|
||||
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);
|
||||
FreePool (NewString);
|
||||
|
||||
ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);
|
||||
ConvertProcessorToString (Type4Record->CurrentSpeed, 6, &NewString);
|
||||
UiCustomizeFrontPageBanner (2, FALSE, &NewString);
|
||||
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);
|
||||
FreePool (NewString);
|
||||
@ -631,13 +634,19 @@ UpdateFrontPageBannerStrings (
|
||||
}
|
||||
|
||||
if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
|
||||
Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;
|
||||
Type19Record = (SMBIOS_TABLE_TYPE19 *)Record;
|
||||
if (Type19Record->StartingAddress != 0xFFFFFFFF ) {
|
||||
InstalledMemory += RShiftU64(Type19Record->EndingAddress -
|
||||
Type19Record->StartingAddress + 1, 10);
|
||||
InstalledMemory += RShiftU64 (
|
||||
Type19Record->EndingAddress -
|
||||
Type19Record->StartingAddress + 1,
|
||||
10
|
||||
);
|
||||
} else {
|
||||
InstalledMemory += RShiftU64(Type19Record->ExtendedEndingAddress -
|
||||
Type19Record->ExtendedStartingAddress + 1, 20);
|
||||
InstalledMemory += RShiftU64 (
|
||||
Type19Record->ExtendedEndingAddress -
|
||||
Type19Record->ExtendedStartingAddress + 1,
|
||||
20
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -647,7 +656,7 @@ UpdateFrontPageBannerStrings (
|
||||
//
|
||||
// Now update the total installed RAM size
|
||||
//
|
||||
ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString );
|
||||
ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString);
|
||||
UiCustomizeFrontPageBanner (3, FALSE, &NewString);
|
||||
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);
|
||||
FreePool (NewString);
|
||||
@ -695,7 +704,7 @@ UiSetConsoleMode (
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
(VOID**)&GraphicsOutput
|
||||
(VOID **)&GraphicsOutput
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
GraphicsOutput = NULL;
|
||||
@ -704,7 +713,7 @@ UiSetConsoleMode (
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiSimpleTextOutProtocolGuid,
|
||||
(VOID**)&SimpleTextOut
|
||||
(VOID **)&SimpleTextOut
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
SimpleTextOut = NULL;
|
||||
@ -756,15 +765,17 @@ UiSetConsoleMode (
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if ((Info->HorizontalResolution == NewHorizontalResolution) &&
|
||||
(Info->VerticalResolution == NewVerticalResolution)) {
|
||||
(Info->VerticalResolution == NewVerticalResolution))
|
||||
{
|
||||
if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&
|
||||
(GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {
|
||||
(GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution))
|
||||
{
|
||||
//
|
||||
// Current resolution is same with required resolution, check if text mode need be set
|
||||
//
|
||||
Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (CurrentColumn == NewColumns && CurrentRow == NewRows) {
|
||||
if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
|
||||
//
|
||||
// If current text mode is same with required text mode. Do nothing
|
||||
//
|
||||
@ -776,7 +787,7 @@ UiSetConsoleMode (
|
||||
//
|
||||
for (Index = 0; Index < MaxTextMode; Index++) {
|
||||
Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
|
||||
//
|
||||
// Required text mode is supported, set it.
|
||||
@ -795,6 +806,7 @@ UiSetConsoleMode (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == MaxTextMode) {
|
||||
//
|
||||
// If required text mode is not supported, return error.
|
||||
@ -815,6 +827,7 @@ UiSetConsoleMode (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (Info);
|
||||
}
|
||||
}
|
||||
@ -855,9 +868,11 @@ UiSetConsoleMode (
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
|
||||
}
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
@ -900,7 +915,7 @@ InitializeUserInterface (
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
(VOID**)&GraphicsOutput
|
||||
(VOID **)&GraphicsOutput
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
GraphicsOutput = NULL;
|
||||
@ -909,7 +924,7 @@ InitializeUserInterface (
|
||||
Status = gBS->HandleProtocol (
|
||||
gST->ConsoleOutHandle,
|
||||
&gEfiSimpleTextOutProtocolGuid,
|
||||
(VOID**)&SimpleTextOut
|
||||
(VOID **)&SimpleTextOut
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
SimpleTextOut = NULL;
|
||||
@ -1006,7 +1021,7 @@ UiEntry (
|
||||
//
|
||||
// Boot Logo is corrupted, report it using Boot Logo protocol.
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);
|
||||
Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo);
|
||||
if (!EFI_ERROR (Status) && (BootLogo != NULL)) {
|
||||
BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);
|
||||
}
|
||||
@ -1023,7 +1038,7 @@ UiEntry (
|
||||
}
|
||||
|
||||
//
|
||||
//Will leave browser, check any reset required change is applied? if yes, reset system
|
||||
// Will leave browser, check any reset required change is applied? if yes, reset system
|
||||
//
|
||||
SetupResetReminder ();
|
||||
}
|
||||
@ -1034,10 +1049,6 @@ UiEntry (
|
||||
// user change any option setting which needs a reset to be effective, and the reset will be applied according to the user selection.
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Record the info that a reset is required.
|
||||
A module boolean variable is used to record whether a reset is required.
|
||||
@ -1052,10 +1063,6 @@ EnableResetRequired (
|
||||
mResetRequired = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Check if user changed any option setting which needs a system reset to be effective.
|
||||
|
||||
@ -1069,7 +1076,6 @@ IsResetRequired (
|
||||
return mResetRequired;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check whether a reset is needed, and finish the reset reminder feature.
|
||||
If a reset is needed, Popup a menu to notice user, and finish the feature
|
||||
@ -1087,10 +1093,9 @@ SetupResetReminder (
|
||||
CHAR16 *StringBuffer2;
|
||||
|
||||
//
|
||||
//check any reset required change is applied? if yes, reset system
|
||||
// check any reset required change is applied? if yes, reset system
|
||||
//
|
||||
if (IsResetRequired ()) {
|
||||
|
||||
StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));
|
||||
ASSERT (StringBuffer1 != NULL);
|
||||
StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));
|
||||
@ -1110,4 +1115,3 @@ SetupResetReminder (
|
||||
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ extern UINT8 FrontPageVfrBin[];
|
||||
|
||||
extern EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2;
|
||||
|
||||
|
||||
#define SMBIOS_TYPE4_CPU_SOCKET_POPULATED BIT6
|
||||
|
||||
//
|
||||
@ -60,7 +59,6 @@ typedef struct {
|
||||
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
|
||||
} FRONT_PAGE_CALLBACK_DATA;
|
||||
|
||||
|
||||
#define EFI_FP_CALLBACK_DATA_FROM_THIS(a) \
|
||||
CR (a, \
|
||||
FRONT_PAGE_CALLBACK_DATA, \
|
||||
@ -210,4 +208,3 @@ ExtractDevicePathFromHiiHandle (
|
||||
);
|
||||
|
||||
#endif // _FRONT_PAGE_H_
|
||||
|
||||
|
@ -37,7 +37,7 @@ UiCustomizeFrontPage (
|
||||
//
|
||||
// Create empty line.
|
||||
//
|
||||
UiCreateEmptyLine(HiiHandle, StartOpCodeHandle);
|
||||
UiCreateEmptyLine (HiiHandle, StartOpCodeHandle);
|
||||
|
||||
//
|
||||
// Find third party drivers which need to be shown in the front page.
|
||||
@ -47,17 +47,17 @@ UiCustomizeFrontPage (
|
||||
//
|
||||
// Create empty line.
|
||||
//
|
||||
UiCreateEmptyLine(HiiHandle, StartOpCodeHandle);
|
||||
UiCreateEmptyLine (HiiHandle, StartOpCodeHandle);
|
||||
|
||||
//
|
||||
// Create "Continue" menu.
|
||||
//
|
||||
UiCreateContinueMenu(HiiHandle, StartOpCodeHandle);
|
||||
UiCreateContinueMenu (HiiHandle, StartOpCodeHandle);
|
||||
|
||||
//
|
||||
// Create reset menu.
|
||||
//
|
||||
UiCreateResetMenu(HiiHandle, StartOpCodeHandle);
|
||||
UiCreateResetMenu (HiiHandle, StartOpCodeHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,12 +128,14 @@ UiCustomizeFrontPageBanner (
|
||||
{
|
||||
if ((LineIndex == 5) && LeftOrRight) {
|
||||
// Update STR_CUSTOMIZE_BANNER_LINE5_LEFT
|
||||
if (PcdGetBool(PcdTestKeyUsed)) {
|
||||
if (PcdGetBool (PcdTestKeyUsed)) {
|
||||
if (BannerStr != NULL) {
|
||||
FreePool(*BannerStr);
|
||||
FreePool (*BannerStr);
|
||||
}
|
||||
*BannerStr = HiiGetString(gFrontPagePrivate.HiiHandle, STRING_TOKEN(STR_TEST_KEY_USED), NULL);
|
||||
|
||||
*BannerStr = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_TEST_KEY_USED), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ UI_HII_DRIVER_INSTANCE *gHiiDriverList;
|
||||
extern EFI_HII_HANDLE gStringPackHandle;
|
||||
UINT8 gCurrentLanguageIndex;
|
||||
|
||||
|
||||
/**
|
||||
Get next language from language code list (with separator ';').
|
||||
|
||||
@ -91,6 +90,7 @@ GetNextLanguage (
|
||||
if (StringPtr[Index] == ';') {
|
||||
Index++;
|
||||
}
|
||||
|
||||
*LangCode = StringPtr + Index;
|
||||
}
|
||||
|
||||
@ -148,6 +148,7 @@ LanguageChangeHandler (
|
||||
} else {
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
FreePool (Lang);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -181,9 +182,10 @@ UiSupportLibCallbackHandler (
|
||||
OUT EFI_STATUS *Status
|
||||
)
|
||||
{
|
||||
if (QuestionId != FRONT_PAGE_KEY_CONTINUE &&
|
||||
QuestionId != FRONT_PAGE_KEY_RESET &&
|
||||
QuestionId != FRONT_PAGE_KEY_LANGUAGE) {
|
||||
if ((QuestionId != FRONT_PAGE_KEY_CONTINUE) &&
|
||||
(QuestionId != FRONT_PAGE_KEY_RESET) &&
|
||||
(QuestionId != FRONT_PAGE_KEY_LANGUAGE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -194,6 +196,7 @@ UiSupportLibCallbackHandler (
|
||||
} else {
|
||||
*Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -221,7 +224,7 @@ UiSupportLibCallbackHandler (
|
||||
break;
|
||||
|
||||
case FRONT_PAGE_KEY_LANGUAGE:
|
||||
*Status = LanguageChangeHandler(Value);
|
||||
*Status = LanguageChangeHandler (Value);
|
||||
break;
|
||||
|
||||
case FRONT_PAGE_KEY_RESET:
|
||||
@ -272,16 +275,16 @@ UiCreateLanguageMenu (
|
||||
OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
|
||||
ASSERT (OptionsOpCodeHandle != NULL);
|
||||
|
||||
GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLang, NULL);
|
||||
GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&CurrentLang, NULL);
|
||||
|
||||
//
|
||||
// Get Support language list from variable.
|
||||
//
|
||||
GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID**)&gLanguageString, NULL);
|
||||
GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID **)&gLanguageString, NULL);
|
||||
if (gLanguageString == NULL) {
|
||||
gLanguageString = AllocateCopyPool (
|
||||
AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),
|
||||
(CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)
|
||||
AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),
|
||||
(CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)
|
||||
);
|
||||
ASSERT (gLanguageString != NULL);
|
||||
}
|
||||
@ -297,7 +300,7 @@ UiCreateLanguageMenu (
|
||||
OptionCount = 0;
|
||||
while (*LangCode != 0) {
|
||||
GetNextLanguage (&LangCode, Lang);
|
||||
OptionCount ++;
|
||||
OptionCount++;
|
||||
}
|
||||
|
||||
//
|
||||
@ -306,7 +309,7 @@ UiCreateLanguageMenu (
|
||||
gLanguageToken = AllocateZeroPool ((OptionCount + 1) * sizeof (EFI_STRING_ID));
|
||||
ASSERT (gLanguageToken != NULL);
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString);
|
||||
Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **)&HiiString);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
LangCode = gLanguageString;
|
||||
@ -345,25 +348,26 @@ UiCreateLanguageMenu (
|
||||
Lang = AllocatePool (AsciiStrSize (gLanguageString));
|
||||
ASSERT (Lang != NULL);
|
||||
}
|
||||
|
||||
while (*LangCode != 0) {
|
||||
GetNextLanguage (&LangCode, Lang);
|
||||
|
||||
if (CurrentLang != NULL && AsciiStrCmp (Lang, CurrentLang) == 0) {
|
||||
if ((CurrentLang != NULL) && (AsciiStrCmp (Lang, CurrentLang) == 0)) {
|
||||
HiiCreateOneOfOptionOpCode (
|
||||
OptionsOpCodeHandle,
|
||||
gLanguageToken[OptionCount],
|
||||
EFI_IFR_OPTION_DEFAULT,
|
||||
EFI_IFR_NUMERIC_SIZE_1,
|
||||
(UINT8) OptionCount
|
||||
(UINT8)OptionCount
|
||||
);
|
||||
gCurrentLanguageIndex = (UINT8) OptionCount;
|
||||
gCurrentLanguageIndex = (UINT8)OptionCount;
|
||||
} else {
|
||||
HiiCreateOneOfOptionOpCode (
|
||||
OptionsOpCodeHandle,
|
||||
gLanguageToken[OptionCount],
|
||||
0,
|
||||
EFI_IFR_NUMERIC_SIZE_1,
|
||||
(UINT8) OptionCount
|
||||
(UINT8)OptionCount
|
||||
);
|
||||
}
|
||||
|
||||
@ -373,6 +377,7 @@ UiCreateLanguageMenu (
|
||||
if (CurrentLang != NULL) {
|
||||
FreePool (CurrentLang);
|
||||
}
|
||||
|
||||
FreePool (Lang);
|
||||
|
||||
HiiCreateOneOfOpCode (
|
||||
@ -479,7 +484,7 @@ ExtractDevicePathFromHiiHandle (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE);
|
||||
return ConvertDevicePathToText (DevicePathFromHandle (DriverHandle), FALSE, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -512,33 +517,33 @@ RequiredDriver (
|
||||
UINTN TempSize;
|
||||
BOOLEAN RetVal;
|
||||
|
||||
Status = HiiGetFormSetFromHiiHandle(HiiHandle, &Buffer,&BufferSize);
|
||||
Status = HiiGetFormSetFromHiiHandle (HiiHandle, &Buffer, &BufferSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RetVal = FALSE;
|
||||
TempSize = 0;
|
||||
Ptr = (UINT8 *) Buffer;
|
||||
while(TempSize < BufferSize) {
|
||||
TempSize += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
|
||||
Ptr = (UINT8 *)Buffer;
|
||||
while (TempSize < BufferSize) {
|
||||
TempSize += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
|
||||
|
||||
if (((EFI_IFR_OP_HEADER *) Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)){
|
||||
Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
|
||||
if (((EFI_IFR_OP_HEADER *)Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {
|
||||
Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
|
||||
continue;
|
||||
}
|
||||
|
||||
ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
|
||||
ClassGuid = (EFI_GUID *) (VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
|
||||
ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
|
||||
ClassGuid = (EFI_GUID *)(VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
|
||||
while (ClassGuidNum-- > 0) {
|
||||
if (!CompareGuid (Guid, ClassGuid)){
|
||||
ClassGuid ++;
|
||||
if (!CompareGuid (Guid, ClassGuid)) {
|
||||
ClassGuid++;
|
||||
continue;
|
||||
}
|
||||
|
||||
*PromptId = ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle;
|
||||
*HelpId = ((EFI_IFR_FORM_SET *)Ptr)->Help;
|
||||
CopyMem (FormsetGuid, &((EFI_IFR_FORM_SET *) Ptr)->Guid, sizeof (EFI_GUID));
|
||||
CopyMem (FormsetGuid, &((EFI_IFR_FORM_SET *)Ptr)->Guid, sizeof (EFI_GUID));
|
||||
RetVal = TRUE;
|
||||
}
|
||||
}
|
||||
@ -612,6 +617,7 @@ UiListThirdPartyDrivers (
|
||||
DriverListPtr[Count].EmptyLineAfter = EmptyLineAfter;
|
||||
}
|
||||
}
|
||||
|
||||
DriverListPtr[Count].PromptId = HiiSetString (HiiHandle, 0, String, NULL);
|
||||
FreePool (String);
|
||||
|
||||
@ -620,11 +626,12 @@ UiListThirdPartyDrivers (
|
||||
String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
|
||||
ASSERT (String != NULL);
|
||||
}
|
||||
|
||||
DriverListPtr[Count].HelpId = HiiSetString (HiiHandle, 0, String, NULL);
|
||||
FreePool (String);
|
||||
|
||||
DevicePathStr = ExtractDevicePathFromHiiHandle(HiiHandles[Index]);
|
||||
if (DevicePathStr != NULL){
|
||||
DevicePathStr = ExtractDevicePathFromHiiHandle (HiiHandles[Index]);
|
||||
if (DevicePathStr != NULL) {
|
||||
DriverListPtr[Count].DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL);
|
||||
FreePool (DevicePathStr);
|
||||
} else {
|
||||
@ -655,7 +662,7 @@ UiListThirdPartyDrivers (
|
||||
gHiiDriverList[Index].PromptId,
|
||||
gHiiDriverList[Index].HelpId,
|
||||
0,
|
||||
(EFI_QUESTION_ID) (Index + FRONT_PAGE_KEY_DRIVER),
|
||||
(EFI_QUESTION_ID)(Index + FRONT_PAGE_KEY_DRIVER),
|
||||
0,
|
||||
&gHiiDriverList[Index].FormSetGuid,
|
||||
gHiiDriverList[Index].DevicePathId
|
||||
@ -665,7 +672,7 @@ UiListThirdPartyDrivers (
|
||||
UiCreateEmptyLine (HiiHandle, StartOpCodeHandle);
|
||||
}
|
||||
|
||||
Index ++;
|
||||
Index++;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -77,7 +77,7 @@ BOOLEAN
|
||||
IN CHAR16 *DriverName,
|
||||
OUT CHAR16 **NewName,
|
||||
OUT BOOLEAN *EmptyLineAfter
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
Search the drivers in the system which need to show in the front page
|
||||
|
@ -16,7 +16,7 @@ EFI_GUID mUiStringPackGuid = {
|
||||
};
|
||||
|
||||
EFI_GUID mFontPackageGuid = {
|
||||
0x78941450, 0x90ab, 0x4fb1, {0xb7, 0x5f, 0x58, 0x92, 0x14, 0xe2, 0x4a, 0xc}
|
||||
0x78941450, 0x90ab, 0x4fb1, { 0xb7, 0x5f, 0x58, 0x92, 0x14, 0xe2, 0x4a, 0xc }
|
||||
};
|
||||
|
||||
#define NARROW_GLYPH_NUMBER 8
|
||||
|
@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _BDS_MODULE_H_
|
||||
#define _BDS_MODULE_H_
|
||||
|
||||
@ -43,12 +42,10 @@ typedef struct {
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
//
|
||||
//The interface functions related to the Setup Browser Reset Reminder feature
|
||||
// The interface functions related to the Setup Browser Reset Reminder feature
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
Record the info that a reset is required.
|
||||
A module boolean variable is used to record whether a reset is required.
|
||||
@ -60,8 +57,6 @@ EnableResetRequired (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Check whether platform policy enables the reset reminder feature. The default is enabled.
|
||||
|
||||
|
@ -51,13 +51,15 @@ GetVariableStatisticsData (
|
||||
CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
|
||||
SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);
|
||||
|
||||
SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) &SmmCommunicateHeader->Data[0];
|
||||
SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)&SmmCommunicateHeader->Data[0];
|
||||
SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_STATISTICS;
|
||||
|
||||
Status = mMmCommunication2->Communicate (mMmCommunication2,
|
||||
Status = mMmCommunication2->Communicate (
|
||||
mMmCommunication2,
|
||||
SmmCommunicateHeader,
|
||||
SmmCommunicateHeader,
|
||||
SmmCommunicateSize);
|
||||
SmmCommunicateSize
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = SmmVariableFunctionHeader->ReturnStatus;
|
||||
@ -90,12 +92,12 @@ PrintInfoFromSmm (
|
||||
UINTN Size;
|
||||
UINTN MaxSize;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **) &Smmvariable);
|
||||
Status = gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **)&Smmvariable);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiMmCommunication2ProtocolGuid, NULL, (VOID **) &mMmCommunication2);
|
||||
Status = gBS->LocateProtocol (&gEfiMmCommunication2ProtocolGuid, NULL, (VOID **)&mMmCommunication2);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -104,28 +106,31 @@ PrintInfoFromSmm (
|
||||
RealCommSize = 0;
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gEdkiiPiSmmCommunicationRegionTableGuid,
|
||||
(VOID **) &PiSmmCommunicationRegionTable
|
||||
(VOID **)&PiSmmCommunicationRegionTable
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (PiSmmCommunicationRegionTable != NULL);
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *) (PiSmmCommunicationRegionTable + 1);
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
|
||||
Size = 0;
|
||||
MaxSize = 0;
|
||||
for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
|
||||
if (Entry->Type == EfiConventionalMemory) {
|
||||
Size = EFI_PAGES_TO_SIZE ((UINTN) Entry->NumberOfPages);
|
||||
Size = EFI_PAGES_TO_SIZE ((UINTN)Entry->NumberOfPages);
|
||||
if (Size > (SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (VARIABLE_INFO_ENTRY))) {
|
||||
if (Size > MaxSize) {
|
||||
MaxSize = Size;
|
||||
RealCommSize = MaxSize;
|
||||
CommBuffer = (EFI_MM_COMMUNICATE_HEADER *) (UINTN) Entry->PhysicalStart;
|
||||
CommBuffer = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)Entry->PhysicalStart;
|
||||
}
|
||||
}
|
||||
}
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||
}
|
||||
|
||||
ASSERT (CommBuffer != NULL);
|
||||
ZeroMem (CommBuffer, RealCommSize);
|
||||
|
||||
@ -142,8 +147,8 @@ PrintInfoFromSmm (
|
||||
break;
|
||||
}
|
||||
|
||||
FunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) CommBuffer->Data;
|
||||
VariableInfo = (VARIABLE_INFO_ENTRY *) FunctionHeader->Data;
|
||||
FunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)CommBuffer->Data;
|
||||
VariableInfo = (VARIABLE_INFO_ENTRY *)FunctionHeader->Data;
|
||||
|
||||
if (!VariableInfo->Volatile) {
|
||||
Print (
|
||||
@ -172,8 +177,8 @@ PrintInfoFromSmm (
|
||||
break;
|
||||
}
|
||||
|
||||
FunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) CommBuffer->Data;
|
||||
VariableInfo = (VARIABLE_INFO_ENTRY *) FunctionHeader->Data;
|
||||
FunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)CommBuffer->Data;
|
||||
VariableInfo = (VARIABLE_INFO_ENTRY *)FunctionHeader->Data;
|
||||
|
||||
if (VariableInfo->Volatile) {
|
||||
Print (
|
||||
@ -215,9 +220,9 @@ UefiMain (
|
||||
VARIABLE_INFO_ENTRY *VariableInfo;
|
||||
VARIABLE_INFO_ENTRY *Entry;
|
||||
|
||||
RuntimeDxeStatus = EfiGetSystemConfigurationTable (&gEfiVariableGuid, (VOID **) &Entry);
|
||||
RuntimeDxeStatus = EfiGetSystemConfigurationTable (&gEfiVariableGuid, (VOID **)&Entry);
|
||||
if (EFI_ERROR (RuntimeDxeStatus) || (Entry == NULL)) {
|
||||
RuntimeDxeStatus = EfiGetSystemConfigurationTable (&gEfiAuthenticatedVariableGuid, (VOID **) &Entry);
|
||||
RuntimeDxeStatus = EfiGetSystemConfigurationTable (&gEfiAuthenticatedVariableGuid, (VOID **)&Entry);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (RuntimeDxeStatus) && (Entry != NULL)) {
|
||||
@ -253,6 +258,7 @@ UefiMain (
|
||||
VariableInfo->Name
|
||||
);
|
||||
}
|
||||
|
||||
VariableInfo = VariableInfo->Next;
|
||||
} while (VariableInfo != NULL);
|
||||
}
|
||||
|
@ -66,7 +66,6 @@ UINT32 mMaxTransferBlockNumber[2] = {
|
||||
//
|
||||
#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
|
||||
|
||||
|
||||
/**
|
||||
Read AHCI Operation register.
|
||||
|
||||
@ -181,7 +180,7 @@ AhciWaitMmioSet (
|
||||
UINT32 Value;
|
||||
UINT32 Delay;
|
||||
|
||||
Delay = (UINT32) (DivU64x32(Timeout, 1000) + 1);
|
||||
Delay = (UINT32)(DivU64x32 (Timeout, 1000) + 1);
|
||||
|
||||
do {
|
||||
Value = AhciReadReg (AhciBar, Offset) & MaskValue;
|
||||
@ -196,7 +195,6 @@ AhciWaitMmioSet (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (Delay > 0);
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -222,7 +220,7 @@ AhciCheckMemSet (
|
||||
{
|
||||
UINT32 Value;
|
||||
|
||||
Value = *(volatile UINT32 *) Address;
|
||||
Value = *(volatile UINT32 *)Address;
|
||||
Value &= MaskValue;
|
||||
|
||||
if (Value == TestValue) {
|
||||
@ -273,7 +271,7 @@ AhciWaitMemSet (
|
||||
// compiler from optimizing the access to the memory address
|
||||
// to only read once.
|
||||
//
|
||||
Value = *(volatile UINT32 *) (UINTN) Address;
|
||||
Value = *(volatile UINT32 *)(UINTN)Address;
|
||||
Value &= MaskValue;
|
||||
|
||||
if (Value == TestValue) {
|
||||
@ -286,7 +284,6 @@ AhciWaitMemSet (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -395,7 +392,7 @@ AhciDisableFisReceive (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
AhciAndReg (AhciBar, Offset, (UINT32)~(AHCI_PORT_CMD_FRE));
|
||||
AhciAndReg (AhciBar, Offset, (UINT32) ~(AHCI_PORT_CMD_FRE));
|
||||
|
||||
return AhciWaitMmioSet (
|
||||
AhciBar,
|
||||
@ -467,11 +464,11 @@ AhciBuildCommand (
|
||||
return;
|
||||
}
|
||||
|
||||
Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * FisIndex;
|
||||
Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * FisIndex;
|
||||
|
||||
BaseAddr = Data64.Uint64;
|
||||
|
||||
ZeroMem ((VOID *)((UINTN) BaseAddr), sizeof (EFI_AHCI_RECEIVED_FIS));
|
||||
ZeroMem ((VOID *)((UINTN)BaseAddr), sizeof (EFI_AHCI_RECEIVED_FIS));
|
||||
|
||||
ZeroMem (AhciRegisters->AhciCmdTable, sizeof (EFI_AHCI_COMMAND_TABLE));
|
||||
|
||||
@ -480,10 +477,10 @@ AhciBuildCommand (
|
||||
CopyMem (&AhciRegisters->AhciCmdTable->CommandFis, CommandFis, sizeof (EFI_AHCI_COMMAND_FIS));
|
||||
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CMD;
|
||||
AhciAndReg (AhciBar, Offset, (UINT32)~(AHCI_PORT_CMD_DLAE | AHCI_PORT_CMD_ATAPI));
|
||||
AhciAndReg (AhciBar, Offset, (UINT32) ~(AHCI_PORT_CMD_DLAE | AHCI_PORT_CMD_ATAPI));
|
||||
|
||||
RemainedData = (UINTN) DataLength;
|
||||
MemAddr = (UINTN) DataPhysicalAddr;
|
||||
RemainedData = (UINTN)DataLength;
|
||||
MemAddr = (UINTN)DataPhysicalAddr;
|
||||
CommandList->AhciCmdPrdtl = PrdtNumber;
|
||||
|
||||
for (PrdtIndex = 0; PrdtIndex < PrdtNumber; PrdtIndex++) {
|
||||
@ -508,12 +505,12 @@ AhciBuildCommand (
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
(VOID *) ((UINTN) AhciRegisters->AhciCmdList + (UINTN) CommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST)),
|
||||
(VOID *)((UINTN)AhciRegisters->AhciCmdList + (UINTN)CommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST)),
|
||||
CommandList,
|
||||
sizeof (EFI_AHCI_COMMAND_LIST)
|
||||
);
|
||||
|
||||
Data64.Uint64 = (UINT64)(UINTN) AhciRegisters->AhciCmdTable;
|
||||
Data64.Uint64 = (UINT64)(UINTN)AhciRegisters->AhciCmdTable;
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtba = Data64.Uint32.Lower32;
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtbau = Data64.Uint32.Upper32;
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdPmp = PortMultiplier;
|
||||
@ -558,7 +555,7 @@ AhciBuildCommandFis (
|
||||
CmdFis->AhciCFisSecCount = AtaCommandBlock->AtaSectorCount;
|
||||
CmdFis->AhciCFisSecCountExp = AtaCommandBlock->AtaSectorCountExp;
|
||||
|
||||
CmdFis->AhciCFisDevHead = (UINT8) (AtaCommandBlock->AtaDeviceHead | 0xE0);
|
||||
CmdFis->AhciCFisDevHead = (UINT8)(AtaCommandBlock->AtaDeviceHead | 0xE0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -591,7 +588,7 @@ AhciStopCommand (
|
||||
}
|
||||
|
||||
if ((Data & AHCI_PORT_CMD_ST) != 0) {
|
||||
AhciAndReg (AhciBar, Offset, (UINT32)~(AHCI_PORT_CMD_ST));
|
||||
AhciAndReg (AhciBar, Offset, (UINT32) ~(AHCI_PORT_CMD_ST));
|
||||
}
|
||||
|
||||
return AhciWaitMmioSet (
|
||||
@ -637,7 +634,7 @@ AhciStartCommand (
|
||||
//
|
||||
Capability = AhciReadReg (AhciBar, AHCI_CAPABILITY_OFFSET);
|
||||
|
||||
CmdSlotBit = (UINT32) (1 << CommandSlot);
|
||||
CmdSlotBit = (UINT32)(1 << CommandSlot);
|
||||
|
||||
AhciClearPortStatus (
|
||||
AhciBar,
|
||||
@ -762,7 +759,9 @@ AhciPioTransfer (
|
||||
DEBUG_ERROR,
|
||||
"%a: Driver only support a maximum of 0x%x PRDT entries, "
|
||||
"current number of data byte 0x%x is too large, maximum allowed is 0x%x.\n",
|
||||
__FUNCTION__, AHCI_MAX_PRDT_NUMBER, DataCount,
|
||||
__FUNCTION__,
|
||||
AHCI_MAX_PRDT_NUMBER,
|
||||
DataCount,
|
||||
AHCI_MAX_PRDT_NUMBER * AHCI_MAX_DATA_PER_PRDT
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
@ -794,7 +793,7 @@ AhciPioTransfer (
|
||||
OldRfisLo = AhciReadReg (AhciBar, Offset);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FBU;
|
||||
OldRfisHi = AhciReadReg (AhciBar, Offset);
|
||||
Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * FisIndex;
|
||||
Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * FisIndex;
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FB;
|
||||
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Lower32);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FBU;
|
||||
@ -807,7 +806,7 @@ AhciPioTransfer (
|
||||
OldCmdListLo = AhciReadReg (AhciBar, Offset);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLBU;
|
||||
OldCmdListHi = AhciReadReg (AhciBar, Offset);
|
||||
Data64.Uint64 = (UINTN) (AhciRegisters->AhciCmdList);
|
||||
Data64.Uint64 = (UINTN)(AhciRegisters->AhciCmdList);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLB;
|
||||
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Lower32);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLBU;
|
||||
@ -854,7 +853,7 @@ AhciPioTransfer (
|
||||
// Wait device sends the PIO setup fis before data transfer
|
||||
//
|
||||
Status = EFI_TIMEOUT;
|
||||
Delay = (UINT32) DivU64x32 (Timeout, 1000) + 1;
|
||||
Delay = (UINT32)DivU64x32 (Timeout, 1000) + 1;
|
||||
do {
|
||||
PioFisReceived = FALSE;
|
||||
D2hFisReceived = FALSE;
|
||||
@ -864,6 +863,7 @@ AhciPioTransfer (
|
||||
DEBUG ((DEBUG_INFO, "%a: PioFisReceived.\n", __FUNCTION__));
|
||||
PioFisReceived = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// According to SATA 2.6 spec section 11.7, D2h FIS means an error encountered.
|
||||
// But Qemu and Marvel 9230 sata controller may just receive a D2h FIS from
|
||||
@ -880,7 +880,7 @@ AhciPioTransfer (
|
||||
|
||||
if (PioFisReceived || D2hFisReceived) {
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
|
||||
PortTfd = AhciReadReg (AhciBar, (UINT32) Offset);
|
||||
PortTfd = AhciReadReg (AhciBar, (UINT32)Offset);
|
||||
//
|
||||
// PxTFD will be updated if there is a D2H or SetupFIS received.
|
||||
//
|
||||
@ -889,7 +889,7 @@ AhciPioTransfer (
|
||||
break;
|
||||
}
|
||||
|
||||
PrdCount = *(volatile UINT32 *) (&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
|
||||
PrdCount = *(volatile UINT32 *)(&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
|
||||
if (PrdCount == DataCount) {
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
@ -899,7 +899,7 @@ AhciPioTransfer (
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
MicroSecondDelay(100);
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
if (Delay == 0) {
|
||||
@ -923,7 +923,7 @@ AhciPioTransfer (
|
||||
}
|
||||
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
|
||||
PortTfd = AhciReadReg (AhciBar, (UINT32) Offset);
|
||||
PortTfd = AhciReadReg (AhciBar, (UINT32)Offset);
|
||||
if ((PortTfd & AHCI_PORT_TFD_ERR) != 0) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -1048,7 +1048,7 @@ AhciNonDataTransfer (
|
||||
}
|
||||
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
|
||||
PortTfd = AhciReadReg (AhciBar, (UINT32) Offset);
|
||||
PortTfd = AhciReadReg (AhciBar, (UINT32)Offset);
|
||||
if ((PortTfd & AHCI_PORT_TFD_ERR) != 0) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -1104,10 +1104,10 @@ AhciReset (
|
||||
|
||||
AhciOrReg (AhciBar, AHCI_GHC_OFFSET, AHCI_GHC_RESET);
|
||||
|
||||
Delay = (UINT32) (DivU64x32(Timeout, 1000) + 1);
|
||||
Delay = (UINT32)(DivU64x32 (Timeout, 1000) + 1);
|
||||
|
||||
do {
|
||||
Value = AhciReadReg(AhciBar, AHCI_GHC_OFFSET);
|
||||
Value = AhciReadReg (AhciBar, AHCI_GHC_OFFSET);
|
||||
if ((Value & AHCI_GHC_RESET) == 0) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1115,7 +1115,7 @@ AhciReset (
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
MicroSecondDelay(100);
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
} while (Delay > 0);
|
||||
@ -1178,7 +1178,6 @@ AhciIdentify (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Collect the number of bits set within a port bitmap.
|
||||
|
||||
@ -1200,6 +1199,7 @@ AhciGetNumberOfPortsFromMap (
|
||||
if ((PortBitMap & ((UINT32)BIT0)) != 0) {
|
||||
NumberOfPorts++;
|
||||
}
|
||||
|
||||
PortBitMap = PortBitMap >> 1;
|
||||
}
|
||||
|
||||
@ -1242,6 +1242,7 @@ AhciGetPortFromMap (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
PortBitMap = PortBitMap >> 1;
|
||||
*Port = *Port + 1;
|
||||
}
|
||||
@ -1288,7 +1289,7 @@ AhciCreateTransferDescriptor (
|
||||
//
|
||||
// Get the number of command slots per port supported by this HBA.
|
||||
//
|
||||
MaxCommandSlotNumber = (UINT8) (((Capability & 0x1F00) >> 8) + 1);
|
||||
MaxCommandSlotNumber = (UINT8)(((Capability & 0x1F00) >> 8) + 1);
|
||||
ASSERT (MaxCommandSlotNumber > 0);
|
||||
if (MaxCommandSlotNumber == 0) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
@ -1299,10 +1300,11 @@ AhciCreateTransferDescriptor (
|
||||
// allocated for recived FIS.
|
||||
//
|
||||
PortImplementBitMap = AhciReadReg (AhciBar, AHCI_PI_OFFSET);
|
||||
MaxPortNumber = (UINT8)(UINTN)(HighBitSet32(PortImplementBitMap) + 1);
|
||||
MaxPortNumber = (UINT8)(UINTN)(HighBitSet32 (PortImplementBitMap) + 1);
|
||||
if (MaxPortNumber == 0) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the number of ports that actually needed to be initialized.
|
||||
//
|
||||
@ -1321,7 +1323,8 @@ AhciCreateTransferDescriptor (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS) (UINTN) Base));
|
||||
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
|
||||
AhciRegisters->AhciRFis = Base;
|
||||
AhciRegisters->AhciRFisMap = Mapping;
|
||||
AhciRegisters->MaxRFisSize = MaxRFisSize;
|
||||
@ -1343,7 +1346,8 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS) (UINTN) Base));
|
||||
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
|
||||
AhciRegisters->AhciCmdList = Base;
|
||||
AhciRegisters->AhciCmdListMap = Mapping;
|
||||
AhciRegisters->MaxCmdListSize = MaxCmdListSize;
|
||||
@ -1364,7 +1368,8 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS) (UINTN) Base));
|
||||
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
|
||||
AhciRegisters->AhciCmdTable = Base;
|
||||
AhciRegisters->AhciCmdTableMap = Mapping;
|
||||
AhciRegisters->MaxCmdTableSize = MaxCmdTableSize;
|
||||
@ -1472,15 +1477,21 @@ IdentifyAtaDevice (
|
||||
|
||||
if ((IdentifyData->config & BIT15) != 0) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: Not a hard disk device on Port 0x%x PortMultiplierPort 0x%x\n",
|
||||
__FUNCTION__, DeviceData->Port, DeviceData->PortMultiplier
|
||||
DEBUG_ERROR,
|
||||
"%a: Not a hard disk device on Port 0x%x PortMultiplierPort 0x%x\n",
|
||||
__FUNCTION__,
|
||||
DeviceData->Port,
|
||||
DeviceData->PortMultiplier
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO, "%a: Identify Device: Port 0x%x PortMultiplierPort 0x%x\n",
|
||||
__FUNCTION__, DeviceData->Port, DeviceData->PortMultiplier
|
||||
DEBUG_INFO,
|
||||
"%a: Identify Device: Port 0x%x PortMultiplierPort 0x%x\n",
|
||||
__FUNCTION__,
|
||||
DeviceData->Port,
|
||||
DeviceData->PortMultiplier
|
||||
));
|
||||
|
||||
//
|
||||
@ -1510,7 +1521,8 @@ IdentifyAtaDevice (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Invalid Capacity (0) for ATA device.\n", __FUNCTION__));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
Media->LastBlock = (EFI_PEI_LBA) (Capacity - 1);
|
||||
|
||||
Media->LastBlock = (EFI_PEI_LBA)(Capacity - 1);
|
||||
|
||||
Media->BlockSize = 0x200;
|
||||
//
|
||||
@ -1518,15 +1530,17 @@ IdentifyAtaDevice (
|
||||
//
|
||||
PhyLogicSectorSupport = IdentifyData->phy_logic_sector_support;
|
||||
DEBUG ((
|
||||
DEBUG_INFO, "%a: PhyLogicSectorSupport = 0x%x\n",
|
||||
__FUNCTION__, PhyLogicSectorSupport
|
||||
DEBUG_INFO,
|
||||
"%a: PhyLogicSectorSupport = 0x%x\n",
|
||||
__FUNCTION__,
|
||||
PhyLogicSectorSupport
|
||||
));
|
||||
if ((PhyLogicSectorSupport & (BIT14 | BIT15)) == BIT14) {
|
||||
//
|
||||
// Check logical block size
|
||||
//
|
||||
if ((PhyLogicSectorSupport & BIT12) != 0) {
|
||||
Media->BlockSize = (UINT32) (((IdentifyData->logic_sector_size_hi << 16) |
|
||||
Media->BlockSize = (UINT32)(((IdentifyData->logic_sector_size_hi << 16) |
|
||||
IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
|
||||
}
|
||||
}
|
||||
@ -1541,8 +1555,11 @@ IdentifyAtaDevice (
|
||||
}
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO, "%a: BlockSize = 0x%x, LastBlock = 0x%lx\n",
|
||||
__FUNCTION__, Media->BlockSize, Media->LastBlock
|
||||
DEBUG_INFO,
|
||||
"%a: BlockSize = 0x%x, LastBlock = 0x%lx\n",
|
||||
__FUNCTION__,
|
||||
Media->BlockSize,
|
||||
Media->LastBlock
|
||||
));
|
||||
|
||||
if ((IdentifyData->trusted_computing_support & BIT0) != 0) {
|
||||
@ -1622,6 +1639,7 @@ CreateNewDevice (
|
||||
Private->TrustComputingDevices++;
|
||||
DeviceData->TrustComputingDeviceIndex = Private->TrustComputingDevices;
|
||||
}
|
||||
|
||||
Private->ActiveDevices++;
|
||||
InsertTailList (&Private->DeviceList, &DeviceData->Link);
|
||||
|
||||
@ -1690,7 +1708,8 @@ AhciModeInitialization (
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Transfer-related data allocation failed with %r.\n",
|
||||
__FUNCTION__, Status
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -1698,7 +1717,7 @@ AhciModeInitialization (
|
||||
//
|
||||
// Get the number of command slots per port supported by this HBA.
|
||||
//
|
||||
MaxPortNumber = (UINT8) ((Capability & 0x1F) + 1);
|
||||
MaxPortNumber = (UINT8)((Capability & 0x1F) + 1);
|
||||
|
||||
//
|
||||
// Get the bit map of those ports exposed by this HBA.
|
||||
@ -1710,7 +1729,7 @@ AhciModeInitialization (
|
||||
//
|
||||
// Get the number of ports that actually needed to be initialized.
|
||||
//
|
||||
MaxPortNumber = MIN (MaxPortNumber, (UINT8)(UINTN)(HighBitSet32(PortImplementBitMap) + 1));
|
||||
MaxPortNumber = MIN (MaxPortNumber, (UINT8)(UINTN)(HighBitSet32 (PortImplementBitMap) + 1));
|
||||
MaxPortNumber = MIN (MaxPortNumber, AhciGetNumberOfPortsFromMap (Private->PortBitMap));
|
||||
|
||||
PortInitializeBitMap = Private->PortBitMap & PortImplementBitMap;
|
||||
@ -1719,7 +1738,7 @@ AhciModeInitialization (
|
||||
//
|
||||
// Enumerate ATA ports
|
||||
//
|
||||
for (PortIndex = 1; PortIndex <= MaxPortNumber; PortIndex ++) {
|
||||
for (PortIndex = 1; PortIndex <= MaxPortNumber; PortIndex++) {
|
||||
Status = AhciGetPortFromMap (PortInitializeBitMap, PortIndex, &Port);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
@ -1733,14 +1752,14 @@ AhciModeInitialization (
|
||||
// Initialize FIS Base Address Register and Command List Base Address
|
||||
// Register for use.
|
||||
//
|
||||
Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFis) +
|
||||
Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFis) +
|
||||
sizeof (EFI_AHCI_RECEIVED_FIS) * (PortIndex - 1);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FB;
|
||||
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Lower32);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_FBU;
|
||||
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Upper32);
|
||||
|
||||
Data64.Uint64 = (UINTN) (AhciRegisters->AhciCmdList);
|
||||
Data64.Uint64 = (UINTN)(AhciRegisters->AhciCmdList);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLB;
|
||||
AhciWriteReg (AhciBar, Offset, Data64.Uint32.Lower32);
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_CLBU;
|
||||
@ -1806,9 +1825,10 @@ AhciModeInitialization (
|
||||
PhyDetectDelay = 16 * 1000;
|
||||
do {
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_SERR;
|
||||
if (AhciReadReg(AhciBar, Offset) != 0) {
|
||||
if (AhciReadReg (AhciBar, Offset) != 0) {
|
||||
AhciWriteReg (AhciBar, Offset, AhciReadReg (AhciBar, Offset));
|
||||
}
|
||||
|
||||
Offset = AHCI_PORT_START + Port * AHCI_PORT_REG_WIDTH + AHCI_PORT_TFD;
|
||||
|
||||
Data = AhciReadReg (AhciBar, Offset) & AHCI_PORT_TFD_MASK;
|
||||
@ -1824,7 +1844,9 @@ AhciModeInitialization (
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Port %d device presence detected but phy not ready (TFD=0x%x).\n",
|
||||
__FUNCTION__, Port, Data
|
||||
__FUNCTION__,
|
||||
Port,
|
||||
Data
|
||||
));
|
||||
continue;
|
||||
}
|
||||
@ -1844,7 +1866,8 @@ AhciModeInitialization (
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Error occurred when waiting for the first D2H register FIS - %r\n",
|
||||
__FUNCTION__, Status
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
continue;
|
||||
}
|
||||
@ -1856,6 +1879,7 @@ AhciModeInitialization (
|
||||
DEBUG ((DEBUG_ERROR, "%a: AhciIdentify() failed with %r\n", __FUNCTION__, Status));
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: ATA hard disk found on Port %d.\n", __FUNCTION__, Port));
|
||||
} else {
|
||||
continue;
|
||||
@ -1916,10 +1940,11 @@ TransferAtaDevice (
|
||||
//
|
||||
// Ensure Lba48Bit and IsWrite are valid boolean values
|
||||
//
|
||||
ASSERT ((UINTN) DeviceData->Lba48Bit < 2);
|
||||
ASSERT ((UINTN) IsWrite < 2);
|
||||
if (((UINTN) DeviceData->Lba48Bit >= 2) ||
|
||||
((UINTN) IsWrite >= 2)) {
|
||||
ASSERT ((UINTN)DeviceData->Lba48Bit < 2);
|
||||
ASSERT ((UINTN)IsWrite < 2);
|
||||
if (((UINTN)DeviceData->Lba48Bit >= 2) ||
|
||||
((UINTN)IsWrite >= 2))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1928,20 +1953,20 @@ TransferAtaDevice (
|
||||
//
|
||||
ZeroMem (&Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
|
||||
Acb.AtaCommand = mAtaCommands[DeviceData->Lba48Bit][IsWrite];
|
||||
Acb.AtaSectorNumber = (UINT8) StartLba;
|
||||
Acb.AtaCylinderLow = (UINT8) RShiftU64 (StartLba, 8);
|
||||
Acb.AtaCylinderHigh = (UINT8) RShiftU64 (StartLba, 16);
|
||||
Acb.AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 |
|
||||
Acb.AtaSectorNumber = (UINT8)StartLba;
|
||||
Acb.AtaCylinderLow = (UINT8)RShiftU64 (StartLba, 8);
|
||||
Acb.AtaCylinderHigh = (UINT8)RShiftU64 (StartLba, 16);
|
||||
Acb.AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 |
|
||||
(DeviceData->PortMultiplier == 0xFFFF ?
|
||||
0 : (DeviceData->PortMultiplier << 4)));
|
||||
Acb.AtaSectorCount = (UINT8) TransferLength;
|
||||
Acb.AtaSectorCount = (UINT8)TransferLength;
|
||||
if (DeviceData->Lba48Bit) {
|
||||
Acb.AtaSectorNumberExp = (UINT8) RShiftU64 (StartLba, 24);
|
||||
Acb.AtaCylinderLowExp = (UINT8) RShiftU64 (StartLba, 32);
|
||||
Acb.AtaCylinderHighExp = (UINT8) RShiftU64 (StartLba, 40);
|
||||
Acb.AtaSectorCountExp = (UINT8) (TransferLength >> 8);
|
||||
Acb.AtaSectorNumberExp = (UINT8)RShiftU64 (StartLba, 24);
|
||||
Acb.AtaCylinderLowExp = (UINT8)RShiftU64 (StartLba, 32);
|
||||
Acb.AtaCylinderHighExp = (UINT8)RShiftU64 (StartLba, 40);
|
||||
Acb.AtaSectorCountExp = (UINT8)(TransferLength >> 8);
|
||||
} else {
|
||||
Acb.AtaDeviceHead = (UINT8) (Acb.AtaDeviceHead | RShiftU64 (StartLba, 24));
|
||||
Acb.AtaDeviceHead = (UINT8)(Acb.AtaDeviceHead | RShiftU64 (StartLba, 24));
|
||||
}
|
||||
|
||||
//
|
||||
@ -1955,6 +1980,7 @@ TransferAtaDevice (
|
||||
Packet.InDataBuffer = Buffer;
|
||||
Packet.InTransferLength = TransferLength;
|
||||
}
|
||||
|
||||
Packet.Asb = NULL;
|
||||
Packet.Acb = &Acb;
|
||||
Packet.Protocol = mAtaPassThruCmdProtocols[IsWrite];
|
||||
@ -2058,8 +2084,8 @@ TrustTransferAtaDevice (
|
||||
//
|
||||
// Ensure IsTrustSend are valid boolean values
|
||||
//
|
||||
ASSERT ((UINTN) IsTrustSend < 2);
|
||||
if ((UINTN) IsTrustSend >= 2) {
|
||||
ASSERT ((UINTN)IsTrustSend < 2);
|
||||
if ((UINTN)IsTrustSend >= 2) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2072,16 +2098,17 @@ TrustTransferAtaDevice (
|
||||
} else {
|
||||
Acb.AtaCommand = mAtaTrustCommands[IsTrustSend];
|
||||
}
|
||||
|
||||
Acb.AtaFeatures = SecurityProtocolId;
|
||||
Acb.AtaSectorCount = (UINT8) (TransferLength / 512);
|
||||
Acb.AtaSectorNumber = (UINT8) ((TransferLength / 512) >> 8);
|
||||
Acb.AtaSectorCount = (UINT8)(TransferLength / 512);
|
||||
Acb.AtaSectorNumber = (UINT8)((TransferLength / 512) >> 8);
|
||||
//
|
||||
// NOTE: ATA Spec has no explicitly definition for Security Protocol Specific layout.
|
||||
// Here use big endian for Cylinder register.
|
||||
//
|
||||
Acb.AtaCylinderHigh = (UINT8) SecurityProtocolSpecificData;
|
||||
Acb.AtaCylinderLow = (UINT8) (SecurityProtocolSpecificData >> 8);
|
||||
Acb.AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 |
|
||||
Acb.AtaCylinderHigh = (UINT8)SecurityProtocolSpecificData;
|
||||
Acb.AtaCylinderLow = (UINT8)(SecurityProtocolSpecificData >> 8);
|
||||
Acb.AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 |
|
||||
(DeviceData->PortMultiplier == 0xFFFF ?
|
||||
0 : (DeviceData->PortMultiplier << 4)));
|
||||
|
||||
@ -2099,7 +2126,8 @@ TrustTransferAtaDevice (
|
||||
// ATA PassThru PPI.
|
||||
//
|
||||
if ((AtaPassThru->Mode->IoAlign > 1) &&
|
||||
!IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign)) {
|
||||
!IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign))
|
||||
{
|
||||
NewBuffer = AllocateAlignedPages (
|
||||
EFI_SIZE_TO_PAGES (TransferLength),
|
||||
AtaPassThru->Mode->IoAlign
|
||||
@ -2111,14 +2139,16 @@ TrustTransferAtaDevice (
|
||||
CopyMem (NewBuffer, Buffer, TransferLength);
|
||||
Buffer = NewBuffer;
|
||||
}
|
||||
|
||||
Packet.OutDataBuffer = Buffer;
|
||||
Packet.OutTransferLength = (UINT32) TransferLength;
|
||||
Packet.OutTransferLength = (UINT32)TransferLength;
|
||||
Packet.Protocol = mAtaPassThruCmdProtocols[IsTrustSend];
|
||||
} else {
|
||||
Packet.InDataBuffer = Buffer;
|
||||
Packet.InTransferLength = (UINT32) TransferLength;
|
||||
Packet.InTransferLength = (UINT32)TransferLength;
|
||||
Packet.Protocol = mAtaPassThruCmdProtocols[IsTrustSend];
|
||||
}
|
||||
|
||||
Packet.Asb = NULL;
|
||||
Packet.Acb = &Acb;
|
||||
Packet.Timeout = Timeout;
|
||||
@ -2135,5 +2165,6 @@ TrustTransferAtaDevice (
|
||||
*TransferLengthOut = Packet.InTransferLength;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ EFI_PEI_NOTIFY_DESCRIPTOR mAhciEndOfPeiNotifyListTemplate = {
|
||||
AhciPeimEndOfPei
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Free the DMA resources allocated by an ATA AHCI controller.
|
||||
|
||||
@ -82,7 +81,6 @@ AhciFreeDmaResource (
|
||||
AhciRegisters->AhciCmdTableMap
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,7 +155,7 @@ AtaAhciPeimEntry (
|
||||
&gEdkiiPeiAtaAhciHostControllerPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &AhciHcPpi
|
||||
(VOID **)&AhciHcPpi
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Failed to locate AtaAhciHostControllerPpi.\n", __FUNCTION__));
|
||||
@ -187,8 +185,10 @@ AtaAhciPeimEntry (
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: Fail to allocate get the device path for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_ERROR,
|
||||
"%a: Fail to allocate get the device path for Controller %d.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
@ -199,8 +199,10 @@ AtaAhciPeimEntry (
|
||||
Status = AhciIsHcDevicePathValid (DevicePath, DevicePathLength);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: The device path is invalid for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_ERROR,
|
||||
"%a: The device path is invalid for Controller %d.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
Controller++;
|
||||
continue;
|
||||
@ -231,8 +233,10 @@ AtaAhciPeimEntry (
|
||||
Private = AllocateZeroPool (sizeof (PEI_AHCI_CONTROLLER_PRIVATE_DATA));
|
||||
if (Private == NULL) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: Fail to allocate private data for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_ERROR,
|
||||
"%a: Fail to allocate private data for Controller %d.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -304,7 +308,8 @@ AtaAhciPeimEntry (
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Security Security Command PPI will be produced for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
Private->StorageSecurityPpi.Revision = EDKII_STORAGE_SECURITY_PPI_REVISION;
|
||||
Private->StorageSecurityPpi.GetNumberofDevices = AhciStorageSecurityGetDeviceNo;
|
||||
@ -328,8 +333,10 @@ AtaAhciPeimEntry (
|
||||
PeiServicesNotifyPpi (&Private->EndOfPeiNotifyList);
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO, "%a: Controller %d has been successfully initialized.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_INFO,
|
||||
"%a: Controller %d has been successfully initialized.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
Controller++;
|
||||
}
|
||||
|
@ -92,10 +92,10 @@ typedef union {
|
||||
//
|
||||
#define AHCI_MAX_DATA_PER_PRDT 0x400000
|
||||
|
||||
#define AHCI_FIS_REGISTER_H2D 0x27 //Register FIS - Host to Device
|
||||
#define AHCI_FIS_REGISTER_H2D 0x27 // Register FIS - Host to Device
|
||||
#define AHCI_FIS_REGISTER_H2D_LENGTH 20
|
||||
#define AHCI_FIS_REGISTER_D2H 0x34 //Register FIS - Device to Host
|
||||
#define AHCI_FIS_PIO_SETUP 0x5F //PIO Setup FIS - Device to Host
|
||||
#define AHCI_FIS_REGISTER_D2H 0x34 // Register FIS - Device to Host
|
||||
#define AHCI_FIS_PIO_SETUP 0x5F // PIO Setup FIS - Device to Host
|
||||
|
||||
#define AHCI_D2H_FIS_OFFSET 0x40
|
||||
#define AHCI_PIO_FIS_OFFSET 0x20
|
||||
@ -170,19 +170,19 @@ typedef struct {
|
||||
// The entry Data structure is listed at the following.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 AhciCmdCfl:5; //Command FIS Length
|
||||
UINT32 AhciCmdA:1; //ATAPI
|
||||
UINT32 AhciCmdW:1; //Write
|
||||
UINT32 AhciCmdP:1; //Prefetchable
|
||||
UINT32 AhciCmdR:1; //Reset
|
||||
UINT32 AhciCmdB:1; //BIST
|
||||
UINT32 AhciCmdC:1; //Clear Busy upon R_OK
|
||||
UINT32 AhciCmdRsvd:1;
|
||||
UINT32 AhciCmdPmp:4; //Port Multiplier Port
|
||||
UINT32 AhciCmdPrdtl:16; //Physical Region Descriptor Table Length
|
||||
UINT32 AhciCmdPrdbc; //Physical Region Descriptor Byte Count
|
||||
UINT32 AhciCmdCtba; //Command Table Descriptor Base Address
|
||||
UINT32 AhciCmdCtbau; //Command Table Descriptor Base Address Upper 32-BITs
|
||||
UINT32 AhciCmdCfl : 5; // Command FIS Length
|
||||
UINT32 AhciCmdA : 1; // ATAPI
|
||||
UINT32 AhciCmdW : 1; // Write
|
||||
UINT32 AhciCmdP : 1; // Prefetchable
|
||||
UINT32 AhciCmdR : 1; // Reset
|
||||
UINT32 AhciCmdB : 1; // BIST
|
||||
UINT32 AhciCmdC : 1; // Clear Busy upon R_OK
|
||||
UINT32 AhciCmdRsvd : 1;
|
||||
UINT32 AhciCmdPmp : 4; // Port Multiplier Port
|
||||
UINT32 AhciCmdPrdtl : 16; // Physical Region Descriptor Table Length
|
||||
UINT32 AhciCmdPrdbc; // Physical Region Descriptor Byte Count
|
||||
UINT32 AhciCmdCtba; // Command Table Descriptor Base Address
|
||||
UINT32 AhciCmdCtbau; // Command Table Descriptor Base Address Upper 32-BITs
|
||||
UINT32 AhciCmdRsvd1[4];
|
||||
} EFI_AHCI_COMMAND_LIST;
|
||||
|
||||
@ -193,11 +193,11 @@ typedef struct {
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 AhciCFisType;
|
||||
UINT8 AhciCFisPmNum:4;
|
||||
UINT8 AhciCFisRsvd:1;
|
||||
UINT8 AhciCFisRsvd1:1;
|
||||
UINT8 AhciCFisRsvd2:1;
|
||||
UINT8 AhciCFisCmdInd:1;
|
||||
UINT8 AhciCFisPmNum : 4;
|
||||
UINT8 AhciCFisRsvd : 1;
|
||||
UINT8 AhciCFisRsvd1 : 1;
|
||||
UINT8 AhciCFisRsvd2 : 1;
|
||||
UINT8 AhciCFisCmdInd : 1;
|
||||
UINT8 AhciCFisCmd;
|
||||
UINT8 AhciCFisFeature;
|
||||
UINT8 AhciCFisSecNum;
|
||||
@ -230,12 +230,12 @@ typedef struct {
|
||||
// list entry for this command slot.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 AhciPrdtDba; //Data Base Address
|
||||
UINT32 AhciPrdtDbau; //Data Base Address Upper 32-BITs
|
||||
UINT32 AhciPrdtDba; // Data Base Address
|
||||
UINT32 AhciPrdtDbau; // Data Base Address Upper 32-BITs
|
||||
UINT32 AhciPrdtRsvd;
|
||||
UINT32 AhciPrdtDbc:22; //Data Byte Count
|
||||
UINT32 AhciPrdtRsvd1:9;
|
||||
UINT32 AhciPrdtIoc:1; //Interrupt on Completion
|
||||
UINT32 AhciPrdtDbc : 22; // Data Byte Count
|
||||
UINT32 AhciPrdtRsvd1 : 9;
|
||||
UINT32 AhciPrdtIoc : 1; // Interrupt on Completion
|
||||
} EFI_AHCI_COMMAND_PRDT;
|
||||
|
||||
//
|
||||
|
@ -80,8 +80,8 @@ AccessAtaDevice (
|
||||
//
|
||||
// Ensure Lba48Bit is a valid boolean value
|
||||
//
|
||||
ASSERT ((UINTN) DeviceData->Lba48Bit < 2);
|
||||
if ((UINTN) DeviceData->Lba48Bit >= 2) {
|
||||
ASSERT ((UINTN)DeviceData->Lba48Bit < 2);
|
||||
if ((UINTN)DeviceData->Lba48Bit >= 2) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -97,16 +97,20 @@ AccessAtaDevice (
|
||||
TransferBlockNumber = NumberOfBlocks;
|
||||
NumberOfBlocks = 0;
|
||||
}
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_BLKIO, "%a: Blocking AccessAtaDevice, TransferBlockNumber = %x; StartLba = %x\n",
|
||||
__FUNCTION__, TransferBlockNumber, StartLba
|
||||
DEBUG_BLKIO,
|
||||
"%a: Blocking AccessAtaDevice, TransferBlockNumber = %x; StartLba = %x\n",
|
||||
__FUNCTION__,
|
||||
TransferBlockNumber,
|
||||
StartLba
|
||||
));
|
||||
|
||||
Status = TransferAtaDevice (
|
||||
DeviceData,
|
||||
Buffer,
|
||||
StartLba,
|
||||
(UINT32) TransferBlockNumber,
|
||||
(UINT32)TransferBlockNumber,
|
||||
FALSE // Read
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -163,6 +167,7 @@ AhciRead (
|
||||
if (StartLba > DeviceData->Media.LastBlock) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NumberOfBlocks = BufferSize / BlockSize;
|
||||
if (NumberOfBlocks - 1 > DeviceData->Media.LastBlock - StartLba) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -176,7 +181,6 @@ AhciRead (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Gets the count of block I/O devices that one specific block driver detects.
|
||||
|
||||
@ -203,7 +207,7 @@ AhciBlockIoGetDeviceNo (
|
||||
{
|
||||
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || NumberBlockDevices == NULL) {
|
||||
if ((This == NULL) || (NumberBlockDevices == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -266,7 +270,7 @@ AhciBlockIoGetMediaInfo (
|
||||
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
|
||||
PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
|
||||
|
||||
if (This == NULL || MediaInfo == NULL) {
|
||||
if ((This == NULL) || (MediaInfo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -276,9 +280,9 @@ AhciBlockIoGetMediaInfo (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
MediaInfo->DeviceType = (EFI_PEI_BLOCK_DEVICE_TYPE) EDKII_PEI_BLOCK_DEVICE_TYPE_ATA_HARD_DISK;
|
||||
MediaInfo->DeviceType = (EFI_PEI_BLOCK_DEVICE_TYPE)EDKII_PEI_BLOCK_DEVICE_TYPE_ATA_HARD_DISK;
|
||||
MediaInfo->MediaPresent = TRUE;
|
||||
MediaInfo->LastBlock = (UINTN) DeviceData->Media.LastBlock;
|
||||
MediaInfo->LastBlock = (UINTN)DeviceData->Media.LastBlock;
|
||||
MediaInfo->BlockSize = DeviceData->Media.BlockSize;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -371,7 +375,7 @@ AhciBlockIoGetDeviceNo2 (
|
||||
{
|
||||
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || NumberBlockDevices == NULL) {
|
||||
if ((This == NULL) || (NumberBlockDevices == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -434,7 +438,7 @@ AhciBlockIoGetMediaInfo2 (
|
||||
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
|
||||
PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
|
||||
|
||||
if (This == NULL || MediaInfo == NULL) {
|
||||
if ((This == NULL) || (MediaInfo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,8 @@ SearchDeviceByPort (
|
||||
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
|
||||
|
||||
if ((DeviceData->Port == Port) &&
|
||||
(DeviceData->PortMultiplier == PortMultiplierPort)) {
|
||||
(DeviceData->PortMultiplier == PortMultiplierPort))
|
||||
{
|
||||
return DeviceData;
|
||||
}
|
||||
|
||||
@ -95,8 +96,8 @@ AhciPassThruExecute (
|
||||
case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:
|
||||
Status = AhciNonDataTransfer (
|
||||
Private,
|
||||
(UINT8) Port,
|
||||
(UINT8) PortMultiplierPort,
|
||||
(UINT8)Port,
|
||||
(UINT8)PortMultiplierPort,
|
||||
FisIndex,
|
||||
Packet->Acb,
|
||||
Packet->Asb,
|
||||
@ -106,8 +107,8 @@ AhciPassThruExecute (
|
||||
case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN:
|
||||
Status = AhciPioTransfer (
|
||||
Private,
|
||||
(UINT8) Port,
|
||||
(UINT8) PortMultiplierPort,
|
||||
(UINT8)Port,
|
||||
(UINT8)PortMultiplierPort,
|
||||
FisIndex,
|
||||
TRUE,
|
||||
Packet->Acb,
|
||||
@ -120,8 +121,8 @@ AhciPassThruExecute (
|
||||
case EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT:
|
||||
Status = AhciPioTransfer (
|
||||
Private,
|
||||
(UINT8) Port,
|
||||
(UINT8) PortMultiplierPort,
|
||||
(UINT8)Port,
|
||||
(UINT8)PortMultiplierPort,
|
||||
FisIndex,
|
||||
FALSE,
|
||||
Packet->Acb,
|
||||
@ -188,7 +189,7 @@ AhciAtaPassThruPassThru (
|
||||
UINT32 MaxSectorCount;
|
||||
UINT32 BlockSize;
|
||||
|
||||
if (This == NULL || Packet == NULL) {
|
||||
if ((This == NULL) || (Packet == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -218,7 +219,8 @@ AhciAtaPassThruPassThru (
|
||||
// Convert the transfer length from sector count to byte.
|
||||
//
|
||||
if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
|
||||
(Packet->InTransferLength != 0)) {
|
||||
(Packet->InTransferLength != 0))
|
||||
{
|
||||
Packet->InTransferLength = Packet->InTransferLength * BlockSize;
|
||||
}
|
||||
|
||||
@ -226,7 +228,8 @@ AhciAtaPassThruPassThru (
|
||||
// Convert the transfer length from sector count to byte.
|
||||
//
|
||||
if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
|
||||
(Packet->OutTransferLength != 0)) {
|
||||
(Packet->OutTransferLength != 0))
|
||||
{
|
||||
Packet->OutTransferLength = Packet->OutTransferLength * BlockSize;
|
||||
}
|
||||
|
||||
@ -236,7 +239,8 @@ AhciAtaPassThruPassThru (
|
||||
// command, then no data is transferred and EFI_BAD_BUFFER_SIZE is returned.
|
||||
//
|
||||
if (((Packet->InTransferLength != 0) && (Packet->InTransferLength > MaxSectorCount * BlockSize)) ||
|
||||
((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize))) {
|
||||
((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize)))
|
||||
{
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
@ -292,7 +296,7 @@ AhciAtaPassThruGetNextPort (
|
||||
PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
|
||||
LIST_ENTRY *Node;
|
||||
|
||||
if (This == NULL || Port == NULL) {
|
||||
if ((This == NULL) || (Port == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -318,7 +322,7 @@ AhciAtaPassThruGetNextPort (
|
||||
while (!IsNull (&Private->DeviceList, Node)) {
|
||||
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
|
||||
|
||||
if (DeviceData->Port > *Port){
|
||||
if (DeviceData->Port > *Port) {
|
||||
*Port = DeviceData->Port;
|
||||
goto Exit;
|
||||
}
|
||||
@ -402,7 +406,7 @@ AhciAtaPassThruGetNextDevice (
|
||||
PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
|
||||
LIST_ENTRY *Node;
|
||||
|
||||
if (This == NULL || PortMultiplierPort == NULL) {
|
||||
if ((This == NULL) || (PortMultiplierPort == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -425,7 +429,8 @@ AhciAtaPassThruGetNextDevice (
|
||||
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
|
||||
|
||||
if ((DeviceData->Port == Port) &&
|
||||
(DeviceData->PortMultiplier > *PortMultiplierPort)){
|
||||
(DeviceData->PortMultiplier > *PortMultiplierPort))
|
||||
{
|
||||
*PortMultiplierPort = DeviceData->PortMultiplier;
|
||||
goto Exit;
|
||||
}
|
||||
@ -444,7 +449,7 @@ AhciAtaPassThruGetNextDevice (
|
||||
while (!IsNull (&Private->DeviceList, Node)) {
|
||||
DeviceData = AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS (Node);
|
||||
|
||||
if (DeviceData->Port == Port){
|
||||
if (DeviceData->Port == Port) {
|
||||
*PortMultiplierPort = DeviceData->PortMultiplier;
|
||||
goto Exit;
|
||||
}
|
||||
@ -497,7 +502,7 @@ AhciAtaPassThruGetDevicePath (
|
||||
{
|
||||
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || DevicePathLength == NULL || DevicePath == NULL) {
|
||||
if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ AhciS3GetEumeratePorts (
|
||||
}
|
||||
|
||||
DevicePathInst = S3InitDevices;
|
||||
S3InitDevices = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN) S3InitDevices + DevicePathInstLength);
|
||||
S3InitDevices = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)S3InitDevices + DevicePathInstLength);
|
||||
|
||||
if (HcDevicePathLength >= DevicePathInstLength) {
|
||||
continue;
|
||||
@ -101,25 +101,30 @@ AhciS3GetEumeratePorts (
|
||||
DevicePathInst,
|
||||
HcDevicePath,
|
||||
HcDevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)
|
||||
) == 0) {
|
||||
) == 0)
|
||||
{
|
||||
//
|
||||
// Get the port number.
|
||||
//
|
||||
while (DevicePathInst->Type != END_DEVICE_PATH_TYPE) {
|
||||
if ((DevicePathInst->Type == MESSAGING_DEVICE_PATH) &&
|
||||
(DevicePathInst->SubType == MSG_SATA_DP)) {
|
||||
SataDeviceNode = (SATA_DEVICE_PATH *) DevicePathInst;
|
||||
(DevicePathInst->SubType == MSG_SATA_DP))
|
||||
{
|
||||
SataDeviceNode = (SATA_DEVICE_PATH *)DevicePathInst;
|
||||
//
|
||||
// For now, the driver only support upto AHCI_MAX_PORTS ports and
|
||||
// devices directly connected to a HBA.
|
||||
//
|
||||
if ((SataDeviceNode->HBAPortNumber >= AHCI_MAX_PORTS) ||
|
||||
(SataDeviceNode->PortMultiplierPortNumber != 0xFFFF)) {
|
||||
(SataDeviceNode->PortMultiplierPortNumber != 0xFFFF))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
*PortBitMap |= (UINT32)BIT0 << SataDeviceNode->HBAPortNumber;
|
||||
break;
|
||||
}
|
||||
|
||||
DevicePathInst = NextDevicePathNode (DevicePathInst);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ AhciStorageSecurityGetDeviceNo (
|
||||
{
|
||||
PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || NumberofDevices == NULL) {
|
||||
if ((This == NULL) || (NumberofDevices == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ AhciStorageSecurityGetDevicePath (
|
||||
PEI_AHCI_ATA_DEVICE_DATA *DeviceData;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (This == NULL || DevicePathLength == NULL || DevicePath == NULL) {
|
||||
if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ SATA_DEVICE_PATH mAhciSataDevicePathNodeTemplate = {
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_SATA_DP,
|
||||
{
|
||||
(UINT8) (sizeof (SATA_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (SATA_DEVICE_PATH)) >> 8)
|
||||
(UINT8)(sizeof (SATA_DEVICE_PATH)),
|
||||
(UINT8)((sizeof (SATA_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0x0, // HBAPortNumber
|
||||
@ -33,8 +33,8 @@ EFI_DEVICE_PATH_PROTOCOL mAhciEndDevicePathNodeTemplate = {
|
||||
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)
|
||||
}
|
||||
};
|
||||
|
||||
@ -79,7 +79,7 @@ NextDevicePathNode (
|
||||
)
|
||||
{
|
||||
ASSERT (Node != NULL);
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength (Node));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +104,7 @@ GetDevicePathInstanceSize (
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *Walker;
|
||||
|
||||
if (DevicePath == NULL || InstanceSize == NULL || EntireDevicePathEnd == NULL) {
|
||||
if ((DevicePath == NULL) || (InstanceSize == NULL) || (EntireDevicePathEnd == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ GetDevicePathInstanceSize (
|
||||
//
|
||||
// Compute the size of the device path instance
|
||||
//
|
||||
*InstanceSize = ((UINTN) Walker - (UINTN) (DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
*InstanceSize = ((UINTN)Walker - (UINTN)(DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -168,22 +168,24 @@ AhciIsHcDevicePathValid (
|
||||
|
||||
Start = DevicePath;
|
||||
while (!(DevicePath->Type == END_DEVICE_PATH_TYPE &&
|
||||
DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) {
|
||||
DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE))
|
||||
{
|
||||
DevicePath = NextDevicePathNode (DevicePath);
|
||||
|
||||
//
|
||||
// Prevent overflow and invalid zero in the 'Length' field of a device path
|
||||
// node.
|
||||
//
|
||||
if ((UINTN) DevicePath <= (UINTN) Start) {
|
||||
if ((UINTN)DevicePath <= (UINTN)Start) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Prevent touching memory beyond given DevicePathLength.
|
||||
//
|
||||
if ((UINTN) DevicePath - (UINTN) Start >
|
||||
DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
|
||||
if ((UINTN)DevicePath - (UINTN)Start >
|
||||
DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
@ -191,7 +193,7 @@ AhciIsHcDevicePathValid (
|
||||
//
|
||||
// Check if the device path and its size match each other.
|
||||
//
|
||||
Size = ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
Size = ((UINTN)DevicePath - (UINTN)Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
if (Size != DevicePathLength) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -227,7 +229,7 @@ AhciBuildDevicePath (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathWalker;
|
||||
SATA_DEVICE_PATH *SataDeviceNode;
|
||||
|
||||
if (DevicePathLength == NULL || DevicePath == NULL) {
|
||||
if ((DevicePathLength == NULL) || (DevicePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -251,7 +253,7 @@ AhciBuildDevicePath (
|
||||
//
|
||||
// Construct the SATA device node
|
||||
//
|
||||
DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *) ((UINT8 *)DevicePathWalker +
|
||||
DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePathWalker +
|
||||
(Private->DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
|
||||
CopyMem (
|
||||
DevicePathWalker,
|
||||
@ -265,7 +267,7 @@ AhciBuildDevicePath (
|
||||
//
|
||||
// Construct the end device node
|
||||
//
|
||||
DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *) ((UINT8 *)DevicePathWalker +
|
||||
DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePathWalker +
|
||||
sizeof (SATA_DEVICE_PATH));
|
||||
CopyMem (
|
||||
DevicePathWalker,
|
||||
|
@ -28,7 +28,7 @@ GetIoMmu (
|
||||
&gEdkiiIoMmuPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &IoMmu
|
||||
(VOID **)&IoMmu
|
||||
);
|
||||
if (!EFI_ERROR (Status) && (IoMmu != NULL)) {
|
||||
return IoMmu;
|
||||
@ -83,6 +83,7 @@ IoMmuMap (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
switch (Operation) {
|
||||
case EdkiiIoMmuOperationBusMasterRead:
|
||||
case EdkiiIoMmuOperationBusMasterRead64:
|
||||
@ -97,9 +98,10 @@ IoMmuMap (
|
||||
Attribute = EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE;
|
||||
break;
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = IoMmu->SetAttribute (
|
||||
IoMmu,
|
||||
*Mapping,
|
||||
@ -113,6 +115,7 @@ IoMmuMap (
|
||||
*Mapping = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -141,6 +144,7 @@ IoMmuUnmap (
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -192,7 +196,7 @@ IoMmuAllocateBuffer (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
NumberOfBytes = EFI_PAGES_TO_SIZE(Pages);
|
||||
NumberOfBytes = EFI_PAGES_TO_SIZE (Pages);
|
||||
Status = IoMmu->Map (
|
||||
IoMmu,
|
||||
EdkiiIoMmuOperationBusMasterCommonBuffer,
|
||||
@ -204,6 +208,7 @@ IoMmuAllocateBuffer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = IoMmu->SetAttribute (
|
||||
IoMmu,
|
||||
*Mapping,
|
||||
@ -221,10 +226,12 @@ IoMmuAllocateBuffer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
*HostAddress = (VOID *)(UINTN)HostPhyAddress;
|
||||
*DeviceAddress = HostPhyAddress;
|
||||
*Mapping = NULL;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -259,5 +266,6 @@ IoMmuFreeBuffer (
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ AhciReadReg (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
EFI_AHCI_BAR_INDEX,
|
||||
(UINT64) Offset,
|
||||
(UINT64)Offset,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -65,12 +65,12 @@ AhciWriteReg (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
EFI_AHCI_BAR_INDEX,
|
||||
(UINT64) Offset,
|
||||
(UINT64)Offset,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,7 +166,7 @@ AhciWaitMmioSet (
|
||||
//
|
||||
// Access PCI MMIO space to see if the value is the tested one.
|
||||
//
|
||||
Value = AhciReadReg (PciIo, (UINT32) Offset) & MaskValue;
|
||||
Value = AhciReadReg (PciIo, (UINT32)Offset) & MaskValue;
|
||||
|
||||
if (Value == TestValue) {
|
||||
return EFI_SUCCESS;
|
||||
@ -178,7 +178,6 @@ AhciWaitMmioSet (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -226,7 +225,7 @@ AhciWaitMemSet (
|
||||
// compiler from optimizing the access to the memory address
|
||||
// to only read once.
|
||||
//
|
||||
Value = *(volatile UINT32 *) (UINTN) Address;
|
||||
Value = *(volatile UINT32 *)(UINTN)Address;
|
||||
Value &= MaskValue;
|
||||
|
||||
if (Value == TestValue) {
|
||||
@ -239,7 +238,6 @@ AhciWaitMemSet (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -265,7 +263,7 @@ AhciCheckMemSet (
|
||||
{
|
||||
UINT32 Value;
|
||||
|
||||
Value = *(volatile UINT32 *) Address;
|
||||
Value = *(volatile UINT32 *)Address;
|
||||
Value &= MaskValue;
|
||||
|
||||
if (Value == TestValue) {
|
||||
@ -275,7 +273,6 @@ AhciCheckMemSet (
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Clear the port interrupt and error status. It will also clear
|
||||
@ -366,7 +363,6 @@ AhciDumpPortStatus (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enable the FIS running for giving port.
|
||||
|
||||
@ -436,7 +432,7 @@ AhciDisableFisReceive (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
AhciAndReg (PciIo, Offset, (UINT32)~(EFI_AHCI_PORT_CMD_FRE));
|
||||
AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_FRE));
|
||||
|
||||
return AhciWaitMmioSet (
|
||||
PciIo,
|
||||
@ -447,8 +443,6 @@ AhciDisableFisReceive (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Build the command list, command table and prepare the fis receiver.
|
||||
|
||||
@ -501,11 +495,11 @@ AhciBuildCommand (
|
||||
//
|
||||
ASSERT (PrdtNumber <= 65535);
|
||||
|
||||
Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * Port;
|
||||
Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFis) + sizeof (EFI_AHCI_RECEIVED_FIS) * Port;
|
||||
|
||||
BaseAddr = Data64.Uint64;
|
||||
|
||||
ZeroMem ((VOID *)((UINTN) BaseAddr), sizeof (EFI_AHCI_RECEIVED_FIS));
|
||||
ZeroMem ((VOID *)((UINTN)BaseAddr), sizeof (EFI_AHCI_RECEIVED_FIS));
|
||||
|
||||
ZeroMem (AhciRegisters->AhciCommandTable, sizeof (EFI_AHCI_COMMAND_TABLE));
|
||||
|
||||
@ -526,11 +520,11 @@ AhciBuildCommand (
|
||||
|
||||
AhciOrReg (PciIo, Offset, (EFI_AHCI_PORT_CMD_DLAE | EFI_AHCI_PORT_CMD_ATAPI));
|
||||
} else {
|
||||
AhciAndReg (PciIo, Offset, (UINT32)~(EFI_AHCI_PORT_CMD_DLAE | EFI_AHCI_PORT_CMD_ATAPI));
|
||||
AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_DLAE | EFI_AHCI_PORT_CMD_ATAPI));
|
||||
}
|
||||
|
||||
RemainedData = (UINTN) DataLength;
|
||||
MemAddr = (UINTN) DataPhysicalAddr;
|
||||
RemainedData = (UINTN)DataLength;
|
||||
MemAddr = (UINTN)DataPhysicalAddr;
|
||||
CommandList->AhciCmdPrdtl = PrdtNumber;
|
||||
|
||||
for (PrdtIndex = 0; PrdtIndex < PrdtNumber; PrdtIndex++) {
|
||||
@ -555,16 +549,15 @@ AhciBuildCommand (
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
(VOID *) ((UINTN) AhciRegisters->AhciCmdList + (UINTN) CommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST)),
|
||||
(VOID *)((UINTN)AhciRegisters->AhciCmdList + (UINTN)CommandSlotNumber * sizeof (EFI_AHCI_COMMAND_LIST)),
|
||||
CommandList,
|
||||
sizeof (EFI_AHCI_COMMAND_LIST)
|
||||
);
|
||||
|
||||
Data64.Uint64 = (UINT64)(UINTN) AhciRegisters->AhciCommandTablePciAddr;
|
||||
Data64.Uint64 = (UINT64)(UINTN)AhciRegisters->AhciCommandTablePciAddr;
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtba = Data64.Uint32.Lower32;
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtbau = Data64.Uint32.Upper32;
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdPmp = PortMultiplier;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -605,7 +598,7 @@ AhciBuildCommandFis (
|
||||
CmdFis->AhciCFisSecCount = AtaCommandBlock->AtaSectorCount;
|
||||
CmdFis->AhciCFisSecCountExp = AtaCommandBlock->AtaSectorCountExp;
|
||||
|
||||
CmdFis->AhciCFisDevHead = (UINT8) (AtaCommandBlock->AtaDeviceHead | 0xE0);
|
||||
CmdFis->AhciCFisDevHead = (UINT8)(AtaCommandBlock->AtaDeviceHead | 0xE0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -634,9 +627,10 @@ AhciWaitDeviceReady (
|
||||
PhyDetectDelay = 16 * 1000;
|
||||
do {
|
||||
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SERR;
|
||||
if (AhciReadReg(PciIo, Offset) != 0) {
|
||||
AhciWriteReg (PciIo, Offset, AhciReadReg(PciIo, Offset));
|
||||
if (AhciReadReg (PciIo, Offset) != 0) {
|
||||
AhciWriteReg (PciIo, Offset, AhciReadReg (PciIo, Offset));
|
||||
}
|
||||
|
||||
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
|
||||
|
||||
Data = AhciReadReg (PciIo, Offset) & EFI_AHCI_PORT_TFD_MASK;
|
||||
@ -656,7 +650,6 @@ AhciWaitDeviceReady (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset the SATA port. Algorithm follows AHCI spec 1.3.1 section 10.4.2
|
||||
|
||||
@ -681,7 +674,7 @@ AhciResetPort (
|
||||
// SW is required to keep DET set to 0x1 at least for 1 milisecond to ensure that
|
||||
// at least one COMRESET signal is sent.
|
||||
//
|
||||
MicroSecondDelay(1000);
|
||||
MicroSecondDelay (1000);
|
||||
AhciAndReg (PciIo, Offset, ~(UINT32)EFI_AHCI_PORT_SSTS_DET_MASK);
|
||||
|
||||
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
|
||||
@ -778,6 +771,7 @@ AhciCheckFisReceived (
|
||||
DEBUG ((DEBUG_ERROR, "AHCI: Error interrupt reported PxIS: %X\n", PortInterrupt));
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// For PIO setup FIS - According to SATA 2.6 spec section 11.7, D2h FIS means an error encountered.
|
||||
// But Qemu and Marvel 9230 sata controller may just receive a D2h FIS from device
|
||||
@ -786,10 +780,11 @@ AhciCheckFisReceived (
|
||||
// By this way, we can know if there is a real error happened.
|
||||
//
|
||||
if (((FisType == SataFisD2H) && ((PortInterrupt & EFI_AHCI_PORT_IS_DHRS) != 0)) ||
|
||||
((FisType == SataFisPioSetup) && (PortInterrupt & (EFI_AHCI_PORT_IS_PSS | EFI_AHCI_PORT_IS_DHRS)) != 0) ||
|
||||
((FisType == SataFisDmaSetup) && (PortInterrupt & (EFI_AHCI_PORT_IS_DSS | EFI_AHCI_PORT_IS_DHRS)) != 0)) {
|
||||
((FisType == SataFisPioSetup) && ((PortInterrupt & (EFI_AHCI_PORT_IS_PSS | EFI_AHCI_PORT_IS_DHRS)) != 0)) ||
|
||||
((FisType == SataFisDmaSetup) && ((PortInterrupt & (EFI_AHCI_PORT_IS_DSS | EFI_AHCI_PORT_IS_DHRS)) != 0)))
|
||||
{
|
||||
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_TFD;
|
||||
PortTfd = AhciReadReg (PciIo, (UINT32) Offset);
|
||||
PortTfd = AhciReadReg (PciIo, (UINT32)Offset);
|
||||
if ((PortTfd & EFI_AHCI_PORT_TFD_ERR) != 0) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
} else {
|
||||
@ -836,6 +831,7 @@ AhciWaitUntilFisReceived (
|
||||
if (Status != EFI_NOT_READY) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
@ -1017,7 +1013,7 @@ AhciPioTransfer (
|
||||
if (Read && (AtapiCommand == 0)) {
|
||||
Status = AhciWaitUntilFisReceived (PciIo, Port, Timeout, SataFisPioSetup);
|
||||
if (Status == EFI_SUCCESS) {
|
||||
PrdCount = *(volatile UINT32 *) (&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
|
||||
PrdCount = *(volatile UINT32 *)(&(AhciRegisters->AhciCmdList[0].AhciCmdPrdbc));
|
||||
if (PrdCount == DataCount) {
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
@ -1163,12 +1159,13 @@ AhciDmaTransfer (
|
||||
if (EFI_ERROR (Status) || (DataCount != MapLength)) {
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (Task != NULL) {
|
||||
Task->Map = Map;
|
||||
}
|
||||
}
|
||||
|
||||
if (Task == NULL || (Task != NULL && !Task->IsStart)) {
|
||||
if ((Task == NULL) || ((Task != NULL) && !Task->IsStart)) {
|
||||
AhciBuildCommandFis (&CFis, AtaCommandBlock);
|
||||
|
||||
ZeroMem (&CmdList, sizeof (EFI_AHCI_COMMAND_LIST));
|
||||
@ -1191,6 +1188,7 @@ AhciDmaTransfer (
|
||||
//
|
||||
MicroSecondDelay (100);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
for (Retry = 0; Retry < AHCI_COMMAND_RETRIES; Retry++) {
|
||||
AhciBuildCommand (
|
||||
@ -1218,6 +1216,7 @@ AhciDmaTransfer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Status = AhciWaitUntilFisReceived (PciIo, Port, Timeout, SataFisD2H);
|
||||
if (Status == EFI_DEVICE_ERROR) {
|
||||
DEBUG ((DEBUG_ERROR, "DMA command failed at retry: %d\n", Retry));
|
||||
@ -1257,6 +1256,7 @@ AhciDmaTransfer (
|
||||
Task->IsStart = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (Task->IsStart) {
|
||||
Status = AhciCheckFisReceived (PciIo, Port, SataFisD2H);
|
||||
if (Status == EFI_DEVICE_ERROR) {
|
||||
@ -1275,7 +1275,7 @@ AhciDmaTransfer (
|
||||
}
|
||||
|
||||
if (Status == EFI_NOT_READY) {
|
||||
if (!Task->InfiniteWait && Task->RetryTimes == 0) {
|
||||
if (!Task->InfiniteWait && (Task->RetryTimes == 0)) {
|
||||
Status = EFI_TIMEOUT;
|
||||
} else {
|
||||
Task->RetryTimes--;
|
||||
@ -1291,9 +1291,10 @@ AhciDmaTransfer (
|
||||
// EFI_NOT_READY that means the command doesn't finished, try again.), first do the
|
||||
// context cleanup, then set the packet's Asb status.
|
||||
//
|
||||
if (Task == NULL ||
|
||||
if ((Task == NULL) ||
|
||||
((Task != NULL) && (Status != EFI_NOT_READY))
|
||||
) {
|
||||
)
|
||||
{
|
||||
AhciStopCommand (
|
||||
PciIo,
|
||||
Port,
|
||||
@ -1483,7 +1484,7 @@ AhciStopCommand (
|
||||
}
|
||||
|
||||
if ((Data & EFI_AHCI_PORT_CMD_ST) != 0) {
|
||||
AhciAndReg (PciIo, Offset, (UINT32)~(EFI_AHCI_PORT_CMD_ST));
|
||||
AhciAndReg (PciIo, Offset, (UINT32) ~(EFI_AHCI_PORT_CMD_ST));
|
||||
}
|
||||
|
||||
return AhciWaitMmioSet (
|
||||
@ -1528,9 +1529,9 @@ AhciStartCommand (
|
||||
//
|
||||
// Collect AHCI controller information
|
||||
//
|
||||
Capability = AhciReadReg(PciIo, EFI_AHCI_CAPABILITY_OFFSET);
|
||||
Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
|
||||
|
||||
CmdSlotBit = (UINT32) (1 << CommandSlot);
|
||||
CmdSlotBit = (UINT32)(1 << CommandSlot);
|
||||
|
||||
AhciClearPortStatus (
|
||||
PciIo,
|
||||
@ -1588,7 +1589,6 @@ AhciStartCommand (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Do AHCI HBA reset.
|
||||
|
||||
@ -1613,7 +1613,7 @@ AhciReset (
|
||||
//
|
||||
// Make sure that GHC.AE bit is set before accessing any AHCI registers.
|
||||
//
|
||||
Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
|
||||
Value = AhciReadReg (PciIo, EFI_AHCI_GHC_OFFSET);
|
||||
|
||||
if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
|
||||
AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
|
||||
@ -1621,10 +1621,10 @@ AhciReset (
|
||||
|
||||
AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_RESET);
|
||||
|
||||
Delay = DivU64x32(Timeout, 1000) + 1;
|
||||
Delay = DivU64x32 (Timeout, 1000) + 1;
|
||||
|
||||
do {
|
||||
Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
|
||||
Value = AhciReadReg (PciIo, EFI_AHCI_GHC_OFFSET);
|
||||
|
||||
if ((Value & EFI_AHCI_GHC_RESET) == 0) {
|
||||
break;
|
||||
@ -1633,7 +1633,7 @@ AhciReset (
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
MicroSecondDelay(100);
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
} while (Delay > 0);
|
||||
@ -1713,7 +1713,7 @@ AhciAtaSmartReturnStatusCheck (
|
||||
|
||||
FisBaseAddr = (UINTN)AhciRegisters->AhciRFis + Port * sizeof (EFI_AHCI_RECEIVED_FIS);
|
||||
|
||||
Value = *(UINT32 *) (FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET);
|
||||
Value = *(UINT32 *)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET);
|
||||
|
||||
if ((Value & EFI_AHCI_FIS_TYPE_MASK) == EFI_AHCI_FIS_REGISTER_D2H) {
|
||||
LBAMid = ((UINT8 *)(UINTN)(FisBaseAddr + EFI_AHCI_D2H_FIS_OFFSET))[5];
|
||||
@ -1775,8 +1775,12 @@ AhciAtaSmartSupport (
|
||||
//
|
||||
// S.M.A.R.T is not supported by the device
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, "S.M.A.R.T feature is not supported at port [%d] PortMultiplier [%d]!\n",
|
||||
Port, PortMultiplier));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"S.M.A.R.T feature is not supported at port [%d] PortMultiplier [%d]!\n",
|
||||
Port,
|
||||
PortMultiplier
|
||||
));
|
||||
REPORT_STATUS_CODE (
|
||||
EFI_ERROR_CODE | EFI_ERROR_MINOR,
|
||||
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED)
|
||||
@ -1786,7 +1790,6 @@ AhciAtaSmartSupport (
|
||||
// Check if the feature is enabled. If not, then enable S.M.A.R.T.
|
||||
//
|
||||
if ((IdentifyData->AtaData.command_set_feature_enb_85 & 0x0001) != 0x0001) {
|
||||
|
||||
REPORT_STATUS_CODE (
|
||||
EFI_PROGRESS_CODE,
|
||||
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLE)
|
||||
@ -1815,7 +1818,6 @@ AhciAtaSmartSupport (
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// Send S.M.A.R.T AutoSave command to device
|
||||
@ -1851,11 +1853,15 @@ AhciAtaSmartSupport (
|
||||
AtaStatusBlock
|
||||
);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Enabled S.M.A.R.T feature at port [%d] PortMultiplier [%d]!\n",
|
||||
Port, PortMultiplier));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Enabled S.M.A.R.T feature at port [%d] PortMultiplier [%d]!\n",
|
||||
Port,
|
||||
PortMultiplier
|
||||
));
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1887,7 +1893,7 @@ AhciIdentify (
|
||||
EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
|
||||
EFI_ATA_STATUS_BLOCK AtaStatusBlock;
|
||||
|
||||
if (PciIo == NULL || AhciRegisters == NULL || Buffer == NULL) {
|
||||
if ((PciIo == NULL) || (AhciRegisters == NULL) || (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1945,7 +1951,7 @@ AhciIdentifyPacket (
|
||||
EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
|
||||
EFI_ATA_STATUS_BLOCK AtaStatusBlock;
|
||||
|
||||
if (PciIo == NULL || AhciRegisters == NULL) {
|
||||
if ((PciIo == NULL) || (AhciRegisters == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2011,12 +2017,12 @@ AhciDeviceSetFeature (
|
||||
ZeroMem (&AtaStatusBlock, sizeof (EFI_ATA_STATUS_BLOCK));
|
||||
|
||||
AtaCommandBlock.AtaCommand = ATA_CMD_SET_FEATURES;
|
||||
AtaCommandBlock.AtaFeatures = (UINT8) Feature;
|
||||
AtaCommandBlock.AtaFeaturesExp = (UINT8) (Feature >> 8);
|
||||
AtaCommandBlock.AtaSectorCount = (UINT8) FeatureSpecificData;
|
||||
AtaCommandBlock.AtaSectorNumber = (UINT8) (FeatureSpecificData >> 8);
|
||||
AtaCommandBlock.AtaCylinderLow = (UINT8) (FeatureSpecificData >> 16);
|
||||
AtaCommandBlock.AtaCylinderHigh = (UINT8) (FeatureSpecificData >> 24);
|
||||
AtaCommandBlock.AtaFeatures = (UINT8)Feature;
|
||||
AtaCommandBlock.AtaFeaturesExp = (UINT8)(Feature >> 8);
|
||||
AtaCommandBlock.AtaSectorCount = (UINT8)FeatureSpecificData;
|
||||
AtaCommandBlock.AtaSectorNumber = (UINT8)(FeatureSpecificData >> 8);
|
||||
AtaCommandBlock.AtaCylinderLow = (UINT8)(FeatureSpecificData >> 16);
|
||||
AtaCommandBlock.AtaCylinderHigh = (UINT8)(FeatureSpecificData >> 24);
|
||||
|
||||
Status = AhciNonDataTransfer (
|
||||
PciIo,
|
||||
@ -2066,7 +2072,7 @@ AhciPacketCommandExecute (
|
||||
EFI_ATA_STATUS_BLOCK AtaStatusBlock;
|
||||
BOOLEAN Read;
|
||||
|
||||
if (Packet == NULL || Packet->Cdb == NULL) {
|
||||
if ((Packet == NULL) || (Packet->Cdb == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2081,8 +2087,8 @@ AhciPacketCommandExecute (
|
||||
// set the transfersize to ATAPI_MAX_BYTE_COUNT to let the device
|
||||
// determine how many data should be transferred.
|
||||
//
|
||||
AtaCommandBlock.AtaCylinderLow = (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff);
|
||||
AtaCommandBlock.AtaCylinderHigh = (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8);
|
||||
AtaCommandBlock.AtaCylinderLow = (UINT8)(ATAPI_MAX_BYTE_COUNT & 0x00ff);
|
||||
AtaCommandBlock.AtaCylinderHigh = (UINT8)(ATAPI_MAX_BYTE_COUNT >> 8);
|
||||
|
||||
if (Packet->DataDirection == EFI_EXT_SCSI_DATA_DIRECTION_READ) {
|
||||
Buffer = Packet->InDataBuffer;
|
||||
@ -2124,6 +2130,7 @@ AhciPacketCommandExecute (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -2161,18 +2168,18 @@ AhciCreateTransferDescriptor (
|
||||
//
|
||||
// Collect AHCI controller information
|
||||
//
|
||||
Capability = AhciReadReg(PciIo, EFI_AHCI_CAPABILITY_OFFSET);
|
||||
Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
|
||||
//
|
||||
// Get the number of command slots per port supported by this HBA.
|
||||
//
|
||||
MaxCommandSlotNumber = (UINT8) (((Capability & 0x1F00) >> 8) + 1);
|
||||
Support64Bit = (BOOLEAN) (((Capability & BIT31) != 0) ? TRUE : FALSE);
|
||||
MaxCommandSlotNumber = (UINT8)(((Capability & 0x1F00) >> 8) + 1);
|
||||
Support64Bit = (BOOLEAN)(((Capability & BIT31) != 0) ? TRUE : FALSE);
|
||||
|
||||
PortImplementBitMap = AhciReadReg(PciIo, EFI_AHCI_PI_OFFSET);
|
||||
PortImplementBitMap = AhciReadReg (PciIo, EFI_AHCI_PI_OFFSET);
|
||||
//
|
||||
// Get the highest bit of implemented ports which decides how many bytes are allocated for received FIS.
|
||||
//
|
||||
MaxPortNumber = (UINT8)(UINTN)(HighBitSet32(PortImplementBitMap) + 1);
|
||||
MaxPortNumber = (UINT8)(UINTN)(HighBitSet32 (PortImplementBitMap) + 1);
|
||||
if (MaxPortNumber == 0) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -2182,7 +2189,7 @@ AhciCreateTransferDescriptor (
|
||||
PciIo,
|
||||
AllocateAnyPages,
|
||||
EfiBootServicesData,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) MaxReceiveFisSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)MaxReceiveFisSize),
|
||||
&Buffer,
|
||||
0
|
||||
);
|
||||
@ -2221,6 +2228,7 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Error5;
|
||||
}
|
||||
|
||||
AhciRegisters->AhciRFisPciAddr = (EFI_AHCI_RECEIVED_FIS *)(UINTN)AhciRFisPciAddr;
|
||||
|
||||
//
|
||||
@ -2233,7 +2241,7 @@ AhciCreateTransferDescriptor (
|
||||
PciIo,
|
||||
AllocateAnyPages,
|
||||
EfiBootServicesData,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) MaxCommandListSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)MaxCommandListSize),
|
||||
&Buffer,
|
||||
0
|
||||
);
|
||||
@ -2276,6 +2284,7 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Error3;
|
||||
}
|
||||
|
||||
AhciRegisters->AhciCmdListPciAddr = (EFI_AHCI_COMMAND_LIST *)(UINTN)AhciCmdListPciAddr;
|
||||
|
||||
//
|
||||
@ -2289,7 +2298,7 @@ AhciCreateTransferDescriptor (
|
||||
PciIo,
|
||||
AllocateAnyPages,
|
||||
EfiBootServicesData,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) MaxCommandTableSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)MaxCommandTableSize),
|
||||
&Buffer,
|
||||
0
|
||||
);
|
||||
@ -2332,6 +2341,7 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Error1;
|
||||
}
|
||||
|
||||
AhciRegisters->AhciCommandTablePciAddr = (EFI_AHCI_COMMAND_TABLE *)(UINTN)AhciCommandTablePciAddr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -2346,7 +2356,7 @@ Error1:
|
||||
Error2:
|
||||
PciIo->FreeBuffer (
|
||||
PciIo,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) MaxCommandTableSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)MaxCommandTableSize),
|
||||
AhciRegisters->AhciCommandTable
|
||||
);
|
||||
Error3:
|
||||
@ -2357,7 +2367,7 @@ Error3:
|
||||
Error4:
|
||||
PciIo->FreeBuffer (
|
||||
PciIo,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) MaxCommandListSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)MaxCommandListSize),
|
||||
AhciRegisters->AhciCmdList
|
||||
);
|
||||
Error5:
|
||||
@ -2368,7 +2378,7 @@ Error5:
|
||||
Error6:
|
||||
PciIo->FreeBuffer (
|
||||
PciIo,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) MaxReceiveFisSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)MaxReceiveFisSize),
|
||||
AhciRegisters->AhciRFis
|
||||
);
|
||||
|
||||
@ -2403,7 +2413,7 @@ AhciReadLogExt (
|
||||
EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
|
||||
EFI_ATA_STATUS_BLOCK AtaStatusBlock;
|
||||
|
||||
if (PciIo == NULL || AhciRegisters == NULL || Buffer == NULL) {
|
||||
if ((PciIo == NULL) || (AhciRegisters == NULL) || (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2488,19 +2498,28 @@ AhciEnableDevSlp (
|
||||
DEBUG ((DEBUG_INFO, "Port CMD/DEVSLP = %08x / %08x\n", PortCmd, PortDevSlp));
|
||||
if (((PortDevSlp & AHCI_PORT_DEVSLP_DSP) == 0) ||
|
||||
((PortCmd & (EFI_AHCI_PORT_CMD_HPCP | EFI_AHCI_PORT_CMD_MPSP)) != 0)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Do not enable DevSlp if the device doesn't support DevSlp
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, "IDENTIFY DEVICE: [77] = %04x, [78] = %04x, [79] = %04x\n",
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"IDENTIFY DEVICE: [77] = %04x, [78] = %04x, [79] = %04x\n",
|
||||
IdentifyData->AtaData.reserved_77,
|
||||
IdentifyData->AtaData.serial_ata_features_supported, IdentifyData->AtaData.serial_ata_features_enabled));
|
||||
IdentifyData->AtaData.serial_ata_features_supported,
|
||||
IdentifyData->AtaData.serial_ata_features_enabled
|
||||
));
|
||||
if ((IdentifyData->AtaData.serial_ata_features_supported & BIT8) == 0) {
|
||||
DEBUG ((DEBUG_INFO, "DevSlp feature is not supported for device at port [%d] PortMultiplier [%d]!\n",
|
||||
Port, PortMultiplier));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"DevSlp feature is not supported for device at port [%d] PortMultiplier [%d]!\n",
|
||||
Port,
|
||||
PortMultiplier
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -2509,16 +2528,27 @@ AhciEnableDevSlp (
|
||||
//
|
||||
if ((IdentifyData->AtaData.serial_ata_features_enabled & BIT8) != 0) {
|
||||
Status = AhciDeviceSetFeature (
|
||||
PciIo, AhciRegisters, Port, 0, ATA_SUB_CMD_ENABLE_SATA_FEATURE, 0x09, ATA_ATAPI_TIMEOUT
|
||||
PciIo,
|
||||
AhciRegisters,
|
||||
Port,
|
||||
0,
|
||||
ATA_SUB_CMD_ENABLE_SATA_FEATURE,
|
||||
0x09,
|
||||
ATA_ATAPI_TIMEOUT
|
||||
);
|
||||
DEBUG ((DEBUG_INFO, "DevSlp set feature for device at port [%d] PortMultiplier [%d] - %r\n",
|
||||
Port, PortMultiplier, Status));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"DevSlp set feature for device at port [%d] PortMultiplier [%d] - %r\n",
|
||||
Port,
|
||||
PortMultiplier,
|
||||
Status
|
||||
));
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
Status = AhciReadLogExt(PciIo, AhciRegisters, Port, PortMultiplier, LogData, 0x30, 0x08);
|
||||
Status = AhciReadLogExt (PciIo, AhciRegisters, Port, PortMultiplier, LogData, 0x30, 0x08);
|
||||
|
||||
//
|
||||
// Clear PxCMD.ST and PxDEVSLP.ADSE before updating PxDEVSLP.DITO and PxDEVSLP.MDAT.
|
||||
@ -2541,8 +2571,13 @@ AhciEnableDevSlp (
|
||||
ZeroMem (&DevSlpTiming, sizeof (DevSlpTiming));
|
||||
} else {
|
||||
CopyMem (&DevSlpTiming, &LogData[48], sizeof (DevSlpTiming));
|
||||
DEBUG ((DEBUG_INFO, "DevSlpTiming: Supported(%d), Deto(%d), Madt(%d)\n",
|
||||
DevSlpTiming.Supported, DevSlpTiming.Deto, DevSlpTiming.Madt));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"DevSlpTiming: Supported(%d), Deto(%d), Madt(%d)\n",
|
||||
DevSlpTiming.Supported,
|
||||
DevSlpTiming.Deto,
|
||||
DevSlpTiming.Madt
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -2574,11 +2609,16 @@ AhciEnableDevSlp (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AhciWriteReg (PciIo, Offset + EFI_AHCI_PORT_CMD, PortCmd);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Enabled DevSlp feature at port [%d] PortMultiplier [%d], Port CMD/DEVSLP = %08x / %08x\n",
|
||||
Port, PortMultiplier, PortCmd, PortDevSlp));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Enabled DevSlp feature at port [%d] PortMultiplier [%d], Port CMD/DEVSLP = %08x / %08x\n",
|
||||
Port,
|
||||
PortMultiplier,
|
||||
PortCmd,
|
||||
PortDevSlp
|
||||
));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -2612,11 +2652,21 @@ AhciSpinUpDisk (
|
||||
// Use SET_FEATURE subcommand to spin up the device.
|
||||
//
|
||||
Status = AhciDeviceSetFeature (
|
||||
PciIo, AhciRegisters, Port, PortMultiplier,
|
||||
ATA_SUB_CMD_PUIS_SET_DEVICE_SPINUP, 0x00, ATA_SPINUP_TIMEOUT
|
||||
PciIo,
|
||||
AhciRegisters,
|
||||
Port,
|
||||
PortMultiplier,
|
||||
ATA_SUB_CMD_PUIS_SET_DEVICE_SPINUP,
|
||||
0x00,
|
||||
ATA_SPINUP_TIMEOUT
|
||||
);
|
||||
DEBUG ((DEBUG_INFO, "CMD_PUIS_SET_DEVICE_SPINUP for device at port [%d] PortMultiplier [%d] - %r!\n",
|
||||
Port, PortMultiplier, Status));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"CMD_PUIS_SET_DEVICE_SPINUP for device at port [%d] PortMultiplier [%d] - %r!\n",
|
||||
Port,
|
||||
PortMultiplier,
|
||||
Status
|
||||
));
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -2649,8 +2699,13 @@ AhciSpinUpDisk (
|
||||
ATA_SPINUP_TIMEOUT,
|
||||
NULL
|
||||
);
|
||||
DEBUG ((DEBUG_INFO, "Read LBA 0 for device at port [%d] PortMultiplier [%d] - %r!\n",
|
||||
Port, PortMultiplier, Status));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Read LBA 0 for device at port [%d] PortMultiplier [%d] - %r!\n",
|
||||
Port,
|
||||
PortMultiplier,
|
||||
Status
|
||||
));
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -2662,14 +2717,24 @@ AhciSpinUpDisk (
|
||||
ZeroMem (IdentifyData, sizeof (*IdentifyData));
|
||||
Status = AhciIdentify (PciIo, AhciRegisters, Port, PortMultiplier, IdentifyData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Read IDD failed for device at port [%d] PortMultiplier [%d] - %r!\n",
|
||||
Port, PortMultiplier, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"Read IDD failed for device at port [%d] PortMultiplier [%d] - %r!\n",
|
||||
Port,
|
||||
PortMultiplier,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
|
||||
IdentifyData->AtaData.config, IdentifyData->AtaData.specific_config,
|
||||
IdentifyData->AtaData.command_set_supported_83, IdentifyData->AtaData.command_set_feature_enb_86));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
|
||||
IdentifyData->AtaData.config,
|
||||
IdentifyData->AtaData.specific_config,
|
||||
IdentifyData->AtaData.command_set_supported_83,
|
||||
IdentifyData->AtaData.command_set_feature_enb_86
|
||||
));
|
||||
//
|
||||
// Check if IDD is incomplete
|
||||
//
|
||||
@ -2705,10 +2770,17 @@ AhciPuisEnable (
|
||||
} else if (mAtaAtapiPolicy->PuisEnable == 1) {
|
||||
Status = AhciDeviceSetFeature (PciIo, AhciRegisters, Port, PortMultiplier, ATA_SUB_CMD_ENABLE_PUIS, 0x00, ATA_ATAPI_TIMEOUT);
|
||||
}
|
||||
DEBUG ((DEBUG_INFO, "%a PUIS feature at port [%d] PortMultiplier [%d] - %r!\n",
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a PUIS feature at port [%d] PortMultiplier [%d] - %r!\n",
|
||||
(mAtaAtapiPolicy->PuisEnable == 0) ? "Disable" : (
|
||||
(mAtaAtapiPolicy->PuisEnable == 1) ? "Enable" : "Skip"
|
||||
), Port, PortMultiplier, Status));
|
||||
),
|
||||
Port,
|
||||
PortMultiplier,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -2767,7 +2839,7 @@ AhciModeInitialization (
|
||||
//
|
||||
// Make sure that GHC.AE bit is set before accessing any AHCI registers.
|
||||
//
|
||||
Value = AhciReadReg(PciIo, EFI_AHCI_GHC_OFFSET);
|
||||
Value = AhciReadReg (PciIo, EFI_AHCI_GHC_OFFSET);
|
||||
|
||||
if ((Value & EFI_AHCI_GHC_ENABLE) == 0) {
|
||||
AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
|
||||
@ -2785,22 +2857,24 @@ AhciModeInitialization (
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN,
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"AhciModeInitialization: failed to enable 64-bit DMA on 64-bit capable controller (%r)\n",
|
||||
Status));
|
||||
Status
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Get the number of command slots per port supported by this HBA.
|
||||
//
|
||||
MaxPortNumber = (UINT8) ((Capability & 0x1F) + 1);
|
||||
MaxPortNumber = (UINT8)((Capability & 0x1F) + 1);
|
||||
|
||||
//
|
||||
// Get the bit map of those ports exposed by this HBA.
|
||||
// It indicates which ports that the HBA supports are available for software to use.
|
||||
//
|
||||
PortImplementBitMap = AhciReadReg(PciIo, EFI_AHCI_PI_OFFSET);
|
||||
PortImplementBitMap = AhciReadReg (PciIo, EFI_AHCI_PI_OFFSET);
|
||||
|
||||
AhciRegisters = &Instance->AhciRegisters;
|
||||
Status = AhciCreateTransferDescriptor (PciIo, AhciRegisters);
|
||||
@ -2809,7 +2883,7 @@ AhciModeInitialization (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
for (Port = 0; Port < EFI_AHCI_MAX_PORTS; Port ++) {
|
||||
for (Port = 0; Port < EFI_AHCI_MAX_PORTS; Port++) {
|
||||
if ((PortImplementBitMap & (((UINT32)BIT0) << Port)) != 0) {
|
||||
//
|
||||
// According to AHCI spec, MaxPortNumber should be equal or greater than the number of implemented ports.
|
||||
@ -2827,13 +2901,13 @@ AhciModeInitialization (
|
||||
//
|
||||
// Initialize FIS Base Address Register and Command List Base Address Register for use.
|
||||
//
|
||||
Data64.Uint64 = (UINTN) (AhciRegisters->AhciRFisPciAddr) + sizeof (EFI_AHCI_RECEIVED_FIS) * Port;
|
||||
Data64.Uint64 = (UINTN)(AhciRegisters->AhciRFisPciAddr) + sizeof (EFI_AHCI_RECEIVED_FIS) * Port;
|
||||
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_FB;
|
||||
AhciWriteReg (PciIo, Offset, Data64.Uint32.Lower32);
|
||||
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_FBU;
|
||||
AhciWriteReg (PciIo, Offset, Data64.Uint32.Upper32);
|
||||
|
||||
Data64.Uint64 = (UINTN) (AhciRegisters->AhciCmdListPciAddr);
|
||||
Data64.Uint64 = (UINTN)(AhciRegisters->AhciCmdListPciAddr);
|
||||
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CLB;
|
||||
AhciWriteReg (PciIo, Offset, Data64.Uint32.Lower32);
|
||||
Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_CLBU;
|
||||
@ -2910,7 +2984,7 @@ AhciModeInitialization (
|
||||
Offset,
|
||||
0x0000FFFF,
|
||||
0x00000101,
|
||||
EFI_TIMER_PERIOD_SECONDS(16)
|
||||
EFI_TIMER_PERIOD_SECONDS (16)
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
@ -2934,9 +3008,12 @@ AhciModeInitialization (
|
||||
}
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO, "IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
|
||||
Buffer.AtaData.config, Buffer.AtaData.specific_config,
|
||||
Buffer.AtaData.command_set_supported_83, Buffer.AtaData.command_set_feature_enb_86
|
||||
DEBUG_INFO,
|
||||
"IDENTIFY DEVICE: [0] = %016x, [2] = %016x, [83] = %016x, [86] = %016x\n",
|
||||
Buffer.AtaData.config,
|
||||
Buffer.AtaData.specific_config,
|
||||
Buffer.AtaData.command_set_supported_83,
|
||||
Buffer.AtaData.command_set_feature_enb_86
|
||||
));
|
||||
if ((Buffer.AtaData.config & BIT2) != 0) {
|
||||
//
|
||||
@ -2959,8 +3036,14 @@ AhciModeInitialization (
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
DEBUG ((DEBUG_INFO, "port [%d] port multitplier [%d] has a [%a]\n",
|
||||
Port, 0, DeviceType == EfiIdeCdrom ? "cdrom" : "harddisk"));
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"port [%d] port multitplier [%d] has a [%a]\n",
|
||||
Port,
|
||||
0,
|
||||
DeviceType == EfiIdeCdrom ? "cdrom" : "harddisk"
|
||||
));
|
||||
|
||||
//
|
||||
// If the device is a hard disk, then try to enable S.M.A.R.T feature
|
||||
@ -3004,7 +3087,7 @@ AhciModeInitialization (
|
||||
TransferMode.ModeCategory = EFI_ATA_MODE_FLOW_PIO;
|
||||
}
|
||||
|
||||
TransferMode.ModeNumber = (UINT8) (SupportedModes->PioMode.Mode);
|
||||
TransferMode.ModeNumber = (UINT8)(SupportedModes->PioMode.Mode);
|
||||
|
||||
//
|
||||
// Set supported DMA mode on this IDE device. Note that UDMA & MDMA can't
|
||||
@ -3014,10 +3097,10 @@ AhciModeInitialization (
|
||||
//
|
||||
if (SupportedModes->UdmaMode.Valid) {
|
||||
TransferMode.ModeCategory = EFI_ATA_MODE_UDMA;
|
||||
TransferMode.ModeNumber = (UINT8) (SupportedModes->UdmaMode.Mode);
|
||||
TransferMode.ModeNumber = (UINT8)(SupportedModes->UdmaMode.Mode);
|
||||
} else if (SupportedModes->MultiWordDmaMode.Valid) {
|
||||
TransferMode.ModeCategory = EFI_ATA_MODE_MDMA;
|
||||
TransferMode.ModeNumber = (UINT8) SupportedModes->MultiWordDmaMode.Mode;
|
||||
TransferMode.ModeNumber = (UINT8)SupportedModes->MultiWordDmaMode.Mode;
|
||||
}
|
||||
|
||||
Status = AhciDeviceSetFeature (PciIo, AhciRegisters, Port, 0, 0x03, (UINT32)(*(UINT8 *)&TransferMode), ATA_ATAPI_TIMEOUT);
|
||||
|
@ -5,6 +5,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __ATA_HC_AHCI_MODE_H__
|
||||
#define __ATA_HC_AHCI_MODE_H__
|
||||
|
||||
@ -61,20 +62,20 @@ typedef union {
|
||||
//
|
||||
#define EFI_AHCI_MAX_DATA_PER_PRDT 0x400000
|
||||
|
||||
#define EFI_AHCI_FIS_REGISTER_H2D 0x27 //Register FIS - Host to Device
|
||||
#define EFI_AHCI_FIS_REGISTER_H2D 0x27 // Register FIS - Host to Device
|
||||
#define EFI_AHCI_FIS_REGISTER_H2D_LENGTH 20
|
||||
#define EFI_AHCI_FIS_REGISTER_D2H 0x34 //Register FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_REGISTER_D2H 0x34 // Register FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_REGISTER_D2H_LENGTH 20
|
||||
#define EFI_AHCI_FIS_DMA_ACTIVATE 0x39 //DMA Activate FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_DMA_ACTIVATE 0x39 // DMA Activate FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_DMA_ACTIVATE_LENGTH 4
|
||||
#define EFI_AHCI_FIS_DMA_SETUP 0x41 //DMA Setup FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_DMA_SETUP 0x41 // DMA Setup FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_DMA_SETUP_LENGTH 28
|
||||
#define EFI_AHCI_FIS_DATA 0x46 //Data FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_BIST 0x58 //BIST Activate FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_DATA 0x46 // Data FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_BIST 0x58 // BIST Activate FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_BIST_LENGTH 12
|
||||
#define EFI_AHCI_FIS_PIO_SETUP 0x5F //PIO Setup FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_PIO_SETUP 0x5F // PIO Setup FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_PIO_SETUP_LENGTH 20
|
||||
#define EFI_AHCI_FIS_SET_DEVICE 0xA1 //Set Device Bits FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_SET_DEVICE 0xA1 // Set Device Bits FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_SET_DEVICE_LENGTH 8
|
||||
|
||||
#define EFI_AHCI_D2H_FIS_OFFSET 0x40
|
||||
@ -200,19 +201,19 @@ typedef union {
|
||||
// The entry data structure is listed at the following.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 AhciCmdCfl:5; //Command FIS Length
|
||||
UINT32 AhciCmdA:1; //ATAPI
|
||||
UINT32 AhciCmdW:1; //Write
|
||||
UINT32 AhciCmdP:1; //Prefetchable
|
||||
UINT32 AhciCmdR:1; //Reset
|
||||
UINT32 AhciCmdB:1; //BIST
|
||||
UINT32 AhciCmdC:1; //Clear Busy upon R_OK
|
||||
UINT32 AhciCmdRsvd:1;
|
||||
UINT32 AhciCmdPmp:4; //Port Multiplier Port
|
||||
UINT32 AhciCmdPrdtl:16; //Physical Region Descriptor Table Length
|
||||
UINT32 AhciCmdPrdbc; //Physical Region Descriptor Byte Count
|
||||
UINT32 AhciCmdCtba; //Command Table Descriptor Base Address
|
||||
UINT32 AhciCmdCtbau; //Command Table Descriptor Base Address Upper 32-BITs
|
||||
UINT32 AhciCmdCfl : 5; // Command FIS Length
|
||||
UINT32 AhciCmdA : 1; // ATAPI
|
||||
UINT32 AhciCmdW : 1; // Write
|
||||
UINT32 AhciCmdP : 1; // Prefetchable
|
||||
UINT32 AhciCmdR : 1; // Reset
|
||||
UINT32 AhciCmdB : 1; // BIST
|
||||
UINT32 AhciCmdC : 1; // Clear Busy upon R_OK
|
||||
UINT32 AhciCmdRsvd : 1;
|
||||
UINT32 AhciCmdPmp : 4; // Port Multiplier Port
|
||||
UINT32 AhciCmdPrdtl : 16; // Physical Region Descriptor Table Length
|
||||
UINT32 AhciCmdPrdbc; // Physical Region Descriptor Byte Count
|
||||
UINT32 AhciCmdCtba; // Command Table Descriptor Base Address
|
||||
UINT32 AhciCmdCtbau; // Command Table Descriptor Base Address Upper 32-BITs
|
||||
UINT32 AhciCmdRsvd1[4];
|
||||
} EFI_AHCI_COMMAND_LIST;
|
||||
|
||||
@ -223,11 +224,11 @@ typedef struct {
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 AhciCFisType;
|
||||
UINT8 AhciCFisPmNum:4;
|
||||
UINT8 AhciCFisRsvd:1;
|
||||
UINT8 AhciCFisRsvd1:1;
|
||||
UINT8 AhciCFisRsvd2:1;
|
||||
UINT8 AhciCFisCmdInd:1;
|
||||
UINT8 AhciCFisPmNum : 4;
|
||||
UINT8 AhciCFisRsvd : 1;
|
||||
UINT8 AhciCFisRsvd1 : 1;
|
||||
UINT8 AhciCFisRsvd2 : 1;
|
||||
UINT8 AhciCFisCmdInd : 1;
|
||||
UINT8 AhciCFisCmd;
|
||||
UINT8 AhciCFisFeature;
|
||||
UINT8 AhciCFisSecNum;
|
||||
@ -266,12 +267,12 @@ typedef struct {
|
||||
// list entry for this command slot.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 AhciPrdtDba; //Data Base Address
|
||||
UINT32 AhciPrdtDbau; //Data Base Address Upper 32-BITs
|
||||
UINT32 AhciPrdtDba; // Data Base Address
|
||||
UINT32 AhciPrdtDbau; // Data Base Address Upper 32-BITs
|
||||
UINT32 AhciPrdtRsvd;
|
||||
UINT32 AhciPrdtDbc:22; //Data Byte Count
|
||||
UINT32 AhciPrdtRsvd1:9;
|
||||
UINT32 AhciPrdtIoc:1; //Interrupt on Completion
|
||||
UINT32 AhciPrdtDbc : 22; // Data Byte Count
|
||||
UINT32 AhciPrdtRsvd1 : 9;
|
||||
UINT32 AhciPrdtIoc : 1; // Interrupt on Completion
|
||||
} EFI_AHCI_COMMAND_PRDT;
|
||||
|
||||
//
|
||||
@ -393,4 +394,3 @@ AhciStopCommand (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -78,8 +78,8 @@ ATA_ATAPI_PASS_THRU_INSTANCE gAtaAtapiPassThruInstanceTemplate = {
|
||||
},
|
||||
EfiAtaUnknownMode, // Work Mode
|
||||
{ // IdeRegisters
|
||||
{0},
|
||||
{0}
|
||||
{ 0 },
|
||||
{ 0 }
|
||||
},
|
||||
{ // AhciRegisters
|
||||
0
|
||||
@ -106,8 +106,8 @@ ATAPI_DEVICE_PATH mAtapiDevicePathTemplate = {
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_ATAPI_DP,
|
||||
{
|
||||
(UINT8) (sizeof (ATAPI_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (ATAPI_DEVICE_PATH)) >> 8)
|
||||
(UINT8)(sizeof (ATAPI_DEVICE_PATH)),
|
||||
(UINT8)((sizeof (ATAPI_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0,
|
||||
@ -120,8 +120,8 @@ SATA_DEVICE_PATH mSataDevicePathTemplate = {
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_SATA_DP,
|
||||
{
|
||||
(UINT8) (sizeof (SATA_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (SATA_DEVICE_PATH)) >> 8)
|
||||
(UINT8)(sizeof (SATA_DEVICE_PATH)),
|
||||
(UINT8)((sizeof (SATA_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0,
|
||||
@ -271,11 +271,12 @@ AtaPassThruPassThruExecute (
|
||||
Task
|
||||
);
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
break;
|
||||
case EfiAtaAhciMode :
|
||||
case EfiAtaAhciMode:
|
||||
if (PortMultiplierPort == 0xFFFF) {
|
||||
//
|
||||
// If there is no port multiplier, PortMultiplierPort will be 0xFFFF
|
||||
@ -284,6 +285,7 @@ AtaPassThruPassThruExecute (
|
||||
//
|
||||
PortMultiplierPort = 0;
|
||||
}
|
||||
|
||||
switch (Protocol) {
|
||||
case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:
|
||||
Status = AhciNonDataTransfer (
|
||||
@ -367,9 +369,10 @@ AtaPassThruPassThruExecute (
|
||||
Task
|
||||
);
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -392,7 +395,7 @@ VOID
|
||||
EFIAPI
|
||||
AsyncNonBlockingTransferRoutine (
|
||||
EFI_EVENT Event,
|
||||
VOID* Context
|
||||
VOID *Context
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
@ -401,7 +404,7 @@ AsyncNonBlockingTransferRoutine (
|
||||
EFI_STATUS Status;
|
||||
ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
|
||||
|
||||
Instance = (ATA_ATAPI_PASS_THRU_INSTANCE *) Context;
|
||||
Instance = (ATA_ATAPI_PASS_THRU_INSTANCE *)Context;
|
||||
EntryHeader = &Instance->NonBlockingTaskList;
|
||||
//
|
||||
// Get the Tasks from the Tasks List and execute it, until there is
|
||||
@ -544,7 +547,7 @@ AtaAtapiPassThruSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID *) &ParentDevicePath,
|
||||
(VOID *)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -555,6 +558,7 @@ AtaAtapiPassThruSupported (
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the protocol because we don't use it here
|
||||
//
|
||||
@ -568,7 +572,7 @@ AtaAtapiPassThruSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiIdeControllerInitProtocolGuid,
|
||||
(VOID **) &IdeControllerInit,
|
||||
(VOID **)&IdeControllerInit,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -597,7 +601,7 @@ AtaAtapiPassThruSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -605,6 +609,7 @@ AtaAtapiPassThruSupported (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Now further check the PCI header: Base class (offset 0x0B) and
|
||||
// Sub Class (offset 0x0A). This controller should be an ATA controller
|
||||
@ -687,7 +692,7 @@ AtaAtapiPassThruStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiIdeControllerInitProtocolGuid,
|
||||
(VOID **) &IdeControllerInit,
|
||||
(VOID **)&IdeControllerInit,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -701,7 +706,7 @@ AtaAtapiPassThruStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -765,8 +770,8 @@ AtaAtapiPassThruStart (
|
||||
Instance->OriginalPciAttributes = OriginalPciAttributes;
|
||||
Instance->AtaPassThru.Mode = &Instance->AtaPassThruMode;
|
||||
Instance->ExtScsiPassThru.Mode = &Instance->ExtScsiPassThruMode;
|
||||
InitializeListHead(&Instance->DeviceList);
|
||||
InitializeListHead(&Instance->NonBlockingTaskList);
|
||||
InitializeListHead (&Instance->DeviceList);
|
||||
InitializeListHead (&Instance->NonBlockingTaskList);
|
||||
|
||||
Instance->TimerEvent = NULL;
|
||||
|
||||
@ -799,8 +804,10 @@ AtaAtapiPassThruStart (
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Controller,
|
||||
&gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),
|
||||
&gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),
|
||||
&gEfiAtaPassThruProtocolGuid,
|
||||
&(Instance->AtaPassThru),
|
||||
&gEfiExtScsiPassThruProtocolGuid,
|
||||
&(Instance->ExtScsiPassThru),
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@ -828,6 +835,7 @@ ErrorExit:
|
||||
DestroyDeviceInfoList (Instance);
|
||||
FreePool (Instance);
|
||||
}
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -877,7 +885,7 @@ AtaAtapiPassThruStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiAtaPassThruProtocolGuid,
|
||||
(VOID **) &AtaPassThru,
|
||||
(VOID **)&AtaPassThru,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -891,8 +899,10 @@ AtaAtapiPassThruStop (
|
||||
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Controller,
|
||||
&gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),
|
||||
&gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),
|
||||
&gEfiAtaPassThruProtocolGuid,
|
||||
&(Instance->AtaPassThru),
|
||||
&gEfiExtScsiPassThruProtocolGuid,
|
||||
&(Instance->ExtScsiPassThru),
|
||||
NULL
|
||||
);
|
||||
|
||||
@ -917,6 +927,7 @@ AtaAtapiPassThruStop (
|
||||
gBS->CloseEvent (Instance->TimerEvent);
|
||||
Instance->TimerEvent = NULL;
|
||||
}
|
||||
|
||||
DestroyAsynTaskList (Instance, FALSE);
|
||||
//
|
||||
// Free allocated resource
|
||||
@ -947,7 +958,7 @@ AtaAtapiPassThruStop (
|
||||
);
|
||||
PciIo->FreeBuffer (
|
||||
PciIo,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxCommandTableSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)AhciRegisters->MaxCommandTableSize),
|
||||
AhciRegisters->AhciCommandTable
|
||||
);
|
||||
PciIo->Unmap (
|
||||
@ -956,7 +967,7 @@ AtaAtapiPassThruStop (
|
||||
);
|
||||
PciIo->FreeBuffer (
|
||||
PciIo,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxCommandListSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)AhciRegisters->MaxCommandListSize),
|
||||
AhciRegisters->AhciCmdList
|
||||
);
|
||||
PciIo->Unmap (
|
||||
@ -965,7 +976,7 @@ AtaAtapiPassThruStop (
|
||||
);
|
||||
PciIo->FreeBuffer (
|
||||
PciIo,
|
||||
EFI_SIZE_TO_PAGES ((UINTN) AhciRegisters->MaxReceiveFisSize),
|
||||
EFI_SIZE_TO_PAGES ((UINTN)AhciRegisters->MaxReceiveFisSize),
|
||||
AhciRegisters->AhciRFis
|
||||
);
|
||||
}
|
||||
@ -1022,13 +1033,15 @@ SearchDeviceInfoList (
|
||||
//
|
||||
if ((Instance->Mode == EfiAtaAhciMode) &&
|
||||
(DeviceInfo->Type == EfiIdeCdrom) &&
|
||||
(PortMultiplier == 0xFF)) {
|
||||
(PortMultiplier == 0xFF))
|
||||
{
|
||||
PortMultiplier = 0xFFFF;
|
||||
}
|
||||
|
||||
if ((DeviceInfo->Type == DeviceType) &&
|
||||
(Port == DeviceInfo->Port) &&
|
||||
(PortMultiplier == DeviceInfo->PortMultiplier)) {
|
||||
(PortMultiplier == DeviceInfo->PortMultiplier))
|
||||
{
|
||||
return Node;
|
||||
}
|
||||
|
||||
@ -1114,6 +1127,7 @@ DestroyDeviceInfoList (
|
||||
if (DeviceInfo->IdentifyData != NULL) {
|
||||
FreePool (DeviceInfo->IdentifyData);
|
||||
}
|
||||
|
||||
FreePool (DeviceInfo);
|
||||
}
|
||||
}
|
||||
@ -1145,7 +1159,8 @@ DestroyAsynTaskList (
|
||||
//
|
||||
for (Entry = (&Instance->NonBlockingTaskList)->ForwardLink;
|
||||
Entry != (&Instance->NonBlockingTaskList);
|
||||
) {
|
||||
)
|
||||
{
|
||||
DelEntry = Entry;
|
||||
Entry = Entry->ForwardLink;
|
||||
Task = ATA_NON_BLOCK_TASK_FROM_ENTRY (DelEntry);
|
||||
@ -1155,9 +1170,11 @@ DestroyAsynTaskList (
|
||||
Task->Packet->Asb->AtaStatus = 0x01;
|
||||
gBS->SignalEvent (Task->Event);
|
||||
}
|
||||
|
||||
FreePool (Task);
|
||||
}
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
}
|
||||
|
||||
@ -1196,7 +1213,7 @@ EnumerateAttachedDevice (
|
||||
ClassCode = PciData.Hdr.ClassCode[1];
|
||||
|
||||
switch (ClassCode) {
|
||||
case PCI_CLASS_MASS_STORAGE_IDE :
|
||||
case PCI_CLASS_MASS_STORAGE_IDE:
|
||||
//
|
||||
// The ATA controller is working at IDE mode
|
||||
//
|
||||
@ -1207,8 +1224,9 @@ EnumerateAttachedDevice (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
break;
|
||||
case PCI_CLASS_MASS_STORAGE_SATADPA :
|
||||
case PCI_CLASS_MASS_STORAGE_SATADPA:
|
||||
//
|
||||
// The ATA controller is working at AHCI mode
|
||||
//
|
||||
@ -1222,7 +1240,7 @@ EnumerateAttachedDevice (
|
||||
}
|
||||
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -1281,22 +1299,22 @@ AtaPassThruPassThru (
|
||||
|
||||
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->InDataBuffer, This->Mode->IoAlign)) {
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->OutDataBuffer, This->Mode->IoAlign)) {
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->Asb, This->Mode->IoAlign)) {
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->Asb, This->Mode->IoAlign)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
|
||||
|
||||
if (Node == NULL) {
|
||||
Node = SearchDeviceInfoList(Instance, Port, PortMultiplierPort, EfiIdeCdrom);
|
||||
Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeCdrom);
|
||||
if (Node == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -1327,7 +1345,7 @@ AtaPassThruPassThru (
|
||||
// Check logical block size
|
||||
//
|
||||
if ((IdentifyData->AtaData.phy_logic_sector_support & BIT12) != 0) {
|
||||
BlockSize = (UINT32) (((IdentifyData->AtaData.logic_sector_size_hi << 16) | IdentifyData->AtaData.logic_sector_size_lo) * sizeof (UINT16));
|
||||
BlockSize = (UINT32)(((IdentifyData->AtaData.logic_sector_size_hi << 16) | IdentifyData->AtaData.logic_sector_size_lo) * sizeof (UINT16));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1335,7 +1353,8 @@ AtaPassThruPassThru (
|
||||
// convert the transfer length from sector count to byte.
|
||||
//
|
||||
if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
|
||||
(Packet->InTransferLength != 0)) {
|
||||
(Packet->InTransferLength != 0))
|
||||
{
|
||||
Packet->InTransferLength = Packet->InTransferLength * BlockSize;
|
||||
}
|
||||
|
||||
@ -1343,7 +1362,8 @@ AtaPassThruPassThru (
|
||||
// convert the transfer length from sector count to byte.
|
||||
//
|
||||
if (((Packet->Length & EFI_ATA_PASS_THRU_LENGTH_BYTES) == 0) &&
|
||||
(Packet->OutTransferLength != 0)) {
|
||||
(Packet->OutTransferLength != 0))
|
||||
{
|
||||
Packet->OutTransferLength = Packet->OutTransferLength * BlockSize;
|
||||
}
|
||||
|
||||
@ -1353,7 +1373,8 @@ AtaPassThruPassThru (
|
||||
// is returned.
|
||||
//
|
||||
if (((Packet->InTransferLength != 0) && (Packet->InTransferLength > MaxSectorCount * BlockSize)) ||
|
||||
((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize))) {
|
||||
((Packet->OutTransferLength != 0) && (Packet->OutTransferLength > MaxSectorCount * BlockSize)))
|
||||
{
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
@ -1372,7 +1393,7 @@ AtaPassThruPassThru (
|
||||
Task->Packet = Packet;
|
||||
Task->Event = Event;
|
||||
Task->IsStart = FALSE;
|
||||
Task->RetryTimes = DivU64x32(Packet->Timeout, 1000) + 1;
|
||||
Task->RetryTimes = DivU64x32 (Packet->Timeout, 1000) + 1;
|
||||
if (Packet->Timeout == 0) {
|
||||
Task->InfiniteWait = TRUE;
|
||||
} else {
|
||||
@ -1468,7 +1489,8 @@ AtaPassThruGetNextPort (
|
||||
DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
|
||||
|
||||
if ((DeviceInfo->Type == EfiIdeHarddisk) &&
|
||||
(DeviceInfo->Port > *Port)){
|
||||
(DeviceInfo->Port > *Port))
|
||||
{
|
||||
*Port = DeviceInfo->Port;
|
||||
goto Exit;
|
||||
}
|
||||
@ -1571,7 +1593,8 @@ AtaPassThruGetNextDevice (
|
||||
|
||||
if ((DeviceInfo->Type == EfiIdeHarddisk) &&
|
||||
(DeviceInfo->Port == Port) &&
|
||||
(DeviceInfo->PortMultiplier > *PortMultiplierPort)){
|
||||
(DeviceInfo->PortMultiplier > *PortMultiplierPort))
|
||||
{
|
||||
*PortMultiplierPort = DeviceInfo->PortMultiplier;
|
||||
goto Exit;
|
||||
}
|
||||
@ -1590,7 +1613,8 @@ AtaPassThruGetNextDevice (
|
||||
DeviceInfo = ATA_ATAPI_DEVICE_INFO_FROM_THIS (Node);
|
||||
|
||||
if ((DeviceInfo->Type == EfiIdeHarddisk) &&
|
||||
(DeviceInfo->Port == Port)){
|
||||
(DeviceInfo->Port == Port))
|
||||
{
|
||||
*PortMultiplierPort = DeviceInfo->PortMultiplier;
|
||||
goto Exit;
|
||||
}
|
||||
@ -1669,7 +1693,7 @@ AtaPassThruBuildDevicePath (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Node = SearchDeviceInfoList(Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
|
||||
Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk);
|
||||
if (Node == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -1679,8 +1703,9 @@ AtaPassThruBuildDevicePath (
|
||||
if (DevicePathNode == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
DevicePathNode->Atapi.PrimarySecondary = (UINT8) Port;
|
||||
DevicePathNode->Atapi.SlaveMaster = (UINT8) PortMultiplierPort;
|
||||
|
||||
DevicePathNode->Atapi.PrimarySecondary = (UINT8)Port;
|
||||
DevicePathNode->Atapi.SlaveMaster = (UINT8)PortMultiplierPort;
|
||||
DevicePathNode->Atapi.Lun = 0;
|
||||
} else {
|
||||
DevicePathNode = AllocateCopyPool (sizeof (SATA_DEVICE_PATH), &mSataDevicePathTemplate);
|
||||
@ -1693,7 +1718,7 @@ AtaPassThruBuildDevicePath (
|
||||
DevicePathNode->Sata.Lun = 0;
|
||||
}
|
||||
|
||||
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DevicePathNode;
|
||||
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1752,7 +1777,7 @@ AtaPassThruGetDevice (
|
||||
//
|
||||
// Validate parameters passed in.
|
||||
//
|
||||
if (DevicePath == NULL || Port == NULL || PortMultiplierPort == NULL) {
|
||||
if ((DevicePath == NULL) || (Port == NULL) || (PortMultiplierPort == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1762,12 +1787,13 @@ AtaPassThruGetDevice (
|
||||
if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
|
||||
((DevicePath->SubType != MSG_SATA_DP) &&
|
||||
(DevicePath->SubType != MSG_ATAPI_DP)) ||
|
||||
((DevicePathNodeLength(DevicePath) != sizeof(ATAPI_DEVICE_PATH)) &&
|
||||
(DevicePathNodeLength(DevicePath) != sizeof(SATA_DEVICE_PATH)))) {
|
||||
((DevicePathNodeLength (DevicePath) != sizeof (ATAPI_DEVICE_PATH)) &&
|
||||
(DevicePathNodeLength (DevicePath) != sizeof (SATA_DEVICE_PATH))))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
DevicePathNode = (EFI_DEV_PATH *) DevicePath;
|
||||
DevicePathNode = (EFI_DEV_PATH *)DevicePath;
|
||||
|
||||
if (Instance->Mode == EfiAtaIdeMode) {
|
||||
*Port = DevicePathNode->Atapi.PrimarySecondary;
|
||||
@ -1777,7 +1803,7 @@ AtaPassThruGetDevice (
|
||||
*PortMultiplierPort = DevicePathNode->Sata.PortMultiplierPortNumber;
|
||||
}
|
||||
|
||||
Node = SearchDeviceInfoList(Instance, *Port, *PortMultiplierPort, EfiIdeHarddisk);
|
||||
Node = SearchDeviceInfoList (Instance, *Port, *PortMultiplierPort, EfiIdeHarddisk);
|
||||
|
||||
if (Node == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
@ -2004,7 +2030,8 @@ ExtScsiPassThruPassThru (
|
||||
// Don't support variable length CDB
|
||||
//
|
||||
if ((Packet->CdbLength != 6) && (Packet->CdbLength != 10) &&
|
||||
(Packet->CdbLength != 12) && (Packet->CdbLength != 16)) {
|
||||
(Packet->CdbLength != 12) && (Packet->CdbLength != 16))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2012,15 +2039,15 @@ ExtScsiPassThruPassThru (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->InDataBuffer, This->Mode->IoAlign)) {
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->OutDataBuffer, This->Mode->IoAlign)) {
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED(Packet->SenseData, This->Mode->IoAlign)) {
|
||||
if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->SenseData, This->Mode->IoAlign)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2045,7 +2072,7 @@ ExtScsiPassThruPassThru (
|
||||
Port = Target[0];
|
||||
PortMultiplier = Target[1];
|
||||
|
||||
Node = SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom);
|
||||
Node = SearchDeviceInfoList (Instance, Port, PortMultiplier, EfiIdeCdrom);
|
||||
if (Node == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -2057,7 +2084,7 @@ ExtScsiPassThruPassThru (
|
||||
// Normally it should NOT be passed down through ExtScsiPassThru protocol interface.
|
||||
// But to response EFI_DISK_INFO.Identify() request from ScsiDisk, we should handle this command.
|
||||
//
|
||||
if (*((UINT8*)Packet->Cdb) == ATA_CMD_IDENTIFY_DEVICE) {
|
||||
if (*((UINT8 *)Packet->Cdb) == ATA_CMD_IDENTIFY_DEVICE) {
|
||||
CopyMem (Packet->InDataBuffer, DeviceInfo->IdentifyData, sizeof (EFI_IDENTIFY_DATA));
|
||||
//
|
||||
// For IDENTIFY DEVICE cmd, we don't need to get sense data.
|
||||
@ -2088,9 +2115,10 @@ ExtScsiPassThruPassThru (
|
||||
//
|
||||
PortMultiplier = 0;
|
||||
}
|
||||
|
||||
Status = AhciPacketCommandExecute (Instance->PciIo, &Instance->AhciRegisters, Port, PortMultiplier, Packet);
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
break;
|
||||
}
|
||||
@ -2098,7 +2126,7 @@ ExtScsiPassThruPassThru (
|
||||
//
|
||||
// If the cmd doesn't get executed correctly, then check sense data.
|
||||
//
|
||||
if (EFI_ERROR (Status) && (Packet->SenseDataLength != 0) && (*((UINT8*)Packet->Cdb) != ATA_CMD_REQUEST_SENSE)) {
|
||||
if (EFI_ERROR (Status) && (Packet->SenseDataLength != 0) && (*((UINT8 *)Packet->Cdb) != ATA_CMD_REQUEST_SENSE)) {
|
||||
PtrSenseData = AllocateAlignedPages (EFI_SIZE_TO_PAGES (sizeof (EFI_SCSI_SENSE_DATA)), This->Mode->IoAlign);
|
||||
if (PtrSenseData == NULL) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
@ -2117,7 +2145,7 @@ ExtScsiPassThruPassThru (
|
||||
break;
|
||||
}
|
||||
|
||||
CopyMem ((UINT8*)Packet->SenseData + SenseDataLen, PtrSenseData, sizeof (EFI_SCSI_SENSE_DATA));
|
||||
CopyMem ((UINT8 *)Packet->SenseData + SenseDataLen, PtrSenseData, sizeof (EFI_SCSI_SENSE_DATA));
|
||||
SenseDataLen += sizeof (EFI_SCSI_SENSE_DATA);
|
||||
|
||||
//
|
||||
@ -2125,12 +2153,15 @@ ExtScsiPassThruPassThru (
|
||||
// skip the loop.
|
||||
//
|
||||
if ((PtrSenseData->Sense_Key == EFI_SCSI_SK_NO_SENSE) ||
|
||||
(SenseDataLen + sizeof (EFI_SCSI_SENSE_DATA) > Packet->SenseDataLength)) {
|
||||
(SenseDataLen + sizeof (EFI_SCSI_SENSE_DATA) > Packet->SenseDataLength))
|
||||
{
|
||||
SenseReq = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
FreeAlignedPages (PtrSenseData, EFI_SIZE_TO_PAGES (sizeof (EFI_SCSI_SENSE_DATA)));
|
||||
}
|
||||
|
||||
//
|
||||
// Update the SenseDataLength field to the data length received.
|
||||
//
|
||||
@ -2180,7 +2211,7 @@ ExtScsiPassThruGetNextTargetLun (
|
||||
|
||||
Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
if (Target == NULL || Lun == NULL) {
|
||||
if ((Target == NULL) || (Lun == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2191,7 +2222,7 @@ ExtScsiPassThruGetNextTargetLun (
|
||||
Target8 = *Target;
|
||||
Target16 = (UINT16 *)*Target;
|
||||
|
||||
if (CompareMem(Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
|
||||
if (CompareMem (Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
|
||||
//
|
||||
// For ATAPI device, we use 2 least significant bytes to represent the location of SCSI device.
|
||||
// So the higher bytes in Target array should be 0xFF.
|
||||
@ -2205,7 +2236,8 @@ ExtScsiPassThruGetNextTargetLun (
|
||||
// previous target id to see if it is returned by previous call.
|
||||
//
|
||||
if ((*Target16 != Instance->PreviousTargetId) ||
|
||||
(*Lun != Instance->PreviousLun)) {
|
||||
(*Lun != Instance->PreviousLun))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2225,7 +2257,8 @@ ExtScsiPassThruGetNextTargetLun (
|
||||
if ((DeviceInfo->Type == EfiIdeCdrom) &&
|
||||
((Target8[0] < DeviceInfo->Port) ||
|
||||
((Target8[0] == DeviceInfo->Port) &&
|
||||
(Target8[1] < (UINT8)DeviceInfo->PortMultiplier)))) {
|
||||
(Target8[1] < (UINT8)DeviceInfo->PortMultiplier))))
|
||||
{
|
||||
Target8[0] = (UINT8)DeviceInfo->Port;
|
||||
Target8[1] = (UINT8)DeviceInfo->PortMultiplier;
|
||||
goto Exit;
|
||||
@ -2327,7 +2360,7 @@ ExtScsiPassThruBuildDevicePath (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom) == NULL) {
|
||||
if (SearchDeviceInfoList (Instance, Port, PortMultiplier, EfiIdeCdrom) == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -2339,7 +2372,7 @@ ExtScsiPassThruBuildDevicePath (
|
||||
|
||||
DevicePathNode->Atapi.PrimarySecondary = Port;
|
||||
DevicePathNode->Atapi.SlaveMaster = PortMultiplier;
|
||||
DevicePathNode->Atapi.Lun = (UINT16) Lun;
|
||||
DevicePathNode->Atapi.Lun = (UINT16)Lun;
|
||||
} else {
|
||||
DevicePathNode = AllocateCopyPool (sizeof (SATA_DEVICE_PATH), &mSataDevicePathTemplate);
|
||||
if (DevicePathNode == NULL) {
|
||||
@ -2354,10 +2387,10 @@ ExtScsiPassThruBuildDevicePath (
|
||||
// to 0xFFFF according to the UEFI spec.
|
||||
//
|
||||
DevicePathNode->Sata.PortMultiplierPortNumber = PortMultiplier == 0xFF ? 0xFFFF : PortMultiplier;
|
||||
DevicePathNode->Sata.Lun = (UINT16) Lun;
|
||||
DevicePathNode->Sata.Lun = (UINT16)Lun;
|
||||
}
|
||||
|
||||
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DevicePathNode;
|
||||
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePathNode;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -2399,39 +2432,41 @@ ExtScsiPassThruGetTargetLun (
|
||||
//
|
||||
// Validate parameters passed in.
|
||||
//
|
||||
if (DevicePath == NULL || Target == NULL || Lun == NULL) {
|
||||
if ((DevicePath == NULL) || (Target == NULL) || (Lun == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (*Target == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether the DevicePath belongs to SCSI_DEVICE_PATH
|
||||
//
|
||||
if ((DevicePath->Type != MESSAGING_DEVICE_PATH) ||
|
||||
((DevicePath->SubType != MSG_ATAPI_DP) &&
|
||||
(DevicePath->SubType != MSG_SATA_DP)) ||
|
||||
((DevicePathNodeLength(DevicePath) != sizeof(ATAPI_DEVICE_PATH)) &&
|
||||
(DevicePathNodeLength(DevicePath) != sizeof(SATA_DEVICE_PATH)))) {
|
||||
((DevicePathNodeLength (DevicePath) != sizeof (ATAPI_DEVICE_PATH)) &&
|
||||
(DevicePathNodeLength (DevicePath) != sizeof (SATA_DEVICE_PATH))))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
SetMem (*Target, TARGET_MAX_BYTES, 0xFF);
|
||||
|
||||
DevicePathNode = (EFI_DEV_PATH *) DevicePath;
|
||||
DevicePathNode = (EFI_DEV_PATH *)DevicePath;
|
||||
|
||||
if (Instance->Mode == EfiAtaIdeMode) {
|
||||
(*Target)[0] = (UINT8) DevicePathNode->Atapi.PrimarySecondary;
|
||||
(*Target)[1] = (UINT8) DevicePathNode->Atapi.SlaveMaster;
|
||||
*Lun = (UINT8) DevicePathNode->Atapi.Lun;
|
||||
(*Target)[0] = (UINT8)DevicePathNode->Atapi.PrimarySecondary;
|
||||
(*Target)[1] = (UINT8)DevicePathNode->Atapi.SlaveMaster;
|
||||
*Lun = (UINT8)DevicePathNode->Atapi.Lun;
|
||||
} else {
|
||||
(*Target)[0] = (UINT8) DevicePathNode->Sata.HBAPortNumber;
|
||||
(*Target)[1] = (UINT8) DevicePathNode->Sata.PortMultiplierPortNumber;
|
||||
*Lun = (UINT8) DevicePathNode->Sata.Lun;
|
||||
(*Target)[0] = (UINT8)DevicePathNode->Sata.HBAPortNumber;
|
||||
(*Target)[1] = (UINT8)DevicePathNode->Sata.PortMultiplierPortNumber;
|
||||
*Lun = (UINT8)DevicePathNode->Sata.Lun;
|
||||
}
|
||||
|
||||
Node = SearchDeviceInfoList(Instance, (*Target)[0], (*Target)[1], EfiIdeCdrom);
|
||||
Node = SearchDeviceInfoList (Instance, (*Target)[0], (*Target)[1], EfiIdeCdrom);
|
||||
|
||||
if (Node == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
@ -2506,6 +2541,7 @@ ExtScsiPassThruResetTargetLun (
|
||||
if (Lun != 0) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// The layout of Target array:
|
||||
// ________________________________________________________________________
|
||||
@ -2520,7 +2556,7 @@ ExtScsiPassThruResetTargetLun (
|
||||
Port = Target[0];
|
||||
PortMultiplier = Target[1];
|
||||
|
||||
Node = SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom);
|
||||
Node = SearchDeviceInfoList (Instance, Port, PortMultiplier, EfiIdeCdrom);
|
||||
if (Node == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -2568,14 +2604,14 @@ ExtScsiPassThruGetNextTarget (
|
||||
|
||||
Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);
|
||||
|
||||
if (Target == NULL || *Target == NULL) {
|
||||
if ((Target == NULL) || (*Target == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Target8 = *Target;
|
||||
Target16 = (UINT16 *)*Target;
|
||||
|
||||
if (CompareMem(Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
|
||||
if (CompareMem (Target8, mScsiId, TARGET_MAX_BYTES) != 0) {
|
||||
//
|
||||
// For ATAPI device, we use 2 least significant bytes to represent the location of SCSI device.
|
||||
// So the higher bytes in Target array should be 0xFF.
|
||||
@ -2607,7 +2643,8 @@ ExtScsiPassThruGetNextTarget (
|
||||
if ((DeviceInfo->Type == EfiIdeCdrom) &&
|
||||
((Target8[0] < DeviceInfo->Port) ||
|
||||
((Target8[0] == DeviceInfo->Port) &&
|
||||
(Target8[1] < (UINT8)DeviceInfo->PortMultiplier)))) {
|
||||
(Target8[1] < (UINT8)DeviceInfo->PortMultiplier))))
|
||||
{
|
||||
Target8[0] = (UINT8)DeviceInfo->Port;
|
||||
Target8[1] = (UINT8)DeviceInfo->PortMultiplier;
|
||||
goto Exit;
|
||||
|
@ -5,6 +5,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __ATA_ATAPI_PASS_THRU_H__
|
||||
#define __ATA_ATAPI_PASS_THRU_H__
|
||||
|
||||
@ -532,7 +533,7 @@ VOID
|
||||
EFIAPI
|
||||
AsyncNonBlockingTransferRoutine (
|
||||
EFI_EVENT Event,
|
||||
VOID* Context
|
||||
VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
@ -1296,4 +1297,3 @@ AtaPioDataInOut (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruDriverNameTable[] = {
|
||||
{ "eng;en", L"AtaAtapiPassThru Driver" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
//
|
||||
@ -21,12 +21,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruDriverNa
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruIdeControllerNameTable[] = {
|
||||
{ "eng;en", L"IDE Controller" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaAtapiPassThruAhciControllerNameTable[] = {
|
||||
{ "eng;en", L"AHCI Controller" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
//
|
||||
@ -42,8 +42,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaAtapiPassThruComp
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaAtapiPassThruComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AtaAtapiPassThruComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) AtaAtapiPassThruComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)AtaAtapiPassThruComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)AtaAtapiPassThruComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
@ -103,7 +103,6 @@ AtaAtapiPassThruComponentNameGetDriverName (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -187,7 +186,7 @@ AtaAtapiPassThruComponentNameGetControllerName (
|
||||
VOID *Interface;
|
||||
ATA_ATAPI_PASS_THRU_INSTANCE *Instance;
|
||||
|
||||
if (Language == NULL || ControllerName == NULL) {
|
||||
if ((Language == NULL) || (ControllerName == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ IdeReadPortB (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint8,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
(UINT64) Port,
|
||||
(UINT64)Port,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -66,7 +66,7 @@ IdeWritePortB (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint8,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
(UINT64) Port,
|
||||
(UINT64)Port,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -96,7 +96,7 @@ IdeWritePortW (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint16,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
(UINT64) Port,
|
||||
(UINT64)Port,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -126,7 +126,7 @@ IdeWritePortDW (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
(UINT64) Port,
|
||||
(UINT64)Port,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -162,11 +162,10 @@ IdeWritePortWMultiple (
|
||||
PciIo,
|
||||
EfiPciIoWidthFifoUint16,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
(UINT64) Port,
|
||||
(UINT64)Port,
|
||||
Count,
|
||||
(UINT16 *) Buffer
|
||||
(UINT16 *)Buffer
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,11 +198,10 @@ IdeReadPortWMultiple (
|
||||
PciIo,
|
||||
EfiPciIoWidthFifoUint16,
|
||||
EFI_PCI_IO_PASS_THROUGH_BAR,
|
||||
(UINT64) Port,
|
||||
(UINT64)Port,
|
||||
Count,
|
||||
(UINT16 *) Buffer
|
||||
(UINT16 *)Buffer
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,6 +282,7 @@ DumpAllIdeRegisters (
|
||||
DEBUG ((DEBUG_ERROR, "CheckRegisterStatus()-- %02x : Error : Address Mark Not Found\n", StatusBlock.AtaError));
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
}
|
||||
|
||||
@ -319,6 +318,7 @@ CheckStatusRegister (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ DRQClear (
|
||||
InfiniteWait = FALSE;
|
||||
}
|
||||
|
||||
Delay = DivU64x32(Timeout, 1000) + 1;
|
||||
Delay = DivU64x32 (Timeout, 1000) + 1;
|
||||
do {
|
||||
StatusRegister = IdeReadPortB (PciIo, IdeRegisters->CmdOrStatus);
|
||||
|
||||
@ -381,11 +381,11 @@ DRQClear (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to poll for the DRQ bit clear in the Alternate
|
||||
Status Register. DRQ is cleared when the device is finished
|
||||
@ -423,7 +423,7 @@ DRQClear2 (
|
||||
InfiniteWait = FALSE;
|
||||
}
|
||||
|
||||
Delay = DivU64x32(Timeout, 1000) + 1;
|
||||
Delay = DivU64x32 (Timeout, 1000) + 1;
|
||||
do {
|
||||
AltRegister = IdeReadPortB (PciIo, IdeRegisters->AltOrDev);
|
||||
|
||||
@ -444,7 +444,6 @@ DRQClear2 (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -499,7 +498,7 @@ DRQReady (
|
||||
InfiniteWait = FALSE;
|
||||
}
|
||||
|
||||
Delay = DivU64x32(Timeout, 1000) + 1;
|
||||
Delay = DivU64x32 (Timeout, 1000) + 1;
|
||||
do {
|
||||
//
|
||||
// Read Status Register will clear interrupt
|
||||
@ -516,6 +515,7 @@ DRQReady (
|
||||
if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@ -536,6 +536,7 @@ DRQReady (
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to poll for the DRQ bit set in the Alternate Status Register.
|
||||
DRQ is set when the device is ready to transfer data. So this function is called after
|
||||
@ -583,7 +584,7 @@ DRQReady2 (
|
||||
InfiniteWait = FALSE;
|
||||
}
|
||||
|
||||
Delay = DivU64x32(Timeout, 1000) + 1;
|
||||
Delay = DivU64x32 (Timeout, 1000) + 1;
|
||||
|
||||
do {
|
||||
//
|
||||
@ -600,6 +601,7 @@ DRQReady2 (
|
||||
if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@ -621,9 +623,6 @@ DRQReady2 (
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
This function is used to poll for the BSY bit clear in the Status Register. BSY
|
||||
is clear when the device is not busy. Every command must be sent after device is not busy.
|
||||
@ -658,7 +657,7 @@ WaitForBSYClear (
|
||||
InfiniteWait = FALSE;
|
||||
}
|
||||
|
||||
Delay = DivU64x32(Timeout, 1000) + 1;
|
||||
Delay = DivU64x32 (Timeout, 1000) + 1;
|
||||
do {
|
||||
StatusRegister = IdeReadPortB (PciIo, IdeRegisters->CmdOrStatus);
|
||||
|
||||
@ -672,13 +671,11 @@ WaitForBSYClear (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get IDE i/o port registers' base addresses by mode.
|
||||
|
||||
@ -755,7 +752,7 @@ GetIdeRegisterIoAddr (
|
||||
return Status;
|
||||
}
|
||||
|
||||
BusMasterBaseAddr = (UINT16) ((PciData.Device.Bar[4] & 0x0000fff0));
|
||||
BusMasterBaseAddr = (UINT16)((PciData.Device.Bar[4] & 0x0000fff0));
|
||||
|
||||
if ((PciData.Hdr.ClassCode[0] & IDE_PRIMARY_OPERATING_MODE) == 0) {
|
||||
CommandBlockBaseAddr = 0x1f0;
|
||||
@ -764,26 +761,27 @@ GetIdeRegisterIoAddr (
|
||||
//
|
||||
// The BARs should be of IO type
|
||||
//
|
||||
if ((PciData.Device.Bar[0] & BIT0) == 0 ||
|
||||
(PciData.Device.Bar[1] & BIT0) == 0) {
|
||||
if (((PciData.Device.Bar[0] & BIT0) == 0) ||
|
||||
((PciData.Device.Bar[1] & BIT0) == 0))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
CommandBlockBaseAddr = (UINT16) (PciData.Device.Bar[0] & 0x0000fff8);
|
||||
ControlBlockBaseAddr = (UINT16) ((PciData.Device.Bar[1] & 0x0000fffc) + 2);
|
||||
CommandBlockBaseAddr = (UINT16)(PciData.Device.Bar[0] & 0x0000fff8);
|
||||
ControlBlockBaseAddr = (UINT16)((PciData.Device.Bar[1] & 0x0000fffc) + 2);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate IDE primary channel I/O register base address.
|
||||
//
|
||||
IdeRegisters[EfiIdePrimary].Data = CommandBlockBaseAddr;
|
||||
IdeRegisters[EfiIdePrimary].ErrOrFeature = (UINT16) (CommandBlockBaseAddr + 0x01);
|
||||
IdeRegisters[EfiIdePrimary].SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
|
||||
IdeRegisters[EfiIdePrimary].SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
|
||||
IdeRegisters[EfiIdePrimary].CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
|
||||
IdeRegisters[EfiIdePrimary].CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
|
||||
IdeRegisters[EfiIdePrimary].Head = (UINT16) (CommandBlockBaseAddr + 0x06);
|
||||
IdeRegisters[EfiIdePrimary].CmdOrStatus = (UINT16) (CommandBlockBaseAddr + 0x07);
|
||||
IdeRegisters[EfiIdePrimary].ErrOrFeature = (UINT16)(CommandBlockBaseAddr + 0x01);
|
||||
IdeRegisters[EfiIdePrimary].SectorCount = (UINT16)(CommandBlockBaseAddr + 0x02);
|
||||
IdeRegisters[EfiIdePrimary].SectorNumber = (UINT16)(CommandBlockBaseAddr + 0x03);
|
||||
IdeRegisters[EfiIdePrimary].CylinderLsb = (UINT16)(CommandBlockBaseAddr + 0x04);
|
||||
IdeRegisters[EfiIdePrimary].CylinderMsb = (UINT16)(CommandBlockBaseAddr + 0x05);
|
||||
IdeRegisters[EfiIdePrimary].Head = (UINT16)(CommandBlockBaseAddr + 0x06);
|
||||
IdeRegisters[EfiIdePrimary].CmdOrStatus = (UINT16)(CommandBlockBaseAddr + 0x07);
|
||||
IdeRegisters[EfiIdePrimary].AltOrDev = ControlBlockBaseAddr;
|
||||
IdeRegisters[EfiIdePrimary].BusMasterBaseAddr = BusMasterBaseAddr;
|
||||
|
||||
@ -794,33 +792,33 @@ GetIdeRegisterIoAddr (
|
||||
//
|
||||
// The BARs should be of IO type
|
||||
//
|
||||
if ((PciData.Device.Bar[2] & BIT0) == 0 ||
|
||||
(PciData.Device.Bar[3] & BIT0) == 0) {
|
||||
if (((PciData.Device.Bar[2] & BIT0) == 0) ||
|
||||
((PciData.Device.Bar[3] & BIT0) == 0))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
CommandBlockBaseAddr = (UINT16) (PciData.Device.Bar[2] & 0x0000fff8);
|
||||
ControlBlockBaseAddr = (UINT16) ((PciData.Device.Bar[3] & 0x0000fffc) + 2);
|
||||
CommandBlockBaseAddr = (UINT16)(PciData.Device.Bar[2] & 0x0000fff8);
|
||||
ControlBlockBaseAddr = (UINT16)((PciData.Device.Bar[3] & 0x0000fffc) + 2);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate IDE secondary channel I/O register base address.
|
||||
//
|
||||
IdeRegisters[EfiIdeSecondary].Data = CommandBlockBaseAddr;
|
||||
IdeRegisters[EfiIdeSecondary].ErrOrFeature = (UINT16) (CommandBlockBaseAddr + 0x01);
|
||||
IdeRegisters[EfiIdeSecondary].SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
|
||||
IdeRegisters[EfiIdeSecondary].SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
|
||||
IdeRegisters[EfiIdeSecondary].CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
|
||||
IdeRegisters[EfiIdeSecondary].CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
|
||||
IdeRegisters[EfiIdeSecondary].Head = (UINT16) (CommandBlockBaseAddr + 0x06);
|
||||
IdeRegisters[EfiIdeSecondary].CmdOrStatus = (UINT16) (CommandBlockBaseAddr + 0x07);
|
||||
IdeRegisters[EfiIdeSecondary].ErrOrFeature = (UINT16)(CommandBlockBaseAddr + 0x01);
|
||||
IdeRegisters[EfiIdeSecondary].SectorCount = (UINT16)(CommandBlockBaseAddr + 0x02);
|
||||
IdeRegisters[EfiIdeSecondary].SectorNumber = (UINT16)(CommandBlockBaseAddr + 0x03);
|
||||
IdeRegisters[EfiIdeSecondary].CylinderLsb = (UINT16)(CommandBlockBaseAddr + 0x04);
|
||||
IdeRegisters[EfiIdeSecondary].CylinderMsb = (UINT16)(CommandBlockBaseAddr + 0x05);
|
||||
IdeRegisters[EfiIdeSecondary].Head = (UINT16)(CommandBlockBaseAddr + 0x06);
|
||||
IdeRegisters[EfiIdeSecondary].CmdOrStatus = (UINT16)(CommandBlockBaseAddr + 0x07);
|
||||
IdeRegisters[EfiIdeSecondary].AltOrDev = ControlBlockBaseAddr;
|
||||
IdeRegisters[EfiIdeSecondary].BusMasterBaseAddr = (UINT16) (BusMasterBaseAddr + 0x8);
|
||||
IdeRegisters[EfiIdeSecondary].BusMasterBaseAddr = (UINT16)(BusMasterBaseAddr + 0x8);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send ATA Ext command into device with NON_DATA protocol.
|
||||
|
||||
@ -861,7 +859,7 @@ AtaIssueCommand (
|
||||
//
|
||||
// Select device (bit4), set LBA mode(bit6) (use 0xe0 for compatibility)
|
||||
//
|
||||
IdeWritePortB (PciIo, IdeRegisters->Head, (UINT8) (0xe0 | DeviceHead));
|
||||
IdeWritePortB (PciIo, IdeRegisters->Head, (UINT8)(0xe0 | DeviceHead));
|
||||
|
||||
//
|
||||
// set all the command parameters
|
||||
@ -963,7 +961,7 @@ AtaPioDataInOut (
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
Buffer16 = (UINT16 *) Buffer;
|
||||
Buffer16 = (UINT16 *)Buffer;
|
||||
|
||||
//
|
||||
// According to PIO data in protocol, host can perform a series of reads to
|
||||
@ -987,7 +985,7 @@ AtaPioDataInOut (
|
||||
//
|
||||
WordCount = 0;
|
||||
|
||||
while (WordCount < RShiftU64(ByteCount, 1)) {
|
||||
while (WordCount < RShiftU64 (ByteCount, 1)) {
|
||||
//
|
||||
// Poll DRQ bit set, data transfer can be performed only when DRQ is ready
|
||||
//
|
||||
@ -1000,8 +998,8 @@ AtaPioDataInOut (
|
||||
//
|
||||
// Get the byte count for one series of read
|
||||
//
|
||||
if ((WordCount + Increment) > RShiftU64(ByteCount, 1)) {
|
||||
Increment = (UINTN)(RShiftU64(ByteCount, 1) - WordCount);
|
||||
if ((WordCount + Increment) > RShiftU64 (ByteCount, 1)) {
|
||||
Increment = (UINTN)(RShiftU64 (ByteCount, 1) - WordCount);
|
||||
}
|
||||
|
||||
if (Read) {
|
||||
@ -1159,7 +1157,7 @@ AtaUdmStatusWait (
|
||||
break;
|
||||
}
|
||||
|
||||
IoPortForBmis = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
|
||||
IoPortForBmis = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
|
||||
RegisterValue = IdeReadPortB (PciIo, IoPortForBmis);
|
||||
if (((RegisterValue & BMIS_ERROR) != 0) || (Timeout == 0)) {
|
||||
DEBUG ((DEBUG_ERROR, "ATA UDMA operation fails\n"));
|
||||
@ -1171,6 +1169,7 @@ AtaUdmStatusWait (
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
@ -1213,7 +1212,7 @@ AtaUdmStatusCheck (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
IoPortForBmis = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
|
||||
IoPortForBmis = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
|
||||
RegisterValue = IdeReadPortB (PciIo, IoPortForBmis);
|
||||
|
||||
if ((RegisterValue & BMIS_ERROR) != 0) {
|
||||
@ -1329,6 +1328,7 @@ AtaUdmaInOut (
|
||||
//
|
||||
MicroSecondDelay (1000);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
//
|
||||
@ -1341,9 +1341,9 @@ AtaUdmaInOut (
|
||||
//
|
||||
// Set relevant IO Port address.
|
||||
//
|
||||
IoPortForBmic = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIC_OFFSET);
|
||||
IoPortForBmis = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
|
||||
IoPortForBmid = (UINT16) (IdeRegisters->BusMasterBaseAddr + BMID_OFFSET);
|
||||
IoPortForBmic = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMIC_OFFSET);
|
||||
IoPortForBmis = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMIS_OFFSET);
|
||||
IoPortForBmid = (UINT16)(IdeRegisters->BusMasterBaseAddr + BMID_OFFSET);
|
||||
|
||||
//
|
||||
// For Blocking mode, start the command.
|
||||
@ -1355,7 +1355,7 @@ AtaUdmaInOut (
|
||||
// Calculate the number of PRD entry.
|
||||
// Every entry in PRD table can specify a 64K memory region.
|
||||
//
|
||||
PrdTableNum = (UINTN)(RShiftU64(DataLength, 16) + 1);
|
||||
PrdTableNum = (UINTN)(RShiftU64 (DataLength, 16) + 1);
|
||||
|
||||
//
|
||||
// Make sure that the memory region of PRD table is not cross 64K boundary
|
||||
@ -1394,7 +1394,7 @@ AtaUdmaInOut (
|
||||
Status = PciIo->Map (
|
||||
PciIo,
|
||||
EfiPciIoOperationBusMasterCommonBuffer,
|
||||
(VOID*)(UINTN)BaseAddr,
|
||||
(VOID *)(UINTN)BaseAddr,
|
||||
&ByteCount,
|
||||
&BaseMapAddr,
|
||||
&PrdTableMap
|
||||
@ -1405,18 +1405,18 @@ AtaUdmaInOut (
|
||||
// it means the DMA operation may be broken into several discontinuous smaller chunks.
|
||||
// Can't handle this case.
|
||||
//
|
||||
PciIo->FreeBuffer (PciIo, RealPageCount, (VOID*)(UINTN)BaseAddr);
|
||||
PciIo->FreeBuffer (PciIo, RealPageCount, (VOID *)(UINTN)BaseAddr);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID *) ((UINTN) BaseAddr), ByteCount);
|
||||
ZeroMem ((VOID *)((UINTN)BaseAddr), ByteCount);
|
||||
|
||||
//
|
||||
// Calculate the 64K align address as PRD Table base address.
|
||||
//
|
||||
AlignmentMask = SIZE_64KB - 1;
|
||||
PrdTableBaseAddr = ((UINTN) BaseAddr + AlignmentMask) & ~AlignmentMask;
|
||||
PrdTableMapAddr = ((UINTN) BaseMapAddr + AlignmentMask) & ~AlignmentMask;
|
||||
PrdTableBaseAddr = ((UINTN)BaseAddr + AlignmentMask) & ~AlignmentMask;
|
||||
PrdTableMapAddr = ((UINTN)BaseMapAddr + AlignmentMask) & ~AlignmentMask;
|
||||
|
||||
//
|
||||
// Map the host address of DataBuffer to DMA master address.
|
||||
@ -1438,7 +1438,7 @@ AtaUdmaInOut (
|
||||
);
|
||||
if (EFI_ERROR (Status) || (ByteCount != DataLength)) {
|
||||
PciIo->Unmap (PciIo, PrdTableMap);
|
||||
PciIo->FreeBuffer (PciIo, RealPageCount, (VOID*)(UINTN)BaseAddr);
|
||||
PciIo->FreeBuffer (PciIo, RealPageCount, (VOID *)(UINTN)BaseAddr);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@ -1452,17 +1452,17 @@ AtaUdmaInOut (
|
||||
// Fill the PRD table with appropriate bus master address of data buffer and data length.
|
||||
//
|
||||
ByteRemaining = ByteCount;
|
||||
TempPrdBaseAddr = (EFI_ATA_DMA_PRD*)(UINTN)PrdTableBaseAddr;
|
||||
TempPrdBaseAddr = (EFI_ATA_DMA_PRD *)(UINTN)PrdTableBaseAddr;
|
||||
while (ByteRemaining != 0) {
|
||||
if (ByteRemaining <= 0x10000) {
|
||||
TempPrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress);
|
||||
TempPrdBaseAddr->ByteCount = (UINT16) ByteRemaining;
|
||||
TempPrdBaseAddr->RegionBaseAddr = (UINT32)((UINTN)BufferMapAddress);
|
||||
TempPrdBaseAddr->ByteCount = (UINT16)ByteRemaining;
|
||||
TempPrdBaseAddr->EndOfTable = 0x8000;
|
||||
break;
|
||||
}
|
||||
|
||||
TempPrdBaseAddr->RegionBaseAddr = (UINT32) ((UINTN) BufferMapAddress);
|
||||
TempPrdBaseAddr->ByteCount = (UINT16) 0x0;
|
||||
TempPrdBaseAddr->RegionBaseAddr = (UINT32)((UINTN)BufferMapAddress);
|
||||
TempPrdBaseAddr->ByteCount = (UINT16)0x0;
|
||||
|
||||
ByteRemaining -= 0x10000;
|
||||
BufferMapAddress += 0x10000;
|
||||
@ -1485,7 +1485,7 @@ AtaUdmaInOut (
|
||||
//
|
||||
// Read BMIS register and clear ERROR and INTR bit
|
||||
//
|
||||
RegisterValue = IdeReadPortB(PciIo, IoPortForBmis);
|
||||
RegisterValue = IdeReadPortB (PciIo, IoPortForBmis);
|
||||
RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);
|
||||
IdeWritePortB (PciIo, IoPortForBmis, RegisterValue);
|
||||
|
||||
@ -1497,18 +1497,19 @@ AtaUdmaInOut (
|
||||
//
|
||||
// Set BMIC register to identify the operation direction
|
||||
//
|
||||
RegisterValue = IdeReadPortB(PciIo, IoPortForBmic);
|
||||
RegisterValue = IdeReadPortB (PciIo, IoPortForBmic);
|
||||
if (Read) {
|
||||
RegisterValue |= BMIC_NREAD;
|
||||
} else {
|
||||
RegisterValue &= ~((UINT8) BMIC_NREAD);
|
||||
RegisterValue &= ~((UINT8)BMIC_NREAD);
|
||||
}
|
||||
|
||||
IdeWritePortB (PciIo, IoPortForBmic, RegisterValue);
|
||||
|
||||
if (Task != NULL) {
|
||||
Task->Map = BufferMap;
|
||||
Task->TableMap = PrdTableMap;
|
||||
Task->MapBaseAddress = (EFI_ATA_DMA_PRD*)(UINTN)BaseAddr;
|
||||
Task->MapBaseAddress = (EFI_ATA_DMA_PRD *)(UINTN)BaseAddr;
|
||||
Task->PageCount = RealPageCount;
|
||||
Task->IsStart = TRUE;
|
||||
}
|
||||
@ -1528,13 +1529,13 @@ AtaUdmaInOut (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Set START bit of BMIC register
|
||||
//
|
||||
RegisterValue = IdeReadPortB(PciIo, IoPortForBmic);
|
||||
RegisterValue = IdeReadPortB (PciIo, IoPortForBmic);
|
||||
RegisterValue |= BMIC_START;
|
||||
IdeWritePortB(PciIo, IoPortForBmic, RegisterValue);
|
||||
|
||||
IdeWritePortB (PciIo, IoPortForBmic, RegisterValue);
|
||||
}
|
||||
|
||||
//
|
||||
@ -1552,7 +1553,7 @@ AtaUdmaInOut (
|
||||
// out, or a error has been happened, it needs to clear the register and free
|
||||
// buffer.
|
||||
//
|
||||
if ((Task == NULL) || Status != EFI_NOT_READY) {
|
||||
if ((Task == NULL) || (Status != EFI_NOT_READY)) {
|
||||
//
|
||||
// Read BMIS register and clear ERROR and INTR bit
|
||||
//
|
||||
@ -1563,13 +1564,13 @@ AtaUdmaInOut (
|
||||
//
|
||||
// Read Status Register of IDE device to clear interrupt
|
||||
//
|
||||
RegisterValue = IdeReadPortB(PciIo, IdeRegisters->CmdOrStatus);
|
||||
RegisterValue = IdeReadPortB (PciIo, IdeRegisters->CmdOrStatus);
|
||||
|
||||
//
|
||||
// Clear START bit of BMIC register
|
||||
//
|
||||
RegisterValue = IdeReadPortB(PciIo, IoPortForBmic);
|
||||
RegisterValue &= ~((UINT8) BMIC_START);
|
||||
RegisterValue = IdeReadPortB (PciIo, IoPortForBmic);
|
||||
RegisterValue &= ~((UINT8)BMIC_START);
|
||||
IdeWritePortB (PciIo, IoPortForBmic, RegisterValue);
|
||||
|
||||
//
|
||||
@ -1582,21 +1583,20 @@ AtaUdmaInOut (
|
||||
// Stall for 10 milliseconds.
|
||||
//
|
||||
MicroSecondDelay (10000);
|
||||
|
||||
}
|
||||
|
||||
Exit:
|
||||
//
|
||||
// Free all allocated resource
|
||||
//
|
||||
if ((Task == NULL) || Status != EFI_NOT_READY) {
|
||||
if ((Task == NULL) || (Status != EFI_NOT_READY)) {
|
||||
if (Task != NULL) {
|
||||
PciIo->Unmap (PciIo, Task->TableMap);
|
||||
PciIo->FreeBuffer (PciIo, Task->PageCount, Task->MapBaseAddress);
|
||||
PciIo->Unmap (PciIo, Task->Map);
|
||||
} else {
|
||||
PciIo->Unmap (PciIo, PrdTableMap);
|
||||
PciIo->FreeBuffer (PciIo, RealPageCount, (VOID*)(UINTN)BaseAddr);
|
||||
PciIo->FreeBuffer (PciIo, RealPageCount, (VOID *)(UINTN)BaseAddr);
|
||||
PciIo->Unmap (PciIo, BufferMap);
|
||||
}
|
||||
|
||||
@ -1646,6 +1646,7 @@ AtaPacketReadPendingData (
|
||||
TempWordBuffer = IdeReadPortB (PciIo, IdeRegisters->AltOrDev);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1836,9 +1837,9 @@ AtaPacketCommandExecute (
|
||||
// set the transfersize to ATAPI_MAX_BYTE_COUNT to let the device
|
||||
// determine how many data should be transferred.
|
||||
//
|
||||
AtaCommandBlock.AtaCylinderLow = (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff);
|
||||
AtaCommandBlock.AtaCylinderHigh = (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8);
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8) (Device << 0x4);
|
||||
AtaCommandBlock.AtaCylinderLow = (UINT8)(ATAPI_MAX_BYTE_COUNT & 0x00ff);
|
||||
AtaCommandBlock.AtaCylinderHigh = (UINT8)(ATAPI_MAX_BYTE_COUNT >> 8);
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8)(Device << 0x4);
|
||||
AtaCommandBlock.AtaCommand = ATA_CMD_PACKET;
|
||||
|
||||
IdeWritePortB (PciIo, IdeRegisters->Head, (UINT8)(0xe0 | (Device << 0x4)));
|
||||
@ -1864,7 +1865,7 @@ AtaPacketCommandExecute (
|
||||
// Send out ATAPI command packet
|
||||
//
|
||||
for (Count = 0; Count < 6; Count++) {
|
||||
IdeWritePortW (PciIo, IdeRegisters->Data, *((UINT16*)PacketCommand + Count));
|
||||
IdeWritePortW (PciIo, IdeRegisters->Data, *((UINT16 *)PacketCommand + Count));
|
||||
//
|
||||
// Stall for 10 microseconds.
|
||||
//
|
||||
@ -1897,7 +1898,6 @@ AtaPacketCommandExecute (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the calculated Best transfer mode to a detected device.
|
||||
|
||||
@ -1978,7 +1978,7 @@ SetDriveParameters (
|
||||
|
||||
AtaCommandBlock.AtaCommand = ATA_CMD_INIT_DRIVE_PARAM;
|
||||
AtaCommandBlock.AtaSectorCount = DriveParameters->Sector;
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8) ((Device << 0x4) + DriveParameters->Heads);
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8)((Device << 0x4) + DriveParameters->Heads);
|
||||
|
||||
//
|
||||
// Send Init drive parameters
|
||||
@ -2043,7 +2043,7 @@ IdeAtaSmartReturnStatusCheck (
|
||||
AtaCommandBlock.AtaFeatures = ATA_SMART_RETURN_STATUS;
|
||||
AtaCommandBlock.AtaCylinderLow = ATA_CONSTANT_4F;
|
||||
AtaCommandBlock.AtaCylinderHigh = ATA_CONSTANT_C2;
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8) ((Device << 0x4) | 0xe0);
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8)((Device << 0x4) | 0xe0);
|
||||
|
||||
//
|
||||
// Send S.M.A.R.T Read Return Status command to device
|
||||
@ -2126,8 +2126,12 @@ IdeAtaSmartSupport (
|
||||
//
|
||||
// S.M.A.R.T is not supported by the device
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, "S.M.A.R.T feature is not supported at [%a] channel [%a] device!\n",
|
||||
(Channel == 1) ? "secondary" : "primary", (Device == 1) ? "slave" : "master"));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"S.M.A.R.T feature is not supported at [%a] channel [%a] device!\n",
|
||||
(Channel == 1) ? "secondary" : "primary",
|
||||
(Device == 1) ? "slave" : "master"
|
||||
));
|
||||
REPORT_STATUS_CODE (
|
||||
EFI_ERROR_CODE | EFI_ERROR_MINOR,
|
||||
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED)
|
||||
@ -2137,7 +2141,6 @@ IdeAtaSmartSupport (
|
||||
// Check if the feature is enabled. If not, then enable S.M.A.R.T.
|
||||
//
|
||||
if ((IdentifyData->AtaData.command_set_feature_enb_85 & 0x0001) != 0x0001) {
|
||||
|
||||
REPORT_STATUS_CODE (
|
||||
EFI_PROGRESS_CODE,
|
||||
(EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLE)
|
||||
@ -2149,7 +2152,7 @@ IdeAtaSmartSupport (
|
||||
AtaCommandBlock.AtaFeatures = ATA_SMART_ENABLE_OPERATION;
|
||||
AtaCommandBlock.AtaCylinderLow = ATA_CONSTANT_4F;
|
||||
AtaCommandBlock.AtaCylinderHigh = ATA_CONSTANT_C2;
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8) ((Device << 0x4) | 0xe0);
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8)((Device << 0x4) | 0xe0);
|
||||
|
||||
//
|
||||
// Send S.M.A.R.T Enable command to device
|
||||
@ -2174,7 +2177,7 @@ IdeAtaSmartSupport (
|
||||
AtaCommandBlock.AtaSectorCount = 0xF1;
|
||||
AtaCommandBlock.AtaCylinderLow = ATA_CONSTANT_4F;
|
||||
AtaCommandBlock.AtaCylinderHigh = ATA_CONSTANT_C2;
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8) ((Device << 0x4) | 0xe0);
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8)((Device << 0x4) | 0xe0);
|
||||
|
||||
Status = AtaNonDataCommandIn (
|
||||
Instance->PciIo,
|
||||
@ -2195,15 +2198,17 @@ IdeAtaSmartSupport (
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Enabled S.M.A.R.T feature at [%a] channel [%a] device!\n",
|
||||
(Channel == 1) ? "secondary" : "primary", (Device == 1) ? "slave" : "master"));
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Enabled S.M.A.R.T feature at [%a] channel [%a] device!\n",
|
||||
(Channel == 1) ? "secondary" : "primary",
|
||||
(Device == 1) ? "slave" : "master"
|
||||
));
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sends out an ATA Identify Command to the specified device.
|
||||
|
||||
@ -2315,7 +2320,7 @@ AtaIdentifyPacket (
|
||||
Status = AtaPioDataInOut (
|
||||
Instance->PciIo,
|
||||
&Instance->IdeRegisters[Channel],
|
||||
(VOID *) Buffer,
|
||||
(VOID *)Buffer,
|
||||
sizeof (EFI_IDENTIFY_DATA),
|
||||
TRUE,
|
||||
&AtaCommandBlock,
|
||||
@ -2327,7 +2332,6 @@ AtaIdentifyPacket (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function is used for detect whether the IDE device exists in the
|
||||
specified Channel as the specified Device Number.
|
||||
@ -2392,7 +2396,7 @@ DetectAndConfigIdeDevice (
|
||||
|
||||
Status = WaitForBSYClear (PciIo, IdeRegisters, 350000000);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG((DEBUG_ERROR, "New detecting method: Send Execute Diagnostic Command: WaitForBSYClear: Status: %d\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "New detecting method: Send Execute Diagnostic Command: WaitForBSYClear: Status: %d\n", Status));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2453,9 +2457,13 @@ DetectAndConfigIdeDevice (
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "[%a] channel [%a] [%a] device\n",
|
||||
(IdeChannel == 1) ? "secondary" : "primary ", (IdeDevice == 1) ? "slave " : "master",
|
||||
DeviceType == EfiIdeCdrom ? "cdrom " : "harddisk"));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"[%a] channel [%a] [%a] device\n",
|
||||
(IdeChannel == 1) ? "secondary" : "primary ",
|
||||
(IdeDevice == 1) ? "slave " : "master",
|
||||
DeviceType == EfiIdeCdrom ? "cdrom " : "harddisk"
|
||||
));
|
||||
//
|
||||
// If the device is a hard disk, then try to enable S.M.A.R.T feature
|
||||
//
|
||||
@ -2497,9 +2505,9 @@ DetectAndConfigIdeDevice (
|
||||
TransferMode.ModeCategory = EFI_ATA_MODE_FLOW_PIO;
|
||||
}
|
||||
|
||||
TransferMode.ModeNumber = (UINT8) (SupportedModes->PioMode.Mode);
|
||||
TransferMode.ModeNumber = (UINT8)(SupportedModes->PioMode.Mode);
|
||||
|
||||
if (SupportedModes->ExtModeCount == 0){
|
||||
if (SupportedModes->ExtModeCount == 0) {
|
||||
Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -2516,7 +2524,7 @@ DetectAndConfigIdeDevice (
|
||||
//
|
||||
if (SupportedModes->UdmaMode.Valid) {
|
||||
TransferMode.ModeCategory = EFI_ATA_MODE_UDMA;
|
||||
TransferMode.ModeNumber = (UINT8) (SupportedModes->UdmaMode.Mode);
|
||||
TransferMode.ModeNumber = (UINT8)(SupportedModes->UdmaMode.Mode);
|
||||
Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -2525,7 +2533,7 @@ DetectAndConfigIdeDevice (
|
||||
}
|
||||
} else if (SupportedModes->MultiWordDmaMode.Valid) {
|
||||
TransferMode.ModeCategory = EFI_ATA_MODE_MDMA;
|
||||
TransferMode.ModeNumber = (UINT8) SupportedModes->MultiWordDmaMode.Mode;
|
||||
TransferMode.ModeNumber = (UINT8)SupportedModes->MultiWordDmaMode.Mode;
|
||||
Status = SetDeviceTransferMode (Instance, IdeChannel, IdeDevice, &TransferMode, NULL);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -2543,9 +2551,9 @@ DetectAndConfigIdeDevice (
|
||||
//
|
||||
// Init driver parameters
|
||||
//
|
||||
DriveParameters.Sector = (UINT8) ((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->sectors_per_track;
|
||||
DriveParameters.Heads = (UINT8) (((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->heads - 1);
|
||||
DriveParameters.MultipleSector = (UINT8) ((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->multi_sector_cmd_max_sct_cnt;
|
||||
DriveParameters.Sector = (UINT8)((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->sectors_per_track;
|
||||
DriveParameters.Heads = (UINT8)(((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->heads - 1);
|
||||
DriveParameters.MultipleSector = (UINT8)((ATA5_IDENTIFY_DATA *)(&Buffer.AtaData))->multi_sector_cmd_max_sct_cnt;
|
||||
|
||||
Status = SetDriveParameters (Instance, IdeChannel, IdeDevice, &DriveParameters, NULL);
|
||||
}
|
||||
@ -2568,10 +2576,10 @@ DetectAndConfigIdeDevice (
|
||||
REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_PERIPHERAL_FIXED_MEDIA | EFI_P_PC_ENABLE));
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize ATA host controller at IDE mode.
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __ATA_HC_IDE_MODE_H__
|
||||
#define __ATA_HC_IDE_MODE_H__
|
||||
|
||||
@ -195,4 +196,3 @@ AtaPacketCommandExecute (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -74,15 +74,17 @@ ATA_DEVICE gAtaDeviceTemplate = {
|
||||
0, // Port
|
||||
0, // PortMultiplierPort
|
||||
{ 0, }, // Packet
|
||||
{{ 0}, }, // Acb
|
||||
{
|
||||
{ 0 },
|
||||
}, // Acb
|
||||
NULL, // Asb
|
||||
FALSE, // UdmaValid
|
||||
FALSE, // Lba48Bit
|
||||
NULL, // IdentifyData
|
||||
NULL, // ControllerNameTable
|
||||
{L'\0', }, // ModelName
|
||||
{NULL, NULL}, // AtaTaskList
|
||||
{NULL, NULL}, // AtaSubTaskList
|
||||
{ L'\0', }, // ModelName
|
||||
{ NULL, NULL }, // AtaTaskList
|
||||
{ NULL, NULL }, // AtaSubTaskList
|
||||
FALSE // Abort
|
||||
};
|
||||
|
||||
@ -129,7 +131,6 @@ FreeAlignedBuffer (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release all the resources allocated for the ATA device.
|
||||
|
||||
@ -155,14 +156,16 @@ ReleaseAtaResources (
|
||||
if (AtaDevice->DevicePath != NULL) {
|
||||
FreePool (AtaDevice->DevicePath);
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {
|
||||
//
|
||||
// Free the Subtask list.
|
||||
//
|
||||
for(Entry = AtaDevice->AtaSubTaskList.ForwardLink;
|
||||
for (Entry = AtaDevice->AtaSubTaskList.ForwardLink;
|
||||
Entry != (&AtaDevice->AtaSubTaskList);
|
||||
) {
|
||||
)
|
||||
{
|
||||
DelEntry = Entry;
|
||||
Entry = Entry->ForwardLink;
|
||||
SubTask = ATA_ASYN_SUB_TASK_FROM_ENTRY (DelEntry);
|
||||
@ -171,13 +174,15 @@ ReleaseAtaResources (
|
||||
FreeAtaSubTask (SubTask);
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsListEmpty (&AtaDevice->AtaTaskList)) {
|
||||
//
|
||||
// Free the Subtask list.
|
||||
//
|
||||
for(Entry = AtaDevice->AtaTaskList.ForwardLink;
|
||||
for (Entry = AtaDevice->AtaTaskList.ForwardLink;
|
||||
Entry != (&AtaDevice->AtaTaskList);
|
||||
) {
|
||||
)
|
||||
{
|
||||
DelEntry = Entry;
|
||||
Entry = Entry->ForwardLink;
|
||||
AtaTask = ATA_ASYN_TASK_FROM_ENTRY (DelEntry);
|
||||
@ -186,11 +191,11 @@ ReleaseAtaResources (
|
||||
FreePool (AtaTask);
|
||||
}
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
FreePool (AtaDevice);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Registers an ATA device.
|
||||
|
||||
@ -246,7 +251,7 @@ RegisterAtaDevice (
|
||||
DeviceHandle = NULL;
|
||||
RemainingDevicePath = DevicePath;
|
||||
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);
|
||||
if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd(RemainingDevicePath)) {
|
||||
if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd (RemainingDevicePath)) {
|
||||
Status = EFI_ALREADY_STARTED;
|
||||
FreePool (DevicePath);
|
||||
goto Done;
|
||||
@ -275,6 +280,7 @@ RegisterAtaDevice (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
AtaDevice->IdentifyData = AllocateAlignedBuffer (AtaDevice, sizeof (ATA_IDENTIFY_DATA));
|
||||
if (AtaDevice->IdentifyData == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
@ -368,13 +374,14 @@ RegisterAtaDevice (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Successfully Install Storage Security Protocol on the ATA device\n"));
|
||||
}
|
||||
|
||||
gBS->OpenProtocol (
|
||||
AtaBusDriverData->Controller,
|
||||
&gEfiAtaPassThruProtocolGuid,
|
||||
(VOID **) &AtaPassThru,
|
||||
(VOID **)&AtaPassThru,
|
||||
AtaBusDriverData->DriverBindingHandle,
|
||||
AtaDevice->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -389,10 +396,10 @@ Done:
|
||||
ReleaseAtaResources (AtaDevice);
|
||||
DEBUG ((DEBUG_ERROR | DEBUG_INIT, "Failed to initialize Port %x PortMultiplierPort %x, status = %r\n", Port, PortMultiplierPort, Status));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Unregisters an ATA device.
|
||||
|
||||
@ -427,7 +434,7 @@ UnregisterAtaDevice (
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
(VOID **) &BlockIo,
|
||||
(VOID **)&BlockIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -439,7 +446,7 @@ UnregisterAtaDevice (
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiBlockIo2ProtocolGuid,
|
||||
(VOID **) &BlockIo2,
|
||||
(VOID **)&BlockIo2,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -490,7 +497,7 @@ UnregisterAtaDevice (
|
||||
gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiAtaPassThruProtocolGuid,
|
||||
(VOID **) &AtaPassThru,
|
||||
(VOID **)&AtaPassThru,
|
||||
This->DriverBindingHandle,
|
||||
Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -504,7 +511,7 @@ UnregisterAtaDevice (
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiStorageSecurityCommandProtocolGuid,
|
||||
(VOID **) &StorageSecurity,
|
||||
(VOID **)&StorageSecurity,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -520,7 +527,7 @@ UnregisterAtaDevice (
|
||||
gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiAtaPassThruProtocolGuid,
|
||||
(VOID **) &AtaPassThru,
|
||||
(VOID **)&AtaPassThru,
|
||||
This->DriverBindingHandle,
|
||||
Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -533,8 +540,6 @@ UnregisterAtaDevice (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Tests to see if this driver supports a given controller. If a child device is provided,
|
||||
it further tests to see if this driver supports creating a handle for the specified child device.
|
||||
@ -597,7 +602,7 @@ AtaBusDriverBindingSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiAtaPassThruProtocolGuid,
|
||||
(VOID **) &AtaPassThru,
|
||||
(VOID **)&AtaPassThru,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -662,7 +667,7 @@ AtaBusDriverBindingSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
(VOID **)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -670,7 +675,6 @@ AtaBusDriverBindingSupported (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starts a device controller or a bus controller.
|
||||
|
||||
@ -726,7 +730,7 @@ AtaBusDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
(VOID **)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -747,7 +751,7 @@ AtaBusDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiAtaPassThruProtocolGuid,
|
||||
(VOID **) &AtaPassThru,
|
||||
(VOID **)&AtaPassThru,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -780,12 +784,11 @@ AtaBusDriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
} else {
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &AtaBusDriverData,
|
||||
(VOID **)&AtaBusDriverData,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -826,14 +829,16 @@ AtaBusDriverBindingStart (
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
RegisterAtaDevice (AtaBusDriverData, Port, PortMultiplierPort);
|
||||
}
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = RegisterAtaDevice (AtaBusDriverData,Port, PortMultiplierPort);
|
||||
Status = RegisterAtaDevice (AtaBusDriverData, Port, PortMultiplierPort);
|
||||
}
|
||||
}
|
||||
|
||||
@ -859,10 +864,8 @@ ErrorExit:
|
||||
);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stops a device controller or a bus controller.
|
||||
|
||||
@ -907,7 +910,7 @@ AtaBusDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &AtaBusDriverData,
|
||||
(VOID **)&AtaBusDriverData,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -935,7 +938,6 @@ AtaBusDriverBindingStop (
|
||||
AllChildrenStopped = TRUE;
|
||||
|
||||
for (Index = 0; Index < NumberOfChildren; Index++) {
|
||||
|
||||
Status = UnregisterAtaDevice (This, Controller, ChildHandleBuffer[Index]);
|
||||
if (EFI_ERROR (Status)) {
|
||||
AllChildrenStopped = FALSE;
|
||||
@ -949,7 +951,6 @@ AtaBusDriverBindingStop (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset the Block Device.
|
||||
|
||||
@ -986,7 +987,6 @@ AtaBlockIoReset (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read/Write BufferSize bytes from Lba from/into Buffer.
|
||||
|
||||
@ -1034,10 +1034,10 @@ BlockIoReadWrite (
|
||||
UINTN IoAlign;
|
||||
|
||||
if (IsBlockIo2) {
|
||||
Media = ((EFI_BLOCK_IO2_PROTOCOL *) This)->Media;
|
||||
Media = ((EFI_BLOCK_IO2_PROTOCOL *)This)->Media;
|
||||
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (This);
|
||||
} else {
|
||||
Media = ((EFI_BLOCK_IO_PROTOCOL *) This)->Media;
|
||||
Media = ((EFI_BLOCK_IO_PROTOCOL *)This)->Media;
|
||||
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (This);
|
||||
}
|
||||
|
||||
@ -1057,6 +1057,7 @@ BlockIoReadWrite (
|
||||
Token->TransactionStatus = EFI_SUCCESS;
|
||||
gBS->SignalEvent (Token->Event);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1071,7 +1072,7 @@ BlockIoReadWrite (
|
||||
}
|
||||
|
||||
IoAlign = Media->IoAlign;
|
||||
if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) {
|
||||
if ((IoAlign > 0) && (((UINTN)Buffer & (IoAlign - 1)) != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1087,7 +1088,6 @@ BlockIoReadWrite (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@ -1117,10 +1117,9 @@ AtaBlockIoReadBlocks (
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
return BlockIoReadWrite ((VOID *) This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, FALSE);
|
||||
return BlockIoReadWrite ((VOID *)This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, FALSE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@ -1151,10 +1150,9 @@ AtaBlockIoWriteBlocks (
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
return BlockIoReadWrite ((VOID *) This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, TRUE);
|
||||
return BlockIoReadWrite ((VOID *)This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Flush the Block Device.
|
||||
|
||||
@ -1252,10 +1250,9 @@ AtaBlockIoReadBlocksEx (
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
return BlockIoReadWrite ((VOID *) This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, FALSE);
|
||||
return BlockIoReadWrite ((VOID *)This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, FALSE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@ -1289,10 +1286,9 @@ AtaBlockIoWriteBlocksEx (
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
return BlockIoReadWrite ((VOID *) This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, TRUE);
|
||||
return BlockIoReadWrite ((VOID *)This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Flush the Block Device.
|
||||
|
||||
@ -1314,12 +1310,14 @@ AtaBlockIoFlushBlocksEx (
|
||||
//
|
||||
// Signal event and return directly.
|
||||
//
|
||||
if (Token != NULL && Token->Event != NULL) {
|
||||
if ((Token != NULL) && (Token->Event != NULL)) {
|
||||
Token->TransactionStatus = EFI_SUCCESS;
|
||||
gBS->SignalEvent (Token->Event);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Provides inquiry information for the controller type.
|
||||
|
||||
@ -1347,7 +1345,6 @@ AtaDiskInfoInquiry (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Provides identify information for the controller type.
|
||||
|
||||
@ -1384,12 +1381,12 @@ AtaDiskInfoIdentify (
|
||||
Status = EFI_SUCCESS;
|
||||
CopyMem (IdentifyData, AtaDevice->IdentifyData, sizeof (ATA_IDENTIFY_DATA));
|
||||
}
|
||||
|
||||
*IdentifyDataSize = sizeof (ATA_IDENTIFY_DATA);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Provides sense data information for the controller type.
|
||||
|
||||
@ -1419,7 +1416,6 @@ AtaDiskInfoSenseData (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function is used by the IDE bus driver to get controller information.
|
||||
|
||||
@ -1538,7 +1534,7 @@ AtaStorageSecurityReceiveData (
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "EFI Storage Security Protocol - Read\n"));
|
||||
if ((PayloadBuffer == NULL || PayloadTransferSize == NULL) && PayloadBufferSize != 0) {
|
||||
if (((PayloadBuffer == NULL) || (PayloadTransferSize == NULL)) && (PayloadBufferSize != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1687,7 +1683,7 @@ AtaStorageSecuritySendData (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeAtaBus(
|
||||
InitializeAtaBus (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
|
@ -58,7 +58,7 @@
|
||||
//
|
||||
// The maximum ATA transaction sector count in 48 bit addressing mode.
|
||||
//
|
||||
//#define MAX_48BIT_TRANSFER_BLOCK_NUM 0x10000
|
||||
// #define MAX_48BIT_TRANSFER_BLOCK_NUM 0x10000
|
||||
|
||||
//
|
||||
// BugBug: if the TransferLength is equal with 0x10000 (the 48bit max length),
|
||||
@ -233,7 +233,6 @@ ResetAtaDevice (
|
||||
IN ATA_DEVICE *AtaDevice
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Discovers whether it is a valid ATA device.
|
||||
|
||||
@ -272,7 +271,7 @@ DiscoverAtaDevice (
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
AccessAtaDevice(
|
||||
AccessAtaDevice (
|
||||
IN OUT ATA_DEVICE *AtaDevice,
|
||||
IN OUT UINT8 *Buffer,
|
||||
IN EFI_LBA StartLba,
|
||||
@ -326,6 +325,7 @@ TrustTransferAtaDevice (
|
||||
//
|
||||
// Protocol interface prototypes
|
||||
//
|
||||
|
||||
/**
|
||||
Tests to see if this driver supports a given controller. If a child device is provided,
|
||||
it further tests to see if this driver supports creating a handle for the specified child device.
|
||||
@ -454,7 +454,6 @@ AtaBusDriverBindingStop (
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -502,7 +501,6 @@ AtaBusComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -581,7 +579,6 @@ AtaBusComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Reset the Block Device.
|
||||
|
||||
@ -600,7 +597,6 @@ AtaBlockIoReset (
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Read BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@ -630,7 +626,6 @@ AtaBlockIoReadBlocks (
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@ -661,7 +656,6 @@ AtaBlockIoWriteBlocks (
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Flush the Block Device.
|
||||
|
||||
@ -824,7 +818,6 @@ AtaDiskInfoInquiry (
|
||||
IN OUT UINT32 *InquiryDataSize
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Provides identify information for the controller type.
|
||||
|
||||
@ -851,7 +844,6 @@ AtaDiskInfoIdentify (
|
||||
IN OUT UINT32 *IdentifyDataSize
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Provides sense data information for the controller type.
|
||||
|
||||
@ -878,7 +870,6 @@ AtaDiskInfoSenseData (
|
||||
OUT UINT8 *SenseDataNumber
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This function is used by the IDE bus driver to get controller information.
|
||||
|
||||
|
@ -79,7 +79,6 @@ UINT8 mAtaTrustCommands[2][2] = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Look up table (Lba48Bit) for maximum transfer block number
|
||||
//
|
||||
@ -88,7 +87,6 @@ UINTN mMaxTransferBlockNumber[] = {
|
||||
MAX_48BIT_TRANSFER_BLOCK_NUM
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.PassThru().
|
||||
|
||||
@ -159,7 +157,6 @@ AtaDevicePassThru (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.ResetDevice().
|
||||
|
||||
@ -196,7 +193,6 @@ ResetAtaDevice (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Prints ATA model name to ATA device structure.
|
||||
|
||||
@ -226,10 +222,10 @@ PrintAtaModelName (
|
||||
Destination[Index] = Source[Index + 1];
|
||||
Destination[Index + 1] = Source[Index];
|
||||
}
|
||||
|
||||
AtaDevice->ModelName[MAX_MODEL_NAME_LEN] = L'\0';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Gets ATA device Capacity according to ATA 6.
|
||||
|
||||
@ -275,7 +271,6 @@ GetAtapi6Capacity (
|
||||
return Capacity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Identifies ATA device via the Identify data.
|
||||
|
||||
@ -353,23 +348,26 @@ IdentifyAtaDevice (
|
||||
// Check whether one physical block contains multiple physical blocks
|
||||
//
|
||||
if ((PhyLogicSectorSupport & BIT13) != 0) {
|
||||
BlockMedia->LogicalBlocksPerPhysicalBlock = (UINT32) (1 << (PhyLogicSectorSupport & 0x000f));
|
||||
BlockMedia->LogicalBlocksPerPhysicalBlock = (UINT32)(1 << (PhyLogicSectorSupport & 0x000f));
|
||||
//
|
||||
// Check lowest alignment of logical blocks within physical block
|
||||
//
|
||||
if ((IdentifyData->alignment_logic_in_phy_blocks & (BIT14 | BIT15)) == BIT14) {
|
||||
BlockMedia->LowestAlignedLba = (EFI_LBA) ((BlockMedia->LogicalBlocksPerPhysicalBlock - ((UINT32)IdentifyData->alignment_logic_in_phy_blocks & 0x3fff)) %
|
||||
BlockMedia->LowestAlignedLba = (EFI_LBA)((BlockMedia->LogicalBlocksPerPhysicalBlock - ((UINT32)IdentifyData->alignment_logic_in_phy_blocks & 0x3fff)) %
|
||||
BlockMedia->LogicalBlocksPerPhysicalBlock);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check logical block size
|
||||
//
|
||||
if ((PhyLogicSectorSupport & BIT12) != 0) {
|
||||
BlockMedia->BlockSize = (UINT32) (((IdentifyData->logic_sector_size_hi << 16) | IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
|
||||
BlockMedia->BlockSize = (UINT32)(((IdentifyData->logic_sector_size_hi << 16) | IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
|
||||
}
|
||||
|
||||
AtaDevice->BlockIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION2;
|
||||
}
|
||||
|
||||
//
|
||||
// Get ATA model name from identify data structure.
|
||||
//
|
||||
@ -378,7 +376,6 @@ IdentifyAtaDevice (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Discovers whether it is a valid ATA device.
|
||||
|
||||
@ -408,7 +405,7 @@ DiscoverAtaDevice (
|
||||
//
|
||||
Acb = ZeroMem (&AtaDevice->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
|
||||
Acb->AtaCommand = ATA_CMD_IDENTIFY_DRIVE;
|
||||
Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
|
||||
Acb->AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
|
||||
|
||||
//
|
||||
// Prepare for ATA pass through packet.
|
||||
@ -478,26 +475,26 @@ TransferAtaDevice (
|
||||
//
|
||||
// Ensure AtaDevice->UdmaValid, AtaDevice->Lba48Bit and IsWrite are valid boolean values
|
||||
//
|
||||
ASSERT ((UINTN) AtaDevice->UdmaValid < 2);
|
||||
ASSERT ((UINTN) AtaDevice->Lba48Bit < 2);
|
||||
ASSERT ((UINTN) IsWrite < 2);
|
||||
ASSERT ((UINTN)AtaDevice->UdmaValid < 2);
|
||||
ASSERT ((UINTN)AtaDevice->Lba48Bit < 2);
|
||||
ASSERT ((UINTN)IsWrite < 2);
|
||||
//
|
||||
// Prepare for ATA command block.
|
||||
//
|
||||
Acb = ZeroMem (&AtaDevice->Acb, sizeof (EFI_ATA_COMMAND_BLOCK));
|
||||
Acb->AtaCommand = mAtaCommands[AtaDevice->UdmaValid][AtaDevice->Lba48Bit][IsWrite];
|
||||
Acb->AtaSectorNumber = (UINT8) StartLba;
|
||||
Acb->AtaCylinderLow = (UINT8) RShiftU64 (StartLba, 8);
|
||||
Acb->AtaCylinderHigh = (UINT8) RShiftU64 (StartLba, 16);
|
||||
Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
|
||||
Acb->AtaSectorCount = (UINT8) TransferLength;
|
||||
Acb->AtaSectorNumber = (UINT8)StartLba;
|
||||
Acb->AtaCylinderLow = (UINT8)RShiftU64 (StartLba, 8);
|
||||
Acb->AtaCylinderHigh = (UINT8)RShiftU64 (StartLba, 16);
|
||||
Acb->AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
|
||||
Acb->AtaSectorCount = (UINT8)TransferLength;
|
||||
if (AtaDevice->Lba48Bit) {
|
||||
Acb->AtaSectorNumberExp = (UINT8) RShiftU64 (StartLba, 24);
|
||||
Acb->AtaCylinderLowExp = (UINT8) RShiftU64 (StartLba, 32);
|
||||
Acb->AtaCylinderHighExp = (UINT8) RShiftU64 (StartLba, 40);
|
||||
Acb->AtaSectorCountExp = (UINT8) (TransferLength >> 8);
|
||||
Acb->AtaSectorNumberExp = (UINT8)RShiftU64 (StartLba, 24);
|
||||
Acb->AtaCylinderLowExp = (UINT8)RShiftU64 (StartLba, 32);
|
||||
Acb->AtaCylinderHighExp = (UINT8)RShiftU64 (StartLba, 40);
|
||||
Acb->AtaSectorCountExp = (UINT8)(TransferLength >> 8);
|
||||
} else {
|
||||
Acb->AtaDeviceHead = (UINT8) (Acb->AtaDeviceHead | RShiftU64 (StartLba, 24));
|
||||
Acb->AtaDeviceHead = (UINT8)(Acb->AtaDeviceHead | RShiftU64 (StartLba, 24));
|
||||
}
|
||||
|
||||
//
|
||||
@ -570,6 +567,7 @@ FreeAtaSubTask (
|
||||
if (Task->Packet.Asb != NULL) {
|
||||
FreeAlignedBuffer (Task->Packet.Asb, sizeof (EFI_ATA_STATUS_BLOCK));
|
||||
}
|
||||
|
||||
if (Task->Packet.Acb != NULL) {
|
||||
FreePool (Task->Packet.Acb);
|
||||
}
|
||||
@ -614,6 +612,7 @@ AtaTerminateNonBlockingTask (
|
||||
Entry = RemoveEntryList (Entry);
|
||||
FreePool (AtaTask);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
do {
|
||||
@ -654,7 +653,7 @@ AtaNonBlockingCallBack (
|
||||
LIST_ENTRY *Entry;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Task = (ATA_BUS_ASYN_SUB_TASK *) Context;
|
||||
Task = (ATA_BUS_ASYN_SUB_TASK *)Context;
|
||||
gBS->CloseEvent (Event);
|
||||
|
||||
AtaDevice = Task->AtaDevice;
|
||||
@ -682,7 +681,7 @@ AtaNonBlockingCallBack (
|
||||
//
|
||||
// Reduce the SubEventCount, till it comes to zero.
|
||||
//
|
||||
(*Task->UnsignalledEventCount) --;
|
||||
(*Task->UnsignalledEventCount)--;
|
||||
DEBUG ((DEBUG_BLKIO, "UnsignalledEventCount = %d\n", *Task->UnsignalledEventCount));
|
||||
|
||||
//
|
||||
@ -702,7 +701,6 @@ AtaNonBlockingCallBack (
|
||||
FreePool (Task->UnsignalledEventCount);
|
||||
FreePool (Task->IsError);
|
||||
|
||||
|
||||
//
|
||||
// Finish all subtasks and move to the next task in AtaTaskList.
|
||||
//
|
||||
@ -723,6 +721,7 @@ AtaNonBlockingCallBack (
|
||||
AtaTask->Token->TransactionStatus = Status;
|
||||
gBS->SignalEvent (AtaTask->Token->Event);
|
||||
}
|
||||
|
||||
RemoveEntryList (Entry);
|
||||
FreePool (AtaTask);
|
||||
}
|
||||
@ -763,7 +762,7 @@ AtaNonBlockingCallBack (
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
AccessAtaDevice(
|
||||
AccessAtaDevice (
|
||||
IN OUT ATA_DEVICE *AtaDevice,
|
||||
IN OUT UINT8 *Buffer,
|
||||
IN EFI_LBA StartLba,
|
||||
@ -797,7 +796,7 @@ AccessAtaDevice(
|
||||
//
|
||||
// Ensure AtaDevice->Lba48Bit is a valid boolean value
|
||||
//
|
||||
ASSERT ((UINTN) AtaDevice->Lba48Bit < 2);
|
||||
ASSERT ((UINTN)AtaDevice->Lba48Bit < 2);
|
||||
MaxTransferBlockNumber = mMaxTransferBlockNumber[AtaDevice->Lba48Bit];
|
||||
BlockSize = AtaDevice->BlockMedia.BlockSize;
|
||||
|
||||
@ -813,6 +812,7 @@ AccessAtaDevice(
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
AtaTask->AtaDevice = AtaDevice;
|
||||
AtaTask->Buffer = Buffer;
|
||||
AtaTask->IsWrite = IsWrite;
|
||||
@ -825,6 +825,7 @@ AccessAtaDevice(
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
Token->TransactionStatus = EFI_SUCCESS;
|
||||
@ -838,6 +839,7 @@ AccessAtaDevice(
|
||||
FreePool (EventCount);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "Allocation IsError Addr=%x\n", IsError));
|
||||
*IsError = FALSE;
|
||||
TempCount = (NumberOfBlocks + MaxTransferBlockNumber - 1) / MaxTransferBlockNumber;
|
||||
@ -901,13 +903,13 @@ AccessAtaDevice(
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
Status = TransferAtaDevice (AtaDevice, &SubTask->Packet, Buffer, StartLba, (UINT32) TransferBlockNumber, IsWrite, SubEvent);
|
||||
Status = TransferAtaDevice (AtaDevice, &SubTask->Packet, Buffer, StartLba, (UINT32)TransferBlockNumber, IsWrite, SubEvent);
|
||||
} else {
|
||||
//
|
||||
// Blocking Mode.
|
||||
//
|
||||
DEBUG ((DEBUG_BLKIO, "Blocking AccessAtaDevice, TransferBlockNumber=%x; StartLba = %x\n", TransferBlockNumber, StartLba));
|
||||
Status = TransferAtaDevice (AtaDevice, NULL, Buffer, StartLba, (UINT32) TransferBlockNumber, IsWrite, NULL);
|
||||
Status = TransferAtaDevice (AtaDevice, NULL, Buffer, StartLba, (UINT32)TransferBlockNumber, IsWrite, NULL);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -943,6 +945,7 @@ EXIT:
|
||||
if (SubEvent != NULL) {
|
||||
gBS->CloseEvent (SubEvent);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
}
|
||||
}
|
||||
@ -1001,8 +1004,8 @@ TrustTransferAtaDevice (
|
||||
//
|
||||
// Ensure AtaDevice->UdmaValid and IsTrustSend are valid boolean values
|
||||
//
|
||||
ASSERT ((UINTN) AtaDevice->UdmaValid < 2);
|
||||
ASSERT ((UINTN) IsTrustSend < 2);
|
||||
ASSERT ((UINTN)AtaDevice->UdmaValid < 2);
|
||||
ASSERT ((UINTN)IsTrustSend < 2);
|
||||
//
|
||||
// Prepare for ATA command block.
|
||||
//
|
||||
@ -1012,16 +1015,17 @@ TrustTransferAtaDevice (
|
||||
} else {
|
||||
Acb->AtaCommand = mAtaTrustCommands[AtaDevice->UdmaValid][IsTrustSend];
|
||||
}
|
||||
|
||||
Acb->AtaFeatures = SecurityProtocolId;
|
||||
Acb->AtaSectorCount = (UINT8) (TransferLength / 512);
|
||||
Acb->AtaSectorNumber = (UINT8) ((TransferLength / 512) >> 8);
|
||||
Acb->AtaSectorCount = (UINT8)(TransferLength / 512);
|
||||
Acb->AtaSectorNumber = (UINT8)((TransferLength / 512) >> 8);
|
||||
//
|
||||
// NOTE: ATA Spec has no explicitly definition for Security Protocol Specific layout.
|
||||
// Here use big endian for Cylinder register.
|
||||
//
|
||||
Acb->AtaCylinderHigh = (UINT8) SecurityProtocolSpecificData;
|
||||
Acb->AtaCylinderLow = (UINT8) (SecurityProtocolSpecificData >> 8);
|
||||
Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
|
||||
Acb->AtaCylinderHigh = (UINT8)SecurityProtocolSpecificData;
|
||||
Acb->AtaCylinderLow = (UINT8)(SecurityProtocolSpecificData >> 8);
|
||||
Acb->AtaDeviceHead = (UINT8)(BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort == 0xFFFF ? 0 : (AtaDevice->PortMultiplierPort << 4)));
|
||||
|
||||
//
|
||||
// Prepare for ATA pass through packet.
|
||||
@ -1046,22 +1050,25 @@ TrustTransferAtaDevice (
|
||||
FreePool (Buffer);
|
||||
Buffer = NewBuffer;
|
||||
}
|
||||
|
||||
Packet->OutDataBuffer = Buffer;
|
||||
Packet->OutTransferLength = (UINT32) TransferLength;
|
||||
Packet->OutTransferLength = (UINT32)TransferLength;
|
||||
Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];
|
||||
} else {
|
||||
Packet->InDataBuffer = Buffer;
|
||||
Packet->InTransferLength = (UINT32) TransferLength;
|
||||
Packet->InTransferLength = (UINT32)TransferLength;
|
||||
Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];
|
||||
}
|
||||
|
||||
Packet->Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
|
||||
Packet->Timeout = Timeout;
|
||||
|
||||
Status = AtaDevicePassThru (AtaDevice, NULL, NULL);
|
||||
if (TransferLengthOut != NULL) {
|
||||
if (! IsTrustSend) {
|
||||
if (!IsTrustSend) {
|
||||
*TransferLengthOut = Packet->InTransferLength;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusDriverNameTable[] = {
|
||||
{ "eng;en", L"ATA Bus Driver" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
//
|
||||
@ -21,10 +21,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusDriverNameTable[]
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusControllerNameTable[] = {
|
||||
{ "eng;en", L"ATA Controller" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -38,8 +37,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gAtaBusComponentName
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gAtaBusComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AtaBusComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) AtaBusComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)AtaBusComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)AtaBusComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
@ -99,7 +98,6 @@ AtaBusComponentNameGetDriverName (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -205,13 +203,14 @@ AtaBusComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the child context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
(VOID **) &BlockIo,
|
||||
(VOID **)&BlockIo,
|
||||
gAtaBusDriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -219,9 +218,11 @@ AtaBusComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);
|
||||
ControllerNameTable =AtaDevice->ControllerNameTable;
|
||||
ControllerNameTable = AtaDevice->ControllerNameTable;
|
||||
}
|
||||
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
|
@ -47,8 +47,8 @@ CONTROLLER_DEVICE_PATH gControllerDevicePathTemplate = {
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_CONTROLLER_DP,
|
||||
{
|
||||
(UINT8) (sizeof (CONTROLLER_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (CONTROLLER_DEVICE_PATH)) >> 8)
|
||||
(UINT8)(sizeof (CONTROLLER_DEVICE_PATH)),
|
||||
(UINT8)((sizeof (CONTROLLER_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0
|
||||
@ -62,27 +62,28 @@ VENDOR_DEVICE_PATH gVendorDevicePathTemplate = {
|
||||
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)
|
||||
}
|
||||
},
|
||||
{ 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }}
|
||||
{ 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Driver name table
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mI2cBusDriverNameTable[] = {
|
||||
{ "eng;en", (CHAR16 *) L"I2C Bus Driver" },
|
||||
{ NULL , NULL }
|
||||
{ "eng;en", (CHAR16 *)L"I2C Bus Driver" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gI2cBusComponentName = {
|
||||
(EFI_COMPONENT_NAME_GET_DRIVER_NAME) I2cBusComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) I2cBusComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME_GET_DRIVER_NAME)I2cBusComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)I2cBusComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
@ -280,7 +281,7 @@ CheckRemainingDevicePath (
|
||||
Status = gBS->OpenProtocol (
|
||||
OpenInfoBuffer[Index].ControllerHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &SystemDevicePath,
|
||||
(VOID **)&SystemDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -291,7 +292,8 @@ CheckRemainingDevicePath (
|
||||
//
|
||||
while (!IsDevicePathEnd (SystemDevicePath)) {
|
||||
if ((DevicePathType (SystemDevicePath) == HARDWARE_DEVICE_PATH) &&
|
||||
(DevicePathSubType (SystemDevicePath) == HW_VENDOR_DP)) {
|
||||
(DevicePathSubType (SystemDevicePath) == HW_VENDOR_DP))
|
||||
{
|
||||
//
|
||||
// Check if vendor device path is same between system device path and remaining device path
|
||||
//
|
||||
@ -301,31 +303,37 @@ CheckRemainingDevicePath (
|
||||
//
|
||||
SystemDevicePath = NextDevicePathNode (SystemDevicePath);
|
||||
if ((DevicePathType (SystemDevicePath) == HARDWARE_DEVICE_PATH) &&
|
||||
(DevicePathSubType (SystemDevicePath) == HW_CONTROLLER_DP)) {
|
||||
(DevicePathSubType (SystemDevicePath) == HW_CONTROLLER_DP))
|
||||
{
|
||||
SystemHasControllerNode = TRUE;
|
||||
SystemControllerNumber = ((CONTROLLER_DEVICE_PATH *) SystemDevicePath)->ControllerNumber;
|
||||
SystemControllerNumber = ((CONTROLLER_DEVICE_PATH *)SystemDevicePath)->ControllerNumber;
|
||||
} else {
|
||||
SystemHasControllerNode = FALSE;
|
||||
SystemControllerNumber = 0;
|
||||
}
|
||||
|
||||
if (((SystemHasControllerNode) && (!RemainingHasControllerNode) && (SystemControllerNumber == 0)) ||
|
||||
((!SystemHasControllerNode) && (RemainingHasControllerNode) && (RemainingControllerNumber == 0)) ||
|
||||
((SystemHasControllerNode) && (RemainingHasControllerNode) && (SystemControllerNumber == RemainingControllerNumber)) ||
|
||||
((!SystemHasControllerNode) && (!RemainingHasControllerNode))) {
|
||||
((!SystemHasControllerNode) && (!RemainingHasControllerNode)))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "This I2C device has been already started.\n"));
|
||||
Status = EFI_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SystemDevicePath = NextDevicePathNode (SystemDevicePath);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (OpenInfoBuffer);
|
||||
return Status;
|
||||
}
|
||||
@ -397,7 +405,7 @@ I2cBusDriverSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiI2cEnumerateProtocolGuid,
|
||||
(VOID **) &I2cEnumerate,
|
||||
(VOID **)&I2cEnumerate,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -418,7 +426,7 @@ I2cBusDriverSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
(VOID **)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -442,20 +450,23 @@ I2cBusDriverSupported (
|
||||
// Check if the first node of RemainingDevicePath is a hardware vendor device path
|
||||
//
|
||||
if ((DevicePathType (RemainingDevicePath) != HARDWARE_DEVICE_PATH) ||
|
||||
(DevicePathSubType (RemainingDevicePath) != HW_VENDOR_DP)) {
|
||||
(DevicePathSubType (RemainingDevicePath) != HW_VENDOR_DP))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if the second node of RemainingDevicePath is a controller node
|
||||
//
|
||||
DevPathNode = NextDevicePathNode (RemainingDevicePath);
|
||||
if (!IsDevicePathEnd (DevPathNode)) {
|
||||
if ((DevicePathType (DevPathNode) != HARDWARE_DEVICE_PATH) ||
|
||||
(DevicePathSubType (DevPathNode) != HW_CONTROLLER_DP)) {
|
||||
(DevicePathSubType (DevPathNode) != HW_CONTROLLER_DP))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
} else {
|
||||
RemainingHasControllerNode = TRUE;
|
||||
RemainingControllerNumber = ((CONTROLLER_DEVICE_PATH *) DevPathNode)->ControllerNumber;
|
||||
RemainingControllerNumber = ((CONTROLLER_DEVICE_PATH *)DevPathNode)->ControllerNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -466,7 +477,7 @@ I2cBusDriverSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiI2cHostProtocolGuid,
|
||||
(VOID **) &I2cHost,
|
||||
(VOID **)&I2cHost,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -481,10 +492,10 @@ I2cBusDriverSupported (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
if ((RemainingDevicePath == NULL) ||
|
||||
((RemainingDevicePath != NULL) && IsDevicePathEnd (RemainingDevicePath))) {
|
||||
((RemainingDevicePath != NULL) && IsDevicePathEnd (RemainingDevicePath)))
|
||||
{
|
||||
//
|
||||
// If RemainingDevicePath is NULL or is the End of Device Path Node, return EFI_SUCCESS.
|
||||
//
|
||||
@ -566,7 +577,7 @@ I2cBusDriverStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiI2cHostProtocolGuid,
|
||||
(VOID**)&I2cHost,
|
||||
(VOID **)&I2cHost,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -580,7 +591,7 @@ I2cBusDriverStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &I2cBusContext,
|
||||
(VOID **)&I2cBusContext,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -597,7 +608,7 @@ I2cBusDriverStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiI2cEnumerateProtocolGuid,
|
||||
(VOID**)&I2cEnumerate,
|
||||
(VOID **)&I2cEnumerate,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -610,7 +621,7 @@ I2cBusDriverStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
(VOID **)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -735,7 +746,6 @@ Error:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stops a device controller or a bus controller.
|
||||
|
||||
@ -801,7 +811,7 @@ I2cBusDriverStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &I2cBusContext,
|
||||
(VOID **)&I2cBusContext,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -818,13 +828,13 @@ I2cBusDriverStop (
|
||||
//
|
||||
FreePool (I2cBusContext);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
AllChildrenStopped = TRUE;
|
||||
|
||||
for (Index = 0; Index < NumberOfChildren; Index++) {
|
||||
|
||||
Status = UnRegisterI2cDevice (This, Controller, ChildHandleBuffer[Index]);
|
||||
if (EFI_ERROR (Status)) {
|
||||
AllChildrenStopped = FALSE;
|
||||
@ -834,6 +844,7 @@ I2cBusDriverStop (
|
||||
if (!AllChildrenStopped) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -884,12 +895,13 @@ RegisterI2cDevice (
|
||||
//
|
||||
DevPathNode = NextDevicePathNode (RemainingDevicePath);
|
||||
if ((DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH) &&
|
||||
(DevicePathSubType(DevPathNode) == HW_CONTROLLER_DP)) {
|
||||
(DevicePathSubType (DevPathNode) == HW_CONTROLLER_DP))
|
||||
{
|
||||
//
|
||||
// RemainingDevicePath != NULL and RemainingDevicePath contains Controller Node,
|
||||
// add Controller Node to Device Path on child handle.
|
||||
//
|
||||
RemainingPathDeviceIndex = ((CONTROLLER_DEVICE_PATH *) DevPathNode)->ControllerNumber;
|
||||
RemainingPathDeviceIndex = ((CONTROLLER_DEVICE_PATH *)DevPathNode)->ControllerNumber;
|
||||
} else {
|
||||
//
|
||||
// RemainingDevicePath != NULL and RemainingDevicePath does not contain Controller Node,
|
||||
@ -908,12 +920,13 @@ RegisterI2cDevice (
|
||||
// Get the next I2C device
|
||||
//
|
||||
Status = I2cBusContext->I2cEnumerate->Enumerate (I2cBusContext->I2cEnumerate, &Device);
|
||||
if (EFI_ERROR (Status) || Device == NULL) {
|
||||
if (EFI_ERROR (Status) || (Device == NULL)) {
|
||||
if (RemainingDevicePath != NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -937,14 +950,16 @@ RegisterI2cDevice (
|
||||
// Get the next I2C device
|
||||
//
|
||||
Status = I2cBusContext->I2cEnumerate->Enumerate (I2cBusContext->I2cEnumerate, &TempDevice);
|
||||
if (EFI_ERROR (Status) || TempDevice == NULL) {
|
||||
if (EFI_ERROR (Status) || (TempDevice == NULL)) {
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (CompareGuid (Device->DeviceGuid, TempDevice->DeviceGuid)) {
|
||||
Count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (Count == 1) {
|
||||
//
|
||||
// RemainingDevicePath == NULL and only DeviceIndex 0 is present on the I2C bus,
|
||||
@ -958,7 +973,8 @@ RegisterI2cDevice (
|
||||
// Find I2C device reported in Remaining Device Path
|
||||
//
|
||||
if ((!CompareGuid (&((VENDOR_DEVICE_PATH *)RemainingDevicePath)->Guid, Device->DeviceGuid)) ||
|
||||
(RemainingPathDeviceIndex != Device->DeviceIndex)) {
|
||||
(RemainingPathDeviceIndex != Device->DeviceIndex))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1001,7 +1017,8 @@ RegisterI2cDevice (
|
||||
&I2cDeviceContext->I2cIo,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
I2cDeviceContext->DevicePath,
|
||||
NULL );
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Free resources for this I2C device
|
||||
@ -1016,7 +1033,7 @@ RegisterI2cDevice (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiI2cHostProtocolGuid,
|
||||
(VOID **) &I2cBusContext->I2cHost,
|
||||
(VOID **)&I2cBusContext->I2cHost,
|
||||
I2cBusContext->DriverBindingHandle,
|
||||
I2cDeviceContext->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1048,7 +1065,6 @@ RegisterI2cDevice (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Queue an I2C transaction for execution on the I2C device.
|
||||
|
||||
@ -1161,7 +1177,7 @@ I2cBusQueueRequest (
|
||||
Status = I2cHost->QueueRequest (
|
||||
I2cHost,
|
||||
I2cDevice->I2cBusConfiguration,
|
||||
I2cDevice->SlaveAddressArray [SlaveAddressIndex],
|
||||
I2cDevice->SlaveAddressArray[SlaveAddressIndex],
|
||||
Event,
|
||||
RequestPacket,
|
||||
I2cStatus
|
||||
@ -1225,7 +1241,7 @@ UnRegisterI2cDevice (
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiI2cIoProtocolGuid,
|
||||
(VOID **) &I2cIo,
|
||||
(VOID **)&I2cIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1269,7 +1285,7 @@ UnRegisterI2cDevice (
|
||||
gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiI2cHostProtocolGuid,
|
||||
(VOID **) &I2cHost,
|
||||
(VOID **)&I2cHost,
|
||||
This->DriverBindingHandle,
|
||||
Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -1313,7 +1329,7 @@ I2cBusDevicePathAppend (
|
||||
CopyMem (&gVendorDevicePathTemplate.Guid, I2cDeviceContext->I2cDevice->DeviceGuid, sizeof (EFI_GUID));
|
||||
I2cDeviceContext->DevicePath = AppendDevicePathNode (
|
||||
I2cDeviceContext->I2cBusContext->ParentDevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gVendorDevicePathTemplate
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gVendorDevicePathTemplate
|
||||
);
|
||||
ASSERT (I2cDeviceContext->DevicePath != NULL);
|
||||
if (I2cDeviceContext->DevicePath == NULL) {
|
||||
@ -1328,7 +1344,7 @@ I2cBusDevicePathAppend (
|
||||
gControllerDevicePathTemplate.ControllerNumber = I2cDeviceContext->I2cDevice->DeviceIndex;
|
||||
I2cDeviceContext->DevicePath = AppendDevicePathNode (
|
||||
I2cDeviceContext->DevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gControllerDevicePathTemplate
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gControllerDevicePathTemplate
|
||||
);
|
||||
gBS->FreePool (PreviousDevicePath);
|
||||
ASSERT (I2cDeviceContext->DevicePath != NULL);
|
||||
@ -1353,7 +1369,7 @@ I2cBusDevicePathAppend (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeI2cBus(
|
||||
InitializeI2cBus (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
@ -1373,7 +1389,6 @@ InitializeI2cBus(
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1455,7 +1470,7 @@ I2cBusUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
gI2cBusDriverBinding.DriverBindingHandle,
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
(VOID **) &ComponentName
|
||||
(VOID **)&ComponentName
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
@ -1468,7 +1483,7 @@ I2cBusUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
gI2cBusDriverBinding.DriverBindingHandle,
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
(VOID **) &ComponentName2
|
||||
(VOID **)&ComponentName2
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
|
@ -20,7 +20,7 @@
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeI2c(
|
||||
InitializeI2c (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
@ -30,11 +30,11 @@ InitializeI2c(
|
||||
//
|
||||
// Install driver model protocol(s).
|
||||
//
|
||||
Status = InitializeI2cHost ( ImageHandle, SystemTable );
|
||||
if ( !EFI_ERROR ( Status ))
|
||||
{
|
||||
Status = InitializeI2cBus ( ImageHandle, SystemTable );
|
||||
Status = InitializeI2cHost (ImageHandle, SystemTable);
|
||||
if ( !EFI_ERROR (Status)) {
|
||||
Status = InitializeI2cBus (ImageHandle, SystemTable);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -61,9 +61,10 @@ I2cUnload (
|
||||
//
|
||||
// Disconnect the drivers
|
||||
//
|
||||
Status = I2cBusUnload ( ImageHandle );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = I2cHostUnload ( ImageHandle );
|
||||
Status = I2cBusUnload (ImageHandle);
|
||||
if ( !EFI_ERROR (Status)) {
|
||||
Status = I2cHostUnload (ImageHandle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ I2cBusComponentNameGetControllerName (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeI2cBus(
|
||||
InitializeI2cBus (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
@ -1065,7 +1065,7 @@ I2cHostQueueRequest (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeI2cHost(
|
||||
InitializeI2cHost (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
@ -24,15 +24,15 @@ EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding = {
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mI2cHostDriverNameTable[] = {
|
||||
{ "eng;en", L"I2c Host Driver" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gI2cHostComponentName = {
|
||||
(EFI_COMPONENT_NAME_GET_DRIVER_NAME) I2cHostComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) I2cHostComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME_GET_DRIVER_NAME)I2cHostComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME_GET_CONTROLLER_NAME)I2cHostComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
@ -379,8 +379,8 @@ I2cHostDriverStart (
|
||||
I2cHostContext->Signature = I2C_HOST_SIGNATURE;
|
||||
I2cHostContext->I2cMaster = I2cMaster;
|
||||
I2cHostContext->I2cBusConfigurationManagement = I2cBusConfigurationManagement;
|
||||
I2cHostContext->I2cBusConfiguration = (UINTN) -1;
|
||||
InitializeListHead(&I2cHostContext->RequestList);
|
||||
I2cHostContext->I2cBusConfiguration = (UINTN)-1;
|
||||
InitializeListHead (&I2cHostContext->RequestList);
|
||||
|
||||
//
|
||||
// Reset the controller
|
||||
@ -521,7 +521,7 @@ I2cHostDriverStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiI2cHostProtocolGuid,
|
||||
(VOID **) &I2cHost,
|
||||
(VOID **)&I2cHost,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -542,9 +542,9 @@ I2cHostDriverStop (
|
||||
// If there is pending request or pending bus configuration, do not stop
|
||||
//
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
if (( !I2cHostContext->I2cBusConfigurationManagementPending )
|
||||
&& IsListEmpty (&I2cHostContext->RequestList)) {
|
||||
|
||||
if ( (!I2cHostContext->I2cBusConfigurationManagementPending)
|
||||
&& IsListEmpty (&I2cHostContext->RequestList))
|
||||
{
|
||||
//
|
||||
// Remove the I2C host protocol
|
||||
//
|
||||
@ -637,7 +637,7 @@ I2cHostI2cBusConfigurationAvailable (
|
||||
// Unknown I2C bus configuration
|
||||
// Force next operation to enable the I2C bus configuration
|
||||
//
|
||||
I2cHostContext->I2cBusConfiguration = (UINTN) -1;
|
||||
I2cHostContext->I2cBusConfiguration = (UINTN)-1;
|
||||
|
||||
//
|
||||
// Do not continue current I2C request
|
||||
@ -669,7 +669,7 @@ I2cHostI2cBusConfigurationAvailable (
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG((DEBUG_ERROR, "I2cHostI2cBusConfigurationAvailable: Error starting I2C operation, %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "I2cHostI2cBusConfigurationAvailable: Error starting I2C operation, %r\n", Status));
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,7 +725,7 @@ I2cHostRequestComplete (
|
||||
//
|
||||
// If there is more I2C request, start next one
|
||||
//
|
||||
if(!IsListEmpty (EntryHeader)) {
|
||||
if (!IsListEmpty (EntryHeader)) {
|
||||
I2cHostRequestEnable (I2cHostContext);
|
||||
}
|
||||
|
||||
@ -829,7 +829,7 @@ I2cHostRequestEnable (
|
||||
//
|
||||
// I2C bus configuration is same, no need change configuration and start I2c transaction directly
|
||||
//
|
||||
TplPrevious = gBS->RaiseTPL ( TPL_I2C_SYNC );
|
||||
TplPrevious = gBS->RaiseTPL (TPL_I2C_SYNC);
|
||||
|
||||
//
|
||||
// Same I2C bus configuration
|
||||
@ -840,8 +840,9 @@ I2cHostRequestEnable (
|
||||
//
|
||||
// Release the thread synchronization
|
||||
//
|
||||
gBS->RestoreTPL ( TplPrevious );
|
||||
gBS->RestoreTPL (TplPrevious);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1015,7 +1016,7 @@ I2cHostQueueRequest (
|
||||
//
|
||||
// Synchronize with the other threads
|
||||
//
|
||||
gBS->RaiseTPL ( TPL_I2C_SYNC );
|
||||
gBS->RaiseTPL (TPL_I2C_SYNC);
|
||||
|
||||
FirstRequest = IsListEmpty (&I2cHostContext->RequestList);
|
||||
|
||||
@ -1085,7 +1086,7 @@ I2cHostQueueRequest (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeI2cHost(
|
||||
InitializeI2cHost (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
@ -1185,7 +1186,7 @@ I2cHostUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
gI2cHostDriverBinding.DriverBindingHandle,
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
(VOID **) &ComponentName
|
||||
(VOID **)&ComponentName
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
@ -1198,7 +1199,7 @@ I2cHostUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
gI2cHostDriverBinding.DriverBindingHandle,
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
(VOID **) &ComponentName2
|
||||
(VOID **)&ComponentName2
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
|
@ -14,7 +14,7 @@
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaBusDriverNameTable[] = {
|
||||
{ "eng;en", L"PI ISA BUS Driver" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
//
|
||||
@ -30,8 +30,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIsaBusComponentName
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaBusComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaBusComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaBusComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)IsaBusComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)IsaBusComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
@ -91,7 +91,6 @@ IsaBusComponentNameGetDriverName (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
@ -63,7 +63,6 @@ IsaBusComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
@ -137,8 +137,10 @@ IsaBusCreateChild (
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
ChildHandle,
|
||||
&gEfiIsaHcProtocolGuid, Private->IsaHc,
|
||||
&gEfiCallerIdGuid, Child,
|
||||
&gEfiIsaHcProtocolGuid,
|
||||
Private->IsaHc,
|
||||
&gEfiCallerIdGuid,
|
||||
Child,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -149,7 +151,7 @@ IsaBusCreateChild (
|
||||
return gBS->OpenProtocol (
|
||||
Private->IsaHcHandle,
|
||||
&gEfiIsaHcProtocolGuid,
|
||||
(VOID **) &IsaHc,
|
||||
(VOID **)&IsaHc,
|
||||
gIsaBusDriverBinding.DriverBindingHandle,
|
||||
*ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -191,7 +193,7 @@ IsaBusDestroyChild (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiCallerIdGuid,
|
||||
(VOID **) &Child,
|
||||
(VOID **)&Child,
|
||||
gIsaBusDriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -217,15 +219,17 @@ IsaBusDestroyChild (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ChildHandle,
|
||||
&gEfiIsaHcProtocolGuid, Private->IsaHc,
|
||||
&gEfiCallerIdGuid, Child,
|
||||
&gEfiIsaHcProtocolGuid,
|
||||
Private->IsaHc,
|
||||
&gEfiCallerIdGuid,
|
||||
Child,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->OpenProtocol (
|
||||
Private->IsaHcHandle,
|
||||
&gEfiIsaHcProtocolGuid,
|
||||
(VOID **) &IsaHc,
|
||||
(VOID **)&IsaHc,
|
||||
gIsaBusDriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -290,7 +294,7 @@ IsaBusDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiIsaHcProtocolGuid,
|
||||
(VOID **) &mIsaBusPrivateTemplate.IsaHc,
|
||||
(VOID **)&mIsaBusPrivateTemplate.IsaHc,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -302,7 +306,7 @@ IsaBusDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath,
|
||||
(VOID **)&DevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -324,7 +328,8 @@ IsaBusDriverBindingStart (
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Controller,
|
||||
&gEfiIsaHcServiceBindingProtocolGuid, &Private->ServiceBinding,
|
||||
&gEfiIsaHcServiceBindingProtocolGuid,
|
||||
&Private->ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@ -365,7 +370,7 @@ IsaBusDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiIsaHcServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
(VOID **)&ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -379,7 +384,8 @@ IsaBusDriverBindingStop (
|
||||
if (NumberOfChildren == 0) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Controller,
|
||||
&gEfiIsaHcServiceBindingProtocolGuid, &Private->ServiceBinding,
|
||||
&gEfiIsaHcServiceBindingProtocolGuid,
|
||||
&Private->ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -58,7 +59,6 @@ Ps2KeyboardComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -137,7 +137,6 @@ Ps2KeyboardComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -151,12 +150,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponent
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2KeyboardComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2KeyboardComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Ps2KeyboardComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Ps2KeyboardComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
@ -305,6 +303,7 @@ Ps2KeyboardComponentNameGetControllerName (
|
||||
EFI_STATUS Status;
|
||||
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
|
||||
KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
|
||||
//
|
||||
// This is a device driver, so ChildHandle must be NULL.
|
||||
//
|
||||
@ -319,13 +318,14 @@ Ps2KeyboardComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the device context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiSimpleTextInProtocolGuid,
|
||||
(VOID **) &ConIn,
|
||||
(VOID **)&ConIn,
|
||||
gKeyboardControllerDriver.DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
|
@ -13,9 +13,7 @@ struct {
|
||||
UINT16 EfiScanCode;
|
||||
CHAR16 UnicodeChar;
|
||||
CHAR16 ShiftUnicodeChar;
|
||||
}
|
||||
ConvertKeyboardScanCodeToEfiKey[] = {
|
||||
|
||||
} ConvertKeyboardScanCodeToEfiKey[] = {
|
||||
{
|
||||
0x01, // Escape
|
||||
SCAN_ESC,
|
||||
@ -335,7 +333,7 @@ ConvertKeyboardScanCodeToEfiKey[] = {
|
||||
L'?'
|
||||
},
|
||||
{
|
||||
0x36, //Right Shift
|
||||
0x36, // Right Shift
|
||||
SCAN_NULL,
|
||||
0x0000,
|
||||
0x0000
|
||||
@ -347,7 +345,7 @@ ConvertKeyboardScanCodeToEfiKey[] = {
|
||||
L'*'
|
||||
},
|
||||
{
|
||||
0x38, //Left Alt/Extended Right Alt
|
||||
0x38, // Left Alt/Extended Right Alt
|
||||
SCAN_NULL,
|
||||
0x0000,
|
||||
0x0000
|
||||
@ -359,7 +357,7 @@ ConvertKeyboardScanCodeToEfiKey[] = {
|
||||
L' '
|
||||
},
|
||||
{
|
||||
0x3A, //CapsLock
|
||||
0x3A, // CapsLock
|
||||
SCAN_NULL,
|
||||
0x0000,
|
||||
0x0000
|
||||
@ -527,19 +525,19 @@ ConvertKeyboardScanCodeToEfiKey[] = {
|
||||
0x0000
|
||||
},
|
||||
{
|
||||
0x5B, //Left LOGO
|
||||
0x5B, // Left LOGO
|
||||
SCAN_NULL,
|
||||
0x0000,
|
||||
0x0000
|
||||
},
|
||||
{
|
||||
0x5C, //Right LOGO
|
||||
0x5C, // Right LOGO
|
||||
SCAN_NULL,
|
||||
0x0000,
|
||||
0x0000
|
||||
},
|
||||
{
|
||||
0x5D, //Menu key
|
||||
0x5D, // Menu key
|
||||
SCAN_NULL,
|
||||
0x0000,
|
||||
0x0000
|
||||
@ -559,8 +557,6 @@ UINTN mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
|
||||
|
||||
BOOLEAN mEnableMouseInterface;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Return the count of scancode in the queue.
|
||||
|
||||
@ -608,6 +604,7 @@ GetScancodeBufHead (
|
||||
if (GetScancodeBufCount (Queue) < Count) {
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
|
||||
//
|
||||
// retrieve the values
|
||||
//
|
||||
@ -645,6 +642,7 @@ PopScancodeBufHead (
|
||||
if (GetScancodeBufCount (Queue) < Count) {
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve and remove the values
|
||||
//
|
||||
@ -781,19 +779,19 @@ KeyboardTimerHandler (
|
||||
EFI_TPL OldTpl;
|
||||
KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
|
||||
ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;
|
||||
ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *)Context;
|
||||
|
||||
//
|
||||
// Enter critical section
|
||||
//
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
|
||||
if (((KEYBOARD_CONSOLE_IN_DEV *) Context)->KeyboardErr) {
|
||||
if (((KEYBOARD_CONSOLE_IN_DEV *)Context)->KeyboardErr) {
|
||||
//
|
||||
// Leave critical section and return
|
||||
//
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -806,13 +804,15 @@ KeyboardTimerHandler (
|
||||
|
||||
while ((KeyReadStatusRegister (ConsoleIn) & (KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT|KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA)) ==
|
||||
KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Read one byte of the scan code and store it into the memory buffer
|
||||
//
|
||||
Data = KeyReadDataRegister (ConsoleIn);
|
||||
PushScancodeBufTail (&ConsoleIn->ScancodeQueue, Data);
|
||||
}
|
||||
|
||||
KeyGetchar (ConsoleIn);
|
||||
|
||||
//
|
||||
@ -901,6 +901,7 @@ KeyboardWrite (
|
||||
if (RegEmptied == 0) {
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
//
|
||||
// Write it
|
||||
//
|
||||
@ -946,6 +947,7 @@ KeyboardCommand (
|
||||
if (RegEmptied == 0) {
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
//
|
||||
// issue the command
|
||||
//
|
||||
@ -1005,6 +1007,7 @@ KeyboardWaitForValue (
|
||||
if (Data == Value) {
|
||||
Data = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Read from 8042 (multiple times if needed)
|
||||
// until the expected value appears
|
||||
@ -1034,6 +1037,7 @@ KeyboardWaitForValue (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check results
|
||||
//
|
||||
@ -1042,7 +1046,6 @@ KeyboardWaitForValue (
|
||||
} else {
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1167,7 +1170,7 @@ KeyGetchar (
|
||||
ScancodeArrPos = 0;
|
||||
Status = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED0) {
|
||||
@ -1178,7 +1181,7 @@ KeyGetchar (
|
||||
ScancodeArrPos = 1;
|
||||
Status = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
} else if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED1) {
|
||||
//
|
||||
@ -1188,9 +1191,10 @@ KeyGetchar (
|
||||
ScancodeArrPos = 2;
|
||||
Status = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// if we reach this position, scancodes for a key is in buffer now,pop them
|
||||
//
|
||||
@ -1207,13 +1211,13 @@ KeyGetchar (
|
||||
// Check for special keys and update the driver state.
|
||||
//
|
||||
switch (ScanCode) {
|
||||
|
||||
case SCANCODE_CTRL_MAKE:
|
||||
if (Extend0) {
|
||||
ConsoleIn->RightCtrl = TRUE;
|
||||
} else {
|
||||
ConsoleIn->LeftCtrl = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
case SCANCODE_CTRL_BREAK:
|
||||
if (Extend0) {
|
||||
@ -1221,6 +1225,7 @@ KeyGetchar (
|
||||
} else {
|
||||
ConsoleIn->LeftCtrl = FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCANCODE_ALT_MAKE:
|
||||
@ -1229,6 +1234,7 @@ KeyGetchar (
|
||||
} else {
|
||||
ConsoleIn->LeftAlt = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
case SCANCODE_ALT_BREAK:
|
||||
if (Extend0) {
|
||||
@ -1236,6 +1242,7 @@ KeyGetchar (
|
||||
} else {
|
||||
ConsoleIn->LeftAlt = FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCANCODE_LEFT_SHIFT_MAKE:
|
||||
@ -1248,12 +1255,14 @@ KeyGetchar (
|
||||
ConsoleIn->LeftShift = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case SCANCODE_LEFT_SHIFT_BREAK:
|
||||
if (!Extend0) {
|
||||
ConsoleIn->LeftShift = FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCANCODE_RIGHT_SHIFT_MAKE:
|
||||
@ -1288,11 +1297,13 @@ KeyGetchar (
|
||||
if (Extend0) {
|
||||
ConsoleIn->SysReq = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
case SCANCODE_SYS_REQ_BREAK:
|
||||
if (Extend0) {
|
||||
ConsoleIn->SysReq = FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCANCODE_SYS_REQ_MAKE_WITH_ALT:
|
||||
@ -1303,18 +1314,19 @@ KeyGetchar (
|
||||
break;
|
||||
|
||||
case SCANCODE_CAPS_LOCK_MAKE:
|
||||
ConsoleIn->CapsLock = (BOOLEAN)!ConsoleIn->CapsLock;
|
||||
ConsoleIn->CapsLock = (BOOLEAN) !ConsoleIn->CapsLock;
|
||||
UpdateStatusLights (ConsoleIn);
|
||||
break;
|
||||
case SCANCODE_NUM_LOCK_MAKE:
|
||||
ConsoleIn->NumLock = (BOOLEAN)!ConsoleIn->NumLock;
|
||||
ConsoleIn->NumLock = (BOOLEAN) !ConsoleIn->NumLock;
|
||||
UpdateStatusLights (ConsoleIn);
|
||||
break;
|
||||
case SCANCODE_SCROLL_LOCK_MAKE:
|
||||
if (!Extend0) {
|
||||
ConsoleIn->ScrollLock = (BOOLEAN)!ConsoleIn->ScrollLock;
|
||||
ConsoleIn->ScrollLock = (BOOLEAN) !ConsoleIn->ScrollLock;
|
||||
UpdateStatusLights (ConsoleIn);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1333,9 +1345,10 @@ KeyGetchar (
|
||||
// Handle Ctrl+Alt+Del hotkey
|
||||
//
|
||||
if ((ConsoleIn->LeftCtrl || ConsoleIn->RightCtrl) &&
|
||||
(ConsoleIn->LeftAlt || ConsoleIn->RightAlt ) &&
|
||||
ScanCode == SCANCODE_DELETE_MAKE
|
||||
) {
|
||||
(ConsoleIn->LeftAlt || ConsoleIn->RightAlt) &&
|
||||
(ScanCode == SCANCODE_DELETE_MAKE)
|
||||
)
|
||||
{
|
||||
gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
|
||||
}
|
||||
|
||||
@ -1349,28 +1362,28 @@ KeyGetchar (
|
||||
//
|
||||
// Key Pad "/" shares the same scancode as that of "/" except Key Pad "/" has E0 prefix
|
||||
//
|
||||
if (Extend0 && ScanCode == 0x35) {
|
||||
if (Extend0 && (ScanCode == 0x35)) {
|
||||
KeyData.Key.UnicodeChar = L'/';
|
||||
KeyData.Key.ScanCode = SCAN_NULL;
|
||||
|
||||
//
|
||||
// PAUSE shares the same scancode as that of NUM except PAUSE has E1 prefix
|
||||
//
|
||||
} else if (Extend1 && ScanCode == SCANCODE_NUM_LOCK_MAKE) {
|
||||
} else if (Extend1 && (ScanCode == SCANCODE_NUM_LOCK_MAKE)) {
|
||||
KeyData.Key.UnicodeChar = CHAR_NULL;
|
||||
KeyData.Key.ScanCode = SCAN_PAUSE;
|
||||
|
||||
//
|
||||
// PAUSE shares the same scancode as that of SCROLL except PAUSE (CTRL pressed) has E0 prefix
|
||||
//
|
||||
} else if (Extend0 && ScanCode == SCANCODE_SCROLL_LOCK_MAKE) {
|
||||
} else if (Extend0 && (ScanCode == SCANCODE_SCROLL_LOCK_MAKE)) {
|
||||
KeyData.Key.UnicodeChar = CHAR_NULL;
|
||||
KeyData.Key.ScanCode = SCAN_PAUSE;
|
||||
|
||||
//
|
||||
// PRNT_SCRN shares the same scancode as that of Key Pad "*" except PRNT_SCRN has E0 prefix
|
||||
//
|
||||
} else if (Extend0 && ScanCode == SCANCODE_SYS_REQ_MAKE) {
|
||||
} else if (Extend0 && (ScanCode == SCANCODE_SYS_REQ_MAKE)) {
|
||||
KeyData.Key.UnicodeChar = CHAR_NULL;
|
||||
KeyData.Key.ScanCode = SCAN_NULL;
|
||||
|
||||
@ -1384,7 +1397,8 @@ KeyGetchar (
|
||||
KeyData.Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar;
|
||||
|
||||
if ((ConsoleIn->LeftShift || ConsoleIn->RightShift) &&
|
||||
(ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar != ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar)) {
|
||||
(ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar != ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar))
|
||||
{
|
||||
KeyData.Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar;
|
||||
//
|
||||
// Need not return associated shift state if a class of printable characters that
|
||||
@ -1392,16 +1406,18 @@ KeyGetchar (
|
||||
//
|
||||
KeyData.KeyState.KeyShiftState &= ~(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED);
|
||||
}
|
||||
|
||||
//
|
||||
// alphabetic key is affected by CapsLock State
|
||||
//
|
||||
if (ConsoleIn->CapsLock) {
|
||||
if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {
|
||||
KeyData.Key.UnicodeChar = (UINT16) (KeyData.Key.UnicodeChar - L'a' + L'A');
|
||||
} else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {
|
||||
KeyData.Key.UnicodeChar = (UINT16) (KeyData.Key.UnicodeChar - L'A' + L'a');
|
||||
if ((KeyData.Key.UnicodeChar >= L'a') && (KeyData.Key.UnicodeChar <= L'z')) {
|
||||
KeyData.Key.UnicodeChar = (UINT16)(KeyData.Key.UnicodeChar - L'a' + L'A');
|
||||
} else if ((KeyData.Key.UnicodeChar >= L'A') && (KeyData.Key.UnicodeChar <= L'Z')) {
|
||||
KeyData.Key.UnicodeChar = (UINT16)(KeyData.Key.UnicodeChar - L'A' + L'a');
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1410,10 +1426,10 @@ KeyGetchar (
|
||||
//
|
||||
// distinguish numeric key pad keys' 'up symbol' and 'down symbol'
|
||||
//
|
||||
if (ScanCode >= 0x47 && ScanCode <= 0x53) {
|
||||
if ((ScanCode >= 0x47) && (ScanCode <= 0x53)) {
|
||||
if (ConsoleIn->NumLock && !(ConsoleIn->LeftShift || ConsoleIn->RightShift) && !Extend0) {
|
||||
KeyData.Key.ScanCode = SCAN_NULL;
|
||||
} else if (ScanCode != 0x4a && ScanCode != 0x4e) {
|
||||
} else if ((ScanCode != 0x4a) && (ScanCode != 0x4e)) {
|
||||
KeyData.Key.UnicodeChar = CHAR_NULL;
|
||||
}
|
||||
}
|
||||
@ -1421,9 +1437,9 @@ KeyGetchar (
|
||||
//
|
||||
// If the key can not be converted then just return.
|
||||
//
|
||||
if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
|
||||
if ((KeyData.Key.ScanCode == SCAN_NULL) && (KeyData.Key.UnicodeChar == CHAR_NULL)) {
|
||||
if (!ConsoleIn->IsSupportPartialKey) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1485,7 +1501,7 @@ InitKeyboard (
|
||||
gBS->LocateProtocol (
|
||||
&gEfiPs2PolicyProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &Ps2Policy
|
||||
(VOID **)&Ps2Policy
|
||||
);
|
||||
|
||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||
@ -1501,8 +1517,9 @@ InitKeyboard (
|
||||
if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA) != 0) {
|
||||
while (!EFI_ERROR (Status) && TryTime < KEYBOARD_MAX_TRY) {
|
||||
Status = KeyboardRead (ConsoleIn, &CommandByte);
|
||||
TryTime ++;
|
||||
TryTime++;
|
||||
}
|
||||
|
||||
//
|
||||
// Exceed the max try times. The device may be error.
|
||||
//
|
||||
@ -1511,6 +1528,7 @@ InitKeyboard (
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// We should disable mouse interface during the initialization process
|
||||
// since mouse device output could block keyboard device output in the
|
||||
@ -1544,6 +1562,7 @@ InitKeyboard (
|
||||
KeyboardError (ConsoleIn, L"\n\r");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Test the mouse enabling bit
|
||||
//
|
||||
@ -1597,16 +1616,17 @@ InitKeyboard (
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Don't enable mouse interface later
|
||||
//
|
||||
mEnableMouseInterface = FALSE;
|
||||
|
||||
}
|
||||
|
||||
if (Ps2Policy != NULL) {
|
||||
Ps2Policy->Ps2InitHardware (ConsoleIn->Handle);
|
||||
}
|
||||
|
||||
//
|
||||
// Write 8042 Command Byte, set System Flag
|
||||
// While at the same time:
|
||||
@ -1692,6 +1712,7 @@ InitKeyboard (
|
||||
);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Keyboard reset with a BAT(Basic Assurance Test)
|
||||
//
|
||||
@ -1706,6 +1727,7 @@ InitKeyboard (
|
||||
KeyboardError (ConsoleIn, L"Some specific value not acquired from 8042 controller!\n\r");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// wait for BAT completion code
|
||||
//
|
||||
@ -1760,6 +1782,7 @@ InitKeyboard (
|
||||
KeyboardError (ConsoleIn, L"Some specific value not acquired from 8042 controller!\n\r");
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
if (Ps2Policy != NULL) {
|
||||
if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_CAPSLOCK) == EFI_KEYBOARD_CAPSLOCK) {
|
||||
@ -1774,6 +1797,7 @@ InitKeyboard (
|
||||
ConsoleIn->ScrollLock = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Keyboard Lights
|
||||
//
|
||||
@ -1783,6 +1807,7 @@ InitKeyboard (
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// At last, we can now enable the mouse interface if appropriate
|
||||
//
|
||||
@ -1804,10 +1829,8 @@ Done:
|
||||
} else {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
|
||||
If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
|
||||
@ -1840,6 +1863,7 @@ CheckKeyboardConnect (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// wait for 1s
|
||||
//
|
||||
@ -1860,4 +1884,3 @@ CheckKeyboardConnect (
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Ps2Keyboard.h"
|
||||
|
||||
/**
|
||||
@ -23,7 +22,7 @@ IsEfikeyBufEmpty (
|
||||
IN EFI_KEY_QUEUE *Queue
|
||||
)
|
||||
{
|
||||
return (BOOLEAN) (Queue->Head == Queue->Tail);
|
||||
return (BOOLEAN)(Queue->Head == Queue->Tail);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,12 +43,14 @@ PopEfikeyBufHead (
|
||||
if (IsEfikeyBufEmpty (Queue)) {
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve and remove the values
|
||||
//
|
||||
if (KeyData != NULL) {
|
||||
CopyMem (KeyData, &Queue->Buffer[Queue->Head], sizeof (EFI_KEY_DATA));
|
||||
}
|
||||
|
||||
Queue->Head = (Queue->Head + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -72,6 +73,7 @@ PushEfikeyBufTail (
|
||||
//
|
||||
PopEfikeyBufHead (Queue, NULL);
|
||||
}
|
||||
|
||||
CopyMem (&Queue->Buffer[Queue->Tail], KeyData, sizeof (EFI_KEY_DATA));
|
||||
Queue->Tail = (Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;
|
||||
}
|
||||
@ -98,24 +100,27 @@ 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;
|
||||
}
|
||||
|
||||
//
|
||||
// Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
|
||||
//
|
||||
if (RegsiteredData->KeyState.KeyShiftState != 0 &&
|
||||
RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
|
||||
if ((RegsiteredData->KeyState.KeyShiftState != 0) &&
|
||||
(RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (RegsiteredData->KeyState.KeyToggleState != 0 &&
|
||||
RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
|
||||
|
||||
if ((RegsiteredData->KeyState.KeyToggleState != 0) &&
|
||||
(RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,6 +237,7 @@ KeyboardEfiReset (
|
||||
ConsoleIn->DevicePath
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Report the status If keyboard is locked
|
||||
//
|
||||
@ -280,21 +286,23 @@ KeyboardReadKeyStroke (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// If it is partial keystroke, skip it.
|
||||
//
|
||||
if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
|
||||
if ((KeyData.Key.ScanCode == SCAN_NULL) && (KeyData.Key.UnicodeChar == CHAR_NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Translate the CTRL-Alpha characters to their corresponding control value
|
||||
// (ctrl-a = 0x0001 through ctrl-Z = 0x001A)
|
||||
//
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +330,7 @@ KeyboardWaitForKey (
|
||||
KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
EFI_KEY_DATA KeyData;
|
||||
|
||||
ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;
|
||||
ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *)Context;
|
||||
|
||||
//
|
||||
// Enter critical section
|
||||
@ -344,10 +352,11 @@ KeyboardWaitForKey (
|
||||
&(ConsoleIn->EfiKeyQueue.Buffer[ConsoleIn->EfiKeyQueue.Head]),
|
||||
sizeof (EFI_KEY_DATA)
|
||||
);
|
||||
if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
|
||||
if ((KeyData.Key.ScanCode == SCAN_NULL) && (KeyData.Key.UnicodeChar == CHAR_NULL)) {
|
||||
PopEfikeyBufHead (&ConsoleIn->EfiKeyQueue, &KeyData);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// if there is pending value key, signal the event.
|
||||
//
|
||||
@ -355,6 +364,7 @@ KeyboardWaitForKey (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Leave critical section and return
|
||||
//
|
||||
@ -501,12 +511,15 @@ KeyboardSetState (
|
||||
if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {
|
||||
ConsoleInDev->ScrollLock = TRUE;
|
||||
}
|
||||
|
||||
if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {
|
||||
ConsoleInDev->NumLock = TRUE;
|
||||
}
|
||||
|
||||
if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {
|
||||
ConsoleInDev->CapsLock = TRUE;
|
||||
}
|
||||
|
||||
if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) {
|
||||
ConsoleInDev->IsSupportPartialKey = TRUE;
|
||||
}
|
||||
@ -523,7 +536,6 @@ Exit:
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -560,7 +572,7 @@ KeyboardRegisterKeyNotify (
|
||||
KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
|
||||
KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
|
||||
|
||||
if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
|
||||
if ((KeyData == NULL) || (NotifyHandle == NULL) || (KeyNotificationFunction == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -593,7 +605,7 @@ KeyboardRegisterKeyNotify (
|
||||
//
|
||||
// Allocate resource to save the notification function
|
||||
//
|
||||
NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));
|
||||
NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *)AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));
|
||||
if (NewNotify == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Exit;
|
||||
@ -613,7 +625,6 @@ Exit:
|
||||
//
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -703,7 +714,7 @@ KeyNotifyProcessHandler (
|
||||
KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;
|
||||
ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *)Context;
|
||||
|
||||
//
|
||||
// Invoke notification functions.
|
||||
@ -722,6 +733,7 @@ KeyNotifyProcessHandler (
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
|
||||
CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
|
||||
if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {
|
||||
@ -730,4 +742,3 @@ KeyNotifyProcessHandler (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
|
||||
/**
|
||||
Test controller is a keyboard Controller.
|
||||
|
||||
@ -125,7 +126,7 @@ KbdControllerDriverSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath,
|
||||
(VOID **)&DevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -135,16 +136,17 @@ KbdControllerDriverSupported (
|
||||
}
|
||||
|
||||
do {
|
||||
Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;
|
||||
Acpi = (ACPI_HID_DEVICE_PATH *)DevicePath;
|
||||
DevicePath = NextDevicePathNode (DevicePath);
|
||||
} while (!IsDevicePathEnd (DevicePath));
|
||||
|
||||
if (DevicePathType (Acpi) != ACPI_DEVICE_PATH ||
|
||||
(DevicePathSubType (Acpi) != ACPI_DP && DevicePathSubType (Acpi) != ACPI_EXTENDED_DP)) {
|
||||
if ((DevicePathType (Acpi) != ACPI_DEVICE_PATH) ||
|
||||
((DevicePathSubType (Acpi) != ACPI_DP) && (DevicePathSubType (Acpi) != ACPI_EXTENDED_DP)))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (Acpi->HID != EISA_PNP_ID (0x303) || Acpi->UID != 0) {
|
||||
if ((Acpi->HID != EISA_PNP_ID (0x303)) || (Acpi->UID != 0)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -154,7 +156,7 @@ KbdControllerDriverSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiSioProtocolGuid,
|
||||
(VOID **) &Sio,
|
||||
(VOID **)&Sio,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -206,7 +208,7 @@ KbdControllerDriverStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath,
|
||||
(VOID **)&DevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -214,6 +216,7 @@ KbdControllerDriverStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Report that the keyboard is being enabled
|
||||
//
|
||||
@ -229,7 +232,7 @@ KbdControllerDriverStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiSioProtocolGuid,
|
||||
(VOID **) &Sio,
|
||||
(VOID **)&Sio,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -237,6 +240,7 @@ KbdControllerDriverStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate private data
|
||||
//
|
||||
@ -246,6 +250,7 @@ KbdControllerDriverStart (
|
||||
StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Setup the device instance
|
||||
//
|
||||
@ -304,6 +309,7 @@ KbdControllerDriverStart (
|
||||
StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Setup the WaitForKeyEx event
|
||||
//
|
||||
@ -319,6 +325,7 @@ KbdControllerDriverStart (
|
||||
StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
// Setup a periodic timer, used for reading keystrokes at a fixed interval
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
@ -396,7 +403,6 @@ KbdControllerDriverStart (
|
||||
FALSE
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Install protocol interfaces for the keyboard device.
|
||||
//
|
||||
@ -434,16 +440,20 @@ ErrorExit:
|
||||
if ((ConsoleIn != NULL) && (ConsoleIn->TimerEvent != NULL)) {
|
||||
gBS->CloseEvent (ConsoleIn->TimerEvent);
|
||||
}
|
||||
|
||||
if ((ConsoleIn != NULL) && (ConsoleIn->ConInEx.WaitForKeyEx != NULL)) {
|
||||
gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);
|
||||
}
|
||||
|
||||
if ((ConsoleIn != NULL) && (ConsoleIn->KeyNotifyProcessEvent != NULL)) {
|
||||
gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);
|
||||
}
|
||||
|
||||
KbdFreeNotifyList (&ConsoleIn->NotifyList);
|
||||
if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {
|
||||
FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);
|
||||
}
|
||||
|
||||
//
|
||||
// Since there will be no timer handler for keyboard input any more,
|
||||
// exhaust input data just in case there is still keyboard data left
|
||||
@ -451,7 +461,7 @@ ErrorExit:
|
||||
if (ConsoleIn != NULL) {
|
||||
Status1 = EFI_SUCCESS;
|
||||
while (!EFI_ERROR (Status1) && (Status != EFI_DEVICE_ERROR)) {
|
||||
Status1 = KeyboardRead (ConsoleIn, &Data);;
|
||||
Status1 = KeyboardRead (ConsoleIn, &Data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -503,7 +513,7 @@ KbdControllerDriverStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiSimpleTextInProtocolGuid,
|
||||
(VOID **) &ConIn,
|
||||
(VOID **)&ConIn,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -511,6 +521,7 @@ KbdControllerDriverStop (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiSimpleTextInputExProtocolGuid,
|
||||
@ -545,8 +556,9 @@ KbdControllerDriverStop (
|
||||
//
|
||||
Status = EFI_SUCCESS;
|
||||
while (!EFI_ERROR (Status)) {
|
||||
Status = KeyboardRead (ConsoleIn, &Data);;
|
||||
Status = KeyboardRead (ConsoleIn, &Data);
|
||||
}
|
||||
|
||||
//
|
||||
// Uninstall the SimpleTextIn and SimpleTextInEx protocols
|
||||
//
|
||||
@ -576,14 +588,17 @@ KbdControllerDriverStop (
|
||||
gBS->CloseEvent ((ConsoleIn->ConIn).WaitForKey);
|
||||
(ConsoleIn->ConIn).WaitForKey = NULL;
|
||||
}
|
||||
|
||||
if (ConsoleIn->ConInEx.WaitForKeyEx != NULL) {
|
||||
gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);
|
||||
ConsoleIn->ConInEx.WaitForKeyEx = NULL;
|
||||
}
|
||||
|
||||
if (ConsoleIn->KeyNotifyProcessEvent != NULL) {
|
||||
gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);
|
||||
ConsoleIn->KeyNotifyProcessEvent = NULL;
|
||||
}
|
||||
|
||||
KbdFreeNotifyList (&ConsoleIn->NotifyList);
|
||||
FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);
|
||||
gBS->FreePool (ConsoleIn);
|
||||
@ -609,6 +624,7 @@ KbdFreeNotifyList (
|
||||
if (ListHead == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
while (!IsListEmpty (ListHead)) {
|
||||
NotifyNode = CR (
|
||||
ListHead->ForwardLink,
|
||||
@ -635,7 +651,7 @@ KbdFreeNotifyList (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializePs2Keyboard(
|
||||
InitializePs2Keyboard (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
@ -655,7 +671,5 @@ InitializePs2Keyboard(
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,7 @@ typedef struct {
|
||||
//
|
||||
// Driver entry point
|
||||
//
|
||||
|
||||
/**
|
||||
The user Entry Point for module Ps2Keyboard. The user code starts with this function.
|
||||
|
||||
@ -172,11 +173,11 @@ InstallPs2KeyboardDriver (
|
||||
#define SCANCODE_NUM_LOCK_MAKE 0x45
|
||||
#define SCANCODE_SCROLL_LOCK_MAKE 0x46
|
||||
#define SCANCODE_DELETE_MAKE 0x53
|
||||
#define SCANCODE_LEFT_LOGO_MAKE 0x5B //GUI key defined in Keyboard scan code
|
||||
#define SCANCODE_LEFT_LOGO_MAKE 0x5B// GUI key defined in Keyboard scan code
|
||||
#define SCANCODE_LEFT_LOGO_BREAK 0xDB
|
||||
#define SCANCODE_RIGHT_LOGO_MAKE 0x5C
|
||||
#define SCANCODE_RIGHT_LOGO_BREAK 0xDC
|
||||
#define SCANCODE_MENU_MAKE 0x5D //APPS key defined in Keyboard scan code
|
||||
#define SCANCODE_MENU_MAKE 0x5D// APPS key defined in Keyboard scan code
|
||||
#define SCANCODE_MENU_BREAK 0xDD
|
||||
#define SCANCODE_SYS_REQ_MAKE 0x37
|
||||
#define SCANCODE_SYS_REQ_BREAK 0xB7
|
||||
@ -185,7 +186,6 @@ InstallPs2KeyboardDriver (
|
||||
|
||||
#define SCANCODE_MAX_MAKE 0x60
|
||||
|
||||
|
||||
#define KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA BIT0 ///< 0 - Output register has no data; 1 - Output register has data
|
||||
#define KEYBOARD_STATUS_REGISTER_HAS_INPUT_DATA BIT1 ///< 0 - Input register has no data; 1 - Input register has data
|
||||
#define KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG BIT2 ///< Set to 0 after power on reset
|
||||
@ -211,7 +211,6 @@ InstallPs2KeyboardDriver (
|
||||
#define KEYBOARD_8048_RETURN_8042_BAT_ERROR 0xFC
|
||||
#define KEYBOARD_8048_RETURN_8042_ACK 0xFA
|
||||
|
||||
|
||||
//
|
||||
// Keyboard Controller Status
|
||||
//
|
||||
@ -221,6 +220,7 @@ InstallPs2KeyboardDriver (
|
||||
//
|
||||
// Other functions that are used among .c files
|
||||
//
|
||||
|
||||
/**
|
||||
Show keyboard status lights according to
|
||||
indicators in ConsoleIn.
|
||||
@ -294,7 +294,6 @@ InitKeyboard (
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Timer event handler: read a series of scancodes from 8042
|
||||
and put them into memory scancode buffer.
|
||||
|
@ -34,6 +34,7 @@ KbcSelfTest (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Read return code
|
||||
//
|
||||
@ -45,6 +46,7 @@ KbcSelfTest (
|
||||
if (Data != 0x55) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Set system flag
|
||||
//
|
||||
@ -167,6 +169,7 @@ CheckKbStatus (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Check keyboard enable or not
|
||||
//
|
||||
@ -201,6 +204,7 @@ PS2MouseReset (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Check BAT Complete Code
|
||||
//
|
||||
@ -212,6 +216,7 @@ PS2MouseReset (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Check BAT Complete Code
|
||||
//
|
||||
@ -343,7 +348,6 @@ PS2MouseGetPacket (
|
||||
// State machine to get mouse packet
|
||||
//
|
||||
while (1) {
|
||||
|
||||
switch (State) {
|
||||
case PS2_READ_BYTE_ONE:
|
||||
//
|
||||
@ -370,6 +374,7 @@ PS2MouseGetPacket (
|
||||
KbcDisableKb ();
|
||||
KbcEnableAux ();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PS2_READ_DATA_BYTE:
|
||||
@ -398,6 +403,7 @@ PS2MouseGetPacket (
|
||||
if (KeyboardEnable) {
|
||||
KbcEnableKb ();
|
||||
}
|
||||
|
||||
//
|
||||
// Decode the packet
|
||||
//
|
||||
@ -415,29 +421,29 @@ PS2MouseGetPacket (
|
||||
//
|
||||
// First, Clear X and Y high 8 bits
|
||||
//
|
||||
RelativeMovementX = (INT16) (RelativeMovementX & 0xFF);
|
||||
RelativeMovementY = (INT16) (RelativeMovementY & 0xFF);
|
||||
RelativeMovementX = (INT16)(RelativeMovementX & 0xFF);
|
||||
RelativeMovementY = (INT16)(RelativeMovementY & 0xFF);
|
||||
//
|
||||
// Second, if the 9-bit signed twos complement integer is negative, set the high 8 bit 0xff
|
||||
//
|
||||
if ((Packet[0] & 0x10) != 0) {
|
||||
RelativeMovementX = (INT16) (RelativeMovementX | 0xFF00);
|
||||
RelativeMovementX = (INT16)(RelativeMovementX | 0xFF00);
|
||||
}
|
||||
|
||||
if ((Packet[0] & 0x20) != 0) {
|
||||
RelativeMovementY = (INT16) (RelativeMovementY | 0xFF00);
|
||||
RelativeMovementY = (INT16)(RelativeMovementY | 0xFF00);
|
||||
}
|
||||
|
||||
|
||||
RButton = (UINT8) (Packet[0] & 0x2);
|
||||
LButton = (UINT8) (Packet[0] & 0x1);
|
||||
RButton = (UINT8)(Packet[0] & 0x2);
|
||||
LButton = (UINT8)(Packet[0] & 0x1);
|
||||
|
||||
//
|
||||
// Update mouse state
|
||||
//
|
||||
MouseDev->State.RelativeMovementX += RelativeMovementX;
|
||||
MouseDev->State.RelativeMovementY -= RelativeMovementY;
|
||||
MouseDev->State.RightButton = (UINT8) (RButton ? TRUE : FALSE);
|
||||
MouseDev->State.LeftButton = (UINT8) (LButton ? TRUE : FALSE);
|
||||
MouseDev->State.RightButton = (UINT8)(RButton ? TRUE : FALSE);
|
||||
MouseDev->State.LeftButton = (UINT8)(LButton ? TRUE : FALSE);
|
||||
MouseDev->StateChanged = TRUE;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -478,17 +484,18 @@ PS2MouseRead (
|
||||
}
|
||||
|
||||
for (BytesRead = 0; BytesRead < *BufSize; BytesRead++) {
|
||||
|
||||
Status = WaitOutputFull (TIMEOUT);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
Buffer[BytesRead] = IoRead8 (KBC_DATA_PORT);
|
||||
}
|
||||
|
||||
//
|
||||
// Verify the correct number of bytes read
|
||||
//
|
||||
if (BytesRead == 0 || BytesRead != *BufSize) {
|
||||
if ((BytesRead == 0) || (BytesRead != *BufSize)) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -499,6 +506,7 @@ PS2MouseRead (
|
||||
//
|
||||
// 8042 I/O function
|
||||
//
|
||||
|
||||
/**
|
||||
I/O work flow of outing 8042 command.
|
||||
|
||||
@ -521,6 +529,7 @@ Out8042Command (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Send command
|
||||
//
|
||||
@ -548,6 +557,7 @@ Out8042Data (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Wait keyboard controller input buffer empty
|
||||
//
|
||||
@ -623,6 +633,7 @@ Out8042AuxCommand (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Send write to auxiliary device command
|
||||
//
|
||||
@ -632,6 +643,7 @@ Out8042AuxCommand (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Send auxiliary device command
|
||||
//
|
||||
@ -650,13 +662,11 @@ Out8042AuxCommand (
|
||||
// Receive mouse acknowledge, command send success
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
|
||||
} else if (Resend) {
|
||||
//
|
||||
// Resend fail
|
||||
//
|
||||
return EFI_DEVICE_ERROR;
|
||||
|
||||
} else if (Data == PS2_RESEND) {
|
||||
//
|
||||
// Resend command
|
||||
@ -665,13 +675,11 @@ Out8042AuxCommand (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
} else {
|
||||
//
|
||||
// Invalid return code
|
||||
//
|
||||
return EFI_DEVICE_ERROR;
|
||||
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -691,6 +699,7 @@ Out8042AuxData (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Wait keyboard controller input buffer empty
|
||||
//
|
||||
@ -698,6 +707,7 @@ Out8042AuxData (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Send write to auxiliary device command
|
||||
//
|
||||
@ -746,7 +756,6 @@ In8042AuxData (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check keyboard controller status, if it is output buffer full and for auxiliary device.
|
||||
|
||||
|
@ -268,6 +268,7 @@ PS2MouseRead (
|
||||
//
|
||||
// 8042 I/O function
|
||||
//
|
||||
|
||||
/**
|
||||
I/O work flow of outing 8042 command.
|
||||
|
||||
@ -386,4 +387,3 @@ WaitOutputFull (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -21,12 +21,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentNam
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2MouseComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2MouseComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)Ps2MouseComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)Ps2MouseComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2MouseDriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
@ -182,6 +181,7 @@ Ps2MouseComponentNameGetControllerName (
|
||||
if (ChildHandle != NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Controller's handle
|
||||
//
|
||||
@ -190,13 +190,14 @@ Ps2MouseComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the device context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiSimplePointerProtocolGuid,
|
||||
(VOID **) &SimplePointerProtocol,
|
||||
(VOID **)&SimplePointerProtocol,
|
||||
gPS2MouseDriver.DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
|
@ -55,7 +55,7 @@ PS2MouseDriverSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath,
|
||||
(VOID **)&DevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -65,12 +65,13 @@ PS2MouseDriverSupported (
|
||||
}
|
||||
|
||||
do {
|
||||
Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;
|
||||
Acpi = (ACPI_HID_DEVICE_PATH *)DevicePath;
|
||||
DevicePath = NextDevicePathNode (DevicePath);
|
||||
} while (!IsDevicePathEnd (DevicePath));
|
||||
|
||||
if (DevicePathType (Acpi) != ACPI_DEVICE_PATH ||
|
||||
(DevicePathSubType (Acpi) != ACPI_DP && DevicePathSubType (Acpi) != ACPI_EXTENDED_DP)) {
|
||||
if ((DevicePathType (Acpi) != ACPI_DEVICE_PATH) ||
|
||||
((DevicePathSubType (Acpi) != ACPI_DP) && (DevicePathSubType (Acpi) != ACPI_EXTENDED_DP)))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -104,7 +105,7 @@ PS2MouseDriverSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiSioProtocolGuid,
|
||||
(VOID **) &Sio,
|
||||
(VOID **)&Sio,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -165,7 +166,7 @@ PS2MouseDriverStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath,
|
||||
(VOID **)&DevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -173,6 +174,7 @@ PS2MouseDriverStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Report that the keyboard is being enabled
|
||||
//
|
||||
@ -188,7 +190,7 @@ PS2MouseDriverStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiSioProtocolGuid,
|
||||
(VOID **) &Sio,
|
||||
(VOID **)&Sio,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -196,6 +198,7 @@ PS2MouseDriverStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Raise TPL to avoid keyboard operation impact
|
||||
//
|
||||
@ -209,6 +212,7 @@ PS2MouseDriverStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Setup the device instance
|
||||
//
|
||||
@ -307,6 +311,7 @@ PS2MouseDriverStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Setup a periodic timer, used to poll mouse state
|
||||
//
|
||||
@ -321,6 +326,7 @@ PS2MouseDriverStart (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Start timer to poll mouse (100 samples per second)
|
||||
//
|
||||
@ -346,7 +352,6 @@ PS2MouseDriverStart (
|
||||
FALSE
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Install protocol interfaces for the mouse device.
|
||||
//
|
||||
@ -455,7 +460,7 @@ PS2MouseDriverStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiSimplePointerProtocolGuid,
|
||||
(VOID **) &SimplePointerProtocol,
|
||||
(VOID **)&SimplePointerProtocol,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -625,6 +630,7 @@ MouseReset (
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
@ -723,7 +729,7 @@ MouseWaitForInput (
|
||||
{
|
||||
PS2_MOUSE_DEV *MouseDev;
|
||||
|
||||
MouseDev = (PS2_MOUSE_DEV *) Context;
|
||||
MouseDev = (PS2_MOUSE_DEV *)Context;
|
||||
|
||||
//
|
||||
// Someone is waiting on the mouse event, if there's
|
||||
@ -732,7 +738,6 @@ MouseWaitForInput (
|
||||
if (MouseDev->StateChanged) {
|
||||
gBS->SignalEvent (Event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -753,7 +758,7 @@ PollMouse (
|
||||
{
|
||||
PS2_MOUSE_DEV *MouseDev;
|
||||
|
||||
MouseDev = (PS2_MOUSE_DEV *) Context;
|
||||
MouseDev = (PS2_MOUSE_DEV *)Context;
|
||||
|
||||
//
|
||||
// Polling mouse packet data
|
||||
@ -773,7 +778,7 @@ PollMouse (
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializePs2Mouse(
|
||||
InitializePs2Mouse (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
@ -793,7 +798,5 @@ InitializePs2Mouse(
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -99,6 +99,7 @@ typedef struct {
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. Any ControllerHandle
|
||||
than contains a IsaIo protocol can be supported.
|
||||
@ -170,6 +171,7 @@ PS2MouseDriverStop (
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -217,7 +219,6 @@ Ps2MouseComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ehci.h"
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -23,18 +22,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName =
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EhciComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EhciComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EhciComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EhciComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = {
|
||||
{ "eng;en", L"Usb Ehci Driver" },
|
||||
{ NULL , NULL }
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -179,6 +176,7 @@ EhciComponentNameGetControllerName (
|
||||
if (ChildHandle != NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure this driver is currently managing ControllerHandle
|
||||
//
|
||||
@ -190,13 +188,14 @@ EhciComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the device context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiUsb2HcProtocolGuid,
|
||||
(VOID **) &Usb2Hc,
|
||||
(VOID **)&Usb2Hc,
|
||||
gEhciDriverBinding.DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -214,5 +213,4 @@ EhciComponentNameGetControllerName (
|
||||
ControllerName,
|
||||
(BOOLEAN)(This == &gEhciComponentName)
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _COMPONENT_NAME_H_
|
||||
#define _COMPONENT_NAME_H_
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -58,7 +57,6 @@ EhciComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -138,4 +136,3 @@ EhciComponentNameGetControllerName (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Ehci.h"
|
||||
|
||||
//
|
||||
@ -24,23 +23,23 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// to the UEFI protocol's port state (change).
|
||||
//
|
||||
USB_PORT_STATE_MAP mUsbPortStateMap[] = {
|
||||
{PORTSC_CONN, USB_PORT_STAT_CONNECTION},
|
||||
{PORTSC_ENABLED, USB_PORT_STAT_ENABLE},
|
||||
{PORTSC_SUSPEND, USB_PORT_STAT_SUSPEND},
|
||||
{PORTSC_OVERCUR, USB_PORT_STAT_OVERCURRENT},
|
||||
{PORTSC_RESET, USB_PORT_STAT_RESET},
|
||||
{PORTSC_POWER, USB_PORT_STAT_POWER},
|
||||
{PORTSC_OWNER, USB_PORT_STAT_OWNER}
|
||||
{ PORTSC_CONN, USB_PORT_STAT_CONNECTION },
|
||||
{ PORTSC_ENABLED, USB_PORT_STAT_ENABLE },
|
||||
{ PORTSC_SUSPEND, USB_PORT_STAT_SUSPEND },
|
||||
{ PORTSC_OVERCUR, USB_PORT_STAT_OVERCURRENT },
|
||||
{ PORTSC_RESET, USB_PORT_STAT_RESET },
|
||||
{ PORTSC_POWER, USB_PORT_STAT_POWER },
|
||||
{ PORTSC_OWNER, USB_PORT_STAT_OWNER }
|
||||
};
|
||||
|
||||
USB_PORT_STATE_MAP mUsbPortChangeMap[] = {
|
||||
{PORTSC_CONN_CHANGE, USB_PORT_STAT_C_CONNECTION},
|
||||
{PORTSC_ENABLE_CHANGE, USB_PORT_STAT_C_ENABLE},
|
||||
{PORTSC_OVERCUR_CHANGE, USB_PORT_STAT_C_OVERCURRENT}
|
||||
{ PORTSC_CONN_CHANGE, USB_PORT_STAT_C_CONNECTION },
|
||||
{ PORTSC_ENABLE_CHANGE, USB_PORT_STAT_C_ENABLE },
|
||||
{ PORTSC_OVERCUR_CHANGE, USB_PORT_STAT_C_OVERCURRENT }
|
||||
};
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL
|
||||
gEhciDriverBinding = {
|
||||
gEhciDriverBinding = {
|
||||
EhcDriverBindingSupported,
|
||||
EhcDriverBindingStart,
|
||||
EhcDriverBindingStop,
|
||||
@ -82,8 +81,8 @@ EhcGetCapability (
|
||||
Ehc = EHC_FROM_THIS (This);
|
||||
|
||||
*MaxSpeed = EFI_USB_SPEED_HIGH;
|
||||
*PortNumber = (UINT8) (Ehc->HcStructParams & HCSP_NPORTS);
|
||||
*Is64BitCapable = (UINT8) Ehc->Support64BitDma;
|
||||
*PortNumber = (UINT8)(Ehc->HcStructParams & HCSP_NPORTS);
|
||||
*Is64BitCapable = (UINT8)Ehc->Support64BitDma;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable));
|
||||
|
||||
@ -91,7 +90,6 @@ EhcGetCapability (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Provides software reset for the USB host controller.
|
||||
|
||||
@ -186,7 +184,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieve the current state of the USB host controller.
|
||||
|
||||
@ -229,7 +226,6 @@ EhcGetState (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets the USB host controller to a specific state.
|
||||
|
||||
@ -304,7 +300,6 @@ EhcSetState (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves the current status of a USB root hub port.
|
||||
|
||||
@ -352,7 +347,7 @@ EhcGetRootHubPortStatus (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Offset = (UINT32) (EHC_PORT_STAT_OFFSET + (4 * PortNumber));
|
||||
Offset = (UINT32)(EHC_PORT_STAT_OFFSET + (4 * PortNumber));
|
||||
PortStatus->PortStatus = 0;
|
||||
PortStatus->PortChangeStatus = 0;
|
||||
|
||||
@ -370,7 +365,6 @@ EhcGetRootHubPortStatus (
|
||||
//
|
||||
if (EHC_BIT_IS_SET (State, PORTSC_LINESTATE_K)) {
|
||||
PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED;
|
||||
|
||||
} else if (EHC_BIT_IS_SET (State, PORTSC_ENABLED)) {
|
||||
PortStatus->PortStatus |= USB_PORT_STAT_HIGH_SPEED;
|
||||
}
|
||||
@ -382,7 +376,7 @@ EhcGetRootHubPortStatus (
|
||||
|
||||
for (Index = 0; Index < MapSize; Index++) {
|
||||
if (EHC_BIT_IS_SET (State, mUsbPortStateMap[Index].HwState)) {
|
||||
PortStatus->PortStatus = (UINT16) (PortStatus->PortStatus | mUsbPortStateMap[Index].UefiState);
|
||||
PortStatus->PortStatus = (UINT16)(PortStatus->PortStatus | mUsbPortStateMap[Index].UefiState);
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,7 +384,7 @@ EhcGetRootHubPortStatus (
|
||||
|
||||
for (Index = 0; Index < MapSize; Index++) {
|
||||
if (EHC_BIT_IS_SET (State, mUsbPortChangeMap[Index].HwState)) {
|
||||
PortStatus->PortChangeStatus = (UINT16) (PortStatus->PortChangeStatus | mUsbPortChangeMap[Index].UefiState);
|
||||
PortStatus->PortChangeStatus = (UINT16)(PortStatus->PortChangeStatus | mUsbPortChangeMap[Index].UefiState);
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,7 +393,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets a feature for the specified root hub port.
|
||||
|
||||
@ -438,7 +431,7 @@ EhcSetRootHubPortFeature (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Offset = (UINT32) (EHC_PORT_STAT_OFFSET + (4 * PortNumber));
|
||||
Offset = (UINT32)(EHC_PORT_STAT_OFFSET + (4 * PortNumber));
|
||||
State = EhcReadOpReg (Ehc, Offset);
|
||||
|
||||
//
|
||||
@ -491,6 +484,7 @@ EhcSetRootHubPortFeature (
|
||||
State |= PORTSC_POWER;
|
||||
EhcWriteOpReg (Ehc, Offset, State);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EfiUsbPortOwner:
|
||||
@ -509,7 +503,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clears a feature for the specified root hub port.
|
||||
|
||||
@ -624,6 +617,7 @@ EhcClearRootHubPortFeature (
|
||||
State &= ~PORTSC_POWER;
|
||||
EhcWriteOpReg (Ehc, Offset, State);
|
||||
}
|
||||
|
||||
break;
|
||||
case EfiUsbPortSuspendChange:
|
||||
case EfiUsbPortResetChange:
|
||||
@ -643,7 +637,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Submits control transfer to a target USB device.
|
||||
|
||||
@ -699,22 +692,26 @@ EhcControlTransfer (
|
||||
|
||||
if ((TransferDirection != EfiUsbDataIn) &&
|
||||
(TransferDirection != EfiUsbDataOut) &&
|
||||
(TransferDirection != EfiUsbNoData)) {
|
||||
(TransferDirection != EfiUsbNoData))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((TransferDirection == EfiUsbNoData) &&
|
||||
((Data != NULL) || (*DataLength != 0))) {
|
||||
((Data != NULL) || (*DataLength != 0)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((TransferDirection != EfiUsbNoData) &&
|
||||
((Data == NULL) || (*DataLength == 0))) {
|
||||
((Data == NULL) || (*DataLength == 0)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((MaximumPacketLength != 8) && (MaximumPacketLength != 16) &&
|
||||
(MaximumPacketLength != 32) && (MaximumPacketLength != 64)) {
|
||||
(MaximumPacketLength != 32) && (MaximumPacketLength != 64))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -746,7 +743,7 @@ EhcControlTransfer (
|
||||
// endpoint is bidirectional. EhcCreateUrb expects this
|
||||
// combination of Ep addr and its direction.
|
||||
//
|
||||
Endpoint = (UINT8) (0 | ((TransferDirection == EfiUsbDataIn) ? 0x80 : 0));
|
||||
Endpoint = (UINT8)(0 | ((TransferDirection == EfiUsbDataIn) ? 0x80 : 0));
|
||||
Urb = EhcCreateUrb (
|
||||
Ehc,
|
||||
DeviceAddress,
|
||||
@ -800,7 +797,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Submits bulk transfer to a bulk endpoint of a USB device.
|
||||
|
||||
@ -857,7 +853,8 @@ EhcBulkTransfer (
|
||||
// Validate the parameters
|
||||
//
|
||||
if ((DataLength == NULL) || (*DataLength == 0) ||
|
||||
(Data == NULL) || (Data[0] == NULL) || (TransferResult == NULL)) {
|
||||
(Data == NULL) || (Data[0] == NULL) || (TransferResult == NULL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -867,7 +864,8 @@ EhcBulkTransfer (
|
||||
|
||||
if ((DeviceSpeed == EFI_USB_SPEED_LOW) ||
|
||||
((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
|
||||
((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512))) {
|
||||
((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -940,7 +938,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Submits an asynchronous interrupt transfer to an
|
||||
interrupt endpoint of a USB device.
|
||||
@ -973,7 +970,7 @@ ON_EXIT:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EhcAsyncInterruptTransfer (
|
||||
IN EFI_USB2_HC_PROTOCOL * This,
|
||||
IN EFI_USB2_HC_PROTOCOL *This,
|
||||
IN UINT8 DeviceAddress,
|
||||
IN UINT8 EndPointAddress,
|
||||
IN UINT8 DeviceSpeed,
|
||||
@ -982,7 +979,7 @@ EhcAsyncInterruptTransfer (
|
||||
IN OUT UINT8 *DataToggle,
|
||||
IN UINTN PollingInterval,
|
||||
IN UINTN DataLength,
|
||||
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR * Translator,
|
||||
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
|
||||
IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction,
|
||||
IN VOID *Context OPTIONAL
|
||||
)
|
||||
@ -1065,7 +1062,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Submits synchronous interrupt transfer to an interrupt endpoint
|
||||
of a USB device.
|
||||
@ -1118,7 +1114,8 @@ EhcSyncInterruptTransfer (
|
||||
// Validates parameters
|
||||
//
|
||||
if ((DataLength == NULL) || (*DataLength == 0) ||
|
||||
(Data == NULL) || (TransferResult == NULL)) {
|
||||
(Data == NULL) || (TransferResult == NULL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1128,7 +1125,8 @@ EhcSyncInterruptTransfer (
|
||||
|
||||
if (((DeviceSpeed == EFI_USB_SPEED_LOW) && (MaximumPacketLength != 8)) ||
|
||||
((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
|
||||
((DeviceSpeed == EFI_USB_SPEED_HIGH) && (MaximumPacketLength > 3072))) {
|
||||
((DeviceSpeed == EFI_USB_SPEED_HIGH) && (MaximumPacketLength > 3072)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1195,7 +1193,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Submits isochronous transfer to a target USB device.
|
||||
|
||||
@ -1235,7 +1232,6 @@ EhcIsochronousTransfer (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Submits Async isochronous transfer to a target USB device.
|
||||
|
||||
@ -1305,7 +1301,6 @@ EhcDriverEntryPoint (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. Any
|
||||
ControllerHandle that has Usb2HcProtocol installed will
|
||||
@ -1337,7 +1332,7 @@ EhcDriverBindingSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -1363,9 +1358,9 @@ EhcDriverBindingSupported (
|
||||
//
|
||||
// Test whether the controller belongs to Ehci type
|
||||
//
|
||||
if ((UsbClassCReg.BaseCode != PCI_CLASS_SERIAL) || (UsbClassCReg.SubClassCode != PCI_CLASS_SERIAL_USB)
|
||||
|| ((UsbClassCReg.ProgInterface != PCI_IF_EHCI) && (UsbClassCReg.ProgInterface != PCI_IF_UHCI) && (UsbClassCReg.ProgInterface != PCI_IF_OHCI))) {
|
||||
|
||||
if ( (UsbClassCReg.BaseCode != PCI_CLASS_SERIAL) || (UsbClassCReg.SubClassCode != PCI_CLASS_SERIAL_USB)
|
||||
|| ((UsbClassCReg.ProgInterface != PCI_IF_EHCI) && (UsbClassCReg.ProgInterface != PCI_IF_UHCI) && (UsbClassCReg.ProgInterface != PCI_IF_OHCI)))
|
||||
{
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -1503,7 +1498,6 @@ EhcGetUsbDebugPortInfo (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create and initialize a USB2_HC_DEV.
|
||||
|
||||
@ -1610,7 +1604,7 @@ EhcExitBootService (
|
||||
{
|
||||
USB2_HC_DEV *Ehc;
|
||||
|
||||
Ehc = (USB2_HC_DEV *) Context;
|
||||
Ehc = (USB2_HC_DEV *)Context;
|
||||
|
||||
//
|
||||
// Reset the Host Controller
|
||||
@ -1618,7 +1612,6 @@ EhcExitBootService (
|
||||
EhcResetHC (Ehc, EHC_RESET_TIMEOUT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starting the Usb EHCI Driver.
|
||||
|
||||
@ -1667,7 +1660,7 @@ EhcDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -1684,7 +1677,7 @@ EhcDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &HcDevicePath,
|
||||
(VOID **)&HcDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1704,6 +1697,7 @@ EhcDriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto CLOSE_PCIIO;
|
||||
}
|
||||
|
||||
PciAttributesSaved = TRUE;
|
||||
|
||||
Status = PciIo->Attributes (
|
||||
@ -1742,14 +1736,16 @@ EhcDriverBindingStart (
|
||||
Status = EFI_UNSUPPORTED;
|
||||
goto CLOSE_PCIIO;
|
||||
}
|
||||
|
||||
//
|
||||
// Determine if the device is UHCI or OHCI host controller or not. If yes, then find out the
|
||||
// companion usb ehci host controller and force EHCI driver get attached to it before
|
||||
// UHCI or OHCI driver attaches to UHCI or OHCI host controller.
|
||||
//
|
||||
if ((UsbClassCReg.ProgInterface == PCI_IF_UHCI || UsbClassCReg.ProgInterface == PCI_IF_OHCI) &&
|
||||
if (((UsbClassCReg.ProgInterface == PCI_IF_UHCI) || (UsbClassCReg.ProgInterface == PCI_IF_OHCI)) &&
|
||||
(UsbClassCReg.BaseCode == PCI_CLASS_SERIAL) &&
|
||||
(UsbClassCReg.SubClassCode == PCI_CLASS_SERIAL_USB)) {
|
||||
(UsbClassCReg.SubClassCode == PCI_CLASS_SERIAL_USB))
|
||||
{
|
||||
Status = PciIo->GetLocation (
|
||||
PciIo,
|
||||
&CompanionSegmentNumber,
|
||||
@ -1798,7 +1794,8 @@ EhcDriverBindingStart (
|
||||
|
||||
if ((UsbClassCReg.ProgInterface == PCI_IF_EHCI) &&
|
||||
(UsbClassCReg.BaseCode == PCI_CLASS_SERIAL) &&
|
||||
(UsbClassCReg.SubClassCode == PCI_CLASS_SERIAL_USB)) {
|
||||
(UsbClassCReg.SubClassCode == PCI_CLASS_SERIAL_USB))
|
||||
{
|
||||
Status = Instance->GetLocation (
|
||||
Instance,
|
||||
&EhciSegmentNumber,
|
||||
@ -1809,6 +1806,7 @@ EhcDriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto CLOSE_PCIIO;
|
||||
}
|
||||
|
||||
//
|
||||
// Currently, the judgment on the companion usb host controller is through the
|
||||
// same bus number, which may vary on different platform.
|
||||
@ -1820,10 +1818,11 @@ EhcDriverBindingStart (
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
EhcDriverBindingStart(This, HandleBuffer[Index], NULL);
|
||||
EhcDriverBindingStart (This, HandleBuffer[Index], NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto CLOSE_PCIIO;
|
||||
}
|
||||
@ -1854,9 +1853,13 @@ EhcDriverBindingStart (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Ehc->Support64BitDma = TRUE;
|
||||
} else {
|
||||
DEBUG ((DEBUG_WARN,
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: failed to enable 64-bit DMA on 64-bit capable controller @ %p (%r)\n",
|
||||
__FUNCTION__, Controller, Status));
|
||||
__FUNCTION__,
|
||||
Controller,
|
||||
Status
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1937,7 +1940,6 @@ EhcDriverBindingStart (
|
||||
FALSE
|
||||
);
|
||||
|
||||
|
||||
DEBUG ((DEBUG_INFO, "EhcDriverBindingStart: EHCI started for controller @ %p\n", Controller));
|
||||
return EFI_SUCCESS;
|
||||
|
||||
@ -1976,7 +1978,6 @@ CLOSE_PCIIO:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. Support stopping any child handles
|
||||
created by this driver.
|
||||
@ -2012,7 +2013,7 @@ EhcDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiUsb2HcProtocolGuid,
|
||||
(VOID **) &Usb2Hc,
|
||||
(VOID **)&Usb2Hc,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
|
@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _EFI_EHCI_H_
|
||||
#define _EFI_EHCI_H_
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/Usb2HostController.h>
|
||||
@ -83,7 +82,6 @@ typedef struct _USB2_HC_DEV USB2_HC_DEV;
|
||||
|
||||
#define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
|
||||
|
||||
|
||||
#define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))
|
||||
#define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
|
||||
#define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
|
||||
@ -160,7 +158,6 @@ struct _USB2_HC_DEV {
|
||||
BOOLEAN Support64BitDma; // Whether 64 bit DMA may be used with this device
|
||||
};
|
||||
|
||||
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2;
|
||||
@ -230,4 +227,3 @@ EhcDriverBindingStop (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8,7 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Ehci.h"
|
||||
|
||||
/**
|
||||
@ -57,7 +56,6 @@ EhcDumpStatus (
|
||||
DEBUG ((DEBUG_VERBOSE, "\n"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Dump the fields of a QTD.
|
||||
|
||||
@ -89,13 +87,10 @@ EhcDumpQtd (
|
||||
|
||||
if (QtdHw->Pid == QTD_PID_SETUP) {
|
||||
DEBUG ((DEBUG_VERBOSE, "PID : Setup\n"));
|
||||
|
||||
} else if (QtdHw->Pid == QTD_PID_INPUT) {
|
||||
DEBUG ((DEBUG_VERBOSE, "PID : IN\n"));
|
||||
|
||||
} else if (QtdHw->Pid == QTD_PID_OUTPUT) {
|
||||
DEBUG ((DEBUG_VERBOSE, "PID : OUT\n"));
|
||||
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "Error Count : %d\n", QtdHw->ErrCnt));
|
||||
@ -109,7 +104,6 @@ EhcDumpQtd (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Dump the queue head.
|
||||
|
||||
@ -134,8 +128,13 @@ EhcDumpQh (
|
||||
DEBUG ((DEBUG_VERBOSE, Msg));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "Queue head @ 0x%p, interval %ld, next qh %p\n",
|
||||
Qh, (UINT64)Qh->Interval, Qh->NextQh));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"Queue head @ 0x%p, interval %ld, next qh %p\n",
|
||||
Qh,
|
||||
(UINT64)Qh->Interval,
|
||||
Qh->NextQh
|
||||
));
|
||||
|
||||
QhHw = &Qh->QhHw;
|
||||
|
||||
@ -166,10 +165,8 @@ EhcDumpQh (
|
||||
|
||||
if (QhHw->Pid == QTD_PID_SETUP) {
|
||||
DEBUG ((DEBUG_VERBOSE, "PID : Setup\n"));
|
||||
|
||||
} else if (QhHw->Pid == QTD_PID_INPUT) {
|
||||
DEBUG ((DEBUG_VERBOSE, "PID : IN\n"));
|
||||
|
||||
} else if (QhHw->Pid == QTD_PID_OUTPUT) {
|
||||
DEBUG ((DEBUG_VERBOSE, "PID : OUT\n"));
|
||||
}
|
||||
@ -196,7 +193,6 @@ EhcDumpQh (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Dump the buffer in the form of hex.
|
||||
|
||||
@ -214,7 +210,7 @@ EhcDumpBuf (
|
||||
|
||||
for (Index = 0; Index < Len; Index++) {
|
||||
if (Index % 16 == 0) {
|
||||
DEBUG ((DEBUG_VERBOSE,"\n"));
|
||||
DEBUG ((DEBUG_VERBOSE, "\n"));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%02x ", Buf[Index]));
|
||||
|
@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _EFI_EHCI_DEBUG_H_
|
||||
#define _EFI_EHCI_DEBUG_H_
|
||||
|
||||
|
||||
/**
|
||||
Dump the fields of a QTD.
|
||||
|
||||
@ -24,7 +23,6 @@ EhcDumpQtd (
|
||||
IN CHAR8 *Msg
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Dump the queue head.
|
||||
|
||||
@ -40,7 +38,6 @@ EhcDumpQh (
|
||||
IN BOOLEAN DumpBuf
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Dump the buffer in the form of hex.
|
||||
|
||||
@ -54,5 +51,4 @@ EhcDumpBuf (
|
||||
IN UINTN Len
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -7,10 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Ehci.h"
|
||||
|
||||
|
||||
/**
|
||||
Read EHCI capability register.
|
||||
|
||||
@ -34,7 +32,7 @@ EhcReadCapRegister (
|
||||
Ehc->PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
EHC_BAR_INDEX,
|
||||
(UINT64) Offset,
|
||||
(UINT64)Offset,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -83,7 +81,6 @@ EhcReadDbgRegister (
|
||||
return Data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check whether the host controller has an in-use debug port.
|
||||
|
||||
@ -121,7 +118,7 @@ EhcIsDebugPortInUse (
|
||||
//
|
||||
// The Debug Port Number field in HCSPARAMS is one-based.
|
||||
//
|
||||
if (PortNumber != NULL && *PortNumber != Ehc->DebugPortNum - 1) {
|
||||
if ((PortNumber != NULL) && (*PortNumber != Ehc->DebugPortNum - 1)) {
|
||||
//
|
||||
// The caller specified a port, but it's not the debug port of the host
|
||||
// controller.
|
||||
@ -132,11 +129,10 @@ EhcIsDebugPortInUse (
|
||||
//
|
||||
// Deduce usage from the Control Register.
|
||||
//
|
||||
State = EhcReadDbgRegister(Ehc, 0);
|
||||
State = EhcReadDbgRegister (Ehc, 0);
|
||||
return (State & USB_DEBUG_PORT_IN_USE_MASK) == USB_DEBUG_PORT_IN_USE_MASK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read EHCI Operation register.
|
||||
|
||||
@ -175,7 +171,6 @@ EhcReadOpReg (
|
||||
return Data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write the data to the EHCI operation register.
|
||||
|
||||
@ -209,7 +204,6 @@ EhcWriteOpReg (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set one bit of the operational register while keeping other bits.
|
||||
|
||||
@ -232,7 +226,6 @@ EhcSetOpRegBit (
|
||||
EhcWriteOpReg (Ehc, Offset, Data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear one bit of the operational register while keeping other bits.
|
||||
|
||||
@ -255,7 +248,6 @@ EhcClearOpRegBit (
|
||||
EhcWriteOpReg (Ehc, Offset, Data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Wait the operation register's bit as specified by Bit
|
||||
to become set (or clear).
|
||||
@ -292,7 +284,6 @@ EhcWaitOpRegBit (
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Add support for UEFI Over Legacy (UoL) feature, stop
|
||||
the legacy USB SMI support.
|
||||
@ -337,8 +328,6 @@ EhcClearLegacySupport (
|
||||
PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, ExtendCap + 0x4, 1, &Value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Set door bell and wait it to be ACKed by host controller.
|
||||
This function is used to synchronize with the hardware.
|
||||
@ -376,7 +365,6 @@ EhcSetAndWaitDoorBell (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear all the interrutp status bits, these bits
|
||||
are Write-Clean.
|
||||
@ -392,7 +380,6 @@ EhcAckAllInterrupt (
|
||||
EhcWriteOpReg (Ehc, EHC_USBSTS_OFFSET, USBSTS_INTACK_MASK);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enable the periodic schedule then wait EHC to
|
||||
actually enable it.
|
||||
@ -418,11 +405,6 @@ EhcEnablePeriodSchd (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Enable asynchrounous schedule.
|
||||
|
||||
@ -447,12 +429,6 @@ EhcEnableAsyncSchd (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Whether Ehc is halted.
|
||||
|
||||
@ -470,7 +446,6 @@ EhcIsHalt (
|
||||
return EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Whether system error occurred.
|
||||
|
||||
@ -488,7 +463,6 @@ EhcIsSysError (
|
||||
return EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_SYS_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reset the host controller.
|
||||
|
||||
@ -523,7 +497,6 @@ EhcResetHC (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Halt the host controller.
|
||||
|
||||
@ -547,7 +520,6 @@ EhcHaltHC (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the EHCI to run.
|
||||
|
||||
@ -571,7 +543,6 @@ EhcRunHC (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize the HC hardware.
|
||||
EHCI spec lists the five things to do to initialize the hardware:
|
||||
@ -629,15 +600,15 @@ EhcInitHC (
|
||||
// 3. Power up all ports if EHCI has Port Power Control (PPC) support
|
||||
//
|
||||
if (Ehc->HcStructParams & HCSP_PPC) {
|
||||
for (Index = 0; Index < (UINT8) (Ehc->HcStructParams & HCSP_NPORTS); Index++) {
|
||||
for (Index = 0; Index < (UINT8)(Ehc->HcStructParams & HCSP_NPORTS); Index++) {
|
||||
//
|
||||
// Do not clear port status bits on initialization. Otherwise devices will
|
||||
// not enumerate properly at startup.
|
||||
//
|
||||
RegVal = EhcReadOpReg(Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * Index)));
|
||||
RegVal = EhcReadOpReg (Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * Index)));
|
||||
RegVal &= ~PORTSC_CHANGE_MASK;
|
||||
RegVal |= PORTSC_POWER;
|
||||
EhcWriteOpReg (Ehc, (UINT32) (EHC_PORT_STAT_OFFSET + (4 * Index)), RegVal);
|
||||
EhcWriteOpReg (Ehc, (UINT32)(EHC_PORT_STAT_OFFSET + (4 * Index)), RegVal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// EHCI register offset
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Capability register offset
|
||||
//
|
||||
@ -170,7 +169,6 @@ EhcReadOpReg (
|
||||
IN UINT32 Offset
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Write the data to the EHCI operation register.
|
||||
|
||||
@ -228,8 +226,6 @@ EhcClearLegacySupport (
|
||||
IN USB2_HC_DEV *Ehc
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Set door bell and wait it to be ACKed by host controller.
|
||||
This function is used to synchronize with the hardware.
|
||||
@ -247,7 +243,6 @@ EhcSetAndWaitDoorBell (
|
||||
IN UINT32 Timeout
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Clear all the interrutp status bits, these bits are Write-Clean.
|
||||
|
||||
@ -259,8 +254,6 @@ EhcAckAllInterrupt (
|
||||
IN USB2_HC_DEV *Ehc
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Whether Ehc is halted.
|
||||
|
||||
@ -275,7 +268,6 @@ EhcIsHalt (
|
||||
IN USB2_HC_DEV *Ehc
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Whether system error occurred.
|
||||
|
||||
@ -290,7 +282,6 @@ EhcIsSysError (
|
||||
IN USB2_HC_DEV *Ehc
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Reset the host controller.
|
||||
|
||||
@ -307,7 +298,6 @@ EhcResetHC (
|
||||
IN UINT32 Timeout
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Halt the host controller.
|
||||
|
||||
@ -324,7 +314,6 @@ EhcHaltHC (
|
||||
IN UINT32 Timeout
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Set the EHCI to run.
|
||||
|
||||
@ -341,8 +330,6 @@ EhcRunHC (
|
||||
IN UINT32 Timeout
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the HC hardware.
|
||||
EHCI spec lists the five things to do to initialize the hardware:
|
||||
|
@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ehci.h"
|
||||
|
||||
|
||||
/**
|
||||
Create helper QTD/QH for the EHCI device.
|
||||
|
||||
@ -66,7 +65,7 @@ EhcCreateHelpQ (
|
||||
|
||||
PciAddr = UsbHcGetPciAddressForHostMem (Ehc->MemPool, Qh, sizeof (EHC_QH));
|
||||
QhHw = &Qh->QhHw;
|
||||
QhHw->HorizonLink = QH_LINK (PciAddr + OFFSET_OF(EHC_QH, QhHw), EHC_TYPE_QH, FALSE);
|
||||
QhHw->HorizonLink = QH_LINK (PciAddr + OFFSET_OF (EHC_QH, QhHw), EHC_TYPE_QH, FALSE);
|
||||
QhHw->Status = QTD_STAT_HALTED;
|
||||
QhHw->ReclaimHead = 1;
|
||||
Qh->NextQh = Qh;
|
||||
@ -90,7 +89,6 @@ EhcCreateHelpQ (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize the schedule data structure such as frame list.
|
||||
|
||||
@ -242,7 +240,6 @@ ErrorExit1:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the schedule data. It may be partially initialized.
|
||||
|
||||
@ -300,7 +297,6 @@ EhcFreeSched (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Link the queue head to the asynchronous schedule list.
|
||||
UEFI only supports one CTRL/BULK transfer at a time
|
||||
@ -337,7 +333,6 @@ EhcLinkQhToAsync (
|
||||
Head->QhHw.HorizonLink = QH_LINK (PciAddr, EHC_TYPE_QH, FALSE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Unlink a queue head from the asynchronous schedule list.
|
||||
Need to synchronize with hardware.
|
||||
@ -381,7 +376,6 @@ EhcUnlinkQhFromAsync (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Link a queue head for interrupt transfer to the periodic
|
||||
schedule frame list. This code is very much the same as
|
||||
@ -407,8 +401,8 @@ EhcLinkQhToPeriod (
|
||||
// First QH can't be NULL because we always keep PeriodOne
|
||||
// heads on the frame list
|
||||
//
|
||||
ASSERT (!EHC_LINK_TERMINATED (((UINT32*)Ehc->PeriodFrame)[Index]));
|
||||
Next = (EHC_QH*)((UINTN*)Ehc->PeriodFrameHost)[Index];
|
||||
ASSERT (!EHC_LINK_TERMINATED (((UINT32 *)Ehc->PeriodFrame)[Index]));
|
||||
Next = (EHC_QH *)((UINTN *)Ehc->PeriodFrameHost)[Index];
|
||||
Prev = NULL;
|
||||
|
||||
//
|
||||
@ -475,8 +469,8 @@ EhcLinkQhToPeriod (
|
||||
PciAddr = UsbHcGetPciAddressForHostMem (Ehc->MemPool, Qh, sizeof (EHC_QH));
|
||||
|
||||
if (Prev == NULL) {
|
||||
((UINT32*)Ehc->PeriodFrame)[Index] = QH_LINK (PciAddr, EHC_TYPE_QH, FALSE);
|
||||
((UINTN*)Ehc->PeriodFrameHost)[Index] = (UINTN)Qh;
|
||||
((UINT32 *)Ehc->PeriodFrame)[Index] = QH_LINK (PciAddr, EHC_TYPE_QH, FALSE);
|
||||
((UINTN *)Ehc->PeriodFrameHost)[Index] = (UINTN)Qh;
|
||||
} else {
|
||||
Prev->NextQh = Qh;
|
||||
Prev->QhHw.HorizonLink = QH_LINK (PciAddr, EHC_TYPE_QH, FALSE);
|
||||
@ -484,7 +478,6 @@ EhcLinkQhToPeriod (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Unlink an interrupt queue head from the periodic
|
||||
schedule frame list.
|
||||
@ -508,8 +501,8 @@ EhcUnlinkQhFromPeriod (
|
||||
// Frame link can't be NULL because we always keep PeroidOne
|
||||
// on the frame list
|
||||
//
|
||||
ASSERT (!EHC_LINK_TERMINATED (((UINT32*)Ehc->PeriodFrame)[Index]));
|
||||
This = (EHC_QH*)((UINTN*)Ehc->PeriodFrameHost)[Index];
|
||||
ASSERT (!EHC_LINK_TERMINATED (((UINT32 *)Ehc->PeriodFrame)[Index]));
|
||||
This = (EHC_QH *)((UINTN *)Ehc->PeriodFrameHost)[Index];
|
||||
Prev = NULL;
|
||||
|
||||
//
|
||||
@ -533,8 +526,8 @@ EhcUnlinkQhFromPeriod (
|
||||
//
|
||||
// Qh is the first entry in the frame
|
||||
//
|
||||
((UINT32*)Ehc->PeriodFrame)[Index] = Qh->QhHw.HorizonLink;
|
||||
((UINTN*)Ehc->PeriodFrameHost)[Index] = (UINTN)Qh->NextQh;
|
||||
((UINT32 *)Ehc->PeriodFrame)[Index] = Qh->QhHw.HorizonLink;
|
||||
((UINTN *)Ehc->PeriodFrameHost)[Index] = (UINTN)Qh->NextQh;
|
||||
} else {
|
||||
Prev->NextQh = Qh->NextQh;
|
||||
Prev->QhHw.HorizonLink = Qh->QhHw.HorizonLink;
|
||||
@ -542,7 +535,6 @@ EhcUnlinkQhFromPeriod (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check the URB's execution result and update the URB's
|
||||
result accordingly.
|
||||
@ -581,7 +573,7 @@ EhcCheckUrbResult (
|
||||
BASE_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
|
||||
Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
|
||||
QtdHw = &Qtd->QtdHw;
|
||||
State = (UINT8) QtdHw->Status;
|
||||
State = (UINT8)QtdHw->Status;
|
||||
|
||||
if (EHC_BIT_IS_SET (State, QTD_STAT_HALTED)) {
|
||||
//
|
||||
@ -606,7 +598,6 @@ EhcCheckUrbResult (
|
||||
|
||||
Finished = TRUE;
|
||||
goto ON_EXIT;
|
||||
|
||||
} else if (EHC_BIT_IS_SET (State, QTD_STAT_ACTIVE)) {
|
||||
//
|
||||
// The QTD is still active, no need to check furthur.
|
||||
@ -615,7 +606,6 @@ EhcCheckUrbResult (
|
||||
|
||||
Finished = FALSE;
|
||||
goto ON_EXIT;
|
||||
|
||||
} else {
|
||||
//
|
||||
// This QTD is finished OK or met short packet read. Update the
|
||||
@ -657,12 +647,11 @@ ON_EXIT:
|
||||
// NOTICE: don't move DT update before the loop, otherwise there is
|
||||
// a race condition that DT is wrong.
|
||||
//
|
||||
Urb->DataToggle = (UINT8) Urb->Qh->QhHw.DataToggle;
|
||||
Urb->DataToggle = (UINT8)Urb->Qh->QhHw.DataToggle;
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Execute the transfer by polling the URB. This is a synchronous operation.
|
||||
|
||||
@ -717,7 +706,6 @@ EhcExecTransfer (
|
||||
EhcDumpQh (Urb->Qh, NULL, FALSE);
|
||||
|
||||
Status = EFI_TIMEOUT;
|
||||
|
||||
} else if (Urb->Result != EFI_USB_NOERROR) {
|
||||
DEBUG ((DEBUG_ERROR, "EhcExecTransfer: transfer failed with %x\n", Urb->Result));
|
||||
EhcDumpQh (Urb->Qh, NULL, FALSE);
|
||||
@ -728,7 +716,6 @@ EhcExecTransfer (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Delete a single asynchronous interrupt transfer for
|
||||
the device and endpoint.
|
||||
@ -762,7 +749,8 @@ EhciDelAsyncIntTransfer (
|
||||
Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
|
||||
|
||||
if ((Urb->Ep.DevAddr == DevAddr) && (Urb->Ep.EpAddr == EpNum) &&
|
||||
(Urb->Ep.Direction == Direction)) {
|
||||
(Urb->Ep.Direction == Direction))
|
||||
{
|
||||
//
|
||||
// Check the URB status to retrieve the next data toggle
|
||||
// from the associated queue head.
|
||||
@ -782,7 +770,6 @@ EhciDelAsyncIntTransfer (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Remove all the asynchronous interrutp transfers.
|
||||
|
||||
@ -931,7 +918,7 @@ EhcFlushAsyncIntMap (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Urb->DataPhy = (VOID *) ((UINTN) PhyAddr);
|
||||
Urb->DataPhy = (VOID *)((UINTN)PhyAddr);
|
||||
Urb->DataMap = Map;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
@ -939,7 +926,6 @@ ON_ERROR:
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Update the queue head for next round of asynchronous transfer.
|
||||
|
||||
@ -985,13 +971,13 @@ EhcUpdateAsyncRequest (
|
||||
QtdHw->Status = QTD_STAT_ACTIVE;
|
||||
QtdHw->ErrCnt = QTD_MAX_ERR;
|
||||
QtdHw->CurPage = 0;
|
||||
QtdHw->TotalBytes = (UINT32) Qtd->DataLen;
|
||||
QtdHw->TotalBytes = (UINT32)Qtd->DataLen;
|
||||
//
|
||||
// calculate physical address by offset.
|
||||
//
|
||||
PciAddr = (UINTN)Urb->DataPhy + ((UINTN)Qtd->Data - (UINTN)Urb->Data);
|
||||
QtdHw->Page[0] = EHC_LOW_32BIT (PciAddr);
|
||||
QtdHw->PageHigh[0]= EHC_HIGH_32BIT (PciAddr);
|
||||
QtdHw->PageHigh[0] = EHC_HIGH_32BIT (PciAddr);
|
||||
}
|
||||
|
||||
//
|
||||
@ -1020,10 +1006,9 @@ EhcUpdateAsyncRequest (
|
||||
QhHw->NextQtd = QTD_LINK (PciAddr, FALSE);
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Interrupt transfer periodic check handler.
|
||||
|
||||
@ -1048,7 +1033,7 @@ EhcMonitorAsyncRequests (
|
||||
EFI_STATUS Status;
|
||||
|
||||
OldTpl = gBS->RaiseTPL (EHC_TPL);
|
||||
Ehc = (USB2_HC_DEV *) Context;
|
||||
Ehc = (USB2_HC_DEV *)Context;
|
||||
|
||||
BASE_LIST_FOR_EACH_SAFE (Entry, Next, &Ehc->AsyncIntTransfers) {
|
||||
Urb = EFI_LIST_CONTAINER (Entry, URB, UrbList);
|
||||
@ -1113,7 +1098,7 @@ EhcMonitorAsyncRequests (
|
||||
// his callback. Some drivers may has a lower TPL restriction.
|
||||
//
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
(Urb->Callback) (ProcBuf, Urb->Completed, Urb->Context, Urb->Result);
|
||||
(Urb->Callback)(ProcBuf, Urb->Completed, Urb->Context, Urb->Result);
|
||||
OldTpl = gBS->RaiseTPL (EHC_TPL);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _EFI_EHCI_SCHED_H_
|
||||
#define _EFI_EHCI_SCHED_H_
|
||||
|
||||
|
||||
/**
|
||||
Initialize the schedule data structure such as frame list.
|
||||
|
||||
@ -25,7 +24,6 @@ EhcInitSched (
|
||||
IN USB2_HC_DEV *Ehc
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Free the schedule data. It may be partially initialized.
|
||||
|
||||
@ -37,7 +35,6 @@ EhcFreeSched (
|
||||
IN USB2_HC_DEV *Ehc
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Link the queue head to the asynchronous schedule list.
|
||||
UEFI only supports one CTRL/BULK transfer at a time
|
||||
@ -55,7 +52,6 @@ EhcLinkQhToAsync (
|
||||
IN EHC_QH *Qh
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Unlink a queue head from the asynchronous schedule list.
|
||||
Need to synchronize with hardware.
|
||||
@ -70,7 +66,6 @@ EhcUnlinkQhFromAsync (
|
||||
IN EHC_QH *Qh
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Link a queue head for interrupt transfer to the periodic
|
||||
schedule frame list. This code is very much the same as
|
||||
@ -86,7 +81,6 @@ EhcLinkQhToPeriod (
|
||||
IN EHC_QH *Qh
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Unlink an interrupt queue head from the periodic
|
||||
schedule frame list.
|
||||
@ -101,8 +95,6 @@ EhcUnlinkQhFromPeriod (
|
||||
IN EHC_QH *Qh
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Execute the transfer by polling the URB. This is a synchronous operation.
|
||||
|
||||
@ -122,7 +114,6 @@ EhcExecTransfer (
|
||||
IN UINTN TimeOut
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Delete a single asynchronous interrupt transfer for
|
||||
the device and endpoint.
|
||||
@ -144,7 +135,6 @@ EhciDelAsyncIntTransfer (
|
||||
OUT UINT8 *DataToggle
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Remove all the asynchronous interrutp transfers.
|
||||
|
||||
|
@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Ehci.h"
|
||||
|
||||
|
||||
/**
|
||||
Create a single QTD to hold the data.
|
||||
|
||||
@ -104,15 +103,13 @@ EhcCreateQtd (
|
||||
Len = Len - Len % MaxPacket;
|
||||
}
|
||||
|
||||
QtdHw->TotalBytes = (UINT32) Len;
|
||||
QtdHw->TotalBytes = (UINT32)Len;
|
||||
Qtd->DataLen = Len;
|
||||
}
|
||||
|
||||
return Qtd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the queue head for interrupt transfer,
|
||||
that is, initialize the following three fields:
|
||||
@ -139,7 +136,7 @@ EhcInitIntQh (
|
||||
//
|
||||
if (Ep->DevSpeed == EFI_USB_SPEED_HIGH) {
|
||||
QhHw->SMask = QH_MICROFRAME_0;
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -157,8 +154,6 @@ EhcInitIntQh (
|
||||
QhHw->CMask = QH_MICROFRAME_3 | QH_MICROFRAME_4 | QH_MICROFRAME_5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Allocate and initialize a EHCI queue head.
|
||||
|
||||
@ -197,7 +192,7 @@ EhcCreateQh (
|
||||
QhHw->EpSpeed = Ep->DevSpeed;
|
||||
QhHw->DtCtrl = 0;
|
||||
QhHw->ReclaimHead = 0;
|
||||
QhHw->MaxPacketLen = (UINT32) Ep->MaxPacket;
|
||||
QhHw->MaxPacketLen = (UINT32)Ep->MaxPacket;
|
||||
QhHw->CtrlEp = 0;
|
||||
QhHw->NakReload = QH_NAK_RELOAD;
|
||||
QhHw->HubAddr = Ep->HubAddr;
|
||||
@ -221,6 +216,7 @@ EhcCreateQh (
|
||||
if (Ep->DevSpeed != EFI_USB_SPEED_HIGH) {
|
||||
QhHw->CtrlEp = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EHC_INT_TRANSFER_ASYNC:
|
||||
@ -244,7 +240,6 @@ EhcCreateQh (
|
||||
return Qh;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert the poll interval from application to that
|
||||
be used by EHCI interface data structure. Only need
|
||||
@ -282,7 +277,6 @@ EhcConvertPollRate (
|
||||
return (UINTN)1 << (BitCount - 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free a list of QTDs.
|
||||
|
||||
@ -308,7 +302,6 @@ EhcFreeQtds (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free an allocated URB. It is possible for it to be partially inited.
|
||||
|
||||
@ -346,7 +339,6 @@ EhcFreeUrb (
|
||||
gBS->FreePool (Urb);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a list of QTDs for the URB.
|
||||
|
||||
@ -448,8 +440,8 @@ EhcCreateQtds (
|
||||
while (Len < Urb->DataLen) {
|
||||
Qtd = EhcCreateQtd (
|
||||
Ehc,
|
||||
(UINT8 *) Urb->Data + Len,
|
||||
(UINT8 *) Urb->DataPhy + Len,
|
||||
(UINT8 *)Urb->Data + Len,
|
||||
(UINT8 *)Urb->DataPhy + Len,
|
||||
Urb->DataLen - Len,
|
||||
Pid,
|
||||
Toggle,
|
||||
@ -467,7 +459,7 @@ EhcCreateQtds (
|
||||
// Switch the Toggle bit if odd number of packets are included in the QTD.
|
||||
//
|
||||
if (((Qtd->DataLen + Ep->MaxPacket - 1) / Ep->MaxPacket) % 2) {
|
||||
Toggle = (UINT8) (1 - Toggle);
|
||||
Toggle = (UINT8)(1 - Toggle);
|
||||
}
|
||||
|
||||
Len += Qtd->DataLen;
|
||||
@ -511,7 +503,6 @@ ON_ERROR:
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a new URB and its associated QTD.
|
||||
|
||||
@ -571,7 +562,7 @@ EhcCreateUrb (
|
||||
|
||||
Ep = &Urb->Ep;
|
||||
Ep->DevAddr = DevAddr;
|
||||
Ep->EpAddr = (UINT8) (EpAddr & 0x0F);
|
||||
Ep->EpAddr = (UINT8)(EpAddr & 0x0F);
|
||||
Ep->Direction = (((EpAddr & 0x80) != 0) ? EfiUsbDataIn : EfiUsbDataOut);
|
||||
Ep->DevSpeed = DevSpeed;
|
||||
Ep->MaxPacket = MaxPacket;
|
||||
@ -615,7 +606,7 @@ EhcCreateUrb (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Urb->RequestPhy = (VOID *) ((UINTN) PhyAddr);
|
||||
Urb->RequestPhy = (VOID *)((UINTN)PhyAddr);
|
||||
Urb->RequestMap = Map;
|
||||
}
|
||||
|
||||
@ -634,7 +625,7 @@ EhcCreateUrb (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Urb->DataPhy = (VOID *) ((UINTN) PhyAddr);
|
||||
Urb->DataPhy = (VOID *)((UINTN)PhyAddr);
|
||||
Urb->DataMap = Map;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _EFI_EHCI_URB_H_
|
||||
#define _EFI_EHCI_URB_H_
|
||||
|
||||
|
||||
typedef struct _EHC_QTD EHC_QTD;
|
||||
typedef struct _EHC_QH EHC_QH;
|
||||
typedef struct _URB URB;
|
||||
@ -143,7 +142,6 @@ typedef struct {
|
||||
} QH_HW;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
//
|
||||
// Endpoint address and its capabilities
|
||||
//
|
||||
@ -230,8 +228,6 @@ struct _URB {
|
||||
UINT8 DataToggle;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Create a single QTD to hold the data.
|
||||
|
||||
@ -257,8 +253,6 @@ EhcCreateQtd (
|
||||
IN UINTN MaxPacket
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Allocate and initialize a EHCI queue head.
|
||||
|
||||
@ -274,7 +268,6 @@ EhcCreateQh (
|
||||
IN USB_ENDPOINT *Ep
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Free an allocated URB. It is possible for it to be partially inited.
|
||||
|
||||
@ -288,7 +281,6 @@ EhcFreeUrb (
|
||||
IN URB *Urb
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Create a new URB and its associated QTD.
|
||||
|
||||
@ -327,4 +319,5 @@ EhcCreateUrb (
|
||||
IN VOID *Context,
|
||||
IN UINTN Interval
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -7,10 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Ehci.h"
|
||||
|
||||
|
||||
/**
|
||||
Allocate a block of memory to be used by the buffer pool.
|
||||
|
||||
@ -97,7 +95,7 @@ UsbHcAllocMemBlock (
|
||||
}
|
||||
|
||||
Block->BufHost = BufHost;
|
||||
Block->Buf = (UINT8 *) ((UINTN) MappedAddr);
|
||||
Block->Buf = (UINT8 *)((UINTN)MappedAddr);
|
||||
Block->Mapping = Mapping;
|
||||
|
||||
return Block;
|
||||
@ -111,7 +109,6 @@ FREE_BITARRAY:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the memory block from the memory pool.
|
||||
|
||||
@ -141,7 +138,6 @@ UsbHcFreeMemBlock (
|
||||
gBS->FreePool (Block);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Alloc some memory from the block.
|
||||
|
||||
@ -185,7 +181,6 @@ UsbHcAllocMemFromBlock (
|
||||
}
|
||||
|
||||
NEXT_BIT (Byte, Bit);
|
||||
|
||||
} else {
|
||||
NEXT_BIT (Byte, Bit);
|
||||
|
||||
@ -208,7 +203,7 @@ UsbHcAllocMemFromBlock (
|
||||
for (Count = 0; Count < Units; Count++) {
|
||||
ASSERT (!USB_HC_BIT_IS_SET (Block->Bits[Byte], Bit));
|
||||
|
||||
Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] | USB_HC_BIT (Bit));
|
||||
Block->Bits[Byte] = (UINT8)(Block->Bits[Byte] | USB_HC_BIT (Bit));
|
||||
NEXT_BIT (Byte, Bit);
|
||||
}
|
||||
|
||||
@ -249,7 +244,7 @@ UsbHcGetPciAddressForHostMem (
|
||||
// scan the memory block list for the memory block that
|
||||
// completely contains the allocated memory.
|
||||
//
|
||||
if ((Block->BufHost <= (UINT8 *) Mem) && (((UINT8 *) Mem + AllocSize) <= (Block->BufHost + Block->BufLen))) {
|
||||
if ((Block->BufHost <= (UINT8 *)Mem) && (((UINT8 *)Mem + AllocSize) <= (Block->BufHost + Block->BufLen))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -259,11 +254,10 @@ UsbHcGetPciAddressForHostMem (
|
||||
// calculate the pci memory address for host memory address.
|
||||
//
|
||||
Offset = (UINT8 *)Mem - Block->BufHost;
|
||||
PhyAddr = (EFI_PHYSICAL_ADDRESS)(UINTN) (Block->Buf + Offset);
|
||||
PhyAddr = (EFI_PHYSICAL_ADDRESS)(UINTN)(Block->Buf + Offset);
|
||||
return PhyAddr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Insert the memory block to the pool's list of the blocks.
|
||||
|
||||
@ -282,7 +276,6 @@ UsbHcInsertMemBlockToPool (
|
||||
Head->Next = Block;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Is the memory block empty?
|
||||
|
||||
@ -308,7 +301,6 @@ UsbHcIsMemBlockEmpty (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Unlink the memory block from the pool's list.
|
||||
|
||||
@ -335,7 +327,6 @@ UsbHcUnlinkMemBlock (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize the memory management pool for the host controller.
|
||||
|
||||
@ -376,7 +367,6 @@ UsbHcInitMemPool (
|
||||
return Pool;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release the memory management pool.
|
||||
|
||||
@ -410,7 +400,6 @@ UsbHcFreeMemPool (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allocate some memory from the host controller's memory pool
|
||||
which can be used to communicate with host controller.
|
||||
@ -487,7 +476,6 @@ UsbHcAllocateMem (
|
||||
return Mem;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free the allocated memory back to the memory pool.
|
||||
|
||||
@ -513,7 +501,7 @@ UsbHcFreeMem (
|
||||
|
||||
Head = Pool->Head;
|
||||
AllocSize = USBHC_MEM_ROUND (Size);
|
||||
ToFree = (UINT8 *) Mem;
|
||||
ToFree = (UINT8 *)Mem;
|
||||
|
||||
for (Block = Head; Block != NULL; Block = Block->Next) {
|
||||
//
|
||||
@ -533,7 +521,7 @@ UsbHcFreeMem (
|
||||
for (Count = 0; Count < (AllocSize / USBHC_MEM_UNIT); Count++) {
|
||||
ASSERT (USB_HC_BIT_IS_SET (Block->Bits[Byte], Bit));
|
||||
|
||||
Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] ^ USB_HC_BIT (Bit));
|
||||
Block->Bits[Byte] = (UINT8)(Block->Bits[Byte] ^ USB_HC_BIT (Bit));
|
||||
NEXT_BIT (Byte, Bit);
|
||||
}
|
||||
|
||||
@ -556,5 +544,5 @@ UsbHcFreeMem (
|
||||
UsbHcFreeMemBlock (Pool, Block);
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
@ -63,8 +63,6 @@ typedef struct _USBHC_MEM_POOL {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the memory management pool for the host controller.
|
||||
|
||||
@ -84,7 +82,6 @@ UsbHcInitMemPool (
|
||||
IN UINT32 Which4G
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Release the memory management pool.
|
||||
|
||||
@ -99,7 +96,6 @@ UsbHcFreeMemPool (
|
||||
IN USBHC_MEM_POOL *Pool
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Allocate some memory from the host controller's memory pool
|
||||
which can be used to communicate with host controller.
|
||||
@ -116,7 +112,6 @@ UsbHcAllocateMem (
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Free the allocated memory back to the memory pool.
|
||||
|
||||
|
@ -54,6 +54,7 @@ IoMmuMap (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
switch (Operation) {
|
||||
case EdkiiIoMmuOperationBusMasterRead:
|
||||
case EdkiiIoMmuOperationBusMasterRead64:
|
||||
@ -68,9 +69,10 @@ IoMmuMap (
|
||||
Attribute = EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE;
|
||||
break;
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = IoMmu->SetAttribute (
|
||||
IoMmu,
|
||||
*Mapping,
|
||||
@ -82,10 +84,11 @@ IoMmuMap (
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
*DeviceAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
|
||||
*DeviceAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;
|
||||
*Mapping = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -170,6 +173,7 @@ IoMmuAllocateBuffer (
|
||||
*HostAddress = NULL;
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = IoMmu->SetAttribute (
|
||||
IoMmu,
|
||||
*Mapping,
|
||||
@ -191,10 +195,12 @@ IoMmuAllocateBuffer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
*HostAddress = (VOID *) (UINTN) HostPhyAddress;
|
||||
|
||||
*HostAddress = (VOID *)(UINTN)HostPhyAddress;
|
||||
*DeviceAddress = HostPhyAddress;
|
||||
*Mapping = NULL;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -237,7 +243,6 @@ IoMmuInit (
|
||||
&gEdkiiIoMmuPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) IoMmu
|
||||
(VOID **)IoMmu
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -15,19 +15,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// to the UEFI protocol's port state (change).
|
||||
//
|
||||
USB_PORT_STATE_MAP mUsbPortStateMap[] = {
|
||||
{PORTSC_CONN, USB_PORT_STAT_CONNECTION},
|
||||
{PORTSC_ENABLED, USB_PORT_STAT_ENABLE},
|
||||
{PORTSC_SUSPEND, USB_PORT_STAT_SUSPEND},
|
||||
{PORTSC_OVERCUR, USB_PORT_STAT_OVERCURRENT},
|
||||
{PORTSC_RESET, USB_PORT_STAT_RESET},
|
||||
{PORTSC_POWER, USB_PORT_STAT_POWER},
|
||||
{PORTSC_OWNER, USB_PORT_STAT_OWNER}
|
||||
{ PORTSC_CONN, USB_PORT_STAT_CONNECTION },
|
||||
{ PORTSC_ENABLED, USB_PORT_STAT_ENABLE },
|
||||
{ PORTSC_SUSPEND, USB_PORT_STAT_SUSPEND },
|
||||
{ PORTSC_OVERCUR, USB_PORT_STAT_OVERCURRENT },
|
||||
{ PORTSC_RESET, USB_PORT_STAT_RESET },
|
||||
{ PORTSC_POWER, USB_PORT_STAT_POWER },
|
||||
{ PORTSC_OWNER, USB_PORT_STAT_OWNER }
|
||||
};
|
||||
|
||||
USB_PORT_STATE_MAP mUsbPortChangeMap[] = {
|
||||
{PORTSC_CONN_CHANGE, USB_PORT_STAT_C_CONNECTION},
|
||||
{PORTSC_ENABLE_CHANGE, USB_PORT_STAT_C_ENABLE},
|
||||
{PORTSC_OVERCUR_CHANGE, USB_PORT_STAT_C_OVERCURRENT}
|
||||
{ PORTSC_CONN_CHANGE, USB_PORT_STAT_C_CONNECTION },
|
||||
{ PORTSC_ENABLE_CHANGE, USB_PORT_STAT_C_ENABLE },
|
||||
{ PORTSC_OVERCUR_CHANGE, USB_PORT_STAT_C_OVERCURRENT }
|
||||
};
|
||||
|
||||
/**
|
||||
@ -69,11 +69,9 @@ EhcWriteOpReg (
|
||||
IN UINT32 Data
|
||||
)
|
||||
{
|
||||
|
||||
ASSERT (Ehc->CapLen != 0);
|
||||
|
||||
MmioWrite32(Ehc->UsbHostControllerBaseAddress + Ehc->CapLen + Offset, Data);
|
||||
|
||||
MmioWrite32 (Ehc->UsbHostControllerBaseAddress + Ehc->CapLen + Offset, Data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +171,7 @@ EhcReadCapRegister (
|
||||
{
|
||||
UINT32 Data;
|
||||
|
||||
Data = MmioRead32(Ehc->UsbHostControllerBaseAddress + Offset);
|
||||
Data = MmioRead32 (Ehc->UsbHostControllerBaseAddress + Offset);
|
||||
|
||||
return Data;
|
||||
}
|
||||
@ -414,7 +412,7 @@ EhcPowerOnAllPorts (
|
||||
// Do not clear port status bits on initialization. Otherwise devices will
|
||||
// not enumerate properly at startup.
|
||||
//
|
||||
RegVal = EhcReadOpReg(Ehc, EHC_PORT_STAT_OFFSET + 4 * Index);
|
||||
RegVal = EhcReadOpReg (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index);
|
||||
RegVal &= ~PORTSC_CHANGE_MASK;
|
||||
RegVal |= PORTSC_POWER;
|
||||
EhcWriteOpReg (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, RegVal);
|
||||
@ -454,13 +452,14 @@ EhcInitHC (
|
||||
if (Ehc->PeriodFrame != NULL) {
|
||||
EhcFreeSched (Ehc);
|
||||
}
|
||||
PageNumber = sizeof(PEI_URB)/PAGESIZE +1;
|
||||
|
||||
PageNumber = sizeof (PEI_URB)/PAGESIZE +1;
|
||||
Status = PeiServicesAllocatePages (
|
||||
EfiBootServicesCode,
|
||||
PageNumber,
|
||||
&TempPtr
|
||||
);
|
||||
Ehc->Urb = (PEI_URB *) ((UINTN) TempPtr);
|
||||
Ehc->Urb = (PEI_URB *)((UINTN)TempPtr);
|
||||
if (Ehc->Urb == NULL) {
|
||||
return Status;
|
||||
}
|
||||
@ -473,6 +472,7 @@ EhcInitHC (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// 1. Program the CTRLDSSEGMENT register with the high 32 bit addr
|
||||
//
|
||||
@ -571,7 +571,8 @@ EhcBulkTransfer (
|
||||
// Validate the parameters
|
||||
//
|
||||
if ((DataLength == NULL) || (*DataLength == 0) ||
|
||||
(Data == NULL) || (Data[0] == NULL) || (TransferResult == NULL)) {
|
||||
(Data == NULL) || (Data[0] == NULL) || (TransferResult == NULL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -581,11 +582,12 @@ EhcBulkTransfer (
|
||||
|
||||
if ((DeviceSpeed == EFI_USB_SPEED_LOW) ||
|
||||
((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
|
||||
((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512))) {
|
||||
((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Ehc =PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS(This);
|
||||
Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
|
||||
*TransferResult = EFI_USB_ERR_SYSTEM;
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
|
||||
@ -661,8 +663,8 @@ EhcGetRootHubPortNumber (
|
||||
OUT UINT8 *PortNumber
|
||||
)
|
||||
{
|
||||
|
||||
PEI_USB2_HC_DEV *EhcDev;
|
||||
|
||||
EhcDev = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
|
||||
|
||||
if (PortNumber == NULL) {
|
||||
@ -671,7 +673,6 @@ EhcGetRootHubPortNumber (
|
||||
|
||||
*PortNumber = (UINT8)(EhcDev->HcStructParams & HCSP_NPORTS);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -834,7 +835,7 @@ EhcSetRootHubPortFeature (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Offset = (UINT32) (EHC_PORT_STAT_OFFSET + (4 * PortNumber));
|
||||
Offset = (UINT32)(EHC_PORT_STAT_OFFSET + (4 * PortNumber));
|
||||
State = EhcReadOpReg (Ehc, Offset);
|
||||
|
||||
//
|
||||
@ -932,7 +933,7 @@ EhcGetRootHubPortStatus (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS(This);
|
||||
Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
TotalPort = (Ehc->HcStructParams & HCSP_NPORTS);
|
||||
@ -942,7 +943,7 @@ EhcGetRootHubPortStatus (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Offset = (UINT32) (EHC_PORT_STAT_OFFSET + (4 * PortNumber));
|
||||
Offset = (UINT32)(EHC_PORT_STAT_OFFSET + (4 * PortNumber));
|
||||
PortStatus->PortStatus = 0;
|
||||
PortStatus->PortChangeStatus = 0;
|
||||
|
||||
@ -956,7 +957,6 @@ EhcGetRootHubPortStatus (
|
||||
//
|
||||
if (EHC_BIT_IS_SET (State, PORTSC_LINESTATE_K)) {
|
||||
PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED;
|
||||
|
||||
} else if (EHC_BIT_IS_SET (State, PORTSC_ENABLED)) {
|
||||
PortStatus->PortStatus |= USB_PORT_STAT_HIGH_SPEED;
|
||||
}
|
||||
@ -968,7 +968,7 @@ EhcGetRootHubPortStatus (
|
||||
|
||||
for (Index = 0; Index < MapSize; Index++) {
|
||||
if (EHC_BIT_IS_SET (State, mUsbPortStateMap[Index].HwState)) {
|
||||
PortStatus->PortStatus = (UINT16) (PortStatus->PortStatus | mUsbPortStateMap[Index].UefiState);
|
||||
PortStatus->PortStatus = (UINT16)(PortStatus->PortStatus | mUsbPortStateMap[Index].UefiState);
|
||||
}
|
||||
}
|
||||
|
||||
@ -976,7 +976,7 @@ EhcGetRootHubPortStatus (
|
||||
|
||||
for (Index = 0; Index < MapSize; Index++) {
|
||||
if (EHC_BIT_IS_SET (State, mUsbPortChangeMap[Index].HwState)) {
|
||||
PortStatus->PortChangeStatus = (UINT16) (PortStatus->PortChangeStatus | mUsbPortChangeMap[Index].UefiState);
|
||||
PortStatus->PortChangeStatus = (UINT16)(PortStatus->PortChangeStatus | mUsbPortChangeMap[Index].UefiState);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1041,29 +1041,33 @@ EhcControlTransfer (
|
||||
|
||||
if ((TransferDirection != EfiUsbDataIn) &&
|
||||
(TransferDirection != EfiUsbDataOut) &&
|
||||
(TransferDirection != EfiUsbNoData)) {
|
||||
(TransferDirection != EfiUsbNoData))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((TransferDirection == EfiUsbNoData) &&
|
||||
((Data != NULL) || (*DataLength != 0))) {
|
||||
((Data != NULL) || (*DataLength != 0)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((TransferDirection != EfiUsbNoData) &&
|
||||
((Data == NULL) || (*DataLength == 0))) {
|
||||
((Data == NULL) || (*DataLength == 0)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ((MaximumPacketLength != 8) && (MaximumPacketLength != 16) &&
|
||||
(MaximumPacketLength != 32) && (MaximumPacketLength != 64)) {
|
||||
(MaximumPacketLength != 32) && (MaximumPacketLength != 64))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
if ((DeviceSpeed == EFI_USB_SPEED_LOW) ||
|
||||
((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
|
||||
((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512))) {
|
||||
((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1088,7 +1092,7 @@ EhcControlTransfer (
|
||||
// endpoint is bidirectional. EhcCreateUrb expects this
|
||||
// combination of Ep addr and its direction.
|
||||
//
|
||||
Endpoint = (UINT8) (0 | ((TransferDirection == EfiUsbDataIn) ? 0x80 : 0));
|
||||
Endpoint = (UINT8)(0 | ((TransferDirection == EfiUsbDataIn) ? 0x80 : 0));
|
||||
Urb = EhcCreateUrb (
|
||||
Ehc,
|
||||
DeviceAddress,
|
||||
@ -1197,7 +1201,7 @@ EhcPeimEntry (
|
||||
&gPeiUsbControllerPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &ChipSetUsbControllerPpi
|
||||
(VOID **)&ChipSetUsbControllerPpi
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
@ -1206,7 +1210,7 @@ EhcPeimEntry (
|
||||
Index = 0;
|
||||
while (TRUE) {
|
||||
Status = ChipSetUsbControllerPpi->GetUsbController (
|
||||
(EFI_PEI_SERVICES **) PeiServices,
|
||||
(EFI_PEI_SERVICES **)PeiServices,
|
||||
ChipSetUsbControllerPpi,
|
||||
Index,
|
||||
&ControllerType,
|
||||
@ -1237,15 +1241,14 @@ EhcPeimEntry (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
ZeroMem((VOID *)(UINTN)TempPtr, MemPages*PAGESIZE);
|
||||
EhcDev = (PEI_USB2_HC_DEV *) ((UINTN) TempPtr);
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, MemPages*PAGESIZE);
|
||||
EhcDev = (PEI_USB2_HC_DEV *)((UINTN)TempPtr);
|
||||
|
||||
EhcDev->Signature = USB2_HC_DEV_SIGNATURE;
|
||||
|
||||
IoMmuInit (&EhcDev->IoMmu);
|
||||
|
||||
EhcDev->UsbHostControllerBaseAddress = (UINT32) BaseAddress;
|
||||
|
||||
EhcDev->UsbHostControllerBaseAddress = (UINT32)BaseAddress;
|
||||
|
||||
EhcDev->HcStructParams = EhcReadCapRegister (EhcDev, EHC_HCSPARAMS_OFFSET);
|
||||
EhcDev->HcCapParams = EhcReadCapRegister (EhcDev, EHC_HCCPARAMS_OFFSET);
|
||||
@ -1301,7 +1304,6 @@ InitializeUsbHC (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
|
||||
EhcResetHC (EhcDev, EHC_RESET_TIMEOUT);
|
||||
|
||||
Status = EhcInitHC (EhcDev);
|
||||
|
@ -51,7 +51,6 @@ typedef struct _PEI_USB2_HC_DEV PEI_USB2_HC_DEV;
|
||||
#define EHC_RESET_TIMEOUT (1 * EHC_1_SECOND)
|
||||
#define EHC_GENERIC_TIMEOUT (10 * EHC_1_MILLISECOND)
|
||||
|
||||
|
||||
//
|
||||
// Wait for roothub port power stable, refers to Spec[EHCI1.0-2.3.9]
|
||||
//
|
||||
@ -64,7 +63,6 @@ typedef struct _PEI_USB2_HC_DEV PEI_USB2_HC_DEV;
|
||||
|
||||
#define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
|
||||
|
||||
|
||||
#define EHC_LOW_32BIT(Addr64) ((UINT32)(((UINTN)(Addr64)) & 0XFFFFFFFF))
|
||||
#define EHC_HIGH_32BIT(Addr64) ((UINT32)(RShiftU64((UINTN)(Addr64), 32) & 0XFFFFFFFF))
|
||||
#define EHC_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
|
||||
|
@ -10,8 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _EFI_EHCI_REG_H_
|
||||
#define _EFI_EHCI_REG_H_
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Capability register offset
|
||||
//
|
||||
@ -106,7 +104,6 @@ typedef struct {
|
||||
} USB_CLASSC;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
/**
|
||||
Read EHCI capability register.
|
||||
|
||||
|
@ -160,7 +160,7 @@ EhcInitSched (
|
||||
//
|
||||
// Initialize the frame list entries then set the registers
|
||||
//
|
||||
Desc = (UINT32 *) Ehc->PeriodFrame;
|
||||
Desc = (UINT32 *)Ehc->PeriodFrame;
|
||||
PciAddr = UsbHcGetPciAddressForHostMem (Ehc->MemPool, Ehc->PeriodOne, sizeof (PEI_EHC_QH));
|
||||
for (Index = 0; Index < EHC_FRAME_LEN; Index++) {
|
||||
Desc[Index] = QH_LINK (PciAddr, EHC_TYPE_QH, FALSE);
|
||||
@ -247,7 +247,7 @@ EhcLinkQhToAsync (
|
||||
Qh->NextQh = Head->NextQh;
|
||||
Head->NextQh = Qh;
|
||||
|
||||
Qh->QhHw.HorizonLink = QH_LINK (Head, EHC_TYPE_QH, FALSE);;
|
||||
Qh->QhHw.HorizonLink = QH_LINK (Head, EHC_TYPE_QH, FALSE);
|
||||
Head->QhHw.HorizonLink = QH_LINK (Qh, EHC_TYPE_QH, FALSE);
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ EhcCheckUrbResult (
|
||||
BASE_LIST_FOR_EACH (Entry, &Urb->Qh->Qtds) {
|
||||
Qtd = EFI_LIST_CONTAINER (Entry, PEI_EHC_QTD, QtdList);
|
||||
QtdHw = &Qtd->QtdHw;
|
||||
State = (UINT8) QtdHw->Status;
|
||||
State = (UINT8)QtdHw->Status;
|
||||
|
||||
if (EHC_BIT_IS_SET (State, QTD_STAT_HALTED)) {
|
||||
//
|
||||
@ -352,7 +352,6 @@ EhcCheckUrbResult (
|
||||
|
||||
Finished = TRUE;
|
||||
goto ON_EXIT;
|
||||
|
||||
} else if (EHC_BIT_IS_SET (State, QTD_STAT_ACTIVE)) {
|
||||
//
|
||||
// The QTD is still active, no need to check furthur.
|
||||
@ -361,7 +360,6 @@ EhcCheckUrbResult (
|
||||
|
||||
Finished = FALSE;
|
||||
goto ON_EXIT;
|
||||
|
||||
} else {
|
||||
//
|
||||
// This QTD is finished OK or met short packet read. Update the
|
||||
@ -372,7 +370,7 @@ EhcCheckUrbResult (
|
||||
}
|
||||
|
||||
if ((QtdHw->TotalBytes != 0) && (QtdHw->Pid == QTD_PID_INPUT)) {
|
||||
//EHC_DUMP_QH ((Urb->Qh, "Short packet read", FALSE));
|
||||
// EHC_DUMP_QH ((Urb->Qh, "Short packet read", FALSE));
|
||||
|
||||
//
|
||||
// Short packet read condition. If it isn't a setup transfer,
|
||||
@ -381,7 +379,6 @@ EhcCheckUrbResult (
|
||||
// Status Stage of the setup transfer to get the finial result
|
||||
//
|
||||
if (QtdHw->AltNext == QTD_LINK (Ehc->ShortReadStop, FALSE)) {
|
||||
|
||||
Finished = TRUE;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
@ -399,7 +396,7 @@ ON_EXIT:
|
||||
// NOTICE: don't move DT update before the loop, otherwise there is
|
||||
// a race condition that DT is wrong.
|
||||
//
|
||||
Urb->DataToggle = (UINT8) Urb->Qh->QhHw.DataToggle;
|
||||
Urb->DataToggle = (UINT8)Urb->Qh->QhHw.DataToggle;
|
||||
|
||||
return Finished;
|
||||
}
|
||||
@ -460,4 +457,3 @@ EhcExecTransfer (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ EhcCreateQtd (
|
||||
Len = Len - Len % MaxPacket;
|
||||
}
|
||||
|
||||
QtdHw->TotalBytes = (UINT32) Len;
|
||||
QtdHw->TotalBytes = (UINT32)Len;
|
||||
Qtd->DataLen = Len;
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ EhcInitIntQh (
|
||||
//
|
||||
if (Ep->DevSpeed == EFI_USB_SPEED_HIGH) {
|
||||
QhHw->SMask = QH_MICROFRAME_0;
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -190,7 +190,7 @@ EhcCreateQh (
|
||||
QhHw->EpSpeed = Ep->DevSpeed;
|
||||
QhHw->DtCtrl = 0;
|
||||
QhHw->ReclaimHead = 0;
|
||||
QhHw->MaxPacketLen = (UINT32) Ep->MaxPacket;
|
||||
QhHw->MaxPacketLen = (UINT32)Ep->MaxPacket;
|
||||
QhHw->CtrlEp = 0;
|
||||
QhHw->NakReload = QH_NAK_RELOAD;
|
||||
QhHw->HubAddr = Ep->HubAddr;
|
||||
@ -214,6 +214,7 @@ EhcCreateQh (
|
||||
if (Ep->DevSpeed != EFI_USB_SPEED_HIGH) {
|
||||
QhHw->CtrlEp = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EHC_INT_TRANSFER_ASYNC:
|
||||
@ -428,7 +429,7 @@ EhcCreateQtds (
|
||||
while (Len < Urb->DataLen) {
|
||||
Qtd = EhcCreateQtd (
|
||||
Ehc,
|
||||
(UINT8 *) Urb->DataPhy + Len,
|
||||
(UINT8 *)Urb->DataPhy + Len,
|
||||
Urb->DataLen - Len,
|
||||
Pid,
|
||||
Toggle,
|
||||
@ -446,7 +447,7 @@ EhcCreateQtds (
|
||||
// Switch the Toggle bit if odd number of packets are included in the QTD.
|
||||
//
|
||||
if (((Qtd->DataLen + Ep->MaxPacket - 1) / Ep->MaxPacket) % 2) {
|
||||
Toggle = (UINT8) (1 - Toggle);
|
||||
Toggle = (UINT8)(1 - Toggle);
|
||||
}
|
||||
|
||||
Len += Qtd->DataLen;
|
||||
@ -543,7 +544,7 @@ EhcCreateUrb (
|
||||
|
||||
Ep = &Urb->Ep;
|
||||
Ep->DevAddr = DevAddr;
|
||||
Ep->EpAddr = (UINT8) (EpAddr & 0x0F);
|
||||
Ep->EpAddr = (UINT8)(EpAddr & 0x0F);
|
||||
Ep->Direction = (((EpAddr & 0x80) != 0) ? EfiUsbDataIn : EfiUsbDataOut);
|
||||
Ep->DevSpeed = DevSpeed;
|
||||
Ep->MaxPacket = MaxPacket;
|
||||
@ -590,7 +591,7 @@ EhcCreateUrb (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Urb->RequestPhy = (VOID *) ((UINTN) PhyAddr);
|
||||
Urb->RequestPhy = (VOID *)((UINTN)PhyAddr);
|
||||
Urb->RequestMap = Map;
|
||||
}
|
||||
|
||||
@ -609,7 +610,7 @@ EhcCreateUrb (
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Urb->DataPhy = (VOID *) ((UINTN) PhyAddr);
|
||||
Urb->DataPhy = (VOID *)((UINTN)PhyAddr);
|
||||
Urb->DataMap = Map;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,6 @@ typedef struct {
|
||||
} QH_HW;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
//
|
||||
// Endpoint address and its capabilities
|
||||
//
|
||||
@ -167,8 +166,6 @@ struct _PEI_EHC_QTD {
|
||||
UINTN DataLen; // Original amount of data in this QTD
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Software QH structure. All three different transaction types
|
||||
// supported by UEFI USB, that is the control/bulk/interrupt
|
||||
@ -321,4 +318,5 @@ EhcCreateUrb (
|
||||
IN UINTN Interval
|
||||
)
|
||||
;
|
||||
|
||||
#endif
|
||||
|
@ -36,7 +36,7 @@ UsbHcAllocMemBlock (
|
||||
EFI_PHYSICAL_ADDRESS TempPtr;
|
||||
|
||||
Mapping = NULL;
|
||||
PageNumber = sizeof(USBHC_MEM_BLOCK)/PAGESIZE +1;
|
||||
PageNumber = sizeof (USBHC_MEM_BLOCK)/PAGESIZE +1;
|
||||
Status = PeiServicesAllocatePages (
|
||||
EfiBootServicesCode,
|
||||
PageNumber,
|
||||
@ -46,6 +46,7 @@ UsbHcAllocMemBlock (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, PageNumber*EFI_PAGE_SIZE);
|
||||
|
||||
//
|
||||
@ -54,7 +55,7 @@ UsbHcAllocMemBlock (
|
||||
//
|
||||
ASSERT (USBHC_MEM_UNIT * 8 <= EFI_PAGE_SIZE);
|
||||
|
||||
Block = (USBHC_MEM_BLOCK*)(UINTN)TempPtr;
|
||||
Block = (USBHC_MEM_BLOCK *)(UINTN)TempPtr;
|
||||
Block->BufLen = EFI_PAGES_TO_SIZE (Pages);
|
||||
Block->BitsLen = Block->BufLen / (USBHC_MEM_UNIT * 8);
|
||||
|
||||
@ -68,6 +69,7 @@ UsbHcAllocMemBlock (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, PageNumber*EFI_PAGE_SIZE);
|
||||
|
||||
Block->Bits = (UINT8 *)(UINTN)TempPtr;
|
||||
@ -75,13 +77,14 @@ UsbHcAllocMemBlock (
|
||||
Status = IoMmuAllocateBuffer (
|
||||
Ehc->IoMmu,
|
||||
Pages,
|
||||
(VOID **) &BufHost,
|
||||
(VOID **)&BufHost,
|
||||
&MappedAddr,
|
||||
&Mapping
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem (BufHost, Pages*EFI_PAGE_SIZE);
|
||||
|
||||
//
|
||||
@ -93,12 +96,11 @@ UsbHcAllocMemBlock (
|
||||
}
|
||||
|
||||
Block->BufHost = BufHost;
|
||||
Block->Buf = (UINT8 *) ((UINTN) MappedAddr);
|
||||
Block->Buf = (UINT8 *)((UINTN)MappedAddr);
|
||||
Block->Mapping = Mapping;
|
||||
Block->Next = NULL;
|
||||
|
||||
return Block;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +166,6 @@ UsbHcAllocMemFromBlock (
|
||||
}
|
||||
|
||||
NEXT_BIT (Byte, Bit);
|
||||
|
||||
} else {
|
||||
NEXT_BIT (Byte, Bit);
|
||||
|
||||
@ -187,7 +188,7 @@ UsbHcAllocMemFromBlock (
|
||||
for (Count = 0; Count < Units; Count++) {
|
||||
ASSERT (!USB_HC_BIT_IS_SET (Block->Bits[Byte], Bit));
|
||||
|
||||
Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] | (UINT8) USB_HC_BIT (Bit));
|
||||
Block->Bits[Byte] = (UINT8)(Block->Bits[Byte] | (UINT8)USB_HC_BIT (Bit));
|
||||
NEXT_BIT (Byte, Bit);
|
||||
}
|
||||
|
||||
@ -228,7 +229,7 @@ UsbHcGetPciAddressForHostMem (
|
||||
// scan the memory block list for the memory block that
|
||||
// completely contains the allocated memory.
|
||||
//
|
||||
if ((Block->BufHost <= (UINT8 *) Mem) && (((UINT8 *) Mem + AllocSize) <= (Block->BufHost + Block->BufLen))) {
|
||||
if ((Block->BufHost <= (UINT8 *)Mem) && (((UINT8 *)Mem + AllocSize) <= (Block->BufHost + Block->BufLen))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -238,7 +239,7 @@ UsbHcGetPciAddressForHostMem (
|
||||
// calculate the pci memory address for host memory address.
|
||||
//
|
||||
Offset = (UINT8 *)Mem - Block->BufHost;
|
||||
PhyAddr = (EFI_PHYSICAL_ADDRESS)(UINTN) (Block->Buf + Offset);
|
||||
PhyAddr = (EFI_PHYSICAL_ADDRESS)(UINTN)(Block->Buf + Offset);
|
||||
return PhyAddr;
|
||||
}
|
||||
|
||||
@ -276,7 +277,6 @@ UsbHcIsMemBlockEmpty (
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
|
||||
for (Index = 0; Index < Block->BitsLen; Index++) {
|
||||
if (Block->Bits[Index] != 0) {
|
||||
return FALSE;
|
||||
@ -286,7 +286,6 @@ UsbHcIsMemBlockEmpty (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize the memory management pool for the host controller.
|
||||
|
||||
@ -311,7 +310,7 @@ UsbHcInitMemPool (
|
||||
EFI_STATUS Status;
|
||||
EFI_PHYSICAL_ADDRESS TempPtr;
|
||||
|
||||
PageNumber = sizeof(USBHC_MEM_POOL)/PAGESIZE +1;
|
||||
PageNumber = sizeof (USBHC_MEM_POOL)/PAGESIZE +1;
|
||||
Status = PeiServicesAllocatePages (
|
||||
EfiBootServicesCode,
|
||||
PageNumber,
|
||||
@ -321,9 +320,10 @@ UsbHcInitMemPool (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, PageNumber*EFI_PAGE_SIZE);
|
||||
|
||||
Pool = (USBHC_MEM_POOL *) ((UINTN) TempPtr);
|
||||
Pool = (USBHC_MEM_POOL *)((UINTN)TempPtr);
|
||||
|
||||
Pool->Check4G = Check4G;
|
||||
Pool->Which4G = Which4G;
|
||||
@ -425,7 +425,8 @@ UsbHcAllocateMem (
|
||||
} else {
|
||||
Pages = USBHC_MEM_DEFAULT_PAGES;
|
||||
}
|
||||
NewBlock = UsbHcAllocMemBlock (Ehc,Pool, Pages);
|
||||
|
||||
NewBlock = UsbHcAllocMemBlock (Ehc, Pool, Pages);
|
||||
|
||||
if (NewBlock == NULL) {
|
||||
return NULL;
|
||||
@ -471,7 +472,7 @@ UsbHcFreeMem (
|
||||
|
||||
Head = Pool->Head;
|
||||
AllocSize = USBHC_MEM_ROUND (Size);
|
||||
ToFree = (UINT8 *) Mem;
|
||||
ToFree = (UINT8 *)Mem;
|
||||
|
||||
for (Block = Head; Block != NULL; Block = Block->Next) {
|
||||
//
|
||||
@ -491,7 +492,7 @@ UsbHcFreeMem (
|
||||
for (Count = 0; Count < (AllocSize / USBHC_MEM_UNIT); Count++) {
|
||||
ASSERT (USB_HC_BIT_IS_SET (Block->Bits[Byte], Bit));
|
||||
|
||||
Block->Bits[Byte] = (UINT8) (Block->Bits[Byte] ^ USB_HC_BIT (Bit));
|
||||
Block->Bits[Byte] = (UINT8)(Block->Bits[Byte] ^ USB_HC_BIT (Bit));
|
||||
NEXT_BIT (Byte, Bit);
|
||||
}
|
||||
|
||||
@ -513,5 +514,5 @@ UsbHcFreeMem (
|
||||
UsbHcFreeMemBlock (Ehc, Pool, Block);
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
@ -66,7 +66,6 @@ typedef struct _USBHC_MEM_POOL {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
Calculate the corresponding pci bus address according to the Mem parameter.
|
||||
|
||||
|
@ -43,7 +43,7 @@ AtapiPeimEntry (
|
||||
&gPeiAtaControllerPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &AtaControllerPpi
|
||||
(VOID **)&AtaControllerPpi
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
@ -169,7 +169,7 @@ AtapiGetBlockDeviceMediaInfo (
|
||||
|
||||
AtapiBlkIoDev = NULL;
|
||||
|
||||
if (This == NULL || MediaInfo == NULL) {
|
||||
if ((This == NULL) || (MediaInfo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ AtapiGetBlockDeviceMediaInfo (
|
||||
//
|
||||
// Get media info from AtapiBlkIoDev
|
||||
//
|
||||
CopyMem (MediaInfo, &AtapiBlkIoDev->DeviceInfo[Index].MediaInfo, sizeof(EFI_PEI_BLOCK_IO_MEDIA));
|
||||
CopyMem (MediaInfo, &AtapiBlkIoDev->DeviceInfo[Index].MediaInfo, sizeof (EFI_PEI_BLOCK_IO_MEDIA));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -264,7 +264,6 @@ AtapiReadBlocks (
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
|
||||
EFI_PEI_BLOCK_IO_MEDIA MediaInfo;
|
||||
EFI_STATUS Status;
|
||||
UINTN NumberOfBlocks;
|
||||
@ -412,7 +411,7 @@ AtapiGetBlockDeviceMediaInfo2 (
|
||||
|
||||
AtapiBlkIoDev = NULL;
|
||||
|
||||
if (This == NULL || MediaInfo == NULL) {
|
||||
if ((This == NULL) || (MediaInfo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -427,10 +426,11 @@ AtapiGetBlockDeviceMediaInfo2 (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get media info from AtapiBlkIoDev
|
||||
//
|
||||
CopyMem (MediaInfo, &AtapiBlkIoDev->DeviceInfo[DeviceIndex - 1].MediaInfo2, sizeof(EFI_PEI_BLOCK_IO2_MEDIA));
|
||||
CopyMem (MediaInfo, &AtapiBlkIoDev->DeviceInfo[DeviceIndex - 1].MediaInfo2, sizeof (EFI_PEI_BLOCK_IO2_MEDIA));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -503,7 +503,6 @@ AtapiReadBlocks2 (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enumerate Atapi devices.
|
||||
|
||||
@ -540,7 +539,7 @@ AtapiEnumerateDevices (
|
||||
// Enable Sata and IDE controller.
|
||||
//
|
||||
AtapiBlkIoDev->AtaControllerPpi->EnableAtaChannel (
|
||||
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer(),
|
||||
(EFI_PEI_SERVICES **)GetPeiServicesTablePointer (),
|
||||
AtapiBlkIoDev->AtaControllerPpi,
|
||||
PEI_ICH_IDE_PRIMARY | PEI_ICH_IDE_SECONDARY
|
||||
);
|
||||
@ -556,7 +555,7 @@ AtapiEnumerateDevices (
|
||||
// Get four channels (primary or secondary Pata, Sata Channel) Command and Control Regs Base address.
|
||||
//
|
||||
IdeEnabledNumber = AtapiBlkIoDev->AtaControllerPpi->GetIdeRegsBaseAddr (
|
||||
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer(),
|
||||
(EFI_PEI_SERVICES **)GetPeiServicesTablePointer (),
|
||||
AtapiBlkIoDev->AtaControllerPpi,
|
||||
IdeRegsBaseAddr
|
||||
);
|
||||
@ -564,20 +563,20 @@ AtapiEnumerateDevices (
|
||||
//
|
||||
// Using Command and Control Regs Base Address to fill other registers.
|
||||
//
|
||||
for (Index1 = 0; Index1 < IdeEnabledNumber; Index1 ++) {
|
||||
for (Index1 = 0; Index1 < IdeEnabledNumber; Index1++) {
|
||||
CommandBlockBaseAddr = IdeRegsBaseAddr[Index1].CommandBlockBaseAddr;
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].Data = CommandBlockBaseAddr;
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].Reg1.Feature = (UINT16) (CommandBlockBaseAddr + 0x1);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].SectorCount = (UINT16) (CommandBlockBaseAddr + 0x2);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x3);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x4);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x5);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].Head = (UINT16) (CommandBlockBaseAddr + 0x6);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].Reg.Command = (UINT16) (CommandBlockBaseAddr + 0x7);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].Reg1.Feature = (UINT16)(CommandBlockBaseAddr + 0x1);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].SectorCount = (UINT16)(CommandBlockBaseAddr + 0x2);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].SectorNumber = (UINT16)(CommandBlockBaseAddr + 0x3);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].CylinderLsb = (UINT16)(CommandBlockBaseAddr + 0x4);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].CylinderMsb = (UINT16)(CommandBlockBaseAddr + 0x5);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].Head = (UINT16)(CommandBlockBaseAddr + 0x6);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].Reg.Command = (UINT16)(CommandBlockBaseAddr + 0x7);
|
||||
|
||||
ControlBlockBaseAddr = IdeRegsBaseAddr[Index1].ControlBlockBaseAddr;
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].Alt.DeviceControl = ControlBlockBaseAddr;
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].DriveAddress = (UINT16) (ControlBlockBaseAddr + 0x1);
|
||||
AtapiBlkIoDev->IdeIoPortReg[Index1].DriveAddress = (UINT16)(ControlBlockBaseAddr + 0x1);
|
||||
|
||||
//
|
||||
// Scan IDE bus for ATAPI devices IDE or Sata device
|
||||
@ -611,6 +610,7 @@ AtapiEnumerateDevices (
|
||||
AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo2.MediaPresent = FALSE;
|
||||
AtapiBlkIoDev->DeviceInfo[DeviceCount].MediaInfo2.LastBlock = 0;
|
||||
}
|
||||
|
||||
DeviceCount += 1;
|
||||
}
|
||||
}
|
||||
@ -644,11 +644,11 @@ DiscoverAtapiDevice (
|
||||
if (!DetectIDEController (AtapiBlkIoDev, DevicePosition)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// test if it is an ATAPI device (only supported device)
|
||||
//
|
||||
if (ATAPIIdentify (AtapiBlkIoDev, DevicePosition) == EFI_SUCCESS) {
|
||||
|
||||
Status = Inquiry (AtapiBlkIoDev, DevicePosition, MediaInfo, MediaInfo2);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return TRUE;
|
||||
@ -690,8 +690,8 @@ CheckPowerMode (
|
||||
UINT8 ErrorValue;
|
||||
UINT8 SectorCountValue;
|
||||
|
||||
Channel = (UINT8) (DevicePosition / 2);
|
||||
Device = (UINT8) (DevicePosition % 2);
|
||||
Channel = (UINT8)(DevicePosition / 2);
|
||||
Device = (UINT8)(DevicePosition % 2);
|
||||
|
||||
ASSERT (Channel < MAX_IDE_CHANNELS);
|
||||
|
||||
@ -704,7 +704,7 @@ CheckPowerMode (
|
||||
//
|
||||
// select device
|
||||
//
|
||||
IoWrite8 (HeadRegister, (UINT8) ((Device << 4) | 0xe0));
|
||||
IoWrite8 (HeadRegister, (UINT8)((Device << 4) | 0xe0));
|
||||
|
||||
//
|
||||
// refresh the SectorCount register
|
||||
@ -715,14 +715,14 @@ CheckPowerMode (
|
||||
//
|
||||
// select device
|
||||
//
|
||||
IoWrite8 (HeadRegister, (UINT8) ((Device << 4) | 0xe0));
|
||||
IoWrite8 (HeadRegister, (UINT8)((Device << 4) | 0xe0));
|
||||
|
||||
Status = DRDYReady (AtapiBlkIoDev, &(AtapiBlkIoDev->IdeIoPortReg[Channel]), 100);
|
||||
|
||||
//
|
||||
// select device
|
||||
//
|
||||
IoWrite8 (HeadRegister, (UINT8) ((Device << 4) | 0xe0));
|
||||
IoWrite8 (HeadRegister, (UINT8)((Device << 4) | 0xe0));
|
||||
//
|
||||
// send 'check power' commandd via Command Register
|
||||
//
|
||||
@ -766,7 +766,7 @@ CheckPowerMode (
|
||||
// Write SectorCount 0x55 but return valid state value. Maybe no device
|
||||
// exists or some slow kind of ATAPI device exists.
|
||||
//
|
||||
IoWrite8 (HeadRegister, (UINT8) ((Device << 4) | 0xe0));
|
||||
IoWrite8 (HeadRegister, (UINT8)((Device << 4) | 0xe0));
|
||||
|
||||
//
|
||||
// write 0x55 and 0xaa to SectorCounter register,
|
||||
@ -781,6 +781,7 @@ CheckPowerMode (
|
||||
if (SectorCountValue != 0x55) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Send a "ATAPI TEST UNIT READY" command ... slow but accurate
|
||||
//
|
||||
@ -811,7 +812,7 @@ DetectIDEController (
|
||||
EFI_STATUS Status;
|
||||
UINT8 AtaCommand;
|
||||
|
||||
Channel = (UINT8) (DevicePosition / 2);
|
||||
Channel = (UINT8)(DevicePosition / 2);
|
||||
|
||||
ASSERT (Channel < MAX_IDE_CHANNELS);
|
||||
//
|
||||
@ -821,6 +822,7 @@ DetectIDEController (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Send 'check power' command for IDE device
|
||||
//
|
||||
@ -865,10 +867,10 @@ WaitForBSYClear (
|
||||
if ((StatusValue & ATA_STSREG_BSY) == 0x00) {
|
||||
break;
|
||||
}
|
||||
|
||||
MicroSecondDelay (250);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (Delay != 0);
|
||||
|
||||
if (Delay == 0) {
|
||||
@ -925,7 +927,6 @@ DRDYReady (
|
||||
MicroSecondDelay (250);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (Delay != 0);
|
||||
|
||||
if (Delay == 0) {
|
||||
@ -964,7 +965,6 @@ DRQClear (
|
||||
|
||||
Delay = ((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 250) + 1;
|
||||
do {
|
||||
|
||||
StatusValue = IoRead8 (StatusRegister);
|
||||
|
||||
//
|
||||
@ -1022,7 +1022,6 @@ DRQClear2 (
|
||||
|
||||
Delay = ((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 250) + 1;
|
||||
do {
|
||||
|
||||
AltStatusValue = IoRead8 (AltStatusRegister);
|
||||
|
||||
//
|
||||
@ -1095,12 +1094,12 @@ DRQReady (
|
||||
}
|
||||
|
||||
if ((StatusValue & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {
|
||||
|
||||
ErrValue = IoRead8 (IdeIoRegisters->Reg1.Error);
|
||||
if ((ErrValue & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
}
|
||||
|
||||
MicroSecondDelay (250);
|
||||
|
||||
Delay--;
|
||||
@ -1143,7 +1142,6 @@ DRQReady2 (
|
||||
|
||||
Delay = ((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 250) + 1;
|
||||
do {
|
||||
|
||||
AltStatusValue = IoRead8 (AltStatusRegister);
|
||||
|
||||
//
|
||||
@ -1154,12 +1152,12 @@ DRQReady2 (
|
||||
}
|
||||
|
||||
if ((AltStatusValue & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {
|
||||
|
||||
ErrValue = IoRead8 (IdeIoRegisters->Reg1.Error);
|
||||
if ((ErrValue & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
}
|
||||
|
||||
MicroSecondDelay (250);
|
||||
|
||||
Delay--;
|
||||
@ -1193,12 +1191,10 @@ CheckErrorStatus (
|
||||
StatusValue = IoRead8 (StatusReg);
|
||||
|
||||
if ((StatusValue & (ATA_STSREG_ERR | ATA_STSREG_DWF | ATA_STSREG_CORR)) == 0) {
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1238,10 +1234,10 @@ ATAPIIdentify (
|
||||
EFI_STATUS Status;
|
||||
|
||||
ByteCount = sizeof (AtapiIdentifyData);
|
||||
Buffer16 = (UINT16 *) &AtapiIdentifyData;
|
||||
Buffer16 = (UINT16 *)&AtapiIdentifyData;
|
||||
|
||||
Channel = (UINT8) (DevicePosition / 2);
|
||||
Device = (UINT8) (DevicePosition % 2);
|
||||
Channel = (UINT8)(DevicePosition / 2);
|
||||
Device = (UINT8)(DevicePosition % 2);
|
||||
|
||||
ASSERT (Channel < MAX_IDE_CHANNELS);
|
||||
|
||||
@ -1261,9 +1257,11 @@ ATAPIIdentify (
|
||||
AtapiBlkIoDev,
|
||||
&(AtapiBlkIoDev->IdeIoPortReg[Channel]),
|
||||
ATATIMEOUT
|
||||
) != EFI_SUCCESS) {
|
||||
) != EFI_SUCCESS)
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// select device via Head/Device register.
|
||||
// Before write Head/Device register, BSY and DRQ must be 0.
|
||||
@ -1271,11 +1269,12 @@ ATAPIIdentify (
|
||||
if (DRQClear2 (AtapiBlkIoDev, &(AtapiBlkIoDev->IdeIoPortReg[Channel]), ATATIMEOUT) != EFI_SUCCESS) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// e0:1110,0000-- bit7 and bit5 are reserved bits.
|
||||
// bit6 set means LBA mode
|
||||
//
|
||||
IoWrite8 (HeadReg, (UINT8) ((Device << 4) | 0xe0));
|
||||
IoWrite8 (HeadReg, (UINT8)((Device << 4) | 0xe0));
|
||||
|
||||
//
|
||||
// set all the command parameters
|
||||
@ -1285,8 +1284,8 @@ ATAPIIdentify (
|
||||
AtapiBlkIoDev,
|
||||
&(AtapiBlkIoDev->IdeIoPortReg[Channel]),
|
||||
ATATIMEOUT
|
||||
) != EFI_SUCCESS) {
|
||||
|
||||
) != EFI_SUCCESS)
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@ -1330,15 +1329,16 @@ ATAPIIdentify (
|
||||
}
|
||||
|
||||
if (CheckErrorStatus (AtapiBlkIoDev, StatusReg) != EFI_SUCCESS) {
|
||||
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the byte count for one series of read
|
||||
//
|
||||
if ((WordCount + Increment) > ByteCount / 2) {
|
||||
Increment = ByteCount / 2 - WordCount;
|
||||
}
|
||||
|
||||
//
|
||||
// perform a series of read without check DRQ ready
|
||||
//
|
||||
@ -1347,8 +1347,8 @@ ATAPIIdentify (
|
||||
}
|
||||
|
||||
WordCount += Increment;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// while
|
||||
//
|
||||
@ -1356,12 +1356,12 @@ ATAPIIdentify (
|
||||
AtapiBlkIoDev,
|
||||
&(AtapiBlkIoDev->IdeIoPortReg[Channel]),
|
||||
ATATIMEOUT
|
||||
) != EFI_SUCCESS) {
|
||||
) != EFI_SUCCESS)
|
||||
{
|
||||
return CheckErrorStatus (AtapiBlkIoDev, StatusReg);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1449,8 +1449,8 @@ AtapiPacketCommandIn (
|
||||
//
|
||||
UINT32 ActualWordCount;
|
||||
|
||||
Channel = (UINT8) (DevicePosition / 2);
|
||||
Device = (UINT8) (DevicePosition % 2);
|
||||
Channel = (UINT8)(DevicePosition / 2);
|
||||
Device = (UINT8)(DevicePosition % 2);
|
||||
|
||||
ASSERT (Channel < MAX_IDE_CHANNELS);
|
||||
|
||||
@ -1471,14 +1471,16 @@ AtapiPacketCommandIn (
|
||||
AtapiBlkIoDev,
|
||||
&(AtapiBlkIoDev->IdeIoPortReg[Channel]),
|
||||
ATATIMEOUT
|
||||
) != EFI_SUCCESS) {
|
||||
) != EFI_SUCCESS)
|
||||
{
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Select device via Device/Head Register.
|
||||
// DEFAULT_CMD: 0xa0 (1010,0000)
|
||||
//
|
||||
IoWrite8 (HeadReg, (UINT8) ((Device << 4) | ATA_DEFAULT_CMD));
|
||||
IoWrite8 (HeadReg, (UINT8)((Device << 4) | ATA_DEFAULT_CMD));
|
||||
|
||||
//
|
||||
// No OVL; No DMA
|
||||
@ -1489,8 +1491,8 @@ AtapiPacketCommandIn (
|
||||
// set the transfersize to MAX_ATAPI_BYTE_COUNT to let the device
|
||||
// determine how many data should be transfered.
|
||||
//
|
||||
IoWrite8 (CylinderLsbReg, (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff));
|
||||
IoWrite8 (CylinderMsbReg, (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8));
|
||||
IoWrite8 (CylinderLsbReg, (UINT8)(ATAPI_MAX_BYTE_COUNT & 0x00ff));
|
||||
IoWrite8 (CylinderMsbReg, (UINT8)(ATAPI_MAX_BYTE_COUNT >> 8));
|
||||
|
||||
//
|
||||
// DEFAULT_CTL:0x0a (0000,1010)
|
||||
@ -1508,6 +1510,7 @@ AtapiPacketCommandIn (
|
||||
if (Status != EFI_SUCCESS) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Send out command packet
|
||||
//
|
||||
@ -1527,9 +1530,10 @@ AtapiPacketCommandIn (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (Buffer == NULL || ByteCount == 0) {
|
||||
if ((Buffer == NULL) || (ByteCount == 0)) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// call PioReadWriteData() function to get
|
||||
// requested transfer data form device.
|
||||
@ -1551,9 +1555,11 @@ AtapiPacketCommandIn (
|
||||
AtapiBlkIoDev,
|
||||
&(AtapiBlkIoDev->IdeIoPortReg[Channel]),
|
||||
TimeoutInMilliSeconds
|
||||
) != EFI_SUCCESS) {
|
||||
) != EFI_SUCCESS)
|
||||
{
|
||||
return CheckErrorStatus (AtapiBlkIoDev, StatusReg);
|
||||
}
|
||||
|
||||
//
|
||||
// read Status Register will clear interrupt
|
||||
//
|
||||
@ -1571,21 +1577,19 @@ AtapiPacketCommandIn (
|
||||
// perform a series data In/Out.
|
||||
//
|
||||
for (Index = 0; (Index < WordCount) && (ActualWordCount < RequiredWordCount); Index++, ActualWordCount++) {
|
||||
|
||||
*PtrBuffer = IoRead16 (DataReg);
|
||||
|
||||
PtrBuffer++;
|
||||
|
||||
}
|
||||
|
||||
if (((ATAPI_REQUEST_SENSE_CMD *) Packet)->opcode == ATA_CMD_REQUEST_SENSE && ActualWordCount >= 4) {
|
||||
if ((((ATAPI_REQUEST_SENSE_CMD *)Packet)->opcode == ATA_CMD_REQUEST_SENSE) && (ActualWordCount >= 4)) {
|
||||
RequiredWordCount = MIN (
|
||||
RequiredWordCount,
|
||||
(UINT32) (4 + (((ATAPI_REQUEST_SENSE_DATA *) Buffer)->addnl_sense_length / 2))
|
||||
(UINT32)(4 + (((ATAPI_REQUEST_SENSE_DATA *)Buffer)->addnl_sense_length / 2))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// After data transfer is completed, normally, DRQ bit should clear.
|
||||
//
|
||||
@ -1593,6 +1597,7 @@ AtapiPacketCommandIn (
|
||||
if (Status != EFI_SUCCESS) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// read status register to check whether error happens.
|
||||
//
|
||||
@ -1634,7 +1639,7 @@ Inquiry (
|
||||
|
||||
Packet.Inquiry.opcode = ATA_CMD_INQUIRY;
|
||||
Packet.Inquiry.page_code = 0;
|
||||
Packet.Inquiry.allocation_length = (UINT8) sizeof (ATAPI_INQUIRY_DATA);
|
||||
Packet.Inquiry.allocation_length = (UINT8)sizeof (ATAPI_INQUIRY_DATA);
|
||||
|
||||
//
|
||||
// Send command packet and get requested Inquiry data.
|
||||
@ -1643,15 +1648,16 @@ Inquiry (
|
||||
AtapiBlkIoDev,
|
||||
DevicePosition,
|
||||
&Packet,
|
||||
(UINT16 *) (&Idata),
|
||||
(UINT16 *)(&Idata),
|
||||
sizeof (ATAPI_INQUIRY_DATA),
|
||||
ATAPITIMEOUT
|
||||
//50
|
||||
// 50
|
||||
);
|
||||
|
||||
if (Status != EFI_SUCCESS) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Identify device type via INQUIRY data.
|
||||
//
|
||||
@ -1718,7 +1724,6 @@ DetectMedia (
|
||||
IN OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo2
|
||||
)
|
||||
{
|
||||
|
||||
UINTN Index;
|
||||
UINTN RetryNum;
|
||||
UINTN MaxRetryNum;
|
||||
@ -1738,7 +1743,6 @@ DetectMedia (
|
||||
// the device will produce corresponding Sense data.
|
||||
//
|
||||
for (Index = 0; Index < 2; Index++) {
|
||||
|
||||
Status = TestUnitReady (AtapiBlkIoDev, DevicePosition);
|
||||
if (Status != EFI_SUCCESS) {
|
||||
Status = ResetDevice (AtapiBlkIoDev, DevicePosition, FALSE);
|
||||
@ -1746,7 +1750,6 @@ DetectMedia (
|
||||
if (Status != EFI_SUCCESS) {
|
||||
ResetDevice (AtapiBlkIoDev, DevicePosition, TRUE);
|
||||
}
|
||||
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -1776,9 +1779,7 @@ DetectMedia (
|
||||
}
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
|
||||
if (IsNoMedia (SenseBuffers, SenseCounts)) {
|
||||
|
||||
NeedReadCapacity = FALSE;
|
||||
MediaInfo->MediaPresent = FALSE;
|
||||
MediaInfo->LastBlock = 0;
|
||||
@ -1801,19 +1802,16 @@ DetectMedia (
|
||||
// initial retry once
|
||||
//
|
||||
for (Index = 0; (Index < RetryNum) && (Index < MaxRetryNum); Index++) {
|
||||
|
||||
Status = ReadCapacity (AtapiBlkIoDev, DevicePosition, MediaInfo, MediaInfo2);
|
||||
MicroSecondDelay (200000);
|
||||
SenseCounts = MAX_SENSE_KEY_COUNT;
|
||||
|
||||
if (Status != EFI_SUCCESS) {
|
||||
|
||||
Status = RequestSense (AtapiBlkIoDev, DevicePosition, SenseBuffers, &SenseCounts);
|
||||
//
|
||||
// If Request Sense data failed, reset the device and retry.
|
||||
//
|
||||
if (Status != EFI_SUCCESS) {
|
||||
|
||||
Status = ResetDevice (AtapiBlkIoDev, DevicePosition, FALSE);
|
||||
//
|
||||
// if ATAPI soft reset fail,
|
||||
@ -1829,11 +1827,11 @@ DetectMedia (
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// No Media
|
||||
//
|
||||
if (IsNoMedia (SenseBuffers, SenseCounts)) {
|
||||
|
||||
MediaInfo->MediaPresent = FALSE;
|
||||
MediaInfo->LastBlock = 0;
|
||||
MediaInfo2->MediaPresent = FALSE;
|
||||
@ -1857,15 +1855,13 @@ DetectMedia (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// if read capacity fail not for above reasons, retry once more
|
||||
//
|
||||
RetryNum++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -1898,8 +1894,8 @@ ResetDevice (
|
||||
UINT8 Channel;
|
||||
UINT8 Device;
|
||||
|
||||
Channel = (UINT8) (DevicePosition / 2);
|
||||
Device = (UINT8) (DevicePosition % 2);
|
||||
Channel = (UINT8)(DevicePosition / 2);
|
||||
Device = (UINT8)(DevicePosition % 2);
|
||||
|
||||
ASSERT (Channel < MAX_IDE_CHANNELS);
|
||||
|
||||
@ -1908,7 +1904,6 @@ ResetDevice (
|
||||
HeadReg = AtapiBlkIoDev->IdeIoPortReg[Channel].Head;
|
||||
|
||||
if (Extensive) {
|
||||
|
||||
DevControl = 0;
|
||||
DevControl |= ATA_CTLREG_SRST;
|
||||
//
|
||||
@ -1940,13 +1935,12 @@ ResetDevice (
|
||||
if (WaitForBSYClear (AtapiBlkIoDev, &(AtapiBlkIoDev->IdeIoPortReg[Channel]), 31000) == EFI_TIMEOUT) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
//
|
||||
// for ATAPI device, no need to wait DRDY ready after device selecting.
|
||||
// bit7 and bit5 are both set to 1 for backward compatibility
|
||||
//
|
||||
DeviceSelect = (UINT8) (((BIT7 | BIT5) | (Device << 4)));
|
||||
DeviceSelect = (UINT8)(((BIT7 | BIT5) | (Device << 4)));
|
||||
IoWrite8 (HeadReg, DeviceSelect);
|
||||
|
||||
Command = ATA_CMD_SOFT_RESET;
|
||||
@ -1959,6 +1953,7 @@ ResetDevice (
|
||||
if (WaitForBSYClear (AtapiBlkIoDev, &(AtapiBlkIoDev->IdeIoPortReg[Channel]), 31000) != EFI_SUCCESS) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// stall 5 seconds to make the device status stable
|
||||
//
|
||||
@ -1966,7 +1961,6 @@ ResetDevice (
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2001,9 +1995,9 @@ RequestSense (
|
||||
//
|
||||
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
|
||||
Packet.RequestSence.opcode = ATA_CMD_REQUEST_SENSE;
|
||||
Packet.RequestSence.allocation_length = (UINT8) sizeof (ATAPI_REQUEST_SENSE_DATA);
|
||||
Packet.RequestSence.allocation_length = (UINT8)sizeof (ATAPI_REQUEST_SENSE_DATA);
|
||||
|
||||
Ptr = (UINT16 *) SenseBuffers;
|
||||
Ptr = (UINT16 *)SenseBuffers;
|
||||
//
|
||||
// initialize pointer
|
||||
//
|
||||
@ -2012,8 +2006,7 @@ RequestSense (
|
||||
// request sense data from device continiously until no sense data exists in the device.
|
||||
//
|
||||
for (SenseReq = TRUE; SenseReq;) {
|
||||
|
||||
Sense = (ATAPI_REQUEST_SENSE_DATA *) Ptr;
|
||||
Sense = (ATAPI_REQUEST_SENSE_DATA *)Ptr;
|
||||
|
||||
//
|
||||
// send out Request Sense Packet Command and get one Sense data form device
|
||||
@ -2042,6 +2035,7 @@ RequestSense (
|
||||
if (*SenseCounts > MAX_SENSE_KEY_COUNT) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// We limit MAX sense data count to 20 in order to avoid dead loop. Some
|
||||
// incompatible ATAPI devices don't retrive NO_SENSE when there is no media.
|
||||
@ -2049,7 +2043,6 @@ RequestSense (
|
||||
// supposed to be large enough for any ATAPI device.
|
||||
//
|
||||
if ((Sense->sense_key != ATA_SK_NO_SENSE) && ((*SenseCounts) < 20)) {
|
||||
|
||||
Ptr += sizeof (ATAPI_REQUEST_SENSE_DATA) / 2;
|
||||
//
|
||||
// Ptr is word based pointer
|
||||
@ -2100,18 +2093,16 @@ ReadCapacity (
|
||||
ZeroMem (&FormatData, sizeof (FormatData));
|
||||
|
||||
if (MediaInfo->DeviceType == IdeCDROM) {
|
||||
|
||||
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
|
||||
Packet.Inquiry.opcode = ATA_CMD_READ_CAPACITY;
|
||||
Status = AtapiPacketCommandIn (
|
||||
AtapiBlkIoDev,
|
||||
DevicePosition,
|
||||
&Packet,
|
||||
(UINT16 *) (&Data),
|
||||
(UINT16 *)(&Data),
|
||||
sizeof (ATAPI_READ_CAPACITY_DATA),
|
||||
ATAPITIMEOUT
|
||||
);
|
||||
|
||||
} else {
|
||||
//
|
||||
// DeviceType == IdeLS120
|
||||
@ -2123,17 +2114,15 @@ ReadCapacity (
|
||||
AtapiBlkIoDev,
|
||||
DevicePosition,
|
||||
&Packet,
|
||||
(UINT16 *) (&FormatData),
|
||||
(UINT16 *)(&FormatData),
|
||||
sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA),
|
||||
ATAPITIMEOUT*10
|
||||
);
|
||||
}
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
|
||||
if (MediaInfo->DeviceType == IdeCDROM) {
|
||||
|
||||
MediaInfo->LastBlock = ((UINT32) Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
|
||||
MediaInfo->LastBlock = ((UINT32)Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
|
||||
MediaInfo->MediaPresent = TRUE;
|
||||
//
|
||||
// Because the user data portion in the sector of the Data CD supported
|
||||
@ -2147,14 +2136,13 @@ ReadCapacity (
|
||||
}
|
||||
|
||||
if (MediaInfo->DeviceType == IdeLS120) {
|
||||
|
||||
if (FormatData.DesCode == 3) {
|
||||
MediaInfo->MediaPresent = FALSE;
|
||||
MediaInfo->LastBlock = 0;
|
||||
MediaInfo2->MediaPresent = FALSE;
|
||||
MediaInfo2->LastBlock = 0;
|
||||
} else {
|
||||
MediaInfo->LastBlock = ((UINT32) FormatData.LastLba3 << 24) |
|
||||
MediaInfo->LastBlock = ((UINT32)FormatData.LastLba3 << 24) |
|
||||
(FormatData.LastLba2 << 16) |
|
||||
(FormatData.LastLba1 << 8) |
|
||||
FormatData.LastLba0;
|
||||
@ -2167,12 +2155,10 @@ ReadCapacity (
|
||||
MediaInfo2->LastBlock = MediaInfo->LastBlock;
|
||||
MediaInfo2->MediaPresent = MediaInfo->MediaPresent;
|
||||
MediaInfo2->BlockSize = (UINT32)MediaInfo->BlockSize;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
} else {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -2202,7 +2188,6 @@ ReadSectors (
|
||||
IN UINTN BlockSize
|
||||
)
|
||||
{
|
||||
|
||||
ATAPI_PACKET_COMMAND Packet;
|
||||
ATAPI_READ10_CMD *Read10Packet;
|
||||
EFI_STATUS Status;
|
||||
@ -2218,13 +2203,13 @@ ReadSectors (
|
||||
//
|
||||
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
|
||||
Read10Packet = &Packet.Read10;
|
||||
Lba32 = (UINT32) StartLba;
|
||||
Lba32 = (UINT32)StartLba;
|
||||
PtrBuffer = Buffer;
|
||||
|
||||
//
|
||||
// limit the data bytes that can be transfered by one Read(10) Command
|
||||
//
|
||||
MaxBlock = (UINT16) (0x10000 / BlockSize);
|
||||
MaxBlock = (UINT16)(0x10000 / BlockSize);
|
||||
//
|
||||
// (64k bytes)
|
||||
//
|
||||
@ -2232,12 +2217,12 @@ ReadSectors (
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
while (BlocksRemaining > 0) {
|
||||
|
||||
if (BlocksRemaining <= MaxBlock) {
|
||||
SectorCount = (UINT16) BlocksRemaining;
|
||||
SectorCount = (UINT16)BlocksRemaining;
|
||||
} else {
|
||||
SectorCount = MaxBlock;
|
||||
}
|
||||
|
||||
//
|
||||
// fill the Packet data sturcture
|
||||
//
|
||||
@ -2247,25 +2232,25 @@ ReadSectors (
|
||||
// Lba0 ~ Lba3 specify the start logical block address of the data transfer.
|
||||
// Lba0 is MSB, Lba3 is LSB
|
||||
//
|
||||
Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
|
||||
Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);
|
||||
Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);
|
||||
Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);
|
||||
Read10Packet->Lba3 = (UINT8)(Lba32 & 0xff);
|
||||
Read10Packet->Lba2 = (UINT8)(Lba32 >> 8);
|
||||
Read10Packet->Lba1 = (UINT8)(Lba32 >> 16);
|
||||
Read10Packet->Lba0 = (UINT8)(Lba32 >> 24);
|
||||
|
||||
//
|
||||
// TranLen0 ~ TranLen1 specify the transfer length in block unit.
|
||||
// TranLen0 is MSB, TranLen is LSB
|
||||
//
|
||||
Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
|
||||
Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
|
||||
Read10Packet->TranLen1 = (UINT8)(SectorCount & 0xff);
|
||||
Read10Packet->TranLen0 = (UINT8)(SectorCount >> 8);
|
||||
|
||||
ByteCount = (UINT32) (SectorCount * BlockSize);
|
||||
ByteCount = (UINT32)(SectorCount * BlockSize);
|
||||
|
||||
Status = AtapiPacketCommandIn (
|
||||
AtapiBlkIoDev,
|
||||
DevicePosition,
|
||||
&Packet,
|
||||
(UINT16 *) PtrBuffer,
|
||||
(UINT16 *)PtrBuffer,
|
||||
ByteCount,
|
||||
ATAPILONGTIMEOUT
|
||||
);
|
||||
@ -2274,7 +2259,7 @@ ReadSectors (
|
||||
}
|
||||
|
||||
Lba32 += SectorCount;
|
||||
PtrBuffer = (UINT8 *) PtrBuffer + SectorCount * BlockSize;
|
||||
PtrBuffer = (UINT8 *)PtrBuffer + SectorCount * BlockSize;
|
||||
BlocksRemaining -= SectorCount;
|
||||
}
|
||||
|
||||
@ -2306,7 +2291,6 @@ IsNoMedia (
|
||||
SensePtr = SenseData;
|
||||
|
||||
for (Index = 0; Index < SenseCounts; Index++) {
|
||||
|
||||
if ((SensePtr->sense_key == ATA_SK_NOT_READY) && (SensePtr->addnl_sense_code == ATA_ASC_NO_MEDIA)) {
|
||||
IsNoMedia = TRUE;
|
||||
}
|
||||
@ -2342,7 +2326,6 @@ IsDeviceStateUnclear (
|
||||
SensePtr = SenseData;
|
||||
|
||||
for (Index = 0; Index < SenseCounts; Index++) {
|
||||
|
||||
if (SensePtr->sense_key == 0x06) {
|
||||
//
|
||||
// Sense key is 0x06 means the device is just be reset or media just
|
||||
@ -2383,9 +2366,7 @@ IsMediaError (
|
||||
SensePtr = SenseData;
|
||||
|
||||
for (Index = 0; Index < SenseCounts; Index++) {
|
||||
|
||||
switch (SensePtr->sense_key) {
|
||||
|
||||
case ATA_SK_MEDIUM_ERROR:
|
||||
switch (SensePtr->addnl_sense_code) {
|
||||
case ATA_ASC_MEDIA_ERR1:
|
||||
@ -2419,6 +2400,7 @@ IsMediaError (
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -2459,9 +2441,7 @@ IsDriveReady (
|
||||
SensePtr = SenseData;
|
||||
|
||||
for (Index = 0; Index < SenseCounts; Index++) {
|
||||
|
||||
switch (SensePtr->sense_key) {
|
||||
|
||||
case ATA_SK_NOT_READY:
|
||||
switch (SensePtr->addnl_sense_code) {
|
||||
case ATA_ASC_NOT_READY:
|
||||
@ -2476,11 +2456,13 @@ IsDriveReady (
|
||||
*NeedRetry = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -26,7 +26,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
|
||||
#include <IndustryStandard/Atapi.h>
|
||||
|
||||
#define MAX_SENSE_KEY_COUNT 6
|
||||
@ -81,11 +80,9 @@ typedef struct {
|
||||
} IDE_BASE_REGISTERS;
|
||||
|
||||
typedef struct {
|
||||
|
||||
UINTN DevicePosition;
|
||||
EFI_PEI_BLOCK_IO_MEDIA MediaInfo;
|
||||
EFI_PEI_BLOCK_IO2_MEDIA MediaInfo2;
|
||||
|
||||
} PEI_ATAPI_DEVICE_INFO;
|
||||
|
||||
#define ATAPI_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('a', 'b', 'i', 'o')
|
||||
@ -99,14 +96,13 @@ typedef struct {
|
||||
PEI_ATA_CONTROLLER_PPI *AtaControllerPpi;
|
||||
|
||||
UINTN DeviceCount;
|
||||
PEI_ATAPI_DEVICE_INFO DeviceInfo[MAX_IDE_DEVICES]; //for max 8 device
|
||||
IDE_BASE_REGISTERS IdeIoPortReg[MAX_IDE_CHANNELS]; //for max 4 channel.
|
||||
PEI_ATAPI_DEVICE_INFO DeviceInfo[MAX_IDE_DEVICES]; // for max 8 device
|
||||
IDE_BASE_REGISTERS IdeIoPortReg[MAX_IDE_CHANNELS]; // for max 4 channel.
|
||||
} ATAPI_BLK_IO_DEV;
|
||||
|
||||
#define PEI_RECOVERY_ATAPI_FROM_BLKIO_THIS(a) CR (a, ATAPI_BLK_IO_DEV, AtapiBlkIo, ATAPI_BLK_IO_DEV_SIGNATURE)
|
||||
#define PEI_RECOVERY_ATAPI_FROM_BLKIO2_THIS(a) CR (a, ATAPI_BLK_IO_DEV, AtapiBlkIo2, ATAPI_BLK_IO_DEV_SIGNATURE)
|
||||
|
||||
|
||||
#define STALL_1_MILLI_SECOND 1000 // stall 1 ms
|
||||
#define STALL_1_SECONDS 1000 * STALL_1_MILLI_SECOND
|
||||
|
||||
@ -558,7 +554,7 @@ EFI_STATUS
|
||||
TestUnitReady (
|
||||
IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,
|
||||
IN UINTN DevicePosition
|
||||
) ;
|
||||
);
|
||||
|
||||
/**
|
||||
Send out ATAPI commands conforms to the Packet Command with PIO Data In Protocol.
|
||||
|
@ -106,7 +106,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED UINT64 mIncompatiblePciDeviceList[] = {
|
||||
// Device Adaptec 9004
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x9004, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
PCI_DEVICE_ID (0x9004, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
DEVICE_RES_TAG,
|
||||
ACPI_ADDRESS_SPACE_TYPE_IO,
|
||||
0,
|
||||
@ -120,7 +120,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED UINT64 mIncompatiblePciDeviceList[] = {
|
||||
// Device Adaptec 9005
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x9005, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
PCI_DEVICE_ID (0x9005, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
DEVICE_RES_TAG,
|
||||
ACPI_ADDRESS_SPACE_TYPE_IO,
|
||||
0,
|
||||
@ -134,7 +134,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED UINT64 mIncompatiblePciDeviceList[] = {
|
||||
// Device QLogic 1007
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x1077, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
PCI_DEVICE_ID (0x1077, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
DEVICE_RES_TAG,
|
||||
ACPI_ADDRESS_SPACE_TYPE_IO,
|
||||
0,
|
||||
@ -148,7 +148,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED UINT64 mIncompatiblePciDeviceList[] = {
|
||||
// Device Agilent 103C
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x103C, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
PCI_DEVICE_ID (0x103C, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
DEVICE_RES_TAG,
|
||||
ACPI_ADDRESS_SPACE_TYPE_IO,
|
||||
0,
|
||||
@ -162,7 +162,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED UINT64 mIncompatiblePciDeviceList[] = {
|
||||
// Device Agilent 15BC
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x15BC, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
PCI_DEVICE_ID (0x15BC, MAX_UINT64, MAX_UINT64, MAX_UINT64, MAX_UINT64),
|
||||
DEVICE_RES_TAG,
|
||||
ACPI_ADDRESS_SPACE_TYPE_IO,
|
||||
0,
|
||||
@ -178,7 +178,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED UINT64 mIncompatiblePciDeviceList[] = {
|
||||
LIST_END_TAG
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Entry point of the incompatible pci device support code. Setup an incompatible device list template
|
||||
and install EFI Incompatible PCI Device Support protocol.
|
||||
@ -260,19 +259,19 @@ PCheckDevice (
|
||||
if (Configuration == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the return value to NULL
|
||||
//
|
||||
* (VOID **) Configuration = NULL;
|
||||
*(VOID **)Configuration = NULL;
|
||||
|
||||
ListPtr = mIncompatiblePciDeviceList;
|
||||
while (*ListPtr != LIST_END_TAG) {
|
||||
|
||||
Tag = *ListPtr;
|
||||
|
||||
switch (Tag) {
|
||||
case DEVICE_INF_TAG:
|
||||
Header = (EFI_PCI_DEVICE_HEADER_INFO *) (ListPtr + 1);
|
||||
Header = (EFI_PCI_DEVICE_HEADER_INFO *)(ListPtr + 1);
|
||||
ListPtr = ListPtr + 1 + sizeof (EFI_PCI_DEVICE_HEADER_INFO) / sizeof (UINT64);
|
||||
//
|
||||
// See if the Header matches the parameters passed in
|
||||
@ -306,6 +305,7 @@ PCheckDevice (
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Matched an item, so construct the ACPI descriptor for the resource.
|
||||
//
|
||||
@ -315,6 +315,7 @@ PCheckDevice (
|
||||
for (Index = 0, TempListPtr = ListPtr; *TempListPtr == DEVICE_RES_TAG; Index++) {
|
||||
TempListPtr = TempListPtr + 1 + ((sizeof (EFI_PCI_RESOUCE_DESCRIPTOR)) / sizeof (UINT64));
|
||||
}
|
||||
|
||||
//
|
||||
// If there is at least one type of resource request,
|
||||
// allocate an acpi resource node
|
||||
@ -333,16 +334,15 @@ PCheckDevice (
|
||||
// Fill the EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR structure
|
||||
// according to the EFI_PCI_RESOUCE_DESCRIPTOR structure
|
||||
//
|
||||
for (; *ListPtr == DEVICE_RES_TAG;) {
|
||||
|
||||
Dsc = (EFI_PCI_RESOUCE_DESCRIPTOR *) (ListPtr + 1);
|
||||
for ( ; *ListPtr == DEVICE_RES_TAG;) {
|
||||
Dsc = (EFI_PCI_RESOUCE_DESCRIPTOR *)(ListPtr + 1);
|
||||
|
||||
AcpiPtr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
|
||||
AcpiPtr->Len = (UINT16) sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
|
||||
AcpiPtr->ResType = (UINT8) Dsc->ResType;
|
||||
AcpiPtr->GenFlag = (UINT8) Dsc->GenFlag;
|
||||
AcpiPtr->SpecificFlag = (UINT8) Dsc->SpecificFlag;
|
||||
AcpiPtr->AddrSpaceGranularity = Dsc->AddrSpaceGranularity;;
|
||||
AcpiPtr->Len = (UINT16)sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
|
||||
AcpiPtr->ResType = (UINT8)Dsc->ResType;
|
||||
AcpiPtr->GenFlag = (UINT8)Dsc->GenFlag;
|
||||
AcpiPtr->SpecificFlag = (UINT8)Dsc->SpecificFlag;
|
||||
AcpiPtr->AddrSpaceGranularity = Dsc->AddrSpaceGranularity;
|
||||
AcpiPtr->AddrRangeMin = Dsc->AddrRangeMin;
|
||||
AcpiPtr->AddrRangeMax = Dsc->AddrRangeMax;
|
||||
AcpiPtr->AddrTranslationOffset = Dsc->AddrTranslationOffset;
|
||||
@ -351,14 +351,15 @@ PCheckDevice (
|
||||
ListPtr = ListPtr + 1 + ((sizeof (EFI_PCI_RESOUCE_DESCRIPTOR)) / sizeof (UINT64));
|
||||
AcpiPtr++;
|
||||
}
|
||||
|
||||
//
|
||||
// Put the checksum
|
||||
//
|
||||
PtrEnd = (EFI_ACPI_END_TAG_DESCRIPTOR *) (AcpiPtr);
|
||||
PtrEnd = (EFI_ACPI_END_TAG_DESCRIPTOR *)(AcpiPtr);
|
||||
PtrEnd->Desc = ACPI_END_TAG_DESCRIPTOR;
|
||||
PtrEnd->Checksum = 0;
|
||||
|
||||
*(VOID **) Configuration = OldAcpiPtr;
|
||||
*(VOID **)Configuration = OldAcpiPtr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
@ -376,4 +377,3 @@ PCheckDevice (
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
|
||||
};
|
||||
|
||||
EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &NonDiscoverablePciGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &NonDiscoverablePciGetDeviceName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)&NonDiscoverablePciGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)&NonDiscoverablePciGetDeviceName,
|
||||
"en" // SupportedLanguages, RFC 4646 language codes
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ EFI_CPU_ARCH_PROTOCOL *mCpu;
|
||||
// We only support the following device types
|
||||
//
|
||||
STATIC
|
||||
CONST EFI_GUID * CONST
|
||||
CONST EFI_GUID *CONST
|
||||
SupportedNonDiscoverableDevices[] = {
|
||||
&gEdkiiNonDiscoverableAhciDeviceGuid,
|
||||
&gEdkiiNonDiscoverableEhciDeviceGuid,
|
||||
@ -73,17 +73,21 @@ NonDiscoverablePciDeviceSupported (
|
||||
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc;
|
||||
INTN Idx;
|
||||
|
||||
Status = gBS->OpenProtocol (DeviceHandle,
|
||||
&gEdkiiNonDiscoverableDeviceProtocolGuid, (VOID **)&Device,
|
||||
This->DriverBindingHandle, DeviceHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER);
|
||||
Status = gBS->OpenProtocol (
|
||||
DeviceHandle,
|
||||
&gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
(VOID **)&Device,
|
||||
This->DriverBindingHandle,
|
||||
DeviceHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = EFI_UNSUPPORTED;
|
||||
for (Idx = 0; Idx < ARRAY_SIZE (SupportedNonDiscoverableDevices); Idx++) {
|
||||
if (CompareGuid (Device->Type, SupportedNonDiscoverableDevices [Idx])) {
|
||||
if (CompareGuid (Device->Type, SupportedNonDiscoverableDevices[Idx])) {
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
}
|
||||
@ -98,17 +102,23 @@ NonDiscoverablePciDeviceSupported (
|
||||
// that they only describe things that we can handle
|
||||
//
|
||||
for (Desc = Device->Resources; Desc->Desc != ACPI_END_TAG_DESCRIPTOR;
|
||||
Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3)) {
|
||||
if (Desc->Desc != ACPI_ADDRESS_SPACE_DESCRIPTOR ||
|
||||
Desc->ResType != ACPI_ADDRESS_SPACE_TYPE_MEM) {
|
||||
Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3))
|
||||
{
|
||||
if ((Desc->Desc != ACPI_ADDRESS_SPACE_DESCRIPTOR) ||
|
||||
(Desc->ResType != ACPI_ADDRESS_SPACE_TYPE_MEM))
|
||||
{
|
||||
Status = EFI_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CloseProtocol:
|
||||
gBS->CloseProtocol (DeviceHandle, &gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
This->DriverBindingHandle, DeviceHandle);
|
||||
gBS->CloseProtocol (
|
||||
DeviceHandle,
|
||||
&gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
DeviceHandle
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
@ -148,10 +158,14 @@ NonDiscoverablePciDeviceStart (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = gBS->OpenProtocol (DeviceHandle,
|
||||
Status = gBS->OpenProtocol (
|
||||
DeviceHandle,
|
||||
&gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
(VOID **)&Dev->Device, This->DriverBindingHandle,
|
||||
DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);
|
||||
(VOID **)&Dev->Device,
|
||||
This->DriverBindingHandle,
|
||||
DeviceHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeDev;
|
||||
}
|
||||
@ -163,8 +177,12 @@ NonDiscoverablePciDeviceStart (
|
||||
// EFI_PCI_IO_PROTOCOL interface.
|
||||
//
|
||||
Dev->Signature = NON_DISCOVERABLE_PCI_DEVICE_SIG;
|
||||
Status = gBS->InstallProtocolInterface (&DeviceHandle, &gEfiPciIoProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE, &Dev->PciIo);
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&DeviceHandle,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&Dev->PciIo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto CloseProtocol;
|
||||
}
|
||||
@ -174,8 +192,12 @@ NonDiscoverablePciDeviceStart (
|
||||
return EFI_SUCCESS;
|
||||
|
||||
CloseProtocol:
|
||||
gBS->CloseProtocol (DeviceHandle, &gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
This->DriverBindingHandle, DeviceHandle);
|
||||
gBS->CloseProtocol (
|
||||
DeviceHandle,
|
||||
&gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
DeviceHandle
|
||||
);
|
||||
|
||||
FreeDev:
|
||||
FreePool (Dev);
|
||||
@ -209,9 +231,14 @@ NonDiscoverablePciDeviceStop (
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
NON_DISCOVERABLE_PCI_DEVICE *Dev;
|
||||
|
||||
Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
|
||||
(VOID **)&PciIo, This->DriverBindingHandle, DeviceHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
Status = gBS->OpenProtocol (
|
||||
DeviceHandle,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
DeviceHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -221,21 +248,27 @@ NonDiscoverablePciDeviceStop (
|
||||
//
|
||||
// Handle Stop() requests for in-use driver instances gracefully.
|
||||
//
|
||||
Status = gBS->UninstallProtocolInterface (DeviceHandle,
|
||||
&gEfiPciIoProtocolGuid, &Dev->PciIo);
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
DeviceHandle,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
&Dev->PciIo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
gBS->CloseProtocol (DeviceHandle, &gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
This->DriverBindingHandle, DeviceHandle);
|
||||
gBS->CloseProtocol (
|
||||
DeviceHandle,
|
||||
&gEdkiiNonDiscoverableDeviceProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
DeviceHandle
|
||||
);
|
||||
|
||||
FreePool (Dev);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// The static object that groups the Supported() (ie. probe), Start() and
|
||||
// Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata
|
||||
@ -270,7 +303,7 @@ NonDiscoverablePciDeviceDxeEntryPoint (
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return EfiLibInstallDriverBindingComponentName2 (
|
||||
ImageHandle,
|
||||
|
@ -52,8 +52,8 @@ GetBarResource (
|
||||
|
||||
for (Desc = Dev->Device->Resources;
|
||||
Desc->Desc != ACPI_END_TAG_DESCRIPTOR;
|
||||
Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3)) {
|
||||
|
||||
Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3))
|
||||
{
|
||||
if (BarIndex == 0) {
|
||||
*Descriptor = Desc;
|
||||
return EFI_SUCCESS;
|
||||
@ -61,6 +61,7 @@ GetBarResource (
|
||||
|
||||
BarIndex -= 1;
|
||||
}
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -106,7 +107,7 @@ PciIoPollMem (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
Count = 1;
|
||||
|
||||
Status = GetBarResource (Dev, BarIndex, &Desc);
|
||||
@ -164,7 +165,7 @@ PciIoPollIo (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
Count = 1;
|
||||
|
||||
Status = GetBarResource (Dev, BarIndex, &Desc);
|
||||
@ -222,23 +223,26 @@ PciIoMemRW (
|
||||
case EfiPciWidthUint8:
|
||||
Dst8 = (UINT8 *)Dst;
|
||||
Src8 = (UINT8 *)Src;
|
||||
for (;Count > 0; Count--, Dst8 += DstStride, Src8 += SrcStride) {
|
||||
for ( ; Count > 0; Count--, Dst8 += DstStride, Src8 += SrcStride) {
|
||||
*Dst8 = *Src8;
|
||||
}
|
||||
|
||||
break;
|
||||
case EfiPciWidthUint16:
|
||||
Dst16 = (UINT16 *)Dst;
|
||||
Src16 = (UINT16 *)Src;
|
||||
for (;Count > 0; Count--, Dst16 += DstStride, Src16 += SrcStride) {
|
||||
for ( ; Count > 0; Count--, Dst16 += DstStride, Src16 += SrcStride) {
|
||||
*Dst16 = *Src16;
|
||||
}
|
||||
|
||||
break;
|
||||
case EfiPciWidthUint32:
|
||||
Dst32 = (UINT32 *)Dst;
|
||||
Src32 = (UINT32 *)Src;
|
||||
for (;Count > 0; Count--, Dst32 += DstStride, Src32 += SrcStride) {
|
||||
for ( ; Count > 0; Count--, Dst32 += DstStride, Src32 += SrcStride) {
|
||||
*Dst32 = *Src32;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -289,7 +293,7 @@ PciIoMemRead (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
//
|
||||
// Only allow accesses to the BARs we emulate
|
||||
@ -331,6 +335,7 @@ PciIoMemRead (
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -376,7 +381,7 @@ PciIoMemWrite (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
//
|
||||
// Only allow accesses to the BARs we emulate
|
||||
@ -418,6 +423,7 @@ PciIoMemWrite (
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -458,7 +464,7 @@ PciIoIoRead (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
Status = GetBarResource (Dev, BarIndex, &Desc);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -510,7 +516,7 @@ PciIoIoWrite (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
Status = GetBarResource (Dev, BarIndex, &Desc);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -551,11 +557,11 @@ PciIoPciRead (
|
||||
VOID *Address;
|
||||
UINTN Length;
|
||||
|
||||
if (Width < 0 || Width >= EfiPciIoWidthMaximum || Buffer == NULL) {
|
||||
if ((Width < 0) || (Width >= EfiPciIoWidthMaximum) || (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
Address = (UINT8 *)&Dev->ConfigSpace + Offset;
|
||||
Length = Count << ((UINTN)Width & 0x3);
|
||||
|
||||
@ -574,6 +580,7 @@ PciIoPciRead (
|
||||
|
||||
Count -= Length >> ((UINTN)Width & 0x3);
|
||||
}
|
||||
|
||||
return PciIoMemRW (Width, Count, 1, Buffer, 1, Address);
|
||||
}
|
||||
|
||||
@ -607,11 +614,11 @@ PciIoPciWrite (
|
||||
NON_DISCOVERABLE_PCI_DEVICE *Dev;
|
||||
VOID *Address;
|
||||
|
||||
if (Width < 0 || Width >= EfiPciIoWidthMaximum || Buffer == NULL) {
|
||||
if ((Width < 0) || (Width >= EfiPciIoWidthMaximum) || (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
Address = (UINT8 *)&Dev->ConfigSpace + Offset;
|
||||
|
||||
if (Offset + (Count << ((UINTN)Width & 0x3)) > sizeof (Dev->ConfigSpace)) {
|
||||
@ -661,7 +668,7 @@ PciIoCopyMem (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
Status = GetBarResource (Dev, DestBarIndex, &DestDesc);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -720,16 +727,18 @@ CoherentPciIoMap (
|
||||
EFI_STATUS Status;
|
||||
NON_DISCOVERABLE_PCI_DEVICE_MAP_INFO *MapInfo;
|
||||
|
||||
if (Operation != EfiPciIoOperationBusMasterRead &&
|
||||
Operation != EfiPciIoOperationBusMasterWrite &&
|
||||
Operation != EfiPciIoOperationBusMasterCommonBuffer) {
|
||||
if ((Operation != EfiPciIoOperationBusMasterRead) &&
|
||||
(Operation != EfiPciIoOperationBusMasterWrite) &&
|
||||
(Operation != EfiPciIoOperationBusMasterCommonBuffer))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (HostAddress == NULL ||
|
||||
NumberOfBytes == NULL ||
|
||||
DeviceAddress == NULL ||
|
||||
Mapping == NULL) {
|
||||
if ((HostAddress == NULL) ||
|
||||
(NumberOfBytes == NULL) ||
|
||||
(DeviceAddress == NULL) ||
|
||||
(Mapping == NULL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -737,10 +746,10 @@ CoherentPciIoMap (
|
||||
// If HostAddress exceeds 4 GB, and this device does not support 64-bit DMA
|
||||
// addressing, we need to allocate a bounce buffer and copy over the data.
|
||||
//
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
if ((Dev->Attributes & EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE) == 0 &&
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress + *NumberOfBytes > SIZE_4GB) {
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
if (((Dev->Attributes & EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE) == 0) &&
|
||||
((EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress + *NumberOfBytes > SIZE_4GB))
|
||||
{
|
||||
//
|
||||
// Bounce buffering is not possible for consistent mappings
|
||||
//
|
||||
@ -758,9 +767,12 @@ CoherentPciIoMap (
|
||||
MapInfo->Operation = Operation;
|
||||
MapInfo->NumberOfBytes = *NumberOfBytes;
|
||||
|
||||
Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData,
|
||||
Status = gBS->AllocatePages (
|
||||
AllocateMaxAddress,
|
||||
EfiBootServicesData,
|
||||
EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes),
|
||||
&MapInfo->AllocAddress);
|
||||
&MapInfo->AllocAddress
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// If we fail here, it is likely because the system has no memory below
|
||||
@ -770,16 +782,22 @@ CoherentPciIoMap (
|
||||
FreePool (MapInfo);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if (Operation == EfiPciIoOperationBusMasterRead) {
|
||||
gBS->CopyMem ((VOID *)(UINTN)MapInfo->AllocAddress, HostAddress,
|
||||
*NumberOfBytes);
|
||||
gBS->CopyMem (
|
||||
(VOID *)(UINTN)MapInfo->AllocAddress,
|
||||
HostAddress,
|
||||
*NumberOfBytes
|
||||
);
|
||||
}
|
||||
|
||||
*DeviceAddress = MapInfo->AllocAddress;
|
||||
*Mapping = MapInfo;
|
||||
} else {
|
||||
*DeviceAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress;
|
||||
*Mapping = NULL;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -805,13 +823,20 @@ CoherentPciIoUnmap (
|
||||
MapInfo = Mapping;
|
||||
if (MapInfo != NULL) {
|
||||
if (MapInfo->Operation == EfiPciIoOperationBusMasterWrite) {
|
||||
gBS->CopyMem (MapInfo->HostAddress, (VOID *)(UINTN)MapInfo->AllocAddress,
|
||||
MapInfo->NumberOfBytes);
|
||||
gBS->CopyMem (
|
||||
MapInfo->HostAddress,
|
||||
(VOID *)(UINTN)MapInfo->AllocAddress,
|
||||
MapInfo->NumberOfBytes
|
||||
);
|
||||
}
|
||||
gBS->FreePages (MapInfo->AllocAddress,
|
||||
EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes));
|
||||
|
||||
gBS->FreePages (
|
||||
MapInfo->AllocAddress,
|
||||
EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes)
|
||||
);
|
||||
FreePool (MapInfo);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -852,7 +877,8 @@ CoherentPciIoAllocateBuffer (
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((Attributes & ~(EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE |
|
||||
EFI_PCI_ATTRIBUTE_MEMORY_CACHED)) != 0) {
|
||||
EFI_PCI_ATTRIBUTE_MEMORY_CACHED)) != 0)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -861,7 +887,8 @@ CoherentPciIoAllocateBuffer (
|
||||
}
|
||||
|
||||
if ((MemoryType != EfiBootServicesData) &&
|
||||
(MemoryType != EfiRuntimeServicesData)) {
|
||||
(MemoryType != EfiRuntimeServicesData))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -870,7 +897,7 @@ CoherentPciIoAllocateBuffer (
|
||||
// been set. If the system has no memory available below 4 GB, there
|
||||
// is little we can do except propagate the error.
|
||||
//
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
if ((Dev->Attributes & EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE) == 0) {
|
||||
AllocAddress = MAX_UINT32;
|
||||
AllocType = AllocateMaxAddress;
|
||||
@ -882,6 +909,7 @@ CoherentPciIoAllocateBuffer (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*HostAddress = (VOID *)(UINTN)AllocAddress;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -934,7 +962,7 @@ NonCoherentPciIoFreeBuffer (
|
||||
NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION *Alloc;
|
||||
BOOLEAN Found;
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
Found = FALSE;
|
||||
Alloc = NULL;
|
||||
@ -945,10 +973,10 @@ NonCoherentPciIoFreeBuffer (
|
||||
//
|
||||
for (Entry = Dev->UncachedAllocationList.ForwardLink;
|
||||
Entry != &Dev->UncachedAllocationList;
|
||||
Entry = Entry->ForwardLink) {
|
||||
|
||||
Entry = Entry->ForwardLink)
|
||||
{
|
||||
Alloc = BASE_CR (Entry, NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
|
||||
if (Alloc->HostAddress == HostAddress && Alloc->NumPages == Pages) {
|
||||
if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages == Pages)) {
|
||||
//
|
||||
// We are freeing the exact allocation we were given
|
||||
// before by AllocateBuffer()
|
||||
@ -968,7 +996,8 @@ NonCoherentPciIoFreeBuffer (
|
||||
Status = gDS->SetMemorySpaceAttributes (
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
|
||||
EFI_PAGES_TO_SIZE (Pages),
|
||||
Alloc->Attributes);
|
||||
Alloc->Attributes
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeAlloc;
|
||||
}
|
||||
@ -1026,17 +1055,24 @@ NonCoherentPciIoAllocateBuffer (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
Status = CoherentPciIoAllocateBuffer (This, Type, MemoryType, Pages,
|
||||
&AllocAddress, Attributes);
|
||||
Status = CoherentPciIoAllocateBuffer (
|
||||
This,
|
||||
Type,
|
||||
MemoryType,
|
||||
Pages,
|
||||
&AllocAddress,
|
||||
Attributes
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gDS->GetMemorySpaceDescriptor (
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)AllocAddress,
|
||||
&GcdDescriptor);
|
||||
&GcdDescriptor
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeBuffer;
|
||||
}
|
||||
@ -1049,8 +1085,9 @@ NonCoherentPciIoAllocateBuffer (
|
||||
//
|
||||
// Set the preferred memory attributes
|
||||
//
|
||||
if ((Attributes & EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE) != 0 ||
|
||||
(GcdDescriptor.Capabilities & EFI_MEMORY_UC) == 0) {
|
||||
if (((Attributes & EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE) != 0) ||
|
||||
((GcdDescriptor.Capabilities & EFI_MEMORY_UC) == 0))
|
||||
{
|
||||
//
|
||||
// Use write combining if it was requested, or if it is the only
|
||||
// type supported by the region.
|
||||
@ -1078,7 +1115,8 @@ NonCoherentPciIoAllocateBuffer (
|
||||
Status = gDS->SetMemorySpaceAttributes (
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)AllocAddress,
|
||||
EFI_PAGES_TO_SIZE (Pages),
|
||||
MemType);
|
||||
MemType
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto RemoveList;
|
||||
}
|
||||
@ -1087,7 +1125,8 @@ NonCoherentPciIoAllocateBuffer (
|
||||
mCpu,
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)AllocAddress,
|
||||
EFI_PAGES_TO_SIZE (Pages),
|
||||
EfiCpuFlushTypeInvalidate);
|
||||
EfiCpuFlushTypeInvalidate
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto RemoveList;
|
||||
}
|
||||
@ -1144,16 +1183,18 @@ NonCoherentPciIoMap (
|
||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
||||
BOOLEAN Bounce;
|
||||
|
||||
if (HostAddress == NULL ||
|
||||
NumberOfBytes == NULL ||
|
||||
DeviceAddress == NULL ||
|
||||
Mapping == NULL) {
|
||||
if ((HostAddress == NULL) ||
|
||||
(NumberOfBytes == NULL) ||
|
||||
(DeviceAddress == NULL) ||
|
||||
(Mapping == NULL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Operation != EfiPciIoOperationBusMasterRead &&
|
||||
Operation != EfiPciIoOperationBusMasterWrite &&
|
||||
Operation != EfiPciIoOperationBusMasterCommonBuffer) {
|
||||
if ((Operation != EfiPciIoOperationBusMasterRead) &&
|
||||
(Operation != EfiPciIoOperationBusMasterWrite) &&
|
||||
(Operation != EfiPciIoOperationBusMasterCommonBuffer))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1166,7 +1207,7 @@ NonCoherentPciIoMap (
|
||||
MapInfo->Operation = Operation;
|
||||
MapInfo->NumberOfBytes = *NumberOfBytes;
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
//
|
||||
// If this device does not support 64-bit DMA addressing, we need to allocate
|
||||
@ -1184,9 +1225,10 @@ NonCoherentPciIoMap (
|
||||
// the CPUs DMA buffer alignment.
|
||||
//
|
||||
AlignMask = mCpu->DmaBufferAlignment - 1;
|
||||
if ((((UINTN) HostAddress | *NumberOfBytes) & AlignMask) == 0) {
|
||||
if ((((UINTN)HostAddress | *NumberOfBytes) & AlignMask) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// fall through
|
||||
|
||||
case EfiPciIoOperationBusMasterCommonBuffer:
|
||||
@ -1195,11 +1237,14 @@ NonCoherentPciIoMap (
|
||||
//
|
||||
Status = gDS->GetMemorySpaceDescriptor (
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
|
||||
&GcdDescriptor);
|
||||
&GcdDescriptor
|
||||
);
|
||||
if (EFI_ERROR (Status) ||
|
||||
(GcdDescriptor.Attributes & (EFI_MEMORY_WB|EFI_MEMORY_WT)) != 0) {
|
||||
((GcdDescriptor.Attributes & (EFI_MEMORY_WB|EFI_MEMORY_WT)) != 0))
|
||||
{
|
||||
Bounce = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1213,16 +1258,23 @@ NonCoherentPciIoMap (
|
||||
goto FreeMapInfo;
|
||||
}
|
||||
|
||||
Status = NonCoherentPciIoAllocateBuffer (This, AllocateAnyPages,
|
||||
EfiBootServicesData, EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes),
|
||||
&AllocAddress, EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE);
|
||||
Status = NonCoherentPciIoAllocateBuffer (
|
||||
This,
|
||||
AllocateAnyPages,
|
||||
EfiBootServicesData,
|
||||
EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes),
|
||||
&AllocAddress,
|
||||
EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeMapInfo;
|
||||
}
|
||||
|
||||
MapInfo->AllocAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocAddress;
|
||||
if (Operation == EfiPciIoOperationBusMasterRead) {
|
||||
gBS->CopyMem (AllocAddress, HostAddress, *NumberOfBytes);
|
||||
}
|
||||
|
||||
*DeviceAddress = MapInfo->AllocAddress;
|
||||
} else {
|
||||
MapInfo->AllocAddress = 0;
|
||||
@ -1238,8 +1290,12 @@ NonCoherentPciIoMap (
|
||||
// may be written back unexpectedly, and clobber the data written to
|
||||
// main memory by the device.
|
||||
//
|
||||
mCpu->FlushDataCache (mCpu, (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
|
||||
*NumberOfBytes, EfiCpuFlushTypeWriteBack);
|
||||
mCpu->FlushDataCache (
|
||||
mCpu,
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
|
||||
*NumberOfBytes,
|
||||
EfiCpuFlushTypeWriteBack
|
||||
);
|
||||
}
|
||||
|
||||
*Mapping = MapInfo;
|
||||
@ -1281,12 +1337,18 @@ NonCoherentPciIoUnmap (
|
||||
// and free the buffer.
|
||||
//
|
||||
if (MapInfo->Operation == EfiPciIoOperationBusMasterWrite) {
|
||||
gBS->CopyMem (MapInfo->HostAddress, (VOID *)(UINTN)MapInfo->AllocAddress,
|
||||
MapInfo->NumberOfBytes);
|
||||
gBS->CopyMem (
|
||||
MapInfo->HostAddress,
|
||||
(VOID *)(UINTN)MapInfo->AllocAddress,
|
||||
MapInfo->NumberOfBytes
|
||||
);
|
||||
}
|
||||
NonCoherentPciIoFreeBuffer (This,
|
||||
|
||||
NonCoherentPciIoFreeBuffer (
|
||||
This,
|
||||
EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes),
|
||||
(VOID *)(UINTN)MapInfo->AllocAddress);
|
||||
(VOID *)(UINTN)MapInfo->AllocAddress
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// We are *not* using a bounce buffer: if this is a bus master write,
|
||||
@ -1294,11 +1356,15 @@ NonCoherentPciIoUnmap (
|
||||
// data written by the device.
|
||||
//
|
||||
if (MapInfo->Operation == EfiPciIoOperationBusMasterWrite) {
|
||||
mCpu->FlushDataCache (mCpu,
|
||||
mCpu->FlushDataCache (
|
||||
mCpu,
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)MapInfo->HostAddress,
|
||||
MapInfo->NumberOfBytes, EfiCpuFlushTypeInvalidate);
|
||||
MapInfo->NumberOfBytes,
|
||||
EfiCpuFlushTypeInvalidate
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (MapInfo);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1345,14 +1411,15 @@ PciIoGetLocation (
|
||||
{
|
||||
NON_DISCOVERABLE_PCI_DEVICE *Dev;
|
||||
|
||||
if (SegmentNumber == NULL ||
|
||||
BusNumber == NULL ||
|
||||
DeviceNumber == NULL ||
|
||||
FunctionNumber == NULL) {
|
||||
if ((SegmentNumber == NULL) ||
|
||||
(BusNumber == NULL) ||
|
||||
(DeviceNumber == NULL) ||
|
||||
(FunctionNumber == NULL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
*SegmentNumber = 0xff;
|
||||
*BusNumber = Dev->UniqueId >> 5;
|
||||
@ -1394,7 +1461,7 @@ PciIoAttributes (
|
||||
NON_DISCOVERABLE_PCI_DEVICE *Dev;
|
||||
BOOLEAN Enable;
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
if ((Attributes & (~(DEV_SUPPORTED_ATTRIBUTES))) != 0) {
|
||||
return EFI_UNSUPPORTED;
|
||||
@ -1406,6 +1473,7 @@ PciIoAttributes (
|
||||
if (Result == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Result = Dev->Attributes;
|
||||
break;
|
||||
|
||||
@ -1413,6 +1481,7 @@ PciIoAttributes (
|
||||
if (Result == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Result = DEV_SUPPORTED_ATTRIBUTES;
|
||||
break;
|
||||
|
||||
@ -1429,16 +1498,17 @@ PciIoAttributes (
|
||||
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// If we're setting any of the EFI_PCI_DEVICE_ENABLE bits, perform
|
||||
// the device specific initialization now.
|
||||
//
|
||||
if (Enable && !Dev->Enabled && Dev->Device->Initialize != NULL) {
|
||||
if (Enable && !Dev->Enabled && (Dev->Device->Initialize != NULL)) {
|
||||
Dev->Device->Initialize (Dev->Device);
|
||||
Dev->Enabled = TRUE;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1480,11 +1550,11 @@ PciIoGetBarAttributes (
|
||||
EFI_ACPI_END_TAG_DESCRIPTOR *End;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (Supports == NULL && Resources == NULL) {
|
||||
if ((Supports == NULL) && (Resources == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
|
||||
Status = GetBarResource (Dev, BarIndex, &BarDesc);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -1499,20 +1569,23 @@ PciIoGetBarAttributes (
|
||||
}
|
||||
|
||||
if (Resources != NULL) {
|
||||
Descriptor = AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) +
|
||||
sizeof (EFI_ACPI_END_TAG_DESCRIPTOR));
|
||||
Descriptor = AllocatePool (
|
||||
sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) +
|
||||
sizeof (EFI_ACPI_END_TAG_DESCRIPTOR)
|
||||
);
|
||||
if (Descriptor == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (Descriptor, BarDesc, sizeof *Descriptor);
|
||||
|
||||
End = (EFI_ACPI_END_TAG_DESCRIPTOR *) (Descriptor + 1);
|
||||
End = (EFI_ACPI_END_TAG_DESCRIPTOR *)(Descriptor + 1);
|
||||
End->Desc = ACPI_END_TAG_DESCRIPTOR;
|
||||
End->Checksum = 0;
|
||||
|
||||
*Resources = Descriptor;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1550,15 +1623,15 @@ PciIoSetBarAttributes (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (Offset == NULL || Length == NULL) {
|
||||
if ((Offset == NULL) || (Length == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(This);
|
||||
Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
|
||||
Width = EfiPciIoWidthUint8;
|
||||
Count = (UINT32) *Length;
|
||||
Count = (UINT32)*Length;
|
||||
|
||||
Status = GetBarResource(Dev, BarIndex, &Desc);
|
||||
Status = GetBarResource (Dev, BarIndex, &Desc);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -1612,7 +1685,7 @@ InitializePciIoProtocol (
|
||||
Dev->ConfigSpace.Hdr.DeviceId = PCI_ID_DEVICE_DONTCARE;
|
||||
|
||||
// Copy protocol structure
|
||||
CopyMem(&Dev->PciIo, &PciIoTemplate, sizeof PciIoTemplate);
|
||||
CopyMem (&Dev->PciIo, &PciIoTemplate, sizeof PciIoTemplate);
|
||||
|
||||
if (Dev->Device->DmaType == NonDiscoverableDeviceDmaTypeNonCoherent) {
|
||||
Dev->PciIo.AllocateBuffer = NonCoherentPciIoAllocateBuffer;
|
||||
@ -1626,44 +1699,65 @@ InitializePciIoProtocol (
|
||||
Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_CLASS_MASS_STORAGE_SATADPA;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_MASS_STORAGE;
|
||||
Dev->BarOffset = 5;
|
||||
} else if (CompareGuid (Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableEhciDeviceGuid)) {
|
||||
} else if (CompareGuid (
|
||||
Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableEhciDeviceGuid
|
||||
))
|
||||
{
|
||||
Dev->ConfigSpace.Hdr.ClassCode[0] = PCI_IF_EHCI;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_CLASS_SERIAL_USB;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SERIAL;
|
||||
Dev->BarOffset = 0;
|
||||
} else if (CompareGuid (Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableNvmeDeviceGuid)) {
|
||||
} else if (CompareGuid (
|
||||
Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableNvmeDeviceGuid
|
||||
))
|
||||
{
|
||||
Dev->ConfigSpace.Hdr.ClassCode[0] = 0x2; // PCI_IF_NVMHCI
|
||||
Dev->ConfigSpace.Hdr.ClassCode[1] = 0x8; // PCI_CLASS_MASS_STORAGE_NVM
|
||||
Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_MASS_STORAGE;
|
||||
Dev->BarOffset = 0;
|
||||
} else if (CompareGuid (Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableOhciDeviceGuid)) {
|
||||
} else if (CompareGuid (
|
||||
Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableOhciDeviceGuid
|
||||
))
|
||||
{
|
||||
Dev->ConfigSpace.Hdr.ClassCode[0] = PCI_IF_OHCI;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_CLASS_SERIAL_USB;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SERIAL;
|
||||
Dev->BarOffset = 0;
|
||||
} else if (CompareGuid (Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableSdhciDeviceGuid)) {
|
||||
} else if (CompareGuid (
|
||||
Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableSdhciDeviceGuid
|
||||
))
|
||||
{
|
||||
Dev->ConfigSpace.Hdr.ClassCode[0] = 0x0; // don't care
|
||||
Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_SUBCLASS_SD_HOST_CONTROLLER;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SYSTEM_PERIPHERAL;
|
||||
Dev->BarOffset = 0;
|
||||
} else if (CompareGuid (Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableXhciDeviceGuid)) {
|
||||
} else if (CompareGuid (
|
||||
Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableXhciDeviceGuid
|
||||
))
|
||||
{
|
||||
Dev->ConfigSpace.Hdr.ClassCode[0] = PCI_IF_XHCI;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_CLASS_SERIAL_USB;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SERIAL;
|
||||
Dev->BarOffset = 0;
|
||||
} else if (CompareGuid (Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableUhciDeviceGuid)) {
|
||||
} else if (CompareGuid (
|
||||
Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableUhciDeviceGuid
|
||||
))
|
||||
{
|
||||
Dev->ConfigSpace.Hdr.ClassCode[0] = PCI_IF_UHCI;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[1] = PCI_CLASS_SERIAL_USB;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_SERIAL;
|
||||
Dev->BarOffset = 0;
|
||||
} else if (CompareGuid (Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableUfsDeviceGuid)) {
|
||||
} else if (CompareGuid (
|
||||
Dev->Device->Type,
|
||||
&gEdkiiNonDiscoverableUfsDeviceGuid
|
||||
))
|
||||
{
|
||||
Dev->ConfigSpace.Hdr.ClassCode[0] = 0x0; // don't care
|
||||
Dev->ConfigSpace.Hdr.ClassCode[1] = 0x9; // UFS controller subclass;
|
||||
Dev->ConfigSpace.Hdr.ClassCode[2] = PCI_CLASS_MASS_STORAGE;
|
||||
@ -1678,16 +1772,19 @@ InitializePciIoProtocol (
|
||||
Idx = Dev->BarOffset;
|
||||
for (Desc = Dev->Device->Resources, Dev->BarCount = 0;
|
||||
Desc->Desc != ACPI_END_TAG_DESCRIPTOR;
|
||||
Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3)) {
|
||||
|
||||
Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3))
|
||||
{
|
||||
ASSERT (Desc->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR);
|
||||
ASSERT (Desc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM);
|
||||
|
||||
if (Idx >= PCI_MAX_BAR ||
|
||||
(Idx == PCI_MAX_BAR - 1 && Desc->AddrSpaceGranularity == 64)) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
if ((Idx >= PCI_MAX_BAR) ||
|
||||
((Idx == PCI_MAX_BAR - 1) && (Desc->AddrSpaceGranularity == 64)))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: resource count exceeds number of emulated BARs\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
ASSERT (FALSE);
|
||||
break;
|
||||
}
|
||||
@ -1698,7 +1795,9 @@ InitializePciIoProtocol (
|
||||
if (Desc->AddrSpaceGranularity == 64) {
|
||||
Dev->ConfigSpace.Device.Bar[Idx] |= 0x4;
|
||||
Dev->ConfigSpace.Device.Bar[++Idx] = (UINT32)RShiftU64 (
|
||||
Desc->AddrRangeMin, 32);
|
||||
Desc->AddrRangeMin,
|
||||
32
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gNvmExpressComponentNa
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gNvmExpressComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) NvmExpressComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) NvmExpressComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)NvmExpressComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)NvmExpressComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
@ -198,13 +198,14 @@ NvmExpressComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the child context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
(VOID **) &BlockIo,
|
||||
(VOID **)&BlockIo,
|
||||
gNvmExpressDriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -212,6 +213,7 @@ NvmExpressComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Device = NVME_DEVICE_PRIVATE_DATA_FROM_BLOCK_IO (BlockIo);
|
||||
ControllerNameTable = Device->ControllerNameTable;
|
||||
}
|
||||
@ -223,5 +225,4 @@ NvmExpressComponentNameGetControllerName (
|
||||
ControllerName,
|
||||
(BOOLEAN)(This == &gNvmExpressComponentName)
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ EnumerateNvmeDevNamespace (
|
||||
//
|
||||
// Allocate a buffer for Identify Namespace data
|
||||
//
|
||||
NamespaceData = AllocateZeroPool(sizeof (NVME_ADMIN_NAMESPACE_DATA));
|
||||
if(NamespaceData == NULL) {
|
||||
NamespaceData = AllocateZeroPool (sizeof (NVME_ADMIN_NAMESPACE_DATA));
|
||||
if (NamespaceData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@ -96,9 +96,10 @@ EnumerateNvmeDevNamespace (
|
||||
NamespaceId,
|
||||
(VOID *)NamespaceData
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Namespace
|
||||
//
|
||||
@ -108,7 +109,7 @@ EnumerateNvmeDevNamespace (
|
||||
//
|
||||
// allocate device private data for each discovered namespace
|
||||
//
|
||||
Device = AllocateZeroPool(sizeof(NVME_DEVICE_PRIVATE_DATA));
|
||||
Device = AllocateZeroPool (sizeof (NVME_DEVICE_PRIVATE_DATA));
|
||||
if (Device == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Exit;
|
||||
@ -186,7 +187,7 @@ EnumerateNvmeDevNamespace (
|
||||
&NewDevicePathNode
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@ -202,7 +203,7 @@ EnumerateNvmeDevNamespace (
|
||||
DeviceHandle = NULL;
|
||||
RemainingDevicePath = DevicePath;
|
||||
Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);
|
||||
if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd(RemainingDevicePath)) {
|
||||
if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd (RemainingDevicePath)) {
|
||||
Status = EFI_ALREADY_STARTED;
|
||||
FreePool (DevicePath);
|
||||
goto Exit;
|
||||
@ -228,7 +229,7 @@ EnumerateNvmeDevNamespace (
|
||||
NULL
|
||||
);
|
||||
|
||||
if(EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@ -242,7 +243,7 @@ EnumerateNvmeDevNamespace (
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&Device->StorageSecurity
|
||||
);
|
||||
if(EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
Device->DeviceHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
@ -262,7 +263,7 @@ EnumerateNvmeDevNamespace (
|
||||
gBS->OpenProtocol (
|
||||
Private->ControllerHandle,
|
||||
&gEfiNvmExpressPassThruProtocolGuid,
|
||||
(VOID **) &DummyInterface,
|
||||
(VOID **)&DummyInterface,
|
||||
Private->DriverBindingHandle,
|
||||
Device->DeviceHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -304,7 +305,7 @@ EnumerateNvmeDevNamespace (
|
||||
}
|
||||
|
||||
Exit:
|
||||
if(NamespaceData != NULL) {
|
||||
if (NamespaceData != NULL) {
|
||||
FreePool (NamespaceData);
|
||||
}
|
||||
|
||||
@ -312,12 +313,14 @@ Exit:
|
||||
FreePool (NewDevicePathNode);
|
||||
}
|
||||
|
||||
if(EFI_ERROR(Status) && (Device != NULL) && (Device->DevicePath != NULL)) {
|
||||
if (EFI_ERROR (Status) && (Device != NULL) && (Device->DevicePath != NULL)) {
|
||||
FreePool (Device->DevicePath);
|
||||
}
|
||||
if(EFI_ERROR(Status) && (Device != NULL)) {
|
||||
|
||||
if (EFI_ERROR (Status) && (Device != NULL)) {
|
||||
FreePool (Device);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -358,7 +361,7 @@ DiscoverAllNamespaces (
|
||||
NamespaceId
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -400,7 +403,7 @@ UnregisterNvmeNamespace (
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
(VOID **) &BlockIo,
|
||||
(VOID **)&BlockIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -457,7 +460,7 @@ UnregisterNvmeNamespace (
|
||||
gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiNvmExpressPassThruProtocolGuid,
|
||||
(VOID **) &DummyInterface,
|
||||
(VOID **)&DummyInterface,
|
||||
This->DriverBindingHandle,
|
||||
Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -471,7 +474,7 @@ UnregisterNvmeNamespace (
|
||||
Status = gBS->OpenProtocol (
|
||||
Handle,
|
||||
&gEfiStorageSecurityCommandProtocolGuid,
|
||||
(VOID **) &StorageSecurity,
|
||||
(VOID **)&StorageSecurity,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -487,7 +490,7 @@ UnregisterNvmeNamespace (
|
||||
gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiNvmExpressPassThruProtocolGuid,
|
||||
(VOID **) &DummyInterface,
|
||||
(VOID **)&DummyInterface,
|
||||
This->DriverBindingHandle,
|
||||
Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -496,7 +499,7 @@ UnregisterNvmeNamespace (
|
||||
}
|
||||
}
|
||||
|
||||
if(Device->DevicePath != NULL) {
|
||||
if (Device->DevicePath != NULL) {
|
||||
FreePool (Device->DevicePath);
|
||||
}
|
||||
|
||||
@ -521,7 +524,7 @@ VOID
|
||||
EFIAPI
|
||||
ProcessAsyncTaskList (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID* Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
@ -538,7 +541,7 @@ ProcessAsyncTaskList (
|
||||
BOOLEAN HasNewItem;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Private = (NVME_CONTROLLER_PRIVATE_DATA*)Context;
|
||||
Private = (NVME_CONTROLLER_PRIVATE_DATA *)Context;
|
||||
QueueId = 2;
|
||||
Cq = Private->CqBuffer[QueueId] + Private->CqHdbl[QueueId].Cqh;
|
||||
HasNewItem = FALSE;
|
||||
@ -549,7 +552,8 @@ ProcessAsyncTaskList (
|
||||
//
|
||||
for (Link = GetFirstNode (&Private->UnsubmittedSubtasks);
|
||||
!IsNull (&Private->UnsubmittedSubtasks, Link);
|
||||
Link = NextLink) {
|
||||
Link = NextLink)
|
||||
{
|
||||
NextLink = GetNextNode (&Private->UnsubmittedSubtasks, Link);
|
||||
Subtask = NVME_BLKIO2_SUBTASK_FROM_LINK (Link);
|
||||
BlkIo2Request = Subtask->BlockIo2Request;
|
||||
@ -563,7 +567,8 @@ ProcessAsyncTaskList (
|
||||
if (Token->TransactionStatus != EFI_SUCCESS) {
|
||||
if (IsListEmpty (&BlkIo2Request->SubtasksQueue) &&
|
||||
BlkIo2Request->LastSubtaskSubmitted &&
|
||||
(BlkIo2Request->UnsubmittedSubtaskNum == 0)) {
|
||||
(BlkIo2Request->UnsubmittedSubtaskNum == 0))
|
||||
{
|
||||
//
|
||||
// Remove the BlockIo2 request from the device asynchronous queue.
|
||||
//
|
||||
@ -594,7 +599,8 @@ ProcessAsyncTaskList (
|
||||
Token->TransactionStatus = EFI_DEVICE_ERROR;
|
||||
|
||||
if (IsListEmpty (&BlkIo2Request->SubtasksQueue) &&
|
||||
Subtask->IsLast) {
|
||||
Subtask->IsLast)
|
||||
{
|
||||
//
|
||||
// Remove the BlockIo2 request from the device asynchronous queue.
|
||||
//
|
||||
@ -625,7 +631,8 @@ ProcessAsyncTaskList (
|
||||
//
|
||||
for (Link = GetFirstNode (&Private->AsyncPassThruQueue);
|
||||
!IsNull (&Private->AsyncPassThruQueue, Link);
|
||||
Link = NextLink) {
|
||||
Link = NextLink)
|
||||
{
|
||||
NextLink = GetNextNode (&Private->AsyncPassThruQueue, Link);
|
||||
AsyncRequest = NVME_PASS_THRU_ASYNC_REQ_FROM_THIS (Link);
|
||||
if (AsyncRequest->CommandId == Cq->Cid) {
|
||||
@ -636,7 +643,7 @@ ProcessAsyncTaskList (
|
||||
CopyMem (
|
||||
AsyncRequest->Packet->NvmeCompletion,
|
||||
Cq,
|
||||
sizeof(EFI_NVM_EXPRESS_COMPLETION)
|
||||
sizeof (EFI_NVM_EXPRESS_COMPLETION)
|
||||
);
|
||||
|
||||
//
|
||||
@ -645,12 +652,15 @@ ProcessAsyncTaskList (
|
||||
if (AsyncRequest->MapData != NULL) {
|
||||
PciIo->Unmap (PciIo, AsyncRequest->MapData);
|
||||
}
|
||||
|
||||
if (AsyncRequest->MapMeta != NULL) {
|
||||
PciIo->Unmap (PciIo, AsyncRequest->MapMeta);
|
||||
}
|
||||
|
||||
if (AsyncRequest->MapPrpList != NULL) {
|
||||
PciIo->Unmap (PciIo, AsyncRequest->MapPrpList);
|
||||
}
|
||||
|
||||
if (AsyncRequest->PrpListHost != NULL) {
|
||||
PciIo->FreeBuffer (
|
||||
PciIo,
|
||||
@ -681,12 +691,12 @@ ProcessAsyncTaskList (
|
||||
}
|
||||
|
||||
if (HasNewItem) {
|
||||
Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]);
|
||||
Data = ReadUnaligned32 ((UINT32 *)&Private->CqHdbl[QueueId]);
|
||||
PciIo->Mem.Write (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
NVME_BAR,
|
||||
NVME_CQHDBL_OFFSET(QueueId, Private->Cap.Dstrd),
|
||||
NVME_CQHDBL_OFFSET (QueueId, Private->Cap.Dstrd),
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -766,7 +776,8 @@ NvmExpressDriverBindingSupported (
|
||||
|
||||
if ((DevicePathNode.DevPath->Type != MESSAGING_DEVICE_PATH) ||
|
||||
(DevicePathNode.DevPath->SubType != MSG_NVME_NAMESPACE_DP) ||
|
||||
(DevicePathNodeLength(DevicePathNode.DevPath) != sizeof(NVME_NAMESPACE_DEVICE_PATH))) {
|
||||
(DevicePathNodeLength (DevicePathNode.DevPath) != sizeof (NVME_NAMESPACE_DEVICE_PATH)))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
@ -778,7 +789,7 @@ NvmExpressDriverBindingSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
(VOID **)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -807,7 +818,7 @@ NvmExpressDriverBindingSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -853,7 +864,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starts a device controller or a bus controller.
|
||||
|
||||
@ -915,7 +925,7 @@ NvmExpressDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
(VOID **)&ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -927,7 +937,7 @@ NvmExpressDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -965,7 +975,7 @@ NvmExpressDriverBindingStart (
|
||||
AllocateAnyPages,
|
||||
EfiBootServicesData,
|
||||
6,
|
||||
(VOID**)&Private->Buffer,
|
||||
(VOID **)&Private->Buffer,
|
||||
0
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -1004,7 +1014,7 @@ NvmExpressDriverBindingStart (
|
||||
InitializeListHead (&Private->UnsubmittedSubtasks);
|
||||
|
||||
Status = NvmeControllerInit (Private);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@ -1046,7 +1056,7 @@ NvmExpressDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiNvmExpressPassThruProtocolGuid,
|
||||
(VOID **) &Passthru,
|
||||
(VOID **)&Passthru,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1065,7 +1075,6 @@ NvmExpressDriverBindingStart (
|
||||
Status = DiscoverAllNamespaces (
|
||||
Private
|
||||
);
|
||||
|
||||
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
//
|
||||
// Enumerate the specified NVME namespace
|
||||
@ -1127,7 +1136,6 @@ Exit:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stops a device controller or a bus controller.
|
||||
|
||||
@ -1175,7 +1183,7 @@ NvmExpressDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiNvmExpressPassThruProtocolGuid,
|
||||
(VOID **) &PassThru,
|
||||
(VOID **)&PassThru,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1342,7 +1350,7 @@ NvmExpressUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
ImageHandle,
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
(VOID **) &ComponentName
|
||||
(VOID **)&ComponentName
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
@ -1355,7 +1363,7 @@ NvmExpressUnload (
|
||||
Status = gBS->HandleProtocol (
|
||||
ImageHandle,
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
(VOID **) &ComponentName2
|
||||
(VOID **)&ComponentName2
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->UninstallProtocolInterface (
|
||||
@ -1374,6 +1382,7 @@ EXIT:
|
||||
if (DeviceHandleBuffer != NULL) {
|
||||
gBS->FreePool (DeviceHandleBuffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,6 @@ struct _NVME_DEVICE_PRIVATE_DATA {
|
||||
NVME_ADMIN_NAMESPACE_DATA NamespaceData;
|
||||
|
||||
NVME_CONTROLLER_PRIVATE_DATA *Controller;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
@ -235,7 +234,7 @@ struct _NVME_DEVICE_PRIVATE_DATA {
|
||||
NVME_DEVICE_PRIVATE_DATA_SIGNATURE \
|
||||
)
|
||||
|
||||
#define NVME_DEVICE_PRIVATE_DATA_FROM_STORAGE_SECURITY(a)\
|
||||
#define NVME_DEVICE_PRIVATE_DATA_FROM_STORAGE_SECURITY(a) \
|
||||
CR (a, \
|
||||
NVME_DEVICE_PRIVATE_DATA, \
|
||||
StorageSecurity, \
|
||||
|
@ -41,9 +41,9 @@ ReadSectors (
|
||||
BlockSize = Device->Media.BlockSize;
|
||||
Bytes = Blocks * BlockSize;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -57,7 +57,7 @@ ReadSectors (
|
||||
CommandPacket.QueueType = NVME_IO_QUEUE;
|
||||
|
||||
CommandPacket.NvmeCmd->Cdw10 = (UINT32)Lba;
|
||||
CommandPacket.NvmeCmd->Cdw11 = (UINT32)RShiftU64(Lba, 32);
|
||||
CommandPacket.NvmeCmd->Cdw11 = (UINT32)RShiftU64 (Lba, 32);
|
||||
CommandPacket.NvmeCmd->Cdw12 = (Blocks - 1) & 0xFFFF;
|
||||
|
||||
CommandPacket.NvmeCmd->Flags = CDW10_VALID | CDW11_VALID | CDW12_VALID;
|
||||
@ -104,9 +104,9 @@ WriteSectors (
|
||||
BlockSize = Device->Media.BlockSize;
|
||||
Bytes = Blocks * BlockSize;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -120,7 +120,7 @@ WriteSectors (
|
||||
CommandPacket.QueueType = NVME_IO_QUEUE;
|
||||
|
||||
CommandPacket.NvmeCmd->Cdw10 = (UINT32)Lba;
|
||||
CommandPacket.NvmeCmd->Cdw11 = (UINT32)RShiftU64(Lba, 32);
|
||||
CommandPacket.NvmeCmd->Cdw11 = (UINT32)RShiftU64 (Lba, 32);
|
||||
//
|
||||
// Set Force Unit Access bit (bit 30) to use write-through behaviour
|
||||
//
|
||||
@ -207,14 +207,22 @@ NvmeRead (
|
||||
Blocks = 0;
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n", __FUNCTION__, Lba,
|
||||
(UINT64)OrginalBlocks, (UINT64)Blocks, BlockSize, Status));
|
||||
DEBUG ((
|
||||
DEBUG_BLKIO,
|
||||
"%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n",
|
||||
__FUNCTION__,
|
||||
Lba,
|
||||
(UINT64)OrginalBlocks,
|
||||
(UINT64)Blocks,
|
||||
BlockSize,
|
||||
Status
|
||||
));
|
||||
|
||||
return Status;
|
||||
}
|
||||
@ -285,14 +293,22 @@ NvmeWrite (
|
||||
Blocks = 0;
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n", __FUNCTION__, Lba,
|
||||
(UINT64)OrginalBlocks, (UINT64)Blocks, BlockSize, Status));
|
||||
DEBUG ((
|
||||
DEBUG_BLKIO,
|
||||
"%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n",
|
||||
__FUNCTION__,
|
||||
Lba,
|
||||
(UINT64)OrginalBlocks,
|
||||
(UINT64)Blocks,
|
||||
BlockSize,
|
||||
Status
|
||||
));
|
||||
|
||||
return Status;
|
||||
}
|
||||
@ -319,9 +335,9 @@ NvmeFlush (
|
||||
|
||||
Private = Device->Controller;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -363,8 +379,8 @@ AsyncIoCallback (
|
||||
|
||||
gBS->CloseEvent (Event);
|
||||
|
||||
Subtask = (NVME_BLKIO2_SUBTASK *) Context;
|
||||
Completion = (NVME_CQ *) Subtask->CommandPacket->NvmeCompletion;
|
||||
Subtask = (NVME_BLKIO2_SUBTASK *)Context;
|
||||
Completion = (NVME_CQ *)Subtask->CommandPacket->NvmeCompletion;
|
||||
Request = Subtask->BlockIo2Request;
|
||||
Token = Request->Token;
|
||||
|
||||
@ -379,9 +395,9 @@ AsyncIoCallback (
|
||||
//
|
||||
// Dump completion entry status for debugging.
|
||||
//
|
||||
DEBUG_CODE_BEGIN();
|
||||
DEBUG_CODE_BEGIN ();
|
||||
NvmeDumpStatus (Completion);
|
||||
DEBUG_CODE_END();
|
||||
DEBUG_CODE_END ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,7 +504,7 @@ AsyncReadSectors (
|
||||
Subtask,
|
||||
&Subtask->Event
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
@ -504,7 +520,7 @@ AsyncReadSectors (
|
||||
CommandPacket->QueueType = NVME_IO_QUEUE;
|
||||
|
||||
CommandPacket->NvmeCmd->Cdw10 = (UINT32)Lba;
|
||||
CommandPacket->NvmeCmd->Cdw11 = (UINT32)RShiftU64(Lba, 32);
|
||||
CommandPacket->NvmeCmd->Cdw11 = (UINT32)RShiftU64 (Lba, 32);
|
||||
CommandPacket->NvmeCmd->Cdw12 = (Blocks - 1) & 0xFFFF;
|
||||
|
||||
CommandPacket->NvmeCmd->Flags = CDW10_VALID | CDW11_VALID | CDW12_VALID;
|
||||
@ -627,7 +643,7 @@ AsyncWriteSectors (
|
||||
Subtask,
|
||||
&Subtask->Event
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
@ -643,7 +659,7 @@ AsyncWriteSectors (
|
||||
CommandPacket->QueueType = NVME_IO_QUEUE;
|
||||
|
||||
CommandPacket->NvmeCmd->Cdw10 = (UINT32)Lba;
|
||||
CommandPacket->NvmeCmd->Cdw11 = (UINT32)RShiftU64(Lba, 32);
|
||||
CommandPacket->NvmeCmd->Cdw11 = (UINT32)RShiftU64 (Lba, 32);
|
||||
//
|
||||
// Set Force Unit Access bit (bit 30) to use write-through behaviour
|
||||
//
|
||||
@ -745,7 +761,8 @@ NvmeAsyncRead (
|
||||
if (Blocks > MaxTransferBlocks) {
|
||||
Status = AsyncReadSectors (
|
||||
Device,
|
||||
BlkIo2Req, (UINT64)(UINTN)Buffer,
|
||||
BlkIo2Req,
|
||||
(UINT64)(UINTN)Buffer,
|
||||
Lba,
|
||||
MaxTransferBlocks,
|
||||
FALSE
|
||||
@ -767,7 +784,7 @@ NvmeAsyncRead (
|
||||
Blocks = 0;
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
IsEmpty = IsListEmpty (&BlkIo2Req->SubtasksQueue) &&
|
||||
(BlkIo2Req->UnsubmittedSubtaskNum == 0);
|
||||
@ -796,9 +813,17 @@ NvmeAsyncRead (
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n", __FUNCTION__, Lba,
|
||||
(UINT64)OrginalBlocks, (UINT64)Blocks, BlockSize, Status));
|
||||
DEBUG ((
|
||||
DEBUG_BLKIO,
|
||||
"%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n",
|
||||
__FUNCTION__,
|
||||
Lba,
|
||||
(UINT64)OrginalBlocks,
|
||||
(UINT64)Blocks,
|
||||
BlockSize,
|
||||
Status
|
||||
));
|
||||
|
||||
return Status;
|
||||
}
|
||||
@ -887,7 +912,7 @@ NvmeAsyncWrite (
|
||||
Blocks = 0;
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
IsEmpty = IsListEmpty (&BlkIo2Req->SubtasksQueue) &&
|
||||
(BlkIo2Req->UnsubmittedSubtaskNum == 0);
|
||||
@ -916,9 +941,17 @@ NvmeAsyncWrite (
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n", __FUNCTION__, Lba,
|
||||
(UINT64)OrginalBlocks, (UINT64)Blocks, BlockSize, Status));
|
||||
DEBUG ((
|
||||
DEBUG_BLKIO,
|
||||
"%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n",
|
||||
__FUNCTION__,
|
||||
Lba,
|
||||
(UINT64)OrginalBlocks,
|
||||
(UINT64)Blocks,
|
||||
BlockSize,
|
||||
Status
|
||||
));
|
||||
|
||||
return Status;
|
||||
}
|
||||
@ -1039,7 +1072,7 @@ NvmeBlockIoReadBlocks (
|
||||
}
|
||||
|
||||
IoAlign = Media->IoAlign;
|
||||
if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) {
|
||||
if ((IoAlign > 0) && (((UINTN)Buffer & (IoAlign - 1)) != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1123,7 +1156,7 @@ NvmeBlockIoWriteBlocks (
|
||||
}
|
||||
|
||||
IoAlign = Media->IoAlign;
|
||||
if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) {
|
||||
if ((IoAlign > 0) && (((UINTN)Buffer & (IoAlign - 1)) != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1316,6 +1349,7 @@ NvmeBlockIoReadBlocksEx (
|
||||
Token->TransactionStatus = EFI_SUCCESS;
|
||||
gBS->SignalEvent (Token->Event);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1330,7 +1364,7 @@ NvmeBlockIoReadBlocksEx (
|
||||
}
|
||||
|
||||
IoAlign = Media->IoAlign;
|
||||
if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) {
|
||||
if ((IoAlign > 0) && (((UINTN)Buffer & (IoAlign - 1)) != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1428,6 +1462,7 @@ NvmeBlockIoWriteBlocksEx (
|
||||
Token->TransactionStatus = EFI_SUCCESS;
|
||||
gBS->SignalEvent (Token->Event);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1442,7 +1477,7 @@ NvmeBlockIoWriteBlocksEx (
|
||||
}
|
||||
|
||||
IoAlign = Media->IoAlign;
|
||||
if (IoAlign > 0 && (((UINTN) Buffer & (IoAlign - 1)) != 0)) {
|
||||
if ((IoAlign > 0) && (((UINTN)Buffer & (IoAlign - 1)) != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1618,7 +1653,7 @@ TrustTransferNvmeDevice (
|
||||
if (EFI_ERROR (Status)) {
|
||||
*TransferLengthOut = 0;
|
||||
} else {
|
||||
*TransferLengthOut = (UINTN) TransferLength;
|
||||
*TransferLengthOut = (UINTN)TransferLength;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1848,7 +1883,3 @@ NvmeStorageSecuritySendData (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -33,7 +33,6 @@ InitializeDiskInfo (
|
||||
CopyMem (&Device->DiskInfo, &gNvmExpressDiskInfoProtocolTemplate, sizeof (EFI_DISK_INFO_PROTOCOL));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Provides inquiry information for the controller type.
|
||||
|
||||
@ -61,7 +60,6 @@ NvmExpressDiskInfoInquiry (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Provides identify information for the controller type.
|
||||
|
||||
@ -98,6 +96,7 @@ NvmExpressDiskInfoIdentify (
|
||||
Status = EFI_SUCCESS;
|
||||
CopyMem (IdentifyData, &Device->NamespaceData, sizeof (Device->NamespaceData));
|
||||
}
|
||||
|
||||
*IdentifyDataSize = sizeof (Device->NamespaceData);
|
||||
return Status;
|
||||
}
|
||||
@ -131,7 +130,6 @@ NvmExpressDiskInfoSenseData (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function is used to get controller information.
|
||||
|
||||
@ -153,4 +151,3 @@ NvmExpressDiskInfoWhichIde (
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ InitializeDiskInfo (
|
||||
IN NVME_DEVICE_PRIVATE_DATA *Device
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Provides inquiry information for the controller type.
|
||||
|
||||
@ -100,7 +99,6 @@ NvmExpressDiskInfoSenseData (
|
||||
OUT UINT8 *SenseDataNumber
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This function is used to get controller information.
|
||||
|
||||
|
@ -47,11 +47,11 @@ ReadNvmeControllerCapabilities (
|
||||
&Data
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
WriteUnaligned64 ((UINT64*)Cap, Data);
|
||||
WriteUnaligned64 ((UINT64 *)Cap, Data);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -85,11 +85,11 @@ ReadNvmeControllerConfiguration (
|
||||
&Data
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
WriteUnaligned32 ((UINT32*)Cc, Data);
|
||||
WriteUnaligned32 ((UINT32 *)Cc, Data);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ WriteNvmeControllerConfiguration (
|
||||
UINT32 Data;
|
||||
|
||||
PciIo = Private->PciIo;
|
||||
Data = ReadUnaligned32 ((UINT32*)Cc);
|
||||
Data = ReadUnaligned32 ((UINT32 *)Cc);
|
||||
Status = PciIo->Mem.Write (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
@ -124,7 +124,7 @@ WriteNvmeControllerConfiguration (
|
||||
&Data
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -169,16 +169,14 @@ ReadNvmeControllerStatus (
|
||||
&Data
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
WriteUnaligned32 ((UINT32*)Csts, Data);
|
||||
WriteUnaligned32 ((UINT32 *)Csts, Data);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Write Nvm Express admin queue attributes register.
|
||||
|
||||
@ -200,7 +198,7 @@ WriteNvmeAdminQueueAttributes (
|
||||
UINT32 Data;
|
||||
|
||||
PciIo = Private->PciIo;
|
||||
Data = ReadUnaligned32 ((UINT32*)Aqa);
|
||||
Data = ReadUnaligned32 ((UINT32 *)Aqa);
|
||||
Status = PciIo->Mem.Write (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
@ -210,7 +208,7 @@ WriteNvmeAdminQueueAttributes (
|
||||
&Data
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -220,7 +218,6 @@ WriteNvmeAdminQueueAttributes (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write Nvm Express admin submission queue base address register.
|
||||
|
||||
@ -242,7 +239,7 @@ WriteNvmeAdminSubmissionQueueBaseAddress (
|
||||
UINT64 Data;
|
||||
|
||||
PciIo = Private->PciIo;
|
||||
Data = ReadUnaligned64 ((UINT64*)Asq);
|
||||
Data = ReadUnaligned64 ((UINT64 *)Asq);
|
||||
|
||||
Status = PciIo->Mem.Write (
|
||||
PciIo,
|
||||
@ -253,7 +250,7 @@ WriteNvmeAdminSubmissionQueueBaseAddress (
|
||||
&Data
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -262,8 +259,6 @@ WriteNvmeAdminSubmissionQueueBaseAddress (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Write Nvm Express admin completion queue base address register.
|
||||
|
||||
@ -285,7 +280,7 @@ WriteNvmeAdminCompletionQueueBaseAddress (
|
||||
UINT64 Data;
|
||||
|
||||
PciIo = Private->PciIo;
|
||||
Data = ReadUnaligned64 ((UINT64*)Acq);
|
||||
Data = ReadUnaligned64 ((UINT64 *)Acq);
|
||||
|
||||
Status = PciIo->Mem.Write (
|
||||
PciIo,
|
||||
@ -296,7 +291,7 @@ WriteNvmeAdminCompletionQueueBaseAddress (
|
||||
&Data
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -329,7 +324,7 @@ NvmeDisableController (
|
||||
// Read Controller Configuration Register.
|
||||
//
|
||||
Status = ReadNvmeControllerConfiguration (Private, &Cc);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -340,7 +335,7 @@ NvmeDisableController (
|
||||
//
|
||||
Status = WriteNvmeControllerConfiguration (Private, &Cc);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -354,15 +349,15 @@ NvmeDisableController (
|
||||
Timeout = Private->Cap.To;
|
||||
}
|
||||
|
||||
for(Index = (Timeout * 500); Index != 0; --Index) {
|
||||
gBS->Stall(1000);
|
||||
for (Index = (Timeout * 500); Index != 0; --Index) {
|
||||
gBS->Stall (1000);
|
||||
|
||||
//
|
||||
// Check if the controller is initialized
|
||||
//
|
||||
Status = ReadNvmeControllerStatus (Private, &Csts);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -414,7 +409,7 @@ NvmeEnableController (
|
||||
Cc.Iocqes = 4;
|
||||
|
||||
Status = WriteNvmeControllerConfiguration (Private, &Cc);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -428,15 +423,15 @@ NvmeEnableController (
|
||||
Timeout = Private->Cap.To;
|
||||
}
|
||||
|
||||
for(Index = (Timeout * 500); Index != 0; --Index) {
|
||||
gBS->Stall(1000);
|
||||
for (Index = (Timeout * 500); Index != 0; --Index) {
|
||||
gBS->Stall (1000);
|
||||
|
||||
//
|
||||
// Check if the controller is initialized
|
||||
//
|
||||
Status = ReadNvmeControllerStatus (Private, &Csts);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -478,9 +473,9 @@ NvmeIdentifyController (
|
||||
EFI_NVM_EXPRESS_COMPLETION Completion;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
|
||||
Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_CMD;
|
||||
//
|
||||
@ -534,9 +529,9 @@ NvmeIdentifyNamespace (
|
||||
EFI_NVM_EXPRESS_COMPLETION Completion;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -589,10 +584,10 @@ NvmeCreateIoCompletionQueue (
|
||||
Private->CreateIoQueue = TRUE;
|
||||
|
||||
for (Index = 1; Index < NVME_MAX_QUEUES; Index++) {
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CrIoCq, sizeof(NVME_ADMIN_CRIOCQ));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CrIoCq, sizeof (NVME_ADMIN_CRIOCQ));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -661,10 +656,10 @@ NvmeCreateIoSubmissionQueue (
|
||||
Private->CreateIoQueue = TRUE;
|
||||
|
||||
for (Index = 1; Index < NVME_MAX_QUEUES; Index++) {
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CrIoSq, sizeof(NVME_ADMIN_CRIOSQ));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CrIoSq, sizeof (NVME_ADMIN_CRIOSQ));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -731,6 +726,7 @@ NvmeControllerInit (
|
||||
NVME_ACQ Acq;
|
||||
UINT8 Sn[21];
|
||||
UINT8 Mn[41];
|
||||
|
||||
//
|
||||
// Save original PCI attributes and enable this controller.
|
||||
//
|
||||
@ -815,7 +811,7 @@ NvmeControllerInit (
|
||||
|
||||
Status = NvmeDisableController (Private);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -869,7 +865,7 @@ NvmeControllerInit (
|
||||
//
|
||||
Status = WriteNvmeAdminQueueAttributes (Private, &Aqa);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -878,7 +874,7 @@ NvmeControllerInit (
|
||||
//
|
||||
Status = WriteNvmeAdminSubmissionQueueBaseAddress (Private, &Asq);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -887,12 +883,12 @@ NvmeControllerInit (
|
||||
//
|
||||
Status = WriteNvmeAdminCompletionQueueBaseAddress (Private, &Acq);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = NvmeEnableController (Private);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -900,7 +896,7 @@ NvmeControllerInit (
|
||||
// Allocate buffer for Identify Controller data
|
||||
//
|
||||
if (Private->ControllerData == NULL) {
|
||||
Private->ControllerData = (NVME_ADMIN_CONTROLLER_DATA *)AllocateZeroPool (sizeof(NVME_ADMIN_CONTROLLER_DATA));
|
||||
Private->ControllerData = (NVME_ADMIN_CONTROLLER_DATA *)AllocateZeroPool (sizeof (NVME_ADMIN_CONTROLLER_DATA));
|
||||
|
||||
if (Private->ControllerData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -912,8 +908,8 @@ NvmeControllerInit (
|
||||
//
|
||||
Status = NvmeIdentifyController (Private, Private->ControllerData);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
FreePool(Private->ControllerData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Private->ControllerData);
|
||||
Private->ControllerData = NULL;
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -930,11 +926,11 @@ NvmeControllerInit (
|
||||
DEBUG ((DEBUG_INFO, " PCI SSVID : 0x%x\n", Private->ControllerData->Ssvid));
|
||||
DEBUG ((DEBUG_INFO, " SN : %a\n", Sn));
|
||||
DEBUG ((DEBUG_INFO, " MN : %a\n", Mn));
|
||||
DEBUG ((DEBUG_INFO, " FR : 0x%x\n", *((UINT64*)Private->ControllerData->Fr)));
|
||||
DEBUG ((DEBUG_INFO, " TNVMCAP (high 8-byte) : 0x%lx\n", *((UINT64*)(Private->ControllerData->Tnvmcap + 8))));
|
||||
DEBUG ((DEBUG_INFO, " TNVMCAP (low 8-byte) : 0x%lx\n", *((UINT64*)Private->ControllerData->Tnvmcap)));
|
||||
DEBUG ((DEBUG_INFO, " FR : 0x%x\n", *((UINT64 *)Private->ControllerData->Fr)));
|
||||
DEBUG ((DEBUG_INFO, " TNVMCAP (high 8-byte) : 0x%lx\n", *((UINT64 *)(Private->ControllerData->Tnvmcap + 8))));
|
||||
DEBUG ((DEBUG_INFO, " TNVMCAP (low 8-byte) : 0x%lx\n", *((UINT64 *)Private->ControllerData->Tnvmcap)));
|
||||
DEBUG ((DEBUG_INFO, " RAB : 0x%x\n", Private->ControllerData->Rab));
|
||||
DEBUG ((DEBUG_INFO, " IEEE : 0x%x\n", *(UINT32*)Private->ControllerData->Ieee_oui));
|
||||
DEBUG ((DEBUG_INFO, " IEEE : 0x%x\n", *(UINT32 *)Private->ControllerData->Ieee_oui));
|
||||
DEBUG ((DEBUG_INFO, " AERL : 0x%x\n", Private->ControllerData->Aerl));
|
||||
DEBUG ((DEBUG_INFO, " SQES : 0x%x\n", Private->ControllerData->Sqes));
|
||||
DEBUG ((DEBUG_INFO, " CQES : 0x%x\n", Private->ControllerData->Cqes));
|
||||
@ -945,7 +941,7 @@ NvmeControllerInit (
|
||||
// One for blocking I/O, one for non-blocking I/O.
|
||||
//
|
||||
Status = NvmeCreateIoCompletionQueue (Private);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1023,11 +1019,12 @@ NvmeShutdownAllControllers (
|
||||
// gImageHandle equals to DriverBinding handle for this driver.
|
||||
//
|
||||
if (((OpenInfos[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) &&
|
||||
(OpenInfos[OpenInfoIndex].AgentHandle == gImageHandle)) {
|
||||
(OpenInfos[OpenInfoIndex].AgentHandle == gImageHandle))
|
||||
{
|
||||
Status = gBS->OpenProtocol (
|
||||
OpenInfos[OpenInfoIndex].ControllerHandle,
|
||||
&gEfiNvmExpressPassThruProtocolGuid,
|
||||
(VOID **) &NvmePassThru,
|
||||
(VOID **)&NvmePassThru,
|
||||
NULL,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -1035,22 +1032,24 @@ NvmeShutdownAllControllers (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (NvmePassThru);
|
||||
|
||||
//
|
||||
// Read Controller Configuration Register.
|
||||
//
|
||||
Status = ReadNvmeControllerConfiguration (Private, &Cc);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// The host should set the Shutdown Notification (CC.SHN) field to 01b
|
||||
// to indicate a normal shutdown operation.
|
||||
//
|
||||
Cc.Shn = NVME_CC_SHN_NORMAL_SHUTDOWN;
|
||||
Status = WriteNvmeControllerConfiguration (Private, &Cc);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1061,10 +1060,11 @@ NvmeShutdownAllControllers (
|
||||
//
|
||||
for (Index = 0; Index < NVME_SHUTDOWN_PROCESS_TIMEOUT * 100; Index++) {
|
||||
Status = ReadNvmeControllerStatus (Private, &Csts);
|
||||
if (!EFI_ERROR(Status) && (Csts.Shst == NVME_CSTS_SHST_SHUTDOWN_COMPLETED)) {
|
||||
DEBUG((DEBUG_INFO, "NvmeShutdownController: shutdown processing is completed after %dms.\n", Index * 10));
|
||||
if (!EFI_ERROR (Status) && (Csts.Shst == NVME_CSTS_SHST_SHUTDOWN_COMPLETED)) {
|
||||
DEBUG ((DEBUG_INFO, "NvmeShutdownController: shutdown processing is completed after %dms.\n", Index * 10));
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 10ms
|
||||
//
|
||||
@ -1072,7 +1072,7 @@ NvmeShutdownAllControllers (
|
||||
}
|
||||
|
||||
if (Index == NVME_SHUTDOWN_PROCESS_TIMEOUT * 100) {
|
||||
DEBUG((DEBUG_ERROR, "NvmeShutdownController: shutdown processing is timed out\n"));
|
||||
DEBUG ((DEBUG_ERROR, "NvmeShutdownController: shutdown processing is timed out\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1094,7 +1094,7 @@ NvmeRegisterShutdownNotification (
|
||||
|
||||
mNvmeControllerNumber++;
|
||||
if (mNvmeControllerNumber == 1) {
|
||||
Status = gBS->LocateProtocol (&gEfiResetNotificationProtocolGuid, NULL, (VOID **) &ResetNotify);
|
||||
Status = gBS->LocateProtocol (&gEfiResetNotificationProtocolGuid, NULL, (VOID **)&ResetNotify);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = ResetNotify->RegisterResetNotify (ResetNotify, NvmeShutdownAllControllers);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@ -1119,7 +1119,7 @@ NvmeUnregisterShutdownNotification (
|
||||
|
||||
mNvmeControllerNumber--;
|
||||
if (mNvmeControllerNumber == 0) {
|
||||
Status = gBS->LocateProtocol (&gEfiResetNotificationProtocolGuid, NULL, (VOID **) &ResetNotify);
|
||||
Status = gBS->LocateProtocol (&gEfiResetNotificationProtocolGuid, NULL, (VOID **)&ResetNotify);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = ResetNotify->UnregisterResetNotify (ResetNotify, NvmeShutdownAllControllers);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
@ -67,4 +67,3 @@ NvmeIdentifyNamespace (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -97,6 +97,7 @@ NvmeDumpStatus (
|
||||
DEBUG ((DEBUG_VERBOSE, "Reservation Conflict\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x1:
|
||||
@ -159,6 +160,7 @@ NvmeDumpStatus (
|
||||
DEBUG ((DEBUG_VERBOSE, "Attempted Write to Read Only Range\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x2:
|
||||
@ -185,6 +187,7 @@ NvmeDumpStatus (
|
||||
DEBUG ((DEBUG_VERBOSE, "Access Denied\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -206,7 +209,7 @@ NvmeDumpStatus (
|
||||
@retval The pointer to the first PRP List of the PRP lists.
|
||||
|
||||
**/
|
||||
VOID*
|
||||
VOID *
|
||||
NvmeCreatePrpList (
|
||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
||||
IN EFI_PHYSICAL_ADDRESS PhysicalAddr,
|
||||
@ -271,45 +274,46 @@ NvmeCreatePrpList (
|
||||
DEBUG ((DEBUG_ERROR, "NvmeCreatePrpList: create PrpList failure!\n"));
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Fill all PRP lists except of last one.
|
||||
//
|
||||
ZeroMem (*PrpListHost, Bytes);
|
||||
for (PrpListIndex = 0; PrpListIndex < *PrpListNo - 1; ++PrpListIndex) {
|
||||
PrpListBase = *(UINT64*)PrpListHost + PrpListIndex * EFI_PAGE_SIZE;
|
||||
PrpListBase = *(UINT64 *)PrpListHost + PrpListIndex * EFI_PAGE_SIZE;
|
||||
|
||||
for (PrpEntryIndex = 0; PrpEntryIndex < PrpEntryNo; ++PrpEntryIndex) {
|
||||
if (PrpEntryIndex != PrpEntryNo - 1) {
|
||||
//
|
||||
// Fill all PRP entries except of last one.
|
||||
//
|
||||
*((UINT64*)(UINTN)PrpListBase + PrpEntryIndex) = PhysicalAddr;
|
||||
*((UINT64 *)(UINTN)PrpListBase + PrpEntryIndex) = PhysicalAddr;
|
||||
PhysicalAddr += EFI_PAGE_SIZE;
|
||||
} else {
|
||||
//
|
||||
// Fill last PRP entries with next PRP List pointer.
|
||||
//
|
||||
*((UINT64*)(UINTN)PrpListBase + PrpEntryIndex) = PrpListPhyAddr + (PrpListIndex + 1) * EFI_PAGE_SIZE;
|
||||
*((UINT64 *)(UINTN)PrpListBase + PrpEntryIndex) = PrpListPhyAddr + (PrpListIndex + 1) * EFI_PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fill last PRP list.
|
||||
//
|
||||
PrpListBase = *(UINT64*)PrpListHost + PrpListIndex * EFI_PAGE_SIZE;
|
||||
PrpListBase = *(UINT64 *)PrpListHost + PrpListIndex * EFI_PAGE_SIZE;
|
||||
for (PrpEntryIndex = 0; PrpEntryIndex < Remainder; ++PrpEntryIndex) {
|
||||
*((UINT64*)(UINTN)PrpListBase + PrpEntryIndex) = PhysicalAddr;
|
||||
*((UINT64 *)(UINTN)PrpListBase + PrpEntryIndex) = PhysicalAddr;
|
||||
PhysicalAddr += EFI_PAGE_SIZE;
|
||||
}
|
||||
|
||||
return (VOID*)(UINTN)PrpListPhyAddr;
|
||||
return (VOID *)(UINTN)PrpListPhyAddr;
|
||||
|
||||
EXIT:
|
||||
PciIo->FreeBuffer (PciIo, *PrpListNo, *PrpListHost);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Aborts the asynchronous PassThru requests.
|
||||
|
||||
@ -343,7 +347,8 @@ AbortAsyncPassThruTasks (
|
||||
//
|
||||
for (Link = GetFirstNode (&Private->UnsubmittedSubtasks);
|
||||
!IsNull (&Private->UnsubmittedSubtasks, Link);
|
||||
Link = NextLink) {
|
||||
Link = NextLink)
|
||||
{
|
||||
NextLink = GetNextNode (&Private->UnsubmittedSubtasks, Link);
|
||||
Subtask = NVME_BLKIO2_SUBTASK_FROM_LINK (Link);
|
||||
BlkIo2Request = Subtask->BlockIo2Request;
|
||||
@ -353,6 +358,7 @@ AbortAsyncPassThruTasks (
|
||||
if (Subtask->IsLast) {
|
||||
BlkIo2Request->LastSubtaskSubmitted = TRUE;
|
||||
}
|
||||
|
||||
Token->TransactionStatus = EFI_ABORTED;
|
||||
|
||||
RemoveEntryList (Link);
|
||||
@ -365,19 +371,23 @@ AbortAsyncPassThruTasks (
|
||||
//
|
||||
for (Link = GetFirstNode (&Private->AsyncPassThruQueue);
|
||||
!IsNull (&Private->AsyncPassThruQueue, Link);
|
||||
Link = NextLink) {
|
||||
Link = NextLink)
|
||||
{
|
||||
NextLink = GetNextNode (&Private->AsyncPassThruQueue, Link);
|
||||
AsyncRequest = NVME_PASS_THRU_ASYNC_REQ_FROM_THIS (Link);
|
||||
|
||||
if (AsyncRequest->MapData != NULL) {
|
||||
PciIo->Unmap (PciIo, AsyncRequest->MapData);
|
||||
}
|
||||
|
||||
if (AsyncRequest->MapMeta != NULL) {
|
||||
PciIo->Unmap (PciIo, AsyncRequest->MapMeta);
|
||||
}
|
||||
|
||||
if (AsyncRequest->MapPrpList != NULL) {
|
||||
PciIo->Unmap (PciIo, AsyncRequest->MapPrpList);
|
||||
}
|
||||
|
||||
if (AsyncRequest->PrpListHost != NULL) {
|
||||
PciIo->FreeBuffer (
|
||||
PciIo,
|
||||
@ -392,7 +402,8 @@ AbortAsyncPassThruTasks (
|
||||
}
|
||||
|
||||
if (IsListEmpty (&Private->AsyncPassThruQueue) &&
|
||||
IsListEmpty (&Private->UnsubmittedSubtasks)) {
|
||||
IsListEmpty (&Private->UnsubmittedSubtasks))
|
||||
{
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
@ -403,7 +414,6 @@ AbortAsyncPassThruTasks (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports
|
||||
both blocking I/O and non-blocking I/O. The blocking I/O functionality is required, and the non-blocking
|
||||
@ -483,7 +493,7 @@ NvmExpressPassThru (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Packet->QueueType != NVME_ADMIN_QUEUE && Packet->QueueType != NVME_IO_QUEUE) {
|
||||
if ((Packet->QueueType != NVME_ADMIN_QUEUE) && (Packet->QueueType != NVME_IO_QUEUE)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -494,7 +504,8 @@ NvmExpressPassThru (
|
||||
//
|
||||
Attributes = This->Mode->Attributes;
|
||||
if ((Attributes & (EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL |
|
||||
EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL)) == 0) {
|
||||
EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL)) == 0)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -502,11 +513,11 @@ NvmExpressPassThru (
|
||||
// Buffer alignment check for TransferBuffer & MetadataBuffer.
|
||||
//
|
||||
IoAlign = This->Mode->IoAlign;
|
||||
if (IoAlign > 0 && (((UINTN) Packet->TransferBuffer & (IoAlign - 1)) != 0)) {
|
||||
if ((IoAlign > 0) && (((UINTN)Packet->TransferBuffer & (IoAlign - 1)) != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (IoAlign > 0 && (((UINTN) Packet->MetadataBuffer & (IoAlign - 1)) != 0)) {
|
||||
if ((IoAlign > 0) && (((UINTN)Packet->MetadataBuffer & (IoAlign - 1)) != 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -516,7 +527,8 @@ NvmExpressPassThru (
|
||||
// Check NamespaceId is valid or not.
|
||||
//
|
||||
if ((NamespaceId > Private->ControllerData->Nn) &&
|
||||
(NamespaceId != (UINT32) -1)) {
|
||||
(NamespaceId != (UINT32)-1))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -555,11 +567,13 @@ NvmExpressPassThru (
|
||||
// Submission queue full check.
|
||||
//
|
||||
if ((Private->SqTdbl[QueueId].Sqt + 1) % QueueSize ==
|
||||
Private->AsyncSqHead) {
|
||||
Private->AsyncSqHead)
|
||||
{
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sq = Private->SqBuffer[QueueId] + Private->SqTdbl[QueueId].Sqt;
|
||||
Cq = Private->CqBuffer[QueueId] + Private->CqHdbl[QueueId].Cqh;
|
||||
|
||||
@ -584,7 +598,8 @@ NvmExpressPassThru (
|
||||
|
||||
Sq->Prp[0] = (UINT64)(UINTN)Packet->TransferBuffer;
|
||||
if ((Packet->QueueType == NVME_ADMIN_QUEUE) &&
|
||||
((Sq->Opc == NVME_ADMIN_CRIOCQ_CMD) || (Sq->Opc == NVME_ADMIN_CRIOSQ_CMD))) {
|
||||
((Sq->Opc == NVME_ADMIN_CRIOCQ_CMD) || (Sq->Opc == NVME_ADMIN_CRIOSQ_CMD)))
|
||||
{
|
||||
//
|
||||
// Currently, we only use the IO Completion/Submission queues created internally
|
||||
// by this driver during controller initialization. Any other IO queues created
|
||||
@ -601,7 +616,8 @@ NvmExpressPassThru (
|
||||
// If the NVMe cmd has data in or out, then mapping the user buffer to the PCI controller specific addresses.
|
||||
//
|
||||
if (((Packet->TransferLength != 0) && (Packet->TransferBuffer == NULL)) ||
|
||||
((Packet->TransferLength == 0) && (Packet->TransferBuffer != NULL))) {
|
||||
((Packet->TransferLength == 0) && (Packet->TransferBuffer != NULL)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -629,7 +645,7 @@ NvmExpressPassThru (
|
||||
Sq->Prp[1] = 0;
|
||||
}
|
||||
|
||||
if((Packet->MetadataLength != 0) && (Packet->MetadataBuffer != NULL)) {
|
||||
if ((Packet->MetadataLength != 0) && (Packet->MetadataBuffer != NULL)) {
|
||||
MapLength = Packet->MetadataLength;
|
||||
Status = PciIo->Map (
|
||||
PciIo,
|
||||
@ -647,9 +663,11 @@ NvmExpressPassThru (
|
||||
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Sq->Mptr = PhyAddr;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If the buffer size spans more than two memory pages (page size as defined in CC.Mps),
|
||||
// then build a PRP list in the second PRP submission queue entry.
|
||||
@ -662,7 +680,7 @@ NvmExpressPassThru (
|
||||
// Create PrpList for remaining data buffer.
|
||||
//
|
||||
PhyAddr = (Sq->Prp[0] + EFI_PAGE_SIZE) & ~(EFI_PAGE_SIZE - 1);
|
||||
Prp = NvmeCreatePrpList (PciIo, PhyAddr, EFI_SIZE_TO_PAGES(Offset + Bytes) - 1, &PrpListHost, &PrpListNo, &MapPrpList);
|
||||
Prp = NvmeCreatePrpList (PciIo, PhyAddr, EFI_SIZE_TO_PAGES (Offset + Bytes) - 1, &PrpListHost, &PrpListNo, &MapPrpList);
|
||||
if (Prp == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto EXIT;
|
||||
@ -673,28 +691,35 @@ NvmExpressPassThru (
|
||||
Sq->Prp[1] = (Sq->Prp[0] + EFI_PAGE_SIZE) & ~(EFI_PAGE_SIZE - 1);
|
||||
}
|
||||
|
||||
if(Packet->NvmeCmd->Flags & CDW2_VALID) {
|
||||
if (Packet->NvmeCmd->Flags & CDW2_VALID) {
|
||||
Sq->Rsvd2 = (UINT64)Packet->NvmeCmd->Cdw2;
|
||||
}
|
||||
if(Packet->NvmeCmd->Flags & CDW3_VALID) {
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW3_VALID) {
|
||||
Sq->Rsvd2 |= LShiftU64 ((UINT64)Packet->NvmeCmd->Cdw3, 32);
|
||||
}
|
||||
if(Packet->NvmeCmd->Flags & CDW10_VALID) {
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW10_VALID) {
|
||||
Sq->Payload.Raw.Cdw10 = Packet->NvmeCmd->Cdw10;
|
||||
}
|
||||
if(Packet->NvmeCmd->Flags & CDW11_VALID) {
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW11_VALID) {
|
||||
Sq->Payload.Raw.Cdw11 = Packet->NvmeCmd->Cdw11;
|
||||
}
|
||||
if(Packet->NvmeCmd->Flags & CDW12_VALID) {
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW12_VALID) {
|
||||
Sq->Payload.Raw.Cdw12 = Packet->NvmeCmd->Cdw12;
|
||||
}
|
||||
if(Packet->NvmeCmd->Flags & CDW13_VALID) {
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW13_VALID) {
|
||||
Sq->Payload.Raw.Cdw13 = Packet->NvmeCmd->Cdw13;
|
||||
}
|
||||
if(Packet->NvmeCmd->Flags & CDW14_VALID) {
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW14_VALID) {
|
||||
Sq->Payload.Raw.Cdw14 = Packet->NvmeCmd->Cdw14;
|
||||
}
|
||||
if(Packet->NvmeCmd->Flags & CDW15_VALID) {
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW15_VALID) {
|
||||
Sq->Payload.Raw.Cdw15 = Packet->NvmeCmd->Cdw15;
|
||||
}
|
||||
|
||||
@ -707,12 +732,13 @@ NvmExpressPassThru (
|
||||
} else {
|
||||
Private->SqTdbl[QueueId].Sqt ^= 1;
|
||||
}
|
||||
Data = ReadUnaligned32 ((UINT32*)&Private->SqTdbl[QueueId]);
|
||||
|
||||
Data = ReadUnaligned32 ((UINT32 *)&Private->SqTdbl[QueueId]);
|
||||
Status = PciIo->Mem.Write (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
NVME_BAR,
|
||||
NVME_SQTDBL_OFFSET(QueueId, Private->Cap.Dstrd),
|
||||
NVME_SQTDBL_OFFSET (QueueId, Private->Cap.Dstrd),
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -760,9 +786,9 @@ NvmExpressPassThru (
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
Status = gBS->SetTimer(TimerEvent, TimerRelative, Packet->CommandTimeout);
|
||||
Status = gBS->SetTimer (TimerEvent, TimerRelative, Packet->CommandTimeout);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
@ -788,14 +814,15 @@ NvmExpressPassThru (
|
||||
//
|
||||
// Dump every completion entry status for debugging.
|
||||
//
|
||||
DEBUG_CODE_BEGIN();
|
||||
NvmeDumpStatus(Cq);
|
||||
DEBUG_CODE_END();
|
||||
DEBUG_CODE_BEGIN ();
|
||||
NvmeDumpStatus (Cq);
|
||||
DEBUG_CODE_END ();
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the Respose Queue entry for this command to the callers response buffer
|
||||
//
|
||||
CopyMem(Packet->NvmeCompletion, Cq, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
CopyMem (Packet->NvmeCompletion, Cq, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
} else {
|
||||
//
|
||||
// Timeout occurs for an NVMe command. Reset the controller to abort the
|
||||
@ -840,13 +867,13 @@ NvmExpressPassThru (
|
||||
Private->Pt[QueueId] ^= 1;
|
||||
}
|
||||
|
||||
Data = ReadUnaligned32 ((UINT32*)&Private->CqHdbl[QueueId]);
|
||||
Data = ReadUnaligned32 ((UINT32 *)&Private->CqHdbl[QueueId]);
|
||||
PreviousStatus = Status;
|
||||
Status = PciIo->Mem.Write (
|
||||
PciIo,
|
||||
EfiPciIoWidthUint32,
|
||||
NVME_BAR,
|
||||
NVME_CQHDBL_OFFSET(QueueId, Private->Cap.Dstrd),
|
||||
NVME_CQHDBL_OFFSET (QueueId, Private->Cap.Dstrd),
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
@ -892,6 +919,7 @@ EXIT:
|
||||
if (TimerEvent != NULL) {
|
||||
gBS->CloseEvent (TimerEvent);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -966,7 +994,7 @@ NvmExpressGetNextNamespace (
|
||||
}
|
||||
|
||||
Status = NvmeIdentifyNamespace (Private, NextNamespaceId, NamespaceData);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
@ -990,7 +1018,7 @@ NvmExpressGetNextNamespace (
|
||||
}
|
||||
|
||||
Status = NvmeIdentifyNamespace (Private, NextNamespaceId, NamespaceData);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
@ -999,7 +1027,7 @@ NvmExpressGetNextNamespace (
|
||||
|
||||
Done:
|
||||
if (NamespaceData != NULL) {
|
||||
FreePool(NamespaceData);
|
||||
FreePool (NamespaceData);
|
||||
}
|
||||
|
||||
return Status;
|
||||
@ -1052,7 +1080,7 @@ NvmExpressGetNamespace (
|
||||
Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (This);
|
||||
|
||||
if (DevicePath->SubType == MSG_NVME_NAMESPACE_DP) {
|
||||
if (DevicePathNodeLength(DevicePath) != sizeof(NVME_NAMESPACE_DEVICE_PATH)) {
|
||||
if (DevicePathNodeLength (DevicePath) != sizeof (NVME_NAMESPACE_DEVICE_PATH)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -1060,7 +1088,8 @@ NvmExpressGetNamespace (
|
||||
// Check NamespaceId in the device path node is valid or not.
|
||||
//
|
||||
if ((Node->NamespaceId == 0) ||
|
||||
(Node->NamespaceId > Private->ControllerData->Nn)) {
|
||||
(Node->NamespaceId > Private->ControllerData->Nn))
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -1130,7 +1159,8 @@ NvmExpressBuildDevicePath (
|
||||
// Check NamespaceId is valid or not.
|
||||
//
|
||||
if ((NamespaceId == 0) ||
|
||||
(NamespaceId > Private->ControllerData->Nn)) {
|
||||
(NamespaceId > Private->ControllerData->Nn))
|
||||
{
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -1148,8 +1178,8 @@ NvmExpressBuildDevicePath (
|
||||
// Allocate a buffer for Identify Namespace data.
|
||||
//
|
||||
NamespaceData = NULL;
|
||||
NamespaceData = AllocateZeroPool(sizeof (NVME_ADMIN_NAMESPACE_DATA));
|
||||
if(NamespaceData == NULL) {
|
||||
NamespaceData = AllocateZeroPool (sizeof (NVME_ADMIN_NAMESPACE_DATA));
|
||||
if (NamespaceData == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Exit;
|
||||
}
|
||||
@ -1163,7 +1193,7 @@ NvmExpressBuildDevicePath (
|
||||
(VOID *)NamespaceData
|
||||
);
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@ -1172,7 +1202,7 @@ NvmExpressBuildDevicePath (
|
||||
*DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Node;
|
||||
|
||||
Exit:
|
||||
if(NamespaceData != NULL) {
|
||||
if (NamespaceData != NULL) {
|
||||
FreePool (NamespaceData);
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@ NVME_NAMESPACE_DEVICE_PATH mNvmeDevicePathNodeTemplate = {
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_NVME_NAMESPACE_DP,
|
||||
{
|
||||
(UINT8) (sizeof (NVME_NAMESPACE_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (NVME_NAMESPACE_DEVICE_PATH)) >> 8)
|
||||
(UINT8)(sizeof (NVME_NAMESPACE_DEVICE_PATH)),
|
||||
(UINT8)((sizeof (NVME_NAMESPACE_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0x0, // NamespaceId
|
||||
@ -32,8 +32,8 @@ EFI_DEVICE_PATH_PROTOCOL mNvmeEndDevicePathNodeTemplate = {
|
||||
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)
|
||||
}
|
||||
};
|
||||
|
||||
@ -78,7 +78,7 @@ NextDevicePathNode (
|
||||
)
|
||||
{
|
||||
ASSERT (Node != NULL);
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength (Node));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +103,7 @@ GetDevicePathInstanceSize (
|
||||
{
|
||||
EFI_DEVICE_PATH_PROTOCOL *Walker;
|
||||
|
||||
if (DevicePath == NULL || InstanceSize == NULL || EntireDevicePathEnd == NULL) {
|
||||
if ((DevicePath == NULL) || (InstanceSize == NULL) || (EntireDevicePathEnd == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ GetDevicePathInstanceSize (
|
||||
//
|
||||
// Compute the size of the device path instance
|
||||
//
|
||||
*InstanceSize = ((UINTN) Walker - (UINTN) (DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
*InstanceSize = ((UINTN)Walker - (UINTN)(DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -167,22 +167,24 @@ NvmeIsHcDevicePathValid (
|
||||
|
||||
Start = DevicePath;
|
||||
while (!(DevicePath->Type == END_DEVICE_PATH_TYPE &&
|
||||
DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) {
|
||||
DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE))
|
||||
{
|
||||
DevicePath = NextDevicePathNode (DevicePath);
|
||||
|
||||
//
|
||||
// Prevent overflow and invalid zero in the 'Length' field of a device path
|
||||
// node.
|
||||
//
|
||||
if ((UINTN) DevicePath <= (UINTN) Start) {
|
||||
if ((UINTN)DevicePath <= (UINTN)Start) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Prevent touching memory beyond given DevicePathLength.
|
||||
//
|
||||
if ((UINTN) DevicePath - (UINTN) Start >
|
||||
DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
|
||||
if ((UINTN)DevicePath - (UINTN)Start >
|
||||
DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
@ -190,7 +192,7 @@ NvmeIsHcDevicePathValid (
|
||||
//
|
||||
// Check if the device path and its size match exactly with each other.
|
||||
//
|
||||
Size = ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
Size = ((UINTN)DevicePath - (UINTN)Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
||||
if (Size != DevicePathLength) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -227,7 +229,7 @@ NvmeBuildDevicePath (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathWalker;
|
||||
NVME_NAMESPACE_DEVICE_PATH *NvmeDeviceNode;
|
||||
|
||||
if (DevicePathLength == NULL || DevicePath == NULL) {
|
||||
if ((DevicePathLength == NULL) || (DevicePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -251,7 +253,7 @@ NvmeBuildDevicePath (
|
||||
//
|
||||
// Construct the Nvm Express device node
|
||||
//
|
||||
DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *) ((UINT8 *)DevicePathWalker +
|
||||
DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePathWalker +
|
||||
(Private->DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
|
||||
CopyMem (
|
||||
DevicePathWalker,
|
||||
@ -265,7 +267,7 @@ NvmeBuildDevicePath (
|
||||
//
|
||||
// Construct the end device node
|
||||
//
|
||||
DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *) ((UINT8 *)DevicePathWalker +
|
||||
DevicePathWalker = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePathWalker +
|
||||
sizeof (NVME_NAMESPACE_DEVICE_PATH));
|
||||
CopyMem (
|
||||
DevicePathWalker,
|
||||
|
@ -28,7 +28,7 @@ GetIoMmu (
|
||||
&gEdkiiIoMmuPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &IoMmu
|
||||
(VOID **)&IoMmu
|
||||
);
|
||||
if (!EFI_ERROR (Status) && (IoMmu != NULL)) {
|
||||
return IoMmu;
|
||||
@ -83,6 +83,7 @@ IoMmuMap (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
switch (Operation) {
|
||||
case EdkiiIoMmuOperationBusMasterRead:
|
||||
case EdkiiIoMmuOperationBusMasterRead64:
|
||||
@ -97,9 +98,10 @@ IoMmuMap (
|
||||
Attribute = EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE;
|
||||
break;
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
ASSERT (FALSE);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = IoMmu->SetAttribute (
|
||||
IoMmu,
|
||||
*Mapping,
|
||||
@ -113,6 +115,7 @@ IoMmuMap (
|
||||
*Mapping = NULL;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -141,6 +144,7 @@ IoMmuUnmap (
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -192,7 +196,7 @@ IoMmuAllocateBuffer (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
NumberOfBytes = EFI_PAGES_TO_SIZE(Pages);
|
||||
NumberOfBytes = EFI_PAGES_TO_SIZE (Pages);
|
||||
Status = IoMmu->Map (
|
||||
IoMmu,
|
||||
EdkiiIoMmuOperationBusMasterCommonBuffer,
|
||||
@ -204,6 +208,7 @@ IoMmuAllocateBuffer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = IoMmu->SetAttribute (
|
||||
IoMmu,
|
||||
*Mapping,
|
||||
@ -221,10 +226,12 @@ IoMmuAllocateBuffer (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
*HostAddress = (VOID *)(UINTN)HostPhyAddress;
|
||||
*DeviceAddress = HostPhyAddress;
|
||||
*Mapping = NULL;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -259,5 +266,6 @@ IoMmuFreeBuffer (
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ EnumerateNvmeDevNamespace (
|
||||
UINT32 Flbas;
|
||||
UINT32 LbaFmtIdx;
|
||||
|
||||
NamespaceData = (NVME_ADMIN_NAMESPACE_DATA *) AllocateZeroPool (sizeof (NVME_ADMIN_NAMESPACE_DATA));
|
||||
NamespaceData = (NVME_ADMIN_NAMESPACE_DATA *)AllocateZeroPool (sizeof (NVME_ADMIN_NAMESPACE_DATA));
|
||||
if (NamespaceData == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -110,8 +110,8 @@ EnumerateNvmeDevNamespace (
|
||||
NamespaceInfo->Media.RemovableMedia = FALSE;
|
||||
NamespaceInfo->Media.MediaPresent = TRUE;
|
||||
NamespaceInfo->Media.ReadOnly = FALSE;
|
||||
NamespaceInfo->Media.BlockSize = (UINT32) 1 << Lbads;
|
||||
NamespaceInfo->Media.LastBlock = (EFI_PEI_LBA) NamespaceData->Nsze - 1;
|
||||
NamespaceInfo->Media.BlockSize = (UINT32)1 << Lbads;
|
||||
NamespaceInfo->Media.LastBlock = (EFI_PEI_LBA)NamespaceData->Nsze - 1;
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Namespace ID %d - BlockSize = 0x%x, LastBlock = 0x%lx\n",
|
||||
@ -161,6 +161,7 @@ NvmeDiscoverNamespaces (
|
||||
//
|
||||
EnumerateNvmeDevNamespace (Private, NamespaceId);
|
||||
}
|
||||
|
||||
if (Private->ActiveNamespaceNum == 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -239,7 +240,7 @@ NvmExpressPeimEntry (
|
||||
&gEdkiiPeiNvmExpressHostControllerPpiGuid,
|
||||
0,
|
||||
NULL,
|
||||
(VOID **) &NvmeHcPpi
|
||||
(VOID **)&NvmeHcPpi
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Fail to locate NvmeHostControllerPpi.\n", __FUNCTION__));
|
||||
@ -269,8 +270,10 @@ NvmExpressPeimEntry (
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: Fail to allocate get the device path for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_ERROR,
|
||||
"%a: Fail to allocate get the device path for Controller %d.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
@ -281,8 +284,10 @@ NvmExpressPeimEntry (
|
||||
Status = NvmeIsHcDevicePathValid (DevicePath, DevicePathLength);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: The device path is invalid for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_ERROR,
|
||||
"%a: The device path is invalid for Controller %d.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
Controller++;
|
||||
continue;
|
||||
@ -295,10 +300,13 @@ NvmExpressPeimEntry (
|
||||
// during S3 resume.
|
||||
//
|
||||
if ((BootMode == BOOT_ON_S3_RESUME) &&
|
||||
(NvmeS3SkipThisController (DevicePath, DevicePathLength))) {
|
||||
(NvmeS3SkipThisController (DevicePath, DevicePathLength)))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: Controller %d is skipped during S3.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_ERROR,
|
||||
"%a: Controller %d is skipped during S3.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
Controller++;
|
||||
continue;
|
||||
@ -310,8 +318,10 @@ NvmExpressPeimEntry (
|
||||
Private = AllocateZeroPool (sizeof (PEI_NVME_CONTROLLER_PRIVATE_DATA));
|
||||
if (Private == NULL) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: Fail to allocate private data for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_ERROR,
|
||||
"%a: Fail to allocate private data for Controller %d.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -327,12 +337,15 @@ NvmExpressPeimEntry (
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR, "%a: Fail to allocate DMA buffers for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_ERROR,
|
||||
"%a: Fail to allocate DMA buffers for Controller %d.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS) (UINTN) Private->Buffer));
|
||||
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Private->Buffer));
|
||||
DEBUG ((DEBUG_INFO, "%a: DMA buffer base at 0x%x\n", __FUNCTION__, Private->Buffer));
|
||||
|
||||
//
|
||||
@ -351,7 +364,9 @@ NvmExpressPeimEntry (
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Controller initialization fail for Controller %d with Status - %r.\n",
|
||||
__FUNCTION__, Controller, Status
|
||||
__FUNCTION__,
|
||||
Controller,
|
||||
Status
|
||||
));
|
||||
NvmeFreeDmaResource (Private);
|
||||
Controller++;
|
||||
@ -369,7 +384,9 @@ NvmExpressPeimEntry (
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Namespaces discovery fail for Controller %d with Status - %r.\n",
|
||||
__FUNCTION__, Controller, Status
|
||||
__FUNCTION__,
|
||||
Controller,
|
||||
Status
|
||||
));
|
||||
NvmeFreeDmaResource (Private);
|
||||
Controller++;
|
||||
@ -428,7 +445,8 @@ NvmExpressPeimEntry (
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Security Security Command PPI will be produced for Controller %d.\n",
|
||||
__FUNCTION__, Controller
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
Private->StorageSecurityPpi.Revision = EDKII_STORAGE_SECURITY_PPI_REVISION;
|
||||
Private->StorageSecurityPpi.GetNumberofDevices = NvmeStorageSecurityGetDeviceNo;
|
||||
@ -452,8 +470,10 @@ NvmExpressPeimEntry (
|
||||
PeiServicesNotifyPpi (&Private->EndOfPeiNotifyList);
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO, "%a: Controller %d has been successfully initialized.\n",
|
||||
__FUNCTION__, Controller
|
||||
DEBUG_INFO,
|
||||
"%a: Controller %d has been successfully initialized.\n",
|
||||
__FUNCTION__,
|
||||
Controller
|
||||
));
|
||||
Controller++;
|
||||
}
|
||||
|
@ -156,7 +156,6 @@ struct _PEI_NVME_CONTROLLER_PRIVATE_DATA {
|
||||
#define GET_NVME_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a) \
|
||||
CR (a, PEI_NVME_CONTROLLER_PRIVATE_DATA, EndOfPeiNotifyList, NVME_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
|
||||
|
||||
|
||||
//
|
||||
// Internal functions
|
||||
//
|
||||
|
@ -44,9 +44,9 @@ ReadSectors (
|
||||
BlockSize = NamespaceInfo->Media.BlockSize;
|
||||
Bytes = Blocks * BlockSize;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -60,7 +60,7 @@ ReadSectors (
|
||||
CommandPacket.QueueType = NVME_IO_QUEUE;
|
||||
|
||||
CommandPacket.NvmeCmd->Cdw10 = (UINT32)Lba;
|
||||
CommandPacket.NvmeCmd->Cdw11 = (UINT32)RShiftU64(Lba, 32);
|
||||
CommandPacket.NvmeCmd->Cdw11 = (UINT32)RShiftU64 (Lba, 32);
|
||||
CommandPacket.NvmeCmd->Cdw12 = (Blocks - 1) & 0xFFFF;
|
||||
|
||||
CommandPacket.NvmeCmd->Flags = CDW10_VALID | CDW11_VALID | CDW12_VALID;
|
||||
@ -120,14 +120,15 @@ NvmeRead (
|
||||
Lba,
|
||||
Blocks > MaxTransferBlocks ? MaxTransferBlocks : (UINT32)Blocks
|
||||
);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
Retries++;
|
||||
MaxTransferBlocks = MaxTransferBlocks >> 1;
|
||||
|
||||
if (Retries > NVME_READ_MAX_RETRY || MaxTransferBlocks < 1) {
|
||||
if ((Retries > NVME_READ_MAX_RETRY) || (MaxTransferBlocks < 1)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: ReadSectors fail, Status - %r\n", __FUNCTION__, Status));
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_BLKIO,
|
||||
"%a: ReadSectors fail, retry with smaller transfer block number - 0x%x\n",
|
||||
@ -146,9 +147,17 @@ NvmeRead (
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_BLKIO, "%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n", __FUNCTION__, Lba,
|
||||
(UINT64)OrginalBlocks, (UINT64)Blocks, BlockSize, Status));
|
||||
DEBUG ((
|
||||
DEBUG_BLKIO,
|
||||
"%a: Lba = 0x%08Lx, Original = 0x%08Lx, "
|
||||
"Remaining = 0x%08Lx, BlockSize = 0x%x, Status = %r\n",
|
||||
__FUNCTION__,
|
||||
Lba,
|
||||
(UINT64)OrginalBlocks,
|
||||
(UINT64)Blocks,
|
||||
BlockSize,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -178,7 +187,7 @@ NvmeBlockIoPeimGetDeviceNo (
|
||||
{
|
||||
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || NumberBlockDevices == NULL) {
|
||||
if ((This == NULL) || (NumberBlockDevices == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -240,7 +249,7 @@ NvmeBlockIoPeimGetMediaInfo (
|
||||
{
|
||||
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || MediaInfo == NULL) {
|
||||
if ((This == NULL) || (MediaInfo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -250,7 +259,7 @@ NvmeBlockIoPeimGetMediaInfo (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
MediaInfo->DeviceType = (EFI_PEI_BLOCK_DEVICE_TYPE) EDKII_PEI_BLOCK_DEVICE_TYPE_NVME;
|
||||
MediaInfo->DeviceType = (EFI_PEI_BLOCK_DEVICE_TYPE)EDKII_PEI_BLOCK_DEVICE_TYPE_NVME;
|
||||
MediaInfo->MediaPresent = TRUE;
|
||||
MediaInfo->LastBlock = (UINTN)Private->NamespaceInfo[DeviceIndex-1].Media.LastBlock;
|
||||
MediaInfo->BlockSize = Private->NamespaceInfo[DeviceIndex-1].Media.BlockSize;
|
||||
@ -313,7 +322,7 @@ NvmeBlockIoPeimReadBlocks (
|
||||
//
|
||||
// Check parameters
|
||||
//
|
||||
if (This == NULL || Buffer == NULL) {
|
||||
if ((This == NULL) || (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -337,6 +346,7 @@ NvmeBlockIoPeimReadBlocks (
|
||||
if (StartLBA > NamespaceInfo->Media.LastBlock) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
NumberOfBlocks = BufferSize / BlockSize;
|
||||
if (NumberOfBlocks - 1 > NamespaceInfo->Media.LastBlock - StartLBA) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -371,7 +381,7 @@ NvmeBlockIoPeimGetDeviceNo2 (
|
||||
{
|
||||
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || NumberBlockDevices == NULL) {
|
||||
if ((This == NULL) || (NumberBlockDevices == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -435,7 +445,7 @@ NvmeBlockIoPeimGetMediaInfo2 (
|
||||
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
EFI_PEI_BLOCK_IO_MEDIA Media;
|
||||
|
||||
if (This == NULL || MediaInfo == NULL) {
|
||||
if ((This == NULL) || (MediaInfo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ NvmeMmioRead (
|
||||
Data = MmioRead8 (MmioAddr + Offset);
|
||||
Ptr[Offset] = Data;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -106,6 +107,7 @@ NvmeMmioWrite (
|
||||
Data = Ptr[Offset];
|
||||
MmioWrite8 (MmioAddr + Offset, Data);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -181,19 +183,19 @@ NvmeWaitController (
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
for(Index = (Timeout * 500); Index != 0; --Index) {
|
||||
for (Index = (Timeout * 500); Index != 0; --Index) {
|
||||
MicroSecondDelay (1000);
|
||||
|
||||
//
|
||||
// Check if the controller is initialized
|
||||
//
|
||||
Status = NVME_GET_CSTS (Private, &Csts);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: NVME_GET_CSTS fail, Status - %r\n", __FUNCTION__, Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
if ((BOOLEAN) Csts.Rdy == WaitReady) {
|
||||
if ((BOOLEAN)Csts.Rdy == WaitReady) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -325,9 +327,9 @@ NvmeIdentifyController (
|
||||
EFI_NVM_EXPRESS_COMPLETION Completion;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
|
||||
Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_CMD;
|
||||
//
|
||||
@ -379,9 +381,9 @@ NvmeIdentifyNamespace (
|
||||
EFI_NVM_EXPRESS_COMPLETION Completion;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
|
||||
Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_CMD;
|
||||
Command.Nsid = NamespaceId;
|
||||
@ -430,9 +432,9 @@ NvmeDumpControllerData (
|
||||
DEBUG ((DEBUG_INFO, " PCI SSVID : 0x%x\n", ControllerData->Ssvid));
|
||||
DEBUG ((DEBUG_INFO, " SN : %a\n", Sn));
|
||||
DEBUG ((DEBUG_INFO, " MN : %a\n", Mn));
|
||||
DEBUG ((DEBUG_INFO, " FR : 0x%lx\n", *((UINT64*)ControllerData->Fr)));
|
||||
DEBUG ((DEBUG_INFO, " FR : 0x%lx\n", *((UINT64 *)ControllerData->Fr)));
|
||||
DEBUG ((DEBUG_INFO, " RAB : 0x%x\n", ControllerData->Rab));
|
||||
DEBUG ((DEBUG_INFO, " IEEE : 0x%x\n", *(UINT32*)ControllerData->Ieee_oui));
|
||||
DEBUG ((DEBUG_INFO, " IEEE : 0x%x\n", *(UINT32 *)ControllerData->Ieee_oui));
|
||||
DEBUG ((DEBUG_INFO, " AERL : 0x%x\n", ControllerData->Aerl));
|
||||
DEBUG ((DEBUG_INFO, " SQES : 0x%x\n", ControllerData->Sqes));
|
||||
DEBUG ((DEBUG_INFO, " CQES : 0x%x\n", ControllerData->Cqes));
|
||||
@ -460,10 +462,10 @@ NvmeCreateIoCompletionQueue (
|
||||
EFI_STATUS Status;
|
||||
NVME_ADMIN_CRIOCQ CrIoCq;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CrIoCq, sizeof(NVME_ADMIN_CRIOCQ));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CrIoCq, sizeof (NVME_ADMIN_CRIOCQ));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -508,10 +510,10 @@ NvmeCreateIoSubmissionQueue (
|
||||
EFI_STATUS Status;
|
||||
NVME_ADMIN_CRIOSQ CrIoSq;
|
||||
|
||||
ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CrIoSq, sizeof(NVME_ADMIN_CRIOSQ));
|
||||
ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
|
||||
ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
|
||||
ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
|
||||
ZeroMem (&CrIoSq, sizeof (NVME_ADMIN_CRIOSQ));
|
||||
|
||||
CommandPacket.NvmeCmd = &Command;
|
||||
CommandPacket.NvmeCompletion = &Completion;
|
||||
@ -589,6 +591,7 @@ NvmeControllerInit (
|
||||
ZeroMem ((VOID *)(UINTN)(&Private->SqTdbl[Index]), sizeof (NVME_SQTDBL));
|
||||
ZeroMem ((VOID *)(UINTN)(&Private->CqHdbl[Index]), sizeof (NVME_CQHDBL));
|
||||
}
|
||||
|
||||
ZeroMem (Private->Buffer, EFI_PAGE_SIZE * NVME_MEM_MAX_PAGES);
|
||||
|
||||
//
|
||||
@ -657,11 +660,13 @@ NvmeControllerInit (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
Status = NvmeIdentifyController (Private, Private->ControllerData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: NvmeIdentifyController fail, Status - %r\n", __FUNCTION__, Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
NvmeDumpControllerData (Private->ControllerData);
|
||||
|
||||
//
|
||||
@ -684,6 +689,7 @@ NvmeControllerInit (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Create IO completion queue fail, Status - %r\n", __FUNCTION__, Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = NvmeCreateIoSubmissionQueue (Private);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Create IO submission queue fail, Status - %r\n", __FUNCTION__, Status));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user