]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Ppi/IoMmu.h
MdeModulePkg/S3SmmInitDone.h: Fix copyright coding style error.
[mirror_edk2.git] / MdeModulePkg / Include / Ppi / IoMmu.h
CommitLineData
2b620ee1
JY
1/** @file\r
2 PEI IOMMU PPI.\r
3\r
20b58eb8 4Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r
2b620ee1
JY
5This program and the accompanying materials are licensed and made available under\r
6the terms and conditions of the BSD License that accompanies this distribution.\r
7The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php.\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT 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
42typedef 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
20b58eb8
SZ
72 @retval EFI_NOT_AVAILABLE_YET DMA protection has been enabled, but DMA buffer are\r
73 not available to be allocated yet.\r
2b620ee1
JY
74\r
75**/\r
76typedef\r
77EFI_STATUS\r
78(EFIAPI *EDKII_PEI_IOMMU_SET_ATTRIBUTE)(\r
79 IN EDKII_IOMMU_PPI *This,\r
80 IN VOID *Mapping,\r
81 IN UINT64 IoMmuAccess\r
82 );\r
83\r
84/**\r
85 Provides the controller-specific addresses required to access system memory from a\r
86 DMA bus master.\r
87\r
88 @param This The PPI instance pointer.\r
89 @param Operation Indicates if the bus master is going to read or write to system memory.\r
90 @param HostAddress The system memory address to map to the PCI controller.\r
91 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes\r
92 that were mapped.\r
93 @param DeviceAddress The resulting map address for the bus master PCI controller to use to\r
94 access the hosts HostAddress.\r
95 @param Mapping A resulting value to pass to Unmap().\r
96\r
97 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r
98 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.\r
99 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
100 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
101 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.\r
20b58eb8
SZ
102 @retval EFI_NOT_AVAILABLE_YET DMA protection has been enabled, but DMA buffer are\r
103 not available to be allocated yet.\r
2b620ee1
JY
104\r
105**/\r
106typedef\r
107EFI_STATUS\r
108(EFIAPI *EDKII_PEI_IOMMU_MAP)(\r
109 IN EDKII_IOMMU_PPI *This,\r
110 IN EDKII_IOMMU_OPERATION Operation,\r
111 IN VOID *HostAddress,\r
112 IN OUT UINTN *NumberOfBytes,\r
113 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
114 OUT VOID **Mapping\r
115 );\r
116\r
117/**\r
118 Completes the Map() operation and releases any corresponding resources.\r
119\r
120 @param This The PPI instance pointer.\r
121 @param Mapping The mapping value returned from Map().\r
122\r
123 @retval EFI_SUCCESS The range was unmapped.\r
124 @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().\r
125 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.\r
20b58eb8
SZ
126 @retval EFI_NOT_AVAILABLE_YET DMA protection has been enabled, but DMA buffer are\r
127 not available to be allocated yet.\r
128\r
2b620ee1
JY
129**/\r
130typedef\r
131EFI_STATUS\r
132(EFIAPI *EDKII_PEI_IOMMU_UNMAP)(\r
133 IN EDKII_IOMMU_PPI *This,\r
134 IN VOID *Mapping\r
135 );\r
136\r
137/**\r
138 Allocates pages that are suitable for an OperationBusMasterCommonBuffer or\r
139 OperationBusMasterCommonBuffer64 mapping.\r
140\r
141 @param This The PPI instance pointer.\r
142 @param MemoryType The type of memory to allocate, EfiBootServicesData or\r
143 EfiRuntimeServicesData.\r
144 @param Pages The number of pages to allocate.\r
145 @param HostAddress A pointer to store the base system memory address of the\r
146 allocated range.\r
147 @param Attributes The requested bit mask of attributes for the allocated range.\r
148\r
149 @retval EFI_SUCCESS The requested memory pages were allocated.\r
150 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are\r
b02f14f3 151 MEMORY_WRITE_COMBINE, MEMORY_CACHED and DUAL_ADDRESS_CYCLE.\r
2b620ee1
JY
152 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
153 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r
20b58eb8
SZ
154 @retval EFI_NOT_AVAILABLE_YET DMA protection has been enabled, but DMA buffer are\r
155 not available to be allocated yet.\r
2b620ee1
JY
156\r
157**/\r
158typedef\r
159EFI_STATUS\r
160(EFIAPI *EDKII_PEI_IOMMU_ALLOCATE_BUFFER)(\r
161 IN EDKII_IOMMU_PPI *This,\r
162 IN EFI_MEMORY_TYPE MemoryType,\r
163 IN UINTN Pages,\r
164 IN OUT VOID **HostAddress,\r
165 IN UINT64 Attributes\r
166 );\r
167\r
168/**\r
169 Frees memory that was allocated with AllocateBuffer().\r
170\r
20b58eb8 171 @param This The PPI instance pointer.\r
2b620ee1
JY
172 @param Pages The number of pages to free.\r
173 @param HostAddress The base system memory address of the allocated range.\r
174\r
175 @retval EFI_SUCCESS The requested memory pages were freed.\r
176 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages\r
177 was not allocated with AllocateBuffer().\r
20b58eb8
SZ
178 @retval EFI_NOT_AVAILABLE_YET DMA protection has been enabled, but DMA buffer are\r
179 not available to be allocated yet.\r
2b620ee1
JY
180\r
181**/\r
182typedef\r
183EFI_STATUS\r
184(EFIAPI *EDKII_PEI_IOMMU_FREE_BUFFER)(\r
185 IN EDKII_IOMMU_PPI *This,\r
186 IN UINTN Pages,\r
187 IN VOID *HostAddress\r
188 );\r
189\r
190///\r
191/// IOMMU PPI structure.\r
192///\r
193struct _EDKII_IOMMU_PPI {\r
194 UINT64 Revision;\r
195 EDKII_PEI_IOMMU_SET_ATTRIBUTE SetAttribute;\r
196 EDKII_PEI_IOMMU_MAP Map;\r
197 EDKII_PEI_IOMMU_UNMAP Unmap;\r
198 EDKII_PEI_IOMMU_ALLOCATE_BUFFER AllocateBuffer;\r
199 EDKII_PEI_IOMMU_FREE_BUFFER FreeBuffer;\r
200};\r
201\r
202///\r
203/// IOMMU PPI GUID variable.\r
204///\r
205extern EFI_GUID gEdkiiIoMmuPpiGuid;\r
206\r
207#endif\r