nsp32_debug.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /*
  2. * Workbit NinjaSCSI-32Bi/UDE PCI/CardBus SCSI Host Bus Adapter driver
  3. * Debug routine
  4. *
  5. * This software may be used and distributed according to the terms of
  6. * the GNU General Public License.
  7. */
  8. /*
  9. * Show the command data of a command
  10. */
  11. static const char unknown[] = "UNKNOWN";
  12. static const char * group_0_commands[] = {
  13. /* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
  14. /* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reassign Blocks",
  15. /* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
  16. /* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
  17. /* 13-16 */ unknown, "Recover Buffered Data", "Mode Select", "Reserve",
  18. /* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
  19. /* 1c-1d */ "Receive Diagnostic", "Send Diagnostic",
  20. /* 1e-1f */ "Prevent/Allow Medium Removal", unknown,
  21. };
  22. static const char *group_1_commands[] = {
  23. /* 20-22 */ unknown, unknown, unknown,
  24. /* 23-28 */ unknown, unknown, "Read Capacity", unknown, unknown, "Read (10)",
  25. /* 29-2d */ unknown, "Write (10)", "Seek (10)", unknown, unknown,
  26. /* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal",
  27. /* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position",
  28. /* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data",
  29. /* 38-3c */ "Medium Scan", "Compare","Copy Verify", "Write Buffer", "Read Buffer",
  30. /* 3d-3f */ "Update Block", "Read Long", "Write Long",
  31. };
  32. static const char *group_2_commands[] = {
  33. /* 40-41 */ "Change Definition", "Write Same",
  34. /* 42-48 */ "Read Sub-Ch(cd)", "Read TOC", "Read Header(cd)", "Play Audio(cd)", unknown, "Play Audio MSF(cd)", "Play Audio Track/Index(cd)",
  35. /* 49-4f */ "Play Track Relative(10)(cd)", unknown, "Pause/Resume(cd)", "Log Select", "Log Sense", unknown, unknown,
  36. /* 50-55 */ unknown, unknown, unknown, unknown, unknown, "Mode Select (10)",
  37. /* 56-5b */ unknown, unknown, unknown, unknown, "Mode Sense (10)", unknown,
  38. /* 5c-5f */ unknown, unknown, unknown,
  39. };
  40. #define group(opcode) (((opcode) >> 5) & 7)
  41. #define RESERVED_GROUP 0
  42. #define VENDOR_GROUP 1
  43. #define NOTEXT_GROUP 2
  44. static const char **commands[] = {
  45. group_0_commands, group_1_commands, group_2_commands,
  46. (const char **) RESERVED_GROUP, (const char **) RESERVED_GROUP,
  47. (const char **) NOTEXT_GROUP, (const char **) VENDOR_GROUP,
  48. (const char **) VENDOR_GROUP
  49. };
  50. static const char reserved[] = "RESERVED";
  51. static const char vendor[] = "VENDOR SPECIFIC";
  52. static void print_opcodek(unsigned char opcode)
  53. {
  54. const char **table = commands[ group(opcode) ];
  55. switch ((unsigned long) table) {
  56. case RESERVED_GROUP:
  57. printk("%s[%02x] ", reserved, opcode);
  58. break;
  59. case NOTEXT_GROUP:
  60. printk("%s(notext)[%02x] ", unknown, opcode);
  61. break;
  62. case VENDOR_GROUP:
  63. printk("%s[%02x] ", vendor, opcode);
  64. break;
  65. default:
  66. if (table[opcode & 0x1f] != unknown)
  67. printk("%s[%02x] ", table[opcode & 0x1f], opcode);
  68. else
  69. printk("%s[%02x] ", unknown, opcode);
  70. break;
  71. }
  72. }
  73. static void print_commandk (unsigned char *command)
  74. {
  75. int i,s;
  76. // printk(KERN_DEBUG);
  77. print_opcodek(command[0]);
  78. /*printk(KERN_DEBUG "%s ", __func__);*/
  79. if ((command[0] >> 5) == 6 ||
  80. (command[0] >> 5) == 7 ) {
  81. s = 12; /* vender specific */
  82. } else {
  83. s = COMMAND_SIZE(command[0]);
  84. }
  85. for ( i = 1; i < s; ++i) {
  86. printk("%02x ", command[i]);
  87. }
  88. switch (s) {
  89. case 6:
  90. printk("LBA=%d len=%d",
  91. (((unsigned int)command[1] & 0x0f) << 16) |
  92. ( (unsigned int)command[2] << 8) |
  93. ( (unsigned int)command[3] ),
  94. (unsigned int)command[4]
  95. );
  96. break;
  97. case 10:
  98. printk("LBA=%d len=%d",
  99. ((unsigned int)command[2] << 24) |
  100. ((unsigned int)command[3] << 16) |
  101. ((unsigned int)command[4] << 8) |
  102. ((unsigned int)command[5] ),
  103. ((unsigned int)command[7] << 8) |
  104. ((unsigned int)command[8] )
  105. );
  106. break;
  107. case 12:
  108. printk("LBA=%d len=%d",
  109. ((unsigned int)command[2] << 24) |
  110. ((unsigned int)command[3] << 16) |
  111. ((unsigned int)command[4] << 8) |
  112. ((unsigned int)command[5] ),
  113. ((unsigned int)command[6] << 24) |
  114. ((unsigned int)command[7] << 16) |
  115. ((unsigned int)command[8] << 8) |
  116. ((unsigned int)command[9] )
  117. );
  118. break;
  119. default:
  120. break;
  121. }
  122. printk("\n");
  123. }
  124. static void show_command(Scsi_Cmnd *SCpnt)
  125. {
  126. print_commandk(SCpnt->cmnd);
  127. }
  128. static void show_busphase(unsigned char stat)
  129. {
  130. switch(stat) {
  131. case BUSPHASE_COMMAND:
  132. printk( "BUSPHASE_COMMAND\n");
  133. break;
  134. case BUSPHASE_MESSAGE_IN:
  135. printk( "BUSPHASE_MESSAGE_IN\n");
  136. break;
  137. case BUSPHASE_MESSAGE_OUT:
  138. printk( "BUSPHASE_MESSAGE_OUT\n");
  139. break;
  140. case BUSPHASE_DATA_IN:
  141. printk( "BUSPHASE_DATA_IN\n");
  142. break;
  143. case BUSPHASE_DATA_OUT:
  144. printk( "BUSPHASE_DATA_OUT\n");
  145. break;
  146. case BUSPHASE_STATUS:
  147. printk( "BUSPHASE_STATUS\n");
  148. break;
  149. case BUSPHASE_SELECT:
  150. printk( "BUSPHASE_SELECT\n");
  151. break;
  152. default:
  153. printk( "BUSPHASE_other: 0x%x\n", stat);
  154. break;
  155. }
  156. }
  157. static void show_autophase(unsigned short i)
  158. {
  159. printk("auto: 0x%x,", i);
  160. if(i & COMMAND_PHASE) {
  161. printk(" cmd");
  162. }
  163. if(i & DATA_IN_PHASE) {
  164. printk(" din");
  165. }
  166. if(i & DATA_OUT_PHASE) {
  167. printk(" dout");
  168. }
  169. if(i & MSGOUT_PHASE) {
  170. printk(" mout");
  171. }
  172. if(i & STATUS_PHASE) {
  173. printk(" stat");
  174. }
  175. if(i & ILLEGAL_PHASE) {
  176. printk(" ill");
  177. }
  178. if(i & BUS_FREE_OCCUER) {
  179. printk(" bfree-o");
  180. }
  181. if(i & MSG_IN_OCCUER) {
  182. printk(" min-o");
  183. }
  184. if(i & MSG_OUT_OCCUER) {
  185. printk(" mout-o");
  186. }
  187. if(i & SELECTION_TIMEOUT) {
  188. printk(" sel");
  189. }
  190. if(i & MSGIN_00_VALID) {
  191. printk(" m0");
  192. }
  193. if(i & MSGIN_02_VALID) {
  194. printk(" m2");
  195. }
  196. if(i & MSGIN_03_VALID) {
  197. printk(" m3");
  198. }
  199. if(i & MSGIN_04_VALID) {
  200. printk(" m4");
  201. }
  202. if(i & AUTOSCSI_BUSY) {
  203. printk(" busy");
  204. }
  205. printk("\n");
  206. }
  207. static void nsp32_print_register(int base)
  208. {
  209. if (!(NSP32_DEBUG_MASK & NSP32_SPECIAL_PRINT_REGISTER))
  210. return;
  211. printk("Phase=0x%x, ", nsp32_read1(base, SCSI_BUS_MONITOR));
  212. printk("OldPhase=0x%x, ", nsp32_index_read1(base, OLD_SCSI_PHASE));
  213. printk("syncreg=0x%x, ", nsp32_read1(base, SYNC_REG));
  214. printk("ackwidth=0x%x, ", nsp32_read1(base, ACK_WIDTH));
  215. printk("sgtpaddr=0x%lx, ", nsp32_read4(base, SGT_ADR));
  216. printk("scsioutlatch=0x%x, ", nsp32_read1(base, SCSI_OUT_LATCH_TARGET_ID));
  217. printk("msgout=0x%lx, ", nsp32_read4(base, SCSI_MSG_OUT));
  218. printk("miscrd=0x%x, ", nsp32_index_read2(base, MISC_WR));
  219. printk("seltimeout=0x%x, ", nsp32_read2(base, SEL_TIME_OUT));
  220. printk("sreqrate=0x%x, ", nsp32_read1(base, SREQ_SMPL_RATE));
  221. printk("transStatus=0x%x, ", nsp32_read2(base, TRANSFER_STATUS));
  222. printk("reselectid=0x%x, ", nsp32_read2(base, COMMAND_CONTROL));
  223. printk("arbit=0x%x, ", nsp32_read1(base, ARBIT_STATUS));
  224. printk("BmStart=0x%lx, ", nsp32_read4(base, BM_START_ADR));
  225. printk("BmCount=0x%lx, ", nsp32_read4(base, BM_CNT));
  226. printk("SackCnt=0x%lx, ", nsp32_read4(base, SACK_CNT));
  227. printk("SReqCnt=0x%lx, ", nsp32_read4(base, SREQ_CNT));
  228. printk("SavedSackCnt=0x%lx, ", nsp32_read4(base, SAVED_SACK_CNT));
  229. printk("ScsiBusControl=0x%x, ", nsp32_read1(base, SCSI_BUS_CONTROL));
  230. printk("FifoRestCnt=0x%x, ", nsp32_read2(base, FIFO_REST_CNT));
  231. printk("CdbIn=0x%x, ", nsp32_read1(base, SCSI_CSB_IN));
  232. printk("\n");
  233. if (0) {
  234. printk("execph=0x%x, ", nsp32_read2(base, SCSI_EXECUTE_PHASE));
  235. printk("IrqStatus=0x%x, ", nsp32_read2(base, IRQ_STATUS));
  236. printk("\n");
  237. }
  238. }
  239. /* end */