Compare commits

..

25 Commits

Author SHA1 Message Date
f40dc199c2 Merge pull request #6 from system76/boot-uefi-only
Skip volumes that do not have an EFI volume
2020-01-27 15:47:07 -07:00
3f54e8f57a Skip volumes that do not have an EFI volume 2020-01-27 15:32:04 -07:00
55849a4a46 IntelFrameworkModulePkg/BdsDxe: Ensure forms have unique IDs 2020-01-24 19:13:51 -07:00
74f2015276 Expand HD paths when checking for invalid options 2020-01-24 19:13:51 -07:00
6dff36c9b2 Add PlatformBdsPreBoot to allow hooks immediately before booting an option 2020-01-24 18:50:48 -07:00
814c0fa862 Load firmware-smmstore driver 2020-01-24 18:50:48 -07:00
a05aa4aff0 Also ignore keysizes of 0 2020-01-24 18:50:48 -07:00
30c84e8277 Update numbering 2020-01-24 18:50:48 -07:00
2ba9869baa Prioritize Udf and ElTorito partition types over Mbr to fix ISO boots 2020-01-24 18:50:48 -07:00
826b9d30cf Add firmware version to front page 2020-01-24 18:50:48 -07:00
b0e7e3919f Add SPACE for recovery message 2020-01-24 18:50:48 -07:00
976842130a Revise key handling in boot phase
Add escape key handler as early as possible, and set timeout immediately
upon displaying splash.
2020-01-24 18:50:48 -07:00
52d5d1b2c5 Improve error output when boot option fails to load 2020-01-24 18:50:48 -07:00
7050fc3a26 Make it possible to delete SMMSTORE variable by appending it with size 0 2020-01-24 18:50:48 -07:00
0eca9e3c1a Replace Front Page with computer name 2020-01-24 18:43:52 -07:00
19304f2144 Edit strings 2020-01-24 18:43:52 -07:00
b062ed0c86 Make Change Boot Order the primary boot maintenance manager page 2020-01-24 18:32:19 -07:00
d9cf95c6a2 Remove cruft from boot options 2020-01-24 18:10:15 -07:00
75a5161506 Ignore DEBUG interrupt (happens on gaze14) 2020-01-24 18:10:09 -07:00
d193b18023 Increase size of buffer for DMI information 2020-01-24 18:10:04 -07:00
061df3962f Update serial port to use 2020-01-24 18:09:54 -07:00
f6e7c15556 Add Intel GOP driver 2020-01-24 18:09:45 -07:00
95fb70f34d Update logo 2020-01-24 18:09:37 -07:00
900debdeec Add System76 Setup menu 2020-01-24 18:09:31 -07:00
33006e4f4e Order NVMe devices first 2020-01-24 18:09:23 -07:00
35 changed files with 418 additions and 1015 deletions

View File

