Reorder basic_access() to reduce stack usage.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 29 Mar 2008 16:45:53 +0000 (12:45 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 29 Mar 2008 16:45:53 +0000 (12:45 -0400)
src/disk.c

index 880052b381f0b84b7cb34b92d992a5e9c3d3c72d..8345208725853a4757a300620505ae9164d11a34 100644 (file)
@@ -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"