[edk2-devel] [PATCH edk2-platforms 1/2] Platform/Intel/WhiskeylakeOpenBoardPkg: Fix ALIGN16 macro

Rebecca Cran posted 2 patches 1 year, 5 months ago
[edk2-devel] [PATCH edk2-platforms 1/2] Platform/Intel/WhiskeylakeOpenBoardPkg: Fix ALIGN16 macro
Posted by Rebecca Cran 1 year, 5 months ago
The IS_ALIGNED macro defined in PlatformBoardConfig.h conflicts with the
definition from MdePkg/Include/Base.h. Delete it, and switch to
ADDRESS_IS_ALIGNED.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
---
 Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
index 44b4059f8ebf..4872a0afc65a 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
@@ -15,8 +15,7 @@
 #include <GpioConfig.h>
 #include <TbtBoardInfo.h>
 
-#define IS_ALIGNED(addr, size) (((addr) & (size - 1)) ? 0 : 1)
-#define ALIGN16(size)          (IS_ALIGNED(size, 16) ? size : ((size + 16) & 0xFFF0))
+#define ALIGN16(size)          (ADDRESS_IS_ALIGNED(size, 16) ? size : ((size + 16) & 0xFFF0))
 
 #define BOARD_CONFIG_BLOCK_PEI_PREMEM_VERSION  0x00000001
 #define BOARD_CONFIG_BLOCK_PEI_POSTMEM_VERSION 0x00000001
-- 
2.39.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104850): https://edk2.groups.io/g/devel/message/104850
Mute This Topic: https://groups.io/mt/98897866/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH edk2-platforms 1/2] Platform/Intel/WhiskeylakeOpenBoardPkg: Fix ALIGN16 macro
Posted by Pedro Falcato 1 year, 5 months ago
On Mon, May 15, 2023 at 6:43 AM Rebecca Cran <rebecca@bsdio.com> wrote:
>
> The IS_ALIGNED macro defined in PlatformBoardConfig.h conflicts with the
> definition from MdePkg/Include/Base.h. Delete it, and switch to
> ADDRESS_IS_ALIGNED.
>
> Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
> ---
>  Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
> index 44b4059f8ebf..4872a0afc65a 100644
> --- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
> +++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/Include/PlatformBoardConfig.h
> @@ -15,8 +15,7 @@
>  #include <GpioConfig.h>
>  #include <TbtBoardInfo.h>
>
> -#define IS_ALIGNED(addr, size) (((addr) & (size - 1)) ? 0 : 1)
> -#define ALIGN16(size)          (IS_ALIGNED(size, 16) ? size : ((size + 16) & 0xFFF0))
> +#define ALIGN16(size)          (ADDRESS_IS_ALIGNED(size, 16) ? size : ((size + 16) & 0xFFF0))

As I mentioned on Discord, ALIGN16 should not need a branch like this.
I propose switching ALIGN16 to use ALIGN_VALUE, or if you need compat
with older edk2s, even:

#define ALIGN16(size)         (((size) + 15) & -16)

Which is a common enough pattern that it hopefully is self-explanatory.

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104871): https://edk2.groups.io/g/devel/message/104871
Mute This Topic: https://groups.io/mt/98897866/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH edk2-platforms 1/2] Platform/Intel/WhiskeylakeOpenBoardPkg: Fix ALIGN16 macro
Posted by Rebecca Cran 1 year, 5 months ago
On 5/15/23 07:22, Pedro Falcato wrote:

> As I mentioned on Discord, ALIGN16 should not need a branch like this.
> I propose switching ALIGN16 to use ALIGN_VALUE, or if you need compat
> with older edk2s, even:
>
> #define ALIGN16(size)         (((size) + 15) & -16)
>
> Which is a common enough pattern that it hopefully is self-explanatory.

Thanks. I realized ALIGN16 isn't even used anymore, so I've just sent 
out a v2 patch to just delete them.


-- 

Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104880): https://edk2.groups.io/g/devel/message/104880
Mute This Topic: https://groups.io/mt/98897866/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-