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