18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Thread support for the Hexagon architecture 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _ASM_THREAD_INFO_H 98c2ecf20Sopenharmony_ci#define _ASM_THREAD_INFO_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 148c2ecf20Sopenharmony_ci#include <asm/processor.h> 158c2ecf20Sopenharmony_ci#include <asm/registers.h> 168c2ecf20Sopenharmony_ci#include <asm/page.h> 178c2ecf20Sopenharmony_ci#endif 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define THREAD_SHIFT 12 208c2ecf20Sopenharmony_ci#define THREAD_SIZE (1<<THREAD_SHIFT) 218c2ecf20Sopenharmony_ci#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_citypedef struct { 268c2ecf20Sopenharmony_ci unsigned long seg; 278c2ecf20Sopenharmony_ci} mm_segment_t; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* 308c2ecf20Sopenharmony_ci * This is union'd with the "bottom" of the kernel stack. 318c2ecf20Sopenharmony_ci * It keeps track of thread info which is handy for routines 328c2ecf20Sopenharmony_ci * to access quickly. 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistruct thread_info { 368c2ecf20Sopenharmony_ci struct task_struct *task; /* main task structure */ 378c2ecf20Sopenharmony_ci unsigned long flags; /* low level flags */ 388c2ecf20Sopenharmony_ci __u32 cpu; /* current cpu */ 398c2ecf20Sopenharmony_ci int preempt_count; /* 0=>preemptible,<0=>BUG */ 408c2ecf20Sopenharmony_ci mm_segment_t addr_limit; /* segmentation sux */ 418c2ecf20Sopenharmony_ci /* 428c2ecf20Sopenharmony_ci * used for syscalls somehow; 438c2ecf20Sopenharmony_ci * seems to have a function pointer and four arguments 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_ci /* Points to the current pt_regs frame */ 468c2ecf20Sopenharmony_ci struct pt_regs *regs; 478c2ecf20Sopenharmony_ci /* 488c2ecf20Sopenharmony_ci * saved kernel sp at switch_to time; 498c2ecf20Sopenharmony_ci * not sure if this is used (it's not in the VM model it seems; 508c2ecf20Sopenharmony_ci * see thread_struct) 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_ci unsigned long sp; 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#else /* !__ASSEMBLY__ */ 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#include <asm/asm-offsets.h> 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define INIT_THREAD_INFO(tsk) \ 648c2ecf20Sopenharmony_ci{ \ 658c2ecf20Sopenharmony_ci .task = &tsk, \ 668c2ecf20Sopenharmony_ci .flags = 0, \ 678c2ecf20Sopenharmony_ci .cpu = 0, \ 688c2ecf20Sopenharmony_ci .preempt_count = 1, \ 698c2ecf20Sopenharmony_ci .addr_limit = KERNEL_DS, \ 708c2ecf20Sopenharmony_ci .sp = 0, \ 718c2ecf20Sopenharmony_ci .regs = NULL, \ 728c2ecf20Sopenharmony_ci} 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* Tacky preprocessor trickery */ 758c2ecf20Sopenharmony_ci#define qqstr(s) qstr(s) 768c2ecf20Sopenharmony_ci#define qstr(s) #s 778c2ecf20Sopenharmony_ci#define QUOTED_THREADINFO_REG qqstr(THREADINFO_REG) 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciregister struct thread_info *__current_thread_info asm(QUOTED_THREADINFO_REG); 808c2ecf20Sopenharmony_ci#define current_thread_info() __current_thread_info 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* 858c2ecf20Sopenharmony_ci * thread information flags 868c2ecf20Sopenharmony_ci * - these are process state flags that various assembly files 878c2ecf20Sopenharmony_ci * may need to access 888c2ecf20Sopenharmony_ci * - pending work-to-be-done flags are in LSW 898c2ecf20Sopenharmony_ci * - other flags in MSW 908c2ecf20Sopenharmony_ci */ 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 938c2ecf20Sopenharmony_ci#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 948c2ecf20Sopenharmony_ci#define TIF_SIGPENDING 2 /* signal pending */ 958c2ecf20Sopenharmony_ci#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 968c2ecf20Sopenharmony_ci#define TIF_SINGLESTEP 4 /* restore ss @ return to usr mode */ 978c2ecf20Sopenharmony_ci#define TIF_RESTORE_SIGMASK 6 /* restore sig mask in do_signal() */ 988c2ecf20Sopenharmony_ci#define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */ 998c2ecf20Sopenharmony_ci/* true if poll_idle() is polling TIF_NEED_RESCHED */ 1008c2ecf20Sopenharmony_ci#define TIF_MEMDIE 17 /* OOM killer killed process */ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 1038c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) 1048c2ecf20Sopenharmony_ci#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 1058c2ecf20Sopenharmony_ci#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 1068c2ecf20Sopenharmony_ci#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) 1078c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* work to do on interrupt/exception return - All but TIF_SYSCALL_TRACE */ 1108c2ecf20Sopenharmony_ci#define _TIF_WORK_MASK (0x0000FFFF & ~_TIF_SYSCALL_TRACE) 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* work to do on any return to u-space */ 1138c2ecf20Sopenharmony_ci#define _TIF_ALLWORK_MASK 0x0000FFFF 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci#endif 118