27 {
"pci-host-ecam-generic" }
66 STATIC INT32 LocalSegGroup = 0;
72 return EFI_INVALID_PARAMETER;
75 Data = fdt_getprop (Fdt, HostPciNode,
"linux,pci-domain", &DataSize);
76 if ((Data ==
NULL) || (DataSize < 0)) {
78 if (LocalSegGroup < 0) {
84 *SegGroup = LocalSegGroup++;
88 if ((DataSize >
sizeof (UINT32)) ||
101 *SegGroup = fdt32_to_cpu (*(UINT32 *)Data);
121 IN INT32 HostPciNode,
134 return EFI_INVALID_PARAMETER;
137 Data = fdt_getprop (Fdt, HostPciNode,
"bus-range", &DataSize);
138 if ((Data ==
NULL) || (DataSize < 0)) {
142 }
else if (DataSize == (2 *
sizeof (UINT32))) {
144 StartBus = fdt32_to_cpu (((UINT32 *)Data)[0]);
145 EndBus = fdt32_to_cpu (((UINT32 *)Data)[1]);
151 PciInfo->PciConfigSpaceInfo.StartBusNumber = StartBus;
152 PciInfo->PciConfigSpaceInfo.EndBusNumber = EndBus;
178 IN INT32 HostPciNode,
179 IN INT32 AddressCells,
187 UINT32 AddressMapSize;
189 UINT32 PciAddressAttr;
198 Data = fdt_getprop (Fdt, HostPciNode,
"ranges", &DataSize);
199 if ((Data ==
NULL) ||
201 ((DataSize % AddressMapSize) != 0))
208 Count = DataSize / AddressMapSize;
213 if (PciAddressMapInfo ==
NULL) {
215 return EFI_OUT_OF_RESOURCES;
218 for (Index = 0; Index < Count; Index++) {
219 Offset = Index * AddressMapSize;
222 PciAddressAttr = fdt32_to_cpu (*(UINT32 *)&Data[Offset]);
224 Offset +=
sizeof (UINT32);
228 fdt64_to_cpu (*(UINT64 *)&Data[Offset]);
232 if (AddressCells == 2) {
234 fdt64_to_cpu (*(UINT64 *)&Data[Offset]);
237 fdt32_to_cpu (*(UINT32 *)&Data[Offset]);
240 Offset += AddressCells *
sizeof (UINT32);
244 fdt64_to_cpu (*(UINT64 *)&Data[Offset]);
245 Offset += PCI_SIZE_CELLS *
sizeof (UINT32);
287 IN INT32 HostPciNode,
298 INT32 IntcAddressCells;
306 CONST UINT8 *IrqMapMask;
307 INT32 IrqMapMaskSize;
311 UINT32 PciAddressAttr;
316 Data = fdt_getprop (Fdt, HostPciNode,
"interrupt-map", &DataSize);
317 if ((Data ==
NULL) || (DataSize <= 0)) {
320 "Fdt parser: No Legacy interrupts found for PCI configuration space at "
321 "address: 0x%lx, group segment: %d\n",
322 PciInfo->PciConfigSpaceInfo.BaseAddress,
323 PciInfo->PciConfigSpaceInfo.PciSegmentGroupNumber
325 return EFI_NOT_FOUND;
330 if (EFI_ERROR (Status)) {
335 if (PciIntCells != PCI_INTERRUPTS_CELLS) {
340 IrqMapMask = fdt_getprop (
343 "interrupt-map-mask",
346 if ((IrqMapMask ==
NULL) ||
356 if (PHandleOffset > DataSize) {
361 IntcPhandle = fdt32_to_cpu (*(UINT32 *)&Data[PHandleOffset]);
362 IntcNode = fdt_node_offset_by_phandle (Fdt, IntcPhandle);
370 if (EFI_ERROR (Status)) {
377 if (EFI_ERROR (Status)) {
385 + IntcAddressCells + IntcCells) *
sizeof (UINT32);
386 if ((DataSize % IrqMapSize) != 0) {
392 IrqMapCount = DataSize / IrqMapSize;
396 for (Index = 0; Index < IrqMapCount; Index++) {
397 if (IntcPhandle != fdt32_to_cpu (
398 *(UINT32 *)&Data[(Index * IrqMapSize) + PHandleOffset]
407 IrqMapCount = DataSize / IrqMapSize;
410 if (PciInterruptMapInfo ==
NULL) {
412 return EFI_OUT_OF_RESOURCES;
415 for (Index = 0; Index < IrqMapCount; Index++) {
416 Offset = Index * IrqMapSize;
419 PciAddressAttr = fdt32_to_cpu (
420 (*(UINT32 *)&Data[Offset]) &
421 (*(UINT32 *)&IrqMapMask[0])
428 PciInterruptMapInfo[Index].
PciInterrupt = fdt32_to_cpu (
429 (*(UINT32 *)&Data[Offset]) &
430 (*(UINT32 *)&IrqMapMask[3 *
sizeof (UINT32)])
434 Offset += PCI_INTERRUPTS_CELLS *
sizeof (UINT32);
437 Offset +=
sizeof (UINT32);
440 Offset += IntcAddressCells *
sizeof (UINT32);
475 IN INT32 HostPciNode,
490 return EFI_INVALID_PARAMETER;
495 if (EFI_ERROR (Status)) {
500 PciInfo->PciConfigSpaceInfo.PciSegmentGroupNumber = SegGroup;
504 if (EFI_ERROR (Status)) {
515 if (EFI_ERROR (Status)) {
521 if ((AddressCells < 1) ||
522 (AddressCells > 2) ||
530 Data = fdt_getprop (Fdt, HostPciNode,
"reg", &DataSize);
531 if ((Data ==
NULL) ||
532 (DataSize != ((AddressCells + SizeCells) *
sizeof (UINT32))))
540 if (AddressCells == 2) {
541 PciInfo->PciConfigSpaceInfo.BaseAddress = fdt64_to_cpu (*(UINT64 *)Data);
543 PciInfo->PciConfigSpaceInfo.BaseAddress = fdt32_to_cpu (*(UINT32 *)Data);
553 if (EFI_ERROR (Status)) {
564 if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
597 if ((FdtParserHandle ==
NULL) ||
598 (PciTableInfo ==
NULL))
601 return EFI_INVALID_PARAMETER;
604 PciConfigSpaceInfo = &PciTableInfo->PciConfigSpaceInfo;
612 if (EFI_ERROR (Status)) {
626 if (EFI_ERROR (Status)) {
638 &PciTableInfo->PciConfigSpaceInfo,
664 if (PciTableInfo ==
NULL) {
666 return EFI_INVALID_PARAMETER;
670 Data = PciTableInfo->Mapping[Index].Data;
734 if (FdtParserHandle ==
NULL) {
736 return EFI_INVALID_PARAMETER;
739 Fdt = FdtParserHandle->Fdt;
752 if (EFI_ERROR (Status)) {
757 if (PciNodeCount == 0) {
758 return EFI_NOT_FOUND;
763 for (Index = 0; Index < PciNodeCount; Index++) {
772 if (EFI_ERROR (Status)) {
774 if (Status == EFI_NOT_FOUND) {
776 Status = EFI_ABORTED;
783 if (EFI_ERROR (Status)) {
789 Status =
PciInfoAdd (FdtParserHandle, &PciTableInfo);
790 if (EFI_ERROR (Status)) {
796 if (EFI_ERROR (Status)) {
struct CmArchCommonPciInterruptMapInfo CM_ARCH_COMMON_PCI_INTERRUPT_MAP_INFO
struct CmArchCommonPciAddressMapInfo CM_ARCH_COMMON_PCI_ADDRESS_MAP_INFO
@ EArchCommonObjPciAddressMapInfo
9 - Pci Address Map Info
@ EArchCommonObjPciInterruptMapInfo
10 - Pci Interrupt Map Info
@ EArchCommonObjPciConfigSpaceInfo
8 - PCI Configuration Space Info
UINT32 EFIAPI FdtGetInterruptId(UINT32 CONST *Data)
EFI_STATUS EFIAPI FdtGetIntcAddressCells(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *AddressCells, OPTIONAL OUT INT32 *SizeCells OPTIONAL)
UINT32 EFIAPI FdtGetInterruptFlags(UINT32 CONST *Data)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI AddMultipleCmObjWithCmObjRef(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN CM_OBJ_DESCRIPTOR *CmObjDesc, OUT CM_OBJECT_TOKEN *Token)
EFI_STATUS EFIAPI AddSingleCmObj(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN CM_OBJECT_ID ObjectId, IN VOID *Data, IN UINT32 Size, OUT CM_OBJECT_TOKEN *Token OPTIONAL)
#define CREATE_CM_ARCH_COMMON_OBJECT_ID(ObjectId)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI FdtGetNextCompatNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST COMPATIBILITY_INFO *CompatNamesInfo, IN OUT INT32 *Node)
EFI_STATUS EFIAPI FdtGetParentAddressInfo(IN CONST VOID *Fdt, IN INT32 Node, OUT INT32 *AddressCells, OPTIONAL OUT INT32 *SizeCells OPTIONAL)
EFI_STATUS EFIAPI FdtCountCompatNodeInBranch(IN CONST VOID *Fdt, IN INT32 FdtBranch, IN CONST COMPATIBILITY_INFO *CompatNamesInfo, OUT UINT32 *NodeCount)
EFI_STATUS EFIAPI FdtGetInterruptCellsInfo(IN CONST VOID *Fdt, IN INT32 IntcNode, OUT INT32 *IntCells)
#define ARRAY_SIZE(Array)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
STATIC EFI_STATUS EFIAPI FreeParserTable(IN PCI_PARSER_TABLE *PciTableInfo)
STATIC EFI_STATUS EFIAPI GetPciSegGroup(IN CONST VOID *Fdt, IN INT32 HostPciNode, OUT INT32 *SegGroup)
STATIC EFI_STATUS EFIAPI PciNodeParser(IN CONST VOID *Fdt, IN INT32 HostPciNode, IN OUT PCI_PARSER_TABLE *PciInfo)
STATIC CONST COMPATIBILITY_INFO PciCompatibleInfo
STATIC EFI_STATUS EFIAPI PopulateBusRange(IN CONST VOID *Fdt, IN INT32 HostPciNode, IN OUT PCI_PARSER_TABLE *PciInfo)
STATIC EFI_STATUS EFIAPI ParseIrqMap(IN CONST VOID *Fdt, IN INT32 HostPciNode, IN OUT PCI_PARSER_TABLE *PciInfo)
STATIC EFI_STATUS EFIAPI ParseAddressMap(IN CONST VOID *Fdt, IN INT32 HostPciNode, IN INT32 AddressCells, IN OUT PCI_PARSER_TABLE *PciInfo)
STATIC CONST COMPATIBILITY_STR PciCompatibleStr[]
EFI_STATUS EFIAPI PciConfigInfoParser(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
STATIC EFI_STATUS EFIAPI PciInfoAdd(IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN PCI_PARSER_TABLE *PciTableInfo)
#define READ_PCI_BBBBBBBB(ADDR)
Bus number.
#define READ_PCI_DDDDD(ADDR)
Device number.
@ PciMappingTableMax
2 - Max
@ PciMappingTableInterrupt
1 - Interrupt mapping
@ PciMappingTableAddress
0 - Address mapping
#define PCI_ADDRESS_CELLS
#define READ_PCI_SS(ADDR)
UINT32 Interrupt
Interrupt number.
UINT64 AddressSize
Address size.
UINT64 CpuAddress
Cpu address.
UINT64 PciAddress
PCI address.
CM_OBJECT_TOKEN InterruptMapToken
CM_OBJECT_TOKEN AddressMapToken
CM_ARCH_COMMON_GENERIC_INTERRUPT IntcInterrupt