| Index: apps/embiosapp.h | 
| — | — | @@ -7,7 +7,7 @@ | 
| 8 | 8 |  | 
| 9 | 9 | #define EMBIOS_APP_HEADER(threadnamestr, stacksizebytes, mainfunc, threadprio)                    \ | 
| 10 | 10 | uint32_t __embios_thread_stack[stacksizebytes >> 2];                                          \ | 
| 11 |  | -    char __embios_thread_name[] = threadnamestr;                                                  \
 | 
|  | 11 | +    const char __embios_thread_name[] = threadnamestr;                                            \ | 
| 12 | 12 | struct embios_app_header                                                                      \ | 
| 13 | 13 | {                                                                                             \ | 
| 14 | 14 | char signature[8];                                                                        \ | 
| — | — | @@ -18,7 +18,7 @@ | 
| 19 | 19 | void* stackaddr;                                                                          \ | 
| 20 | 20 | int stacksize;                                                                            \ | 
| 21 | 21 | void* entrypoint;                                                                         \ | 
| 22 |  | -        char* threadname;                                                                         \
 | 
|  | 22 | +        const char* threadname;                                                                   \ | 
| 23 | 23 | int threadtype;                                                                           \ | 
| 24 | 24 | int threadpriority;                                                                       \ | 
| 25 | 25 | } __embios_executable_hdr __attribute__((section(".execheader"))) =                           \ | 
| — | — | @@ -35,10 +35,15 @@ | 
| 36 | 36 | .threadtype = 0,                                                                          \ | 
| 37 | 37 | .threadpriority = threadprio                                                              \ | 
| 38 | 38 | };                                                                                            \ | 
| 39 |  | -    struct embios_syscall_table* __embios_syscall;
 | 
|  | 39 | +    struct embios_syscall_table* __embios_syscall;                                                \ | 
|  | 40 | +    const uint32_t __embios_required_version = EMBIOS_API_VERSION;                                \ | 
|  | 41 | +    const char __embios_incompatible_api_str[] = "Incompatible API version!\nGot %d, need %d"; | 
| 40 | 42 |  | 
| 41 | 43 |  | 
| 42 | 44 | #define embios_init()                                                                             \ | 
| 43 |  | -    asm volatile("swi\t2\n\tldr\tr1,\t=__embios_syscall\n\tstr\tr0,\t[r1]\n\t"                    \
 | 
|  | 45 | +    asm volatile("swi\t2\n\tldr\tr3,\t=__embios_required_version\nldr\tr3,\t[r3]\n\t"             \ | 
|  | 46 | +                 "ldr\tr2,\t[r0]\n\tcmp\tr3,\tr2\n\tldrls\tr1,\t[r0,#4]\n\tcmpls\tr1,\tr3\n\t"    \ | 
|  | 47 | +                 "movhi\tr0,\t#0\n\tldrhi\tr1,\t=__embios_incompatible_api_str\n\t"               \ | 
|  | 48 | +                 "swihi\t1\n\tldr\tr1,\t=__embios_syscall\n\tstr\tr0,\t[r1]\n\t"                  \ | 
| 44 | 49 | ::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory"); | 
| 45 | 50 |  | 
| Index: apps/syscallapi.h | 
| — | — | @@ -56,6 +56,8 @@ | 
| 57 | 57 |  | 
| 58 | 58 | struct embios_syscall_table | 
| 59 | 59 | { | 
|  | 60 | +    uint32_t table_version; | 
|  | 61 | +    uint32_t table_minversion; | 
| 60 | 62 | void (*panic) (enum panic_severity severity, const char* string); | 
| 61 | 63 | void (*panicf) (enum panic_severity severity, const char* fmt, ...); | 
| 62 | 64 | }; | 
| Index: embios/trunk/syscallapi.c | 
| — | — | @@ -28,6 +28,8 @@ | 
| 29 | 29 |  | 
| 30 | 30 | struct embios_syscall_table syscall_table ICONST_ATTR = | 
| 31 | 31 | { | 
|  | 32 | +    .table_version = EMBIOS_API_VERSION, | 
|  | 33 | +    .table_minversion = EMBIOS_MIN_API_VERSION, | 
| 32 | 34 | .panic = panic, | 
| 33 | 35 | .panicf = panicf | 
| 34 | 36 | }; | 
| Index: embios/trunk/syscallapi.h | 
| — | — | @@ -56,6 +56,8 @@ | 
| 57 | 57 |  | 
| 58 | 58 | struct embios_syscall_table | 
| 59 | 59 | { | 
|  | 60 | +    uint32_t table_version; | 
|  | 61 | +    uint32_t table_minversion; | 
| 60 | 62 | void (*panic) (enum panic_severity severity, const char* string); | 
| 61 | 63 | void (*panicf) (enum panic_severity severity, const char* fmt, ...); | 
| 62 | 64 | }; |