]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.h
Add function doxygen header for PciBus module.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / PciBusDxe / PciResourceSupport.h
1 /**@file
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 **/
13
14 #ifndef _EFI_PCI_RESOURCE_SUPPORT_H
15 #define _EFI_PCI_RESOURCE_SUPPORT_H
16
17 #define RESERVED_RESOURCE_SIGNATURE EFI_SIGNATURE_32 ('r', 's', 'v', 'd')
18
19 typedef struct {
20 UINT64 Base;
21 UINT64 Length;
22 PCI_BAR_TYPE ResType;
23 } PCI_RESERVED_RESOURCE_NODE;
24
25 typedef struct {
26 UINT32 Signature;
27 LIST_ENTRY Link;
28 PCI_RESERVED_RESOURCE_NODE Node;
29 } PCI_RESERVED_RESOURCE_LIST;
30
31 #define RESOURCED_LIST_FROM_NODE(a) \
32 CR (a, PCI_RESERVED_RESOURCE_LIST, Node, RESERVED_RESOURCE_SIGNATURE)
33
34 #define RESOURCED_LIST_FROM_LINK(a) \
35 CR (a, PCI_RESERVED_RESOURCE_LIST, Link, RESERVED_RESOURCE_SIGNATURE)
36
37 typedef enum {
38 PciResUsageTypical = 0,
39 PciResUsagePadding,
40 PciResUsageOptionRomProcessing
41 } PCI_RESOURCE_USAGE;
42
43 #define PCI_RESOURCE_SIGNATURE EFI_SIGNATURE_32 ('p', 'c', 'r', 'c')
44
45 typedef struct {
46 UINT32 Signature;
47 LIST_ENTRY Link;
48 LIST_ENTRY ChildList;
49 PCI_IO_DEVICE *PciDev;
50 UINT64 Alignment;
51 UINT64 Offset;
52 UINT8 Bar;
53 PCI_BAR_TYPE ResType;
54 UINT64 Length;
55 BOOLEAN Reserved;
56 PCI_RESOURCE_USAGE ResourceUsage;
57 } PCI_RESOURCE_NODE;
58
59 #define RESOURCE_NODE_FROM_LINK(a) \
60 CR (a, PCI_RESOURCE_NODE, Link, PCI_RESOURCE_SIGNATURE)
61
62 /**
63 The function is used to skip VGA range
64
65 @param Start address including VGA range
66 @param Length length of VGA range.
67
68 @retval EFI_SUCCESS success
69 **/
70 EFI_STATUS
71 SkipVGAAperture (
72 OUT UINT64 *Start,
73 IN UINT64 Length
74 )
75 ;
76
77 /**
78 This function is used to skip ISA aliasing aperture
79
80 @param Start address including ISA aliasing aperture
81 @param Length length of ISA aliasing aperture
82
83 @retval EFI_SUCCESS success
84 **/
85 EFI_STATUS
86 SkipIsaAliasAperture (
87 OUT UINT64 *Start,
88 IN UINT64 Length
89 )
90 ;
91
92 /**
93 This function inserts a resource node into the resource list.
94 The resource list is sorted in descend order.
95
96 @param Bridge PCI resource node for bridge
97 @param ResNode Resource node want to be inserted
98
99 @retval EFI_SUCCESS Success
100 **/
101 EFI_STATUS
102 InsertResourceNode (
103 PCI_RESOURCE_NODE *Bridge,
104 PCI_RESOURCE_NODE *ResNode
105 )
106 ;
107
108 /**
109
110 Routine Description:
111
112 This routine is used to merge two different resource tree in need of
113 resoure degradation. For example, if a upstream PPB doesn't support,
114 prefetchable memory decoding, the PCI bus driver will choose to call this function
115 to merge prefectchable memory resource list into normal memory list.
116
117 If the TypeMerge is TRUE, Res resource type is changed to the type of destination resource
118 type.
119
120 @param Dst Point to destination resource tree
121 @param Res Point to source resource tree
122 @param TypeMerge If the TypeMerge is TRUE, Res resource type is changed to the type of
123 destination resource type.
124
125
126 @retval EFI_SUCCESS Success
127 **/
128 EFI_STATUS
129 MergeResourceTree (
130 PCI_RESOURCE_NODE *Dst,
131 PCI_RESOURCE_NODE *Res,
132 BOOLEAN TypeMerge
133 )
134 ;
135
136 /**
137 This function is used to calculate the IO16 aperture
138 for a bridge.
139
140 @param Bridge PCI resource node for bridge.
141
142 @retval EFI_SUCCESS Success
143 **/
144 EFI_STATUS
145 CalculateApertureIo16 (
146 IN PCI_RESOURCE_NODE *Bridge
147 )
148 ;
149
150 /**
151 This function is used to calculate the resource aperture
152 for a given bridge device
153
154 @param Bridge Give bridge device
155
156 @retval EFI_SUCCESS Success
157 **/
158 EFI_STATUS
159 CalculateResourceAperture (
160 IN PCI_RESOURCE_NODE *Bridge
161 )
162 ;
163
164 /**
165 Get IO/Memory resource infor for given PCI device
166
167 @param PciDev Pci device instance
168 @param IoNode Resource info node for IO
169 @param Mem32Node Resource info node for 32-bit memory
170 @param PMem32Node Resource info node for 32-bit PMemory
171 @param Mem64Node Resource info node for 64-bit memory
172 @param PMem64Node Resource info node for 64-bit PMemory
173
174 @retval EFI_SUCCESS Success
175 **/
176 EFI_STATUS
177 GetResourceFromDevice (
178 PCI_IO_DEVICE *PciDev,
179 PCI_RESOURCE_NODE *IoNode,
180 PCI_RESOURCE_NODE *Mem32Node,
181 PCI_RESOURCE_NODE *PMem32Node,
182 PCI_RESOURCE_NODE *Mem64Node,
183 PCI_RESOURCE_NODE *PMem64Node
184 )
185 ;
186
187 /**
188 This function is used to create a resource node
189
190 @param PciDev Pci device instance
191 @param Length Length of Io/Memory resource
192 @param Alignment Alignment of resource
193 @param Bar Bar index
194 @param ResType Type of resource: IO/Memory
195 @param ResUage Resource usage
196 **/
197 PCI_RESOURCE_NODE *
198 CreateResourceNode (
199 IN PCI_IO_DEVICE *PciDev,
200 IN UINT64 Length,
201 IN UINT64 Alignment,
202 IN UINT8 Bar,
203 IN PCI_BAR_TYPE ResType,
204 IN PCI_RESOURCE_USAGE ResUsage
205 )
206 ;
207
208 /**
209 This routine is used to extract resource request from
210 device node list.
211
212 @param Bridge Pci device instance
213 @param IoNode Resource info node for IO
214 @param Mem32Node Resource info node for 32-bit memory
215 @param PMem32Node Resource info node for 32-bit PMemory
216 @param Mem64Node Resource info node for 64-bit memory
217 @param PMem64Node Resource info node for 64-bit PMemory
218
219 @retval EFI_SUCCESS Success
220 **/
221 EFI_STATUS
222 CreateResourceMap (
223 IN PCI_IO_DEVICE *Bridge,
224 IN PCI_RESOURCE_NODE *IoNode,
225 IN PCI_RESOURCE_NODE *Mem32Node,
226 IN PCI_RESOURCE_NODE *PMem32Node,
227 IN PCI_RESOURCE_NODE *Mem64Node,
228 IN PCI_RESOURCE_NODE *PMem64Node
229 )
230 ;
231
232 /**
233 This function is used to do the resource padding for a specific platform
234
235 @param Bridge Pci device instance
236 @param IoNode Resource info node for IO
237 @param Mem32Node Resource info node for 32-bit memory
238 @param PMem32Node Resource info node for 32-bit PMemory
239 @param Mem64Node Resource info node for 64-bit memory
240 @param PMem64Node Resource info node for 64-bit PMemory
241
242 @retval EFI_SUCCESS Success
243 **/
244 EFI_STATUS
245 ResourcePaddingPolicy (
246 PCI_IO_DEVICE *PciDev,
247 PCI_RESOURCE_NODE *IoNode,
248 PCI_RESOURCE_NODE *Mem32Node,
249 PCI_RESOURCE_NODE *PMem32Node,
250 PCI_RESOURCE_NODE *Mem64Node,
251 PCI_RESOURCE_NODE *PMem64Node
252 )
253 ;
254
255 /**
256 This function is used to degrade resource if the upstream bridge
257 doesn't support certain resource. Degradation path is
258 PMEM64 -> MEM64 -> MEM32
259 PMEM64 -> PMEM32 -> MEM32
260 IO32 -> IO16
261
262 @param Bridge Pci device instance
263 @param IoNode Resource info node for IO
264 @param Mem32Node Resource info node for 32-bit memory
265 @param PMem32Node Resource info node for 32-bit PMemory
266 @param Mem64Node Resource info node for 64-bit memory
267 @param PMem64Node Resource info node for 64-bit PMemory
268
269 @retval EFI_SUCCESS Success
270 **/
271 EFI_STATUS
272 DegradeResource (
273 IN PCI_IO_DEVICE *Bridge,
274 IN PCI_RESOURCE_NODE *Mem32Node,
275 IN PCI_RESOURCE_NODE *PMem32Node,
276 IN PCI_RESOURCE_NODE *Mem64Node,
277 IN PCI_RESOURCE_NODE *PMem64Node
278 )
279 ;
280
281 /**
282 Test whether bridge device support decode resource
283
284 @param Bridge Bridge device instance
285 @param Decode Decode type according to resource type
286
287 @return whether bridge device support decode resource
288
289 **/
290 BOOLEAN
291 BridgeSupportResourceDecode (
292 IN PCI_IO_DEVICE *Bridge,
293 IN UINT32 Decode
294 )
295 ;
296
297 /**
298 This function is used to program the resource allocated
299 for each resource node
300
301
302 @param Base Base address of resource
303 @param Bridge Bridge device instance
304
305 @retval EFI_SUCCESS Success
306 **/
307 EFI_STATUS
308 ProgramResource (
309 IN UINT64 Base,
310 IN PCI_RESOURCE_NODE *Bridge
311 )
312 ;
313
314 /**
315 Program Bar register.
316
317 @param Base Base address for resource
318 @param Node Point to resoure node structure
319
320 @retval EFI_SUCCESS Success
321 **/
322 EFI_STATUS
323 ProgramBar (
324 IN UINT64 Base,
325 IN PCI_RESOURCE_NODE *Node
326 )
327 ;
328
329 /**
330 Program PPB apperture
331
332 @param Base Base address for resource
333 @param Node Point to resoure node structure
334
335 @retval EFI_SUCCESS Success
336 **/
337 EFI_STATUS
338 ProgramPpbApperture (
339 IN UINT64 Base,
340 IN PCI_RESOURCE_NODE *Node
341 )
342 ;
343
344 /**
345 Program parent bridge for oprom
346
347 @param PciDevice Pci deivce instance
348 @param OptionRomBase Base address for oprom
349 @param Enable Enable/Disable
350
351 @retval EFI_SUCCESS Success
352 **/
353 EFI_STATUS
354 ProgrameUpstreamBridgeForRom (
355 IN PCI_IO_DEVICE *PciDevice,
356 IN UINT32 OptionRomBase,
357 IN BOOLEAN Enable
358 )
359 ;
360
361 /**
362 Test whether resource exists for a bridge
363
364 @param Bridge Point to resource node for a bridge
365
366 @return whether resource exists
367 **/
368 BOOLEAN
369 ResourceRequestExisted (
370 IN PCI_RESOURCE_NODE *Bridge
371 )
372 ;
373
374 /**
375 Initialize resource pool structure.
376
377 @param ResourcePool Point to resource pool structure
378 @param ResourceType Type of resource
379 **/
380 EFI_STATUS
381 InitializeResourcePool (
382 PCI_RESOURCE_NODE *ResourcePool,
383 PCI_BAR_TYPE ResourceType
384 )
385 ;
386
387 /**
388 Get all resource information for given Pci device
389
390 @param PciDev Pci device instance
391 @param IoBridge Io resource node
392 @param Mem32Bridge 32-bit memory node
393 @param PMem32Bridge 32-bit Pmemory node
394 @param Mem64Bridge 64-bit memory node
395 @param PMem64Bridge 64-bit PMemory node
396 @param IoPool Link list header for Io resource
397 @param Mem32Pool Link list header for 32-bit memory
398 @param PMem32Pool Link list header for 32-bit Pmemory
399 @param Mem64Pool Link list header for 64-bit memory
400 @param PMem64Pool Link list header for 64-bit Pmemory
401
402 @retval EFI_SUCCESS Success
403 **/
404 EFI_STATUS
405 GetResourceMap (
406 PCI_IO_DEVICE *PciDev,
407 PCI_RESOURCE_NODE **IoBridge,
408 PCI_RESOURCE_NODE **Mem32Bridge,
409 PCI_RESOURCE_NODE **PMem32Bridge,
410 PCI_RESOURCE_NODE **Mem64Bridge,
411 PCI_RESOURCE_NODE **PMem64Bridge,
412 PCI_RESOURCE_NODE *IoPool,
413 PCI_RESOURCE_NODE *Mem32Pool,
414 PCI_RESOURCE_NODE *PMem32Pool,
415 PCI_RESOURCE_NODE *Mem64Pool,
416 PCI_RESOURCE_NODE *PMem64Pool
417 )
418 ;
419
420 /**
421 Destory given resource tree
422
423 @param Bridge root node of resource tree
424
425 @retval EFI_SUCCESS Success
426 **/
427 EFI_STATUS
428 DestroyResourceTree (
429 IN PCI_RESOURCE_NODE *Bridge
430 )
431 ;
432
433 /**
434 Record the reserved resource and insert to reserved list.
435
436 @param Base Base address of reserved resourse
437 @param Length Length of reserved resource
438 @param ResType Resource type
439 @param Bridge Pci device instance
440 **/
441 EFI_STATUS
442 RecordReservedResource (
443 IN UINT64 Base,
444 IN UINT64 Length,
445 IN PCI_BAR_TYPE ResType,
446 IN PCI_IO_DEVICE *Bridge
447 )
448 ;
449
450 /**
451 Insert resource padding for P2C
452
453 @param PciDev Pci device instance
454 @param IoNode Resource info node for IO
455 @param Mem32Node Resource info node for 32-bit memory
456 @param PMem32Node Resource info node for 32-bit PMemory
457 @param Mem64Node Resource info node for 64-bit memory
458 @param PMem64Node Resource info node for 64-bit PMemory
459
460 @retval EFI_SUCCESS Success
461 **/
462 EFI_STATUS
463 ResourcePaddingForCardBusBridge (
464 PCI_IO_DEVICE *PciDev,
465 PCI_RESOURCE_NODE *IoNode,
466 PCI_RESOURCE_NODE *Mem32Node,
467 PCI_RESOURCE_NODE *PMem32Node,
468 PCI_RESOURCE_NODE *Mem64Node,
469 PCI_RESOURCE_NODE *PMem64Node
470 )
471 ;
472
473 /**
474 Program P2C register for given resource node
475
476 @param Base Base address of P2C device
477 @param Node Given resource node.
478
479 @retval EFI_SUCCESS Success
480 **/
481 EFI_STATUS
482 ProgramP2C (
483 IN UINT64 Base,
484 IN PCI_RESOURCE_NODE *Node
485 )
486 ;
487
488 /**
489 Create padding resource node.
490
491 @param PciDev Pci device instance
492 @param IoNode Resource info node for IO
493 @param Mem32Node Resource info node for 32-bit memory
494 @param PMem32Node Resource info node for 32-bit PMemory
495 @param Mem64Node Resource info node for 64-bit memory
496 @param PMem64Node Resource info node for 64-bit PMemory
497
498 @retval EFI_SUCCESS Success
499
500 **/
501 EFI_STATUS
502 ApplyResourcePadding (
503 PCI_IO_DEVICE *PciDev,
504 PCI_RESOURCE_NODE *IoNode,
505 PCI_RESOURCE_NODE *Mem32Node,
506 PCI_RESOURCE_NODE *PMem32Node,
507 PCI_RESOURCE_NODE *Mem64Node,
508 PCI_RESOURCE_NODE *PMem64Node
509 )
510 ;
511
512 /**
513 Get padding resource for PPB
514 Light PCI bus driver woundn't support hotplug root device
515 So no need to pad resource for them
516
517 @param PciIoDevice Pci device instance
518 **/
519 VOID
520 GetResourcePaddingPpb (
521 IN PCI_IO_DEVICE *PciIoDevice
522 )
523 ;
524
525 /**
526 Reset and all bus number from specific bridge.
527
528 @param Bridge Parent specific bridge
529 @param StartBusNumber start bus number
530 **/
531 EFI_STATUS
532 ResetAllPpbBusNumber (
533 IN PCI_IO_DEVICE *Bridge,
534 IN UINT8 StartBusNumber
535 )
536 ;
537
538 #endif