GNU Linux-libre 4.14.290-gnu1
[releases.git] / arch / frv / include / uapi / asm / registers.h
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /* registers.h: register frame declarations
3  *
4  * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
5  * Written by David Howells (dhowells@redhat.com)
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version
10  * 2 of the License, or (at your option) any later version.
11  */
12
13 /*
14  * notes:
15  *
16  * (1) that the members of all these structures are carefully aligned to permit
17  *     usage of STD/STDF instructions
18  *
19  * (2) if you change these structures, you must change the code in
20  *     arch/frvnommu/kernel/{break.S,entry.S,switch_to.S,gdb-stub.c}
21  *
22  *
23  * the kernel stack space block looks like this:
24  *
25  *      +0x2000 +----------------------
26  *              | union {
27  *              |       struct frv_frame0 {
28  *              |               struct user_context {
29  *              |                       struct user_int_regs
30  *              |                       struct user_fpmedia_regs
31  *              |               }
32  *              |               struct frv_debug_regs
33  *              |       }
34  *              |       struct pt_regs [user exception]
35  *              | }
36  *              +---------------------- <-- __kernel_frame0_ptr (maybe GR28)
37  *              |
38  *              | kernel stack
39  *              |
40  *              |......................
41  *              | struct pt_regs [kernel exception]
42  *              |...................... <-- __kernel_frame0_ptr (maybe GR28)
43  *              |
44  *              | kernel stack
45  *              |
46  *              |...................... <-- stack pointer (GR1)
47  *              |
48  *              | unused stack space
49  *              |
50  *              +----------------------
51  *              | struct thread_info
52  *      +0x0000 +---------------------- <-- __current_thread_info (GR15);
53  *
54  * note that GR28 points to the current exception frame
55  */
56
57 #ifndef _ASM_REGISTERS_H
58 #define _ASM_REGISTERS_H
59
60 #ifndef __ASSEMBLY__
61 #define __OFFSET(X,N)   ((X)+(N)*4)
62 #define __OFFSETC(X,N)  xxxxxxxxxxxxxxxxxxxxxxxx
63 #else
64 #define __OFFSET(X,N)   ((X)+(N)*4)
65 #define __OFFSETC(X,N)  ((X)+(N))
66 #endif
67
68 /*****************************************************************************/
69 /*
70  * Exception/Interrupt frame
71  * - held on kernel stack
72  * - 8-byte aligned on stack (old SP is saved in frame)
73  * - GR0 is fixed 0, so we don't save it
74  */
75 #ifndef __ASSEMBLY__
76
77 struct pt_regs {
78         unsigned long           psr;            /* Processor Status Register */
79         unsigned long           isr;            /* Integer Status Register */
80         unsigned long           ccr;            /* Condition Code Register */
81         unsigned long           cccr;           /* Condition Code for Conditional Insns Register */
82         unsigned long           lr;             /* Link Register */
83         unsigned long           lcr;            /* Loop Count Register */
84         unsigned long           pc;             /* Program Counter Register */
85         unsigned long           __status;       /* exception status */
86         unsigned long           syscallno;      /* syscall number or -1 */
87         unsigned long           orig_gr8;       /* original syscall arg #1 */
88         unsigned long           gner0;
89         unsigned long           gner1;
90         unsigned long long      iacc0;
91         unsigned long           tbr;            /* GR0 is fixed zero, so we use this for TBR */
92         unsigned long           sp;             /* GR1: USP/KSP */
93         unsigned long           fp;             /* GR2: FP */
94         unsigned long           gr3;
95         unsigned long           gr4;
96         unsigned long           gr5;
97         unsigned long           gr6;
98         unsigned long           gr7;            /* syscall number */
99         unsigned long           gr8;            /* 1st syscall param; syscall return */
100         unsigned long           gr9;            /* 2nd syscall param */
101         unsigned long           gr10;           /* 3rd syscall param */
102         unsigned long           gr11;           /* 4th syscall param */
103         unsigned long           gr12;           /* 5th syscall param */
104         unsigned long           gr13;           /* 6th syscall param */
105         unsigned long           gr14;
106         unsigned long           gr15;
107         unsigned long           gr16;           /* GP pointer */
108         unsigned long           gr17;           /* small data */
109         unsigned long           gr18;           /* PIC/PID */
110         unsigned long           gr19;
111         unsigned long           gr20;
112         unsigned long           gr21;
113         unsigned long           gr22;
114         unsigned long           gr23;
115         unsigned long           gr24;
116         unsigned long           gr25;
117         unsigned long           gr26;
118         unsigned long           gr27;
119         struct pt_regs          *next_frame;    /* GR28 - next exception frame */
120         unsigned long           gr29;           /* GR29 - OS reserved */
121         unsigned long           gr30;           /* GR30 - OS reserved */
122         unsigned long           gr31;           /* GR31 - OS reserved */
123 } __attribute__((aligned(8)));
124
125 #endif
126
127 #define REG__STATUS_STEP        0x00000001      /* - reenable single stepping on return */
128 #define REG__STATUS_STEPPED     0x00000002      /* - single step caused exception */
129 #define REG__STATUS_BROKE       0x00000004      /* - BREAK insn caused exception */
130 #define REG__STATUS_SYSC_ENTRY  0x40000000      /* - T on syscall entry (ptrace.c only) */
131 #define REG__STATUS_SYSC_EXIT   0x80000000      /* - T on syscall exit (ptrace.c only) */
132
133 #define REG_GR(R)       __OFFSET(REG_GR0, (R))
134
135 #define REG_SP          REG_GR(1)
136 #define REG_FP          REG_GR(2)
137 #define REG_PREV_FRAME  REG_GR(28)      /* previous exception frame pointer (old gr28 value) */
138 #define REG_CURR_TASK   REG_GR(29)      /* current task */
139
140 /*****************************************************************************/
141 /*
142  * debugging registers
143  */
144 #ifndef __ASSEMBLY__
145
146 struct frv_debug_regs
147 {
148         unsigned long           dcr;
149         unsigned long           ibar[4] __attribute__((aligned(8)));
150         unsigned long           dbar[4] __attribute__((aligned(8)));
151         unsigned long           dbdr[4][4] __attribute__((aligned(8)));
152         unsigned long           dbmr[4][4] __attribute__((aligned(8)));
153 } __attribute__((aligned(8)));
154
155 #endif
156
157 /*****************************************************************************/
158 /*
159  * userspace registers
160  */
161 #ifndef __ASSEMBLY__
162
163 struct user_int_regs
164 {
165         /* integer registers
166          * - up to gr[31] mirror pt_regs
167          * - total size must be multiple of 8 bytes
168          */
169         unsigned long           psr;            /* Processor Status Register */
170         unsigned long           isr;            /* Integer Status Register */
171         unsigned long           ccr;            /* Condition Code Register */
172         unsigned long           cccr;           /* Condition Code for Conditional Insns Register */
173         unsigned long           lr;             /* Link Register */
174         unsigned long           lcr;            /* Loop Count Register */
175         unsigned long           pc;             /* Program Counter Register */
176         unsigned long           __status;       /* exception status */
177         unsigned long           syscallno;      /* syscall number or -1 */
178         unsigned long           orig_gr8;       /* original syscall arg #1 */
179         unsigned long           gner[2];
180         unsigned long long      iacc[1];
181
182         union {
183                 unsigned long   tbr;
184                 unsigned long   gr[64];
185         };
186 };
187
188 struct user_fpmedia_regs
189 {
190         /* FP/Media registers */
191         unsigned long   fr[64];
192         unsigned long   fner[2];
193         unsigned long   msr[2];
194         unsigned long   acc[8];
195         unsigned char   accg[8];
196         unsigned long   fsr[1];
197 };
198
199 struct user_context
200 {
201         struct user_int_regs            i;
202         struct user_fpmedia_regs        f;
203
204         /* we provide a context extension so that we can save the regs for CPUs that
205          * implement many more of Fujitsu's lavish register spec
206          */
207         void *extension;
208 } __attribute__((aligned(8)));
209
210 struct frv_frame0 {
211         union {
212                 struct pt_regs          regs;
213                 struct user_context     uc;
214         };
215
216         struct frv_debug_regs           debug;
217
218 } __attribute__((aligned(32)));
219
220 #endif
221
222 #define __INT_GR(R)             __OFFSET(__INT_GR0,             (R))
223
224 #define __FPMEDIA_FR(R)         __OFFSET(__FPMEDIA_FR0,         (R))
225 #define __FPMEDIA_FNER(R)       __OFFSET(__FPMEDIA_FNER0,       (R))
226 #define __FPMEDIA_MSR(R)        __OFFSET(__FPMEDIA_MSR0,        (R))
227 #define __FPMEDIA_ACC(R)        __OFFSET(__FPMEDIA_ACC0,        (R))
228 #define __FPMEDIA_ACCG(R)       __OFFSETC(__FPMEDIA_ACCG0,      (R))
229 #define __FPMEDIA_FSR(R)        __OFFSET(__FPMEDIA_FSR0,        (R))
230
231 #define __THREAD_GR(R)          __OFFSET(__THREAD_GR16,         (R) - 16)
232
233 #endif /* _ASM_REGISTERS_H */