linux/arch/unicore32/include/asm/ptrace.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/*
   3 * linux/arch/unicore32/include/asm/ptrace.h
   4 *
   5 * Code specific to PKUnity SoC and UniCore ISA
   6 *
   7 * Copyright (C) 2001-2010 GUAN Xue-tao
   8 */
   9#ifndef __UNICORE_PTRACE_H__
  10#define __UNICORE_PTRACE_H__
  11
  12#include <uapi/asm/ptrace.h>
  13
  14#ifndef __ASSEMBLY__
  15
  16#define user_mode(regs) \
  17        (processor_mode(regs) == USER_MODE)
  18
  19#define processor_mode(regs) \
  20        ((regs)->UCreg_asr & MODE_MASK)
  21
  22#define interrupts_enabled(regs) \
  23        (!((regs)->UCreg_asr & PSR_I_BIT))
  24
  25#define fast_interrupts_enabled(regs) \
  26        (!((regs)->UCreg_asr & PSR_R_BIT))
  27
  28/* Are the current registers suitable for user mode?
  29 * (used to maintain security in signal handlers)
  30 */
  31static inline int valid_user_regs(struct pt_regs *regs)
  32{
  33        unsigned long mode = regs->UCreg_asr & MODE_MASK;
  34
  35        /*
  36         * Always clear the R (REAL) bits
  37         */
  38        regs->UCreg_asr &= ~(PSR_R_BIT);
  39
  40        if ((regs->UCreg_asr & PSR_I_BIT) == 0) {
  41                if (mode == USER_MODE)
  42                        return 1;
  43        }
  44
  45        /*
  46         * Force ASR to something logical...
  47         */
  48        regs->UCreg_asr &= PSR_f | USER_MODE;
  49
  50        return 0;
  51}
  52
  53#define instruction_pointer(regs)       ((regs)->UCreg_pc)
  54#define user_stack_pointer(regs)        ((regs)->UCreg_sp)
  55#define profile_pc(regs)                instruction_pointer(regs)
  56
  57#endif /* __ASSEMBLY__ */
  58#endif
  59