Subversion Repositories freemyipod

Rev

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

Rev 424 Rev 427
Line 1... Line 1...
1
#include "syscallwrappers.h"
1
#include "syscallwrappers.h"
2
 
2
 
3
 
3
 
4
#define EMBIOS_APP_HEADER(threadnamestr, stacksizebytes, mainfunc, threadprio)                    \
4
#define EMCORE_APP_HEADER(threadnamestr, stacksizebytes, mainfunc, threadprio)                    \
5
    extern char __bss_start;                                                                      \
5
    extern char __bss_start;                                                                      \
6
    extern char __bss_end;                                                                        \
6
    extern char __bss_end;                                                                        \
7
    void __embios_init()                                                                          \
7
    void __emcore_init()                                                                          \
8
    {                                                                                             \
8
    {                                                                                             \
9
        asm volatile("swi\t2\n\tldr\tr3, =__embios_required_version\nldr\tr3, [r3]\n\t"           \
9
        asm volatile("swi\t2\n\tldr\tr3, =__emcore_required_version\nldr\tr3, [r3]\n\t"           \
10
                     "ldr\tr2, [r0]\n\tcmp\tr3, r2\n\tldrls\tr1, [r0,#4]\n\tcmpls\tr1, r3\n\t"    \
10
                     "ldr\tr2, [r0]\n\tcmp\tr3, r2\n\tldrls\tr1, [r0,#4]\n\tcmpls\tr1, r3\n\t"    \
11
                     "movhi\tr0, #0\n\tldrhi\tr1, =__embios_incompatible_api_str\n\t"             \
11
                     "movhi\tr0, #0\n\tldrhi\tr1, =__emcore_incompatible_api_str\n\t"             \
12
                     "swihi\t1\n\tldr\tr1, =__embios_syscall\n\tstr\tr0, [r1]\n\t"                \
12
                     "swihi\t1\n\tldr\tr1, =__emcore_syscall\n\tstr\tr0, [r1]\n\t"                \
13
                 ::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory");                        \
13
                 ::: "r0", "r1", "r2", "r3", "r12", "lr", "cc", "memory");                        \
14
        memset(&__bss_start, 0, (&__bss_end) - (&__bss_start));                                   \
14
        memset(&__bss_start, 0, (&__bss_end) - (&__bss_start));                                   \
15
        mainfunc();                                                                               \
15
        mainfunc();                                                                               \
16
    }                                                                                             \
16
    }                                                                                             \
17
    uint32_t __embios_thread_stack[stacksizebytes >> 2] __attribute__((section(".stack")));       \
17
    uint32_t __emcore_thread_stack[stacksizebytes >> 2] __attribute__((section(".stack")));       \
18
    const char __embios_thread_name[] = threadnamestr;                                            \
18
    const char __emcore_thread_name[] = threadnamestr;                                            \
19
    struct embios_app_header                                                                      \
19
    struct emcore_app_header                                                                      \
20
    {                                                                                             \
20
    {                                                                                             \
21
        char signature[8];                                                                        \
21
        char signature[8];                                                                        \
22
        int version;                                                                              \
22
        int version;                                                                              \
23
        void* baseaddr;                                                                           \
23
        void* baseaddr;                                                                           \
24
        int size;                                                                                 \
24
        int size;                                                                                 \
Line 27... Line 27...
27
        int stacksize;                                                                            \
27
        int stacksize;                                                                            \
28
        void* entrypoint;                                                                         \
28
        void* entrypoint;                                                                         \
29
        const char* threadname;                                                                   \
29
        const char* threadname;                                                                   \
30
        int threadtype;                                                                           \
30
        int threadtype;                                                                           \
31
        int threadpriority;                                                                       \
31
        int threadpriority;                                                                       \
32
    } __embios_executable_hdr __attribute__((section(".execheader"))) =                           \
32
    } __emcore_executable_hdr __attribute__((section(".execheader"))) =                           \
33
    {                                                                                             \
33
    {                                                                                             \
34
        .signature = "emBIexec",                                                                  \
34
        .signature = "emBIexec",                                                                  \
35
        .version = 0,                                                                             \
35
        .version = 0,                                                                             \
36
        .baseaddr = &__embios_executable_hdr,                                                     \
36
        .baseaddr = &__emcore_executable_hdr,                                                     \
37
        .size = -1,                                                                               \
37
        .size = -1,                                                                               \
38
        .crc32 = 0,                                                                               \
38
        .crc32 = 0,                                                                               \
39
        .stackaddr = __embios_thread_stack,                                                       \
39
        .stackaddr = __emcore_thread_stack,                                                       \
40
        .stacksize = stacksizebytes,                                                              \
40
        .stacksize = stacksizebytes,                                                              \
41
        .entrypoint = __embios_init,                                                              \
41
        .entrypoint = __emcore_init,                                                              \
42
        .threadname = __embios_thread_name,                                                       \
42
        .threadname = __emcore_thread_name,                                                       \
43
        .threadtype = 0,                                                                          \
43
        .threadtype = 0,                                                                          \
44
        .threadpriority = threadprio                                                              \
44
        .threadpriority = threadprio                                                              \
45
    };                                                                                            \
45
    };                                                                                            \
46
    struct embios_syscall_table* __embios_syscall __attribute__((section(".stack")));             \
46
    struct emcore_syscall_table* __emcore_syscall __attribute__((section(".stack")));             \
47
    const uint32_t __embios_required_version = EMBIOS_API_VERSION;                                \
47
    const uint32_t __emcore_required_version = EMCORE_API_VERSION;                                \
48
    const char __embios_incompatible_api_str[] = "Incompatible API version!\nGot %d, need %d";
48
    const char __emcore_incompatible_api_str[] = "Incompatible API version!\nGot %d, need %d";