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