cmd_scsi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /*
  2. * (C) Copyright 2001
  3. * Denis Peter, MPL AG Switzerland
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. *
  24. *
  25. */
  26. /*
  27. * SCSI support.
  28. */
  29. #include <common.h>
  30. #include <command.h>
  31. #include <cmd_boot.h>
  32. #include <asm/processor.h>
  33. #include <scsi.h>
  34. #include <image.h>
  35. #include <cmd_disk.h>
  36. #include <pci.h>
  37. #undef SCSI_DEBUG
  38. #ifdef SCSI_DEBUG
  39. #define PRINTF(fmt,args...) printf (fmt ,##args)
  40. #else
  41. #define PRINTF(fmt,args...)
  42. #endif
  43. #if (CONFIG_COMMANDS & CFG_CMD_SCSI)
  44. #ifdef CONFIG_SCSI_SYM53C8XX
  45. #define SCSI_VEND_ID 0x1000
  46. #ifndef CONFIG_SCSI_DEV_ID
  47. #define SCSI_DEV_ID 0x0001
  48. #else
  49. #define SCSI_DEV_ID CONFIG_SCSI_DEV_ID
  50. #endif
  51. #else
  52. #error CONFIG_SCSI_SYM53C8XX must be defined
  53. #endif
  54. static ccb tempccb; /* temporary scsi command buffer */
  55. static unsigned char tempbuff[512]; /* temporary data buffer */
  56. static int scsi_max_devs; /* number of highest available scsi device */
  57. static int scsi_curr_dev; /* current device */
  58. static block_dev_desc_t scsi_dev_desc[CFG_SCSI_MAX_DEVICE];
  59. /********************************************************************************
  60. * forward declerations of some Setup Routines
  61. */
  62. void scsi_setup_test_unit_ready(ccb * pccb);
  63. void scsi_setup_read_capacity(ccb * pccb);
  64. void scsi_setup_read6(ccb * pccb, unsigned long start, unsigned short blocks);
  65. void scsi_setup_read_ext(ccb * pccb, unsigned long start, unsigned short blocks);
  66. void scsi_setup_inquiry(ccb * pccb);
  67. void scsi_ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
  68. ulong scsi_read(int device, ulong blknr, ulong blkcnt, ulong *buffer);
  69. /*********************************************************************************
  70. * (re)-scan the scsi bus and reports scsi device info
  71. * to the user if mode = 1
  72. */
  73. void scsi_scan(int mode)
  74. {
  75. unsigned char i,perq,modi,lun;
  76. unsigned long capacity,blksz;
  77. ccb* pccb=(ccb *)&tempccb;
  78. if(mode==1) {
  79. printf("scanning bus for devices...\n");
  80. }
  81. for(i=0;i<CFG_SCSI_MAX_DEVICE;i++) {
  82. scsi_dev_desc[i].target=0xff;
  83. scsi_dev_desc[i].lun=0xff;
  84. scsi_dev_desc[i].lba=0;
  85. scsi_dev_desc[i].blksz=0;
  86. scsi_dev_desc[i].type=DEV_TYPE_UNKNOWN;
  87. scsi_dev_desc[i].vendor[0]=0;
  88. scsi_dev_desc[i].product[0]=0;
  89. scsi_dev_desc[i].revision[0]=0;
  90. scsi_dev_desc[i].removable=FALSE;
  91. scsi_dev_desc[i].if_type=IF_TYPE_SCSI;
  92. scsi_dev_desc[i].dev=i;
  93. scsi_dev_desc[i].part_type=PART_TYPE_UNKNOWN;
  94. scsi_dev_desc[i].block_read=scsi_read;
  95. }
  96. scsi_max_devs=0;
  97. for(i=0;i<CFG_SCSI_MAX_SCSI_ID;i++) {
  98. pccb->target=i;
  99. for(lun=0;lun<CFG_SCSI_MAX_LUN;lun++) {
  100. pccb->lun=lun;
  101. pccb->pdata=(unsigned char *)&tempbuff;
  102. pccb->datalen=512;
  103. scsi_setup_inquiry(pccb);
  104. if(scsi_exec(pccb)!=TRUE) {
  105. if(pccb->contr_stat==SCSI_SEL_TIME_OUT) {
  106. PRINTF("Selection timeout ID %d\n",pccb->target);
  107. continue; /* selection timeout => assuming no device present */
  108. }
  109. scsi_print_error(pccb);
  110. continue;
  111. }
  112. perq=tempbuff[0];
  113. modi=tempbuff[1];
  114. if((perq & 0x1f)==0x1f) {
  115. continue; /* skip unknown devices */
  116. }
  117. if((modi&0x80)==0x80) /* drive is removable */
  118. scsi_dev_desc[scsi_max_devs].removable=TRUE;
  119. /* get info for this device */
  120. scsi_ident_cpy(&scsi_dev_desc[scsi_max_devs].vendor[0],&tempbuff[8],8);
  121. scsi_ident_cpy(&scsi_dev_desc[scsi_max_devs].product[0],&tempbuff[16],16);
  122. scsi_ident_cpy(&scsi_dev_desc[scsi_max_devs].revision[0],&tempbuff[32],4);
  123. scsi_dev_desc[scsi_max_devs].target=pccb->target;
  124. scsi_dev_desc[scsi_max_devs].lun=pccb->lun;
  125. pccb->datalen=0;
  126. scsi_setup_test_unit_ready(pccb);
  127. if(scsi_exec(pccb)!=TRUE) {
  128. if(scsi_dev_desc[scsi_max_devs].removable==TRUE) {
  129. scsi_dev_desc[scsi_max_devs].type=perq;
  130. goto removable;
  131. }
  132. scsi_print_error(pccb);
  133. continue;
  134. }
  135. pccb->datalen=8;
  136. scsi_setup_read_capacity(pccb);
  137. if(scsi_exec(pccb)!=TRUE) {
  138. scsi_print_error(pccb);
  139. continue;
  140. }
  141. capacity=((unsigned long)tempbuff[0]<<24)|((unsigned long)tempbuff[1]<<16)|
  142. ((unsigned long)tempbuff[2]<<8)|((unsigned long)tempbuff[3]);
  143. blksz=((unsigned long)tempbuff[4]<<24)|((unsigned long)tempbuff[5]<<16)|
  144. ((unsigned long)tempbuff[6]<<8)|((unsigned long)tempbuff[7]);
  145. scsi_dev_desc[scsi_max_devs].lba=capacity;
  146. scsi_dev_desc[scsi_max_devs].blksz=blksz;
  147. scsi_dev_desc[scsi_max_devs].type=perq;
  148. init_part(&scsi_dev_desc[scsi_max_devs]);
  149. removable:
  150. if(mode==1) {
  151. printf (" Device %d: ", scsi_max_devs);
  152. dev_print(&scsi_dev_desc[scsi_max_devs]);
  153. } /* if mode */
  154. scsi_max_devs++;
  155. } /* next LUN */
  156. }
  157. if(scsi_max_devs>0)
  158. scsi_curr_dev=0;
  159. else
  160. scsi_curr_dev=-1;
  161. }
  162. void scsi_init(void)
  163. {
  164. int busdevfunc;
  165. busdevfunc=pci_find_device(SCSI_VEND_ID,SCSI_DEV_ID,0); /* get PCI Device ID */
  166. if(busdevfunc==-1) {
  167. printf("Error SCSI Controller (%04X,%04X) not found\n",SCSI_VEND_ID,SCSI_DEV_ID);
  168. return;
  169. }
  170. #ifdef DEBUG
  171. else {
  172. printf("SCSI Controller (%04X,%04X) found (%d:%d:%d)\n",SCSI_VEND_ID,SCSI_DEV_ID,(busdevfunc>>16)&0xFF,(busdevfunc>>11)&0x1F,(busdevfunc>>8)&0x7);
  173. }
  174. #endif
  175. scsi_low_level_init(busdevfunc);
  176. scsi_scan(1);
  177. }
  178. block_dev_desc_t * scsi_get_dev(int dev)
  179. {
  180. return((block_dev_desc_t *)&scsi_dev_desc[dev]);
  181. }
  182. /******************************************************************************
  183. * scsi boot command intepreter. Derived from diskboot
  184. */
  185. int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  186. {
  187. char *boot_device = NULL;
  188. char *ep;
  189. int dev, part = 0;
  190. ulong cnt;
  191. ulong addr;
  192. disk_partition_t info;
  193. image_header_t *hdr;
  194. int rcode = 0;
  195. switch (argc) {
  196. case 1:
  197. addr = CFG_LOAD_ADDR;
  198. boot_device = getenv ("bootdevice");
  199. break;
  200. case 2:
  201. addr = simple_strtoul(argv[1], NULL, 16);
  202. boot_device = getenv ("bootdevice");
  203. break;
  204. case 3:
  205. addr = simple_strtoul(argv[1], NULL, 16);
  206. boot_device = argv[2];
  207. break;
  208. default:
  209. printf ("Usage:\n%s\n", cmdtp->usage);
  210. return 1;
  211. }
  212. if (!boot_device) {
  213. puts ("\n** No boot device **\n");
  214. return 1;
  215. }
  216. dev = simple_strtoul(boot_device, &ep, 16);
  217. printf("booting from dev %d\n",dev);
  218. if (scsi_dev_desc[dev].type == DEV_TYPE_UNKNOWN) {
  219. printf ("\n** Device %d not available\n", dev);
  220. return 1;
  221. }
  222. if (*ep) {
  223. if (*ep != ':') {
  224. puts ("\n** Invalid boot device, use `dev[:part]' **\n");
  225. return 1;
  226. }
  227. part = simple_strtoul(++ep, NULL, 16);
  228. }
  229. if (get_partition_info (&scsi_dev_desc[dev], part, &info)) {
  230. printf("error reading partinfo\n");
  231. return 1;
  232. }
  233. if ((strncmp(info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) &&
  234. (strncmp(info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) {
  235. printf ("\n** Invalid partition type \"%.32s\""
  236. " (expect \"" BOOT_PART_TYPE "\")\n",
  237. info.type);
  238. return 1;
  239. }
  240. printf ("\nLoading from SCSI device %d, partition %d: "
  241. "Name: %.32s Type: %.32s\n",
  242. dev, part, info.name, info.type);
  243. PRINTF ("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
  244. info.start, info.size, info.blksz);
  245. if (scsi_read (dev, info.start, 1, (ulong *)addr) != 1) {
  246. printf ("** Read error on %d:%d\n", dev, part);
  247. return 1;
  248. }
  249. hdr = (image_header_t *)addr;
  250. if (hdr->ih_magic == IH_MAGIC) {
  251. print_image_hdr (hdr);
  252. cnt = (hdr->ih_size + sizeof(image_header_t));
  253. cnt += info.blksz - 1;
  254. cnt /= info.blksz;
  255. cnt -= 1;
  256. } else {
  257. printf("\n** Bad Magic Number **\n");
  258. return 1;
  259. }
  260. if (scsi_read (dev, info.start+1, cnt,
  261. (ulong *)(addr+info.blksz)) != cnt) {
  262. printf ("** Read error on %d:%d\n", dev, part);
  263. return 1;
  264. }
  265. /* Loading ok, update default load address */
  266. load_addr = addr;
  267. flush_cache (addr, (cnt+1)*info.blksz);
  268. /* Check if we should attempt an auto-start */
  269. if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
  270. char *local_args[2];
  271. extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
  272. local_args[0] = argv[0];
  273. local_args[1] = NULL;
  274. printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
  275. rcode = do_bootm (cmdtp, 0, 1, local_args);
  276. }
  277. return rcode;
  278. }
  279. /*********************************************************************************
  280. * scsi command intepreter
  281. */
  282. int do_scsi (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  283. {
  284. switch (argc) {
  285. case 0:
  286. case 1: printf ("Usage:\n%s\n", cmdtp->usage); return 1;
  287. case 2:
  288. if (strncmp(argv[1],"res",3) == 0) {
  289. printf("\nReset SCSI\n");
  290. scsi_bus_reset();
  291. scsi_scan(1);
  292. return 0;
  293. }
  294. if (strncmp(argv[1],"inf",3) == 0) {
  295. int i;
  296. for (i=0; i<CFG_SCSI_MAX_DEVICE; ++i) {
  297. if(scsi_dev_desc[i].type==DEV_TYPE_UNKNOWN)
  298. continue; /* list only known devices */
  299. printf ("SCSI dev. %d: ", i);
  300. dev_print(&scsi_dev_desc[i]);
  301. }
  302. return 0;
  303. }
  304. if (strncmp(argv[1],"dev",3) == 0) {
  305. if ((scsi_curr_dev < 0) || (scsi_curr_dev >= CFG_SCSI_MAX_DEVICE)) {
  306. printf("\nno SCSI devices available\n");
  307. return 1;
  308. }
  309. printf ("\n Device %d: ", scsi_curr_dev);
  310. dev_print(&scsi_dev_desc[scsi_curr_dev]);
  311. return 0;
  312. }
  313. if (strncmp(argv[1],"scan",4) == 0) {
  314. scsi_scan(1);
  315. return 0;
  316. }
  317. if (strncmp(argv[1],"part",4) == 0) {
  318. int dev, ok;
  319. for (ok=0, dev=0; dev<CFG_SCSI_MAX_DEVICE; ++dev) {
  320. if (scsi_dev_desc[dev].type!=DEV_TYPE_UNKNOWN) {
  321. ok++;
  322. if (dev)
  323. printf("\n");
  324. PRINTF("print_part of %x\n",dev);
  325. print_part(&scsi_dev_desc[dev]);
  326. }
  327. }
  328. if (!ok)
  329. printf("\nno SCSI devices available\n");
  330. return 1;
  331. }
  332. printf ("Usage:\n%s\n", cmdtp->usage);
  333. return 1;
  334. case 3:
  335. if (strncmp(argv[1],"dev",3) == 0) {
  336. int dev = (int)simple_strtoul(argv[2], NULL, 10);
  337. printf ("\nSCSI device %d: ", dev);
  338. if (dev >= CFG_SCSI_MAX_DEVICE) {
  339. printf("unknown device\n");
  340. return 1;
  341. }
  342. printf ("\n Device %d: ", dev);
  343. dev_print(&scsi_dev_desc[dev]);
  344. if(scsi_dev_desc[dev].type == DEV_TYPE_UNKNOWN) {
  345. return 1;
  346. }
  347. scsi_curr_dev = dev;
  348. printf("... is now current device\n");
  349. return 0;
  350. }
  351. if (strncmp(argv[1],"part",4) == 0) {
  352. int dev = (int)simple_strtoul(argv[2], NULL, 10);
  353. if(scsi_dev_desc[dev].type != DEV_TYPE_UNKNOWN) {
  354. print_part(&scsi_dev_desc[dev]);
  355. }
  356. else {
  357. printf ("\nSCSI device %d not available\n", dev);
  358. }
  359. return 1;
  360. }
  361. printf ("Usage:\n%s\n", cmdtp->usage);
  362. return 1;
  363. default:
  364. /* at least 4 args */
  365. if (strcmp(argv[1],"read") == 0) {
  366. ulong addr = simple_strtoul(argv[2], NULL, 16);
  367. ulong blk = simple_strtoul(argv[3], NULL, 16);
  368. ulong cnt = simple_strtoul(argv[4], NULL, 16);
  369. ulong n;
  370. printf ("\nSCSI read: device %d block # %ld, count %ld ... ",
  371. scsi_curr_dev, blk, cnt);
  372. n = scsi_read(scsi_curr_dev, blk, cnt, (ulong *)addr);
  373. printf ("%ld blocks read: %s\n",n,(n==cnt) ? "OK" : "ERROR");
  374. return 0;
  375. }
  376. } /* switch */
  377. printf ("Usage:\n%s\n", cmdtp->usage);
  378. return 1;
  379. }
  380. /****************************************************************************************
  381. * scsi_read
  382. */
  383. #define SCSI_MAX_READ_BLK 0xFFFF /* almost the maximum amount of the scsi_ext command.. */
  384. ulong scsi_read(int device, ulong blknr, ulong blkcnt, ulong *buffer)
  385. {
  386. ulong start,blks, buf_addr;
  387. unsigned short smallblks;
  388. ccb* pccb=(ccb *)&tempccb;
  389. device&=0xff;
  390. /* Setup device
  391. */
  392. pccb->target=scsi_dev_desc[device].target;
  393. pccb->lun=scsi_dev_desc[device].lun;
  394. buf_addr=(unsigned long)buffer;
  395. start=blknr;
  396. blks=blkcnt;
  397. PRINTF("\nscsi_read: dev %d startblk %lx, blccnt %lx buffer %lx\n",device,start,blks,(unsigned long)buffer);
  398. do {
  399. pccb->pdata=(unsigned char *)buf_addr;
  400. if(blks>SCSI_MAX_READ_BLK) {
  401. pccb->datalen=scsi_dev_desc[device].blksz * SCSI_MAX_READ_BLK;
  402. smallblks=SCSI_MAX_READ_BLK;
  403. scsi_setup_read_ext(pccb,start,smallblks);
  404. start+=SCSI_MAX_READ_BLK;
  405. blks-=SCSI_MAX_READ_BLK;
  406. }
  407. else {
  408. pccb->datalen=scsi_dev_desc[device].blksz * blks;
  409. smallblks=(unsigned short) blks;
  410. scsi_setup_read_ext(pccb,start,smallblks);
  411. start+=blks;
  412. blks=0;
  413. }
  414. PRINTF("scsi_read_ext: startblk %lx, blccnt %x buffer %lx\n",start,smallblks,buf_addr);
  415. if(scsi_exec(pccb)!=TRUE) {
  416. scsi_print_error(pccb);
  417. blkcnt-=blks;
  418. break;
  419. }
  420. buf_addr+=pccb->datalen;
  421. } while(blks!=0);
  422. PRINTF("scsi_read_ext: end startblk %lx, blccnt %x buffer %lx\n",start,smallblks,buf_addr);
  423. return(blkcnt);
  424. }
  425. /* copy src to dest, skipping leading and trailing blanks
  426. * and null terminate the string
  427. */
  428. void scsi_ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len)
  429. {
  430. int start,end;
  431. start=0;
  432. while(start<len) {
  433. if(src[start]!=' ')
  434. break;
  435. start++;
  436. }
  437. end=len-1;
  438. while(end>start) {
  439. if(src[end]!=' ')
  440. break;
  441. end--;
  442. }
  443. for( ; start<=end; start++) {
  444. *dest++=src[start];
  445. }
  446. *dest='\0';
  447. }
  448. /* Trim trailing blanks, and NUL-terminate string
  449. */
  450. void scsi_trim_trail (unsigned char *str, unsigned int len)
  451. {
  452. unsigned char *p = str + len - 1;
  453. while (len-- > 0) {
  454. *p-- = '\0';
  455. if (*p != ' ') {
  456. return;
  457. }
  458. }
  459. }
  460. /************************************************************************************
  461. * Some setup (fill-in) routines
  462. */
  463. void scsi_setup_test_unit_ready(ccb * pccb)
  464. {
  465. pccb->cmd[0]=SCSI_TST_U_RDY;
  466. pccb->cmd[1]=pccb->lun<<5;
  467. pccb->cmd[2]=0;
  468. pccb->cmd[3]=0;
  469. pccb->cmd[4]=0;
  470. pccb->cmd[5]=0;
  471. pccb->cmdlen=6;
  472. pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
  473. }
  474. void scsi_setup_read_capacity(ccb * pccb)
  475. {
  476. pccb->cmd[0]=SCSI_RD_CAPAC;
  477. pccb->cmd[1]=pccb->lun<<5;
  478. pccb->cmd[2]=0;
  479. pccb->cmd[3]=0;
  480. pccb->cmd[4]=0;
  481. pccb->cmd[5]=0;
  482. pccb->cmd[6]=0;
  483. pccb->cmd[7]=0;
  484. pccb->cmd[8]=0;
  485. pccb->cmd[9]=0;
  486. pccb->cmdlen=10;
  487. pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
  488. }
  489. void scsi_setup_read_ext(ccb * pccb, unsigned long start, unsigned short blocks)
  490. {
  491. pccb->cmd[0]=SCSI_READ10;
  492. pccb->cmd[1]=pccb->lun<<5;
  493. pccb->cmd[2]=((unsigned char) (start>>24))&0xff;
  494. pccb->cmd[3]=((unsigned char) (start>>16))&0xff;
  495. pccb->cmd[4]=((unsigned char) (start>>8))&0xff;
  496. pccb->cmd[5]=((unsigned char) (start))&0xff;
  497. pccb->cmd[6]=0;
  498. pccb->cmd[7]=((unsigned char) (blocks>>8))&0xff;
  499. pccb->cmd[8]=(unsigned char) blocks & 0xff;
  500. pccb->cmd[6]=0;
  501. pccb->cmdlen=10;
  502. pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
  503. PRINTF("scsi_setup_read_ext: cmd: %02X %02X startblk %02X%02X%02X%02X blccnt %02X%02X\n",
  504. pccb->cmd[0],pccb->cmd[1],
  505. pccb->cmd[2],pccb->cmd[3],pccb->cmd[4],pccb->cmd[5],
  506. pccb->cmd[7],pccb->cmd[8]);
  507. }
  508. void scsi_setup_read6(ccb * pccb, unsigned long start, unsigned short blocks)
  509. {
  510. pccb->cmd[0]=SCSI_READ6;
  511. pccb->cmd[1]=pccb->lun<<5 | (((unsigned char)(start>>16))&0x1f);
  512. pccb->cmd[2]=((unsigned char) (start>>8))&0xff;
  513. pccb->cmd[3]=((unsigned char) (start))&0xff;
  514. pccb->cmd[4]=(unsigned char) blocks & 0xff;
  515. pccb->cmd[5]=0;
  516. pccb->cmdlen=6;
  517. pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
  518. PRINTF("scsi_setup_read6: cmd: %02X %02X startblk %02X%02X blccnt %02X\n",
  519. pccb->cmd[0],pccb->cmd[1],
  520. pccb->cmd[2],pccb->cmd[3],pccb->cmd[4]);
  521. }
  522. void scsi_setup_inquiry(ccb * pccb)
  523. {
  524. pccb->cmd[0]=SCSI_INQUIRY;
  525. pccb->cmd[1]=pccb->lun<<5;
  526. pccb->cmd[2]=0;
  527. pccb->cmd[3]=0;
  528. if(pccb->datalen>255)
  529. pccb->cmd[4]=255;
  530. else
  531. pccb->cmd[4]=(unsigned char)pccb->datalen;
  532. pccb->cmd[5]=0;
  533. pccb->cmdlen=6;
  534. pccb->msgout[0]=SCSI_IDENTIFY; /* NOT USED */
  535. }
  536. #endif /* #if (CONFIG_COMMANDS & CFG_CMD_SCSI) */