File tree 7 files changed +14
-117
lines changed 7 files changed +14
-117
lines changed Original file line number Diff line number Diff line change @@ -288,7 +288,8 @@ SRC_C = \
288
288
lib/libc/string0.c \
289
289
lib/mp-readline/readline.c \
290
290
$(BUILD ) /autogen_usb_descriptor.c \
291
- freetouch/adafruit_ptc.c
291
+ freetouch/adafruit_ptc.c \
292
+ supervisor/shared/memory.c
292
293
293
294
# Choose which flash filesystem impl to use.
294
295
# (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 += \
118
118
lib/utils/stdout_helpers.c \
119
119
lib/libc/string0.c \
120
120
lib/mp-readline/readline.c \
121
+ supervisor/shared/memory.c
121
122
<
10000
br>
122
123
ifeq ($(MCU_SUB_VARIANT ) ,nrf52840)
123
124
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 24
24
* THE SOFTWARE.
25
25
*/
26
26
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
+
27
31
#ifndef MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
28
32
#define MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
29
33
@@ -38,6 +42,10 @@ typedef struct {
38
42
void memory_init (void );
39
43
void free_memory (supervisor_allocation * allocation );
40
44
supervisor_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.
41
49
supervisor_allocation * allocate_memory (uint32_t length , bool high_address );
42
50
43
51
#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) {
82
82
}
83
83
84
84
supervisor_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 ) {
86
86
return NULL ;
87
87
}
88
88
uint8_t index = 0 ;
Original file line number Diff line number Diff line change @@ -52,11 +52,11 @@ void allocate_stack(void) {
52
52
}
53
53
}
54
54
55
- inline void stack_init (void ) {
55
+ void stack_init (void ) {
56
56
allocate_stack ();
57
57
}
58
58
59
- inline void stack_resize (void ) {
59
+ void stack_resize (void ) {
60
60
if (next_stack_size == current_stack_size ) {
61
61
return ;
62
62
}
Original file line number Diff line number Diff line change 1
1
SRC_SUPERVISOR = \
2
2
main.c \
3
- supervisor/memory.c \
4
3
supervisor/port.c \
5
4
supervisor/shared/autoreload.c \
6
5
supervisor/shared/rgb_led_status.c \
You can’t perform that action at this time.
0 commit comments