processor-generic.h 2.8 KB
Newer Older
L
Linus Torvalds 已提交
1
/* 
J
Jeff Dike 已提交
2
 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
L
Linus Torvalds 已提交
3 4 5 6 7 8 9 10 11 12 13
 * Licensed under the GPL
 */

#ifndef __UM_PROCESSOR_GENERIC_H
#define __UM_PROCESSOR_GENERIC_H

struct pt_regs;

struct task_struct;

#include "asm/ptrace.h"
14
#include "registers.h"
J
Jeff Dike 已提交
15
#include "sysdep/archsetjmp.h"
L
Linus Torvalds 已提交
16

17 18
#include <linux/prefetch.h>

L
Linus Torvalds 已提交
19 20 21
struct mm_struct;

struct thread_struct {
J
Jeff Dike 已提交
22 23 24
	struct task_struct *saved_task;
	/*
	 * This flag is set to 1 before calling do_fork (and analyzed in
25 26
	 * copy_thread) to mark that we are begin called from userspace (fork /
	 * vfork / clone), and reset to 0 after. It is left to 0 when called
J
Jeff Dike 已提交
27 28 29
	 * from kernelspace (i.e. kernel_thread() or fork_idle(),
	 * as of 2.6.11).
	 */
L
Linus Torvalds 已提交
30 31 32 33
	int forking;
	struct pt_regs regs;
	int singlestep_syscall;
	void *fault_addr;
J
Jeff Dike 已提交
34
	jmp_buf *fault_catcher;
L
Linus Torvalds 已提交
35 36
	struct task_struct *prev_sched;
	unsigned long temp_stack;
J
Jeff Dike 已提交
37
	jmp_buf *exec_buf;
L
Linus Torvalds 已提交
38
	struct arch_thread arch;
39 40
	jmp_buf switch_buf;
	int mm_count;
L
Linus Torvalds 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
	struct {
		int op;
		union {
			struct {
				int pid;
			} fork, exec;
			struct {
				int (*proc)(void *);
				void *arg;
			} thread;
			struct {
				void (*proc)(void *);
				void *arg;
			} cb;
		} u;
	} request;
};

#define INIT_THREAD \
{ \
	.forking		= 0, \
J
Jeff Dike 已提交
62
	.regs		   	= EMPTY_REGS,	\
L
Linus Torvalds 已提交
63 64 65 66 67 68 69 70
	.fault_addr		= NULL, \
	.prev_sched		= NULL, \
	.temp_stack		= 0, \
	.exec_buf		= NULL, \
	.arch			= INIT_ARCH_THREAD, \
	.request		= { 0 } \
}

71 72 73 74
static inline void release_thread(struct task_struct *task)
{
}

L
Linus Torvalds 已提交
75
extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
76 77 78 79 80

static inline void prepare_to_copy(struct task_struct *tsk)
{
}

L
Linus Torvalds 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93

extern unsigned long thread_saved_pc(struct task_struct *t);

static inline void mm_copy_segments(struct mm_struct *from_mm,
				    struct mm_struct *new_mm)
{
}

#define init_stack	(init_thread_union.stack)

/*
 * User space process size: 3GB (default).
 */
J
Jeff Dike 已提交
94 95 96
extern unsigned long task_size;

#define TASK_SIZE (task_size)
L
Linus Torvalds 已提交
97

98 99 100 101 102 103 104 105 106
#undef STACK_TOP
#undef STACK_TOP_MAX

extern unsigned long stacksizelim;

#define STACK_ROOM	(stacksizelim)
#define STACK_TOP	(TASK_SIZE - 2 * PAGE_SIZE)
#define STACK_TOP_MAX	STACK_TOP

L
Linus Torvalds 已提交
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
/* This decides where the kernel will search for a free chunk of vm
 * space during mmap's.
 */
#define TASK_UNMAPPED_BASE	(0x40000000)

extern void start_thread(struct pt_regs *regs, unsigned long entry, 
			 unsigned long stack);

struct cpuinfo_um {
	unsigned long loops_per_jiffy;
	int ipi_pipe[2];
};

extern struct cpuinfo_um boot_cpu_data;

#define my_cpu_data		cpu_data[smp_processor_id()]

#ifdef CONFIG_SMP
extern struct cpuinfo_um cpu_data[];
#define current_cpu_data cpu_data[smp_processor_id()]
#else
#define cpu_data (&boot_cpu_data)
#define current_cpu_data boot_cpu_data
#endif


133
#define KSTK_REG(tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf)
J
Jeff Dike 已提交
134
extern unsigned long get_wchan(struct task_struct *p);
L
Linus Torvalds 已提交
135

136
#endif