u8 channel = ataid / 2;
u16 iobase1 = GET_GLOBAL(ATA_channels[channel].iobase1);
u8 status = inb(iobase1 + ATA_CB_STAT);
- return (status & ( ATA_CB_STAT_BSY | ATA_CB_STAT_RDY )) == ATA_CB_STAT_RDY;
+ if ((status & (ATA_CB_STAT_BSY|ATA_CB_STAT_RDY)) == ATA_CB_STAT_RDY)
+ return DISK_RET_SUCCESS;
+ return DISK_RET_ENOTREADY;
}
static int
return 0;
case CMD_RESET:
ata_reset(op->driveid);
- return 0;
+ return DISK_RET_SUCCESS;
case CMD_ISREADY:
return isready(op->driveid);
}
if (!CONFIG_ATA)
return 0;
+ int ret;
switch (op->command) {
case CMD_READ:
- return ata_cmd_data(op, 0, ATA_CMD_READ_SECTORS);
+ ret = ata_cmd_data(op, 0, ATA_CMD_READ_SECTORS);
+ break;
case CMD_WRITE:
- return ata_cmd_data(op, 1, ATA_CMD_WRITE_SECTORS);
+ ret = ata_cmd_data(op, 1, ATA_CMD_WRITE_SECTORS);
+ break;
default:
return process_ata_misc_op(op);
}
+ if (ret)
+ return DISK_RET_EBADTRACK;
+ return DISK_RET_SUCCESS;
}
int
process_atapi_op(struct disk_op_s *op)
{
+ int ret;
switch (op->command) {
case CMD_READ:
- return cdrom_read(op);
+ ret = cdrom_read(op);
+ break;
default:
return process_ata_misc_op(op);
}
+ if (ret)
+ return DISK_RET_EBADTRACK;
+ return DISK_RET_SUCCESS;
}
// Send a simple atapi command to a drive.
// Update count with total sectors transferred.
SET_FARVAR(op_seg, op_far->count, dop.count);
- if (status)
- dprintf(1, "disk_op cmd %d error %d!\n", dop.command, status);
-
return status;
}
regs->al = dop.count;
- if (status) {
- disk_ret(regs, DISK_RET_EBADTRACK);
- return;
- }
- disk_ret(regs, DISK_RET_SUCCESS);
+ disk_ret(regs, status);
}
// Perform cdemu read/verify
u8 *cdbuf_far = (void*)offsetof(struct extended_bios_data_area_s, cdemu_buf);
u8 *dest_far = (void*)(regs->bx+0);
regs->al = 0;
+ int status = DISK_RET_SUCCESS;
if (vlba & 3) {
dop.count = 1;
dop.buf_fl = MAKE_FLATPTR(ebda_seg, cdbuf_far);
- int status = send_disk_op(&dop);
+ status = send_disk_op(&dop);
if (status)
goto fail;
u8 thiscount = 4 - (vlba & 3);
if (count > 3) {
dop.count = count / 4;
dop.buf_fl = MAKE_FLATPTR(regs->es, dest_far);
- int status = send_disk_op(&dop);
+ status = send_disk_op(&dop);
regs->al += dop.count * 4;
if (status)
goto fail;
if (count) {
dop.count = 1;
dop.buf_fl = MAKE_FLATPTR(ebda_seg, cdbuf_far);
- int status = send_disk_op(&dop);
+ status = send_disk_op(&dop);
if (status)
goto fail;
u8 thiscount = count;
regs->al += thiscount;
}
- disk_ret(regs, DISK_RET_SUCCESS);
- return;
fail:
- disk_ret(regs, DISK_RET_EBADTRACK);
+ disk_ret(regs, status);
}
// Perform read/write/verify using new-style "int13ext" accesses.
SET_INT13EXT(regs, count, dop.count);
- if (status) {
- disk_ret(regs, DISK_RET_EBADTRACK);
- return;
- }
- disk_ret(regs, DISK_RET_SUCCESS);
+ disk_ret(regs, status);
}
struct disk_op_s dop;
dop.driveid = driveid;
dop.command = CMD_RESET;
- send_disk_op(&dop);
+ int status = send_disk_op(&dop);
+ disk_ret(regs, status);
}
// read disk status
dop.driveid = driveid;
dop.command = CMD_ISREADY;
int status = send_disk_op(&dop);
- if (status)
- disk_ret(regs, DISK_RET_ENOTREADY);
- else
- disk_ret(regs, DISK_RET_SUCCESS);
+ disk_ret(regs, status);
}
// recalibrate