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