18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Amit Bhor, Sameer Dhavale: Codito Technologies 2004 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#ifndef __ASM_ARC_PTRACE_H 88c2ecf20Sopenharmony_ci#define __ASM_ARC_PTRACE_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <uapi/asm/ptrace.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* THE pt_regs: Defines how regs are saved during entry into kernel */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#ifdef CONFIG_ISA_ARCOMPACT 178c2ecf20Sopenharmony_cistruct pt_regs { 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci /* Real registers */ 208c2ecf20Sopenharmony_ci unsigned long bta; /* bta_l1, bta_l2, erbta */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci unsigned long lp_start, lp_end, lp_count; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci unsigned long status32; /* status32_l1, status32_l2, erstatus */ 258c2ecf20Sopenharmony_ci unsigned long ret; /* ilink1, ilink2 or eret */ 268c2ecf20Sopenharmony_ci unsigned long blink; 278c2ecf20Sopenharmony_ci unsigned long fp; 288c2ecf20Sopenharmony_ci unsigned long r26; /* gp */ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci unsigned long r12, r11, r10, r9, r8, r7, r6, r5, r4, r3, r2, r1, r0; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci unsigned long sp; /* User/Kernel depending on where we came from */ 338c2ecf20Sopenharmony_ci unsigned long orig_r0; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci /* 368c2ecf20Sopenharmony_ci * To distinguish bet excp, syscall, irq 378c2ecf20Sopenharmony_ci * For traps and exceptions, Exception Cause Register. 388c2ecf20Sopenharmony_ci * ECR: <00> <VV> <CC> <PP> 398c2ecf20Sopenharmony_ci * Last word used by Linux for extra state mgmt (syscall-restart) 408c2ecf20Sopenharmony_ci * For interrupts, use artificial ECR values to note current prio-level 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_ci union { 438c2ecf20Sopenharmony_ci struct { 448c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_BIG_ENDIAN 458c2ecf20Sopenharmony_ci unsigned long state:8, ecr_vec:8, 468c2ecf20Sopenharmony_ci ecr_cause:8, ecr_param:8; 478c2ecf20Sopenharmony_ci#else 488c2ecf20Sopenharmony_ci unsigned long ecr_param:8, ecr_cause:8, 498c2ecf20Sopenharmony_ci ecr_vec:8, state:8; 508c2ecf20Sopenharmony_ci#endif 518c2ecf20Sopenharmony_ci }; 528c2ecf20Sopenharmony_ci unsigned long event; 538c2ecf20Sopenharmony_ci }; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci unsigned long user_r25; 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci#else 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct pt_regs { 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci unsigned long orig_r0; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci union { 648c2ecf20Sopenharmony_ci struct { 658c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_BIG_ENDIAN 668c2ecf20Sopenharmony_ci unsigned long state:8, ecr_vec:8, 678c2ecf20Sopenharmony_ci ecr_cause:8, ecr_param:8; 688c2ecf20Sopenharmony_ci#else 698c2ecf20Sopenharmony_ci unsigned long ecr_param:8, ecr_cause:8, 708c2ecf20Sopenharmony_ci ecr_vec:8, state:8; 718c2ecf20Sopenharmony_ci#endif 728c2ecf20Sopenharmony_ci }; 738c2ecf20Sopenharmony_ci unsigned long event; 748c2ecf20Sopenharmony_ci }; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci unsigned long bta; /* bta_l1, bta_l2, erbta */ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci unsigned long user_r25; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci unsigned long r26; /* gp */ 818c2ecf20Sopenharmony_ci unsigned long fp; 828c2ecf20Sopenharmony_ci unsigned long sp; /* user/kernel sp depending on where we came from */ 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci unsigned long r12, r30; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#ifdef CONFIG_ARC_HAS_ACCL_REGS 878c2ecf20Sopenharmony_ci unsigned long r58, r59; /* ACCL/ACCH used by FPU / DSP MPY */ 888c2ecf20Sopenharmony_ci#endif 898c2ecf20Sopenharmony_ci#ifdef CONFIG_ARC_DSP_SAVE_RESTORE_REGS 908c2ecf20Sopenharmony_ci unsigned long DSP_CTRL; 918c2ecf20Sopenharmony_ci#endif 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci /*------- Below list auto saved by h/w -----------*/ 948c2ecf20Sopenharmony_ci unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci unsigned long blink; 978c2ecf20Sopenharmony_ci unsigned long lp_end, lp_start, lp_count; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci unsigned long ei, ldi, jli; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci unsigned long ret; 1028c2ecf20Sopenharmony_ci unsigned long status32; 1038c2ecf20Sopenharmony_ci}; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci#endif 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/* Callee saved registers - need to be saved only when you are scheduled out */ 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistruct callee_regs { 1108c2ecf20Sopenharmony_ci unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13; 1118c2ecf20Sopenharmony_ci}; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define instruction_pointer(regs) ((regs)->ret) 1148c2ecf20Sopenharmony_ci#define profile_pc(regs) instruction_pointer(regs) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci/* return 1 if user mode or 0 if kernel mode */ 1178c2ecf20Sopenharmony_ci#define user_mode(regs) (regs->status32 & STATUS_U_MASK) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define user_stack_pointer(regs)\ 1208c2ecf20Sopenharmony_ci({ unsigned int sp; \ 1218c2ecf20Sopenharmony_ci if (user_mode(regs)) \ 1228c2ecf20Sopenharmony_ci sp = (regs)->sp;\ 1238c2ecf20Sopenharmony_ci else \ 1248c2ecf20Sopenharmony_ci sp = -1; \ 1258c2ecf20Sopenharmony_ci sp; \ 1268c2ecf20Sopenharmony_ci}) 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci/* return 1 if PC in delay slot */ 1298c2ecf20Sopenharmony_ci#define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK) 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#define in_syscall(regs) ((regs->ecr_vec == ECR_V_TRAP) && !regs->ecr_param) 1328c2ecf20Sopenharmony_ci#define in_brkpt_trap(regs) ((regs->ecr_vec == ECR_V_TRAP) && regs->ecr_param) 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define STATE_SCALL_RESTARTED 0x01 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#define syscall_wont_restart(reg) (reg->state |= STATE_SCALL_RESTARTED) 1378c2ecf20Sopenharmony_ci#define syscall_restartable(reg) !(reg->state & STATE_SCALL_RESTARTED) 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#define current_pt_regs() \ 1408c2ecf20Sopenharmony_ci({ \ 1418c2ecf20Sopenharmony_ci /* open-coded current_thread_info() */ \ 1428c2ecf20Sopenharmony_ci register unsigned long sp asm ("sp"); \ 1438c2ecf20Sopenharmony_ci unsigned long pg_start = (sp & ~(THREAD_SIZE - 1)); \ 1448c2ecf20Sopenharmony_ci (struct pt_regs *)(pg_start + THREAD_SIZE) - 1; \ 1458c2ecf20Sopenharmony_ci}) 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_cistatic inline long regs_return_value(struct pt_regs *regs) 1488c2ecf20Sopenharmony_ci{ 1498c2ecf20Sopenharmony_ci return (long)regs->r0; 1508c2ecf20Sopenharmony_ci} 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#endif /* __ASM_PTRACE_H */ 155