summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/Library/BasePciCapLib/BasePciCapLib.h
blob: e84dab62c54b6748978605e044abbcd62f248851 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/** @file
  Work with PCI capabilities in PCI config space -- internal type definitions.

  Copyright (C) 2018, Red Hat, Inc.

  SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#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__