Skip to content

Commit f3151bb

Browse files
committed
Use get top and limit stack functions
1 parent 96756b3 commit f3151bb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ void gc_collect(void) {
477477

478478
// This naively collects all object references from an approximate stack
479479
// range.
480-
gc_collect_root((void**)sp, ((uint32_t)&_estack - sp) / sizeof(uint32_t));
480+
gc_collect_root((void**)sp, ((uint32_t)port_stack_get_top() - sp) / sizeof(uint32_t));
481481
gc_collect_end();
482482
}
483483

supervisor/shared/memory.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include "supervisor/memory.h"
28+
#include "supervisor/port.h"
2829

2930
#include <stddef.h>
3031

@@ -36,12 +37,10 @@ static supervisor_allocation allocations[CIRCUITPY_SUPERVISOR_ALLOC_COUNT];
3637
// We use uint32_t* to ensure word (4 byte) alignment.
3738
uint32_t* low_address;
3839
uint32_t* high_address;
39-
extern uint32_t _ebss;
40-
extern uint32_t _estack;
4140

4241
void memory_init(void) {
43-
low_address = &_ebss;
44-
high_address = &_estack;
42+
low_address = port_stack_get_limit();
43+
high_address = port_stack_get_top();
4544
}
4645

4746
void free_memory(supervisor_allocation* allocation) {

supervisor/shared/stack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "py/mpconfig.h"
3030
#include "py/runtime.h"
3131
#include "supervisor/cpu.h"
32+
#include "supervisor/port.h"
3233
#include "supervisor/shared/safe_mode.h"
3334

3435
extern uint32_t _estack;
@@ -43,7 +44,7 @@ void allocate_stack(void) {
4344
mp_uint_t regs[10];
4445
mp_uint_t sp = cpu_get_regs_and_sp(regs);
4546

46-
mp_uint_t c_size = (uint32_t) &_estack - sp;
47+
mp_uint_t c_size = (uint32_t) port_stack_get_top() - sp;
4748

4849
stack_alloc = allocate_memory(c_size + next_stack_size + EXCEPTION_STACK_SIZE, true);
4950
if (stack_alloc == NULL) {

0 commit comments

Comments
 (0)