18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * NiosII low-level thread information 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch> 58c2ecf20Sopenharmony_ci * Copyright (C) 2004 Microtronix Datacom Ltd. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Based on asm/thread_info_no.h from m68k which is: 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Copyright (C) 2002 David Howells <dhowells@redhat.com> 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 128c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 138c2ecf20Sopenharmony_ci * for more details. 148c2ecf20Sopenharmony_ci */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#ifndef _ASM_NIOS2_THREAD_INFO_H 178c2ecf20Sopenharmony_ci#define _ASM_NIOS2_THREAD_INFO_H 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* 228c2ecf20Sopenharmony_ci * Size of the kernel stack for each process. 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci#define THREAD_SIZE_ORDER 1 258c2ecf20Sopenharmony_ci#define THREAD_SIZE 8192 /* 2 * PAGE_SIZE */ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_citypedef struct { 308c2ecf20Sopenharmony_ci unsigned long seg; 318c2ecf20Sopenharmony_ci} mm_segment_t; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* 348c2ecf20Sopenharmony_ci * low level task data that entry.S needs immediate access to 358c2ecf20Sopenharmony_ci * - this struct should fit entirely inside of one cache line 368c2ecf20Sopenharmony_ci * - this struct shares the supervisor stack pages 378c2ecf20Sopenharmony_ci * - if the contents of this structure are changed, the assembly constants 388c2ecf20Sopenharmony_ci * must also be changed 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_cistruct thread_info { 418c2ecf20Sopenharmony_ci struct task_struct *task; /* main task structure */ 428c2ecf20Sopenharmony_ci unsigned long flags; /* low level flags */ 438c2ecf20Sopenharmony_ci __u32 cpu; /* current CPU */ 448c2ecf20Sopenharmony_ci int preempt_count; /* 0 => preemptable,<0 => BUG */ 458c2ecf20Sopenharmony_ci mm_segment_t addr_limit; /* thread address space: 468c2ecf20Sopenharmony_ci 0-0x7FFFFFFF for user-thead 478c2ecf20Sopenharmony_ci 0-0xFFFFFFFF for kernel-thread 488c2ecf20Sopenharmony_ci */ 498c2ecf20Sopenharmony_ci struct pt_regs *regs; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * macros/functions for gaining access to the thread information structure 548c2ecf20Sopenharmony_ci * 558c2ecf20Sopenharmony_ci * preempt_count needs to be 1 initially, until the scheduler is functional. 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci#define INIT_THREAD_INFO(tsk) \ 588c2ecf20Sopenharmony_ci{ \ 598c2ecf20Sopenharmony_ci .task = &tsk, \ 608c2ecf20Sopenharmony_ci .flags = 0, \ 618c2ecf20Sopenharmony_ci .cpu = 0, \ 628c2ecf20Sopenharmony_ci .preempt_count = INIT_PREEMPT_COUNT, \ 638c2ecf20Sopenharmony_ci .addr_limit = KERNEL_DS, \ 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* how to get the thread information struct from C */ 678c2ecf20Sopenharmony_cistatic inline struct thread_info *current_thread_info(void) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci register unsigned long sp asm("sp"); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); 728c2ecf20Sopenharmony_ci} 738c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* 768c2ecf20Sopenharmony_ci * thread information flags 778c2ecf20Sopenharmony_ci * - these are process state flags that various assembly files may need to 788c2ecf20Sopenharmony_ci * access 798c2ecf20Sopenharmony_ci * - pending work-to-be-done flags are in LSW 808c2ecf20Sopenharmony_ci * - other flags in MSW 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 838c2ecf20Sopenharmony_ci#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 848c2ecf20Sopenharmony_ci#define TIF_SIGPENDING 2 /* signal pending */ 858c2ecf20Sopenharmony_ci#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 868c2ecf20Sopenharmony_ci#define TIF_MEMDIE 4 /* is terminating due to OOM killer */ 878c2ecf20Sopenharmony_ci#define TIF_SECCOMP 5 /* secure computing */ 888c2ecf20Sopenharmony_ci#define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */ 898c2ecf20Sopenharmony_ci#define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */ 908c2ecf20Sopenharmony_ci#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling 938c2ecf20Sopenharmony_ci TIF_NEED_RESCHED */ 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 968c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 978c2ecf20Sopenharmony_ci#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 988c2ecf20Sopenharmony_ci#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 998c2ecf20Sopenharmony_ci#define _TIF_SECCOMP (1 << TIF_SECCOMP) 1008c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 1018c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) 1028c2ecf20Sopenharmony_ci#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 1038c2ecf20Sopenharmony_ci#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* work to do on interrupt/exception return */ 1068c2ecf20Sopenharmony_ci#define _TIF_WORK_MASK 0x0000FFFE 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci/* work to do on any return to u-space */ 1098c2ecf20Sopenharmony_ci# define _TIF_ALLWORK_MASK 0x0000FFFF 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#endif /* _ASM_NIOS2_THREAD_INFO_H */ 114