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