processor_32.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (C) 1994 Linus Torvalds
  3. */
  4. #ifndef __ASM_I386_PROCESSOR_H
  5. #define __ASM_I386_PROCESSOR_H
  6. #include <asm/vm86.h>
  7. #include <asm/math_emu.h>
  8. #include <asm/segment.h>
  9. #include <asm/page.h>
  10. #include <asm/types.h>
  11. #include <asm/sigcontext.h>
  12. #include <asm/cpufeature.h>
  13. #include <asm/msr.h>
  14. #include <asm/system.h>
  15. #include <linux/threads.h>
  16. #include <linux/init.h>
  17. #include <asm/desc_defs.h>
  18. /*
  19. * the following now lives in the per cpu area:
  20. * extern int cpu_llc_id[NR_CPUS];
  21. */
  22. DECLARE_PER_CPU(u8, cpu_llc_id);
  23. /*
  24. * User space process size: 3GB (default).
  25. */
  26. #define TASK_SIZE (PAGE_OFFSET)
  27. struct i387_fsave_struct {
  28. long cwd;
  29. long swd;
  30. long twd;
  31. long fip;
  32. long fcs;
  33. long foo;
  34. long fos;
  35. long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
  36. long status; /* software status information */
  37. };
  38. struct i387_fxsave_struct {
  39. unsigned short cwd;
  40. unsigned short swd;
  41. unsigned short twd;
  42. unsigned short fop;
  43. long fip;
  44. long fcs;
  45. long foo;
  46. long fos;
  47. long mxcsr;
  48. long mxcsr_mask;
  49. long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
  50. long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
  51. long padding[56];
  52. } __attribute__ ((aligned (16)));
  53. struct i387_soft_struct {
  54. long cwd;
  55. long swd;
  56. long twd;
  57. long fip;
  58. long fcs;
  59. long foo;
  60. long fos;
  61. long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
  62. unsigned char ftop, changed, lookahead, no_update, rm, alimit;
  63. struct info *info;
  64. unsigned long entry_eip;
  65. };
  66. union i387_union {
  67. struct i387_fsave_struct fsave;
  68. struct i387_fxsave_struct fxsave;
  69. struct i387_soft_struct soft;
  70. };
  71. #define INIT_THREAD { \
  72. .sp0 = sizeof(init_stack) + (long)&init_stack, \
  73. .vm86_info = NULL, \
  74. .sysenter_cs = __KERNEL_CS, \
  75. .io_bitmap_ptr = NULL, \
  76. .fs = __KERNEL_PERCPU, \
  77. }
  78. /*
  79. * Note that the .io_bitmap member must be extra-big. This is because
  80. * the CPU will access an additional byte beyond the end of the IO
  81. * permission bitmap. The extra byte must be all 1 bits, and must
  82. * be within the limit.
  83. */
  84. #define INIT_TSS { \
  85. .x86_tss = { \
  86. .sp0 = sizeof(init_stack) + (long)&init_stack, \
  87. .ss0 = __KERNEL_DS, \
  88. .ss1 = __KERNEL_CS, \
  89. .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
  90. }, \
  91. .io_bitmap = { [ 0 ... IO_BITMAP_LONGS] = ~0 }, \
  92. }
  93. #define start_thread(regs, new_eip, new_esp) do { \
  94. __asm__("movl %0,%%gs": :"r" (0)); \
  95. regs->fs = 0; \
  96. set_fs(USER_DS); \
  97. regs->ds = __USER_DS; \
  98. regs->es = __USER_DS; \
  99. regs->ss = __USER_DS; \
  100. regs->cs = __USER_CS; \
  101. regs->ip = new_eip; \
  102. regs->sp = new_esp; \
  103. } while (0)
  104. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  105. #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
  106. #define KSTK_TOP(info) \
  107. ({ \
  108. unsigned long *__ptr = (unsigned long *)(info); \
  109. (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
  110. })
  111. /*
  112. * The below -8 is to reserve 8 bytes on top of the ring0 stack.
  113. * This is necessary to guarantee that the entire "struct pt_regs"
  114. * is accessable even if the CPU haven't stored the SS/ESP registers
  115. * on the stack (interrupt gate does not save these registers
  116. * when switching to the same priv ring).
  117. * Therefore beware: accessing the ss/esp fields of the
  118. * "struct pt_regs" is possible, but they may contain the
  119. * completely wrong values.
  120. */
  121. #define task_pt_regs(task) \
  122. ({ \
  123. struct pt_regs *__regs__; \
  124. __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
  125. __regs__ - 1; \
  126. })
  127. #define KSTK_ESP(task) (task_pt_regs(task)->sp)
  128. #endif /* __ASM_I386_PROCESSOR_H */