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