Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reorder basic_access() to reduce stack usage.
  • Loading branch information
KevinOConnor committed Mar 29, 2008
1 parent f06f03a commit 0cdac0e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/disk.c
Expand Up @@ -39,18 +39,6 @@ checksum_seg(u16 seg, u16 offset, u32 len)
static void
basic_access(struct bregs *regs, u8 device, u16 command)
{
u16 count = regs->al;
u16 cylinder = regs->ch | ((((u16) regs->cl) << 2) & 0x300);
u16 sector = regs->cl & 0x3f;
u16 head = regs->dh;

if (count > 128 || count == 0 || sector == 0) {
BX_INFO("int13_harddisk: function %02x, parameter out of range!\n"
, regs->ah);
disk_ret(regs, DISK_RET_EPARAM);
return;
}

u8 type = GET_EBDA(ata.devices[device].type);
u16 nlc, nlh, nlspt;
if (type == ATA_TYPE_ATA) {
Expand All @@ -64,6 +52,18 @@ basic_access(struct bregs *regs, u8 device, u16 command)
nlspt = GET_EBDA(cdemu.vdevice.spt);
}

u16 count = regs->al;
u16 cylinder = regs->ch | ((((u16) regs->cl) << 2) & 0x300);
u16 sector = regs->cl & 0x3f;
u16 head = regs->dh;

if (count > 128 || count == 0 || sector == 0) {
BX_INFO("int13_harddisk: function %02x, parameter out of range!\n"
, regs->ah);
disk_ret(regs, DISK_RET_EPARAM);
return;
}

// sanity check on cyl heads, sec
if (cylinder >= nlc || head >= nlh || sector > nlspt) {
BX_INFO("int13_harddisk: function %02x, parameters out of"
Expand Down

0 comments on commit 0cdac0e

Please sign in to comment.