Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
465 theseven 1
#include "syscallwrappers.h"
2
 
3
 
466 theseven 4
#define EMCORE_LIB_HEADER(lib_identifier, lib_version, init_func, shutdown_func, api_pointer)     \
465 theseven 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");                        \
466 theseven 10
        if (__emcore_syscall->table_version < EMCORE_API_VERSION                                  \
11
         || __emcore_syscall->table_minversion > EMCORE_API_VERSION)                              \
465 theseven 12
             return 0x80000000;                                                                   \
466 theseven 13
        if (init_func) return init_func();                                                        \
465 theseven 14
    }                                                                                             \
466 theseven 15
    struct emcorelib_header __emcore_lib_header __attribute__((section(".emcoreentrypoint"))) =   \
465 theseven 16
    {                                                                                             \
17
        .headerversion = EMCORELIB_HEADER_VERSION,                                                \
466 theseven 18
        .identifier = lib_identifier,                                                             \
19
        .version = lib_version,                                                                   \
465 theseven 20
        .initfunc = __emcore_lib_init,                                                            \
466 theseven 21
        .shutdownfunc = shutdown_func,                                                            \
22
        .api = &api_pointer                                                                       \
465 theseven 23
    };