MP_REGISTER_ROOT_POINTER for port-specific root pointers

This commit is contained in:
Dan Halbert 2023-09-29 15:46:42 -04:00
parent 1c388ab315
commit 68a2927385
26 changed files with 29 additions and 73 deletions

View File

@ -432,4 +432,6 @@ void audio_dma_evsys_handler(void) {
} }
} }
MP_REGISTER_ROOT_POINTER(mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]);
#endif #endif

View File

@ -270,13 +270,4 @@
#include "peripherals/samd/dma.h" #include "peripherals/samd/dma.h"
#if CIRCUITPY_AUDIOCORE
#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS \
mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT];
#else
#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS
#endif
#endif // __INCLUDED_MPCONFIGPORT_H #endif // __INCLUDED_MPCONFIGPORT_H

View File

@ -57,7 +57,4 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS
#endif // __INCLUDED_MPCONFIGPORT_H #endif // __INCLUDED_MPCONFIGPORT_H

View File

@ -45,7 +45,4 @@
#define MICROPY_BYTES_PER_GC_BLOCK (32) #define MICROPY_BYTES_PER_GC_BLOCK (32)
#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS \
#endif // __INCLUDED_MPCONFIGPORT_H #endif // __INCLUDED_MPCONFIGPORT_H

View File

@ -368,3 +368,5 @@ MP_DEFINE_CONST_OBJ_TYPE(
protocol, &espnow_stream_p, protocol, &espnow_stream_p,
unary_op, &espnow_unary_op unary_op, &espnow_unary_op
); );
MP_REGISTER_ROOT_POINTER(struct _espnow_obj_t *espnow_singleton);

View File

@ -126,3 +126,5 @@ int ble_event_run_handlers(struct ble_gap_event *event) {
#endif #endif
return 0; return 0;
} }
MP_REGISTER_ROOT_POINTER(struct ble_event_handler_entry *ble_event_handler_entries);

View File

@ -37,23 +37,6 @@
#include "py/circuitpy_mpconfig.h" #include "py/circuitpy_mpconfig.h"
#if CIRCUITPY_BLEIO
#define BLEIO_ROOT_POINTERS struct ble_event_handler_entry *ble_event_handler_entries;
#else
#define BLEIO_ROOT_POINTERS
#endif
#if CIRCUITPY_ESPNOW
#define ESPNOW_ROOT_POINTERS struct _espnow_obj_t *espnow_singleton;
#else
#define ESPNOW_ROOT_POINTERS
#endif
#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS \
BLEIO_ROOT_POINTERS \
ESPNOW_ROOT_POINTERS
#define MICROPY_NLR_SETJMP (1) #define MICROPY_NLR_SETJMP (1)
#define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000

View File

@ -34,8 +34,6 @@
#include "py/circuitpy_mpconfig.h" #include "py/circuitpy_mpconfig.h"
#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS
#define MICROPY_NLR_SETJMP (1) #define MICROPY_NLR_SETJMP (1)
#define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000

View File

@ -52,10 +52,7 @@ extern uint8_t _ld_default_stack_size;
#include "py/circuitpy_mpconfig.h" #include "py/circuitpy_mpconfig.h"
#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS \
// TODO: // TODO:
// mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]; // mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT] as an MP_REGISTER_ROOT_POINTER.
#endif // __INCLUDED_MPCONFIGPORT_H #endif // __INCLUDED_MPCONFIGPORT_H

View File

@ -196,3 +196,5 @@ void SD_EVT_IRQHandler(void) {
ble_serial_enable(); ble_serial_enable();
#endif #endif
} }
MP_REGISTER_ROOT_POINTER(ble_drv_evt_handler_entry_t *ble_drv_evt_handler_entries);

View File

@ -333,3 +333,5 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout,
// Update the next start. // Update the next start.
next_start_raw_ticks = port_get_raw_ticks(NULL) + 4; next_start_raw_ticks = port_get_raw_ticks(NULL) + 4;
} }
MP_REGISTER_ROOT_POINTER(uint16_t *pixels_pattern_heap);

View File

@ -204,11 +204,4 @@
#error RAM size regions do not use all of RAM #error RAM size regions do not use all of RAM
#endif #endif
#define MICROPY_PORT_ROOT_POINTERS \
CIRCUITPY_COMMON_ROOT_POINTERS \
uint16_t *pixels_pattern_heap; \
ble_drv_evt_handler_entry_t *ble_drv_evt_handler_entries; \
#endif // NRF5_MPCONFIGPORT_H__ #endif // NRF5_MPCONFIGPORT_H__

