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