Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Licensed under the GPL |
| 4 | */ |
| 5 | |
| 6 | #ifndef __UM_PROCESSOR_GENERIC_H |
| 7 | #define __UM_PROCESSOR_GENERIC_H |
| 8 | |
| 9 | struct pt_regs; |
| 10 | |
| 11 | struct task_struct; |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include "asm/ptrace.h" |
Allan Graves | fad1c45 | 2005-10-04 14:53:52 -0400 | [diff] [blame] | 14 | #include "registers.h" |
Jeff Dike | 3c91735 | 2006-09-27 01:50:40 -0700 | [diff] [blame] | 15 | #include "sysdep/archsetjmp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | struct mm_struct; |
| 18 | |
| 19 | struct thread_struct { |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 20 | struct task_struct *saved_task; |
| 21 | /* |
| 22 | * This flag is set to 1 before calling do_fork (and analyzed in |
Paolo 'Blaisorblade' Giarrusso | acef2e5 | 2005-05-01 08:58:56 -0700 | [diff] [blame] | 23 | * copy_thread) to mark that we are begin called from userspace (fork / |
| 24 | * vfork / clone), and reset to 0 after. It is left to 0 when called |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 25 | * from kernelspace (i.e. kernel_thread() or fork_idle(), |
| 26 | * as of 2.6.11). |
| 27 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | int forking; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | struct pt_regs regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | int singlestep_syscall; |
| 31 | void *fault_addr; |
Jeff Dike | fab95c5 | 2007-10-16 01:27:05 -0700 | [diff] [blame] | 32 | jmp_buf *fault_catcher; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | struct task_struct *prev_sched; |
| 34 | unsigned long temp_stack; |
Jeff Dike | fab95c5 | 2007-10-16 01:27:05 -0700 | [diff] [blame] | 35 | jmp_buf *exec_buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | struct arch_thread arch; |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 37 | jmp_buf switch_buf; |
| 38 | int mm_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | struct { |
| 40 | int op; |
| 41 | union { |
| 42 | struct { |
| 43 | int pid; |
| 44 | } fork, exec; |
| 45 | struct { |
| 46 | int (*proc)(void *); |
| 47 | void *arg; |
| 48 | } thread; |
| 49 | struct { |
| 50 | void (*proc)(void *); |
| 51 | void *arg; |
| 52 | } cb; |
| 53 | } u; |
| 54 | } request; |
| 55 | }; |
| 56 | |
| 57 | #define INIT_THREAD \ |
| 58 | { \ |
| 59 | .forking = 0, \ |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 60 | .regs = EMPTY_REGS, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | .fault_addr = NULL, \ |
| 62 | .prev_sched = NULL, \ |
| 63 | .temp_stack = 0, \ |
| 64 | .exec_buf = NULL, \ |
| 65 | .arch = INIT_ARCH_THREAD, \ |
| 66 | .request = { 0 } \ |
| 67 | } |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | extern struct task_struct *alloc_task_struct(void); |
| 70 | |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 71 | static inline void release_thread(struct task_struct *task) |
| 72 | { |
| 73 | } |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); |
Paolo 'Blaisorblade' Giarrusso | c16993d | 2005-05-01 08:58:54 -0700 | [diff] [blame] | 76 | |
| 77 | static inline void prepare_to_copy(struct task_struct *tsk) |
| 78 | { |
| 79 | } |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | extern unsigned long thread_saved_pc(struct task_struct *t); |
| 83 | |
| 84 | static inline void mm_copy_segments(struct mm_struct *from_mm, |
| 85 | struct mm_struct *new_mm) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | #define init_stack (init_thread_union.stack) |
| 90 | |
| 91 | /* |
| 92 | * User space process size: 3GB (default). |
| 93 | */ |
Jeff Dike | 536788f | 2008-02-08 04:22:07 -0800 | [diff] [blame] | 94 | extern unsigned long task_size; |
| 95 | |
| 96 | #define TASK_SIZE (task_size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
David Howells | 922a70d | 2008-02-08 04:19:26 -0800 | [diff] [blame] | 98 | #undef STACK_TOP |
| 99 | #undef STACK_TOP_MAX |
| 100 | |
| 101 | extern unsigned long stacksizelim; |
| 102 | |
| 103 | #define STACK_ROOM (stacksizelim) |
| 104 | #define STACK_TOP (TASK_SIZE - 2 * PAGE_SIZE) |
| 105 | #define STACK_TOP_MAX STACK_TOP |
| 106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | /* This decides where the kernel will search for a free chunk of vm |
| 108 | * space during mmap's. |
| 109 | */ |
| 110 | #define TASK_UNMAPPED_BASE (0x40000000) |
| 111 | |
| 112 | extern void start_thread(struct pt_regs *regs, unsigned long entry, |
| 113 | unsigned long stack); |
| 114 | |
| 115 | struct cpuinfo_um { |
| 116 | unsigned long loops_per_jiffy; |
| 117 | int ipi_pipe[2]; |
| 118 | }; |
| 119 | |
| 120 | extern struct cpuinfo_um boot_cpu_data; |
| 121 | |
| 122 | #define my_cpu_data cpu_data[smp_processor_id()] |
| 123 | |
| 124 | #ifdef CONFIG_SMP |
| 125 | extern struct cpuinfo_um cpu_data[]; |
| 126 | #define current_cpu_data cpu_data[smp_processor_id()] |
| 127 | #else |
| 128 | #define cpu_data (&boot_cpu_data) |
| 129 | #define current_cpu_data boot_cpu_data |
| 130 | #endif |
| 131 | |
Allan Graves | fad1c45 | 2005-10-04 14:53:52 -0400 | [diff] [blame] | 132 | |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 133 | #define KSTK_REG(tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf) |
Jeff Dike | c112746 | 2008-02-04 22:30:36 -0800 | [diff] [blame] | 134 | extern unsigned long get_wchan(struct task_struct *p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | #endif |