5 extern unsigned long long * idt
;
6 extern unsigned long long * gdt
;
8 #define move_to_user_mode() \
9 __asm__ ("movl %%esp,%%eax\n\t" \
16 "1:\tmovl $0x17,%%eax\n\t" \
17 "movw %%ax,%%ds\n\t" \
18 "movw %%ax,%%es\n\t" \
19 "movw %%ax,%%fs\n\t" \
27 #define cli() __asm__("cli\n\t")
28 #define sti() __asm__("sti\n\t")
29 #define nop() __asm__ ("nop"::)
31 #define iret() __asm__ ("iret"::)
37 #define _set_gate(gate_addr,type,dpl,addr) \
38 __asm__ ("movw %%dx, %%ax\n\t" \
40 "movl %%eax, %1\n\t" \
42 ::"i"((short)(0x8000 + (dpl << 13) + (type << 8))), \
43 "o"(*((char *)(gate_addr))), \
44 "o"(*(4 + (char *)(gate_addr))), \
45 "d"((char *)(addr)), "a"(0x00080000))
47 #define set_intr_gate(n,addr) \
48 _set_gate(&idt[n],14,0,addr)
50 #define set_trap_gate(n,addr) \
51 _set_gate(&idt[n],15,0,addr)
53 #define set_system_gate(n,addr) \
54 _set_gate(&idt[n],15,3,addr)
57 #define _set_tssldt_desc(n,addr,type) \
58 __asm__ ("movw $104,%1\n\t" \
60 "rorl $16,%%eax\n\t" \
62 "movb $" type ",%4\n\t" \
66 ::"a" (addr), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), \
67 "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) \
70 #define set_tss_desc(n,addr) _set_tssldt_desc(((unsigned char *) (n)),((int)(addr)),"0x89")
71 #define set_ldt_desc(n,addr) _set_tssldt_desc(((unsigned char *) (n)),((int)(addr)),"0x82")