@@ -255,19 +255,23 @@ typedef int (*bootrom_api_callback_generic_t)(uint32_t r0, uint32_t r1, uint32_t
255255#define BOOTROM_NS_API_get_b_partition 7
256256#define BOOTROM_NS_API_COUNT 8
257257
258+ #define OTP_CMD_ROW_BITS 0x0000ffffu
259+ #define OTP_CMD_ROW_LSB _u(0)
260+ #define OTP_CMD_WRITE_BITS 0x00010000u
261+ #define OTP_CMD_WRITE_LSB _u(16)
262+ #define OTP_CMD_ECC_BITS 0x00020000u
263+ #define OTP_CMD_ECC_LSB _u(17)
264+
258265#ifndef __ASSEMBLER__
266+ static_assert (OTP_CMD_WRITE_BITS == (1 << OTP_CMD_WRITE_LSB ), "" );
267+ static_assert (OTP_CMD_ECC_BITS == (1 << OTP_CMD_ECC_LSB ), "" );
259268
260269typedef struct {
261270 uint32_t permissions_and_location ;
262271 uint32_t permissions_and_flags ;
263272} resident_partition_t ;
264273static_assert (sizeof (resident_partition_t ) == 8 , "" );
265274
266- #define OTP_CMD_ROW_BITS 0x0000ffffu
267- #define OTP_CMD_ROW_LSB 0u
268- #define OTP_CMD_WRITE_BITS 0x00010000u
269- #define OTP_CMD_ECC_BITS 0x00020000u
270-
271275typedef struct otp_cmd {
272276 uint32_t flags ;
273277} otp_cmd_t ;
@@ -304,37 +308,37 @@ typedef struct cflash_flags {
304308 uint32_t flags ;
305309} cflash_flags_t ;
306310
311+ #endif // #ifdef __ASSEMBLER__
312+
307313// Bits which are permitted to be set in a flags variable -- any other bits being set is an error
308314#define CFLASH_FLAGS_BITS 0x00070301u
309315
310316// Used to tell checked flash API which space a given address belongs to
311317#define CFLASH_ASPACE_BITS 0x00000001u
312- #define CFLASH_ASPACE_LSB 0u
313- #define CFLASH_ASPACE_VALUE_STORAGE 0u
314- #define CFLASH_ASPACE_VALUE_RUNTIME 1u
318+ #define CFLASH_ASPACE_LSB _u(0)
319+ #define CFLASH_ASPACE_VALUE_STORAGE _u(0)
320+ #define CFLASH_ASPACE_VALUE_RUNTIME _u(1)
315321
316322// Used to tell checked flash APIs the effective security level of a flash access (may be forced to
317323// one of these values for the NonSecure-exported version of this API)
318324#define CFLASH_SECLEVEL_BITS 0x00000300u
319- #define CFLASH_SECLEVEL_LSB 8u
325+ #define CFLASH_SECLEVEL_LSB _u(8)
320326// Zero is not a valid security level:
321- #define CFLASH_SECLEVEL_VALUE_SECURE 1u
322- #define CFLASH_SECLEVEL_VALUE_NONSECURE 2u
323- #define CFLASH_SECLEVEL_VALUE_BOOTLOADER 3u
327+ #define CFLASH_SECLEVEL_VALUE_SECURE _u(1)
328+ #define CFLASH_SECLEVEL_VALUE_NONSECURE _u(2)
329+ #define CFLASH_SECLEVEL_VALUE_BOOTLOADER _u(3)
324330
325331#define CFLASH_OP_BITS 0x00070000u
326- #define CFLASH_OP_LSB 16u
332+ #define CFLASH_OP_LSB _u(16)
327333// Erase size_bytes bytes of flash, starting at address addr. Both addr and size_bytes must be a
328334// multiple of 4096 bytes (one flash sector).
329- #define CFLASH_OP_VALUE_ERASE 0u
335+ #define CFLASH_OP_VALUE_ERASE _u(0)
330336// Program size_bytes bytes of flash, starting at address addr. Both addr and size_bytes must be a
331337// multiple of 256 bytes (one flash page).
332- #define CFLASH_OP_VALUE_PROGRAM 1u
338+ #define CFLASH_OP_VALUE_PROGRAM _u(1)
333339// Read size_bytes bytes of flash, starting at address addr. There are no alignment restrictions on
334340// addr or size_bytes.
335- #define CFLASH_OP_VALUE_READ 2u
336- #define CFLASH_OP_MAX 2u
337-
338- #endif
341+ #define CFLASH_OP_VALUE_READ _u(2)
342+ #define CFLASH_OP_MAX _u(2)
339343
340344#endif
0 commit comments