aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-03-29 12:45:53 -0400
committerKevin O'Connor <kevin@koconnor.net>2008-03-29 12:45:53 -0400
commit0cdac0e6206367616ad03eed93b3bf9f0999461f (patch)
treefff161c97a0fb3050bb655cc51ca2aea05509ccd
parentf06f03a8727193171cf7f6bd062ecf911119d883 (diff)
downloadseabios-0cdac0e6206367616ad03eed93b3bf9f0999461f.tar.gz
Reorder basic_access() to reduce stack usage.
-rw-r--r--src/disk.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/disk.c b/src/disk.c
index 880052b3..83452087 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -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) {
@@ -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"