1 | /** @file
|
---|
2 | Include file of PciSegmentPciRootBridgeIo Library.
|
---|
3 |
|
---|
4 | Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef __DXE_PCI_SEGMENT_LIB__
|
---|
10 | #define __DXE_PCI_SEGMENT_LIB__
|
---|
11 |
|
---|
12 | #include <Protocol/PciRootBridgeIo.h>
|
---|
13 |
|
---|
14 | #include <Library/PciSegmentLib.h>
|
---|
15 | #include <Library/BaseLib.h>
|
---|
16 | #include <Library/MemoryAllocationLib.h>
|
---|
17 | #include <Library/UefiBootServicesTableLib.h>
|
---|
18 | #include <Library/DebugLib.h>
|
---|
19 |
|
---|
20 | #include <IndustryStandard/Acpi.h>
|
---|
21 |
|
---|
22 | typedef struct {
|
---|
23 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
|
---|
24 | UINT32 SegmentNumber;
|
---|
25 | UINT64 MinBusNumber;
|
---|
26 | UINT64 MaxBusNumber;
|
---|
27 | } PCI_ROOT_BRIDGE_DATA;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | Assert the validity of a PCI Segment address.
|
---|
31 | A valid PCI Segment address should not contain 1's in bits 28..31 and 48..63
|
---|
32 |
|
---|
33 | @param A The address to validate.
|
---|
34 | @param M Additional bits to assert to be zero.
|
---|
35 |
|
---|
36 | **/
|
---|
37 | #define ASSERT_INVALID_PCI_SEGMENT_ADDRESS(A, M) \
|
---|
38 | ASSERT (((A) & (0xffff0000f0000000ULL | (M))) == 0)
|
---|
39 |
|
---|
40 | /**
|
---|
41 | Translate PCI Lib address into format of PCI Root Bridge I/O Protocol
|
---|
42 |
|
---|
43 | @param A The address that encodes the PCI Bus, Device, Function and
|
---|
44 | Register.
|
---|
45 |
|
---|
46 | **/
|
---|
47 | #define PCI_TO_PCI_ROOT_BRIDGE_IO_ADDRESS(A) \
|
---|
48 | ((((UINT32)(A) << 4) & 0xff000000) | (((UINT32)(A) >> 4) & 0x00000700) | (((UINT32)(A) << 1) & 0x001f0000) | (LShiftU64((A) & 0xfff, 32)))
|
---|
49 |
|
---|
50 | #endif
|
---|