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