summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2018-05-24 13:12:18 -0700
committerScott Shawcroft <scott@tannewt.org>2018-07-31 05:18:03 -0700
commit777542c716e07e78439c3c6bbf442722ebaaecc6 (patch)
tree2882c68c4d9655e52d9741d4ef5808ed8758a228 /supervisor
parentbf033123a7fa75394fd7a01d17ec99afd9abe645 (diff)
Add basic memory allocation outside Python runtime
This allows for the heap to fill all space but the stack. It also allows us to designate space for memory outside the runtime for things such as USB descriptors, flash cache and main filename. Fixes #754
Diffstat (limited to 'supervisor')
-rwxr-xr-xsupervisor/memory.h43
-rwxr-xr-x[-rw-r--r--]supervisor/supervisor.mk1
2 files changed, 44 insertions, 0 deletions
diff --git a/supervisor/memory.h b/supervisor/memory.h
new file mode 100755
index 000000000..1d64c2cde
--- /dev/null
+++ b/supervisor/memory.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
+#define MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+typedef struct {
+ uint32_t* ptr;
+ uint32_t length; // in bytes
+} supervisor_allocation;
+
+void memory_init(void);
+void free_memory(supervisor_allocation* allocation);
+supervisor_allocation* allocate_remaining_memory(void);
+supervisor_allocation* allocate_memory(uint32_t length, bool high_address);
+
+#endif // MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk
index c56557197..ea6afae29 100644..100755
--- a/supervisor/supervisor.mk
+++ b/supervisor/supervisor.mk
@@ -1,5 +1,6 @@
SRC_SUPERVISOR = \
main.c \
+ supervisor/memory.c \
supervisor/port.c \
supervisor/shared/autoreload.c \
supervisor/shared/rgb_led_status.c