Import kern/ subdirectory.
[bertos.git] / kern / switch_i196.s32
1 ;* Copyright 2004 Develer S.r.l. (http://www.develer.com/)
2 ;* Copyright 1999,2000,2001 Bernardo Innocenti <bernie@develer.com>
3 ;*
4 ;* \version $Id$
5 ;*
6 ;* \author Bernardo Innocenti <bernie@develer.com>
7 ;*
8
9 ;* $Log$
10 ;* Revision 1.1  2004/05/23 17:27:00  bernie
11 ;* Import kern/ subdirectory.
12 ;*
13 ;*
14
15 !!!!!! THIS FILE HAS NOT BEEN REVISED FOR THE NEW SCHEDULER API !!!!!!
16
17
18
19         NAME    AsmSwitch
20         RSEG    CODE
21
22         EXTERN  ?LR
23         EXTERN  ?GR
24         PUBLIC  AsmSwitchContext
25         PUBLIC  AsmReplaceContext
26
27
28 ;* Perform low-level process context switching
29 ;*
30 ;*      void AsmSwitchContext(cpustack_t *new_sp, cpustack_t **save_sp)
31 ;*                                        GR+0                 SP+2
32 ;*
33 ;* Replace current context with new process
34 ;*
35 ;*      void AsmReplaceContext(cpustack_t *new_sp, cpustack_t **dummy)
36 ;*                                         GR+0                 SP+2
37 ;*
38
39 AsmSwitchContext:
40
41 ; pop 2nd parameter from the stack
42         ld      ?GR+2,2[SP]
43
44 ; save all registers
45         push    ?LR+0
46         push    ?LR+2
47         push    ?LR+4
48         push    ?LR+6
49         push    ?LR+8
50         push    ?LR+10
51         push    ?LR+12
52         push    ?LR+14
53         push    ?LR+16
54         push    ?LR+18
55         push    ?LR+20
56         push    ?LR+22
57         push    ?LR+24
58         push    ?LR+26
59         push    ?LR+28
60         push    ?LR+30
61         st      SP,[?GR+2]              ; save old stack pointer
62         ; fall-thru
63
64 AsmReplaceContext:
65         ld      SP,?GR+0                ; load new stack pointer
66
67 ; restore all registers
68         pop     ?LR+30
69         pop     ?LR+28
70         pop     ?LR+26
71         pop     ?LR+24
72         pop     ?LR+22
73         pop     ?LR+20
74         pop     ?LR+18
75         pop     ?LR+16
76         pop     ?LR+14
77         pop     ?LR+12
78         pop     ?LR+10
79         pop     ?LR+8
80         pop     ?LR+6
81         pop     ?LR+4
82         pop     ?LR+2
83         pop     ?LR+0
84
85 ; restore execution in new context
86         ret
87
88         END