iSeries_proc.c 3.6 KB

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