proc.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *  linux/arch/mips/kernel/proc.c
  3.  *
  4.  *  Copyright (C) 1995, 1996, 2001  Ralf Baechle
  5.  *  Copyright (C) 2001  MIPS Technologies, Inc.
  6.  */
  7. #include <linux/config.h>
  8. #include <linux/delay.h>
  9. #include <linux/kernel.h>
  10. #include <linux/sched.h>
  11. #include <linux/seq_file.h>
  12. #include <asm/bootinfo.h>
  13. #include <asm/cpu.h>
  14. #include <asm/mipsregs.h>
  15. #include <asm/processor.h>
  16. #include <asm/watch.h>
  17. unsigned int vced_count, vcei_count;
  18. #ifndef CONFIG_CPU_HAS_LLSC
  19. unsigned long ll_ops, sc_ops;
  20. #endif
  21. static const char *cpu_name[] = {
  22. [CPU_UNKNOWN] "unknown",
  23. [CPU_R2000] "R2000",
  24. [CPU_R3000] "R3000",
  25. [CPU_R3000A] "R3000A",
  26. [CPU_R3041] "R3041",
  27. [CPU_R3051] "R3051",
  28. [CPU_R3052] "R3052",
  29. [CPU_R3081] "R3081",
  30. [CPU_R3081E] "R3081E",
  31. [CPU_R4000PC] "R4000PC",
  32. [CPU_R4000SC] "R4000SC",
  33. [CPU_R4000MC] "R4000MC",
  34.         [CPU_R4200] "R4200",
  35. [CPU_R4400PC] "R4400PC",
  36. [CPU_R4400SC] "R4400SC",
  37. [CPU_R4400MC] "R4400MC",
  38. [CPU_R4600] "R4600",
  39. [CPU_R6000] "R6000",
  40.         [CPU_R6000A] "R6000A",
  41. [CPU_R8000] "R8000",
  42. [CPU_R10000] "R10000",
  43. [CPU_R4300] "R4300",
  44. [CPU_R4650] "R4650",
  45. [CPU_R4700] "R4700",
  46. [CPU_R5000] "R5000",
  47.         [CPU_R5000A] "R5000A",
  48. [CPU_R4640] "R4640",
  49. [CPU_NEVADA] "Nevada",
  50. [CPU_RM7000] "RM7000",
  51. [CPU_R5432] "R5432",
  52. [CPU_4KC] "MIPS 4Kc",
  53.         [CPU_5KC] "MIPS 5Kc",
  54. [CPU_R4310] "R4310",
  55. [CPU_SB1] "SiByte SB1",
  56. [CPU_TX3912] "TX3912",
  57. [CPU_TX3922] "TX3922",
  58. [CPU_TX3927] "TX3927",
  59. [CPU_AU1000] "Au1000",
  60. [CPU_AU1500] "Au1500",
  61. [CPU_4KEC] "MIPS 4KEc",
  62. [CPU_4KSC] "MIPS 4KSc",
  63. [CPU_VR41XX] "NEC Vr41xx",
  64. [CPU_R5500] "R5500",
  65. [CPU_TX49XX] "TX49xx",
  66. [CPU_TX39XX] "TX39xx",
  67. [CPU_20KC] "MIPS 20Kc",
  68. [CPU_VR4111] "NEC VR4111",
  69. [CPU_VR4121] "NEC VR4121",
  70. [CPU_VR4122] "NEC VR4122",
  71. [CPU_VR4131] "NEC VR4131",
  72. [CPU_VR4181] "NEC VR4181",
  73. [CPU_VR4181A] "NEC VR4181A"
  74. };
  75. static int show_cpuinfo(struct seq_file *m, void *v)
  76. {
  77. unsigned int version = mips_cpu.processor_id;
  78. unsigned int fp_vers = mips_cpu.fpu_id;
  79. unsigned long n = (unsigned long) v - 1;
  80. char fmt [64];
  81. #ifdef CONFIG_SMP
  82. if (!CPUMASK_TSTB(cpu_online_map, n))
  83. return 0;
  84. #endif
  85. /*
  86.  * For the first processor also print the system type
  87.  */
  88. if (n == 0)
  89. seq_printf(m, "system typett: %sn", get_system_type());
  90. seq_printf(m, "processortt: %ldn", n);
  91. sprintf(fmt, "cpu modeltt: %%s V%%d.%%d%sn",
  92.         (mips_cpu.options & MIPS_CPU_FPU) ? "  FPU V%d.%d" : "");
  93. seq_printf(m, fmt, cpu_name[mips_cpu.cputype <= CPU_LAST ?
  94.                             mips_cpu.cputype : CPU_UNKNOWN],
  95.                            (version >> 4) & 0x0f, version & 0x0f,
  96.                            (fp_vers >> 4) & 0x0f, fp_vers & 0x0f);
  97. seq_printf(m, "BogoMIPStt: %lu.%02lun",
  98.               loops_per_jiffy / (500000/HZ),
  99.               (loops_per_jiffy / (5000/HZ)) % 100);
  100. seq_printf(m, "wait instructiont: %sn", cpu_wait ? "yes" : "no");
  101. seq_printf(m, "microsecond timerst: %sn",
  102.               (mips_cpu.options & MIPS_CPU_COUNTER) ? "yes" : "no");
  103. seq_printf(m, "tlb_entriestt: %dn", mips_cpu.tlbsize);
  104. seq_printf(m, "extra interrupt vectort: %sn",
  105.               (mips_cpu.options & MIPS_CPU_DIVEC) ? "yes" : "no");
  106. seq_printf(m, "hardware watchpointt: %sn",
  107.               watch_available ? "yes" : "no");
  108. sprintf(fmt, "VCE%%c exceptionstt: %sn",
  109.         (mips_cpu.options & MIPS_CPU_VCE) ? "%d" : "not available");
  110. seq_printf(m, fmt, 'D', vced_count);
  111. seq_printf(m, fmt, 'I', vcei_count);
  112. #ifndef CONFIG_CPU_HAS_LLSC
  113. seq_printf(m, "ll emulationstt: %lun", ll_ops);
  114. seq_printf(m, "sc emulationstt: %lun", sc_ops);
  115. #endif
  116. return 0;
  117. }
  118. static void *c_start(struct seq_file *m, loff_t *pos)
  119. {
  120. unsigned long i = *pos;
  121. return i < NR_CPUS ? (void *) (i + 1) : NULL;
  122. }
  123. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  124. {
  125. ++*pos;
  126. return c_start(m, pos);
  127. }
  128. static void c_stop(struct seq_file *m, void *v)
  129. {
  130. }
  131. struct seq_operations cpuinfo_op = {
  132. start: c_start,
  133. next: c_next,
  134. stop: c_stop,
  135. show: show_cpuinfo,
  136. };