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