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;
|
||||
}
|
||||
|
||||
@ -168,7 +168,8 @@ GetLineWidth (
|
||||
(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
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
//
|
||||
@ -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);
|
||||
}
|
||||
@ -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
|
||||
|
||||
|
@ -209,6 +209,7 @@ WriteFileFromBuffer (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (FileInfo);
|
||||
|
||||
//
|
||||
@ -229,4 +230,3 @@ WriteFileFromBuffer (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ CreateBmpFmp (
|
||||
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);
|
||||
@ -63,6 +64,7 @@ CreateBmpFmp (
|
||||
Print (L"CapsuleApp: NO output capsule name.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
OutputCapsuleName = Argv[4];
|
||||
|
||||
BmpBuffer = NULL;
|
||||
@ -89,9 +91,11 @@ CreateBmpFmp (
|
||||
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);
|
||||
|
||||
if (Height > Info->VerticalResolution) {
|
||||
@ -99,6 +103,7 @@ CreateBmpFmp (
|
||||
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);
|
||||
@ -140,7 +145,8 @@ 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
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -311,6 +321,7 @@ CreateNestedFmp (
|
||||
Print (L"CapsuleApp: NO output capsule name.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
OutputCapsuleName = Argv[4];
|
||||
|
||||
CapsuleBuffer = NULL;
|
||||
@ -323,6 +334,7 @@ CreateNestedFmp (
|
||||
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);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
@ -341,6 +353,7 @@ CreateNestedFmp (
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
FwType = GetEsrtFwType (ImageTypeId);
|
||||
if ((FwType != ESRT_FW_TYPE_SYSTEMFIRMWARE) && (FwType != ESRT_FW_TYPE_DEVICEFIRMWARE)) {
|
||||
Print (L"CapsuleApp: Capsule FwType is invalid.\n");
|
||||
@ -380,7 +393,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clear capsule status variable.
|
||||
|
||||
@ -418,6 +430,7 @@ ClearCapsuleStatusVariable (
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
Found = TRUE;
|
||||
|
||||
Print (L"Clear %s %r\n", CapsuleVarName, Status);
|
||||
@ -524,6 +537,7 @@ 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);
|
||||
@ -747,38 +761,47 @@ UefiMain (
|
||||
Print (L"Please use UEFI SHELL to run this application!\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Argc < 2) {
|
||||
PrintUsage ();
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (StrCmp (Argv[1], L"-D") == 0) {
|
||||
if (Argc != 3) {
|
||||
Print (L"CapsuleApp: Incorrect parameter count.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Status = DumpCapsule (Argv[2]);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (StrCmp (Argv[1], L"-G") == 0) {
|
||||
Status = CreateBmpFmp ();
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (StrCmp (Argv[1], L"-N") == 0) {
|
||||
Status = CreateNestedFmp ();
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (StrCmp (Argv[1], L"-S") == 0) {
|
||||
Status = DumpCapsuleStatusVariable ();
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (StrCmp (Argv[1], L"-C") == 0) {
|
||||
Status = ClearCapsuleStatusVariable ();
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (StrCmp (Argv[1], L"-P") == 0) {
|
||||
if (Argc == 2) {
|
||||
DumpFmpData ();
|
||||
}
|
||||
|
||||
if (Argc >= 3) {
|
||||
if (StrCmp (Argv[2], L"GET") != 0) {
|
||||
Print (L"CapsuleApp: Unrecognized option(%s).\n", Argv[2]);
|
||||
@ -797,14 +820,17 @@ 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");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
DumpFmpImage (&ImageTypeId, ImageIndex, Argv[6]);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -814,11 +840,12 @@ UefiMain (
|
||||
}
|
||||
|
||||
if (StrCmp (Argv[1], L"-L") == 0) {
|
||||
if (Argc >= 3 && StrCmp(Argv[2], L"INFO") == 0) {
|
||||
if ((Argc >= 3) && (StrCmp (Argv[2], L"INFO") == 0)) {
|
||||
DumpProvisionedCapsule (TRUE);
|
||||
} else {
|
||||
DumpProvisionedCapsule (FALSE);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -889,6 +916,7 @@ UefiMain (
|
||||
Print (L"CapsuleApp: NO capsule image.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (CapsuleNum > MAX_CAPSULE_NUM) {
|
||||
Print (L"CapsuleApp: Too many capsule images.\n");
|
||||
return EFI_UNSUPPORTED;
|
||||
@ -905,10 +933,12 @@ UefiMain (
|
||||
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);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
CapsuleNames[Index] = CapsuleName;
|
||||
}
|
||||
|
||||
@ -930,6 +960,7 @@ UefiMain (
|
||||
NeedReset = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
CapsuleHeaderArray[CapsuleNum] = NULL;
|
||||
|
||||
//
|
||||
@ -975,6 +1006,7 @@ UefiMain (
|
||||
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.
|
||||
|
@ -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,6 +37,7 @@ DumpUxCapsule (
|
||||
)
|
||||
{
|
||||
EFI_DISPLAY_CAPSULE *DisplayCapsule;
|
||||
|
||||
DisplayCapsule = (EFI_DISPLAY_CAPSULE *)CapsuleHeader;
|
||||
Print (L"[UxCapsule]\n");
|
||||
Print (L"CapsuleHeader:\n");
|
||||
@ -53,7 +54,6 @@ DumpUxCapsule (
|
||||
Print (L" OffsetY - 0x%x\n", DisplayCapsule->ImagePayload.OffsetY);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Dump a non-nested FMP capsule.
|
||||
|
||||
@ -155,9 +155,11 @@ IsNestedFmpCapsule (
|
||||
if (NestedCapsuleSize < sizeof (EFI_CAPSULE_HEADER)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!CompareGuid (&NestedCapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -185,6 +187,7 @@ DumpCapsule (
|
||||
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);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
@ -201,6 +204,7 @@ DumpCapsule (
|
||||
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gEfiFmpCapsuleGuid)) {
|
||||
DumpFmpCapsule (CapsuleHeader);
|
||||
}
|
||||
|
||||
if (IsNestedFmpCapsule (CapsuleHeader)) {
|
||||
Print (L"[NestedCapsule]\n");
|
||||
Print (L"CapsuleHeader:\n");
|
||||
@ -215,6 +219,7 @@ Done:
|
||||
if (Buffer != NULL) {
|
||||
FreePool (Buffer);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -254,6 +259,7 @@ DumpCapsuleStatusVariable (
|
||||
Print (L"CapsuleMax - %s\n", CapsuleIndexData);
|
||||
FreePool (CapsuleIndex);
|
||||
}
|
||||
|
||||
Status = GetVariable2 (
|
||||
L"CapsuleLast",
|
||||
&gEfiCapsuleReportGuid,
|
||||
@ -268,7 +274,6 @@ DumpCapsuleStatusVariable (
|
||||
FreePool (CapsuleIndex);
|
||||
}
|
||||
|
||||
|
||||
StrCpyS (CapsuleVarName, sizeof (CapsuleVarName)/sizeof (CapsuleVarName[0]), L"Capsule");
|
||||
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
|
||||
Index = 0;
|
||||
@ -287,6 +292,7 @@ DumpCapsuleStatusVariable (
|
||||
} else if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSERT (CapsuleResult != NULL);
|
||||
|
||||
//
|
||||
@ -451,11 +457,11 @@ DumpEsrtData (
|
||||
Print (L"ESRT - %r\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
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,7 +567,8 @@ PadStrInTail (
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; StrBuf[Index] != L'\0'; Index++);
|
||||
for (Index = 0; StrBuf[Index] != L'\0'; Index++) {
|
||||
}
|
||||
|
||||
while (PadLen != 0) {
|
||||
StrBuf[Index] = Character;
|
||||
@ -591,12 +600,13 @@ SplitFileNameExtension (
|
||||
UINTN StringLen;
|
||||
|
||||
StringLen = StrLen (FileName);
|
||||
for (Index = StringLen; Index > 0 && FileName[Index] != L'.'; Index--);
|
||||
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 {
|
||||
@ -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;
|
||||
}
|
||||
@ -842,6 +853,7 @@ Done:
|
||||
FreePool (FileInfoBuffer[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (FileInfoBuffer);
|
||||
}
|
||||
|
||||
@ -870,11 +882,13 @@ DumpBlockDescriptors (
|
||||
if (DumpCapsuleInfo) {
|
||||
Print (L"******************************************************\n");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
TempBlockPtr += 1;
|
||||
} else {
|
||||
if (TempBlockPtr->Union.ContinuationPointer == (UINTN)NULL) {
|
||||
@ -944,10 +958,11 @@ DumpProvisionedCapsule (
|
||||
(VOID **)&CapsuleDataPtr64,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status) || CapsuleDataPtr64 == NULL) {
|
||||
if (EFI_ERROR (Status) || (CapsuleDataPtr64 == NULL)) {
|
||||
if (Index == 0) {
|
||||
Print (L"No data.\n");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -968,7 +983,7 @@ DumpProvisionedCapsule (
|
||||
(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);
|
||||
@ -1057,11 +1072,13 @@ DumpFmpImageInfo (
|
||||
do {
|
||||
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
|
||||
//
|
||||
@ -1206,6 +1223,7 @@ DumpFmpData (
|
||||
if (PackageVersionName != NULL) {
|
||||
FreePool (PackageVersionName);
|
||||
}
|
||||
|
||||
FreePool (FmpImageInfoBuf);
|
||||
|
||||
//
|
||||
@ -1237,6 +1255,7 @@ DumpFmpData (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Print (L"\n");
|
||||
|
||||
EXIT:
|
||||
@ -1270,8 +1289,10 @@ IsThisFmpImageInfo (
|
||||
if (CompareGuid (&CurrentImageInfo->ImageTypeId, ImageTypeId)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CurrentImageInfo = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)((UINT8 *)CurrentImageInfo + DescriptorSize);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1374,11 +1395,13 @@ FindFmpFromImageTypeId (
|
||||
if (IsThisFmpImageInfo (FmpImageInfoBuf, FmpImageInfoCount, DescriptorSize, ImageTypeId)) {
|
||||
TargetFmp = Fmp;
|
||||
}
|
||||
|
||||
FreePool (FmpImageInfoBuf);
|
||||
if (TargetFmp != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (HandleBuffer);
|
||||
return TargetFmp;
|
||||
}
|
||||
|
@ -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,7 +127,7 @@ DumpAllEfiSysPartition (
|
||||
|
||||
ShellProtocol = GetShellProtocol ();
|
||||
if (ShellProtocol == NULL) {
|
||||
Print (L"Get Shell Protocol Fail\n");;
|
||||
Print (L"Get Shell Protocol Fail\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -344,6 +351,7 @@ GetEfiSysPartitionFromBootOptionFilePath (
|
||||
DEBUG ((DEBUG_INFO, "Full device path %s\n", DevicePathStr));
|
||||
FreePool (DevicePathStr);
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
Status = GetEfiSysPartitionFromDevPath (CurFullPath, &FsFullPath, Fs);
|
||||
@ -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 {
|
||||
@ -449,8 +457,9 @@ GetUpdateFileSystem (
|
||||
//
|
||||
BootOptionBuffer = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
|
||||
if ((BootOptionBuffer == NULL) ||
|
||||
(BootOptionCount == 0 && Map == 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;
|
||||
}
|
||||
|
||||
@ -478,6 +488,7 @@ GetUpdateFileSystem (
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO, "DevicePathToStr failed\n"));
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
Status = GetEfiSysPartitionFromBootOptionFilePath (DevicePath, &FullPath, Fs);
|
||||
@ -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);
|
||||
@ -533,7 +545,8 @@ GetUpdateFileSystem (
|
||||
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;
|
||||
@ -604,6 +617,7 @@ WriteUpdateFile (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@ -699,12 +713,13 @@ 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,
|
||||
|
@ -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
|
||||
@ -50,7 +48,6 @@ static CONST CHAR8 mHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '
|
||||
static UINTN Argc;
|
||||
static CHAR16 **Argv;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
This function parse application ARG.
|
||||
@ -162,7 +159,6 @@ DumpHex (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Safely append with automatic string resizing given length of Destination and
|
||||
desired length of copy from Source.
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -246,6 +242,7 @@ InternalStrnCatGrow (
|
||||
while (NewSize < (DestinationStartSize + (SourceLen*sizeof (CHAR16)))) {
|
||||
NewSize += 2 * SourceLen * sizeof (CHAR16);
|
||||
}
|
||||
|
||||
*Destination = ReallocatePool (*CurrentSize, NewSize, *Destination);
|
||||
*CurrentSize = NewSize;
|
||||
}
|
||||
@ -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.
|
||||
//
|
||||
@ -503,6 +512,7 @@ ProcessPcd (
|
||||
Print (L"%EError. %NNo matching PCD found: %s.\n", InputPcdName);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -607,4 +617,3 @@ DumpDynPcdMain (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -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;
|
||||
@ -346,15 +349,18 @@ ProfileActionToStr (
|
||||
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;
|
||||
}
|
||||
@ -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);
|
||||
@ -443,6 +450,7 @@ DumpMemoryProfileDriverInfo (
|
||||
if (DriverInfo->PdbStringOffset != 0) {
|
||||
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);
|
||||
@ -452,11 +460,13 @@ DumpMemoryProfileDriverInfo (
|
||||
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);
|
||||
@ -466,6 +476,7 @@ DumpMemoryProfileDriverInfo (
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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,11 +512,13 @@ 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);
|
||||
@ -516,6 +530,7 @@ DumpMemoryProfileContext (
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
@ -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);
|
||||
@ -603,6 +620,7 @@ 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);
|
||||
@ -649,10 +667,12 @@ ScanMemoryProfileBySignature (
|
||||
//
|
||||
return (VOID *)CommonHeader;
|
||||
}
|
||||
|
||||
if (CommonHeader->Length == 0) {
|
||||
ASSERT (FALSE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CommonHeader = (MEMORY_PROFILE_COMMON_HEADER *)((UINTN)CommonHeader + CommonHeader->Length);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -776,10 +798,12 @@ CreateAllocSummaryInfo (
|
||||
} else {
|
||||
AllocSummaryInfo->ActionString = NULL;
|
||||
}
|
||||
|
||||
AllocSummaryInfo->AllocateCount = 0;
|
||||
AllocSummaryInfo->TotalSize = 0;
|
||||
InsertTailList (DriverSummaryInfoData->AllocSummaryInfoList, &AllocSummaryInfoData->Link);
|
||||
}
|
||||
|
||||
AllocSummaryInfo = &AllocSummaryInfoData->AllocSummaryInfo;
|
||||
AllocSummaryInfo->AllocateCount++;
|
||||
AllocSummaryInfo->TotalSize += AllocInfo->Size;
|
||||
@ -815,6 +839,7 @@ CreateDriverSummaryInfo (
|
||||
if (DriverSummaryInfoData == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DriverSummaryInfoData->Signature = MEMORY_PROFILE_DRIVER_INFO_SIGNATURE;
|
||||
DriverSummaryInfoData->DriverInfo = DriverInfo;
|
||||
DriverSummaryInfoData->AllocSummaryInfoList = (LIST_ENTRY *)(DriverSummaryInfoData + 1);
|
||||
@ -828,6 +853,7 @@ CreateDriverSummaryInfo (
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (MEMORY_PROFILE_DRIVER_INFO *)AllocInfo;
|
||||
}
|
||||
|
||||
@ -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,
|
||||
@ -924,13 +951,15 @@ DumpContextSummaryData (
|
||||
} else {
|
||||
Print (L"\n");
|
||||
}
|
||||
|
||||
Print (L"Caller List:\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,6 +977,7 @@ DumpContextSummaryData (
|
||||
Print (L" (%a)\n", ProfileActionToStr (AllocSummaryInfo->Action, AllocSummaryInfo->ActionString, IsForSmm));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -975,7 +1006,8 @@ DestroyContextSummaryData (
|
||||
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,6 +1036,7 @@ DestroyContextSummaryData (
|
||||
RemoveEntryList (&DriverSummaryInfoData->Link);
|
||||
FreePool (DriverSummaryInfoData);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1069,7 +1103,6 @@ GetUefiMemoryProfileData (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
|
||||
Print (L"UefiMemoryProfileSize - 0x%x\n", Size);
|
||||
Print (L"======= UefiMemoryProfile begin =======\n");
|
||||
DumpMemoryProfile ((PHYSICAL_ADDRESS)(UINTN)Data, Size, FALSE);
|
||||
@ -1142,15 +1175,29 @@ 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,
|
||||
@ -1160,6 +1207,7 @@ GetSmramProfileData (
|
||||
DEBUG ((DEBUG_ERROR, "SmramProfile: Get PiSmmCommunicationRegionTable - %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (PiSmmCommunicationRegionTable != NULL);
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
|
||||
Size = 0;
|
||||
@ -1170,8 +1218,10 @@ GetSmramProfileData (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||
}
|
||||
|
||||
ASSERT (Index < PiSmmCommunicationRegionTable->NumberOfEntries);
|
||||
CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
|
||||
|
||||
@ -1201,6 +1251,7 @@ 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];
|
||||
@ -1274,6 +1325,7 @@ GetSmramProfileData (
|
||||
} else {
|
||||
CommGetProfileData->ProfileSize = (UINT64)(ProfileSize - CommGetProfileData->ProfileOffset);
|
||||
}
|
||||
|
||||
Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
@ -1282,10 +1334,10 @@ GetSmramProfileData (
|
||||
Print (L"GetProfileData - 0x%x\n", CommGetProfileData->Header.ReturnStatus);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -41,6 +41,7 @@ InternalDumpData (
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < Size; Index++) {
|
||||
Print (L"%02x", (UINTN)Data[Index]);
|
||||
if ((Index + 1) != Size) {
|
||||
@ -88,6 +89,7 @@ GetSmiHandlerProfileDatabase(
|
||||
Print (L"SmiHandlerProfile: Get PiSmmCommunicationRegionTable - %r\n", Status);
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (PiSmmCommunicationRegionTable != NULL);
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
|
||||
Size = 0;
|
||||
@ -98,8 +100,10 @@ GetSmiHandlerProfileDatabase(
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||
}
|
||||
|
||||
ASSERT (Index < PiSmmCommunicationRegionTable->NumberOfEntries);
|
||||
CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
|
||||
|
||||
@ -162,6 +166,7 @@ GetSmiHandlerProfileDatabase(
|
||||
} else {
|
||||
CommGetData->DataSize = (UINT64)(mSmiHandlerProfileDatabaseSize - CommGetData->DataOffset);
|
||||
}
|
||||
|
||||
Status = SmmCommunication->Communicate (SmmCommunication, CommBuffer, &CommSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
@ -171,6 +176,7 @@ GetSmiHandlerProfileDatabase(
|
||||
Print (L"SmiHandlerProfile: GetData - 0x%x\n", CommGetData->Header.ReturnStatus);
|
||||
return;
|
||||
}
|
||||
|
||||
CopyMem ((UINT8 *)mSmiHandlerProfileDatabase + Offset, (VOID *)(UINTN)CommGetData->DataBuffer, (UINTN)CommGetData->DataSize);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -345,6 +355,7 @@ DumpSmmLoadedImage(
|
||||
if (ImageStruct->EntryPoint != 0) {
|
||||
Print (L" EntryPoint=\"0x%lx\"", ImageStruct->EntryPoint);
|
||||
}
|
||||
|
||||
Print (L" FvFile=\"%g\"", &ImageStruct->FileGuid);
|
||||
Print (L" RefId=\"0x%x\"", ImageStruct->ImageRef);
|
||||
Print (L">\n");
|
||||
@ -352,6 +363,7 @@ DumpSmmLoadedImage(
|
||||
PdbString = (CHAR8 *)((UINTN)ImageStruct + ImageStruct->PdbStringOffset);
|
||||
Print (L" <Pdb>%a</Pdb>\n", PdbString);
|
||||
}
|
||||
|
||||
Print (L" </Image>\n");
|
||||
}
|
||||
|
||||
@ -382,7 +394,7 @@ 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);
|
||||
@ -407,7 +419,7 @@ 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);
|
||||
@ -432,7 +444,7 @@ 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);
|
||||
@ -457,7 +469,7 @@ 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);
|
||||
@ -483,7 +495,7 @@ 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);
|
||||
@ -508,7 +520,7 @@ 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);
|
||||
@ -588,12 +600,14 @@ DumpSmiHandler(
|
||||
if (!IsZeroGuid (&SmiStruct->HandlerType)) {
|
||||
Print (L" HandlerType=\"%g\"", &SmiStruct->HandlerType);
|
||||
}
|
||||
|
||||
Print (L">\n");
|
||||
for (Index = 0; Index < SmiStruct->HandlerCount; Index++) {
|
||||
Print (L" <SmiHandler");
|
||||
if (SmiHandlerStruct->ContextBufferSize != 0) {
|
||||
DumpSmiChildContext (&SmiStruct->HandlerType, (UINT8 *)SmiHandlerStruct + SmiHandlerStruct->ContextBufferOffset, SmiHandlerStruct->ContextBufferSize);
|
||||
}
|
||||
|
||||
Print (L">\n");
|
||||
ImageStruct = GetImageFromRef ((UINTN)SmiHandlerStruct->ImageRef);
|
||||
NameString = GetDriverNameString (ImageStruct);
|
||||
@ -601,22 +615,27 @@ DumpSmiHandler(
|
||||
if ((ImageStruct != NULL) && (ImageStruct->PdbStringOffset != 0)) {
|
||||
Print (L" <Pdb>%a</Pdb>\n", (UINT8 *)ImageStruct + ImageStruct->PdbStringOffset);
|
||||
}
|
||||
|
||||
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" </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" </Caller>\n", SmiHandlerStruct->Handler);
|
||||
SmiHandlerStruct = (VOID *)((UINTN)SmiHandlerStruct + SmiHandlerStruct->Length);
|
||||
Print (L" </SmiHandler>\n");
|
||||
}
|
||||
|
||||
Print (L" </SmiEntry>\n");
|
||||
}
|
||||
|
||||
SmiStruct = (VOID *)((UINTN)SmiStruct + SmiStruct->Header.Length);
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,8 @@ HII_VENDOR_DEVICE_PATH mFrontPageHiiVendorDevicePath = {
|
||||
//
|
||||
// {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,
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -253,6 +255,7 @@ InitializeFrontPage (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Locate Hii relative protocols
|
||||
//
|
||||
@ -353,6 +356,7 @@ FreeFrontPage(
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
gFrontPagePrivate.DriverHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
@ -401,6 +405,7 @@ ConvertProcessorToString (
|
||||
} else {
|
||||
FreqMhz = 0;
|
||||
}
|
||||
|
||||
DestMax = 0x20 / sizeof (CHAR16);
|
||||
StringBuffer = AllocateZeroPool (0x20);
|
||||
ASSERT (StringBuffer != NULL);
|
||||
@ -419,7 +424,6 @@ ConvertProcessorToString (
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert Memory Size to a string.
|
||||
|
||||
@ -492,7 +496,6 @@ GetOptionalStringByIndex (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Update the banner information for the Front Page based on Smbios information.
|
||||
@ -633,11 +636,17 @@ UpdateFrontPageBannerStrings (
|
||||
if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
//
|
||||
@ -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);
|
||||
}
|
||||
@ -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
|
||||
@ -1090,7 +1096,6 @@ SetupResetReminder (
|
||||
// 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_
|
||||
|
||||
|
@ -132,8 +132,10 @@ UiCustomizeFrontPageBanner (
|
||||
if (BannerStr != NULL) {
|
||||
FreePool (*BannerStr);
|
||||
}
|
||||
|
||||
*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;
|
||||
}
|
||||
|
||||
@ -345,10 +348,11 @@ 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],
|
||||
@ -373,6 +377,7 @@ UiCreateLanguageMenu (
|
||||
if (CurrentLang != NULL) {
|
||||
FreePool (CurrentLang);
|
||||
}
|
||||
|
||||
FreePool (Lang);
|
||||
|
||||
HiiCreateOneOfOpCode (
|
||||
@ -612,6 +617,7 @@ UiListThirdPartyDrivers (
|
||||
DriverListPtr[Count].EmptyLineAfter = EmptyLineAfter;
|
||||
}
|
||||
}
|
||||
|
||||
DriverListPtr[Count].PromptId = HiiSetString (HiiHandle, 0, String, NULL);
|
||||
FreePool (String);
|
||||
|
||||
@ -620,6 +626,7 @@ UiListThirdPartyDrivers (
|
||||
String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
|
||||
ASSERT (String != NULL);
|
||||
}
|
||||
|
||||
DriverListPtr[Count].HelpId = HiiSetString (HiiHandle, 0, String, NULL);
|
||||
FreePool (String);
|
||||
|
||||
|
@ -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
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
|
||||
|
@ -54,10 +54,12 @@ GetVariableStatisticsData (
|
||||
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;
|
||||
@ -109,6 +111,7 @@ PrintInfoFromSmm (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (PiSmmCommunicationRegionTable != NULL);
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
|
||||
Size = 0;
|
||||
@ -124,8 +127,10 @@ PrintInfoFromSmm (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
|
||||
}
|
||||
|
||||
ASSERT (CommBuffer != NULL);
|
||||
ZeroMem (CommBuffer, RealCommSize);
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -196,7 +195,6 @@ AhciWaitMmioSet (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (Delay > 0);
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -286,7 +284,6 @@ AhciWaitMemSet (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -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;
|
||||
@ -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
|
||||
@ -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;
|
||||
}
|
||||
@ -1303,6 +1304,7 @@ AhciCreateTransferDescriptor (
|
||||
if (MaxPortNumber == 0) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the number of ports that actually needed to be initialized.
|
||||
//
|
||||
@ -1321,6 +1323,7 @@ AhciCreateTransferDescriptor (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
|
||||
AhciRegisters->AhciRFis = Base;
|
||||
AhciRegisters->AhciRFisMap = Mapping;
|
||||
@ -1343,6 +1346,7 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
|
||||
AhciRegisters->AhciCmdList = Base;
|
||||
AhciRegisters->AhciCmdListMap = Mapping;
|
||||
@ -1364,6 +1368,7 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
ASSERT (DeviceAddress == ((EFI_PHYSICAL_ADDRESS)(UINTN)Base));
|
||||
AhciRegisters->AhciCmdTable = Base;
|
||||
AhciRegisters->AhciCmdTableMap = Mapping;
|
||||
@ -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,6 +1521,7 @@ IdentifyAtaDevice (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Invalid Capacity (0) for ATA device.\n", __FUNCTION__));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Media->LastBlock = (EFI_PEI_LBA)(Capacity - 1);
|
||||
|
||||
Media->BlockSize = 0x200;
|
||||
@ -1518,8 +1530,10 @@ 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) {
|
||||
//
|
||||
@ -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;
|
||||
}
|
||||
@ -1809,6 +1828,7 @@ AhciModeInitialization (
|
||||
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;
|
||||
@ -1919,7 +1943,8 @@ TransferAtaDevice (
|
||||
ASSERT ((UINTN)DeviceData->Lba48Bit < 2);
|
||||
ASSERT ((UINTN)IsWrite < 2);
|
||||
if (((UINTN)DeviceData->Lba48Bit >= 2) ||
|
||||
((UINTN) IsWrite >= 2)) {
|
||||
((UINTN)IsWrite >= 2))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1955,6 +1980,7 @@ TransferAtaDevice (
|
||||
Packet.InDataBuffer = Buffer;
|
||||
Packet.InTransferLength = TransferLength;
|
||||
}
|
||||
|
||||
Packet.Asb = NULL;
|
||||
Packet.Acb = &Acb;
|
||||
Packet.Protocol = mAtaPassThruCmdProtocols[IsWrite];
|
||||
@ -2072,6 +2098,7 @@ TrustTransferAtaDevice (
|
||||
} else {
|
||||
Acb.AtaCommand = mAtaTrustCommands[IsTrustSend];
|
||||
}
|
||||
|
||||
Acb.AtaFeatures = SecurityProtocolId;
|
||||
Acb.AtaSectorCount = (UINT8)(TransferLength / 512);
|
||||
Acb.AtaSectorNumber = (UINT8)((TransferLength / 512) >> 8);
|
||||
@ -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,6 +2139,7 @@ TrustTransferAtaDevice (
|
||||
CopyMem (NewBuffer, Buffer, TransferLength);
|
||||
Buffer = NewBuffer;
|
||||
}
|
||||
|
||||
Packet.OutDataBuffer = Buffer;
|
||||
Packet.OutTransferLength = (UINT32)TransferLength;
|
||||
Packet.Protocol = mAtaPassThruCmdProtocols[IsTrustSend];
|
||||
@ -2119,6 +2148,7 @@ TrustTransferAtaDevice (
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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++;
|
||||
}
|
||||
|
@ -97,9 +97,13 @@ 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 (
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
(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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -168,7 +168,8 @@ 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);
|
||||
|
||||
//
|
||||
@ -183,7 +184,8 @@ AhciIsHcDevicePathValid (
|
||||
// Prevent touching memory beyond given DevicePathLength.
|
||||
//
|
||||
if ((UINTN)DevicePath - (UINTN)Start >
|
||||
DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
|
||||
DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,7 @@ IoMmuMap (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
switch (Operation) {
|
||||
case EdkiiIoMmuOperationBusMasterRead:
|
||||
case EdkiiIoMmuOperationBusMasterRead64:
|
||||
@ -100,6 +101,7 @@ IoMmuMap (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
@ -178,7 +178,6 @@ AhciWaitMmioSet (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -239,7 +238,6 @@ AhciWaitMemSet (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -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.
|
||||
|
||||
@ -447,8 +443,6 @@ AhciDisableFisReceive (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Build the command list, command table and prepare the fis receiver.
|
||||
|
||||
@ -564,7 +558,6 @@ AhciBuildCommand (
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtba = Data64.Uint32.Lower32;
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdCtbau = Data64.Uint32.Upper32;
|
||||
AhciRegisters->AhciCmdList[CommandSlotNumber].AhciCmdPmp = PortMultiplier;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -637,6 +630,7 @@ AhciWaitDeviceReady (
|
||||
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
|
||||
|
||||
@ -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,8 +780,9 @@ 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);
|
||||
if ((PortTfd & EFI_AHCI_PORT_TFD_ERR) != 0) {
|
||||
@ -836,6 +831,7 @@ AhciWaitUntilFisReceived (
|
||||
if (Status != EFI_NOT_READY) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
@ -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,
|
||||
@ -1588,7 +1589,6 @@ AhciStartCommand (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Do AHCI HBA reset.
|
||||
|
||||
@ -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,8 +1853,12 @@ 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;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -2124,6 +2130,7 @@ AhciPacketCommandExecute (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -2221,6 +2228,7 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Error5;
|
||||
}
|
||||
|
||||
AhciRegisters->AhciRFisPciAddr = (EFI_AHCI_RECEIVED_FIS *)(UINTN)AhciRFisPciAddr;
|
||||
|
||||
//
|
||||
@ -2276,6 +2284,7 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Error3;
|
||||
}
|
||||
|
||||
AhciRegisters->AhciCmdListPciAddr = (EFI_AHCI_COMMAND_LIST *)(UINTN)AhciCmdListPciAddr;
|
||||
|
||||
//
|
||||
@ -2332,6 +2341,7 @@ AhciCreateTransferDescriptor (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Error1;
|
||||
}
|
||||
|
||||
AhciRegisters->AhciCommandTablePciAddr = (EFI_AHCI_COMMAND_TABLE *)(UINTN)AhciCommandTablePciAddr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -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,10 +2528,21 @@ 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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -2785,9 +2857,11 @@ 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
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
@ -5,6 +5,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __ATA_HC_AHCI_MODE_H__
|
||||
#define __ATA_HC_AHCI_MODE_H__
|
||||
|
||||
@ -393,4 +394,3 @@ AhciStopCommand (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -274,6 +274,7 @@ AtaPassThruPassThruExecute (
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
break;
|
||||
case EfiAtaAhciMode:
|
||||
if (PortMultiplierPort == 0xFFFF) {
|
||||
@ -284,6 +285,7 @@ AtaPassThruPassThruExecute (
|
||||
//
|
||||
PortMultiplierPort = 0;
|
||||
}
|
||||
|
||||
switch (Protocol) {
|
||||
case EFI_ATA_PASS_THRU_PROTOCOL_ATA_NON_DATA:
|
||||
Status = AhciNonDataTransfer (
|
||||
@ -370,6 +372,7 @@ AtaPassThruPassThruExecute (
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -555,6 +558,7 @@ AtaAtapiPassThruSupported (
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the protocol because we don't use it here
|
||||
//
|
||||
@ -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
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -1207,6 +1224,7 @@ EnumerateAttachedDevice (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
break;
|
||||
case PCI_CLASS_MASS_STORAGE_SATADPA:
|
||||
//
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1679,6 +1703,7 @@ AtaPassThruBuildDevicePath (
|
||||
if (DevicePathNode == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
DevicePathNode->Atapi.PrimarySecondary = (UINT8)Port;
|
||||
DevicePathNode->Atapi.SlaveMaster = (UINT8)PortMultiplierPort;
|
||||
DevicePathNode->Atapi.Lun = 0;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -1763,7 +1788,8 @@ AtaPassThruGetDevice (
|
||||
((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 (SATA_DEVICE_PATH))))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -2088,6 +2115,7 @@ ExtScsiPassThruPassThru (
|
||||
//
|
||||
PortMultiplier = 0;
|
||||
}
|
||||
|
||||
Status = AhciPacketCommandExecute (Instance->PciIo, &Instance->AhciRegisters, Port, PortMultiplier, Packet);
|
||||
break;
|
||||
default:
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -2399,13 +2432,14 @@ 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
|
||||
//
|
||||
@ -2413,7 +2447,8 @@ ExtScsiPassThruGetTargetLun (
|
||||
((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 (SATA_DEVICE_PATH))))
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -2506,6 +2541,7 @@ ExtScsiPassThruResetTargetLun (
|
||||
if (Lun != 0) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// The layout of Target array:
|
||||
// ________________________________________________________________________
|
||||
@ -2568,7 +2604,7 @@ 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;
|
||||
}
|
||||
|
||||
@ -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__
|
||||
|
||||
@ -1296,4 +1297,3 @@ AtaPioDataInOut (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,6 @@ IdeWritePortWMultiple (
|
||||
Count,
|
||||
(UINT16 *)Buffer
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,7 +202,6 @@ IdeReadPortWMultiple (
|
||||
Count,
|
||||
(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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -444,7 +444,6 @@ DRQClear2 (
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (InfiniteWait || (Delay > 0));
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
@ -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
|
||||
@ -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.
|
||||
@ -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.
|
||||
|
||||
@ -764,8 +761,9 @@ 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;
|
||||
}
|
||||
|
||||
@ -794,8 +792,9 @@ 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;
|
||||
}
|
||||
|
||||
@ -820,7 +819,6 @@ GetIdeRegisterIoAddr (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send ATA Ext command into device with NON_DATA protocol.
|
||||
|
||||
@ -1171,6 +1169,7 @@ AtaUdmStatusWait (
|
||||
Status = EFI_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
@ -1329,6 +1328,7 @@ AtaUdmaInOut (
|
||||
//
|
||||
MicroSecondDelay (1000);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
//
|
||||
@ -1503,6 +1503,7 @@ AtaUdmaInOut (
|
||||
} else {
|
||||
RegisterValue &= ~((UINT8)BMIC_NREAD);
|
||||
}
|
||||
|
||||
IdeWritePortB (PciIo, IoPortForBmic, RegisterValue);
|
||||
|
||||
if (Task != NULL) {
|
||||
@ -1528,13 +1529,13 @@ AtaUdmaInOut (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Set START bit of BMIC register
|
||||
//
|
||||
RegisterValue = IdeReadPortB (PciIo, IoPortForBmic);
|
||||
RegisterValue |= BMIC_START;
|
||||
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
|
||||
//
|
||||
@ -1582,14 +1583,13 @@ 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);
|
||||
@ -1646,6 +1646,7 @@ AtaPacketReadPendingData (
|
||||
TempWordBuffer = IdeReadPortB (PciIo, IdeRegisters->AltOrDev);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1897,7 +1898,6 @@ AtaPacketCommandExecute (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the calculated Best transfer mode to a detected 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)
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sends out an ATA Identify Command to the specified device.
|
||||
|
||||
@ -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.
|
||||
@ -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
|
||||
//
|
||||
@ -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,7 +74,9 @@ ATA_DEVICE gAtaDeviceTemplate = {
|
||||
0, // Port
|
||||
0, // PortMultiplierPort
|
||||
{ 0, }, // Packet
|
||||
{{ 0}, }, // Acb
|
||||
{
|
||||
{ 0 },
|
||||
}, // Acb
|
||||
NULL, // Asb
|
||||
FALSE, // UdmaValid
|
||||
FALSE, // Lba48Bit
|
||||
@ -129,7 +131,6 @@ FreeAlignedBuffer (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release all the resources allocated for the ATA device.
|
||||
|
||||
@ -155,6 +156,7 @@ ReleaseAtaResources (
|
||||
if (AtaDevice->DevicePath != NULL) {
|
||||
FreePool (AtaDevice->DevicePath);
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
if (!IsListEmpty (&AtaDevice->AtaSubTaskList)) {
|
||||
//
|
||||
@ -162,7 +164,8 @@ ReleaseAtaResources (
|
||||
//
|
||||
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;
|
||||
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.
|
||||
|
||||
@ -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,6 +374,7 @@ RegisterAtaDevice (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Successfully Install Storage Security Protocol on the ATA device\n"));
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
@ -670,7 +675,6 @@ AtaBusDriverBindingSupported (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starts a device controller or a bus controller.
|
||||
|
||||
@ -780,7 +784,6 @@ AtaBusDriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
} else {
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
@ -826,9 +829,11 @@ AtaBusDriverBindingStart (
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
RegisterAtaDevice (AtaBusDriverData, Port, PortMultiplierPort);
|
||||
}
|
||||
}
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
} else if (!IsDevicePathEnd (RemainingDevicePath)) {
|
||||
Status = AtaPassThru->GetDevice (AtaPassThru, RemainingDevicePath, &Port, &PortMultiplierPort);
|
||||
@ -859,10 +864,8 @@ ErrorExit:
|
||||
);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stops a device controller or a bus controller.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -1120,7 +1120,6 @@ AtaBlockIoReadBlocks (
|
||||
return BlockIoReadWrite ((VOID *)This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, FALSE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@ -1154,7 +1153,6 @@ AtaBlockIoWriteBlocks (
|
||||
return BlockIoReadWrite ((VOID *)This, MediaId, Lba, NULL, BufferSize, Buffer, FALSE, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Flush the Block Device.
|
||||
|
||||
@ -1255,7 +1253,6 @@ AtaBlockIoReadBlocksEx (
|
||||
return BlockIoReadWrite ((VOID *)This, MediaId, Lba, Token, BufferSize, Buffer, TRUE, FALSE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@ -1292,7 +1289,6 @@ AtaBlockIoWriteBlocksEx (
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,6 @@ ResetAtaDevice (
|
||||
IN ATA_DEVICE *AtaDevice
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Discovers whether it is a valid ATA device.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -362,14 +357,17 @@ IdentifyAtaDevice (
|
||||
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));
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
@ -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 {
|
||||
@ -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);
|
||||
}
|
||||
@ -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;
|
||||
@ -943,6 +945,7 @@ EXIT:
|
||||
if (SubEvent != NULL) {
|
||||
gBS->CloseEvent (SubEvent);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
}
|
||||
}
|
||||
@ -1012,6 +1015,7 @@ TrustTransferAtaDevice (
|
||||
} else {
|
||||
Acb->AtaCommand = mAtaTrustCommands[AtaDevice->UdmaValid][IsTrustSend];
|
||||
}
|
||||
|
||||
Acb->AtaFeatures = SecurityProtocolId;
|
||||
Acb->AtaSectorCount = (UINT8)(TransferLength / 512);
|
||||
Acb->AtaSectorNumber = (UINT8)((TransferLength / 512) >> 8);
|
||||
@ -1046,6 +1050,7 @@ TrustTransferAtaDevice (
|
||||
FreePool (Buffer);
|
||||
Buffer = NewBuffer;
|
||||
}
|
||||
|
||||
Packet->OutDataBuffer = Buffer;
|
||||
Packet->OutTransferLength = (UINT32)TransferLength;
|
||||
Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];
|
||||
@ -1054,6 +1059,7 @@ TrustTransferAtaDevice (
|
||||
Packet->InTransferLength = (UINT32)TransferLength;
|
||||
Packet->Protocol = mAtaPassThruCmdProtocols[AtaDevice->UdmaValid][IsTrustSend];
|
||||
}
|
||||
|
||||
Packet->Length = EFI_ATA_PASS_THRU_LENGTH_BYTES;
|
||||
Packet->Timeout = Timeout;
|
||||
|
||||
@ -1063,5 +1069,6 @@ TrustTransferAtaDevice (
|
||||
*TransferLengthOut = Packet->InTransferLength;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mAtaBusControllerNameTabl
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -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,6 +203,7 @@ AtaBusComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the child context
|
||||
//
|
||||
@ -219,9 +218,11 @@ AtaBusComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);
|
||||
ControllerNameTable = AtaDevice->ControllerNameTable;
|
||||
}
|
||||
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
|
@ -66,7 +66,8 @@ VENDOR_DEVICE_PATH gVendorDevicePathTemplate = {
|
||||
(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 }
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
@ -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;
|
||||
} 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;
|
||||
}
|
||||
@ -442,16 +450,19 @@ 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;
|
||||
@ -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.
|
||||
//
|
||||
@ -735,7 +746,6 @@ Error:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stops a device controller or a bus controller.
|
||||
|
||||
@ -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,7 +895,8 @@ 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.
|
||||
@ -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
|
||||
@ -1048,7 +1065,6 @@ RegisterI2cDevice (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Queue an I2C transaction for execution on the I2C device.
|
||||
|
||||
@ -1373,7 +1389,6 @@ InitializeI2cBus(
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,10 @@ InitializeI2c(
|
||||
// Install driver model protocol(s).
|
||||
//
|
||||
Status = InitializeI2cHost (ImageHandle, SystemTable);
|
||||
if ( !EFI_ERROR ( Status ))
|
||||
{
|
||||
if ( !EFI_ERROR (Status)) {
|
||||
Status = InitializeI2cBus (ImageHandle, SystemTable);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -65,5 +65,6 @@ I2cUnload (
|
||||
if ( !EFI_ERROR (Status)) {
|
||||
Status = I2cHostUnload (ImageHandle);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -543,8 +543,8 @@ I2cHostDriverStop (
|
||||
//
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
if ( (!I2cHostContext->I2cBusConfigurationManagementPending)
|
||||
&& IsListEmpty (&I2cHostContext->RequestList)) {
|
||||
|
||||
&& IsListEmpty (&I2cHostContext->RequestList))
|
||||
{
|
||||
//
|
||||
// Remove the I2C host protocol
|
||||
//
|
||||
@ -842,6 +842,7 @@ I2cHostRequestEnable (
|
||||
//
|
||||
gBS->RestoreTPL (TplPrevious);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
@ -217,8 +219,10 @@ IsaBusDestroyChild (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ChildHandle,
|
||||
&gEfiIsaHcProtocolGuid, Private->IsaHc,
|
||||
&gEfiCallerIdGuid, Child,
|
||||
&gEfiIsaHcProtocolGuid,
|
||||
Private->IsaHc,
|
||||
&gEfiCallerIdGuid,
|
||||
Child,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -324,7 +328,8 @@ IsaBusDriverBindingStart (
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Controller,
|
||||
&gEfiIsaHcServiceBindingProtocolGuid, &Private->ServiceBinding,
|
||||
&gEfiIsaHcServiceBindingProtocolGuid,
|
||||
&Private->ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
@ -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
|
||||
//
|
||||
@ -156,7 +155,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponent
|
||||
"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,6 +318,7 @@ Ps2KeyboardComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the device context
|
||||
//
|
||||
|
@ -13,9 +13,7 @@ struct {
|
||||
UINT16 EfiScanCode;
|
||||
CHAR16 UnicodeChar;
|
||||
CHAR16 ShiftUnicodeChar;
|
||||
}
|
||||
ConvertKeyboardScanCodeToEfiKey[] = {
|
||||
|
||||
} ConvertKeyboardScanCodeToEfiKey[] = {
|
||||
{
|
||||
0x01, // Escape
|
||||
SCAN_ESC,
|
||||
@ -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
|
||||
//
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1191,6 +1194,7 @@ KeyGetchar (
|
||||
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:
|
||||
@ -1315,6 +1326,7 @@ KeyGetchar (
|
||||
ConsoleIn->ScrollLock = (BOOLEAN) !ConsoleIn->ScrollLock;
|
||||
UpdateStatusLights (ConsoleIn);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1334,8 +1346,9 @@ KeyGetchar (
|
||||
//
|
||||
if ((ConsoleIn->LeftCtrl || ConsoleIn->RightCtrl) &&
|
||||
(ConsoleIn->LeftAlt || ConsoleIn->RightAlt) &&
|
||||
ScanCode == SCANCODE_DELETE_MAKE
|
||||
) {
|
||||
(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') {
|
||||
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') {
|
||||
} 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,7 +1437,7 @@ 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;
|
||||
}
|
||||
@ -1503,6 +1519,7 @@ InitKeyboard (
|
||||
Status = KeyboardRead (ConsoleIn, &CommandByte);
|
||||
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"
|
||||
|
||||
/**
|
||||
@ -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,20 +286,22 @@ 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') {
|
||||
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') {
|
||||
} else if ((KeyData.Key.UnicodeChar >= L'A') && (KeyData.Key.UnicodeChar <= L'Z')) {
|
||||
KeyData.Key.UnicodeChar = (CHAR16)(KeyData.Key.UnicodeChar - L'A' + 1);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -613,7 +625,6 @@ Exit:
|
||||
//
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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.
|
||||
|
||||
@ -139,12 +140,13 @@ KbdControllerDriverSupported (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -214,6 +216,7 @@ KbdControllerDriverStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Report that the keyboard is being enabled
|
||||
//
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
//
|
||||
@ -423,11 +429,11 @@ PS2MouseGetPacket (
|
||||
if ((Packet[0] & 0x10) != 0) {
|
||||
RelativeMovementX = (INT16)(RelativeMovementX | 0xFF00);
|
||||
}
|
||||
|
||||
if ((Packet[0] & 0x20) != 0) {
|
||||
RelativeMovementY = (INT16)(RelativeMovementY | 0xFF00);
|
||||
}
|
||||
|
||||
|
||||
RButton = (UINT8)(Packet[0] & 0x2);
|
||||
LButton = (UINT8)(Packet[0] & 0x1);
|
||||
|
||||
@ -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
|
||||
|
||||
|
@ -26,7 +26,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentNam
|
||||
"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,6 +190,7 @@ Ps2MouseComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the device context
|
||||
//
|
||||
|
@ -69,8 +69,9 @@ PS2MouseDriverSupported (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -173,6 +174,7 @@ PS2MouseDriverStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Report that the keyboard is being enabled
|
||||
//
|
||||
@ -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.
|
||||
//
|
||||
@ -625,6 +630,7 @@ MouseReset (
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
@ -732,7 +738,6 @@ MouseWaitForInput (
|
||||
if (MouseDev->StateChanged) {
|
||||
gBS->SignalEvent (Event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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
|
||||
//
|
||||
@ -28,13 +27,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2 =
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = {
|
||||
{ "eng;en", L"Usb Ehci Driver" },
|
||||
{ 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,6 +188,7 @@ EhciComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the device context
|
||||
//
|
||||
@ -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"
|
||||
|
||||
//
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -399,7 +393,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets a feature for the specified root hub port.
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -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
|
||||
@ -1364,8 +1359,8 @@ 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))) {
|
||||
|
||||
|| ((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.
|
||||
|
||||
@ -1618,7 +1612,6 @@ EhcExitBootService (
|
||||
EhcResetHC (Ehc, EHC_RESET_TIMEOUT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starting the Usb EHCI Driver.
|
||||
|
||||
@ -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.
|
||||
@ -1824,6 +1822,7 @@ EhcDriverBindingStart (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
@ -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.
|
||||
@ -136,7 +133,6 @@ EhcIsDebugPortInUse (
|
||||
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:
|
||||
|
@ -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.
|
||||
|
||||
@ -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
|
||||
@ -484,7 +478,6 @@ EhcLinkQhToPeriod (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Unlink an interrupt queue head from the periodic
|
||||
schedule frame list.
|
||||
@ -542,7 +535,6 @@ EhcUnlinkQhFromPeriod (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check the URB's execution result and update the URB's
|
||||
result accordingly.
|
||||
@ -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
|
||||
@ -662,7 +652,6 @@ ON_EXIT:
|
||||
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.
|
||||
|
||||
@ -939,7 +926,6 @@ ON_ERROR:
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Update the queue head for next round of asynchronous transfer.
|
||||
|
||||
@ -1023,7 +1009,6 @@ EhcUpdateAsyncRequest (
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Interrupt transfer periodic check handler.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
@ -111,8 +110,6 @@ EhcCreateQtd (
|
||||
return Qtd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Initialize the queue head for interrupt transfer,
|
||||
that is, initialize the following three fields:
|
||||
@ -157,8 +154,6 @@ EhcInitIntQh (
|
||||
QhHw->CMask = QH_MICROFRAME_3 | QH_MICROFRAME_4 | QH_MICROFRAME_5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Allocate and initialize a EHCI queue head.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -511,7 +503,6 @@ ON_ERROR:
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a new URB and its associated QTD.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -263,7 +258,6 @@ UsbHcGetPciAddressForHostMem (
|
||||
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.
|
||||
|
||||
|
@ -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:
|
||||
@ -71,6 +72,7 @@ IoMmuMap (
|
||||
ASSERT (FALSE);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = IoMmu->SetAttribute (
|
||||
IoMmu,
|
||||
*Mapping,
|
||||
@ -86,6 +88,7 @@ IoMmuMap (
|
||||
*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;
|
||||
*DeviceAddress = HostPhyAddress;
|
||||
*Mapping = NULL;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -240,4 +246,3 @@ IoMmuInit (
|
||||
(VOID **)IoMmu
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -69,11 +69,9 @@ EhcWriteOpReg (
|
||||
IN UINT32 Data
|
||||
)
|
||||
{
|
||||
|
||||
ASSERT (Ehc->CapLen != 0);
|
||||
|
||||
MmioWrite32 (Ehc->UsbHostControllerBaseAddress + Ehc->CapLen + Offset, Data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -454,6 +452,7 @@ EhcInitHC (
|
||||
if (Ehc->PeriodFrame != NULL) {
|
||||
EhcFreeSched (Ehc);
|
||||
}
|
||||
|
||||
PageNumber = sizeof (PEI_URB)/PAGESIZE +1;
|
||||
Status = PeiServicesAllocatePages (
|
||||
EfiBootServicesCode,
|
||||
@ -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,7 +582,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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -1246,7 +1250,6 @@ EhcPeimEntry (
|
||||
|
||||
EhcDev->UsbHostControllerBaseAddress = (UINT32)BaseAddress;
|
||||
|
||||
|
||||
EhcDev->HcStructParams = EhcReadCapRegister (EhcDev, EHC_HCSPARAMS_OFFSET);
|
||||
EhcDev->HcCapParams = EhcReadCapRegister (EhcDev, EHC_HCCPARAMS_OFFSET);
|
||||
EhcDev->CapLen = EhcReadCapRegister (EhcDev, EHC_CAPLENGTH_OFFSET) & 0x0FF;
|
||||
@ -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.
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -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;
|
||||
}
|
||||
@ -460,4 +457,3 @@ EhcExecTransfer (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -214,6 +214,7 @@ EhcCreateQh (
|
||||
if (Ep->DevSpeed != EFI_USB_SPEED_HIGH) {
|
||||
QhHw->CtrlEp = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EHC_INT_TRANSFER_ASYNC:
|
||||
|
@ -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
|
||||
|
@ -46,6 +46,7 @@ UsbHcAllocMemBlock (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, PageNumber*EFI_PAGE_SIZE);
|
||||
|
||||
//
|
||||
@ -68,6 +69,7 @@ UsbHcAllocMemBlock (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, PageNumber*EFI_PAGE_SIZE);
|
||||
|
||||
Block->Bits = (UINT8 *)(UINTN)TempPtr;
|
||||
@ -82,6 +84,7 @@ UsbHcAllocMemBlock (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem (BufHost, Pages*EFI_PAGE_SIZE);
|
||||
|
||||
//
|
||||
@ -98,7 +101,6 @@ UsbHcAllocMemBlock (
|
||||
Block->Next = NULL;
|
||||
|
||||
return Block;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +166,6 @@ UsbHcAllocMemFromBlock (
|
||||
}
|
||||
|
||||
NEXT_BIT (Byte, Bit);
|
||||
|
||||
} else {
|
||||
NEXT_BIT (Byte, Bit);
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -321,6 +320,7 @@ UsbHcInitMemPool (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem ((VOID *)(UINTN)TempPtr, PageNumber*EFI_PAGE_SIZE);
|
||||
|
||||
Pool = (USBHC_MEM_POOL *)((UINTN)TempPtr);
|
||||
@ -425,6 +425,7 @@ UsbHcAllocateMem (
|
||||
} else {
|
||||
Pages = USBHC_MEM_DEFAULT_PAGES;
|
||||
}
|
||||
|
||||
NewBlock = UsbHcAllocMemBlock (Ehc, Pool, Pages);
|
||||
|
||||
if (NewBlock == NULL) {
|
||||
|
@ -66,7 +66,6 @@ typedef struct _USBHC_MEM_POOL {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
Calculate the corresponding pci bus address according to the Mem parameter.
|
||||
|
||||
|
@ -169,7 +169,7 @@ AtapiGetBlockDeviceMediaInfo (
|
||||
|
||||
AtapiBlkIoDev = NULL;
|
||||
|
||||
if (This == NULL || MediaInfo == NULL) {
|
||||
if ((This == NULL) || (MediaInfo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -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,6 +426,7 @@ AtapiGetBlockDeviceMediaInfo2 (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get media info from AtapiBlkIoDev
|
||||
//
|
||||
@ -503,7 +503,6 @@ AtapiReadBlocks2 (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enumerate Atapi devices.
|
||||
|
||||
@ -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;
|
||||
@ -781,6 +781,7 @@ CheckPowerMode (
|
||||
if (SectorCountValue != 0x55) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Send a "ATAPI TEST UNIT READY" command ... slow but accurate
|
||||
//
|
||||
@ -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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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,6 +1269,7 @@ 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
|
||||
@ -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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1471,9 +1471,11 @@ 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)
|
||||
@ -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))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
@ -1652,6 +1657,7 @@ Inquiry (
|
||||
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;
|
||||
@ -1908,7 +1904,6 @@ ResetDevice (
|
||||
HeadReg = AtapiBlkIoDev->IdeIoPortReg[Channel].Head;
|
||||
|
||||
if (Extensive) {
|
||||
|
||||
DevControl = 0;
|
||||
DevControl |= ATA_CTLREG_SRST;
|
||||
//
|
||||
@ -1940,7 +1935,6 @@ 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.
|
||||
@ -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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2012,7 +2006,6 @@ 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;
|
||||
|
||||
//
|
||||
@ -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,7 +2093,6 @@ ReadCapacity (
|
||||
ZeroMem (&FormatData, sizeof (FormatData));
|
||||
|
||||
if (MediaInfo->DeviceType == IdeCDROM) {
|
||||
|
||||
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
|
||||
Packet.Inquiry.opcode = ATA_CMD_READ_CAPACITY;
|
||||
Status = AtapiPacketCommandIn (
|
||||
@ -2111,7 +2103,6 @@ ReadCapacity (
|
||||
sizeof (ATAPI_READ_CAPACITY_DATA),
|
||||
ATAPITIMEOUT
|
||||
);
|
||||
|
||||
} else {
|
||||
//
|
||||
// DeviceType == IdeLS120
|
||||
@ -2130,9 +2121,7 @@ ReadCapacity (
|
||||
}
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
|
||||
if (MediaInfo->DeviceType == IdeCDROM) {
|
||||
|
||||
MediaInfo->LastBlock = ((UINT32)Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
|
||||
MediaInfo->MediaPresent = TRUE;
|
||||
//
|
||||
@ -2147,7 +2136,6 @@ ReadCapacity (
|
||||
}
|
||||
|
||||
if (MediaInfo->DeviceType == IdeLS120) {
|
||||
|
||||
if (FormatData.DesCode == 3) {
|
||||
MediaInfo->MediaPresent = FALSE;
|
||||
MediaInfo->LastBlock = 0;
|
||||
@ -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;
|
||||
@ -2232,12 +2217,12 @@ ReadSectors (
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
while (BlocksRemaining > 0) {
|
||||
|
||||
if (BlocksRemaining <= MaxBlock) {
|
||||
SectorCount = (UINT16)BlocksRemaining;
|
||||
} else {
|
||||
SectorCount = MaxBlock;
|
||||
}
|
||||
|
||||
//
|
||||
// fill the Packet data sturcture
|
||||
//
|
||||
@ -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')
|
||||
@ -106,7 +103,6 @@ typedef struct {
|
||||
#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
|
||||
|
||||
|
@ -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,6 +259,7 @@ PCheckDevice (
|
||||
if (Configuration == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the return value to NULL
|
||||
//
|
||||
@ -267,7 +267,6 @@ PCheckDevice (
|
||||
|
||||
ListPtr = mIncompatiblePciDeviceList;
|
||||
while (*ListPtr != LIST_END_TAG) {
|
||||
|
||||
Tag = *ListPtr;
|
||||
|
||||
switch (Tag) {
|
||||
@ -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
|
||||
@ -334,7 +335,6 @@ PCheckDevice (
|
||||
// according to the EFI_PCI_RESOUCE_DESCRIPTOR structure
|
||||
//
|
||||
for ( ; *ListPtr == DEVICE_RES_TAG;) {
|
||||
|
||||
Dsc = (EFI_PCI_RESOUCE_DESCRIPTOR *)(ListPtr + 1);
|
||||
|
||||
AcpiPtr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
|
||||
@ -342,7 +342,7 @@ PCheckDevice (
|
||||
AcpiPtr->ResType = (UINT8)Dsc->ResType;
|
||||
AcpiPtr->GenFlag = (UINT8)Dsc->GenFlag;
|
||||
AcpiPtr->SpecificFlag = (UINT8)Dsc->SpecificFlag;
|
||||
AcpiPtr->AddrSpaceGranularity = Dsc->AddrSpaceGranularity;;
|
||||
AcpiPtr->AddrSpaceGranularity = Dsc->AddrSpaceGranularity;
|
||||
AcpiPtr->AddrRangeMin = Dsc->AddrRangeMin;
|
||||
AcpiPtr->AddrRangeMax = Dsc->AddrRangeMax;
|
||||
AcpiPtr->AddrTranslationOffset = Dsc->AddrTranslationOffset;
|
||||
@ -351,6 +351,7 @@ PCheckDevice (
|
||||
ListPtr = ListPtr + 1 + ((sizeof (EFI_PCI_RESOUCE_DESCRIPTOR)) / sizeof (UINT64));
|
||||
AcpiPtr++;
|
||||
}
|
||||
|
||||
//
|
||||
// Put the checksum
|
||||
//
|
||||
@ -376,4 +377,3 @@ PCheckDevice (
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -73,10 +73,14 @@ 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;
|
||||
}
|
||||
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -225,6 +226,7 @@ PciIoMemRW (
|
||||
for ( ; Count > 0; Count--, Dst8 += DstStride, Src8 += SrcStride) {
|
||||
*Dst8 = *Src8;
|
||||
}
|
||||
|
||||
break;
|
||||
case EfiPciWidthUint16:
|
||||
Dst16 = (UINT16 *)Dst;
|
||||
@ -232,6 +234,7 @@ PciIoMemRW (
|
||||
for ( ; Count > 0; Count--, Dst16 += DstStride, Src16 += SrcStride) {
|
||||
*Dst16 = *Src16;
|
||||
}
|
||||
|
||||
break;
|
||||
case EfiPciWidthUint32:
|
||||
Dst32 = (UINT32 *)Dst;
|
||||
@ -239,6 +242,7 @@ PciIoMemRW (
|
||||
for ( ; Count > 0; Count--, Dst32 += DstStride, Src32 += SrcStride) {
|
||||
*Dst32 = *Src32;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -331,6 +335,7 @@ PciIoMemRead (
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -418,6 +423,7 @@ PciIoMemWrite (
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -551,7 +557,7 @@ PciIoPciRead (
|
||||
VOID *Address;
|
||||
UINTN Length;
|
||||
|
||||
if (Width < 0 || Width >= EfiPciIoWidthMaximum || Buffer == NULL) {
|
||||
if ((Width < 0) || (Width >= EfiPciIoWidthMaximum) || (Buffer == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -574,6 +580,7 @@ PciIoPciRead (
|
||||
|
||||
Count -= Length >> ((UINTN)Width & 0x3);
|
||||
}
|
||||
|
||||
return PciIoMemRW (Width, Count, 1, Buffer, 1, Address);
|
||||
}
|
||||
|
||||
@ -607,7 +614,7 @@ 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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -738,9 +747,9 @@ CoherentPciIoMap (
|
||||
// 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) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -882,6 +909,7 @@ CoherentPciIoAllocateBuffer (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*HostAddress = (VOID *)(UINTN)AllocAddress;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1028,15 +1057,22 @@ NonCoherentPciIoAllocateBuffer (
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1187,6 +1228,7 @@ NonCoherentPciIoMap (
|
||||
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,10 +1411,11 @@ 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;
|
||||
}
|
||||
|
||||
@ -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,7 +1550,7 @@ PciIoGetBarAttributes (
|
||||
EFI_ACPI_END_TAG_DESCRIPTOR *End;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (Supports == NULL && Resources == NULL) {
|
||||
if ((Supports == NULL) && (Resources == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1499,8 +1569,10 @@ 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;
|
||||
}
|
||||
@ -1513,6 +1585,7 @@ PciIoGetBarAttributes (
|
||||
|
||||
*Resources = Descriptor;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1550,7 +1623,7 @@ PciIoSetBarAttributes (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (Offset == NULL || Length == NULL) {
|
||||
if ((Offset == NULL) || (Length == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +198,7 @@ NvmExpressComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the child context
|
||||
//
|
||||
@ -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)
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ EnumerateNvmeDevNamespace (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Namespace
|
||||
//
|
||||
@ -315,9 +316,11 @@ Exit:
|
||||
if (EFI_ERROR (Status) && (Device != NULL) && (Device->DevicePath != NULL)) {
|
||||
FreePool (Device->DevicePath);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status) && (Device != NULL)) {
|
||||
FreePool (Device);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
@ -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,
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -853,7 +864,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starts a device controller or a bus controller.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -212,9 +212,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;
|
||||
}
|
||||
@ -290,9 +298,17 @@ NvmeWrite (
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -745,7 +761,8 @@ NvmeAsyncRead (
|
||||
if (Blocks > MaxTransferBlocks) {
|
||||
Status = AsyncReadSectors (
|
||||
Device,
|
||||
BlkIo2Req, (UINT64)(UINTN)Buffer,
|
||||
BlkIo2Req,
|
||||
(UINT64)(UINTN)Buffer,
|
||||
Lba,
|
||||
MaxTransferBlocks,
|
||||
FALSE
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
|
@ -177,8 +177,6 @@ ReadNvmeControllerStatus (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Write Nvm Express admin queue attributes register.
|
||||
|
||||
@ -220,7 +218,6 @@ WriteNvmeAdminQueueAttributes (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write Nvm Express admin submission queue base address register.
|
||||
|
||||
@ -262,8 +259,6 @@ WriteNvmeAdminSubmissionQueueBaseAddress (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Write Nvm Express admin completion queue base address register.
|
||||
|
||||
@ -731,6 +726,7 @@ NvmeControllerInit (
|
||||
NVME_ACQ Acq;
|
||||
UINT8 Sn[21];
|
||||
UINT8 Mn[41];
|
||||
|
||||
//
|
||||
// Save original PCI attributes and enable this controller.
|
||||
//
|
||||
@ -1023,7 +1019,8 @@ 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,
|
||||
@ -1035,6 +1032,7 @@ NvmeShutdownAllControllers (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (NvmePassThru);
|
||||
|
||||
//
|
||||
@ -1044,6 +1042,7 @@ NvmeShutdownAllControllers (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// The host should set the Shutdown Notification (CC.SHN) field to 01b
|
||||
// to indicate a normal shutdown operation.
|
||||
@ -1065,6 +1064,7 @@ NvmeShutdownAllControllers (
|
||||
DEBUG ((DEBUG_INFO, "NvmeShutdownController: shutdown processing is completed after %dms.\n", Index * 10));
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 10ms
|
||||
//
|
||||
|
@ -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:
|
||||
@ -271,6 +274,7 @@ NvmeCreatePrpList (
|
||||
DEBUG ((DEBUG_ERROR, "NvmeCreatePrpList: create PrpList failure!\n"));
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Fill all PRP lists except of last one.
|
||||
//
|
||||
@ -293,6 +297,7 @@ NvmeCreatePrpList (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fill last PRP list.
|
||||
//
|
||||
@ -309,7 +314,6 @@ EXIT:
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -676,24 +694,31 @@ NvmExpressPassThru (
|
||||
if (Packet->NvmeCmd->Flags & CDW2_VALID) {
|
||||
Sq->Rsvd2 = (UINT64)Packet->NvmeCmd->Cdw2;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW3_VALID) {
|
||||
Sq->Rsvd2 |= LShiftU64 ((UINT64)Packet->NvmeCmd->Cdw3, 32);
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW10_VALID) {
|
||||
Sq->Payload.Raw.Cdw10 = Packet->NvmeCmd->Cdw10;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW11_VALID) {
|
||||
Sq->Payload.Raw.Cdw11 = Packet->NvmeCmd->Cdw11;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW12_VALID) {
|
||||
Sq->Payload.Raw.Cdw12 = Packet->NvmeCmd->Cdw12;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW13_VALID) {
|
||||
Sq->Payload.Raw.Cdw13 = Packet->NvmeCmd->Cdw13;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW14_VALID) {
|
||||
Sq->Payload.Raw.Cdw14 = Packet->NvmeCmd->Cdw14;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW15_VALID) {
|
||||
Sq->Payload.Raw.Cdw15 = Packet->NvmeCmd->Cdw15;
|
||||
}
|
||||
@ -707,6 +732,7 @@ NvmExpressPassThru (
|
||||
} else {
|
||||
Private->SqTdbl[QueueId].Sqt ^= 1;
|
||||
}
|
||||
|
||||
Data = ReadUnaligned32 ((UINT32 *)&Private->SqTdbl[QueueId]);
|
||||
Status = PciIo->Mem.Write (
|
||||
PciIo,
|
||||
@ -792,6 +818,7 @@ NvmExpressPassThru (
|
||||
NvmeDumpStatus (Cq);
|
||||
DEBUG_CODE_END ();
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the Respose Queue entry for this command to the callers response buffer
|
||||
//
|
||||
@ -892,6 +919,7 @@ EXIT:
|
||||
if (TimerEvent != NULL) {
|
||||
gBS->CloseEvent (TimerEvent);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -167,7 +167,8 @@ 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);
|
||||
|
||||
//
|
||||
@ -182,7 +183,8 @@ NvmeIsHcDevicePathValid (
|
||||
// Prevent touching memory beyond given DevicePathLength.
|
||||
//
|
||||
if ((UINTN)DevicePath - (UINTN)Start >
|
||||
DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
|
||||
DevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,7 @@ IoMmuMap (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
switch (Operation) {
|
||||
case EdkiiIoMmuOperationBusMasterRead:
|
||||
case EdkiiIoMmuOperationBusMasterRead64:
|
||||
@ -100,6 +101,7 @@ IoMmuMap (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
@ -161,6 +161,7 @@ NvmeDiscoverNamespaces (
|
||||
//
|
||||
EnumerateNvmeDevNamespace (Private, NamespaceId);
|
||||
}
|
||||
|
||||
if (Private->ActiveNamespaceNum == 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -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,11 +337,14 @@ 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));
|
||||
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
|
||||
//
|
||||
|
@ -124,10 +124,11 @@ NvmeRead (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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));
|
||||
|
@ -51,7 +51,6 @@ enum {
|
||||
#define NVME_CQ_BASE(Private, Index) (ALIGN (NVME_MEM_BASE(Private) + ((NvmeBaseMemPageOffset (BASEMEM_CQ) + ((Index)*(NVME_MAX_QUEUES-1))) * EFI_PAGE_SIZE), EFI_PAGE_SIZE))
|
||||
#define NVME_PRP_BASE(Private) (ALIGN (NVME_MEM_BASE(Private) + ((NvmeBaseMemPageOffset (BASEMEM_PRP)) * EFI_PAGE_SIZE), EFI_PAGE_SIZE))
|
||||
|
||||
|
||||
/**
|
||||
Transfer MMIO Data to memory.
|
||||
|
||||
|
@ -62,6 +62,7 @@ NvmeCreatePrpList (
|
||||
));
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrpListHost = (VOID *)(UINTN)NVME_PRP_BASE (Private);
|
||||
|
||||
Bytes = EFI_PAGES_TO_SIZE (PrpListNo);
|
||||
@ -117,7 +118,7 @@ NvmeCheckCqStatus (
|
||||
IN NVME_CQ *Cq
|
||||
)
|
||||
{
|
||||
if (Cq->Sct == 0x0 && Cq->Sc == 0x0) {
|
||||
if ((Cq->Sct == 0x0) && (Cq->Sc == 0x0)) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -202,6 +203,7 @@ NvmeCheckCqStatus (
|
||||
DEBUG ((DEBUG_INFO, "Reservation Conflict\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x1:
|
||||
@ -264,6 +266,7 @@ NvmeCheckCqStatus (
|
||||
DEBUG ((DEBUG_INFO, "Attempted Write to Read Only Range\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x2:
|
||||
@ -290,6 +293,7 @@ NvmeCheckCqStatus (
|
||||
DEBUG ((DEBUG_INFO, "Access Denied\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -378,7 +382,7 @@ NvmePassThruExecute (
|
||||
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)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a, Invalid parameter: QueueId(%lx)\n",
|
||||
@ -413,7 +417,7 @@ NvmePassThruExecute (
|
||||
ZeroMem (Sq, sizeof (NVME_SQ));
|
||||
Sq->Opc = (UINT8)Packet->NvmeCmd->Cdw0.Opcode;
|
||||
Sq->Fuse = (UINT8)Packet->NvmeCmd->Cdw0.FusedOperation;
|
||||
Sq->Cid = Private->Cid[QueueId]++;;
|
||||
Sq->Cid = Private->Cid[QueueId]++;
|
||||
Sq->Nsid = Packet->NvmeCmd->Nsid;
|
||||
|
||||
//
|
||||
@ -436,7 +440,8 @@ NvmePassThruExecute (
|
||||
//
|
||||
if ((Sq->Opc & (BIT0 | BIT1)) != 0) {
|
||||
if (((Packet->TransferLength != 0) && (Packet->TransferBuffer == NULL)) ||
|
||||
((Packet->TransferLength == 0) && (Packet->TransferBuffer != NULL))) {
|
||||
((Packet->TransferLength == 0) && (Packet->TransferBuffer != NULL)))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -445,9 +450,11 @@ NvmePassThruExecute (
|
||||
// allocated internally by the driver.
|
||||
//
|
||||
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)))
|
||||
{
|
||||
if ((Packet->TransferBuffer != Private->SqBuffer[NVME_IO_QUEUE]) &&
|
||||
(Packet->TransferBuffer != Private->CqBuffer[NVME_IO_QUEUE])) {
|
||||
(Packet->TransferBuffer != Private->CqBuffer[NVME_IO_QUEUE]))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Does not support external IO queues creation request.\n",
|
||||
@ -494,6 +501,7 @@ NvmePassThruExecute (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Fail to map meta data buffer.\n", __FUNCTION__));
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
Sq->Mptr = PhyAddr;
|
||||
}
|
||||
}
|
||||
@ -521,7 +529,6 @@ NvmePassThruExecute (
|
||||
DEBUG ((DEBUG_ERROR, "%a: Create PRP list fail, Status - %r\n", __FUNCTION__, Status));
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
} else if ((Offset + Bytes) > EFI_PAGE_SIZE) {
|
||||
Sq->Prp[1] = (Sq->Prp[0] + EFI_PAGE_SIZE) & ~(EFI_PAGE_SIZE - 1);
|
||||
}
|
||||
@ -529,18 +536,23 @@ NvmePassThruExecute (
|
||||
if (Packet->NvmeCmd->Flags & CDW10_VALID) {
|
||||
Sq->Payload.Raw.Cdw10 = Packet->NvmeCmd->Cdw10;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW11_VALID) {
|
||||
Sq->Payload.Raw.Cdw11 = Packet->NvmeCmd->Cdw11;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW12_VALID) {
|
||||
Sq->Payload.Raw.Cdw12 = Packet->NvmeCmd->Cdw12;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW13_VALID) {
|
||||
Sq->Payload.Raw.Cdw13 = Packet->NvmeCmd->Cdw13;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW14_VALID) {
|
||||
Sq->Payload.Raw.Cdw14 = Packet->NvmeCmd->Cdw14;
|
||||
}
|
||||
|
||||
if (Packet->NvmeCmd->Flags & CDW15_VALID) {
|
||||
Sq->Payload.Raw.Cdw15 = Packet->NvmeCmd->Cdw15;
|
||||
}
|
||||
@ -552,6 +564,7 @@ NvmePassThruExecute (
|
||||
if (Private->SqTdbl[QueueId].Sqt == SqSize) {
|
||||
Private->SqTdbl[QueueId].Sqt = 0;
|
||||
}
|
||||
|
||||
Data32 = ReadUnaligned32 ((UINT32 *)&Private->SqTdbl[QueueId]);
|
||||
Status = NVME_SET_SQTDBL (Private, QueueId, &Data32);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -588,6 +601,7 @@ NvmePassThruExecute (
|
||||
//
|
||||
Status = EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@ -650,7 +664,7 @@ NvmePassThruGetDevicePath (
|
||||
{
|
||||
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || DevicePathLength == NULL || DevicePath == NULL) {
|
||||
if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -713,7 +727,7 @@ NvmePassThruGetNextNameSpace (
|
||||
UINT32 DeviceIndex;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (This == NULL || NamespaceId == NULL) {
|
||||
if ((This == NULL) || (NamespaceId == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -752,13 +766,13 @@ NvmePassThruGetNextNameSpace (
|
||||
*NamespaceId = Private->NamespaceInfo[DeviceIndex + 1].NamespaceId;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -803,7 +817,7 @@ NvmePassThru (
|
||||
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (This == NULL || Packet == NULL) {
|
||||
if ((This == NULL) || (Packet == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -812,7 +826,8 @@ NvmePassThru (
|
||||
// Check NamespaceId is valid or not.
|
||||
//
|
||||
if ((NamespaceId > Private->ControllerData->Nn) &&
|
||||
(NamespaceId != (UINT32) -1)) {
|
||||
(NamespaceId != (UINT32)-1))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -823,6 +838,4 @@ NvmePassThru (
|
||||
);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,6 @@
|
||||
#ifndef _NVM_EXPRESS_PEI_PASSTHRU_H_
|
||||
#define _NVM_EXPRESS_PEI_PASSTHRU_H_
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function only
|
||||
supports blocking execution of the command.
|
||||
|
@ -97,7 +97,8 @@ NvmeS3SkipThisController (
|
||||
DevicePathInst,
|
||||
HcDevicePath,
|
||||
HcDevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)
|
||||
) == 0) {
|
||||
) == 0)
|
||||
{
|
||||
Skip = FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ NvmeStorageSecurityGetDeviceNo (
|
||||
{
|
||||
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || NumberofDevices == NULL) {
|
||||
if ((This == NULL) || (NumberofDevices == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ NvmeStorageSecurityGetDevicePath (
|
||||
{
|
||||
PEI_NVME_CONTROLLER_PRIVATE_DATA *Private;
|
||||
|
||||
if (This == NULL || DevicePathLength == NULL || DevicePath == NULL) {
|
||||
if ((This == NULL) || (DevicePathLength == NULL) || (DevicePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPciBusComponentName2
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPciBusDriverNameTable[] = {
|
||||
{ "eng;en", (CHAR16 *)L"PCI Bus Driver" },
|
||||
{ NULL, NULL }
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user