aboutsummaryrefslogtreecommitdiff
path: root/src/disk.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2013-12-11 19:15:45 -0500
committerKevin O'Connor <kevin@koconnor.net>2013-12-12 23:14:19 -0500
commitb84899e1df0030387d009b4a061becf0699523a1 (patch)
treeb381c88026ba9f40cf840699327fbff2b1630444 /src/disk.c
parentcd891f1b587c50ed189e84758073084884e23a2b (diff)
downloadseabios-hppa-b84899e1df0030387d009b4a061becf0699523a1.zip
seabios-hppa-b84899e1df0030387d009b4a061becf0699523a1.tar.gz
seabios-hppa-b84899e1df0030387d009b4a061becf0699523a1.tar.bz2
On disk format request, verify cylinders and pass to driver.
The regs->ch field contains the cylinder to format on a disk_1305 call. Verify that parameter and pass to the low-level driver code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/disk.c')
-rw-r--r--src/disk.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/disk.c b/src/disk.c
index 1011b39..4421d9d 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -186,12 +186,13 @@ disk_1305(struct bregs *regs, struct drive_s *drive_gf)
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;
}
@@ -199,8 +200,8 @@ disk_1305(struct bregs *regs, struct drive_s *drive_gf)
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);