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