Newer
Older
dev_desc->removable = 1;
else
dev_desc->removable = 0;
memset(ccb,0,sizeof(ccb));
memset(iobuf,0,sizeof(iobuf));
ccb[0]=ATAPI_CMD_START_STOP;
ccb[4]=0x03; /* start */
c=atapi_issue_autoreq(device,ccb,12,(unsigned char *)iobuf,0);
debug ("ATAPI_CMD_START_STOP returned %x\n",c);
if (c!=0)
return;
memset(ccb,0,sizeof(ccb));
memset(iobuf,0,sizeof(iobuf));
c=atapi_issue_autoreq(device,ccb,12,(unsigned char *)iobuf,0);
debug ("ATAPI_CMD_UNIT_TEST_READY returned %x\n",c);
if (c!=0)
return;
memset(ccb,0,sizeof(ccb));
memset(iobuf,0,sizeof(iobuf));
ccb[0]=ATAPI_CMD_READ_CAP;
c=atapi_issue_autoreq(device,ccb,12,(unsigned char *)iobuf,8);
debug ("ATAPI_CMD_READ_CAP returned %x\n",c);
debug ("Read Cap: LBA %02X%02X%02X%02X blksize %02X%02X%02X%02X\n",
iobuf[0],iobuf[1],iobuf[2],iobuf[3],
iobuf[4],iobuf[5],iobuf[6],iobuf[7]);
dev_desc->lba =((unsigned long)iobuf[0]<<24) +
((unsigned long)iobuf[1]<<16) +
((unsigned long)iobuf[2]<< 8) +
((unsigned long)iobuf[3]);
dev_desc->blksz=((unsigned long)iobuf[4]<<24) +
((unsigned long)iobuf[5]<<16) +
((unsigned long)iobuf[6]<< 8) +
((unsigned long)iobuf[7]);
dev_desc->lba48 = 0; /* ATAPI devices cannot use 48bit addressing (ATA/ATAPI v7) */
return;
}
/*
* atapi_read:
* we transfer only one block per command, since the multiple DRQ per
* command is not yet implemented
*/
#define ATAPI_READ_MAX_BYTES 2048 /* we read max 2kbytes */
#define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */
#define ATAPI_READ_MAX_BLOCK ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE /* max blocks */
Grant Likely
committed
ulong atapi_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
{
ulong n = 0;
unsigned char ccb[12]; /* Command descriptor block */
ulong cnt;
debug ("atapi_read dev %d start %lX, blocks %lX buffer at %lX\n",
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
device, blknr, blkcnt, (ulong)buffer);
do {
if (blkcnt>ATAPI_READ_MAX_BLOCK) {
cnt=ATAPI_READ_MAX_BLOCK;
} else {
cnt=blkcnt;
}
ccb[0]=ATAPI_CMD_READ_12;
ccb[1]=0; /* reserved */
ccb[2]=(unsigned char) (blknr>>24) & 0xFF; /* MSB Block */
ccb[3]=(unsigned char) (blknr>>16) & 0xFF; /* */
ccb[4]=(unsigned char) (blknr>> 8) & 0xFF;
ccb[5]=(unsigned char) blknr & 0xFF; /* LSB Block */
ccb[6]=(unsigned char) (cnt >>24) & 0xFF; /* MSB Block count */
ccb[7]=(unsigned char) (cnt >>16) & 0xFF;
ccb[8]=(unsigned char) (cnt >> 8) & 0xFF;
ccb[9]=(unsigned char) cnt & 0xFF; /* LSB Block */
ccb[10]=0; /* reserved */
ccb[11]=0; /* reserved */
if (atapi_issue_autoreq(device,ccb,12,
(unsigned char *)buffer,
cnt*ATAPI_READ_BLOCK_SIZE) == 0xFF) {
return (n);
}
n+=cnt;
blkcnt-=cnt;
blknr+=cnt;
buffer+=(cnt*ATAPI_READ_BLOCK_SIZE);
} while (blkcnt > 0);
return (n);
}
/* ------------------------------------------------------------------------- */
#endif /* CONFIG_ATAPI */
U_BOOT_CMD(
ide, 5, 1, do_ide,
"reset - reset IDE controller\n"
"ide info - show available IDE devices\n"
"ide device [dev] - show or set current device\n"
"ide part [dev] - print partition table of one or all IDE devices\n"
"ide read addr blk# cnt\n"
"ide write addr blk# cnt - read/write `cnt'"
" blocks starting at block `blk#'\n"
U_BOOT_CMD(
diskboot, 3, 1, do_diskboot,