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