@ -1169,6 +1169,19 @@ InstallReadyToLock (
return;
}
static BOOLEAN ESCAPE_KEY_DETECTED = FALSE;
EFI_STATUS
EFIAPI
EscapeKeyNotify (
EFI_KEY_DATA *KeyData
)
{
DEBUG((DEBUG_INFO, "Detected escape key\n"));
ESCAPE_KEY_DETECTED = TRUE;
return EFI_SUCCESS;
}
VOID
EFIAPI
PlatformBdsPolicyBehavior (
@ -1198,9 +1211,13 @@ Returns:
--*/
{
EFI_STATUS Status;
UINT16 Timeout;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleTextInEx;
EFI_KEY_DATA EscapeKeyData;
EFI_HANDLE EscapeKeyHandle;
EFI_EVENT UserInputDurationTime;
EFI_EVENT Events[2];
UINTN Index;
UINT16 Timeout;
EFI_INPUT_KEY Key;
EFI_BOOT_MODE BootMode;
@ -1238,6 +1255,30 @@ Returns:
PlatformBdsNoConsoleAction ();
}
// Find simple text input extension protocol for console in
SimpleTextInEx = NULL;
Status = gBS->HandleProtocol(
gST->ConsoleInHandle,
&gEfiSimpleTextInputExProtocolGuid,
(VOID **) &SimpleTextInEx
);
// Register a handler for escape key
ESCAPE_KEY_DETECTED = FALSE;
if (SimpleTextInEx != NULL) {
EscapeKeyData.Key.ScanCode = SCAN_ESC;
EscapeKeyData.Key.UnicodeChar = 0;
EscapeKeyData.KeyState.KeyShiftState = 0;
EscapeKeyData.KeyState.KeyToggleState = 0;
Status = SimpleTextInEx->RegisterKeyNotify(
SimpleTextInEx,
&EscapeKeyData,
EscapeKeyNotify,
&EscapeKeyHandle
);
ASSERT (Status == EFI_SUCCESS);
}
//
// Perform some platform specific connect sequence
//
@ -1250,9 +1291,9 @@ Returns:
//
BdsLibConnectAll ();
//
// Create a 1s duration event to ensure user has enough input time to enter Setup
// Create a 2s duration event to ensure user has enough input time to enter Setup
//
Status = gBS->CreateEvent (
EVT_TIMER,
@ -1265,29 +1306,49 @@ Returns:
Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 20000000);
ASSERT (Status == EFI_SUCCESS);
//
// invoke SMM handler to put eMMC/SD devices into ACPI mode for OS
//
IoWrite8(0xb2, 0xcd);
// Connect all drivers, could be delayed
BdsLibConnectAll ();
//
// To give the User a chance to enter Setup here, if user set TimeOut is 0.
// BDS should still give user a chance to enter Setup
// Check whether the user input after the duration time has expired
//
gBS->WaitForEvent (1, &UserInputDurationTime, &Index);
gBS->CloseEvent (UserInputDurationTime);
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (!EFI_ERROR (Status)) {
//
// Enter Setup if user input
//
Timeout = 0xffff;
} else {
Timeout = 0;
// The escape key could have been pressed already
if (!ESCAPE_KEY_DETECTED) {
//
// To give the User a chance to enter Setup here, if user set TimeOut is 0.
// BDS should still give user a chance to enter Setup
// Check whether the user input after the duration time has expired
//
Events[0] = gST->ConIn->WaitForKey;
Events[1] = UserInputDurationTime;
gBS->WaitForEvent (2, Events, &Index);
}
gBS->CloseEvent (UserInputDurationTime);
if (SimpleTextInEx != NULL) {
// Remove escape key handler
Status = SimpleTextInEx->UnregisterKeyNotify(
SimpleTextInEx,
EscapeKeyHandle
);
ASSERT (Status == EFI_SUCCESS);
} else {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (!EFI_ERROR (Status)) {
//
// Enter Setup if user input
//
ESCAPE_KEY_DETECTED = TRUE;
}
}
if (ESCAPE_KEY_DETECTED) {
Timeout = 0xffff;
DEBUG((DEBUG_INFO, "Escape key detected, going to menu\n"));
// Clear pending keypresses if we are going to the menu
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
} else {
Timeout = 0;
}
BdsLibEnumerateAllBootOption (BootOptionList);
PlatformBdsEnterFrontPage (Timeout, FALSE);
//not run/reached if Timeout = 0xffff
@ -1296,6 +1357,42 @@ Returns:
}
VOID
EFIAPI
PlatformBdsPreBoot (
IN BDS_COMMON_OPTION *Option
)
{
EFI_STATUS Status;
EFI_EVENT UserInputDurationTime;
EFI_EVENT Events[2];
UINTN Index;
if (!ESCAPE_KEY_DETECTED) {
// Did not enter menu, return immediately
return;
}
// Clear screen before waiting for input
gST->ConOut->ClearScreen(gST->ConOut);
// Create a 1s duration event to ensure user has enough input time to provide a key to boot option
Status = gBS->CreateEvent (
EVT_TIMER,
0,
NULL,
NULL,
&UserInputDurationTime
);
ASSERT (Status == EFI_SUCCESS);
Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 10000000);
ASSERT (Status == EFI_SUCCESS);
Events[0] = gST->ConIn->WaitForKey;
Events[1] = UserInputDurationTime;
gBS->WaitForEvent (2, Events, &Index);
}
VOID
EFIAPI
PlatformBdsBootSuccess (
@ -1320,7 +1417,14 @@ Returns:
--*/
{
CHAR16 *TmpStr;
EFI_INPUT_KEY Key;
CHAR16 *TmpStr;
// Clear screen before showing success message
gST->ConOut->ClearScreen(gST->ConOut);
// Clear pending keypresses before showing success message
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
//
// If Boot returned with EFI_SUCCESS and there is not in the boot device
@ -1363,7 +1467,14 @@ Returns:
--*/
{
CHAR16 *TmpStr;
EFI_INPUT_KEY Key;
CHAR16 *TmpStr;
// Clear screen before showing fail message
gST->ConOut->ClearScreen(gST->ConOut);
// Clear pending keypresses before showing fail message
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
//
// If Boot returned with failed status then we need to pop up a UI and wait

View File

@ -42,7 +42,6 @@ Abstract:
#include <Library/UefiLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Library/IoLib.h>
#include <Protocol/PciIo.h>

View File

@ -110,9 +110,11 @@ INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 CorebootPayloadPkg/s76-smmstore/s76-smmstore.inf
!ifdef $(FIRMWARE_OPEN_FIRMWARE_SMMSTORE)
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 $(FIRMWARE_OPEN_FIRMWARE_SMMSTORE)
!endif
!endif
INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
@ -123,6 +125,12 @@ INF PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
!ifdef $(FIRMWARE_OPEN_FIRMWARE_SETUP)
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 $(FIRMWARE_OPEN_FIRMWARE_SETUP)
!endif
!endif
INF CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf
INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
@ -217,10 +225,26 @@ FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
SECTION RAW = CorebootPayloadPkg/Logo/Logo.bmp
}
!ifdef $(FIRMWARE_OPEN_GOP_POLICY)
# Add PlatformGopPolicy implementation
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 $(FIRMWARE_OPEN_GOP_POLICY)
!endif
!endif
!ifdef $(FIRMWARE_OPEN_GOP)
# Use IntelGopDriver binary
!if $(ARCH) == IA32
!else
INF RuleOverride=BINARY USE = X64 $(FIRMWARE_OPEN_GOP)
!endif
!else
#
# Framebuffer Gop
#
INF CorebootPayloadPkg/FbGop/FbGop.inf
!endif
################################################################################
#

View File

@ -293,19 +293,17 @@
[PcdsPatchableInModule.common]
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
!if $(TARGET) == DEBUG
!if $(SOURCE_DEBUG_ENABLE)
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
!else
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2B
!endif
!if $(SOURCE_DEBUG_ENABLE)
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
!else
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
!endif
#
# The following parameters are set by Library/PlatformHookLib
#
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3f8
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3e8
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE)
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1

View File

@ -294,19 +294,17 @@
[PcdsPatchableInModule.common]
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
!if $(TARGET) == DEBUG
!if $(SOURCE_DEBUG_ENABLE)
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
!else
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2B
!endif
!if $(SOURCE_DEBUG_ENABLE)
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
!else
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
!endif
#
# The following parameters are set by Library/PlatformHookLib
#
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3f8
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x3e8
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate|$(BAUD_RATE)
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 315 KiB

View File

@ -1,9 +0,0 @@
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = system76-firmware-smmstore
FILE_GUID = 764f0f8d-658b-4d32-a057-b44fb209512c
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
[Binaries.X64]
PE32|s76-smmstore.efi|*

View File

@ -91,6 +91,12 @@ PlatformBdsPolicyBehavior (
IN BASEM_MEMORY_TEST BaseMemoryTest
);
VOID
EFIAPI
PlatformBdsPreBoot (
IN BDS_COMMON_OPTION *Option
);
/**
Hook point for a user-provided function, for after a boot attempt fails.

View File

@ -2964,6 +2964,7 @@ BdsDeleteAllInvalidEfiBootOption (
UINTN Index2;
UINT16 BootOption[BOOT_OPTION_MAX_CHAR];
EFI_DEVICE_PATH_PROTOCOL *OptionDevicePath;
EFI_DEVICE_PATH_PROTOCOL *WorkingDevicePath;
UINT8 *TempPtr;
CHAR16 *Description;
BOOLEAN Corrupted;
@ -3018,6 +3019,24 @@ BdsDeleteAllInvalidEfiBootOption (
Index++;
continue;
}
//
// If it's Device Path that starts with a hard drive path, append it with the front part to compose a
// full device path
//
WorkingDevicePath = NULL;
if ((DevicePathType (OptionDevicePath) == MEDIA_DEVICE_PATH) &&
(DevicePathSubType (OptionDevicePath) == MEDIA_HARDDRIVE_DP)) {
WorkingDevicePath = BdsExpandPartitionPartialDevicePathToFull (
(HARDDRIVE_DEVICE_PATH *)OptionDevicePath
);
if (WorkingDevicePath != NULL) {
OptionDevicePath = WorkingDevicePath;
} else {
// Ensure unexpandable HD paths are removed
Corrupted = TRUE;
}
}
}
if (Corrupted || !BdsLibIsValidEFIBootOptDevicePathExt (OptionDevicePath, FALSE, Description)) {
@ -3139,6 +3158,7 @@ BdsLibEnumerateAllBootOption (
EFI_BLOCK_IO_PROTOCOL *BlkIo;
BOOLEAN Removable[2];
UINTN RemovableIndex;
UINTN DPTIndex;
UINTN Index;
UINTN NumOfLoadFileHandles;
EFI_HANDLE *LoadFileHandles;
@ -3234,6 +3254,7 @@ BdsLibEnumerateAllBootOption (
);
for (RemovableIndex = 0; RemovableIndex < 2; RemovableIndex++) {
for (DPTIndex = 0; DPTIndex < 2; DPTIndex++) {
for (Index = 0; Index < NumberBlockIoHandles; Index++) {
Status = gBS->HandleProtocol (
BlockIoHandles[Index],
@ -3256,6 +3277,22 @@ BdsLibEnumerateAllBootOption (
DevicePath = DevicePathFromHandle (BlockIoHandles[Index]);
DevicePathType = BdsGetBootTypeFromDevicePath (DevicePath);
//
// Skip devices that do not have an EFI volume
//
if (BdsLibGetBootableHandle (DevicePath) == NULL) {
continue;
}
// Do NVMe devices first, all others second
if (DPTIndex == 0) {
if (DevicePathType != BDS_EFI_MESSAGE_NVME_BOOT) {
continue;
}
} else if (DevicePathType == BDS_EFI_MESSAGE_NVME_BOOT) {
continue;
}
//
// get description for current block handle
//
@ -3266,7 +3303,7 @@ BdsLibEnumerateAllBootOption (
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"Floppy: %s", DevName);
} else if (FloppyNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)), FloppyNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)), FloppyNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_FLOPPY)));
}
@ -3283,7 +3320,7 @@ BdsLibEnumerateAllBootOption (
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"CD/DVD: %s", DevName);
} else if (CdromNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)), CdromNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)), CdromNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_CD_DVD)));
}
@ -3296,7 +3333,7 @@ BdsLibEnumerateAllBootOption (
UnicodeSPrint (Buffer, sizeof (Buffer), L"SATA: %s", DevName);
}
} else if (HarddriveNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)), HarddriveNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)), HarddriveNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_HARDDRIVE)));
}
@ -3310,7 +3347,7 @@ BdsLibEnumerateAllBootOption (
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"USB: %s", DevName);
} else if (UsbNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)), UsbNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)), UsbNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_USB)));
}
@ -3322,7 +3359,7 @@ BdsLibEnumerateAllBootOption (
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"SCSI: %s", DevName);
} else if (ScsiNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)), ScsiNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)), ScsiNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_SCSI)));
}
@ -3334,7 +3371,7 @@ BdsLibEnumerateAllBootOption (
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"eMMC: %s", DevName);
} else if (MiscNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI eMMC Device %d", MiscNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI eMMC Device %d", MiscNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI eMMC Device");
}
@ -3346,7 +3383,7 @@ BdsLibEnumerateAllBootOption (
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"SD: %s", DevName);
} else if (SdNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI SD Device %d", SdNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI SD Device %d", SdNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI SD Device");
}
@ -3358,7 +3395,7 @@ BdsLibEnumerateAllBootOption (
if (DevName != NULL) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"NVMe: %s", DevName);
} else if (NvmeNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI NVMe Device %d", NvmeNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI NVMe Device %d", NvmeNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"EFI NVMe Device");
}
@ -3376,6 +3413,7 @@ BdsLibEnumerateAllBootOption (
break;
}
}
}
}
if (NumberBlockIoHandles != 0) {
@ -3431,7 +3469,7 @@ BdsLibEnumerateAllBootOption (
BdsLibDeleteOptionFromHandle (FileSystemHandles[Index]);
} else {
if (NonBlockNumber != 0) {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)), NonBlockNumber);
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s %d", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)), NonBlockNumber + 1);
} else {
UnicodeSPrint (Buffer, sizeof (Buffer), L"%s", BdsLibGetStringById (STRING_TOKEN (STR_DESCRIPTION_NON_BLOCK)));
}

View File

@ -105,6 +105,8 @@ BdsBootDeviceSelect (
BOOLEAN BootNextExist;
LIST_ENTRY *LinkBootNext;
EFI_EVENT ConnectConInEvent;
UINTN Index;
EFI_INPUT_KEY Key;
//
// Got the latest boot option
@ -261,6 +263,8 @@ BdsBootDeviceSelect (
//
BdsSetConsoleMode (FALSE);
PlatformBdsPreBoot (BootOption);
//
// All the driver options should have been processed since
// now boot will be performed.
@ -273,6 +277,16 @@ BdsBootDeviceSelect (
BootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));
PlatformBdsBootFail (BootOption, Status, ExitData, ExitDataSize);
// Wait for key
gST->ConOut->OutputString (
gST->ConOut,
GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))
);
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
ASSERT_EFI_ERROR (Status);
ASSERT (Index == 0);
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
//
// Check the next boot option
//

View File

@ -26,6 +26,14 @@ formset
name = BmmData,
guid = BOOT_MAINT_FORMSET_GUID;
form formid = FORM_BOOT_CHG_ID,
title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);
label FORM_BOOT_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_MAIN_ID,
title = STRING_TOKEN(STR_FORM_MAIN_TITLE);
@ -74,14 +82,6 @@ formset
label LABEL_END;
endform;
form formid = FORM_BOOT_CHG_ID,
title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);
label FORM_BOOT_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_DRV_DEL_ID,
title = STRING_TOKEN(STR_FORM_DRV_DEL_TITLE);

View File

@ -232,7 +232,7 @@
#language fr-FR "Boot system from a file or device"
#string STR_OPTIONAL_DATA #language en-US "Input Optional Data"
#language fr-FR "Input Optional Data"
#string STR_CHANGE_ORDER #language en-US "Change the order"
#string STR_CHANGE_ORDER #language en-US "Change Boot Order"
#language fr-FR "Change the order"
#string STR_BOOT_LEGACY #language en-US "Boot Legacy System"
#language fr-FR "Boot Legacy System"

View File

@ -1483,7 +1483,8 @@ FormSetDispatcher (
EFI_BROWSER_ACTION_REQUEST ActionRequest;
while (TRUE) {
UpdatePageId (CallbackData, FORM_MAIN_ID);
UpdatePageId (CallbackData, FORM_BOOT_CHG_ID);
UpdatePageBody (FORM_BOOT_CHG_ID, CallbackData);
ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
Status = gFormBrowser2->SendForm (

View File

@ -203,6 +203,7 @@ CallBootManager (
CHAR16 *ExitData;
UINTN ExitDataSize;
EFI_STRING_ID Token;
UINTN Index;
EFI_INPUT_KEY Key;
CHAR16 *HelpString;
UINTN HelpSize;
@ -379,6 +380,8 @@ CallBootManager (
//
BdsSetConsoleMode (FALSE);
PlatformBdsPreBoot (gOption);
//
// parse the selected option
//
@ -390,10 +393,15 @@ CallBootManager (
} else {
gOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));
PlatformBdsBootFail (gOption, Status, ExitData, ExitDataSize);
// Wait for key
gST->ConOut->OutputString (
gST->ConOut,
GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))
);
gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
ASSERT_EFI_ERROR (Status);
ASSERT (Index == 0);
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
}
}

View File

@ -18,7 +18,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Bds.h"
#include "FrontPage.h"
#define BOOT_MANAGER_FORM_ID 0x1000
#define BOOT_MANAGER_FORM_ID 0x1030
#define LABEL_BOOT_OPTION 0x00
#define LABEL_BOOT_OPTION_END 0x01

View File

@ -18,7 +18,7 @@
#langdef en-US "English"
#langdef fr-FR "Français"
#string STR_BM_BANNER #language en-US "Boot Menu"
#string STR_BM_BANNER #language en-US "One Time Boot"
#language fr-FR "Boot Menu"
#string STR_HELP_FOOTER #language en-US "↑ and ↓ to change option, ENTER to select an option, ESC to exit"
#language fr-FR "↑ pour ↓ changer l'option, ENTRER choisir une option, ESC pour sortir"

View File

@ -15,7 +15,7 @@
#include <Guid/BdsHii.h>
#define BOOT_MANAGER_FORM_ID 0x1000
#define BOOT_MANAGER_FORM_ID 0x1030
#define LABEL_BOOT_OPTION 0x00
#define LABEL_BOOT_OPTION_END 0x01
@ -32,9 +32,9 @@ formset
form formid = BOOT_MANAGER_FORM_ID,
title = STRING_TOKEN(STR_BM_BANNER);
subtitle text = STRING_TOKEN(STR_LAST_STRING);
subtitle text = STRING_TOKEN(STR_BOOT_OPTION_BANNER);
subtitle text = STRING_TOKEN(STR_LAST_STRING);
// subtitle text = STRING_TOKEN(STR_LAST_STRING);
// subtitle text = STRING_TOKEN(STR_BOOT_OPTION_BANNER);
// subtitle text = STRING_TOKEN(STR_LAST_STRING);
//
// This is where we will dynamically add choices for the Boot Manager

View File

@ -737,8 +737,6 @@ GetDeviceNameFromProduct (
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 13");
} else if (!StrCmp(Product, L"Akali 360")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook Spin 13");
} else if (!StrCmp(Product, L"Aleena")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 315");
} else if (!StrCmp(Product, L"Atlas")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Google Pixelbook Go 2019");
} else if (!StrCmp(Product, L"Auron")) {
@ -753,18 +751,12 @@ GetDeviceNameFromProduct (
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 15 CB5-532");
} else if (!StrCmp(Product, L"Bard")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 715");
} else if (!StrCmp(Product, L"Barla")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook 11A G6 EE");
} else if (!StrCmp(Product, L"Buddy")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebase 24");
} else if (!StrCmp(Product, L"Butterfly")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Pavilion Chromebook 14");
} else if (!StrCmp(Product, L"Candy")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Chromebook 11 3120");
} else if (!StrCmp(Product, L"Careena")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"HP Chromebook 14");
} else if (!StrCmp(Product, L"Caroline")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Samsung Chromebook Pro");
} else if (!StrCmp(Product, L"Cave")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebook Flip C302");
} else if (!StrCmp(Product, L"Celes")) {
@ -795,8 +787,6 @@ GetDeviceNameFromProduct (
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"AMD StonyRidge Chromebook");
} else if (!StrCmp(Product, L"Guado")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Asus Chromebox 2 / CN62");
} else if (!StrCmp(Product, L"Kasumi")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 311");
} else if (!StrCmp(Product, L"Kefka")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Chromebook 11 3180/3189");
} else if (!StrCmp(Product, L"Kench")) {
@ -807,8 +797,8 @@ GetDeviceNameFromProduct (
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Acer Chromebook 14 for Work");
} else if (!StrCmp(Product, L"Leon")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Toshiba Chromebook");
} else if (!StrCmp(Product, L"Liara")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Lenovo 14e Chromebook");
} else if (!StrCmp(Product, L"Librem 13 v2")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Purism Librem 13 v2");
} else if (!StrCmp(Product, L"Lulu")) {
StrCatS (*DeviceName, 0x60 / sizeof (CHAR16), L"Dell Chromebook 13 7310");
} else if (!StrCmp(Product, L"Link")) {
@ -930,16 +920,16 @@ UpdateFrontPageStrings (
SmbiosTable = GetSmbiosTableFromType (EntryPoint, EFI_SMBIOS_TYPE_BIOS_INFORMATION , 0);
if (SmbiosTable.Raw == NULL) {
} else {
NewString3 = AllocateZeroPool (0x60);
NewString3 = AllocateZeroPool (0xC0);
StrIndex = SmbiosTable.Type0->BiosVersion;
Str2Index = SmbiosTable.Type0->BiosReleaseDate;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), StrIndex, &NewString);
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), Str2Index, &NewString2);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), L"FW: ");
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), L" ");
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString2);
StrCatS (NewString3, 0x80 / sizeof (CHAR16), L"Version: ");
StrCatS (NewString3, 0x80 / sizeof (CHAR16), NewString);
// StrCatS (NewString3, 0x80 / sizeof (CHAR16), L" ");
// StrCatS (NewString3, 0x80 / sizeof (CHAR16), NewString2);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString3, NULL);
FreePool (NewString);
@ -966,6 +956,16 @@ UpdateFrontPageStrings (
StrCatS (NewString3, 0x60 / sizeof (CHAR16), L" ");
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString);
}
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_TITLE);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString3, NULL);
FreePool (NewString);
NewString3 = AllocateZeroPool (0x60);
StrIndex = SmbiosTable.Type1->Version;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), StrIndex, &NewString);
StrCatS (NewString3, 0x60 / sizeof (CHAR16), L"Model: ");
StrCatS (NewString3, 0x60 / sizeof (CHAR16), NewString);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString3, NULL);
FreePool (NewString);

View File

@ -44,21 +44,21 @@
#language fr-FR "ACME® EFI BIOS Version 13.5 Release 1039.92"
#string STR_FRONT_PAGE_BANNER_3_LEFT #language en-US "Serial Number: 1Z123456789MARMAR (Need SMBIOS entries)"
#language fr-FR "Numéro de série: 1Z123456789MARMAR (Les entrées de SMBIOS de besoin)"
#string STR_CONTINUE_PROMPT #language en-US "Default Boot"
#string STR_CONTINUE_PROMPT #language en-US "Boot Default"
#language fr-FR "Default Boot"
#string STR_CONTINUE_HELP #language en-US "Boot the Default Selection"
#string STR_CONTINUE_HELP #language en-US "Boot the default entry"
#language fr-FR "Cette sélection dirigera le système pour continuer au charger de procédé"
#string STR_LANGUAGE_SELECT #language en-US "Select Language"
#language fr-FR "Choisir la Langue"
#string STR_LANGUAGE_SELECT_HELP #language en-US "This is the option one adjusts to change the language for the current system"
#language fr-FR "Ceci est l'option que celui ajuste changer la langue pour le système actuel"
#string STR_BOOT_MANAGER #language en-US "Boot Menu"
#string STR_BOOT_MANAGER #language en-US "One Time Boot"
#language fr-FR "Charger le Directeur"
#string STR_BOOT_MANAGER_HELP #language en-US "Show One-Time Boot Menu"
#string STR_BOOT_MANAGER_HELP #language en-US "Boot an entry one time"
#language fr-FR "Cette sélection vous prendra au Directeur de Botte"
#string STR_BOOT_MAINT_MANAGER #language en-US "Boot Manager"
#string STR_BOOT_MAINT_MANAGER #language en-US "Change Boot Order"
#language fr-FR "Directeur d'Entretien"
#string STR_BOOT_MAINT_MANAGER_HELP #language en-US "Change/Add/Remove Boot Menu Entries"
#string STR_BOOT_MAINT_MANAGER_HELP #language en-US "Change the order of boot entries"
#language fr-FR "Cette sélection vous prendra au Directeur d'Entretien"
#string STR_DEVICE_MANAGER #language en-US "Device Manager"
#language fr-FR "Directeur d'appareil"

View File

@ -45,25 +45,29 @@ formset
form formid = FRONT_PAGE_FORM_ID,
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE);
banner
title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL),
line 1,
align center;
subtitle text = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL);
subtitle text = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION);
subtitle text = STRING_TOKEN(STR_NULL_STRING);
banner
title = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION),
line 3,
align left;
//banner
// title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL),
// line 1,
// align center;
banner
title = STRING_TOKEN(STR_FRONT_PAGE_CPU_MODEL),
line 4,
align left;
//banner
// title = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION),
// line 3,
// align left;
banner
title = STRING_TOKEN(STR_FRONT_PAGE_MEMORY_SIZE),
line 5,
align left;
//banner
// title = STRING_TOKEN(STR_FRONT_PAGE_CPU_MODEL),
// line 4,
// align left;
//banner
// title = STRING_TOKEN(STR_FRONT_PAGE_MEMORY_SIZE),
// line 5,
// align left;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
@ -73,7 +77,7 @@ formset
flags = INTERACTIVE,
key = FRONT_PAGE_KEY_CONTINUE;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
//subtitle text = STRING_TOKEN(STR_NULL_STRING);
goto FRONT_PAGE_ITEM_THREE,
prompt = STRING_TOKEN(STR_BOOT_MANAGER),
@ -81,7 +85,7 @@ formset
flags = INTERACTIVE,
key = FRONT_PAGE_KEY_BOOT_MANAGER;
subtitle text = STRING_TOKEN(STR_NULL_STRING);
//subtitle text = STRING_TOKEN(STR_NULL_STRING);
goto FRONT_PAGE_ITEM_FIVE,
prompt = STRING_TOKEN(STR_BOOT_MAINT_MANAGER),

View File

@ -77,6 +77,8 @@ HotkeyBoot (
EFI_STATUS Status;
UINTN ExitDataSize;
CHAR16 *ExitData;
UINTN Index;
EFI_INPUT_KEY Key;
if (mHotkeyBootOption == NULL) {
return EFI_NOT_FOUND;
@ -89,6 +91,8 @@ HotkeyBoot (
//
gST->ConOut->Reset (gST->ConOut, FALSE);
PlatformBdsPreBoot (mHotkeyBootOption);
Status = BdsLibBootViaBootOption (mHotkeyBootOption, mHotkeyBootOption->DevicePath, &ExitDataSize, &ExitData);
if (EFI_ERROR (Status)) {
@ -97,6 +101,16 @@ HotkeyBoot (
//
mHotkeyBootOption->StatusString = GetStringById (STRING_TOKEN (STR_BOOT_FAILED));
PlatformBdsBootFail (mHotkeyBootOption, Status, ExitData, ExitDataSize);
// Wait for key
gST->ConOut->OutputString (
gST->ConOut,
GetStringById (STRING_TOKEN (STR_ANY_KEY_CONTINUE))
);
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
ASSERT_EFI_ERROR (Status);
ASSERT (Index == 0);
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
} else {
//
// Call platform action to indicate the boot success

View File

@ -339,7 +339,7 @@ Done:
PlatformBdsShowProgress (
Foreground,
Background,
L"Press ESC for Boot Options/Settings",
L"Press ESC for Boot Options/Settings, or SPACE for Pop!_OS Recovery",
Color,
100,
(UINTN) PreviousValue

210
MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c Normal file → Executable file
View File

@ -526,34 +526,15 @@ EmmcTuningClkForHs200 (
if (EFI_ERROR (Status)) {
return Status;
}
if(BhtHostPciSupport(PciIo)) {
//set data transfer with 4bit
Status = SdMmcHcSetBusWidth (PciIo, Slot, 4);
//enable hardware tuning
HostCtrl2 = (UINT8)(~0x10);
Status = SdMmcHcAndMmio (PciIo, Slot, 0x110,sizeof (HostCtrl2), &HostCtrl2);
Status = EmmcSendTuningBlk (PassThru, Slot, 4);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails with %r\n", Status));
return Status;
}
}
//
// Ask the device to send a sequence of tuning blocks till the tuning procedure is done.
//
Retry = 0;
do {
if(!BhtHostPciSupport(PciIo)) {
Status = EmmcSendTuningBlk (PassThru, Slot, BusWidth);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails with %r\n", Status));
return Status;
}
} else {
gBS->Stall(5000);
Status = EmmcSendTuningBlk (PassThru, Slot, BusWidth);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails with %r\n", Status));
return Status;
}
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, TRUE, sizeof (HostCtrl2), &HostCtrl2);
@ -566,10 +547,6 @@ EmmcTuningClkForHs200 (
}
if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
if(BhtHostPciSupport(PciIo)) {
//set data transfer with default
Status = SdMmcHcSetBusWidth (PciIo, Slot, BusWidth);
}
return EFI_SUCCESS;
}
} while (++Retry < 40);
@ -793,21 +770,10 @@ EmmcSwitchToHighSpeed (
Private = SD_MMC_HC_PRIVATE_FROM_THIS (PassThru);
DbgMsg("switch to HS mode %dMHz\n", ClockFreq);
Status = EmmcSwitchBusWidth (PciIo, PassThru, Slot, Rca, IsDdr, BusWidth);
if (EFI_ERROR (Status)) {
return Status;
}
if (BhtHostPciSupport(PciIo)) {
HsTiming = 1;
Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq);
if (EFI_ERROR (Status)) {
return Status;
}
}
//
// Set to Hight Speed timing
//
@ -830,10 +796,8 @@ EmmcSwitchToHighSpeed (
return Status;
}
if (!BhtHostPciSupport(PciIo)) {
HsTiming = 1;
Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq);
}
HsTiming = 1;
Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq);
return Status;
}
@ -873,8 +837,6 @@ EmmcSwitchToHS200 (
Private = SD_MMC_HC_PRIVATE_FROM_THIS (PassThru);
DbgMsg("switch to HS200 mode %dMHz\n", ClockFreq);
if ((BusWidth != 4) && (BusWidth != 8)) {
return EFI_INVALID_PARAMETER;
}
@ -883,15 +845,6 @@ EmmcSwitchToHS200 (
if (EFI_ERROR (Status)) {
return Status;
}
if (BhtHostPciSupport(PciIo)){
HsTiming = 2;
Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq);
if (EFI_ERROR (Status)) {
return Status;
}
}
//
// Set to HS200/SDR104 timing
//
@ -913,73 +866,31 @@ EmmcSwitchToHS200 (
//
// Wait Internal Clock Stable in the Clock Control register to be 1 before set SD Clock Enable bit
//
if (BhtHostPciSupport(PciIo)) {
Status = SdMmcHcWaitMmioSet (
PciIo,
Slot,
0x1cc,
sizeof (ClockCtrl),
BIT14,
BIT14,
SD_MMC_HC_GENERIC_TIMEOUT
Status = SdMmcHcWaitMmioSet (
PciIo,
Slot,
SD_MMC_HC_CLOCK_CTRL,
sizeof (ClockCtrl),
BIT1,
BIT1,
SD_MMC_HC_GENERIC_TIMEOUT
);
} else {
Status = SdMmcHcWaitMmioSet (
PciIo,
Slot,
SD_MMC_HC_CLOCK_CTRL,
sizeof (ClockCtrl),
BIT1,
BIT1,
SD_MMC_HC_GENERIC_TIMEOUT
);
}
if (EFI_ERROR (Status)) {
return Status;
}
if (BhtHostPciSupport(PciIo)) {
//Wait 2nd Card Detect debounce Finished by wait twice of debounce max time
UINT32 value32;
while (1) {
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof(value32), &value32);
if (((value32 >> 18) & 0x01) == ((value32 >> 16) & 0x01)) {
break;
}
}
}
//
// Set SD Clock Enable in the Clock Control register to 1
//
ClockCtrl = BIT2;
Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof (ClockCtrl), &ClockCtrl);
if (!BhtHostPciSupport(PciIo)) {
HsTiming = 2;
Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq);
if (EFI_ERROR (Status)) {
return Status;
}
} else {
Status = SdMmcHcWaitMmioSet (
PciIo,
Slot,
0x1cc,
sizeof (ClockCtrl),
BIT11,
BIT11,
SD_MMC_CLOCK_STABLE_TIMEOUT
);
if (EFI_ERROR(Status)) {
DbgMsg("Wait Clock Stable timeout, ClockFreq=%d\n", ClockFreq);
return Status;
}
HsTiming = 2;
Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing, ClockFreq);
if (EFI_ERROR (Status)) {
return Status;
}
Status = EmmcTuningClkForHs200 (PciIo, PassThru, Slot, BusWidth);
if (EFI_ERROR(Status)) {
DbgMsg("Emmc tuning failed\n");
}
return Status;
}
@ -1157,37 +1068,6 @@ EmmcSetBusMode (
DEBUG ((DEBUG_INFO, "EmmcSetBusMode: HsTiming %d ClockFreq %d BusWidth %d Ddr %a\n", HsTiming, ClockFreq, BusWidth, IsDdr ? "TRUE":"FALSE"));
if (BhtHostPciSupport(PciIo)) {
UINT8 EmmcVar;
UINTN EmmcVarSize;
Status = gRT->GetVariable (
L"EMMC_FORCE_CARD_MODE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (!EFI_ERROR(Status) && EmmcVar <= 2) {
if (EmmcVar == 2) {
HsTiming = 2;
IsDdr = FALSE;
ClockFreq = 200;
} else if (EmmcVar == 1) {
HsTiming = 2;
IsDdr = FALSE;
ClockFreq = 100;
} else {
HsTiming = 1;
IsDdr = FALSE;
ClockFreq = 52;
}
} else {
HsTiming = 1;
IsDdr = FALSE;
ClockFreq = 52;
}
}
if (HsTiming == 3) {
//
// Execute HS400 timing switch procedure
@ -1198,60 +1078,6 @@ EmmcSetBusMode (
// Execute HS200 timing switch procedure
//
Status = EmmcSwitchToHS200 (PciIo, PassThru, Slot, Rca, ClockFreq, BusWidth);
if (EFI_ERROR(Status)) {
if (BhtHostPciSupport(PciIo)) {
UINT32 val32;
UINT16 EmmcVar;
UINTN EmmcVarSize;
DbgMsg("switch to HS200 200MHZ failed, freq decrease to 100MHz\n");
#if !defined(HS100_ALLPASS_PHASE) || HS100_ALLPASS_PHASE > 10 || HS100_ALLPASS_PHASE < 0
#error "HS100_ALLPASS_PHASE is undefined or value is invalid"
#else
val32 = PciBhtRead32(PciIo, 0x300);
val32 &= 0xFF0FFFFF;
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_HS100_ALLPASS_PHASE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status) || EmmcVar > 10)
EmmcVar = HS100_ALLPASS_PHASE;
val32 |= (EmmcVar << 20);
PciBhtWrite32(PciIo, 0x300, 0x21000033 | val32);
#endif
ClockFreq = 100;
SdMmcHcRwMmio (PciIo, Slot, 0x3C, TRUE, sizeof(val32), &val32);
val32 &= ~BIT22;
SdMmcHcRwMmio (PciIo, Slot, 0x3C, FALSE, sizeof(val32), &val32);
val32 = (BIT26 | BIT25);
SdMmcHcOrMmio (PciIo, Slot, 0x2C, sizeof(val32), &val32);
Status = EmmcSwitchToHS200 (PciIo, PassThru, Slot, Rca, ClockFreq, BusWidth);
if (EFI_ERROR(Status)) {
if (((ExtCsd.DeviceType & BIT1) != 0) && (Private->Capability[Slot].HighSpeed != 0)) {
DbgMsg("switch to HS200 100MHZ failed, mode decrease to HS 50MHz\n");
HsTiming = 1;
IsDdr = FALSE;
ClockFreq = 52;
Status = EmmcSwitchToHighSpeed (PciIo, PassThru, Slot, Rca, ClockFreq, IsDdr, BusWidth);
} else if (((ExtCsd.DeviceType & BIT0) != 0) && (Private->Capability[Slot].HighSpeed != 0)) {
DbgMsg("switch to HS200 100MHZ failed, mode decrease to HS 25MHz\n");
HsTiming = 1;
IsDdr = FALSE;
ClockFreq = 26;
Status = EmmcSwitchToHighSpeed (PciIo, PassThru, Slot, Rca, ClockFreq, IsDdr, BusWidth);
} else {
DbgMsg("switch to HS200 100MHZ failed, but emmc chip didn't support hs mode\n");
}
}
}
}
} else {
//
// Execute High Speed timing switch procedure

View File

@ -295,13 +295,6 @@ SdMmcPciHcEnumerateDevice (
continue;
}
if (BhtHostPciSupport(Private->PciIo)) {
Status = SdMmcHcGetCapability (Private->PciIo, Slot, &Private->Capability[Slot]);
if (EFI_ERROR (Status)) {
continue;
}
}
Private->Slot[Slot].MediaPresent = TRUE;
Private->Slot[Slot].Initialized = TRUE;
RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof (CARD_TYPE_DETECT_ROUTINE);
@ -318,7 +311,6 @@ SdMmcPciHcEnumerateDevice (
// This card doesn't get initialized correctly.
//
if (Index == RoutineNum) {
DEBUG ((DEBUG_INFO, "Load driver failure\n"));
Private->Slot[Slot].Initialized = FALSE;
}
@ -538,8 +530,6 @@ SdMmcPciHcDriverBindingStart (
UINT32 RoutineNum;
BOOLEAN MediaPresent;
BOOLEAN Support64BitDma;
UINT16 IntStatus;
UINT32 value;
DEBUG ((DEBUG_INFO, "SdMmcPciHcDriverBindingStart: Start\n"));
@ -695,13 +685,6 @@ SdMmcPciHcDriverBindingStart (
continue;
}
if (BhtHostPciSupport(PciIo)) {
Status = SdMmcHcGetCapability (PciIo, Slot, &Private->Capability[Slot]);
if (EFI_ERROR (Status)) {
continue;
}
}
Private->Slot[Slot].MediaPresent = TRUE;
Private->Slot[Slot].Initialized = TRUE;
RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof (CARD_TYPE_DETECT_ROUTINE);
@ -718,52 +701,9 @@ SdMmcPciHcDriverBindingStart (
// This card doesn't get initialized correctly.
//
if (Index == RoutineNum) {
DEBUG ((DEBUG_INFO, "Load driver failure\n"));
Private->Slot[Slot].Initialized = FALSE;
}
}
if (BhtHostPciSupport(Private->PciIo)) {
DbgMsg("HOST_CLK_DRIVE_STRENGTH: 0x%x\n",HOST_CLK_DRIVE_STRENGTH);
DbgMsg("HOST_DAT_DRIVE_STRENGTH: 0x%x\n",HOST_DAT_DRIVE_STRENGTH);
DbgMsg("HS200_ALLPASS_PHASE: 0x%x\n",HS200_ALLPASS_PHASE);
DbgMsg("HS100_ALLPASS_PHASE: 0x%x\n",HS100_ALLPASS_PHASE);
SdMmcHcRwMmio (Private->PciIo,0,0x110,TRUE,sizeof (value),&value);
DbgMsg("0x110: 0x%x\n",value);
SdMmcHcRwMmio (Private->PciIo,0,0x114,TRUE,sizeof (value),&value);
DbgMsg("0x114: 0x%x\n",value);
SdMmcHcRwMmio (Private->PciIo,0,0x1a8,TRUE,sizeof (value),&value);
DbgMsg("MEM 1A8: 0x%x\n",value);
SdMmcHcRwMmio (Private->PciIo,0,0x1ac,TRUE,sizeof (value),&value);
DbgMsg("MEM 1AC: 0x%x\n",value);
SdMmcHcRwMmio (Private->PciIo,0,0x1B0,TRUE,sizeof (value),&value);
DbgMsg("MEM 1B0: 0x%x\n",value);
SdMmcHcRwMmio (Private->PciIo,0,0x1CC,TRUE,sizeof (value),&value);
DbgMsg("MEM 1CC: 0x%x\n",value);
DbgMsg(" - pcr 0x300 = 0x%08x\n", PciBhtRead32(Private->PciIo, 0x300));
DbgMsg(" - pcr 0x304 = 0x%08x\n", PciBhtRead32(Private->PciIo, 0x304));
DbgMsg(" - pcr 0x328 = 0x%08x\n", PciBhtRead32(Private->PciIo, 0x328));
DbgMsg(" - pcr 0x3e4 = 0x%08x\n", PciBhtRead32(Private->PciIo, 0x3e4));
SdMmcHcRwMmio (Private->PciIo,0,0x040,TRUE,sizeof (value),&value);
DbgMsg("0x40: 0x%x\n",value);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_PRESENT_STATE,TRUE,sizeof (value),&value);
DbgMsg("Present State: 0x%x\n",value);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_HOST_CTRL1,TRUE,sizeof (IntStatus),&IntStatus);
DbgMsg("Power&Host1: 0x%x\n",IntStatus);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_CLOCK_CTRL,TRUE,sizeof (IntStatus),&IntStatus);
DbgMsg("CLK: 0x%x\n",IntStatus);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_TIMEOUT_CTRL,TRUE,sizeof (IntStatus),&IntStatus);
DbgMsg("SWR&Timeout: 0x%x\n",IntStatus);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_NOR_INT_STS,TRUE,sizeof (value),&value);
DbgMsg("INR&IER: 0x%x\n",value);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_HOST_CTRL2,TRUE,sizeof (IntStatus),&IntStatus);
DbgMsg("Host2: 0x%x\n",IntStatus);
}
//
// Enable 64-bit DMA support in the PCI layer if this controller

View File

@ -25,7 +25,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiDriverEntryPoint.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiLib.h>
@ -39,8 +38,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/SdMmcOverride.h>
#include <Protocol/SdMmcPassThru.h>
#include <Guid/DebugMask.h>
#include "SdMmcPciHci.h"
extern EFI_COMPONENT_NAME_PROTOCOL gSdMmcPciHcComponentName;
@ -54,16 +51,10 @@ extern EDKII_SD_MMC_OVERRIDE *mOverride;
#define SD_MMC_HC_PRIVATE_FROM_THIS(a) \
CR(a, SD_MMC_HC_PRIVATE_DATA, PassThru, SD_MMC_HC_PRIVATE_SIGNATURE)
#define HOST_CLK_DRIVE_STRENGTH 2
#define HOST_DAT_DRIVE_STRENGTH 2
#define HS200_ALLPASS_PHASE 0
#define HS100_ALLPASS_PHASE 6
//
// Generic time out value, 1 microsecond as unit.
//
#define SD_MMC_HC_GENERIC_TIMEOUT 1 * 1000 * 1000
#define SD_MMC_CLOCK_STABLE_TIMEOUT 3 * 1000
//
// SD/MMC async transfer timer interval, set by experience.

View File

@ -18,12 +18,12 @@
##
[Defines]
INF_VERSION = 0x00010007
INF_VERSION = 0x00010005
BASE_NAME = SdMmcPciHcDxe
MODULE_UNI_FILE = SdMmcPciHcDxe.uni
FILE_GUID = 8E325979-3FE1-4927-AAE2-8F5C4BD2AF0D
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.5.4
VERSION_STRING = 1.0
ENTRY_POINT = InitializeSdMmcPciHcDxe
#
@ -67,9 +67,6 @@
gEfiPciIoProtocolGuid ## TO_START
gEfiSdMmcPassThruProtocolGuid ## BY_START
[Guids]
gEfiGenericVariableGuid
# [Event]
# EVENT_TYPE_PERIODIC_TIMER ## SOMETIMES_CONSUMES

View File

@ -17,9 +17,6 @@
#include "SdMmcPciHcDxe.h"
int g_deviceId = 0;
/**
Dump the content of SD/MMC host controller's Capability Register.
@ -1034,15 +1031,6 @@ SdMmcHcInitPowerVoltage (
// Set SD Bus Voltage Select and SD Bus Power fields in Power Control Register
//
Status = SdMmcHcPowerControl (PciIo, Slot, MaxVoltage);
if (BhtHostPciSupport(PciIo)){
// 1.8V signaling enable
HostCtrl2 = BIT3;
Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
gBS->Stall (5000);
if (EFI_ERROR (Status)) {
return Status;
}
}
return Status;
}
@ -1094,7 +1082,6 @@ SdMmcHcInitHost (
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
SD_MMC_HC_SLOT_CAP Capability;
UINT32 value32;
//
// Notify the SD/MMC override protocol that we are about to initialize
@ -1117,199 +1104,14 @@ SdMmcHcInitHost (
PciIo = Private->PciIo;
Capability = Private->Capability[Slot];
if (BhtHostPciSupport(PciIo)){
UINT8 CardMode;
UINT16 EmmcVar;
UINTN EmmcVarSize;
UINT64 Cap;
DbgMsg("find bht emmc chip\n");
//unlock PCR write protect
#ifdef DISABLE_L1_2
PciBhtAnd32(PciIo, 0xd0, ~(BIT31));
PciBhtAnd32(PciIo, 0x90, ~(BIT1 | BIT0));
value32 = PciBhtRead32(PciIo, 0xe0);
value32 &= ~(BIT31 | BIT30 | BIT29 | BIT28);
value32 |= (BIT29 | BIT28);
PciBhtWrite32(PciIo, 0xe0, value32);
value32 = PciBhtRead32(PciIo, 0xfc);
value32 &= ~(BIT19 | BIT18 | BIT17 | BIT16);
value32 |= (BIT19);
PciBhtWrite32(PciIo, 0xfc, value32);
value32 = PciBhtRead32(PciIo, 0x3f4);
value32 &= ~(BIT3 | BIT2 | BIT1 | BIT0);
value32 |= (BIT3 | BIT1);
PciBhtWrite32(PciIo, 0x3f4, value32);
value32 = PciBhtRead32(PciIo, 0x248);
value32 &= ~(BIT3 | BIT2 | BIT1 | BIT0);
value32 |= (BIT3 | BIT1);
PciBhtWrite32(PciIo, 0x248, value32);
value32 = PciBhtRead32(PciIo, 0x90);
value32 &= ~(BIT1 | BIT0);
value32 |= (BIT1);
PciBhtWrite32(PciIo, 0x90, value32);
#endif
/* FET on */
PciBhtOr32(PciIo, 0xEC, 0x3);
/* Led on */
//PciBhtAnd32(PciIo, 0x334, (UINT32)~BIT13);
PciBhtOr32(PciIo, 0xD4, BIT6);
/* Set 1.8v emmc signaling flag */
PciBhtOr32(PciIo, 0x308, BIT4);
/* Set 200MBaseClock */
value32 = PciBhtRead32(PciIo, 0x304);
value32 &= 0x0000FFFF;
value32 |= 0x25100000;
#if !defined(HOST_CLK_DRIVE_STRENGTH) || HOST_CLK_DRIVE_STRENGTH > 7 || HOST_CLK_DRIVE_STRENGTH < 0
#error "HOST_CMD_DRIVE_STRENGTH is undefined or value is invalid"
#else
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_CLK_DRIVER_STRENGTH",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status))
EmmcVar = HOST_CLK_DRIVE_STRENGTH;
value32 &= 0xFFFFFF8F;
value32 |= ((EmmcVar & 0x7) << 4);
#endif
#if !defined(HOST_DAT_DRIVE_STRENGTH) || HOST_DAT_DRIVE_STRENGTH > 7 || HOST_DAT_DRIVE_STRENGTH < 0
#error "HOST_DATA_DRIVE_STRENGTH is undefined or value is invalid"
#else
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_DATA_DRIVER_STRENGTH",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status))
EmmcVar = HOST_DAT_DRIVE_STRENGTH;
value32 &= 0xFFFFFFF1;
value32 |= ((EmmcVar & 0x7) << 1);
#endif
PciBhtWrite32(PciIo, 0x304, value32);
PciBhtOr32(PciIo, 0x3E4, BIT22);
EmmcVarSize = sizeof(CardMode);
Status = gRT->GetVariable (
L"EMMC_FORCE_CARD_MODE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&CardMode
);
if (EFI_ERROR(Status) || CardMode > 2) {
CardMode = 0;
}
if (CardMode == 1) {
#if !defined(HS100_ALLPASS_PHASE) || HS100_ALLPASS_PHASE > 10 || HS100_ALLPASS_PHASE < 0
#error "HS200_ALLPASS_PHASE is undefined or value is invalid"
#else
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_HS100_ALLPASS_PHASE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status) || EmmcVar > 10)
EmmcVar = HS100_ALLPASS_PHASE;
#endif
} else if (CardMode == 2) {
#if !defined(HS200_ALLPASS_PHASE) || HS200_ALLPASS_PHASE > 10 || HS200_ALLPASS_PHASE < 0
#error "HS200_ALLPASS_PHASE is undefined or value is invalid"
#else
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_HS200_ALLPASS_PHASE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status) || EmmcVar > 10)
EmmcVar = HS200_ALLPASS_PHASE;
}
#endif
value32 = 0x21000033 | (EmmcVar << 20);
PciBhtWrite32(PciIo, 0x300, value32);
//enable internal clk
value32 = BIT0;
Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL,sizeof(value32), &value32);
//reset pll start
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE, sizeof(value32), &value32);
value32 |= BIT12;
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, FALSE, sizeof(value32), &value32);
gBS->Stall(1);
//reset pll end
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE,sizeof(value32), &value32);
value32 &= ~BIT12;
value32 |= BIT18;
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, FALSE, sizeof(value32), &value32);
//wait BaseClk stable 0x1CC bit14
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE, sizeof(value32), &value32);
while(!(value32&BIT14)){
gBS->Stall(100);
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE, sizeof(value32), &value32);
DbgMsg("1CC=0x%08x\n", value32);
}
if (value32 & BIT18)
{
//Wait 2nd Card Detect debounce Finished by wait twice of debounce max time
while (1) {
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof(value32), &value32);
if (((value32 >> 16) & 0x01) == ((value32 >> 18) & 0x01))
break;
}
//force pll active end
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE, sizeof(value32), &value32);
value32 &= ~BIT18;
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, FALSE, sizeof(value32), &value32);
}
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_CAP, TRUE, sizeof (Cap), &Cap);
if (EFI_ERROR (Status)) {
return Status;
}
CopyMem (&Capability, &Cap, sizeof (Cap));
Status = SdMmcHcInitPowerVoltage (PciIo, Slot, Capability);
if (EFI_ERROR (Status)) {
DbgMsg("emmc host init failure\n");
return Status;
}
}
Status = SdMmcHcInitClockFreq (PciIo, Slot, Private->BaseClkFreq[Slot]);
if (EFI_ERROR (Status)) {
return Status;
}
if (!BhtHostPciSupport(PciIo)){
Status = SdMmcHcInitPowerVoltage (PciIo, Slot, Capability);
if (EFI_ERROR (Status)) {
return Status;
}
Status = SdMmcHcInitPowerVoltage (PciIo, Slot, Capability);
if (EFI_ERROR (Status)) {
return Status;
}
Status = SdMmcHcInitTimeoutCtrl (PciIo, Slot);
@ -2294,280 +2096,3 @@ SdMmcWaitTrbResult (
return EFI_TIMEOUT;
}
BOOLEAN BhtHostPciSupport(EFI_PCI_IO_PROTOCOL *PciIo)
{
PCI_TYPE00 Pci;
PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32,
0, sizeof Pci / sizeof (UINT32), &Pci);
DEBUG ((DEBUG_INFO, "check device %04x:%04x\n", Pci.Hdr.VendorId, Pci.Hdr.DeviceId));
if (Pci.Hdr.VendorId != 0x1217)
goto end;
switch (Pci.Hdr.DeviceId)
{
case 0x8420: //PCI_DEV_ID_SDS0
case 0x8421: //PCI_DEV_ID_SDS1
case 0x8520: //PCI_DEV_ID_FJ2
case 0x8620: //PCI_DEV_ID_SB0
case 0x8621: //PCI_DEV_ID_SB1
g_deviceId = Pci.Hdr.DeviceId;
return 1;
default:
break;
}
end:
return 0;
}
void DbgNull(IN CONST CHAR16 * fmt, ...)
{
}
UINT32 bht_readl(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset)
{
UINT32 arg;
PciIo->Mem.Read(PciIo,EfiPciIoWidthUint32,1,offset,1,&arg);
return arg;
}
void bht_writel(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value)
{
PciIo->Mem.Write(PciIo,EfiPciIoWidthUint32,1,offset,1,&value);
}
UINT32 PciBhtRead32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset)
{
UINT32 i = 0;
UINT32 tmp[3] = {0};
if((g_deviceId == PCI_DEV_ID_SDS0) ||
(g_deviceId == PCI_DEV_ID_SDS1) ||
(g_deviceId == PCI_DEV_ID_FJ2) ||
(g_deviceId == PCI_DEV_ID_SB0) ||
(g_deviceId == PCI_DEV_ID_SB1))
{
// For Sandstorm, HW implement a mapping method by memory space reg to access PCI reg.
// Enable mapping
// Check function conflict
if((g_deviceId == PCI_DEV_ID_SDS0) ||
(g_deviceId == PCI_DEV_ID_FJ2) ||
(g_deviceId == PCI_DEV_ID_SB0) ||
(g_deviceId == PCI_DEV_ID_SB1))
{
i = 0;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x40000000);
while((bht_readl(PciIo, BHT_PCIRMappingEn) & 0x40000000) == 0)
{
if(i == 5)
{
//DbgMsg((DRIVERNAME " - %s() function 0 can't lock!\n", __FUNCTION__));
goto RD_DIS_MAPPING;
}
gBS->Stall(1000);
i++;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x40000000);
}
}
else if(g_deviceId == PCI_DEV_ID_SDS1)
{
i = 0;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x20000000);
while((bht_readl(PciIo, BHT_PCIRMappingEn) & 0x20000000) == 0)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() function 1 can't lock!\n", __FUNCTION__));
goto RD_DIS_MAPPING;
}
gBS->Stall(1000);
i++;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x20000000);
}
}
// Check last operation is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0xc0000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - [204] = 0x%x\n", RegisterRead32(ELN_dPCIRMappingCtl)));
//DbgErr((DRIVERNAME " - [208] = 0x%x\n", RegisterRead32(ELN_dPCIRMappingEn)));
//DbgErr((DRIVERNAME " - %s() check last operation complete timeout!!!\n", __FUNCTION__));
goto RD_DIS_MAPPING;
}
gBS->Stall(1000);
i += 1;
}
// Set register address
tmp[0] |= 0x40000000;
tmp[0] |= offset;
bht_writel(PciIo, BHT_PCIRMappingCtl, tmp[0]);
// Check read is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0x40000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() check read operation complete timeout!!!\n", __FUNCTION__));
goto RD_DIS_MAPPING;
}
gBS->Stall(1000);
i += 1;
}
// Get PCIR value
tmp[1] = bht_readl(PciIo, BHT_PCIRMappingVal);
RD_DIS_MAPPING:
// Disable mapping
bht_writel(PciIo, BHT_PCIRMappingEn, 0x80000000);
//DbgDebug(L"%s offset=%x Value:%x\n", __FUNCTION__, offset, tmp[1]);
return tmp[1];
}
//DbgDebug(L"%s offset=%x Value:%x\n", __FUNCTION__, offset, tmp[0]);
return tmp[0];
}
void PciBhtWrite32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value)
{
UINT32 tmp = 0;
UINT32 i = 0;
if((g_deviceId == PCI_DEV_ID_SDS0) ||
(g_deviceId == PCI_DEV_ID_SDS1) ||
(g_deviceId == PCI_DEV_ID_FJ2) ||
(g_deviceId == PCI_DEV_ID_SB0) ||
(g_deviceId == PCI_DEV_ID_SB1))
{
// For Sandstorm, HW implement a mapping method by memory space reg to access PCI reg.
// Upper caller doesn't need to set 0xD0.
// Enable mapping
// Check function conflict
if((g_deviceId == PCI_DEV_ID_SDS0) ||
(g_deviceId == PCI_DEV_ID_FJ2) ||
(g_deviceId == PCI_DEV_ID_SB0) ||
(g_deviceId == PCI_DEV_ID_SB1))
{
i = 0;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x40000000);
while((bht_readl(PciIo, BHT_PCIRMappingEn) & 0x40000000) == 0)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() function 0 can't lock!\n", __FUNCTION__));
goto WR_DIS_MAPPING;
}
gBS->Stall(1000);
i++;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x40000000);
}
}
else if(g_deviceId == PCI_DEV_ID_SDS1)
{
i = 0;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x20000000);
while((bht_readl(PciIo, BHT_PCIRMappingEn) & 0x20000000) == 0)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() function 0 can't lock!\n", __FUNCTION__));
goto WR_DIS_MAPPING;
}
gBS->Stall(1000);
i++;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x20000000);
}
}
// Enable MEM access
bht_writel(PciIo, BHT_PCIRMappingVal, 0x80000000);
bht_writel(PciIo, BHT_PCIRMappingCtl, 0x800000D0);
// Check last operation is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0xc0000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() check last operation complete timeout!!!\n", __FUNCTION__));
goto WR_DIS_MAPPING;
}
gBS->Stall(1000);
i += 1;
}
// Set write value
bht_writel(PciIo, BHT_PCIRMappingVal, value);
// Set register address
tmp |= 0x80000000;
tmp |= offset;
bht_writel(PciIo, BHT_PCIRMappingCtl, tmp);
// Check write is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0x80000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() check write operation complete timeout!!!\n", __FUNCTION__));
goto WR_DIS_MAPPING;
}
gBS->Stall(1000);
i += 1;
}
WR_DIS_MAPPING:
// Disable MEM access
bht_writel(PciIo, BHT_PCIRMappingVal, 0x80000001);
bht_writel(PciIo, BHT_PCIRMappingCtl, 0x800000D0);
// Check last operation is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0xc0000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() check last operation complete timeout!!!\n", __FUNCTION__));
break;
}
gBS->Stall(1000);
i += 1;
}
// Disable function conflict
// Disable mapping
bht_writel(PciIo, BHT_PCIRMappingEn, 0x80000000);
}
}
void PciBhtOr32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value)
{
UINT32 arg;
arg = PciBhtRead32(PciIo, offset);
PciBhtWrite32(PciIo, offset, value | arg);
}
void PciBhtAnd32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value)
{
UINT32 arg;
arg = PciBhtRead32(PciIo, offset);
PciBhtWrite32(PciIo, offset, value & arg);
}

