ftape-proc.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. #include <linux/config.h>
  24. #if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
  25. #include <linux/proc_fs.h>
  26. #include <linux/ftape.h>
  27. #include <linux/init.h>
  28. #include <linux/qic117.h>
  29. #include "../lowlevel/ftape-io.h"
  30. #include "../lowlevel/ftape-ctl.h"
  31. #include "../lowlevel/ftape-proc.h"
  32. #include "../lowlevel/ftape-tracing.h"
  33. static size_t get_driver_info(char *buf)
  34. {
  35. const char *debug_level[] = { "bugs" ,
  36. "errors",
  37. "warnings",
  38. "informational",
  39. "noisy",
  40. "program flow",
  41. "fdc and dma",
  42. "data flow",
  43. "anything" };
  44. return sprintf(buf,
  45. "version : %s\n"
  46. "used data rate: %d kbit/sec\n"
  47. "dma memory : %d kb\n"
  48. "debug messages: %s\n",
  49. FTAPE_VERSION,
  50. ft_data_rate,
  51. FT_BUFF_SIZE * ft_nr_buffers >> 10,
  52. debug_level[TRACE_LEVEL]);
  53. }
  54. static size_t get_tapedrive_info(char *buf)
  55. {
  56. return sprintf(buf,
  57. "vendor id : 0x%04x\n"
  58. "drive name: %s\n"
  59. "wind speed: %d ips\n"
  60. "wakeup : %s\n"
  61. "max. rate : %d kbit/sec\n",
  62. ft_drive_type.vendor_id,
  63. ft_drive_type.name,
  64. ft_drive_type.speed,
  65. ((ft_drive_type.wake_up == no_wake_up)
  66. ? "No wakeup needed" :
  67. ((ft_drive_type.wake_up == wake_up_colorado)
  68. ? "Colorado" :
  69. ((ft_drive_type.wake_up == wake_up_mountain)
  70. ? "Mountain" :
  71. ((ft_drive_type.wake_up == wake_up_insight)
  72. ? "Motor on" :
  73. "Unknown")))),
  74. ft_drive_max_rate);
  75. }
  76. static size_t get_cartridge_info(char *buf)
  77. {
  78. if (ftape_init_drive_needed) {
  79. return sprintf(buf, "uninitialized\n");
  80. }
  81. if (ft_no_tape) {
  82. return sprintf(buf, "no cartridge inserted\n");
  83. }
  84. return sprintf(buf,
  85. "segments : %5d\n"
  86. "tracks : %5d\n"
  87. "length : %5dft\n"
  88. "formatted : %3s\n"
  89. "writable : %3s\n"
  90. "QIC spec. : QIC-%s\n"
  91. "fmt-code : %1d\n",
  92. ft_segments_per_track,
  93. ft_tracks_per_tape,
  94. ftape_tape_len,
  95. (ft_formatted == 1) ? "yes" : "no",
  96. (ft_write_protected == 1) ? "no" : "yes",
  97. ((ft_qic_std == QIC_TAPE_QIC40) ? "40" :
  98. ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
  99. ((ft_qic_std == QIC_TAPE_QIC3010) ? "3010" :
  100. ((ft_qic_std == QIC_TAPE_QIC3020) ? "3020" :
  101. "???")))),
  102. ft_format_code);
  103. }
  104. static size_t get_controller_info(char *buf)
  105. {
  106. const char *fdc_name[] = { "no fdc",
  107. "i8272",
  108. "i82077",
  109. "i82077AA",
  110. "Colorado FC-10 or FC-20",
  111. "i82078",
  112. "i82078_1" };
  113. return sprintf(buf,
  114. "FDC type : %s\n"
  115. "FDC base : 0x%03x\n"
  116. "FDC irq : %d\n"
  117. "FDC dma : %d\n"
  118. "FDC thr. : %d\n"
  119. "max. rate : %d kbit/sec\n",
  120. ft_mach2 ? "Mountain MACH-2" : fdc_name[fdc.type],
  121. fdc.sra, fdc.irq, fdc.dma,
  122. ft_fdc_threshold, ft_fdc_max_rate);
  123. }
  124. static size_t get_history_info(char *buf)
  125. {
  126. size_t len;
  127. len = sprintf(buf,
  128. "\nFDC isr statistics\n"
  129. " id_am_errors : %3d\n"
  130. " id_crc_errors : %3d\n"
  131. " data_am_errors : %3d\n"
  132. " data_crc_errors : %3d\n"
  133. " overrun_errors : %3d\n"
  134. " no_data_errors : %3d\n"
  135. " retries : %3d\n",
  136. ft_history.id_am_errors, ft_history.id_crc_errors,
  137. ft_history.data_am_errors, ft_history.data_crc_errors,
  138. ft_history.overrun_errors, ft_history.no_data_errors,
  139. ft_history.retries);
  140. len += sprintf(buf + len,
  141. "\nECC statistics\n"
  142. " crc_errors : %3d\n"
  143. " crc_failures : %3d\n"
  144. " ecc_failures : %3d\n"
  145. " sectors corrected: %3d\n",
  146. ft_history.crc_errors, ft_history.crc_failures,
  147. ft_history.ecc_failures, ft_history.corrected);
  148. len += sprintf(buf + len,
  149. "\ntape quality statistics\n"
  150. " media defects : %3d\n",
  151. ft_history.defects);
  152. len += sprintf(buf + len,
  153. "\ntape motion statistics\n"
  154. " repositions : %3d\n",
  155. ft_history.rewinds);
  156. return len;
  157. }
  158. static int ftape_read_proc(char *page, char **start, off_t off,
  159. int count, int *eof, void *data)
  160. {
  161. char *ptr = page;
  162. size_t len;
  163. ptr += sprintf(ptr, "Kernel Driver\n\n");
  164. ptr += get_driver_info(ptr);
  165. ptr += sprintf(ptr, "\nTape Drive\n\n");
  166. ptr += get_tapedrive_info(ptr);
  167. ptr += sprintf(ptr, "\nFDC Controller\n\n");
  168. ptr += get_controller_info(ptr);
  169. ptr += sprintf(ptr, "\nTape Cartridge\n\n");
  170. ptr += get_cartridge_info(ptr);
  171. ptr += sprintf(ptr, "\nHistory Record\n\n");
  172. ptr += get_history_info(ptr);
  173. len = strlen(page);
  174. *start = NULL;
  175. if (off+count >= len) {
  176. *eof = 1;
  177. } else {
  178. *eof = 0;
  179. }
  180. return len;
  181. }
  182. int __init ftape_proc_init(void)
  183. {
  184. return create_proc_read_entry("ftape", 0, &proc_root,
  185. ftape_read_proc, NULL) != NULL;
  186. }
  187. void ftape_proc_destroy(void)
  188. {
  189. remove_proc_entry("ftape", &proc_root);
  190. }
  191. #endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) */