// 3 : error
// 4 : not ready
u16
-ata_cmd_packet(u16 device, u16 cmdbuf, u8 cmdlen, u16 header
+ata_cmd_packet(u16 device, u8 *cmdbuf, u8 cmdlen, u16 header
, u32 length, u8 inout, u16 bufseg, u16 bufoff)
{
u16 iobase1, iobase2;
// Send command to device
irq_enable();
- outsw(iobase1, GET_SEG(SS), cmdbuf, cmdlen);
+ outsw(iobase1, GET_SEG(SS), (u32)cmdbuf, cmdlen);
if (inout == ATA_DATA_NO) {
await_ide(NOT_BSY, iobase1, IDE_TIMEOUT);
status = inb(iobase1 + ATA_CB_STAT);
- }
- else {
+ } else {
u16 loops = 0;
u8 sc;
while (1) {
if (loops == 0) {//first time through
status = inb(iobase2 + ATA_CB_ASTAT);
await_ide(NOT_BSY_DRQ, iobase1, IDE_TIMEOUT);
- }
- else
+ } else
await_ide(NOT_BSY, iobase1, IDE_TIMEOUT);
loops++;
lcount = ((u16)(inb(iobase1 + ATA_CB_CH))<<8)+inb(iobase1 + ATA_CB_CL);
// adjust to read what we want
- if(header>lcount) {
+ if (header > lcount) {
lbefore=lcount;
header-=lcount;
lcount=0;
- }
- else {
+ } else {
lbefore=header;
header=0;
lcount-=lbefore;
}
- if(lcount>length) {
+ if (lcount > length) {
lafter=lcount-length;
lcount=length;
length=0;
- }
- else {
+ } else {
lafter=0;
length-=lcount;
}
inw(iobase1);
if (lmode == ATA_MODE_PIO32)
- insl(iobase1, bufoff, bufseg, lcount);
+ insl(iobase1, bufseg, bufoff, lcount);
else
- insw(iobase1, bufoff, bufseg, lcount);
+ insw(iobase1, bufseg, bufoff, lcount);
for (i=0; i<lafter; i++)
if (lmode == ATA_MODE_PIO32)
return 0;
}
+u16
+cdrom_read(u16 device, u32 lba, u32 count, u16 segment, u16 offset, u16 skip)
+{
+ u16 sectors = (count + 2048 - 1) / 2048;
+
+ u8 atacmd[12];
+ memset(atacmd, 0, sizeof(atacmd));
+ atacmd[0]=0x28; // READ command
+ atacmd[7]=(sectors & 0xff00) >> 8; // Sectors
+ atacmd[8]=(sectors & 0x00ff); // Sectors
+ atacmd[2]=(lba & 0xff000000) >> 24; // LBA
+ atacmd[3]=(lba & 0x00ff0000) >> 16;
+ atacmd[4]=(lba & 0x0000ff00) >> 8;
+ atacmd[5]=(lba & 0x000000ff);
+
+ return ata_cmd_packet(device, atacmd, sizeof(atacmd)
+ , skip, count, ATA_DATA_IN
+ , segment, offset);
+}
+
// ---------------------------------------------------------------------------
// ATA/ATAPI driver : device detection
// ---------------------------------------------------------------------------
SET_EBDA(ata.devices[device].lchs.spt, spt);
// fill hdidmap
- SET_EBDA(ata.hdidmap[hdcount], device);
+ SET_EBDA(ata.idmap[0][hdcount], device);
hdcount++;
}
SET_EBDA(ata.devices[device].blksize, blksize);
// fill cdidmap
- SET_EBDA(ata.cdidmap[cdcount], device);
+ SET_EBDA(ata.idmap[1][cdcount], device);
cdcount++;
}