| 465 |
theseven |
1 |
#include "syscallwrappers.h"
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
#define EMCORE_LIB_HEADER(libidentifier, libversion, initfunc, shutdownfunc, apipointer) \
|
|
|
5 |
struct emcore_syscall_table* __emcore_syscall; \
|
|
|
6 |
int __emcore_lib_init() \
|
|
|
7 |
{ \
|
|
|
8 |
asm volatile("swi\t2\n\tldr\tr1, =__emcore_syscall\n\tstr\tr0, [r1]\n\t" \
|
|
|
9 |
::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory"); \
|
|
|
10 |
if (__embios_syscall->table_version < EMCORE_API_VERSION \
|
|
|
11 |
|| __embios_syscall->table_minversion > EMCORE_API_VERSION) \
|
|
|
12 |
return 0x80000000; \
|
|
|
13 |
if (initfunc) return initfunc(); \
|
|
|
14 |
} \
|
|
|
15 |
struct emcorelib_header __attribute__((section(".emcoreentrypoint"))) __emcore_entrypoint() \
|
|
|
16 |
{ \
|
|
|
17 |
.headerversion = EMCORELIB_HEADER_VERSION, \
|
|
|
18 |
.identifier = libidentifier, \
|
|
|
19 |
.version = libversion, \
|
|
|
20 |
.initfunc = __emcore_lib_init, \
|
|
|
21 |
.shutdownfunc = shutdownfunc, \
|
|
|
22 |
.api = apipointer \
|
|
|
23 |
};
|