~funderscore blog cgit wiki get in touch
aboutsummaryrefslogtreecommitdiff
blob: b796d4faf6baee071783568724812bd10e299460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * include/asm-microblaze/ptrace.h -- Access to CPU registers
 *
 *  Copyright (C) 2003       John Williams <jwilliams@itee.uq.edu.au>
 *  Copyright (C) 2001,2002  NEC Corporation
 *  Copyright (C) 2001,2002  Miles Bader <miles@gnu.org>
 *
 * This file is subject to the terms and conditions of the GNU General
 * Public License.  See the file COPYING in the main directory of this
 * archive for more details.
 *
 * Written by Miles Bader <miles@gnu.org>
 * Microblaze port by John Williams
 */

#ifndef __MICROBLAZE_PTRACE_H__
#define __MICROBLAZE_PTRACE_H__


/* Microblaze general purpose registers with special meanings.  */
#define GPR_ZERO	0	/* constant zero */
#define GPR_ASM		18	/* reserved for assembler */
#define GPR_SP		1	/* stack pointer */
#define GPR_GP		2	/* global data pointer */
#define GPR_EP		30	/* `element pointer' */
#define GPR_LP		15	/* link pointer (current return address) */

/* These aren't official names, but they make some code more descriptive.  */
#define GPR_ARG0	5
#define GPR_ARG1	6
#define GPR_ARG2	7
#define GPR_ARG3	8
#define GPR_ARG4	9
#define GPR_ARG5	10
#define GPR_RVAL0	3
#define GPR_RVAL1	4
#define GPR_RVAL	GPR_RVAL0

#define NUM_GPRS	32

/* `system' registers.  */
/* Note these are old v850 values, microblaze has many fewer */
#define SR_EIPC		0
#define SR_EIPSW	1
#define SR_FEPC		2
#define SR_FEPSW	3
#define SR_ECR		4
#define SR_PSW		5
#define SR_CTPC		16
#define SR_CTPSW	17
#define SR_DBPC		18
#define SR_DBPSW	19
#define SR_CTBP		20
#define SR_DIR		21
#define SR_ASID		23


#ifndef __ASSEMBLY__

typedef unsigned long microblaze_reg_t;

/* How processor state is stored on the stack during a syscall/signal.
   If you change this structure, change the associated assembly-language
   macros below too (PT_*)!  */
struct pt_regs
{
	/* General purpose registers.  */
	microblaze_reg_t gpr[NUM_GPRS];

	microblaze_reg_t pc;		/* program counter */
	microblaze_reg_t psw;		/* program status word */

	microblaze_reg_t kernel_mode;	/* 1 if in `kernel mode', 0 if user mode */
	microblaze_reg_t single_step;	/* 1 if in single step mode */
};


#define instruction_pointer(regs)	((regs)->pc)
#define user_mode(regs)			(!(regs)->kernel_mode)

/* When a struct pt_regs is used to save user state for a system call in
   the kernel, the system call is stored in the space for R0 (since it's
   never used otherwise, R0 being a constant 0).  Non-system-calls
   simply store 0 there.  */
#define PT_REGS_SYSCALL(regs)		(regs)->gpr[0]
#define PT_REGS_SET_SYSCALL(regs, val)	((regs)->gpr[0] = (val))

#endif /* !__ASSEMBLY__ */


/* The number of bytes used to store each register.  */
#define _PT_REG_SIZE	4

/* Offset of a general purpose register in a stuct pt_regs.  */
#define PT_GPR(num)	((num) * _PT_REG_SIZE)

/* Offsets of various special registers & fields in a struct pt_regs.  */
#define NUM_SPECIAL	4
#define PT_PC		((NUM_GPRS + 0) * _PT_REG_SIZE)
#define PT_PSW		((NUM_GPRS + 1) * _PT_REG_SIZE)
#define PT_KERNEL_MODE	((NUM_GPRS + 2) * _PT_REG_SIZE)
#define PT_SINGLESTEP	((NUM_GPRS + 3) * _PT_REG_SIZE)

#define PT_SYSCALL	PT_GPR(0)

/* Size of struct pt_regs, including alignment.  */
#define PT_SIZE		((NUM_GPRS + NUM_SPECIAL) * _PT_REG_SIZE)

/* These are `magic' values for PTRACE_PEEKUSR that return info about where
   a process is located in memory.  */
#define PT_TEXT_ADDR    (PT_SIZE + 1)
#define PT_TEXT_LEN     (PT_SIZE + 2)
#define PT_DATA_ADDR    (PT_SIZE + 3)
#define PT_DATA_LEN     (PT_SIZE + 4)

#endif /* __MICROBLAZE_PTRACE_H__ */