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