Remove stale declarations (moved to monitor.h).
[bertos.git] / kern / switch_dsp56k.c
1 /*!
2  * \file
3  * <!--
4  * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See devlib/README for information.
6  * -->
7  *
8  * \version $Id$
9  *
10  * \author Giovanni Bajo <rasky@develer.com>
11  *
12  * \brief DSP5680x task switching support
13  */
14
15 /*#*
16  *#* $Log$
17  *#* Revision 1.4  2004/08/25 14:12:09  rasky
18  *#* Aggiornato il comment block dei log RCS
19  *#*
20  *#* Revision 1.3  2004/07/30 14:24:16  rasky
21  *#* Task switching con salvataggio perfetto stato di interrupt (SR)
22  *#* Kernel monitor per dump informazioni su stack dei processi
23  *#*
24  *#* Revision 1.2  2004/06/03 11:27:09  bernie
25  *#* Add dual-license information.
26  *#*
27  *#* Revision 1.1  2004/05/23 17:27:00  bernie
28  *#* Import kern/ subdirectory.
29  *#*
30  *#*/
31
32 void asm_switch_context(void ** new_sp/*R2*/, void ** save_sp/*R3*/);
33 asm void asm_switch_context(void ** new_sp, void ** save_sp)
34 {
35         lea   (SP)+
36
37         ; From the manual:
38         ; The compiler uses page 0 address locations X: 0x0030 - 0x003F as register
39         ; variables. Frequently accessed local variables are assigned to the page 0
40         ; registers instead of to stack locations so that load and store instructions
41         ; are shortened. Addresses X: 0x0030 - 0x0037 (page 0 registers MR0-MR7) are
42         ; volatile registers and can be overwritten. The remaining registers (page 0
43         ; registers MR8-MR15) are treated as non-volatile and, if used by a routine,
44         ; must be saved on entry and restored on exit.
45         ;
46         ; So, register 0x30-0x37 are caller-save, while 0x38-0x3F are callee-save.
47         move  x:<$38,y1
48         move  y1,x:(SP)+
49         move  x:<$39,y1
50         move  y1,x:(SP)+
51         move  x:<$3A,y1
52         move  y1,x:(SP)+
53         move  x:<$3B,y1
54         move  y1,x:(SP)+
55         move  x:<$3C,y1
56         move  y1,x:(SP)+
57         move  x:<$3D,y1
58         move  y1,x:(SP)+
59         move  x:<$3E,y1
60         move  y1,x:(SP)+
61         move  x:<$3F,y1
62         move  y1,x:(SP)
63         
64         ; 
65         ; Switch stacks
66         nop
67         move SP, x:(R3)
68         nop
69         move x:(R2), SP
70         nop
71
72         ;
73         ; restore all saved registers
74         ;
75         pop   y1
76         move  y1,x:<$3F
77         pop   y1
78         move  y1,x:<$3E
79         pop   y1
80         move  y1,x:<$3D
81         pop   y1
82         move  y1,x:<$3C
83         pop   y1
84         move  y1,x:<$3B
85         pop   y1
86         move  y1,x:<$3A
87         pop   y1
88         move  y1,x:<$39
89         pop   y1
90         move  y1,x:<$38
91
92         ; SR is already pushed on the stack (normal call context). Use RTI to restore
93         ; it, so that interrupt status is preserved across the tasks.
94         rti
95 }
96
97 int asm_switch_version(void);
98 int asm_switch_version(void)
99 {
100         return 1;
101 }