source: libcfa/src/concurrency/CtxSwitch-arm32.S @ 13d326ec

ADTast-experimentalpthread-emulation
Last change on this file since 13d326ec was 95472ee, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

readd ARM 32-bit context-switch assemble file

  • Property mode set to 100644
File size: 1.7 KB
Line 
1        # 32 bit ARM context switch
2        # This function assumes that r9 has no special meaning on the platform it's
3        # being built on.
4        # If r9 is special, uncomment the following line and it will be left alone
5
6        # #define R9_SPECIAL
7
8        #define PTR_BYTE        4
9        #define SP_OFFSET       ( 0 * PTR_BYTE )
10        #define FP_OFFSET       ( 1 * PTR_BYTE )
11        #define PC_OFFSET       ( 2 * PTR_BYTE )
12
13        .text
14        .align  2
15        .global __cfactx_switch
16        .type   __cfactx_switch, %function
17
18__cfactx_switch:
19        # save callee-saved registers: r4-r8, r10, r11, r13(sp) (plus r9 depending on platform specification)
20        # I've seen reference to 31 registers on 64-bit, if this is the case, more need to be saved
21        # save thread state registers: r14(lr)
22        # r12(ip) is intra-procedure-call scratch register, does not need saving between function calls
23
24        #ifdef R9_SPECIAL
25        stmfd r13!, {r4-r8,r10,r11,r14}
26        #else
27        stmfd r13!, {r4-r11,r14}
28        #endif // R9_SPECIAL
29
30        # save floating point registers: s16-s31
31        vstmdb r13!, {s16-s31}
32
33        # save frame pointer and stack pointer to outgoing datastructure
34        str sp, [r0, #SP_OFFSET]
35        str fp, [r0, #FP_OFFSET]
36
37        # restore frame pointer and stack pointer from incoming datastructure
38        ldr fp, [r1, #FP_OFFSET]
39        ldr sp, [r1, #SP_OFFSET]
40
41        # restore floating point registers: s16-s31
42        vldm r13!, {s16-s31}
43        # restore r14(lr)
44        # restore 64-bit extra registers?
45        # restore callee-saved registers: r4-r8, r10, r11, r13
46
47        #ifdef R9_SPECIAL
48        ldmfd r13!, {r4-r8,r10,r11,r15}
49        #else
50        ldmfd r13!, {r4-r11,r14}    # loading r14 back into r15 returns
51
52        mov r15, r14
53        #endif // R9_SPECIAL
54
55        .text
56        .align  2
57        .global __cfactx_invoke_stub
58        .type   __cfactx_invoke_stub, %function
59
60__cfactx_invoke_stub:
61        ldmfd r13!, {r0-r1}
62        mov r15, r1
Note: See TracBrowser for help on using the repository browser.