]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePciLibCf8/PciLib.c
Synchronize function comment in h file
[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 If Address is not aligned on a 16-bit boundary, then ASSERT().
386
387 @param Address Address that encodes the PCI Bus, Device, Function and
388 Register.
389
390 @return The read value from the PCI configuration register.
391
392 **/
393 UINT16
394 EFIAPI
395 PciRead16 (
396 IN UINTN Address
397 )
398 {
399 return PciCf8Read16 (Address);
400 }
401
402 /**
403 Writes a 16-bit PCI configuration register.
404
405 Writes the 16-bit PCI configuration register specified by Address with the
406 value specified by Value. Value is returned. This function must guarantee
407 that all PCI read and write operations are serialized.
408
409 If Address > 0x0FFFFFFF, then ASSERT().
410 If Address is not aligned on a 16-bit boundary, then ASSERT().
411
412 @param Address Address that encodes the PCI Bus, Device, Function and
413 Register.
414 @param Value The value to write.
415
416 @return The value written to the PCI configuration register.
417
418 **/
419 UINT16
420 EFIAPI
421 PciWrite16 (
422 IN UINTN Address,
423 IN UINT16 Value
424 )
425 {
426 return PciCf8Write16 (Address, Value);
427 }
428
429 /**
430 Performs a bitwise inclusive OR of a 16-bit PCI configuration register with
431 a 16-bit value.
432
433 Reads the 16-bit PCI configuration register specified by Address, performs a
434 bitwise inclusive OR between the read result and the value specified by
435 OrData, and writes the result to the 16-bit PCI configuration register
436 specified by Address. The value written to the PCI configuration register is
437 returned. This function must guarantee that all PCI read and write operations
438 are serialized.
439
440 If Address > 0x0FFFFFFF, then ASSERT().
441 If Address is not aligned on a 16-bit boundary, then ASSERT().
442
443 @param Address Address that encodes the PCI Bus, Device, Function and
444 Register.
445 @param OrData The value to OR with the PCI configuration register.
446
447 @return The value written back to the PCI configuration register.
448
449 **/
450 UINT16
451 EFIAPI
452 PciOr16 (
453 IN UINTN Address,
454 IN UINT16 OrData
455 )
456 {
457 return PciCf8Or16 (Address, OrData);
458 }
459
460 /**
461 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
462 value.
463
464 Reads the 16-bit PCI configuration register specified by Address, performs a
465 bitwise AND between the read result and the value specified by AndData, and
466 writes the result to the 16-bit PCI configuration register specified by
467 Address. The value written to the PCI configuration register is returned.
468 This function must guarantee that all PCI read and write operations are
469 serialized.
470
471 If Address > 0x0FFFFFFF, then ASSERT().
472 If Address is not aligned on a 16-bit boundary, then ASSERT().
473
474 @param Address Address that encodes the PCI Bus, Device, Function and
475 Register.
476 @param AndData The value to AND with the PCI configuration register.
477
478 @return The value written back to the PCI configuration register.
479
480 **/
481 UINT16
482 EFIAPI
483 PciAnd16 (
484 IN UINTN Address,
485 IN UINT16 AndData
486 )
487 {
488 return PciCf8And16 (Address, AndData);
489 }
490
491 /**
492 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
493 value, followed a bitwise inclusive OR with another 16-bit value.
494
495 Reads the 16-bit PCI configuration register specified by Address, performs a
496 bitwise AND between the read result and the value specified by AndData,
497 performs a bitwise inclusive OR between the result of the AND operation and
498 the value specified by OrData, and writes the result to the 16-bit PCI
499 configuration register specified by Address. The value written to the PCI
500 configuration register is returned. This function must guarantee that all PCI
501 read and write operations are serialized.
502
503 If Address > 0x0FFFFFFF, then ASSERT().
504 If Address is not aligned on a 16-bit boundary, then ASSERT().
505
506 @param Address Address that encodes the PCI Bus, Device, Function and
507 Register.
508 @param AndData The value to AND with the PCI configuration register.
509 @param OrData The value to OR with the result of the AND operation.
510
511 @return The value written back to the PCI configuration register.
512
513 **/
514 UINT16
515 EFIAPI
516 PciAndThenOr16 (
517 IN UINTN Address,
518 IN UINT16 AndData,
519 IN UINT16 OrData
520 )
521 {
522 return PciCf8AndThenOr16 (Address, AndData, OrData);
523 }
524
525 /**
526 Reads a bit field of a PCI configuration register.
527
528 Reads the bit field in a 16-bit PCI configuration register. The bit field is
529 specified by the StartBit and the EndBit. The value of the bit field is
530 returned.
531
532 If Address > 0x0FFFFFFF, then ASSERT().
533 If Address is not aligned on a 16-bit boundary, then ASSERT().
534 If StartBit is greater than 15, then ASSERT().
535 If EndBit is greater than 15, then ASSERT().
536 If EndBit is less than StartBit, then ASSERT().
537
538 @param Address PCI configuration register to read.
539 @param StartBit The ordinal of the least significant bit in the bit field.
540 Range 0..15.
541 @param EndBit The ordinal of the most significant bit in the bit field.
542 Range 0..15.
543
544 @return The value of the bit field read from the PCI configuration register.
545
546 **/
547 UINT16
548 EFIAPI
549 PciBitFieldRead16 (
550 IN UINTN Address,
551 IN UINTN StartBit,
552 IN UINTN EndBit
553 )
554 {
555 return PciCf8BitFieldRead16 (Address, StartBit, EndBit);
556 }
557
558 /**
559 Writes a bit field to a PCI configuration register.
560
561 Writes Value to the bit field of the PCI configuration register. The bit
562 field is specified by the StartBit and the EndBit. All other bits in the
563 destination PCI configuration register are preserved. The new value of the
564 16-bit register is returned.
565
566 If Address > 0x0FFFFFFF, then ASSERT().
567 If Address is not aligned on a 16-bit boundary, then ASSERT().
568 If StartBit is greater than 15, then ASSERT().
569 If EndBit is greater than 15, then ASSERT().
570 If EndBit is less than StartBit, then ASSERT().
571
572 @param Address PCI configuration register to write.
573 @param StartBit The ordinal of the least significant bit in the bit field.
574 Range 0..15.
575 @param EndBit The ordinal of the most significant bit in the bit field.
576 Range 0..15.
577 @param Value New value of the bit field.
578
579 @return The value written back to the PCI configuration register.
580
581 **/
582 UINT16
583 EFIAPI
584 PciBitFieldWrite16 (
585 IN UINTN Address,
586 IN UINTN StartBit,
587 IN UINTN EndBit,
588 IN UINT16 Value
589 )
590 {
591 return PciCf8BitFieldWrite16 (Address, StartBit, EndBit, Value);
592 }
593
594 /**
595 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
596 writes the result back to the bit field in the 16-bit port.
597
598 Reads the 16-bit PCI configuration register specified by Address, performs a
599 bitwise inclusive OR between the read result and the value specified by
600 OrData, and writes the result to the 16-bit PCI configuration register
601 specified by Address. The value written to the PCI configuration register is
602 returned. This function must guarantee that all PCI read and write operations
603 are serialized. Extra left bits in OrData are stripped.
604
605 If Address > 0x0FFFFFFF, then ASSERT().
606 If Address is not aligned on a 16-bit boundary, then ASSERT().
607 If StartBit is greater than 15, then ASSERT().
608 If EndBit is greater than 15, then ASSERT().
609 If EndBit is less than StartBit, then ASSERT().
610
611 @param Address PCI configuration register to write.
612 @param StartBit The ordinal of the least significant bit in the bit field.
613 Range 0..15.
614 @param EndBit The ordinal of the most significant bit in the bit field.
615 Range 0..15.
616 @param OrData The value to OR with the PCI configuration register.
617
618 @return The value written back to the PCI configuration register.
619
620 **/
621 UINT16
622 EFIAPI
623 PciBitFieldOr16 (
624 IN UINTN Address,
625 IN UINTN StartBit,
626 IN UINTN EndBit,
627 IN UINT16 OrData
628 )
629 {
630 return PciCf8BitFieldOr16 (Address, StartBit, EndBit, OrData);
631 }
632
633 /**
634 Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
635 AND, and writes the result back to the bit field in the 16-bit register.
636
637 Reads the 16-bit PCI configuration register specified by Address, performs a
638 bitwise AND between the read result and the value specified by AndData, and
639 writes the result to the 16-bit PCI configuration register specified by
640 Address. The value written to the PCI configuration register is returned.
641 This function must guarantee that all PCI read and write operations are
642 serialized. Extra left bits in AndData are stripped.
643
644 If Address > 0x0FFFFFFF, then ASSERT().
645 If Address is not aligned on a 16-bit boundary, then ASSERT().
646 If StartBit is greater than 15, then ASSERT().
647 If EndBit is greater than 15, then ASSERT().
648 If EndBit is less than StartBit, then ASSERT().
649
650 @param Address PCI configuration register to write.
651 @param StartBit The ordinal of the least significant bit in the bit field.
652 Range 0..15.
653 @param EndBit The ordinal of the most significant bit in the bit field.
654 Range 0..15.
655 @param AndData The value to AND with the PCI configuration register.
656
657 @return The value written back to the PCI configuration register.
658
659 **/
660 UINT16
661 EFIAPI
662 PciBitFieldAnd16 (
663 IN UINTN Address,
664 IN UINTN StartBit,
665 IN UINTN EndBit,
666 IN UINT16 AndData
667 )
668 {
669 return PciCf8BitFieldAnd16 (Address, StartBit, EndBit, AndData);
670 }
671
672 /**
673 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
674 bitwise inclusive OR, and writes the result back to the bit field in the
675 16-bit port.
676
677 Reads the 16-bit PCI configuration register specified by Address, performs a
678 bitwise AND followed by a bitwise inclusive OR between the read result and
679 the value specified by AndData, and writes the result to the 16-bit PCI
680 configuration register specified by Address. The value written to the PCI
681 configuration register is returned. This function must guarantee that all PCI
682 read and write operations are serialized. Extra left bits in both AndData and
683 OrData are stripped.
684
685 If Address > 0x0FFFFFFF, then ASSERT().
686 If Address is not aligned on a 16-bit boundary, then ASSERT().
687 If StartBit is greater than 15, then ASSERT().
688 If EndBit is greater than 15, then ASSERT().
689 If EndBit is less than StartBit, then ASSERT().
690
691 @param Address PCI configuration register to write.
692 @param StartBit The ordinal of the least significant bit in the bit field.
693 Range 0..15.
694 @param EndBit The ordinal of the most significant bit in the bit field.
695 Range 0..15.
696 @param AndData The value to AND with the PCI configuration register.
697 @param OrData The value to OR with the result of the AND operation.
698
699 @return The value written back to the PCI configuration register.
700
701 **/
702 UINT16
703 EFIAPI
704 PciBitFieldAndThenOr16 (
705 IN UINTN Address,
706 IN UINTN StartBit,
707 IN UINTN EndBit,
708 IN UINT16 AndData,
709 IN UINT16 OrData
710 )
711 {
712 return PciCf8BitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData);
713 }
714
715 /**
716 Reads a 32-bit PCI configuration register.
717
718 Reads and returns the 32-bit PCI configuration register specified by Address.
719 This function must guarantee that all PCI read and write operations are
720 serialized.
721
722 If Address > 0x0FFFFFFF, then ASSERT().
723 If Address is not aligned on a 32-bit boundary, then ASSERT().
724
725 @param Address Address that encodes the PCI Bus, Device, Function and
726 Register.
727
728 @return The read value from the PCI configuration register.
729
730 **/
731 UINT32
732 EFIAPI
733 PciRead32 (
734 IN UINTN Address
735 )
736 {
737 return PciCf8Read32 (Address);
738 }
739
740 /**
741 Writes a 32-bit PCI configuration register.
742
743 Writes the 32-bit PCI configuration register specified by Address with the
744 value specified by Value. Value is returned. This function must guarantee
745 that all PCI read and write operations are serialized.
746
747 If Address > 0x0FFFFFFF, then ASSERT().
748 If Address is not aligned on a 32-bit boundary, then ASSERT().
749
750 @param Address Address that encodes the PCI Bus, Device, Function and
751 Register.
752 @param Value The value to write.
753
754 @return The value written to the PCI configuration register.
755
756 **/
757 UINT32
758 EFIAPI
759 PciWrite32 (
760 IN UINTN Address,
761 IN UINT32 Value
762 )
763 {
764 return PciCf8Write32 (Address, Value);
765 }
766
767 /**
768 Performs a bitwise inclusive OR of a 32-bit PCI configuration register with
769 a 32-bit value.
770
771 Reads the 32-bit PCI configuration register specified by Address, performs a
772 bitwise inclusive OR between the read result and the value specified by
773 OrData, and writes the result to the 32-bit PCI configuration register
774 specified by Address. The value written to the PCI configuration register is
775 returned. This function must guarantee that all PCI read and write operations
776 are serialized.
777
778 If Address > 0x0FFFFFFF, then ASSERT().
779 If Address is not aligned on a 32-bit boundary, then ASSERT().
780
781 @param Address Address that encodes the PCI Bus, Device, Function and
782 Register.
783 @param OrData The value to OR with the PCI configuration register.
784
785 @return The value written back to the PCI configuration register.
786
787 **/
788 UINT32
789 EFIAPI
790 PciOr32 (
791 IN UINTN Address,
792 IN UINT32 OrData
793 )
794 {
795 return PciCf8Or32 (Address, OrData);
796 }
797
798 /**
799 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
800 value.
801
802 Reads the 32-bit PCI configuration register specified by Address, performs a
803 bitwise AND between the read result and the value specified by AndData, and
804 writes the result to the 32-bit PCI configuration register specified by
805 Address. The value written to the PCI configuration register is returned.
806 This function must guarantee that all PCI read and write operations are
807 serialized.
808
809 If Address > 0x0FFFFFFF, then ASSERT().
810 If Address is not aligned on a 32-bit boundary, then ASSERT().
811
812 @param Address Address that encodes the PCI Bus, Device, Function and
813 Register.
814 @param AndData The value to AND with the PCI configuration register.
815
816 @return The value written back to the PCI configuration register.
817
818 **/
819 UINT32
820 EFIAPI
821 PciAnd32 (
822 IN UINTN Address,
823 IN UINT32 AndData
824 )
825 {
826 return PciCf8And32 (Address, AndData);
827 }
828
829 /**
830 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
831 value, followed a bitwise inclusive OR with another 32-bit value.
832
833 Reads the 32-bit PCI configuration register specified by Address, performs a
834 bitwise AND between the read result and the value specified by AndData,
835 performs a bitwise inclusive OR between the result of the AND operation and
836 the value specified by OrData, and writes the result to the 32-bit PCI
837 configuration register specified by Address. The value written to the PCI
838 configuration register is returned. This function must guarantee that all PCI
839 read and write operations are serialized.
840
841 If Address > 0x0FFFFFFF, then ASSERT().
842 If Address is not aligned on a 32-bit boundary, then ASSERT().
843
844 @param Address Address that encodes the PCI Bus, Device, Function and
845 Register.
846 @param AndData The value to AND with the PCI configuration register.
847 @param OrData The value to OR with the result of the AND operation.
848
849 @return The value written back to the PCI configuration register.
850
851 **/
852 UINT32
853 EFIAPI
854 PciAndThenOr32 (
855 IN UINTN Address,
856 IN UINT32 AndData,
857 IN UINT32 OrData
858 )
859 {
860 return PciCf8AndThenOr32 (Address, AndData, OrData);
861 }
862
863 /**
864 Reads a bit field of a PCI configuration register.
865
866 Reads the bit field in a 32-bit PCI configuration register. The bit field is
867 specified by the StartBit and the EndBit. The value of the bit field is
868 returned.
869
870 If Address > 0x0FFFFFFF, then ASSERT().
871 If Address is not aligned on a 32-bit boundary, then ASSERT().
872 If StartBit is greater than 31, then ASSERT().
873 If EndBit is greater than 31, then ASSERT().
874 If EndBit is less than StartBit, then ASSERT().
875
876 @param Address PCI configuration register to read.
877 @param StartBit The ordinal of the least significant bit in the bit field.
878 Range 0..31.
879 @param EndBit The ordinal of the most significant bit in the bit field.
880 Range 0..31.
881
882 @return The value of the bit field read from the PCI configuration register.
883
884 **/
885 UINT32
886 EFIAPI
887 PciBitFieldRead32 (
888 IN UINTN Address,
889 IN UINTN StartBit,
890 IN UINTN EndBit
891 )
892 {
893 return PciCf8BitFieldRead32 (Address, StartBit, EndBit);
894 }
895
896 /**
897 Writes a bit field to a PCI configuration register.
898
899 Writes Value to the bit field of the PCI configuration register. The bit
900 field is specified by the StartBit and the EndBit. All other bits in the
901 destination PCI configuration register are preserved. The new value of the
902 32-bit register is returned.
903
904 If Address > 0x0FFFFFFF, then ASSERT().
905 If Address is not aligned on a 32-bit boundary, 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 Value New value of the bit field.
916
917 @return The value written back to the PCI configuration register.
918
919 **/
920 UINT32
921 EFIAPI
922 PciBitFieldWrite32 (
923 IN UINTN Address,
924 IN UINTN StartBit,
925 IN UINTN EndBit,
926 IN UINT32 Value
927 )
928 {
929 return PciCf8BitFieldWrite32 (Address, StartBit, EndBit, Value);
930 }
931
932 /**
933 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
934 writes the result back to the bit field in the 32-bit port.
935
936 Reads the 32-bit PCI configuration register specified by Address, performs a
937 bitwise inclusive OR between the read result and the value specified by
938 OrData, and writes the result to the 32-bit PCI configuration register
939 specified by Address. The value written to the PCI configuration register is
940 returned. This function must guarantee that all PCI read and write operations
941 are serialized. Extra left bits in OrData are stripped.
942
943 If Address > 0x0FFFFFFF, then ASSERT().
944 If Address is not aligned on a 32-bit boundary, then ASSERT().
945 If StartBit is greater than 31, then ASSERT().
946 If EndBit is greater than 31, then ASSERT().
947 If EndBit is less than StartBit, then ASSERT().
948
949 @param Address PCI configuration register to write.
950 @param StartBit The ordinal of the least significant bit in the bit field.
951 Range 0..31.
952 @param EndBit The ordinal of the most significant bit in the bit field.
953 Range 0..31.
954 @param OrData The value to OR with the PCI configuration register.
955
956 @return The value written back to the PCI configuration register.
957
958 **/
959 UINT32
960 EFIAPI
961 PciBitFieldOr32 (
962 IN UINTN Address,
963 IN UINTN StartBit,
964 IN UINTN EndBit,
965 IN UINT32 OrData
966 )
967 {
968 return PciCf8BitFieldOr32 (Address, StartBit, EndBit, OrData);
969 }
970
971 /**
972 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
973 AND, and writes the result back to the bit field in the 32-bit register.
974
975 Reads the 32-bit PCI configuration register specified by Address, performs a
976 bitwise AND between the read result and the value specified by AndData, and
977 writes the result to the 32-bit PCI configuration register specified by
978 Address. The value written to the PCI configuration register is returned.
979 This function must guarantee that all PCI read and write operations are
980 serialized. Extra left bits in AndData are stripped.
981
982 If Address > 0x0FFFFFFF, then ASSERT().
983 If Address is not aligned on a 32-bit boundary, 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
995 @return The value written back to the PCI configuration register.
996
997 **/
998 UINT32
999 EFIAPI
1000 PciBitFieldAnd32 (
1001 IN UINTN Address,
1002 IN UINTN StartBit,
1003 IN UINTN EndBit,
1004 IN UINT32 AndData
1005 )
1006 {
1007 return PciCf8BitFieldAnd32 (Address, StartBit, EndBit, AndData);
1008 }
1009
1010 /**
1011 Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
1012 bitwise inclusive OR, and writes the result back to the bit field in the
1013 32-bit port.
1014
1015 Reads the 32-bit PCI configuration register specified by Address, performs a
1016 bitwise AND followed by a bitwise inclusive OR between the read result and
1017 the value specified by AndData, and writes the result to the 32-bit PCI
1018 configuration register specified by Address. The value written to the PCI
1019 configuration register is returned. This function must guarantee that all PCI
1020 read and write operations are serialized. Extra left bits in both AndData and
1021 OrData are stripped.
1022
1023 If Address > 0x0FFFFFFF, then ASSERT().
1024 If Address is not aligned on a 32-bit boundary, then ASSERT().
1025 If StartBit is greater than 31, then ASSERT().
1026 If EndBit is greater than 31, then ASSERT().
1027 If EndBit is less than StartBit, then ASSERT().
1028
1029 @param Address PCI configuration register to write.
1030 @param StartBit The ordinal of the least significant bit in the bit field.
1031 Range 0..31.
1032 @param EndBit The ordinal of the most significant bit in the bit field.
1033 Range 0..31.
1034 @param AndData The value to AND with the PCI configuration register.
1035 @param OrData The value to OR with the result of the AND operation.
1036
1037 @return The value written back to the PCI configuration register.
1038
1039 **/
1040 UINT32
1041 EFIAPI
1042 PciBitFieldAndThenOr32 (
1043 IN UINTN Address,
1044 IN UINTN StartBit,
1045 IN UINTN EndBit,
1046 IN UINT32 AndData,
1047 IN UINT32 OrData
1048 )
1049 {
1050 return PciCf8BitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData);
1051 }
1052
1053 /**
1054 Reads a range of PCI configuration registers into a caller supplied buffer.
1055
1056 Reads the range of PCI configuration registers specified by StartAddress and
1057 Size into the buffer specified by Buffer. This function only allows the PCI
1058 configuration registers from a single PCI function to be read. Size is
1059 returned. When possible 32-bit PCI configuration read cycles are used to read
1060 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
1061 and 16-bit PCI configuration read cycles may be used at the beginning and the
1062 end of the range.
1063
1064 If StartAddress > 0x0FFFFFFF, then ASSERT().
1065 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1066 If Size > 0 and Buffer is NULL, then ASSERT().
1067
1068 @param StartAddress Starting address that encodes the PCI Bus, Device,
1069 Function and Register.
1070 @param Size Size in bytes of the transfer.
1071 @param Buffer Pointer to a buffer receiving the data read.
1072
1073 @return Size
1074
1075 **/
1076 UINTN
1077 EFIAPI
1078 PciReadBuffer (
1079 IN UINTN StartAddress,
1080 IN UINTN Size,
1081 OUT VOID *Buffer
1082 )
1083 {
1084 return PciCf8ReadBuffer (StartAddress, Size, Buffer);
1085 }
1086
1087 /**
1088 Copies the data in a caller supplied buffer to a specified range of PCI
1089 configuration space.
1090
1091 Writes the range of PCI configuration registers specified by StartAddress and
1092 Size from the buffer specified by Buffer. This function only allows the PCI
1093 configuration registers from a single PCI function to be written. Size is
1094 returned. When possible 32-bit PCI configuration write cycles are used to
1095 write from StartAdress to StartAddress + Size. Due to alignment restrictions,
1096 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
1097 and the end of the range.
1098
1099 If StartAddress > 0x0FFFFFFF, then ASSERT().
1100 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
1101 If Size > 0 and Buffer is NULL, then ASSERT().
1102
1103 @param StartAddress Starting address that encodes the PCI Bus, Device,
1104 Function and Register.
1105 @param Size Size in bytes of the transfer.
1106 @param Buffer Pointer to a buffer containing the data to write.
1107
1108 @return Size
1109
1110 **/
1111 UINTN
1112 EFIAPI
1113 PciWriteBuffer (
1114 IN UINTN StartAddress,
1115 IN UINTN Size,
1116 IN VOID *Buffer
1117 )
1118 {
1119 return PciCf8WriteBuffer (StartAddress, Size, Buffer);
1120 }