diff options
Diffstat (limited to 'include/asm-i386/system.h')
-rw-r--r-- | include/asm-i386/system.h | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h index 3db717a244f0..acd5c26b69ba 100644 --- a/include/asm-i386/system.h +++ b/include/asm-i386/system.h | |||
@@ -14,8 +14,7 @@ extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struc | |||
14 | 14 | ||
15 | #define switch_to(prev,next,last) do { \ | 15 | #define switch_to(prev,next,last) do { \ |
16 | unsigned long esi,edi; \ | 16 | unsigned long esi,edi; \ |
17 | asm volatile("pushfl\n\t" \ | 17 | asm volatile("pushl %%ebp\n\t" \ |
18 | "pushl %%ebp\n\t" \ | ||
19 | "movl %%esp,%0\n\t" /* save ESP */ \ | 18 | "movl %%esp,%0\n\t" /* save ESP */ \ |
20 | "movl %5,%%esp\n\t" /* restore ESP */ \ | 19 | "movl %5,%%esp\n\t" /* restore ESP */ \ |
21 | "movl $1f,%1\n\t" /* save EIP */ \ | 20 | "movl $1f,%1\n\t" /* save EIP */ \ |
@@ -23,7 +22,6 @@ extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struc | |||
23 | "jmp __switch_to\n" \ | 22 | "jmp __switch_to\n" \ |
24 | "1:\t" \ | 23 | "1:\t" \ |
25 | "popl %%ebp\n\t" \ | 24 | "popl %%ebp\n\t" \ |
26 | "popfl" \ | ||
27 | :"=m" (prev->thread.esp),"=m" (prev->thread.eip), \ | 25 | :"=m" (prev->thread.esp),"=m" (prev->thread.eip), \ |
28 | "=a" (last),"=S" (esi),"=D" (edi) \ | 26 | "=a" (last),"=S" (esi),"=D" (edi) \ |
29 | :"m" (next->thread.esp),"m" (next->thread.eip), \ | 27 | :"m" (next->thread.esp),"m" (next->thread.eip), \ |
@@ -93,13 +91,13 @@ static inline unsigned long _get_base(char * addr) | |||
93 | ".align 4\n\t" \ | 91 | ".align 4\n\t" \ |
94 | ".long 1b,3b\n" \ | 92 | ".long 1b,3b\n" \ |
95 | ".previous" \ | 93 | ".previous" \ |
96 | : :"m" (value)) | 94 | : :"rm" (value)) |
97 | 95 | ||
98 | /* | 96 | /* |
99 | * Save a segment register away | 97 | * Save a segment register away |
100 | */ | 98 | */ |
101 | #define savesegment(seg, value) \ | 99 | #define savesegment(seg, value) \ |
102 | asm volatile("mov %%" #seg ",%0":"=m" (value)) | 100 | asm volatile("mov %%" #seg ",%0":"=rm" (value)) |
103 | 101 | ||
104 | /* | 102 | /* |
105 | * Clear and set 'TS' bit respectively | 103 | * Clear and set 'TS' bit respectively |
@@ -107,13 +105,33 @@ static inline unsigned long _get_base(char * addr) | |||
107 | #define clts() __asm__ __volatile__ ("clts") | 105 | #define clts() __asm__ __volatile__ ("clts") |
108 | #define read_cr0() ({ \ | 106 | #define read_cr0() ({ \ |
109 | unsigned int __dummy; \ | 107 | unsigned int __dummy; \ |
110 | __asm__( \ | 108 | __asm__ __volatile__( \ |
111 | "movl %%cr0,%0\n\t" \ | 109 | "movl %%cr0,%0\n\t" \ |
112 | :"=r" (__dummy)); \ | 110 | :"=r" (__dummy)); \ |
113 | __dummy; \ | 111 | __dummy; \ |
114 | }) | 112 | }) |
115 | #define write_cr0(x) \ | 113 | #define write_cr0(x) \ |
116 | __asm__("movl %0,%%cr0": :"r" (x)); | 114 | __asm__ __volatile__("movl %0,%%cr0": :"r" (x)); |
115 | |||
116 | #define read_cr2() ({ \ | ||
117 | unsigned int __dummy; \ | ||
118 | __asm__ __volatile__( \ | ||
119 | "movl %%cr2,%0\n\t" \ | ||
120 | :"=r" (__dummy)); \ | ||
121 | __dummy; \ | ||
122 | }) | ||
123 | #define write_cr2(x) \ | ||
124 | __asm__ __volatile__("movl %0,%%cr2": :"r" (x)); | ||
125 | |||
126 | #define read_cr3() ({ \ | ||
127 | unsigned int __dummy; \ | ||
128 | __asm__ ( \ | ||
129 | "movl %%cr3,%0\n\t" \ | ||
130 | :"=r" (__dummy)); \ | ||
131 | __dummy; \ | ||
132 | }) | ||
133 | #define write_cr3(x) \ | ||
134 | __asm__ __volatile__("movl %0,%%cr3": :"r" (x)); | ||
117 | 135 | ||
118 | #define read_cr4() ({ \ | 136 | #define read_cr4() ({ \ |
119 | unsigned int __dummy; \ | 137 | unsigned int __dummy; \ |
@@ -123,7 +141,7 @@ static inline unsigned long _get_base(char * addr) | |||
123 | __dummy; \ | 141 | __dummy; \ |
124 | }) | 142 | }) |
125 | #define write_cr4(x) \ | 143 | #define write_cr4(x) \ |
126 | __asm__("movl %0,%%cr4": :"r" (x)); | 144 | __asm__ __volatile__("movl %0,%%cr4": :"r" (x)); |
127 | #define stts() write_cr0(8 | read_cr0()) | 145 | #define stts() write_cr0(8 | read_cr0()) |
128 | 146 | ||
129 | #endif /* __KERNEL__ */ | 147 | #endif /* __KERNEL__ */ |
@@ -447,6 +465,8 @@ struct alt_instr { | |||
447 | #define local_irq_enable() __asm__ __volatile__("sti": : :"memory") | 465 | #define local_irq_enable() __asm__ __volatile__("sti": : :"memory") |
448 | /* used in the idle loop; sti takes one instruction cycle to complete */ | 466 | /* used in the idle loop; sti takes one instruction cycle to complete */ |
449 | #define safe_halt() __asm__ __volatile__("sti; hlt": : :"memory") | 467 | #define safe_halt() __asm__ __volatile__("sti; hlt": : :"memory") |
468 | /* used when interrupts are already enabled or to shutdown the processor */ | ||
469 | #define halt() __asm__ __volatile__("hlt": : :"memory") | ||
450 | 470 | ||
451 | #define irqs_disabled() \ | 471 | #define irqs_disabled() \ |
452 | ({ \ | 472 | ({ \ |