OvmfPkg: introduce PciCapLib
Add a library class, and a BASE lib instance, to work more easily with PCI capabilities in PCI config space. Functions are provided to parse capabilities lists, and to locate, describe, read and write capabilities. PCI config space access is abstracted away. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Suggested-by: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
1009
OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c
Normal file
1009
OvmfPkg/Library/BasePciCapLib/BasePciCapLib.c
Normal file
File diff suppressed because it is too large
Load Diff
60
OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h
Normal file
60
OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/** @file
|
||||
Work with PCI capabilities in PCI config space -- internal type definitions.
|
||||
|
||||
Copyright (C) 2018, Red Hat, Inc.
|
||||
|
||||
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 __BASE_PCI_CAP_LIB_H__
|
||||
#define __BASE_PCI_CAP_LIB_H__
|
||||
|
||||
#include <Library/OrderedCollectionLib.h>
|
||||
|
||||
#include <Library/PciCapLib.h>
|
||||
|
||||
//
|
||||
// Structure that uniquely identifies a capability instance and serves as key
|
||||
// for insertion and lookup.
|
||||
//
|
||||
typedef struct {
|
||||
PCI_CAP_DOMAIN Domain;
|
||||
UINT16 CapId;
|
||||
UINT16 Instance;
|
||||
} PCI_CAP_KEY;
|
||||
|
||||
//
|
||||
// In Instance==0 PCI_CAP objects, store NumInstances directly. In Instance>0
|
||||
// PCI_CAP objects, link Instance#0 of the same (Domain, CapId). This way
|
||||
// NumInstances needs maintenance in one object only, per (Domain, CapId) pair.
|
||||
//
|
||||
typedef union {
|
||||
UINT16 NumInstances;
|
||||
PCI_CAP *InstanceZero;
|
||||
} PCI_CAP_NUM_INSTANCES;
|
||||
|
||||
//
|
||||
// Complete the incomplete PCI_CAP structure here.
|
||||
//
|
||||
struct PCI_CAP {
|
||||
PCI_CAP_KEY Key;
|
||||
PCI_CAP_NUM_INSTANCES NumInstancesUnion;
|
||||
UINT16 Offset;
|
||||
UINT16 MaxSizeHint;
|
||||
UINT8 Version;
|
||||
};
|
||||
|
||||
//
|
||||
// Complete the incomplete PCI_CAP_LIST structure here.
|
||||
//
|
||||
struct PCI_CAP_LIST {
|
||||
ORDERED_COLLECTION *Capabilities;
|
||||
};
|
||||
|
||||
#endif // __BASE_PCI_CAP_LIB_H__
|
38
OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
Normal file
38
OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
Normal file
@@ -0,0 +1,38 @@
|
||||
## @file
|
||||
# Work with PCI capabilities in PCI config space.
|
||||
#
|
||||
# Provides functions to parse capabilities lists, and to locate, describe, read
|
||||
# and write capabilities. PCI config space access is abstracted away.
|
||||
#
|
||||
# Copyright (C) 2018, Red Hat, Inc.
|
||||
#
|
||||
# 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 = 1.27
|
||||
BASE_NAME = BasePciCapLib
|
||||
FILE_GUID = 6957540D-F7B5-4D5B-BEE4-FC14114DCD3C
|
||||
MODULE_TYPE = BASE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PciCapLib
|
||||
|
||||
[Sources]
|
||||
BasePciCapLib.h
|
||||
BasePciCapLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
OvmfPkg/OvmfPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
MemoryAllocationLib
|
||||
OrderedCollectionLib
|
Reference in New Issue
Block a user