From 5c722ec8f3c618578073da53920215a0374d630e Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Tue, 19 Nov 2024 21:09:59 -0600 Subject: [PATCH 1/2] prevent early macro expansion in PICOBIN_..._AS_BITS() macros --- src/common/boot_picobin_headers/include/boot/picobin.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/boot_picobin_headers/include/boot/picobin.h b/src/common/boot_picobin_headers/include/boot/picobin.h index 40a058007..1c8bf5e00 100644 --- a/src/common/boot_picobin_headers/include/boot/picobin.h +++ b/src/common/boot_picobin_headers/include/boot/picobin.h @@ -59,27 +59,27 @@ #define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_INVALID _u(0x0) #define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_EXE _u(0x1) #define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_DATA _u(0x2) -#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_IMAGE_TYPE, x) +#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_IMAGE_TYPE, ## x) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_LSB _u(4) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_BITS _u(0x0030) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_UNSPECIFIED _u(0x0) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_NS _u(0x1) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_S _u(0x2) -#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_SECURITY, x) +#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_SECURITY, ## x) #define PICOBIN_IMAGE_TYPE_EXE_CPU_LSB _u(8) #define PICOBIN_IMAGE_TYPE_EXE_CPU_BITS _u(0x0700) #define PICOBIN_IMAGE_TYPE_EXE_CPU_ARM _u(0) #define PICOBIN_IMAGE_TYPE_EXE_CPU_RISCV _u(1) #define PICOBIN_IMAGE_TYPE_EXE_CPU_VARMULET _u(2) -#define PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CPU, x) +#define PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CPU, ## x) #define PICOBIN_IMAGE_TYPE_EXE_CHIP_LSB _u(12) #define PICOBIN_IMAGE_TYPE_EXE_CHIP_BITS _u(0x7000) #define PICOBIN_IMAGE_TYPE_EXE_CHIP_RP2040 _u(0) #define PICOBIN_IMAGE_TYPE_EXE_CHIP_RP2350 _u(1) -#define PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CHIP, x) +#define PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CHIP, ## x) #define PICOBIN_IMAGE_TYPE_EXE_TBYB_BITS _u(0x8000) @@ -135,7 +135,7 @@ #define PICOBIN_PARTITION_FLAGS_LINK_TYPE_NONE _u(0) #define PICOBIN_PARTITION_FLAGS_LINK_TYPE_A_PARTITION _u(1) #define PICOBIN_PARTITION_FLAGS_LINK_TYPE_OWNER_PARTITION _u(2) -#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_PARTITION_FLAGS_LINK_TYPE, x) +#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_PARTITION_FLAGS_LINK_TYPE, ## x) #define PICOBIN_HASH_SHA256 _u(0x01) From aa8527265027eb7c110c984c1dd3cc6d10f68090 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Tue, 19 Nov 2024 22:25:02 -0600 Subject: [PATCH 2/2] arg some compilers don't like unary ## --- .../boot_picobin_headers/include/boot/picobin.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/boot_picobin_headers/include/boot/picobin.h b/src/common/boot_picobin_headers/include/boot/picobin.h index 1c8bf5e00..25308478b 100644 --- a/src/common/boot_picobin_headers/include/boot/picobin.h +++ b/src/common/boot_picobin_headers/include/boot/picobin.h @@ -52,6 +52,7 @@ // ---- +#define _PICOBIN_INDEX_TO_BITS(y, x) (y ## x << y ## _LSB) #define PICOBIN_INDEX_TO_BITS(y, x) (y ## _ ## x << y ## _LSB) #define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_LSB _u(0) @@ -59,27 +60,27 @@ #define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_INVALID _u(0x0) #define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_EXE _u(0x1) #define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_DATA _u(0x2) -#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_IMAGE_TYPE, ## x) +#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(x) _PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_IMAGE_TYPE, _ ## x) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_LSB _u(4) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_BITS _u(0x0030) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_UNSPECIFIED _u(0x0) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_NS _u(0x1) #define PICOBIN_IMAGE_TYPE_EXE_SECURITY_S _u(0x2) -#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_SECURITY, ## x) +#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(x) _PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_SECURITY, _ ## x) #define PICOBIN_IMAGE_TYPE_EXE_CPU_LSB _u(8) #define PICOBIN_IMAGE_TYPE_EXE_CPU_BITS _u(0x0700) #define PICOBIN_IMAGE_TYPE_EXE_CPU_ARM _u(0) #define PICOBIN_IMAGE_TYPE_EXE_CPU_RISCV _u(1) #define PICOBIN_IMAGE_TYPE_EXE_CPU_VARMULET _u(2) -#define PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CPU, ## x) +#define PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(x) _PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CPU, _ ## x) #define PICOBIN_IMAGE_TYPE_EXE_CHIP_LSB _u(12) #define PICOBIN_IMAGE_TYPE_EXE_CHIP_BITS _u(0x7000) #define PICOBIN_IMAGE_TYPE_EXE_CHIP_RP2040 _u(0) #define PICOBIN_IMAGE_TYPE_EXE_CHIP_RP2350 _u(1) -#define PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CHIP, ## x) +#define PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(x) _PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CHIP, _ ## x) #define PICOBIN_IMAGE_TYPE_EXE_TBYB_BITS _u(0x8000) @@ -135,7 +136,7 @@ #define PICOBIN_PARTITION_FLAGS_LINK_TYPE_NONE _u(0) #define PICOBIN_PARTITION_FLAGS_LINK_TYPE_A_PARTITION _u(1) #define PICOBIN_PARTITION_FLAGS_LINK_TYPE_OWNER_PARTITION _u(2) -#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_PARTITION_FLAGS_LINK_TYPE, ## x) +#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_AS_BITS(x) _PICOBIN_INDEX_TO_BITS(PICOBIN_PARTITION_FLAGS_LINK_TYPE, _ ## x) #define PICOBIN_HASH_SHA256 _u(0x01)