Path: blob/master/arch/h8300/platform/h8s/ptrace_h8s.c
10819 views
/*1* linux/arch/h8300/platform/h8s/ptrace_h8s.c2* ptrace cpu depend helper functions3*4* Yoshinori Sato <[email protected]>5*6* This file is subject to the terms and conditions of the GNU General7* Public License. See the file COPYING in the main directory of8* this archive for more details.9*/1011#include <linux/linkage.h>12#include <linux/sched.h>13#include <linux/errno.h>14#include <asm/ptrace.h>1516#define CCR_MASK 0x6f17#define EXR_TRACE 0x801819/* Mapping from PT_xxx to the stack offset at which the register is20saved. Notice that usp has no stack-slot and needs to be treated21specially (see get_reg/put_reg below). */22static const int h8300_register_offset[] = {23PT_REG(er1), PT_REG(er2), PT_REG(er3), PT_REG(er4),24PT_REG(er5), PT_REG(er6), PT_REG(er0), PT_REG(orig_er0),25PT_REG(ccr), PT_REG(pc), 0, PT_REG(exr)26};2728/* read register */29long h8300_get_reg(struct task_struct *task, int regno)30{31switch (regno) {32case PT_USP:33return task->thread.usp + sizeof(long)*2 + 2;34case PT_CCR:35case PT_EXR:36return *(unsigned short *)(task->thread.esp0 + h8300_register_offset[regno]);37default:38return *(unsigned long *)(task->thread.esp0 + h8300_register_offset[regno]);39}40}4142/* write register */43int h8300_put_reg(struct task_struct *task, int regno, unsigned long data)44{45unsigned short oldccr;46switch (regno) {47case PT_USP:48task->thread.usp = data - sizeof(long)*2 - 2;49case PT_CCR:50oldccr = *(unsigned short *)(task->thread.esp0 + h8300_register_offset[regno]);51oldccr &= ~CCR_MASK;52data &= CCR_MASK;53data |= oldccr;54*(unsigned short *)(task->thread.esp0 + h8300_register_offset[regno]) = data;55break;56case PT_EXR:57/* exr modify not support */58return -EIO;59default:60*(unsigned long *)(task->thread.esp0 + h8300_register_offset[regno]) = data;61break;62}63return 0;64}6566/* disable singlestep */67void user_disable_single_step(struct task_struct *child)68{69*(unsigned short *)(child->thread.esp0 + h8300_register_offset[PT_EXR]) &= ~EXR_TRACE;70}7172/* enable singlestep */73void user_enable_single_step(struct task_struct *child)74{75*(unsigned short *)(child->thread.esp0 + h8300_register_offset[PT_EXR]) |= EXR_TRACE;76}7778asmlinkage void trace_trap(unsigned long bp)79{80(void)bp;81force_sig(SIGTRAP,current);82}83848586