]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Library/PciSegmentLib.h
MdePkg/PciSegmentLib: Optimize PCI_SEGMENT_LIB_ADDRESS()
[mirror_edk2.git] / MdePkg / Include / Library / PciSegmentLib.h
... / ...
CommitLineData
1/** @file\r
2 Provides services to access PCI Configuration Space on a platform with multiple PCI segments.\r
3 \r
4 The PCI Segment Library function provide services to read, write, and modify the PCI configuration\r
5 registers on PCI root bridges on any supported PCI segment. These library services take a single \r
6 address parameter that encodes the PCI Segment, PCI Bus, PCI Device, PCI Function, and PCI Register. \r
7 The layout of this address parameter is as follows:\r
8 \r
9 PCI Register: Bits 0..11\r
10 PCI Function Bits 12..14\r
11 PCI Device Bits 15..19\r
12 PCI Bus Bits 20..27\r
13 Reserved Bits 28..31. Must be 0.\r
14 PCI Segment Bits 32..47\r
15 Reserved Bits 48..63. Must be 0.\r
16 \r
17 | Reserved (MBZ) | Segment | Reserved (MBZ) | Bus | Device | Function | Register |\r
18 63 48 47 32 31 28 27 20 19 15 14 12 11 0\r
19\r
20 These functions perform PCI configuration cycles using the default PCI configuration access \r
21 method. This may use I/O ports 0xCF8 and 0xCFC to perform PCI configuration accesses, or it \r
22 may use MMIO registers relative to the PcdPciExpressBaseAddress, or it may use some alternate \r
23 access method. Modules will typically use the PCI Segment Library for its PCI configuration \r
24 accesses when PCI Segments other than Segment #0 must be accessed. \r
25\r
26Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
27This program and the accompanying materials\r
28are licensed and made available under the terms and conditions of the BSD License\r
29which accompanies this distribution. The full text of the license may be found at\r
30http://opensource.org/licenses/bsd-license.php\r
31\r
32THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
33WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
34\r
35**/\r
36\r
37#ifndef __PCI_SEGMENT_LIB__\r
38#define __PCI_SEGMENT_LIB__\r
39\r
40\r
41/**\r
42 Macro that converts PCI Segment, PCI Bus, PCI Device, PCI Function,\r
43 and PCI Register to an address that can be passed to the PCI Segment Library functions.\r
44\r
45 Computes an address that is compatible with the PCI Segment Library functions.\r
46 The unused upper bits of Segment, Bus, Device, Function,\r
47 and Register are stripped prior to the generation of the address.\r
48\r
49 @param Segment PCI Segment number. Range 0..65535.\r
50 @param Bus PCI Bus number. Range 0..255.\r
51 @param Device PCI Device number. Range 0..31.\r
52 @param Function PCI Function number. Range 0..7.\r
53 @param Register PCI Register number. Range 0..255 for PCI. Range 0..4095 for PCI Express.\r
54\r
55 @return The address that is compatible with the PCI Segment Library functions.\r
56\r
57**/\r
58#define PCI_SEGMENT_LIB_ADDRESS(Segment,Bus,Device,Function,Register) \\r
59 ((Segment != 0) ? \\r
60 ( ((Register) & 0xfff) | \\r
61 (((Function) & 0x07) << 12) | \\r
62 (((Device) & 0x1f) << 15) | \\r
63 (((Bus) & 0xff) << 20) | \\r
64 (LShiftU64 ((Segment) & 0xffff, 32)) \\r
65 ) : \\r
66 ( ((Register) & 0xfff) | \\r
67 (((Function) & 0x07) << 12) | \\r
68 (((Device) & 0x1f) << 15) | \\r
69 (((Bus) & 0xff) << 20) \\r
70 ) \\r
71 )\r
72\r
73/**\r
74 Register a PCI device so PCI configuration registers may be accessed after \r
75 SetVirtualAddressMap().\r
76 \r
77 If any reserved bits in Address are set, then ASSERT().\r
78\r
79 @param Address Address that encodes the PCI Bus, Device, Function and\r
80 Register.\r
81 \r
82 @retval RETURN_SUCCESS The PCI device was registered for runtime access.\r
83 @retval RETURN_UNSUPPORTED An attempt was made to call this function \r
84 after ExitBootServices().\r
85 @retval RETURN_UNSUPPORTED The resources required to access the PCI device\r
86 at runtime could not be mapped.\r
87 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to\r
88 complete the registration.\r
89\r
90**/\r
91RETURN_STATUS\r
92EFIAPI\r
93PciSegmentRegisterForRuntimeAccess (\r
94 IN UINTN Address\r
95 );\r
96\r
97/**\r
98 Reads an 8-bit PCI configuration register.\r
99\r
100 Reads and returns the 8-bit PCI configuration register specified by Address.\r
101 This function must guarantee that all PCI read and write operations are serialized.\r
102 \r
103 If any reserved bits in Address are set, then ASSERT().\r
104 \r
105 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
106\r
107 @return The 8-bit PCI configuration register specified by Address.\r
108\r
109**/\r
110UINT8\r
111EFIAPI\r
112PciSegmentRead8 (\r
113 IN UINT64 Address\r
114 );\r
115\r
116/**\r
117 Writes an 8-bit PCI configuration register.\r
118\r
119 Writes the 8-bit PCI configuration register specified by Address with the value specified by Value.\r
120 Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r
121 \r
122 If any reserved bits in Address are set, then ASSERT().\r
123\r
124 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
125 @param Value The value to write.\r
126\r
127 @return The value written to the PCI configuration register.\r
128\r
129**/\r
130UINT8\r
131EFIAPI\r
132PciSegmentWrite8 (\r
133 IN UINT64 Address,\r
134 IN UINT8 Value\r
135 );\r
136\r
137/**\r
138 Performs a bitwise OR of an 8-bit PCI configuration register with an 8-bit value.\r
139\r
140 Reads the 8-bit PCI configuration register specified by Address,\r
141 performs a bitwise OR between the read result and the value specified by OrData,\r
142 and writes the result to the 8-bit PCI configuration register specified by Address.\r
143 The value written to the PCI configuration register is returned.\r
144 This function must guarantee that all PCI read and write operations are serialized.\r
145 \r
146 If any reserved bits in Address are set, then ASSERT().\r
147\r
148 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
149 @param OrData The value to OR with the PCI configuration register.\r
150\r
151 @return The value written to the PCI configuration register.\r
152\r
153**/\r
154UINT8\r
155EFIAPI\r
156PciSegmentOr8 (\r
157 IN UINT64 Address,\r
158 IN UINT8 OrData\r
159 );\r
160\r
161/**\r
162 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value.\r
163\r
164 Reads the 8-bit PCI configuration register specified by Address,\r
165 performs a bitwise AND between the read result and the value specified by AndData,\r
166 and writes the result to the 8-bit PCI configuration register specified by Address.\r
167 The value written to the PCI configuration register is returned.\r
168 This function must guarantee that all PCI read and write operations are serialized.\r
169 If any reserved bits in Address are set, then ASSERT().\r
170\r
171 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
172 @param AndData The value to AND with the PCI configuration register.\r
173\r
174 @return The value written to the PCI configuration register.\r
175\r
176**/\r
177UINT8\r
178EFIAPI\r
179PciSegmentAnd8 (\r
180 IN UINT64 Address,\r
181 IN UINT8 AndData\r
182 );\r
183\r
184/**\r
185 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value,\r
186 followed a bitwise OR with another 8-bit value.\r
187 \r
188 Reads the 8-bit PCI configuration register specified by Address,\r
189 performs a bitwise AND between the read result and the value specified by AndData,\r
190 performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
191 and writes the result to the 8-bit PCI configuration register specified by Address.\r
192 The value written to the PCI configuration register is returned.\r
193 This function must guarantee that all PCI read and write operations are serialized.\r
194 \r
195 If any reserved bits in Address are set, then ASSERT().\r
196\r
197 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
198 @param AndData The value to AND with the PCI configuration register.\r
199 @param OrData The value to OR with the PCI configuration register.\r
200\r
201 @return The value written to the PCI configuration register.\r
202\r
203**/\r
204UINT8\r
205EFIAPI\r
206PciSegmentAndThenOr8 (\r
207 IN UINT64 Address,\r
208 IN UINT8 AndData,\r
209 IN UINT8 OrData\r
210 );\r
211\r
212/**\r
213 Reads a bit field of a PCI configuration register.\r
214\r
215 Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
216 specified by the StartBit and the EndBit. The value of the bit field is\r
217 returned.\r
218\r
219 If any reserved bits in Address are set, then ASSERT().\r
220 If StartBit is greater than 7, then ASSERT().\r
221 If EndBit is greater than 7, then ASSERT().\r
222 If EndBit is less than StartBit, then ASSERT().\r
223\r
224 @param Address PCI configuration register to read.\r
225 @param StartBit The ordinal of the least significant bit in the bit field.\r
226 Range 0..7.\r
227 @param EndBit The ordinal of the most significant bit in the bit field.\r
228 Range 0..7.\r
229\r
230 @return The value of the bit field read from the PCI configuration register.\r
231\r
232**/\r
233UINT8\r
234EFIAPI\r
235PciSegmentBitFieldRead8 (\r
236 IN UINT64 Address,\r
237 IN UINTN StartBit,\r
238 IN UINTN EndBit\r
239 );\r
240\r
241/**\r
242 Writes a bit field to a PCI configuration register.\r
243\r
244 Writes Value to the bit field of the PCI configuration register. The bit\r
245 field is specified by the StartBit and the EndBit. All other bits in the\r
246 destination PCI configuration register are preserved. The new value of the\r
247 8-bit register is returned.\r
248\r
249 If any reserved bits in Address are set, then ASSERT().\r
250 If StartBit is greater than 7, then ASSERT().\r
251 If EndBit is greater than 7, then ASSERT().\r
252 If EndBit is less than StartBit, then ASSERT().\r
253 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
254\r
255 @param Address PCI configuration register to write.\r
256 @param StartBit The ordinal of the least significant bit in the bit field.\r
257 Range 0..7.\r
258 @param EndBit The ordinal of the most significant bit in the bit field.\r
259 Range 0..7.\r
260 @param Value New value of the bit field.\r
261\r
262 @return The value written back to the PCI configuration register.\r
263\r
264**/\r
265UINT8\r
266EFIAPI\r
267PciSegmentBitFieldWrite8 (\r
268 IN UINT64 Address,\r
269 IN UINTN StartBit,\r
270 IN UINTN EndBit,\r
271 IN UINT8 Value\r
272 );\r
273\r
274/**\r
275 Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
276 writes the result back to the bit field in the 8-bit port.\r
277\r
278 Reads the 8-bit PCI configuration register specified by Address, performs a\r
279 bitwise OR between the read result and the value specified by\r
280 OrData, and writes the result to the 8-bit PCI configuration register\r
281 specified by Address. The value written to the PCI configuration register is\r
282 returned. This function must guarantee that all PCI read and write operations\r
283 are serialized. Extra left bits in OrData are stripped.\r
284\r
285 If any reserved bits in Address are set, then ASSERT().\r
286 If StartBit is greater than 7, then ASSERT().\r
287 If EndBit is greater than 7, then ASSERT().\r
288 If EndBit is less than StartBit, then ASSERT().\r
289 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
290\r
291 @param Address PCI configuration register to write.\r
292 @param StartBit The ordinal of the least significant bit in the bit field.\r
293 Range 0..7.\r
294 @param EndBit The ordinal of the most significant bit in the bit field.\r
295 Range 0..7.\r
296 @param OrData The value to OR with the PCI configuration register.\r
297\r
298 @return The value written back to the PCI configuration register.\r
299\r
300**/\r
301UINT8\r
302EFIAPI\r
303PciSegmentBitFieldOr8 (\r
304 IN UINT64 Address,\r
305 IN UINTN StartBit,\r
306 IN UINTN EndBit,\r
307 IN UINT8 OrData\r
308 );\r
309\r
310/**\r
311 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
312 AND, and writes the result back to the bit field in the 8-bit register.\r
313\r
314 Reads the 8-bit PCI configuration register specified by Address, performs a\r
315 bitwise AND between the read result and the value specified by AndData, and\r
316 writes the result to the 8-bit PCI configuration register specified by\r
317 Address. The value written to the PCI configuration register is returned.\r
318 This function must guarantee that all PCI read and write operations are\r
319 serialized. Extra left bits in AndData are stripped.\r
320\r
321 If any reserved bits in Address are set, then ASSERT().\r
322 If StartBit is greater than 7, then ASSERT().\r
323 If EndBit is greater than 7, then ASSERT().\r
324 If EndBit is less than StartBit, then ASSERT().\r
325 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
326\r
327 @param Address PCI configuration register to write.\r
328 @param StartBit The ordinal of the least significant bit in the bit field.\r
329 Range 0..7.\r
330 @param EndBit The ordinal of the most significant bit in the bit field.\r
331 Range 0..7.\r
332 @param AndData The value to AND with the PCI configuration register.\r
333\r
334 @return The value written back to the PCI configuration register.\r
335\r
336**/\r
337UINT8\r
338EFIAPI\r
339PciSegmentBitFieldAnd8 (\r
340 IN UINT64 Address,\r
341 IN UINTN StartBit,\r
342 IN UINTN EndBit,\r
343 IN UINT8 AndData\r
344 );\r
345\r
346/**\r
347 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
348 bitwise OR, and writes the result back to the bit field in the\r
349 8-bit port.\r
350\r
351 Reads the 8-bit PCI configuration register specified by Address, performs a\r
352 bitwise AND followed by a bitwise OR between the read result and\r
353 the value specified by AndData, and writes the result to the 8-bit PCI\r
354 configuration register specified by Address. The value written to the PCI\r
355 configuration register is returned. This function must guarantee that all PCI\r
356 read and write operations are serialized. Extra left bits in both AndData and\r
357 OrData are stripped.\r
358\r
359 If any reserved bits in Address are set, then ASSERT().\r
360 If StartBit is greater than 7, then ASSERT().\r
361 If EndBit is greater than 7, then ASSERT().\r
362 If EndBit is less than StartBit, then ASSERT().\r
363 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
364 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
365\r
366 @param Address PCI configuration register to write.\r
367 @param StartBit The ordinal of the least significant bit in the bit field.\r
368 Range 0..7.\r
369 @param EndBit The ordinal of the most significant bit in the bit field.\r
370 Range 0..7.\r
371 @param AndData The value to AND with the PCI configuration register.\r
372 @param OrData The value to OR with the result of the AND operation.\r
373\r
374 @return The value written back to the PCI configuration register.\r
375\r
376**/\r
377UINT8\r
378EFIAPI\r
379PciSegmentBitFieldAndThenOr8 (\r
380 IN UINT64 Address,\r
381 IN UINTN StartBit,\r
382 IN UINTN EndBit,\r
383 IN UINT8 AndData,\r
384 IN UINT8 OrData\r
385 );\r
386\r
387/**\r
388 Reads a 16-bit PCI configuration register.\r
389\r
390 Reads and returns the 16-bit PCI configuration register specified by Address.\r
391 This function must guarantee that all PCI read and write operations are serialized.\r
392 \r
393 If any reserved bits in Address are set, then ASSERT().\r
394 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
395 \r
396 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
397\r
398 @return The 16-bit PCI configuration register specified by Address.\r
399\r
400**/\r
401UINT16\r
402EFIAPI\r
403PciSegmentRead16 (\r
404 IN UINT64 Address\r
405 );\r
406\r
407/**\r
408 Writes a 16-bit PCI configuration register.\r
409\r
410 Writes the 16-bit PCI configuration register specified by Address with the value specified by Value.\r
411 Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r
412 \r
413 If any reserved bits in Address are set, then ASSERT().\r
414 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
415\r
416 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
417 @param Value The value to write.\r
418\r
419 @return The parameter of Value.\r
420\r
421**/\r
422UINT16\r
423EFIAPI\r
424PciSegmentWrite16 (\r
425 IN UINT64 Address,\r
426 IN UINT16 Value\r
427 );\r
428\r
429/**\r
430 Performs a bitwise OR of a 16-bit PCI configuration register with\r
431 a 16-bit value.\r
432\r
433 Reads the 16-bit PCI configuration register specified by Address, performs a\r
434 bitwise OR between the read result and the value specified by\r
435 OrData, and writes the result to the 16-bit PCI configuration register\r
436 specified by Address. The value written to the PCI configuration register is\r
437 returned. This function must guarantee that all PCI read and write operations\r
438 are serialized.\r
439\r
440 If any reserved bits in Address are set, then ASSERT().\r
441 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
442\r
443 @param Address Address that encodes the PCI Segment, Bus, Device, Function and\r
444 Register.\r
445 @param OrData The value to OR with the PCI configuration register.\r
446\r
447 @return The value written back to the PCI configuration register.\r
448\r
449**/\r
450UINT16\r
451EFIAPI\r
452PciSegmentOr16 (\r
453 IN UINT64 Address,\r
454 IN UINT16 OrData\r
455 );\r
456\r
457/**\r
458 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value.\r
459\r
460 Reads the 16-bit PCI configuration register specified by Address,\r
461 performs a bitwise AND between the read result and the value specified by AndData,\r
462 and writes the result to the 16-bit PCI configuration register specified by Address.\r
463 The value written to the PCI configuration register is returned.\r
464 This function must guarantee that all PCI read and write operations are serialized.\r
465 \r
466 If any reserved bits in Address are set, then ASSERT().\r
467 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
468 \r
469 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
470 @param AndData The value to AND with the PCI configuration register.\r
471\r
472 @return The value written to the PCI configuration register.\r
473\r
474**/\r
475UINT16\r
476EFIAPI\r
477PciSegmentAnd16 (\r
478 IN UINT64 Address,\r
479 IN UINT16 AndData\r
480 );\r
481\r
482/**\r
483 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value,\r
484 followed a bitwise OR with another 16-bit value.\r
485 \r
486 Reads the 16-bit PCI configuration register specified by Address,\r
487 performs a bitwise AND between the read result and the value specified by AndData,\r
488 performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
489 and writes the result to the 16-bit PCI configuration register specified by Address.\r
490 The value written to the PCI configuration register is returned.\r
491 This function must guarantee that all PCI read and write operations are serialized.\r
492 \r
493 If any reserved bits in Address are set, then ASSERT().\r
494 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
495\r
496 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
497 @param AndData The value to AND with the PCI configuration register.\r
498 @param OrData The value to OR with the PCI configuration register.\r
499\r
500 @return The value written to the PCI configuration register.\r
501\r
502**/\r
503UINT16\r
504EFIAPI\r
505PciSegmentAndThenOr16 (\r
506 IN UINT64 Address,\r
507 IN UINT16 AndData,\r
508 IN UINT16 OrData\r
509 );\r
510\r
511/**\r
512 Reads a bit field of a PCI configuration register.\r
513\r
514 Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
515 specified by the StartBit and the EndBit. The value of the bit field is\r
516 returned.\r
517\r
518 If any reserved bits in Address are set, then ASSERT().\r
519 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
520 If StartBit is greater than 15, then ASSERT().\r
521 If EndBit is greater than 15, then ASSERT().\r
522 If EndBit is less than StartBit, then ASSERT().\r
523\r
524 @param Address PCI configuration register to read.\r
525 @param StartBit The ordinal of the least significant bit in the bit field.\r
526 Range 0..15.\r
527 @param EndBit The ordinal of the most significant bit in the bit field.\r
528 Range 0..15.\r
529\r
530 @return The value of the bit field read from the PCI configuration register.\r
531\r
532**/\r
533UINT16\r
534EFIAPI\r
535PciSegmentBitFieldRead16 (\r
536 IN UINT64 Address,\r
537 IN UINTN StartBit,\r
538 IN UINTN EndBit\r
539 );\r
540\r
541/**\r
542 Writes a bit field to a PCI configuration register.\r
543\r
544 Writes Value to the bit field of the PCI configuration register. The bit\r
545 field is specified by the StartBit and the EndBit. All other bits in the\r
546 destination PCI configuration register are preserved. The new value of the\r
547 16-bit register is returned.\r
548\r
549 If any reserved bits in Address are set, then ASSERT().\r
550 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
551 If StartBit is greater than 15, then ASSERT().\r
552 If EndBit is greater than 15, then ASSERT().\r
553 If EndBit is less than StartBit, then ASSERT().\r
554 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
555\r
556 @param Address PCI configuration register to write.\r
557 @param StartBit The ordinal of the least significant bit in the bit field.\r
558 Range 0..15.\r
559 @param EndBit The ordinal of the most significant bit in the bit field.\r
560 Range 0..15.\r
561 @param Value New value of the bit field.\r
562\r
563 @return The value written back to the PCI configuration register.\r
564\r
565**/\r
566UINT16\r
567EFIAPI\r
568PciSegmentBitFieldWrite16 (\r
569 IN UINT64 Address,\r
570 IN UINTN StartBit,\r
571 IN UINTN EndBit,\r
572 IN UINT16 Value\r
573 );\r
574\r
575/**\r
576 Reads the 16-bit PCI configuration register specified by Address,\r
577 performs a bitwise OR between the read result and the value specified by OrData,\r
578 and writes the result to the 16-bit PCI configuration register specified by Address. \r
579\r
580 If any reserved bits in Address are set, then ASSERT().\r
581 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
582 If StartBit is greater than 15, then ASSERT().\r
583 If EndBit is greater than 15, then ASSERT().\r
584 If EndBit is less than StartBit, then ASSERT().\r
585 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
586\r
587 @param Address PCI configuration register to write.\r
588 @param StartBit The ordinal of the least significant bit in the bit field.\r
589 Range 0..15.\r
590 @param EndBit The ordinal of the most significant bit in the bit field.\r
591 Range 0..15.\r
592 @param OrData The value to OR with the PCI configuration register.\r
593\r
594 @return The value written back to the PCI configuration register.\r
595\r
596**/\r
597UINT16\r
598EFIAPI\r
599PciSegmentBitFieldOr16 (\r
600 IN UINT64 Address,\r
601 IN UINTN StartBit,\r
602 IN UINTN EndBit,\r
603 IN UINT16 OrData\r
604 );\r
605\r
606/**\r
607 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR,\r
608 and writes the result back to the bit field in the 16-bit port.\r
609\r
610 Reads the 16-bit PCI configuration register specified by Address,\r
611 performs a bitwise OR between the read result and the value specified by OrData,\r
612 and writes the result to the 16-bit PCI configuration register specified by Address.\r
613 The value written to the PCI configuration register is returned.\r
614 This function must guarantee that all PCI read and write operations are serialized.\r
615 Extra left bits in OrData are stripped.\r
616 \r
617 If any reserved bits in Address are set, then ASSERT().\r
618 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
619 If StartBit is greater than 7, then ASSERT().\r
620 If EndBit is greater than 7, then ASSERT().\r
621 If EndBit is less than StartBit, then ASSERT().\r
622 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
623\r
624 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
625 @param StartBit The ordinal of the least significant bit in the bit field.\r
626 The ordinal of the least significant bit in a byte is bit 0.\r
627 @param EndBit The ordinal of the most significant bit in the bit field.\r
628 The ordinal of the most significant bit in a byte is bit 7.\r
629 @param AndData The value to AND with the read value from the PCI configuration register.\r
630\r
631 @return The value written to the PCI configuration register.\r
632\r
633**/\r
634UINT16\r
635EFIAPI\r
636PciSegmentBitFieldAnd16 (\r
637 IN UINT64 Address,\r
638 IN UINTN StartBit,\r
639 IN UINTN EndBit,\r
640 IN UINT16 AndData\r
641 );\r
642\r
643/**\r
644 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
645 bitwise OR, and writes the result back to the bit field in the\r
646 16-bit port.\r
647\r
648 Reads the 16-bit PCI configuration register specified by Address, performs a\r
649 bitwise AND followed by a bitwise OR between the read result and\r
650 the value specified by AndData, and writes the result to the 16-bit PCI\r
651 configuration register specified by Address. The value written to the PCI\r
652 configuration register is returned. This function must guarantee that all PCI\r
653 read and write operations are serialized. Extra left bits in both AndData and\r
654 OrData are stripped.\r
655\r
656 If any reserved bits in Address are set, then ASSERT().\r
657 If StartBit is greater than 15, then ASSERT().\r
658 If EndBit is greater than 15, then ASSERT().\r
659 If EndBit is less than StartBit, then ASSERT().\r
660 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
661 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
662\r
663 @param Address PCI configuration register to write.\r
664 @param StartBit The ordinal of the least significant bit in the bit field.\r
665 Range 0..15.\r
666 @param EndBit The ordinal of the most significant bit in the bit field.\r
667 Range 0..15.\r
668 @param AndData The value to AND with the PCI configuration register.\r
669 @param OrData The value to OR with the result of the AND operation.\r
670\r
671 @return The value written back to the PCI configuration register.\r
672\r
673**/\r
674UINT16\r
675EFIAPI\r
676PciSegmentBitFieldAndThenOr16 (\r
677 IN UINT64 Address,\r
678 IN UINTN StartBit,\r
679 IN UINTN EndBit,\r
680 IN UINT16 AndData,\r
681 IN UINT16 OrData\r
682 );\r
683\r
684/**\r
685 Reads a 32-bit PCI configuration register.\r
686\r
687 Reads and returns the 32-bit PCI configuration register specified by Address.\r
688 This function must guarantee that all PCI read and write operations are serialized.\r
689 \r
690 If any reserved bits in Address are set, then ASSERT().\r
691 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
692\r
693 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
694\r
695 @return The 32-bit PCI configuration register specified by Address.\r
696\r
697**/\r
698UINT32\r
699EFIAPI\r
700PciSegmentRead32 (\r
701 IN UINT64 Address\r
702 );\r
703\r
704/**\r
705 Writes a 32-bit PCI configuration register.\r
706\r
707 Writes the 32-bit PCI configuration register specified by Address with the value specified by Value.\r
708 Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r
709 \r
710 If any reserved bits in Address are set, then ASSERT().\r
711 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
712\r
713 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
714 @param Value The value to write.\r
715\r
716 @return The parameter of Value.\r
717\r
718**/\r
719UINT32\r
720EFIAPI\r
721PciSegmentWrite32 (\r
722 IN UINT64 Address,\r
723 IN UINT32 Value\r
724 );\r
725\r
726/**\r
727 Performs a bitwise OR of a 32-bit PCI configuration register with a 32-bit value.\r
728\r
729 Reads the 32-bit PCI configuration register specified by Address,\r
730 performs a bitwise OR between the read result and the value specified by OrData,\r
731 and writes the result to the 32-bit PCI configuration register specified by Address.\r
732 The value written to the PCI configuration register is returned.\r
733 This function must guarantee that all PCI read and write operations are serialized.\r
734 \r
735 If any reserved bits in Address are set, then ASSERT().\r
736 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
737\r
738 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
739 @param OrData The value to OR with the PCI configuration register.\r
740\r
741 @return The value written to the PCI configuration register.\r
742\r
743**/\r
744UINT32\r
745EFIAPI\r
746PciSegmentOr32 (\r
747 IN UINT64 Address,\r
748 IN UINT32 OrData\r
749 );\r
750\r
751/**\r
752 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value.\r
753\r
754 Reads the 32-bit PCI configuration register specified by Address,\r
755 performs a bitwise AND between the read result and the value specified by AndData,\r
756 and writes the result to the 32-bit PCI configuration register specified by Address.\r
757 The value written to the PCI configuration register is returned.\r
758 This function must guarantee that all PCI read and write operations are serialized.\r
759 \r
760 If any reserved bits in Address are set, then ASSERT().\r
761 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
762\r
763 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
764 @param AndData The value to AND with the PCI configuration register.\r
765\r
766 @return The value written to the PCI configuration register.\r
767\r
768**/\r
769UINT32\r
770EFIAPI\r
771PciSegmentAnd32 (\r
772 IN UINT64 Address,\r
773 IN UINT32 AndData\r
774 );\r
775\r
776/**\r
777 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value,\r
778 followed a bitwise OR with another 32-bit value.\r
779 \r
780 Reads the 32-bit PCI configuration register specified by Address,\r
781 performs a bitwise AND between the read result and the value specified by AndData,\r
782 performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
783 and writes the result to the 32-bit PCI configuration register specified by Address.\r
784 The value written to the PCI configuration register is returned.\r
785 This function must guarantee that all PCI read and write operations are serialized.\r
786 \r
787 If any reserved bits in Address are set, then ASSERT().\r
788 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
789\r
790 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
791 @param AndData The value to AND with the PCI configuration register.\r
792 @param OrData The value to OR with the PCI configuration register.\r
793\r
794 @return The value written to the PCI configuration register.\r
795\r
796**/\r
797UINT32\r
798EFIAPI\r
799PciSegmentAndThenOr32 (\r
800 IN UINT64 Address,\r
801 IN UINT32 AndData,\r
802 IN UINT32 OrData\r
803 );\r
804\r
805/**\r
806 Reads a bit field of a PCI configuration register.\r
807\r
808 Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
809 specified by the StartBit and the EndBit. The value of the bit field is\r
810 returned.\r
811\r
812 If any reserved bits in Address are set, then ASSERT().\r
813 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
814 If StartBit is greater than 31, then ASSERT().\r
815 If EndBit is greater than 31, then ASSERT().\r
816 If EndBit is less than StartBit, then ASSERT().\r
817\r
818 @param Address PCI configuration register to read.\r
819 @param StartBit The ordinal of the least significant bit in the bit field.\r
820 Range 0..31.\r
821 @param EndBit The ordinal of the most significant bit in the bit field.\r
822 Range 0..31.\r
823\r
824 @return The value of the bit field read from the PCI configuration register.\r
825\r
826**/\r
827UINT32\r
828EFIAPI\r
829PciSegmentBitFieldRead32 (\r
830 IN UINT64 Address,\r
831 IN UINTN StartBit,\r
832 IN UINTN EndBit\r
833 );\r
834\r
835/**\r
836 Writes a bit field to a PCI configuration register.\r
837\r
838 Writes Value to the bit field of the PCI configuration register. The bit\r
839 field is specified by the StartBit and the EndBit. All other bits in the\r
840 destination PCI configuration register are preserved. The new value of the\r
841 32-bit register is returned.\r
842\r
843 If any reserved bits in Address are set, then ASSERT().\r
844 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
845 If StartBit is greater than 31, then ASSERT().\r
846 If EndBit is greater than 31, then ASSERT().\r
847 If EndBit is less than StartBit, then ASSERT().\r
848 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
849\r
850 @param Address PCI configuration register to write.\r
851 @param StartBit The ordinal of the least significant bit in the bit field.\r
852 Range 0..31.\r
853 @param EndBit The ordinal of the most significant bit in the bit field.\r
854 Range 0..31.\r
855 @param Value New value of the bit field.\r
856\r
857 @return The value written back to the PCI configuration register.\r
858\r
859**/\r
860UINT32\r
861EFIAPI\r
862PciSegmentBitFieldWrite32 (\r
863 IN UINT64 Address,\r
864 IN UINTN StartBit,\r
865 IN UINTN EndBit,\r
866 IN UINT32 Value\r
867 );\r
868\r
869/**\r
870 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
871 writes the result back to the bit field in the 32-bit port.\r
872\r
873 Reads the 32-bit PCI configuration register specified by Address, performs a\r
874 bitwise OR between the read result and the value specified by\r
875 OrData, and writes the result to the 32-bit PCI configuration register\r
876 specified by Address. The value written to the PCI configuration register is\r
877 returned. This function must guarantee that all PCI read and write operations\r
878 are serialized. Extra left bits in OrData are stripped.\r
879\r
880 If any reserved bits in Address are set, 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 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
885\r
886 @param Address PCI configuration register to write.\r
887 @param StartBit The ordinal of the least significant bit in the bit field.\r
888 Range 0..31.\r
889 @param EndBit The ordinal of the most significant bit in the bit field.\r
890 Range 0..31.\r
891 @param OrData The value to OR with the PCI configuration register.\r
892\r
893 @return The value written back to the PCI configuration register.\r
894\r
895**/\r
896UINT32\r
897EFIAPI\r
898PciSegmentBitFieldOr32 (\r
899 IN UINT64 Address,\r
900 IN UINTN StartBit,\r
901 IN UINTN EndBit,\r
902 IN UINT32 OrData\r
903 );\r
904\r
905/**\r
906 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
907 AND, and writes the result back to the bit field in the 32-bit register.\r
908\r
909 \r
910 Reads the 32-bit PCI configuration register specified by Address, performs a bitwise\r
911 AND between the read result and the value specified by AndData, and writes the result\r
912 to the 32-bit PCI configuration register specified by Address. The value written to\r
913 the PCI configuration register is returned. This function must guarantee that all PCI\r
914 read and write operations are serialized. Extra left bits in AndData are stripped.\r
915 If any reserved bits in Address are set, then ASSERT().\r
916 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
917 If StartBit is greater than 31, then ASSERT().\r
918 If EndBit is greater than 31, then ASSERT().\r
919 If EndBit is less than StartBit, then ASSERT().\r
920 If AndData is larger than the bitmask value range specified by StartBit and EndBit, 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
934PciSegmentBitFieldAnd32 (\r
935 IN UINT64 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 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 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 any reserved bits in Address are set, then ASSERT().\r
955 If StartBit is greater than 31, then ASSERT().\r
956 If EndBit is greater than 31, then ASSERT().\r
957 If EndBit is less than StartBit, then ASSERT().\r
958 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
959 If OrData is larger than the bitmask value range specified by StartBit and EndBit, 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
974PciSegmentBitFieldAndThenOr32 (\r
975 IN UINT64 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 any reserved bits in StartAddress are set, then ASSERT().\r
994 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
995 If Size > 0 and Buffer is NULL, then ASSERT().\r
996\r
997 @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r
998 Function and Register.\r
999 @param Size Size in bytes of the transfer.\r
1000 @param Buffer Pointer to a buffer receiving the data read.\r
1001\r
1002 @return Size\r
1003\r
1004**/\r
1005UINTN\r
1006EFIAPI\r
1007PciSegmentReadBuffer (\r
1008 IN UINT64 StartAddress,\r
1009 IN UINTN Size,\r
1010 OUT VOID *Buffer\r
1011 );\r
1012\r
1013/**\r
1014 Copies the data in a caller supplied buffer to a specified range of PCI\r
1015 configuration space.\r
1016\r
1017 Writes the range of PCI configuration registers specified by StartAddress and\r
1018 Size from the buffer specified by Buffer. This function only allows the PCI\r
1019 configuration registers from a single PCI function to be written. Size is\r
1020 returned. When possible 32-bit PCI configuration write cycles are used to\r
1021 write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
1022 8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
1023 and the end of the range.\r
1024\r
1025 If any reserved bits in StartAddress are set, then ASSERT().\r
1026 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
1027 If Size > 0 and Buffer is NULL, then ASSERT().\r
1028\r
1029 @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r
1030 Function and Register.\r
1031 @param Size Size in bytes of the transfer.\r
1032 @param Buffer Pointer to a buffer containing the data to write.\r
1033\r
1034 @return The parameter of Size.\r
1035\r
1036**/\r
1037UINTN\r
1038EFIAPI\r
1039PciSegmentWriteBuffer (\r
1040 IN UINT64 StartAddress,\r
1041 IN UINTN Size,\r
1042 IN VOID *Buffer\r
1043 );\r
1044\r
1045#endif\r