| 99 |
theseven |
1 |
#include <stdint.h>
|
|
|
2 |
#include <stdarg.h>
|
|
|
3 |
#include <stdbool.h>
|
|
|
4 |
#include "syscallapi.h"
|
|
|
5 |
#include "syscallwrappers.h"
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
#define EMBIOS_APP_HEADER(threadnamestr, stacksizebytes, mainfunc, threadprio) \
|
|
|
9 |
uint32_t __embios_thread_stack[stacksizebytes >> 2]; \
|
|
|
10 |
char __embios_thread_name[] = threadnamestr; \
|
|
|
11 |
struct embios_app_header \
|
|
|
12 |
{ \
|
|
|
13 |
char signature[8]; \
|
|
|
14 |
int version; \
|
|
|
15 |
void* baseaddr; \
|
|
|
16 |
int size; \
|
|
|
17 |
uint32_t crc32; \
|
|
|
18 |
void* stackaddr; \
|
|
|
19 |
int stacksize; \
|
|
|
20 |
void* entrypoint; \
|
|
|
21 |
char* threadname; \
|
|
|
22 |
int threadtype; \
|
|
|
23 |
int threadpriority; \
|
|
|
24 |
} __embios_executable_hdr __attribute__((section(".execheader"))) = \
|
|
|
25 |
{ \
|
|
|
26 |
.signature = "emBIexec", \
|
|
|
27 |
.version = 0, \
|
|
|
28 |
.baseaddr = &__embios_executable_hdr, \
|
|
|
29 |
.size = -1, \
|
|
|
30 |
.crc32 = 0, \
|
|
|
31 |
.stackaddr = __embios_thread_stack, \
|
|
|
32 |
.stacksize = stacksizebytes, \
|
|
|
33 |
.entrypoint = mainfunc, \
|
|
|
34 |
.threadname = __embios_thread_name, \
|
|
|
35 |
.threadtype = 0, \
|
|
|
36 |
.threadpriority = threadprio \
|
|
|
37 |
}; \
|
|
|
38 |
struct embios_syscall_table* __embios_syscall;
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
#define embios_init() \
|
|
|
42 |
asm volatile("swi\t2\n\tldr\tr1,\t=__embios_syscall\n\tstr\tr0,\t[r1]\n\t" \
|
|
|
43 |
::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory");
|
|
|
44 |
|