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