]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Copyright (C) 2016, Linaro Ltd. All rights reserved.<BR>\r | |
4 | \r | |
5 | This program and the accompanying materials are licensed and made available\r | |
6 | under the terms and conditions of the BSD License which accompanies this\r | |
7 | distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r | |
11 | WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #ifndef __NON_DISCOVERABLE_PCI_DEVICE_IO_H__\r | |
16 | #define __NON_DISCOVERABLE_PCI_DEVICE_IO_H__\r | |
17 | \r | |
18 | #include <PiDxe.h>\r | |
19 | \r | |
20 | #include <Library/BaseMemoryLib.h>\r | |
21 | #include <Library/DebugLib.h>\r | |
22 | #include <Library/MemoryAllocationLib.h>\r | |
23 | #include <Library/UefiBootServicesTableLib.h>\r | |
24 | #include <Library/UefiLib.h>\r | |
25 | \r | |
26 | #include <IndustryStandard/Pci.h>\r | |
27 | \r | |
28 | #include <Protocol/ComponentName.h>\r | |
29 | #include <Protocol/NonDiscoverableDevice.h>\r | |
30 | #include <Protocol/Cpu.h>\r | |
31 | #include <Protocol/PciIo.h>\r | |
32 | \r | |
33 | #define NON_DISCOVERABLE_PCI_DEVICE_SIG SIGNATURE_32 ('P', 'P', 'I', 'D')\r | |
34 | \r | |
35 | #define NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO(PciIoPointer) \\r | |
36 | CR (PciIoPointer, NON_DISCOVERABLE_PCI_DEVICE, PciIo, \\r | |
37 | NON_DISCOVERABLE_PCI_DEVICE_SIG)\r | |
38 | \r | |
39 | #define PCI_ID_VENDOR_UNKNOWN 0xffff\r | |
40 | #define PCI_ID_DEVICE_DONTCARE 0x0000\r | |
41 | \r | |
42 | #define PCI_MAX_BARS 6\r | |
43 | \r | |
44 | extern EFI_CPU_ARCH_PROTOCOL *mCpu;\r | |
45 | \r | |
46 | typedef struct {\r | |
47 | //\r | |
48 | // The linked-list next pointer\r | |
49 | //\r | |
50 | LIST_ENTRY List;\r | |
51 | //\r | |
52 | // The address of the uncached allocation\r | |
53 | //\r | |
54 | VOID *HostAddress;\r | |
55 | //\r | |
56 | // The number of pages in the allocation\r | |
57 | //\r | |
58 | UINTN NumPages;\r | |
59 | //\r | |
60 | // The attributes of the allocation\r | |
61 | //\r | |
62 | UINT64 Attributes;\r | |
63 | } NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION;\r | |
64 | \r | |
65 | typedef struct {\r | |
66 | UINT32 Signature;\r | |
67 | //\r | |
68 | // The bound non-discoverable device protocol instance\r | |
69 | //\r | |
70 | NON_DISCOVERABLE_DEVICE *Device;\r | |
71 | //\r | |
72 | // The exposed PCI I/O protocol instance.\r | |
73 | //\r | |
74 | EFI_PCI_IO_PROTOCOL PciIo;\r | |
75 | //\r | |
76 | // The emulated PCI config space of the device. Only the minimally required\r | |
77 | // items are assigned.\r | |
78 | //\r | |
79 | PCI_TYPE00 ConfigSpace;\r | |
80 | //\r | |
81 | // The first virtual BAR to assign based on the resources described\r | |
82 | // by the non-discoverable device.\r | |
83 | //\r | |
84 | UINT32 BarOffset;\r | |
85 | //\r | |
86 | // The number of virtual BARs we expose based on the number of\r | |
87 | // resources\r | |
88 | //\r | |
89 | UINT32 BarCount;\r | |
90 | //\r | |
91 | // The PCI I/O attributes for this device\r | |
92 | //\r | |
93 | UINT64 Attributes;\r | |
94 | //\r | |
95 | // Whether this device has been enabled\r | |
96 | //\r | |
97 | BOOLEAN Enabled;\r | |
98 | //\r | |
99 | // Linked list to keep track of uncached allocations performed\r | |
100 | // on behalf of this device\r | |
101 | //\r | |
102 | LIST_ENTRY UncachedAllocationList;\r | |
103 | } NON_DISCOVERABLE_PCI_DEVICE;\r | |
104 | \r | |
105 | VOID\r | |
106 | InitializePciIoProtocol (\r | |
107 | NON_DISCOVERABLE_PCI_DEVICE *Device\r | |
108 | );\r | |
109 | \r | |
110 | extern EFI_COMPONENT_NAME_PROTOCOL gComponentName;\r | |
111 | extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2;\r | |
112 | \r | |
113 | #endif\r |