summaryrefslogtreecommitdiffstats
path: root/MdePkg/Include/Library/RegisterFilterLib.h
blob: 75f359c5c5de06609709cdafd6d2d5f5b2cd5c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/** @file
  Public include file for the Port IO/MMIO/MSR RegisterFilterLib.

Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>

SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef REGISTER_FILTER_LIB_H_
#define REGISTER_FILTER_LIB_H_

typedef enum {
  FilterWidth8,
  FilterWidth16,
  FilterWidth32,
  FilterWidth64
} FILTER_IO_WIDTH;

/**
  Filter IO read operation before read IO port.
  It is used to filter IO read operation.

  It will return the flag to decide whether require read real IO port.
  It can be used for emulation environment.

  @param[in]       Width    Signifies the width of the I/O operation.
  @param[in]       Address  The base address of the I/O operation.
  @param[in]       Buffer   The destination buffer to store the results.

  @retval TRUE         Need to excute the IO read.
  @retval FALSE        Skip the IO read.

**/
BOOLEAN
EFIAPI
FilterBeforeIoRead (
  IN FILTER_IO_WIDTH  Width,
  IN UINTN            Address,
  IN OUT VOID         *Buffer
  );

/**
  Trace IO read operation after read IO port.
  It is used to trace IO operation.

  @param[in]       Width    Signifies the width of the I/O operation.
  @param[in]       Address  The base address of the I/O operation.
  @param[in]       Buffer   The destination buffer to store the results.

**/
VOID
EFIAPI
FilterAfterIoRead (
  IN FILTER_IO_WIDTH  Width,
  IN UINTN            Address,
  IN VOID             *Buffer
  );

/**
  Filter IO Write operation before wirte IO port.
  It is used to filter IO operation.

  It will return the flag to decide whether require read write IO port.
  It can be used for emulation environment.

  @param[in]       Width    Signifies the width of the I/O operation.
  @param[in]       Address  The base address of the I/O operation.
  @param[in]       Buffer   The source buffer from which to BeforeWrite data.

  @retval TRUE         Need to excute the IO write.
  @retval FALSE        Skip the IO write.

**/
BOOLEAN
EFIAPI
FilterBeforeIoWrite (
  IN FILTER_IO_WIDTH  Width,
  IN UINTN            Address,
  IN VOID             *Buffer
  );

/**
Trace IO Write operation after wirte IO port.
It is used to trace IO operation.

@param[in]       Width    Signifies the width of the I/O operation.
@param[in]       Address  The base address of the I/O operation.
@param[in]       Buffer   The source buffer from which to BeforeWrite data.

**/
VOID
EFIAPI
FilterAfterIoWrite (
  IN FILTER_IO_WIDTH  Width,
  IN UINTN            Address,
  IN VOID             *Buffer
  );

/**
  Filter memory IO before Read operation.

  It will return the flag to decide whether require read real MMIO.
  It can be used for emulation environment.

  @param[in]       Width    Signifies the width of the memory I/O operation.
  @param[in]       Address  The base address of the memory I/O operation.
  @param[in]       Buffer   The destination buffer to store the results.

  @retval TRUE         Need to excute the MMIO read.
  @retval FALSE        Skip the MMIO read.

**/
BOOLEAN
EFIAPI
FilterBeforeMmIoRead (
  IN FILTER_IO_WIDTH  Width,
  IN UINTN            Address,
  IN OUT VOID         *Buffer
  );

/**
  Tracer memory IO after read operation

  @param[in]       Width    Signifies the width of the memory I/O operation.
  @param[in]       Address  The base address of the memory I/O operation.
  @param[in]       Buffer   The destination buffer to store the results.

**/
VOID
EFIAPI
FilterAfterMmIoRead (
  IN FILTER_IO_WIDTH  Width,
  IN UINTN            Address,
  IN VOID             *Buffer
  );

/**
  Filter memory IO before write operation

  It will return the flag to decide whether require wirte real MMIO.
  It can be used for emulation environment.

  @param[in]       Width    Signifies the width of the memory I/O operation.
  @param[in]       Address  The base address of the memory I/O operation.
  @param[in]       Buffer   The source buffer from which to BeforeWrite data.

  @retval TRUE         Need to excute the MMIO write.
  @retval FALSE        Skip the MMIO write.

**/
BOOLEAN
EFIAPI
FilterBeforeMmIoWrite (
  IN FILTER_IO_WIDTH  Width,
  IN UINTN            Address,
  IN VOID             *Buffer
  );

/**
  Tracer memory IO after write operation

  @param[in]       Width    Signifies the width of the memory I/O operation.
  @param[in]       Address  The base address of the memory I/O operation.
  @param[in]       Buffer   The source buffer from which to BeforeWrite data.

**/
VOID
EFIAPI
FilterAfterMmIoWrite (
  IN FILTER_IO_WIDTH  Width,
  IN UINTN            Address,
  IN VOID             *Buffer
  );

/**
  Filter MSR before read operation.

  It will return the flag to decide whether require read real MSR.
  It can be used for emulation environment.

  @param  Index                     The 8-bit Machine Specific Register index to BeforeWrite.
  @param  Value                     The 64-bit value to BeforeRead from the Machine Specific Register.

  @retval TRUE         Need to excute the MSR read.
  @retval FALSE        Skip the MSR read.

**/
BOOLEAN
EFIAPI
FilterBeforeMsrRead (
  IN UINT32      Index,
  IN OUT UINT64  *Value
  );

/**
  Trace MSR after read operation

  @param  Index                     The 8-bit Machine Specific Register index to BeforeWrite.
  @param  Value                     The 64-bit value to BeforeRead from the Machine Specific Register.

**/
VOID
EFIAPI
FilterAfterMsrRead (
  IN UINT32  Index,
  IN UINT64  *Value
  );

/**
  Filter MSR before write operation

  It will return the flag to decide whether require write real MSR.
  It can be used for emulation environment.

  @param  Index                     The 8-bit Machine Specific Register index to BeforeWrite.
  @param  Value                     The 64-bit value to BeforeWrite to the Machine Specific Register.

  @retval TRUE         Need to excute the MSR write.
  @retval FALSE        Skip the MSR write.

**/
BOOLEAN
EFIAPI
FilterBeforeMsrWrite (
  IN UINT32  Index,
  IN UINT64  *Value
  );

/**
  Trace MSR after write operation

  @param  Index                     The 8-bit Machine Specific Register index to BeforeWrite.
  @param  Value                     The 64-bit value to BeforeWrite to the Machine Specific Register.

**/
VOID
EFIAPI
FilterAfterMsrWrite (
  IN UINT32  Index,
  IN UINT64  *Value
  );

#endif // REGISTER_FILTER_LIB_H_