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