desc_defs.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Written 2000 by Andi Kleen */
  2. #ifndef __ARCH_DESC_DEFS_H
  3. #define __ARCH_DESC_DEFS_H
  4. /*
  5. * Segment descriptor structure definitions, usable from both x86_64 and i386
  6. * archs.
  7. */
  8. #ifndef __ASSEMBLY__
  9. #include <linux/types.h>
  10. // 8 byte segment descriptor
  11. struct desc_struct {
  12. u16 limit0;
  13. u16 base0;
  14. unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
  15. unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8;
  16. } __attribute__((packed));
  17. struct n_desc_struct {
  18. unsigned int a,b;
  19. };
  20. enum {
  21. GATE_INTERRUPT = 0xE,
  22. GATE_TRAP = 0xF,
  23. GATE_CALL = 0xC,
  24. };
  25. // 16byte gate
  26. struct gate_struct {
  27. u16 offset_low;
  28. u16 segment;
  29. unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
  30. u16 offset_middle;
  31. u32 offset_high;
  32. u32 zero1;
  33. } __attribute__((packed));
  34. #define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF)
  35. #define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF)
  36. #define PTR_HIGH(x) ((unsigned long)(x) >> 32)
  37. enum {
  38. DESC_TSS = 0x9,
  39. DESC_LDT = 0x2,
  40. };
  41. // LDT or TSS descriptor in the GDT. 16 bytes.
  42. struct ldttss_desc {
  43. u16 limit0;
  44. u16 base0;
  45. unsigned base1 : 8, type : 5, dpl : 2, p : 1;
  46. unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
  47. u32 base3;
  48. u32 zero1;
  49. } __attribute__((packed));
  50. struct desc_ptr {
  51. unsigned short size;
  52. unsigned long address;
  53. } __attribute__((packed)) ;
  54. #endif /* !__ASSEMBLY__ */
  55. #endif