View File

@ -552,42 +552,4 @@ SdMmcHcUhsSignaling (
IN SD_MMC_BUS_MODE Timing
);
BOOLEAN
BhtHostPciSupport(EFI_PCI_IO_PROTOCOL *PciIo);
UINT32
PciBhtRead32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset);
void
PciBhtWrite32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value);
void
PciBhtOr32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value);
void
PciBhtAnd32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value);
extern void
DbgNull(IN CONST CHAR16 * fmt, ...);
#if(0)
#define DbgMsg(arg, ...) Print(L##arg, __VA_ARGS__)
#else
#define DbgMsg(...) DEBUG((DEBUG_INFO, __VA_ARGS__))
#endif
#define PCI_DEV_ID_RJ 0x8320
#define PCI_DEV_ID_SDS0 0x8420
#define PCI_DEV_ID_SDS1 0x8421
#define PCI_DEV_ID_FJ2 0x8520
#define PCI_DEV_ID_SB0 0x8620
#define PCI_DEV_ID_SB1 0x8621
// O2/BHT add BAR1 for PCIR mapping registers
// These registers is defined by O2/BHT, but we may follow name definition rule.
#define BHT_PCIRMappingVal (0x200) /* PCI CFG Space Register Mapping Value Register */
#define BHT_PCIRMappingCtl (0x204) /* PCI CFG Space Register Mapping Control Register */
#define BHT_PCIRMappingEn (0x208) /* PCI CFG Space Register Mapping Enable Register */
#define BHT_GPIOCTL (0x210) /* GPIO control register*/
#endif

