Skip to content

Commit 5ba4f77

Browse files
authored
Merge pull request #10325 from tannewt/collect_rv32_registers
Factor out register saves
2 parents d0776d3 + e6271b2 commit 5ba4f77

File tree

28 files changed

+169
-359
lines changed

28 files changed

+169
-359
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ LINKERFILE = linking/$(MCU_VARIANT_LOWER)_cktpy.ld
138138
LDFLAGS += -nostartfiles -specs=nano.specs
139139
endif
140140

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

144144
# Needed to compile some MAX32 headers
145145
CFLAGS += -D$(MCU_VARIANT_UPPER) \
@@ -236,6 +236,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
236236
endif
237237
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
238238
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
239+
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
239240
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
240241

241242
# List of sources for qstr extraction

ports/analog/supervisor/cpu.s

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

ports/atmel-samd/Makefile

Lines changed: 2 additions & 2 deletions
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_UPPER = 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))
@@ -317,7 +317,7 @@ ifeq ($(INTERNAL_LIBM),1)
317317
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
318318
endif
319319
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
320-
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
320+
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
321321
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
322322

323323
QSTR_GLOBAL_REQUIREMENTS += $(HEADER_BUILD)/sdiodata.h

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: 2 additions & 2 deletions
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_UPPER = supervisor/shared/cpu_regs.S
114114

115115
SRC_C += \
116116
background.c \
@@ -120,7 +120,7 @@ SRC_C += \
120120
lib/tinyusb/src/portable/sony/cxd56/dcd_cxd56.c \
121121

122122
OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
123-
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
123+
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
124124
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
125125
ifeq ($(INTERNAL_LIBM),1)
126126
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))

ports/cxd56/supervisor/cpu.s

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy