xref: /openbmc/u-boot/arch/microblaze/include/asm/ptrace.h (revision 83653121d7382fccfe329cb732f77f116341ef1d)
1*819833afSPeter Tyser /*
2*819833afSPeter Tyser  * include/asm-microblaze/ptrace.h -- Access to CPU registers
3*819833afSPeter Tyser  *
4*819833afSPeter Tyser  *  Copyright (C) 2003       John Williams <jwilliams@itee.uq.edu.au>
5*819833afSPeter Tyser  *  Copyright (C) 2001,2002  NEC Corporation
6*819833afSPeter Tyser  *  Copyright (C) 2001,2002  Miles Bader <miles@gnu.org>
7*819833afSPeter Tyser  *
8*819833afSPeter Tyser  * This file is subject to the terms and conditions of the GNU General
9*819833afSPeter Tyser  * Public License.  See the file COPYING in the main directory of this
10*819833afSPeter Tyser  * archive for more details.
11*819833afSPeter Tyser  *
12*819833afSPeter Tyser  * Written by Miles Bader <miles@gnu.org>
13*819833afSPeter Tyser  * Microblaze port by John Williams
14*819833afSPeter Tyser  */
15*819833afSPeter Tyser 
16*819833afSPeter Tyser #ifndef __MICROBLAZE_PTRACE_H__
17*819833afSPeter Tyser #define __MICROBLAZE_PTRACE_H__
18*819833afSPeter Tyser 
19*819833afSPeter Tyser 
20*819833afSPeter Tyser /* Microblaze general purpose registers with special meanings.  */
21*819833afSPeter Tyser #define GPR_ZERO	0	/* constant zero */
22*819833afSPeter Tyser #define GPR_ASM		18	/* reserved for assembler */
23*819833afSPeter Tyser #define GPR_SP		1	/* stack pointer */
24*819833afSPeter Tyser #define GPR_GP		2	/* global data pointer */
25*819833afSPeter Tyser #define GPR_EP		30	/* `element pointer' */
26*819833afSPeter Tyser #define GPR_LP		15	/* link pointer (current return address) */
27*819833afSPeter Tyser 
28*819833afSPeter Tyser /* These aren't official names, but they make some code more descriptive.  */
29*819833afSPeter Tyser #define GPR_ARG0	5
30*819833afSPeter Tyser #define GPR_ARG1	6
31*819833afSPeter Tyser #define GPR_ARG2	7
32*819833afSPeter Tyser #define GPR_ARG3	8
33*819833afSPeter Tyser #define GPR_ARG4	9
34*819833afSPeter Tyser #define GPR_ARG5	10
35*819833afSPeter Tyser #define GPR_RVAL0	3
36*819833afSPeter Tyser #define GPR_RVAL1	4
37*819833afSPeter Tyser #define GPR_RVAL	GPR_RVAL0
38*819833afSPeter Tyser 
39*819833afSPeter Tyser #define NUM_GPRS	32
40*819833afSPeter Tyser 
41*819833afSPeter Tyser /* `system' registers.  */
42*819833afSPeter Tyser /* Note these are old v850 values, microblaze has many fewer */
43*819833afSPeter Tyser #define SR_EIPC		0
44*819833afSPeter Tyser #define SR_EIPSW	1
45*819833afSPeter Tyser #define SR_FEPC		2
46*819833afSPeter Tyser #define SR_FEPSW	3
47*819833afSPeter Tyser #define SR_ECR		4
48*819833afSPeter Tyser #define SR_PSW		5
49*819833afSPeter Tyser #define SR_CTPC		16
50*819833afSPeter Tyser #define SR_CTPSW	17
51*819833afSPeter Tyser #define SR_DBPC		18
52*819833afSPeter Tyser #define SR_DBPSW	19
53*819833afSPeter Tyser #define SR_CTBP		20
54*819833afSPeter Tyser #define SR_DIR		21
55*819833afSPeter Tyser #define SR_ASID		23
56*819833afSPeter Tyser 
57*819833afSPeter Tyser 
58*819833afSPeter Tyser #ifndef __ASSEMBLY__
59*819833afSPeter Tyser 
60*819833afSPeter Tyser typedef unsigned long microblaze_reg_t;
61*819833afSPeter Tyser 
62*819833afSPeter Tyser /* How processor state is stored on the stack during a syscall/signal.
63*819833afSPeter Tyser    If you change this structure, change the associated assembly-language
64*819833afSPeter Tyser    macros below too (PT_*)!  */
65*819833afSPeter Tyser struct pt_regs
66*819833afSPeter Tyser {
67*819833afSPeter Tyser 	/* General purpose registers.  */
68*819833afSPeter Tyser 	microblaze_reg_t gpr[NUM_GPRS];
69*819833afSPeter Tyser 
70*819833afSPeter Tyser 	microblaze_reg_t pc;		/* program counter */
71*819833afSPeter Tyser 	microblaze_reg_t psw;		/* program status word */
72*819833afSPeter Tyser 
73*819833afSPeter Tyser 	microblaze_reg_t kernel_mode;	/* 1 if in `kernel mode', 0 if user mode */
74*819833afSPeter Tyser 	microblaze_reg_t single_step;	/* 1 if in single step mode */
75*819833afSPeter Tyser };
76*819833afSPeter Tyser 
77*819833afSPeter Tyser 
78*819833afSPeter Tyser #define instruction_pointer(regs)	((regs)->pc)
79*819833afSPeter Tyser #define user_mode(regs)			(!(regs)->kernel_mode)
80*819833afSPeter Tyser 
81*819833afSPeter Tyser /* When a struct pt_regs is used to save user state for a system call in
82*819833afSPeter Tyser    the kernel, the system call is stored in the space for R0 (since it's
83*819833afSPeter Tyser    never used otherwise, R0 being a constant 0).  Non-system-calls
84*819833afSPeter Tyser    simply store 0 there.  */
85*819833afSPeter Tyser #define PT_REGS_SYSCALL(regs)		(regs)->gpr[0]
86*819833afSPeter Tyser #define PT_REGS_SET_SYSCALL(regs, val)	((regs)->gpr[0] = (val))
87*819833afSPeter Tyser 
88*819833afSPeter Tyser #endif /* !__ASSEMBLY__ */
89*819833afSPeter Tyser 
90*819833afSPeter Tyser 
91*819833afSPeter Tyser /* The number of bytes used to store each register.  */
92*819833afSPeter Tyser #define _PT_REG_SIZE	4
93*819833afSPeter Tyser 
94*819833afSPeter Tyser /* Offset of a general purpose register in a stuct pt_regs.  */
95*819833afSPeter Tyser #define PT_GPR(num)	((num) * _PT_REG_SIZE)
96*819833afSPeter Tyser 
97*819833afSPeter Tyser /* Offsets of various special registers & fields in a struct pt_regs.  */
98*819833afSPeter Tyser #define NUM_SPECIAL	4
99*819833afSPeter Tyser #define PT_PC		((NUM_GPRS + 0) * _PT_REG_SIZE)
100*819833afSPeter Tyser #define PT_PSW		((NUM_GPRS + 1) * _PT_REG_SIZE)
101*819833afSPeter Tyser #define PT_KERNEL_MODE	((NUM_GPRS + 2) * _PT_REG_SIZE)
102*819833afSPeter Tyser #define PT_SINGLESTEP	((NUM_GPRS + 3) * _PT_REG_SIZE)
103*819833afSPeter Tyser 
104*819833afSPeter Tyser #define PT_SYSCALL	PT_GPR(0)
105*819833afSPeter Tyser 
106*819833afSPeter Tyser /* Size of struct pt_regs, including alignment.  */
107*819833afSPeter Tyser #define PT_SIZE		((NUM_GPRS + NUM_SPECIAL) * _PT_REG_SIZE)
108*819833afSPeter Tyser 
109*819833afSPeter Tyser /* These are `magic' values for PTRACE_PEEKUSR that return info about where
110*819833afSPeter Tyser    a process is located in memory.  */
111*819833afSPeter Tyser #define PT_TEXT_ADDR    (PT_SIZE + 1)
112*819833afSPeter Tyser #define PT_TEXT_LEN     (PT_SIZE + 2)
113*819833afSPeter Tyser #define PT_DATA_ADDR    (PT_SIZE + 3)
114*819833afSPeter Tyser #define PT_DATA_LEN     (PT_SIZE + 4)
115*819833afSPeter Tyser 
116*819833afSPeter Tyser #endif /* __MICROBLAZE_PTRACE_H__ */
117