View File

@ -221,7 +221,7 @@ USBKeyboardDriverBindingStart (
EndpointNumber = UsbKeyboardDevice->InterfaceDescriptor.NumEndpoints;
//
// Traverse endpoints to find interrupt endpoint IN
// Traverse endpoints to find interrupt endpoint
//
Found = FALSE;
for (Index = 0; Index < EndpointNumber; Index++) {
@ -232,8 +232,7 @@ USBKeyboardDriverBindingStart (
&EndpointDescriptor
);
if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT &&
(EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) ) {
if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) {
//
// We only care interrupt endpoint here
//

View File

@ -793,29 +793,6 @@ InitKeyboardLayout (
}
/**
Determine if SetIdle request is needed
@param DevDesc The EFI_USB_DEVICE_DESCRIPTOR instance.
@retval TRUE The USB device requires SetIdle to be called.
@retval FALSE The USB device does not require SetIdle to be called.
**/
BOOLEAN
UsbQuirkRequireSetIdle (
IN EFI_USB_DEVICE_DESCRIPTOR DevDesc
)
{
switch (DevDesc.IdVendor) {
case 0x0557:
return DevDesc.IdProduct == 0x2419;
default:
return FALSE;
}
}
/**
Initialize USB keyboard device and all private data structures.
@ -830,8 +807,10 @@ InitUSBKeyboard (
IN OUT USB_KB_DEV *UsbKeyboardDevice
)
{
EFI_STATUS Status;
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
UINT16 ConfigValue;
UINT8 Protocol;
EFI_STATUS Status;
UINT32 TransferResult;
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_PROGRESS_CODE,
@ -844,38 +823,55 @@ InitUSBKeyboard (
InitQueue (&UsbKeyboardDevice->EfiKeyQueueForNotify, sizeof (EFI_KEY_DATA));
//
// Get device descriptor so vendor/device IDs available
// for quirk handling
// Use the config out of the descriptor
// Assumed the first config is the correct one and this is not always the case
//
Status = UsbKeyboardDevice->UsbIo->UsbGetDeviceDescriptor (
Status = UsbGetConfiguration (
UsbKeyboardDevice->UsbIo,
&DevDesc);
&ConfigValue,
&TransferResult
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
ConfigValue = 0x01;
//
// Uses default configuration to configure the USB Keyboard device.
//
Status = UsbSetConfiguration (
UsbKeyboardDevice->UsbIo,
ConfigValue,
&TransferResult
);
if (EFI_ERROR (Status)) {
//
// If configuration could not be set here, it means
// the keyboard interface has some errors and could
// not be initialized
//
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_ERROR_CODE | EFI_ERROR_MINOR,
(EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_INTERFACE_ERROR),
UsbKeyboardDevice->DevicePath
);
return EFI_DEVICE_ERROR;
}
}
UsbGetProtocolRequest (
UsbKeyboardDevice->UsbIo,
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
&Protocol
);
//
// Set boot protocol for the USB Keyboard.
// This driver only supports boot protocol.
//
Status = UsbSetProtocolRequest (
UsbKeyboardDevice->UsbIo,
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
BOOT_PROTOCOL
);
if (EFI_ERROR (Status)) {
//
// If protocol could not be set here, it means
// the keyboard interface has some errors and could
// not be initialized
//
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_ERROR_CODE | EFI_ERROR_MINOR,
(EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_INTERFACE_ERROR),
UsbKeyboardDevice->DevicePath
if (Protocol != BOOT_PROTOCOL) {
UsbSetProtocolRequest (
UsbKeyboardDevice->UsbIo,
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
BOOT_PROTOCOL
);
return EFI_DEVICE_ERROR;
}
UsbKeyboardDevice->CtrlOn = FALSE;
@ -900,16 +896,6 @@ InitUSBKeyboard (
UsbKeyboardDevice->CurrentNsKey = NULL;
//
// Some keyboards don't send interrupt transfers until SetIdle is called
//
if (UsbQuirkRequireSetIdle(DevDesc)) {
UsbSetIdleRequest(UsbKeyboardDevice->UsbIo,
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
0,
0);
}
//
// Sync the initial state of lights on keyboard.
//

View File

@ -329,18 +329,4 @@ InitializeKeyState (
OUT EFI_KEY_STATE *KeyState
);
/**
Determine if SetIdle request is needed
@param DevDesc The EFI_USB_DEVICE_DESCRIPTOR instance.
@retval TRUE The USB device requires SetIdle to be called.
@retval FALSE The USB device does not require SetIdle to be called.
**/
BOOLEAN
UsbQuirkRequireSetIdle (
IN EFI_USB_DEVICE_DESCRIPTOR DevDesc
);
#endif

View File

@ -209,7 +209,7 @@ USBMouseDriverBindingStart (
EndpointNumber = UsbMouseDevice->InterfaceDescriptor.NumEndpoints;
//
// Traverse endpoints to find interrupt endpoint IN
// Traverse endpoints to find interrupt endpoint
//
Found = FALSE;
for (Index = 0; Index < EndpointNumber; Index++) {
@ -219,8 +219,7 @@ USBMouseDriverBindingStart (
&EndpointDescriptor
);
if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT &&
(EndpointDescriptor.EndpointAddress & USB_ENDPOINT_DIR_IN) ) {
if ((EndpointDescriptor.Attributes & (BIT0 | BIT1)) == USB_ENDPOINT_INTERRUPT) {
//
// We only care interrupt endpoint here
//

View File

@ -944,7 +944,6 @@ UpdateVariable (
UINTN VarSize;
VARIABLE_GLOBAL *Global;
UINTN NonVolatileVarableStoreSize;
UINT32 Result;
BOOLEAN Delete = FALSE;
Global = &mVariableModuleGlobal->VariableGlobal[Physical];
@ -1100,14 +1099,13 @@ UpdateVariable (
Store:
// If the store is initialized
// And we are storing or deleting a non volatile variable
// And variable name starts with 'Boot'
// Send the new data to SMMSTORE
if (storeInitialized && (
(Attributes & EFI_VARIABLE_NON_VOLATILE) != 0 || (
Delete &&
(Variable->CurrPtr->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0
)) && (!StrnCmp(L"Boot", VariableName, StrLen(L"Boot")))
) {
)
)) {
/* TODO: add hook for logging nv changes here */
@ -1126,10 +1124,7 @@ Store:
CopyMem (keydata + sizeof (EFI_GUID), VariableName, VarNameSize);
CopyMem (valdata, Data, DataSize);
Result = call_smm(SMMSTORE_APM_CNT, SMMSTORE_CMD_APPEND, (UINT32)rt_buffer_phys);
if (Result != SMMSTORE_RET_SUCCESS) {
return EFI_DEVICE_ERROR;
}
call_smm(SMMSTORE_APM_CNT, SMMSTORE_CMD_APPEND, (UINT32)rt_buffer_phys);
/* call into SMM through EFI_ISA_IO_PROTOCOL to write to 0xb2:
* set registers (how?)
* UINT8 Data = ...;
@ -1901,7 +1896,7 @@ VariableCommonInitialize (
)
{
EFI_STATUS Status;
UINT32 Result;
//
// Allocate memory for mVariableModuleGlobal
//
@ -1954,11 +1949,7 @@ VariableCommonInitialize (
.bufsize = sizeof(buf),
};
ASSERT((UINTN)&read_cmd <= 0x100000000 - sizeof(read_cmd));
Result = call_smm(SMMSTORE_APM_CNT, SMMSTORE_CMD_READ, (UINT32)(UINTN)&read_cmd);
if (Result != SMMSTORE_RET_SUCCESS) {
// The SMM store hasn't been compiled in. There's nothing we can do.
return EFI_SUCCESS;
}
call_smm(SMMSTORE_APM_CNT, SMMSTORE_CMD_READ, (UINT32)(UINTN)&read_cmd);
DEBUG ((DEBUG_WARN, "Initialize buffer from 0x%x bytes of flash\n", read_cmd.bufsize));
int i = 0;
@ -1979,27 +1970,23 @@ VariableCommonInitialize (
EFI_GUID *guid = (EFI_GUID *)(buf + i + 8);
VOID *data = (VOID *)(buf + i + 8 + keysz);
// only update Boot* variables
if (!StrnCmp(L"Boot", varname, StrLen(L"Boot"))) {
DEBUG ((DEBUG_WARN, "Fetching variable: %s\n", varname));
DEBUG ((DEBUG_WARN, "buf: %p, buf+i: %p, guid: %p, varname: %p, data: %p\n", buf, buf + i, guid, varname, data));
VARIABLE_POINTER_TRACK Variable;
FindVariable (varname, guid, &Variable, (VARIABLE_GLOBAL *)mVariableModuleGlobal);
DEBUG ((DEBUG_WARN, "Fetching variable: %s\n", varname));
DEBUG ((DEBUG_WARN, "buf: %p, buf+i: %p, guid: %p, varname: %p, data: %p\n", buf, buf + i, guid, varname, data));
VARIABLE_POINTER_TRACK Variable;
FindVariable (varname, guid, &Variable, (VARIABLE_GLOBAL *)mVariableModuleGlobal);
DEBUG ((DEBUG_WARN, "Updating variable: %s\n", varname));
UpdateVariable (
varname,
guid,
data,
valsz,
// all of these variables are nv
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
&Variable
);
} else {
DEBUG ((DEBUG_WARN, "Skipping non-Boot variable: %s\n", varname));
}
DEBUG ((DEBUG_WARN, "Updating variable: %s\n", varname));
UpdateVariable (
varname,
guid,
data,
valsz,
// all of these variables are nv
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
&Variable
);
}
DEBUG ((DEBUG_WARN, "Added variable: 0x%x, val size: %x\n", keysz, valsz));
// no UEFI variable since it's at most the GUID part, so skip
i += 8 + keysz + valsz + 1;
i = (i + 3) & ~3;

View File

@ -117,7 +117,7 @@ CommonExceptionHandlerWorker (
//
// Enter a dead loop if needn't to execute old IDT handler further
//
if (ReservedVectors[ExceptionType].Attribute != EFI_VECTOR_HANDOFF_HOOK_BEFORE) {
if (ReservedVectors[ExceptionType].Attribute != EFI_VECTOR_HANDOFF_HOOK_BEFORE && ExceptionType != EXCEPT_IA32_DEBUG) {
CpuDeadLoop ();
}
}
@ -299,4 +299,3 @@ RegisterCpuInterruptHandlerWorker (
ExternalInterruptHandler[InterruptType] = InterruptHandler;
return EFI_SUCCESS;
}