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