| Line 1... |
Line 1... |
| 1 |
#include "syscallwrappers.h"
|
1 |
#include "syscallwrappers.h"
|
| 2 |
|
2 |
|
| 3 |
|
3 |
|
| 4 |
#define EMCORE_LIB_HEADER(lib_identifier, lib_version, init_func, shutdown_func, api_pointer) \
|
4 |
#define EMCORE_LIB_HEADER(lib_identifier, lib_version, lib_min_version, init_func, shutdown_func, \
|
| - |
|
5 |
api_pointer) \
|
| 5 |
struct emcore_syscall_table* __emcore_syscall; \
|
6 |
struct emcore_syscall_table* __emcore_syscall; \
|
| 6 |
int __emcore_lib_init() \
|
7 |
int __emcore_lib_init() \
|
| 7 |
{ \
|
8 |
{ \
|
| 8 |
asm volatile("swi\t2\n\tldr\tr1, =__emcore_syscall\n\tstr\tr0, [r1]\n\t" \
|
9 |
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 |
::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory"); \
|
| 10 |
if (__emcore_syscall->table_version < EMCORE_API_VERSION \
|
11 |
if (__emcore_syscall->table_version < EMCORE_API_VERSION \
|
| 11 |
|| __emcore_syscall->table_minversion > EMCORE_API_VERSION) \
|
12 |
|| __emcore_syscall->table_minversion > EMCORE_API_VERSION) \
|
| 12 |
return 0x80000000; \
|
13 |
return 0x80000000; \
|
| 13 |
if (init_func) return init_func(); \
|
- |
|
| 14 |
} \
|
14 |
} \
|
| 15 |
struct emcorelib_header __emcore_lib_header __attribute__((section(".emcoreentrypoint"))) = \
|
15 |
struct emcorelib_header __emcore_lib_header __attribute__((section(".emcoreentrypoint"))) = \
|
| 16 |
{ \
|
16 |
{ \
|
| 17 |
.headerversion = EMCORELIB_HEADER_VERSION, \
|
17 |
.headerversion = EMCORELIB_HEADER_VERSION, \
|
| 18 |
.identifier = lib_identifier, \
|
18 |
.identifier = lib_identifier, \
|
| 19 |
.version = lib_version, \
|
19 |
.version = lib_version, \
|
| - |
|
20 |
.minversion = lib_min_version, \
|
| 20 |
.initfunc = __emcore_lib_init, \
|
21 |
.setupfunc = __emcore_lib_init, \
|
| - |
|
22 |
.initfunc = init_func, \
|
| 21 |
.shutdownfunc = shutdown_func, \
|
23 |
.shutdownfunc = shutdown_func, \
|
| 22 |
.api = &api_pointer \
|
24 |
.api = &api_pointer \
|
| 23 |
};
|
25 |
};
|