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