1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * NiosII low-level thread information 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch> 5*4882a593Smuzhiyun * Copyright (C) 2004 Microtronix Datacom Ltd. 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * Based on asm/thread_info_no.h from m68k which is: 8*4882a593Smuzhiyun * 9*4882a593Smuzhiyun * Copyright (C) 2002 David Howells <dhowells@redhat.com> 10*4882a593Smuzhiyun * 11*4882a593Smuzhiyun * This file is subject to the terms and conditions of the GNU General Public 12*4882a593Smuzhiyun * License. See the file "COPYING" in the main directory of this archive 13*4882a593Smuzhiyun * for more details. 14*4882a593Smuzhiyun */ 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #ifndef _ASM_NIOS2_THREAD_INFO_H 17*4882a593Smuzhiyun #define _ASM_NIOS2_THREAD_INFO_H 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun #ifdef __KERNEL__ 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun /* 22*4882a593Smuzhiyun * Size of the kernel stack for each process. 23*4882a593Smuzhiyun */ 24*4882a593Smuzhiyun #define THREAD_SIZE_ORDER 1 25*4882a593Smuzhiyun #define THREAD_SIZE 8192 /* 2 * PAGE_SIZE */ 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun #ifndef __ASSEMBLY__ 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun typedef struct { 30*4882a593Smuzhiyun unsigned long seg; 31*4882a593Smuzhiyun } mm_segment_t; 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /* 34*4882a593Smuzhiyun * low level task data that entry.S needs immediate access to 35*4882a593Smuzhiyun * - this struct should fit entirely inside of one cache line 36*4882a593Smuzhiyun * - this struct shares the supervisor stack pages 37*4882a593Smuzhiyun * - if the contents of this structure are changed, the assembly constants 38*4882a593Smuzhiyun * must also be changed 39*4882a593Smuzhiyun */ 40*4882a593Smuzhiyun struct thread_info { 41*4882a593Smuzhiyun struct task_struct *task; /* main task structure */ 42*4882a593Smuzhiyun unsigned long flags; /* low level flags */ 43*4882a593Smuzhiyun __u32 cpu; /* current CPU */ 44*4882a593Smuzhiyun int preempt_count; /* 0 => preemptable,<0 => BUG */ 45*4882a593Smuzhiyun mm_segment_t addr_limit; /* thread address space: 46*4882a593Smuzhiyun 0-0x7FFFFFFF for user-thead 47*4882a593Smuzhiyun 0-0xFFFFFFFF for kernel-thread 48*4882a593Smuzhiyun */ 49*4882a593Smuzhiyun struct pt_regs *regs; 50*4882a593Smuzhiyun }; 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun /* 53*4882a593Smuzhiyun * macros/functions for gaining access to the thread information structure 54*4882a593Smuzhiyun * 55*4882a593Smuzhiyun * preempt_count needs to be 1 initially, until the scheduler is functional. 56*4882a593Smuzhiyun */ 57*4882a593Smuzhiyun #define INIT_THREAD_INFO(tsk) \ 58*4882a593Smuzhiyun { \ 59*4882a593Smuzhiyun .task = &tsk, \ 60*4882a593Smuzhiyun .flags = 0, \ 61*4882a593Smuzhiyun .cpu = 0, \ 62*4882a593Smuzhiyun .preempt_count = INIT_PREEMPT_COUNT, \ 63*4882a593Smuzhiyun .addr_limit = KERNEL_DS, \ 64*4882a593Smuzhiyun } 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /* how to get the thread information struct from C */ current_thread_info(void)67*4882a593Smuzhiyunstatic inline struct thread_info *current_thread_info(void) 68*4882a593Smuzhiyun { 69*4882a593Smuzhiyun register unsigned long sp asm("sp"); 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); 72*4882a593Smuzhiyun } 73*4882a593Smuzhiyun #endif /* !__ASSEMBLY__ */ 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /* 76*4882a593Smuzhiyun * thread information flags 77*4882a593Smuzhiyun * - these are process state flags that various assembly files may need to 78*4882a593Smuzhiyun * access 79*4882a593Smuzhiyun * - pending work-to-be-done flags are in LSW 80*4882a593Smuzhiyun * - other flags in MSW 81*4882a593Smuzhiyun */ 82*4882a593Smuzhiyun #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 83*4882a593Smuzhiyun #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 84*4882a593Smuzhiyun #define TIF_SIGPENDING 2 /* signal pending */ 85*4882a593Smuzhiyun #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 86*4882a593Smuzhiyun #define TIF_MEMDIE 4 /* is terminating due to OOM killer */ 87*4882a593Smuzhiyun #define TIF_SECCOMP 5 /* secure computing */ 88*4882a593Smuzhiyun #define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */ 89*4882a593Smuzhiyun #define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */ 90*4882a593Smuzhiyun #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling 93*4882a593Smuzhiyun TIF_NEED_RESCHED */ 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 96*4882a593Smuzhiyun #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 97*4882a593Smuzhiyun #define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 98*4882a593Smuzhiyun #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 99*4882a593Smuzhiyun #define _TIF_SECCOMP (1 << TIF_SECCOMP) 100*4882a593Smuzhiyun #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 101*4882a593Smuzhiyun #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) 102*4882a593Smuzhiyun #define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 103*4882a593Smuzhiyun #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun /* work to do on interrupt/exception return */ 106*4882a593Smuzhiyun #define _TIF_WORK_MASK 0x0000FFFE 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun /* work to do on any return to u-space */ 109*4882a593Smuzhiyun # define _TIF_ALLWORK_MASK 0x0000FFFF 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun #endif /* __KERNEL__ */ 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun #endif /* _ASM_NIOS2_THREAD_INFO_H */ 114