Commit | Line | Data |
---|---|---|
ba9f8351 | 1 | /** @file\r |
2 | High-level Io/Mmio functions.\r | |
3 | \r | |
4 | All assertions for bit field operations are handled bit field functions in the\r | |
5 | Base Library.\r | |
6 | \r | |
94952554 | 7 | Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
ba9f8351 | 9 | \r |
10 | **/\r | |
11 | \r | |
ba9f8351 | 12 | #include "DxeCpuIo2LibInternal.h"\r |
13 | \r | |
14 | /**\r | |
15 | Reads an 8-bit I/O port, performs a bitwise OR, and writes the\r | |
16 | result back to the 8-bit I/O port.\r | |
17 | \r | |
18 | Reads the 8-bit I/O port specified by Port, performs a bitwise OR\r | |
19 | between the read result and the value specified by OrData, and writes the\r | |
20 | result to the 8-bit I/O port specified by Port. The value written to the I/O\r | |
21 | port is returned. This function must guarantee that all I/O read and write\r | |
22 | operations are serialized.\r | |
23 | \r | |
24 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
25 | \r | |
26 | @param Port The I/O port to write.\r | |
27 | @param OrData The value to OR with the read value from the I/O port.\r | |
28 | \r | |
29 | @return The value written back to the I/O port.\r | |
30 | \r | |
31 | **/\r | |
32 | UINT8\r | |
33 | EFIAPI\r | |
34 | IoOr8 (\r | |
2f88bd3a MK |
35 | IN UINTN Port,\r |
36 | IN UINT8 OrData\r | |
ba9f8351 | 37 | )\r |
38 | {\r | |
2f88bd3a | 39 | return IoWrite8 (Port, (UINT8)(IoRead8 (Port) | OrData));\r |
ba9f8351 | 40 | }\r |
41 | \r | |
42 | /**\r | |
43 | Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back\r | |
44 | to the 8-bit I/O port.\r | |
45 | \r | |
46 | Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r | |
47 | the read result and the value specified by AndData, and writes the result to\r | |
48 | the 8-bit I/O port specified by Port. The value written to the I/O port is\r | |
49 | returned. This function must guarantee that all I/O read and write operations\r | |
50 | are serialized.\r | |
51 | \r | |
52 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
53 | \r | |
54 | @param Port The I/O port to write.\r | |
55 | @param AndData The value to AND with the read value from the I/O port.\r | |
56 | \r | |
57 | @return The value written back to the I/O port.\r | |
58 | \r | |
59 | **/\r | |
60 | UINT8\r | |
61 | EFIAPI\r | |
62 | IoAnd8 (\r | |
2f88bd3a MK |
63 | IN UINTN Port,\r |
64 | IN UINT8 AndData\r | |
ba9f8351 | 65 | )\r |
66 | {\r | |
2f88bd3a | 67 | return IoWrite8 (Port, (UINT8)(IoRead8 (Port) & AndData));\r |
ba9f8351 | 68 | }\r |
69 | \r | |
70 | /**\r | |
71 | Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise\r | |
72 | inclusive OR, and writes the result back to the 8-bit I/O port.\r | |
73 | \r | |
74 | Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r | |
75 | the read result and the value specified by AndData, performs a bitwise OR\r | |
76 | between the result of the AND operation and the value specified by OrData,\r | |
77 | and writes the result to the 8-bit I/O port specified by Port. The value\r | |
78 | written to the I/O port is returned. This function must guarantee that all\r | |
79 | I/O read and write operations are serialized.\r | |
80 | \r | |
81 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
82 | \r | |
83 | @param Port The I/O port to write.\r | |
84 | @param AndData The value to AND with the read value from the I/O port.\r | |
85 | @param OrData The value to OR with the result of the AND operation.\r | |
86 | \r | |
87 | @return The value written back to the I/O port.\r | |
88 | \r | |
89 | **/\r | |
90 | UINT8\r | |
91 | EFIAPI\r | |
92 | IoAndThenOr8 (\r | |
2f88bd3a MK |
93 | IN UINTN Port,\r |
94 | IN UINT8 AndData,\r | |
95 | IN UINT8 OrData\r | |
ba9f8351 | 96 | )\r |
97 | {\r | |
2f88bd3a | 98 | return IoWrite8 (Port, (UINT8)((IoRead8 (Port) & AndData) | OrData));\r |
ba9f8351 | 99 | }\r |
100 | \r | |
101 | /**\r | |
102 | Reads a bit field of an I/O register.\r | |
103 | \r | |
104 | Reads the bit field in an 8-bit I/O register. The bit field is specified by\r | |
105 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
106 | \r | |
107 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
108 | If StartBit is greater than 7, then ASSERT().\r | |
109 | If EndBit is greater than 7, then ASSERT().\r | |
110 | If EndBit is less than StartBit, then ASSERT().\r | |
111 | \r | |
112 | @param Port The I/O port to read.\r | |
113 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
114 | Range 0..7.\r | |
115 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
116 | Range 0..7.\r | |
117 | \r | |
118 | @return The value read.\r | |
119 | \r | |
120 | **/\r | |
121 | UINT8\r | |
122 | EFIAPI\r | |
123 | IoBitFieldRead8 (\r | |
2f88bd3a MK |
124 | IN UINTN Port,\r |
125 | IN UINTN StartBit,\r | |
126 | IN UINTN EndBit\r | |
ba9f8351 | 127 | )\r |
128 | {\r | |
129 | return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit);\r | |
130 | }\r | |
131 | \r | |
132 | /**\r | |
133 | Writes a bit field to an I/O register.\r | |
134 | \r | |
135 | Writes Value to the bit field of the I/O register. The bit field is specified\r | |
136 | by the StartBit and the EndBit. All other bits in the destination I/O\r | |
137 | register are preserved. The value written to the I/O port is returned. Extra\r | |
138 | left bits in Value are stripped.\r | |
139 | \r | |
140 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
141 | If StartBit is greater than 7, then ASSERT().\r | |
142 | If EndBit is greater than 7, then ASSERT().\r | |
143 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 144 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 145 | \r |
146 | @param Port The I/O port to write.\r | |
147 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
148 | Range 0..7.\r | |
149 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
150 | Range 0..7.\r | |
2fc59a00 | 151 | @param Value The new value of the bit field.\r |
ba9f8351 | 152 | \r |
153 | @return The value written back to the I/O port.\r | |
154 | \r | |
155 | **/\r | |
156 | UINT8\r | |
157 | EFIAPI\r | |
158 | IoBitFieldWrite8 (\r | |
2f88bd3a MK |
159 | IN UINTN Port,\r |
160 | IN UINTN StartBit,\r | |
161 | IN UINTN EndBit,\r | |
162 | IN UINT8 Value\r | |
ba9f8351 | 163 | )\r |
164 | {\r | |
165 | return IoWrite8 (\r | |
166 | Port,\r | |
167 | BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value)\r | |
168 | );\r | |
169 | }\r | |
170 | \r | |
171 | /**\r | |
172 | Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the\r | |
173 | result back to the bit field in the 8-bit port.\r | |
174 | \r | |
175 | Reads the 8-bit I/O port specified by Port, performs a bitwise OR\r | |
176 | between the read result and the value specified by OrData, and writes the\r | |
177 | result to the 8-bit I/O port specified by Port. The value written to the I/O\r | |
178 | port is returned. This function must guarantee that all I/O read and write\r | |
179 | operations are serialized. Extra left bits in OrData are stripped.\r | |
180 | \r | |
181 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
182 | If StartBit is greater than 7, then ASSERT().\r | |
183 | If EndBit is greater than 7, then ASSERT().\r | |
184 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 185 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 186 | \r |
187 | @param Port The I/O port to write.\r | |
188 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
189 | Range 0..7.\r | |
190 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
191 | Range 0..7.\r | |
192 | @param OrData The value to OR with the read value from the I/O port.\r | |
193 | \r | |
194 | @return The value written back to the I/O port.\r | |
195 | \r | |
196 | **/\r | |
197 | UINT8\r | |
198 | EFIAPI\r | |
199 | IoBitFieldOr8 (\r | |
2f88bd3a MK |
200 | IN UINTN Port,\r |
201 | IN UINTN StartBit,\r | |
202 | IN UINTN EndBit,\r | |
203 | IN UINT8 OrData\r | |
ba9f8351 | 204 | )\r |
205 | {\r | |
206 | return IoWrite8 (\r | |
207 | Port,\r | |
208 | BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData)\r | |
209 | );\r | |
210 | }\r | |
211 | \r | |
212 | /**\r | |
213 | Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the\r | |
214 | result back to the bit field in the 8-bit port.\r | |
215 | \r | |
216 | Reads the 8-bit I/O port specified by Port, performs a bitwise AND between\r | |
217 | the read result and the value specified by AndData, and writes the result to\r | |
218 | the 8-bit I/O port specified by Port. The value written to the I/O port is\r | |
219 | returned. This function must guarantee that all I/O read and write operations\r | |
220 | are serialized. Extra left bits in AndData are stripped.\r | |
221 | \r | |
222 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
223 | If StartBit is greater than 7, then ASSERT().\r | |
224 | If EndBit is greater than 7, then ASSERT().\r | |
225 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 226 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 227 | \r |
228 | @param Port The I/O port to write.\r | |
229 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
230 | Range 0..7.\r | |
231 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
232 | Range 0..7.\r | |
233 | @param AndData The value to AND with the read value from the I/O port.\r | |
234 | \r | |
235 | @return The value written back to the I/O port.\r | |
236 | \r | |
237 | **/\r | |
238 | UINT8\r | |
239 | EFIAPI\r | |
240 | IoBitFieldAnd8 (\r | |
2f88bd3a MK |
241 | IN UINTN Port,\r |
242 | IN UINTN StartBit,\r | |
243 | IN UINTN EndBit,\r | |
244 | IN UINT8 AndData\r | |
ba9f8351 | 245 | )\r |
246 | {\r | |
247 | return IoWrite8 (\r | |
248 | Port,\r | |
249 | BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData)\r | |
250 | );\r | |
251 | }\r | |
252 | \r | |
253 | /**\r | |
254 | Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r | |
255 | bitwise OR, and writes the result back to the bit field in the\r | |
256 | 8-bit port.\r | |
257 | \r | |
258 | Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed\r | |
259 | by a bitwise OR between the read result and the value specified by\r | |
260 | AndData, and writes the result to the 8-bit I/O port specified by Port. The\r | |
261 | value written to the I/O port is returned. This function must guarantee that\r | |
262 | all I/O read and write operations are serialized. Extra left bits in both\r | |
263 | AndData and OrData are stripped.\r | |
264 | \r | |
265 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
266 | If StartBit is greater than 7, then ASSERT().\r | |
267 | If EndBit is greater than 7, then ASSERT().\r | |
268 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
269 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
270 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ba9f8351 | 271 | \r |
272 | @param Port The I/O port to write.\r | |
273 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
274 | Range 0..7.\r | |
275 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
276 | Range 0..7.\r | |
277 | @param AndData The value to AND with the read value from the I/O port.\r | |
278 | @param OrData The value to OR with the result of the AND operation.\r | |
279 | \r | |
280 | @return The value written back to the I/O port.\r | |
281 | \r | |
282 | **/\r | |
283 | UINT8\r | |
284 | EFIAPI\r | |
285 | IoBitFieldAndThenOr8 (\r | |
2f88bd3a MK |
286 | IN UINTN Port,\r |
287 | IN UINTN StartBit,\r | |
288 | IN UINTN EndBit,\r | |
289 | IN UINT8 AndData,\r | |
290 | IN UINT8 OrData\r | |
ba9f8351 | 291 | )\r |
292 | {\r | |
293 | return IoWrite8 (\r | |
294 | Port,\r | |
295 | BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData)\r | |
296 | );\r | |
297 | }\r | |
298 | \r | |
299 | /**\r | |
300 | Reads a 16-bit I/O port, performs a bitwise OR, and writes the\r | |
301 | result back to the 16-bit I/O port.\r | |
302 | \r | |
303 | Reads the 16-bit I/O port specified by Port, performs a bitwise OR\r | |
304 | between the read result and the value specified by OrData, and writes the\r | |
305 | result to the 16-bit I/O port specified by Port. The value written to the I/O\r | |
306 | port is returned. This function must guarantee that all I/O read and write\r | |
307 | operations are serialized.\r | |
308 | \r | |
309 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
310 | \r | |
311 | @param Port The I/O port to write.\r | |
312 | @param OrData The value to OR with the read value from the I/O port.\r | |
313 | \r | |
314 | @return The value written back to the I/O port.\r | |
315 | \r | |
316 | **/\r | |
317 | UINT16\r | |
318 | EFIAPI\r | |
319 | IoOr16 (\r | |
2f88bd3a MK |
320 | IN UINTN Port,\r |
321 | IN UINT16 OrData\r | |
ba9f8351 | 322 | )\r |
323 | {\r | |
2f88bd3a | 324 | return IoWrite16 (Port, (UINT16)(IoRead16 (Port) | OrData));\r |
ba9f8351 | 325 | }\r |
326 | \r | |
327 | /**\r | |
328 | Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back\r | |
329 | to the 16-bit I/O port.\r | |
330 | \r | |
331 | Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r | |
332 | the read result and the value specified by AndData, and writes the result to\r | |
333 | the 16-bit I/O port specified by Port. The value written to the I/O port is\r | |
334 | returned. This function must guarantee that all I/O read and write operations\r | |
335 | are serialized.\r | |
336 | \r | |
337 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
338 | \r | |
339 | @param Port The I/O port to write.\r | |
340 | @param AndData The value to AND with the read value from the I/O port.\r | |
341 | \r | |
342 | @return The value written back to the I/O port.\r | |
343 | \r | |
344 | **/\r | |
345 | UINT16\r | |
346 | EFIAPI\r | |
347 | IoAnd16 (\r | |
2f88bd3a MK |
348 | IN UINTN Port,\r |
349 | IN UINT16 AndData\r | |
ba9f8351 | 350 | )\r |
351 | {\r | |
2f88bd3a | 352 | return IoWrite16 (Port, (UINT16)(IoRead16 (Port) & AndData));\r |
ba9f8351 | 353 | }\r |
354 | \r | |
355 | /**\r | |
356 | Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise\r | |
357 | inclusive OR, and writes the result back to the 16-bit I/O port.\r | |
358 | \r | |
359 | Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r | |
360 | the read result and the value specified by AndData, performs a bitwise OR\r | |
361 | between the result of the AND operation and the value specified by OrData,\r | |
362 | and writes the result to the 16-bit I/O port specified by Port. The value\r | |
363 | written to the I/O port is returned. This function must guarantee that all\r | |
364 | I/O read and write operations are serialized.\r | |
365 | \r | |
366 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
367 | \r | |
368 | @param Port The I/O port to write.\r | |
369 | @param AndData The value to AND with the read value from the I/O port.\r | |
370 | @param OrData The value to OR with the result of the AND operation.\r | |
371 | \r | |
372 | @return The value written back to the I/O port.\r | |
373 | \r | |
374 | **/\r | |
375 | UINT16\r | |
376 | EFIAPI\r | |
377 | IoAndThenOr16 (\r | |
2f88bd3a MK |
378 | IN UINTN Port,\r |
379 | IN UINT16 AndData,\r | |
380 | IN UINT16 OrData\r | |
ba9f8351 | 381 | )\r |
382 | {\r | |
2f88bd3a | 383 | return IoWrite16 (Port, (UINT16)((IoRead16 (Port) & AndData) | OrData));\r |
ba9f8351 | 384 | }\r |
385 | \r | |
386 | /**\r | |
387 | Reads a bit field of an I/O register.\r | |
388 | \r | |
389 | Reads the bit field in a 16-bit I/O register. The bit field is specified by\r | |
390 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
391 | \r | |
392 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
393 | If StartBit is greater than 15, then ASSERT().\r | |
394 | If EndBit is greater than 15, then ASSERT().\r | |
395 | If EndBit is less than StartBit, then ASSERT().\r | |
396 | \r | |
397 | @param Port The I/O port to read.\r | |
398 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
399 | Range 0..15.\r | |
400 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
401 | Range 0..15.\r | |
402 | \r | |
403 | @return The value read.\r | |
404 | \r | |
405 | **/\r | |
406 | UINT16\r | |
407 | EFIAPI\r | |
408 | IoBitFieldRead16 (\r | |
2f88bd3a MK |
409 | IN UINTN Port,\r |
410 | IN UINTN StartBit,\r | |
411 | IN UINTN EndBit\r | |
ba9f8351 | 412 | )\r |
413 | {\r | |
414 | return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit);\r | |
415 | }\r | |
416 | \r | |
417 | /**\r | |
418 | Writes a bit field to an I/O register.\r | |
419 | \r | |
420 | Writes Value to the bit field of the I/O register. The bit field is specified\r | |
421 | by the StartBit and the EndBit. All other bits in the destination I/O\r | |
422 | register are preserved. The value written to the I/O port is returned. Extra\r | |
423 | left bits in Value are stripped.\r | |
424 | \r | |
425 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
426 | If StartBit is greater than 15, then ASSERT().\r | |
427 | If EndBit is greater than 15, then ASSERT().\r | |
428 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 429 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 430 | \r |
431 | @param Port The I/O port to write.\r | |
432 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
433 | Range 0..15.\r | |
434 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
435 | Range 0..15.\r | |
2fc59a00 | 436 | @param Value The new value of the bit field.\r |
ba9f8351 | 437 | \r |
438 | @return The value written back to the I/O port.\r | |
439 | \r | |
440 | **/\r | |
441 | UINT16\r | |
442 | EFIAPI\r | |
443 | IoBitFieldWrite16 (\r | |
2f88bd3a MK |
444 | IN UINTN Port,\r |
445 | IN UINTN StartBit,\r | |
446 | IN UINTN EndBit,\r | |
447 | IN UINT16 Value\r | |
ba9f8351 | 448 | )\r |
449 | {\r | |
450 | return IoWrite16 (\r | |
451 | Port,\r | |
452 | BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value)\r | |
453 | );\r | |
454 | }\r | |
455 | \r | |
456 | /**\r | |
457 | Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the\r | |
458 | result back to the bit field in the 16-bit port.\r | |
459 | \r | |
460 | Reads the 16-bit I/O port specified by Port, performs a bitwise OR\r | |
461 | between the read result and the value specified by OrData, and writes the\r | |
462 | result to the 16-bit I/O port specified by Port. The value written to the I/O\r | |
463 | port is returned. This function must guarantee that all I/O read and write\r | |
464 | operations are serialized. Extra left bits in OrData are stripped.\r | |
465 | \r | |
466 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
467 | If StartBit is greater than 15, then ASSERT().\r | |
468 | If EndBit is greater than 15, then ASSERT().\r | |
469 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 470 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 471 | \r |
472 | @param Port The I/O port to write.\r | |
473 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
474 | Range 0..15.\r | |
475 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
476 | Range 0..15.\r | |
477 | @param OrData The value to OR with the read value from the I/O port.\r | |
478 | \r | |
479 | @return The value written back to the I/O port.\r | |
480 | \r | |
481 | **/\r | |
482 | UINT16\r | |
483 | EFIAPI\r | |
484 | IoBitFieldOr16 (\r | |
2f88bd3a MK |
485 | IN UINTN Port,\r |
486 | IN UINTN StartBit,\r | |
487 | IN UINTN EndBit,\r | |
488 | IN UINT16 OrData\r | |
ba9f8351 | 489 | )\r |
490 | {\r | |
491 | return IoWrite16 (\r | |
492 | Port,\r | |
493 | BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData)\r | |
494 | );\r | |
495 | }\r | |
496 | \r | |
497 | /**\r | |
498 | Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the\r | |
499 | result back to the bit field in the 16-bit port.\r | |
500 | \r | |
501 | Reads the 16-bit I/O port specified by Port, performs a bitwise AND between\r | |
502 | the read result and the value specified by AndData, and writes the result to\r | |
503 | the 16-bit I/O port specified by Port. The value written to the I/O port is\r | |
504 | returned. This function must guarantee that all I/O read and write operations\r | |
505 | are serialized. Extra left bits in AndData are stripped.\r | |
506 | \r | |
507 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
508 | If StartBit is greater than 15, then ASSERT().\r | |
509 | If EndBit is greater than 15, then ASSERT().\r | |
510 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 511 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 512 | \r |
513 | @param Port The I/O port to write.\r | |
514 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
515 | Range 0..15.\r | |
516 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
517 | Range 0..15.\r | |
518 | @param AndData The value to AND with the read value from the I/O port.\r | |
519 | \r | |
520 | @return The value written back to the I/O port.\r | |
521 | \r | |
522 | **/\r | |
523 | UINT16\r | |
524 | EFIAPI\r | |
525 | IoBitFieldAnd16 (\r | |
2f88bd3a MK |
526 | IN UINTN Port,\r |
527 | IN UINTN StartBit,\r | |
528 | IN UINTN EndBit,\r | |
529 | IN UINT16 AndData\r | |
ba9f8351 | 530 | )\r |
531 | {\r | |
532 | return IoWrite16 (\r | |
533 | Port,\r | |
534 | BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData)\r | |
535 | );\r | |
536 | }\r | |
537 | \r | |
538 | /**\r | |
539 | Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r | |
540 | bitwise OR, and writes the result back to the bit field in the\r | |
541 | 16-bit port.\r | |
542 | \r | |
543 | Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed\r | |
544 | by a bitwise OR between the read result and the value specified by\r | |
545 | AndData, and writes the result to the 16-bit I/O port specified by Port. The\r | |
546 | value written to the I/O port is returned. This function must guarantee that\r | |
547 | all I/O read and write operations are serialized. Extra left bits in both\r | |
548 | AndData and OrData are stripped.\r | |
549 | \r | |
550 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
551 | If StartBit is greater than 15, then ASSERT().\r | |
552 | If EndBit is greater than 15, then ASSERT().\r | |
553 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
554 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
555 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ba9f8351 | 556 | \r |
557 | @param Port The I/O port to write.\r | |
558 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
559 | Range 0..15.\r | |
560 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
561 | Range 0..15.\r | |
562 | @param AndData The value to AND with the read value from the I/O port.\r | |
563 | @param OrData The value to OR with the result of the AND operation.\r | |
564 | \r | |
565 | @return The value written back to the I/O port.\r | |
566 | \r | |
567 | **/\r | |
568 | UINT16\r | |
569 | EFIAPI\r | |
570 | IoBitFieldAndThenOr16 (\r | |
2f88bd3a MK |
571 | IN UINTN Port,\r |
572 | IN UINTN StartBit,\r | |
573 | IN UINTN EndBit,\r | |
574 | IN UINT16 AndData,\r | |
575 | IN UINT16 OrData\r | |
ba9f8351 | 576 | )\r |
577 | {\r | |
578 | return IoWrite16 (\r | |
579 | Port,\r | |
580 | BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData)\r | |
581 | );\r | |
582 | }\r | |
583 | \r | |
584 | /**\r | |
585 | Reads a 32-bit I/O port, performs a bitwise OR, and writes the\r | |
586 | result back to the 32-bit I/O port.\r | |
587 | \r | |
588 | Reads the 32-bit I/O port specified by Port, performs a bitwise OR\r | |
589 | between the read result and the value specified by OrData, and writes the\r | |
590 | result to the 32-bit I/O port specified by Port. The value written to the I/O\r | |
591 | port is returned. This function must guarantee that all I/O read and write\r | |
592 | operations are serialized.\r | |
593 | \r | |
594 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
595 | \r | |
596 | @param Port The I/O port to write.\r | |
597 | @param OrData The value to OR with the read value from the I/O port.\r | |
598 | \r | |
599 | @return The value written back to the I/O port.\r | |
600 | \r | |
601 | **/\r | |
602 | UINT32\r | |
603 | EFIAPI\r | |
604 | IoOr32 (\r | |
2f88bd3a MK |
605 | IN UINTN Port,\r |
606 | IN UINT32 OrData\r | |
ba9f8351 | 607 | )\r |
608 | {\r | |
609 | return IoWrite32 (Port, IoRead32 (Port) | OrData);\r | |
610 | }\r | |
611 | \r | |
612 | /**\r | |
613 | Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back\r | |
614 | to the 32-bit I/O port.\r | |
615 | \r | |
616 | Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r | |
617 | the read result and the value specified by AndData, and writes the result to\r | |
618 | the 32-bit I/O port specified by Port. The value written to the I/O port is\r | |
619 | returned. This function must guarantee that all I/O read and write operations\r | |
620 | are serialized.\r | |
621 | \r | |
622 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
623 | \r | |
624 | @param Port The I/O port to write.\r | |
625 | @param AndData The value to AND with the read value from the I/O port.\r | |
626 | \r | |
627 | @return The value written back to the I/O port.\r | |
628 | \r | |
629 | **/\r | |
630 | UINT32\r | |
631 | EFIAPI\r | |
632 | IoAnd32 (\r | |
2f88bd3a MK |
633 | IN UINTN Port,\r |
634 | IN UINT32 AndData\r | |
ba9f8351 | 635 | )\r |
636 | {\r | |
637 | return IoWrite32 (Port, IoRead32 (Port) & AndData);\r | |
638 | }\r | |
639 | \r | |
640 | /**\r | |
641 | Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise\r | |
642 | inclusive OR, and writes the result back to the 32-bit I/O port.\r | |
643 | \r | |
644 | Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r | |
645 | the read result and the value specified by AndData, performs a bitwise OR\r | |
646 | between the result of the AND operation and the value specified by OrData,\r | |
647 | and writes the result to the 32-bit I/O port specified by Port. The value\r | |
648 | written to the I/O port is returned. This function must guarantee that all\r | |
649 | I/O read and write operations are serialized.\r | |
650 | \r | |
651 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
652 | \r | |
653 | @param Port The I/O port to write.\r | |
654 | @param AndData The value to AND with the read value from the I/O port.\r | |
655 | @param OrData The value to OR with the result of the AND operation.\r | |
656 | \r | |
657 | @return The value written back to the I/O port.\r | |
658 | \r | |
659 | **/\r | |
660 | UINT32\r | |
661 | EFIAPI\r | |
662 | IoAndThenOr32 (\r | |
2f88bd3a MK |
663 | IN UINTN Port,\r |
664 | IN UINT32 AndData,\r | |
665 | IN UINT32 OrData\r | |
ba9f8351 | 666 | )\r |
667 | {\r | |
668 | return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData);\r | |
669 | }\r | |
670 | \r | |
671 | /**\r | |
672 | Reads a bit field of an I/O register.\r | |
673 | \r | |
674 | Reads the bit field in a 32-bit I/O register. The bit field is specified by\r | |
675 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
676 | \r | |
677 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
678 | If StartBit is greater than 31, then ASSERT().\r | |
679 | If EndBit is greater than 31, then ASSERT().\r | |
680 | If EndBit is less than StartBit, then ASSERT().\r | |
681 | \r | |
682 | @param Port The I/O port to read.\r | |
683 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
684 | Range 0..31.\r | |
685 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
686 | Range 0..31.\r | |
687 | \r | |
688 | @return The value read.\r | |
689 | \r | |
690 | **/\r | |
691 | UINT32\r | |
692 | EFIAPI\r | |
693 | IoBitFieldRead32 (\r | |
2f88bd3a MK |
694 | IN UINTN Port,\r |
695 | IN UINTN StartBit,\r | |
696 | IN UINTN EndBit\r | |
ba9f8351 | 697 | )\r |
698 | {\r | |
699 | return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit);\r | |
700 | }\r | |
701 | \r | |
702 | /**\r | |
703 | Writes a bit field to an I/O register.\r | |
704 | \r | |
705 | Writes Value to the bit field of the I/O register. The bit field is specified\r | |
706 | by the StartBit and the EndBit. All other bits in the destination I/O\r | |
707 | register are preserved. The value written to the I/O port is returned. Extra\r | |
708 | left bits in Value are stripped.\r | |
709 | \r | |
710 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
711 | If StartBit is greater than 31, then ASSERT().\r | |
712 | If EndBit is greater than 31, then ASSERT().\r | |
713 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 714 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 715 | \r |
716 | @param Port The I/O port to write.\r | |
717 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
718 | Range 0..31.\r | |
719 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
720 | Range 0..31.\r | |
2fc59a00 | 721 | @param Value The new value of the bit field.\r |
ba9f8351 | 722 | \r |
723 | @return The value written back to the I/O port.\r | |
724 | \r | |
725 | **/\r | |
726 | UINT32\r | |
727 | EFIAPI\r | |
728 | IoBitFieldWrite32 (\r | |
2f88bd3a MK |
729 | IN UINTN Port,\r |
730 | IN UINTN StartBit,\r | |
731 | IN UINTN EndBit,\r | |
732 | IN UINT32 Value\r | |
ba9f8351 | 733 | )\r |
734 | {\r | |
735 | return IoWrite32 (\r | |
736 | Port,\r | |
737 | BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value)\r | |
738 | );\r | |
739 | }\r | |
740 | \r | |
741 | /**\r | |
742 | Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the\r | |
743 | result back to the bit field in the 32-bit port.\r | |
744 | \r | |
745 | Reads the 32-bit I/O port specified by Port, performs a bitwise OR\r | |
746 | between the read result and the value specified by OrData, and writes the\r | |
747 | result to the 32-bit I/O port specified by Port. The value written to the I/O\r | |
748 | port is returned. This function must guarantee that all I/O read and write\r | |
749 | operations are serialized. Extra left bits in OrData are stripped.\r | |
750 | \r | |
751 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
752 | If StartBit is greater than 31, then ASSERT().\r | |
753 | If EndBit is greater than 31, then ASSERT().\r | |
754 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 755 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 756 | \r |
757 | @param Port The I/O port to write.\r | |
758 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
759 | Range 0..31.\r | |
760 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
761 | Range 0..31.\r | |
762 | @param OrData The value to OR with the read value from the I/O port.\r | |
763 | \r | |
764 | @return The value written back to the I/O port.\r | |
765 | \r | |
766 | **/\r | |
767 | UINT32\r | |
768 | EFIAPI\r | |
769 | IoBitFieldOr32 (\r | |
2f88bd3a MK |
770 | IN UINTN Port,\r |
771 | IN UINTN StartBit,\r | |
772 | IN UINTN EndBit,\r | |
773 | IN UINT32 OrData\r | |
ba9f8351 | 774 | )\r |
775 | {\r | |
776 | return IoWrite32 (\r | |
777 | Port,\r | |
778 | BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData)\r | |
779 | );\r | |
780 | }\r | |
781 | \r | |
782 | /**\r | |
783 | Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the\r | |
784 | result back to the bit field in the 32-bit port.\r | |
785 | \r | |
786 | Reads the 32-bit I/O port specified by Port, performs a bitwise AND between\r | |
787 | the read result and the value specified by AndData, and writes the result to\r | |
788 | the 32-bit I/O port specified by Port. The value written to the I/O port is\r | |
789 | returned. This function must guarantee that all I/O read and write operations\r | |
790 | are serialized. Extra left bits in AndData are stripped.\r | |
791 | \r | |
792 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
793 | If StartBit is greater than 31, then ASSERT().\r | |
794 | If EndBit is greater than 31, then ASSERT().\r | |
795 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 796 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 797 | \r |
798 | @param Port The I/O port to write.\r | |
799 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
800 | Range 0..31.\r | |
801 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
802 | Range 0..31.\r | |
803 | @param AndData The value to AND with the read value from the I/O port.\r | |
804 | \r | |
805 | @return The value written back to the I/O port.\r | |
806 | \r | |
807 | **/\r | |
808 | UINT32\r | |
809 | EFIAPI\r | |
810 | IoBitFieldAnd32 (\r | |
2f88bd3a MK |
811 | IN UINTN Port,\r |
812 | IN UINTN StartBit,\r | |
813 | IN UINTN EndBit,\r | |
814 | IN UINT32 AndData\r | |
ba9f8351 | 815 | )\r |
816 | {\r | |
817 | return IoWrite32 (\r | |
818 | Port,\r | |
819 | BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData)\r | |
820 | );\r | |
821 | }\r | |
822 | \r | |
823 | /**\r | |
824 | Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r | |
825 | bitwise OR, and writes the result back to the bit field in the\r | |
826 | 32-bit port.\r | |
827 | \r | |
828 | Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed\r | |
829 | by a bitwise OR between the read result and the value specified by\r | |
830 | AndData, and writes the result to the 32-bit I/O port specified by Port. The\r | |
831 | value written to the I/O port is returned. This function must guarantee that\r | |
832 | all I/O read and write operations are serialized. Extra left bits in both\r | |
833 | AndData and OrData are stripped.\r | |
834 | \r | |
835 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
836 | If StartBit is greater than 31, then ASSERT().\r | |
837 | If EndBit is greater than 31, then ASSERT().\r | |
838 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
839 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
840 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ba9f8351 | 841 | \r |
842 | @param Port The I/O port to write.\r | |
843 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
844 | Range 0..31.\r | |
845 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
846 | Range 0..31.\r | |
847 | @param AndData The value to AND with the read value from the I/O port.\r | |
848 | @param OrData The value to OR with the result of the AND operation.\r | |
849 | \r | |
850 | @return The value written back to the I/O port.\r | |
851 | \r | |
852 | **/\r | |
853 | UINT32\r | |
854 | EFIAPI\r | |
855 | IoBitFieldAndThenOr32 (\r | |
2f88bd3a MK |
856 | IN UINTN Port,\r |
857 | IN UINTN StartBit,\r | |
858 | IN UINTN EndBit,\r | |
859 | IN UINT32 AndData,\r | |
860 | IN UINT32 OrData\r | |
ba9f8351 | 861 | )\r |
862 | {\r | |
863 | return IoWrite32 (\r | |
864 | Port,\r | |
865 | BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData)\r | |
866 | );\r | |
867 | }\r | |
868 | \r | |
869 | /**\r | |
870 | Reads a 64-bit I/O port, performs a bitwise OR, and writes the\r | |
871 | result back to the 64-bit I/O port.\r | |
872 | \r | |
873 | Reads the 64-bit I/O port specified by Port, performs a bitwise OR\r | |
874 | between the read result and the value specified by OrData, and writes the\r | |
875 | result to the 64-bit I/O port specified by Port. The value written to the I/O\r | |
876 | port is returned. This function must guarantee that all I/O read and write\r | |
877 | operations are serialized.\r | |
878 | \r | |
879 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
880 | \r | |
881 | @param Port The I/O port to write.\r | |
882 | @param OrData The value to OR with the read value from the I/O port.\r | |
883 | \r | |
884 | @return The value written back to the I/O port.\r | |
885 | \r | |
886 | **/\r | |
887 | UINT64\r | |
888 | EFIAPI\r | |
889 | IoOr64 (\r | |
2f88bd3a MK |
890 | IN UINTN Port,\r |
891 | IN UINT64 OrData\r | |
ba9f8351 | 892 | )\r |
893 | {\r | |
894 | return IoWrite64 (Port, IoRead64 (Port) | OrData);\r | |
895 | }\r | |
896 | \r | |
897 | /**\r | |
898 | Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back\r | |
899 | to the 64-bit I/O port.\r | |
900 | \r | |
901 | Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r | |
902 | the read result and the value specified by AndData, and writes the result to\r | |
903 | the 64-bit I/O port specified by Port. The value written to the I/O port is\r | |
904 | returned. This function must guarantee that all I/O read and write operations\r | |
905 | are serialized.\r | |
906 | \r | |
907 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
908 | \r | |
909 | @param Port The I/O port to write.\r | |
910 | @param AndData The value to AND with the read value from the I/O port.\r | |
911 | \r | |
912 | @return The value written back to the I/O port.\r | |
913 | \r | |
914 | **/\r | |
915 | UINT64\r | |
916 | EFIAPI\r | |
917 | IoAnd64 (\r | |
2f88bd3a MK |
918 | IN UINTN Port,\r |
919 | IN UINT64 AndData\r | |
ba9f8351 | 920 | )\r |
921 | {\r | |
922 | return IoWrite64 (Port, IoRead64 (Port) & AndData);\r | |
923 | }\r | |
924 | \r | |
925 | /**\r | |
926 | Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise\r | |
927 | inclusive OR, and writes the result back to the 64-bit I/O port.\r | |
928 | \r | |
929 | Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r | |
930 | the read result and the value specified by AndData, performs a bitwise OR\r | |
931 | between the result of the AND operation and the value specified by OrData,\r | |
932 | and writes the result to the 64-bit I/O port specified by Port. The value\r | |
933 | written to the I/O port is returned. This function must guarantee that all\r | |
934 | I/O read and write operations are serialized.\r | |
935 | \r | |
936 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
937 | \r | |
938 | @param Port The I/O port to write.\r | |
939 | @param AndData The value to AND with the read value from the I/O port.\r | |
940 | @param OrData The value to OR with the result of the AND operation.\r | |
941 | \r | |
942 | @return The value written back to the I/O port.\r | |
943 | \r | |
944 | **/\r | |
945 | UINT64\r | |
946 | EFIAPI\r | |
947 | IoAndThenOr64 (\r | |
2f88bd3a MK |
948 | IN UINTN Port,\r |
949 | IN UINT64 AndData,\r | |
950 | IN UINT64 OrData\r | |
ba9f8351 | 951 | )\r |
952 | {\r | |
953 | return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData);\r | |
954 | }\r | |
955 | \r | |
956 | /**\r | |
957 | Reads a bit field of an I/O register.\r | |
958 | \r | |
959 | Reads the bit field in a 64-bit I/O register. The bit field is specified by\r | |
960 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
961 | \r | |
962 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
963 | If StartBit is greater than 63, then ASSERT().\r | |
964 | If EndBit is greater than 63, then ASSERT().\r | |
965 | If EndBit is less than StartBit, then ASSERT().\r | |
966 | \r | |
967 | @param Port The I/O port to read.\r | |
968 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
969 | Range 0..63.\r | |
970 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
971 | Range 0..63.\r | |
972 | \r | |
973 | @return The value read.\r | |
974 | \r | |
975 | **/\r | |
976 | UINT64\r | |
977 | EFIAPI\r | |
978 | IoBitFieldRead64 (\r | |
2f88bd3a MK |
979 | IN UINTN Port,\r |
980 | IN UINTN StartBit,\r | |
981 | IN UINTN EndBit\r | |
ba9f8351 | 982 | )\r |
983 | {\r | |
984 | return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit);\r | |
985 | }\r | |
986 | \r | |
987 | /**\r | |
988 | Writes a bit field to an I/O register.\r | |
989 | \r | |
990 | Writes Value to the bit field of the I/O register. The bit field is specified\r | |
991 | by the StartBit and the EndBit. All other bits in the destination I/O\r | |
992 | register are preserved. The value written to the I/O port is returned. Extra\r | |
993 | left bits in Value are stripped.\r | |
994 | \r | |
995 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
996 | If StartBit is greater than 63, then ASSERT().\r | |
997 | If EndBit is greater than 63, then ASSERT().\r | |
998 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 999 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1000 | \r |
1001 | @param Port The I/O port to write.\r | |
1002 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1003 | Range 0..63.\r | |
1004 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1005 | Range 0..63.\r | |
2fc59a00 | 1006 | @param Value The new value of the bit field.\r |
ba9f8351 | 1007 | \r |
1008 | @return The value written back to the I/O port.\r | |
1009 | \r | |
1010 | **/\r | |
1011 | UINT64\r | |
1012 | EFIAPI\r | |
1013 | IoBitFieldWrite64 (\r | |
2f88bd3a MK |
1014 | IN UINTN Port,\r |
1015 | IN UINTN StartBit,\r | |
1016 | IN UINTN EndBit,\r | |
1017 | IN UINT64 Value\r | |
ba9f8351 | 1018 | )\r |
1019 | {\r | |
1020 | return IoWrite64 (\r | |
1021 | Port,\r | |
1022 | BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value)\r | |
1023 | );\r | |
1024 | }\r | |
1025 | \r | |
1026 | /**\r | |
1027 | Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the\r | |
1028 | result back to the bit field in the 64-bit port.\r | |
1029 | \r | |
1030 | Reads the 64-bit I/O port specified by Port, performs a bitwise OR\r | |
1031 | between the read result and the value specified by OrData, and writes the\r | |
1032 | result to the 64-bit I/O port specified by Port. The value written to the I/O\r | |
1033 | port is returned. This function must guarantee that all I/O read and write\r | |
1034 | operations are serialized. Extra left bits in OrData are stripped.\r | |
1035 | \r | |
1036 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1037 | If StartBit is greater than 63, then ASSERT().\r | |
1038 | If EndBit is greater than 63, then ASSERT().\r | |
1039 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1040 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1041 | \r |
1042 | @param Port The I/O port to write.\r | |
1043 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1044 | Range 0..63.\r | |
1045 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1046 | Range 0..63.\r | |
1047 | @param OrData The value to OR with the read value from the I/O port.\r | |
1048 | \r | |
1049 | @return The value written back to the I/O port.\r | |
1050 | \r | |
1051 | **/\r | |
1052 | UINT64\r | |
1053 | EFIAPI\r | |
1054 | IoBitFieldOr64 (\r | |
2f88bd3a MK |
1055 | IN UINTN Port,\r |
1056 | IN UINTN StartBit,\r | |
1057 | IN UINTN EndBit,\r | |
1058 | IN UINT64 OrData\r | |
ba9f8351 | 1059 | )\r |
1060 | {\r | |
1061 | return IoWrite64 (\r | |
1062 | Port,\r | |
1063 | BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData)\r | |
1064 | );\r | |
1065 | }\r | |
1066 | \r | |
1067 | /**\r | |
1068 | Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the\r | |
1069 | result back to the bit field in the 64-bit port.\r | |
1070 | \r | |
1071 | Reads the 64-bit I/O port specified by Port, performs a bitwise AND between\r | |
1072 | the read result and the value specified by AndData, and writes the result to\r | |
1073 | the 64-bit I/O port specified by Port. The value written to the I/O port is\r | |
1074 | returned. This function must guarantee that all I/O read and write operations\r | |
1075 | are serialized. Extra left bits in AndData are stripped.\r | |
1076 | \r | |
1077 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1078 | If StartBit is greater than 63, then ASSERT().\r | |
1079 | If EndBit is greater than 63, then ASSERT().\r | |
1080 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1081 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1082 | \r |
1083 | @param Port The I/O port to write.\r | |
1084 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1085 | Range 0..63.\r | |
1086 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1087 | Range 0..63.\r | |
1088 | @param AndData The value to AND with the read value from the I/O port.\r | |
1089 | \r | |
1090 | @return The value written back to the I/O port.\r | |
1091 | \r | |
1092 | **/\r | |
1093 | UINT64\r | |
1094 | EFIAPI\r | |
1095 | IoBitFieldAnd64 (\r | |
2f88bd3a MK |
1096 | IN UINTN Port,\r |
1097 | IN UINTN StartBit,\r | |
1098 | IN UINTN EndBit,\r | |
1099 | IN UINT64 AndData\r | |
ba9f8351 | 1100 | )\r |
1101 | {\r | |
1102 | return IoWrite64 (\r | |
1103 | Port,\r | |
1104 | BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData)\r | |
1105 | );\r | |
1106 | }\r | |
1107 | \r | |
1108 | /**\r | |
1109 | Reads a bit field in a 64-bit port, performs a bitwise AND followed by a\r | |
1110 | bitwise OR, and writes the result back to the bit field in the\r | |
1111 | 64-bit port.\r | |
1112 | \r | |
1113 | Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed\r | |
1114 | by a bitwise OR between the read result and the value specified by\r | |
1115 | AndData, and writes the result to the 64-bit I/O port specified by Port. The\r | |
1116 | value written to the I/O port is returned. This function must guarantee that\r | |
1117 | all I/O read and write operations are serialized. Extra left bits in both\r | |
1118 | AndData and OrData are stripped.\r | |
1119 | \r | |
1120 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
1121 | If StartBit is greater than 63, then ASSERT().\r | |
1122 | If EndBit is greater than 63, then ASSERT().\r | |
1123 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
1124 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
1125 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ba9f8351 | 1126 | \r |
1127 | @param Port The I/O port to write.\r | |
1128 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1129 | Range 0..63.\r | |
1130 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1131 | Range 0..63.\r | |
1132 | @param AndData The value to AND with the read value from the I/O port.\r | |
1133 | @param OrData The value to OR with the result of the AND operation.\r | |
1134 | \r | |
1135 | @return The value written back to the I/O port.\r | |
1136 | \r | |
1137 | **/\r | |
1138 | UINT64\r | |
1139 | EFIAPI\r | |
1140 | IoBitFieldAndThenOr64 (\r | |
2f88bd3a MK |
1141 | IN UINTN Port,\r |
1142 | IN UINTN StartBit,\r | |
1143 | IN UINTN EndBit,\r | |
1144 | IN UINT64 AndData,\r | |
1145 | IN UINT64 OrData\r | |
ba9f8351 | 1146 | )\r |
1147 | {\r | |
1148 | return IoWrite64 (\r | |
1149 | Port,\r | |
1150 | BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData)\r | |
1151 | );\r | |
1152 | }\r | |
1153 | \r | |
1154 | /**\r | |
1155 | Reads an 8-bit MMIO register, performs a bitwise OR, and writes the\r | |
1156 | result back to the 8-bit MMIO register.\r | |
1157 | \r | |
1158 | Reads the 8-bit MMIO register specified by Address, performs a bitwise\r | |
1159 | inclusive OR between the read result and the value specified by OrData, and\r | |
1160 | writes the result to the 8-bit MMIO register specified by Address. The value\r | |
1161 | written to the MMIO register is returned. This function must guarantee that\r | |
1162 | all MMIO read and write operations are serialized.\r | |
1163 | \r | |
1164 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1165 | \r | |
1166 | @param Address The MMIO register to write.\r | |
1167 | @param OrData The value to OR with the read value from the MMIO register.\r | |
1168 | \r | |
1169 | @return The value written back to the MMIO register.\r | |
1170 | \r | |
1171 | **/\r | |
1172 | UINT8\r | |
1173 | EFIAPI\r | |
1174 | MmioOr8 (\r | |
2f88bd3a MK |
1175 | IN UINTN Address,\r |
1176 | IN UINT8 OrData\r | |
ba9f8351 | 1177 | )\r |
1178 | {\r | |
2f88bd3a | 1179 | return MmioWrite8 (Address, (UINT8)(MmioRead8 (Address) | OrData));\r |
ba9f8351 | 1180 | }\r |
1181 | \r | |
1182 | /**\r | |
1183 | Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result\r | |
1184 | back to the 8-bit MMIO register.\r | |
1185 | \r | |
1186 | Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r | |
1187 | between the read result and the value specified by AndData, and writes the\r | |
1188 | result to the 8-bit MMIO register specified by Address. The value written to\r | |
1189 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1190 | read and write operations are serialized.\r | |
1191 | \r | |
1192 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1193 | \r | |
1194 | @param Address The MMIO register to write.\r | |
1195 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1196 | \r | |
1197 | @return The value written back to the MMIO register.\r | |
1198 | \r | |
1199 | **/\r | |
1200 | UINT8\r | |
1201 | EFIAPI\r | |
1202 | MmioAnd8 (\r | |
2f88bd3a MK |
1203 | IN UINTN Address,\r |
1204 | IN UINT8 AndData\r | |
ba9f8351 | 1205 | )\r |
1206 | {\r | |
2f88bd3a | 1207 | return MmioWrite8 (Address, (UINT8)(MmioRead8 (Address) & AndData));\r |
ba9f8351 | 1208 | }\r |
1209 | \r | |
1210 | /**\r | |
1211 | Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise\r | |
1212 | inclusive OR, and writes the result back to the 8-bit MMIO register.\r | |
1213 | \r | |
1214 | Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r | |
1215 | between the read result and the value specified by AndData, performs a\r | |
1216 | bitwise OR between the result of the AND operation and the value specified by\r | |
1217 | OrData, and writes the result to the 8-bit MMIO register specified by\r | |
1218 | Address. The value written to the MMIO register is returned. This function\r | |
1219 | must guarantee that all MMIO read and write operations are serialized.\r | |
1220 | \r | |
1221 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1222 | \r | |
1223 | \r | |
1224 | @param Address The MMIO register to write.\r | |
1225 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1226 | @param OrData The value to OR with the result of the AND operation.\r | |
1227 | \r | |
1228 | @return The value written back to the MMIO register.\r | |
1229 | \r | |
1230 | **/\r | |
1231 | UINT8\r | |
1232 | EFIAPI\r | |
1233 | MmioAndThenOr8 (\r | |
2f88bd3a MK |
1234 | IN UINTN Address,\r |
1235 | IN UINT8 AndData,\r | |
1236 | IN UINT8 OrData\r | |
ba9f8351 | 1237 | )\r |
1238 | {\r | |
2f88bd3a | 1239 | return MmioWrite8 (Address, (UINT8)((MmioRead8 (Address) & AndData) | OrData));\r |
ba9f8351 | 1240 | }\r |
1241 | \r | |
1242 | /**\r | |
1243 | Reads a bit field of a MMIO register.\r | |
1244 | \r | |
1245 | Reads the bit field in an 8-bit MMIO register. The bit field is specified by\r | |
1246 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
1247 | \r | |
1248 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1249 | If StartBit is greater than 7, then ASSERT().\r | |
1250 | If EndBit is greater than 7, then ASSERT().\r | |
1251 | If EndBit is less than StartBit, then ASSERT().\r | |
1252 | \r | |
58380e9c | 1253 | @param Address The MMIO register to read.\r |
ba9f8351 | 1254 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1255 | Range 0..7.\r | |
1256 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1257 | Range 0..7.\r | |
1258 | \r | |
1259 | @return The value read.\r | |
1260 | \r | |
1261 | **/\r | |
1262 | UINT8\r | |
1263 | EFIAPI\r | |
1264 | MmioBitFieldRead8 (\r | |
2f88bd3a MK |
1265 | IN UINTN Address,\r |
1266 | IN UINTN StartBit,\r | |
1267 | IN UINTN EndBit\r | |
ba9f8351 | 1268 | )\r |
1269 | {\r | |
1270 | return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit);\r | |
1271 | }\r | |
1272 | \r | |
1273 | /**\r | |
1274 | Writes a bit field to a MMIO register.\r | |
1275 | \r | |
1276 | Writes Value to the bit field of the MMIO register. The bit field is\r | |
1277 | specified by the StartBit and the EndBit. All other bits in the destination\r | |
1278 | MMIO register are preserved. The new value of the 8-bit register is returned.\r | |
1279 | \r | |
1280 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1281 | If StartBit is greater than 7, then ASSERT().\r | |
1282 | If EndBit is greater than 7, then ASSERT().\r | |
1283 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1284 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1285 | \r |
58380e9c | 1286 | @param Address The MMIO register to write.\r |
ba9f8351 | 1287 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1288 | Range 0..7.\r | |
1289 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1290 | Range 0..7.\r | |
2fc59a00 | 1291 | @param Value The new value of the bit field.\r |
ba9f8351 | 1292 | \r |
1293 | @return The value written back to the MMIO register.\r | |
1294 | \r | |
1295 | **/\r | |
1296 | UINT8\r | |
1297 | EFIAPI\r | |
1298 | MmioBitFieldWrite8 (\r | |
2f88bd3a MK |
1299 | IN UINTN Address,\r |
1300 | IN UINTN StartBit,\r | |
1301 | IN UINTN EndBit,\r | |
1302 | IN UINT8 Value\r | |
ba9f8351 | 1303 | )\r |
1304 | {\r | |
1305 | return MmioWrite8 (\r | |
1306 | Address,\r | |
1307 | BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value)\r | |
1308 | );\r | |
1309 | }\r | |
1310 | \r | |
1311 | /**\r | |
1312 | Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and\r | |
1313 | writes the result back to the bit field in the 8-bit MMIO register.\r | |
1314 | \r | |
1315 | Reads the 8-bit MMIO register specified by Address, performs a bitwise\r | |
1316 | inclusive OR between the read result and the value specified by OrData, and\r | |
1317 | writes the result to the 8-bit MMIO register specified by Address. The value\r | |
1318 | written to the MMIO register is returned. This function must guarantee that\r | |
1319 | all MMIO read and write operations are serialized. Extra left bits in OrData\r | |
1320 | are stripped.\r | |
1321 | \r | |
1322 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1323 | If StartBit is greater than 7, then ASSERT().\r | |
1324 | If EndBit is greater than 7, then ASSERT().\r | |
1325 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1326 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1327 | \r |
58380e9c | 1328 | @param Address The MMIO register to write.\r |
ba9f8351 | 1329 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1330 | Range 0..7.\r | |
1331 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1332 | Range 0..7.\r | |
1333 | @param OrData The value to OR with read value from the MMIO register.\r | |
1334 | \r | |
1335 | @return The value written back to the MMIO register.\r | |
1336 | \r | |
1337 | **/\r | |
1338 | UINT8\r | |
1339 | EFIAPI\r | |
1340 | MmioBitFieldOr8 (\r | |
2f88bd3a MK |
1341 | IN UINTN Address,\r |
1342 | IN UINTN StartBit,\r | |
1343 | IN UINTN EndBit,\r | |
1344 | IN UINT8 OrData\r | |
ba9f8351 | 1345 | )\r |
1346 | {\r | |
1347 | return MmioWrite8 (\r | |
1348 | Address,\r | |
1349 | BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData)\r | |
1350 | );\r | |
1351 | }\r | |
1352 | \r | |
1353 | /**\r | |
1354 | Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and\r | |
1355 | writes the result back to the bit field in the 8-bit MMIO register.\r | |
1356 | \r | |
1357 | Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r | |
1358 | between the read result and the value specified by AndData, and writes the\r | |
1359 | result to the 8-bit MMIO register specified by Address. The value written to\r | |
1360 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1361 | read and write operations are serialized. Extra left bits in AndData are\r | |
1362 | stripped.\r | |
1363 | \r | |
1364 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1365 | If StartBit is greater than 7, then ASSERT().\r | |
1366 | If EndBit is greater than 7, then ASSERT().\r | |
1367 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1368 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1369 | \r |
58380e9c | 1370 | @param Address The MMIO register to write.\r |
ba9f8351 | 1371 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1372 | Range 0..7.\r | |
1373 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1374 | Range 0..7.\r | |
1375 | @param AndData The value to AND with read value from the MMIO register.\r | |
1376 | \r | |
1377 | @return The value written back to the MMIO register.\r | |
1378 | \r | |
1379 | **/\r | |
1380 | UINT8\r | |
1381 | EFIAPI\r | |
1382 | MmioBitFieldAnd8 (\r | |
2f88bd3a MK |
1383 | IN UINTN Address,\r |
1384 | IN UINTN StartBit,\r | |
1385 | IN UINTN EndBit,\r | |
1386 | IN UINT8 AndData\r | |
ba9f8351 | 1387 | )\r |
1388 | {\r | |
1389 | return MmioWrite8 (\r | |
1390 | Address,\r | |
1391 | BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData)\r | |
1392 | );\r | |
1393 | }\r | |
1394 | \r | |
1395 | /**\r | |
1396 | Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed\r | |
1397 | by a bitwise OR, and writes the result back to the bit field in the\r | |
1398 | 8-bit MMIO register.\r | |
1399 | \r | |
1400 | Reads the 8-bit MMIO register specified by Address, performs a bitwise AND\r | |
1401 | followed by a bitwise OR between the read result and the value\r | |
1402 | specified by AndData, and writes the result to the 8-bit MMIO register\r | |
1403 | specified by Address. The value written to the MMIO register is returned.\r | |
1404 | This function must guarantee that all MMIO read and write operations are\r | |
1405 | serialized. Extra left bits in both AndData and OrData are stripped.\r | |
1406 | \r | |
1407 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
1408 | If StartBit is greater than 7, then ASSERT().\r | |
1409 | If EndBit is greater than 7, then ASSERT().\r | |
1410 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
1411 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
1412 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ba9f8351 | 1413 | \r |
58380e9c | 1414 | @param Address The MMIO register to write.\r |
ba9f8351 | 1415 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1416 | Range 0..7.\r | |
1417 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1418 | Range 0..7.\r | |
1419 | @param AndData The value to AND with read value from the MMIO register.\r | |
1420 | @param OrData The value to OR with the result of the AND operation.\r | |
1421 | \r | |
1422 | @return The value written back to the MMIO register.\r | |
1423 | \r | |
1424 | **/\r | |
1425 | UINT8\r | |
1426 | EFIAPI\r | |
1427 | MmioBitFieldAndThenOr8 (\r | |
2f88bd3a MK |
1428 | IN UINTN Address,\r |
1429 | IN UINTN StartBit,\r | |
1430 | IN UINTN EndBit,\r | |
1431 | IN UINT8 AndData,\r | |
1432 | IN UINT8 OrData\r | |
ba9f8351 | 1433 | )\r |
1434 | {\r | |
1435 | return MmioWrite8 (\r | |
1436 | Address,\r | |
1437 | BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData)\r | |
1438 | );\r | |
1439 | }\r | |
1440 | \r | |
1441 | /**\r | |
1442 | Reads a 16-bit MMIO register, performs a bitwise OR, and writes the\r | |
1443 | result back to the 16-bit MMIO register.\r | |
1444 | \r | |
1445 | Reads the 16-bit MMIO register specified by Address, performs a bitwise\r | |
1446 | inclusive OR between the read result and the value specified by OrData, and\r | |
1447 | writes the result to the 16-bit MMIO register specified by Address. The value\r | |
1448 | written to the MMIO register is returned. This function must guarantee that\r | |
1449 | all MMIO read and write operations are serialized.\r | |
1450 | \r | |
1451 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1452 | \r | |
1453 | @param Address The MMIO register to write.\r | |
1454 | @param OrData The value to OR with the read value from the MMIO register.\r | |
1455 | \r | |
1456 | @return The value written back to the MMIO register.\r | |
1457 | \r | |
1458 | **/\r | |
1459 | UINT16\r | |
1460 | EFIAPI\r | |
1461 | MmioOr16 (\r | |
2f88bd3a MK |
1462 | IN UINTN Address,\r |
1463 | IN UINT16 OrData\r | |
ba9f8351 | 1464 | )\r |
1465 | {\r | |
2f88bd3a | 1466 | return MmioWrite16 (Address, (UINT16)(MmioRead16 (Address) | OrData));\r |
ba9f8351 | 1467 | }\r |
1468 | \r | |
1469 | /**\r | |
1470 | Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result\r | |
1471 | back to the 16-bit MMIO register.\r | |
1472 | \r | |
1473 | Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r | |
1474 | between the read result and the value specified by AndData, and writes the\r | |
1475 | result to the 16-bit MMIO register specified by Address. The value written to\r | |
1476 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1477 | read and write operations are serialized.\r | |
1478 | \r | |
1479 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1480 | \r | |
1481 | @param Address The MMIO register to write.\r | |
1482 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1483 | \r | |
1484 | @return The value written back to the MMIO register.\r | |
1485 | \r | |
1486 | **/\r | |
1487 | UINT16\r | |
1488 | EFIAPI\r | |
1489 | MmioAnd16 (\r | |
2f88bd3a MK |
1490 | IN UINTN Address,\r |
1491 | IN UINT16 AndData\r | |
ba9f8351 | 1492 | )\r |
1493 | {\r | |
2f88bd3a | 1494 | return MmioWrite16 (Address, (UINT16)(MmioRead16 (Address) & AndData));\r |
ba9f8351 | 1495 | }\r |
1496 | \r | |
1497 | /**\r | |
1498 | Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise\r | |
1499 | inclusive OR, and writes the result back to the 16-bit MMIO register.\r | |
1500 | \r | |
1501 | Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r | |
1502 | between the read result and the value specified by AndData, performs a\r | |
1503 | bitwise OR between the result of the AND operation and the value specified by\r | |
1504 | OrData, and writes the result to the 16-bit MMIO register specified by\r | |
1505 | Address. The value written to the MMIO register is returned. This function\r | |
1506 | must guarantee that all MMIO read and write operations are serialized.\r | |
1507 | \r | |
1508 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1509 | \r | |
1510 | \r | |
1511 | @param Address The MMIO register to write.\r | |
1512 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1513 | @param OrData The value to OR with the result of the AND operation.\r | |
1514 | \r | |
1515 | @return The value written back to the MMIO register.\r | |
1516 | \r | |
1517 | **/\r | |
1518 | UINT16\r | |
1519 | EFIAPI\r | |
1520 | MmioAndThenOr16 (\r | |
2f88bd3a MK |
1521 | IN UINTN Address,\r |
1522 | IN UINT16 AndData,\r | |
1523 | IN UINT16 OrData\r | |
ba9f8351 | 1524 | )\r |
1525 | {\r | |
2f88bd3a | 1526 | return MmioWrite16 (Address, (UINT16)((MmioRead16 (Address) & AndData) | OrData));\r |
ba9f8351 | 1527 | }\r |
1528 | \r | |
1529 | /**\r | |
1530 | Reads a bit field of a MMIO register.\r | |
1531 | \r | |
1532 | Reads the bit field in a 16-bit MMIO register. The bit field is specified by\r | |
1533 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
1534 | \r | |
1535 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1536 | If StartBit is greater than 15, then ASSERT().\r | |
1537 | If EndBit is greater than 15, then ASSERT().\r | |
1538 | If EndBit is less than StartBit, then ASSERT().\r | |
1539 | \r | |
58380e9c | 1540 | @param Address The MMIO register to read.\r |
ba9f8351 | 1541 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1542 | Range 0..15.\r | |
1543 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1544 | Range 0..15.\r | |
1545 | \r | |
1546 | @return The value read.\r | |
1547 | \r | |
1548 | **/\r | |
1549 | UINT16\r | |
1550 | EFIAPI\r | |
1551 | MmioBitFieldRead16 (\r | |
2f88bd3a MK |
1552 | IN UINTN Address,\r |
1553 | IN UINTN StartBit,\r | |
1554 | IN UINTN EndBit\r | |
ba9f8351 | 1555 | )\r |
1556 | {\r | |
1557 | return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit);\r | |
1558 | }\r | |
1559 | \r | |
1560 | /**\r | |
1561 | Writes a bit field to a MMIO register.\r | |
1562 | \r | |
1563 | Writes Value to the bit field of the MMIO register. The bit field is\r | |
1564 | specified by the StartBit and the EndBit. All other bits in the destination\r | |
1565 | MMIO register are preserved. The new value of the 16-bit register is returned.\r | |
1566 | \r | |
1567 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1568 | If StartBit is greater than 15, then ASSERT().\r | |
1569 | If EndBit is greater than 15, then ASSERT().\r | |
1570 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1571 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1572 | \r |
58380e9c | 1573 | @param Address The MMIO register to write.\r |
ba9f8351 | 1574 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1575 | Range 0..15.\r | |
1576 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1577 | Range 0..15.\r | |
2fc59a00 | 1578 | @param Value The new value of the bit field.\r |
ba9f8351 | 1579 | \r |
1580 | @return The value written back to the MMIO register.\r | |
1581 | \r | |
1582 | **/\r | |
1583 | UINT16\r | |
1584 | EFIAPI\r | |
1585 | MmioBitFieldWrite16 (\r | |
2f88bd3a MK |
1586 | IN UINTN Address,\r |
1587 | IN UINTN StartBit,\r | |
1588 | IN UINTN EndBit,\r | |
1589 | IN UINT16 Value\r | |
ba9f8351 | 1590 | )\r |
1591 | {\r | |
1592 | return MmioWrite16 (\r | |
1593 | Address,\r | |
1594 | BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value)\r | |
1595 | );\r | |
1596 | }\r | |
1597 | \r | |
1598 | /**\r | |
1599 | Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and\r | |
1600 | writes the result back to the bit field in the 16-bit MMIO register.\r | |
1601 | \r | |
1602 | Reads the 16-bit MMIO register specified by Address, performs a bitwise\r | |
1603 | inclusive OR between the read result and the value specified by OrData, and\r | |
1604 | writes the result to the 16-bit MMIO register specified by Address. The value\r | |
1605 | written to the MMIO register is returned. This function must guarantee that\r | |
1606 | all MMIO read and write operations are serialized. Extra left bits in OrData\r | |
1607 | are stripped.\r | |
1608 | \r | |
1609 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1610 | If StartBit is greater than 15, then ASSERT().\r | |
1611 | If EndBit is greater than 15, then ASSERT().\r | |
1612 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1613 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1614 | \r |
58380e9c | 1615 | @param Address The MMIO register to write.\r |
ba9f8351 | 1616 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1617 | Range 0..15.\r | |
1618 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1619 | Range 0..15.\r | |
1620 | @param OrData The value to OR with read value from the MMIO register.\r | |
1621 | \r | |
1622 | @return The value written back to the MMIO register.\r | |
1623 | \r | |
1624 | **/\r | |
1625 | UINT16\r | |
1626 | EFIAPI\r | |
1627 | MmioBitFieldOr16 (\r | |
2f88bd3a MK |
1628 | IN UINTN Address,\r |
1629 | IN UINTN StartBit,\r | |
1630 | IN UINTN EndBit,\r | |
1631 | IN UINT16 OrData\r | |
ba9f8351 | 1632 | )\r |
1633 | {\r | |
1634 | return MmioWrite16 (\r | |
1635 | Address,\r | |
1636 | BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData)\r | |
1637 | );\r | |
1638 | }\r | |
1639 | \r | |
1640 | /**\r | |
1641 | Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and\r | |
1642 | writes the result back to the bit field in the 16-bit MMIO register.\r | |
1643 | \r | |
1644 | Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r | |
1645 | between the read result and the value specified by AndData, and writes the\r | |
1646 | result to the 16-bit MMIO register specified by Address. The value written to\r | |
1647 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1648 | read and write operations are serialized. Extra left bits in AndData are\r | |
1649 | stripped.\r | |
1650 | \r | |
1651 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1652 | If StartBit is greater than 15, then ASSERT().\r | |
1653 | If EndBit is greater than 15, then ASSERT().\r | |
1654 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1655 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1656 | \r |
58380e9c | 1657 | @param Address The MMIO register to write.\r |
ba9f8351 | 1658 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1659 | Range 0..15.\r | |
1660 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1661 | Range 0..15.\r | |
1662 | @param AndData The value to AND with read value from the MMIO register.\r | |
1663 | \r | |
1664 | @return The value written back to the MMIO register.\r | |
1665 | \r | |
1666 | **/\r | |
1667 | UINT16\r | |
1668 | EFIAPI\r | |
1669 | MmioBitFieldAnd16 (\r | |
2f88bd3a MK |
1670 | IN UINTN Address,\r |
1671 | IN UINTN StartBit,\r | |
1672 | IN UINTN EndBit,\r | |
1673 | IN UINT16 AndData\r | |
ba9f8351 | 1674 | )\r |
1675 | {\r | |
1676 | return MmioWrite16 (\r | |
1677 | Address,\r | |
1678 | BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData)\r | |
1679 | );\r | |
1680 | }\r | |
1681 | \r | |
1682 | /**\r | |
1683 | Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed\r | |
1684 | by a bitwise OR, and writes the result back to the bit field in the\r | |
1685 | 16-bit MMIO register.\r | |
1686 | \r | |
1687 | Reads the 16-bit MMIO register specified by Address, performs a bitwise AND\r | |
1688 | followed by a bitwise OR between the read result and the value\r | |
1689 | specified by AndData, and writes the result to the 16-bit MMIO register\r | |
1690 | specified by Address. The value written to the MMIO register is returned.\r | |
1691 | This function must guarantee that all MMIO read and write operations are\r | |
1692 | serialized. Extra left bits in both AndData and OrData are stripped.\r | |
1693 | \r | |
1694 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
1695 | If StartBit is greater than 15, then ASSERT().\r | |
1696 | If EndBit is greater than 15, then ASSERT().\r | |
1697 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
1698 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
1699 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ba9f8351 | 1700 | \r |
58380e9c | 1701 | @param Address The MMIO register to write.\r |
ba9f8351 | 1702 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1703 | Range 0..15.\r | |
1704 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1705 | Range 0..15.\r | |
1706 | @param AndData The value to AND with read value from the MMIO register.\r | |
1707 | @param OrData The value to OR with the result of the AND operation.\r | |
1708 | \r | |
1709 | @return The value written back to the MMIO register.\r | |
1710 | \r | |
1711 | **/\r | |
1712 | UINT16\r | |
1713 | EFIAPI\r | |
1714 | MmioBitFieldAndThenOr16 (\r | |
2f88bd3a MK |
1715 | IN UINTN Address,\r |
1716 | IN UINTN StartBit,\r | |
1717 | IN UINTN EndBit,\r | |
1718 | IN UINT16 AndData,\r | |
1719 | IN UINT16 OrData\r | |
ba9f8351 | 1720 | )\r |
1721 | {\r | |
1722 | return MmioWrite16 (\r | |
1723 | Address,\r | |
1724 | BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData)\r | |
1725 | );\r | |
1726 | }\r | |
1727 | \r | |
1728 | /**\r | |
1729 | Reads a 32-bit MMIO register, performs a bitwise OR, and writes the\r | |
1730 | result back to the 32-bit MMIO register.\r | |
1731 | \r | |
1732 | Reads the 32-bit MMIO register specified by Address, performs a bitwise\r | |
1733 | inclusive OR between the read result and the value specified by OrData, and\r | |
1734 | writes the result to the 32-bit MMIO register specified by Address. The value\r | |
1735 | written to the MMIO register is returned. This function must guarantee that\r | |
1736 | all MMIO read and write operations are serialized.\r | |
1737 | \r | |
1738 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
1739 | \r | |
1740 | @param Address The MMIO register to write.\r | |
1741 | @param OrData The value to OR with the read value from the MMIO register.\r | |
1742 | \r | |
1743 | @return The value written back to the MMIO register.\r | |
1744 | \r | |
1745 | **/\r | |
1746 | UINT32\r | |
1747 | EFIAPI\r | |
1748 | MmioOr32 (\r | |
2f88bd3a MK |
1749 | IN UINTN Address,\r |
1750 | IN UINT32 OrData\r | |
ba9f8351 | 1751 | )\r |
1752 | {\r | |
1753 | return MmioWrite32 (Address, MmioRead32 (Address) | OrData);\r | |
1754 | }\r | |
1755 | \r | |
1756 | /**\r | |
1757 | Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result\r | |
1758 | back to the 32-bit MMIO register.\r | |
1759 | \r | |
1760 | Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r | |
1761 | between the read result and the value specified by AndData, and writes the\r | |
1762 | result to the 32-bit MMIO register specified by Address. The value written to\r | |
1763 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1764 | read and write operations are serialized.\r | |
1765 | \r | |
1766 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
1767 | \r | |
1768 | @param Address The MMIO register to write.\r | |
1769 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1770 | \r | |
1771 | @return The value written back to the MMIO register.\r | |
1772 | \r | |
1773 | **/\r | |
1774 | UINT32\r | |
1775 | EFIAPI\r | |
1776 | MmioAnd32 (\r | |
2f88bd3a MK |
1777 | IN UINTN Address,\r |
1778 | IN UINT32 AndData\r | |
ba9f8351 | 1779 | )\r |
1780 | {\r | |
1781 | return MmioWrite32 (Address, MmioRead32 (Address) & AndData);\r | |
1782 | }\r | |
1783 | \r | |
1784 | /**\r | |
1785 | Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise\r | |
1786 | inclusive OR, and writes the result back to the 32-bit MMIO register.\r | |
1787 | \r | |
1788 | Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r | |
1789 | between the read result and the value specified by AndData, performs a\r | |
1790 | bitwise OR between the result of the AND operation and the value specified by\r | |
1791 | OrData, and writes the result to the 32-bit MMIO register specified by\r | |
1792 | Address. The value written to the MMIO register is returned. This function\r | |
1793 | must guarantee that all MMIO read and write operations are serialized.\r | |
1794 | \r | |
1795 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
1796 | \r | |
1797 | \r | |
1798 | @param Address The MMIO register to write.\r | |
1799 | @param AndData The value to AND with the read value from the MMIO register.\r | |
1800 | @param OrData The value to OR with the result of the AND operation.\r | |
1801 | \r | |
1802 | @return The value written back to the MMIO register.\r | |
1803 | \r | |
1804 | **/\r | |
1805 | UINT32\r | |
1806 | EFIAPI\r | |
1807 | MmioAndThenOr32 (\r | |
2f88bd3a MK |
1808 | IN UINTN Address,\r |
1809 | IN UINT32 AndData,\r | |
1810 | IN UINT32 OrData\r | |
ba9f8351 | 1811 | )\r |
1812 | {\r | |
1813 | return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData);\r | |
1814 | }\r | |
1815 | \r | |
1816 | /**\r | |
1817 | Reads a bit field of a MMIO register.\r | |
1818 | \r | |
1819 | Reads the bit field in a 32-bit MMIO register. The bit field is specified by\r | |
1820 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
1821 | \r | |
1822 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
1823 | If StartBit is greater than 31, then ASSERT().\r | |
1824 | If EndBit is greater than 31, then ASSERT().\r | |
1825 | If EndBit is less than StartBit, then ASSERT().\r | |
1826 | \r | |
58380e9c | 1827 | @param Address The MMIO register to read.\r |
ba9f8351 | 1828 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1829 | Range 0..31.\r | |
1830 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1831 | Range 0..31.\r | |
1832 | \r | |
1833 | @return The value read.\r | |
1834 | \r | |
1835 | **/\r | |
1836 | UINT32\r | |
1837 | EFIAPI\r | |
1838 | MmioBitFieldRead32 (\r | |
2f88bd3a MK |
1839 | IN UINTN Address,\r |
1840 | IN UINTN StartBit,\r | |
1841 | IN UINTN EndBit\r | |
ba9f8351 | 1842 | )\r |
1843 | {\r | |
1844 | return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit);\r | |
1845 | }\r | |
1846 | \r | |
1847 | /**\r | |
1848 | Writes a bit field to a MMIO register.\r | |
1849 | \r | |
1850 | Writes Value to the bit field of the MMIO register. The bit field is\r | |
1851 | specified by the StartBit and the EndBit. All other bits in the destination\r | |
1852 | MMIO register are preserved. The new value of the 32-bit register is returned.\r | |
1853 | \r | |
1854 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
1855 | If StartBit is greater than 31, then ASSERT().\r | |
1856 | If EndBit is greater than 31, then ASSERT().\r | |
1857 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1858 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1859 | \r |
58380e9c | 1860 | @param Address The MMIO register to write.\r |
ba9f8351 | 1861 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1862 | Range 0..31.\r | |
1863 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1864 | Range 0..31.\r | |
2fc59a00 | 1865 | @param Value The new value of the bit field.\r |
ba9f8351 | 1866 | \r |
1867 | @return The value written back to the MMIO register.\r | |
1868 | \r | |
1869 | **/\r | |
1870 | UINT32\r | |
1871 | EFIAPI\r | |
1872 | MmioBitFieldWrite32 (\r | |
2f88bd3a MK |
1873 | IN UINTN Address,\r |
1874 | IN UINTN StartBit,\r | |
1875 | IN UINTN EndBit,\r | |
1876 | IN UINT32 Value\r | |
ba9f8351 | 1877 | )\r |
1878 | {\r | |
1879 | return MmioWrite32 (\r | |
1880 | Address,\r | |
1881 | BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value)\r | |
1882 | );\r | |
1883 | }\r | |
1884 | \r | |
1885 | /**\r | |
1886 | Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and\r | |
1887 | writes the result back to the bit field in the 32-bit MMIO register.\r | |
1888 | \r | |
1889 | Reads the 32-bit MMIO register specified by Address, performs a bitwise\r | |
1890 | inclusive OR between the read result and the value specified by OrData, and\r | |
1891 | writes the result to the 32-bit MMIO register specified by Address. The value\r | |
1892 | written to the MMIO register is returned. This function must guarantee that\r | |
1893 | all MMIO read and write operations are serialized. Extra left bits in OrData\r | |
1894 | are stripped.\r | |
1895 | \r | |
1896 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
1897 | If StartBit is greater than 31, then ASSERT().\r | |
1898 | If EndBit is greater than 31, then ASSERT().\r | |
1899 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1900 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1901 | \r |
58380e9c | 1902 | @param Address The MMIO register to write.\r |
ba9f8351 | 1903 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1904 | Range 0..31.\r | |
1905 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1906 | Range 0..31.\r | |
1907 | @param OrData The value to OR with read value from the MMIO register.\r | |
1908 | \r | |
1909 | @return The value written back to the MMIO register.\r | |
1910 | \r | |
1911 | **/\r | |
1912 | UINT32\r | |
1913 | EFIAPI\r | |
1914 | MmioBitFieldOr32 (\r | |
2f88bd3a MK |
1915 | IN UINTN Address,\r |
1916 | IN UINTN StartBit,\r | |
1917 | IN UINTN EndBit,\r | |
1918 | IN UINT32 OrData\r | |
ba9f8351 | 1919 | )\r |
1920 | {\r | |
1921 | return MmioWrite32 (\r | |
1922 | Address,\r | |
1923 | BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData)\r | |
1924 | );\r | |
1925 | }\r | |
1926 | \r | |
1927 | /**\r | |
1928 | Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and\r | |
1929 | writes the result back to the bit field in the 32-bit MMIO register.\r | |
1930 | \r | |
1931 | Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r | |
1932 | between the read result and the value specified by AndData, and writes the\r | |
1933 | result to the 32-bit MMIO register specified by Address. The value written to\r | |
1934 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
1935 | read and write operations are serialized. Extra left bits in AndData are\r | |
1936 | stripped.\r | |
1937 | \r | |
1938 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
1939 | If StartBit is greater than 31, then ASSERT().\r | |
1940 | If EndBit is greater than 31, then ASSERT().\r | |
1941 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 1942 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 1943 | \r |
58380e9c | 1944 | @param Address The MMIO register to write.\r |
ba9f8351 | 1945 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1946 | Range 0..31.\r | |
1947 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1948 | Range 0..31.\r | |
1949 | @param AndData The value to AND with read value from the MMIO register.\r | |
1950 | \r | |
1951 | @return The value written back to the MMIO register.\r | |
1952 | \r | |
1953 | **/\r | |
1954 | UINT32\r | |
1955 | EFIAPI\r | |
1956 | MmioBitFieldAnd32 (\r | |
2f88bd3a MK |
1957 | IN UINTN Address,\r |
1958 | IN UINTN StartBit,\r | |
1959 | IN UINTN EndBit,\r | |
1960 | IN UINT32 AndData\r | |
ba9f8351 | 1961 | )\r |
1962 | {\r | |
1963 | return MmioWrite32 (\r | |
1964 | Address,\r | |
1965 | BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData)\r | |
1966 | );\r | |
1967 | }\r | |
1968 | \r | |
1969 | /**\r | |
1970 | Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed\r | |
1971 | by a bitwise OR, and writes the result back to the bit field in the\r | |
1972 | 32-bit MMIO register.\r | |
1973 | \r | |
1974 | Reads the 32-bit MMIO register specified by Address, performs a bitwise AND\r | |
1975 | followed by a bitwise OR between the read result and the value\r | |
1976 | specified by AndData, and writes the result to the 32-bit MMIO register\r | |
1977 | specified by Address. The value written to the MMIO register is returned.\r | |
1978 | This function must guarantee that all MMIO read and write operations are\r | |
1979 | serialized. Extra left bits in both AndData and OrData are stripped.\r | |
1980 | \r | |
1981 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
1982 | If StartBit is greater than 31, then ASSERT().\r | |
1983 | If EndBit is greater than 31, then ASSERT().\r | |
1984 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
1985 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
1986 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ba9f8351 | 1987 | \r |
58380e9c | 1988 | @param Address The MMIO register to write.\r |
ba9f8351 | 1989 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
1990 | Range 0..31.\r | |
1991 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1992 | Range 0..31.\r | |
1993 | @param AndData The value to AND with read value from the MMIO register.\r | |
1994 | @param OrData The value to OR with the result of the AND operation.\r | |
1995 | \r | |
1996 | @return The value written back to the MMIO register.\r | |
1997 | \r | |
1998 | **/\r | |
1999 | UINT32\r | |
2000 | EFIAPI\r | |
2001 | MmioBitFieldAndThenOr32 (\r | |
2f88bd3a MK |
2002 | IN UINTN Address,\r |
2003 | IN UINTN StartBit,\r | |
2004 | IN UINTN EndBit,\r | |
2005 | IN UINT32 AndData,\r | |
2006 | IN UINT32 OrData\r | |
ba9f8351 | 2007 | )\r |
2008 | {\r | |
2009 | return MmioWrite32 (\r | |
2010 | Address,\r | |
2011 | BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData)\r | |
2012 | );\r | |
2013 | }\r | |
2014 | \r | |
2015 | /**\r | |
2016 | Reads a 64-bit MMIO register, performs a bitwise OR, and writes the\r | |
2017 | result back to the 64-bit MMIO register.\r | |
2018 | \r | |
2019 | Reads the 64-bit MMIO register specified by Address, performs a bitwise\r | |
2020 | inclusive OR between the read result and the value specified by OrData, and\r | |
2021 | writes the result to the 64-bit MMIO register specified by Address. The value\r | |
2022 | written to the MMIO register is returned. This function must guarantee that\r | |
2023 | all MMIO read and write operations are serialized.\r | |
2024 | \r | |
2025 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2026 | \r | |
2027 | @param Address The MMIO register to write.\r | |
2028 | @param OrData The value to OR with the read value from the MMIO register.\r | |
2029 | \r | |
2030 | @return The value written back to the MMIO register.\r | |
2031 | \r | |
2032 | **/\r | |
2033 | UINT64\r | |
2034 | EFIAPI\r | |
2035 | MmioOr64 (\r | |
2f88bd3a MK |
2036 | IN UINTN Address,\r |
2037 | IN UINT64 OrData\r | |
ba9f8351 | 2038 | )\r |
2039 | {\r | |
2040 | return MmioWrite64 (Address, MmioRead64 (Address) | OrData);\r | |
2041 | }\r | |
2042 | \r | |
2043 | /**\r | |
2044 | Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result\r | |
2045 | back to the 64-bit MMIO register.\r | |
2046 | \r | |
2047 | Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r | |
2048 | between the read result and the value specified by AndData, and writes the\r | |
2049 | result to the 64-bit MMIO register specified by Address. The value written to\r | |
2050 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
2051 | read and write operations are serialized.\r | |
2052 | \r | |
2053 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2054 | \r | |
2055 | @param Address The MMIO register to write.\r | |
2056 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2057 | \r | |
2058 | @return The value written back to the MMIO register.\r | |
2059 | \r | |
2060 | **/\r | |
2061 | UINT64\r | |
2062 | EFIAPI\r | |
2063 | MmioAnd64 (\r | |
2f88bd3a MK |
2064 | IN UINTN Address,\r |
2065 | IN UINT64 AndData\r | |
ba9f8351 | 2066 | )\r |
2067 | {\r | |
2068 | return MmioWrite64 (Address, MmioRead64 (Address) & AndData);\r | |
2069 | }\r | |
2070 | \r | |
2071 | /**\r | |
2072 | Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise\r | |
2073 | inclusive OR, and writes the result back to the 64-bit MMIO register.\r | |
2074 | \r | |
2075 | Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r | |
2076 | between the read result and the value specified by AndData, performs a\r | |
2077 | bitwise OR between the result of the AND operation and the value specified by\r | |
2078 | OrData, and writes the result to the 64-bit MMIO register specified by\r | |
2079 | Address. The value written to the MMIO register is returned. This function\r | |
2080 | must guarantee that all MMIO read and write operations are serialized.\r | |
2081 | \r | |
2082 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2083 | \r | |
2084 | \r | |
2085 | @param Address The MMIO register to write.\r | |
2086 | @param AndData The value to AND with the read value from the MMIO register.\r | |
2087 | @param OrData The value to OR with the result of the AND operation.\r | |
2088 | \r | |
2089 | @return The value written back to the MMIO register.\r | |
2090 | \r | |
2091 | **/\r | |
2092 | UINT64\r | |
2093 | EFIAPI\r | |
2094 | MmioAndThenOr64 (\r | |
2f88bd3a MK |
2095 | IN UINTN Address,\r |
2096 | IN UINT64 AndData,\r | |
2097 | IN UINT64 OrData\r | |
ba9f8351 | 2098 | )\r |
2099 | {\r | |
2100 | return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData);\r | |
2101 | }\r | |
2102 | \r | |
2103 | /**\r | |
2104 | Reads a bit field of a MMIO register.\r | |
2105 | \r | |
2106 | Reads the bit field in a 64-bit MMIO register. The bit field is specified by\r | |
2107 | the StartBit and the EndBit. The value of the bit field is returned.\r | |
2108 | \r | |
2109 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2110 | If StartBit is greater than 63, then ASSERT().\r | |
2111 | If EndBit is greater than 63, then ASSERT().\r | |
2112 | If EndBit is less than StartBit, then ASSERT().\r | |
2113 | \r | |
58380e9c | 2114 | @param Address The MMIO register to read.\r |
ba9f8351 | 2115 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
2116 | Range 0..63.\r | |
2117 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2118 | Range 0..63.\r | |
2119 | \r | |
2120 | @return The value read.\r | |
2121 | \r | |
2122 | **/\r | |
2123 | UINT64\r | |
2124 | EFIAPI\r | |
2125 | MmioBitFieldRead64 (\r | |
2f88bd3a MK |
2126 | IN UINTN Address,\r |
2127 | IN UINTN StartBit,\r | |
2128 | IN UINTN EndBit\r | |
ba9f8351 | 2129 | )\r |
2130 | {\r | |
2131 | return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit);\r | |
2132 | }\r | |
2133 | \r | |
2134 | /**\r | |
2135 | Writes a bit field to a MMIO register.\r | |
2136 | \r | |
2137 | Writes Value to the bit field of the MMIO register. The bit field is\r | |
2138 | specified by the StartBit and the EndBit. All other bits in the destination\r | |
2139 | MMIO register are preserved. The new value of the 64-bit register is returned.\r | |
2140 | \r | |
2141 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2142 | If StartBit is greater than 63, then ASSERT().\r | |
2143 | If EndBit is greater than 63, then ASSERT().\r | |
2144 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2145 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 2146 | \r |
58380e9c | 2147 | @param Address The MMIO register to write.\r |
ba9f8351 | 2148 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
2149 | Range 0..63.\r | |
2150 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2151 | Range 0..63.\r | |
2fc59a00 | 2152 | @param Value The new value of the bit field.\r |
ba9f8351 | 2153 | \r |
2154 | @return The value written back to the MMIO register.\r | |
2155 | \r | |
2156 | **/\r | |
2157 | UINT64\r | |
2158 | EFIAPI\r | |
2159 | MmioBitFieldWrite64 (\r | |
2f88bd3a MK |
2160 | IN UINTN Address,\r |
2161 | IN UINTN StartBit,\r | |
2162 | IN UINTN EndBit,\r | |
2163 | IN UINT64 Value\r | |
ba9f8351 | 2164 | )\r |
2165 | {\r | |
2166 | return MmioWrite64 (\r | |
2167 | Address,\r | |
2168 | BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value)\r | |
2169 | );\r | |
2170 | }\r | |
2171 | \r | |
2172 | /**\r | |
2173 | Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and\r | |
2174 | writes the result back to the bit field in the 64-bit MMIO register.\r | |
2175 | \r | |
2176 | Reads the 64-bit MMIO register specified by Address, performs a bitwise\r | |
2177 | inclusive OR between the read result and the value specified by OrData, and\r | |
2178 | writes the result to the 64-bit MMIO register specified by Address. The value\r | |
2179 | written to the MMIO register is returned. This function must guarantee that\r | |
2180 | all MMIO read and write operations are serialized. Extra left bits in OrData\r | |
2181 | are stripped.\r | |
2182 | \r | |
2183 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2184 | If StartBit is greater than 63, then ASSERT().\r | |
2185 | If EndBit is greater than 63, then ASSERT().\r | |
2186 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2187 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 2188 | \r |
58380e9c | 2189 | @param Address The MMIO register to write.\r |
ba9f8351 | 2190 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
2191 | Range 0..63.\r | |
2192 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2193 | Range 0..63.\r | |
2194 | @param OrData The value to OR with read value from the MMIO register.\r | |
2195 | \r | |
2196 | @return The value written back to the MMIO register.\r | |
2197 | \r | |
2198 | **/\r | |
2199 | UINT64\r | |
2200 | EFIAPI\r | |
2201 | MmioBitFieldOr64 (\r | |
2f88bd3a MK |
2202 | IN UINTN Address,\r |
2203 | IN UINTN StartBit,\r | |
2204 | IN UINTN EndBit,\r | |
2205 | IN UINT64 OrData\r | |
ba9f8351 | 2206 | )\r |
2207 | {\r | |
2208 | return MmioWrite64 (\r | |
2209 | Address,\r | |
2210 | BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData)\r | |
2211 | );\r | |
2212 | }\r | |
2213 | \r | |
2214 | /**\r | |
2215 | Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and\r | |
2216 | writes the result back to the bit field in the 64-bit MMIO register.\r | |
2217 | \r | |
2218 | Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r | |
2219 | between the read result and the value specified by AndData, and writes the\r | |
2220 | result to the 64-bit MMIO register specified by Address. The value written to\r | |
2221 | the MMIO register is returned. This function must guarantee that all MMIO\r | |
2222 | read and write operations are serialized. Extra left bits in AndData are\r | |
2223 | stripped.\r | |
2224 | \r | |
2225 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2226 | If StartBit is greater than 63, then ASSERT().\r | |
2227 | If EndBit is greater than 63, then ASSERT().\r | |
2228 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2229 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ba9f8351 | 2230 | \r |
58380e9c | 2231 | @param Address The MMIO register to write.\r |
ba9f8351 | 2232 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
2233 | Range 0..63.\r | |
2234 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2235 | Range 0..63.\r | |
2236 | @param AndData The value to AND with read value from the MMIO register.\r | |
2237 | \r | |
2238 | @return The value written back to the MMIO register.\r | |
2239 | \r | |
2240 | **/\r | |
2241 | UINT64\r | |
2242 | EFIAPI\r | |
2243 | MmioBitFieldAnd64 (\r | |
2f88bd3a MK |
2244 | IN UINTN Address,\r |
2245 | IN UINTN StartBit,\r | |
2246 | IN UINTN EndBit,\r | |
2247 | IN UINT64 AndData\r | |
ba9f8351 | 2248 | )\r |
2249 | {\r | |
2250 | return MmioWrite64 (\r | |
2251 | Address,\r | |
2252 | BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData)\r | |
2253 | );\r | |
2254 | }\r | |
2255 | \r | |
2256 | /**\r | |
2257 | Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed\r | |
2258 | by a bitwise OR, and writes the result back to the bit field in the\r | |
2259 | 64-bit MMIO register.\r | |
2260 | \r | |
2261 | Reads the 64-bit MMIO register specified by Address, performs a bitwise AND\r | |
2262 | followed by a bitwise OR between the read result and the value\r | |
2263 | specified by AndData, and writes the result to the 64-bit MMIO register\r | |
2264 | specified by Address. The value written to the MMIO register is returned.\r | |
2265 | This function must guarantee that all MMIO read and write operations are\r | |
2266 | serialized. Extra left bits in both AndData and OrData are stripped.\r | |
2267 | \r | |
2268 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
2269 | If StartBit is greater than 63, then ASSERT().\r | |
2270 | If EndBit is greater than 63, then ASSERT().\r | |
2271 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
2272 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
2273 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ba9f8351 | 2274 | \r |
58380e9c | 2275 | @param Address The MMIO register to write.\r |
ba9f8351 | 2276 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
2277 | Range 0..63.\r | |
2278 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2279 | Range 0..63.\r | |
2280 | @param AndData The value to AND with read value from the MMIO register.\r | |
2281 | @param OrData The value to OR with the result of the AND operation.\r | |
2282 | \r | |
2283 | @return The value written back to the MMIO register.\r | |
2284 | \r | |
2285 | **/\r | |
2286 | UINT64\r | |
2287 | EFIAPI\r | |
2288 | MmioBitFieldAndThenOr64 (\r | |
2f88bd3a MK |
2289 | IN UINTN Address,\r |
2290 | IN UINTN StartBit,\r | |
2291 | IN UINTN EndBit,\r | |
2292 | IN UINT64 AndData,\r | |
2293 | IN UINT64 OrData\r | |
ba9f8351 | 2294 | )\r |
2295 | {\r | |
2296 | return MmioWrite64 (\r | |
2297 | Address,\r | |
2298 | BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData)\r | |
2299 | );\r | |
2300 | }\r |