1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * OpenRISC Linux 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Linux architectural port borrowing liberally from similar works of 6*4882a593Smuzhiyun * others. All original copyrights apply as per the original source 7*4882a593Smuzhiyun * declaration. 8*4882a593Smuzhiyun * 9*4882a593Smuzhiyun * OpenRISC implementation: 10*4882a593Smuzhiyun * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> 11*4882a593Smuzhiyun * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> 12*4882a593Smuzhiyun * et al. 13*4882a593Smuzhiyun */ 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun #ifndef _ASM_THREAD_INFO_H 16*4882a593Smuzhiyun #define _ASM_THREAD_INFO_H 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun #ifdef __KERNEL__ 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #ifndef __ASSEMBLY__ 21*4882a593Smuzhiyun #include <asm/types.h> 22*4882a593Smuzhiyun #include <asm/processor.h> 23*4882a593Smuzhiyun #endif 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun /* THREAD_SIZE is the size of the task_struct/kernel_stack combo. 27*4882a593Smuzhiyun * normally, the stack is found by doing something like p + THREAD_SIZE 28*4882a593Smuzhiyun * in or32, a page is 8192 bytes, which seems like a sane size 29*4882a593Smuzhiyun */ 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun #define THREAD_SIZE_ORDER 0 32*4882a593Smuzhiyun #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun /* 35*4882a593Smuzhiyun * low level task data that entry.S needs immediate access to 36*4882a593Smuzhiyun * - this struct should fit entirely inside of one cache line 37*4882a593Smuzhiyun * - this struct shares the supervisor stack pages 38*4882a593Smuzhiyun * - if the contents of this structure are changed, the assembly constants 39*4882a593Smuzhiyun * must also be changed 40*4882a593Smuzhiyun */ 41*4882a593Smuzhiyun #ifndef __ASSEMBLY__ 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun typedef unsigned long mm_segment_t; 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun struct thread_info { 46*4882a593Smuzhiyun struct task_struct *task; /* main task structure */ 47*4882a593Smuzhiyun unsigned long flags; /* low level flags */ 48*4882a593Smuzhiyun __u32 cpu; /* current CPU */ 49*4882a593Smuzhiyun __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun mm_segment_t addr_limit; /* thread address space: 52*4882a593Smuzhiyun 0-0x7FFFFFFF for user-thead 53*4882a593Smuzhiyun 0-0xFFFFFFFF for kernel-thread 54*4882a593Smuzhiyun */ 55*4882a593Smuzhiyun __u8 supervisor_stack[0]; 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun /* saved context data */ 58*4882a593Smuzhiyun unsigned long ksp; 59*4882a593Smuzhiyun }; 60*4882a593Smuzhiyun #endif 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun /* 63*4882a593Smuzhiyun * macros/functions for gaining access to the thread information structure 64*4882a593Smuzhiyun * 65*4882a593Smuzhiyun * preempt_count needs to be 1 initially, until the scheduler is functional. 66*4882a593Smuzhiyun */ 67*4882a593Smuzhiyun #ifndef __ASSEMBLY__ 68*4882a593Smuzhiyun #define INIT_THREAD_INFO(tsk) \ 69*4882a593Smuzhiyun { \ 70*4882a593Smuzhiyun .task = &tsk, \ 71*4882a593Smuzhiyun .flags = 0, \ 72*4882a593Smuzhiyun .cpu = 0, \ 73*4882a593Smuzhiyun .preempt_count = INIT_PREEMPT_COUNT, \ 74*4882a593Smuzhiyun .addr_limit = KERNEL_DS, \ 75*4882a593Smuzhiyun .ksp = 0, \ 76*4882a593Smuzhiyun } 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun /* how to get the thread information struct from C */ 79*4882a593Smuzhiyun register struct thread_info *current_thread_info_reg asm("r10"); 80*4882a593Smuzhiyun #define current_thread_info() (current_thread_info_reg) 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun #define get_thread_info(ti) get_task_struct((ti)->task) 83*4882a593Smuzhiyun #define put_thread_info(ti) put_task_struct((ti)->task) 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun #endif /* !__ASSEMBLY__ */ 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun /* 88*4882a593Smuzhiyun * thread information flags 89*4882a593Smuzhiyun * these are process state flags that various assembly files may need to 90*4882a593Smuzhiyun * access 91*4882a593Smuzhiyun * - pending work-to-be-done flags are in LSW 92*4882a593Smuzhiyun * - other flags in MSW 93*4882a593Smuzhiyun */ 94*4882a593Smuzhiyun #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 95*4882a593Smuzhiyun #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 96*4882a593Smuzhiyun #define TIF_SIGPENDING 2 /* signal pending */ 97*4882a593Smuzhiyun #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 98*4882a593Smuzhiyun #define TIF_SINGLESTEP 4 /* restore singlestep on return to user 99*4882a593Smuzhiyun * mode 100*4882a593Smuzhiyun */ 101*4882a593Smuzhiyun #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ 102*4882a593Smuzhiyun #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */ 103*4882a593Smuzhiyun #define TIF_RESTORE_SIGMASK 9 104*4882a593Smuzhiyun #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling * TIF_NEED_RESCHED 105*4882a593Smuzhiyun */ 106*4882a593Smuzhiyun #define TIF_MEMDIE 17 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 109*4882a593Smuzhiyun #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 110*4882a593Smuzhiyun #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 111*4882a593Smuzhiyun #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 112*4882a593Smuzhiyun #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 113*4882a593Smuzhiyun #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL) 114*4882a593Smuzhiyun #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun /* Work to do when returning from interrupt/exception */ 118*4882a593Smuzhiyun /* For OpenRISC, this is anything in the LSW other than syscall trace */ 119*4882a593Smuzhiyun #define _TIF_WORK_MASK (0xff & ~(_TIF_SYSCALL_TRACE|_TIF_SINGLESTEP)) 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun #endif /* __KERNEL__ */ 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun #endif /* _ASM_THREAD_INFO_H */ 124