18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * OpenRISC Linux 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Linux architectural port borrowing liberally from similar works of 68c2ecf20Sopenharmony_ci * others. All original copyrights apply as per the original source 78c2ecf20Sopenharmony_ci * declaration. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * OpenRISC implementation: 108c2ecf20Sopenharmony_ci * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> 118c2ecf20Sopenharmony_ci * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> 128c2ecf20Sopenharmony_ci * et al. 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef _ASM_THREAD_INFO_H 168c2ecf20Sopenharmony_ci#define _ASM_THREAD_INFO_H 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 218c2ecf20Sopenharmony_ci#include <asm/types.h> 228c2ecf20Sopenharmony_ci#include <asm/processor.h> 238c2ecf20Sopenharmony_ci#endif 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* THREAD_SIZE is the size of the task_struct/kernel_stack combo. 278c2ecf20Sopenharmony_ci * normally, the stack is found by doing something like p + THREAD_SIZE 288c2ecf20Sopenharmony_ci * in or32, a page is 8192 bytes, which seems like a sane size 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define THREAD_SIZE_ORDER 0 328c2ecf20Sopenharmony_ci#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * low level task data that entry.S needs immediate access to 368c2ecf20Sopenharmony_ci * - this struct should fit entirely inside of one cache line 378c2ecf20Sopenharmony_ci * - this struct shares the supervisor stack pages 388c2ecf20Sopenharmony_ci * - if the contents of this structure are changed, the assembly constants 398c2ecf20Sopenharmony_ci * must also be changed 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_citypedef unsigned long mm_segment_t; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct thread_info { 468c2ecf20Sopenharmony_ci struct task_struct *task; /* main task structure */ 478c2ecf20Sopenharmony_ci unsigned long flags; /* low level flags */ 488c2ecf20Sopenharmony_ci __u32 cpu; /* current CPU */ 498c2ecf20Sopenharmony_ci __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci mm_segment_t addr_limit; /* thread address space: 528c2ecf20Sopenharmony_ci 0-0x7FFFFFFF for user-thead 538c2ecf20Sopenharmony_ci 0-0xFFFFFFFF for kernel-thread 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci __u8 supervisor_stack[0]; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci /* saved context data */ 588c2ecf20Sopenharmony_ci unsigned long ksp; 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci#endif 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* 638c2ecf20Sopenharmony_ci * macros/functions for gaining access to the thread information structure 648c2ecf20Sopenharmony_ci * 658c2ecf20Sopenharmony_ci * preempt_count needs to be 1 initially, until the scheduler is functional. 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 688c2ecf20Sopenharmony_ci#define INIT_THREAD_INFO(tsk) \ 698c2ecf20Sopenharmony_ci{ \ 708c2ecf20Sopenharmony_ci .task = &tsk, \ 718c2ecf20Sopenharmony_ci .flags = 0, \ 728c2ecf20Sopenharmony_ci .cpu = 0, \ 738c2ecf20Sopenharmony_ci .preempt_count = INIT_PREEMPT_COUNT, \ 748c2ecf20Sopenharmony_ci .addr_limit = KERNEL_DS, \ 758c2ecf20Sopenharmony_ci .ksp = 0, \ 768c2ecf20Sopenharmony_ci} 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* how to get the thread information struct from C */ 798c2ecf20Sopenharmony_ciregister struct thread_info *current_thread_info_reg asm("r10"); 808c2ecf20Sopenharmony_ci#define current_thread_info() (current_thread_info_reg) 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define get_thread_info(ti) get_task_struct((ti)->task) 838c2ecf20Sopenharmony_ci#define put_thread_info(ti) put_task_struct((ti)->task) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* 888c2ecf20Sopenharmony_ci * thread information flags 898c2ecf20Sopenharmony_ci * these are process state flags that various assembly files may need to 908c2ecf20Sopenharmony_ci * access 918c2ecf20Sopenharmony_ci * - pending work-to-be-done flags are in LSW 928c2ecf20Sopenharmony_ci * - other flags in MSW 938c2ecf20Sopenharmony_ci */ 948c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 958c2ecf20Sopenharmony_ci#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 968c2ecf20Sopenharmony_ci#define TIF_SIGPENDING 2 /* signal pending */ 978c2ecf20Sopenharmony_ci#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 988c2ecf20Sopenharmony_ci#define TIF_SINGLESTEP 4 /* restore singlestep on return to user 998c2ecf20Sopenharmony_ci * mode 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_ci#define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ 1028c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */ 1038c2ecf20Sopenharmony_ci#define TIF_RESTORE_SIGMASK 9 1048c2ecf20Sopenharmony_ci#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling * TIF_NEED_RESCHED 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_ci#define TIF_MEMDIE 17 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 1098c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 1108c2ecf20Sopenharmony_ci#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 1118c2ecf20Sopenharmony_ci#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 1128c2ecf20Sopenharmony_ci#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 1138c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL) 1148c2ecf20Sopenharmony_ci#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* Work to do when returning from interrupt/exception */ 1188c2ecf20Sopenharmony_ci/* For OpenRISC, this is anything in the LSW other than syscall trace */ 1198c2ecf20Sopenharmony_ci#define _TIF_WORK_MASK (0xff & ~(_TIF_SYSCALL_TRACE|_TIF_SINGLESTEP)) 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci#endif /* _ASM_THREAD_INFO_H */ 124