segment.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef _ASM_SEGMENT_H
  2. #define _ASM_SEGMENT_H
  3. /*
  4. * The layout of the per-CPU GDT under Linux:
  5. *
  6. * 0 - null
  7. * 1 - reserved
  8. * 2 - reserved
  9. * 3 - reserved
  10. *
  11. * 4 - unused <==== new cacheline
  12. * 5 - unused
  13. *
  14. * ------- start of TLS (Thread-Local Storage) segments:
  15. *
  16. * 6 - TLS segment #1 [ glibc's TLS segment ]
  17. * 7 - TLS segment #2 [ Wine's %fs Win32 segment ]
  18. * 8 - TLS segment #3
  19. * 9 - reserved
  20. * 10 - reserved
  21. * 11 - reserved
  22. *
  23. * ------- start of kernel segments:
  24. *
  25. * 12 - kernel code segment <==== new cacheline
  26. * 13 - kernel data segment
  27. * 14 - default user CS
  28. * 15 - default user DS
  29. * 16 - TSS
  30. * 17 - LDT
  31. * 18 - PNPBIOS support (16->32 gate)
  32. * 19 - PNPBIOS support
  33. * 20 - PNPBIOS support
  34. * 21 - PNPBIOS support
  35. * 22 - PNPBIOS support
  36. * 23 - APM BIOS support
  37. * 24 - APM BIOS support
  38. * 25 - APM BIOS support
  39. *
  40. * 26 - ESPFIX small SS
  41. * 27 - unused
  42. * 28 - unused
  43. * 29 - unused
  44. * 30 - unused
  45. * 31 - TSS for double fault handler
  46. */
  47. #define GDT_ENTRY_TLS_ENTRIES 3
  48. #define GDT_ENTRY_TLS_MIN 6
  49. #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
  50. #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
  51. #define GDT_ENTRY_DEFAULT_USER_CS 14
  52. #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
  53. #define GDT_ENTRY_DEFAULT_USER_DS 15
  54. #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
  55. #define GDT_ENTRY_KERNEL_BASE 12
  56. #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)
  57. #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
  58. #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)
  59. #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
  60. #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)
  61. #define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)
  62. #define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6)
  63. #define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11)
  64. #define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)
  65. #define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
  66. #define GDT_ENTRY_DOUBLEFAULT_TSS 31
  67. /*
  68. * The GDT has 32 entries
  69. */
  70. #define GDT_ENTRIES 32
  71. #define GDT_SIZE (GDT_ENTRIES * 8)
  72. /* Simple and small GDT entries for booting only */
  73. #define GDT_ENTRY_BOOT_CS 2
  74. #define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
  75. #define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
  76. #define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
  77. /* The PnP BIOS entries in the GDT */
  78. #define GDT_ENTRY_PNPBIOS_CS32 (GDT_ENTRY_PNPBIOS_BASE + 0)
  79. #define GDT_ENTRY_PNPBIOS_CS16 (GDT_ENTRY_PNPBIOS_BASE + 1)
  80. #define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2)
  81. #define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3)
  82. #define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4)
  83. /* The PnP BIOS selectors */
  84. #define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8) /* segment for calling fn */
  85. #define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8) /* code segment for BIOS */
  86. #define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8) /* data segment for BIOS */
  87. #define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8) /* transfer data segment */
  88. #define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8) /* another data segment */
  89. /*
  90. * The interrupt descriptor table has room for 256 idt's,
  91. * the global descriptor table is dependent on the number
  92. * of tasks we can have..
  93. */
  94. #define IDT_ENTRIES 256
  95. #endif