Skip to content

Commit

Permalink
DynamicTablesPkg: Fix conversion compiler warnings
Browse files Browse the repository at this point in the history
Some CM objects fields are wider than the targeted field in ACPI
tables. Some assignments are also subject to data loss and
trigger the following warnings:
- '<': signed/unsigned mismatch
- '=': conversion from 'UINTxx' to 'UINTyy', possible loss of data
with xx > yy.

Add checks/cast to remove the warnings.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
  • Loading branch information
pierregondois committed Jul 25, 2024
1 parent a9b751c commit 4650d8e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
15 changes: 11 additions & 4 deletions DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/PcctGenerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,12 @@ AddSubspaceStructType1 (
Doorbell = &GenericPccCmObj->DoorbellReg;
ChannelTiming = &GenericPccCmObj->ChannelTiming;

ASSERT ((PccCmObj->PlatIrq.Flags & ~MAX_UINT8) == 0);

PccAcpi->Type = GenericPccCmObj->Type;
PccAcpi->Length = sizeof (EFI_ACPI_6_4_PCCT_SUBSPACE_1_HW_REDUCED_COMMUNICATIONS);
PccAcpi->PlatformInterrupt = PccCmObj->PlatIrq.Interrupt;
PccAcpi->PlatformInterruptFlags = PccCmObj->PlatIrq.Flags;
PccAcpi->PlatformInterruptFlags = (UINT8)PccCmObj->PlatIrq.Flags;
PccAcpi->Reserved = EFI_ACPI_RESERVED_BYTE;
PccAcpi->BaseAddress = GenericPccCmObj->BaseAddress;
PccAcpi->AddressLength = GenericPccCmObj->AddressLength;
Expand Down Expand Up @@ -441,10 +443,12 @@ AddSubspaceStructType2 (
PlatIrqAck = &PccCmObj->PlatIrqAckReg;
ChannelTiming = &GenericPccCmObj->ChannelTiming;

ASSERT ((PccCmObj->PlatIrq.Flags & ~MAX_UINT8) == 0);

PccAcpi->Type = GenericPccCmObj->Type;
PccAcpi->Length = sizeof (EFI_ACPI_6_4_PCCT_SUBSPACE_2_HW_REDUCED_COMMUNICATIONS);
PccAcpi->PlatformInterrupt = PccCmObj->PlatIrq.Interrupt;
PccAcpi->PlatformInterruptFlags = PccCmObj->PlatIrq.Flags;
PccAcpi->PlatformInterruptFlags = (UINT8)PccCmObj->PlatIrq.Flags;
PccAcpi->BaseAddress = GenericPccCmObj->BaseAddress;
PccAcpi->Reserved = EFI_ACPI_RESERVED_BYTE;
PccAcpi->BaseAddress = GenericPccCmObj->BaseAddress;
Expand Down Expand Up @@ -519,13 +523,16 @@ AddSubspaceStructType34 (
ErrorStatus = &PccCmObj->ErrorStatusReg;
ChannelTiming = &GenericPccCmObj->ChannelTiming;

ASSERT ((PccCmObj->PlatIrq.Flags & ~MAX_UINT8) == 0);
ASSERT ((GenericPccCmObj->AddressLength & ~MAX_UINT32) == 0);

PccAcpi->Type = GenericPccCmObj->Type;
PccAcpi->Length = sizeof (EFI_ACPI_6_4_PCCT_SUBSPACE_3_EXTENDED_PCC);
PccAcpi->PlatformInterrupt = PccCmObj->PlatIrq.Interrupt;
PccAcpi->PlatformInterruptFlags = PccCmObj->PlatIrq.Flags;
PccAcpi->PlatformInterruptFlags = (UINT8)PccCmObj->PlatIrq.Flags;
PccAcpi->Reserved = EFI_ACPI_RESERVED_BYTE;
PccAcpi->BaseAddress = GenericPccCmObj->BaseAddress;
PccAcpi->AddressLength = GenericPccCmObj->AddressLength;
PccAcpi->AddressLength = (UINT32)GenericPccCmObj->AddressLength;

CopyMem (
&PccAcpi->DoorbellRegister,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,8 @@ CreateAmlCpuTopologyTree (
if (Generator->ProcNodeList[Index].OverrideNameUidEnabled) {
Name = Generator->ProcNodeList[Index].OverrideName;
} else {
Name = CpuIndex;
ASSERT ((CpuIndex & ~MAX_UINT16) == 0);
Name = (UINT16)CpuIndex;
}

Status = CreateAmlCpuFromProcHierarchy (
Expand Down Expand Up @@ -1061,7 +1062,8 @@ CreateAmlCpuTopologyTree (
Name = Generator->ProcNodeList[Index].OverrideName;
Uid = Generator->ProcNodeList[Index].OverrideUid;
} else {
Name = ProcContainerName;
ASSERT ((ProcContainerName & ~MAX_UINT16) == 0);
Name = (UINT16)ProcContainerName;
Uid = *ProcContainerIndex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ GeneratePrt (
)
{
EFI_STATUS Status;
INT32 Index;
UINT32 Index;
AML_OBJECT_NODE_HANDLE PrtNode;
CM_ARCH_COMMON_OBJ_REF *RefInfo;
UINT32 RefCount;
Expand Down Expand Up @@ -561,6 +561,11 @@ GeneratePciCrs (
break;

case PCI_SS_M32:
ASSERT ((AddrMapInfo->PciAddress & ~MAX_UINT32) == 0);
ASSERT (((AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1) & ~MAX_UINT32) == 0);
ASSERT (((Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress : 0) & ~MAX_UINT32) == 0);
ASSERT ((AddrMapInfo->AddressSize & ~MAX_UINT32) == 0);

Status = AmlCodeGenRdDWordMemory (
FALSE,
IsPosDecode,
Expand All @@ -569,10 +574,10 @@ GeneratePciCrs (
AmlMemoryCacheable,
TRUE,
0,
AddrMapInfo->PciAddress,
AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress : 0,
AddrMapInfo->AddressSize,
(UINT32)(AddrMapInfo->PciAddress),
(UINT32)(AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1),
(UINT32)(Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress : 0),
(UINT32)(AddrMapInfo->AddressSize),
0,
NULL,
AmlAddressRangeMemory,
Expand Down

0 comments on commit 4650d8e

Please sign in to comment.