]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Library/PciSegmentLib.h
Detect some unsupported cases when save boot script, then return error early.
[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 - 2009, 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 ( ((Register) & 0xfff) | \\r
60 (((Function) & 0x07) << 12) | \\r
61 (((Device) & 0x1f) << 15) | \\r
62 (((Bus) & 0xff) << 20) | \\r
63 (LShiftU64((Segment) & 0xffff, 32)) \\r
64 )\r
65\r
66/**\r
67 Register a PCI device so PCI configuration registers may be accessed after \r
68 SetVirtualAddressMap().\r
69 \r
70 If any reserved bits in Address are set, then ASSERT().\r
71\r
72 @param Address Address that encodes the PCI Bus, Device, Function and\r
73 Register.\r
74 \r
75 @retval RETURN_SUCCESS The PCI device was registered for runtime access.\r
76 @retval RETURN_UNSUPPORTED An attempt was made to call this function \r
77 after ExitBootServices().\r
78 @retval RETURN_UNSUPPORTED The resources required to access the PCI device\r
79 at runtime could not be mapped.\r
80 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to\r
81 complete the registration.\r
82\r
83**/\r
84RETURN_STATUS\r
85EFIAPI\r
86PciSegmentRegisterForRuntimeAccess (\r
87 IN UINTN Address\r
88 );\r
89\r
90/**\r
91 Reads an 8-bit PCI configuration register.\r
92\r
93 Reads and returns the 8-bit PCI configuration register specified by Address.\r
94 This function must guarantee that all PCI read and write operations are serialized.\r
95 \r
96 If any reserved bits in Address are set, then ASSERT().\r
97 \r
98 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
99\r
100 @return The 8-bit PCI configuration register specified by Address.\r
101\r
102**/\r
103UINT8\r
104EFIAPI\r
105PciSegmentRead8 (\r
106 IN UINT64 Address\r
107 );\r
108\r
109/**\r
110 Writes an 8-bit PCI configuration register.\r
111\r
112 Writes the 8-bit PCI configuration register specified by Address with the value specified by Value.\r
113 Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r
114 \r
115 If any reserved bits in Address are set, then ASSERT().\r
116\r
117 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
118 @param Value The value to write.\r
119\r
120 @return The value written to the PCI configuration register.\r
121\r
122**/\r
123UINT8\r
124EFIAPI\r
125PciSegmentWrite8 (\r
126 IN UINT64 Address,\r
127 IN UINT8 Value\r
128 );\r
129\r
130/**\r
131 Performs a bitwise OR of an 8-bit PCI configuration register with an 8-bit value.\r
132\r
133 Reads the 8-bit PCI configuration register specified by Address,\r
134 performs a bitwise OR between the read result and the value specified by OrData,\r
135 and writes the result to the 8-bit PCI configuration register specified by Address.\r
136 The value written to the PCI configuration register is returned.\r
137 This function must guarantee that all PCI read and write operations are serialized.\r
138 \r
139 If any reserved bits in Address are set, then ASSERT().\r
140\r
141 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
142 @param OrData The value to OR with the PCI configuration register.\r
143\r
144 @return The value written to the PCI configuration register.\r
145\r
146**/\r
147UINT8\r
148EFIAPI\r
149PciSegmentOr8 (\r
150 IN UINT64 Address,\r
151 IN UINT8 OrData\r
152 );\r
153\r
154/**\r
155 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value.\r
156\r
157 Reads the 8-bit PCI configuration register specified by Address,\r
158 performs a bitwise AND between the read result and the value specified by AndData,\r
159 and writes the result to the 8-bit PCI configuration register specified by Address.\r
160 The value written to the PCI configuration register is returned.\r
161 This function must guarantee that all PCI read and write operations are serialized.\r
162 If any reserved bits in Address are set, then ASSERT().\r
163\r
164 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
165 @param AndData The value to AND with the PCI configuration register.\r
166\r
167 @return The value written to the PCI configuration register.\r
168\r
169**/\r
170UINT8\r
171EFIAPI\r
172PciSegmentAnd8 (\r
173 IN UINT64 Address,\r
174 IN UINT8 AndData\r
175 );\r
176\r
177/**\r
178 Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value,\r
179 followed a bitwise OR with another 8-bit value.\r
180 \r
181 Reads the 8-bit PCI configuration register specified by Address,\r
182 performs a bitwise AND between the read result and the value specified by AndData,\r
183 performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
184 and writes the result to the 8-bit PCI configuration register specified by Address.\r
185 The value written to the PCI configuration register is returned.\r
186 This function must guarantee that all PCI read and write operations are serialized.\r
187 \r
188 If any reserved bits in Address are set, then ASSERT().\r
189\r
190 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
191 @param AndData The value to AND with the PCI configuration register.\r
192 @param OrData The value to OR with the PCI configuration register.\r
193\r
194 @return The value written to the PCI configuration register.\r
195\r
196**/\r
197UINT8\r
198EFIAPI\r
199PciSegmentAndThenOr8 (\r
200 IN UINT64 Address,\r
201 IN UINT8 AndData,\r
202 IN UINT8 OrData\r
203 );\r
204\r
205/**\r
206 Reads a bit field of a PCI configuration register.\r
207\r
208 Reads the bit field in an 8-bit PCI configuration register. The bit field is\r
209 specified by the StartBit and the EndBit. The value of the bit field is\r
210 returned.\r
211\r
212 If any reserved bits in Address are set, then ASSERT().\r
213 If StartBit is greater than 7, then ASSERT().\r
214 If EndBit is greater than 7, then ASSERT().\r
215 If EndBit is less than StartBit, then ASSERT().\r
216\r
217 @param Address PCI configuration register to read.\r
218 @param StartBit The ordinal of the least significant bit in the bit field.\r
219 Range 0..7.\r
220 @param EndBit The ordinal of the most significant bit in the bit field.\r
221 Range 0..7.\r
222\r
223 @return The value of the bit field read from the PCI configuration register.\r
224\r
225**/\r
226UINT8\r
227EFIAPI\r
228PciSegmentBitFieldRead8 (\r
229 IN UINT64 Address,\r
230 IN UINTN StartBit,\r
231 IN UINTN EndBit\r
232 );\r
233\r
234/**\r
235 Writes a bit field to a PCI configuration register.\r
236\r
237 Writes Value to the bit field of the PCI configuration register. The bit\r
238 field is specified by the StartBit and the EndBit. All other bits in the\r
239 destination PCI configuration register are preserved. The new value of the\r
240 8-bit register is returned.\r
241\r
242 If any reserved bits in Address are set, 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
259PciSegmentBitFieldWrite8 (\r
260 IN UINT64 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
271 bitwise OR between the read result and the value specified by\r
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 any reserved bits in Address are set, then ASSERT().\r
278 If StartBit is greater than 7, then ASSERT().\r
279 If EndBit is greater than 7, then ASSERT().\r
280 If EndBit is less than StartBit, then ASSERT().\r
281\r
282 @param Address PCI configuration register to write.\r
283 @param StartBit The ordinal of the least significant bit in the bit field.\r
284 Range 0..7.\r
285 @param EndBit The ordinal of the most significant bit in the bit field.\r
286 Range 0..7.\r
287 @param OrData The value to OR with the PCI configuration register.\r
288\r
289 @return The value written back to the PCI configuration register.\r
290\r
291**/\r
292UINT8\r
293EFIAPI\r
294PciSegmentBitFieldOr8 (\r
295 IN UINT64 Address,\r
296 IN UINTN StartBit,\r
297 IN UINTN EndBit,\r
298 IN UINT8 OrData\r
299 );\r
300\r
301/**\r
302 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
303 AND, and writes the result back to the bit field in the 8-bit register.\r
304\r
305 Reads the 8-bit PCI configuration register specified by Address, performs a\r
306 bitwise AND between the read result and the value specified by AndData, and\r
307 writes the result to the 8-bit PCI configuration register specified by\r
308 Address. The value written to the PCI configuration register is returned.\r
309 This function must guarantee that all PCI read and write operations are\r
310 serialized. Extra left bits in AndData are stripped.\r
311\r
312 If any reserved bits in Address are set, then ASSERT().\r
313 If StartBit is greater than 7, then ASSERT().\r
314 If EndBit is greater than 7, then ASSERT().\r
315 If EndBit is less than StartBit, then ASSERT().\r
316\r
317 @param Address PCI configuration register to write.\r
318 @param StartBit The ordinal of the least significant bit in the bit field.\r
319 Range 0..7.\r
320 @param EndBit The ordinal of the most significant bit in the bit field.\r
321 Range 0..7.\r
322 @param AndData The value to AND with the PCI configuration register.\r
323\r
324 @return The value written back to the PCI configuration register.\r
325\r
326**/\r
327UINT8\r
328EFIAPI\r
329PciSegmentBitFieldAnd8 (\r
330 IN UINT64 Address,\r
331 IN UINTN StartBit,\r
332 IN UINTN EndBit,\r
333 IN UINT8 AndData\r
334 );\r
335\r
336/**\r
337 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
338 bitwise OR, and writes the result back to the bit field in the\r
339 8-bit port.\r
340\r
341 Reads the 8-bit PCI configuration register specified by Address, performs a\r
342 bitwise AND followed by a bitwise OR between the read result and\r
343 the value specified by AndData, and writes the result to the 8-bit PCI\r
344 configuration register specified by Address. The value written to the PCI\r
345 configuration register is returned. This function must guarantee that all PCI\r
346 read and write operations are serialized. Extra left bits in both AndData and\r
347 OrData are stripped.\r
348\r
349 If any reserved bits in Address are set, 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
353\r
354 @param Address PCI configuration register to write.\r
355 @param StartBit The ordinal of the least significant bit in the bit field.\r
356 Range 0..7.\r
357 @param EndBit The ordinal of the most significant bit in the bit field.\r
358 Range 0..7.\r
359 @param AndData The value to AND with the PCI configuration register.\r
360 @param OrData The value to OR with the result of the AND operation.\r
361\r
362 @return The value written back to the PCI configuration register.\r
363\r
364**/\r
365UINT8\r
366EFIAPI\r
367PciSegmentBitFieldAndThenOr8 (\r
368 IN UINT64 Address,\r
369 IN UINTN StartBit,\r
370 IN UINTN EndBit,\r
371 IN UINT8 AndData,\r
372 IN UINT8 OrData\r
373 );\r
374\r
375/**\r
376 Reads a 16-bit PCI configuration register.\r
377\r
378 Reads and returns the 16-bit PCI configuration register specified by Address.\r
379 This function must guarantee that all PCI read and write operations are serialized.\r
380 \r
381 If any reserved bits in Address are set, then ASSERT().\r
382 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
383 \r
384 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
385\r
386 @return The 16-bit PCI configuration register specified by Address.\r
387\r
388**/\r
389UINT16\r
390EFIAPI\r
391PciSegmentRead16 (\r
392 IN UINT64 Address\r
393 );\r
394\r
395/**\r
396 Writes a 16-bit PCI configuration register.\r
397\r
398 Writes the 16-bit PCI configuration register specified by Address with the value specified by Value.\r
399 Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r
400 \r
401 If any reserved bits in Address are set, then ASSERT().\r
402 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
403\r
404 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
405 @param Value The value to write.\r
406\r
407 @return The parameter of Value.\r
408\r
409**/\r
410UINT16\r
411EFIAPI\r
412PciSegmentWrite16 (\r
413 IN UINT64 Address,\r
414 IN UINT16 Value\r
415 );\r
416\r
417/**\r
418 Performs a bitwise OR of a 16-bit PCI configuration register with\r
419 a 16-bit value.\r
420\r
421 Reads the 16-bit PCI configuration register specified by Address, performs a\r
422 bitwise OR between the read result and the value specified by\r
423 OrData, and writes the result to the 16-bit PCI configuration register\r
424 specified by Address. The value written to the PCI configuration register is\r
425 returned. This function must guarantee that all PCI read and write operations\r
426 are serialized.\r
427\r
428 If any reserved bits in Address are set, then ASSERT().\r
429 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
430\r
431 @param Address Address that encodes the PCI Segment, Bus, Device, Function and\r
432 Register.\r
433 @param OrData The value to OR with the PCI configuration register.\r
434\r
435 @return The value written back to the PCI configuration register.\r
436\r
437**/\r
438UINT16\r
439EFIAPI\r
440PciSegmentOr16 (\r
441 IN UINT64 Address,\r
442 IN UINT16 OrData\r
443 );\r
444\r
445/**\r
446 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value.\r
447\r
448 Reads the 16-bit PCI configuration register specified by Address,\r
449 performs a bitwise AND between the read result and the value specified by AndData,\r
450 and writes the result to the 16-bit PCI configuration register specified by Address.\r
451 The value written to the PCI configuration register is returned.\r
452 This function must guarantee that all PCI read and write operations are serialized.\r
453 \r
454 If any reserved bits in Address are set, then ASSERT().\r
455 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
456 \r
457 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
458 @param AndData The value to AND with the PCI configuration register.\r
459\r
460 @return The value written to the PCI configuration register.\r
461\r
462**/\r
463UINT16\r
464EFIAPI\r
465PciSegmentAnd16 (\r
466 IN UINT64 Address,\r
467 IN UINT16 AndData\r
468 );\r
469\r
470/**\r
471 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value,\r
472 followed a bitwise OR with another 16-bit value.\r
473 \r
474 Reads the 16-bit PCI configuration register specified by Address,\r
475 performs a bitwise AND between the read result and the value specified by AndData,\r
476 performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
477 and writes the result to the 16-bit PCI configuration register specified by Address.\r
478 The value written to the PCI configuration register is returned.\r
479 This function must guarantee that all PCI read and write operations are serialized.\r
480 \r
481 If any reserved bits in Address are set, then ASSERT().\r
482 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
483\r
484 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
485 @param AndData The value to AND with the PCI configuration register.\r
486 @param OrData The value to OR with the PCI configuration register.\r
487\r
488 @return The value written to the PCI configuration register.\r
489\r
490**/\r
491UINT16\r
492EFIAPI\r
493PciSegmentAndThenOr16 (\r
494 IN UINT64 Address,\r
495 IN UINT16 AndData,\r
496 IN UINT16 OrData\r
497 );\r
498\r
499/**\r
500 Reads a bit field of a PCI configuration register.\r
501\r
502 Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
503 specified by the StartBit and the EndBit. The value of the bit field is\r
504 returned.\r
505\r
506 If any reserved bits in Address are set, then ASSERT().\r
507 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
508 If StartBit is greater than 15, then ASSERT().\r
509 If EndBit is greater than 15, then ASSERT().\r
510 If EndBit is less than StartBit, then ASSERT().\r
511\r
512 @param Address PCI configuration register to read.\r
513 @param StartBit The ordinal of the least significant bit in the bit field.\r
514 Range 0..15.\r
515 @param EndBit The ordinal of the most significant bit in the bit field.\r
516 Range 0..15.\r
517\r
518 @return The value of the bit field read from the PCI configuration register.\r
519\r
520**/\r
521UINT16\r
522EFIAPI\r
523PciSegmentBitFieldRead16 (\r
524 IN UINT64 Address,\r
525 IN UINTN StartBit,\r
526 IN UINTN EndBit\r
527 );\r
528\r
529/**\r
530 Writes a bit field to a PCI configuration register.\r
531\r
532 Writes Value to the bit field of the PCI configuration register. The bit\r
533 field is specified by the StartBit and the EndBit. All other bits in the\r
534 destination PCI configuration register are preserved. The new value of the\r
535 16-bit register is returned.\r
536\r
537 If any reserved bits in Address are set, then ASSERT().\r
538 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
539 If StartBit is greater than 15, then ASSERT().\r
540 If EndBit is greater than 15, then ASSERT().\r
541 If EndBit is less than StartBit, then ASSERT().\r
542\r
543 @param Address PCI configuration register to write.\r
544 @param StartBit The ordinal of the least significant bit in the bit field.\r
545 Range 0..15.\r
546 @param EndBit The ordinal of the most significant bit in the bit field.\r
547 Range 0..15.\r
548 @param Value New value of the bit field.\r
549\r
550 @return The value written back to the PCI configuration register.\r
551\r
552**/\r
553UINT16\r
554EFIAPI\r
555PciSegmentBitFieldWrite16 (\r
556 IN UINT64 Address,\r
557 IN UINTN StartBit,\r
558 IN UINTN EndBit,\r
559 IN UINT16 Value\r
560 );\r
561\r
562/**\r
563 Reads the 16-bit PCI configuration register specified by Address,\r
564 performs a bitwise OR between the read result and the value specified by OrData,\r
565 and writes the result to the 16-bit PCI configuration register specified by Address. \r
566\r
567 If any reserved bits in Address are set, then ASSERT().\r
568 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
569 If StartBit is greater than 15, then ASSERT().\r
570 If EndBit is greater than 15, then ASSERT().\r
571 If EndBit is less than StartBit, then ASSERT().\r
572\r
573 @param Address PCI configuration register to write.\r
574 @param StartBit The ordinal of the least significant bit in the bit field.\r
575 Range 0..15.\r
576 @param EndBit The ordinal of the most significant bit in the bit field.\r
577 Range 0..15.\r
578 @param OrData The value to OR with the PCI configuration register.\r
579\r
580 @return The value written back to the PCI configuration register.\r
581\r
582**/\r
583UINT16\r
584EFIAPI\r
585PciSegmentBitFieldOr16 (\r
586 IN UINT64 Address,\r
587 IN UINTN StartBit,\r
588 IN UINTN EndBit,\r
589 IN UINT16 OrData\r
590 );\r
591\r
592/**\r
593 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR,\r
594 and writes the result back to the bit field in the 16-bit port.\r
595\r
596 Reads the 16-bit PCI configuration register specified by Address,\r
597 performs a bitwise OR between the read result and the value specified by OrData,\r
598 and writes the result to the 16-bit PCI configuration register specified by Address.\r
599 The value written to the PCI configuration register is returned.\r
600 This function must guarantee that all PCI read and write operations are serialized.\r
601 Extra left bits in OrData are stripped.\r
602 \r
603 If any reserved bits in Address are set, then ASSERT().\r
604 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
605 If StartBit is greater than 7, then ASSERT().\r
606 If EndBit is greater than 7, then ASSERT().\r
607 If EndBit is less than StartBit, then ASSERT().\r
608\r
609 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
610 @param StartBit The ordinal of the least significant bit in the bit field.\r
611 The ordinal of the least significant bit in a byte is bit 0.\r
612 @param EndBit The ordinal of the most significant bit in the bit field.\r
613 The ordinal of the most significant bit in a byte is bit 7.\r
614 @param AndData The value to AND with the read value from the PCI configuration register.\r
615\r
616 @return The value written to the PCI configuration register.\r
617\r
618**/\r
619UINT16\r
620EFIAPI\r
621PciSegmentBitFieldAnd16 (\r
622 IN UINT64 Address,\r
623 IN UINTN StartBit,\r
624 IN UINTN EndBit,\r
625 IN UINT16 AndData\r
626 );\r
627\r
628/**\r
629 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
630 bitwise OR, and writes the result back to the bit field in the\r
631 16-bit port.\r
632\r
633 Reads the 16-bit PCI configuration register specified by Address, performs a\r
634 bitwise AND followed by a bitwise OR between the read result and\r
635 the value specified by AndData, and writes the result to the 16-bit PCI\r
636 configuration register specified by Address. The value written to the PCI\r
637 configuration register is returned. This function must guarantee that all PCI\r
638 read and write operations are serialized. Extra left bits in both AndData and\r
639 OrData are stripped.\r
640\r
641 If any reserved bits in Address are set, then ASSERT().\r
642 If StartBit is greater than 15, then ASSERT().\r
643 If EndBit is greater than 15, then ASSERT().\r
644 If EndBit is less than StartBit, then ASSERT().\r
645\r
646 @param Address PCI configuration register to write.\r
647 @param StartBit The ordinal of the least significant bit in the bit field.\r
648 Range 0..15.\r
649 @param EndBit The ordinal of the most significant bit in the bit field.\r
650 Range 0..15.\r
651 @param AndData The value to AND with the PCI configuration register.\r
652 @param OrData The value to OR with the result of the AND operation.\r
653\r
654 @return The value written back to the PCI configuration register.\r
655\r
656**/\r
657UINT16\r
658EFIAPI\r
659PciSegmentBitFieldAndThenOr16 (\r
660 IN UINT64 Address,\r
661 IN UINTN StartBit,\r
662 IN UINTN EndBit,\r
663 IN UINT16 AndData,\r
664 IN UINT16 OrData\r
665 );\r
666\r
667/**\r
668 Reads a 32-bit PCI configuration register.\r
669\r
670 Reads and returns the 32-bit PCI configuration register specified by Address.\r
671 This function must guarantee that all PCI read and write operations are serialized.\r
672 \r
673 If any reserved bits in Address are set, then ASSERT().\r
674 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
675\r
676 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
677\r
678 @return The 32-bit PCI configuration register specified by Address.\r
679\r
680**/\r
681UINT32\r
682EFIAPI\r
683PciSegmentRead32 (\r
684 IN UINT64 Address\r
685 );\r
686\r
687/**\r
688 Writes a 32-bit PCI configuration register.\r
689\r
690 Writes the 32-bit PCI configuration register specified by Address with the value specified by Value.\r
691 Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r
692 \r
693 If any reserved bits in Address are set, then ASSERT().\r
694 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
695\r
696 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
697 @param Value The value to write.\r
698\r
699 @return The parameter of Value.\r
700\r
701**/\r
702UINT32\r
703EFIAPI\r
704PciSegmentWrite32 (\r
705 IN UINT64 Address,\r
706 IN UINT32 Value\r
707 );\r
708\r
709/**\r
710 Performs a bitwise OR of a 32-bit PCI configuration register with a 32-bit value.\r
711\r
712 Reads the 32-bit PCI configuration register specified by Address,\r
713 performs a bitwise OR between the read result and the value specified by OrData,\r
714 and writes the result to the 32-bit PCI configuration register specified by Address.\r
715 The value written to the PCI configuration register is returned.\r
716 This function must guarantee that all PCI read and write operations are serialized.\r
717 \r
718 If any reserved bits in Address are set, then ASSERT().\r
719 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
720\r
721 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
722 @param OrData The value to OR with the PCI configuration register.\r
723\r
724 @return The value written to the PCI configuration register.\r
725\r
726**/\r
727UINT32\r
728EFIAPI\r
729PciSegmentOr32 (\r
730 IN UINT64 Address,\r
731 IN UINT32 OrData\r
732 );\r
733\r
734/**\r
735 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value.\r
736\r
737 Reads the 32-bit PCI configuration register specified by Address,\r
738 performs a bitwise AND between the read result and the value specified by AndData,\r
739 and writes the result to the 32-bit PCI configuration register specified by Address.\r
740 The value written to the PCI configuration register is returned.\r
741 This function must guarantee that all PCI read and write operations are serialized.\r
742 \r
743 If any reserved bits in Address are set, then ASSERT().\r
744 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
745\r
746 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
747 @param AndData The value to AND with the PCI configuration register.\r
748\r
749 @return The value written to the PCI configuration register.\r
750\r
751**/\r
752UINT32\r
753EFIAPI\r
754PciSegmentAnd32 (\r
755 IN UINT64 Address,\r
756 IN UINT32 AndData\r
757 );\r
758\r
759/**\r
760 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value,\r
761 followed a bitwise OR with another 32-bit value.\r
762 \r
763 Reads the 32-bit PCI configuration register specified by Address,\r
764 performs a bitwise AND between the read result and the value specified by AndData,\r
765 performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
766 and writes the result to the 32-bit PCI configuration register specified by Address.\r
767 The value written to the PCI configuration register is returned.\r
768 This function must guarantee that all PCI read and write operations are serialized.\r
769 \r
770 If any reserved bits in Address are set, then ASSERT().\r
771 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
772\r
773 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
774 @param AndData The value to AND with the PCI configuration register.\r
775 @param OrData The value to OR with the PCI configuration register.\r
776\r
777 @return The value written to the PCI configuration register.\r
778\r
779**/\r
780UINT32\r
781EFIAPI\r
782PciSegmentAndThenOr32 (\r
783 IN UINT64 Address,\r
784 IN UINT32 AndData,\r
785 IN UINT32 OrData\r
786 );\r
787\r
788/**\r
789 Reads a bit field of a PCI configuration register.\r
790\r
791 Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
792 specified by the StartBit and the EndBit. The value of the bit field is\r
793 returned.\r
794\r
795 If any reserved bits in Address are set, then ASSERT().\r
796 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
797 If StartBit is greater than 31, then ASSERT().\r
798 If EndBit is greater than 31, then ASSERT().\r
799 If EndBit is less than StartBit, then ASSERT().\r
800\r
801 @param Address PCI configuration register to read.\r
802 @param StartBit The ordinal of the least significant bit in the bit field.\r
803 Range 0..31.\r
804 @param EndBit The ordinal of the most significant bit in the bit field.\r
805 Range 0..31.\r
806\r
807 @return The value of the bit field read from the PCI configuration register.\r
808\r
809**/\r
810UINT32\r
811EFIAPI\r
812PciSegmentBitFieldRead32 (\r
813 IN UINT64 Address,\r
814 IN UINTN StartBit,\r
815 IN UINTN EndBit\r
816 );\r
817\r
818/**\r
819 Writes a bit field to a PCI configuration register.\r
820\r
821 Writes Value to the bit field of the PCI configuration register. The bit\r
822 field is specified by the StartBit and the EndBit. All other bits in the\r
823 destination PCI configuration register are preserved. The new value of the\r
824 32-bit register is returned.\r
825\r
826 If any reserved bits in Address are set, then ASSERT().\r
827 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
828 If StartBit is greater than 31, then ASSERT().\r
829 If EndBit is greater than 31, then ASSERT().\r
830 If EndBit is less than StartBit, then ASSERT().\r
831\r
832 @param Address PCI configuration register to write.\r
833 @param StartBit The ordinal of the least significant bit in the bit field.\r
834 Range 0..31.\r
835 @param EndBit The ordinal of the most significant bit in the bit field.\r
836 Range 0..31.\r
837 @param Value New value of the bit field.\r
838\r
839 @return The value written back to the PCI configuration register.\r
840\r
841**/\r
842UINT32\r
843EFIAPI\r
844PciSegmentBitFieldWrite32 (\r
845 IN UINT64 Address,\r
846 IN UINTN StartBit,\r
847 IN UINTN EndBit,\r
848 IN UINT32 Value\r
849 );\r
850\r
851/**\r
852 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
853 writes the result back to the bit field in the 32-bit port.\r
854\r
855 Reads the 32-bit PCI configuration register specified by Address, performs a\r
856 bitwise OR between the read result and the value specified by\r
857 OrData, and writes the result to the 32-bit PCI configuration register\r
858 specified by Address. The value written to the PCI configuration register is\r
859 returned. This function must guarantee that all PCI read and write operations\r
860 are serialized. Extra left bits in OrData are stripped.\r
861\r
862 If any reserved bits in Address are set, then ASSERT().\r
863 If StartBit is greater than 31, then ASSERT().\r
864 If EndBit is greater than 31, then ASSERT().\r
865 If EndBit is less than StartBit, then ASSERT().\r
866\r
867 @param Address PCI configuration register to write.\r
868 @param StartBit The ordinal of the least significant bit in the bit field.\r
869 Range 0..31.\r
870 @param EndBit The ordinal of the most significant bit in the bit field.\r
871 Range 0..31.\r
872 @param OrData The value to OR with the PCI configuration register.\r
873\r
874 @return The value written back to the PCI configuration register.\r
875\r
876**/\r
877UINT32\r
878EFIAPI\r
879PciSegmentBitFieldOr32 (\r
880 IN UINT64 Address,\r
881 IN UINTN StartBit,\r
882 IN UINTN EndBit,\r
883 IN UINT32 OrData\r
884 );\r
885\r
886/**\r
887 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
888 AND, and writes the result back to the bit field in the 32-bit register.\r
889\r
890 \r
891 Reads the 32-bit PCI configuration register specified by Address, performs a bitwise\r
892 AND between the read result and the value specified by AndData, and writes the result\r
893 to the 32-bit PCI configuration register specified by Address. The value written to\r
894 the PCI configuration register is returned. This function must guarantee that all PCI\r
895 read and write operations are serialized. Extra left bits in AndData are stripped.\r
896 If any reserved bits in Address are set, then ASSERT().\r
897 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
898 If StartBit is greater than 31, then ASSERT().\r
899 If EndBit is greater than 31, then ASSERT().\r
900 If EndBit is less than StartBit, then ASSERT().\r
901 \r
902\r
903 @param Address PCI configuration register to write.\r
904 @param StartBit The ordinal of the least significant bit in the bit field.\r
905 Range 0..31.\r
906 @param EndBit The ordinal of the most significant bit in the bit field.\r
907 Range 0..31.\r
908 @param AndData The value to AND with the PCI configuration register.\r
909\r
910 @return The value written back to the PCI configuration register.\r
911\r
912**/\r
913UINT32\r
914EFIAPI\r
915PciSegmentBitFieldAnd32 (\r
916 IN UINT64 Address,\r
917 IN UINTN StartBit,\r
918 IN UINTN EndBit,\r
919 IN UINT32 AndData\r
920 );\r
921\r
922/**\r
923 Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
924 bitwise OR, and writes the result back to the bit field in the\r
925 32-bit port.\r
926\r
927 Reads the 32-bit PCI configuration register specified by Address, performs a\r
928 bitwise AND followed by a bitwise OR between the read result and\r
929 the value specified by AndData, and writes the result to the 32-bit PCI\r
930 configuration register specified by Address. The value written to the PCI\r
931 configuration register is returned. This function must guarantee that all PCI\r
932 read and write operations are serialized. Extra left bits in both AndData and\r
933 OrData are stripped.\r
934\r
935 If any reserved bits in Address are set, then ASSERT().\r
936 If StartBit is greater than 31, then ASSERT().\r
937 If EndBit is greater than 31, then ASSERT().\r
938 If EndBit is less than StartBit, then ASSERT().\r
939\r
940 @param Address PCI configuration register to write.\r
941 @param StartBit The ordinal of the least significant bit in the bit field.\r
942 Range 0..31.\r
943 @param EndBit The ordinal of the most significant bit in the bit field.\r
944 Range 0..31.\r
945 @param AndData The value to AND with the PCI configuration register.\r
946 @param OrData The value to OR with the result of the AND operation.\r
947\r
948 @return The value written back to the PCI configuration register.\r
949\r
950**/\r
951UINT32\r
952EFIAPI\r
953PciSegmentBitFieldAndThenOr32 (\r
954 IN UINT64 Address,\r
955 IN UINTN StartBit,\r
956 IN UINTN EndBit,\r
957 IN UINT32 AndData,\r
958 IN UINT32 OrData\r
959 );\r
960\r
961/**\r
962 Reads a range of PCI configuration registers into a caller supplied buffer.\r
963\r
964 Reads the range of PCI configuration registers specified by StartAddress and\r
965 Size into the buffer specified by Buffer. This function only allows the PCI\r
966 configuration registers from a single PCI function to be read. Size is\r
967 returned. When possible 32-bit PCI configuration read cycles are used to read\r
968 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
969 and 16-bit PCI configuration read cycles may be used at the beginning and the\r
970 end of the range.\r
971\r
972 If any reserved bits in StartAddress are set, then ASSERT().\r
973 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
974 If Size > 0 and Buffer is NULL, then ASSERT().\r
975\r
976 @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r
977 Function and Register.\r
978 @param Size Size in bytes of the transfer.\r
979 @param Buffer Pointer to a buffer receiving the data read.\r
980\r
981 @return Size\r
982\r
983**/\r
984UINTN\r
985EFIAPI\r
986PciSegmentReadBuffer (\r
987 IN UINT64 StartAddress,\r
988 IN UINTN Size,\r
989 OUT VOID *Buffer\r
990 );\r
991\r
992/**\r
993 Copies the data in a caller supplied buffer to a specified range of PCI\r
994 configuration space.\r
995\r
996 Writes the range of PCI configuration registers specified by StartAddress and\r
997 Size from the buffer specified by Buffer. This function only allows the PCI\r
998 configuration registers from a single PCI function to be written. Size is\r
999 returned. When possible 32-bit PCI configuration write cycles are used to\r
1000 write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
1001 8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
1002 and the end of the range.\r
1003\r
1004 If any reserved bits in StartAddress are set, then ASSERT().\r
1005 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
1006 If Size > 0 and Buffer is NULL, then ASSERT().\r
1007\r
1008 @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r
1009 Function and Register.\r
1010 @param Size Size in bytes of the transfer.\r
1011 @param Buffer Pointer to a buffer containing the data to write.\r
1012\r
1013 @return The parameter of Size.\r
1014\r
1015**/\r
1016UINTN\r
1017EFIAPI\r
1018PciSegmentWriteBuffer (\r
1019 IN UINT64 StartAddress,\r
1020 IN UINTN Size,\r
1021 IN VOID *Buffer\r
1022 );\r
1023\r
1024#endif\r