IntelSiliconPkg/VtdPmrPei: Add premem support.
[mirror_edk2.git] / IntelSiliconPkg / Feature / VTd / IntelVTdPmrPei / IntelVTdPmrPei.h
CommitLineData
3f5ed3fa
JY
1/** @file\r
2 The definition for DMA access Library.\r
3\r
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this 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,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __DMA_ACCESS_LIB_H__\r
16#define __DMA_ACCESS_LIB_H__\r
17\r
8e9da4ba 18typedef struct {\r
a1e7cd0b
JY
19 EFI_ACPI_DMAR_HEADER *AcpiDmarTable;\r
20 UINT64 EngineMask;\r
8e9da4ba
JY
21 UINT8 HostAddressWidth;\r
22 UINTN VTdEngineCount;\r
23 UINT64 VTdEngineAddress[1];\r
24} VTD_INFO;\r
25\r
3f5ed3fa
JY
26/**\r
27 Set DMA protected region.\r
28\r
a1e7cd0b 29 @param VTdInfo The VTd engine context information.\r
8e9da4ba 30 @param EngineMask The mask of the VTd engine to be accessed.\r
3f5ed3fa
JY
31 @param LowMemoryBase The protected low memory region base.\r
32 @param LowMemoryLength The protected low memory region length.\r
33 @param HighMemoryBase The protected high memory region base.\r
34 @param HighMemoryLength The protected high memory region length.\r
35\r
36 @retval EFI_SUCCESS The DMA protection is set.\r
37 @retval EFI_UNSUPPORTED The DMA protection is not set.\r
38**/\r
39EFI_STATUS\r
40SetDmaProtectedRange (\r
a1e7cd0b 41 IN VTD_INFO *VTdInfo,\r
8e9da4ba 42 IN UINT64 EngineMask,\r
3f5ed3fa
JY
43 IN UINT32 LowMemoryBase,\r
44 IN UINT32 LowMemoryLength,\r
45 IN UINT64 HighMemoryBase,\r
46 IN UINT64 HighMemoryLength\r
47 );\r
48\r
49/**\r
50 Diable DMA protection.\r
51\r
a1e7cd0b 52 @param VTdInfo The VTd engine context information.\r
8e9da4ba
JY
53 @param EngineMask The mask of the VTd engine to be accessed.\r
54\r
3f5ed3fa
JY
55 @retval DMA protection is disabled.\r
56**/\r
57EFI_STATUS\r
58DisableDmaProtection (\r
a1e7cd0b
JY
59 IN VTD_INFO *VTdInfo,\r
60 IN UINT64 EngineMask\r
61 );\r
62\r
63/**\r
64 Return if the DMA protection is enabled.\r
65\r
66 @param VTdInfo The VTd engine context information.\r
67 @param EngineMask The mask of the VTd engine to be accessed.\r
68\r
69 @retval TRUE DMA protection is enabled in at least one VTd engine.\r
70 @retval FALSE DMA protection is disabled in all VTd engines.\r
71**/\r
72UINT64\r
73GetDmaProtectionEnabledEngineMask (\r
74 IN VTD_INFO *VTdInfo,\r
8e9da4ba 75 IN UINT64 EngineMask\r
3f5ed3fa
JY
76 );\r
77\r
78/**\r
79 Get protected low memory alignment.\r
80\r
a1e7cd0b 81 @param VTdInfo The VTd engine context information.\r
8e9da4ba
JY
82 @param EngineMask The mask of the VTd engine to be accessed.\r
83\r
3f5ed3fa
JY
84 @return protected low memory alignment.\r
85**/\r
86UINT32\r
87GetLowMemoryAlignment (\r
a1e7cd0b 88 IN VTD_INFO *VTdInfo,\r
8e9da4ba 89 IN UINT64 EngineMask\r
3f5ed3fa
JY
90 );\r
91\r
92/**\r
93 Get protected high memory alignment.\r
94\r
a1e7cd0b 95 @param VTdInfo The VTd engine context information.\r
8e9da4ba
JY
96 @param EngineMask The mask of the VTd engine to be accessed.\r
97\r
3f5ed3fa
JY
98 @return protected high memory alignment.\r
99**/\r
100UINT64\r
101GetHighMemoryAlignment (\r
a1e7cd0b
JY
102 IN VTD_INFO *VTdInfo,\r
103 IN UINT64 EngineMask\r
104 );\r
105\r
106/**\r
107 Enable VTd translation table protection.\r
108\r
109 @param VTdInfo The VTd engine context information.\r
110 @param EngineMask The mask of the VTd engine to be accessed.\r
111**/\r
112VOID\r
113EnableVTdTranslationProtection (\r
114 IN VTD_INFO *VTdInfo,\r
115 IN UINT64 EngineMask\r
116 );\r
117\r
118/**\r
119 Disable VTd translation table protection.\r
120\r
121 @param VTdInfo The VTd engine context information.\r
122 @param EngineMask The mask of the VTd engine to be accessed.\r
123**/\r
124VOID\r
125DisableVTdTranslationProtection (\r
126 IN VTD_INFO *VTdInfo,\r
8e9da4ba 127 IN UINT64 EngineMask\r
3f5ed3fa
JY
128 );\r
129\r
a1e7cd0b
JY
130/**\r
131 Parse DMAR DRHD table.\r
132\r
133 @param[in] AcpiDmarTable DMAR ACPI table\r
134\r
135 @return EFI_SUCCESS The DMAR DRHD table is parsed.\r
136**/\r
137EFI_STATUS\r
138ParseDmarAcpiTableDrhd (\r
139 IN EFI_ACPI_DMAR_HEADER *AcpiDmarTable\r
140 );\r
141\r
142/**\r
143 Parse DMAR DRHD table.\r
144\r
145 @param VTdInfo The VTd engine context information.\r
146**/\r
147VOID\r
148ParseDmarAcpiTableRmrr (\r
149 IN VTD_INFO *VTdInfo\r
150 );\r
151\r
152/**\r
153 Dump DMAR ACPI table.\r
154\r
155 @param[in] Dmar DMAR ACPI table\r
156**/\r
157VOID\r
158DumpAcpiDMAR (\r
159 IN EFI_ACPI_DMAR_HEADER *Dmar\r
160 );\r
161\r
162/**\r
163 Get the highest memory.\r
164\r
165 @return the highest memory.\r
166**/\r
167UINT64\r
168GetTopMemory (\r
169 VOID\r
170 );\r
171\r
172extern EFI_GUID mVTdInfoGuid;\r
173\r
3f5ed3fa
JY
174#endif\r
175\r