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