emcyfra/runner.c

41 lines
1007 B
C

#include <platform/platform.h>
#include <platform/printf.h>
#include <stdint.h>
#define RAM_START 0x20000000
#define RAM_END RAM_START + 0x00800000
#define LIB_MAGIC 0x88DAD0F2
typedef int (*func_t)();
void execute_library_function() {
printf("Scanning RAM...\n");
uint32_t *ptr = (uint32_t *)RAM_START;
uint32_t entry_point;
while ((uint32_t)ptr < RAM_END) {
if (*ptr == LIB_MAGIC) {
printf("Found libpqscheme_test 0x%X!\n", ptr);
entry_point = RAM_START + (*(ptr + 1));
entry_point |= 1; // Ensure thumb mod
func_t test_func = (func_t)(entry_point);
if (test_func) {
printf("Result: %d\n", test_func());
}
return;
}
ptr++;
}
printf("Test binary not found!\n");
}
void main() {
platform_init(PLATFORM_CLOCK_MAX);
platform_sync();
printf("Runner started\n");
execute_library_function();
printf("Execution finished\n");
}