]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/PciSegmentLibSegmentInfo/BasePciSegmentLib.c
MdePkg/PciSegmentLib: Add instances that consumes PciSegmentInfoLib
[mirror_edk2.git] / MdePkg / Library / PciSegmentLibSegmentInfo / BasePciSegmentLib.c
1 /** @file
2 Instance of Base PCI Segment Library that support multi-segment PCI configuration access.
3
4 PCI Segment Library that consumes segment information provided by PciSegmentInfoLib to
5 support multi-segment PCI configuration access through enhanced configuration access mechanism.
6
7 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials are
9 licensed and made available under the terms and conditions of
10 the BSD License which accompanies this distribution. The full
11 text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php.
13
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 **/
18
19 #include "PciSegmentLibCommon.h"
20
21 /**
22 Return the virtual address for the physical address.
23
24 @param Address The physical address.
25
26 @retval The virtual address.
27 **/
28 UINTN
29 PciSegmentLibVirtualAddress (
30 IN UINTN Address
31 )
32 {
33 return Address;
34 }
35
36 /**
37 Register a PCI device so PCI configuration registers may be accessed after
38 SetVirtualAddressMap().
39
40 If any reserved bits in Address are set, then ASSERT().
41
42 @param Address The address that encodes the PCI Bus, Device, Function and
43 Register.
44
45 @retval RETURN_SUCCESS The PCI device was registered for runtime access.
46 @retval RETURN_UNSUPPORTED An attempt was made to call this function
47 after ExitBootServices().
48 @retval RETURN_UNSUPPORTED The resources required to access the PCI device
49 at runtime could not be mapped.
50 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to
51 complete the registration.
52
53 **/
54 RETURN_STATUS
55 EFIAPI
56 PciSegmentRegisterForRuntimeAccess (
57 IN UINTN Address
58 )
59 {
60 //
61 // Use PciSegmentLibGetEcamAddress() to validate the Address.
62 //
63 DEBUG_CODE (
64 UINTN Count;
65 PCI_SEGMENT_INFO *SegmentInfo;
66
67 SegmentInfo = GetPciSegmentInfo (&Count);
68 PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count);
69 );
70 return RETURN_SUCCESS;
71 }