View File

@ -487,4 +487,5 @@ void isr_dma_0(void) {
} }
} }
MP_REGISTER_ROOT_POINTER(mp_obj_t playing_audio[NUM_DMA_CHANNELS]);
#endif #endif

View File

@ -111,3 +111,5 @@ void counter_interrupt_handler(void) {
self->count += 65536; self->count += 65536;
} }
} }
MP_REGISTER_ROOT_POINTER(mp_obj_t counting[NUM_PWM_SLICES]);

View File

@ -1098,3 +1098,5 @@ bool common_hal_rp2pio_statemachine_get_writing(rp2pio_statemachine_obj_t *self)
int common_hal_rp2pio_statemachine_get_pending(rp2pio_statemachine_obj_t *self) { int common_hal_rp2pio_statemachine_get_pending(rp2pio_statemachine_obj_t *self) {
return self->pending_buffers; return self->pending_buffers;
} }
MP_REGISTER_ROOT_POINTER(mp_obj_t background_pio[NUM_DMA_CHANNELS]);

View File

@ -55,12 +55,6 @@
// This also includes mpconfigboard.h. // This also includes mpconfigboard.h.
#include "py/circuitpy_mpconfig.h" #include "py/circuitpy_mpconfig.h"
#define MICROPY_PORT_ROOT_POINTERS \
mp_obj_t counting[NUM_PWM_SLICES]; \
mp_obj_t playing_audio[NUM_DMA_CHANNELS]; \
mp_obj_t background_pio[NUM_DMA_CHANNELS]; \
CIRCUITPY_COMMON_ROOT_POINTERS;
#if CIRCUITPY_CYW43 #if CIRCUITPY_CYW43
#include "pico/cyw43_arch.h" #include "pico/cyw43_arch.h"
#define MICROPY_PY_LWIP_ENTER cyw43_arch_lwip_begin(); #define MICROPY_PY_LWIP_ENTER cyw43_arch_lwip_begin();

View File

@ -65,9 +65,4 @@
#include "py/circuitpy_mpconfig.h" #include "py/circuitpy_mpconfig.h"
#define MICROPY_PORT_ROOT_POINTERS \
void *cpy_uart_obj_all[MAX_UART]; \
void *cpy_i2c_obj_all[MAX_I2C]; \
CIRCUITPY_COMMON_ROOT_POINTERS
#endif // EFR32_MPCONFIGPORT_H__ #endif // EFR32_MPCONFIGPORT_H__

View File

@ -400,3 +400,5 @@ void I2C3_EV_IRQHandler(void) {
void I2C4_EV_IRQHandler(void) { void I2C4_EV_IRQHandler(void) {
call_hal_irq(4); call_hal_irq(4);
} }
MP_REGISTER_ROOT_POINTER(void *cpy_i2c_obj_all[MAX_I2C]);

View File

@ -674,3 +674,5 @@ STATIC void uart_assign_irq(busio_uart_obj_t *self, USART_TypeDef *USARTx) {
} }
#endif #endif
} }
MP_REGISTER_ROOT_POINTER(void *cpy_uart_obj_all[MAX_UART]);

View File

@ -60,9 +60,4 @@ extern uint8_t _ld_default_stack_size;
#define MAX_I2C 4 #define MAX_I2C 4
#define MAX_SPI 6 #define MAX_SPI 6
#define MICROPY_PORT_ROOT_POINTERS \
void *cpy_uart_obj_all[MAX_UART]; \
void *cpy_i2c_obj_all[MAX_I2C]; \
CIRCUITPY_COMMON_ROOT_POINTERS
#endif // __INCLUDED_MPCONFIGPORT_H #endif // __INCLUDED_MPCONFIGPORT_H

View File

@ -1769,11 +1769,6 @@ typedef double mp_float_t;
#define MICROPY_PORT_CONSTANTS #define MICROPY_PORT_CONSTANTS
#endif #endif
// Any root pointers for GC scanning - see mpstate.c
#ifndef MICROPY_PORT_ROOT_POINTERS
#define MICROPY_PORT_ROOT_POINTERS
#endif
/*****************************************************************************/ /*****************************************************************************/
/* Hooks for a port to wrap functions with attributes */ /* Hooks for a port to wrap functions with attributes */

View File

