Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
0004  *
0005  * Vineetg: Oct 2009
0006  *  No need for ARC specific thread_info allocator (kmalloc/free). This is
0007  *  anyways one page allocation, thus slab alloc can be short-circuited and
0008  *  the generic version (get_free_page) would be loads better.
0009  *
0010  * Sameer Dhavale: Codito Technologies 2004
0011  */
0012 
0013 #ifndef _ASM_THREAD_INFO_H
0014 #define _ASM_THREAD_INFO_H
0015 
0016 #include <asm/page.h>
0017 
0018 #ifdef CONFIG_16KSTACKS
0019 #define THREAD_SIZE_ORDER 1
0020 #else
0021 #define THREAD_SIZE_ORDER 0
0022 #endif
0023 
0024 #define THREAD_SIZE     (PAGE_SIZE << THREAD_SIZE_ORDER)
0025 #define THREAD_SHIFT    (PAGE_SHIFT << THREAD_SIZE_ORDER)
0026 
0027 #ifndef __ASSEMBLY__
0028 
0029 #include <linux/thread_info.h>
0030 
0031 /*
0032  * low level task data that entry.S needs immediate access to
0033  * - this struct should fit entirely inside of one cache line
0034  * - this struct shares the supervisor stack pages
0035  * - if the contents of this structure are changed, the assembly constants
0036  *   must also be changed
0037  */
0038 struct thread_info {
0039     unsigned long flags;        /* low level flags */
0040     int preempt_count;      /* 0 => preemptable, <0 => BUG */
0041     struct task_struct *task;   /* main task structure */
0042     __u32 cpu;          /* current CPU */
0043     unsigned long thr_ptr;      /* TLS ptr */
0044 };
0045 
0046 /*
0047  * macros/functions for gaining access to the thread information structure
0048  *
0049  * preempt_count needs to be 1 initially, until the scheduler is functional.
0050  */
0051 #define INIT_THREAD_INFO(tsk)           \
0052 {                       \
0053     .task       = &tsk,         \
0054     .flags      = 0,            \
0055     .cpu        = 0,            \
0056     .preempt_count  = INIT_PREEMPT_COUNT,   \
0057 }
0058 
0059 static inline __attribute_const__ struct thread_info *current_thread_info(void)
0060 {
0061     register unsigned long sp asm("sp");
0062     return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
0063 }
0064 
0065 #endif /* !__ASSEMBLY__ */
0066 
0067 /*
0068  * thread information flags
0069  * - these are process state flags that various assembly files may need to
0070  *   access
0071  * - pending work-to-be-done flags are in LSW
0072  * - other flags in MSW
0073  */
0074 #define TIF_RESTORE_SIGMASK 0   /* restore sig mask in do_signal() */
0075 #define TIF_NOTIFY_RESUME   1   /* resumption notification requested */
0076 #define TIF_SIGPENDING      2   /* signal pending */
0077 #define TIF_NEED_RESCHED    3   /* rescheduling necessary */
0078 #define TIF_SYSCALL_AUDIT   4   /* syscall auditing active */
0079 #define TIF_NOTIFY_SIGNAL   5   /* signal notifications exist */
0080 #define TIF_SYSCALL_TRACE   15  /* syscall trace active */
0081 /* true if poll_idle() is polling TIF_NEED_RESCHED */
0082 #define TIF_MEMDIE      16
0083 #define TIF_SYSCALL_TRACEPOINT  17  /* syscall tracepoint instrumentation */
0084 
0085 #define _TIF_SYSCALL_TRACE  (1<<TIF_SYSCALL_TRACE)
0086 #define _TIF_NOTIFY_RESUME  (1<<TIF_NOTIFY_RESUME)
0087 #define _TIF_SIGPENDING     (1<<TIF_SIGPENDING)
0088 #define _TIF_NEED_RESCHED   (1<<TIF_NEED_RESCHED)
0089 #define _TIF_SYSCALL_AUDIT  (1<<TIF_SYSCALL_AUDIT)
0090 #define _TIF_NOTIFY_SIGNAL  (1<<TIF_NOTIFY_SIGNAL)
0091 #define _TIF_MEMDIE     (1<<TIF_MEMDIE)
0092 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
0093 
0094 /* work to do on interrupt/exception return */
0095 #define _TIF_WORK_MASK      (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
0096                  _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL)
0097 
0098 #define _TIF_SYSCALL_WORK   (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
0099 
0100 /*
0101  * _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it.
0102  * SYSCALL_TRACE is anyway separately/unconditionally tested right after a
0103  * syscall, so all that remains to be tested is _TIF_WORK_MASK
0104  */
0105 
0106 #endif /* _ASM_THREAD_INFO_H */