]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Include/Library/PciCapPciSegmentLib.h
OvmfPkg: introduce PciCapPciSegmentLib
[mirror_edk2.git] / OvmfPkg / Include / Library / PciCapPciSegmentLib.h
1 /** @file
2 Library class layered on top of PciCapLib that allows clients to plug a
3 PciSegmentLib backend into PciCapLib, for config space access.
4
5 Copyright (C) 2018, Red Hat, Inc.
6
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 **/
15
16 #ifndef __PCI_CAP_PCI_SEGMENT_LIB_H__
17 #define __PCI_CAP_PCI_SEGMENT_LIB_H__
18
19 #include <Library/PciCapLib.h>
20
21
22 /**
23 Create a PCI_CAP_DEV object from the PCI Segment:Bus:Device.Function
24 quadruplet. The config space accessors are based upon PciSegmentLib.
25
26 @param[in] MaxDomain If MaxDomain is PciCapExtended, then
27 PciDevice->ReadConfig() and PciDevice->WriteConfig()
28 will delegate extended config space accesses too to
29 PciSegmentReadBuffer() and PciSegmentWriteBuffer(),
30 respectively. Otherwise, PciDevice->ReadConfig() and
31 PciDevice->WriteConfig() will reject accesses to
32 extended config space with RETURN_UNSUPPORTED, without
33 calling PciSegmentReadBuffer() or
34 PciSegmentWriteBuffer(). By setting MaxDomain to
35 PciCapNormal, the platform can prevent undefined
36 PciSegmentLib behavior when the PCI root bridge under
37 the PCI device at Segment:Bus:Device.Function doesn't
38 support extended config space.
39
40 @param[in] Segment 16-bit wide segment number.
41
42 @param[in] Bus 8-bit wide bus number.
43
44 @param[in] Device 5-bit wide device number.
45
46 @param[in] Function 3-bit wide function number.
47
48 @param[out] PciDevice The PCI_CAP_DEV object constructed as described above.
49 PciDevice can be passed to the PciCapLib APIs.
50
51 @retval RETURN_SUCCESS PciDevice has been constructed and output.
52
53 @retval RETURN_INVALID_PARAMETER Device or Function does not fit in the
54 permitted number of bits.
55
56 @retval RETURN_OUT_OF_RESOURCES Memory allocation failed.
57 **/
58 RETURN_STATUS
59 EFIAPI
60 PciCapPciSegmentDeviceInit (
61 IN PCI_CAP_DOMAIN MaxDomain,
62 IN UINT16 Segment,
63 IN UINT8 Bus,
64 IN UINT8 Device,
65 IN UINT8 Function,
66 OUT PCI_CAP_DEV **PciDevice
67 );
68
69
70 /**
71 Free the resources used by PciDevice.
72
73 @param[in] PciDevice The PCI_CAP_DEV object to free, originally produced by
74 PciCapPciSegmentDeviceInit().
75 **/
76 VOID
77 EFIAPI
78 PciCapPciSegmentDeviceUninit (
79 IN PCI_CAP_DEV *PciDevice
80 );
81
82 #endif // __PCI_CAP_PCI_SEGMENT_LIB_H__