diff options
author | danh-arm <dan.handley@arm.com> | 2016-07-15 18:23:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-15 18:23:11 +0100 |
commit | 9306f135922bc7811dfc1e24a755c38ce2e671cd (patch) | |
tree | d2e24908471445d11150ef86418420f1d497fcc8 /include/common/asm_macros.S | |
parent | 9ca516bba7ca16844bd2bc0d67b527ee8d8e78e2 (diff) | |
parent | 663db206f85653f05c5f6adb577970cc4669a7ea (diff) |
Merge pull request #659 from soby-mathew/sm/declare_stack
Derive stack alignment from CACHE_WRITEBACK_GRANULE
Diffstat (limited to 'include/common/asm_macros.S')
-rw-r--r-- | include/common/asm_macros.S | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/include/common/asm_macros.S b/include/common/asm_macros.S index d4bd11ee..bd8bb709 100644 --- a/include/common/asm_macros.S +++ b/include/common/asm_macros.S @@ -148,17 +148,33 @@ #endif /* + * Helper assembler macro to count trailing zeros. The output is + * populated in the `TZ_COUNT` symbol. + */ + .macro count_tz _value, _tz_count + .if \_value + count_tz "(\_value >> 1)", "(\_tz_count + 1)" + .else + .equ TZ_COUNT, (\_tz_count - 1) + .endif + .endm + + /* * This macro declares an array of 1 or more stacks, properly * aligned and in the requested section */ -#define STACK_ALIGN 6 +#define DEFAULT_STACK_ALIGN (1 << 6) /* In case the caller doesnt provide alignment */ - .macro declare_stack _name, _section, _size, _count - .if ((\_size & ((1 << STACK_ALIGN) - 1)) <> 0) + .macro declare_stack _name, _section, _size, _count, _align=DEFAULT_STACK_ALIGN + count_tz \_align, 0 + .if (\_align - (1 << TZ_COUNT)) + .error "Incorrect stack alignment specified (Must be a power of 2)." + .endif + .if ((\_size & ((1 << TZ_COUNT) - 1)) <> 0) .error "Stack size not correctly aligned" .endif .section \_section, "aw", %nobits - .align STACK_ALIGN + .align TZ_COUNT \_name: .space ((\_count) * (\_size)), 0 .endm |