| 1 | /* |
| 2 | * arch/ubicom32/include/asm/thread_info.h |
| 3 | * Ubicom32 architecture low-level thread information. |
| 4 | * |
| 5 | * (C) Copyright 2009, Ubicom, Inc. |
| 6 | * Adapted from the i386 and PPC versions by Greg Ungerer (gerg@snapgear.com) |
| 7 | * Copyright (C) 2002 David Howells (dhowells@redhat.com) |
| 8 | * - Incorporating suggestions made by Linus Torvalds and Dave Miller |
| 9 | * |
| 10 | * This file is part of the Ubicom32 Linux Kernel Port. |
| 11 | * |
| 12 | * The Ubicom32 Linux Kernel Port is free software: you can redistribute |
| 13 | * it and/or modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation, either version 2 of the |
| 15 | * License, or (at your option) any later version. |
| 16 | * |
| 17 | * The Ubicom32 Linux Kernel Port is distributed in the hope that it |
| 18 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 19 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 20 | * the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with the Ubicom32 Linux Kernel Port. If not, |
| 24 | * see <http://www.gnu.org/licenses/>. |
| 25 | * |
| 26 | * Ubicom32 implementation derived from (with many thanks): |
| 27 | * arch/m68knommu |
| 28 | * arch/blackfin |
| 29 | * arch/parisc |
| 30 | */ |
| 31 | |
| 32 | #ifndef _ASM_UBICOM32_THREAD_INFO_H |
| 33 | #define _ASM_UBICOM32_THREAD_INFO_H |
| 34 | |
| 35 | #include <asm/page.h> |
| 36 | |
| 37 | /* |
| 38 | * Size of kernel stack for each process. This must be a power of 2... |
| 39 | */ |
| 40 | #ifdef CONFIG_4KSTACKS |
| 41 | #define THREAD_SIZE_ORDER (0) |
| 42 | #else |
| 43 | #define THREAD_SIZE_ORDER (1) |
| 44 | #endif |
| 45 | |
| 46 | /* |
| 47 | * for asm files, THREAD_SIZE is now generated by asm-offsets.c |
| 48 | */ |
| 49 | #define THREAD_SIZE (PAGE_SIZE<<THREAD_SIZE_ORDER) |
| 50 | |
| 51 | #ifdef __KERNEL__ |
| 52 | |
| 53 | #ifndef __ASSEMBLY__ |
| 54 | |
| 55 | /* |
| 56 | * low level task data. |
| 57 | */ |
| 58 | struct thread_info { |
| 59 | struct task_struct *task; /* main task structure */ |
| 60 | struct exec_domain *exec_domain; /* execution domain */ |
| 61 | unsigned long flags; /* low level flags */ |
| 62 | int cpu; /* cpu we're on */ |
| 63 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
| 64 | int interrupt_nesting; /* Interrupt nesting level. */ |
| 65 | struct restart_block restart_block; |
| 66 | }; |
| 67 | |
| 68 | /* |
| 69 | * macros/functions for gaining access to the thread information structure |
| 70 | */ |
| 71 | #define INIT_THREAD_INFO(tsk) \ |
| 72 | { \ |
| 73 | .task = &tsk, \ |
| 74 | .exec_domain = &default_exec_domain, \ |
| 75 | .flags = 0, \ |
| 76 | .cpu = 0, \ |
| 77 | .interrupt_nesting = 0, \ |
| 78 | .restart_block = { \ |
| 79 | .fn = do_no_restart_syscall, \ |
| 80 | }, \ |
| 81 | } |
| 82 | |
| 83 | #define init_thread_info (init_thread_union.thread_info) |
| 84 | #define init_stack (init_thread_union.stack) |
| 85 | |
| 86 | |
| 87 | /* how to get the thread information struct from C */ |
| 88 | static inline struct thread_info *current_thread_info(void) |
| 89 | { |
| 90 | struct thread_info *ti; |
| 91 | |
| 92 | asm ( |
| 93 | "and.4 %0, sp, %1\n\t" |
| 94 | : "=&r" (ti) |
| 95 | : "d" (~(THREAD_SIZE-1)) |
| 96 | : "cc" |
| 97 | ); |
| 98 | |
| 99 | return ti; |
| 100 | } |
| 101 | |
| 102 | #define STACK_WARN (THREAD_SIZE / 8) |
| 103 | |
| 104 | #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR 1 |
| 105 | |
| 106 | /* thread information allocation */ |
| 107 | #define alloc_thread_info(tsk) ((struct thread_info *) \ |
| 108 | __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER)) |
| 109 | #define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_SIZE_ORDER) |
| 110 | #endif /* __ASSEMBLY__ */ |
| 111 | |
| 112 | #define PREEMPT_ACTIVE 0x4000000 |
| 113 | |
| 114 | /* |
| 115 | * thread information flag bit numbers |
| 116 | */ |
| 117 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ |
| 118 | #define TIF_SIGPENDING 1 /* signal pending */ |
| 119 | #define TIF_NEED_RESCHED 2 /* rescheduling necessary */ |
| 120 | #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling |
| 121 | TIF_NEED_RESCHED */ |
| 122 | #define TIF_MEMDIE 4 |
| 123 | |
| 124 | /* as above, but as bit values */ |
| 125 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) |
| 126 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
| 127 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) |
| 128 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) |
| 129 | |
| 130 | #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ |
| 131 | |
| 132 | #endif /* __KERNEL__ */ |
| 133 | |
| 134 | #endif /* _ASM_UBICOM32_THREAD_INFO_H */ |
| 135 | |