proc.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Copyright (C) 2001 Kyle A. Lucke IBM Corporation
  3. * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen IBM Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/init.h>
  20. #include <linux/proc_fs.h>
  21. #include <linux/seq_file.h>
  22. #include <linux/param.h> /* for HZ */
  23. #include <asm/paca.h>
  24. #include <asm/processor.h>
  25. #include <asm/time.h>
  26. #include <asm/lppaca.h>
  27. #include <asm/firmware.h>
  28. #include <asm/iseries/hv_call_xm.h>
  29. #include "processor_vpd.h"
  30. #include "main_store.h"
  31. static int __init iseries_proc_create(void)
  32. {
  33. struct proc_dir_entry *e;
  34. if (!firmware_has_feature(FW_FEATURE_ISERIES))
  35. return 0;
  36. e = proc_mkdir("iSeries", 0);
  37. if (!e)
  38. return 1;
  39. return 0;
  40. }
  41. core_initcall(iseries_proc_create);
  42. static unsigned long startTitan = 0;
  43. static unsigned long startTb = 0;
  44. static int proc_titantod_show(struct seq_file *m, void *v)
  45. {
  46. unsigned long tb0, titan_tod;
  47. tb0 = get_tb();
  48. titan_tod = HvCallXm_loadTod();
  49. seq_printf(m, "Titan\n" );
  50. seq_printf(m, " time base = %016lx\n", tb0);
  51. seq_printf(m, " titan tod = %016lx\n", titan_tod);
  52. seq_printf(m, " xProcFreq = %016x\n",
  53. xIoHriProcessorVpd[0].xProcFreq);
  54. seq_printf(m, " xTimeBaseFreq = %016x\n",
  55. xIoHriProcessorVpd[0].xTimeBaseFreq);
  56. seq_printf(m, " tb_ticks_per_jiffy = %lu\n", tb_ticks_per_jiffy);
  57. seq_printf(m, " tb_ticks_per_usec = %lu\n", tb_ticks_per_usec);
  58. if (!startTitan) {
  59. startTitan = titan_tod;
  60. startTb = tb0;
  61. } else {
  62. unsigned long titan_usec = (titan_tod - startTitan) >> 12;
  63. unsigned long tb_ticks = (tb0 - startTb);
  64. unsigned long titan_jiffies = titan_usec / (1000000/HZ);
  65. unsigned long titan_jiff_usec = titan_jiffies * (1000000/HZ);
  66. unsigned long titan_jiff_rem_usec =
  67. titan_usec - titan_jiff_usec;
  68. unsigned long tb_jiffies = tb_ticks / tb_ticks_per_jiffy;
  69. unsigned long tb_jiff_ticks = tb_jiffies * tb_ticks_per_jiffy;
  70. unsigned long tb_jiff_rem_ticks = tb_ticks - tb_jiff_ticks;
  71. unsigned long tb_jiff_rem_usec =
  72. tb_jiff_rem_ticks / tb_ticks_per_usec;
  73. unsigned long new_tb_ticks_per_jiffy =
  74. (tb_ticks * (1000000/HZ))/titan_usec;
  75. seq_printf(m, " titan elapsed = %lu uSec\n", titan_usec);
  76. seq_printf(m, " tb elapsed = %lu ticks\n", tb_ticks);
  77. seq_printf(m, " titan jiffies = %lu.%04lu\n", titan_jiffies,
  78. titan_jiff_rem_usec);
  79. seq_printf(m, " tb jiffies = %lu.%04lu\n", tb_jiffies,
  80. tb_jiff_rem_usec);
  81. seq_printf(m, " new tb_ticks_per_jiffy = %lu\n",
  82. new_tb_ticks_per_jiffy);
  83. }
  84. return 0;
  85. }
  86. static int proc_titantod_open(struct inode *inode, struct file *file)
  87. {
  88. return single_open(file, proc_titantod_show, NULL);
  89. }
  90. static const struct file_operations proc_titantod_operations = {
  91. .open = proc_titantod_open,
  92. .read = seq_read,
  93. .llseek = seq_lseek,
  94. .release = single_release,
  95. };
  96. static int __init iseries_proc_init(void)
  97. {
  98. if (!firmware_has_feature(FW_FEATURE_ISERIES))
  99. return 0;
  100. proc_create("iSeries/titanTod", S_IFREG|S_IRUGO, NULL,
  101. &proc_titantod_operations);
  102. return 0;
  103. }
  104. __initcall(iseries_proc_init);