debug_stub(regs);
struct chs_s chs = getLCHS(drive_gf);
- u16 nlh=chs.head, nls=chs.sector;
+ u16 nlc=chs.cylinder, nlh=chs.head, nls=chs.sector;
- u8 num_sectors = regs->al;
- u8 head = regs->dh;
+ u8 count = regs->al;
+ u8 cylinder = regs->ch;
+ u8 head = regs->dh;
- if (head >= nlh || num_sectors == 0 || num_sectors > nls) {
+ if (cylinder >= nlc || head >= nlh || count == 0 || count > nls) {
disk_ret(regs, DISK_RET_EPARAM);
return;
}
struct disk_op_s dop;
dop.drive_gf = drive_gf;
dop.command = CMD_FORMAT;
- dop.lba = head;
- dop.count = num_sectors;
+ dop.lba = (((u32)cylinder * (u32)nlh) + (u32)head) * (u32)nls;
+ dop.count = count;
dop.buf_fl = MAKE_FLATPTR(regs->es, regs->bx);
int status = send_disk_op(&dop);
disk_ret(regs, status);
static int
floppy_format(struct disk_op_s *op)
{
- u8 head = op->lba;
+ struct chs_s chs = lba2chs(op);
// send format-track command to controller
u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id);
u8 param[7];
- param[0] = (head << 2) | floppyid; // HD DR1 DR2
+ param[0] = (chs.head << 2) | floppyid; // HD DR1 DR2
param[1] = FLOPPY_SIZE_CODE;
param[2] = op->count; // number of sectors per track
param[3] = FLOPPY_FORMAT_GAPLEN;