]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Library/PciSegmentLib.h
ArmPlatformPkg: Fix stack switch bug after commit 7945b29
[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 - 2012, 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 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
247\r
248 @param Address PCI configuration register to write.\r
249 @param StartBit The ordinal of the least significant bit in the bit field.\r
250 Range 0..7.\r
251 @param EndBit The ordinal of the most significant bit in the bit field.\r
252 Range 0..7.\r
253 @param Value New value of the bit field.\r
254\r
255 @return The value written back to the PCI configuration register.\r
256\r
257**/\r
258UINT8\r
259EFIAPI\r
260PciSegmentBitFieldWrite8 (\r
261 IN UINT64 Address,\r
262 IN UINTN StartBit,\r
263 IN UINTN EndBit,\r
264 IN UINT8 Value\r
265 );\r
266\r
267/**\r
268 Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and\r
269 writes the result back to the bit field in the 8-bit port.\r
270\r
271 Reads the 8-bit PCI configuration register specified by Address, performs a\r
272 bitwise OR between the read result and the value specified by\r
273 OrData, and writes the result to the 8-bit PCI configuration register\r
274 specified by Address. The value written to the PCI configuration register is\r
275 returned. This function must guarantee that all PCI read and write operations\r
276 are serialized. Extra left bits in OrData are stripped.\r
277\r
278 If any reserved bits in Address are set, then ASSERT().\r
279 If StartBit is greater than 7, then ASSERT().\r
280 If EndBit is greater than 7, then ASSERT().\r
281 If EndBit is less than StartBit, then ASSERT().\r
282 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
283\r
284 @param Address PCI configuration register to write.\r
285 @param StartBit The ordinal of the least significant bit in the bit field.\r
286 Range 0..7.\r
287 @param EndBit The ordinal of the most significant bit in the bit field.\r
288 Range 0..7.\r
289 @param OrData The value to OR with the PCI configuration register.\r
290\r
291 @return The value written back to the PCI configuration register.\r
292\r
293**/\r
294UINT8\r
295EFIAPI\r
296PciSegmentBitFieldOr8 (\r
297 IN UINT64 Address,\r
298 IN UINTN StartBit,\r
299 IN UINTN EndBit,\r
300 IN UINT8 OrData\r
301 );\r
302\r
303/**\r
304 Reads a bit field in an 8-bit PCI configuration register, performs a bitwise\r
305 AND, and writes the result back to the bit field in the 8-bit register.\r
306\r
307 Reads the 8-bit PCI configuration register specified by Address, performs a\r
308 bitwise AND between the read result and the value specified by AndData, and\r
309 writes the result to the 8-bit PCI configuration register specified by\r
310 Address. The value written to the PCI configuration register is returned.\r
311 This function must guarantee that all PCI read and write operations are\r
312 serialized. Extra left bits in AndData are stripped.\r
313\r
314 If any reserved bits in Address are set, then ASSERT().\r
315 If StartBit is greater than 7, then ASSERT().\r
316 If EndBit is greater than 7, then ASSERT().\r
317 If EndBit is less than StartBit, then ASSERT().\r
318 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
319\r
320 @param Address PCI configuration register to write.\r
321 @param StartBit The ordinal of the least significant bit in the bit field.\r
322 Range 0..7.\r
323 @param EndBit The ordinal of the most significant bit in the bit field.\r
324 Range 0..7.\r
325 @param AndData The value to AND with the PCI configuration register.\r
326\r
327 @return The value written back to the PCI configuration register.\r
328\r
329**/\r
330UINT8\r
331EFIAPI\r
332PciSegmentBitFieldAnd8 (\r
333 IN UINT64 Address,\r
334 IN UINTN StartBit,\r
335 IN UINTN EndBit,\r
336 IN UINT8 AndData\r
337 );\r
338\r
339/**\r
340 Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r
341 bitwise OR, and writes the result back to the bit field in the\r
342 8-bit port.\r
343\r
344 Reads the 8-bit PCI configuration register specified by Address, performs a\r
345 bitwise AND followed by a bitwise OR between the read result and\r
346 the value specified by AndData, and writes the result to the 8-bit PCI\r
347 configuration register specified by Address. The value written to the PCI\r
348 configuration register is returned. This function must guarantee that all PCI\r
349 read and write operations are serialized. Extra left bits in both AndData and\r
350 OrData are stripped.\r
351\r
352 If any reserved bits in Address are set, then ASSERT().\r
353 If StartBit is greater than 7, then ASSERT().\r
354 If EndBit is greater than 7, then ASSERT().\r
355 If EndBit is less than StartBit, then ASSERT().\r
356 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
357 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
358\r
359 @param Address PCI configuration register to write.\r
360 @param StartBit The ordinal of the least significant bit in the bit field.\r
361 Range 0..7.\r
362 @param EndBit The ordinal of the most significant bit in the bit field.\r
363 Range 0..7.\r
364 @param AndData The value to AND with the PCI configuration register.\r
365 @param OrData The value to OR with the result of the AND operation.\r
366\r
367 @return The value written back to the PCI configuration register.\r
368\r
369**/\r
370UINT8\r
371EFIAPI\r
372PciSegmentBitFieldAndThenOr8 (\r
373 IN UINT64 Address,\r
374 IN UINTN StartBit,\r
375 IN UINTN EndBit,\r
376 IN UINT8 AndData,\r
377 IN UINT8 OrData\r
378 );\r
379\r
380/**\r
381 Reads a 16-bit PCI configuration register.\r
382\r
383 Reads and returns the 16-bit PCI configuration register specified by Address.\r
384 This function must guarantee that all PCI read and write operations are serialized.\r
385 \r
386 If any reserved bits in Address are set, then ASSERT().\r
387 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
388 \r
389 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
390\r
391 @return The 16-bit PCI configuration register specified by Address.\r
392\r
393**/\r
394UINT16\r
395EFIAPI\r
396PciSegmentRead16 (\r
397 IN UINT64 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 value specified by Value.\r
404 Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r
405 \r
406 If any reserved bits in Address are set, then ASSERT().\r
407 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
408\r
409 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
410 @param Value The value to write.\r
411\r
412 @return The parameter of Value.\r
413\r
414**/\r
415UINT16\r
416EFIAPI\r
417PciSegmentWrite16 (\r
418 IN UINT64 Address,\r
419 IN UINT16 Value\r
420 );\r
421\r
422/**\r
423 Performs a bitwise OR of a 16-bit PCI configuration register with\r
424 a 16-bit value.\r
425\r
426 Reads the 16-bit PCI configuration register specified by Address, performs a\r
427 bitwise OR between the read result and the value specified by\r
428 OrData, and writes the result to the 16-bit PCI configuration register\r
429 specified by Address. The value written to the PCI configuration register is\r
430 returned. This function must guarantee that all PCI read and write operations\r
431 are serialized.\r
432\r
433 If any reserved bits in Address are set, then ASSERT().\r
434 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
435\r
436 @param Address Address that encodes the PCI Segment, Bus, Device, Function and\r
437 Register.\r
438 @param OrData The value to OR with the PCI configuration register.\r
439\r
440 @return The value written back to the PCI configuration register.\r
441\r
442**/\r
443UINT16\r
444EFIAPI\r
445PciSegmentOr16 (\r
446 IN UINT64 Address,\r
447 IN UINT16 OrData\r
448 );\r
449\r
450/**\r
451 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value.\r
452\r
453 Reads the 16-bit PCI configuration register specified by Address,\r
454 performs a bitwise AND between the read result and the value specified by AndData,\r
455 and writes the result to the 16-bit PCI configuration register specified by Address.\r
456 The value written to the PCI configuration register is returned.\r
457 This function must guarantee that all PCI read and write operations are serialized.\r
458 \r
459 If any reserved bits in Address are set, then ASSERT().\r
460 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
461 \r
462 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
463 @param AndData The value to AND with the PCI configuration register.\r
464\r
465 @return The value written to the PCI configuration register.\r
466\r
467**/\r
468UINT16\r
469EFIAPI\r
470PciSegmentAnd16 (\r
471 IN UINT64 Address,\r
472 IN UINT16 AndData\r
473 );\r
474\r
475/**\r
476 Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value,\r
477 followed a bitwise OR with another 16-bit value.\r
478 \r
479 Reads the 16-bit PCI configuration register specified by Address,\r
480 performs a bitwise AND between the read result and the value specified by AndData,\r
481 performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
482 and writes the result to the 16-bit PCI configuration register specified by Address.\r
483 The value written to the PCI configuration register is returned.\r
484 This function must guarantee that all PCI read and write operations are serialized.\r
485 \r
486 If any reserved bits in Address are set, then ASSERT().\r
487 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
488\r
489 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
490 @param AndData The value to AND with the PCI configuration register.\r
491 @param OrData The value to OR with the PCI configuration register.\r
492\r
493 @return The value written to the PCI configuration register.\r
494\r
495**/\r
496UINT16\r
497EFIAPI\r
498PciSegmentAndThenOr16 (\r
499 IN UINT64 Address,\r
500 IN UINT16 AndData,\r
501 IN UINT16 OrData\r
502 );\r
503\r
504/**\r
505 Reads a bit field of a PCI configuration register.\r
506\r
507 Reads the bit field in a 16-bit PCI configuration register. The bit field is\r
508 specified by the StartBit and the EndBit. The value of the bit field is\r
509 returned.\r
510\r
511 If any reserved bits in Address are set, then ASSERT().\r
512 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
513 If StartBit is greater than 15, then ASSERT().\r
514 If EndBit is greater than 15, then ASSERT().\r
515 If EndBit is less than StartBit, then ASSERT().\r
516\r
517 @param Address PCI configuration register to read.\r
518 @param StartBit The ordinal of the least significant bit in the bit field.\r
519 Range 0..15.\r
520 @param EndBit The ordinal of the most significant bit in the bit field.\r
521 Range 0..15.\r
522\r
523 @return The value of the bit field read from the PCI configuration register.\r
524\r
525**/\r
526UINT16\r
527EFIAPI\r
528PciSegmentBitFieldRead16 (\r
529 IN UINT64 Address,\r
530 IN UINTN StartBit,\r
531 IN UINTN EndBit\r
532 );\r
533\r
534/**\r
535 Writes a bit field to a PCI configuration register.\r
536\r
537 Writes Value to the bit field of the PCI configuration register. The bit\r
538 field is specified by the StartBit and the EndBit. All other bits in the\r
539 destination PCI configuration register are preserved. The new value of the\r
540 16-bit register is returned.\r
541\r
542 If any reserved bits in Address are set, then ASSERT().\r
543 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
544 If StartBit is greater than 15, then ASSERT().\r
545 If EndBit is greater than 15, then ASSERT().\r
546 If EndBit is less than StartBit, then ASSERT().\r
547 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
548\r
549 @param Address PCI configuration register to write.\r
550 @param StartBit The ordinal of the least significant bit in the bit field.\r
551 Range 0..15.\r
552 @param EndBit The ordinal of the most significant bit in the bit field.\r
553 Range 0..15.\r
554 @param Value New value of the bit field.\r
555\r
556 @return The value written back to the PCI configuration register.\r
557\r
558**/\r
559UINT16\r
560EFIAPI\r
561PciSegmentBitFieldWrite16 (\r
562 IN UINT64 Address,\r
563 IN UINTN StartBit,\r
564 IN UINTN EndBit,\r
565 IN UINT16 Value\r
566 );\r
567\r
568/**\r
569 Reads the 16-bit PCI configuration register specified by Address,\r
570 performs a bitwise OR between the read result and the value specified by OrData,\r
571 and writes the result to the 16-bit PCI configuration register specified by Address. \r
572\r
573 If any reserved bits in Address are set, then ASSERT().\r
574 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
575 If StartBit is greater than 15, then ASSERT().\r
576 If EndBit is greater than 15, then ASSERT().\r
577 If EndBit is less than StartBit, then ASSERT().\r
578 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
579\r
580 @param Address PCI configuration register to write.\r
581 @param StartBit The ordinal of the least significant bit in the bit field.\r
582 Range 0..15.\r
583 @param EndBit The ordinal of the most significant bit in the bit field.\r
584 Range 0..15.\r
585 @param OrData The value to OR with the PCI configuration register.\r
586\r
587 @return The value written back to the PCI configuration register.\r
588\r
589**/\r
590UINT16\r
591EFIAPI\r
592PciSegmentBitFieldOr16 (\r
593 IN UINT64 Address,\r
594 IN UINTN StartBit,\r
595 IN UINTN EndBit,\r
596 IN UINT16 OrData\r
597 );\r
598\r
599/**\r
600 Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR,\r
601 and writes the result back to the bit field in the 16-bit port.\r
602\r
603 Reads the 16-bit PCI configuration register specified by Address,\r
604 performs a bitwise OR between the read result and the value specified by OrData,\r
605 and writes the result to the 16-bit PCI configuration register specified by Address.\r
606 The value written to the PCI configuration register is returned.\r
607 This function must guarantee that all PCI read and write operations are serialized.\r
608 Extra left bits in OrData are stripped.\r
609 \r
610 If any reserved bits in Address are set, then ASSERT().\r
611 If Address is not aligned on a 16-bit boundary, then ASSERT().\r
612 If StartBit is greater than 7, then ASSERT().\r
613 If EndBit is greater than 7, then ASSERT().\r
614 If EndBit is less than StartBit, then ASSERT().\r
615 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
616\r
617 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
618 @param StartBit The ordinal of the least significant bit in the bit field.\r
619 The ordinal of the least significant bit in a byte is bit 0.\r
620 @param EndBit The ordinal of the most significant bit in the bit field.\r
621 The ordinal of the most significant bit in a byte is bit 7.\r
622 @param AndData The value to AND with the read value from the PCI configuration register.\r
623\r
624 @return The value written to the PCI configuration register.\r
625\r
626**/\r
627UINT16\r
628EFIAPI\r
629PciSegmentBitFieldAnd16 (\r
630 IN UINT64 Address,\r
631 IN UINTN StartBit,\r
632 IN UINTN EndBit,\r
633 IN UINT16 AndData\r
634 );\r
635\r
636/**\r
637 Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r
638 bitwise OR, and writes the result back to the bit field in the\r
639 16-bit port.\r
640\r
641 Reads the 16-bit PCI configuration register specified by Address, performs a\r
642 bitwise AND followed by a bitwise OR between the read result and\r
643 the value specified by AndData, and writes the result to the 16-bit PCI\r
644 configuration register specified by Address. The value written to the PCI\r
645 configuration register is returned. This function must guarantee that all PCI\r
646 read and write operations are serialized. Extra left bits in both AndData and\r
647 OrData are stripped.\r
648\r
649 If any reserved bits in Address are set, then ASSERT().\r
650 If StartBit is greater than 15, then ASSERT().\r
651 If EndBit is greater than 15, then ASSERT().\r
652 If EndBit is less than StartBit, then ASSERT().\r
653 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
654 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
655\r
656 @param Address PCI configuration register to write.\r
657 @param StartBit The ordinal of the least significant bit in the bit field.\r
658 Range 0..15.\r
659 @param EndBit The ordinal of the most significant bit in the bit field.\r
660 Range 0..15.\r
661 @param AndData The value to AND with the PCI configuration register.\r
662 @param OrData The value to OR with the result of the AND operation.\r
663\r
664 @return The value written back to the PCI configuration register.\r
665\r
666**/\r
667UINT16\r
668EFIAPI\r
669PciSegmentBitFieldAndThenOr16 (\r
670 IN UINT64 Address,\r
671 IN UINTN StartBit,\r
672 IN UINTN EndBit,\r
673 IN UINT16 AndData,\r
674 IN UINT16 OrData\r
675 );\r
676\r
677/**\r
678 Reads a 32-bit PCI configuration register.\r
679\r
680 Reads and returns the 32-bit PCI configuration register specified by Address.\r
681 This function must guarantee that all PCI read and write operations are serialized.\r
682 \r
683 If any reserved bits in Address are set, then ASSERT().\r
684 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
685\r
686 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
687\r
688 @return The 32-bit PCI configuration register specified by Address.\r
689\r
690**/\r
691UINT32\r
692EFIAPI\r
693PciSegmentRead32 (\r
694 IN UINT64 Address\r
695 );\r
696\r
697/**\r
698 Writes a 32-bit PCI configuration register.\r
699\r
700 Writes the 32-bit PCI configuration register specified by Address with the value specified by Value.\r
701 Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r
702 \r
703 If any reserved bits in Address are set, then ASSERT().\r
704 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
705\r
706 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
707 @param Value The value to write.\r
708\r
709 @return The parameter of Value.\r
710\r
711**/\r
712UINT32\r
713EFIAPI\r
714PciSegmentWrite32 (\r
715 IN UINT64 Address,\r
716 IN UINT32 Value\r
717 );\r
718\r
719/**\r
720 Performs a bitwise OR of a 32-bit PCI configuration register with a 32-bit value.\r
721\r
722 Reads the 32-bit PCI configuration register specified by Address,\r
723 performs a bitwise OR between the read result and the value specified by OrData,\r
724 and writes the result to the 32-bit PCI configuration register specified by Address.\r
725 The value written to the PCI configuration register is returned.\r
726 This function must guarantee that all PCI read and write operations are serialized.\r
727 \r
728 If any reserved bits in Address are set, then ASSERT().\r
729 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
730\r
731 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
732 @param OrData The value to OR with the PCI configuration register.\r
733\r
734 @return The value written to the PCI configuration register.\r
735\r
736**/\r
737UINT32\r
738EFIAPI\r
739PciSegmentOr32 (\r
740 IN UINT64 Address,\r
741 IN UINT32 OrData\r
742 );\r
743\r
744/**\r
745 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value.\r
746\r
747 Reads the 32-bit PCI configuration register specified by Address,\r
748 performs a bitwise AND between the read result and the value specified by AndData,\r
749 and writes the result to the 32-bit PCI configuration register specified by Address.\r
750 The value written to the PCI configuration register is returned.\r
751 This function must guarantee that all PCI read and write operations are serialized.\r
752 \r
753 If any reserved bits in Address are set, then ASSERT().\r
754 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
755\r
756 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
757 @param AndData The value to AND with the PCI configuration register.\r
758\r
759 @return The value written to the PCI configuration register.\r
760\r
761**/\r
762UINT32\r
763EFIAPI\r
764PciSegmentAnd32 (\r
765 IN UINT64 Address,\r
766 IN UINT32 AndData\r
767 );\r
768\r
769/**\r
770 Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value,\r
771 followed a bitwise OR with another 32-bit value.\r
772 \r
773 Reads the 32-bit PCI configuration register specified by Address,\r
774 performs a bitwise AND between the read result and the value specified by AndData,\r
775 performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r
776 and writes the result to the 32-bit PCI configuration register specified by Address.\r
777 The value written to the PCI configuration register is returned.\r
778 This function must guarantee that all PCI read and write operations are serialized.\r
779 \r
780 If any reserved bits in Address are set, then ASSERT().\r
781 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
782\r
783 @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r
784 @param AndData The value to AND with the PCI configuration register.\r
785 @param OrData The value to OR with the PCI configuration register.\r
786\r
787 @return The value written to the PCI configuration register.\r
788\r
789**/\r
790UINT32\r
791EFIAPI\r
792PciSegmentAndThenOr32 (\r
793 IN UINT64 Address,\r
794 IN UINT32 AndData,\r
795 IN UINT32 OrData\r
796 );\r
797\r
798/**\r
799 Reads a bit field of a PCI configuration register.\r
800\r
801 Reads the bit field in a 32-bit PCI configuration register. The bit field is\r
802 specified by the StartBit and the EndBit. The value of the bit field is\r
803 returned.\r
804\r
805 If any reserved bits in Address are set, then ASSERT().\r
806 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
807 If StartBit is greater than 31, then ASSERT().\r
808 If EndBit is greater than 31, then ASSERT().\r
809 If EndBit is less than StartBit, then ASSERT().\r
810\r
811 @param Address PCI configuration register to read.\r
812 @param StartBit The ordinal of the least significant bit in the bit field.\r
813 Range 0..31.\r
814 @param EndBit The ordinal of the most significant bit in the bit field.\r
815 Range 0..31.\r
816\r
817 @return The value of the bit field read from the PCI configuration register.\r
818\r
819**/\r
820UINT32\r
821EFIAPI\r
822PciSegmentBitFieldRead32 (\r
823 IN UINT64 Address,\r
824 IN UINTN StartBit,\r
825 IN UINTN EndBit\r
826 );\r
827\r
828/**\r
829 Writes a bit field to a PCI configuration register.\r
830\r
831 Writes Value to the bit field of the PCI configuration register. The bit\r
832 field is specified by the StartBit and the EndBit. All other bits in the\r
833 destination PCI configuration register are preserved. The new value of the\r
834 32-bit register is returned.\r
835\r
836 If any reserved bits in Address are set, then ASSERT().\r
837 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
838 If StartBit is greater than 31, then ASSERT().\r
839 If EndBit is greater than 31, then ASSERT().\r
840 If EndBit is less than StartBit, then ASSERT().\r
841 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
842\r
843 @param Address PCI configuration register to write.\r
844 @param StartBit The ordinal of the least significant bit in the bit field.\r
845 Range 0..31.\r
846 @param EndBit The ordinal of the most significant bit in the bit field.\r
847 Range 0..31.\r
848 @param Value New value of the bit field.\r
849\r
850 @return The value written back to the PCI configuration register.\r
851\r
852**/\r
853UINT32\r
854EFIAPI\r
855PciSegmentBitFieldWrite32 (\r
856 IN UINT64 Address,\r
857 IN UINTN StartBit,\r
858 IN UINTN EndBit,\r
859 IN UINT32 Value\r
860 );\r
861\r
862/**\r
863 Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r
864 writes the result back to the bit field in the 32-bit port.\r
865\r
866 Reads the 32-bit PCI configuration register specified by Address, performs a\r
867 bitwise OR between the read result and the value specified by\r
868 OrData, and writes the result to the 32-bit PCI configuration register\r
869 specified by Address. The value written to the PCI configuration register is\r
870 returned. This function must guarantee that all PCI read and write operations\r
871 are serialized. Extra left bits in OrData are stripped.\r
872\r
873 If any reserved bits in Address are set, then ASSERT().\r
874 If StartBit is greater than 31, then ASSERT().\r
875 If EndBit is greater than 31, then ASSERT().\r
876 If EndBit is less than StartBit, then ASSERT().\r
877 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
878\r
879 @param Address PCI configuration register to write.\r
880 @param StartBit The ordinal of the least significant bit in the bit field.\r
881 Range 0..31.\r
882 @param EndBit The ordinal of the most significant bit in the bit field.\r
883 Range 0..31.\r
884 @param OrData The value to OR with the PCI configuration register.\r
885\r
886 @return The value written back to the PCI configuration register.\r
887\r
888**/\r
889UINT32\r
890EFIAPI\r
891PciSegmentBitFieldOr32 (\r
892 IN UINT64 Address,\r
893 IN UINTN StartBit,\r
894 IN UINTN EndBit,\r
895 IN UINT32 OrData\r
896 );\r
897\r
898/**\r
899 Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r
900 AND, and writes the result back to the bit field in the 32-bit register.\r
901\r
902 \r
903 Reads the 32-bit PCI configuration register specified by Address, performs a bitwise\r
904 AND between the read result and the value specified by AndData, and writes the result\r
905 to the 32-bit PCI configuration register specified by Address. The value written to\r
906 the PCI configuration register is returned. This function must guarantee that all PCI\r
907 read and write operations are serialized. Extra left bits in AndData are stripped.\r
908 If any reserved bits in Address are set, then ASSERT().\r
909 If Address is not aligned on a 32-bit boundary, then ASSERT().\r
910 If StartBit is greater than 31, then ASSERT().\r
911 If EndBit is greater than 31, then ASSERT().\r
912 If EndBit is less than StartBit, then ASSERT().\r
913 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
914\r
915 @param Address PCI configuration register to write.\r
916 @param StartBit The ordinal of the least significant bit in the bit field.\r
917 Range 0..31.\r
918 @param EndBit The ordinal of the most significant bit in the bit field.\r
919 Range 0..31.\r
920 @param AndData The value to AND with the PCI configuration register.\r
921\r
922 @return The value written back to the PCI configuration register.\r
923\r
924**/\r
925UINT32\r
926EFIAPI\r
927PciSegmentBitFieldAnd32 (\r
928 IN UINT64 Address,\r
929 IN UINTN StartBit,\r
930 IN UINTN EndBit,\r
931 IN UINT32 AndData\r
932 );\r
933\r
934/**\r
935 Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r
936 bitwise OR, and writes the result back to the bit field in the\r
937 32-bit port.\r
938\r
939 Reads the 32-bit PCI configuration register specified by Address, performs a\r
940 bitwise AND followed by a bitwise OR between the read result and\r
941 the value specified by AndData, and writes the result to the 32-bit PCI\r
942 configuration register specified by Address. The value written to the PCI\r
943 configuration register is returned. This function must guarantee that all PCI\r
944 read and write operations are serialized. Extra left bits in both AndData and\r
945 OrData are stripped.\r
946\r
947 If any reserved bits in Address are set, then ASSERT().\r
948 If StartBit is greater than 31, then ASSERT().\r
949 If EndBit is greater than 31, then ASSERT().\r
950 If EndBit is less than StartBit, then ASSERT().\r
951 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
952 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
953\r
954 @param Address PCI configuration register to write.\r
955 @param StartBit The ordinal of the least significant bit in the bit field.\r
956 Range 0..31.\r
957 @param EndBit The ordinal of the most significant bit in the bit field.\r
958 Range 0..31.\r
959 @param AndData The value to AND with the PCI configuration register.\r
960 @param OrData The value to OR with the result of the AND operation.\r
961\r
962 @return The value written back to the PCI configuration register.\r
963\r
964**/\r
965UINT32\r
966EFIAPI\r
967PciSegmentBitFieldAndThenOr32 (\r
968 IN UINT64 Address,\r
969 IN UINTN StartBit,\r
970 IN UINTN EndBit,\r
971 IN UINT32 AndData,\r
972 IN UINT32 OrData\r
973 );\r
974\r
975/**\r
976 Reads a range of PCI configuration registers into a caller supplied buffer.\r
977\r
978 Reads the range of PCI configuration registers specified by StartAddress and\r
979 Size into the buffer specified by Buffer. This function only allows the PCI\r
980 configuration registers from a single PCI function to be read. Size is\r
981 returned. When possible 32-bit PCI configuration read cycles are used to read\r
982 from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit\r
983 and 16-bit PCI configuration read cycles may be used at the beginning and the\r
984 end of the range.\r
985\r
986 If any reserved bits in StartAddress are set, then ASSERT().\r
987 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
988 If Size > 0 and Buffer is NULL, then ASSERT().\r
989\r
990 @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r
991 Function and Register.\r
992 @param Size Size in bytes of the transfer.\r
993 @param Buffer Pointer to a buffer receiving the data read.\r
994\r
995 @return Size\r
996\r
997**/\r
998UINTN\r
999EFIAPI\r
1000PciSegmentReadBuffer (\r
1001 IN UINT64 StartAddress,\r
1002 IN UINTN Size,\r
1003 OUT VOID *Buffer\r
1004 );\r
1005\r
1006/**\r
1007 Copies the data in a caller supplied buffer to a specified range of PCI\r
1008 configuration space.\r
1009\r
1010 Writes the range of PCI configuration registers specified by StartAddress and\r
1011 Size from the buffer specified by Buffer. This function only allows the PCI\r
1012 configuration registers from a single PCI function to be written. Size is\r
1013 returned. When possible 32-bit PCI configuration write cycles are used to\r
1014 write from StartAdress to StartAddress + Size. Due to alignment restrictions,\r
1015 8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r
1016 and the end of the range.\r
1017\r
1018 If any reserved bits in StartAddress are set, then ASSERT().\r
1019 If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r
1020 If Size > 0 and Buffer is NULL, then ASSERT().\r
1021\r
1022 @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r
1023 Function and Register.\r
1024 @param Size Size in bytes of the transfer.\r
1025 @param Buffer Pointer to a buffer containing the data to write.\r
1026\r
1027 @return The parameter of Size.\r
1028\r
1029**/\r
1030UINTN\r
1031EFIAPI\r
1032PciSegmentWriteBuffer (\r
1033 IN UINT64 StartAddress,\r
1034 IN UINTN Size,\r
1035 IN VOID *Buffer\r
1036 );\r
1037\r
1038#endif\r