ftape-proc.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Copyright (C) 1997 Claus-Justus Heine
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; see the file COPYING. If not, write to
  13. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  14. *
  15. * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-proc.c,v $
  16. * $Revision: 1.11 $
  17. * $Date: 1997/10/24 14:47:37 $
  18. *
  19. * This file contains the procfs interface for the
  20. * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
  21. * Old code removed, switched to dynamic proc entry.
  22. */
  23. #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
  24. #include <linux/proc_fs.h>
  25. #include <linux/ftape.h>
  26. #include <linux/init.h>
  27. #include <linux/qic117.h>
  28. #include "../lowlevel/ftape-io.h"
  29. #include "../lowlevel/ftape-ctl.h"
  30. #include "../lowlevel/ftape-proc.h"
  31. #include "../lowlevel/ftape-tracing.h"
  32. static size_t get_driver_info(char *buf)
  33. {
  34. const char *debug_level[] = { "bugs" ,
  35. "errors",
  36. "warnings",
  37. "informational",
  38. "noisy",
  39. "program flow",
  40. "fdc and dma",
  41. "data flow",
  42. "anything" };
  43. return sprintf(buf,
  44. "version : %s\n"
  45. "used data rate: %d kbit/sec\n"
  46. "dma memory : %d kb\n"
  47. "debug messages: %s\n",
  48. FTAPE_VERSION,
  49. ft_data_rate,
  50. FT_BUFF_SIZE * ft_nr_buffers >> 10,
  51. debug_level[TRACE_LEVEL]);
  52. }
  53. static size_t get_tapedrive_info(char *buf)
  54. {
  55. return sprintf(buf,
  56. "vendor id : 0x%04x\n"
  57. "drive name: %s\n"
  58. "wind speed: %d ips\n"
  59. "wakeup : %s\n"
  60. "max. rate : %d kbit/sec\n",
  61. ft_drive_type.vendor_id,
  62. ft_drive_type.name,
  63. ft_drive_type.speed,
  64. ((ft_drive_type.wake_up == no_wake_up)
  65. ? "No wakeup needed" :
  66. ((ft_drive_type.wake_up == wake_up_colorado)
  67. ? "Colorado" :
  68. ((ft_drive_type.wake_up == wake_up_mountain)
  69. ? "Mountain" :
  70. ((ft_drive_type.wake_up == wake_up_insight)
  71. ? "Motor on" :
  72. "Unknown")))),
  73. ft_drive_max_rate);
  74. }
  75. static size_t get_cartridge_info(char *buf)
  76. {
  77. if (ftape_init_drive_needed) {
  78. return sprintf(buf, "uninitialized\n");
  79. }
  80. if (ft_no_tape) {
  81. return sprintf(buf, "no cartridge inserted\n");
  82. }
  83. return sprintf(buf,
  84. "segments : %5d\n"
  85. "tracks : %5d\n"
  86. "length : %5dft\n"
  87. "formatted : %3s\n"
  88. "writable : %3s\n"
  89. "QIC spec. : QIC-%s\n"
  90. "fmt-code : %1d\n",
  91. ft_segments_per_track,
  92. ft_tracks_per_tape,
  93. ftape_tape_len,
  94. (ft_formatted == 1) ? "yes" : "no",
  95. (ft_write_protected == 1) ? "no" : "yes",
  96. ((ft_qic_std == QIC_TAPE_QIC40) ? "40" :
  97. ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
  98. ((ft_qic_std == QIC_TAPE_QIC3010) ? "3010" :
  99. ((ft_qic_std == QIC_TAPE_QIC3020) ? "3020" :
  100. "???")))),
  101. ft_format_code);
  102. }
  103. static size_t get_controller_info(char *buf)
  104. {
  105. const char *fdc_name[] = { "no fdc",
  106. "i8272",
  107. "i82077",
  108. "i82077AA",
  109. "Colorado FC-10 or FC-20",
  110. "i82078",
  111. "i82078_1" };
  112. return sprintf(buf,
  113. "FDC type : %s\n"
  114. "FDC base : 0x%03x\n"
  115. "FDC irq : %d\n"
  116. "FDC dma : %d\n"
  117. "FDC thr. : %d\n"
  118. "max. rate : %d kbit/sec\n",
  119. ft_mach2 ? "Mountain MACH-2" : fdc_name[fdc.type],
  120. fdc.sra, fdc.irq, fdc.dma,
  121. ft_fdc_threshold, ft_fdc_max_rate);
  122. }
  123. static size_t get_history_info(char *buf)
  124. {
  125. size_t len;
  126. len = sprintf(buf,
  127. "\nFDC isr statistics\n"
  128. " id_am_errors : %3d\n"
  129. " id_crc_errors : %3d\n"
  130. " data_am_errors : %3d\n"
  131. " data_crc_errors : %3d\n"
  132. " overrun_errors : %3d\n"
  133. " no_data_errors : %3d\n"
  134. " retries : %3d\n",
  135. ft_history.id_am_errors, ft_history.id_crc_errors,
  136. ft_history.data_am_errors, ft_history.data_crc_errors,
  137. ft_history.overrun_errors, ft_history.no_data_errors,
  138. ft_history.retries);
  139. len += sprintf(buf + len,
  140. "\nECC statistics\n"
  141. " crc_errors : %3d\n"
  142. " crc_failures : %3d\n"
  143. " ecc_failures : %3d\n"
  144. " sectors corrected: %3d\n",
  145. ft_history.crc_errors, ft_history.crc_failures,
  146. ft_history.ecc_failures, ft_history.corrected);
  147. len += sprintf(buf + len,
  148. "\ntape quality statistics\n"
  149. " media defects : %3d\n",
  150. ft_history.defects);
  151. len += sprintf(buf + len,
  152. "\ntape motion statistics\n"
  153. " repositions : %3d\n",
  154. ft_history.rewinds);
  155. return len;
  156. }
  157. static int ftape_read_proc(char *page, char **start, off_t off,
  158. int count, int *eof, void *data)
  159. {
  160. char *ptr = page;
  161. size_t len;
  162. ptr += sprintf(ptr, "Kernel Driver\n\n");
  163. ptr += get_driver_info(ptr);
  164. ptr += sprintf(ptr, "\nTape Drive\n\n");
  165. ptr += get_tapedrive_info(ptr);
  166. ptr += sprintf(ptr, "\nFDC Controller\n\n");
  167. ptr += get_controller_info(ptr);
  168. ptr += sprintf(ptr, "\nTape Cartridge\n\n");
  169. ptr += get_cartridge_info(ptr);
  170. ptr += sprintf(ptr, "\nHistory Record\n\n");
  171. ptr += get_history_info(ptr);
  172. len = strlen(page);
  173. *start = NULL;
  174. if (off+count >= len) {
  175. *eof = 1;
  176. } else {
  177. *eof = 0;
  178. }
  179. return len;
  180. }
  181. int __init ftape_proc_init(void)
  182. {
  183. return create_proc_read_entry("ftape", 0, &proc_root,
  184. ftape_read_proc, NULL) != NULL;
  185. }
  186. void ftape_proc_destroy(void)
  187. {
  188. remove_proc_entry("ftape", &proc_root);
  189. }
  190. #endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) */