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