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