2 Registers onboard PCI ROMs with PCI.IO
4 Copyright (c) 2013-2015 Intel Corporation.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "CommonHeader.h"
13 #include "PciPlatform.h"
16 PCI_OPTION_ROM_TABLE mPciOptionRomTable
[] = {
17 { NULL_ROM_FILE_GUID
, 0, 0, 0, 0, 0xffff, 0xffff }
19 EFI_PCI_PLATFORM_PROTOCOL mPciPlatform
= {
21 PlatformPrepController
,
26 EFI_HANDLE mPciPlatformHandle
= NULL
;
27 EFI_HANDLE mImageHandle
= NULL
;
32 IN EFI_PCI_PLATFORM_PROTOCOL
*This
,
33 IN EFI_HANDLE HostBridge
,
34 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
,
35 IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase
38 UINT8 UsbHostBusNumber
= IOH_BUS
;
39 if (Phase
== EfiPciHostBridgeEndResourceAllocation
) {
40 // Required for QuarkSouthCluster.
41 // Enable USB controller memory, io and bus master before Ehci driver.
42 EnableUsbMemIoBusMaster (UsbHostBusNumber
);
45 return EFI_UNSUPPORTED
;
50 PlatformPrepController (
51 IN EFI_PCI_PLATFORM_PROTOCOL
*This
,
52 IN EFI_HANDLE HostBridge
,
53 IN EFI_HANDLE RootBridge
,
54 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress
,
55 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
,
56 IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase
59 return EFI_UNSUPPORTED
;
64 IN CONST EFI_PCI_PLATFORM_PROTOCOL
*This
,
65 OUT EFI_PCI_PLATFORM_POLICY
*PciPolicy
68 if (PciPolicy
== NULL
) {
69 return EFI_INVALID_PARAMETER
;
72 return EFI_UNSUPPORTED
;
77 IN CONST EFI_PCI_PLATFORM_PROTOCOL
*This
,
78 IN EFI_HANDLE PciHandle
,
85 Return a PCI ROM image for the onboard device represented by PciHandle
88 This - Protocol instance pointer.
89 PciHandle - PCI device to return the ROM image for.
90 RomImage - PCI Rom Image for onboard device
91 RomSize - Size of RomImage in bytes
94 EFI_SUCCESS - RomImage is valid
95 EFI_NOT_FOUND - No RomImage
100 EFI_PCI_IO_PROTOCOL
*PciIo
;
110 Status
= gBS
->HandleProtocol (
112 &gEfiPciIoProtocolGuid
,
115 if (EFI_ERROR (Status
)) {
116 return EFI_NOT_FOUND
;
119 PciIo
->GetLocation (PciIo
, &Segment
, &Bus
, &Device
, &Function
);
121 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
, 0x0A, 1, &DeviceClass
);
123 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
, 0, 1, &VendorId
);
125 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
, 2, 1, &DeviceId
);
128 // Loop through table of video option rom descriptions
130 for (TableIndex
= 0; mPciOptionRomTable
[TableIndex
].VendorId
!= 0xffff; TableIndex
++) {
133 // See if the PCI device specified by PciHandle matches at device in mPciOptionRomTable
135 if (VendorId
!= mPciOptionRomTable
[TableIndex
].VendorId
||
136 DeviceId
!= mPciOptionRomTable
[TableIndex
].DeviceId
||
137 Segment
!= mPciOptionRomTable
[TableIndex
].Segment
||
138 Bus
!= mPciOptionRomTable
[TableIndex
].Bus
||
139 Device
!= mPciOptionRomTable
[TableIndex
].Device
||
140 Function
!= mPciOptionRomTable
[TableIndex
].Function
) {
144 Status
= GetSectionFromFv (
145 &mPciOptionRomTable
[TableIndex
].FileName
,
152 if (EFI_ERROR (Status
)) {
159 return EFI_NOT_FOUND
;
163 PciPlatformDriverEntry (
164 IN EFI_HANDLE ImageHandle
,
165 IN EFI_SYSTEM_TABLE
*SystemTable
172 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
181 mImageHandle
= ImageHandle
;
184 // Install on a new handle
186 Status
= gBS
->InstallProtocolInterface (
188 &gEfiPciPlatformProtocolGuid
,
189 EFI_NATIVE_INTERFACE
,