Add hexdump lib function
[thunix.git] / include / asm / system.h
blob58289f4bdd35912d4fc864f92941762cb4618984
1 #ifndef SYSTEM_H
2 #define SYSTEM_H
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" \
10 "pushl $0x17\n\t" \
11 "pushl %%eax\n\t" \
12 "pushfl\n\t" \
13 "pushl $0x0f\n\t" \
14 "pushl $1f\n\t" \
15 "iret\n" \
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" \
20 "movw %%ax,%%gs" \
21 ::)
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" \
39 "movw %0, %%dx\n\t" \
40 "movl %%eax, %1\n\t" \
41 "movl %%edx, %2" \
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" \
59 "movw %%ax,%2\n\t" \
60 "rorl $16,%%eax\n\t" \
61 "movb %%al,%3\n\t" \
62 "movb $" type ",%4\n\t" \
63 "movb $0x00,%5\n\t" \
64 "movb %%ah,%6\n\t" \
65 "rorl $16,%%eax" \
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")
75 #endif /* system.h */