Skip to content

Commit a7ce054

Browse files
committed
WIP register saves
1 parent 66093e8 commit a7ce054

File tree

25 files changed

+151
-348
lines changed

25 files changed

+151
-348
lines changed

main.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "supervisor/cpu.h"
3131
#include "supervisor/filesystem.h"
3232
#include "supervisor/port.h"
33+
#include "supervisor/shared/cpu_regs.h"
3334
#include "supervisor/shared/reload.h"
3435
#include "supervisor/shared/safe_mode.h"
3536
#include "supervisor/shared/serial.h"
@@ -1135,9 +1136,14 @@ int __attribute__((used)) main(void) {
11351136
void gc_collect(void) {
11361137
gc_collect_start();
11371138

1138-
mp_uint_t regs[10];
1139+
// Load register values onto the stack. They get collected below with the rest of the stack.
1140+
size_t regs[SAVED_REGISTER_COUNT];
11391141
mp_uint_t sp = cpu_get_regs_and_sp(regs);
11401142

1143+
// This naively collects all object references from an approximate stack
1144+
// range.
1145+
gc_collect_root((void **)sp, ((mp_uint_t)port_stack_get_top() - sp) / sizeof(mp_uint_t));
1146+
11411147
// This collects root pointers from the VFS mount table. Some of them may
11421148
// have lost their references in the VM even though they are mounted.
11431149
gc_collect_root((void **)&MP_STATE_VM(vfs_mount_table), sizeof(mp_vfs_mount_t) / sizeof(mp_uint_t));
@@ -1170,9 +1176,6 @@ void gc_collect(void) {
11701176
common_hal_wifi_gc_collect();
11711177
#endif
11721178

1173-
// This naively collects all object references from an approximate stack
1174-
// range.
1175-
gc_collect_root((void **)sp, ((mp_uint_t)port_stack_get_top() - sp) / sizeof(mp_uint_t));
11761179
gc_collect_end();
11771180
}
11781181

ports/analog/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ LINKERFILE = linking/$(MCU_VARIANT_LOWER)_cktpy.ld
138138
LDFLAGS += -nostartfiles -specs=nano.specs
139139
endif
140140

141-
SRC_S += supervisor/cpu.s \
141+
SRC_S += $(TOP)/supervisor/shared/cpu_regs.S \
142142
$(STARTUPFILE)
143143

144144
# Needed to compile some MAX32 headers

ports/analog/supervisor/cpu.s

Lines changed: 0 additions & 34 deletions
This file was deleted.

ports/atmel-samd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ ifeq ($(CIRCUITPY_AUDIOBUSIO),1)
308308
SRC_C += peripherals/samd/i2s.c peripherals/samd/$(PERIPHERALS_CHIP_FAMILY)/i2s.c
309309
endif
310310

311-
SRC_S = supervisor/$(CHIP_FAMILY)_cpu.s
311+
SRC_S = $(TOP)/supervisor/shared/cpu_regs.S
312312

313313
OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
314314
OBJ += $(addprefix $(BUILD)/, $(SRC_ASF:.c=.o))

ports/atmel-samd/supervisor/samd21_cpu.s

Lines changed: 0 additions & 35 deletions
This file was deleted.

ports/atmel-samd/supervisor/samd51_cpu.s

Lines changed: 0 additions & 27 deletions
This file was deleted.

ports/atmel-samd/supervisor/same51_cpu.s

Lines changed: 0 additions & 27 deletions
This file was deleted.

ports/atmel-samd/supervisor/same54_cpu.s

Lines changed: 0 additions & 27 deletions
This file was deleted.

ports/cxd56/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ LDFLAGS = \
110110

111111
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_CXD56 -DCFG_TUD_MIDI_RX_BUFSIZE=512 -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_MIDI_TX_BUFSIZE=512 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=512 $(CFLAGS_MOD)
112112

113-
SRC_S = supervisor/cpu.s
113+
SRC_S = $(TOP)/supervisor/shared/cpu_regs.S
114114

115115
SRC_C += \
116116
background.c \

ports/cxd56/supervisor/cpu.s

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)