Use get top and limit stack functions

This commit is contained in:
Kamil Tomaszewski 2019-10-18 11:05:08 +02:00
parent 96756b3945
commit f3151bb6c4
3 changed files with 6 additions and 6 deletions

2
main.c
View File

@ -477,7 +477,7 @@ void gc_collect(void) {
// This naively collects all object references from an approximate stack
// range.
gc_collect_root((void**)sp, ((uint32_t)&_estack - sp) / sizeof(uint32_t));
gc_collect_root((void**)sp, ((uint32_t)port_stack_get_top() - sp) / sizeof(uint32_t));
gc_collect_end();
}

View File

@ -25,6 +25,7 @@
*/
#include "supervisor/memory.h"
#include "supervisor/port.h"
#include <stddef.h>
@ -36,12 +37,10 @@ static supervisor_allocation allocations[CIRCUITPY_SUPERVISOR_ALLOC_COUNT];
// We use uint32_t* to ensure word (4 byte) alignment.
uint32_t* low_address;
uint32_t* high_address;
extern uint32_t _ebss;
extern uint32_t _estack;
void memory_init(void) {
low_address = &_ebss;
high_address = &_estack;
low_address = port_stack_get_limit();
high_address = port_stack_get_top();
}
void free_memory(supervisor_allocation* allocation) {

View File

@ -29,6 +29,7 @@
#include "py/mpconfig.h"
#include "py/runtime.h"
#include "supervisor/cpu.h"
#include "supervisor/port.h"
#include "supervisor/shared/safe_mode.h"
extern uint32_t _estack;
@ -43,7 +44,7 @@ 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) &_estack - sp;
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) {