desc_defs.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /*
  11. * FIXME: Acessing the desc_struct through its fields is more elegant,
  12. * and should be the one valid thing to do. However, a lot of open code
  13. * still touches the a and b acessors, and doing this allow us to do it
  14. * incrementally. We keep the signature as a struct, rather than an union,
  15. * so we can get rid of it transparently in the future -- glommer
  16. */
  17. /* 8 byte segment descriptor */
  18. struct desc_struct {
  19. union {
  20. struct {
  21. unsigned int a;
  22. unsigned int b;
  23. };
  24. struct {
  25. u16 limit0;
  26. u16 base0;
  27. unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
  28. unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
  29. };
  30. };
  31. } __attribute__((packed));
  32. enum {
  33. GATE_INTERRUPT = 0xE,
  34. GATE_TRAP = 0xF,
  35. GATE_CALL = 0xC,
  36. GATE_TASK = 0x5,
  37. };
  38. /* 16byte gate */
  39. struct gate_struct64 {
  40. u16 offset_low;
  41. u16 segment;
  42. unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
  43. u16 offset_middle;
  44. u32 offset_high;
  45. u32 zero1;
  46. } __attribute__((packed));
  47. #define PTR_LOW(x) ((unsigned long long)(x) & 0xFFFF)
  48. #define PTR_MIDDLE(x) (((unsigned long long)(x) >> 16) & 0xFFFF)
  49. #define PTR_HIGH(x) ((unsigned long long)(x) >> 32)
  50. enum {
  51. DESC_TSS = 0x9,
  52. DESC_LDT = 0x2,
  53. DESCTYPE_S = 0x10, /* !system */
  54. };
  55. /* LDT or TSS descriptor in the GDT. 16 bytes. */
  56. struct ldttss_desc64 {
  57. u16 limit0;
  58. u16 base0;
  59. unsigned base1 : 8, type : 5, dpl : 2, p : 1;
  60. unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
  61. u32 base3;
  62. u32 zero1;
  63. } __attribute__((packed));
  64. #ifdef CONFIG_X86_64
  65. typedef struct gate_struct64 gate_desc;
  66. typedef struct ldttss_desc64 ldt_desc;
  67. typedef struct ldttss_desc64 tss_desc;
  68. #else
  69. typedef struct desc_struct gate_desc;
  70. typedef struct desc_struct ldt_desc;
  71. typedef struct desc_struct tss_desc;
  72. #endif
  73. struct desc_ptr {
  74. unsigned short size;
  75. unsigned long address;
  76. } __attribute__((packed)) ;
  77. #endif /* !__ASSEMBLY__ */
  78. #endif