Subversion Repositories freemyipod

Rev

Rev 465 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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