]> xenbits.xensource.com Git - seabios.git/commitdiff
disk: Avoid stack_hop() path if already on the extra stack
authorKevin O'Connor <kevin@koconnor.net>
Thu, 31 Mar 2016 18:29:07 +0000 (14:29 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 31 Mar 2016 18:53:44 +0000 (14:53 -0400)
If CONFIG_ENTRY_EXTRASTACK is set (enabled by default) then the 16bit
disk interface code is already running on the extra stack and it is
not necessary to support stack switching on each disk request.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/block.c
src/disk.c

index a38357478a054dd597f7fbe46e611007fd5b53ec..f7280cf1766eb9d5f801be7d40328794672776dc 100644 (file)
@@ -599,6 +599,10 @@ process_op_16(struct disk_op_s *op)
 int
 process_op(struct disk_op_s *op)
 {
+    dprintf(DEBUG_HDL_13, "disk_op d=%p lba=%d buf=%p count=%d cmd=%d\n"
+            , op->drive_gf, (u32)op->lba, op->buf_fl
+            , op->count, op->command);
+
     int ret, origcount = op->count;
     if (origcount * GET_GLOBALFLAT(op->drive_gf->blksize) > 64*1024) {
         op->count = 0;
index bcd6a09fdb31e6f7a871d68b4017e83ce8a5c58e..6e58428b425c951e92de15f9a1002935a9fcaa27 100644 (file)
@@ -87,18 +87,12 @@ getLCHS(struct drive_s *drive_gf)
     return res;
 }
 
-// Execute a "disk_op_s" request - this runs on the extra stack.
+// Execute a "disk_op_s" request after jumping to the extra stack.
 static int
 __send_disk_op(struct disk_op_s *op_far, u16 op_seg)
 {
     struct disk_op_s dop;
-    memcpy_far(GET_SEG(SS), &dop
-               , op_seg, op_far
-               , sizeof(dop));
-
-    dprintf(DEBUG_HDL_13, "disk_op d=%p lba=%d buf=%p count=%d cmd=%d\n"
-            , dop.drive_gf, (u32)dop.lba, dop.buf_fl
-            , dop.count, dop.command);
+    memcpy_far(GET_SEG(SS), &dop, op_seg, op_far, sizeof(dop));
 
     int status = process_op(&dop);
 
@@ -108,15 +102,17 @@ __send_disk_op(struct disk_op_s *op_far, u16 op_seg)
     return status;
 }
 
-// Execute a "disk_op_s" request by jumping to the extra 16bit stack.
+// Execute a "disk_op_s" request (using the extra 16bit stack).
 static int
 send_disk_op(struct disk_op_s *op)
 {
     ASSERT16();
     if (! CONFIG_DRIVES)
         return -1;
-
-    return stack_hop(__send_disk_op, op, GET_SEG(SS));
+    if (!CONFIG_ENTRY_EXTRASTACK)
+        // Jump on to extra stack
+        return stack_hop(__send_disk_op, op, GET_SEG(SS));
+    return process_op(op);
 }
 
 // Perform read/write/verify using old-style chs accesses