blob: 6608d8a6ea324cb091f52efb4bfa2e13f68f4131 [file] [log] [blame]
Stefan Kristiansson6e560bb2011-11-26 19:04:49 +00001/*
2 * OpenRISC Linux
3 *
4 * Linux architectural port borrowing liberally from similar works of
5 * others. All original copyrights apply as per the original source
6 * declaration.
7 *
8 * OpenRISC implementation:
9 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
10 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
11 * et al.
12 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +020013 * SPDX-License-Identifier: GPL-2.0+
Stefan Kristiansson6e560bb2011-11-26 19:04:49 +000014 */
15
16#ifndef __ASM_OPENRISC_PTRACE_H
17#define __ASM_OPENRISC_PTRACE_H
18
19#include <asm/spr-defs.h>
20
21#ifndef __ASSEMBLY__
22/*
23 * This is the layout of the regset returned by the GETREGSET ptrace call
24 */
25struct user_regs_struct {
26 /* GPR R0-R31... */
27 unsigned long gpr[32];
28 unsigned long pc;
29 unsigned long sr;
30 unsigned long pad1;
31 unsigned long pad2;
32};
33#endif
34
35#ifdef __KERNEL__
36
37/*
38 * Make kernel PTrace/register structures opaque to userspace... userspace can
39 * access thread state via the regset mechanism. This allows us a bit of
40 * flexibility in how we order the registers on the stack, permitting some
41 * optimizations like packing call-clobbered registers together so that
42 * they share a cacheline (not done yet, though... future optimization).
43 */
44
45#ifndef __ASSEMBLY__
46/*
47 * This struct describes how the registers are laid out on the kernel stack
48 * during a syscall or other kernel entry.
49 *
50 * This structure should always be cacheline aligned on the stack.
51 * FIXME: I don't think that's the case right now. The alignment is
52 * taken care of elsewhere... head.S, process.c, etc.
53 */
54
55struct pt_regs {
56 union {
57 struct {
58 /* Named registers */
59 long sr; /* Stored in place of r0 */
60 long sp; /* r1 */
61 };
62 struct {
63 /* Old style */
64 long offset[2];
65 long gprs[30];
66 };
67 struct {
68 /* New style */
69 long gpr[32];
70 };
71 };
72 long pc;
73 long orig_gpr11; /* For restarting system calls */
74 long syscallno; /* Syscall number (used by strace) */
75 long dummy; /* Cheap alignment fix */
76};
77#endif /* __ASSEMBLY__ */
78
79/* TODO: Rename this to REDZONE because that's what it is */
80#define STACK_FRAME_OVERHEAD 128 /* size of minimum stack frame */
81
82#define instruction_pointer(regs) ((regs)->pc)
83#define user_mode(regs) (((regs)->sr & SPR_SR_SM) == 0)
84#define user_stack_pointer(regs) ((unsigned long)(regs)->sp)
85#define profile_pc(regs) instruction_pointer(regs)
86
87/*
88 * Offsets used by 'ptrace' system call interface.
89 */
90#define PT_SR 0
91#define PT_SP 4
92#define PT_GPR2 8
93#define PT_GPR3 12
94#define PT_GPR4 16
95#define PT_GPR5 20
96#define PT_GPR6 24
97#define PT_GPR7 28
98#define PT_GPR8 32
99#define PT_GPR9 36
100#define PT_GPR10 40
101#define PT_GPR11 44
102#define PT_GPR12 48
103#define PT_GPR13 52
104#define PT_GPR14 56
105#define PT_GPR15 60
106#define PT_GPR16 64
107#define PT_GPR17 68
108#define PT_GPR18 72
109#define PT_GPR19 76
110#define PT_GPR20 80
111#define PT_GPR21 84
112#define PT_GPR22 88
113#define PT_GPR23 92
114#define PT_GPR24 96
115#define PT_GPR25 100
116#define PT_GPR26 104
117#define PT_GPR27 108
118#define PT_GPR28 112
119#define PT_GPR29 116
120#define PT_GPR30 120
121#define PT_GPR31 124
122#define PT_PC 128
123#define PT_ORIG_GPR11 132
124#define PT_SYSCALLNO 136
125
126#endif /* __KERNEL__ */
127
128#endif /* __ASM_OPENRISC_PTRACE_H */