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