xref: /nrf52832-nimble/rt-thread/libcpu/ppc/common/ptrace.h (revision 104654410c56c573564690304ae786df310c91fc)
1 #ifndef _PPC_PTRACE_H
2 #define _PPC_PTRACE_H
3 
4 /*
5  * This struct defines the way the registers are stored on the
6  * kernel stack during a system call or other kernel entry.
7  *
8  * this should only contain volatile regs
9  * since we can keep non-volatile in the thread_struct
10  * should set this up when only volatiles are saved
11  * by intr code.
12  *
13  * Since this is going on the stack, *CARE MUST BE TAKEN* to insure
14  * that the overall structure is a multiple of 16 bytes in length.
15  *
16  * Note that the offsets of the fields in this struct correspond with
17  * the PT_* values below.  This simplifies arch/ppc/kernel/ptrace.c.
18  */
19 
20 #ifndef __ASSEMBLY__
21 #define PPC_REG unsigned long
22 
23 struct pt_regs {
24     PPC_REG gpr[32];
25     PPC_REG nip;
26     PPC_REG msr;
27     PPC_REG orig_gpr3;	/* Used for restarting system calls */
28     PPC_REG ctr;
29     PPC_REG link;
30     PPC_REG xer;
31     PPC_REG ccr;
32     PPC_REG mq;		/* 601 only (not used at present) */
33                     /* Used on APUS to hold IPL value. */
34     PPC_REG trap;		/* Reason for being here */
35     PPC_REG dar;		/* Fault registers */
36     PPC_REG dsisr;
37     PPC_REG result;		/* Result of a system call */
38 }__attribute__((packed)) CELL_STACK_FRAME_t;
39 #endif
40 
41 #define STACK_FRAME_OVERHEAD	16	/* size of minimum stack frame */
42 
43 /* Size of stack frame allocated when calling signal handler. */
44 #define __SIGNAL_FRAMESIZE	64
45 
46 #define instruction_pointer(regs) ((regs)->nip)
47 #define user_mode(regs) (((regs)->msr & MSR_PR) != 0)
48 
49 /*
50  * Offsets used by 'ptrace' system call interface.
51  * These can't be changed without breaking binary compatibility
52  * with MkLinux, etc.
53  */
54 #define PT_R0	0
55 #define PT_R1	1
56 #define PT_R2	2
57 #define PT_R3	3
58 #define PT_R4	4
59 #define PT_R5	5
60 #define PT_R6	6
61 #define PT_R7	7
62 #define PT_R8	8
63 #define PT_R9	9
64 #define PT_R10	10
65 #define PT_R11	11
66 #define PT_R12	12
67 #define PT_R13	13
68 #define PT_R14	14
69 #define PT_R15	15
70 #define PT_R16	16
71 #define PT_R17	17
72 #define PT_R18	18
73 #define PT_R19	19
74 #define PT_R20	20
75 #define PT_R21	21
76 #define PT_R22	22
77 #define PT_R23	23
78 #define PT_R24	24
79 #define PT_R25	25
80 #define PT_R26	26
81 #define PT_R27	27
82 #define PT_R28	28
83 #define PT_R29	29
84 #define PT_R30	30
85 #define PT_R31	31
86 
87 #define PT_NIP	32
88 #define PT_MSR	33
89 #define PT_ORIG_R3 34
90 #define PT_CTR	35
91 #define PT_LNK	36
92 #define PT_XER	37
93 #define PT_CCR	38
94 #define PT_MQ	39
95 
96 #define PT_FPR0	48	/* each FP reg occupies 2 slots in this space */
97 #define PT_FPR31 (PT_FPR0 + 2*31)
98 #define PT_FPSCR (PT_FPR0 + 2*32 + 1)
99 
100 #endif
101