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