cpu-info.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994 Waldorf GMBH
  7. * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
  8. * Copyright (C) 1996 Paul M. Antoine
  9. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  10. * Copyright (C) 2004 Maciej W. Rozycki
  11. */
  12. #ifndef __ASM_CPU_INFO_H
  13. #define __ASM_CPU_INFO_H
  14. #include <linux/types.h>
  15. #include <asm/cache.h>
  16. /*
  17. * Descriptor for a cache
  18. */
  19. struct cache_desc {
  20. unsigned int waysize; /* Bytes per way */
  21. unsigned short sets; /* Number of lines per set */
  22. unsigned char ways; /* Number of ways */
  23. unsigned char linesz; /* Size of line in bytes */
  24. unsigned char waybit; /* Bits to select in a cache set */
  25. unsigned char flags; /* Flags describing cache properties */
  26. };
  27. struct guest_info {
  28. unsigned long ases;
  29. unsigned long ases_dyn;
  30. unsigned long long options;
  31. unsigned long long options_dyn;
  32. u8 conf;
  33. u8 kscratch_mask;
  34. };
  35. /*
  36. * Flag definitions
  37. */
  38. #define MIPS_CACHE_NOT_PRESENT 0x00000001
  39. #define MIPS_CACHE_VTAG 0x00000002 /* Virtually tagged cache */
  40. #define MIPS_CACHE_ALIASES 0x00000004 /* Cache could have aliases */
  41. #define MIPS_CACHE_IC_F_DC 0x00000008 /* Ic can refill from D-cache */
  42. #define MIPS_IC_SNOOPS_REMOTE 0x00000010 /* Ic snoops remote stores */
  43. #define MIPS_CACHE_PINDEX 0x00000020 /* Physically indexed cache */
  44. struct cpuinfo_mips {
  45. unsigned long asid_cache;
  46. #ifdef CONFIG_MIPS_ASID_BITS_VARIABLE
  47. unsigned long asid_mask;
  48. #endif
  49. /*
  50. * Capability and feature descriptor structure for MIPS CPU
  51. */
  52. unsigned long ases;
  53. unsigned long long options;
  54. unsigned int udelay_val;
  55. unsigned int processor_id;
  56. unsigned int fpu_id;
  57. unsigned int fpu_csr31;
  58. unsigned int fpu_msk31;
  59. unsigned int msa_id;
  60. unsigned int cputype;
  61. int isa_level;
  62. int tlbsize;
  63. int tlbsizevtlb;
  64. int tlbsizeftlbsets;
  65. int tlbsizeftlbways;
  66. struct cache_desc icache; /* Primary I-cache */
  67. struct cache_desc dcache; /* Primary D or combined I/D cache */
  68. struct cache_desc vcache; /* Victim cache, between pcache and scache */
  69. struct cache_desc scache; /* Secondary cache */
  70. struct cache_desc tcache; /* Tertiary/split secondary cache */
  71. int srsets; /* Shadow register sets */
  72. int package;/* physical package number */
  73. int core; /* physical core number */
  74. #ifdef CONFIG_64BIT
  75. int vmbits; /* Virtual memory size in bits */
  76. #endif
  77. #if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6)
  78. /*
  79. * There is not necessarily a 1:1 mapping of VPE num to CPU number
  80. * in particular on multi-core systems.
  81. */
  82. int vpe_id; /* Virtual Processor number */
  83. #endif
  84. void *data; /* Additional data */
  85. unsigned int watch_reg_count; /* Number that exist */
  86. unsigned int watch_reg_use_cnt; /* Usable by ptrace */
  87. #define NUM_WATCH_REGS 4
  88. u16 watch_reg_masks[NUM_WATCH_REGS];
  89. unsigned int kscratch_mask; /* Usable KScratch mask. */
  90. /*
  91. * Cache Coherency attribute for write-combine memory writes.
  92. * (shifted by _CACHE_SHIFT)
  93. */
  94. unsigned int writecombine;
  95. /*
  96. * Simple counter to prevent enabling HTW in nested
  97. * htw_start/htw_stop calls
  98. */
  99. unsigned int htw_seq;
  100. /* VZ & Guest features */
  101. struct guest_info guest;
  102. unsigned int gtoffset_mask;
  103. unsigned int guestid_mask;
  104. } __attribute__((aligned(SMP_CACHE_BYTES)));
  105. extern struct cpuinfo_mips cpu_data[];
  106. #define current_cpu_data cpu_data[smp_processor_id()]
  107. #define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
  108. #define boot_cpu_data cpu_data[0]
  109. extern void cpu_probe(void);
  110. extern void cpu_report(void);
  111. extern const char *__cpu_name[];
  112. #define cpu_name_string() __cpu_name[raw_smp_processor_id()]
  113. struct seq_file;
  114. struct notifier_block;
  115. extern int register_proc_cpuinfo_notifier(struct notifier_block *nb);
  116. extern int proc_cpuinfo_notifier_call_chain(unsigned long val, void *v);
  117. #define proc_cpuinfo_notifier(fn, pri) \
  118. ({ \
  119. static struct notifier_block fn##_nb = { \
  120. .notifier_call = fn, \
  121. .priority = pri \
  122. }; \
  123. \
  124. register_proc_cpuinfo_notifier(&fn##_nb); \
  125. })
  126. struct proc_cpuinfo_notifier_args {
  127. struct seq_file *m;
  128. unsigned long n;
  129. };
  130. #if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_CPU_MIPSR6)
  131. # define cpu_vpe_id(cpuinfo) ((cpuinfo)->vpe_id)
  132. #else
  133. # define cpu_vpe_id(cpuinfo) ({ (void)cpuinfo; 0; })
  134. #endif
  135. static inline unsigned long cpu_asid_inc(void)
  136. {
  137. return 1 << CONFIG_MIPS_ASID_SHIFT;
  138. }
  139. static inline unsigned long cpu_asid_mask(struct cpuinfo_mips *cpuinfo)
  140. {
  141. #ifdef CONFIG_MIPS_ASID_BITS_VARIABLE
  142. return cpuinfo->asid_mask;
  143. #endif
  144. return ((1 << CONFIG_MIPS_ASID_BITS) - 1) << CONFIG_MIPS_ASID_SHIFT;
  145. }
  146. static inline void set_cpu_asid_mask(struct cpuinfo_mips *cpuinfo,
  147. unsigned long asid_mask)
  148. {
  149. #ifdef CONFIG_MIPS_ASID_BITS_VARIABLE
  150. cpuinfo->asid_mask = asid_mask;
  151. #endif
  152. }
  153. #endif /* __ASM_CPU_INFO_H */