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