Complete the library instances in IntelFrameworkModulePkg
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2810 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/**@file
|
||||
Common header file shared by all source files.
|
||||
|
||||
This file includes package header files, library classes and protocol, PPI & GUID definitions.
|
||||
|
||||
Copyright (c) 2007, Intel Corporation.
|
||||
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 __COMMON_HEADER_H_
|
||||
#define __COMMON_HEADER_H_
|
||||
|
||||
|
||||
//
|
||||
// The package level header files this module uses
|
||||
//
|
||||
#include <PiDxe.h>
|
||||
//
|
||||
// The Library classes this module consumes
|
||||
//
|
||||
#include <Library/PciIncompatibleDeviceSupportLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
||||
#endif
|
@@ -0,0 +1,214 @@
|
||||
/** @file
|
||||
The incompatible PCI device list
|
||||
|
||||
Copyright (c) 2007 Intel Corporation. All rights reserved. <BR>
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _EFI_INCOMPATIBLE_PCI_DEVICE_LIST_H
|
||||
#define _EFI_INCOMPATIBLE_PCI_DEVICE_LIST_H
|
||||
|
||||
//
|
||||
// Include common header file for this module.
|
||||
//
|
||||
#include "CommonHeader.h"
|
||||
|
||||
#include <IndustryStandard/pci22.h>
|
||||
#include <IndustryStandard/Acpi.h>
|
||||
|
||||
|
||||
#define PCI_DEVICE_ID(VendorId, DeviceId, Revision, SubVendorId, SubDeviceId) \
|
||||
VendorId, DeviceId, Revision, SubVendorId, SubDeviceId
|
||||
|
||||
#define PCI_BAR_TYPE_IO ACPI_ADDRESS_SPACE_TYPE_IO
|
||||
#define PCI_BAR_TYPE_MEM ACPI_ADDRESS_SPACE_TYPE_MEM
|
||||
|
||||
#define DEVICE_INF_TAG 0xFFF2
|
||||
#define DEVICE_RES_TAG 0xFFF1
|
||||
#define LIST_END_TAG 0x0000
|
||||
|
||||
//
|
||||
// descriptor for access width of incompatible PCI device
|
||||
//
|
||||
typedef struct {
|
||||
UINT64 AccessType;
|
||||
UINT64 AccessWidth;
|
||||
EFI_PCI_REGISTER_ACCESS_DATA PciRegisterAccessData;
|
||||
} EFI_PCI_REGISTER_ACCESS_DESCRIPTOR;
|
||||
|
||||
//
|
||||
// descriptor for register value of incompatible PCI device
|
||||
//
|
||||
typedef struct {
|
||||
UINT64 AccessType;
|
||||
UINT64 Offset;
|
||||
EFI_PCI_REGISTER_VALUE_DATA PciRegisterValueData;
|
||||
} EFI_PCI_REGISTER_VALUE_DESCRIPTOR;
|
||||
|
||||
|
||||
//
|
||||
// the incompatible PCI devices list for ACPI resource
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED UINT64 IncompatiblePciDeviceListForResource[] = {
|
||||
//
|
||||
// DEVICE_INF_TAG,
|
||||
// PCI_DEVICE_ID (VendorID, DeviceID, Revision, SubVendorId, SubDeviceId),
|
||||
// DEVICE_RES_TAG,
|
||||
// ResType, GFlag , SFlag, Granularity, RangeMin,
|
||||
// RangeMax, Offset, AddrLen
|
||||
//
|
||||
//
|
||||
// Device Adaptec 9004
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x9004, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE),
|
||||
DEVICE_RES_TAG,
|
||||
PCI_BAR_TYPE_IO,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_BAR_EVEN_ALIGN,
|
||||
PCI_BAR_ALL,
|
||||
PCI_BAR_NOCHANGE,
|
||||
//
|
||||
// Device Adaptec 9005
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x9005, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE),
|
||||
DEVICE_RES_TAG,
|
||||
PCI_BAR_TYPE_IO,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_BAR_EVEN_ALIGN,
|
||||
PCI_BAR_ALL,
|
||||
PCI_BAR_NOCHANGE,
|
||||
//
|
||||
// Device QLogic 1007
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x1077, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE),
|
||||
DEVICE_RES_TAG,
|
||||
PCI_BAR_TYPE_IO,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_BAR_EVEN_ALIGN,
|
||||
PCI_BAR_ALL,
|
||||
PCI_BAR_NOCHANGE,
|
||||
//
|
||||
// Device Agilent 103C
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x103C, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE),
|
||||
DEVICE_RES_TAG,
|
||||
PCI_BAR_TYPE_IO,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_BAR_EVEN_ALIGN,
|
||||
PCI_BAR_ALL,
|
||||
PCI_BAR_NOCHANGE,
|
||||
//
|
||||
// Device Agilent 15BC
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x15BC, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE),
|
||||
DEVICE_RES_TAG,
|
||||
PCI_BAR_TYPE_IO,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_ACPI_UNUSED,
|
||||
PCI_BAR_EVEN_ALIGN,
|
||||
PCI_BAR_ALL,
|
||||
PCI_BAR_NOCHANGE,
|
||||
//
|
||||
// The end of the list
|
||||
//
|
||||
LIST_END_TAG
|
||||
};
|
||||
|
||||
//
|
||||
// the incompatible PCI devices list for the values of configuration registers
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED UINT64 IncompatiblePciDeviceListForRegister[] = {
|
||||
//
|
||||
// DEVICE_INF_TAG,
|
||||
// PCI_DEVICE_ID (VendorID, DeviceID, Revision, SubVendorId, SubDeviceId),
|
||||
// PCI_RES_TAG,
|
||||
// PCI_ACCESS_TYPE, PCI_CONFIG_ADDRESS,
|
||||
// AND_VALUE, OR_VALUE
|
||||
|
||||
//
|
||||
// Device Lava 0x1407, DeviceId 0x0110
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x1407, 0x0110, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE),
|
||||
DEVICE_RES_TAG,
|
||||
PCI_REGISTER_READ,
|
||||
PCI_CAPBILITY_POINTER_OFFSET,
|
||||
0xffffff00,
|
||||
VALUE_NOCARE,
|
||||
|
||||
//
|
||||
// Device Lava 0x1407, DeviceId 0x0111
|
||||
//
|
||||
DEVICE_INF_TAG,
|
||||
PCI_DEVICE_ID(0x1407, 0x0111, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE),
|
||||
DEVICE_RES_TAG,
|
||||
PCI_REGISTER_READ,
|
||||
PCI_CAPBILITY_POINTER_OFFSET,
|
||||
0xffffff00,
|
||||
VALUE_NOCARE,
|
||||
|
||||
//
|
||||
// The end of the list
|
||||
//
|
||||
LIST_END_TAG
|
||||
};
|
||||
|
||||
//
|
||||
// the incompatible PCI devices list for the access width of configuration registers
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED UINT64 DeviceListForAccessWidth[] = {
|
||||
//
|
||||
// DEVICE_INF_TAG,
|
||||
// PCI_DEVICE_ID (VendorID, DeviceID, Revision, SubVendorId, SubDeviceId),
|
||||
// DEVICE_RES_TAG,
|
||||
// PCI_ACCESS_TYPE, PCI_ACCESS_WIDTH,
|
||||
// START_ADDRESS, END_ADDRESS,
|
||||
// ACTUAL_PCI_ACCESS_WIDTH,
|
||||
//
|
||||
|
||||
//
|
||||
// Sample Device
|
||||
//
|
||||
//DEVICE_INF_TAG,
|
||||
//PCI_DEVICE_ID(0xXXXX, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE, DEVICE_ID_NOCARE),
|
||||
//DEVICE_RES_TAG,
|
||||
//PCI_REGISTER_READ,
|
||||
//EfiPciWidthUint8,
|
||||
//0,
|
||||
//0xFF,
|
||||
//EfiPciWidthUint32,
|
||||
//
|
||||
|
||||
//
|
||||
// The end of the list
|
||||
//
|
||||
LIST_END_TAG
|
||||
};
|
||||
|
||||
#endif
|
@@ -0,0 +1,393 @@
|
||||
/** @file
|
||||
The implementation of PCI incompatible device support libary.
|
||||
|
||||
Copyright (c) 2007 Intel Corporation. All rights reserved. <BR>
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
**/
|
||||
|
||||
//
|
||||
// Include common header file for this module.
|
||||
//
|
||||
#include "CommonHeader.h"
|
||||
|
||||
#include "IncompatiblePciDeviceList.h"
|
||||
|
||||
/**
|
||||
Check whether two PCI devices matched
|
||||
|
||||
@param PciDeviceInfo A pointer to EFI_PCI_DEVICE_INFO.
|
||||
@param Header A pointer to EFI_PCI_DEVICE_INFO.
|
||||
|
||||
@retval returns EFI_SUCCESS if two PCI device matched.
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
DeviceCheck (
|
||||
IN EFI_PCI_DEVICE_INFO *PciDeviceInfo,
|
||||
IN EFI_PCI_DEVICE_INFO *Header
|
||||
)
|
||||
{
|
||||
//
|
||||
// See if the Header matches the parameters passed in
|
||||
//
|
||||
if (Header->VendorID != DEVICE_ID_NOCARE) {
|
||||
if (PciDeviceInfo->VendorID != Header->VendorID) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (Header->DeviceID != DEVICE_ID_NOCARE) {
|
||||
if (PciDeviceInfo->DeviceID != Header->DeviceID) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (Header->RevisionID != DEVICE_ID_NOCARE) {
|
||||
if (PciDeviceInfo->RevisionID != Header->RevisionID) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (Header->SubsystemVendorID != DEVICE_ID_NOCARE) {
|
||||
if (PciDeviceInfo->SubsystemVendorID != Header->SubsystemVendorID) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (Header->SubsystemID != DEVICE_ID_NOCARE) {
|
||||
if (PciDeviceInfo->SubsystemID != Header->SubsystemID) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check the incompatible device list for ACPI resource update and return
|
||||
the configuration
|
||||
|
||||
This function searches the incompatible device list according to request
|
||||
information. If the PCI device belongs to the devices list, corresponding
|
||||
configuration informtion will be returned, in the meantime return EFI_SUCCESS.
|
||||
|
||||
@param PciDeviceInfo A pointer to PCI device information.
|
||||
@param Configuration Returned information.
|
||||
|
||||
@retval returns EFI_SUCCESS if check incompatible device ok.
|
||||
Otherwise return EFI_UNSUPPORTED.
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
PciResourceUpdateCheck (
|
||||
IN EFI_PCI_DEVICE_INFO *PciDeviceInfo,
|
||||
OUT VOID *Configuration
|
||||
)
|
||||
{
|
||||
UINT64 Tag;
|
||||
UINT64 *ListPtr;
|
||||
UINT64 *TempListPtr;
|
||||
EFI_PCI_DEVICE_INFO *Header;
|
||||
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *AcpiPtr;
|
||||
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *OldAcpiPtr;
|
||||
EFI_PCI_RESOUCE_DESCRIPTOR *Dsc;
|
||||
EFI_ACPI_END_TAG_DESCRIPTOR *PtrEnd;
|
||||
UINTN Index;
|
||||
|
||||
ASSERT (PciDeviceInfo != NULL);
|
||||
|
||||
//
|
||||
// Initialize the return value to NULL
|
||||
//
|
||||
* (VOID **) Configuration = NULL;
|
||||
|
||||
ListPtr = IncompatiblePciDeviceListForResource;
|
||||
while (*ListPtr != LIST_END_TAG) {
|
||||
|
||||
Tag = *ListPtr;
|
||||
|
||||
switch (Tag) {
|
||||
case DEVICE_INF_TAG:
|
||||
Header = (EFI_PCI_DEVICE_INFO *) (ListPtr + 1);
|
||||
ListPtr = ListPtr + 1 + sizeof (EFI_PCI_DEVICE_INFO) / sizeof (UINT64);
|
||||
|
||||
if (DeviceCheck (PciDeviceInfo, Header) != EFI_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Matched an item, so construct the ACPI descriptor for the resource.
|
||||
//
|
||||
//
|
||||
// Count the resource items so that to allocate space
|
||||
//
|
||||
for (Index = 0, TempListPtr = ListPtr; *TempListPtr == DEVICE_RES_TAG; Index++) {
|
||||
TempListPtr = TempListPtr + 1 + ((sizeof (EFI_PCI_RESOUCE_DESCRIPTOR)) / sizeof (UINT64));
|
||||
}
|
||||
//
|
||||
// If there is at least one type of resource request,
|
||||
// allocate a acpi resource node
|
||||
//
|
||||
if (Index == 0) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
AcpiPtr = AllocateZeroPool (
|
||||
sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) * Index + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR)
|
||||
);
|
||||
|
||||
OldAcpiPtr = AcpiPtr;
|
||||
|
||||
//
|
||||
// Fill the EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR structure
|
||||
// according to the EFI_PCI_RESOUCE_DESCRIPTOR structure
|
||||
//
|
||||
for (; *ListPtr == DEVICE_RES_TAG;) {
|
||||
|
||||
Dsc = (EFI_PCI_RESOUCE_DESCRIPTOR *) (ListPtr + 1);
|
||||
|
||||
AcpiPtr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
|
||||
AcpiPtr->Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR);
|
||||
AcpiPtr->ResType = (UINT8) Dsc->ResType;
|
||||
AcpiPtr->GenFlag = (UINT8) Dsc->GenFlag;
|
||||
AcpiPtr->SpecificFlag = (UINT8) Dsc->SpecificFlag;
|
||||
AcpiPtr->AddrSpaceGranularity = Dsc->AddrSpaceGranularity;;
|
||||
AcpiPtr->AddrRangeMin = Dsc->AddrRangeMin;
|
||||
AcpiPtr->AddrRangeMax = Dsc->AddrRangeMax;
|
||||
AcpiPtr->AddrTranslationOffset = Dsc->AddrTranslationOffset;
|
||||
AcpiPtr->AddrLen = Dsc->AddrLen;
|
||||
|
||||
ListPtr = ListPtr + 1 + ((sizeof (EFI_PCI_RESOUCE_DESCRIPTOR)) / sizeof (UINT64));
|
||||
AcpiPtr++;
|
||||
}
|
||||
//
|
||||
// put the checksum
|
||||
//
|
||||
PtrEnd = (EFI_ACPI_END_TAG_DESCRIPTOR *) (AcpiPtr);
|
||||
PtrEnd->Desc = ACPI_END_TAG_DESCRIPTOR;
|
||||
PtrEnd->Checksum = 0;
|
||||
|
||||
*(VOID **) Configuration = OldAcpiPtr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
case DEVICE_RES_TAG:
|
||||
//
|
||||
// Adjust the pointer to the next PCI resource descriptor item
|
||||
//
|
||||
ListPtr = ListPtr + 1 + ((sizeof (EFI_PCI_RESOUCE_DESCRIPTOR)) / sizeof (UINT64));
|
||||
break;
|
||||
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Check the incompatible device list and return configuraton register mask values.
|
||||
|
||||
This function searches the incompatible device list according to request
|
||||
information. If the PCI device belongs to the devices list, corresponding
|
||||
configuration informtion will be returned, in the meantime return EFI_SUCCESS.
|
||||
|
||||
@param PciDeviceInfo A pointer to EFI_PCI_DEVICE_INFO.
|
||||
@param AccessType Access Type, READ or WRITE.
|
||||
@param Offset The address within the PCI configuration space.
|
||||
@param Configuration Returned information.
|
||||
|
||||
@retval returns EFI_SUCCESS if check incompatible device ok.
|
||||
Otherwise return EFI_UNSUPPORTED.
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
PciRegisterUpdateCheck (
|
||||
IN EFI_PCI_DEVICE_INFO *PciDeviceInfo,
|
||||
IN UINT64 AccessType,
|
||||
IN UINT64 Offset,
|
||||
OUT VOID *Configuration
|
||||
)
|
||||
{
|
||||
EFI_PCI_DEVICE_INFO *Header;
|
||||
UINT64 Tag;
|
||||
UINT64 *ListPtr;
|
||||
EFI_PCI_REGISTER_VALUE_DATA *RegisterPtr;
|
||||
EFI_PCI_REGISTER_VALUE_DATA *Dsc;
|
||||
|
||||
ASSERT (PciDeviceInfo != NULL);
|
||||
|
||||
ListPtr = IncompatiblePciDeviceListForRegister;
|
||||
|
||||
//
|
||||
// Initialize the return value to NULL
|
||||
//
|
||||
* (VOID **) Configuration = NULL;
|
||||
|
||||
while (*ListPtr != LIST_END_TAG) {
|
||||
|
||||
Tag = *ListPtr;
|
||||
|
||||
switch (Tag) {
|
||||
case DEVICE_INF_TAG:
|
||||
Header = (EFI_PCI_DEVICE_INFO *) (ListPtr + 1);
|
||||
ListPtr = ListPtr + 1 + sizeof (EFI_PCI_DEVICE_INFO) / sizeof (UINT64);
|
||||
|
||||
//
|
||||
// Check whether the PCI device matches the device in the incompatible devices list?
|
||||
// If not, ship next
|
||||
//
|
||||
if (DeviceCheck (PciDeviceInfo, Header) != EFI_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Matched an item, check whether access matches?
|
||||
//
|
||||
for (; *ListPtr == DEVICE_RES_TAG;) {
|
||||
ListPtr ++;
|
||||
if (((EFI_PCI_REGISTER_VALUE_DESCRIPTOR *)ListPtr)->Offset == (Offset & 0xfc)) {
|
||||
if (((EFI_PCI_REGISTER_VALUE_DESCRIPTOR *)ListPtr)->AccessType == AccessType) {
|
||||
|
||||
Dsc = (EFI_PCI_REGISTER_VALUE_DATA *) (ListPtr + 2);
|
||||
RegisterPtr = AllocateZeroPool (sizeof (EFI_PCI_REGISTER_VALUE_DATA));
|
||||
|
||||
RegisterPtr->AndValue = Dsc->AndValue;
|
||||
RegisterPtr->OrValue = Dsc->OrValue;
|
||||
|
||||
*(VOID **) Configuration = RegisterPtr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
ListPtr += sizeof (EFI_PCI_REGISTER_VALUE_DESCRIPTOR) / (sizeof (UINT64));
|
||||
}
|
||||
return EFI_UNSUPPORTED;
|
||||
|
||||
case DEVICE_RES_TAG:
|
||||
//
|
||||
// Adjust the pointer to the next item
|
||||
//
|
||||
ListPtr = ListPtr + 1 + ((sizeof (EFI_PCI_REGISTER_VALUE_DESCRIPTOR)) / sizeof (UINT64));
|
||||
break;
|
||||
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
Check the incompatible device list for access width incompatibility and
|
||||
return the configuration
|
||||
|
||||
This function searches the incompatible device list for access width
|
||||
incompatibility according to request information. If the PCI device
|
||||
belongs to the devices list, corresponding configuration informtion
|
||||
will be returned, in the meantime return EFI_SUCCESS.
|
||||
|
||||
@param PciDeviceInfo A pointer to PCI device information.
|
||||
@param AccessType Access type, READ or WRITE.
|
||||
@param Offset The address within the PCI configuration space.
|
||||
@param AccessWidth Access width needs to check incompatibility.
|
||||
@param Configuration Returned information.
|
||||
|
||||
@retval returns EFI_SUCCESS if check incompatible device ok.
|
||||
Otherwise return EFI_UNSUPPORTED.
|
||||
**/
|
||||
RETURN_STATUS
|
||||
EFIAPI
|
||||
PciRegisterAccessCheck (
|
||||
IN EFI_PCI_DEVICE_INFO *PciDeviceInfo,
|
||||
IN UINT64 AccessType,
|
||||
IN UINT64 Offset,
|
||||
IN UINT64 AccessWidth,
|
||||
OUT VOID *Configuration
|
||||
)
|
||||
{
|
||||
EFI_PCI_DEVICE_INFO *Header;
|
||||
UINT64 Tag;
|
||||
UINT64 *ListPtr;
|
||||
EFI_PCI_REGISTER_ACCESS_DATA *RegisterPtr;
|
||||
EFI_PCI_REGISTER_ACCESS_DATA *Dsc;
|
||||
|
||||
ASSERT (PciDeviceInfo != NULL);
|
||||
|
||||
ListPtr = DeviceListForAccessWidth;
|
||||
|
||||
//
|
||||
// Initialize the return value to NULL
|
||||
//
|
||||
* (VOID **) Configuration = NULL;
|
||||
|
||||
while (*ListPtr != LIST_END_TAG) {
|
||||
|
||||
Tag = *ListPtr;
|
||||
|
||||
switch (Tag) {
|
||||
case DEVICE_INF_TAG:
|
||||
Header = (EFI_PCI_DEVICE_INFO *) (ListPtr + 1);
|
||||
ListPtr = ListPtr + 1 + sizeof (EFI_PCI_DEVICE_INFO) / sizeof (UINT64);
|
||||
|
||||
//
|
||||
// Check whether the PCI device matches the device in the incompatible devices list?
|
||||
// If not, ship next
|
||||
//
|
||||
if (DeviceCheck (PciDeviceInfo, Header) != EFI_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Matched an item, check whether access matches?
|
||||
//
|
||||
for (; *ListPtr == DEVICE_RES_TAG;) {
|
||||
ListPtr ++;
|
||||
if (((EFI_PCI_REGISTER_ACCESS_DESCRIPTOR *) ListPtr)->AccessType == AccessType &&
|
||||
((EFI_PCI_REGISTER_ACCESS_DESCRIPTOR *) ListPtr)->AccessWidth == AccessWidth ) {
|
||||
|
||||
Dsc = (EFI_PCI_REGISTER_ACCESS_DATA *) (ListPtr + 2);
|
||||
|
||||
if((Dsc->StartOffset <= Offset) && (Dsc->EndOffset > Offset)) {
|
||||
|
||||
RegisterPtr = AllocateZeroPool (sizeof (EFI_PCI_REGISTER_ACCESS_DATA));
|
||||
|
||||
RegisterPtr->StartOffset = Dsc->StartOffset;
|
||||
RegisterPtr->EndOffset = Dsc->EndOffset;
|
||||
RegisterPtr->Width = Dsc->Width;
|
||||
|
||||
*(VOID **) Configuration = RegisterPtr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
ListPtr += sizeof (EFI_PCI_REGISTER_ACCESS_DESCRIPTOR) / (sizeof (UINT64));
|
||||
}
|
||||
return EFI_UNSUPPORTED;
|
||||
|
||||
case DEVICE_RES_TAG:
|
||||
//
|
||||
// Adjust the pointer to the next item
|
||||
//
|
||||
ListPtr = ListPtr + 1 + ((sizeof (EFI_PCI_REGISTER_ACCESS_DESCRIPTOR)) / sizeof (UINT64));
|
||||
break;
|
||||
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
@@ -0,0 +1,82 @@
|
||||
#/** @file
|
||||
# PCI Incompatible device support Library
|
||||
#
|
||||
# Check PCI incompatible devices and set necessary configuration
|
||||
# Copyright (c) 2007, Intel Corporation.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Defines Section - statements that will be processed to create a Makefile.
|
||||
#
|
||||
################################################################################
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = EdkPciIncompatibleDeviceSupportLib
|
||||
FILE_GUID = 1ca1c1f9-5baf-4204-b6e5-5e24109a4e4e
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PciIncompatibleDeviceSupportLib
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Sources Section - list of files that are required for the build to succeed.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Sources.common]
|
||||
IncompatiblePciDeviceList.h
|
||||
PciIncompatibleDeviceSupportLib.c
|
||||
CommonHeader.h
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Includes Section - list of Include locations that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Includes]
|
||||
$(WORKSPACE)/MdePkg/Include
|
||||
$(WORKSPACE)/IntelFrameworkModulePkg/Include
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Package Dependency Section - list of Package files that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Library Class Section - list of Library Classes that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[LibraryClasses]
|
||||
MemoryAllocationLib
|
||||
DebugLib
|
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>EdkPciIncompatibleDeviceSuppportLib</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>1ca1c1f9-5baf-4204-b6e5-5e24109a4e4e</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>PCI Incompatible device support Library</Abstract>
|
||||
<Description>Check PCI incompatible devices and set necessary configuration</Description>
|
||||
<Copyright>Copyright (c) 2007, Intel Corporation.</Copyright>
|
||||
<License>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.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>EdkPciIncompatibleDeviceSupportLib</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_PRODUCED">
|
||||
<Keyword>PciIncompatibleDeviceSupportLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>MemoryAllocationLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>PciIncompatibleDeviceSupportLib.c</Filename>
|
||||
<Filename>IncompatiblePciDeviceList.h</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
Reference in New Issue
Block a user