diff options
Diffstat (limited to 'include/asm-sh/thread_info.h')
-rw-r--r-- | include/asm-sh/thread_info.h | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h index 7345350d98c0..3ebc3f9039eb 100644 --- a/include/asm-sh/thread_info.h +++ b/include/asm-sh/thread_info.h | |||
@@ -9,8 +9,8 @@ | |||
9 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) | 9 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) |
10 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller | 10 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller |
11 | */ | 11 | */ |
12 | |||
13 | #ifdef __KERNEL__ | 12 | #ifdef __KERNEL__ |
13 | #include <asm/page.h> | ||
14 | 14 | ||
15 | #ifndef __ASSEMBLY__ | 15 | #ifndef __ASSEMBLY__ |
16 | #include <asm/processor.h> | 16 | #include <asm/processor.h> |
@@ -21,7 +21,10 @@ struct thread_info { | |||
21 | unsigned long flags; /* low level flags */ | 21 | unsigned long flags; /* low level flags */ |
22 | __u32 cpu; | 22 | __u32 cpu; |
23 | int preempt_count; /* 0 => preemptable, <0 => BUG */ | 23 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
24 | mm_segment_t addr_limit; /* thread address space */ | ||
24 | struct restart_block restart_block; | 25 | struct restart_block restart_block; |
26 | unsigned long previous_sp; /* sp of previous stack in case | ||
27 | of nested IRQ stacks */ | ||
25 | __u8 supervisor_stack[0]; | 28 | __u8 supervisor_stack[0]; |
26 | }; | 29 | }; |
27 | 30 | ||
@@ -29,6 +32,13 @@ struct thread_info { | |||
29 | 32 | ||
30 | #define PREEMPT_ACTIVE 0x10000000 | 33 | #define PREEMPT_ACTIVE 0x10000000 |
31 | 34 | ||
35 | #ifdef CONFIG_4KSTACKS | ||
36 | #define THREAD_SIZE (PAGE_SIZE) | ||
37 | #else | ||
38 | #define THREAD_SIZE (PAGE_SIZE * 2) | ||
39 | #endif | ||
40 | #define STACK_WARN (THREAD_SIZE / 8) | ||
41 | |||
32 | /* | 42 | /* |
33 | * macros/functions for gaining access to the thread information structure | 43 | * macros/functions for gaining access to the thread information structure |
34 | */ | 44 | */ |
@@ -40,6 +50,7 @@ struct thread_info { | |||
40 | .flags = 0, \ | 50 | .flags = 0, \ |
41 | .cpu = 0, \ | 51 | .cpu = 0, \ |
42 | .preempt_count = 1, \ | 52 | .preempt_count = 1, \ |
53 | .addr_limit = KERNEL_DS, \ | ||
43 | .restart_block = { \ | 54 | .restart_block = { \ |
44 | .fn = do_no_restart_syscall, \ | 55 | .fn = do_no_restart_syscall, \ |
45 | }, \ | 56 | }, \ |
@@ -48,24 +59,42 @@ struct thread_info { | |||
48 | #define init_thread_info (init_thread_union.thread_info) | 59 | #define init_thread_info (init_thread_union.thread_info) |
49 | #define init_stack (init_thread_union.stack) | 60 | #define init_stack (init_thread_union.stack) |
50 | 61 | ||
62 | /* how to get the current stack pointer from C */ | ||
63 | register unsigned long current_stack_pointer asm("r15") __attribute_used__; | ||
64 | |||
51 | /* how to get the thread information struct from C */ | 65 | /* how to get the thread information struct from C */ |
52 | static inline struct thread_info *current_thread_info(void) | 66 | static inline struct thread_info *current_thread_info(void) |
53 | { | 67 | { |
54 | struct thread_info *ti; | 68 | struct thread_info *ti; |
69 | #ifdef CONFIG_CPU_HAS_SR_RB | ||
55 | __asm__("stc r7_bank, %0" : "=r" (ti)); | 70 | __asm__("stc r7_bank, %0" : "=r" (ti)); |
71 | #else | ||
72 | unsigned long __dummy; | ||
73 | |||
74 | __asm__ __volatile__ ( | ||
75 | "mov r15, %0\n\t" | ||
76 | "and %1, %0\n\t" | ||
77 | : "=&r" (ti), "=r" (__dummy) | ||
78 | : "1" (~(THREAD_SIZE - 1)) | ||
79 | : "memory"); | ||
80 | #endif | ||
81 | |||
56 | return ti; | 82 | return ti; |
57 | } | 83 | } |
58 | 84 | ||
59 | /* thread information allocation */ | 85 | /* thread information allocation */ |
60 | #define THREAD_SIZE (2*PAGE_SIZE) | 86 | #ifdef CONFIG_DEBUG_STACK_USAGE |
61 | #define alloc_thread_info(ti) ((struct thread_info *) __get_free_pages(GFP_KERNEL,1)) | 87 | #define alloc_thread_info(ti) kzalloc(THREAD_SIZE, GFP_KERNEL) |
62 | #define free_thread_info(ti) free_pages((unsigned long) (ti), 1) | 88 | #else |
89 | #define alloc_thread_info(ti) kmalloc(THREAD_SIZE, GFP_KERNEL) | ||
90 | #endif | ||
91 | #define free_thread_info(ti) kfree(ti) | ||
63 | 92 | ||
64 | #else /* !__ASSEMBLY__ */ | 93 | #else /* !__ASSEMBLY__ */ |
65 | 94 | ||
66 | /* how to get the thread information struct from ASM */ | 95 | /* how to get the thread information struct from ASM */ |
67 | #define GET_THREAD_INFO(reg) \ | 96 | #define GET_THREAD_INFO(reg) \ |
68 | stc r7_bank, reg | 97 | stc r7_bank, reg |
69 | 98 | ||
70 | #endif | 99 | #endif |
71 | 100 | ||
@@ -79,18 +108,18 @@ static inline struct thread_info *current_thread_info(void) | |||
79 | #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ | 108 | #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ |
80 | #define TIF_SIGPENDING 2 /* signal pending */ | 109 | #define TIF_SIGPENDING 2 /* signal pending */ |
81 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ | 110 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ |
111 | #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ | ||
82 | #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ | 112 | #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ |
83 | #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ | 113 | #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ |
84 | #define TIF_MEMDIE 18 | 114 | #define TIF_MEMDIE 18 |
85 | #define TIF_USERSPACE 31 /* true if FS sets userspace */ | ||
86 | 115 | ||
87 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | 116 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) |
88 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) | 117 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) |
89 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) | 118 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
90 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | 119 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
120 | #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) | ||
91 | #define _TIF_USEDFPU (1<<TIF_USEDFPU) | 121 | #define _TIF_USEDFPU (1<<TIF_USEDFPU) |
92 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) | 122 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) |
93 | #define _TIF_USERSPACE (1<<TIF_USERSPACE) | ||
94 | 123 | ||
95 | #define _TIF_WORK_MASK 0x000000FE /* work to do on interrupt/exception return */ | 124 | #define _TIF_WORK_MASK 0x000000FE /* work to do on interrupt/exception return */ |
96 | #define _TIF_ALLWORK_MASK 0x000000FF /* work to do on any return to u-space */ | 125 | #define _TIF_ALLWORK_MASK 0x000000FF /* work to do on any return to u-space */ |