]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
50a64e5b | 2 | Provides services to access PCI Configuration Space on a platform with multiple PCI segments.\r |
9095d37b | 3 | \r |
badcbfb2 | 4 | The PCI Segment Library function provide services to read, write, and modify the PCI configuration\r |
9095d37b LG |
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 | |
badcbfb2 | 7 | The layout of this address parameter is as follows:\r |
9095d37b | 8 | \r |
40731047 | 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 | |
9095d37b | 16 | \r |
badcbfb2 | 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 | |
9095d37b LG |
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 | |
fb3df220 | 25 | \r |
9095d37b | 26 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 27 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
fb3df220 | 28 | \r |
fb3df220 | 29 | **/\r |
30 | \r | |
31 | #ifndef __PCI_SEGMENT_LIB__\r | |
32 | #define __PCI_SEGMENT_LIB__\r | |
33 | \r | |
fb3df220 | 34 | /**\r |
35 | Macro that converts PCI Segment, PCI Bus, PCI Device, PCI Function,\r | |
36 | and PCI Register to an address that can be passed to the PCI Segment Library functions.\r | |
37 | \r | |
38 | Computes an address that is compatible with the PCI Segment Library functions.\r | |
39 | The unused upper bits of Segment, Bus, Device, Function,\r | |
40 | and Register are stripped prior to the generation of the address.\r | |
41 | \r | |
42 | @param Segment PCI Segment number. Range 0..65535.\r | |
43 | @param Bus PCI Bus number. Range 0..255.\r | |
44 | @param Device PCI Device number. Range 0..31.\r | |
45 | @param Function PCI Function number. Range 0..7.\r | |
46 | @param Register PCI Register number. Range 0..255 for PCI. Range 0..4095 for PCI Express.\r | |
47 | \r | |
48 | @return The address that is compatible with the PCI Segment Library functions.\r | |
49 | \r | |
50 | **/\r | |
2f88bd3a | 51 | #define PCI_SEGMENT_LIB_ADDRESS(Segment, Bus, Device, Function, Register) \\r |
2b27b557 MK |
52 | ((Segment != 0) ? \\r |
53 | ( ((Register) & 0xfff) | \\r | |
54 | (((Function) & 0x07) << 12) | \\r | |
55 | (((Device) & 0x1f) << 15) | \\r | |
56 | (((Bus) & 0xff) << 20) | \\r | |
57 | (LShiftU64 ((Segment) & 0xffff, 32)) \\r | |
58 | ) : \\r | |
59 | ( ((Register) & 0xfff) | \\r | |
60 | (((Function) & 0x07) << 12) | \\r | |
61 | (((Device) & 0x1f) << 15) | \\r | |
62 | (((Bus) & 0xff) << 20) \\r | |
63 | ) \\r | |
fb3df220 | 64 | )\r |
65 | \r | |
f926e538 | 66 | /**\r |
9095d37b | 67 | Register a PCI device so PCI configuration registers may be accessed after\r |
f926e538 | 68 | SetVirtualAddressMap().\r |
9095d37b | 69 | \r |
59ceeabe | 70 | If any reserved bits in Address are set, then ASSERT().\r |
f926e538 | 71 | \r |
72 | @param Address Address that encodes the PCI Bus, Device, Function and\r | |
73 | Register.\r | |
9095d37b | 74 | \r |
f926e538 | 75 | @retval RETURN_SUCCESS The PCI device was registered for runtime access.\r |
9095d37b | 76 | @retval RETURN_UNSUPPORTED An attempt was made to call this function\r |
f926e538 | 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 | |
84 | RETURN_STATUS\r | |
85 | EFIAPI\r | |
86 | PciSegmentRegisterForRuntimeAccess (\r | |
87 | IN UINTN Address\r | |
88 | );\r | |
89 | \r | |
fb3df220 | 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 | |
ebdde8ff | 95 | \r |
fb3df220 | 96 | If any reserved bits in Address are set, then ASSERT().\r |
ebdde8ff | 97 | \r |
fb3df220 | 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 | |
103 | UINT8\r | |
104 | EFIAPI\r | |
105 | PciSegmentRead8 (\r | |
2f88bd3a | 106 | IN UINT64 Address\r |
ed66e1bc | 107 | );\r |
fb3df220 | 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 | |
ebdde8ff | 114 | \r |
59ceeabe | 115 | If any reserved bits in Address are set, then ASSERT().\r |
fb3df220 | 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 | |
d5979dc0 | 120 | @return The value written to the PCI configuration register.\r |
fb3df220 | 121 | \r |
122 | **/\r | |
123 | UINT8\r | |
124 | EFIAPI\r | |
125 | PciSegmentWrite8 (\r | |
2f88bd3a MK |
126 | IN UINT64 Address,\r |
127 | IN UINT8 Value\r | |
ed66e1bc | 128 | );\r |
fb3df220 | 129 | \r |
130 | /**\r | |
62991af2 | 131 | Performs a bitwise OR of an 8-bit PCI configuration register with an 8-bit value.\r |
fb3df220 | 132 | \r |
133 | Reads the 8-bit PCI configuration register specified by Address,\r | |
62991af2 | 134 | performs a bitwise OR between the read result and the value specified by OrData,\r |
fb3df220 | 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 | |
ebdde8ff | 138 | \r |
fb3df220 | 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 | |
147 | UINT8\r | |
148 | EFIAPI\r | |
149 | PciSegmentOr8 (\r | |
2f88bd3a MK |
150 | IN UINT64 Address,\r |
151 | IN UINT8 OrData\r | |
ed66e1bc | 152 | );\r |
fb3df220 | 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 | |
7d9333a9 | 165 | @param AndData The value to AND with the PCI configuration register.\r |
fb3df220 | 166 | \r |
167 | @return The value written to the PCI configuration register.\r | |
168 | \r | |
169 | **/\r | |
170 | UINT8\r | |
171 | EFIAPI\r | |
172 | PciSegmentAnd8 (\r | |
2f88bd3a MK |
173 | IN UINT64 Address,\r |
174 | IN UINT8 AndData\r | |
ed66e1bc | 175 | );\r |
fb3df220 | 176 | \r |
177 | /**\r | |
178 | Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit value,\r | |
62991af2 | 179 | followed a bitwise OR with another 8-bit value.\r |
ebdde8ff | 180 | \r |
fb3df220 | 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 | |
62991af2 | 183 | performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r |
fb3df220 | 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 | |
ebdde8ff | 187 | \r |
fb3df220 | 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 | |
ebdde8ff | 191 | @param AndData The value to AND with the PCI configuration register.\r |
fb3df220 | 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 | |
197 | UINT8\r | |
198 | EFIAPI\r | |
199 | PciSegmentAndThenOr8 (\r | |
2f88bd3a MK |
200 | IN UINT64 Address,\r |
201 | IN UINT8 AndData,\r | |
202 | IN UINT8 OrData\r | |
ed66e1bc | 203 | );\r |
fb3df220 | 204 | \r |
205 | /**\r | |
206 | Reads a bit field of a PCI configuration register.\r | |
207 | \r | |
d5979dc0 | 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 | |
fb3df220 | 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 | |
d5979dc0 | 217 | @param Address PCI configuration register to read.\r |
fb3df220 | 218 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 219 | Range 0..7.\r |
fb3df220 | 220 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 221 | Range 0..7.\r |
fb3df220 | 222 | \r |
d5979dc0 | 223 | @return The value of the bit field read from the PCI configuration register.\r |
fb3df220 | 224 | \r |
225 | **/\r | |
226 | UINT8\r | |
227 | EFIAPI\r | |
228 | PciSegmentBitFieldRead8 (\r | |
2f88bd3a MK |
229 | IN UINT64 Address,\r |
230 | IN UINTN StartBit,\r | |
231 | IN UINTN EndBit\r | |
ed66e1bc | 232 | );\r |
fb3df220 | 233 | \r |
234 | /**\r | |
235 | Writes a bit field to a PCI configuration register.\r | |
236 | \r | |
d5979dc0 | 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 | |
fb3df220 | 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 | |
94952554 | 246 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fb3df220 | 247 | \r |
d5979dc0 | 248 | @param Address PCI configuration register to write.\r |
fb3df220 | 249 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 250 | Range 0..7.\r |
fb3df220 | 251 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 252 | Range 0..7.\r |
fb3df220 | 253 | @param Value New value of the bit field.\r |
254 | \r | |
d5979dc0 | 255 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 256 | \r |
257 | **/\r | |
258 | UINT8\r | |
259 | EFIAPI\r | |
260 | PciSegmentBitFieldWrite8 (\r | |
2f88bd3a MK |
261 | IN UINT64 Address,\r |
262 | IN UINTN StartBit,\r | |
263 | IN UINTN EndBit,\r | |
264 | IN UINT8 Value\r | |
ed66e1bc | 265 | );\r |
fb3df220 | 266 | \r |
267 | /**\r | |
d5979dc0 | 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 | |
62991af2 | 272 | bitwise OR between the read result and the value specified by\r |
d5979dc0 | 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 | |
badcbfb2 | 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 | |
94952554 | 282 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fb3df220 | 283 | \r |
d5979dc0 | 284 | @param Address PCI configuration register to write.\r |
fb3df220 | 285 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 286 | Range 0..7.\r |
fb3df220 | 287 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 288 | Range 0..7.\r |
289 | @param OrData The value to OR with the PCI configuration register.\r | |
fb3df220 | 290 | \r |
d5979dc0 | 291 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 292 | \r |
293 | **/\r | |
294 | UINT8\r | |
295 | EFIAPI\r | |
296 | PciSegmentBitFieldOr8 (\r | |
2f88bd3a MK |
297 | IN UINT64 Address,\r |
298 | IN UINTN StartBit,\r | |
299 | IN UINTN EndBit,\r | |
300 | IN UINT8 OrData\r | |
ed66e1bc | 301 | );\r |
fb3df220 | 302 | \r |
303 | /**\r | |
d5979dc0 | 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 | |
fb3df220 | 313 | \r |
fb3df220 | 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 | |
94952554 | 318 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fb3df220 | 319 | \r |
d5979dc0 | 320 | @param Address PCI configuration register to write.\r |
fb3df220 | 321 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 322 | Range 0..7.\r |
fb3df220 | 323 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 324 | Range 0..7.\r |
325 | @param AndData The value to AND with the PCI configuration register.\r | |
fb3df220 | 326 | \r |
d5979dc0 | 327 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 328 | \r |
329 | **/\r | |
330 | UINT8\r | |
331 | EFIAPI\r | |
332 | PciSegmentBitFieldAnd8 (\r | |
2f88bd3a MK |
333 | IN UINT64 Address,\r |
334 | IN UINTN StartBit,\r | |
335 | IN UINTN EndBit,\r | |
336 | IN UINT8 AndData\r | |
ed66e1bc | 337 | );\r |
fb3df220 | 338 | \r |
339 | /**\r | |
d5979dc0 | 340 | Reads a bit field in an 8-bit port, performs a bitwise AND followed by a\r |
ebdde8ff | 341 | bitwise OR, and writes the result back to the bit field in the 8-bit port.\r |
d5979dc0 | 342 | \r |
343 | Reads the 8-bit PCI configuration register specified by Address, performs a\r | |
62991af2 | 344 | bitwise AND followed by a bitwise OR between the read result and\r |
d5979dc0 | 345 | the value specified by AndData, and writes the result to the 8-bit PCI\r |
346 | configuration register specified by Address. The value written to the PCI\r | |
347 | configuration register is returned. This function must guarantee that all PCI\r | |
348 | read and write operations are serialized. Extra left bits in both AndData and\r | |
349 | OrData are stripped.\r | |
350 | \r | |
fb3df220 | 351 | If any reserved bits in Address are set, then ASSERT().\r |
352 | If StartBit is greater than 7, then ASSERT().\r | |
353 | If EndBit is greater than 7, then ASSERT().\r | |
354 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
355 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
356 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fb3df220 | 357 | \r |
d5979dc0 | 358 | @param Address PCI configuration register to write.\r |
fb3df220 | 359 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 360 | Range 0..7.\r |
fb3df220 | 361 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 362 | Range 0..7.\r |
363 | @param AndData The value to AND with the PCI configuration register.\r | |
364 | @param OrData The value to OR with the result of the AND operation.\r | |
fb3df220 | 365 | \r |
d5979dc0 | 366 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 367 | \r |
368 | **/\r | |
369 | UINT8\r | |
370 | EFIAPI\r | |
371 | PciSegmentBitFieldAndThenOr8 (\r | |
2f88bd3a MK |
372 | IN UINT64 Address,\r |
373 | IN UINTN StartBit,\r | |
374 | IN UINTN EndBit,\r | |
375 | IN UINT8 AndData,\r | |
376 | IN UINT8 OrData\r | |
ed66e1bc | 377 | );\r |
fb3df220 | 378 | \r |
379 | /**\r | |
380 | Reads a 16-bit PCI configuration register.\r | |
381 | \r | |
382 | Reads and returns the 16-bit PCI configuration register specified by Address.\r | |
383 | This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 384 | \r |
fb3df220 | 385 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 386 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r |
ebdde8ff | 387 | \r |
fb3df220 | 388 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r |
389 | \r | |
390 | @return The 16-bit PCI configuration register specified by Address.\r | |
391 | \r | |
392 | **/\r | |
393 | UINT16\r | |
394 | EFIAPI\r | |
395 | PciSegmentRead16 (\r | |
2f88bd3a | 396 | IN UINT64 Address\r |
ed66e1bc | 397 | );\r |
fb3df220 | 398 | \r |
399 | /**\r | |
400 | Writes a 16-bit PCI configuration register.\r | |
401 | \r | |
402 | Writes the 16-bit PCI configuration register specified by Address with the value specified by Value.\r | |
403 | Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 404 | \r |
badcbfb2 | 405 | If any reserved bits in Address are set, then ASSERT().\r |
406 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
fb3df220 | 407 | \r |
408 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
409 | @param Value The value to write.\r | |
410 | \r | |
411 | @return The parameter of Value.\r | |
412 | \r | |
413 | **/\r | |
414 | UINT16\r | |
415 | EFIAPI\r | |
416 | PciSegmentWrite16 (\r | |
2f88bd3a MK |
417 | IN UINT64 Address,\r |
418 | IN UINT16 Value\r | |
ed66e1bc | 419 | );\r |
fb3df220 | 420 | \r |
421 | /**\r | |
62991af2 | 422 | Performs a bitwise OR of a 16-bit PCI configuration register with\r |
d5979dc0 | 423 | a 16-bit value.\r |
424 | \r | |
425 | Reads the 16-bit PCI configuration register specified by Address, performs a\r | |
ebdde8ff RN |
426 | bitwise OR between the read result and the value specified by OrData, and\r |
427 | writes the result to the 16-bit PCI configuration register specified by Address.\r | |
428 | The value written to the PCI configuration register is returned. This function\r | |
429 | must guarantee that all PCI read and write operations are serialized.\r | |
fb3df220 | 430 | \r |
fb3df220 | 431 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 432 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r |
fb3df220 | 433 | \r |
d5979dc0 | 434 | @param Address Address that encodes the PCI Segment, Bus, Device, Function and\r |
435 | Register.\r | |
436 | @param OrData The value to OR with the PCI configuration register.\r | |
fb3df220 | 437 | \r |
d5979dc0 | 438 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 439 | \r |
440 | **/\r | |
441 | UINT16\r | |
442 | EFIAPI\r | |
443 | PciSegmentOr16 (\r | |
2f88bd3a MK |
444 | IN UINT64 Address,\r |
445 | IN UINT16 OrData\r | |
ed66e1bc | 446 | );\r |
fb3df220 | 447 | \r |
448 | /**\r | |
449 | Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value.\r | |
450 | \r | |
451 | Reads the 16-bit PCI configuration register specified by Address,\r | |
452 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
453 | and writes the result to the 16-bit PCI configuration register specified by Address.\r | |
454 | The value written to the PCI configuration register is returned.\r | |
455 | This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 456 | \r |
fb3df220 | 457 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 458 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r |
ebdde8ff | 459 | \r |
fb3df220 | 460 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r |
7d9333a9 | 461 | @param AndData The value to AND with the PCI configuration register.\r |
fb3df220 | 462 | \r |
463 | @return The value written to the PCI configuration register.\r | |
464 | \r | |
465 | **/\r | |
466 | UINT16\r | |
467 | EFIAPI\r | |
468 | PciSegmentAnd16 (\r | |
2f88bd3a MK |
469 | IN UINT64 Address,\r |
470 | IN UINT16 AndData\r | |
ed66e1bc | 471 | );\r |
fb3df220 | 472 | \r |
473 | /**\r | |
474 | Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit value,\r | |
62991af2 | 475 | followed a bitwise OR with another 16-bit value.\r |
ebdde8ff | 476 | \r |
fb3df220 | 477 | Reads the 16-bit PCI configuration register specified by Address,\r |
478 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
62991af2 | 479 | performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r |
fb3df220 | 480 | and writes the result to the 16-bit PCI configuration register specified by Address.\r |
481 | The value written to the PCI configuration register is returned.\r | |
482 | This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 483 | \r |
fb3df220 | 484 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 485 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r |
fb3df220 | 486 | \r |
487 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
ebdde8ff | 488 | @param AndData The value to AND with the PCI configuration register.\r |
fb3df220 | 489 | @param OrData The value to OR with the PCI configuration register.\r |
490 | \r | |
491 | @return The value written to the PCI configuration register.\r | |
492 | \r | |
493 | **/\r | |
494 | UINT16\r | |
495 | EFIAPI\r | |
496 | PciSegmentAndThenOr16 (\r | |
2f88bd3a MK |
497 | IN UINT64 Address,\r |
498 | IN UINT16 AndData,\r | |
499 | IN UINT16 OrData\r | |
ed66e1bc | 500 | );\r |
fb3df220 | 501 | \r |
502 | /**\r | |
503 | Reads a bit field of a PCI configuration register.\r | |
504 | \r | |
d5979dc0 | 505 | Reads the bit field in a 16-bit PCI configuration register. The bit field is\r |
506 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
507 | returned.\r | |
508 | \r | |
fb3df220 | 509 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 510 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r |
d5979dc0 | 511 | If StartBit is greater than 15, then ASSERT().\r |
512 | If EndBit is greater than 15, then ASSERT().\r | |
fb3df220 | 513 | If EndBit is less than StartBit, then ASSERT().\r |
514 | \r | |
d5979dc0 | 515 | @param Address PCI configuration register to read.\r |
fb3df220 | 516 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 517 | Range 0..15.\r |
fb3df220 | 518 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 519 | Range 0..15.\r |
fb3df220 | 520 | \r |
d5979dc0 | 521 | @return The value of the bit field read from the PCI configuration register.\r |
fb3df220 | 522 | \r |
523 | **/\r | |
524 | UINT16\r | |
525 | EFIAPI\r | |
526 | PciSegmentBitFieldRead16 (\r | |
2f88bd3a MK |
527 | IN UINT64 Address,\r |
528 | IN UINTN StartBit,\r | |
529 | IN UINTN EndBit\r | |
ed66e1bc | 530 | );\r |
fb3df220 | 531 | \r |
532 | /**\r | |
533 | Writes a bit field to a PCI configuration register.\r | |
534 | \r | |
d5979dc0 | 535 | Writes Value to the bit field of the PCI configuration register. The bit\r |
536 | field is specified by the StartBit and the EndBit. All other bits in the\r | |
537 | destination PCI configuration register are preserved. The new value of the\r | |
538 | 16-bit register is returned.\r | |
539 | \r | |
fb3df220 | 540 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 541 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r |
d5979dc0 | 542 | If StartBit is greater than 15, then ASSERT().\r |
543 | If EndBit is greater than 15, then ASSERT().\r | |
fb3df220 | 544 | If EndBit is less than StartBit, then ASSERT().\r |
94952554 | 545 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fb3df220 | 546 | \r |
d5979dc0 | 547 | @param Address PCI configuration register to write.\r |
fb3df220 | 548 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 549 | Range 0..15.\r |
fb3df220 | 550 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 551 | Range 0..15.\r |
fb3df220 | 552 | @param Value New value of the bit field.\r |
553 | \r | |
d5979dc0 | 554 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 555 | \r |
556 | **/\r | |
557 | UINT16\r | |
558 | EFIAPI\r | |
559 | PciSegmentBitFieldWrite16 (\r | |
2f88bd3a MK |
560 | IN UINT64 Address,\r |
561 | IN UINTN StartBit,\r | |
562 | IN UINTN EndBit,\r | |
563 | IN UINT16 Value\r | |
ed66e1bc | 564 | );\r |
fb3df220 | 565 | \r |
566 | /**\r | |
ebdde8ff RN |
567 | Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, writes\r |
568 | the result back to the bit field in the 16-bit port.\r | |
569 | \r | |
570 | Reads the 16-bit PCI configuration register specified by Address, performs a\r | |
571 | bitwise OR between the read result and the value specified by\r | |
572 | OrData, and writes the result to the 16-bit PCI configuration register\r | |
573 | specified by Address. The value written to the PCI configuration register is\r | |
574 | returned. This function must guarantee that all PCI read and write operations\r | |
575 | are serialized. Extra left bits in OrData are stripped.\r | |
fb3df220 | 576 | \r |
badcbfb2 | 577 | If any reserved bits in Address are set, then ASSERT().\r |
578 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r | |
579 | If StartBit is greater than 15, then ASSERT().\r | |
580 | If EndBit is greater than 15, then ASSERT().\r | |
581 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 582 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
badcbfb2 | 583 | \r |
d5979dc0 | 584 | @param Address PCI configuration register to write.\r |
fb3df220 | 585 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 586 | Range 0..15.\r |
fb3df220 | 587 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 588 | Range 0..15.\r |
589 | @param OrData The value to OR with the PCI configuration register.\r | |
fb3df220 | 590 | \r |
d5979dc0 | 591 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 592 | \r |
593 | **/\r | |
594 | UINT16\r | |
595 | EFIAPI\r | |
596 | PciSegmentBitFieldOr16 (\r | |
2f88bd3a MK |
597 | IN UINT64 Address,\r |
598 | IN UINTN StartBit,\r | |
599 | IN UINTN EndBit,\r | |
600 | IN UINT16 OrData\r | |
ed66e1bc | 601 | );\r |
fb3df220 | 602 | \r |
603 | /**\r | |
ebdde8ff RN |
604 | Reads a bit field in a 16-bit PCI configuration register, performs a bitwise\r |
605 | AND, writes the result back to the bit field in the 16-bit register.\r | |
606 | \r | |
607 | Reads the 16-bit PCI configuration register specified by Address, performs a\r | |
608 | bitwise AND between the read result and the value specified by AndData, and\r | |
609 | writes the result to the 16-bit PCI configuration register specified by\r | |
610 | Address. The value written to the PCI configuration register is returned.\r | |
611 | This function must guarantee that all PCI read and write operations are\r | |
612 | serialized. Extra left bits in AndData are stripped.\r | |
fb3df220 | 613 | \r |
fb3df220 | 614 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 615 | If Address is not aligned on a 16-bit boundary, then ASSERT().\r |
ebdde8ff RN |
616 | If StartBit is greater than 15, then ASSERT().\r |
617 | If EndBit is greater than 15, then ASSERT().\r | |
fb3df220 | 618 | If EndBit is less than StartBit, then ASSERT().\r |
94952554 | 619 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fb3df220 | 620 | \r |
621 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
622 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
ebdde8ff | 623 | Range 0..15.\r |
fb3df220 | 624 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
ebdde8ff RN |
625 | Range 0..15.\r |
626 | @param AndData The value to AND with the PCI configuration register.\r | |
fb3df220 | 627 | \r |
ebdde8ff | 628 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 629 | \r |
630 | **/\r | |
631 | UINT16\r | |
632 | EFIAPI\r | |
633 | PciSegmentBitFieldAnd16 (\r | |
2f88bd3a MK |
634 | IN UINT64 Address,\r |
635 | IN UINTN StartBit,\r | |
636 | IN UINTN EndBit,\r | |
637 | IN UINT16 AndData\r | |
ed66e1bc | 638 | );\r |
fb3df220 | 639 | \r |
640 | /**\r | |
d5979dc0 | 641 | Reads a bit field in a 16-bit port, performs a bitwise AND followed by a\r |
62991af2 | 642 | bitwise OR, and writes the result back to the bit field in the\r |
d5979dc0 | 643 | 16-bit port.\r |
644 | \r | |
645 | Reads the 16-bit PCI configuration register specified by Address, performs a\r | |
62991af2 | 646 | bitwise AND followed by a bitwise OR between the read result and\r |
d5979dc0 | 647 | the value specified by AndData, and writes the result to the 16-bit PCI\r |
648 | configuration register specified by Address. The value written to the PCI\r | |
649 | configuration register is returned. This function must guarantee that all PCI\r | |
650 | read and write operations are serialized. Extra left bits in both AndData and\r | |
651 | OrData are stripped.\r | |
652 | \r | |
fb3df220 | 653 | If any reserved bits in Address are set, then ASSERT().\r |
d5979dc0 | 654 | If StartBit is greater than 15, then ASSERT().\r |
655 | If EndBit is greater than 15, then ASSERT().\r | |
fb3df220 | 656 | If EndBit is less than StartBit, then ASSERT().\r |
94952554 LG |
657 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
658 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fb3df220 | 659 | \r |
d5979dc0 | 660 | @param Address PCI configuration register to write.\r |
fb3df220 | 661 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 662 | Range 0..15.\r |
fb3df220 | 663 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 664 | Range 0..15.\r |
665 | @param AndData The value to AND with the PCI configuration register.\r | |
666 | @param OrData The value to OR with the result of the AND operation.\r | |
fb3df220 | 667 | \r |
d5979dc0 | 668 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 669 | \r |
670 | **/\r | |
671 | UINT16\r | |
672 | EFIAPI\r | |
673 | PciSegmentBitFieldAndThenOr16 (\r | |
2f88bd3a MK |
674 | IN UINT64 Address,\r |
675 | IN UINTN StartBit,\r | |
676 | IN UINTN EndBit,\r | |
677 | IN UINT16 AndData,\r | |
678 | IN UINT16 OrData\r | |
ed66e1bc | 679 | );\r |
fb3df220 | 680 | \r |
681 | /**\r | |
682 | Reads a 32-bit PCI configuration register.\r | |
683 | \r | |
684 | Reads and returns the 32-bit PCI configuration register specified by Address.\r | |
685 | This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 686 | \r |
badcbfb2 | 687 | If any reserved bits in Address are set, then ASSERT().\r |
688 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
689 | \r | |
fb3df220 | 690 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r |
691 | \r | |
692 | @return The 32-bit PCI configuration register specified by Address.\r | |
693 | \r | |
694 | **/\r | |
695 | UINT32\r | |
696 | EFIAPI\r | |
697 | PciSegmentRead32 (\r | |
2f88bd3a | 698 | IN UINT64 Address\r |
ed66e1bc | 699 | );\r |
fb3df220 | 700 | \r |
701 | /**\r | |
702 | Writes a 32-bit PCI configuration register.\r | |
703 | \r | |
704 | Writes the 32-bit PCI configuration register specified by Address with the value specified by Value.\r | |
705 | Value is returned. This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 706 | \r |
badcbfb2 | 707 | If any reserved bits in Address are set, then ASSERT().\r |
708 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r | |
fb3df220 | 709 | \r |
710 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
711 | @param Value The value to write.\r | |
712 | \r | |
713 | @return The parameter of Value.\r | |
714 | \r | |
715 | **/\r | |
716 | UINT32\r | |
717 | EFIAPI\r | |
718 | PciSegmentWrite32 (\r | |
2f88bd3a MK |
719 | IN UINT64 Address,\r |
720 | IN UINT32 Value\r | |
ed66e1bc | 721 | );\r |
fb3df220 | 722 | \r |
723 | /**\r | |
62991af2 | 724 | Performs a bitwise OR of a 32-bit PCI configuration register with a 32-bit value.\r |
fb3df220 | 725 | \r |
726 | Reads the 32-bit PCI configuration register specified by Address,\r | |
62991af2 | 727 | performs a bitwise OR between the read result and the value specified by OrData,\r |
fb3df220 | 728 | and writes the result to the 32-bit PCI configuration register specified by Address.\r |
729 | The value written to the PCI configuration register is returned.\r | |
730 | This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 731 | \r |
fb3df220 | 732 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 733 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r |
fb3df220 | 734 | \r |
735 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
736 | @param OrData The value to OR with the PCI configuration register.\r | |
737 | \r | |
738 | @return The value written to the PCI configuration register.\r | |
739 | \r | |
740 | **/\r | |
741 | UINT32\r | |
742 | EFIAPI\r | |
743 | PciSegmentOr32 (\r | |
2f88bd3a MK |
744 | IN UINT64 Address,\r |
745 | IN UINT32 OrData\r | |
ed66e1bc | 746 | );\r |
fb3df220 | 747 | \r |
748 | /**\r | |
749 | Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value.\r | |
750 | \r | |
751 | Reads the 32-bit PCI configuration register specified by Address,\r | |
752 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
753 | and writes the result to the 32-bit PCI configuration register specified by Address.\r | |
754 | The value written to the PCI configuration register is returned.\r | |
755 | This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 756 | \r |
fb3df220 | 757 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 758 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r |
fb3df220 | 759 | \r |
760 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
7d9333a9 | 761 | @param AndData The value to AND with the PCI configuration register.\r |
fb3df220 | 762 | \r |
763 | @return The value written to the PCI configuration register.\r | |
764 | \r | |
765 | **/\r | |
766 | UINT32\r | |
767 | EFIAPI\r | |
768 | PciSegmentAnd32 (\r | |
2f88bd3a MK |
769 | IN UINT64 Address,\r |
770 | IN UINT32 AndData\r | |
ed66e1bc | 771 | );\r |
fb3df220 | 772 | \r |
773 | /**\r | |
774 | Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit value,\r | |
62991af2 | 775 | followed a bitwise OR with another 32-bit value.\r |
ebdde8ff | 776 | \r |
fb3df220 | 777 | Reads the 32-bit PCI configuration register specified by Address,\r |
778 | performs a bitwise AND between the read result and the value specified by AndData,\r | |
62991af2 | 779 | performs a bitwise OR between the result of the AND operation and the value specified by OrData,\r |
fb3df220 | 780 | and writes the result to the 32-bit PCI configuration register specified by Address.\r |
781 | The value written to the PCI configuration register is returned.\r | |
782 | This function must guarantee that all PCI read and write operations are serialized.\r | |
ebdde8ff | 783 | \r |
fb3df220 | 784 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 785 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r |
fb3df220 | 786 | \r |
787 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r | |
7d9333a9 | 788 | @param AndData The value to AND with the PCI configuration register.\r |
fb3df220 | 789 | @param OrData The value to OR with the PCI configuration register.\r |
790 | \r | |
791 | @return The value written to the PCI configuration register.\r | |
792 | \r | |
793 | **/\r | |
794 | UINT32\r | |
795 | EFIAPI\r | |
796 | PciSegmentAndThenOr32 (\r | |
2f88bd3a MK |
797 | IN UINT64 Address,\r |
798 | IN UINT32 AndData,\r | |
799 | IN UINT32 OrData\r | |
ed66e1bc | 800 | );\r |
fb3df220 | 801 | \r |
802 | /**\r | |
803 | Reads a bit field of a PCI configuration register.\r | |
804 | \r | |
d5979dc0 | 805 | Reads the bit field in a 32-bit PCI configuration register. The bit field is\r |
806 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
807 | returned.\r | |
808 | \r | |
fb3df220 | 809 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 810 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r |
d5979dc0 | 811 | If StartBit is greater than 31, then ASSERT().\r |
812 | If EndBit is greater than 31, then ASSERT().\r | |
fb3df220 | 813 | If EndBit is less than StartBit, then ASSERT().\r |
814 | \r | |
d5979dc0 | 815 | @param Address PCI configuration register to read.\r |
fb3df220 | 816 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 817 | Range 0..31.\r |
fb3df220 | 818 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 819 | Range 0..31.\r |
fb3df220 | 820 | \r |
d5979dc0 | 821 | @return The value of the bit field read from the PCI configuration register.\r |
fb3df220 | 822 | \r |
823 | **/\r | |
824 | UINT32\r | |
825 | EFIAPI\r | |
826 | PciSegmentBitFieldRead32 (\r | |
2f88bd3a MK |
827 | IN UINT64 Address,\r |
828 | IN UINTN StartBit,\r | |
829 | IN UINTN EndBit\r | |
ed66e1bc | 830 | );\r |
fb3df220 | 831 | \r |
832 | /**\r | |
833 | Writes a bit field to a PCI configuration register.\r | |
834 | \r | |
d5979dc0 | 835 | Writes Value to the bit field of the PCI configuration register. The bit\r |
836 | field is specified by the StartBit and the EndBit. All other bits in the\r | |
837 | destination PCI configuration register are preserved. The new value of the\r | |
838 | 32-bit register is returned.\r | |
839 | \r | |
fb3df220 | 840 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 841 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r |
d5979dc0 | 842 | If StartBit is greater than 31, then ASSERT().\r |
843 | If EndBit is greater than 31, then ASSERT().\r | |
fb3df220 | 844 | If EndBit is less than StartBit, then ASSERT().\r |
94952554 | 845 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fb3df220 | 846 | \r |
d5979dc0 | 847 | @param Address PCI configuration register to write.\r |
fb3df220 | 848 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 849 | Range 0..31.\r |
fb3df220 | 850 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 851 | Range 0..31.\r |
fb3df220 | 852 | @param Value New value of the bit field.\r |
853 | \r | |
d5979dc0 | 854 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 855 | \r |
856 | **/\r | |
857 | UINT32\r | |
858 | EFIAPI\r | |
859 | PciSegmentBitFieldWrite32 (\r | |
2f88bd3a MK |
860 | IN UINT64 Address,\r |
861 | IN UINTN StartBit,\r | |
862 | IN UINTN EndBit,\r | |
863 | IN UINT32 Value\r | |
ed66e1bc | 864 | );\r |
fb3df220 | 865 | \r |
866 | /**\r | |
d5979dc0 | 867 | Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and\r |
868 | writes the result back to the bit field in the 32-bit port.\r | |
869 | \r | |
870 | Reads the 32-bit PCI configuration register specified by Address, performs a\r | |
62991af2 | 871 | bitwise OR between the read result and the value specified by\r |
d5979dc0 | 872 | OrData, and writes the result to the 32-bit PCI configuration register\r |
873 | specified by Address. The value written to the PCI configuration register is\r | |
874 | returned. This function must guarantee that all PCI read and write operations\r | |
875 | are serialized. Extra left bits in OrData are stripped.\r | |
876 | \r | |
badcbfb2 | 877 | If any reserved bits in Address are set, then ASSERT().\r |
d5979dc0 | 878 | If StartBit is greater than 31, then ASSERT().\r |
879 | If EndBit is greater than 31, then ASSERT().\r | |
badcbfb2 | 880 | If EndBit is less than StartBit, then ASSERT().\r |
94952554 | 881 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
d5979dc0 | 882 | \r |
883 | @param Address PCI configuration register to write.\r | |
fb3df220 | 884 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 885 | Range 0..31.\r |
fb3df220 | 886 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 887 | Range 0..31.\r |
888 | @param OrData The value to OR with the PCI configuration register.\r | |
fb3df220 | 889 | \r |
d5979dc0 | 890 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 891 | \r |
892 | **/\r | |
893 | UINT32\r | |
894 | EFIAPI\r | |
895 | PciSegmentBitFieldOr32 (\r | |
2f88bd3a MK |
896 | IN UINT64 Address,\r |
897 | IN UINTN StartBit,\r | |
898 | IN UINTN EndBit,\r | |
899 | IN UINT32 OrData\r | |
ed66e1bc | 900 | );\r |
fb3df220 | 901 | \r |
902 | /**\r | |
d5979dc0 | 903 | Reads a bit field in a 32-bit PCI configuration register, performs a bitwise\r |
904 | AND, and writes the result back to the bit field in the 32-bit register.\r | |
fb3df220 | 905 | \r |
ebdde8ff | 906 | \r |
d5979dc0 | 907 | Reads the 32-bit PCI configuration register specified by Address, performs a bitwise\r |
908 | AND between the read result and the value specified by AndData, and writes the result\r | |
909 | to the 32-bit PCI configuration register specified by Address. The value written to\r | |
910 | the PCI configuration register is returned. This function must guarantee that all PCI\r | |
911 | read and write operations are serialized. Extra left bits in AndData are stripped.\r | |
fb3df220 | 912 | If any reserved bits in Address are set, then ASSERT().\r |
badcbfb2 | 913 | If Address is not aligned on a 32-bit boundary, then ASSERT().\r |
d5979dc0 | 914 | If StartBit is greater than 31, then ASSERT().\r |
915 | If EndBit is greater than 31, then ASSERT().\r | |
fb3df220 | 916 | If EndBit is less than StartBit, then ASSERT().\r |
94952554 | 917 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
fb3df220 | 918 | \r |
ebdde8ff | 919 | @param Address Address that encodes the PCI Segment, Bus, Device, Function, and Register.\r |
fb3df220 | 920 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 921 | Range 0..31.\r |
fb3df220 | 922 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 923 | Range 0..31.\r |
924 | @param AndData The value to AND with the PCI configuration register.\r | |
fb3df220 | 925 | \r |
d5979dc0 | 926 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 927 | \r |
928 | **/\r | |
929 | UINT32\r | |
930 | EFIAPI\r | |
931 | PciSegmentBitFieldAnd32 (\r | |
2f88bd3a MK |
932 | IN UINT64 Address,\r |
933 | IN UINTN StartBit,\r | |
934 | IN UINTN EndBit,\r | |
935 | IN UINT32 AndData\r | |
ed66e1bc | 936 | );\r |
fb3df220 | 937 | \r |
938 | /**\r | |
d5979dc0 | 939 | Reads a bit field in a 32-bit port, performs a bitwise AND followed by a\r |
62991af2 | 940 | bitwise OR, and writes the result back to the bit field in the\r |
d5979dc0 | 941 | 32-bit port.\r |
942 | \r | |
943 | Reads the 32-bit PCI configuration register specified by Address, performs a\r | |
62991af2 | 944 | bitwise AND followed by a bitwise OR between the read result and\r |
d5979dc0 | 945 | the value specified by AndData, and writes the result to the 32-bit PCI\r |
946 | configuration register specified by Address. The value written to the PCI\r | |
947 | configuration register is returned. This function must guarantee that all PCI\r | |
948 | read and write operations are serialized. Extra left bits in both AndData and\r | |
949 | OrData are stripped.\r | |
950 | \r | |
fb3df220 | 951 | If any reserved bits in Address are set, then ASSERT().\r |
d5979dc0 | 952 | If StartBit is greater than 31, then ASSERT().\r |
953 | If EndBit is greater than 31, then ASSERT().\r | |
fb3df220 | 954 | If EndBit is less than StartBit, then ASSERT().\r |
94952554 LG |
955 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
956 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
fb3df220 | 957 | \r |
d5979dc0 | 958 | @param Address PCI configuration register to write.\r |
fb3df220 | 959 | @param StartBit The ordinal of the least significant bit in the bit field.\r |
d5979dc0 | 960 | Range 0..31.\r |
fb3df220 | 961 | @param EndBit The ordinal of the most significant bit in the bit field.\r |
d5979dc0 | 962 | Range 0..31.\r |
963 | @param AndData The value to AND with the PCI configuration register.\r | |
964 | @param OrData The value to OR with the result of the AND operation.\r | |
fb3df220 | 965 | \r |
d5979dc0 | 966 | @return The value written back to the PCI configuration register.\r |
fb3df220 | 967 | \r |
968 | **/\r | |
969 | UINT32\r | |
970 | EFIAPI\r | |
971 | PciSegmentBitFieldAndThenOr32 (\r | |
2f88bd3a MK |
972 | IN UINT64 Address,\r |
973 | IN UINTN StartBit,\r | |
974 | IN UINTN EndBit,\r | |
975 | IN UINT32 AndData,\r | |
976 | IN UINT32 OrData\r | |
ed66e1bc | 977 | );\r |
fb3df220 | 978 | \r |
979 | /**\r | |
980 | Reads a range of PCI configuration registers into a caller supplied buffer.\r | |
981 | \r | |
d5979dc0 | 982 | Reads the range of PCI configuration registers specified by StartAddress and\r |
983 | Size into the buffer specified by Buffer. This function only allows the PCI\r | |
984 | configuration registers from a single PCI function to be read. Size is\r | |
985 | returned. When possible 32-bit PCI configuration read cycles are used to read\r | |
a8ecf980 | 986 | from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit\r |
d5979dc0 | 987 | and 16-bit PCI configuration read cycles may be used at the beginning and the\r |
988 | end of the range.\r | |
989 | \r | |
59ceeabe | 990 | If any reserved bits in StartAddress are set, then ASSERT().\r |
fb3df220 | 991 | If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r |
badcbfb2 | 992 | If Size > 0 and Buffer is NULL, then ASSERT().\r |
fb3df220 | 993 | \r |
d5979dc0 | 994 | @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r |
995 | Function and Register.\r | |
fb3df220 | 996 | @param Size Size in bytes of the transfer.\r |
997 | @param Buffer Pointer to a buffer receiving the data read.\r | |
998 | \r | |
d5979dc0 | 999 | @return Size\r |
fb3df220 | 1000 | \r |
1001 | **/\r | |
1002 | UINTN\r | |
1003 | EFIAPI\r | |
1004 | PciSegmentReadBuffer (\r | |
2f88bd3a MK |
1005 | IN UINT64 StartAddress,\r |
1006 | IN UINTN Size,\r | |
1007 | OUT VOID *Buffer\r | |
ed66e1bc | 1008 | );\r |
fb3df220 | 1009 | \r |
1010 | /**\r | |
d5979dc0 | 1011 | Copies the data in a caller supplied buffer to a specified range of PCI\r |
1012 | configuration space.\r | |
1013 | \r | |
1014 | Writes the range of PCI configuration registers specified by StartAddress and\r | |
1015 | Size from the buffer specified by Buffer. This function only allows the PCI\r | |
1016 | configuration registers from a single PCI function to be written. Size is\r | |
1017 | returned. When possible 32-bit PCI configuration write cycles are used to\r | |
a8ecf980 | 1018 | write from StartAddress to StartAddress + Size. Due to alignment restrictions,\r |
d5979dc0 | 1019 | 8-bit and 16-bit PCI configuration write cycles may be used at the beginning\r |
1020 | and the end of the range.\r | |
1021 | \r | |
59ceeabe | 1022 | If any reserved bits in StartAddress are set, then ASSERT().\r |
fb3df220 | 1023 | If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().\r |
d5979dc0 | 1024 | If Size > 0 and Buffer is NULL, then ASSERT().\r |
fb3df220 | 1025 | \r |
d5979dc0 | 1026 | @param StartAddress Starting address that encodes the PCI Segment, Bus, Device,\r |
1027 | Function and Register.\r | |
fb3df220 | 1028 | @param Size Size in bytes of the transfer.\r |
1029 | @param Buffer Pointer to a buffer containing the data to write.\r | |
1030 | \r | |
badcbfb2 | 1031 | @return The parameter of Size.\r |
fb3df220 | 1032 | \r |
1033 | **/\r | |
1034 | UINTN\r | |
1035 | EFIAPI\r | |
1036 | PciSegmentWriteBuffer (\r | |
2f88bd3a MK |
1037 | IN UINT64 StartAddress,\r |
1038 | IN UINTN Size,\r | |
1039 | IN VOID *Buffer\r | |
ed66e1bc | 1040 | );\r |
fb3df220 | 1041 | \r |
1042 | #endif\r |