diff options
| author | DavePutz <dwputz@gmail.com> | 2020-05-21 11:05:24 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-21 11:05:24 -0500 |
| commit | 1f40f9e04ff9be0eb82f56014bde5749be604ad9 (patch) | |
| tree | cac462c8edf2c5f34bca1b9063652be4f2b6f2e4 /supervisor/shared/stack.c | |
| parent | 7fa5009674c7741436fd45a3d2009019280aa6f6 (diff) | |
| parent | edc5d8938e0360a61fcea03344d3c525d836048d (diff) | |
Merge pull request #5 from adafruit/master
update from adafruit
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; } |
