2 Registers onboard PCI ROMs with PCI.IO
4 Copyright (c) 2013-2015 Intel Corporation.
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "CommonHeader.h"
19 #include "PciPlatform.h"
22 PCI_OPTION_ROM_TABLE mPciOptionRomTable
[] = {
23 { NULL_ROM_FILE_GUID
, 0, 0, 0, 0, 0xffff, 0xffff }
25 EFI_PCI_PLATFORM_PROTOCOL mPciPlatform
= {
27 PlatformPrepController
,
32 EFI_HANDLE mPciPlatformHandle
= NULL
;
33 EFI_HANDLE mImageHandle
= NULL
;
38 IN EFI_PCI_PLATFORM_PROTOCOL
*This
,
39 IN EFI_HANDLE HostBridge
,
40 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
,
41 IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase
44 UINT8 UsbHostBusNumber
= IOH_BUS
;
45 if (Phase
== EfiPciHostBridgeEndResourceAllocation
) {
46 // Required for QuarkSouthCluster.
47 // Enable USB controller memory, io and bus master before Ehci driver.
48 EnableUsbMemIoBusMaster (UsbHostBusNumber
);
51 return EFI_UNSUPPORTED
;
56 PlatformPrepController (
57 IN EFI_PCI_PLATFORM_PROTOCOL
*This
,
58 IN EFI_HANDLE HostBridge
,
59 IN EFI_HANDLE RootBridge
,
60 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress
,
61 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
,
62 IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase
65 return EFI_UNSUPPORTED
;
70 IN CONST EFI_PCI_PLATFORM_PROTOCOL
*This
,
71 OUT EFI_PCI_PLATFORM_POLICY
*PciPolicy
74 if (PciPolicy
== NULL
) {
75 return EFI_INVALID_PARAMETER
;
78 return EFI_UNSUPPORTED
;
83 IN CONST EFI_PCI_PLATFORM_PROTOCOL
*This
,
84 IN EFI_HANDLE PciHandle
,
91 Return a PCI ROM image for the onboard device represented by PciHandle
94 This - Protocol instance pointer.
95 PciHandle - PCI device to return the ROM image for.
96 RomImage - PCI Rom Image for onboard device
97 RomSize - Size of RomImage in bytes
100 EFI_SUCCESS - RomImage is valid
101 EFI_NOT_FOUND - No RomImage
106 EFI_PCI_IO_PROTOCOL
*PciIo
;
116 Status
= gBS
->HandleProtocol (
118 &gEfiPciIoProtocolGuid
,
121 if (EFI_ERROR (Status
)) {
122 return EFI_NOT_FOUND
;
125 PciIo
->GetLocation (PciIo
, &Segment
, &Bus
, &Device
, &Function
);
127 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
, 0x0A, 1, &DeviceClass
);
129 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
, 0, 1, &VendorId
);
131 PciIo
->Pci
.Read (PciIo
, EfiPciIoWidthUint16
, 2, 1, &DeviceId
);
134 // Loop through table of video option rom descriptions
136 for (TableIndex
= 0; mPciOptionRomTable
[TableIndex
].VendorId
!= 0xffff; TableIndex
++) {
139 // See if the PCI device specified by PciHandle matches at device in mPciOptionRomTable
141 if (VendorId
!= mPciOptionRomTable
[TableIndex
].VendorId
||
142 DeviceId
!= mPciOptionRomTable
[TableIndex
].DeviceId
||
143 Segment
!= mPciOptionRomTable
[TableIndex
].Segment
||
144 Bus
!= mPciOptionRomTable
[TableIndex
].Bus
||
145 Device
!= mPciOptionRomTable
[TableIndex
].Device
||
146 Function
!= mPciOptionRomTable
[TableIndex
].Function
) {
150 Status
= GetSectionFromFv (
151 &mPciOptionRomTable
[TableIndex
].FileName
,
158 if (EFI_ERROR (Status
)) {
165 return EFI_NOT_FOUND
;
169 PciPlatformDriverEntry (
170 IN EFI_HANDLE ImageHandle
,
171 IN EFI_SYSTEM_TABLE
*SystemTable
178 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
187 mImageHandle
= ImageHandle
;
190 // Install on a new handle
192 Status
= gBS
->InstallProtocolInterface (
194 &gEfiPciPlatformProtocolGuid
,
195 EFI_NATIVE_INTERFACE
,