3 Copyright (C) 2016, Linaro Ltd. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __NON_DISCOVERABLE_PCI_DEVICE_IO_H__
10 #define __NON_DISCOVERABLE_PCI_DEVICE_IO_H__
14 #include <Library/BaseMemoryLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/MemoryAllocationLib.h>
17 #include <Library/UefiBootServicesTableLib.h>
18 #include <Library/UefiLib.h>
20 #include <IndustryStandard/Pci.h>
22 #include <Protocol/ComponentName.h>
23 #include <Protocol/NonDiscoverableDevice.h>
24 #include <Protocol/Cpu.h>
25 #include <Protocol/PciIo.h>
27 #define NON_DISCOVERABLE_PCI_DEVICE_SIG SIGNATURE_32 ('P', 'P', 'I', 'D')
29 #define NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(PciIoPointer) \
30 CR (PciIoPointer, NON_DISCOVERABLE_PCI_DEVICE, PciIo, \
31 NON_DISCOVERABLE_PCI_DEVICE_SIG)
33 #define PCI_ID_VENDOR_UNKNOWN 0xffff
34 #define PCI_ID_DEVICE_DONTCARE 0x0000
36 #define PCI_MAX_BARS 6
38 extern EFI_CPU_ARCH_PROTOCOL
*mCpu
;
42 // The linked-list next pointer
46 // The address of the uncached allocation
50 // The number of pages in the allocation
54 // The attributes of the allocation
57 } NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION
;
62 // The bound non-discoverable device protocol instance
64 NON_DISCOVERABLE_DEVICE
*Device
;
66 // The exposed PCI I/O protocol instance.
68 EFI_PCI_IO_PROTOCOL PciIo
;
70 // The emulated PCI config space of the device. Only the minimally required
71 // items are assigned.
73 PCI_TYPE00 ConfigSpace
;
75 // The first virtual BAR to assign based on the resources described
76 // by the non-discoverable device.
80 // The number of virtual BARs we expose based on the number of
85 // The PCI I/O attributes for this device
89 // Whether this device has been enabled
93 // Linked list to keep track of uncached allocations performed
94 // on behalf of this device
96 LIST_ENTRY UncachedAllocationList
;
98 // Unique ID for this device instance: needed so that we can report unique
99 // segment/bus/device number for each device instance. Note that this number
100 // may change when disconnecting/reconnecting the driver.
103 } NON_DISCOVERABLE_PCI_DEVICE
;
106 Initialize PciIo Protocol.
108 @param Device Point to NON_DISCOVERABLE_PCI_DEVICE instance.
112 InitializePciIoProtocol (
113 NON_DISCOVERABLE_PCI_DEVICE
*Device
116 extern EFI_COMPONENT_NAME_PROTOCOL gComponentName
;
117 extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2
;