xiaoxiang781216 commented on a change in pull request #2042:
URL: https://github.com/apache/incubator-nuttx/pull/2042#discussion_r508339111
##########
File path: arch/arm/src/cxd56xx/cxd56_irq.c
##########
@@ -115,17 +112,17 @@ static uint64_t g_intstack_alloc[INTSTACK_ALLOC >> 3];
const uint32_t g_cpu_intstack_top[CONFIG_SMP_NCPUS] =
{
- (uint32_t)g_intstack_alloc + INTSTACK_SIZE,
+ (uint32_t)g_intstack_alloc + INTSTACK_SIZE - 8,
Review comment:
> I think that adjustment is necessary to get the address of the last
element in the stack, at least for the case of how g_intstack_alloc is
allocated (a 64bit array)
In most location, -8 is used to calculate the initial stack pointer, but the
convention is always sub the stack pointer first before access the data on the
stack as AAPCS required. -8 is wrong in this case.
If user want to access the last element he should sub 4/8 manually, or use <
in the loop:
for (i = 0; i < stack_size; i += 4/8)
ARM AAPCS(and many other arch) require that push implement like this:
```
sub sp, #4/#8
str val, [sp]
```
so the pointer should point to after the end of stack. -8 make the code
complexity and waste a little memory, or is there a special reason to do in
this way, @patacongo? I have worked with many RTOS and bootloader, but never
see the type of special code.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]