qemu-arm: Use gchelper code to get registers for GC scanning.

This commit is contained in:
Damien George 2019-02-12 14:48:29 +11:00
parent c9ece68d06
commit d53dc04903
2 changed files with 7 additions and 3 deletions

View File

@ -13,6 +13,7 @@ ifeq ($(BOARD),netduino2)
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
CFLAGS += -DQEMU_SOC_STM32
LDSCRIPT = stm32.ld
SRC_BOARD_O = lib/utils/gchelper_m3.o
endif
ifeq ($(BOARD),microbit)
@ -20,12 +21,14 @@ CFLAGS += -mthumb -mcpu=cortex-m0 -mfloat-abi=soft
CFLAGS += -DQEMU_SOC_NRF51
LDSCRIPT = nrf51.ld
QEMU_EXTRA = -global nrf51-soc.flash-size=1048576 -global nrf51-soc.sram-size=262144
SRC_BOARD_O = lib/utils/gchelper_m0.o
endif
ifeq ($(BOARD),mps2-an385)
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
CFLAGS += -DQEMU_SOC_MPS2
LDSCRIPT = mps2.ld
SRC_BOARD_O = lib/utils/gchelper_m3.o
endif
CROSS_COMPILE = arm-none-eabi-
@ -95,6 +98,7 @@ LIB_SRC_C += $(addprefix lib/,\
OBJ_COMMON =
OBJ_COMMON += $(PY_O)
OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_COMMON_C:.c=.o))
OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_BOARD_O))
OBJ_COMMON += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
OBJ_RUN =

View File

@ -11,6 +11,7 @@
#include "py/stackctrl.h"
#include "py/gc.h"
#include "py/mperrno.h"
#include "lib/utils/gchelper.h"
#include "tinytest.h"
#include "tinytest_macros.h"
@ -33,9 +34,8 @@ void gc_collect(void) {
gc_collect_start();
// get the registers and the sp
// TODO get registers
volatile mp_uint_t dummy;
void *sp = (void*)&dummy;
uintptr_t regs[10];
uintptr_t sp = gc_helper_get_regs_and_sp(regs);
// trace the stack, including the registers (since they live on the stack in this function)
gc_collect_root((void**)sp, ((uint32_t)MP_STATE_THREAD(stack_top) - (uint32_t)sp) / sizeof(uint32_t));