| 1 |
1275 |
phoenix |
/*
|
| 2 |
|
|
* include/asm-i386/processor.h
|
| 3 |
|
|
*
|
| 4 |
|
|
* Copyright (C) 1994 Linus Torvalds
|
| 5 |
|
|
*/
|
| 6 |
|
|
|
| 7 |
|
|
#ifndef __ASM_I386_PROCESSOR_H
|
| 8 |
|
|
#define __ASM_I386_PROCESSOR_H
|
| 9 |
|
|
|
| 10 |
|
|
#include <asm/vm86.h>
|
| 11 |
|
|
#include <asm/math_emu.h>
|
| 12 |
|
|
#include <asm/segment.h>
|
| 13 |
|
|
#include <asm/page.h>
|
| 14 |
|
|
#include <asm/types.h>
|
| 15 |
|
|
#include <asm/sigcontext.h>
|
| 16 |
|
|
#include <asm/cpufeature.h>
|
| 17 |
|
|
#include <linux/cache.h>
|
| 18 |
|
|
#include <linux/config.h>
|
| 19 |
|
|
#include <linux/threads.h>
|
| 20 |
|
|
|
| 21 |
|
|
/*
|
| 22 |
|
|
* Default implementation of macro that returns current
|
| 23 |
|
|
* instruction pointer ("program counter").
|
| 24 |
|
|
*/
|
| 25 |
|
|
#define current_text_addr() ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
|
| 26 |
|
|
|
| 27 |
|
|
/*
|
| 28 |
|
|
* CPU type and hardware bug flags. Kept separately for each CPU.
|
| 29 |
|
|
* Members of this structure are referenced in head.S, so think twice
|
| 30 |
|
|
* before touching them. [mj]
|
| 31 |
|
|
*/
|
| 32 |
|
|
|
| 33 |
|
|
struct cpuinfo_x86 {
|
| 34 |
|
|
__u8 x86; /* CPU family */
|
| 35 |
|
|
__u8 x86_vendor; /* CPU vendor */
|
| 36 |
|
|
__u8 x86_model;
|
| 37 |
|
|
__u8 x86_mask;
|
| 38 |
|
|
char wp_works_ok; /* It doesn't on 386's */
|
| 39 |
|
|
char hlt_works_ok; /* Problems on some 486Dx4's and old 386's */
|
| 40 |
|
|
char hard_math;
|
| 41 |
|
|
char rfu;
|
| 42 |
|
|
int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */
|
| 43 |
|
|
__u32 x86_capability[NCAPINTS];
|
| 44 |
|
|
char x86_vendor_id[16];
|
| 45 |
|
|
char x86_model_id[64];
|
| 46 |
|
|
int x86_cache_size; /* in KB - valid for CPUS which support this
|
| 47 |
|
|
call */
|
| 48 |
|
|
int fdiv_bug;
|
| 49 |
|
|
int f00f_bug;
|
| 50 |
|
|
int coma_bug;
|
| 51 |
|
|
unsigned long loops_per_jiffy;
|
| 52 |
|
|
unsigned long *pgd_quick;
|
| 53 |
|
|
unsigned long *pmd_quick;
|
| 54 |
|
|
unsigned long *pte_quick;
|
| 55 |
|
|
unsigned long pgtable_cache_sz;
|
| 56 |
|
|
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
|
| 57 |
|
|
|
| 58 |
|
|
#define X86_VENDOR_INTEL 0
|
| 59 |
|
|
#define X86_VENDOR_CYRIX 1
|
| 60 |
|
|
#define X86_VENDOR_AMD 2
|
| 61 |
|
|
#define X86_VENDOR_UMC 3
|
| 62 |
|
|
#define X86_VENDOR_NEXGEN 4
|
| 63 |
|
|
#define X86_VENDOR_CENTAUR 5
|
| 64 |
|
|
#define X86_VENDOR_RISE 6
|
| 65 |
|
|
#define X86_VENDOR_TRANSMETA 7
|
| 66 |
|
|
#define X86_VENDOR_NSC 8
|
| 67 |
|
|
#define X86_VENDOR_SIS 9
|
| 68 |
|
|
#define X86_VENDOR_UNKNOWN 0xff
|
| 69 |
|
|
|
| 70 |
|
|
/*
|
| 71 |
|
|
* capabilities of CPUs
|
| 72 |
|
|
*/
|
| 73 |
|
|
|
| 74 |
|
|
extern struct cpuinfo_x86 boot_cpu_data;
|
| 75 |
|
|
extern struct tss_struct init_tss[NR_CPUS];
|
| 76 |
|
|
|
| 77 |
|
|
#ifdef CONFIG_SMP
|
| 78 |
|
|
extern struct cpuinfo_x86 cpu_data[];
|
| 79 |
|
|
#define current_cpu_data cpu_data[smp_processor_id()]
|
| 80 |
|
|
#else
|
| 81 |
|
|
#define cpu_data (&boot_cpu_data)
|
| 82 |
|
|
#define current_cpu_data boot_cpu_data
|
| 83 |
|
|
#endif
|
| 84 |
|
|
|
| 85 |
|
|
extern char ignore_irq13;
|
| 86 |
|
|
|
| 87 |
|
|
extern void identify_cpu(struct cpuinfo_x86 *);
|
| 88 |
|
|
extern void print_cpu_info(struct cpuinfo_x86 *);
|
| 89 |
|
|
extern void dodgy_tsc(void);
|
| 90 |
|
|
|
| 91 |
|
|
/*
|
| 92 |
|
|
* EFLAGS bits
|
| 93 |
|
|
*/
|
| 94 |
|
|
#define X86_EFLAGS_CF 0x00000001 /* Carry Flag */
|
| 95 |
|
|
#define X86_EFLAGS_PF 0x00000004 /* Parity Flag */
|
| 96 |
|
|
#define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */
|
| 97 |
|
|
#define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
|
| 98 |
|
|
#define X86_EFLAGS_SF 0x00000080 /* Sign Flag */
|
| 99 |
|
|
#define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
|
| 100 |
|
|
#define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */
|
| 101 |
|
|
#define X86_EFLAGS_DF 0x00000400 /* Direction Flag */
|
| 102 |
|
|
#define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */
|
| 103 |
|
|
#define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */
|
| 104 |
|
|
#define X86_EFLAGS_NT 0x00004000 /* Nested Task */
|
| 105 |
|
|
#define X86_EFLAGS_RF 0x00010000 /* Resume Flag */
|
| 106 |
|
|
#define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */
|
| 107 |
|
|
#define X86_EFLAGS_AC 0x00040000 /* Alignment Check */
|
| 108 |
|
|
#define X86_EFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */
|
| 109 |
|
|
#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
|
| 110 |
|
|
#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
|
| 111 |
|
|
|
| 112 |
|
|
/*
|
| 113 |
|
|
* Generic CPUID function
|
| 114 |
|
|
*/
|
| 115 |
|
|
static inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx)
|
| 116 |
|
|
{
|
| 117 |
|
|
__asm__("cpuid"
|
| 118 |
|
|
: "=a" (*eax),
|
| 119 |
|
|
"=b" (*ebx),
|
| 120 |
|
|
"=c" (*ecx),
|
| 121 |
|
|
"=d" (*edx)
|
| 122 |
|
|
: "0" (op));
|
| 123 |
|
|
}
|
| 124 |
|
|
|
| 125 |
|
|
/*
|
| 126 |
|
|
* CPUID functions returning a single datum
|
| 127 |
|
|
*/
|
| 128 |
|
|
static inline unsigned int cpuid_eax(unsigned int op)
|
| 129 |
|
|
{
|
| 130 |
|
|
unsigned int eax;
|
| 131 |
|
|
|
| 132 |
|
|
__asm__("cpuid"
|
| 133 |
|
|
: "=a" (eax)
|
| 134 |
|
|
: "0" (op)
|
| 135 |
|
|
: "bx", "cx", "dx");
|
| 136 |
|
|
return eax;
|
| 137 |
|
|
}
|
| 138 |
|
|
static inline unsigned int cpuid_ebx(unsigned int op)
|
| 139 |
|
|
{
|
| 140 |
|
|
unsigned int eax, ebx;
|
| 141 |
|
|
|
| 142 |
|
|
__asm__("cpuid"
|
| 143 |
|
|
: "=a" (eax), "=b" (ebx)
|
| 144 |
|
|
: "0" (op)
|
| 145 |
|
|
: "cx", "dx" );
|
| 146 |
|
|
return ebx;
|
| 147 |
|
|
}
|
| 148 |
|
|
static inline unsigned int cpuid_ecx(unsigned int op)
|
| 149 |
|
|
{
|
| 150 |
|
|
unsigned int eax, ecx;
|
| 151 |
|
|
|
| 152 |
|
|
__asm__("cpuid"
|
| 153 |
|
|
: "=a" (eax), "=c" (ecx)
|
| 154 |
|
|
: "0" (op)
|
| 155 |
|
|
: "bx", "dx" );
|
| 156 |
|
|
return ecx;
|
| 157 |
|
|
}
|
| 158 |
|
|
static inline unsigned int cpuid_edx(unsigned int op)
|
| 159 |
|
|
{
|
| 160 |
|
|
unsigned int eax, edx;
|
| 161 |
|
|
|
| 162 |
|
|
__asm__("cpuid"
|
| 163 |
|
|
: "=a" (eax), "=d" (edx)
|
| 164 |
|
|
: "0" (op)
|
| 165 |
|
|
: "bx", "cx");
|
| 166 |
|
|
return edx;
|
| 167 |
|
|
}
|
| 168 |
|
|
|
| 169 |
|
|
/*
|
| 170 |
|
|
* Intel CPU features in CR4
|
| 171 |
|
|
*/
|
| 172 |
|
|
#define X86_CR4_VME 0x0001 /* enable vm86 extensions */
|
| 173 |
|
|
#define X86_CR4_PVI 0x0002 /* virtual interrupts flag enable */
|
| 174 |
|
|
#define X86_CR4_TSD 0x0004 /* disable time stamp at ipl 3 */
|
| 175 |
|
|
#define X86_CR4_DE 0x0008 /* enable debugging extensions */
|
| 176 |
|
|
#define X86_CR4_PSE 0x0010 /* enable page size extensions */
|
| 177 |
|
|
#define X86_CR4_PAE 0x0020 /* enable physical address extensions */
|
| 178 |
|
|
#define X86_CR4_MCE 0x0040 /* Machine check enable */
|
| 179 |
|
|
#define X86_CR4_PGE 0x0080 /* enable global pages */
|
| 180 |
|
|
#define X86_CR4_PCE 0x0100 /* enable performance counters at ipl 3 */
|
| 181 |
|
|
#define X86_CR4_OSFXSR 0x0200 /* enable fast FPU save and restore */
|
| 182 |
|
|
#define X86_CR4_OSXMMEXCPT 0x0400 /* enable unmasked SSE exceptions */
|
| 183 |
|
|
|
| 184 |
|
|
#define load_cr3(pgdir) \
|
| 185 |
|
|
asm volatile("movl %0,%%cr3": :"r" (__pa(pgdir)));
|
| 186 |
|
|
|
| 187 |
|
|
/*
|
| 188 |
|
|
* Save the cr4 feature set we're using (ie
|
| 189 |
|
|
* Pentium 4MB enable and PPro Global page
|
| 190 |
|
|
* enable), so that any CPU's that boot up
|
| 191 |
|
|
* after us can get the correct flags.
|
| 192 |
|
|
*/
|
| 193 |
|
|
extern unsigned long mmu_cr4_features;
|
| 194 |
|
|
|
| 195 |
|
|
static inline void set_in_cr4 (unsigned long mask)
|
| 196 |
|
|
{
|
| 197 |
|
|
mmu_cr4_features |= mask;
|
| 198 |
|
|
__asm__("movl %%cr4,%%eax\n\t"
|
| 199 |
|
|
"orl %0,%%eax\n\t"
|
| 200 |
|
|
"movl %%eax,%%cr4\n"
|
| 201 |
|
|
: : "irg" (mask)
|
| 202 |
|
|
:"ax");
|
| 203 |
|
|
}
|
| 204 |
|
|
|
| 205 |
|
|
static inline void clear_in_cr4 (unsigned long mask)
|
| 206 |
|
|
{
|
| 207 |
|
|
mmu_cr4_features &= ~mask;
|
| 208 |
|
|
__asm__("movl %%cr4,%%eax\n\t"
|
| 209 |
|
|
"andl %0,%%eax\n\t"
|
| 210 |
|
|
"movl %%eax,%%cr4\n"
|
| 211 |
|
|
: : "irg" (~mask)
|
| 212 |
|
|
:"ax");
|
| 213 |
|
|
}
|
| 214 |
|
|
|
| 215 |
|
|
/*
|
| 216 |
|
|
* Cyrix CPU configuration register indexes
|
| 217 |
|
|
*/
|
| 218 |
|
|
#define CX86_CCR0 0xc0
|
| 219 |
|
|
#define CX86_CCR1 0xc1
|
| 220 |
|
|
#define CX86_CCR2 0xc2
|
| 221 |
|
|
#define CX86_CCR3 0xc3
|
| 222 |
|
|
#define CX86_CCR4 0xe8
|
| 223 |
|
|
#define CX86_CCR5 0xe9
|
| 224 |
|
|
#define CX86_CCR6 0xea
|
| 225 |
|
|
#define CX86_CCR7 0xeb
|
| 226 |
|
|
#define CX86_DIR0 0xfe
|
| 227 |
|
|
#define CX86_DIR1 0xff
|
| 228 |
|
|
#define CX86_ARR_BASE 0xc4
|
| 229 |
|
|
#define CX86_RCR_BASE 0xdc
|
| 230 |
|
|
|
| 231 |
|
|
/*
|
| 232 |
|
|
* Cyrix CPU indexed register access macros
|
| 233 |
|
|
*/
|
| 234 |
|
|
|
| 235 |
|
|
#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
|
| 236 |
|
|
|
| 237 |
|
|
#define setCx86(reg, data) do { \
|
| 238 |
|
|
outb((reg), 0x22); \
|
| 239 |
|
|
outb((data), 0x23); \
|
| 240 |
|
|
} while (0)
|
| 241 |
|
|
|
| 242 |
|
|
/*
|
| 243 |
|
|
* Bus types (default is ISA, but people can check others with these..)
|
| 244 |
|
|
*/
|
| 245 |
|
|
#ifdef CONFIG_EISA
|
| 246 |
|
|
extern int EISA_bus;
|
| 247 |
|
|
#else
|
| 248 |
|
|
#define EISA_bus (0)
|
| 249 |
|
|
#endif
|
| 250 |
|
|
extern int MCA_bus;
|
| 251 |
|
|
|
| 252 |
|
|
/* from system description table in BIOS. Mostly for MCA use, but
|
| 253 |
|
|
others may find it useful. */
|
| 254 |
|
|
extern unsigned int machine_id;
|
| 255 |
|
|
extern unsigned int machine_submodel_id;
|
| 256 |
|
|
extern unsigned int BIOS_revision;
|
| 257 |
|
|
extern unsigned int mca_pentium_flag;
|
| 258 |
|
|
|
| 259 |
|
|
/*
|
| 260 |
|
|
* User space process size: 3GB (default).
|
| 261 |
|
|
*/
|
| 262 |
|
|
#define TASK_SIZE (PAGE_OFFSET)
|
| 263 |
|
|
|
| 264 |
|
|
/* This decides where the kernel will search for a free chunk of vm
|
| 265 |
|
|
* space during mmap's.
|
| 266 |
|
|
*/
|
| 267 |
|
|
#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
|
| 268 |
|
|
|
| 269 |
|
|
/*
|
| 270 |
|
|
* Size of io_bitmap in longwords: 32 is ports 0-0x3ff.
|
| 271 |
|
|
*/
|
| 272 |
|
|
#define IO_BITMAP_SIZE 32
|
| 273 |
|
|
#define IO_BITMAP_BYTES (IO_BITMAP_SIZE * 4)
|
| 274 |
|
|
#define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
|
| 275 |
|
|
#define INVALID_IO_BITMAP_OFFSET 0x8000
|
| 276 |
|
|
|
| 277 |
|
|
struct i387_fsave_struct {
|
| 278 |
|
|
long cwd;
|
| 279 |
|
|
long swd;
|
| 280 |
|
|
long twd;
|
| 281 |
|
|
long fip;
|
| 282 |
|
|
long fcs;
|
| 283 |
|
|
long foo;
|
| 284 |
|
|
long fos;
|
| 285 |
|
|
long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
|
| 286 |
|
|
long status; /* software status information */
|
| 287 |
|
|
};
|
| 288 |
|
|
|
| 289 |
|
|
struct i387_fxsave_struct {
|
| 290 |
|
|
unsigned short cwd;
|
| 291 |
|
|
unsigned short swd;
|
| 292 |
|
|
unsigned short twd;
|
| 293 |
|
|
unsigned short fop;
|
| 294 |
|
|
long fip;
|
| 295 |
|
|
long fcs;
|
| 296 |
|
|
long foo;
|
| 297 |
|
|
long fos;
|
| 298 |
|
|
long mxcsr;
|
| 299 |
|
|
long reserved;
|
| 300 |
|
|
long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
|
| 301 |
|
|
long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
|
| 302 |
|
|
long padding[56];
|
| 303 |
|
|
} __attribute__ ((aligned (16)));
|
| 304 |
|
|
|
| 305 |
|
|
struct i387_soft_struct {
|
| 306 |
|
|
long cwd;
|
| 307 |
|
|
long swd;
|
| 308 |
|
|
long twd;
|
| 309 |
|
|
long fip;
|
| 310 |
|
|
long fcs;
|
| 311 |
|
|
long foo;
|
| 312 |
|
|
long fos;
|
| 313 |
|
|
long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
|
| 314 |
|
|
unsigned char ftop, changed, lookahead, no_update, rm, alimit;
|
| 315 |
|
|
struct info *info;
|
| 316 |
|
|
unsigned long entry_eip;
|
| 317 |
|
|
};
|
| 318 |
|
|
|
| 319 |
|
|
union i387_union {
|
| 320 |
|
|
struct i387_fsave_struct fsave;
|
| 321 |
|
|
struct i387_fxsave_struct fxsave;
|
| 322 |
|
|
struct i387_soft_struct soft;
|
| 323 |
|
|
};
|
| 324 |
|
|
|
| 325 |
|
|
typedef struct {
|
| 326 |
|
|
unsigned long seg;
|
| 327 |
|
|
} mm_segment_t;
|
| 328 |
|
|
|
| 329 |
|
|
struct tss_struct {
|
| 330 |
|
|
unsigned short back_link,__blh;
|
| 331 |
|
|
unsigned long esp0;
|
| 332 |
|
|
unsigned short ss0,__ss0h;
|
| 333 |
|
|
unsigned long esp1;
|
| 334 |
|
|
unsigned short ss1,__ss1h;
|
| 335 |
|
|
unsigned long esp2;
|
| 336 |
|
|
unsigned short ss2,__ss2h;
|
| 337 |
|
|
unsigned long __cr3;
|
| 338 |
|
|
unsigned long eip;
|
| 339 |
|
|
unsigned long eflags;
|
| 340 |
|
|
unsigned long eax,ecx,edx,ebx;
|
| 341 |
|
|
unsigned long esp;
|
| 342 |
|
|
unsigned long ebp;
|
| 343 |
|
|
unsigned long esi;
|
| 344 |
|
|
unsigned long edi;
|
| 345 |
|
|
unsigned short es, __esh;
|
| 346 |
|
|
unsigned short cs, __csh;
|
| 347 |
|
|
unsigned short ss, __ssh;
|
| 348 |
|
|
unsigned short ds, __dsh;
|
| 349 |
|
|
unsigned short fs, __fsh;
|
| 350 |
|
|
unsigned short gs, __gsh;
|
| 351 |
|
|
unsigned short ldt, __ldth;
|
| 352 |
|
|
unsigned short trace, bitmap;
|
| 353 |
|
|
unsigned long io_bitmap[IO_BITMAP_SIZE+1];
|
| 354 |
|
|
/*
|
| 355 |
|
|
* pads the TSS to be cacheline-aligned (size is 0x100)
|
| 356 |
|
|
*/
|
| 357 |
|
|
unsigned long __cacheline_filler[5];
|
| 358 |
|
|
};
|
| 359 |
|
|
|
| 360 |
|
|
struct thread_struct {
|
| 361 |
|
|
unsigned long esp0;
|
| 362 |
|
|
unsigned long eip;
|
| 363 |
|
|
unsigned long esp;
|
| 364 |
|
|
unsigned long fs;
|
| 365 |
|
|
unsigned long gs;
|
| 366 |
|
|
/* Hardware debugging registers */
|
| 367 |
|
|
unsigned long debugreg[8]; /* %%db0-7 debug registers */
|
| 368 |
|
|
/* fault info */
|
| 369 |
|
|
unsigned long cr2, trap_no, error_code;
|
| 370 |
|
|
/* floating point info */
|
| 371 |
|
|
union i387_union i387;
|
| 372 |
|
|
/* virtual 86 mode info */
|
| 373 |
|
|
struct vm86_struct * vm86_info;
|
| 374 |
|
|
unsigned long screen_bitmap;
|
| 375 |
|
|
unsigned long v86flags, v86mask, saved_esp0;
|
| 376 |
|
|
/* IO permissions */
|
| 377 |
|
|
int ioperm;
|
| 378 |
|
|
unsigned long io_bitmap[IO_BITMAP_SIZE+1];
|
| 379 |
|
|
};
|
| 380 |
|
|
|
| 381 |
|
|
#define INIT_THREAD { \
|
| 382 |
|
|
0, \
|
| 383 |
|
|
0, 0, 0, 0, \
|
| 384 |
|
|
{ [0 ... 7] = 0 }, /* debugging registers */ \
|
| 385 |
|
|
0, 0, 0, \
|
| 386 |
|
|
{ { 0, }, }, /* 387 state */ \
|
| 387 |
|
|
0,0,0,0,0, \
|
| 388 |
|
|
0,{~0,} /* io permissions */ \
|
| 389 |
|
|
}
|
| 390 |
|
|
|
| 391 |
|
|
#define INIT_TSS { \
|
| 392 |
|
|
0,0, /* back_link, __blh */ \
|
| 393 |
|
|
sizeof(init_stack) + (long) &init_stack, /* esp0 */ \
|
| 394 |
|
|
__KERNEL_DS, 0, /* ss0 */ \
|
| 395 |
|
|
0,0,0,0,0,0, /* stack1, stack2 */ \
|
| 396 |
|
|
0, /* cr3 */ \
|
| 397 |
|
|
0,0, /* eip,eflags */ \
|
| 398 |
|
|
0,0,0,0, /* eax,ecx,edx,ebx */ \
|
| 399 |
|
|
0,0,0,0, /* esp,ebp,esi,edi */ \
|
| 400 |
|
|
0,0,0,0,0,0, /* es,cs,ss */ \
|
| 401 |
|
|
0,0,0,0,0,0, /* ds,fs,gs */ \
|
| 402 |
|
|
__LDT(0),0, /* ldt */ \
|
| 403 |
|
|
0, INVALID_IO_BITMAP_OFFSET, /* tace, bitmap */ \
|
| 404 |
|
|
{~0, } /* ioperm */ \
|
| 405 |
|
|
}
|
| 406 |
|
|
|
| 407 |
|
|
#define start_thread(regs, new_eip, new_esp) do { \
|
| 408 |
|
|
__asm__("movl %0,%%fs ; movl %0,%%gs": :"r" (0)); \
|
| 409 |
|
|
set_fs(USER_DS); \
|
| 410 |
|
|
regs->xds = __USER_DS; \
|
| 411 |
|
|
regs->xes = __USER_DS; \
|
| 412 |
|
|
regs->xss = __USER_DS; \
|
| 413 |
|
|
regs->xcs = __USER_CS; \
|
| 414 |
|
|
regs->eip = new_eip; \
|
| 415 |
|
|
regs->esp = new_esp; \
|
| 416 |
|
|
} while (0)
|
| 417 |
|
|
|
| 418 |
|
|
/* Forward declaration, a strange C thing */
|
| 419 |
|
|
struct task_struct;
|
| 420 |
|
|
struct mm_struct;
|
| 421 |
|
|
|
| 422 |
|
|
/* Free all resources held by a thread. */
|
| 423 |
|
|
extern void release_thread(struct task_struct *);
|
| 424 |
|
|
/*
|
| 425 |
|
|
* create a kernel thread without removing it from tasklists
|
| 426 |
|
|
*/
|
| 427 |
|
|
extern int arch_kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
|
| 428 |
|
|
|
| 429 |
|
|
/* Copy and release all segment info associated with a VM
|
| 430 |
|
|
* Unusable due to lack of error handling, use {init_new,destroy}_context
|
| 431 |
|
|
* instead.
|
| 432 |
|
|
*/
|
| 433 |
|
|
static inline void copy_segments(struct task_struct *p, struct mm_struct * mm) { }
|
| 434 |
|
|
static inline void release_segments(struct mm_struct * mm) { }
|
| 435 |
|
|
|
| 436 |
|
|
/*
|
| 437 |
|
|
* Return saved PC of a blocked thread.
|
| 438 |
|
|
*/
|
| 439 |
|
|
static inline unsigned long thread_saved_pc(struct thread_struct *t)
|
| 440 |
|
|
{
|
| 441 |
|
|
return ((unsigned long *)t->esp)[3];
|
| 442 |
|
|
}
|
| 443 |
|
|
|
| 444 |
|
|
unsigned long get_wchan(struct task_struct *p);
|
| 445 |
|
|
#define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1019])
|
| 446 |
|
|
#define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1022])
|
| 447 |
|
|
|
| 448 |
|
|
#define THREAD_SIZE (2*PAGE_SIZE)
|
| 449 |
|
|
#define alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
|
| 450 |
|
|
#define free_task_struct(p) free_pages((unsigned long) (p), 1)
|
| 451 |
|
|
#define get_task_struct(tsk) atomic_inc(&virt_to_page(tsk)->count)
|
| 452 |
|
|
|
| 453 |
|
|
#define init_task (init_task_union.task)
|
| 454 |
|
|
#define init_stack (init_task_union.stack)
|
| 455 |
|
|
|
| 456 |
|
|
struct microcode_header {
|
| 457 |
|
|
unsigned int hdrver;
|
| 458 |
|
|
unsigned int rev;
|
| 459 |
|
|
unsigned int date;
|
| 460 |
|
|
unsigned int sig;
|
| 461 |
|
|
unsigned int cksum;
|
| 462 |
|
|
unsigned int ldrver;
|
| 463 |
|
|
unsigned int pf;
|
| 464 |
|
|
unsigned int datasize;
|
| 465 |
|
|
unsigned int totalsize;
|
| 466 |
|
|
unsigned int reserved[3];
|
| 467 |
|
|
};
|
| 468 |
|
|
|
| 469 |
|
|
struct microcode {
|
| 470 |
|
|
struct microcode_header hdr;
|
| 471 |
|
|
unsigned int bits[0];
|
| 472 |
|
|
};
|
| 473 |
|
|
|
| 474 |
|
|
typedef struct microcode microcode_t;
|
| 475 |
|
|
typedef struct microcode_header microcode_header_t;
|
| 476 |
|
|
|
| 477 |
|
|
/* microcode format is extended from prescott processors */
|
| 478 |
|
|
struct extended_signature {
|
| 479 |
|
|
unsigned int sig;
|
| 480 |
|
|
unsigned int pf;
|
| 481 |
|
|
unsigned int cksum;
|
| 482 |
|
|
};
|
| 483 |
|
|
|
| 484 |
|
|
struct extended_sigtable {
|
| 485 |
|
|
unsigned int count;
|
| 486 |
|
|
unsigned int cksum;
|
| 487 |
|
|
unsigned int reserved[3];
|
| 488 |
|
|
struct extended_signature sigs[0];
|
| 489 |
|
|
};
|
| 490 |
|
|
/* '6' because it used to be for P6 only (but now covers Pentium 4 as well) */
|
| 491 |
|
|
#define MICROCODE_IOCFREE _IO('6',0)
|
| 492 |
|
|
|
| 493 |
|
|
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
|
| 494 |
|
|
static inline void rep_nop(void)
|
| 495 |
|
|
{
|
| 496 |
|
|
__asm__ __volatile__("rep;nop" ::: "memory");
|
| 497 |
|
|
}
|
| 498 |
|
|
|
| 499 |
|
|
#define cpu_relax() rep_nop()
|
| 500 |
|
|
|
| 501 |
|
|
/* Prefetch instructions for Pentium III and AMD Athlon */
|
| 502 |
|
|
#if defined(CONFIG_MPENTIUMIII) || defined (CONFIG_MPENTIUM4)
|
| 503 |
|
|
|
| 504 |
|
|
#define ARCH_HAS_PREFETCH
|
| 505 |
|
|
extern inline void prefetch(const void *x)
|
| 506 |
|
|
{
|
| 507 |
|
|
__asm__ __volatile__ ("prefetchnta (%0)" : : "r"(x));
|
| 508 |
|
|
}
|
| 509 |
|
|
|
| 510 |
|
|
#elif CONFIG_X86_USE_3DNOW
|
| 511 |
|
|
|
| 512 |
|
|
#define ARCH_HAS_PREFETCH
|
| 513 |
|
|
#define ARCH_HAS_PREFETCHW
|
| 514 |
|
|
#define ARCH_HAS_SPINLOCK_PREFETCH
|
| 515 |
|
|
|
| 516 |
|
|
extern inline void prefetch(const void *x)
|
| 517 |
|
|
{
|
| 518 |
|
|
__asm__ __volatile__ ("prefetch (%0)" : : "r"(x));
|
| 519 |
|
|
}
|
| 520 |
|
|
|
| 521 |
|
|
extern inline void prefetchw(const void *x)
|
| 522 |
|
|
{
|
| 523 |
|
|
__asm__ __volatile__ ("prefetchw (%0)" : : "r"(x));
|
| 524 |
|
|
}
|
| 525 |
|
|
#define spin_lock_prefetch(x) prefetchw(x)
|
| 526 |
|
|
|
| 527 |
|
|
#endif
|
| 528 |
|
|
|
| 529 |
|
|
#endif /* __ASM_I386_PROCESSOR_H */
|