Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SYSTEM_H |
| 2 | #define __ASM_SYSTEM_H |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | #include <asm/segment.h> |
| 5 | #include <asm/cpufeature.h> |
Jeff Dike | a436ed9 | 2007-05-08 00:35:02 -0700 | [diff] [blame] | 6 | #include <asm/cmpxchg.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
| 8 | #ifdef __KERNEL__ |
Olaf Hering | 4f9a58d | 2007-10-16 23:30:12 -0700 | [diff] [blame] | 9 | #define AT_VECTOR_SIZE_ARCH 2 /* entries in ARCH_DLINFO */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 11 | struct task_struct; /* one of the stranger aspects of C forward declarations.. */ |
| 12 | extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next)); |
| 13 | |
Linus Torvalds | 47a5c6f | 2006-09-18 16:20:40 -0700 | [diff] [blame] | 14 | /* |
| 15 | * Saving eflags is important. It switches not only IOPL between tasks, |
| 16 | * it also protects other tasks from NT leaking through sysenter etc. |
| 17 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #define switch_to(prev,next,last) do { \ |
| 19 | unsigned long esi,edi; \ |
Linus Torvalds | 47a5c6f | 2006-09-18 16:20:40 -0700 | [diff] [blame] | 20 | asm volatile("pushfl\n\t" /* Save flags */ \ |
| 21 | "pushl %%ebp\n\t" \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | "movl %%esp,%0\n\t" /* save ESP */ \ |
| 23 | "movl %5,%%esp\n\t" /* restore ESP */ \ |
| 24 | "movl $1f,%1\n\t" /* save EIP */ \ |
| 25 | "pushl %6\n\t" /* restore EIP */ \ |
| 26 | "jmp __switch_to\n" \ |
| 27 | "1:\t" \ |
| 28 | "popl %%ebp\n\t" \ |
Linus Torvalds | 47a5c6f | 2006-09-18 16:20:40 -0700 | [diff] [blame] | 29 | "popfl" \ |
H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 30 | :"=m" (prev->thread.sp),"=m" (prev->thread.ip), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | "=a" (last),"=S" (esi),"=D" (edi) \ |
H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 32 | :"m" (next->thread.sp),"m" (next->thread.ip), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | "2" (prev), "d" (next)); \ |
| 34 | } while (0) |
| 35 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #endif /* __KERNEL__ */ |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 39 | #include <linux/irqflags.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * disable hlt during certain critical i/o operations |
| 43 | */ |
| 44 | #define HAVE_DISABLE_HLT |
Adrian Bunk | cdb0452 | 2006-03-24 03:15:57 -0800 | [diff] [blame] | 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #endif |