X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=DuetPkg%2FPciBusNoEnumerationDxe%2FPciIo.c;h=9f473737435e539a2edd7cbae63928bed514ed86;hb=d5988a8ac9716130a323fb12bbf81c41807c7865;hp=8e7c8151720b328cebf14f6cfa08aa56f5ea6ecd;hpb=b1f700a8593435e2bdc8f9b3dc21bced4774c80f;p=mirror_edk2.git diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciIo.c b/DuetPkg/PciBusNoEnumerationDxe/PciIo.c index 8e7c815172..9f47373743 100644 --- a/DuetPkg/PciBusNoEnumerationDxe/PciIo.c +++ b/DuetPkg/PciBusNoEnumerationDxe/PciIo.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -343,7 +343,7 @@ Returns: --*/ { - if (Width < 0 || Width >= EfiPciIoWidthMaximum) { + if ((UINT32)Width >= EfiPciIoWidthMaximum) { return EFI_INVALID_PARAMETER; } @@ -366,7 +366,7 @@ Returns: // If Width is EfiPciIoWidthFifoUintX then convert to EfiPciIoWidthUintX // If Width is EfiPciIoWidthFillUintX then convert to EfiPciIoWidthUintX // - if (Width >= EfiPciWidthFifoUint8 && Width <= EfiPciWidthFifoUint64) { + if (Width >= EfiPciIoWidthFifoUint8 && Width <= EfiPciIoWidthFifoUint64) { Count = 1; } @@ -404,7 +404,7 @@ Returns: { UINT64 ExtendOffset; - if (Width < 0 || Width >= EfiPciIoWidthMaximum) { + if ((UINT32)Width >= EfiPciIoWidthMaximum) { return EFI_INVALID_PARAMETER; } @@ -465,7 +465,7 @@ Returns: PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); - if (Width < 0 || Width >= EfiPciIoWidthMaximum) { + if ((UINT32)Width >= EfiPciIoWidthMaximum) { return EFI_INVALID_PARAMETER; } @@ -521,7 +521,7 @@ Returns: PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); - if (Width < 0 || Width > EfiPciIoWidthUint64) { + if ((UINT32)Width > EfiPciIoWidthUint64) { return EFI_INVALID_PARAMETER; } @@ -576,7 +576,7 @@ Returns: PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); - if (Width < 0 || Width >= EfiPciIoWidthMaximum) { + if ((UINT32)Width >= EfiPciIoWidthMaximum) { return EFI_INVALID_PARAMETER; } @@ -629,7 +629,7 @@ Returns: PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); - if (Width < 0 || Width >= EfiPciIoWidthMaximum) { + if ((UINT32)Width >= EfiPciIoWidthMaximum) { return EFI_INVALID_PARAMETER; } @@ -682,7 +682,7 @@ Returns: PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); - if (Width < 0 || Width >= EfiPciIoWidthMaximum) { + if ((UINT32)Width >= EfiPciIoWidthMaximum) { return EFI_INVALID_PARAMETER; } @@ -735,7 +735,7 @@ Returns: PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); - if (Width < 0 || Width >= EfiPciIoWidthMaximum) { + if ((UINT32)Width >= EfiPciIoWidthMaximum) { return EFI_INVALID_PARAMETER; } @@ -877,7 +877,7 @@ Returns: PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); - if (Width < 0 || Width >= EfiPciIoWidthMaximum) { + if ((UINT32)Width >= EfiPciIoWidthMaximum) { return EFI_INVALID_PARAMETER; } @@ -942,7 +942,7 @@ Returns: PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); - if (Operation < 0 || Operation >= EfiPciIoOperationMaximum) { + if ((UINT32)Operation >= EfiPciIoOperationMaximum) { return EFI_INVALID_PARAMETER; } @@ -1600,14 +1600,10 @@ Returns: --*/ { - UINT8 *Configuration; - UINT8 NumConfig; PCI_IO_DEVICE *PciIoDevice; - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Ptr; - EFI_ACPI_END_TAG_DESCRIPTOR *PtrEnd; - - NumConfig = 0; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *AddressSpace; + EFI_ACPI_END_TAG_DESCRIPTOR *End; PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (This); @@ -1615,7 +1611,7 @@ Returns: return EFI_INVALID_PARAMETER; } - if (BarIndex >= PCI_MAX_BAR) { + if ((BarIndex >= PCI_MAX_BAR) || (PciIoDevice->PciBar[BarIndex].BarType == PciBarTypeUnknown)) { return EFI_UNSUPPORTED; } @@ -1628,106 +1624,93 @@ Returns: } if (Resources != NULL) { - - if (PciIoDevice->PciBar[BarIndex].BarType != PciBarTypeUnknown) { - NumConfig = 1; - } - - Configuration = AllocatePool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) * NumConfig + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR)); + Configuration = AllocateZeroPool (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR)); if (Configuration == NULL) { return EFI_OUT_OF_RESOURCES; } - ZeroMem ( - Configuration, - sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) * NumConfig + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR) - ); - - Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration; + AddressSpace = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration; - if (NumConfig == 1) { - Ptr->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR; - Ptr->Len = sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3; + AddressSpace->Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR; + AddressSpace->Len = (UINT16) (sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3); - Ptr->AddrRangeMin = PciIoDevice->PciBar[BarIndex].BaseAddress; - Ptr->AddrLen = PciIoDevice->PciBar[BarIndex].Length; - Ptr->AddrRangeMax = PciIoDevice->PciBar[BarIndex].Alignment; + AddressSpace->AddrRangeMin = PciIoDevice->PciBar[BarIndex].BaseAddress; + AddressSpace->AddrLen = PciIoDevice->PciBar[BarIndex].Length; + AddressSpace->AddrRangeMax = PciIoDevice->PciBar[BarIndex].Alignment; - switch (PciIoDevice->PciBar[BarIndex].BarType) { - case PciBarTypeIo16: - case PciBarTypeIo32: - // - // Io - // - Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_IO; - break; + switch (PciIoDevice->PciBar[BarIndex].BarType) { + case PciBarTypeIo16: + case PciBarTypeIo32: + // + // Io + // + AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_IO; + break; - case PciBarTypeMem32: - // - // Mem - // - Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; - // - // 32 bit - // - Ptr->AddrSpaceGranularity = 32; - break; + case PciBarTypeMem32: + // + // Mem + // + AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; + // + // 32 bit + // + AddressSpace->AddrSpaceGranularity = 32; + break; - case PciBarTypePMem32: - // - // Mem - // - Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; - // - // prefechable - // - Ptr->SpecificFlag = 0x6; - // - // 32 bit - // - Ptr->AddrSpaceGranularity = 32; - break; + case PciBarTypePMem32: + // + // Mem + // + AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; + // + // prefechable + // + AddressSpace->SpecificFlag = 0x6; + // + // 32 bit + // + AddressSpace->AddrSpaceGranularity = 32; + break; - case PciBarTypeMem64: - // - // Mem - // - Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; - // - // 64 bit - // - Ptr->AddrSpaceGranularity = 64; - break; + case PciBarTypeMem64: + // + // Mem + // + AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; + // + // 64 bit + // + AddressSpace->AddrSpaceGranularity = 64; + break; - case PciBarTypePMem64: - // - // Mem - // - Ptr->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; - // - // prefechable - // - Ptr->SpecificFlag = 0x6; - // - // 64 bit - // - Ptr->AddrSpaceGranularity = 64; - break; - default: - break; - } + case PciBarTypePMem64: + // + // Mem + // + AddressSpace->ResType = ACPI_ADDRESS_SPACE_TYPE_MEM; + // + // prefechable + // + AddressSpace->SpecificFlag = 0x6; + // + // 64 bit + // + AddressSpace->AddrSpaceGranularity = 64; + break; - Ptr = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) ((UINT8 *) Ptr + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR)); + default: + break; } - + // // put the checksum // - PtrEnd = (EFI_ACPI_END_TAG_DESCRIPTOR *) ((UINT8 *) Ptr); - PtrEnd->Desc = ACPI_END_TAG_DESCRIPTOR; - PtrEnd->Checksum = 0; + End = (EFI_ACPI_END_TAG_DESCRIPTOR *) (AddressSpace + 1); + End->Desc = ACPI_END_TAG_DESCRIPTOR; + End->Checksum = 0; - *Resources = Configuration; + *Resources = Configuration; } return EFI_SUCCESS;