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