1 /* Written 2000 by Andi Kleen */
5 #include <linux/threads.h>
10 #include <linux/string.h>
12 #include <asm/segment.h>
14 static inline void _set_gate(int gate, unsigned type, unsigned long func,
15 unsigned dpl, unsigned ist)
19 s.offset_low = PTR_LOW(func);
20 s.segment = __KERNEL_CS;
27 s.offset_middle = PTR_MIDDLE(func);
28 s.offset_high = PTR_HIGH(func);
30 * does not need to be atomic because it is only done once at
33 write_idt_entry(idt_table, gate, &s);
36 static inline void set_intr_gate(int nr, void *func)
38 BUG_ON((unsigned)nr > 0xFF);
39 _set_gate(nr, GATE_INTERRUPT, (unsigned long) func, 0, 0);
42 static inline void set_intr_gate_ist(int nr, void *func, unsigned ist)
44 BUG_ON((unsigned)nr > 0xFF);
45 _set_gate(nr, GATE_INTERRUPT, (unsigned long) func, 0, ist);
48 static inline void set_system_gate(int nr, void *func)
50 BUG_ON((unsigned)nr > 0xFF);
51 _set_gate(nr, GATE_INTERRUPT, (unsigned long) func, 3, 0);
54 static inline void set_system_gate_ist(int nr, void *func, unsigned ist)
56 _set_gate(nr, GATE_INTERRUPT, (unsigned long) func, 3, ist);
59 static inline void set_tss_desc(unsigned cpu, void *addr)
61 struct desc_struct *d = get_cpu_gdt_table(cpu);
65 * sizeof(unsigned long) coming from an extra "long" at the end
66 * of the iobitmap. See tss_struct definition in processor.h
68 * -1? seg base+limit should be pointing to the address of the
71 set_tssldt_descriptor(&tss,
72 (unsigned long)addr, DESC_TSS,
73 IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
74 write_gdt_entry(d, GDT_ENTRY_TSS, &tss, DESC_TSS);
77 #endif /* !__ASSEMBLY__ */