]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePciLibCf8/PciLib.c
Make comments match the Spec.
[mirror_edk2.git] / MdePkg / Library / BasePciLibCf8 / PciLib.c
1 /** @file
2 PCI Library functions that use I/O ports 0xCF8 and 0xCFC to perform
3 PCI Configuration cycles. Layers on top of one PCI CF8 Library instance.
4
5 Copyright (c) 2006 - 2008, Intel Corporation<BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16
17 #include <Base.h>
18
19 #include <Library/PciLib.h>
20 #include <Library/PciCf8Lib.h>
21
22 /**
23 Registers a PCI device so PCI configuration registers may be accessed after
24 SetVirtualAddressMap().
25
26 Registers the PCI device specified by Address so all the PCI configuration registers
27 associated with that PCI device may be accessed after SetVirtualAddressMap() is called.
28
29 If Address > 0x0FFFFFFF, then ASSERT().
30
31 @param Address Address that encodes the PCI Bus, Device, Function and
32 Register.
33
34 @retval RETURN_SUCCESS The PCI device was registered for runtime access.
35 @retval RETURN_UNSUPPORTED An attempt was made to call this function
36 after ExitBootServices().
37 @retval RETURN_UNSUPPORTED The resources required to access the PCI device
38 at runtime could not be mapped.
39 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to
40 complete the registration.
41
42 **/
43 RETURN_STATUS
44 EFIAPI
45 PciRegisterForRuntimeAccess (
46 IN UINTN Address
47 )
48 {
49 return PciCf8RegisterForRuntimeAccess (Address);
50 }
51
52 /**
53 Reads an 8-bit PCI configuration register.
54
55 Reads and returns the 8-bit PCI configuration register specified by Address.
56 This function must guarantee that all PCI read and write operations are
57 serialized.
58
59 If Address > 0x0FFFFFFF, then ASSERT().
60
61 @param Address Address that encodes the PCI Bus, Device, Function and
62 Register.
63
64 @return The read value from the PCI configuration register.
65
66 **/
67 UINT8
68 EFIAPI
69 PciRead8 (
70 IN UINTN Address
71 )
72 {
73 return PciCf8Read8 (Address);
74 }
75
76 /**
77 Writes an 8-bit PCI configuration register.
78
79 Writes the 8-bit PCI configuration register specified by Address with the
80 value specified by Value. Value is returned. This function must guarantee
81 that all PCI read and write operations are serialized.
82
83 If Address > 0x0FFFFFFF, then ASSERT().
84
85 @param Address Address that encodes the PCI Bus, Device, Function and
86 Register.
87 @param Value The value to write.
88
89 @return The value written to the PCI configuration register.
90
91 **/
92 UINT8
93 EFIAPI
94 PciWrite8 (
95 IN UINTN Address,
96 IN UINT8 Value
97 )
98 {
99 return PciCf8Write8 (Address, Value);
100 }
101
102 /**
103 Performs a bitwise OR of an 8-bit PCI configuration register with
104 an 8-bit value.
105
106 Reads the 8-bit PCI configuration register specified by Address, performs a
107 bitwise OR between the read result and the value specified by
108 OrData, and writes the result to the 8-bit PCI configuration register
109 specified by Address. The value written to the PCI configuration register is
110 returned. This function must guarantee that all PCI read and write operations
111 are serialized.
112
113 If Address > 0x0FFFFFFF, then ASSERT().
114
115 @param Address Address that encodes the PCI Bus, Device, Function and
116 Register.
117 @param OrData The value to OR with the PCI configuration register.
118
119 @return The value written back to the PCI configuration register.
120
121 **/
122 UINT8
123 EFIAPI
124 PciOr8 (
125 IN UINTN Address,
126 IN UINT8 OrData
127 )
128 {
129 return PciCf8Or8 (Address, OrData);
130 }
131
132 /**
133 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
134 value.
135
136 Reads the 8-bit PCI configuration register specified by Address, performs a
137 bitwise AND between the read result and the value specified by AndData, and
138 writes the result to the 8-bit PCI configuration register specified by
139 Address. The value written to the PCI configuration register is returned.
140 This function must guarantee that all PCI read and write operations are
141 serialized.
142
143 If Address > 0x0FFFFFFF, then ASSERT().
144
145 @param Address Address that encodes the PCI Bus, Device, Function and
146 Register.
147 @param AndData The value to AND with the PCI configuration register.
148
149 @return The value written back to the PCI configuration register.
150
151 **/
152 UINT8
153 EFIAPI
154 PciAnd8 (
155 IN UINTN Address,
156 IN UINT8 AndData
157 )
158 {
159 return PciCf8And8 (Address, AndData);
160 }
161
162 /**
163 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
164 value, followed a bitwise OR with another 8-bit value.
165
166 Reads the 8-bit PCI configuration register specified by Address, performs a
167 bitwise AND between the read result and the value specified by AndData,
168 performs a bitwise OR between the result of the AND operation and
169 the value specified by OrData, and writes the result to the 8-bit PCI
170 configuration register specified by Address. The value written to the PCI
171 configuration register is returned. This function must guarantee that all PCI
172 read and write operations are serialized.
173
174 If Address > 0x0FFFFFFF, then ASSERT().
175
176 @param Address Address that encodes the PCI Bus, Device, Function and
177 Register.
178 @param AndData The value to AND with the PCI configuration register.
179 @param OrData The value to OR with the result of the AND operation.
180
181 @return The value written back to the PCI configuration register.
182
183 **/
184 UINT8
185 EFIAPI
186 PciAndThenOr8 (
187 IN UINTN Address,
188 IN UINT8 AndData,
189 IN UINT8 OrData
190 )
191 {
192 return PciCf8AndThenOr8 (Address, AndData, OrData);
193 }
194
195 /**
196 Reads a bit field of a PCI configuration register.
197
198 Reads the bit field in an 8-bit PCI configuration register. The bit field is
199 specified by the StartBit and the EndBit. The value of the bit field is
200 returned.
201
202 If Address > 0x0FFFFFFF, then ASSERT().
203 If StartBit is greater than 7, then ASSERT().
204 If EndBit is greater than 7, then ASSERT().
205 If EndBit is less than StartBit, then ASSERT().
206
207 @param Address PCI configuration register to read.
208 @param StartBit The ordinal of the least significant bit in the bit field.
209 Range 0..7.
210 @param EndBit The ordinal of the most significant bit in the bit field.
211 Range 0..7.
212
213 @return The value of the bit field read from the PCI configuration register.
214
215 **/
216 UINT8
217 EFIAPI
218 PciBitFieldRead8 (
219 IN UINTN Address,
220 IN UINTN StartBit,
221 IN UINTN EndBit
222 )
223 {
224 return PciCf8BitFieldRead8 (Address, StartBit, EndBit);
225 }
226
227 /**
228 Writes a bit field to a PCI configuration register.
229
230 Writes Value to the bit field of the PCI configuration register. The bit
231 field is specified by the StartBit and the EndBit. All other bits in the
232 destination PCI configuration register are preserved. The new value of the
233 8-bit register is returned.
234
235 If Address > 0x0FFFFFFF, then ASSERT().
236 If StartBit is greater than 7, then ASSERT().
237 If EndBit is greater than 7, then ASSERT().
238 If EndBit is less than StartBit, then ASSERT().
239
240 @param Address PCI configuration register to write.
241 @param StartBit The ordinal of the least significant bit in the bit field.
242 Range 0..7.
243 @param EndBit The ordinal of the most significant bit in the bit field.
244 Range 0..7.
245 @param Value New value of the bit field.
246
247 @return The value written back to the PCI configuration register.
248
249 **/
250 UINT8
251 EFIAPI
252 PciBitFieldWrite8 (
253 IN UINTN Address,
254 IN UINTN StartBit,
255 IN UINTN EndBit,
256 IN UINT8 Value
257 )
258 {
259 return PciCf8BitFieldWrite8 (Address, StartBit, EndBit, Value);
260 }
261
262 /**
263 Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
264 writes the result back to the bit field in the 8-bit port.
265
266 Reads the 8-bit PCI configuration register specified by Address, performs a
267 bitwise OR between the read result and the value specified by
268 OrData, and writes the result to the 8-bit PCI configuration register
269 specified by Address. The value written to the PCI configuration register is
270 returned. This function must guarantee that all PCI read and write operations
271 are serialized. Extra left bits in OrData are stripped.
272
273 If Address > 0x0FFFFFFF, then ASSERT().
274 If StartBit is greater than 7, then ASSERT().
275 If EndBit is greater than 7, then ASSERT().
276 If EndBit is less than StartBit, then ASSERT().
277
278 @param Address PCI configuration register to write.
279 @param StartBit The ordinal of the least significant bit in the bit field.
280 Range 0..7.
281 @param EndBit The ordinal of the most significant bit in the bit field.
282 Range 0..7.
283 @param OrData The value to OR with the PCI configuration register.
284
285 @return The value written back to the PCI configuration register.
286
287 **/
288 UINT8
289 EFIAPI
290 PciBitFieldOr8 (
291 IN UINTN Address,
292 IN UINTN StartBit,
293 IN UINTN EndBit,
294 IN UINT8 OrData
295 )
296 {
297 return PciCf8BitFieldOr8 (Address, StartBit, EndBit, OrData);
298 }
299
300 /**
301 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
302 AND, and writes the result back to the bit field in the 8-bit register.
303
304 Reads the 8-bit PCI configuration register specified by Address, performs a
305 bitwise AND between the read result and the value specified by AndData, and
306 writes the result to the 8-bit PCI configuration register specified by
307 Address. The value written to the PCI configuration register is returned.
308 This function must guarantee that all PCI read and write operations are
309 serialized. Extra left bits in AndData are stripped.
310
311 If Address > 0x0FFFFFFF, then ASSERT().
312 If StartBit is greater than 7, then ASSERT().
313 If EndBit is greater than 7, then ASSERT().
314 If EndBit is less than StartBit, then ASSERT().
315
316 @param Address PCI configuration register to write.
317 @param StartBit The ordinal of the least significant bit in the bit field.
318 Range 0..7.
319 @param EndBit The ordinal of the most significant bit in the bit field.
320 Range 0..7.
321 @param AndData The value to AND with the PCI configuration register.
322
323 @return The value written back to the PCI configuration register.
324
325 **/
326 UINT8
327 EFIAPI
328 PciBitFieldAnd8 (
329 IN UINTN Address,
330 IN UINTN StartBit,
331 IN UINTN EndBit,
332 IN UINT8 AndData
333 )
334 {
335 return PciCf8BitFieldAnd8 (Address, StartBit, EndBit, AndData);
336 }
337
338 /**
339 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
340 bitwise OR, and writes the result back to the bit field in the
341 8-bit port.
342
343 Reads the 8-bit PCI configuration register specified by Address, performs a
344 bitwise AND followed by a bitwise OR between the read result and
345 the value specified by AndData, and writes the result to the 8-bit PCI
346 configuration register specified by Address. The value written to the PCI
347 configuration register is returned. This function must guarantee that all PCI
348 read and write operations are serialized. Extra left bits in both AndData and
349 OrData are stripped.
350
351 If Address > 0x0FFFFFFF, then ASSERT().
352 If StartBit is greater than 7, then ASSERT().
353 If EndBit is greater than 7, then ASSERT().
354 If EndBit is less than StartBit, then ASSERT().
355
356 @param Address PCI configuration register to write.
357 @param StartBit The ordinal of the least significant bit in the bit field.
358 Range 0..7.
359 @param EndBit The ordinal of the most significant bit in the bit field.
360 Range 0..7.
361 @param AndData The value to AND with the PCI configuration register.
362 @param OrData The value to OR with the result of the AND operation.
363
364 @return The value written back to the PCI configuration register.
365
366 **/
367 UINT8
368 EFIAPI
369 PciBitFieldAndThenOr8 (
370 IN UINTN Address,
371 IN UINTN StartBit,
372 IN UINTN EndBit,
373 IN UINT8 AndData,
374 IN UINT8 OrData
375 )
376 {
377 return PciCf8BitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData);
378 }
379
380 /**
381 Reads a 16-bit PCI configuration register.
382
383 Reads and returns the 16-bit PCI configuration register specified by Address.
384 This function must guarantee that all PCI read and write operations are
385 serialized.
386
387 If Address > 0x0FFFFFFF, then ASSERT().
388 If Address is not aligned on a 16-bit boundary, then ASSERT().
389
390 @param Address Address that encodes the PCI Bus, Device, Function and
391 Register.
392
393 @return The read value from the PCI configuration register.
394
395 **/
396 UINT16
397 EFIAPI
398 PciRead16 (
399 IN UINTN Address
400 )
401 {
402 return PciCf8Read16 (Address);
403 }
404
405 /**
406 Writes a 16-bit PCI configuration register.
407
408 Writes the 16-bit PCI configuration register specified by Address with the
409 value specified by Value. Value is returned. This function must guarantee
410 that all PCI read and write operations are serialized.
411
412 If Address > 0x0FFFFFFF, then ASSERT().
413 If Address is not aligned on a 16-bit boundary, then ASSERT().
414
415 @param Address Address that encodes the PCI Bus, Device, Function and
416 Register.
417 @param Value The value to write.
418
419 @return The value written to the PCI configuration register.
420
421 **/
422 UINT16
423 EFIAPI
424 PciWrite16 (
425 IN UINTN Address,
426 IN UINT16 Value
427 )
428 {
429 return PciCf8Write16 (Address, Value);
430 }
431
432 /**
433 Performs a bitwise OR of a 16-bit PCI configuration register with
434 a 16-bit value.
435
436 Reads the 16-bit PCI configuration register specified by Address, performs a
437 bitwise OR between the read result and the value specified by
438 OrData, and writes the result to the 16-bit PCI configuration register
439 specified by Address. The value written to the PCI configuration register is
440 returned. This function must guarantee that all PCI read and write operations
441 are serialized.
442
443 If Address > 0x0FFFFFFF, then ASSERT().
444 If Address is not aligned on a 16-bit boundary, then ASSERT().
445
446 @param Address Address that encodes the PCI Bus, Device, Function and
447 Register.
448 @param OrData The value to OR with the PCI configuration register.
449
450 @return The value written back to the PCI configuration register.
451
452 **/
453 UINT16
454 EFIAPI
455 PciOr16 (
456 IN UINTN Address,
457 IN UINT16 OrData
458 )
459 {
460 return PciCf8Or16 (Address, OrData);
461 }
462
463 /**
464 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
465 value.
466
467 Reads the 16-bit PCI configuration register specified by Address, performs a
468 bitwise AND between the read result and the value specified by AndData, and
469 writes the result to the 16-bit PCI configuration register specified by
470 Address. The value written to the PCI configuration register is returned.
471 This function must guarantee that all PCI read and write operations are
472 serialized.
473
474 If Address > 0x0FFFFFFF, then ASSERT().
475 If Address is not aligned on a 16-bit boundary, then ASSERT().
476
477 @param Address Address that encodes the PCI Bus, Device, Function and
478 Register.
479 @param AndData The value to AND with the PCI configuration register.
480
481 @return The value written back to the PCI configuration register.
482
483 **/
484 UINT16
485 EFIAPI
486 PciAnd16 (
487 IN UINTN Address,
488 IN UINT16 AndData
489 )
490 {
491 return PciCf8And16 (Address, AndData);
492 }
493
494 /**
495 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
496 value, followed a bitwise OR with another 16-bit value.
497
498 Reads the 16-bit PCI configuration register specified by Address, performs a
499 bitwise AND between the read result and the value specified by AndData,
500 performs a bitwise OR between the result of the AND operation and
501 the value specified by OrData, and writes the result to the 16-bit PCI
502 configuration register specified by Address. The value written to the PCI
503 configuration register is returned. This function must guarantee that all PCI
504 read and write operations are serialized.
505
506 If Address > 0x0FFFFFFF, then ASSERT().
507 If Address is not aligned on a 16-bit boundary, then ASSERT().
508
509 @param Address Address that encodes the PCI Bus, Device, Function and
510 Register.
511 @param AndData The value to AND with the PCI configuration register.
512 @param OrData The value to OR with the result of the AND operation.
513
514 @return The value written back to the PCI configuration register.
515
516 **/
517 UINT16
518 EFIAPI
519 PciAndThenOr16 (
520 IN UINTN Address,
521 IN UINT16 AndData,
522 IN UINT16 OrData
523 )
524 {
525 return PciCf8AndThenOr16 (Address, AndData, OrData);
526 }
527
528 /**
529 Reads a bit field of a PCI configuration register.
530
531 Reads the bit field in a 16-bit PCI configuration register. The bit field is
532 specified by the StartBit and the EndBit. The value of the bit field is
533 returned.
534
535 If Address > 0x0FFFFFFF, then ASSERT().
536 If Address is not aligned on a 16-bit boundary, then ASSERT().
537 If StartBit is greater than 15, then ASSERT().
538 If EndBit is greater than 15, then ASSERT().
539 If EndBit is less than StartBit, then ASSERT().
540
541 @param Address PCI configuration register to read.
542 @param StartBit The ordinal of the least significant bit in the bit field.
543 Range 0..15.
544 @param EndBit The ordinal of the most significant bit in the bit field.
545 Range 0..15.
546
547 @return The value of the bit field read from the PCI configuration register.
548
549 **/
550 UINT16
551 EFIAPI
552 PciBitFieldRead16 (
553 IN UINTN Address,
554 IN UINTN StartBit,
555 IN UINTN EndBit
556 )
557 {
558 return PciCf8BitFieldRead16 (Address, StartBit, EndBit);
559 }
560
561 /**
562 Writes a bit field to a PCI configuration register.
563
564 Writes Value to the bit field of the PCI configuration register. The bit
565 field is specified by the StartBit and the EndBit. All other bits in the
566 destination PCI configuration register are preserved. The new value of the
567 16-bit register is returned.
568
569 If Address > 0x0FFFFFFF, then ASSERT().
570 If Address is not aligned on a 16-bit boundary, then ASSERT().
571 If StartBit is greater than 15, then ASSERT().
572 If EndBit is greater than 15, then ASSERT().
573 If EndBit is less than StartBit, then ASSERT().
574
575 @param Address PCI configuration register to write.
576 @param StartBit The ordinal of the least significant bit in the bit field.
577 Range 0..15.
578 @param EndBit The ordinal of the most significant bit in the bit field.
579 Range 0..15.
580 @param Value New value of the bit field.
581
582 @return The value written back to the PCI configuration register.
583
584 **/
585 UINT16
586 EFIAPI
587 PciBitFieldWrite16 (
588 IN UINTN Address,
589 IN UINTN StartBit,
590 IN UINTN EndBit,
591 IN UINT16 Value
592 )
593 {
594 return PciCf8BitFieldWrite16 (Address, StartBit, EndBit, Value);
595 }
596
597 /**
598 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
599 writes the result back to the bit field in the 16-bit port.
600
601 Reads the 16-bit PCI configuration register specified by Address, performs a
602 bitwise OR between the read result and the value specified by
603 OrData, and writes the result to the 16-bit PCI configuration register
604 specified by Address. The value written to the PCI configuration register is
605 returned. This function must guarantee that all PCI read and write operations
606 are serialized. Extra left bits in OrData are stripped.
607
608 If Address > 0x0FFFFFFF, then ASSERT().
609 If Address is not aligned on a 16-bit boundary, then ASSERT().
610 If StartBit is greater than 15, then ASSERT().
611 If EndBit is greater than 15, then ASSERT().
612 If EndBit is less than StartBit, then ASSERT().
613
614 @param Address PCI configuration register to write.
615 @param StartBit The ordinal of the least significant bit in the bit field.
616 Range 0..15.
617 @param EndBit The ordinal of the most significant bit in the bit field.
618 Range 0..15.
619 @param OrData The value to OR with the PCI configuration register.
620
621 @return The value written back to the PCI configuration register.
622
623 **/
624 UINT16
625 EFIAPI
626 PciBitFieldOr16 (
627 IN UINTN Address,
628 IN UINTN StartBit,
629 IN UINTN EndBit,
630 IN UINT16 OrData
631 )
632 {
633 return PciCf8BitFieldOr16 (Address, StartBit, EndBit, OrData);
634 }
635
636 /**
637 Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
638 AND, and writes the result back to the bit field in the 16-bit register.
639
640 Reads the 16-bit PCI configuration register specified by Address, performs a
641 bitwise AND between the read result and the value specified by AndData, and
642 writes the result to the 16-bit PCI configuration register specified by
643 Address. The value written to the PCI configuration register is returned.
644 This function must guarantee that all PCI read and write operations are
645 serialized. Extra left bits in AndData are stripped.
646
647 If Address > 0x0FFFFFFF, then ASSERT().
648 If Address is not aligned on a 16-bit boundary, then ASSERT().
649 If StartBit is greater than 15, then ASSERT().
650 If EndBit is greater than 15, then ASSERT().
651 If EndBit is less than StartBit, then ASSERT().
652
653 @param Address PCI configuration register to write.
654 @param StartBit The ordinal of the least significant bit in the bit field.
655 Range 0..15.
656 @param EndBit The ordinal of the most significant bit in the bit field.
657 Range 0..15.
658 @param AndData The value to AND with the PCI configuration register.
659
660 @return The value written back to the PCI configuration register.
661
662 **/
663 UINT16
664 EFIAPI
665 PciBitFieldAnd16 (
666 IN UINTN Address,
667 IN UINTN StartBit,
668 IN UINTN EndBit,
669 IN UINT16 AndData
670 )
671 {
672 return PciCf8BitFieldAnd16 (Address, StartBit, EndBit, AndData);
673 }
674
675 /**
676 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
677 bitwise OR, and writes the result back to the bit field in the
678 16-bit port.
679
680 Reads the 16-bit PCI configuration register specified by Address, performs a
681 bitwise AND followed by a bitwise OR between the read result and
682 the value specified by AndData, and writes the result to the 16-bit PCI
683 configuration register specified by Address. The value written to the PCI
684 configuration register is returned. This function must guarantee that all PCI
685 read and write operations are serialized. Extra left bits in both AndData and
686 OrData are stripped.
687
688 If Address > 0x0FFFFFFF, then ASSERT().
689 If Address is not aligned on a 16-bit boundary, then ASSERT().
690 If StartBit is greater than 15, then ASSERT().
691 If EndBit is greater than 15, then ASSERT().
692 If EndBit is less than StartBit, then ASSERT().
693
694 @param Address PCI configuration register to write.
695 @param StartBit The ordinal of the least significant bit in the bit field.
696 Range 0..15.
697 @param EndBit The ordinal of the most significant bit in the bit field.
698 Range 0..15.
699 @param AndData The value to AND with the PCI configuration register.
700 @param OrData The value to OR with the result of the AND operation.
701
702 @return The value written back to the PCI configuration register.
703
704 **/
705 UINT16
706 EFIAPI
707 PciBitFieldAndThenOr16 (
708 IN UINTN Address,
709 IN UINTN StartBit,
710 IN UINTN EndBit,
711 IN UINT16 AndData,
712 IN UINT16 OrData
713 )
714 {
715 return PciCf8BitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData);
716 }
717
718 /**
719 Reads a 32-bit PCI configuration register.
720
721 Reads and returns the 32-bit PCI configuration register specified by Address.
722 This function must guarantee that all PCI read and write operations are
723 serialized.
724
725 If Address > 0x0FFFFFFF, then ASSERT().
726 If Address is not aligned on a 32-bit boundary, then ASSERT().
727
728 @param Address Address that encodes the PCI Bus, Device, Function and
729 Register.
730
731 @return The read value from the PCI configuration register.
732
733 **/
734 UINT32
735 EFIAPI
736 PciRead32 (
737 IN UINTN Address
738 )
739 {
740 return PciCf8Read32 (Address);
741 }
742
743 /**
744 Writes a 32-bit PCI configuration register.
745
746 Writes the 32-bit PCI configuration register specified by Address with the
747 value specified by Value. Value is returned. This function must guarantee
748 that all PCI read and write operations are serialized.
749
750 If Address > 0x0FFFFFFF, then ASSERT().
751 If Address is not aligned on a 32-bit boundary, then ASSERT().
752
753 @param Address Address that encodes the PCI Bus, Device, Function and
754 Register.
755 @param Value The value to write.
756
757 @return The value written to the PCI configuration register.
758
759 **/
760 UINT32
761 EFIAPI
762 PciWrite32 (
763 IN UINTN Address,
764 IN UINT32 Value
765 )
766 {
767 return PciCf8Write32 (Address, Value);
768 }
769
770 /**
771 Performs a bitwise OR of a 32-bit PCI configuration register with
772 a 32-bit value.
773
774 Reads the 32-bit PCI configuration register specified by Address, performs a
775 bitwise OR between the read result and the value specified by
776 OrData, and writes the result to the 32-bit PCI configuration register
777 specified by Address. The value written to the PCI configuration register is
778 returned. This function must guarantee that all PCI read and write operations
779 are serialized.
780
781 If Address > 0x0FFFFFFF, then ASSERT().
782 If Address is not aligned on a 32-bit boundary, then ASSERT().
783
784 @param Address Address that encodes the PCI Bus, Device, Function and
785 Register.
786 @param OrData The value to OR with the PCI configuration register.
787
788 @return The value written back to the PCI configuration register.
789
790 **/
791 UINT32
792 EFIAPI
793 PciOr32 (
794 IN UINTN Address,
795 IN UINT32 OrData
796 )
797 {
798 return PciCf8Or32 (Address, OrData);
799 }
800
801 /**
802 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
803 value.
804
805 Reads the 32-bit PCI configuration register specified by Address, performs a
806 bitwise AND between the read result and the value specified by AndData, and
807 writes the result to the 32-bit PCI configuration register specified by
808 Address. The value written to the PCI configuration register is returned.
809 This function must guarantee that all PCI read and write operations are
810 serialized.
811
812 If Address > 0x0FFFFFFF, then ASSERT().
813 If Address is not aligned on a 32-bit boundary, then ASSERT().
814
815 @param Address Address that encodes the PCI Bus, Device, Function and
816 Register.
817 @param AndData The value to AND with the PCI configuration register.
818
819 @return The value written back to the PCI configuration register.
820
821 **/
822 UINT32
823 EFIAPI
824 PciAnd32 (
825 IN UINTN Address,
826 IN UINT32 AndData
827 )
828 {
829 return PciCf8And32 (Address, AndData);
830 }
831
832 /**
833 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
834 value, followed a bitwise OR with another 32-bit value.
835
836 Reads the 32-bit PCI configuration register specified by Address, performs a
837 bitwise AND between the read result and the value specified by AndData,
838 performs a bitwise OR between the result of the AND operation and
839 the value specified by OrData, and writes the result to the 32-bit PCI
840 configuration register specified by Address. The value written to the PCI
841 configuration register is returned. This function must guarantee that all PCI
842 read and write operations are serialized.
843
844 If Address > 0x0FFFFFFF, then ASSERT().
845 If Address is not aligned on a 32-bit boundary, then ASSERT().
846
847 @param Address Address that encodes the PCI Bus, Device, Function and
848 Register.
849 @param AndData The value to AND with the PCI configuration register.
850 @param OrData The value to OR with the result of the AND operation.
851
852 @return The value written back to the PCI configuration register.
853
854 **/
855 UINT32
856 EFIAPI
857 PciAndThenOr32 (
858 IN UINTN Address,
859 IN UINT32 AndData,
860 IN UINT32 OrData
861 )
862 {
863 return PciCf8AndThenOr32 (Address, AndData, OrData);
864 }
865
866 /**
867 Reads a bit field of a PCI configuration register.
868
869 Reads the bit field in a 32-bit PCI configuration register. The bit field is
870 specified by the StartBit and the EndBit. The value of the bit field is
871 returned.
872
873 If Address > 0x0FFFFFFF, then ASSERT().
874 If Address is not aligned on a 32-bit boundary, then ASSERT().
875 If StartBit is greater than 31, then ASSERT().
876 If EndBit is greater than 31, then ASSERT().
877 If EndBit is less than StartBit, then ASSERT().
878
879 @param Address PCI configuration register to read.
880 @param StartBit The ordinal of the least significant bit in the bit field.
881 Range 0..31.
882 @param EndBit The ordinal of the most significant bit in the bit field.
883 Range 0..31.
884
885 @return The value of the bit field read from the PCI configuration register.
886
887 **/
888 UINT32
889 EFIAPI
890 PciBitFieldRead32 (
891 IN UINTN Address,
892 IN UINTN StartBit,
893 IN UINTN EndBit
894 )
895 {
896 return PciCf8BitFieldRead32 (Address, StartBit, EndBit);
897 }
898
899 /**
900 Writes a bit field to a PCI configuration register.
901
902 Writes Value to the bit field of the PCI configuration register. The bit
903 field is specified by the StartBit and the EndBit. All other bits in the
904 destination PCI configuration register are preserved. The new value of the
905 32-bit register is returned.
906
907 If Address > 0x0FFFFFFF, then ASSERT().
908 If Address is not aligned on a 32-bit boundary, then ASSERT().
909 If StartBit is greater than 31, then ASSERT().
910 If EndBit is greater than 31, then ASSERT().
911 If EndBit is less than StartBit, then ASSERT().
912
913 @param Address PCI configuration register to write.
914 @param StartBit The ordinal of the least significant bit in the bit field.
915 Range 0..31.
916 @param EndBit The ordinal of the most significant bit in the bit field.
917 Range 0..31.
918 @param Value New value of the bit field.
919
920 @return The value written back to the PCI configuration register.
921
922 **/
923 UINT32
924 EFIAPI
925 PciBitFieldWrite32 (
926 IN UINTN Address,
927 IN UINTN StartBit,
928 IN UINTN EndBit,
929 IN UINT32 Value
930 )
931 {
932 return PciCf8BitFieldWrite32 (Address, StartBit, EndBit, Value);
933 }
934
935 /**
936 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
937 writes the result back to the bit field in the 32-bit port.
938
939 Reads the 32-bit PCI configuration register specified by Address, performs a
940 bitwise OR between the read result and the value specified by
941 OrData, and writes the result to the 32-bit PCI configuration register
942 specified by Address. The value written to the PCI configuration register is
943 returned. This function must guarantee that all PCI read and write operations
944 are serialized. Extra left bits in OrData are stripped.
945
946 If Address > 0x0FFFFFFF, then ASSERT().
947 If Address is not aligned on a 32-bit boundary, then ASSERT().
948 If StartBit is greater than 31, then ASSERT().
949 If EndBit is greater than 31, then ASSERT().
950 If EndBit is less than StartBit, then ASSERT().
951
952 @param Address PCI configuration register to write.
953 @param StartBit The ordinal of the least significant bit in the bit field.
954 Range 0..31.
955 @param EndBit The ordinal of the most significant bit in the bit field.
956 Range 0..31.
957 @param OrData The value to OR with the PCI configuration register.
958
959 @return The value written back to the PCI configuration register.
960
961 **/
962 UINT32
963 EFIAPI
964 PciBitFieldOr32 (
965 IN UINTN Address,
966 IN UINTN StartBit,
967 IN UINTN EndBit,
968 IN UINT32 OrData
969 )
970 {
971 return PciCf8BitFieldOr32 (Address, StartBit, EndBit, OrData);
972 }
973
974 /**
975 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
976 AND, and writes the result back to the bit field in the 32-bit register.
977
978 Reads the 32-bit PCI configuration register specified by Address, performs a
979 bitwise AND between the read result and the value specified by AndData, and
980 writes the result to the 32-bit PCI configuration register specified by
981 Address. The value written to the PCI configuration register is returned.
982 This function must guarantee that all PCI read and write operations are
983 serialized. Extra left bits in AndData are stripped.
984
985 If Address > 0x0FFFFFFF, then ASSERT().
986 If Address is not aligned on a 32-bit boundary, then ASSERT().
987 If StartBit is greater than 31, then ASSERT().
988 If EndBit is greater than 31, then ASSERT().
989 If EndBit is less than StartBit, then ASSERT().
990
991 @param Address PCI configuration register to write.
992 @param StartBit The ordinal of the least significant bit in the bit field.
993 Range 0..31.
994 @param EndBit The ordinal of the most significant bit in the bit field.
995 Range 0..31.
996 @param AndData The value to AND with the PCI configuration register.
997
998 @return The value written back to the PCI configuration register.
999
1000 **/
1001 UINT32
1002 EFIAPI
1003 PciBitFieldAnd32 (
1004 IN UINTN Address,
1005 IN UINTN StartBit,
1006 IN UINTN EndBit,
1007 IN UINT32 AndData
1008 )
1009 {
1010 return PciCf8BitFieldAnd32 (Address, StartBit, EndBit, AndData);
1011 }
1012
1013 /**
1014 Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
1015 bitwise OR, and writes the result back to the bit field in the
1016 32-bit port.
1017
1018 Reads the 32-bit PCI configuration register specified by Address, performs a
1019 bitwise AND followed by a bitwise OR between the read result and
1020 the value specified by AndData, and writes the result to the 32-bit PCI
1021 configuration register specified by Address. The value written to the PCI
1022 configuration register is returned. This function must guarantee that all PCI
1023 read and write operations are serialized. Extra left bits in both AndData and
1024 OrData are stripped.
1025
1026 If Address > 0x0FFFFFFF, then ASSERT().
1027 If Address is not aligned on a 32-bit boundary, then ASSERT().
1028 If StartBit is greater than 31, then ASSERT().
1029 If EndBit is greater than 31, then ASSERT().
1030 If EndBit is less than StartBit, then ASSERT().
1031
1032 @param Address PCI configuration register to write.
1033 @param StartBit The ordinal of the least significant bit in the bit field.
1034 Range 0..31.
1035 @param EndBit The ordinal of the most significant bit in the bit field.
1036 Range 0..31.
1037 @param AndData The value to AND with the PCI configuration register.
1038 @param OrData The value to OR with the result of the AND operation.
1039
1040 @return The value written back to the PCI configuration register.
1041
1042 **/
1043 UINT32
1044 EFIAPI
1045 PciBitFieldAndThenOr32 (
1046 IN UINTN Address,
1047 IN UINTN StartBit,
1048 IN UINTN EndBit,
1049 IN UINT32 AndData,
1050 IN UINT32 OrData
1051 )
1052 {
1053 return PciCf8BitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData);
1054 }
1055
1056 /**
1057 Reads a range of PCI configuration registers into a caller supplied buffer.
1058
1059 Reads the range of PCI configuration registers specified by StartAddress and
1060 Size into the buffer specified by Buffer. This function only allows the PCI
1061 configuration registers from a single PCI function to be read. Size is
1062 returned. When possible 32-bit PCI configuration read cycles are used to read
1063 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
1064 and 16-bit PCI configuration read cycles may be used at the beginning and the
1065 end of the range.
1066
1067 If StartAddress > 0x0FFFFFFF, then ASSERT().
1068 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1069 If Size > 0 and Buffer is NULL, then ASSERT().
1070
1071 @param StartAddress Starting address that encodes the PCI Bus, Device,
1072 Function and Register.
1073 @param Size Size in bytes of the transfer.
1074 @param Buffer Pointer to a buffer receiving the data read.
1075
1076 @return Size
1077
1078 **/
1079 UINTN
1080 EFIAPI
1081 PciReadBuffer (
1082 IN UINTN StartAddress,
1083 IN UINTN Size,
1084 OUT VOID *Buffer
1085 )
1086 {
1087 return PciCf8ReadBuffer (StartAddress, Size, Buffer);
1088 }
1089
1090 /**
1091 Copies the data in a caller supplied buffer to a specified range of PCI
1092 configuration space.
1093
1094 Writes the range of PCI configuration registers specified by StartAddress and
1095 Size from the buffer specified by Buffer. This function only allows the PCI
1096 configuration registers from a single PCI function to be written. Size is
1097 returned. When possible 32-bit PCI configuration write cycles are used to
1098 write from StartAdress to StartAddress + Size. Due to alignment restrictions,
1099 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
1100 and the end of the range.
1101
1102 If StartAddress > 0x0FFFFFFF, then ASSERT().
1103 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1104 If Size > 0 and Buffer is NULL, then ASSERT().
1105
1106 @param StartAddress Starting address that encodes the PCI Bus, Device,
1107 Function and Register.
1108 @param Size Size in bytes of the transfer.
1109 @param Buffer Pointer to a buffer containing the data to write.
1110
1111 @return Size
1112
1113 **/
1114 UINTN
1115 EFIAPI
1116 PciWriteBuffer (
1117 IN UINTN StartAddress,
1118 IN UINTN Size,
1119 IN VOID *Buffer
1120 )
1121 {
1122 return PciCf8WriteBuffer (StartAddress, Size, Buffer);
1123 }