Date   

[PATCH 1/2] MdePkg: modify the wrong 'AcpiId' to 'ApicId' in MpWakeupStructure

duntan
 

modify the wrong 'AcpiId' to 'ApicId' of MpWakeupStructure defination
in Acpi64.h.

Signed-off-by: Dun Tan <dun.tan@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Ray Ni <ray.ni@...>
---
MdePkg/Include/IndustryStandard/Acpi64.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h b/MdePkg/Include/IndustryStandard/Acpi64.h
index 575ca0430c..16c2faaaf2 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -607,7 +607,7 @@ typedef struct {
typedef struct {
UINT16 Command;
UINT16 Reserved;
- UINT32 AcpiId;
+ UINT32 ApicId;
UINT64 WakeupVector;
UINT8 ReservedForOs[2032];
UINT8 ReservedForFirmware[2048];
--
2.31.1.windows.1


[PATCH 0/2] Modify defination for MpWakeupStructure

duntan
 

Modify the wrong 'AcpiId' to 'ApicId' of MpWakeupStructure defination.
Add define for Multiprocessor Wakeup Structure Version.

Dun Tan (2):
MdePkg: modify the wrong 'AcpiId' to 'ApicId' in MpWakeupStructure
MdePkg: add define for Multiprocessor Wakeup Structure Version

MdePkg/Include/IndustryStandard/Acpi64.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

--
2.31.1.windows.1


[PATCH 5/5] OvmfPkg: Consume new alignment-related macros

Gerd Hoffmann
 

This patch substitutes the macros that were renamed in the second
patch with the new, shared alignment macros.

Signed-off-by: Gerd Hoffmann <kraxel@...>
---
OvmfPkg/AmdSevDxe/AmdSevDxe.c | 6 ++----
.../BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c | 3 +--
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c
index 71a1eaaf0a1d..9b0d0e92b6f7 100644
--- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c
+++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c
@@ -44,8 +44,6 @@ STATIC BOOLEAN mAcceptAllMemoryAtEBS = TRUE;

STATIC EFI_EVENT mAcceptAllMemoryEvent = NULL;

-#define IS_ALIGNED_(x, y) ((((x) & ((y) - 1)) == 0))
-
STATIC
EFI_STATUS
EFIAPI
@@ -60,8 +58,8 @@ AmdSevMemoryAccept (
// multiple of SIZE_4KB. Use an assert instead of returning an erros since
// this is an EDK2-internal protocol.
//
- ASSERT (IS_ALIGNED_ (StartAddress, SIZE_4KB));
- ASSERT (IS_ALIGNED_ (Size, SIZE_4KB));
+ ASSERT (IS_ALIGNED (StartAddress, SIZE_4KB));
+ ASSERT (IS_ALIGNED (Size, SIZE_4KB));
ASSERT (Size != 0);

MemEncryptSevSnpPreValidateSystemRam (
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
index f35bba5deb46..7a8878b1a9c2 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
@@ -20,7 +20,6 @@

#include "SnpPageStateChange.h"

-#define IS_ALIGNED_(x, y) ((((x) & (y - 1)) == 0))
#define PAGES_PER_LARGE_ENTRY 512

STATIC
@@ -150,7 +149,7 @@ BuildPageStateBuffer (
//
// Is this a 2MB aligned page? Check if we can use the Large RMP entry.
//
- if (UseLargeEntry && IS_ALIGNED_ (BaseAddress, SIZE_2MB) &&
+ if (UseLargeEntry && IS_ALIGNED (BaseAddress, SIZE_2MB) &&
((EndAddress - BaseAddress) >= SIZE_2MB))
{
RmpPageSize = PvalidatePageSize2MB;
--
2.39.2


[PATCH 4/5] MdeModulePkg: Consume new alignment-related macros

Gerd Hoffmann
 

From: Marvin Häuser <mhaeuser@...>

This patch substitutes the macros that were renamed in the first
patch with the new, shared alignment macros.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Ray Ni <ray.ni@...>
Cc: Vitaly Cheptsov <vit9696@...>
Signed-off-by: Marvin Häuser <mhaeuser@...>
---
MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h | 3 +-
.../Ata/AtaAtapiPassThru/AtaAtapiPassThru.h | 2 --
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h | 1 -
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 2 --
.../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h | 2 --
.../Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 2 --
MdeModulePkg/Universal/EbcDxe/EbcExecute.h | 3 +-
MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c | 2 +-
.../Bus/Ata/AhciPei/AhciPeiPassThru.c | 6 ++--
.../Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 12 +++----
.../Bus/Ata/AtaBusDxe/AtaPassThruExecute.c | 2 +-
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 4 +--
.../Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 6 ++--
MdeModulePkg/Universal/EbcDxe/EbcExecute.c | 36 +++++++++----------
14 files changed, 36 insertions(+), 47 deletions(-)

diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
index 71d34c962ad1..e2e4ba43e7c4 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
@@ -146,8 +146,7 @@ typedef union {
#define AHCI_PORT_SERR 0x0030
#define AHCI_PORT_CI 0x0038

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

#pragma pack(1)

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
index 7937886614e1..016fc6890ae9 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
@@ -148,8 +148,6 @@ struct _ATA_NONBLOCK_TASK {
#define ATA_ATAPI_TIMEOUT EFI_TIMER_PERIOD_SECONDS(3)
#define ATA_SPINUP_TIMEOUT EFI_TIMER_PERIOD_SECONDS(10)

-#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
-
#define ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
ATA_ATAPI_PASS_THRU_INSTANCE, \
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
index 47346e911d47..6bc345f7e777 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
@@ -76,7 +76,6 @@
#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 ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)

//
// ATA bus data structure for ATA controller
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
index ed384ad52182..5a25b55c4952 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
@@ -38,8 +38,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

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

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

typedef struct {
diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h
index 1adb382aa8c3..ed4776f548e0 100644
--- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h
+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h
@@ -133,8 +133,6 @@ typedef struct _UFS_PEIM_HC_PRIVATE_DATA {

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

-#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)
#define GET_UFS_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a) CR (a, UFS_PEIM_HC_PRIVATE_DATA, EndOfPeiNotifyList, UFS_PEIM_HC_SIG)
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
index 0ec37e56652b..bc1139da6e3b 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
@@ -105,8 +105,6 @@ typedef struct {

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

-#define ADDRESS_IS_ALIGNED_(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
-
#define UFS_PASS_THRU_PRIVATE_DATA_FROM_THIS(a) \
CR (a, \
UFS_PASS_THRU_PRIVATE_DATA, \
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h
index 6dc6730ab095..f3768e79528e 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h
+++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h
@@ -14,8 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Macros to check and set alignment
//
-#define ASSERT_ALIGNED(addr, size) ASSERT (!((UINT32) (addr) & (size - 1)))
-#define ADDRESS_IS_ALIGNED_(addr, size) !((UINT32) (addr) & (size - 1))
+#define ASSERT_ALIGNED(addr, size) ASSERT (ADDRESS_IS_ALIGNED (addr, size))

//
// Debug macro
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
index d93fa78c81f3..0f0198d3085b 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
@@ -2126,7 +2126,7 @@ TrustTransferAtaDevice (
// ATA PassThru PPI.
//
if ((AtaPassThru->Mode->IoAlign > 1) &&
- !ADDRESS_IS_ALIGNED_ (Buffer, AtaPassThru->Mode->IoAlign))
+ !ADDRESS_IS_ALIGNED (Buffer, AtaPassThru->Mode->IoAlign))
{
NewBuffer = AllocateAlignedPages (
EFI_SIZE_TO_PAGES (TransferLength),
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
index 0c49059a00d5..cd55272c96cd 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
@@ -194,15 +194,15 @@ AhciAtaPassThruPassThru (
}

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

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

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

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
index 324abadd02dd..50406fe0270d 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
@@ -1299,15 +1299,15 @@ AtaPassThruPassThru (

Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This);

- if ((This->Mode->IoAlign > 1) && !ADDRESS_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) && !ADDRESS_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) && !ADDRESS_IS_ALIGNED_ (Packet->Asb, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->Asb, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

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

- if ((This->Mode->IoAlign > 1) && !ADDRESS_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) && !ADDRESS_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) && !ADDRESS_IS_ALIGNED_ (Packet->SenseData, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->SenseData, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
index 18aa4f9bb666..a77852bae054 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
@@ -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) && !ADDRESS_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;
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index faf4ae332e46..873581d817ce 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -2029,7 +2029,7 @@ ScsiDiskReceiveData (
goto Done;
}

- if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_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;
@@ -2249,7 +2249,7 @@ ScsiDiskSendData (
goto Done;
}

- if ((ScsiDiskDevice->ScsiIo->IoAlign > 1) && !ADDRESS_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;
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
index 392a295caf04..880e7d85114e 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
@@ -171,15 +171,15 @@ UfsPassThruPassThru (
return EFI_INVALID_PARAMETER;
}

- if ((This->Mode->IoAlign > 1) && !ADDRESS_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) && !ADDRESS_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) && !ADDRESS_IS_ALIGNED_ (Packet->SenseData, This->Mode->IoAlign)) {
+ if ((This->Mode->IoAlign > 1) && !ADDRESS_IS_ALIGNED (Packet->SenseData, This->Mode->IoAlign)) {
return EFI_INVALID_PARAMETER;
}

diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
index 28f108c44873..3221f95a739f 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
@@ -2015,7 +2015,7 @@ ExecuteJMP (
// check for alignment, and jump absolute.
//
Data64 = (UINT64)VmReadImmed64 (VmPtr, 2);
- if (!ADDRESS_IS_ALIGNED_ ((UINTN)Data64, sizeof (UINT16))) {
+ if (!ADDRESS_IS_ALIGNED ((UINTN)Data64, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -2074,7 +2074,7 @@ ExecuteJMP (
// Form: JMP32 @Rx {Index32}
//
Addr = VmReadMemN (VmPtr, (UINTN)Data64 + Index32);
- if (!ADDRESS_IS_ALIGNED_ ((UINTN)Addr, sizeof (UINT16))) {
+ if (!ADDRESS_IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -2097,7 +2097,7 @@ ExecuteJMP (
// Form: JMP32 Rx {Immed32}
//
Addr = (UINTN)(Data64 + Index32);
- if (!ADDRESS_IS_ALIGNED_ ((UINTN)Addr, sizeof (UINT16))) {
+ if (!ADDRESS_IS_ALIGNED ((UINTN)Addr, sizeof (UINT16))) {
EbcDebugSignalException (
EXCEPT_EBC_ALIGNMENT_CHECK,
EXCEPTION_FLAG_FATAL,
@@ -3158,7 +3158,7 @@ ExecuteRET (
// Pull the return address off the VM app's stack and set the IP
// to it
//
- if (!ADDRESS_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,
@@ -4733,7 +4733,7 @@ VmWriteMem16 (
//
// Do a simple write if aligned
//
- if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT16))) {
+ if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT16))) {
*(UINT16 *)Addr = Data;
} else {
//
@@ -4795,7 +4795,7 @@ VmWriteMem32 (
//
// Do a simple write if aligned
//
- if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT32))) {
+ if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT32))) {
*(UINT32 *)Addr = Data;
} else {
//
@@ -4857,7 +4857,7 @@ VmWriteMem64 (
//
// Do a simple write if aligned
//
- if (ADDRESS_IS_ALIGNED_ (Addr, sizeof (UINT64))) {
+ if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINT64))) {
*(UINT64 *)Addr = Data;
} else {
//
@@ -4922,7 +4922,7 @@ VmWriteMemN (
//
// Do a simple write if aligned
//
- if (ADDRESS_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++) {
@@ -4985,7 +4985,7 @@ VmReadImmed16 (
//
// Read direct if aligned
//
- if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) {
+ if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (INT16))) {
return *(INT16 *)(VmPtr->Ip + Offset);
} else {
//
@@ -5029,7 +5029,7 @@ VmReadImmed32 (
//
// Read direct if aligned
//
- if (ADDRESS_IS_ALIGNED_ ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
+ if (ADDRESS_IS_ALIGNED ((UINTN)VmPtr->Ip + Offset, sizeof (UINT32))) {
return *(INT32 *)(VmPtr->Ip + Offset);
}

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

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

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

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

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

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

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

--
2.39.2


[PATCH 2/5] OvmfPkg: Rename IS_ALIGNED macros to avoid name collisions

Gerd Hoffmann
 

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 OvmfPkg.
Temporarily rename them to avoid build failure, till they can be
substituted with the new, shared definitions.

Signed-off-by: Gerd Hoffmann <kraxel@...>
---
OvmfPkg/AmdSevDxe/AmdSevDxe.c | 6 +++---
.../BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/AmdSevDxe/AmdSevDxe.c b/OvmfPkg/AmdSevDxe/AmdSevDxe.c
index a726498e2792..71a1eaaf0a1d 100644
--- a/OvmfPkg/AmdSevDxe/AmdSevDxe.c
+++ b/OvmfPkg/AmdSevDxe/AmdSevDxe.c
@@ -44,7 +44,7 @@ STATIC BOOLEAN mAcceptAllMemoryAtEBS = TRUE;

STATIC EFI_EVENT mAcceptAllMemoryEvent = NULL;

-#define IS_ALIGNED(x, y) ((((x) & ((y) - 1)) == 0))
+#define IS_ALIGNED_(x, y) ((((x) & ((y) - 1)) == 0))

STATIC
EFI_STATUS
@@ -60,8 +60,8 @@ AmdSevMemoryAccept (
// multiple of SIZE_4KB. Use an assert instead of returning an erros since
// this is an EDK2-internal protocol.
//
- ASSERT (IS_ALIGNED (StartAddress, SIZE_4KB));
- ASSERT (IS_ALIGNED (Size, SIZE_4KB));
+ ASSERT (IS_ALIGNED_ (StartAddress, SIZE_4KB));
+ ASSERT (IS_ALIGNED_ (Size, SIZE_4KB));
ASSERT (Size != 0);

MemEncryptSevSnpPreValidateSystemRam (
diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
index 4d684964d838..f35bba5deb46 100644
--- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
+++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c
@@ -20,7 +20,7 @@

#include "SnpPageStateChange.h"

-#define IS_ALIGNED(x, y) ((((x) & (y - 1)) == 0))
+#define IS_ALIGNED_(x, y) ((((x) & (y - 1)) == 0))
#define PAGES_PER_LARGE_ENTRY 512

STATIC
@@ -150,7 +150,7 @@ BuildPageStateBuffer (
//
// Is this a 2MB aligned page? Check if we can use the Large RMP entry.
//
- if (UseLargeEntry && IS_ALIGNED (BaseAddress, SIZE_2MB) &&
+ if (UseLargeEntry && IS_ALIGNED_ (BaseAddress, SIZE_2MB) &&
((EndAddress - BaseAddress) >= SIZE_2MB))
{
RmpPageSize = PvalidatePageSize2MB;
--
2.39.2


[PATCH 3/5] MdePkg/Base.h: Introduce various alignment-related macros

Gerd Hoffmann
 

From: Marvin Häuser <mhaeuser@...>

ALIGNOF: Determining the alignment requirement of data types is
crucial to ensure safe memory accesses when parsing untrusted data.

IS_POW2: Determining whether a value is a power of two is important
to verify whether untrusted values are valid alignment values.

IS_ALIGNED: In combination with ALIGNOF data offsets can be verified.
A more general version of the IS_ALIGNED macro previously defined by several modules.

ADDRESS_IS_ALIGNED: Variant of IS_ALIGNED for pointers and addresses.
Replaces module-specific definitions throughout the codebase.

ALIGN_VALUE_ADDEND: The addend to align up can be used to directly
determine the required offset for data alignment.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Vitaly Cheptsov <vit9696@...>
Signed-off-by: Marvin Häuser <mhaeuser@...>
---
MdePkg/Include/Base.h | 95 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index d209e6de280a..2053314b50d1 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -758,6 +758,40 @@ typedef UINTN *BASE_LIST;
#define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
#endif

+/**
+ Returns the alignment requirement of a type.
+
+ @param TYPE The name of the type to retrieve the alignment requirement of.
+
+ @return Alignment requirement, in Bytes, of TYPE.
+**/
+#if defined (__cplusplus)
+//
+// Standard C++ operator.
+//
+#define ALIGNOF(TYPE) alignof (TYPE)
+#elif defined (__GNUC__) || defined (__clang__) || (defined (_MSC_VER) && _MSC_VER >= 1900)
+//
+// All supported versions of GCC and Clang, as well as MSVC 2015 and later,
+// support the standard operator _Alignof.
+//
+#define ALIGNOF(TYPE) _Alignof (TYPE)
+#elif defined (_MSC_EXTENSIONS)
+//
+// Earlier versions of MSVC, at least MSVC 2008 and later, support the vendor
+// extension __alignof.
+//
+#define ALIGNOF(TYPE) __alignof (TYPE)
+#else
+//
+// For compilers that do not support inbuilt alignof operators, use OFFSET_OF.
+// CHAR8 is known to have both a size and an alignment requirement of 1 Byte.
+// As such, A must be located exactly at the offset equal to its alignment
+// requirement.
+//
+#define ALIGNOF(TYPE) OFFSET_OF (struct { CHAR8 C; TYPE A; }, A)
+#endif
+
/**
Portable definition for compile time assertions.
Equivalent to C11 static_assert macro from assert.h.
@@ -793,6 +827,21 @@ STATIC_ASSERT (sizeof (CHAR16) == 2, "sizeof (CHAR16) does not meet UEFI Specif
STATIC_ASSERT (sizeof (L'A') == 2, "sizeof (L'A') does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (sizeof (L"A") == 4, "sizeof (L\"A\") does not meet UEFI Specification Data Type requirements");

+STATIC_ASSERT (ALIGNOF (BOOLEAN) == sizeof (BOOLEAN), "Alignment of BOOLEAN does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (INT8) == sizeof (INT8), "Alignment of INT8 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (UINT8) == sizeof (UINT8), "Alignment of INT16 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (INT16) == sizeof (INT16), "Alignment of INT16 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (UINT16) == sizeof (UINT16), "Alignment of UINT16 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (INT32) == sizeof (INT32), "Alignment of INT32 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (UINT32) == sizeof (UINT32), "Alignment of UINT32 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (INT64) == sizeof (INT64), "Alignment of INT64 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (UINT64) == sizeof (UINT64), "Alignment of UINT64 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (CHAR8) == sizeof (CHAR8), "Alignment of CHAR8 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (CHAR16) == sizeof (CHAR16), "Alignment of CHAR16 does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (INTN) == sizeof (INTN), "Alignment of INTN does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (UINTN) == sizeof (UINTN), "Alignment of UINTN does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (VOID *) == sizeof (VOID *), "Alignment of VOID * does not meet UEFI Specification Data Type requirements");
+
//
// The following three enum types are used to verify that the compiler
// configuration for enum types is compliant with Section 2.3.1 of the
@@ -816,6 +865,10 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of enum does not me
STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");

+STATIC_ASSERT (ALIGNOF (__VERIFY_UINT8_ENUM_SIZE) == sizeof (__VERIFY_UINT8_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (__VERIFY_UINT16_ENUM_SIZE) == sizeof (__VERIFY_UINT16_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (ALIGNOF (__VERIFY_UINT32_ENUM_SIZE) == sizeof (__VERIFY_UINT32_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
+
/**
Macro that returns a pointer to the data structure that contains a specified field of
that data structure. This is a lightweight method to hide information by placing a
@@ -837,6 +890,46 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not m
**/
#define BASE_CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - OFFSET_OF (TYPE, Field)))

+/**
+ Checks whether a value is a power of two.
+
+ @param Value The value to check.
+
+ @return Whether Value is a power of two.
+**/
+#define IS_POW2(Value) ((Value) != 0U && ((Value) & ((Value) - 1U)) == 0U)
+
+/**
+ Checks whether a value is aligned by a specified alignment.
+
+ @param Value The value to check.
+ @param Alignment The alignment boundary used to check against.
+
+ @return Whether Value is aligned by Alignment.
+**/
+#define IS_ALIGNED(Value, Alignment) (((Value) & ((Alignment) - 1U)) == 0U)
+
+/**
+ Checks whether a pointer or address is aligned by a specified alignment.
+
+ @param Address The pointer or address to check.
+ @param Alignment The alignment boundary used to check against.
+
+ @return Whether Address is aligned by Alignment.
+**/
+#define ADDRESS_IS_ALIGNED(Address, Alignment) IS_ALIGNED ((UINTN) (Address), Alignment)
+
+/**
+ Determines the addend to add to a value to round it up to the next boundary of
+ a specified alignment.
+
+ @param Value The value to round up.
+ @param Alignment The alignment boundary used to return the addend.
+
+ @return Addend to round Value up to alignment boundary Alignment.
+**/
+#define ALIGN_VALUE_ADDEND(Value, Alignment) (((Alignment) - (Value)) & ((Alignment) - 1U))
+
/**
Rounds a value up to the next boundary using a specified alignment.

@@ -849,7 +942,7 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not m
@return A value up to the next boundary.

**/
-#define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1)))
+#define ALIGN_VALUE(Value, Alignment) ((Value) + ALIGN_VALUE_ADDEND (Value, Alignment))

/**
Adjust a pointer by adding the minimum offset required for it to be aligned on
--
2.39.2


[PATCH 1/5] MdeModulePkg: Rename IS_ALIGNED macros to avoid name collisions

Gerd Hoffmann
 

From: Marvin Häuser <mhaeuser@...>

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@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Ray Ni <ray.ni@...>
Signed-off-by: Marvin Häuser <mhaeuser@...>
---
MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h | 4 +--
.../Ata/AtaAtapiPassThru/AtaAtapiPassThru.h | 2 +-
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h | 2 +-
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 2 +-
.../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h | 2 +-
.../Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 2 +-
MdeModulePkg/Universal/EbcDxe/EbcExecute.h | 4 +--
MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c | 2 +-
.../Bus/Ata/AhciPei/AhciPeiPassThru.c | 6 ++--
.../Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 12 +++----
.../Bus/Ata/AtaBusDxe/AtaPassThruExecute.c | 2 +-
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 4 +--
.../Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 6 ++--
MdeModulePkg/Universal/EbcDxe/EbcExecute.c | 36 +++++++++----------
14 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
index 4aed1cb7ad8a..71d34c962ad1 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h
@@ -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)

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
index 62ba6d6680dd..7937886614e1 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.h
@@ -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, \
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
index 4428c484fd6c..47346e911d47 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h
@@ -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
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
index 5b4047e1dbdd..ed384ad52182 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
@@ -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

diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h
index a0b615b7eab3..1adb382aa8c3 100644
--- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h
+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h
@@ -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)
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
index 2b4f5d32d901..0ec37e56652b 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
@@ -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, \
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h
index 32b8670c5b2a..6dc6730ab095 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h
+++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h
@@ -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
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
index 7b97887c5dbd..d93fa78c81f3 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c
@@ -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),
diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
index d5ed93dc4f67..0c49059a00d5 100644
--- a/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
+++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciPeiPassThru.c
@@ -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;
}

diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
index 1070516b358a..324abadd02dd 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
@@ -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;
}

@@ -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;
}

diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
index 4334169d256a..18aa4f9bb666 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
@@ -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;
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index fbc236cb465e..faf4ae332e46 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -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;
@@ -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;
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
index ae593ff03a0d..392a295caf04 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
@@ -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;
}

diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
index 82a7782fb99a..28f108c44873 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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 {
//
@@ -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 {
//
@@ -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 {
//
@@ -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++) {
@@ -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 {
//
@@ -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);
}

@@ -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);
}

@@ -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 {
//
@@ -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);
}

@@ -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);
}

@@ -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;
}

@@ -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;
}

@@ -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;
}

@@ -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;
}

--
2.39.2


[PATCH 0/5] MdePkg/Base.h: Introduce various alignment-related macros

Gerd Hoffmann
 

Gerd Hoffmann (2):
OvmfPkg: Rename IS_ALIGNED macros to avoid name collisions
OvmfPkg: Consume new alignment-related macros

Marvin Häuser (3):
MdeModulePkg: Rename IS_ALIGNED macros to avoid name collisions
MdePkg/Base.h: Introduce various alignment-related macros
MdeModulePkg: Consume new alignment-related macros

MdeModulePkg/Bus/Ata/AhciPei/AhciPei.h | 1 -
.../Ata/AtaAtapiPassThru/AtaAtapiPassThru.h | 2 -
MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h | 1 -
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h | 2 -
.../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.h | 2 -
.../Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 2 -
MdeModulePkg/Universal/EbcDxe/EbcExecute.h | 3 +-
MdePkg/Include/Base.h | 95 ++++++++++++++++++-
MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c | 2 +-
.../Bus/Ata/AhciPei/AhciPeiPassThru.c | 6 +-
.../Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 12 +--
.../Bus/Ata/AtaBusDxe/AtaPassThruExecute.c | 2 +-
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 4 +-
.../Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 6 +-
MdeModulePkg/Universal/EbcDxe/EbcExecute.c | 36 +++----
OvmfPkg/AmdSevDxe/AmdSevDxe.c | 2 -
.../X64/SnpPageStateChangeInternal.c | 1 -
17 files changed, 129 insertions(+), 50 deletions(-)

--
2.39.2


Re: [edk2 0/3] v2 RISC-V SBI-backed SerialLib

Sunil V L
 

On Thu, Mar 02, 2023 at 03:49:17PM -0600, Andrei Warkentin wrote:
Hello!

Here are three patches that provide a SerialLib backed by SBI console. Both legacy and DBCN mechanisms
are supported in various execution environments and have been tested (with UART and HTIF).

This is also available at https://github.com/andreiw/edk2-rv-wip/tree/patchset-2
Hi Andrei,

Here are some quick comments.

1) Please run python BaseTools/Scripts/SetupGit.py -n edk2 in your clone
always.

2) Please run BaseTools/Scripts/PatchCheck.py on each patch/commit and
fix the errors.

for ex: I see many CRLF errors

* Line ending ('\n') is not CRLF
File: OvmfPkg/RiscVVirt/Sec/SecMain.c


3)Since these are new INF files, it should have INF_VERSION as 1.27
(0x0001001B)

https://tianocore-docs.github.io/edk2-InfSpecification/release-1.27/2_inf_overview/24_[defines]_section.html#24-defines-section

4) GUID should be unique for different libraries.

5) MODULE_TYPE should not be BASE but something like SEC|PEI. BASE will
include DXE also. Similarly, DXE library should exclude SEC/PEI.

6) Legacy extensions can be deprecated. So, I think it is
better to probe both DBCN and legacy extension and then only use it.

Will review in detail some time next week.

Thanks,
Sunil


Tianocore Community meeting EMEA/NAMO/APAC 20230302

Demeter, Miki
 

# TianoCore Community Meeting

**Highlights:**

  • GHSA Discussion/Update – GHSR and GHSA will be trialed through the next Stable Tag release in May
  • Assessment of edk2-platform with goal to remove stale/abandoned code
  • SBOM – Recognize need for it but lots of work to define minimum set of expectations

 

 

# Meeting Minutes:

 **Opens (_30 minutes_)**

  • Miki - GHSA Discussion/Update – GHSR and GHSA will be trialed through the next Stable Tag release in May


**Event Updates (_5 minutes]**

  • No Update

 

**Stable Tag Updates (_5 minutes_)**

  • edk2-stable202211 Current Stable Release
  • Soft Freeze 2023-02-06
  • Hard Freeze 2023-03-03
  • Release 2023-03-03

 

**Stewards Download (_20 minutes_)**

  • Assessment of edk2-platform with goal to remove stale/abandoned code
  • SBOM – Recognize need for it but lots of work to define minimum set of expectations

 

 

Join the UEFI Talkbox Discord Server!

Check out the UEFI Talkbox community on Discord - hang out with 66 other members and enjoy free voice and text chat.

This is the link to join the Discord:
https://discord.gg/DrmDQAv


** Next Meeting

 

April 6, 2023 8-9am PST and 7:30-8:30pm PST

-- 

Miki Demeter (she/her/Miki)

Security Researcher / FW Developer

FST

Intel Corporation

 

Co-Chair, Network of Intel African-Ancestry(NIA) - Oregon

NIA-Oregon

 

Portland Women in Tech Best Speaker

miki.demeter@...

503.712.8030 (office)

971.248.0123 (cell)

 


[PATCH V2] MdePkg/Include: Add DMTF MCTP definitions

Chang, Abner
 

From: Abner Chang <abner.chang@...>

BZ #4355
This change adds definitions for DMTF MCTP
base specification.

Spec ref:
https://www.dmtf.org/sites/default/files/standards/documents/DSP0236_1.3.1.pdf

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Nickle Wang <nicklew@...>
Cc: Igor Kulchytskyy <igork@...>
Cc: Isaac Oram <isaac.w.oram@...>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
MdePkg/Include/IndustryStandard/Mctp.h | 114 +++++++++++++++++++++++++
1 file changed, 114 insertions(+)
create mode 100644 MdePkg/Include/IndustryStandard/Mctp.h

diff --git a/MdePkg/Include/IndustryStandard/Mctp.h b/MdePkg/Include/IndustryStandard/Mctp.h
new file mode 100644
index 00000000000..b71063a6502
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Mctp.h
@@ -0,0 +1,114 @@
+/** @file
+
+ The definitions of DMTF Management Component Transport Protocol (MCTP)
+ Base Specification.
+
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Revision Reference:
+ DMTF Management Component Transport Protocol (MCTP) Base Specification
+ Version 1.3.1
+ https://www.dmtf.org/sites/default/files/standards/documents/DSP0236_1.3.1.pdf
+**/
+
+#ifndef MCTP_H_
+#define MCTP_H_
+
+///
+/// Definitions of endpoint ID
+///
+#define MCTP_NULL_DESTINATION_ENDPOINT_ID 0
+#define MCTP_NULL_SOURCE_ENDPOINT_ID 0
+#define MCTP_RESERVED_ENDPOINT_START_ID 1
+#define MCTP_RESERVED_ENDPOINT_END_ID 7
+#define MCTP_BROADCAST_ENDPOINT_ID 0xFF
+
+// Minimum transmission size is 64 bytes.
+#define MCTP_BASELINE_MINIMUM_UNIT_TRANSMISSION_SIZE 0x40
+
+///
+/// The 32-bit Header of MCTP packet.
+///
+typedef union {
+ struct {
+ UINT8 Reserved : 4; ///< Reserved for future definitions.
+ UINT8 HeaderVersion : 4; ///< The version of header.
+ UINT8 DestinationEndpointId : 8; ///< Destination endpoint Id (EID).
+ UINT8 SourceEndpointId : 8; ///< Source endpoint Id (EID)
+ UINT8 StartOfMessage : 1; ///< Indicates the first packet of message.
+ UINT8 EndOfMessage : 1; ///< Indicates the last packet of message.
+ UINT8 PacketSequence : 2; ///< Sequence number increments modulo 4 on
+ ///< each packet.
+ UINT8 TagOwner : 1; ///< Tag owner identifies the message was
+ ///< originated by the source EID or
+ ///< destination EID.
+ UINT8 MessageTag : 3; ///< Check the MCTP Base specification for the
+ ///< usages.
+ } Bits;
+ UINT32 Header;
+} MCTP_HEADER;
+
+///
+/// MCTP Control Commands
+///
+#define MCTP_CONTROL_RESERVED 0x00
+#define MCTP_CONTROL_SET_ENDPOINT_ID 0x01
+#define MCTP_CONTROL_GET_ENDPOINT_ID 0x02
+#define MCTP_CONTROL_GET_ENDPOINT_UUID 0x03
+#define MCTP_CONTROL_GET_MCTP_VERSION_SUPPORT 0x04
+#define MCTP_CONTROL_GET_MESSAGE_TYPE_SUPPORT 0x05
+#define MCTP_CONTROL_GET_VENDOR_DEFINED_MESSAGE_SUPPORT 0x06
+#define MCTP_CONTROL_RESOLVE_ENDPOINT_ID 0x07
+#define MCTP_CONTROL_ALLOCATE_ENDPOINT_IDS 0x08
+#define MCTP_CONTROL_ROUTING_INFORMATION_UPDATE 0x09
+#define MCTP_CONTROL_GET_ROUTINE_TABLE_ENTRIES 0x0A
+#define MCTP_CONTROL_PREPARE_FOR_ENDPOINT_DISCOVERY 0x0B
+#define MCTP_CONTROL_ENDPOINT_DISCOVERY 0x0C
+#define MCTP_CONTROL_DISCOVERY_NOTIFY 0x0D
+#define MCTP_CONTROL_GET_NETWORK_ID 0x0E
+#define MCTP_CONTROL_QUERY_HOP 0x0F
+#define MCTP_CONTROL_RESOLVE_UUID 0x10
+#define MCTP_CONTROL_QUERY_RATE_LIMIT 0x11
+#define MCTP_CONTROL_REQUEST_TX_RATE_LIMIT 0x12
+#define MCTP_CONTROL_UPDATE_RATE_LIMIT 0x13
+#define MCTP_CONTROL_QUERY_SUPPORTED_INTERFACES 0x14
+#define MCTP_CONTROL_TRANSPORT_SPECIFIC_START 0xF0
+#define MCTP_CONTROL_TRANSPORT_SPECIFIC_END 0xFF
+
+///
+/// MCTP Control Message Completion Codes
+///
+#define MCTP_CONTROL_COMPLETION_CODES_SUCCESS 0x00
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR 0x01
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR_INVALID_DATA 0x02
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR_INVALID_LENGTH 0x03
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR_NOT_READY 0x04
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR_UNSUPPORTED_CMD 0x05
+#define MCTP_CONTROL_COMPLETION_CODES_COMMAND_SPECIFIC_START 0x80
+#define MCTP_CONTROL_COMPLETION_CODES_COMMAND_SPECIFIC_END 0xFF
+
+///
+/// MCTP Control Message Types
+///
+#define MCTP_MESSAGE_TYPE_CONTROL 0x00
+#define MCTP_MESSAGE_TYPE_VENDOR_DEFINED_PCI 0x7E
+#define MCTP_MESSAGE_TYPE_VENDOR_DEFINED_IANA 0x7F
+
+///
+/// MCTP Control Message Format
+///
+typedef struct {
+ struct {
+ UINT8 IntegrityCheck : 1; ///< Message integrity check.
+ UINT8 MessageType : 7; ///< Message type.
+ UINT8 RequestBit : 1; ///< Request bit.
+ UINT8 DatagramBit : 1; ///< Datagram bit.
+ UINT8 Reserved : 1; ///< Reserved bit.
+ UINT8 InstanceId : 5; ///< Instance ID.
+ UINT8 CommandCode : 8; ///< Command code of request message.
+ UINT8 CompletionCode : 8; ///< Completion code in response message.
+ } Bits;
+ UINT32 BodyHeader;
+} MCTP_CONTROL_MESSAGE;
+#endif
--
2.37.1.windows.1


[PATCH V2] MdePkg/Include: Add IPMI KCS definitions

Chang, Abner
 

From: Abner Chang <abner.chang@...>

BZ #4354
This change adds definitions for IPMI KCS.

Spec ref:
https://www.intel.com/content/www/us/en/products/docs/servers/ipmi/ipmi-second-gen-interface-spec-v2-rev1-1.html

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Nickle Wang <nicklew@...>
Cc: Igor Kulchytskyy <igork@...>
Cc: Isaac Oram <isaac.w.oram@...>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
MdePkg/MdePkg.dec | 5 ++
MdePkg/Include/IndustryStandard/IpmiKcs.h | 77 +++++++++++++++++++++++
2 files changed, 82 insertions(+)
create mode 100644 MdePkg/Include/IndustryStandard/IpmiKcs.h

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 3d08f20d15b..0ed033983bf 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -9,6 +9,7 @@
# (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP<BR>
# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -2332,6 +2333,10 @@
# @Prompt Memory Address of GuidedExtractHandler Table.
gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x1000000|UINT64|0x30001015

+ ## This value is the IPMI KCS Interface I/O base address used to transmit IPMI commands.
+ # @Prompt IPMI KCS Interface I/O Base Address
+ gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress|0xca2|UINT16|0x00000031
+
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This value is used to set the base address of PCI express hierarchy.
# @Prompt PCI Express Base Address.
diff --git a/MdePkg/Include/IndustryStandard/IpmiKcs.h b/MdePkg/Include/IndustryStandard/IpmiKcs.h
new file mode 100644
index 00000000000..6533135dcde
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/IpmiKcs.h
@@ -0,0 +1,77 @@
+/** @file
+ IPMI KCS Register Definitions
+
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Revision Reference:
+ IPMI Specification
+ Version 2.0, Rev. 1.1
+ https://www.intel.com/content/www/us/en/products/docs/servers/ipmi/ipmi-second-gen-interface-spec-v2-rev1-1.html
+**/
+
+#ifndef IPMI_KCS_H_
+#define IPMI_KCS_H_
+
+#define IPMI_KCS_STATUS_REGISTER_OFFSET 1
+#define IPMI_KCS_COMMAND_REGISTER_OFFSET 1
+#define IPMI_KCS_DATA_OUT_REGISTER_OFFSET 0
+#define IPMI_KCS_DATA_IN_REGISTER_OFFSET 0
+
+///
+/// IPMI KCS Interface Status Bits
+///
+#define IPMI_KCS_OBF BIT0
+#define IPMI_KCS_IBF BIT1
+#define IPMI_KCS_SMS_ATN BIT2
+#define IPMI_KCS_COMMAND_DATA BIT3
+#define IPMI_KCS_OEM1 BIT4
+#define IPMI_KCS_OEM2 BIT5
+#define IPMI_KCS_S0 BIT6
+#define IPMI_KCS_S1 BIT7
+
+///
+/// IPMI KCS Interface Control Codes
+///
+#define IPMI_KCS_CONTROL_CODE_GET_STATUS_ABORT 0x60
+#define IPMI_KCS_CONTROL_CODE_WRITE_START 0x61
+#define IPMI_KCS_CONTROL_CODE_WRITE_END 0x62
+#define IPMI_KCS_CONTROL_CODE_READ 0x68
+
+///
+/// Status Codes
+///
+#define IPMI_KCS_STATUS_NO_ERROR 0x00
+#define IPMI_KCS_STATUS_ABORT 0x01
+#define IPMI_KCS_STATUS_ILLEGAL 0x02
+#define IPMI_KCS_STATUS_LENGTH_ERROR 0x06
+#define IPMI_KCS_STATUS_UNSPECIFIED 0xFF
+
+///
+/// KCS Interface State Bit
+///
+typedef enum {
+ IPMI_KCS_IDLE_STATE = 0,
+ IPMI_KCS_READ_STATE,
+ IPMI_KCS_WRITE_STATE,
+ IPMI_KCS_ERROR_STATE
+} IPMI_KCS_STATE;
+
+///
+/// IPMI KCS Interface Request Format
+///
+typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 Data[0];
+} IPMI_KCS_RESQUEST_HEADER;
+
+///
+/// IPMI KCS Interface Response Format
+///
+typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 CompletionCode;
+} IPMI_KCS_RESPONSE_HEADER;
+#endif
--
2.37.1.windows.1


Event: TianoCore Community Meeting - APAC/NAMO - Thursday, March 2, 2023 #cal-reminder

Group Notification <noreply@...>
 

Reminder: TianoCore Community Meeting - APAC/NAMO

When:
Thursday, March 2, 2023
7:30pm to 8:30pm
(UTC-08:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_Y2M1NDE3ODYtN2M3Yy00MDMxLTk3OWYtMTlkNjhlNWFlMjA2%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d

Organizer: Miki Demeter

View Event

Description:

 

________________________________________________________________________________

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Meeting ID: 283 318 374 436
Passcode: 633zLo

Download Teams | Join on the web

Join with a video conferencing device

teams@...

Video Conference ID: 119 493 012 8

Alternate VTC instructions

Learn More | Meeting options

________________________________________________________________________________


Re: [PATCH] MdePkg/Include: Add IPMI KCS definitions

Chang, Abner
 

[AMD Official Use Only - General]

Ah got you. will send out the V2 for the link to spec.

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@...>
Sent: Friday, March 3, 2023 11:05 AM
To: devel@edk2.groups.io; Chang, Abner <Abner.Chang@...>
Cc: Gao, Liming <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Nickle Wang <nicklew@...>; Igor
Kulchytskyy <igork@...>; Oram, Isaac W <isaac.w.oram@...>;
Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@...>; Kinney,
Michael D <michael.d.kinney@...>
Subject: RE: [edk2-devel] [PATCH] MdePkg/Include: Add IPMI KCS
definitions

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


I meant in the MdePkg/Include/IndustryStandard/IpmiKcs.h file and the
commit message in this patch that adds that file.

Mike

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang,
Abner via groups.io
Sent: Thursday, March 2, 2023 7:03 PM
To: Kinney, Michael D <michael.d.kinney@...>;
devel@edk2.groups.io
Cc: Gao, Liming <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Nickle Wang <nicklew@...>; Igor
Kulchytskyy <igork@...>; Oram, Isaac W <isaac.w.oram@...>;
Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@...>
Subject: Re: [edk2-devel] [PATCH] MdePkg/Include: Add IPMI KCS
definitions

[AMD Official Use Only - General]

Ok, that would be the patch set for edk2-platform I am going to send
later, will update these two edk2 industry standard definition patches (KCS
and MCTP) after edk2-platforms one.

Thanks
Abner

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@...>
Sent: Friday, March 3, 2023 11:00 AM
To: Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Gao, Liming <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Nickle Wang <nicklew@...>; Igor
Kulchytskyy <igork@...>; Oram, Isaac W
<isaac.w.oram@...>;
Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@...>;
Kinney, Michael D <michael.d.kinney@...>
Subject: RE: [PATCH] MdePkg/Include: Add IPMI KCS definitions

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


Hi Abner,

Can you add a link/reference to the spec used in the INF and commit
message?

Thanks,

Mike

-----Original Message-----
From: abner.chang@... <abner.chang@...>
Sent: Thursday, March 2, 2023 6:32 PM
To: devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@...>; Gao, Liming
<gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Nickle Wang <nicklew@...>; Igor
Kulchytskyy <igork@...>; Oram, Isaac W
<isaac.w.oram@...>; Abdul Lateef Attar
<AbdulLateef.Attar@...>
Subject: [PATCH] MdePkg/Include: Add IPMI KCS definitions

From: Abner Chang <abner.chang@...>

BZ #4354
This change adds definitions for IPMI KCS.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Nickle Wang <nicklew@...>
Cc: Igor Kulchytskyy <igork@...>
Cc: Isaac Oram <isaac.w.oram@...>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
MdePkg/MdePkg.dec | 5 ++
MdePkg/Include/IndustryStandard/IpmiKcs.h | 72
+++++++++++++++++++++++
2 files changed, 77 insertions(+) create mode 100644
MdePkg/Include/IndustryStandard/IpmiKcs.h

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index
3d08f20d15b..0ed033983bf 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -9,6 +9,7 @@
# (C) Copyright 2016 - 2021 Hewlett Packard Enterprise
Development LP<BR> # Copyright (c) 2022, Loongson Technology
Corporation Limited.
All rights reserved.<BR> # Copyright (c) 2021 - 2022, Arm Limited.
All rights reserved.<BR>
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -2332,6
+2333,10 @@
# @Prompt Memory Address of GuidedExtractHandler Table.

gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x1000
000
|UINT64|0x30001015

+ ## This value is the IPMI KCS Interface I/O base address used
+ to transmit
IPMI commands.
+ # @Prompt IPMI KCS Interface I/O Base Address
+
+
gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress|0xca2|UINT16|0x0000
00
+ 31
+
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic,
PcdsDynamicEx]
## This value is used to set the base address of PCI express hierarchy.
# @Prompt PCI Express Base Address.
diff --git a/MdePkg/Include/IndustryStandard/IpmiKcs.h
b/MdePkg/Include/IndustryStandard/IpmiKcs.h
new file mode 100644
index 00000000000..2a51698b126
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/IpmiKcs.h
@@ -0,0 +1,72 @@
+/** @file
+ IPMI KCS Register Definitions
+
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#ifndef IPMI_KCS_H_
+#define IPMI_KCS_H_
+
+#define IPMI_KCS_STATUS_REGISTER_OFFSET 1
+#define IPMI_KCS_COMMAND_REGISTER_OFFSET 1
+#define IPMI_KCS_DATA_OUT_REGISTER_OFFSET 0
+#define IPMI_KCS_DATA_IN_REGISTER_OFFSET 0
+
+///
+/// IPMI KCS Interface Status Bits ///
+#define IPMI_KCS_OBF BIT0
+#define IPMI_KCS_IBF BIT1
+#define IPMI_KCS_SMS_ATN BIT2
+#define IPMI_KCS_COMMAND_DATA BIT3
+#define IPMI_KCS_OEM1 BIT4
+#define IPMI_KCS_OEM2 BIT5
+#define IPMI_KCS_S0 BIT6
+#define IPMI_KCS_S1 BIT7
+
+///
+/// IPMI KCS Interface Control Codes /// #define
+IPMI_KCS_CONTROL_CODE_GET_STATUS_ABORT 0x60
+#define IPMI_KCS_CONTROL_CODE_WRITE_START 0x61
+#define IPMI_KCS_CONTROL_CODE_WRITE_END 0x62
+#define IPMI_KCS_CONTROL_CODE_READ 0x68
+
+///
+/// Status Codes
+///
+#define IPMI_KCS_STATUS_NO_ERROR 0x00
+#define IPMI_KCS_STATUS_ABORT 0x01
+#define IPMI_KCS_STATUS_ILLEGAL 0x02
+#define IPMI_KCS_STATUS_LENGTH_ERROR 0x06
+#define IPMI_KCS_STATUS_UNSPECIFIED 0xFF
+
+///
+/// KCS Interface State Bit
+///
+typedef enum {
+ IPMI_KCS_IDLE_STATE = 0,
+ IPMI_KCS_READ_STATE,
+ IPMI_KCS_WRITE_STATE,
+ IPMI_KCS_ERROR_STATE
+} IPMI_KCS_STATE;
+
+///
+/// IPMI KCS Interface Request Format /// typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 Data[0];
+} IPMI_KCS_RESQUEST_HEADER;
+
+///
+/// IPMI KCS Interface Response Format /// typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 CompletionCode;
+} IPMI_KCS_RESPONSE_HEADER;
+#endif
--
2.37.1.windows.1



Re: [PATCH] MdePkg/Include: Add IPMI KCS definitions

Michael D Kinney
 

I meant in the MdePkg/Include/IndustryStandard/IpmiKcs.h file
and the commit message in this patch that adds that file.

Mike

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chang, Abner via groups.io
Sent: Thursday, March 2, 2023 7:03 PM
To: Kinney, Michael D <michael.d.kinney@...>; devel@edk2.groups.io
Cc: Gao, Liming <gaoliming@...>; Liu, Zhiguang <zhiguang.liu@...>; Nickle Wang <nicklew@...>; Igor
Kulchytskyy <igork@...>; Oram, Isaac W <isaac.w.oram@...>; Attar, AbdulLateef (Abdul Lateef)
<AbdulLateef.Attar@...>
Subject: Re: [edk2-devel] [PATCH] MdePkg/Include: Add IPMI KCS definitions

[AMD Official Use Only - General]

Ok, that would be the patch set for edk2-platform I am going to send later, will update these two edk2 industry standard
definition patches (KCS and MCTP) after edk2-platforms one.

Thanks
Abner

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@...>
Sent: Friday, March 3, 2023 11:00 AM
To: Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Gao, Liming <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Nickle Wang <nicklew@...>; Igor
Kulchytskyy <igork@...>; Oram, Isaac W <isaac.w.oram@...>;
Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@...>; Kinney,
Michael D <michael.d.kinney@...>
Subject: RE: [PATCH] MdePkg/Include: Add IPMI KCS definitions

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


Hi Abner,

Can you add a link/reference to the spec used in the INF and commit
message?

Thanks,

Mike

-----Original Message-----
From: abner.chang@... <abner.chang@...>
Sent: Thursday, March 2, 2023 6:32 PM
To: devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@...>; Gao, Liming
<gaoliming@...>; Liu, Zhiguang <zhiguang.liu@...>;
Nickle Wang <nicklew@...>; Igor Kulchytskyy <igork@...>;
Oram, Isaac W <isaac.w.oram@...>; Abdul Lateef Attar
<AbdulLateef.Attar@...>
Subject: [PATCH] MdePkg/Include: Add IPMI KCS definitions

From: Abner Chang <abner.chang@...>

BZ #4354
This change adds definitions for IPMI KCS.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Nickle Wang <nicklew@...>
Cc: Igor Kulchytskyy <igork@...>
Cc: Isaac Oram <isaac.w.oram@...>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
MdePkg/MdePkg.dec | 5 ++
MdePkg/Include/IndustryStandard/IpmiKcs.h | 72
+++++++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 MdePkg/Include/IndustryStandard/IpmiKcs.h

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index
3d08f20d15b..0ed033983bf 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -9,6 +9,7 @@
# (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development
LP<BR> # Copyright (c) 2022, Loongson Technology Corporation Limited.
All rights reserved.<BR> # Copyright (c) 2021 - 2022, Arm Limited.
All rights reserved.<BR>
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -2332,6 +2333,10
@@
# @Prompt Memory Address of GuidedExtractHandler Table.

gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x1000
000
|UINT64|0x30001015

+ ## This value is the IPMI KCS Interface I/O base address used to transmit
IPMI commands.
+ # @Prompt IPMI KCS Interface I/O Base Address
+
+
gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress|0xca2|UINT16|0x0000
00
+ 31
+
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This value is used to set the base address of PCI express hierarchy.
# @Prompt PCI Express Base Address.
diff --git a/MdePkg/Include/IndustryStandard/IpmiKcs.h
b/MdePkg/Include/IndustryStandard/IpmiKcs.h
new file mode 100644
index 00000000000..2a51698b126
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/IpmiKcs.h
@@ -0,0 +1,72 @@
+/** @file
+ IPMI KCS Register Definitions
+
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#ifndef IPMI_KCS_H_
+#define IPMI_KCS_H_
+
+#define IPMI_KCS_STATUS_REGISTER_OFFSET 1
+#define IPMI_KCS_COMMAND_REGISTER_OFFSET 1
+#define IPMI_KCS_DATA_OUT_REGISTER_OFFSET 0
+#define IPMI_KCS_DATA_IN_REGISTER_OFFSET 0
+
+///
+/// IPMI KCS Interface Status Bits
+///
+#define IPMI_KCS_OBF BIT0
+#define IPMI_KCS_IBF BIT1
+#define IPMI_KCS_SMS_ATN BIT2
+#define IPMI_KCS_COMMAND_DATA BIT3
+#define IPMI_KCS_OEM1 BIT4
+#define IPMI_KCS_OEM2 BIT5
+#define IPMI_KCS_S0 BIT6
+#define IPMI_KCS_S1 BIT7
+
+///
+/// IPMI KCS Interface Control Codes
+///
+#define IPMI_KCS_CONTROL_CODE_GET_STATUS_ABORT 0x60
+#define IPMI_KCS_CONTROL_CODE_WRITE_START 0x61
+#define IPMI_KCS_CONTROL_CODE_WRITE_END 0x62
+#define IPMI_KCS_CONTROL_CODE_READ 0x68
+
+///
+/// Status Codes
+///
+#define IPMI_KCS_STATUS_NO_ERROR 0x00
+#define IPMI_KCS_STATUS_ABORT 0x01
+#define IPMI_KCS_STATUS_ILLEGAL 0x02
+#define IPMI_KCS_STATUS_LENGTH_ERROR 0x06
+#define IPMI_KCS_STATUS_UNSPECIFIED 0xFF
+
+///
+/// KCS Interface State Bit
+///
+typedef enum {
+ IPMI_KCS_IDLE_STATE = 0,
+ IPMI_KCS_READ_STATE,
+ IPMI_KCS_WRITE_STATE,
+ IPMI_KCS_ERROR_STATE
+} IPMI_KCS_STATE;
+
+///
+/// IPMI KCS Interface Request Format /// typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 Data[0];
+} IPMI_KCS_RESQUEST_HEADER;
+
+///
+/// IPMI KCS Interface Response Format /// typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 CompletionCode;
+} IPMI_KCS_RESPONSE_HEADER;
+#endif
--
2.37.1.windows.1



Re: [PATCH] MdePkg/Include: Add IPMI KCS definitions

Chang, Abner
 

[AMD Official Use Only - General]

Ok, that would be the patch set for edk2-platform I am going to send later, will update these two edk2 industry standard definition patches (KCS and MCTP) after edk2-platforms one.

Thanks
Abner

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@...>
Sent: Friday, March 3, 2023 11:00 AM
To: Chang, Abner <Abner.Chang@...>; devel@edk2.groups.io
Cc: Gao, Liming <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Nickle Wang <nicklew@...>; Igor
Kulchytskyy <igork@...>; Oram, Isaac W <isaac.w.oram@...>;
Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@...>; Kinney,
Michael D <michael.d.kinney@...>
Subject: RE: [PATCH] MdePkg/Include: Add IPMI KCS definitions

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


Hi Abner,

Can you add a link/reference to the spec used in the INF and commit
message?

Thanks,

Mike

-----Original Message-----
From: abner.chang@... <abner.chang@...>
Sent: Thursday, March 2, 2023 6:32 PM
To: devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@...>; Gao, Liming
<gaoliming@...>; Liu, Zhiguang <zhiguang.liu@...>;
Nickle Wang <nicklew@...>; Igor Kulchytskyy <igork@...>;
Oram, Isaac W <isaac.w.oram@...>; Abdul Lateef Attar
<AbdulLateef.Attar@...>
Subject: [PATCH] MdePkg/Include: Add IPMI KCS definitions

From: Abner Chang <abner.chang@...>

BZ #4354
This change adds definitions for IPMI KCS.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Nickle Wang <nicklew@...>
Cc: Igor Kulchytskyy <igork@...>
Cc: Isaac Oram <isaac.w.oram@...>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
MdePkg/MdePkg.dec | 5 ++
MdePkg/Include/IndustryStandard/IpmiKcs.h | 72
+++++++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 MdePkg/Include/IndustryStandard/IpmiKcs.h

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index
3d08f20d15b..0ed033983bf 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -9,6 +9,7 @@
# (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development
LP<BR> # Copyright (c) 2022, Loongson Technology Corporation Limited.
All rights reserved.<BR> # Copyright (c) 2021 - 2022, Arm Limited.
All rights reserved.<BR>
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -2332,6 +2333,10
@@
# @Prompt Memory Address of GuidedExtractHandler Table.

gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x1000
000
|UINT64|0x30001015

+ ## This value is the IPMI KCS Interface I/O base address used to transmit
IPMI commands.
+ # @Prompt IPMI KCS Interface I/O Base Address
+
+
gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress|0xca2|UINT16|0x0000
00
+ 31
+
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This value is used to set the base address of PCI express hierarchy.
# @Prompt PCI Express Base Address.
diff --git a/MdePkg/Include/IndustryStandard/IpmiKcs.h
b/MdePkg/Include/IndustryStandard/IpmiKcs.h
new file mode 100644
index 00000000000..2a51698b126
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/IpmiKcs.h
@@ -0,0 +1,72 @@
+/** @file
+ IPMI KCS Register Definitions
+
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
+reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#ifndef IPMI_KCS_H_
+#define IPMI_KCS_H_
+
+#define IPMI_KCS_STATUS_REGISTER_OFFSET 1
+#define IPMI_KCS_COMMAND_REGISTER_OFFSET 1
+#define IPMI_KCS_DATA_OUT_REGISTER_OFFSET 0
+#define IPMI_KCS_DATA_IN_REGISTER_OFFSET 0
+
+///
+/// IPMI KCS Interface Status Bits
+///
+#define IPMI_KCS_OBF BIT0
+#define IPMI_KCS_IBF BIT1
+#define IPMI_KCS_SMS_ATN BIT2
+#define IPMI_KCS_COMMAND_DATA BIT3
+#define IPMI_KCS_OEM1 BIT4
+#define IPMI_KCS_OEM2 BIT5
+#define IPMI_KCS_S0 BIT6
+#define IPMI_KCS_S1 BIT7
+
+///
+/// IPMI KCS Interface Control Codes
+///
+#define IPMI_KCS_CONTROL_CODE_GET_STATUS_ABORT 0x60
+#define IPMI_KCS_CONTROL_CODE_WRITE_START 0x61
+#define IPMI_KCS_CONTROL_CODE_WRITE_END 0x62
+#define IPMI_KCS_CONTROL_CODE_READ 0x68
+
+///
+/// Status Codes
+///
+#define IPMI_KCS_STATUS_NO_ERROR 0x00
+#define IPMI_KCS_STATUS_ABORT 0x01
+#define IPMI_KCS_STATUS_ILLEGAL 0x02
+#define IPMI_KCS_STATUS_LENGTH_ERROR 0x06
+#define IPMI_KCS_STATUS_UNSPECIFIED 0xFF
+
+///
+/// KCS Interface State Bit
+///
+typedef enum {
+ IPMI_KCS_IDLE_STATE = 0,
+ IPMI_KCS_READ_STATE,
+ IPMI_KCS_WRITE_STATE,
+ IPMI_KCS_ERROR_STATE
+} IPMI_KCS_STATE;
+
+///
+/// IPMI KCS Interface Request Format /// typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 Data[0];
+} IPMI_KCS_RESQUEST_HEADER;
+
+///
+/// IPMI KCS Interface Response Format /// typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 CompletionCode;
+} IPMI_KCS_RESPONSE_HEADER;
+#endif
--
2.37.1.windows.1


Re: [PATCH] MdePkg/Include: Add IPMI KCS definitions

Michael D Kinney
 

Hi Abner,

Can you add a link/reference to the spec used in the INF and commit message?

Thanks,

Mike

-----Original Message-----
From: abner.chang@... <abner.chang@...>
Sent: Thursday, March 2, 2023 6:32 PM
To: devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@...>; Gao, Liming <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Nickle Wang <nicklew@...>; Igor Kulchytskyy <igork@...>; Oram, Isaac W
<isaac.w.oram@...>; Abdul Lateef Attar <AbdulLateef.Attar@...>
Subject: [PATCH] MdePkg/Include: Add IPMI KCS definitions

From: Abner Chang <abner.chang@...>

BZ #4354
This change adds definitions for IPMI KCS.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Nickle Wang <nicklew@...>
Cc: Igor Kulchytskyy <igork@...>
Cc: Isaac Oram <isaac.w.oram@...>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
MdePkg/MdePkg.dec | 5 ++
MdePkg/Include/IndustryStandard/IpmiKcs.h | 72 +++++++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 MdePkg/Include/IndustryStandard/IpmiKcs.h

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 3d08f20d15b..0ed033983bf 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -9,6 +9,7 @@
# (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP<BR>
# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -2332,6 +2333,10 @@
# @Prompt Memory Address of GuidedExtractHandler Table.
gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x1000000|UINT64|0x30001015

+ ## This value is the IPMI KCS Interface I/O base address used to transmit IPMI commands.
+ # @Prompt IPMI KCS Interface I/O Base Address
+ gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress|0xca2|UINT16|0x00000031
+
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This value is used to set the base address of PCI express hierarchy.
# @Prompt PCI Express Base Address.
diff --git a/MdePkg/Include/IndustryStandard/IpmiKcs.h b/MdePkg/Include/IndustryStandard/IpmiKcs.h
new file mode 100644
index 00000000000..2a51698b126
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/IpmiKcs.h
@@ -0,0 +1,72 @@
+/** @file
+ IPMI KCS Register Definitions
+
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef IPMI_KCS_H_
+#define IPMI_KCS_H_
+
+#define IPMI_KCS_STATUS_REGISTER_OFFSET 1
+#define IPMI_KCS_COMMAND_REGISTER_OFFSET 1
+#define IPMI_KCS_DATA_OUT_REGISTER_OFFSET 0
+#define IPMI_KCS_DATA_IN_REGISTER_OFFSET 0
+
+///
+/// IPMI KCS Interface Status Bits
+///
+#define IPMI_KCS_OBF BIT0
+#define IPMI_KCS_IBF BIT1
+#define IPMI_KCS_SMS_ATN BIT2
+#define IPMI_KCS_COMMAND_DATA BIT3
+#define IPMI_KCS_OEM1 BIT4
+#define IPMI_KCS_OEM2 BIT5
+#define IPMI_KCS_S0 BIT6
+#define IPMI_KCS_S1 BIT7
+
+///
+/// IPMI KCS Interface Control Codes
+///
+#define IPMI_KCS_CONTROL_CODE_GET_STATUS_ABORT 0x60
+#define IPMI_KCS_CONTROL_CODE_WRITE_START 0x61
+#define IPMI_KCS_CONTROL_CODE_WRITE_END 0x62
+#define IPMI_KCS_CONTROL_CODE_READ 0x68
+
+///
+/// Status Codes
+///
+#define IPMI_KCS_STATUS_NO_ERROR 0x00
+#define IPMI_KCS_STATUS_ABORT 0x01
+#define IPMI_KCS_STATUS_ILLEGAL 0x02
+#define IPMI_KCS_STATUS_LENGTH_ERROR 0x06
+#define IPMI_KCS_STATUS_UNSPECIFIED 0xFF
+
+///
+/// KCS Interface State Bit
+///
+typedef enum {
+ IPMI_KCS_IDLE_STATE = 0,
+ IPMI_KCS_READ_STATE,
+ IPMI_KCS_WRITE_STATE,
+ IPMI_KCS_ERROR_STATE
+} IPMI_KCS_STATE;
+
+///
+/// IPMI KCS Interface Request Format
+///
+typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 Data[0];
+} IPMI_KCS_RESQUEST_HEADER;
+
+///
+/// IPMI KCS Interface Response Format
+///
+typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 CompletionCode;
+} IPMI_KCS_RESPONSE_HEADER;
+#endif
--
2.37.1.windows.1


[PATCH] MdePkg/Include: Add DMTF MCTP definitions

Chang, Abner
 

From: Abner Chang <abner.chang@...>

BZ #4355
This change adds definitions for DMTF MCTP
base specification.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Nickle Wang <nicklew@...>
Cc: Igor Kulchytskyy <igork@...>
Cc: Isaac Oram <isaac.w.oram@...>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
MdePkg/Include/IndustryStandard/Mctp.h | 113 +++++++++++++++++++++++++
1 file changed, 113 insertions(+)
create mode 100644 MdePkg/Include/IndustryStandard/Mctp.h

diff --git a/MdePkg/Include/IndustryStandard/Mctp.h b/MdePkg/Include/IndustryStandard/Mctp.h
new file mode 100644
index 00000000000..45fa63e0435
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Mctp.h
@@ -0,0 +1,113 @@
+/** @file
+
+ The definitions of DMTF Management Component Transport Protocol (MCTP)
+ Base Specification.
+
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Revision Reference:
+ DMTF Management Component Transport Protocol (MCTP) Base Specification
+ Version 1.3.1
+**/
+
+#ifndef MCTP_H_
+#define MCTP_H_
+
+///
+/// Definitions of endpoint ID
+///
+#define MCTP_NULL_DESTINATION_ENDPOINT_ID 0
+#define MCTP_NULL_SOURCE_ENDPOINT_ID 0
+#define MCTP_RESERVED_ENDPOINT_START_ID 1
+#define MCTP_RESERVED_ENDPOINT_END_ID 7
+#define MCTP_BROADCAST_ENDPOINT_ID 0xFF
+
+// Minimum transmission size is 64 bytes.
+#define MCTP_BASELINE_MINIMUM_UNIT_TRANSMISSION_SIZE 0x40
+
+///
+/// The 32-bit Header of MCTP packet.
+///
+typedef union {
+ struct {
+ UINT8 Reserved : 4; ///< Reserved for future definitions.
+ UINT8 HeaderVersion : 4; ///< The version of header.
+ UINT8 DestinationEndpointId : 8; ///< Destination endpoint Id (EID).
+ UINT8 SourceEndpointId : 8; ///< Source endpoint Id (EID)
+ UINT8 StartOfMessage : 1; ///< Indicates the first packet of message.
+ UINT8 EndOfMessage : 1; ///< Indicates the last packet of message.
+ UINT8 PacketSequence : 2; ///< Sequence number increments modulo 4 on
+ ///< each packet.
+ UINT8 TagOwner : 1; ///< Tag owner identifies the message was
+ ///< originated by the source EID or
+ ///< destination EID.
+ UINT8 MessageTag : 3; ///< Check the MCTP Base specification for the
+ ///< usages.
+ } Bits;
+ UINT32 Header;
+} MCTP_HEADER;
+
+///
+/// MCTP Control Commands
+///
+#define MCTP_CONTROL_RESERVED 0x00
+#define MCTP_CONTROL_SET_ENDPOINT_ID 0x01
+#define MCTP_CONTROL_GET_ENDPOINT_ID 0x02
+#define MCTP_CONTROL_GET_ENDPOINT_UUID 0x03
+#define MCTP_CONTROL_GET_MCTP_VERSION_SUPPORT 0x04
+#define MCTP_CONTROL_GET_MESSAGE_TYPE_SUPPORT 0x05
+#define MCTP_CONTROL_GET_VENDOR_DEFINED_MESSAGE_SUPPORT 0x06
+#define MCTP_CONTROL_RESOLVE_ENDPOINT_ID 0x07
+#define MCTP_CONTROL_ALLOCATE_ENDPOINT_IDS 0x08
+#define MCTP_CONTROL_ROUTING_INFORMATION_UPDATE 0x09
+#define MCTP_CONTROL_GET_ROUTINE_TABLE_ENTRIES 0x0A
+#define MCTP_CONTROL_PREPARE_FOR_ENDPOINT_DISCOVERY 0x0B
+#define MCTP_CONTROL_ENDPOINT_DISCOVERY 0x0C
+#define MCTP_CONTROL_DISCOVERY_NOTIFY 0x0D
+#define MCTP_CONTROL_GET_NETWORK_ID 0x0E
+#define MCTP_CONTROL_QUERY_HOP 0x0F
+#define MCTP_CONTROL_RESOLVE_UUID 0x10
+#define MCTP_CONTROL_QUERY_RATE_LIMIT 0x11
+#define MCTP_CONTROL_REQUEST_TX_RATE_LIMIT 0x12
+#define MCTP_CONTROL_UPDATE_RATE_LIMIT 0x13
+#define MCTP_CONTROL_QUERY_SUPPORTED_INTERFACES 0x14
+#define MCTP_CONTROL_TRANSPORT_SPECIFIC_START 0xF0
+#define MCTP_CONTROL_TRANSPORT_SPECIFIC_END 0xFF
+
+///
+/// MCTP Control Message Completion Codes
+///
+#define MCTP_CONTROL_COMPLETION_CODES_SUCCESS 0x00
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR 0x01
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR_INVALID_DATA 0x02
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR_INVALID_LENGTH 0x03
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR_NOT_READY 0x04
+#define MCTP_CONTROL_COMPLETION_CODES_ERROR_UNSUPPORTED_CMD 0x05
+#define MCTP_CONTROL_COMPLETION_CODES_COMMAND_SPECIFIC_START 0x80
+#define MCTP_CONTROL_COMPLETION_CODES_COMMAND_SPECIFIC_END 0xFF
+
+///
+/// MCTP Control Message Types
+///
+#define MCTP_MESSAGE_TYPE_CONTROL 0x00
+#define MCTP_MESSAGE_TYPE_VENDOR_DEFINED_PCI 0x7E
+#define MCTP_MESSAGE_TYPE_VENDOR_DEFINED_IANA 0x7F
+
+///
+/// MCTP Control Message Format
+///
+typedef struct {
+ struct {
+ UINT8 IntegrityCheck : 1; ///< Message integrity check.
+ UINT8 MessageType : 7; ///< Message type.
+ UINT8 RequestBit : 1; ///< Request bit.
+ UINT8 DatagramBit : 1; ///< Datagram bit.
+ UINT8 Reserved : 1; ///< Reserved bit.
+ UINT8 InstanceId : 5; ///< Instance ID.
+ UINT8 CommandCode : 8; ///< Command code of request message.
+ UINT8 CompletionCode : 8; ///< Completion code in response message.
+ } Bits;
+ UINT32 BodyHeader;
+} MCTP_CONTROL_MESSAGE;
+#endif
--
2.37.1.windows.1


[PATCH] MdePkg/Include: Add IPMI KCS definitions

Chang, Abner
 

From: Abner Chang <abner.chang@...>

BZ #4354
This change adds definitions for IPMI KCS.

Signed-off-by: Abner Chang <abner.chang@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Nickle Wang <nicklew@...>
Cc: Igor Kulchytskyy <igork@...>
Cc: Isaac Oram <isaac.w.oram@...>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
MdePkg/MdePkg.dec | 5 ++
MdePkg/Include/IndustryStandard/IpmiKcs.h | 72 +++++++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 MdePkg/Include/IndustryStandard/IpmiKcs.h

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 3d08f20d15b..0ed033983bf 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -9,6 +9,7 @@
# (C) Copyright 2016 - 2021 Hewlett Packard Enterprise Development LP<BR>
# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
# Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -2332,6 +2333,10 @@
# @Prompt Memory Address of GuidedExtractHandler Table.
gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x1000000|UINT64|0x30001015

+ ## This value is the IPMI KCS Interface I/O base address used to transmit IPMI commands.
+ # @Prompt IPMI KCS Interface I/O Base Address
+ gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsBaseAddress|0xca2|UINT16|0x00000031
+
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This value is used to set the base address of PCI express hierarchy.
# @Prompt PCI Express Base Address.
diff --git a/MdePkg/Include/IndustryStandard/IpmiKcs.h b/MdePkg/Include/IndustryStandard/IpmiKcs.h
new file mode 100644
index 00000000000..2a51698b126
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/IpmiKcs.h
@@ -0,0 +1,72 @@
+/** @file
+ IPMI KCS Register Definitions
+
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef IPMI_KCS_H_
+#define IPMI_KCS_H_
+
+#define IPMI_KCS_STATUS_REGISTER_OFFSET 1
+#define IPMI_KCS_COMMAND_REGISTER_OFFSET 1
+#define IPMI_KCS_DATA_OUT_REGISTER_OFFSET 0
+#define IPMI_KCS_DATA_IN_REGISTER_OFFSET 0
+
+///
+/// IPMI KCS Interface Status Bits
+///
+#define IPMI_KCS_OBF BIT0
+#define IPMI_KCS_IBF BIT1
+#define IPMI_KCS_SMS_ATN BIT2
+#define IPMI_KCS_COMMAND_DATA BIT3
+#define IPMI_KCS_OEM1 BIT4
+#define IPMI_KCS_OEM2 BIT5
+#define IPMI_KCS_S0 BIT6
+#define IPMI_KCS_S1 BIT7
+
+///
+/// IPMI KCS Interface Control Codes
+///
+#define IPMI_KCS_CONTROL_CODE_GET_STATUS_ABORT 0x60
+#define IPMI_KCS_CONTROL_CODE_WRITE_START 0x61
+#define IPMI_KCS_CONTROL_CODE_WRITE_END 0x62
+#define IPMI_KCS_CONTROL_CODE_READ 0x68
+
+///
+/// Status Codes
+///
+#define IPMI_KCS_STATUS_NO_ERROR 0x00
+#define IPMI_KCS_STATUS_ABORT 0x01
+#define IPMI_KCS_STATUS_ILLEGAL 0x02
+#define IPMI_KCS_STATUS_LENGTH_ERROR 0x06
+#define IPMI_KCS_STATUS_UNSPECIFIED 0xFF
+
+///
+/// KCS Interface State Bit
+///
+typedef enum {
+ IPMI_KCS_IDLE_STATE = 0,
+ IPMI_KCS_READ_STATE,
+ IPMI_KCS_WRITE_STATE,
+ IPMI_KCS_ERROR_STATE
+} IPMI_KCS_STATE;
+
+///
+/// IPMI KCS Interface Request Format
+///
+typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 Data[0];
+} IPMI_KCS_RESQUEST_HEADER;
+
+///
+/// IPMI KCS Interface Response Format
+///
+typedef struct {
+ UINT8 NetFunc;
+ UINT8 Command;
+ UINT8 CompletionCode;
+} IPMI_KCS_RESPONSE_HEADER;
+#endif
--
2.37.1.windows.1


Re: [PATCH v1 0/1] Remove FP Init in UPL Entry

Guo, Gua
 

What's the issue you encounter ?

-----Original Message-----
From: Dhaval Sharma <dhaval@...>
Sent: Friday, March 3, 2023 2:12 AM
To: devel@edk2.groups.io
Cc: Guo, Gua <gua.guo@...>
Subject: [PATCH v1 0/1] Remove FP Init in UPL Entry

Remove floating point initialization from UPL entry point

Cc: Gua guo <gua.guo@...>
Dhaval Sharma (1):
UefiPayloadPkg: Remove FP Init from UPL entryfunc

UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 3 ---
1 file changed, 3 deletions(-)

--
2.40.0.rc0.57.g454dfcbddf