xref: /openbmc/linux/arch/parisc/include/asm/ptrace.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2deae26bfSKyle McMartin /* written by Philipp Rumpf, Copyright (C) 1999 SuSE GmbH Nuernberg
3deae26bfSKyle McMartin ** Copyright (C) 2000 Grant Grundler, Hewlett-Packard
4deae26bfSKyle McMartin */
570c1674fSDavid Howells #ifndef _PARISC_PTRACE_H
670c1674fSDavid Howells #define _PARISC_PTRACE_H
7deae26bfSKyle McMartin 
8*8d90dbfdSHelge Deller #include <asm/assembly.h>
970c1674fSDavid Howells #include <uapi/asm/ptrace.h>
10deae26bfSKyle McMartin 
11deae26bfSKyle McMartin #define task_regs(task) ((struct pt_regs *) ((char *)(task) + TASK_REGS))
12deae26bfSKyle McMartin 
1381e192d6SHelge Deller #define arch_has_single_step()	1
1481e192d6SHelge Deller #define arch_has_block_step()	1
1581e192d6SHelge Deller 
16deae26bfSKyle McMartin /* XXX should we use iaoq[1] or iaoq[0] ? */
17*8d90dbfdSHelge Deller #define user_mode(regs)			(((regs)->iaoq[0] & 3) != PRIV_KERNEL)
18*8d90dbfdSHelge Deller #define user_space(regs)		((regs)->iasq[1] != PRIV_KERNEL)
19deae26bfSKyle McMartin #define instruction_pointer(regs)	((regs)->iaoq[0] & ~3)
2040e03b68SKyle McMartin #define user_stack_pointer(regs)	((regs)->gr[30])
21deae26bfSKyle McMartin unsigned long profile_pc(struct pt_regs *);
2240e03b68SKyle McMartin 
regs_return_value(struct pt_regs * regs)23527973c8SHelge Deller static inline unsigned long regs_return_value(struct pt_regs *regs)
24527973c8SHelge Deller {
2545efd871SSven Schnelle 	return regs->gr[28];
26527973c8SHelge Deller }
2740e03b68SKyle McMartin 
instruction_pointer_set(struct pt_regs * regs,unsigned long val)2875ebedf1SHelge Deller static inline void instruction_pointer_set(struct pt_regs *regs,
2975ebedf1SHelge Deller 						unsigned long val)
3075ebedf1SHelge Deller {
3175ebedf1SHelge Deller 	regs->iaoq[0] = val;
32f324fa58SSven Schnelle 	regs->iaoq[1] = val + 4;
3375ebedf1SHelge Deller }
3475ebedf1SHelge Deller 
3575ebedf1SHelge Deller /* Query offset/name of register from its name/offset */
3675ebedf1SHelge Deller extern int regs_query_register_offset(const char *name);
3775ebedf1SHelge Deller extern const char *regs_query_register_name(unsigned int offset);
3875ebedf1SHelge Deller #define MAX_REG_OFFSET (offsetof(struct pt_regs, ipsw))
3975ebedf1SHelge Deller 
40ea1afe33SSven Schnelle #define kernel_stack_pointer(regs) ((regs)->gr[30])
41ea1afe33SSven Schnelle 
regs_get_register(struct pt_regs * regs,unsigned int offset)42ea1afe33SSven Schnelle static inline unsigned long regs_get_register(struct pt_regs *regs,
43ea1afe33SSven Schnelle 					      unsigned int offset)
44ea1afe33SSven Schnelle {
45ea1afe33SSven Schnelle 	if (unlikely(offset > MAX_REG_OFFSET))
46ea1afe33SSven Schnelle 		return 0;
47ea1afe33SSven Schnelle 	return *(unsigned long *)((unsigned long)regs + offset);
48ea1afe33SSven Schnelle }
49ea1afe33SSven Schnelle 
50ea1afe33SSven Schnelle unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n);
51ea1afe33SSven Schnelle int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr);
52ea1afe33SSven Schnelle 
53deae26bfSKyle McMartin #endif
54