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