xref: /nrf52832-nimble/rt-thread/libcpu/mips/loongson_1c/stackframe_fpu.h (revision 104654410c56c573564690304ae786df310c91fc)
1 /*
2  * ls1c FPU's stackframe
3  * �ʼ���룬��������뵽stackframe.h�е�SAVE_ALL, RESTORE_ALL��RESTORE_ALL_AND_RET�У�
4  * �����ǵ�Դ�ļ�"stackframe.h"λ��Ŀ¼"libcpu\mips\common"�ڣ���Ӱ�쵽����mips cpu
5  * ���ԣ������½���Դ�ļ�
6  */
7 #ifndef __OPENLOONGSON_STACKFRAME_FPU_H
8 #define __OPENLOONGSON_STACKFRAME_FPU_H
9 
10 
11 #include "../common/asm.h"
12 #include "../common/mipsregs.h"
13 #include "../common/stackframe.h"
14 
15 
16 
17 #define PT_FPU_R0               (0)
18 #define PT_FPU_R2               ((PT_FPU_R0) + 2*LONGSIZE)
19 #define PT_FPU_R4               ((PT_FPU_R2) + 2*LONGSIZE)
20 #define PT_FPU_R6               ((PT_FPU_R4) + 2*LONGSIZE)
21 #define PT_FPU_R8               ((PT_FPU_R6) + 2*LONGSIZE)
22 #define PT_FPU_R10              ((PT_FPU_R8) + 2*LONGSIZE)
23 #define PT_FPU_R12              ((PT_FPU_R10) + 2*LONGSIZE)
24 #define PT_FPU_R14              ((PT_FPU_R12) + 2*LONGSIZE)
25 #define PT_FPU_R16              ((PT_FPU_R14) + 2*LONGSIZE)
26 #define PT_FPU_R18              ((PT_FPU_R16) + 2*LONGSIZE)
27 #define PT_FPU_R20              ((PT_FPU_R18) + 2*LONGSIZE)
28 #define PT_FPU_R22              ((PT_FPU_R20) + 2*LONGSIZE)
29 #define PT_FPU_R24              ((PT_FPU_R22) + 2*LONGSIZE)
30 #define PT_FPU_R26              ((PT_FPU_R24) + 2*LONGSIZE)
31 #define PT_FPU_R28              ((PT_FPU_R26) + 2*LONGSIZE)
32 #define PT_FPU_R30              ((PT_FPU_R28) + 2*LONGSIZE)
33 
34 #define PT_FPU_SIZE             ((((PT_FPU_R30) + 2*LONGSIZE) + (2*PTRSIZE-1)) & ~(2*PTRSIZE-1))
35 
36 
37     .macro SAVE_FPU
38     .set push
39     .set noreorder
40 #ifdef RT_USING_FPU
41     move k1, sp                     /* �����ֳ� */
42     and k0, k1, 0xFFFFFFF8          /* 8�ֽڶ��� */
43     PTR_SUBU sp, k0, PT_FPU_SIZE    /* ����ջ�� */
44     s.d $f0, PT_FPU_R0(sp)
45     s.d $f2, PT_FPU_R2(sp)
46     s.d $f4, PT_FPU_R4(sp)
47     s.d $f6, PT_FPU_R6(sp)
48     s.d $f8, PT_FPU_R8(sp)
49     s.d $f10, PT_FPU_R10(sp)
50     s.d $f12, PT_FPU_R12(sp)
51     s.d $f14, PT_FPU_R14(sp)
52     s.d $f16, PT_FPU_R16(sp)
53     s.d $f18, PT_FPU_R18(sp)
54     s.d $f20, PT_FPU_R20(sp)
55     s.d $f22, PT_FPU_R22(sp)
56     s.d $f24, PT_FPU_R24(sp)
57     s.d $f26, PT_FPU_R26(sp)
58     s.d $f28, PT_FPU_R28(sp)
59     s.d $f30, PT_FPU_R30(sp)
60     move sp, k1                     /* �ָ��ֳ� */
61 #endif
62     .set reorder
63     .set pop
64     .endm
65 
66 
67     .macro RESTORE_FPU
68     .set push
69     .set noreorder
70 #ifdef RT_USING_FPU
71     move k1, sp                     /* �����ֳ� */
72     and k0, k1, 0xFFFFFFF8          /* 8�ֽڶ��� */
73     PTR_SUBU sp, k0, PT_FPU_SIZE    /* ����ջ��*/
74     l.d $f0, PT_FPU_R0(sp)
75     l.d $f2, PT_FPU_R2(sp)
76     l.d $f4, PT_FPU_R4(sp)
77     l.d $f6, PT_FPU_R6(sp)
78     l.d $f8, PT_FPU_R8(sp)
79     l.d $f10, PT_FPU_R10(sp)
80     l.d $f12, PT_FPU_R12(sp)
81     l.d $f14, PT_FPU_R14(sp)
82     l.d $f16, PT_FPU_R16(sp)
83     l.d $f18, PT_FPU_R18(sp)
84     l.d $f20, PT_FPU_R20(sp)
85     l.d $f22, PT_FPU_R22(sp)
86     l.d $f24, PT_FPU_R24(sp)
87     l.d $f26, PT_FPU_R26(sp)
88     l.d $f28, PT_FPU_R28(sp)
89     l.d $f30, PT_FPU_R30(sp)
90     move sp, k1                     /* �ָ��ֳ� */
91 #endif
92     .set reorder
93     .set pop
94     .endm
95 
96 
97 #endif
98 
99