desc_32.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __ARCH_DESC_H
  2. #define __ARCH_DESC_H
  3. #include <asm/ldt.h>
  4. #include <asm/segment.h>
  5. #include <asm/desc_defs.h>
  6. #ifndef __ASSEMBLY__
  7. #include <linux/preempt.h>
  8. #include <linux/percpu.h>
  9. extern void set_intr_gate(unsigned int irq, void * addr);
  10. static inline void pack_gate(gate_desc *gate,
  11. unsigned long base, unsigned short seg, unsigned char type, unsigned char flags)
  12. {
  13. gate->a = (seg << 16) | (base & 0xffff);
  14. gate->b = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff);
  15. }
  16. static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
  17. {
  18. gate_desc g;
  19. pack_gate(&g, (unsigned long)addr, seg, type, 0);
  20. write_idt_entry(idt_table, gate, &g);
  21. }
  22. static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr)
  23. {
  24. tss_desc tss;
  25. pack_descriptor(&tss, (unsigned long)addr,
  26. offsetof(struct tss_struct, __cacheline_filler) - 1,
  27. DESC_TSS, 0);
  28. write_gdt_entry(get_cpu_gdt_table(cpu), entry, &tss, DESC_TSS);
  29. }
  30. #define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
  31. #endif /* !__ASSEMBLY__ */
  32. #endif