processor_32.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #define INIT_THREAD { \
  28. .sp0 = sizeof(init_stack) + (long)&init_stack, \
  29. .vm86_info = NULL, \
  30. .sysenter_cs = __KERNEL_CS, \
  31. .io_bitmap_ptr = NULL, \
  32. .fs = __KERNEL_PERCPU, \
  33. }
  34. /*
  35. * Note that the .io_bitmap member must be extra-big. This is because
  36. * the CPU will access an additional byte beyond the end of the IO
  37. * permission bitmap. The extra byte must be all 1 bits, and must
  38. * be within the limit.
  39. */
  40. #define INIT_TSS { \
  41. .x86_tss = { \
  42. .sp0 = sizeof(init_stack) + (long)&init_stack, \
  43. .ss0 = __KERNEL_DS, \
  44. .ss1 = __KERNEL_CS, \
  45. .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
  46. }, \
  47. .io_bitmap = { [ 0 ... IO_BITMAP_LONGS] = ~0 }, \
  48. }
  49. #define start_thread(regs, new_eip, new_esp) do { \
  50. __asm__("movl %0,%%gs": :"r" (0)); \
  51. regs->fs = 0; \
  52. set_fs(USER_DS); \
  53. regs->ds = __USER_DS; \
  54. regs->es = __USER_DS; \
  55. regs->ss = __USER_DS; \
  56. regs->cs = __USER_CS; \
  57. regs->ip = new_eip; \
  58. regs->sp = new_esp; \
  59. } while (0)
  60. extern unsigned long thread_saved_pc(struct task_struct *tsk);
  61. #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
  62. #define KSTK_TOP(info) \
  63. ({ \
  64. unsigned long *__ptr = (unsigned long *)(info); \
  65. (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
  66. })
  67. /*
  68. * The below -8 is to reserve 8 bytes on top of the ring0 stack.
  69. * This is necessary to guarantee that the entire "struct pt_regs"
  70. * is accessable even if the CPU haven't stored the SS/ESP registers
  71. * on the stack (interrupt gate does not save these registers
  72. * when switching to the same priv ring).
  73. * Therefore beware: accessing the ss/esp fields of the
  74. * "struct pt_regs" is possible, but they may contain the
  75. * completely wrong values.
  76. */
  77. #define task_pt_regs(task) \
  78. ({ \
  79. struct pt_regs *__regs__; \
  80. __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
  81. __regs__ - 1; \
  82. })
  83. #define KSTK_ESP(task) (task_pt_regs(task)->sp)
  84. #endif /* __ASM_I386_PROCESSOR_H */