]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | PEI IOMMU PPI.\r | |
3 | \r | |
4 | Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials are licensed and made available under\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
7 | 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,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | \r | |
16 | #ifndef __PEI_IOMMU_H__\r | |
17 | #define __PEI_IOMMU_H__\r | |
18 | \r | |
19 | //\r | |
20 | // for EFI_ALLOCATE_TYPE\r | |
21 | //\r | |
22 | #include <Uefi.h>\r | |
23 | \r | |
24 | //\r | |
25 | // Include protocol for common definition\r | |
26 | // EDKII_IOMMU_ACCESS_xxx\r | |
27 | // EDKII_IOMMU_OPERATION\r | |
28 | //\r | |
29 | #include <Protocol/IoMmu.h>\r | |
30 | \r | |
31 | //\r | |
32 | // IOMMU Ppi GUID value\r | |
33 | //\r | |
34 | #define EDKII_IOMMU_PPI_GUID \\r | |
35 | { \\r | |
36 | 0x70b0af26, 0xf847, 0x4bb6, { 0xaa, 0xb9, 0xcd, 0xe8, 0x4f, 0xc6, 0x14, 0x31 } \\r | |
37 | }\r | |
38 | \r | |
39 | //\r | |
40 | // Forward reference for pure ANSI compatability\r | |
41 | //\r | |
42 | typedef struct _EDKII_IOMMU_PPI EDKII_IOMMU_PPI;\r | |
43 | \r | |
44 | //\r | |
45 | // Revision The revision to which the IOMMU interface adheres.\r | |
46 | // All future revisions must be backwards compatible.\r | |
47 | // If a future version is not back wards compatible it is not the same GUID.\r | |
48 | //\r | |
49 | #define EDKII_IOMMU_PPI_REVISION 0x00010000\r | |
50 | \r | |
51 | /**\r | |
52 | Set IOMMU attribute for a system memory.\r | |
53 | \r | |
54 | If the IOMMU PPI exists, the system memory cannot be used\r | |
55 | for DMA by default.\r | |
56 | \r | |
57 | When a device requests a DMA access for a system memory,\r | |
58 | the device driver need use SetAttribute() to update the IOMMU\r | |
59 | attribute to request DMA access (read and/or write).\r | |
60 | \r | |
61 | @param[in] This The PPI instance pointer.\r | |
62 | @param[in] Mapping The mapping value returned from Map().\r | |
63 | @param[in] IoMmuAccess The IOMMU access.\r | |
64 | \r | |
65 | @retval EFI_SUCCESS The IoMmuAccess is set for the memory range specified by DeviceAddress and Length.\r | |
66 | @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().\r | |
67 | @retval EFI_INVALID_PARAMETER IoMmuAccess specified an illegal combination of access.\r | |
68 | @retval EFI_UNSUPPORTED The bit mask of IoMmuAccess is not supported by the IOMMU.\r | |
69 | @retval EFI_UNSUPPORTED The IOMMU does not support the memory range specified by Mapping.\r | |
70 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to modify the IOMMU access.\r | |
71 | @retval EFI_DEVICE_ERROR The IOMMU device reported an error while attempting the operation.\r | |
72 | \r | |
73 | **/\r | |
74 | typedef\r | |
75 | EFI_STATUS\r | |
76 | (EFIAPI *EDKII_PEI_IOMMU_SET_ATTRIBUTE)(\r | |
77 | IN EDKII_IOMMU_PPI *This,\r | |
78 | IN VOID *Mapping,\r | |
79 | IN UINT64 IoMmuAccess\r | |
80 | );\r | |
81 | \r | |
82 | /**\r | |
83 | Provides the controller-specific addresses required to access system memory from a\r | |
84 | DMA bus master.\r | |
85 | \r | |
86 | @param This The PPI instance pointer.\r | |
87 | @param Operation Indicates if the bus master is going to read or write to system memory.\r | |
88 | @param HostAddress The system memory address to map to the PCI controller.\r | |
89 | @param NumberOfBytes On input the number of bytes to map. On output the number of bytes\r | |
90 | that were mapped.\r | |
91 | @param DeviceAddress The resulting map address for the bus master PCI controller to use to\r | |
92 | access the hosts HostAddress.\r | |
93 | @param Mapping A resulting value to pass to Unmap().\r | |
94 | \r | |
95 | @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r | |
96 | @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.\r | |
97 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
98 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
99 | @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.\r | |
100 | \r | |
101 | **/\r | |
102 | typedef\r | |
103 | EFI_STATUS\r | |
104 | (EFIAPI *EDKII_PEI_IOMMU_MAP)(\r | |
105 | IN EDKII_IOMMU_PPI *This,\r | |
106 | IN EDKII_IOMMU_OPERATION Operation,\r | |
107 | IN VOID *HostAddress,\r | |
108 | IN OUT UINTN *NumberOfBytes,\r | |
109 | OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r | |
110 | OUT VOID **Mapping\r | |
111 | );\r | |
112 | \r | |
113 | /**\r | |
114 | Completes the Map() operation and releases any corresponding resources.\r | |
115 | \r | |
116 | @param This The PPI instance pointer.\r | |
117 | @param Mapping The mapping value returned from Map().\r | |
118 | \r | |
119 | @retval EFI_SUCCESS The range was unmapped.\r | |
120 | @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().\r | |
121 | @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.\r | |
122 | **/\r | |
123 | typedef\r | |
124 | EFI_STATUS\r | |
125 | (EFIAPI *EDKII_PEI_IOMMU_UNMAP)(\r | |
126 | IN EDKII_IOMMU_PPI *This,\r | |
127 | IN VOID *Mapping\r | |
128 | );\r | |
129 | \r | |
130 | /**\r | |
131 | Allocates pages that are suitable for an OperationBusMasterCommonBuffer or\r | |
132 | OperationBusMasterCommonBuffer64 mapping.\r | |
133 | \r | |
134 | @param This The PPI instance pointer.\r | |
135 | @param MemoryType The type of memory to allocate, EfiBootServicesData or\r | |
136 | EfiRuntimeServicesData.\r | |
137 | @param Pages The number of pages to allocate.\r | |
138 | @param HostAddress A pointer to store the base system memory address of the\r | |
139 | allocated range.\r | |
140 | @param Attributes The requested bit mask of attributes for the allocated range.\r | |
141 | \r | |
142 | @retval EFI_SUCCESS The requested memory pages were allocated.\r | |
143 | @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are\r | |
144 | MEMORY_WRITE_COMBINE and MEMORY_CACHED.\r | |
145 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
146 | @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r | |
147 | \r | |
148 | **/\r | |
149 | typedef\r | |
150 | EFI_STATUS\r | |
151 | (EFIAPI *EDKII_PEI_IOMMU_ALLOCATE_BUFFER)(\r | |
152 | IN EDKII_IOMMU_PPI *This,\r | |
153 | IN EFI_MEMORY_TYPE MemoryType,\r | |
154 | IN UINTN Pages,\r | |
155 | IN OUT VOID **HostAddress,\r | |
156 | IN UINT64 Attributes\r | |
157 | );\r | |
158 | \r | |
159 | /**\r | |
160 | Frees memory that was allocated with AllocateBuffer().\r | |
161 | \r | |
162 | @param This The protocol instance pointer.\r | |
163 | @param Pages The number of pages to free.\r | |
164 | @param HostAddress The base system memory address of the allocated range.\r | |
165 | \r | |
166 | @retval EFI_SUCCESS The requested memory pages were freed.\r | |
167 | @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages\r | |
168 | was not allocated with AllocateBuffer().\r | |
169 | \r | |
170 | **/\r | |
171 | typedef\r | |
172 | EFI_STATUS\r | |
173 | (EFIAPI *EDKII_PEI_IOMMU_FREE_BUFFER)(\r | |
174 | IN EDKII_IOMMU_PPI *This,\r | |
175 | IN UINTN Pages,\r | |
176 | IN VOID *HostAddress\r | |
177 | );\r | |
178 | \r | |
179 | ///\r | |
180 | /// IOMMU PPI structure.\r | |
181 | ///\r | |
182 | struct _EDKII_IOMMU_PPI {\r | |
183 | UINT64 Revision;\r | |
184 | EDKII_PEI_IOMMU_SET_ATTRIBUTE SetAttribute;\r | |
185 | EDKII_PEI_IOMMU_MAP Map;\r | |
186 | EDKII_PEI_IOMMU_UNMAP Unmap;\r | |
187 | EDKII_PEI_IOMMU_ALLOCATE_BUFFER AllocateBuffer;\r | |
188 | EDKII_PEI_IOMMU_FREE_BUFFER FreeBuffer;\r | |
189 | };\r | |
190 | \r | |
191 | ///\r | |
192 | /// IOMMU PPI GUID variable.\r | |
193 | ///\r | |
194 | extern EFI_GUID gEdkiiIoMmuPpiGuid;\r | |
195 | \r | |
196 | #endif\r |