File tree Expand file tree Collapse file tree 7 files changed +14
-117
lines changed Expand file tree Collapse file tree 7 files changed +14
-117
lines changed Original file line number Diff line number Diff line change @@ -288,7 +288,8 @@ SRC_C = \
288288 lib/libc/string0.c \
289289 lib/mp-readline/readline.c \
290290 $(BUILD ) /autogen_usb_descriptor.c \
291- freetouch/adafruit_ptc.c
291+ freetouch/adafruit_ptc.c \
292+ supervisor/shared/memory.c
292293
293294# Choose which flash filesystem impl to use.
294295# (Right now INTERNAL_FLASH_FILESYSTEM and SPI_FLASH_FILESYSTEM are mutually exclusive.
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ SRC_C += \
118118 lib/utils/stdout_helpers.c \
119119 lib/libc/string0.c \
120120 lib/mp-readline/readline.c \
121+ supervisor/shared/memory.c
121122
122123ifeq ($(MCU_SUB_VARIANT ) ,nrf52840)
123124
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2424 * THE SOFTWARE.
2525 */
2626
27+ // Basic allocations outside them for areas such as the VM heap and stack.
28+ // supervisor/shared/memory.c has a basic implementation for a continuous chunk of memory. Add it
29+ // to a SRC_ in a Makefile to use it.
30+
2731#ifndef MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
2832#define MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
2933
@@ -38,6 +42,10 @@ typedef struct {
3842void memory_init (void );
3943void free_memory (supervisor_allocation * allocation );
4044supervisor_allocation * allocate_remaining_memory (void );
45+
46+ // Allocate a piece of a given length in bytes. If high_address is true then it should be allocated
47+ // at a lower address from the top of the stack. Otherwise, addresses will increase starting after
48+ // statically allocated memory.
4149supervisor_allocation * allocate_memory (uint32_t length , bool high_address );
4250
4351#endif // MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ supervisor_allocation* allocate_remaining_memory(void) {
8282}
8383
8484supervisor_allocation * allocate_memory (uint32_t length , bool high ) {
85- if ((high_address - low_address ) * 4 < (int32_t ) length ) {
85+ if ((high_address - low_address ) * 4 < (int32_t ) length || length % 4 != 0 ) {
8686 return NULL ;
8787 }
8888 uint8_t index = 0 ;
Original file line number Diff line number Diff line change @@ -52,11 +52,11 @@ void allocate_stack(void) {
5252 }
5353}
5454
55- inline void stack_init (void ) {
55+ void stack_init (void ) {
5656 allocate_stack ();
5757}
5858
59- inline void stack_resize (void ) {
59+ void stack_resize (void ) {
6060 if (next_stack_size == current_stack_size ) {
6161 return ;
6262 }
Original file line number Diff line number Diff line change 11SRC_SUPERVISOR = \
22 main.c \
3- supervisor/memory.c \
43 supervisor/port.c \
54 supervisor/shared/autoreload.c \
65 supervisor/shared/rgb_led_status.c \
You can’t perform that action at this time.
0 commit comments