35 #include "modulesettings.h"
37 #define MOD_RAM_BEGIN 0x10000000
38 #define MOD_RODATA_BEGIN 0x20000000
39 #define MOD_CALLS_BEGIN 0xdf000000
41 #define CALL_DO_DUMB_TEST_DELAY 0xdf000001
42 #define CALL_PIOS_THREAD_CREATE 0xdf000003
43 #define CALL_PIOS_THREAD_SLEEP 0xdf000005
44 #define CALL_DO_DUMB_REGTASK 0xdf000007
45 #define CALL_ANNUNC_CUSTOM 0xdf000009
51 #ifdef MODULE_Loadable_BUILTIN
54 uint8_t module_state[MODULESETTINGS_ADMINSTATE_NUMELEM];
55 ModuleSettingsAdminStateGet(module_state);
56 if (module_state[MODULESETTINGS_ADMINSTATE_LOADABLE] == MODULESETTINGS_ADMINSTATE_ENABLED) {
67 void *data_seg, uint32_t got_addr)
79 "ldr %0, tramplen\n\t"
80 "adr %1, trampbegin\n\t"
82 "tramplen: .word trampend-trampbegin\n\t"
86 "ldr ip, trampdest\n\t"
87 "ldr r9, trampdata\n\t"
91 "trampdest: .word 123\n\t"
92 "trampdata: .word 456\n\t"
94 :
"=r" (tramp_len),
"=r" (tramp_template));
102 memcpy(tramp_alloc, tramp_template, tramp_len);
104 tramp_alloc[(tramp_len / 4) - 2] = ((uintptr_t) ext) + got_addr;
105 tramp_alloc[(tramp_len / 4) - 1] = (uintptr_t) data_seg;
107 return ((uint32_t) tramp_alloc) + 1;
123 (
void *) (((uintptr_t) ext) + ext->ram_seg_copyoff),
124 ext->ram_seg_copylen);
127 memset(new_seg + ext->ram_seg_copylen, 0,
128 ext->ram_seg_len - ext->ram_seg_copylen);
131 uint32_t *got = (uint32_t *) new_seg;
133 for (
int i = 0;
i < (ext->ram_seg_gotlen /
sizeof(uint32_t));
i++) {
144 got[
i] = (uint32_t) (new_seg + got[
i] -
MOD_RAM_BEGIN - ext->ram_seg_copyoff);
175 :
"r"(
entry),
"r"(data_seg)
178 "r0",
"r1",
"r2",
"r3",
"r12",
180 "s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
"s7",
181 "s8",
"s9",
"s10",
"s11",
"s12",
"s13",
"s14",
"s15",
197 uint8_t *part_beginning;
201 if (!part_beginning) {
205 uint32_t part_pos = 0;
209 (
void *) (part_beginning + part_pos);
265 for (
volatile int i = 0;
i < cycles;
i++);
268 #define EXCEPTION_STACK_PC_OFFSET 6
277 switch ((pc & 0xfffffffe) | 1) {
313 "ldr r1, =stack_sel_mask\n\t"
317 "b MemManageHandler_C\n\t"
318 "using_psp: mrs r0, PSP\n\t"
319 "b MemManageHandler_C\n\t"
320 "stack_sel_mask: .word 0x00000001\n\t"
int32_t PIOS_FLASH_find_partition_id(enum pios_flash_partition_labels label, uintptr_t *partition_id)
static void invoke_loadables()
void * PIOS_FLASH_get_address(uintptr_t partition_id, uint32_t *partition_size)
static void do_dumb_test_delay(int cycles)
void * PIOS_malloc(size_t size)
static int32_t loadable_initialize(void)
#define CALL_DO_DUMB_REGTASK
static uint32_t construct_trampoline(struct loadable_extension *ext, void *data_seg, uint32_t got_addr)
void MemManageHandler_C(uint32_t *exception_stack)
#define MODULE_INITCALL(ifn, sfn)
#define CALL_ANNUNC_CUSTOM
static bool module_enabled
struct pios_thread * PIOS_Thread_Create(void(*fp)(void *), const char *namep, size_t stack_bytes, void *argp, enum pios_thread_prio_e prio)
int32_t TaskMonitorAdd(TaskInfoRunningElem task, struct pios_thread *threadp)
#define CALL_DO_DUMB_TEST_DELAY
#define LOADABLE_EXTENSION_MAGIC
void PIOS_Thread_Sleep(uint32_t time_ms)
#define EXCEPTION_STACK_PC_OFFSET
#define CALL_PIOS_THREAD_SLEEP
static void * layout_extension_ram(struct loadable_extension *ext)
Includes PiOS and core architecture components.
static int32_t loadable_start(void)
#define CALL_PIOS_THREAD_CREATE
void system_annunc_custom_string(const char *string)
#define LOADABLE_REQUIRE_VERSION_INVALID
static void do_dumb_regtask(struct pios_thread *h)
void MemManageVector(void)
static void invoke_one_loadable(struct loadable_extension *ext)