2 * include/asm-i386/processor.h
4 * Copyright (C) 1994 Linus Torvalds
7 #ifndef __ASM_I386_PROCESSOR_H
8 #define __ASM_I386_PROCESSOR_H
11 #include <asm/math_emu.h>
12 #include <asm/segment.h>
16 * CPU type and hardware bug flags. Kept separately for each CPU.
17 * Members of this structure are referenced in head.S, so think twice
18 * before touching them. [mj]
22 __u8 x86
; /* CPU family */
23 __u8 x86_vendor
; /* CPU vendor */
26 char wp_works_ok
; /* It doesn't on 386's */
27 char hlt_works_ok
; /* Problems on some 486Dx4's and old 386's */
30 int cpuid_level
; /* Maximum supported CPUID level, -1=no CPUID */
32 char x86_vendor_id
[16];
33 char x86_model_id
[64];
36 unsigned long loops_per_sec
;
37 unsigned long *pgd_quick
;
38 unsigned long *pte_quick
;
39 unsigned long pgtable_cache_sz
;
42 #define X86_VENDOR_INTEL 0
43 #define X86_VENDOR_CYRIX 1
44 #define X86_VENDOR_AMD 2
45 #define X86_VENDOR_UMC 3
46 #define X86_VENDOR_NEXGEN 4
47 #define X86_VENDOR_CENTAUR 5
48 #define X86_VENDOR_UNKNOWN 0xff
51 * capabilities of CPUs
54 #define X86_FEATURE_FPU 0x00000001 /* onboard FPU */
55 #define X86_FEATURE_VME 0x00000002 /* Virtual Mode Extensions */
56 #define X86_FEATURE_DE 0x00000004 /* Debugging Extensions */
57 #define X86_FEATURE_PSE 0x00000008 /* Page Size Extensions */
58 #define X86_FEATURE_TSC 0x00000010 /* Time Stamp Counter */
59 #define X86_FEATURE_MSR 0x00000020 /* Model-Specific Registers, RDMSR, WRMSR */
60 #define X86_FEATURE_PAE 0x00000040 /* Physical Address Extensions */
61 #define X86_FEATURE_MCE 0x00000080 /* Machine Check Exceptions */
62 #define X86_FEATURE_CX8 0x00000100 /* CMPXCHG8 instruction */
63 #define X86_FEATURE_APIC 0x00000200 /* onboard APIC */
64 #define X86_FEATURE_10 0x00000400
65 #define X86_FEATURE_SEP 0x00000800 /* Fast System Call */
66 #define X86_FEATURE_MTRR 0x00001000 /* Memory Type Range Registers */
67 #define X86_FEATURE_PGE 0x00002000 /* Page Global Enable */
68 #define X86_FEATURE_MCA 0x00004000 /* Machine Check Architecture */
69 #define X86_FEATURE_CMOV 0x00008000 /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
70 #define X86_FEATURE_PAT 0x00010000 /* Page Attribute Table */
71 #define X86_FEATURE_PSE36 0x00020000 /* 36-bit PSEs */
72 #define X86_FEATURE_18 0x00040000
73 #define X86_FEATURE_19 0x00080000
74 #define X86_FEATURE_20 0x00100000
75 #define X86_FEATURE_21 0x00200000
76 #define X86_FEATURE_22 0x00400000
77 #define X86_FEATURE_MMX 0x00800000 /* multimedia extensions */
78 #define X86_FEATURE_FXSR 0x01000000 /* FXSAVE and FXRSTOR instructions (fast save and restore of FPU context), and CR4.OSFXSR (OS uses these instructions) available */
79 #define X86_FEATURE_25 0x02000000
80 #define X86_FEATURE_26 0x04000000
81 #define X86_FEATURE_27 0x08000000
82 #define X86_FEATURE_28 0x10000000
83 #define X86_FEATURE_29 0x20000000
84 #define X86_FEATURE_30 0x40000000
85 #define X86_FEATURE_AMD3D 0x80000000
87 extern struct cpuinfo_x86 boot_cpu_data
;
90 extern struct cpuinfo_x86 cpu_data
[];
91 #define current_cpu_data cpu_data[smp_processor_id()]
93 #define cpu_data &boot_cpu_data
94 #define current_cpu_data boot_cpu_data
97 extern char ignore_irq13
;
99 extern void identify_cpu(struct cpuinfo_x86
*);
100 extern void print_cpu_info(struct cpuinfo_x86
*);
103 * Generic CPUID function
105 extern inline void cpuid(int op
, int *eax
, int *ebx
, int *ecx
, int *edx
)
117 * Cyrix CPU configuration register indexes
119 #define CX86_CCR2 0xc2
120 #define CX86_CCR3 0xc3
121 #define CX86_CCR4 0xe8
122 #define CX86_CCR5 0xe9
123 #define CX86_DIR0 0xfe
124 #define CX86_DIR1 0xff
127 * Cyrix CPU indexed register access macros
130 #define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
132 #define setCx86(reg, data) do { \
134 outb((data), 0x23); \
138 * Bus types (default is ISA, but people can check others with these..)
143 /* from system description table in BIOS. Mostly for MCA use, but
144 others may find it useful. */
145 extern unsigned int machine_id
;
146 extern unsigned int machine_submodel_id
;
147 extern unsigned int BIOS_revision
;
150 * User space process size: 3GB (default).
152 #define TASK_SIZE (PAGE_OFFSET)
154 /* This decides where the kernel will search for a free chunk of vm
155 * space during mmap's.
157 #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
160 * Size of io_bitmap in longwords: 32 is ports 0-0x3ff.
162 #define IO_BITMAP_SIZE 32
164 struct i387_hard_struct
{
172 long st_space
[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
173 long status
; /* software status information */
176 struct i387_soft_struct
{
184 long st_space
[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
185 unsigned char ftop
, changed
, lookahead
, no_update
, rm
, alimit
;
187 unsigned long entry_eip
;
191 struct i387_hard_struct hard
;
192 struct i387_soft_struct soft
;
199 struct thread_struct
{
200 unsigned short back_link
,__blh
;
202 unsigned short ss0
,__ss0h
;
204 unsigned short ss1
,__ss1h
;
206 unsigned short ss2
,__ss2h
;
209 unsigned long eflags
;
210 unsigned long eax
,ecx
,edx
,ebx
;
215 unsigned short es
, __esh
;
216 unsigned short cs
, __csh
;
217 unsigned short ss
, __ssh
;
218 unsigned short ds
, __dsh
;
219 unsigned short fs
, __fsh
;
220 unsigned short gs
, __gsh
;
221 unsigned short ldt
, __ldth
;
222 unsigned short trace
, bitmap
;
223 unsigned long io_bitmap
[IO_BITMAP_SIZE
+1];
225 unsigned long cr2
, trap_no
, error_code
;
226 mm_segment_t segment
;
227 /* debug registers */
228 long debugreg
[8]; /* Hardware debugging registers */
229 /* floating point info */
230 union i387_union i387
;
231 /* virtual 86 mode info */
232 struct vm86_struct
* vm86_info
;
233 unsigned long screen_bitmap
;
234 unsigned long v86flags
, v86mask
, v86mode
, saved_esp0
;
238 { &init_mm, 0, 0, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, NULL, &init_mm.mmap }
241 0,0, /* back_link, __blh */ \
242 sizeof(init_stack) + (long) &init_stack, /* esp0 */ \
243 __KERNEL_DS, 0, /* ss0 */ \
244 0,0,0,0,0,0, /* stack1, stack2 */ \
245 (long) &swapper_pg_dir - PAGE_OFFSET, /* cr3 */ \
246 0,0, /* eip,eflags */ \
247 0,0,0,0, /* eax,ecx,edx,ebx */ \
248 0,0,0,0, /* esp,ebp,esi,edi */ \
249 0,0,0,0,0,0, /* es,cs,ss */ \
250 0,0,0,0,0,0, /* ds,fs,gs */ \
251 _LDT(0),0, /* ldt */ \
252 0, 0x8000, /* tace, bitmap */ \
253 {~0, }, /* ioperm */ \
254 _TSS(0), 0, 0, 0, (mm_segment_t) { 0 }, /* obsolete */ \
256 { { 0, }, }, /* 387 state */ \
257 NULL, 0, 0, 0, 0, 0, /* vm86_info */ \
260 #define start_thread(regs, new_eip, new_esp) do { \
261 __asm__("movl %w0,%%fs ; movl %w0,%%gs": :"r" (0)); \
263 regs->xds = __USER_DS; \
264 regs->xes = __USER_DS; \
265 regs->xss = __USER_DS; \
266 regs->xcs = __USER_CS; \
267 regs->eip = new_eip; \
268 regs->esp = new_esp; \
271 /* Forward declaration, a strange C thing */
274 /* Free all resources held by a thread. */
275 extern void release_thread(struct task_struct
*);
277 /* Copy and release all segment info associated with a VM */
278 extern void copy_segments(int nr
, struct task_struct
*p
, struct mm_struct
* mm
);
279 extern void release_segments(struct mm_struct
* mm
);
282 * Return saved PC of a blocked thread.
284 extern inline unsigned long thread_saved_pc(struct thread_struct
*t
)
286 return ((unsigned long *)t
->esp
)[3];
289 extern struct task_struct
* alloc_task_struct(void);
290 extern void free_task_struct(struct task_struct
*);
292 #define init_task (init_task_union.task)
293 #define init_stack (init_task_union.stack)
295 #endif /* __ASM_I386_PROCESSOR_H */