@ -352,7 +352,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
displayio_group_type, displayio_group_type,
MP_QSTR_Group, MP_QSTR_Group,
MP_TYPE_FLAG_ITER_IS_GETITER, MP_TYPE_FLAG_ITER_IS_GETITER,
.make_new, displayio_group_make_new, make_new, displayio_group_make_new,
locals_dict, &displayio_group_locals_dict, locals_dict, &displayio_group_locals_dict,
subscr, group_subscr, subscr, group_subscr,
unary_op, group_unary_op, unary_op, group_unary_op,

View File

@ -141,7 +141,7 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val
// Convert a tuple or list to a bytearray. // Convert a tuple or list to a bytearray.
if (mp_obj_is_type(value, &mp_type_tuple) || if (mp_obj_is_type(value, &mp_type_tuple) ||
mp_obj_is_type(value, &mp_type_list)) { mp_obj_is_type(value, &mp_type_list)) {
value = mp_type_bytes.make_new(&mp_type_bytes, 1, 0, &value); value = MP_OBJ_TYPE_GET_SLOT(&mp_type_bytes, make_new)(&mp_type_bytes, 1, 0, &value);
} }
uint32_t color; uint32_t color;

View File

@ -148,6 +148,7 @@ STATIC const mp_rom_map_elem_t pulseio_pulseout_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(pulseio_pulseout_locals_dict, pulseio_pulseout_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(pulseio_pulseout_locals_dict, pulseio_pulseout_locals_dict_table);
MP_DEFINE_CONST_OBJ_TYPE( MP_DEFINE_CONST_OBJ_TYPE(
pulseio_pulseout_type,
MP_QSTR_PulseOut, MP_QSTR_PulseOut,
MP_TYPE_FLAG_NONE, MP_TYPE_FLAG_NONE,
make_new, pulseio_pulseout_make_new, make_new, pulseio_pulseout_make_new,

View File

@ -145,7 +145,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
MP_TYPE_FLAG_ITER_IS_ITERNEXT, MP_TYPE_FLAG_ITER_IS_ITERNEXT,
make_new, terminalio_terminal_make_new, make_new, terminalio_terminal_make_new,
locals_dict, (mp_obj_dict_t *)&terminalio_terminal_locals_dict, locals_dict, (mp_obj_dict_t *)&terminalio_terminal_locals_dict,
getiter, mp_identity_getiter, iter, mp_stream_unbuffered_iter,
iternext, mp_stream_unbuffered_iter,
protocol, &terminalio_terminal_stream_p protocol, &terminalio_terminal_stream_p
); );

View File

@ -33,6 +33,7 @@
#include "supervisor/shared/external_flash/common_commands.h" #include "supervisor/shared/external_flash/common_commands.h"
#include "extmod/vfs.h" #include "extmod/vfs.h"
#include "extmod/vfs_fat.h" #include "extmod/vfs_fat.h"
#include "py/gc.h"
#include "py/misc.h" #include "py/misc.h"
#include "py/obj.h" #include "py/obj.h"
#include "py/runtime.h" #include "py/runtime.h"
@ -367,7 +368,8 @@ static bool allocate_ram_cache(void) {
return true; return true;
} }
if (MP_STATE_MEM(gc_pool_start) == 0) { // Couldn't allocate outside the heap. Is the heap available?
if (!gc_alloc_possible()) {
return false; return false;
} }
@ -414,7 +416,7 @@ static void release_ram_cache(void) {
if (supervisor_cache != NULL) { if (supervisor_cache != NULL) {
free_memory(supervisor_cache); free_memory(supervisor_cache);
supervisor_cache = NULL; supervisor_cache = NULL;
} else if (MP_STATE_MEM(gc_pool_start)) { } else if (gc_alloc_possible()) {
m_free(MP_STATE_VM(flash_ram_cache)); m_free(MP_STATE_VM(flash_ram_cache));
} }
MP_STATE_VM(flash_ram_cache) = NULL; MP_STATE_VM(flash_ram_cache) = NULL;
@ -462,7 +464,7 @@ static bool flush_ram_cache(bool keep_cache) {
write_flash(current_sector + (i * pages_per_block + j) * SPI_FLASH_PAGE_SIZE, write_flash(current_sector + (i * pages_per_block + j) * SPI_FLASH_PAGE_SIZE,
MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j], MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j],
SPI_FLASH_PAGE_SIZE); SPI_FLASH_PAGE_SIZE);
if (!keep_cache && supervisor_cache == NULL && MP_STATE_MEM(gc_pool_start)) { if (!keep_cache && supervisor_cache == NULL && gc_alloc_possible()) {
m_free(MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j]); m_free(MP_STATE_VM(flash_ram_cache)[i * pages_per_block + j]);
} }
} }