blob: 7da0716fb317b0082c3b660a6a6665628bd8ac7f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SYSTEM_H
2#define __ASM_SYSTEM_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <asm/segment.h>
5#include <asm/cpufeature.h>
Jeff Dikea436ed92007-05-08 00:35:02 -07006#include <asm/cmpxchg.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8#ifdef __KERNEL__
Olaf Hering4f9a58d2007-10-16 23:30:12 -07009#define AT_VECTOR_SIZE_ARCH 2 /* entries in ARCH_DLINFO */
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11struct task_struct; /* one of the stranger aspects of C forward declarations.. */
12extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
13
Linus Torvalds47a5c6f2006-09-18 16:20:40 -070014/*
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 Torvalds1da177e2005-04-16 15:20:36 -070018#define switch_to(prev,next,last) do { \
19 unsigned long esi,edi; \
Linus Torvalds47a5c6f2006-09-18 16:20:40 -070020 asm volatile("pushfl\n\t" /* Save flags */ \
21 "pushl %%ebp\n\t" \
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 "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 Torvalds47a5c6f2006-09-18 16:20:40 -070029 "popfl" \
H. Peter Anvinfaca6222008-01-30 13:31:02 +010030 :"=m" (prev->thread.sp),"=m" (prev->thread.ip), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 "=a" (last),"=S" (esi),"=D" (edi) \
H. Peter Anvinfaca6222008-01-30 13:31:02 +010032 :"m" (next->thread.sp),"m" (next->thread.ip), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 "2" (prev), "d" (next)); \
34} while (0)
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#endif /* __KERNEL__ */
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Ingo Molnar55f327f2006-07-03 00:24:43 -070039#include <linux/irqflags.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/*
42 * disable hlt during certain critical i/o operations
43 */
44#define HAVE_DISABLE_HLT
Adrian Bunkcdb04522006-03-24 03:15:57 -080045
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#endif