cpudata.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* cpudata.h: Per-cpu parameters.
  2. *
  3. * Copyright (C) 2003, 2005, 2006 David S. Miller (davem@davemloft.net)
  4. */
  5. #ifndef _SPARC64_CPUDATA_H
  6. #define _SPARC64_CPUDATA_H
  7. #ifndef __ASSEMBLY__
  8. #include <linux/percpu.h>
  9. #include <linux/threads.h>
  10. typedef struct {
  11. /* Dcache line 1 */
  12. unsigned int __softirq_pending; /* must be 1st, see rtrap.S */
  13. unsigned int multiplier;
  14. unsigned int counter;
  15. unsigned int idle_volume;
  16. unsigned long clock_tick; /* %tick's per second */
  17. unsigned long udelay_val;
  18. /* Dcache line 2, rarely used */
  19. unsigned int dcache_size;
  20. unsigned int dcache_line_size;
  21. unsigned int icache_size;
  22. unsigned int icache_line_size;
  23. unsigned int ecache_size;
  24. unsigned int ecache_line_size;
  25. unsigned int __pad3;
  26. unsigned int __pad4;
  27. } cpuinfo_sparc;
  28. DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
  29. #define cpu_data(__cpu) per_cpu(__cpu_data, (__cpu))
  30. #define local_cpu_data() __get_cpu_var(__cpu_data)
  31. /* Trap handling code needs to get at a few critical values upon
  32. * trap entry and to process TSB misses. These cannot be in the
  33. * per_cpu() area as we really need to lock them into the TLB and
  34. * thus make them part of the main kernel image. As a result we
  35. * try to make this as small as possible.
  36. *
  37. * This is padded out and aligned to 64-bytes to avoid false sharing
  38. * on SMP.
  39. */
  40. /* If you modify the size of this structure, please update
  41. * TRAP_BLOCK_SZ_SHIFT below.
  42. */
  43. struct thread_info;
  44. struct trap_per_cpu {
  45. /* D-cache line 1 */
  46. struct thread_info *thread;
  47. unsigned long pgd_paddr;
  48. unsigned long __pad1[2];
  49. /* D-cache line 2 */
  50. unsigned long __pad2[4];
  51. } __attribute__((aligned(64)));
  52. extern struct trap_per_cpu trap_block[NR_CPUS];
  53. extern void init_cur_cpu_trap(void);
  54. extern void per_cpu_patch(void);
  55. extern void setup_tba(void);
  56. #endif /* !(__ASSEMBLY__) */
  57. #define TRAP_PER_CPU_THREAD 0x00
  58. #define TRAP_PER_CPU_PGD_PADDR 0x08
  59. #define TRAP_BLOCK_SZ_SHIFT 6
  60. /* Clobbers %g1, loads %g6 with local processor's cpuid */
  61. #define __GET_CPUID \
  62. ba,pt %xcc, __get_cpu_id; \
  63. rd %pc, %g1;
  64. /* Clobbers %g1, current address space PGD phys address into %g7. */
  65. #define TRAP_LOAD_PGD_PHYS \
  66. __GET_CPUID \
  67. sllx %g6, TRAP_BLOCK_SZ_SHIFT, %g6; \
  68. sethi %hi(trap_block), %g7; \
  69. or %g7, %lo(trap_block), %g7; \
  70. add %g7, %g6, %g7; \
  71. ldx [%g7 + TRAP_PER_CPU_PGD_PADDR], %g7;
  72. /* Clobbers %g1, loads local processor's IRQ work area into %g6. */
  73. #define TRAP_LOAD_IRQ_WORK \
  74. __GET_CPUID \
  75. sethi %hi(__irq_work), %g1; \
  76. sllx %g6, 6, %g6; \
  77. or %g1, %lo(__irq_work), %g1; \
  78. add %g1, %g6, %g6;
  79. /* Clobbers %g1, loads %g6 with current thread info pointer. */
  80. #define TRAP_LOAD_THREAD_REG \
  81. __GET_CPUID \
  82. sllx %g6, TRAP_BLOCK_SZ_SHIFT, %g6; \
  83. sethi %hi(trap_block), %g1; \
  84. or %g1, %lo(trap_block), %g1; \
  85. ldx [%g1 + %g6], %g6;
  86. /* Given the current thread info pointer in %g6, load the per-cpu
  87. * area base of the current processor into %g5. REG1, REG2, and REG3 are
  88. * clobbered.
  89. *
  90. * You absolutely cannot use %g5 as a temporary in this code. The
  91. * reason is that traps can happen during execution, and return from
  92. * trap will load the fully resolved %g5 per-cpu base. This can corrupt
  93. * the calculations done by the macro mid-stream.
  94. */
  95. #ifdef CONFIG_SMP
  96. #define LOAD_PER_CPU_BASE(REG1, REG2, REG3) \
  97. ldub [%g6 + TI_CPU], REG1; \
  98. sethi %hi(__per_cpu_shift), REG3; \
  99. sethi %hi(__per_cpu_base), REG2; \
  100. ldx [REG3 + %lo(__per_cpu_shift)], REG3; \
  101. ldx [REG2 + %lo(__per_cpu_base)], REG2; \
  102. sllx REG1, REG3, REG3; \
  103. add REG3, REG2, %g5;
  104. #else
  105. #define LOAD_PER_CPU_BASE(REG1, REG2, REG3)
  106. #endif
  107. #endif /* _SPARC64_CPUDATA_H */