| Line 1... |
Line 1... |
| 1 |
#include "syscallwrappers.h"
|
1 |
#include "syscallwrappers.h"
|
| 2 |
|
2 |
|
| 3 |
|
3 |
|
| 4 |
#define EMCORE_APP_HEADER(threadnamestr, mainfunc, threadprio) \
|
4 |
#define EMCORE_APP_HEADER(threadnamestr, mainfunc, threadprio) \
|
| 5 |
void __attribute__((section(".emcoreentrypoint"))) __emcore_entrypoint() \
|
5 |
void __attribute__((section(".emcoreentrypoint"))) \
|
| - |
|
6 |
__emcore_entrypoint(int argc, const char** argv) \
|
| 6 |
{ \
|
7 |
{ \
|
| 7 |
asm volatile("swi\t2\n\tldr\tr3, =__emcore_required_version\nldr\tr3, [r3]\n\t" \
|
8 |
asm volatile("swi\t2\n\tldr\tr3, =__emcore_required_version\nldr\tr3, [r3]\n\t" \
|
| 8 |
"ldr\tr2, [r0]\n\tcmp\tr3, r2\n\tldrls\tr1, [r0,#4]\n\tcmpls\tr1, r3\n\t" \
|
9 |
"ldr\tr2, [r0]\n\tcmp\tr3, r2\n\tldrls\tr1, [r0,#4]\n\tcmpls\tr1, r3\n\t" \
|
| 9 |
"movhi\tr0, #0\n\tldrhi\tr1, =__emcore_incompatible_api_str\n\t" \
|
10 |
"movhi\tr0, #0\n\tldrhi\tr1, =__emcore_incompatible_api_str\n\t" \
|
| 10 |
"swihi\t1\n\tldr\tr1, =__emcore_syscall\n\tstr\tr0, [r1]\n\t" \
|
11 |
"swihi\t1\n\tldr\tr1, =__emcore_syscall\n\tstr\tr0, [r1]\n\t" \
|
| 11 |
"b\t__emcore_entrypoint_c\n\t.ltorg\n__emcore_entrypoint_c:\n\t" \
|
12 |
"b\t__emcore_entrypoint_c\n\t.ltorg\n__emcore_entrypoint_c:\n\t" \
|
| 12 |
::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory"); \
|
13 |
::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory"); \
|
| 13 |
thread_set_name(NULL, threadnamestr); \
|
14 |
thread_set_name(NULL, threadnamestr); \
|
| 14 |
thread_set_priority(NULL, threadprio); \
|
15 |
thread_set_priority(NULL, threadprio); \
|
| 15 |
mainfunc(); \
|
16 |
mainfunc(argc, argv); \
|
| 16 |
} \
|
17 |
} \
|
| 17 |
struct emcore_syscall_table* __emcore_syscall; \
|
18 |
struct emcore_syscall_table* __emcore_syscall; \
|
| 18 |
const uint32_t __emcore_required_version = EMCORE_API_VERSION; \
|
19 |
const uint32_t __emcore_required_version = EMCORE_API_VERSION; \
|
| 19 |
const char __emcore_incompatible_api_str[] = "Incompatible API version!\nGot %d, need %d";
|
20 |
const char __emcore_incompatible_api_str[] = "Incompatible API version!\nGot %d, need %d";
|
| 20 |
|
21 |
|