1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000 by Ralf Baechle
4 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 #include <linux/compiler.h>
10 #include <linux/types.h>
11 #include <asm/isadep.h>
14 * This struct defines the way the registers are stored on the stack during a
15 * system call/exception. As usual the registers k0/k1 aren't being saved.
17 * If you add a register here, also add it to regoffset_table[] in
18 * arch/mips/kernel/ptrace.c.
22 /* Pad bytes for argument save space on the stack. */
23 unsigned long pad0[8];
26 /* Saved main processor registers. */
27 unsigned long regs[32];
29 /* Saved special registers. */
30 unsigned long cp0_status;
33 #ifdef CONFIG_CPU_HAS_SMARTMIPS
36 unsigned long cp0_badvaddr;
37 unsigned long cp0_cause;
38 unsigned long cp0_epc;
39 #ifdef CONFIG_CPU_CAVIUM_OCTEON
40 unsigned long long mpl[6]; /* MTM{0-5} */
41 unsigned long long mtp[6]; /* MTP{0-5} */
43 unsigned long __last[0];
46 static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
48 return regs->regs[31];
52 * Don't use asm-generic/ptrace.h it defines FP accessors that don't make
53 * sense on MIPS. We rather want an error if they get invoked.
56 static inline void instruction_pointer_set(struct pt_regs *regs,
62 /* Query offset/name of register from its name/offset */
63 extern int regs_query_register_offset(const char *name);
64 #define MAX_REG_OFFSET (offsetof(struct pt_regs, __last))
67 * regs_get_register() - get register value from its offset
68 * @regs: pt_regs from which register value is gotten.
69 * @offset: offset number of the register.
71 * regs_get_register returns the value of a register. The @offset is the
72 * offset of the register in struct pt_regs address which specified by @regs.
73 * If @offset is bigger than MAX_REG_OFFSET, this returns 0.
75 static inline unsigned long regs_get_register(struct pt_regs *regs,
78 if (unlikely(offset > MAX_REG_OFFSET))
81 return *(unsigned long *)((unsigned long)regs + offset);
85 * Does the process account for user or for system time?
87 #define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER)
89 #define instruction_pointer(regs) ((regs)->cp0_epc)
90 #define profile_pc(regs) instruction_pointer(regs)
92 /* Helpers for working with the user stack pointer */
94 static inline unsigned long user_stack_pointer(struct pt_regs *regs)
96 return regs->regs[29];
99 static inline void user_stack_pointer_set(struct pt_regs *regs,
102 regs->regs[29] = val;
105 #endif /* _ASM_PTRACE_H */