Skip to content

Commit

Permalink
MdeModulePkg: Rename IS_ALIGNED macros to avoid name collisions
Browse files Browse the repository at this point in the history
This patch is a preparation for the patches that follow. The
subsequent patches will introduce and integrate new alignment-related
macros, which collide with existing definitions in MdeModulePkg.
Temporarily rename them to avoid build failure, till they can be
substituted with the new, shared definitions.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
  • Loading branch information
mhaeuser authored and mergify[bot] committed Apr 1, 2023
1 parent 67a6f41 commit 583f1ab
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2126,7 +2126,7 @@ TrustTransferAtaDevice (
// ATA PassThru PPI.
//
if ((AtaPassThru->Mode->IoAlign > 1) &&
!IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign))
!ADDRESS_IS_ALIGNED_ (Buffer, AtaPassThru->Mode->IoAlign))
{
NewBuffer = AllocateAlignedPages (
EFI_SIZE_TO_PAGES (TransferLength),
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ typedef union {
#define AHCI_PORT_SERR 0x0030
#define AHCI_PORT_CI 0x0038

#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
#define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)
#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
#define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)

#pragma pack(1)

Expand Down
6 changes: 3 additions & 3 deletions MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ AhciAtaPassThruPassThru (
}

IoAlign = This->Mode->IoAlign;
if ((IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, IoAlign)) {
if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuffer, IoAlign)) {
return EFI_INVALID_PARAMETER;
}

if ((IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, IoAlign)) {
if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBuffer, IoAlign)) {
return EFI_INVALID_PARAMETER;
}

if ((IoAlign > 1) && !IS_ALIGNED (Packet->Asb, IoAlign)) {
if ((IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->Asb, IoAlign)) {
return EFI_INVALID_PARAMETER;
}

Expand Down
12 changes: 6 additions & 6 deletions MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
Original file line number Diff line number Diff line change
Expand Up @@ -1299,15 +1299,15 @@ AtaPassThruPassThru (

Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->Asb, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->Asb, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

Expand Down Expand Up @@ -2039,15 +2039,15 @@ ExtScsiPassThruPassThru (
return EFI_INVALID_PARAMETER;
}

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->SenseData, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->SenseData, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct _ATA_NONBLOCK_TASK {
#define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)
#define ATA_SPINUP_TIMEOUT EFI_TIMER_PERIOD_SECONDS(10)

#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)

#define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
#define ATA_TASK_SIGNATURE SIGNATURE_32 ('A', 'T', 'S', 'K')
#define ATA_DEVICE_SIGNATURE SIGNATURE_32 ('A', 'B', 'I', 'D')
#define ATA_SUB_TASK_SIGNATURE SIGNATURE_32 ('A', 'S', 'T', 'S')
#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)

//
// ATA bus data structure for ATA controller
Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ TrustTransferAtaDevice (
// Check the alignment of the incoming buffer prior to invoking underlying ATA PassThru
//
AtaPassThru = AtaDevice->AtaBusDriverData->AtaPassThru;
if ((AtaPassThru->Mode->IoAlign > 1) && !IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign)) {
if ((AtaPassThru->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Buffer, AtaPassThru->Mode->IoAlign)) {
NewBuffer = AllocateAlignedBuffer (AtaDevice, TransferLength);
if (NewBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,7 @@ ScsiDiskReceiveData (
goto Done;
}

if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !IS_ALIGNED (PayloadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) {
if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (PayloadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) {
AlignedBuffer = AllocateAlignedBuffer (ScsiDiskDevice, PayloadBufferSize);
if (AlignedBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
Expand Down Expand Up @@ -2249,7 +2249,7 @@ ScsiDiskSendData (
goto Done;
}

if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !IS_ALIGNED (PayloadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) {
if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (PayloadBuffer, ScsiDiskDevice->ScsiIo->IoAlign)) {
AlignedBuffer = AllocateAlignedBuffer (ScsiDiskDevice, PayloadBufferSize);
if (AlignedBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0

#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)

#define UFS_WLUN_RPMB 0xC4

Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ typedef struct _UFS_PEIM_HC_PRIVATE_DATA {

#define ROUNDUP8(x) (((x) % 8 == 0) ? (x) : ((x) / 8 + 1) * 8)

#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)

#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, BlkIoPpi, UFS_PEIM_HC_SIG)
#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS2(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, BlkIo2Ppi, UFS_PEIM_HC_SIG)
Expand Down
6 changes: 3 additions & 3 deletions MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ UfsPassThruPassThru (
return EFI_INVALID_PARAMETER;
}

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->InDataBuffer, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->InDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->OutDataBuffer, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->OutDataBuffer, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

if ((This->Mode->IoAlign > 1) && !IS_ALIGNED (Packet->SenseData, This->Mode->IoAlign)) {
if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED_ (Packet->SenseData, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ typedef struct {

#define ROUNDUP8(x) (((x) % 8 == 0) ? (x) : ((x) / 8 + 1) * 8)

#define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)

#define UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
Expand Down
36 changes: 18 additions & 18 deletions MdeModulePkg/Universal/EbcDxe/EbcExecute.c
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ ExecuteJMP (
// check for alignment, and jump absolute.
//
Data64 = (UINT64)VmReadImmed64 (VmPtr, 2);
if (!IS_ALIGNED ((UINTN)Data64, sizeof (UINT16))) {
if (!ADDRESS_IS_ALIGNED_ ((UINTN)Data64, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
Expand Down Expand Up @@ -2074,7 +2074,7 @@ ExecuteJMP (
// Form: JMP32 @Rx {Index32}
//
Addr = VmReadMemN (VmPtr, (UINTN)Data64 + Index32);
if (!IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) {
if (!ADDRESS_IS_ALIGNED_ ((UINTN)Addr, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
Expand All @@ -2097,7 +2097,7 @@ ExecuteJMP (
// Form: JMP32 Rx {Immed32}
//
Addr = (UINTN)(Data64 + Index32);
if (!IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) {
if (!ADDRESS_IS_ALIGNED_ ((UINTN)Addr, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
Expand Down Expand Up @@ -3158,7 +3158,7 @@ ExecuteRET (
// Pull the return address off the VM app's stack and set the IP
// to it
//
if (!IS_ALIGNED ((UINTN)VmPtr->Gpr[0], sizeof (UINT16))) {
if (!ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Gpr[0], sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
Expand Down Expand Up @@ -4733,7 +4733,7 @@ VmWriteMem16 (
//
// Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT16))) {
if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT16))) {
*(UINT16 *)Addr = Data;
} else {
//
Expand Down Expand Up @@ -4795,7 +4795,7 @@ VmWriteMem32 (
//
// Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT32))) {
if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT32))) {
*(UINT32 *)Addr = Data;
} else {
//
Expand Down Expand Up @@ -4857,7 +4857,7 @@ VmWriteMem64 (
//
// Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT64))) {
if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT64))) {
*(UINT64 *)Addr = Data;
} else {
//
Expand Down Expand Up @@ -4922,7 +4922,7 @@ VmWriteMemN (
//
// Do a simple write if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINTN))) {
if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINTN))) {
*(UINTN *)Addr = Data;
} else {
for (Index = 0; Index < sizeof (UINTN) / sizeof (UINT32); Index++) {
Expand Down Expand Up @@ -4985,7 +4985,7 @@ VmReadImmed16 (
//
// Read direct if aligned
//
if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) {
if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) {
return *(INT16 *)(VmPtr->Ip + Offset);
} else {
//
Expand Down Expand Up @@ -5029,7 +5029,7 @@ VmReadImmed32 (
//
// Read direct if aligned
//
if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
return *(INT32 *)(VmPtr->Ip + Offset);
}

Expand Down Expand Up @@ -5068,7 +5068,7 @@ VmReadImmed64 (
//
// Read direct if aligned
//
if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
return *(UINT64 *)(VmPtr->Ip + Offset);
}

Expand Down Expand Up @@ -5105,7 +5105,7 @@ VmReadCode16 (
//
// Read direct if aligned
//
if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT16))) {
if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT16))) {
return *(UINT16 *)(VmPtr->Ip + Offset);
} else {
//
Expand Down Expand Up @@ -5147,7 +5147,7 @@ VmReadCode32 (
//
// Read direct if aligned
//
if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
return *(UINT32 *)(VmPtr->Ip + Offset);
}

Expand Down Expand Up @@ -5184,7 +5184,7 @@ VmReadCode64 (
//
// Read direct if aligned
//
if (IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT64))) {
return *(UINT64 *)(VmPtr->Ip + Offset);
}

Expand Down Expand Up @@ -5247,7 +5247,7 @@ VmReadMem16 (
//
// Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT16))) {
if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT16))) {
return *(UINT16 *)Addr;
}

Expand Down Expand Up @@ -5281,7 +5281,7 @@ VmReadMem32 (
//
// Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT32))) {
if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT32))) {
return *(UINT32 *)Addr;
}

Expand Down Expand Up @@ -5319,7 +5319,7 @@ VmReadMem64 (
//
// Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINT64))) {
if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT64))) {
return *(UINT64 *)Addr;
}

Expand Down Expand Up @@ -5388,7 +5388,7 @@ VmReadMemN (
//
// Read direct if aligned
//
if (IS_ALIGNED (Addr, sizeof (UINTN))) {
if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINTN))) {
return *(UINTN *)Addr;
}

Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Universal/EbcDxe/EbcExecute.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Macros to check and set alignment
//
#define ASSERT_ALIGNED(addr, size) ASSERT (!((UINT32) (addr) & (size - 1)))
#define IS_ALIGNED(addr, size) !((UINT32) (addr) & (size - 1))
#define ASSERT_ALIGNED(addr, size) ASSERT (!((UINT32) (addr) & (size - 1)))
#define ADDRESS_IS_ALIGNED_(addr, size) !((UINT32) (addr) & (size - 1))

//
// Debug macro
Expand Down

0 comments on commit 583f1ab

Please sign in to comment.