2025-02-17 09:09:14 +00:00
|
|
|
#include <platform/platform.h>
|
|
|
|
#include <platform/printf.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2025-02-17 23:49:17 +00:00
|
|
|
#define RAM_START 0x20000000
|
2025-02-17 23:46:39 +00:00
|
|
|
#define RAM_END RAM_START + 0x00800000
|
|
|
|
#define LIB_MAGIC 0x88DAD0F2
|
2025-02-17 09:09:14 +00:00
|
|
|
|
2025-02-17 23:46:39 +00:00
|
|
|
typedef int (*func_t)();
|
2025-02-17 09:09:14 +00:00
|
|
|
|
|
|
|
void execute_library_function() {
|
|
|
|
printf("Scanning RAM...\n");
|
2025-02-17 23:46:39 +00:00
|
|
|
uint32_t *ptr = (uint32_t *)RAM_START;
|
2025-02-18 08:24:27 +00:00
|
|
|
uint32_t entry_point;
|
2025-02-17 09:09:14 +00:00
|
|
|
|
|
|
|
while ((uint32_t)ptr < RAM_END) {
|
|
|
|
if (*ptr == LIB_MAGIC) {
|
2025-02-17 23:46:39 +00:00
|
|
|
printf("Found libpqscheme_test 0x%X!\n", ptr);
|
2025-02-18 08:24:27 +00:00
|
|
|
entry_point = RAM_START + (*(ptr + 1));
|
2025-02-18 22:16:59 +00:00
|
|
|
entry_point |= 1; // Ensure thumb mod
|
2025-02-18 08:24:27 +00:00
|
|
|
func_t test_func = (func_t)(entry_point);
|
2025-02-17 09:09:14 +00:00
|
|
|
if (test_func) {
|
2025-02-18 08:24:27 +00:00
|
|
|
printf("Result: %d\n", test_func());
|
2025-02-17 09:09:14 +00:00
|
|
|
}
|
|
|
|
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");
|
|
|
|
}
|