xref: /kvm-unit-tests/lib/x86/desc.h (revision d21b4f1216592171a358c7d17f81b4aab08aebea)
1 #ifndef __IDT_TEST__
2 #define __IDT_TEST__
3 
4 void setup_idt(void);
5 #ifndef __x86_64__
6 void setup_gdt(void);
7 void setup_tss32(void);
8 #else
9 static inline void setup_gdt(void){}
10 static inline void setup_tss32(void){}
11 #endif
12 
13 #define ASM_TRY(catch)                                  \
14     "movl $0, %%gs:4 \n\t"                              \
15     ".pushsection .data.ex \n\t"                        \
16     ".quad 1111f, " catch "\n\t"                        \
17     ".popsection \n\t"                                  \
18     "1111:"
19 
20 #define UD_VECTOR   6
21 #define GP_VECTOR   13
22 
23 #define TSS_MAIN 0x20
24 #define TSS_INTR 0x28
25 
26 unsigned exception_vector(void);
27 unsigned exception_error_code(void);
28 void set_idt_entry(int vec, void *addr, int dpl);
29 void set_gdt_entry(int num, u32 base,  u32 limit, u8 access, u8 gran);
30 void set_intr_task_gate(int e, void *fn);
31 void print_current_tss_info(void);
32 
33 #endif
34