diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2020-07-02 13:56:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-02 13:56:09 -0700 |
| commit | c33542f978cc61f0466ff60ea769e3067baca95f (patch) | |
| tree | 071e8f8a86971f7e947053c3b4fb2ff7da95d223 /supervisor/shared/stack.c | |
| parent | f572b723060382bbc9ca7a3edc88cb7c30fdcc30 (diff) | |
| parent | eec42d4cb53536a75e88f7f9321515bc6dcfeaa7 (diff) | |
Merge branch 'main' into patch-1
Diffstat (limited to 'supervisor/shared/stack.c')
| -rwxr-xr-x | supervisor/shared/stack.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index 2b7b1c03a..e7aa956b0 100755 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -41,22 +41,24 @@ supervisor_allocation* stack_alloc = NULL; #define EXCEPTION_STACK_SIZE 1024 void allocate_stack(void) { - mp_uint_t regs[10]; - mp_uint_t sp = cpu_get_regs_and_sp(regs); - mp_uint_t c_size = (uint32_t) port_stack_get_top() - sp; + if (port_fixed_stack() != NULL) { + stack_alloc = port_fixed_stack(); + current_stack_size = stack_alloc->length; + } else { + mp_uint_t regs[10]; + mp_uint_t sp = cpu_get_regs_and_sp(regs); - if (port_stack_get_top() != port_heap_get_top()) { - return; + mp_uint_t c_size = (uint32_t) port_stack_get_top() - sp; + stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true); + if (stack_alloc == NULL) { + stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true); + current_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE; + } else { + current_stack_size = next_stack_size; + } } - stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true); - if (stack_alloc == NULL) { - stack_alloc = allocate_memory(c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE, true); - current_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE; - } else { - current_stack_size = next_stack_size; - } *stack_alloc->ptr = STACK_CANARY_VALUE; } |
