Blame view

RIOT/cpu/native/tramp.S 2.5 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  /*
   * Copyright (C) 2013, 2014 Ludwig KnΓΌpfer <ludwig.knuepfer@fu-berlin.de>
   * Copyright (C) 2014 Thomas Eichinger <thomas.eichinger1@gmail.com>
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  .text
  
  #ifdef __MACH__
  .globl __native_sig_leave_tramp
  __native_sig_leave_tramp:
      pushl __native_saved_eip
      pushfl
      pushal
  
      pushl __native_isr_ctx
      pushl __native_cur_ctx
      call _swapcontext
      addl $8, %esp
  
      call _irq_enable
  
      movl $0x0, __native_in_isr
      popal
      popfl
  
      ret
  
  .globl __native_sig_leave_handler
  __native_sig_leave_handler:
      pushl __native_saved_eip
      movl $0x0, __native_in_isr
      ret
  
  #elif __arm__
  
  .globl _native_sig_leave_tramp
  _native_sig_leave_tramp:
      /* save _native_saved_eip and registers */
      stmdb   sp!, {r0}
      ldr     r0, =_native_saved_eip
      ldr     r0, [r0]
      stmdb   sp!, {r0-r12}
      stmdb   sp!, {lr}
  
      /* exchange r0 and _native_saved_eip */
      ldr     r0, [sp,#56]
      ldr     r1, [sp,#4 ]
      str     r0, [sp,#4 ]
      str     r1, [sp,#56]
  
      /* call swapcontext ( _native_cur_ctx, _native_isr_ctx ) */
      ldr     r2, =_native_cur_ctx
      ldr     r0, [r2]
      ldr     r2, =_native_isr_ctx
      ldr     r1, [r2]
      bl      swapcontext
  
      /* reeanble interrupts */
      bl      irq_enable
  
      /* _native_in_isr = 0 */
      eor     r0, r0, r0
      ldr     r2, =_native_in_isr
      str     r0, [r2]
  
      /* restore registers, jump to (saved) _native_saved_eip */
      ldmia   sp!, {lr}
      ldmia   sp!, {r0-r12}
      ldmia   sp!, {pc}
  
  .globl _native_sig_leave_handler
  _native_sig_leave_handler:
      stmdb sp!, {r0}
      ldr r0, =_native_saved_eip
      ldr r0, [r0]
      stmdb sp!, {r0-r12}
      stmdb sp!, {lr}
      /* exchange r0 and _native_saved_eip */
      ldr     r0, [sp,#56]
      ldr     r1, [sp,#4 ]
      str     r0, [sp,#4 ]
      str     r1, [sp,#56]
      /* _native_in_isr = 0 */
      eor     r0, r0, r0
      ldr     r1, =_native_in_isr
      str     r0, [r1]
      ldmia sp!, {lr}
      ldmia sp!, {r0-r12}
      ldmia sp!, {pc}
  
  #else
  .globl _native_sig_leave_tramp
  
  _native_sig_leave_tramp:
      pushl _native_saved_eip
      pushfl
      pushal
  
      pushl _native_isr_ctx
      pushl _native_cur_ctx
      call swapcontext
      addl $8, %esp
  
      call irq_enable
  
      movl $0x0, _native_in_isr
      popal
      popfl
  
      ret
  
  .globl _native_sig_leave_handler
  _native_sig_leave_handler:
      pushl _native_saved_eip
      movl $0x0, _native_in_isr
      ret
  #endif