forked from acidanthera/OpenCorePkg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OcPciIoLib: Add CpuIo/PciRootBridgeIo/PciIo fix for Aptio IV with Abo…
…ve 4G BARs (acidanthera#459)
- Loading branch information
Showing
13 changed files
with
819 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** @file | ||
Copyright (C) 2023, xCuri0. All rights reserved. | ||
All rights reserved. | ||
This program and the accompanying materials | ||
are licensed and made available under the terms and conditions of the BSD License | ||
which accompanies this distribution. The full text of the license may be found at | ||
http://opensource.org/licenses/bsd-license.php | ||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
**/ | ||
|
||
#ifndef OC_PCI_IO_LIB_H | ||
#define OC_PCI_IO_LIB_H | ||
|
||
#include <Protocol/CpuIo2.h> | ||
|
||
/** | ||
The user Entry Point for PciIo. | ||
This function fixes PciIo related protocols. | ||
@param[in] Reinstall Replace any installed protocol. | ||
@returns Installed protocol. | ||
@retval NULL There was an error installing the protocol. | ||
**/ | ||
EFI_CPU_IO2_PROTOCOL * | ||
OcPciIoInstallProtocol ( | ||
IN BOOLEAN Reinstall | ||
); | ||
|
||
#endif // OC_PCI_IO_LIB_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ | |
OcMachoLib | ||
OcMiscLib | ||
OcOSInfoLib | ||
OcPciIoLib | ||
OcSmbiosLib | ||
OcSmcLib | ||
OcStorageLib | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** @file | ||
PciIo overrides | ||
Copyright (c) 2023, xCuri0. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include "OcPciIoU.h" | ||
#include <Library/OcPciIoLib.h> | ||
|
||
EFI_CPU_IO2_PROTOCOL * | ||
OcPciIoInstallProtocol ( | ||
IN BOOLEAN Reinstall | ||
) | ||
{ | ||
EFI_TPL Tpl; | ||
UINTN Index; | ||
EFI_STATUS Status; | ||
EFI_CPU_IO2_PROTOCOL *CpuIo; | ||
UINTN HandleCount; | ||
EFI_HANDLE *HandleBuffer; | ||
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; | ||
|
||
CpuIo = InitializeCpuIo2 (); | ||
if (CpuIo == NULL) { | ||
return NULL; | ||
} | ||
|
||
if (!Reinstall) { | ||
return CpuIo; | ||
} | ||
|
||
Tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); | ||
Status = gBS->LocateHandleBuffer ( | ||
ByProtocol, | ||
&gEfiPciRootBridgeIoProtocolGuid, | ||
NULL, | ||
&HandleCount, | ||
&HandleBuffer | ||
); | ||
|
||
if (EFI_ERROR (Status)) { | ||
gBS->RestoreTPL (Tpl); | ||
return NULL; | ||
} | ||
|
||
DEBUG ((DEBUG_INFO, "OCPIO: Fixing CpuIo2\n")); | ||
// Override with 64-bit MMIO compatible functions | ||
CpuIo->Mem.Read = CpuMemoryServiceRead; | ||
CpuIo->Mem.Write = CpuMemoryServiceWrite; | ||
|
||
for (Index = 0; Index < HandleCount; ++Index) { | ||
DEBUG ((DEBUG_INFO, "OCPIO: Fixing PciRootBridgeIo %d\n", Index)); | ||
|
||
Status = gBS->HandleProtocol ( | ||
HandleBuffer[Index], | ||
&gEfiPciRootBridgeIoProtocolGuid, | ||
(VOID **)&PciRootBridgeIo | ||
); | ||
if (EFI_ERROR (Status)) { | ||
break; | ||
} | ||
|
||
// Override with 64-bit MMIO compatible functions | ||
PciRootBridgeIo->Mem.Read = RootBridgeIoMemRead; | ||
PciRootBridgeIo->Mem.Write = RootBridgeIoMemWrite; | ||
} | ||
|
||
gBS->RestoreTPL (Tpl); | ||
FreePool (HandleBuffer); | ||
return CpuIo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## @file | ||
# | ||
# Component description file for the library producing the English version of Unicode Collation Protocol. | ||
# | ||
# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR> | ||
# | ||
# This program and the accompanying materials | ||
# are licensed and made available under the terms and conditions of the BSD License | ||
# which accompanies this distribution. The full text of the license may be found at | ||
# http://opensource.org/licenses/bsd-license.php | ||
# | ||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = OcPciIoLib | ||
FILE_GUID = BC045E46-093A-4217-B836-8FF2CD890FCC | ||
MODULE_TYPE = DXE_DRIVER | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = OcPciIoLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION DXE_SMM_DRIVER DXE_SAL_DRIVER | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC | ||
# | ||
|
||
[Sources] | ||
OcPciIoU.c | ||
OcPciIoLib.c | ||
OcPciIoU.h | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
OpenCorePkg/OpenCorePkg.dec | ||
|
||
[Protocols] | ||
gEfiPciIoProtocolGuid ## SOMETIMES_PRODUCES | ||
gEfiCpuIo2ProtocolGuid ## SOMETIMES_CONSUMES | ||
|
||
[LibraryClasses] | ||
BaseMemoryLib | ||
DebugLib | ||
MemoryAllocationLib | ||
OcMiscLib | ||
UefiBootServicesTableLib |
Oops, something went wrong.