Compare commits

..

2 Commits

Author SHA1 Message Date
Patrick Rudolph
f6a483461c [HACK] Load OptionROMs immediately
This will make sure the ConsoleInit is able to connect the driver installed
by the VGA Option ROMs.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2023-12-28 14:38:35 -07:00
Patrick Rudolph
1966ffb1c3 MdeModulePkg: Fix OptionROM scanning
The Option ROM scanner can't work as enumeration was done by the
first stage bootloader. Running it will disable the ability of the
PCIPlatform code to scan for ROMs.

Required for the following patch that enables custom Option ROM
scanning using gPciPlatformProtocol.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2023-12-28 14:38:29 -07:00
9 changed files with 12 additions and 321 deletions

View File

@@ -2551,10 +2551,12 @@ PciEnumeratorLight (
//
RemoveRejectedPciDevices (RootBridgeDev->Handle, RootBridgeDev);
if (!PcdGetBool (PcdPciDisableBusEnumeration)) {
//
// Process option rom light
//
ProcessOptionRomLight (RootBridgeDev);
}
//
// Determine attributes for all devices under this root bridge

View File

@@ -285,7 +285,7 @@ UsbHcBulkTransfer (
IN UINT8 DevSpeed,
IN UINTN MaxPacket,
IN UINT8 BufferNum,
IN OUT VOID *Data[],
IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
IN OUT UINTN *DataLength,
IN OUT UINT8 *DataToggle,
IN UINTN TimeOut,

View File

@@ -149,7 +149,7 @@ UsbHcBulkTransfer (
IN UINT8 DevSpeed,
IN UINTN MaxPacket,
IN UINT8 BufferNum,
IN OUT VOID *Data[],
IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
IN OUT UINTN *DataLength,
IN OUT UINT8 *DataToggle,
IN UINTN TimeOut,

View File

@@ -25,7 +25,7 @@ typedef struct {
} DEFERRED_3RD_PARTY_IMAGE_TABLE;
BOOLEAN mImageLoadedAfterEndOfDxe = FALSE;
BOOLEAN mEndOfDxe = FALSE;
BOOLEAN mEndOfDxe = TRUE;
DEFERRED_3RD_PARTY_IMAGE_TABLE mDeferred3rdPartyImage = {
0, // Deferred image count
NULL // The deferred image info

View File

@@ -1,21 +0,0 @@
# SPDX-License-Identifier: MPL-2.0
# SPDX-FileCopyrightText: 2023 System76, Inc.
FmpDevicePkg/FmpDxe/FmpDxe.inf {
<Defines>
FILE_GUID = $(EC_FMP_ESRT_GUID)
<PcdsFixedAtBuild>
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceImageIdName|L"System76 EC"
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceBuildTimeLowestSupportedVersion|0
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressWatchdogTimeInSeconds|0
gFmpDevicePkgTokenSpaceGuid.PcdFmpDeviceProgressColor|0x00FBB86C
<LibraryClasses>
FmpPayloadHeaderLib|FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLibV1.inf
FmpAuthenticationLib|MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.inf
FmpDependencyLib|FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.inf
FmpDependencyCheckLib|FmpDevicePkg/Library/FmpDependencyCheckLibNull/FmpDependencyCheckLibNull.inf
FmpDependencyDeviceLib|FmpDevicePkg/Library/FmpDependencyDeviceLibNull/FmpDependencyDeviceLibNull.inf
CapsuleUpdatePolicyLib|FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.inf
FmpDeviceLib|System76Pkg/Ec/Fmp/EcFmpLib.inf
}

View File

@@ -1,241 +0,0 @@
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: 2023 System76, Inc.
#include <Guid/SystemResourceTable.h>
#include <Library/BaseMemoryLib.h>
#include <Library/FmpDeviceLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <LastAttemptStatus.h>
#define US_PER_MS 1000
EFI_STATUS
EFIAPI
RegisterFmpInstaller(
IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER FmpInstaller
) {
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
RegisterFmpUninstaller(
IN FMP_DEVICE_LIB_REGISTER_FMP_UNINSTALLER FmpUninstaller
) {
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
FmpDeviceSetContext(
IN EFI_HANDLE Handle,
IN OUT VOID **Context
) {
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
FmpDeviceGetSize(
OUT UINTN *Size
) {
if (!Size)
return EFI_INVALID_PARAMETER;
// TODO
*Size = 128 * 1024;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
FmpDeviceGetImageTypeIdGuidPtr(
OUT EFI_GUID **Guid
) {
if (!Guid)
return EFI_INVALID_PARAMETER;
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
FmpDeviceGetAttributes(
OUT UINT64 *Supported,
OUT UINT64 *Setting
) {
if (!Supported || !Setting)
return EFI_INVALID_PARAMETER;
*Supported = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
| IMAGE_ATTRIBUTE_RESET_REQUIRED
| IMAGE_ATTRIBUTE_IN_USE;
*Setting = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
| IMAGE_ATTRIBUTE_RESET_REQUIRED
| IMAGE_ATTRIBUTE_IN_USE;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
FmpDeviceGetLowestSupportedVersion(
OUT UINT32 *LowestSupportedVersion
) {
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
FmpDeviceGetVersionString(
OUT CHAR16 **VersionString
) {
if (!VersionString)
return EFI_INVALID_PARAMETER;
// TODO
*VersionString = AllocatePool(sizeof(L"0.3"));
if (!(*VersionString))
return EFI_OUT_OF_RESOURCES;
CopyMem(VersionString, L"0.3", sizeof(L"0.3"));
//*VersionString = NULL;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
FmpDeviceGetVersion(
OUT UINT32 *Version
) {
if (!Version)
return EFI_INVALID_PARAMETER;
// TODO
*Version = 3;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
FmpDeviceGetHardwareInstance(
OUT UINT64 *HardwareInstance
) {
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
FmpDeviceGetImage(
OUT VOID *Image,
IN OUT UINTN *ImageSize
) {
// TODO
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
FmpDeviceCheckImageWithStatus(
IN CONST VOID *Image,
IN UINTN ImageSize,
OUT UINT32 *ImageUpdatable,
OUT UINT32 *LastAttemptStatus
) {
if (!LastAttemptStatus)
return EFI_INVALID_PARAMETER;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE;
if (!ImageUpdatable || !Image)
return EFI_INVALID_PARAMETER;
// TODO:
*LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
FmpDeviceCheckImage(
IN CONST VOID *Image,
IN UINTN ImageSize,
OUT UINT32 *ImageUpdatable
) {
UINT32 LastAttemptStatus;
return FmpDeviceCheckImageWithStatus(Image, ImageSize, ImageUpdatable, &LastAttemptStatus);
}
EFI_STATUS
EFIAPI
FmpDeviceSetImageWithStatus (
IN CONST VOID *Image,
IN UINTN ImageSize,
IN CONST VOID *VendorCode, OPTIONAL
IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIONAL
IN UINT32 CapsuleFwVersion,
OUT CHAR16 **AbortReason,
OUT UINT32 *LastAttemptStatus
) {
// TODO
EFI_STATUS Status = EFI_SUCCESS;
UINT32 Updateable = 0;
Status = FmpDeviceCheckImageWithStatus(Image, ImageSize, &Updateable, LastAttemptStatus);
if (EFI_ERROR(Status)) {
goto cleanup;
}
if (Updateable != IMAGE_UPDATABLE_VALID) {
Status = EFI_ABORTED;
goto cleanup;
}
if (Progress == NULL) {
Status = EFI_INVALID_PARAMETER;
goto cleanup;
}
gBS->Stall (3000 * US_PER_MS);
Progress(15);
gBS->Stall (2000 * US_PER_MS);
for (int p = 20; p < 100; p++) {
gBS->Stall (100 * US_PER_MS);
Progress (p);
}
cleanup:
if (EFI_ERROR (Status)) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE;
}
return Status;
}
EFI_STATUS
EFIAPI
FmpDeviceSetImage(
IN CONST VOID *Image,
IN UINTN ImageSize,
IN CONST VOID *VendorCode, OPTIONAL
IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OPTIONAL
IN UINT32 CapsuleFwVersion,
OUT CHAR16 **AbortReason
) {
UINT32 LastAttemptStatus;
return FmpDeviceSetImageWithStatus(Image, ImageSize, VendorCode, Progress, CapsuleFwVersion, AbortReason, &LastAttemptStatus);
}
EFI_STATUS
EFIAPI
FmpDeviceLock(
VOID
) {
return EFI_UNSUPPORTED;
}

View File

@@ -1,20 +0,0 @@
# SPDX-License-Identifier: MPL-2.0
# SPDX-FileCopyrightText: 2023 System76, Inc.
[Defines]
INF_VERSION = 1.27
BASE_NAME = EcFmpLib
FILE_GUID = 760B7155-99F7-4E8E-8C07-D38A75F54C54
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 0.1
LIBRARY_CLASS = FmpDeviceLib|DXE_DRIVER
[Sources]
EcFmpLib.c
[Packages]
MdePkg/MdePkg.dec
FmpDevicePkg/FmpDevicePkg.dec
[LibraryClasses]
UefiBootServicesTableLib

View File

@@ -112,9 +112,6 @@
DEFINE SECURE_BOOT_ENABLE = FALSE
DEFINE TPM_ENABLE = FALSE
# FMP
DEFINE EC_FMP_ESRT_GUID = 76FFAC81-FDE6-464D-A6D9-84BDD9EE522D
[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG
@@ -209,16 +206,13 @@
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
# FMP Capsule
BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
#
# CPU
#
@@ -352,9 +346,6 @@
Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibTcg2/Tpm2DeviceLibTcg2.inf
!endif
# FMP Capsule
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -373,9 +364,6 @@
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
!endif
# FMP Capsule
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
[LibraryClasses.common.UEFI_DRIVER,LibraryClasses.common.UEFI_APPLICATION]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@@ -414,10 +402,6 @@
# Disable MTRR programming
gUefiCpuPkgTokenSpaceGuid.PcdCpuDisableMtrrProgramming|TRUE
# Enable Capsule On Disk support
# NOTE: Capsule in RAM is enabled, so UpdateCapsule will still be called
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleOnDiskSupport|TRUE
[PcdsPatchableInModule.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7
@@ -579,6 +563,7 @@
MdeModulePkg/Universal/Metronome/Metronome.inf
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
!if $(DISABLE_RESET_SYSTEM) == FALSE
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
@@ -721,14 +706,6 @@
}
!endif
#
# Firmware update
#
MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
!include System76Pkg/Ec/Fmp/EcFmp.dsc
#------------------------------
# Build the shell
#------------------------------

View File

@@ -113,6 +113,7 @@ INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
INF MdeModulePkg/Universal/Metronome/Metronome.inf
INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
!if $(DISABLE_RESET_SYSTEM) == FALSE
@@ -277,13 +278,6 @@ INF SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
}
!endif
#
# Firmware update
#
INF MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
INF FILE_GUID = $(EC_FMP_ESRT_GUID) FmpDevicePkg/FmpDxe/FmpDxe.inf
#
# Shell
#