1 /* 2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 as 6 * published by the Free Software Foundation. 7 * 8 * Amit Bhor, Sameer Dhavale: Codito Technologies 2004 9 */ 10 #ifndef __ASM_ARC_PTRACE_H 11 #define __ASM_ARC_PTRACE_H 12 13 #include <uapi/asm/ptrace.h> 14 15 #ifndef __ASSEMBLY__ 16 17 /* THE pt_regs: Defines how regs are saved during entry into kernel */ 18 19 struct pt_regs { 20 /* 21 * 1 word gutter after reg-file has been saved 22 * Technically not needed, Since SP always points to a "full" location 23 * (vs. "empty"). But pt_regs is shared with tools.... 24 */ 25 long res; 26 27 /* Real registers */ 28 long bta; /* bta_l1, bta_l2, erbta */ 29 long lp_start; 30 long lp_end; 31 long lp_count; 32 long status32; /* status32_l1, status32_l2, erstatus */ 33 long ret; /* ilink1, ilink2 or eret */ 34 long blink; 35 long fp; 36 long r26; /* gp */ 37 long r12; 38 long r11; 39 long r10; 40 long r9; 41 long r8; 42 long r7; 43 long r6; 44 long r5; 45 long r4; 46 long r3; 47 long r2; 48 long r1; 49 long r0; 50 long sp; /* user/kernel sp depending on where we came from */ 51 long orig_r0; 52 53 /*to distinguish bet excp, syscall, irq */ 54 union { 55 #ifdef CONFIG_CPU_BIG_ENDIAN 56 /* so that assembly code is same for LE/BE */ 57 unsigned long orig_r8:16, event:16; 58 #else 59 unsigned long event:16, orig_r8:16; 60 #endif 61 long orig_r8_word; 62 }; 63 }; 64 65 /* Callee saved registers - need to be saved only when you are scheduled out */ 66 67 struct callee_regs { 68 long res; /* Again this is not needed */ 69 long r25; 70 long r24; 71 long r23; 72 long r22; 73 long r21; 74 long r20; 75 long r19; 76 long r18; 77 long r17; 78 long r16; 79 long r15; 80 long r14; 81 long r13; 82 }; 83 84 #define instruction_pointer(regs) ((regs)->ret) 85 #define profile_pc(regs) instruction_pointer(regs) 86 87 /* return 1 if user mode or 0 if kernel mode */ 88 #define user_mode(regs) (regs->status32 & STATUS_U_MASK) 89 90 #define user_stack_pointer(regs)\ 91 ({ unsigned int sp; \ 92 if (user_mode(regs)) \ 93 sp = (regs)->sp;\ 94 else \ 95 sp = -1; \ 96 sp; \ 97 }) 98 99 /* return 1 if PC in delay slot */ 100 #define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK) 101 102 #define in_syscall(regs) (regs->event & orig_r8_IS_SCALL) 103 #define in_brkpt_trap(regs) (regs->event & orig_r8_IS_BRKPT) 104 105 #define syscall_wont_restart(regs) (regs->event |= orig_r8_IS_SCALL_RESTARTED) 106 #define syscall_restartable(regs) !(regs->event & orig_r8_IS_SCALL_RESTARTED) 107 108 #define current_pt_regs() \ 109 ({ \ 110 /* open-coded current_thread_info() */ \ 111 register unsigned long sp asm ("sp"); \ 112 unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \ 113 (struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1; \ 114 }) 115 116 static inline long regs_return_value(struct pt_regs *regs) 117 { 118 return regs->r0; 119 } 120 121 #endif /* !__ASSEMBLY__ */ 122 123 #define orig_r8_IS_SCALL 0x0001 124 #define orig_r8_IS_SCALL_RESTARTED 0x0002 125 #define orig_r8_IS_BRKPT 0x0004 126 #define orig_r8_IS_EXCPN 0x0008 127 #define orig_r8_IS_IRQ1 0x0010 128 #define orig_r8_IS_IRQ2 0x0020 129 130 #endif /* __ASM_PTRACE_H */ 131