18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * include/asm-xtensa/thread_info.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 58c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 68c2ecf20Sopenharmony_ci * for more details. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright (C) 2001 - 2005 Tensilica Inc. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _XTENSA_THREAD_INFO_H 128c2ecf20Sopenharmony_ci#define _XTENSA_THREAD_INFO_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/stringify.h> 158c2ecf20Sopenharmony_ci#include <asm/kmem_layout.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define CURRENT_SHIFT KERNEL_STACK_SHIFT 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 208c2ecf20Sopenharmony_ci# include <asm/processor.h> 218c2ecf20Sopenharmony_ci#endif 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* 248c2ecf20Sopenharmony_ci * low level task data that entry.S needs immediate access to 258c2ecf20Sopenharmony_ci * - this struct should fit entirely inside of one cache line 268c2ecf20Sopenharmony_ci * - this struct shares the supervisor stack pages 278c2ecf20Sopenharmony_ci * - if the contents of this structure are changed, the assembly constants 288c2ecf20Sopenharmony_ci * must also be changed 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#if XTENSA_HAVE_COPROCESSORS 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_citypedef struct xtregs_coprocessor { 368c2ecf20Sopenharmony_ci xtregs_cp0_t cp0; 378c2ecf20Sopenharmony_ci xtregs_cp1_t cp1; 388c2ecf20Sopenharmony_ci xtregs_cp2_t cp2; 398c2ecf20Sopenharmony_ci xtregs_cp3_t cp3; 408c2ecf20Sopenharmony_ci xtregs_cp4_t cp4; 418c2ecf20Sopenharmony_ci xtregs_cp5_t cp5; 428c2ecf20Sopenharmony_ci xtregs_cp6_t cp6; 438c2ecf20Sopenharmony_ci xtregs_cp7_t cp7; 448c2ecf20Sopenharmony_ci} xtregs_coprocessor_t; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#endif 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistruct thread_info { 498c2ecf20Sopenharmony_ci struct task_struct *task; /* main task structure */ 508c2ecf20Sopenharmony_ci unsigned long flags; /* low level flags */ 518c2ecf20Sopenharmony_ci unsigned long status; /* thread-synchronous flags */ 528c2ecf20Sopenharmony_ci __u32 cpu; /* current CPU */ 538c2ecf20Sopenharmony_ci __s32 preempt_count; /* 0 => preemptable,< 0 => BUG*/ 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci mm_segment_t addr_limit; /* thread address space */ 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci unsigned long cpenable; 588c2ecf20Sopenharmony_ci#if XCHAL_HAVE_EXCLUSIVE 598c2ecf20Sopenharmony_ci /* result of the most recent exclusive store */ 608c2ecf20Sopenharmony_ci unsigned long atomctl8; 618c2ecf20Sopenharmony_ci#endif 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci /* Allocate storage for extra user states and coprocessor states. */ 648c2ecf20Sopenharmony_ci#if XTENSA_HAVE_COPROCESSORS 658c2ecf20Sopenharmony_ci xtregs_coprocessor_t xtregs_cp; 668c2ecf20Sopenharmony_ci#endif 678c2ecf20Sopenharmony_ci xtregs_user_t xtregs_user; 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#endif 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/* 738c2ecf20Sopenharmony_ci * macros/functions for gaining access to the thread information structure 748c2ecf20Sopenharmony_ci */ 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define INIT_THREAD_INFO(tsk) \ 798c2ecf20Sopenharmony_ci{ \ 808c2ecf20Sopenharmony_ci .task = &tsk, \ 818c2ecf20Sopenharmony_ci .flags = 0, \ 828c2ecf20Sopenharmony_ci .cpu = 0, \ 838c2ecf20Sopenharmony_ci .preempt_count = INIT_PREEMPT_COUNT, \ 848c2ecf20Sopenharmony_ci .addr_limit = KERNEL_DS, \ 858c2ecf20Sopenharmony_ci} 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* how to get the thread information struct from C */ 888c2ecf20Sopenharmony_cistatic inline struct thread_info *current_thread_info(void) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci struct thread_info *ti; 918c2ecf20Sopenharmony_ci __asm__("extui %0, a1, 0, "__stringify(CURRENT_SHIFT)"\n\t" 928c2ecf20Sopenharmony_ci "xor %0, a1, %0" : "=&r" (ti) : ); 938c2ecf20Sopenharmony_ci return ti; 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#else /* !__ASSEMBLY__ */ 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci/* how to get the thread information struct from ASM */ 998c2ecf20Sopenharmony_ci#define GET_THREAD_INFO(reg,sp) \ 1008c2ecf20Sopenharmony_ci extui reg, sp, 0, CURRENT_SHIFT; \ 1018c2ecf20Sopenharmony_ci xor reg, sp, reg 1028c2ecf20Sopenharmony_ci#endif 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* 1068c2ecf20Sopenharmony_ci * thread information flags 1078c2ecf20Sopenharmony_ci * - these are process state flags that various assembly files may need to access 1088c2ecf20Sopenharmony_ci */ 1098c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 1108c2ecf20Sopenharmony_ci#define TIF_SIGPENDING 1 /* signal pending */ 1118c2ecf20Sopenharmony_ci#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 1128c2ecf20Sopenharmony_ci#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */ 1138c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACEPOINT 4 /* syscall tracepoint instrumentation */ 1148c2ecf20Sopenharmony_ci#define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ 1158c2ecf20Sopenharmony_ci#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ 1168c2ecf20Sopenharmony_ci#define TIF_NOTIFY_RESUME 7 /* callback before returning to user */ 1178c2ecf20Sopenharmony_ci#define TIF_DB_DISABLED 8 /* debug trap disabled for syscall */ 1188c2ecf20Sopenharmony_ci#define TIF_SYSCALL_AUDIT 9 /* syscall auditing active */ 1198c2ecf20Sopenharmony_ci#define TIF_SECCOMP 10 /* secure computing */ 1208c2ecf20Sopenharmony_ci#define TIF_MEMDIE 11 /* is terminating due to OOM killer */ 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 1238c2ecf20Sopenharmony_ci#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 1248c2ecf20Sopenharmony_ci#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 1258c2ecf20Sopenharmony_ci#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 1268c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) 1278c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL) 1288c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 1298c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 1308c2ecf20Sopenharmony_ci#define _TIF_SECCOMP (1<<TIF_SECCOMP) 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define _TIF_WORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \ 1338c2ecf20Sopenharmony_ci _TIF_SYSCALL_TRACEPOINT | \ 1348c2ecf20Sopenharmony_ci _TIF_SYSCALL_AUDIT | _TIF_SECCOMP) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#define THREAD_SIZE KERNEL_STACK_SIZE 1378c2ecf20Sopenharmony_ci#define THREAD_SIZE_ORDER (KERNEL_STACK_SHIFT - PAGE_SHIFT) 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#endif /* _XTENSA_THREAD_INFO */ 140