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