cmd_scsi.c 16 KB

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