cpudata.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #endif /* !(__ASSEMBLY__) */
  56. #define TRAP_PER_CPU_THREAD 0x00
  57. #define TRAP_PER_CPU_PGD_PADDR 0x08
  58. #define TRAP_BLOCK_SZ_SHIFT 6
  59. /* Clobbers %g1, loads %g6 with local processor's cpuid */
  60. #define __GET_CPUID \
  61. ba,pt %xcc, __get_cpu_id; \
  62. rd %pc, %g1;
  63. /* Clobbers %g1, current address space PGD phys address into %g7. */
  64. #define TRAP_LOAD_PGD_PHYS \
  65. __GET_CPUID \
  66. sllx %g6, TRAP_BLOCK_SZ_SHIFT, %g6; \
  67. sethi %hi(trap_block), %g7; \
  68. or %g7, %lo(trap_block), %g7; \
  69. add %g7, %g6, %g7; \
  70. ldx [%g7 + TRAP_PER_CPU_PGD_PADDR], %g7;
  71. /* Clobbers %g1, loads local processor's IRQ work area into %g6. */
  72. #define TRAP_LOAD_IRQ_WORK \
  73. __GET_CPUID \
  74. sethi %hi(__irq_work), %g1; \
  75. sllx %g6, 6, %g6; \
  76. or %g1, %lo(__irq_work), %g1; \
  77. add %g1, %g6, %g6;
  78. /* Clobbers %g1, loads %g6 with current thread info pointer. */
  79. #define TRAP_LOAD_THREAD_REG \
  80. __GET_CPUID \
  81. sllx %g6, TRAP_BLOCK_SZ_SHIFT, %g6; \
  82. sethi %hi(trap_block), %g1; \
  83. or %g1, %lo(trap_block), %g1; \
  84. ldx [%g1 + %g6], %g6;
  85. /* Given the current thread info pointer in %g6, load the per-cpu
  86. * area base of the current processor into %g5. REG1 and REG2 are
  87. * clobbered.
  88. */
  89. #ifdef CONFIG_SMP
  90. #define LOAD_PER_CPU_BASE(REG1, REG2) \
  91. ldub [%g6 + TI_CPU], REG1; \
  92. sethi %hi(__per_cpu_shift), %g5; \
  93. sethi %hi(__per_cpu_base), REG2; \
  94. ldx [%g5 + %lo(__per_cpu_shift)], %g5; \
  95. ldx [REG2 + %lo(__per_cpu_base)], REG2; \
  96. sllx REG1, %g5, %g5; \
  97. add %g5, REG2, %g5;
  98. #else
  99. #define LOAD_PER_CPU_BASE(REG1, REG2)
  100. #endif
  101. #endif /* _SPARC64_CPUDATA_H */