Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
/* thread_info.h: i386 low-level thread information
2
 *
3
 * Copyright (C) 2002  David Howells (dhowells@redhat.com)
4
 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
5
 */
6
 
7
#ifndef _ASM_THREAD_INFO_H
8
#define _ASM_THREAD_INFO_H
9
 
10
#ifdef __KERNEL__
11
 
12
#ifndef __ASSEMBLY__
13
#include <asm/processor.h>
14
#endif
15
 
16
/*
17
 * low level task data that entry.S needs immediate access to
18
 * - this struct should fit entirely inside of one cache line
19
 * - this struct shares the supervisor stack pages
20
 * - if the contents of this structure are changed, the assembly constants must also be changed
21
 */
22
#ifndef __ASSEMBLY__
23
 
24
struct thread_info {
25
        struct task_struct      *task;          /* main task structure */
26
        struct exec_domain      *exec_domain;   /* execution domain */
27
        unsigned long           flags;          /* low level flags */
28
        unsigned long           status;         /* thread-synchronous flags */
29
        __u32                   cpu;            /* current CPU */
30
        __s32                   preempt_count; /* 0 => preemptable, <0 => BUG */
31
 
32
        mm_segment_t            addr_limit;     /* thread address space:
33
                                                   0-0xBFFFFFFF for user-thead
34
                                                   0-0xFFFFFFFF for kernel-thread
35
                                                */
36
        struct restart_block    restart_block;
37
 
38
        __u8                    supervisor_stack[0];
39
};
40
 
41
#else /* !__ASSEMBLY__ */
42
 
43
/* offsets into the thread_info struct for assembly code access */
44
#define TI_TASK         0x00000000
45
#define TI_EXEC_DOMAIN  0x00000004
46
#define TI_FLAGS        0x00000008
47
#define TI_STATUS       0x0000000C
48
#define TI_CPU          0x00000010
49
#define TI_PRE_COUNT    0x00000014
50
#define TI_ADDR_LIMIT   0x00000018
51
#define TI_RESTART_BLOCK 0x000001C
52
 
53
#endif
54
 
55
#define PREEMPT_ACTIVE          0x4000000
56
 
57
/*
58
 * macros/functions for gaining access to the thread information structure
59
 *
60
 * preempt_count needs to be 1 initially, until the scheduler is functional.
61
 */
62
#ifndef __ASSEMBLY__
63
 
64
#define INIT_THREAD_INFO(tsk)                   \
65
{                                               \
66
        .task           = &tsk,                 \
67
        .exec_domain    = &default_exec_domain, \
68
        .flags          = 0,                    \
69
        .cpu            = 0,                    \
70
        .preempt_count  = 1,                    \
71
        .addr_limit     = KERNEL_DS,            \
72
        .restart_block = {                      \
73
                .fn = do_no_restart_syscall,    \
74
        },                                      \
75
}
76
 
77
#define init_thread_info        (init_thread_union.thread_info)
78
#define init_stack              (init_thread_union.stack)
79
 
80
/* how to get the thread information struct from C */
81
static inline struct thread_info *current_thread_info(void)
82
{
83
        struct thread_info *ti;
84
        __asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~8191UL));
85
        return ti;
86
}
87
 
88
/* thread information allocation */
89
#define THREAD_SIZE (2*PAGE_SIZE)
90
#define alloc_thread_info(task) ((struct thread_info *)kmalloc(THREAD_SIZE, GFP_KERNEL))
91
#define free_thread_info(info)  kfree(info)
92
#define get_thread_info(ti) get_task_struct((ti)->task)
93
#define put_thread_info(ti) put_task_struct((ti)->task)
94
 
95
#else /* !__ASSEMBLY__ */
96
 
97
/* how to get the thread information struct from ASM */
98
#define GET_THREAD_INFO(reg) \
99
        movl $-8192, reg; \
100
        andl %esp, reg
101
 
102
#endif
103
 
104
/*
105
 * thread information flags
106
 * - these are process state flags that various assembly files may need to access
107
 * - pending work-to-be-done flags are in LSW
108
 * - other flags in MSW
109
 */
110
#define TIF_SYSCALL_TRACE       0       /* syscall trace active */
111
#define TIF_NOTIFY_RESUME       1       /* resumption notification requested */
112
#define TIF_SIGPENDING          2       /* signal pending */
113
#define TIF_NEED_RESCHED        3       /* rescheduling necessary */
114
#define TIF_SINGLESTEP          4       /* restore singlestep on return to user mode */
115
#define TIF_IRET                5       /* return with iret */
116
#define TIF_POLLING_NRFLAG      16      /* true if poll_idle() is polling TIF_NEED_RESCHED */
117
 
118
#define _TIF_SYSCALL_TRACE      (1<<TIF_SYSCALL_TRACE)
119
#define _TIF_NOTIFY_RESUME      (1<<TIF_NOTIFY_RESUME)
120
#define _TIF_SIGPENDING         (1<<TIF_SIGPENDING)
121
#define _TIF_NEED_RESCHED       (1<<TIF_NEED_RESCHED)
122
#define _TIF_SINGLESTEP         (1<<TIF_SINGLESTEP)
123
#define _TIF_IRET               (1<<TIF_IRET)
124
#define _TIF_POLLING_NRFLAG     (1<<TIF_POLLING_NRFLAG)
125
 
126
#define _TIF_WORK_MASK          0x0000FFFE      /* work to do on interrupt/exception return */
127
#define _TIF_ALLWORK_MASK       0x0000FFFF      /* work to do on any return to u-space */
128
 
129
/*
130
 * Thread-synchronous status.
131
 *
132
 * This is different from the flags in that nobody else
133
 * ever touches our thread-synchronous status, so we don't
134
 * have to worry about atomic accesses.
135
 */
136
#define TS_USEDFPU              0x0001  /* FPU was used by this task this quantum (SMP) */
137
 
138
#endif /* __KERNEL__ */
139
 
140
#endif /* _ASM_THREAD_INFO_H */