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