Index: trunk/src/ahci.c
===================================================================
--- trunk/src/ahci.c	(revision 7)
+++ trunk/src/ahci.c	(revision 8)
@@ -37,6 +37,4 @@
 /* -------------------------- function prototypes -------------------------- */
 
-static int  exec_polled_cmd       (AD_INFO *ai, int p, int d, int timeout,
-                                   int cmd, ...);
 static void ahci_setup_device     (AD_INFO *ai, int p, int d, u16 *id_buf);
 static void _far timeout_callback (ULONG timer_handle, ULONG p1, ULONG p2);
@@ -265,5 +263,5 @@
 
   /* set maximum command slot number */
-  ai->cmd_max = (u16) ((ai->cap >> 8) & 31);
+  ai->cmd_max = (u16) ((ai->cap >> 8) & 0x1f);
 
   return(0);
@@ -404,5 +402,5 @@
  *  - This function is expected to be called with the spinlock released but
  *    the corresponding adapter's busy flag set. It will aquire the spinlock
- *    temporarily to allocate/free memory for ATA identify buffer.
+ *    temporarily to allocate/free memory for the ATA identify buffer.
  */
 int ahci_scan_ports(AD_INFO *ai)
@@ -457,13 +455,13 @@
       /* this port has a device attached and is ready to accept commands */
       ddprintf("port #%d seems to be attached to a device; probing...\n", p);
-      rc = exec_polled_cmd(ai, p, 0, 500, ATA_CMD_ID_ATA, 
-                           AP_VADDR, (void _far *) id_buf, 512,
-                           AP_END);
+      rc = ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_ID_ATA, 
+                                AP_VADDR, (void _far *) id_buf, 512,
+                                AP_END);
 
       if (rc != 0 || id_buf[ATA_ID_CONFIG] & (1U << 15)) {
         /* this might be an ATAPI device; run IDENTIFY_PACKET_DEVICE */
-        rc = exec_polled_cmd(ai, p, 0, 500, ATA_CMD_ID_ATAPI,
-                             AP_VADDR, (void _far *) id_buf, 512,
-                             AP_END);
+        rc = ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_ID_ATAPI,
+                                  AP_VADDR, (void _far *) id_buf, 512,
+                                  AP_END);
       }
 
@@ -826,15 +824,16 @@
 {
   volatile u32 *cmds;
+  ADD_WORKSPACE _far *aws = add_workspace(iorb);
   AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb);
   P_INFO *port = ai->ports + iorb_unit_port(iorb);
   ULONG timeout = (iorb->Timeout > 0) ? iorb->Timeout : DEFAULT_TIMEOUT;
   u8 _far *port_mmio = port_base(ai, iorb_unit_port(iorb));
-  int is_ncq = ((ai->cap & HOST_CAP_NCQ) &&
-                ncq_capable &&
-                !add_workspace(iorb)->no_ncq);
   int i;
 
-  /* NCQ disabled temporarily until non-NCQ commands are working fine */
-  is_ncq = 0;
+  /* determine whether this will be an NCQ request */
+  aws->is_ncq = ((ai->cap & HOST_CAP_NCQ) && ncq_capable && !aws->no_ncq);
+
+  /* NCQ disabled temporarily until non-NCQ commands are fully working */
+  aws->is_ncq = 0;
 
   /* check whether adapter is available */
@@ -851,5 +850,6 @@
 
     /* prevent NCQ/regular command mix */
-    if (is_ncq && port->reg_cmds == 0 || !is_ncq && port->ncq_cmds == 0) {
+    if (aws->is_ncq && port->reg_cmds == 0 ||
+        !aws->is_ncq && port->ncq_cmds == 0) {
 
       /* Find next available command slot. We use a simple round-robin 
@@ -857,10 +857,10 @@
        * from stalling when new commands are coming in frequently.
        */
-      cmds = (is_ncq) ? &port->ncq_cmds : &port->reg_cmds;
+      cmds = (aws->is_ncq) ? &port->ncq_cmds : &port->reg_cmds;
       for (i = 0; i <= ai->cmd_max; i++) {
         if ((*cmds & (1UL << port->cmd_slot)) == 0) {
           break;
         }
-        if (++(port->cmd_slot) >= ai->cmd_max) {
+        if (++(port->cmd_slot) > ai->cmd_max) {
           port->cmd_slot = 0;
         }
@@ -879,18 +879,14 @@
 
         /* start timer for this IORB */
-        ADD_StartTimerMS(&add_workspace(iorb)->timer, timeout,
-                         (PFN) timeout_callback, iorb, 0);
-
-        /* update IORB and increment next command index */
-        add_workspace(iorb)->queued_hw = 1;
-        add_workspace(iorb)->cmd_slot = port->cmd_slot;
-        if (++(port->cmd_slot) >= ai->cmd_max) {
-          port->cmd_slot = 0;
-        }
+        ADD_StartTimerMS(&aws->timer, timeout, (PFN) timeout_callback, iorb, 0);
+
+        /* update IORB */
+        aws->queued_hw = 1;
+        aws->cmd_slot = port->cmd_slot;
 
         /* issue command to hardware */
-        dprintf("issuing command on slot %d\n", port->cmd_slot);
+        ddprintf("issuing command on slot %d\n", port->cmd_slot);
         *cmds |= (1UL << port->cmd_slot);
-        if (is_ncq) {
+        if (aws->is_ncq) {
           writel(port_mmio + PORT_SCR_ACT, (1UL << port->cmd_slot));
           readl(port_mmio + PORT_SCR_ACT); /* flush */
@@ -899,4 +895,8 @@
         readl(port_mmio + PORT_CMD_ISSUE); /* flush */
 
+        /* make sure next cmd won't use the same slot to prevent starvation */
+        if (++(port->cmd_slot) > ai->cmd_max) {
+          port->cmd_slot = 0;
+        }
         spin_unlock(drv_lock);
         return;
@@ -906,5 +906,5 @@
 
   /* requeue this IORB; it will be picked up again in trigger_engine() */
-  add_workspace(iorb)->processing = 0;
+  aws->processing = 0;
   spin_unlock(drv_lock);
 }
@@ -916,5 +916,7 @@
  *
  *  - We need to restore the BIOS configuration after we're done with this
- *    command because we might still need the BIOS to load additional drivers.
+ *    command because someone might still call int 13 routines; sending
+ *    asynchronous commands and waiting for interrupts to indicate completion
+ *    won't work in such a scenario.
  *  - Our context hooks won't work while the device managers are initializing
  *    (they can't yield at init time).
@@ -951,5 +953,5 @@
   }
 
-  /* restart port (includes the necessary port configuration */
+  /* restart port (includes the necessary port configuration) */
   if (ahci_stop_port(ai, p) || ahci_start_port(ai, p, 0)) {
     iorb_seterr(iorb, IOERR_ADAPTER_NONSPECIFIC);
@@ -983,4 +985,6 @@
       if (add_workspace(iorb)->ppfunc != NULL) {
         add_workspace(iorb)->ppfunc(iorb);
+      } else {
+        add_workspace(iorb)->complete = 1;
       }
     }
@@ -994,6 +998,61 @@
   ahci_restore_bios_config(ai);
 
-  iorb_done(iorb);
+  if (add_workspace(iorb)->complete | (iorb->Status | IORB_ERROR)) {
+    aws_free(add_workspace(iorb));
+    iorb_done(iorb);
+  }
   return;
+}
+
+/******************************************************************************
+ * Execute polled ATA/ATAPI command. This function will block until the command
+ * has completed or the timeout has expired, thus it should only be used during
+ * initialization. Furthermore, it will always use command slot zero.
+ *
+ * The difference to ahci_exec_polled_iorb() is that this function executes
+ * arbitrary ATA/ATAPI commands outside the context of an IORB. It's typically
+ * used when scanning for devices during initialization.
+ */
+int ahci_exec_polled_cmd(AD_INFO *ai, int p, int d, int timeout, int cmd, ...)
+{
+  va_list va;
+  u8 _far *port_mmio = port_base(ai, p);
+  u32 tmp;
+  int rc;
+
+  /* verify that command slot 0 is idle */
+  if (readl(port_mmio + PORT_CMD_ISSUE) & 1) {
+    ddprintf("port %d slot 0 is not idle; not executing polled cmd\n", p);
+    return(-1);
+  }
+
+  /* fill in command slot 0 */
+  va_start(va, cmd);
+  if ((rc = v_ata_cmd(ai, p, d, 0, cmd, va)) != 0) {
+    return(rc);
+  }
+
+  /* start command execution for slot 0 */
+  ddprintf("executing polled cmd...");
+  writel(port_mmio + PORT_CMD_ISSUE, 1);
+
+  /* wait until command has completed */
+  while (timeout > 0 && (readl(port_mmio + PORT_CMD_ISSUE) & 1)) {
+    mdelay(10);
+    timeout -= 10;
+  }
+  ddprintf(" done (time left = %d)\n", timeout);
+
+  /* check error condition */
+  if ((tmp = readl(port_mmio + PORT_SCR_ERR)) != 0) {
+    dprintf("SERR = 0x%08lx\n", tmp);
+    return(-1);
+  }
+  if (((tmp = readl(port_mmio + PORT_TFDATA)) & 0x89) != 0) {
+    dprintf("TFDATA = 0x%08lx\n", tmp);
+    return(-1);
+  }
+
+  return((timeout <= 0) ? -1 : 0);
 }
 
@@ -1119,10 +1178,16 @@
       if (aws->ppfunc != NULL) {
         aws->ppfunc(iorb);
+      } else {
+        aws->complete = 1;
       }
-      aws_free(aws);
-
-      /* move IORB to our temporary done queue */
-      iorb_queue_del(&ai->ports[p].iorb_queue, iorb);
-      iorb_queue_add(&done_queue, iorb);
+
+      if (aws->complete) {
+        /* this IORB is complete */
+        aws_free(aws);
+
+        /* move IORB to our temporary done queue */
+        iorb_queue_del(&ai->ports[p].iorb_queue, iorb);
+        iorb_queue_add(&done_queue, iorb);
+      }
 
       /* clear corresponding bit in issued command bitmaps */
@@ -1205,4 +1270,7 @@
 void ahci_get_geometry(IORBH _far *iorb)
 {
+  dprintf("ahci_get_geometry(%d.%d.%d)\n", (int) iorb_unit_adapter(iorb),
+          (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb));
+
   ahci_exec_iorb(iorb, 0, cmd_func(iorb, get_geometry));
 }
@@ -1213,4 +1281,7 @@
 void ahci_unit_ready(IORBH _far *iorb)
 {
+  dprintf("ahci_unit_ready(%d.%d.%d)\n", (int) iorb_unit_adapter(iorb),
+          (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb));
+
   ahci_exec_iorb(iorb, 0, cmd_func(iorb, unit_ready));
 }
@@ -1221,4 +1292,9 @@
 void ahci_read(IORBH _far *iorb)
 {
+  dprintf("ahci_read(%d.%d.%d, %ld, %ld)\n", (int) iorb_unit_adapter(iorb),
+          (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb),
+          (long) ((IORB_EXECUTEIO _far *) iorb)->RBA,
+          (long) ((IORB_EXECUTEIO _far *) iorb)->BlockCount);
+
   ahci_exec_iorb(iorb, 1, cmd_func(iorb, read));
 }  
@@ -1229,4 +1305,9 @@
 void ahci_verify(IORBH _far *iorb)
 {
+  dprintf("ahci_verify(%d.%d.%d, %ld, %ld)\n", (int) iorb_unit_adapter(iorb),
+          (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb),
+          (long) ((IORB_EXECUTEIO _far *) iorb)->RBA,
+          (long) ((IORB_EXECUTEIO _far *) iorb)->BlockCount);
+
   ahci_exec_iorb(iorb, 0, cmd_func(iorb, verify));
 }
@@ -1237,4 +1318,9 @@
 void ahci_write(IORBH _far *iorb)
 {
+  dprintf("ahci_write(%d.%d.%d, %ld, %ld)\n", (int) iorb_unit_adapter(iorb),
+          (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb),
+          (long) ((IORB_EXECUTEIO _far *) iorb)->RBA,
+          (long) ((IORB_EXECUTEIO _far *) iorb)->BlockCount);
+
   ahci_exec_iorb(iorb, 1, cmd_func(iorb, write));
 }
@@ -1248,4 +1334,9 @@
   int p = iorb_unit_port(iorb);
   int d = iorb_unit_device(iorb);
+
+  dphex(((IORB_ADAPTER_PASSTHRU _far *) iorb)->pControllerCmd,
+        ((IORB_ADAPTER_PASSTHRU _far *) iorb)->ControllerCmdLen,
+        "ahci_execute_cdb(%d.%d.%d)", (int) iorb_unit_adapter(iorb),
+        (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb));
   
   if (ad_infos[a].ports[p].devs[d].atapi) {
@@ -1266,4 +1357,9 @@
   int d = iorb_unit_device(iorb);
   
+  dphex(((IORB_ADAPTER_PASSTHRU _far *) iorb)->pControllerCmd,
+        ((IORB_ADAPTER_PASSTHRU _far *) iorb)->ControllerCmdLen,
+        "ahci_execute_cdb(%d.%d.%d)", (int) iorb_unit_adapter(iorb),
+        (int) iorb_unit_port(iorb), (int) iorb_unit_device(iorb));
+  
   if (ad_infos[a].ports[p].devs[d].atapi) {
     iorb_seterr(iorb, IOERR_CMD_NOT_SUPPORTED);
@@ -1272,52 +1368,4 @@
     ahci_exec_iorb(iorb, 0, ata_execute_ata);
   }
-}
-
-/******************************************************************************
- * Execute polled ATA/ATAPI command. This function will block until the command
- * has completed or the timeout has expired, thus it should only be used during
- * initialization. Furthermore, it will always use command slot zero...
- */
-static int exec_polled_cmd(AD_INFO *ai, int p, int d, int timeout, int cmd, ...)
-{
-  va_list va;
-  u8 _far *port_mmio = port_base(ai, p);
-  u32 tmp;
-  int rc;
-
-  /* verify that command slot 0 is idle */
-  if (readl(port_mmio + PORT_CMD_ISSUE) & 1) {
-    ddprintf("port %d slot 0 is not idle; not executing polled cmd\n", p);
-    return(-1);
-  }
-
-  /* fill in command slot 0 */
-  va_start(va, cmd);
-  if ((rc = v_ata_cmd(ai, p, d, 0, cmd, va)) != 0) {
-    return(rc);
-  }
-
-  /* start command execution for slot 0 */
-  ddprintf("executing polled cmd...");
-  writel(port_mmio + PORT_CMD_ISSUE, 1);
-
-  /* wait until command has completed */
-  while (timeout > 0 && (readl(port_mmio + PORT_CMD_ISSUE) & 1)) {
-    mdelay(10);
-    timeout -= 10;
-  }
-  ddprintf(" done (time left = %d)\n", timeout);
-
-  /* check error condition */
-  if ((tmp = readl(port_mmio + PORT_SCR_ERR)) != 0) {
-    dprintf("SERR = 0x%08lx\n", tmp);
-    return(-1);
-  }
-  if (((tmp = readl(port_mmio + PORT_TFDATA)) & 0x89) != 0) {
-    dprintf("TFDATA = 0x%08lx\n", tmp);
-    return(-1);
-  }
-
-  return((timeout <= 0) ? -1 : 0);
 }
 
Index: trunk/src/ahci.h
===================================================================
--- trunk/src/ahci.h	(revision 7)
+++ trunk/src/ahci.h	(revision 8)
@@ -209,5 +209,5 @@
  *       interface it's developed for, is based on x86 design patterns, we're
  *       not even going to start making a difference between little and big
- *       endian architectures. PCI is little endoian, AHCI is little endian,
+ *       endian architectures. PCI is little endian, AHCI is little endian,
  *       x86 is little endian, and that's it.
  */
Index: trunk/src/ata.c
===================================================================
--- trunk/src/ata.c	(revision 7)
+++ trunk/src/ata.c	(revision 8)
@@ -98,5 +98,5 @@
       break;
 
-    case AP_H2D:
+    case AP_WRITE:
       ahci_flags |= AHCI_CMD_WRITE;
       break;
@@ -221,5 +221,5 @@
    *    than AHCI_MAX_SG entries. In order to help the caller, the return value
    *    of this function will indicate how many OS/2 S/G entries were
-   *    successfully be mapped.
+   *    successfully mapped.
    *
    */
@@ -306,4 +306,78 @@
 
 /******************************************************************************
+ * Get index in S/G list for the number of transferred sectors in the IORB.
+ *
+ * Returning io->cSGList indicates an error.
+ *
+ * NOTE: OS/2 makes sure S/G lists are set up such that entries at the HW
+ *       limit will never cross sector boundaries. This means that splitting
+ *       S/G lists into multiple commands can be done without editing the S/G
+ *       lists.
+ */
+u16 ata_get_sg_indx(IORB_EXECUTEIO _far *io)
+{
+  ULONG offset = io->BlocksXferred * io->BlockSize;
+  USHORT i;
+
+  for (i = 0; i < io->cSGList && offset > 0; i++) {
+    offset -= io->pSGList[i].XferBufLen;
+  }
+
+  return(i);
+}
+
+/******************************************************************************
+ * Get max S/G count which will fit into our HW S/G buffers. This function is
+ * called when the S/G list is too long and we need to split the IORB into
+ * multiple commands. It returns both the number of sectors and S/G list
+ * elements that we can handle in a single command.
+ *
+ * The parameter 'sg_indx' indicates the current start index in the S/G list
+ * (0 if this is the first command iteration).
+ *
+ * The parameter 'sg_max' is the return value of v_ata_cmd() and indicates
+ * how many S/G elements were successfully mapped. Whatever we return needs to
+ * be less or equal to this value.
+ *
+ * Returning 0 in *sg_cnt indicates an error.
+ *
+ * NOTE: OS/2 makes sure S/G lists are set up such that entries at HW limits
+ *       will never cross sector boundaries. This means that splitting S/G
+ *       lists into multiple commands can be done without editing S/G list
+ *       elements. Since AHCI only allows 22 bits for each S/G element, the
+ *       hardware limits are reported as AHCI_MAX_SG / 2 but will vary based
+ *       on the actual length of S/G elements. This function looks for the
+ *       maximum number of S/G elements that can be mapped on sector
+ *       boundaries which will still fit into our HW S/G list.
+ */
+void ata_max_sg_cnt(IORB_EXECUTEIO _far *io, USHORT sg_indx, USHORT sg_max,
+                    USHORT _far *sg_cnt, USHORT _far *sector_cnt)
+{
+  ULONG max_sector_cnt = 0;
+  USHORT max_sg_cnt = 0;
+  ULONG offset = 0;
+  USHORT i;
+
+  for (i = sg_indx; i < io->cSGList; i++) {
+    if (i - sg_indx >= sg_max) {
+      /* we're beyond the number of S/G elements we can map */
+      break;
+    }
+
+    offset += io->pSGList[i].XferBufLen;
+    if (offset % io->BlockSize == 0) {
+      /* this S/G element ends on a sector boundary */
+      max_sector_cnt = offset / io->BlockSize;
+      max_sg_cnt = i + 1;
+    }
+  }
+
+  /* return the best match we found so far (0 indicating failure) */
+  *sector_cnt = max_sector_cnt;
+  *sg_cnt = max_sg_cnt;
+}
+
+
+/******************************************************************************
  * Get device or media geometry. Device and media geometry are expected to be
  * the same for non-removable devices, which will always be the case for the
@@ -334,5 +408,4 @@
   if (rc != 0) {
     free(aws->buf);
-    aws->buf = NULL;
     iorb_seterr(iorb, IOERR_CMD_ADD_SOFTWARE_FAILURE);
   }
@@ -404,4 +477,7 @@
                                ((u32) geometry->NumHeads *
                                 (u32) geometry->SectorsPerTrack);
+
+  /* tell interrupt handler that this IORB is complete */
+  add_workspace(iorb)->complete = 1;
 }
 
@@ -426,28 +502,53 @@
   IORB_EXECUTEIO _far *io = (IORB_EXECUTEIO _far *) iorb;
   AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb);
+  ULONG sector = io->RBA + io->BlocksXferred;
+  USHORT count = io->BlockCount - io->BlocksXferred;
+  USHORT sg_indx;
+  USHORT sg_cnt;
   int p = iorb_unit_port(iorb);
   int d = iorb_unit_device(iorb);
   int rc;
 
-  /* prepare read command */
-  if (io->RBA >= (1UL << 28) || io->BlockCount > 256) {
-    /* need LBA48 for this command */
-    if (!ai->ports[p].devs[d].lba48) {
-      iorb_seterr(iorb, IOERR_RBA_LIMIT);
-      return(-1);
-    }
-    rc = ata_cmd(ai, p, d, slot, ATA_CMD_READ_EXT,
-                 AP_SECTOR_48, (u32) io->RBA, (u16) 0,
-                 AP_COUNT,     (u16) io->BlockCount,
-                 AP_SGLIST,    io->pSGList, (u16) io->cSGList,
-                 AP_DEVICE,    0x4000,
-                 AP_END);
+  /* prepare read command while keeping an eye on S/G count limitations */
+  do {
+    sg_indx = ata_get_sg_indx(io);
+    sg_cnt = io->cSGList - sg_indx;
+
+    if (sector >= (1UL << 28) || count > 256) {
+      /* need LBA48 for this command */
+      if (!ai->ports[p].devs[d].lba48) {
+        iorb_seterr(iorb, IOERR_RBA_LIMIT);
+        return(-1);
+      }
+      rc = ata_cmd(ai, p, d, slot, ATA_CMD_READ_EXT,
+                   AP_SECTOR_48, (u32) sector, (u16) 0,
+                   AP_COUNT,     (u16) count,
+                   AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
+                   AP_DEVICE,    0x4000,
+                   AP_END);
+    } else {
+      rc = ata_cmd(ai, p, d, slot, ATA_CMD_READ,
+                   AP_SECTOR_28, (u32) sector,
+                   AP_COUNT,     (u16) count & 0xffU,
+                   AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
+                   AP_DEVICE,    0x4000,
+                   AP_END);
+    }
+
+    if (rc > 0) {
+      /* couldn't map all S/G elements */
+      ata_max_sg_cnt(io, sg_indx, (USHORT) rc, &sg_cnt, &count);
+    }
+  } while (rc > 0 && sg_cnt > 0);
+
+  if (rc == 0) {
+    add_workspace(iorb)->blocks = count;
+    add_workspace(iorb)->ppfunc = ata_read_pp;
+
+  } else if (rc > 0) {
+    iorb_seterr(iorb, IOERR_CMD_SGLIST_BAD);
+
   } else {
-    rc = ata_cmd(ai, p, d, slot, ATA_CMD_READ,
-                 AP_SECTOR_28, (u32) io->RBA,
-                 AP_COUNT,     (u16) io->BlockCount & 0xffU,
-                 AP_SGLIST,    io->pSGList, (u16) io->cSGList,
-                 AP_DEVICE,    0x4000,
-                 AP_END);
+    iorb_seterr(iorb, IOERR_CMD_ADD_SOFTWARE_FAILURE);
   }
 
@@ -456,5 +557,26 @@
 
 /******************************************************************************
- * Verify readability of sectors on AHCI device.
+ * Post processing function for ata_read(); this function updates the
+ * BlocksXferred counter in the IORB and, if not all blocks have been
+ * transferred, requeues the IORB to process the remaining sectors.
+ */
+void ata_read_pp(IORBH _far *iorb)
+{
+  IORB_EXECUTEIO _far *io = (IORB_EXECUTEIO _far *) iorb;
+
+  io->BlocksXferred += add_workspace(iorb)->blocks;
+  ddprintf("ata_read_pp(): blocks transferred = %d\n", (int) io->BlocksXferred);
+
+  if (io->BlocksXferred >= io->BlockCount) {
+    /* we're done; tell IRQ handler the IORB is complete */
+    add_workspace(iorb)->complete = 1;
+  } else {
+    /* requeue this IORB for next iteration */
+    iorb_requeue(iorb);
+  }
+}
+
+/******************************************************************************
+ * Verify readability of sectors on ATA device.
  */
 int ata_verify(IORBH _far *iorb, int slot)
@@ -476,5 +598,4 @@
                  AP_SECTOR_48, (u32) io->RBA, (u16) 0,
                  AP_COUNT,     (u16) io->BlockCount,
-                 AP_SGLIST,    io->pSGList, (u16) io->cSGList,
                  AP_DEVICE,    0x4000,
                  AP_END);
@@ -483,5 +604,4 @@
                  AP_SECTOR_28, (u32) io->RBA,
                  AP_COUNT,     (u16) io->BlockCount & 0xffU,
-                 AP_SGLIST,    io->pSGList, (u16) io->cSGList,
                  AP_END);
   }
@@ -497,31 +617,79 @@
   IORB_EXECUTEIO _far *io = (IORB_EXECUTEIO _far *) iorb;
   AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb);
+  ULONG sector = io->RBA + io->BlocksXferred;
+  USHORT count = io->BlockCount - io->BlocksXferred;
+  USHORT sg_indx;
+  USHORT sg_cnt;
   int p = iorb_unit_port(iorb);
   int d = iorb_unit_device(iorb);
   int rc;
 
-  /* prepare write command */
-  if (io->RBA >= (1UL << 28) || io->BlockCount > 256) {
-    /* need LBA48 for this command */
-    if (!ai->ports[p].devs[d].lba48) {
-      iorb_seterr(iorb, IOERR_RBA_LIMIT);
-      return(-1);
-    }
-    rc = ata_cmd(ai, p, d, slot, ATA_CMD_WRITE_EXT,
-                 AP_SECTOR_48, (u32) io->RBA, (u16) 0,
-                 AP_COUNT,     (u16) io->BlockCount,
-                 AP_SGLIST,    io->pSGList, (u16) io->cSGList,
-                 AP_DEVICE,    0x4000,
-                 AP_END);
+  /* prepare write command while keeping an eye on S/G count limitations */
+  do {
+    sg_indx = ata_get_sg_indx(io);
+    sg_cnt = io->cSGList - sg_indx;
+
+    if (sector >= (1UL << 28) || count > 256) {
+      /* need LBA48 for this command */
+      if (!ai->ports[p].devs[d].lba48) {
+        iorb_seterr(iorb, IOERR_RBA_LIMIT);
+        return(-1);
+      }
+      rc = ata_cmd(ai, p, d, slot, ATA_CMD_WRITE_EXT,
+                   AP_SECTOR_48, (u32) sector, (u16) 0,
+                   AP_COUNT,     (u16) count,
+                   AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
+                   AP_DEVICE,    0x4000,
+                   AP_WRITE,
+                   AP_END);
+    } else {
+      rc = ata_cmd(ai, p, d, slot, ATA_CMD_WRITE,
+                   AP_SECTOR_28, (u32) sector,
+                   AP_COUNT,     (u16) count & 0xffU,
+                   AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
+                   AP_DEVICE,    0x4000,
+                   AP_WRITE,
+                   AP_END);
+    }
+
+    if (rc > 0) {
+      /* couldn't map all S/G elements */
+      ata_max_sg_cnt(io, sg_indx, (USHORT) rc, &sg_cnt, &count);
+    }
+  } while (rc > 0 && sg_cnt > 0);
+
+  if (rc == 0) {
+    add_workspace(iorb)->blocks = count;
+    add_workspace(iorb)->ppfunc = ata_write_pp;
+
+  } else if (rc > 0) {
+    iorb_seterr(iorb, IOERR_CMD_SGLIST_BAD);
+
   } else {
-    rc = ata_cmd(ai, p, d, slot, ATA_CMD_WRITE,
-                 AP_SECTOR_28, (u32) io->RBA,
-                 AP_COUNT,     (u16) io->BlockCount & 0xffU,
-                 AP_SGLIST,    io->pSGList, (u16) io->cSGList,
-                 AP_DEVICE,    0x4000,
-                 AP_END);
+    iorb_seterr(iorb, IOERR_CMD_ADD_SOFTWARE_FAILURE);
   }
 
   return(rc);
+}
+
+/******************************************************************************
+ * Post processing function for ata_write(); this function updates the
+ * BlocksXferred counter in the IORB and, if not all blocks have been
+ * transferred, requeues the IORB to process the remaining sectors.
+ */
+void ata_write_pp(IORBH _far *iorb)
+{
+  IORB_EXECUTEIO _far *io = (IORB_EXECUTEIO _far *) iorb;
+
+  io->BlocksXferred += add_workspace(iorb)->blocks;
+  ddprintf("ata_write_pp(): blocks transferred = %d\n", (int) io->BlocksXferred);
+
+  if (io->BlocksXferred >= io->BlockCount) {
+    /* we're done; tell IRQ handler the IORB is complete */
+    add_workspace(iorb)->complete = 1;
+  } else {
+    /* requeue this IORB for next iteration */
+    iorb_requeue(iorb);
+  }
 }
 
@@ -536,9 +704,52 @@
 
 /******************************************************************************
- * Request sense information (which means "read ATA log page" for ATA devices)
+ * Request sense information for a failed command. Since there is no "request
+ * sense" command for ATA devices, we need to read the current error code from
+ * the AHCI task file register and fabricate the sense information.
+ *
+ * NOTES:
+ *
+ *   - This function must be called right after an ATA command has failed and
+ *     before any other commands are queued on the corresponding port. This
+ *     function is typically called in the port restart context hook which is
+ *     triggered by an AHCI error interrupt.
+ *
+ *   - The ATA error bits are a complete mess. We'll try and catch the most
+ *     interesting error codes (such as medium errors) and report everything
+ *     else with a generic error code.
  */
 int ata_req_sense(IORBH _far *iorb, int slot)
 {
-  iorb_seterr(iorb, IOERR_CMD_NOT_SUPPORTED);
+  AD_INFO *ai = ad_infos + iorb_unit_adapter(iorb);
+  u8 _far *port_mmio = port_base(ai, iorb_unit_port(iorb));
+  u32 tf_data = readl(port_mmio + PORT_TFDATA);
+  u8 err = (u8) (tf_data >> 8);
+  u8 sts = (u8) (tf_data);
+
+  if (sts & ATA_ERR) {
+    if (sts & ATA_DF) {
+      /* there is a device-specific error condition */
+      if (err & ATA_ICRC) {
+        iorb_seterr(iorb, IOERR_ADAPTER_DEVICEBUSCHECK);
+      } else if (err & ATA_UNC) {
+        iorb_seterr(iorb, IOERR_MEDIA);
+      } else if (err & ATA_IDNF) {
+        iorb_seterr(iorb, IOERR_RBA_ADDRESSING_ERROR);
+      } else {
+        iorb_seterr(iorb, IOERR_DEVICE_NONSPECIFIC);
+      }
+    
+    } else {
+      iorb_seterr(iorb, IOERR_DEVICE_NONSPECIFIC);
+    }
+  }
+
+  /* TBD: fill in SCSI sense buffer in IORB */
+
+  /* Return an error to indicate there's no HW command to be submitted and
+   * that the IORB can be completed "as is" (the upstream code expects the
+   * IORB error code, if any, to be set when this happens and this is exactly
+   * what this function is all about).
+   */
   return(-1);
 }
Index: trunk/src/ata.h
===================================================================
--- trunk/src/ata.h	(revision 7)
+++ trunk/src/ata.h	(revision 8)
@@ -396,5 +396,5 @@
   AP_SGLIST,       /* [void _far *, u16] buffer S/G (SCATGATENTRY/count)    */
   AP_VADDR,        /* [void _far *, u16] buffer virtual address (buf/len)   */
-  AP_H2D,          /* []                 host-to-device direction           */
+  AP_WRITE,        /* []                 indicates a DMA write operation    */
   AP_AHCI_FLAGS,   /* [u16]              AHCI command header flags          */
   AP_ATAPI_CMD,    /* [void _far *, u16] ATAPI command (CDB) and length     */
@@ -442,4 +442,8 @@
 extern void      ata_cmd_to_fis      (u8 _far *fis, ATA_CMD _far *cmd,
                                       int device);
+extern USHORT    ata_get_sg_indx     (IORB_EXECUTEIO _far *io);
+extern void      ata_max_sg_cnt      (IORB_EXECUTEIO _far *io, USHORT sg_indx,
+                                      USHORT sg_max, USHORT _far *sg_cnt,
+                                      USHORT _far *sector_cnt);
 
 extern int       ata_get_geometry    (IORBH _far *iorb, int slot);
@@ -447,7 +451,11 @@
 extern int       ata_unit_ready      (IORBH _far *iorb, int slot);
 extern int       ata_read            (IORBH _far *iorb, int slot);
+extern void      ata_read_pp         (IORBH _far *iorb);
 extern int       ata_verify          (IORBH _far *iorb, int slot);
 extern int       ata_write           (IORBH _far *iorb, int slot);
+extern void      ata_write_pp        (IORBH _far *iorb);
 extern int       ata_execute_ata     (IORBH _far *iorb, int slot);
 extern int       ata_req_sense       (IORBH _far *iorb, int slot);
+
 extern char     *ata_dev_name        (u16 *id_buf);
+
Index: trunk/src/ctxhook.c
===================================================================
--- trunk/src/ctxhook.c	(revision 7)
+++ trunk/src/ctxhook.c	(revision 8)
@@ -82,4 +82,5 @@
 void restart_ctxhook(ULONG parm)
 {
+  IORB_QUEUE done_queue;
   AD_INFO *ai;
   IORBH _far *problem_iorb;
@@ -92,7 +93,8 @@
   int a;
   int p;
-  int d;
 
   dprintf("restart_ctxhook() started\n");
+  memset(&done_queue, 0x00, sizeof(done_queue));
+
   spin_lock(drv_lock);
 
@@ -108,7 +110,7 @@
     for (p = 0; p <= ai->port_max; p++) {
       if (ports_to_restart[a] & (1UL << p)) {
+        ports_to_restart[a] &= ~(1UL << p);
 
         /* restart this port */
-        ports_to_restart[a] &= ~(1UL << p);
         port_mmio = port_base(ai, p);
         problem_iorb = NULL;
@@ -124,4 +126,6 @@
           if (aws->queued_hw) {
             if (ai->ports[p].ncq_cmds != 0) {
+              /* NCQ commands active; force non-NCQ mode and trigger port reset */
+              aws->no_ncq = 1;
               need_reset = 1;
             } else if (aws->cmd_slot == ccs) {
@@ -129,9 +133,5 @@
               problem_iorb = iorb;
             }
-
-            /* requeue this command with the 'no_ncq' flag set */
-            aws_free(aws);
-            memset(&iorb->ADDWorkSpace, sizeof(iorb->ADDWorkSpace), 0x00);
-            aws->no_ncq = 1;
+            iorb_requeue(iorb);
 
             /* remove requeued command from the issued command bitmaps */
@@ -166,23 +166,39 @@
         ai->busy = 0;
 
-        /* reset port status */
-        ai->ports[p].cmd_slot = 0;
+        /* reset internal port status */
         ai->ports[p].ncq_cmds = 0;
         ai->ports[p].reg_cmds = 0;
-
-        if (!need_reset && problem_iorb != NULL) {
-          /* request sense data for the failing command in cmd slot #0 */
-          ADD_WORKSPACE _far *aws = add_workspace(problem_iorb);
-          aws->processing = 1;
-          aws->queued_hw = 1;
-          d = iorb_unit_device(problem_iorb);
-          if (ai->ports[p].devs[d].atapi) {
-            atapi_req_sense(problem_iorb, 0);
+        ai->ports[p].cmd_slot = 0;
+
+        if (problem_iorb != NULL) {
+          /* get details about the error that caused this IORB to fail */
+          if (need_reset) {
+            /* no way to retrieve error details after a reset */
+            iorb_seterr(problem_iorb, IOERR_DEVICE_NONSPECIFIC);
+            iorb_queue_del(&ai->ports[p].iorb_queue, problem_iorb);
+            iorb_queue_add(&done_queue, problem_iorb);
+
           } else {
-            ata_req_sense(problem_iorb, 0);
+            /* get sense information */
+            ADD_WORKSPACE _far *aws = add_workspace(problem_iorb);
+            int d = iorb_unit_device(problem_iorb);
+            int (*req_sense)(IORBH _far *, int) = 
+              (ai->ports[p].devs[d].atapi) ? atapi_req_sense : ata_req_sense;
+
+            aws->processing = 1;
+            aws->queued_hw = 1;
+
+            if (req_sense(problem_iorb, 0) == 0) {
+              /* execute request sense on slot #0 before anything else comes along */
+              ai->ports[p].reg_cmds = 1;
+              writel(port_mmio + PORT_CMD_ISSUE, 1);
+              readl(port_mmio); /* flush */
+
+            } else {
+              /* IORB is expected to contain the error code; just move to done queue */
+              iorb_queue_del(&ai->ports[p].iorb_queue, problem_iorb);
+              iorb_queue_add(&done_queue, problem_iorb);
+            }
           }
-          ai->ports[p].reg_cmds = 1;
-          writel(port_mmio + PORT_CMD_ISSUE, 1);
-          readl(port_mmio); /* flush */
         }
       }
@@ -190,5 +206,16 @@
   }
 
+  spin_unlock(drv_lock);
+
+  /* call notification routine on all IORBs which have completed */
+  for (iorb = done_queue.root; iorb != NULL; iorb = next) {
+    next = iorb->pNxtIORB;
+    if (iorb->RequestControl & IORB_ASYNC_POST) {
+      iorb->NotifyAddress(iorb);
+    }
+  }
+
   /* restart engine to resume IORB processing */
+  spin_lock(drv_lock);
   trigger_engine();
   spin_unlock(drv_lock);
@@ -283,4 +310,6 @@
     for (p = 0; p <= ai->port_max; p++) {
       if (ports_to_reset[a] & (1UL << p)) {
+        ports_to_reset[a] &= ~(1UL << p);
+
         /* Reset this port. Since this is a rather slow operation, we'll
          * release the spinlock while doing so. The adapter is marked as
@@ -288,5 +317,4 @@
          * interfering. 
          */
-        ports_to_reset[a] &= ~(1UL << p);
         ai->busy = 1;
         spin_unlock(drv_lock);
Index: trunk/src/libc.i
===================================================================
--- trunk/src/libc.i	(revision 7)
+++ 	(revision )
@@ -1,955 +1,0 @@
-#line 1 "libc.c"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 1 "os2ahci.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef unsigned char    u8;
-typedef unsigned short   u16;
-typedef unsigned long    u32;
-
-
-typedef struct {
-  u32   options;         
-  u32   status;          
-  u32   tbl_addr;        
-  u32   tbl_addr_high;   
-  u32   reserved[4];
-} AHCI_CMD_HDR;
-
-
-typedef struct {
-  u32   addr;            
-  u32   addr_hi;         
-  u32   reserved;
-  u32   flags_size;      
-} AHCI_SG;
-
-
-
-
-
-typedef struct {
-  u16   vendor;          
-  u16   device;          
-  u16   subvendor;       
-  u16   subdevice;       
-  u32   class;           
-  u32   class_mask;      
-  u32   board;           
-} PCI_ID;
-
-
-typedef struct D_INFO {
-  struct D_INFO  *next;         
-  char            vendor[8];    
-  char            product[8];   
-  char            revision[8];  
-  u32             sectors;      
-};
-
-
-typedef struct P_INFO {
-  struct P_INFO  *p_info;       
-} P_INFO;
-
-
-typedef struct AD_INFO {
-  struct AD_INFO  *next;        
-  PCI_ID          *pci_id;      
-  P_INFO           ports[32];   
-  int              intr;        
-  u8              *mmio;        
-  u8              *dma_buf;     
-} AD_INFO;
-
-
-
-
-
-
-extern int         debug;          
-
-extern PCI_ID      pci_ids[];      
-extern AD_INFO    *ai_root;        
-
-#line 23 "libc.c"
-
-#line 1 "i:/c600/include\\stdarg.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 16 "i:/c600/include\\stdarg.h"
-
-
-
-
-
-#line 22 "i:/c600/include\\stdarg.h"
-
-
-
-
-
-
-
-
-
-
-#line 33 "i:/c600/include\\stdarg.h"
-#line 34 "i:/c600/include\\stdarg.h"
-
-
-typedef char  *va_list;
-
-#line 39 "i:/c600/include\\stdarg.h"
-
-
-
-
-#line 25 "libc.c"
-#line 1 "i:/c600/include\\stdio.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 16 "i:/c600/include\\stdio.h"
-
-
-
-
-
-#line 22 "i:/c600/include\\stdio.h"
-
-
-typedef unsigned int size_t;
-
-#line 27 "i:/c600/include\\stdio.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 41 "i:/c600/include\\stdio.h"
-
-
-
-struct _iobuf {
-	char  *_ptr;
-	int   _cnt;
-	char  *_base;
-	char  _flag;
-	char  _file;
-	};
-typedef struct _iobuf FILE;
-
-#line 54 "i:/c600/include\\stdio.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern FILE _near _cdecl _iob[];
-#line 105 "i:/c600/include\\stdio.h"
-#line 106 "i:/c600/include\\stdio.h"
-
-
-
-
-
-typedef long fpos_t;
-
-#line 114 "i:/c600/include\\stdio.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-int  _cdecl _filbuf(FILE  *);
-int  _cdecl _flsbuf(int, FILE  *);
-FILE  *  _cdecl _fsopen(const char  *,
-	const char  *, int);
-void  _cdecl clearerr(FILE  *);
-int  _cdecl fclose(FILE  *);
-int  _cdecl fcloseall(void);
-FILE  *  _cdecl fdopen(int, const char  *);
-int  _cdecl feof(FILE  *);
-int  _cdecl ferror(FILE  *);
-int  _cdecl fflush(FILE  *);
-int  _cdecl fgetc(FILE  *);
-int  _cdecl fgetchar(void);
-int  _cdecl fgetpos(FILE  *, fpos_t  *);
-char  *  _cdecl fgets(char  *, int, FILE  *);
-int  _cdecl fileno(FILE  *);
-int  _cdecl flushall(void);
-FILE  *  _cdecl fopen(const char  *,
-	const char  *);
-int  _cdecl fprintf(FILE  *, const char  *, ...);
-int  _cdecl fputc(int, FILE  *);
-int  _cdecl fputchar(int);
-int  _cdecl fputs(const char  *, FILE  *);
-size_t  _cdecl fread(void  *, size_t, size_t, FILE  *);
-FILE  *  _cdecl freopen(const char  *,
-	const char  *, FILE  *);
-int  _cdecl fscanf(FILE  *, const char  *, ...);
-int  _cdecl fsetpos(FILE  *, const fpos_t  *);
-int  _cdecl fseek(FILE  *, long, int);
-long  _cdecl ftell(FILE  *);
-size_t  _cdecl fwrite(const void  *, size_t, size_t,
-	FILE  *);
-int  _cdecl getc(FILE  *);
-int  _cdecl getchar(void);
-char  *  _cdecl gets(char  *);
-int  _cdecl getw(FILE  *);
-void  _cdecl perror(const char  *);
-int  _cdecl _pclose(FILE  *);
-FILE  *  _cdecl _popen(const char  *,
-	const char  *);
-int  _cdecl printf(const char  *, ...);
-int  _cdecl putc(int, FILE  *);
-int  _cdecl putchar(int);
-int  _cdecl puts(const char  *);
-int  _cdecl putw(int, FILE  *);
-int  _cdecl remove(const char  *);
-int  _cdecl rename(const char  *, const char  *);
-void  _cdecl rewind(FILE  *);
-int  _cdecl rmtmp(void);
-int  _cdecl scanf(const char  *, ...);
-void  _cdecl setbuf(FILE  *, char  *);
-int  _cdecl setvbuf(FILE  *, char  *, int, size_t);
-int  _cdecl sprintf(char  *, const char  *, ...);
-int  _cdecl sscanf(const char  *, const char  *, ...);
-char  *  _cdecl tempnam(char  *, char  *);
-FILE  *  _cdecl tmpfile(void);
-char  *  _cdecl tmpnam(char  *);
-int  _cdecl ungetc(int, FILE  *);
-int  _cdecl unlink(const char  *);
-int  _cdecl vfprintf(FILE  *, const char  *, va_list);
-int  _cdecl vprintf(const char  *, va_list);
-int  _cdecl vsprintf(char  *, const char  *, va_list);
-
-#line 206 "i:/c600/include\\stdio.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 26 "libc.c"
-#line 1 "i:/c600/include\\string.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 16 "i:/c600/include\\string.h"
-
-
-
-
-
-#line 22 "i:/c600/include\\string.h"
-
-
-
-
-
-
-
-
-void  *  _cdecl memccpy(void  *, const void  *,
-	int, unsigned int);
-void  *  _cdecl memchr(const void  *, int, size_t);
-int  _cdecl memcmp(const void  *, const void  *,
-	size_t);
-int  _cdecl memicmp(const void  *, const void  *,
-	unsigned int);
-void  *  _cdecl memcpy(void  *, const void  *,
-	size_t);
-void  *  _cdecl memmove(void  *, const void  *,
-	size_t);
-void  *  _cdecl memset(void  *, int, size_t);
-void  _cdecl movedata(unsigned int, unsigned int, unsigned int,
-	unsigned int, unsigned int);
-char  *  _cdecl strcat(char  *, const char  *);
-char  *  _cdecl strchr(const char  *, int);
-int  _cdecl strcmp(const char  *, const char  *);
-int  _cdecl strcmpi(const char  *, const char  *);
-int  _cdecl strcoll(const char  *, const char  *);
-int  _cdecl stricmp(const char  *, const char  *);
-char  *  _cdecl strcpy(char  *, const char  *);
-size_t  _cdecl strcspn(const char  *, const char  *);
-char  *  _cdecl strdup(const char  *);
-char  *  _cdecl _strerror(const char  *);
-char  *  _cdecl strerror(int);
-size_t  _cdecl strlen(const char  *);
-char  *  _cdecl strlwr(char  *);
-char  *  _cdecl strncat(char  *, const char  *,
-	size_t);
-int  _cdecl strncmp(const char  *, const char  *,
-	size_t);
-int  _cdecl strnicmp(const char  *, const char  *,
-	size_t);
-char  *  _cdecl strncpy(char  *, const char  *,
-	size_t);
-char  *  _cdecl strnset(char  *, int, size_t);
-char  *  _cdecl strpbrk(const char  *,
-	const char  *);
-char  *  _cdecl strrchr(const char  *, int);
-char  *  _cdecl strrev(char  *);
-char  *  _cdecl strset(char  *, int);
-size_t  _cdecl strspn(const char  *, const char  *);
-char  *  _cdecl strstr(const char  *,
-	const char  *);
-char  *  _cdecl strtok(char  *, const char  *);
-char  *  _cdecl strupr(char  *);
-size_t  _cdecl strxfrm (char  *, const char  *,
-	size_t);
-
-
-
-void _far * _far _cdecl _fmemccpy(void _far *, const void _far *,
-	int, unsigned int);
-void _far * _far _cdecl _fmemchr(const void _far *, int, size_t);
-int _far _cdecl _fmemcmp(const void _far *, const void _far *,
-	size_t);
-void _far * _far _cdecl _fmemcpy(void _far *, const void _far *,
-	size_t);
-int _far _cdecl _fmemicmp(const void _far *, const void _far *,
-	unsigned int);
-void _far * _far _cdecl _fmemmove(void _far *, const void _far *,
-	size_t);
-void _far * _far _cdecl _fmemset(void _far *, int, size_t);
-char _far * _far _cdecl _fstrcat(char _far *, const char _far *);
-char _far * _far _cdecl _fstrchr(const char _far *, int);
-int _far _cdecl _fstrcmp(const char _far *, const char _far *);
-int _far _cdecl _fstricmp(const char _far *, const char _far *);
-char _far * _far _cdecl _fstrcpy(char _far *, const char _far *);
-size_t _far _cdecl _fstrcspn(const char _far *, const char _far *);
-char _far * _far _cdecl _fstrdup(const char _far *);
-char _near * _far _cdecl _nstrdup(const char _far *);
-size_t _far _cdecl _fstrlen(const char _far *);
-char _far * _far _cdecl _fstrlwr(char _far *);
-char _far * _far _cdecl _fstrncat(char _far *, const char _far *,
-	size_t);
-int _far _cdecl _fstrncmp(const char _far *, const char _far *,
-	size_t);
-int _far _cdecl _fstrnicmp(const char _far *, const char _far *,
-	size_t);
-char _far * _far _cdecl _fstrncpy(char _far *, const char _far *,
-	size_t);
-char _far * _far _cdecl _fstrnset(char _far *, int, size_t);
-char _far * _far _cdecl _fstrpbrk(const char _far *,
-	const char _far *);
-char _far * _far _cdecl _fstrrchr(const char _far *, int);
-char _far * _far _cdecl _fstrrev(char _far *);
-char _far * _far _cdecl _fstrset(char _far *, int);
-size_t _far _cdecl _fstrspn(const char _far *, const char _far *);
-char _far * _far _cdecl _fstrstr(const char _far *,
-	const char _far *);
-char _far * _far _cdecl _fstrtok(char _far *, const char _far *);
-char _far * _far _cdecl _fstrupr(char _far *);
-#line 27 "libc.c"
-
-
-
-
-
-
-
-static void long_to_asc(long val, char *buf, int radix);
-
-
-
-static char hex_digits[] = "0123456789abcdef";
-
-
-
-
-
-
-
-
-int vsprintf(char *buf, const char *fmt, va_list va)
-{
-  char *orig = buf;
-  char *s;
-  int lmod;
-
-  for (; *fmt != '\0'; fmt++) {
-    switch (*fmt) {
-
-    case '%':
-      lmod = (fmt[1] == 'l') ? 1 : 0;
-      fmt += lmod;
-      switch (fmt[1]) {
-
-      case 's':
-        if ((s = ((char *  *)(va += sizeof(char *)))[-1]) == ((void *)0))
-          s = "[null]";
-        while ((*buf = *(s++)) != '\0')
-          buf++;
-        break;
-      
-      case 'd':
-        long_to_asc((lmod) ? ((long  *)(va += sizeof(long)))[-1] : ((int  *)(va += sizeof(int)))[-1], buf, 10);
-        buf += strlen(buf);
-        break;
-
-      case 'x':
-        long_to_asc((lmod) ? ((long  *)(va += sizeof(long)))[-1] : ((int  *)(va += sizeof(int)))[-1], buf, 16);
-        buf += strlen(buf);
-        break;
-
-      default:
-        *(buf++) = *fmt;
-        break;
-      }
-
-    case '\n':
-      *(buf++) = '\r';
-      *(buf++) = '\n';
-      break;
-
-    default:
-      *(buf++) = *fmt;
-      break;
-
-    }
-  }
-
-  *buf = '\0';
-  return((size_t) (buf - orig));
-}
-
-
-
-
-int sprintf(char *buf, const char *fmt, ...)
-{
-  va_list va;
-
-  va = (va_list)&fmt + sizeof(fmt);
-  return(vsprintf(buf, fmt, va));
-}
-
-
-
-
-
-
-
-void dprintf(const char *fmt, ...)
-{
-  static long mutex;
-  static char buf[1024];
-  va_list va;
-  char *s;
-
-  if (!debug) {
-    return;
-  }
-
-  DevHelp_SemRequest(&mutex, -1L);
-
-  va = (va_list)&fmt + sizeof(fmt);
-  vsprintf(buf, fmt, va);
-
-  
-  for (s = buf; *s != '\0'; s++) {
-    while (!inp(0x3fd) & 0x40);         
-    outp(0x3f8, *s);                    
-  }
-
-  DevHelp_SemClear(&mutex);
-}
-
-
-
-
-void *memmove(void *v_dst, void *v_src, size_t len)
-{
-  char *dst = (char *) v_dst;
-  char *src = (char *) v_src;
-  void *orig = dst;
-
-  if (dst <= src || dst > src + len) {
-    
-    while (len--) {
-      *(dst++) = *(src++);
-    }
-
-  } else {
-    
-
-
-    src += len;
-    dst += len;
-    while (len--) {
-      *(--dst) = *(--src);
-    }
-  }
-
-  return(orig);
-}
-
-
-
-
-size_t strlen(const char *s)
-{
-  size_t len = 0;
-
-  while (*(s++) != '\0') {
-    len++;
-  }
-  return(len);
-}
-
-
-
-
-char *strcpy(char *dst, const char *src)
-{
-  char *orig = dst;
-
-  while ((*(dst++) = *(src++)) != '\0');
-  return(orig);
-}
-
-
-
-
-static void long_to_asc(long val, char *buf, int radix)
-{
-  char tmp[80];
-  char *s;
-
-  if (radix > 16) {
-    sprintf(buf, "n/a");
-  }
-
-  tmp[sizeof(tmp) - 1] = '\0';
-
-  for (s = tmp + sizeof(tmp) - 2; s > tmp; s--) {
-    *s = hex_digits[val % radix];
-    if ((val /= radix) == 0) {
-      break;
-    }
-  }
-
-  strcpy(buf, s);
-}
-
Index: trunk/src/os2ahci.c
===================================================================
--- trunk/src/os2ahci.c	(revision 7)
+++ trunk/src/os2ahci.c	(revision 8)
@@ -700,5 +700,13 @@
     ptr->AdapterHostBus  = AI_HOSTBUS_OTHER | AI_BUSWIDTH_32BIT;
     ptr->AdapterFlags    = AF_16M | AF_HW_SCATGAT;
-    ptr->MaxHWSGList     = AHCI_MAX_SG;
+
+    /* AHCI limits S/G elements to 22 bits, thus we'll report only half of
+     * our S/G list buffers to reduce complexity. The command preparation code
+     * will always try to map as many S/G elements as possible so the physical
+     * S/G list capacity is not really wasted except in rare conditions where
+     * we need to split commands with long S/G lists without any suitable split
+     * points except those at the reported MaxHWSGList.
+     */
+    ptr->MaxHWSGList     = AHCI_MAX_SG / 2;
 
     if (!ad_info->port_scan_done) {
@@ -978,2 +986,20 @@
 }
 
+/******************************************************************************
+ * Requeue the specified IORB such that it will be sent downstream for
+ * processing again. This includes freeing all resources currently allocated
+ * (timer, buffer, ...) and resetting the flags to 0.
+ *
+ * The following flags are preserved:
+ *  - no_ncq
+ */
+void iorb_requeue(IORBH _far *iorb)
+{
+  ADD_WORKSPACE _far *aws = add_workspace(iorb);
+  u16 no_ncq = aws->no_ncq;
+
+  aws_free(aws);
+  memset(aws, 0x00, sizeof(*aws));
+  aws->no_ncq = no_ncq;
+}
+
Index: trunk/src/os2ahci.h
===================================================================
--- trunk/src/os2ahci.h	(revision 7)
+++ trunk/src/os2ahci.h	(revision 8)
@@ -317,12 +317,14 @@
 /* ADD workspace in IORB (must not exceed 16 bytes) */
 typedef struct {
-  IORBH _far   *next;                  /* link to next IORB in our own queues */
   void (*ppfunc)(IORBH _far *iorb);    /* post-processing function */
   void         *buf;                   /* response buffer (e.g. for identify cmds) */
   ULONG         timer;                 /* timer for timeout procesing */
+  USHORT        blocks;                /* number of blocks to be transferred */
   unsigned      processing    : 1;     /* IORB is being processd */
   unsigned      idempotent    : 1;     /* IORB is idempotent (can be retried) */
   unsigned      queued_hw     : 1;     /* IORB has been queued to hardware */
-  unsigned      no_ncq        : 1;     /* don't use native command queuing */
+  unsigned      no_ncq        : 1;     /* must not use native command queuing */
+  unsigned      is_ncq        : 1;     /* should use native command queueing */
+  unsigned      complete      : 1;     /* IORB has completed processing */
   unsigned      cmd_slot      : 4;     /* AHCI command slot for this IORB */
 } ADD_WORKSPACE;
@@ -357,4 +359,5 @@
 extern void    iorb_seterr            (IORBH _far *iorb, USHORT error_code);
 extern void    iorb_done              (IORBH _far *iorb);
+extern void    iorb_requeue           (IORBH _far *iorb);
 
 /* ahci.c */
@@ -380,4 +383,6 @@
                                              int (*func)(IORBH _far *, int),
                                              ULONG timeout);
+extern int     ahci_exec_polled_cmd         (AD_INFO *ai, int p, int d,
+                                             int timeout, int cmd, ...);
 
 extern int     ahci_intr                    (u16 irq);
Index: trunk/src/os2ahci.i
===================================================================
--- trunk/src/os2ahci.i	(revision 7)
+++ 	(revision )
@@ -1,11322 +1,0 @@
-#line 1 "os2ahci.c"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 1 "os2ahci.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 1 "i:/ddk/base/h\\os2.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    
-#line 22 "i:/ddk/base/h\\os2.h"
-#line 23 "i:/ddk/base/h\\os2.h"
-
-
-
-
-#line 28 "i:/ddk/base/h\\os2.h"
-
-
-
-
-#line 1 "i:/ddk/base/h\\os2def.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-   
-
-
-
-
-
-
-#line 45 "i:/ddk/base/h\\os2def.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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-#line 75 "i:/ddk/base/h\\os2def16.h"
-
-typedef unsigned short  SHANDLE;
-
-typedef void _far        *LHANDLE;
-
-
-
-
-
-
-
-#line 87 "i:/ddk/base/h\\os2def16.h"
-
-
-typedef unsigned char UCHAR;    
-typedef unsigned short USHORT;  
-typedef unsigned long ULONG;    
-
-typedef unsigned int  UINT;     
-#line 95 "i:/ddk/base/h\\os2def16.h"
-
-typedef unsigned char BYTE;     
-
-typedef unsigned char _far  *PSZ;
-typedef unsigned char _near *NPSZ;
-
-typedef unsigned char _far  *PCH;
-typedef unsigned char _near *NPCH;
-
-typedef int   (_pascal _far  *PFN)();
-typedef int   (_pascal _near *NPFN)();
-
-typedef BYTE   _far  *PBYTE;
-typedef BYTE   _near *NPBYTE;
-
-typedef char   _far *PCHAR;
-typedef short  _far *PSHORT;
-typedef long   _far *PLONG;
-
-typedef int    _far *PINT;
-#line 116 "i:/ddk/base/h\\os2def16.h"
-
-typedef UCHAR  _far *PUCHAR;
-typedef USHORT _far *PUSHORT;
-typedef ULONG  _far *PULONG;
-
-typedef UINT   _far *PUINT;
-#line 123 "i:/ddk/base/h\\os2def16.h"
-
-typedef void   _far *PVOID;
-typedef PVOID  _far *PPVOID;
-
-typedef unsigned short BOOL;    
-typedef BOOL _far *PBOOL;
-
-
-
-
-typedef struct _QWORD {        
-        ULONG   ulLo;
-        ULONG   ulHi;
-} QWORD;
-
-typedef QWORD _far *PQWORD;
-
-
-
-
-
-typedef unsigned short SEL;     
-typedef SEL _far *PSEL;
-
-
-
-
-
-
-
-
-
-#line 156 "i:/ddk/base/h\\os2def16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef ULONG ERRORID;  
-typedef ERRORID _far *PERRORID;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef SHANDLE HMODULE;        
-typedef SHANDLE PID;            
-typedef SHANDLE TID;            
-
-typedef USHORT  SGID;           
-#line 216 "i:/ddk/base/h\\os2def16.h"
-
-typedef HMODULE _far *PHMODULE;
-typedef PID _far *PPID;
-typedef TID _far *PTID;
-
-
-typedef void _far *HSEM;     
-typedef HSEM _far *PHSEM;
-#line 225 "i:/ddk/base/h\\os2def16.h"
-
-
-
-typedef LHANDLE   HAB;      
-typedef HAB _far *PHAB;
-
-
-
-typedef LHANDLE   HPS;      
-typedef HPS _far *PHPS;
-
-typedef LHANDLE   HDC;      
-typedef HDC _far *PHDC;
-
-typedef LHANDLE   HRGN;     
-typedef HRGN _far *PHRGN;
-
-typedef LHANDLE   HBITMAP;  
-typedef HBITMAP _far *PHBITMAP;
-
-typedef LHANDLE   HMF;      
-typedef HMF _far *PHMF;
-
-typedef LHANDLE   HPAL;     
-typedef HPAL _far *PHPAL;
-
-typedef long     COLOR;    
-typedef COLOR _far *PCOLOR;
-
-typedef struct _POINTL  {    
-    long  x;
-    long  y;
-} POINTL;
-typedef POINTL  _far  *PPOINTL;
-typedef POINTL  _near *NPPOINTL;
-
-typedef struct _POINTS { 
-    short x;
-    short y;
-} POINTS;
-typedef POINTS _far *PPOINTS;
-
-typedef struct _RECTL {      
-    long  xLeft;
-    long  yBottom;
-    long  xRight;
-    long  yTop;
-} RECTL;
-typedef RECTL _far  *PRECTL;
-typedef RECTL _near *NPRECTL;
-
-typedef char STR8[8];       
-typedef STR8 _far *PSTR8;
-
-
-typedef  long FIXED;     
-typedef  FIXED _far *PFIXED;
-
-typedef struct _MATRIXLF       
-{
-   FIXED fxM11;
-   FIXED fxM12;
-   long  lM13;
-   FIXED fxM21;
-   FIXED fxM22;
-   long  lM23;
-   long  lM31;
-   long  lM32;
-   long  lM33;
-} MATRIXLF;
-typedef MATRIXLF _far *PMATRIXLF;
-
-
-
-
-
-typedef struct _DRIVDATA {      
-    long    cb;
-    long    lVersion;
-    char    szDeviceName[32];
-    char    abGeneralData[1];
-} DRIVDATA;
-typedef DRIVDATA _far *PDRIVDATA;
-
-
-
-typedef PSZ _far *PDEVOPENDATA;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _DEVOPENSTRUC {    
-    PSZ        pszLogAddress;
-    PSZ        pszDriverName;
-    PDRIVDATA  pdriv;
-    PSZ        pszDataType;
-    PSZ        pszComment;
-    PSZ        pszQueueProcName;
-    PSZ        pszQueueProcParams;
-    PSZ        pszSpoolerParams;
-    PSZ        pszNetworkParams;
-} DEVOPENSTRUC;
-typedef DEVOPENSTRUC _far *PDEVOPENSTRUC;
-#line 341 "i:/ddk/base/h\\os2def16.h"
-
-
-
-typedef struct _PRINTDEST {   
-   ULONG        cb;
-   long         lType;
-   PSZ          pszToken;
-   long         lCount;
-   PDEVOPENDATA pdopData;
-   ULONG        fl;
-   PSZ          pszPrinter;
-} PRINTDEST;
-typedef PRINTDEST _far *PPRINTDEST;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _FATTRS {          
-    USHORT  usRecordLength;
-    USHORT  fsSelection;
-    long    lMatch;
-    char    szFacename[32];
-    USHORT  idRegistry;
-    USHORT  usCodePage;
-    long    lMaxBaselineExt;
-    long    lAveCharWidth;
-    USHORT  fsType;
-    USHORT  fsFontUse;
-} FATTRS;
-typedef FATTRS _far *PFATTRS;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _PANOSE { 
-    BYTE    bFamilyType;
-    BYTE    bSerifStyle;
-    BYTE    bWeight;
-    BYTE    bProportion;
-    BYTE    bContrast;
-    BYTE    bStrokeVariation;
-    BYTE    bArmStyle;
-    BYTE    bLetterform;
-    BYTE    bMidline;
-    BYTE    bXHeight;
-    BYTE    fbPassedISO;
-    BYTE    fbFailedISO;
-} PANOSE;
-
-typedef struct _FONTMETRICS {   
-    char    szFamilyname[32];
-    char    szFacename[32];
-    USHORT  idRegistry;
-    USHORT  usCodePage;
-    long    lEmHeight;
-    long    lXHeight;
-    long    lMaxAscender;
-    long    lMaxDescender;
-    long    lLowerCaseAscent;
-    long    lLowerCaseDescent;
-    long    lInternalLeading;
-    long    lExternalLeading;
-    long    lAveCharWidth;
-    long    lMaxCharInc;
-    long    lEmInc;
-    long    lMaxBaselineExt;
-    short   sCharSlope;
-    short   sInlineDir;
-    short   sCharRot;
-    USHORT  usWeightClass;
-    USHORT  usWidthClass;
-    short   sXDeviceRes;
-    short   sYDeviceRes;
-    short   sFirstChar;
-    short   sLastChar;
-    short   sDefaultChar;
-    short   sBreakChar;
-    short   sNominalPointSize;
-    short   sMinimumPointSize;
-    short   sMaximumPointSize;
-    USHORT  fsType;
-    USHORT  fsDefn;
-    USHORT  fsSelection;
-    USHORT  fsCapabilities;
-    long    lSubscriptXSize;
-    long    lSubscriptYSize;
-    long    lSubscriptXOffset;
-    long    lSubscriptYOffset;
-    long    lSuperscriptXSize;
-    long    lSuperscriptYSize;
-    long    lSuperscriptXOffset;
-    long    lSuperscriptYOffset;
-    long    lUnderscoreSize;
-    long    lUnderscorePosition;
-    long    lStrikeoutSize;
-    long    lStrikeoutPosition;
-    short   sKerningPairs;
-    short   sFamilyClass;
-    long    lMatch;
-
-
-    long    FamilyNameAtom;
-    long    FaceNameAtom;
-    PANOSE  panose;
-#line 518 "i:/ddk/base/h\\os2def16.h"
-#line 519 "i:/ddk/base/h\\os2def16.h"
-} FONTMETRICS;
-typedef FONTMETRICS _far *PFONTMETRICS;
-
-
-
-typedef void _far    *MPARAM;    
-typedef MPARAM _far  *PMPARAM;   
-typedef void _far    *MRESULT;   
-typedef MRESULT _far *PMRESULT;  
-
-typedef LHANDLE HWND;      
-typedef HWND _far *PHWND;
-
-typedef LHANDLE HMQ;       
-typedef LHANDLE _far *PHMQ;
-
-typedef struct _WRECT {    
-    short xLeft;
-    short dummy1;
-    short yBottom;
-    short dummy2;
-    short xRight;
-    short dummy3;
-    short yTop;
-    short dummy4;
-} WRECT;
-typedef WRECT _far *PWRECT;
-typedef WRECT _near *NPWRECT;
-
-typedef struct _WPOINT {   
-    short x;
-    short dummy1;
-    short y;
-    short dummy2;
-} WPOINT;
-typedef WPOINT _far *PWPOINT;
-typedef WPOINT _near *NPWPOINT;
-
-#pragma pack(2) 
-
-
-
-
-
-typedef struct _ACCEL    
-{
-   USHORT  fs;
-   USHORT  key;
-   USHORT  cmd;
-} ACCEL;
-typedef ACCEL _far *PACCEL;
-
-
-
-#pragma pack()  
-
-typedef LHANDLE HPOINTER;
-#line 650 "i:/ddk/base/h\\os2def.h"
-   #line 651 "i:/ddk/base/h\\os2def.h"
-
-#line 653 "i:/ddk/base/h\\os2def.h"
-
-
-
-
-
-
-
-
-
-
-#line 33 "i:/ddk/base/h\\os2.h"
-
-
-
-
-#line 1 "i:/ddk/base/h\\bse.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 1 "i:/ddk/base/h\\bsedos.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 1 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 91 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-USHORT  _pascal _far Dos16Beep(USHORT usFrequency, USHORT usDuration);
-
-
-
-void _pascal _far Dos16Exit(USHORT fTerminate, USHORT usExitCode);
-
-
-
-
-
-#line 106 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _GINFOSEG {      
-    ULONG   time;
-    ULONG   msecs;
-    UCHAR   hour;
-    UCHAR   minutes;
-    UCHAR   seconds;
-    UCHAR   hundredths;
-    USHORT  timezone;
-    USHORT  cusecTimerInterval;
-    UCHAR   day;
-    UCHAR   month;
-    USHORT  year;
-    UCHAR   weekday;
-    UCHAR   uchMajorVersion;
-    UCHAR   uchMinorVersion;
-    UCHAR   chRevisionLetter;
-    UCHAR   sgCurrent;
-    UCHAR   sgMax;
-    UCHAR   cHugeShift;
-    UCHAR   fProtectModeOnly;
-    USHORT  pidForeground;
-    UCHAR   fDynamicSched;
-    UCHAR   csecMaxWait;
-    USHORT  cmsecMinSlice;
-    USHORT  cmsecMaxSlice;
-    USHORT  bootdrive;
-    UCHAR   amecRAS[32];
-    UCHAR   csgWindowableVioMax;
-    UCHAR   csgPMMax;
-
-
-
-
-
-
-
-} GINFOSEG;
-typedef GINFOSEG _far *PGINFOSEG;
-
-
-
-typedef struct _LINFOSEG {      
-    PID     pidCurrent;
-    PID     pidParent;
-    USHORT  prtyCurrent;
-    TID     tidCurrent;
-    USHORT  sgCurrent;
-    UCHAR   rfProcStatus;
-    UCHAR   dummy1;
-    BOOL    fForeground;
-    UCHAR   typeProcess;
-    UCHAR   dummy2;
-    SEL     selEnvironment;
-    USHORT  offCmdLine;
-    USHORT  cbDataSegment;
-    USHORT  cbStack;
-    USHORT  cbHeap;
-    HMODULE hmod;
-    SEL     selDS;
-} LINFOSEG;
-typedef LINFOSEG _far *PLINFOSEG;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 305 "i:/ddk/base/h\\bsedos16.h"
-
-
-USHORT  _pascal _far Dos16GetInfoSeg(PSEL pselGlobal, PSEL pselLocal);
-
-
-
-
-
-
-#line 315 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 331 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct  _FIOLOCKCMD {   
-    USHORT  usCmd;              
-    USHORT  cLockCnt;           
-    ULONG   cTimeOut;           
-} FIOLOCKCMD;
-typedef FIOLOCKCMD _far *PFIOLOCKCMD;
-
-
-#pragma pack(2)
-
-
-typedef struct  _FIOLOCKREC {   
-     USHORT fShare;             
-     ULONG  cbStart;            
-     ULONG  cbLength;           
-} FIOLOCKREC;
-typedef FIOLOCKREC _far *PFIOLOCKREC;
-
-
-#pragma pack()
-
-
-typedef struct  _FIOUNLOCKCMD { 
-    USHORT  usCmd;              
-    USHORT  cUnlockCnt;         
-} FIOUNLOCKCMD;
-typedef FIOUNLOCKCMD _far *PFIOUNLOCKCMD;
-
-
-typedef struct  _FIOUNLOCKREC { 
-    ULONG   cbStart;            
-    ULONG   cbLength;           
-} FIOUNLOCKREC;
-typedef FIOUNLOCKREC _far *PFIOUNLOCKREC;
-
-
-typedef struct  _FIOSEEKCMD {   
-    USHORT  usCmd;              
-    USHORT  fsMethod;           
-                                
-    ULONG   cbDistance;         
-    ULONG   cbNewPosition;      
-} FIOSEEKCMD;
-typedef FIOSEEKCMD _far *PFIOSEEKCMD;
-
-
-#pragma pack(2)
-
-
-typedef struct  _FIOREADWRITE { 
-    USHORT      usCmd;          
-    PVOID       pbBuffer;       
-    USHORT      cbBufferLen;    
-    USHORT      cbActualLen;    
-} FIOREADWRITE;
-typedef FIOREADWRITE _far *PFIOREADWRITE;
-
-
-#pragma pack()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-                                       
-
-                                       
-
-
-
-                                       
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _FSDTHREAD {            
-        USHORT  usFunc;                
-        USHORT  usStackSize;
-        ULONG   ulPriorityClass;
-        long    lPriorityLevel;
-} FSDTHREAD;
-typedef FSDTHREAD _far * PFSDTHREAD;
-
-
-typedef struct _FSDDAEMON {            
-        USHORT     usNumThreads;       
-        USHORT     usMoreFlag;
-        USHORT     usCallInstance;
-        FSDTHREAD  tdThrds[16];
-} FSDDAEMON;
-typedef FSDDAEMON _far * PFSDDAEMON;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#pragma pack(1)
-
-
-typedef struct  _FSQBUFFER {    
-    USHORT  iType;              
-    USHORT  cbName;             
-    UCHAR   szName[1];          
-    USHORT  cbFSDName;          
-    UCHAR   szFSDName[1];       
-    USHORT  cbFSAData;          
-    UCHAR   rgFSAData[1];       
-} FSQBUFFER;
-typedef FSQBUFFER _far *PFSQBUFFER;
-
-
-#pragma pack()
-
-#pragma pack(2)
-
-
-typedef struct _SPOOLATTACH {   
-    USHORT      hNmPipe;        
-    ULONG       ulKey;          
-} SPOOLATTACH;
-typedef SPOOLATTACH _far *PSPOOLATTACH;
-
-
-#pragma pack()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef SHANDLE HFILE;          
-typedef HFILE _far *PHFILE;
-
-
-
-
-
-typedef struct _FTIME {         
-    USHORT twosecs : 5;
-    USHORT minutes : 6;
-    USHORT hours   : 5;
-} FTIME;
-typedef FTIME _far *PFTIME;
-
-typedef struct _FDATE {         
-    USHORT day     : 5;
-    USHORT month   : 4;
-    USHORT year    : 7;
-} FDATE;
-typedef FDATE _far *PFDATE;
-
-typedef struct _FILEFINDBUF {   
-    FDATE   fdateCreation;
-    FTIME   ftimeCreation;
-    FDATE   fdateLastAccess;
-    FTIME   ftimeLastAccess;
-    FDATE   fdateLastWrite;
-    FTIME   ftimeLastWrite;
-    ULONG   cbFile;
-    ULONG   cbFileAlloc;
-    USHORT  attrFile;
-    UCHAR   cchName;
-    char    achName[256];
-} FILEFINDBUF;
-typedef FILEFINDBUF _far *PFILEFINDBUF;
-
-
-#pragma pack(1)
-
-
-typedef struct _FILEFINDBUF2 {  
-    FDATE   fdateCreation;
-    FTIME   ftimeCreation;
-    FDATE   fdateLastAccess;
-    FTIME   ftimeLastAccess;
-    FDATE   fdateLastWrite;
-    FTIME   ftimeLastWrite;
-    ULONG   cbFile;
-    ULONG   cbFileAlloc;
-    USHORT  attrFile;
-    ULONG   cbList;
-    UCHAR   cchName;
-    char    achName[256];
-} FILEFINDBUF2;
-typedef FILEFINDBUF2 _far *PFILEFINDBUF2;
-
-
-#pragma pack()
-
-
-
-typedef struct _GEA {          
-    BYTE    cbName;            
-    char    szName[1];         
-} GEA;
-typedef GEA _far *PGEA;
-
-typedef struct _GEALIST {       
-    ULONG  cbList;              
-    GEA    list[1];             
-} GEALIST;
-typedef GEALIST _far * PGEALIST;
-
-typedef struct _FEA {           
-    BYTE    fEA;                
-    BYTE    cbName;             
-    USHORT  cbValue;            
-} FEA;
-typedef FEA _far *PFEA;
-
-
-
-
-
-typedef struct _FEALIST {       
-    ULONG  cbList;              
-    FEA    list[1];             
-} FEALIST;
-typedef FEALIST _far * PFEALIST;
-
-typedef struct _EAOP {          
-    PGEALIST fpGEAList;         
-    PFEALIST fpFEAList;         
-    ULONG    oError;
-} EAOP;
-typedef EAOP _far * PEAOP;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-                                          
-
-
-
-
-
-#pragma pack(1)
-
-
-typedef struct _CNPATH {      
-    ULONG   oNextEntryOffset;
-    ULONG   wFlags;
-    BYTE    cbName;
-    char    szName[1];
-} CNPATH;
-
-typedef CNPATH *PCNPATH;
-
-typedef struct _CNINFO {      
-    ULONG   oNextEntryOffset;
-    char    bAction;
-    USHORT  cbName;
-    char    szName[1];
-} CNINFO;
-
-typedef CNINFO *PCNINFO;
-
-typedef  ULONG  FHLOCK;
-typedef  PULONG  PFHLOCK;
-
-
-#pragma pack()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 780 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 851 "i:/ddk/base/h\\bsedos16.h"
-
-
-USHORT  _pascal _far Dos16Open(PSZ pszFname, PHFILE phfOpen, PUSHORT pusAction,
-                        ULONG ulFSize, USHORT usAttr, USHORT fsOpenFlags,
-                        USHORT fsOpenMode, ULONG ulReserved);
-USHORT  _pascal _far Dos16Open2(PSZ pszFname, PHFILE phf, PUSHORT pusAction,
-                         ULONG ulFSize, USHORT usAttr, USHORT usOpenFlags,
-                         ULONG usOpenMode, PEAOP pvEABuf, ULONG ulReserved);
-USHORT  _pascal _far Dos16ProtectOpen(PSZ pszFname, PHFILE phf, PUSHORT pusAction,
-                         ULONG ulFSize, USHORT usAttr, USHORT usOpenFlags,
-                         ULONG usOpenMode, PEAOP pvEABuf,
-                         PFHLOCK pfhFileHandleLockID, ULONG ulReserved);
-USHORT  _pascal _far Dos16Close(HFILE hf);
-USHORT  _pascal _far Dos16ProtectClose(HFILE hf, FHLOCK fhFileHandleLockID);
-USHORT  _pascal _far Dos16Read(HFILE hf, PVOID pBuf, USHORT cbBuf,
-                        PUSHORT pcbBytesRead);
-USHORT  _pascal _far Dos16ProtectRead(HFILE hf, PVOID pBuf, USHORT cbBuf,
-                        PUSHORT pcbBytesRead, FHLOCK fhFileHandleLockID);
-USHORT  _pascal _far Dos16Write(HFILE hf, PVOID bBuf, USHORT cbBuf,
-                         PUSHORT pcbBytesWritten);
-USHORT  _pascal _far Dos16ProtectWrite(HFILE hf, PVOID bBuf, USHORT cbBuf,
-                         PUSHORT pcbBytesWritten, FHLOCK fhFileHandleLockID);
-
-
-
-USHORT  _pascal _far Dos16Shutdown(ULONG ulReserved);
-
-
-
-typedef struct _FILESTATUS {    
-    FDATE   fdateCreation;
-    FTIME   ftimeCreation;
-    FDATE   fdateLastAccess;
-    FTIME   ftimeLastAccess;
-    FDATE   fdateLastWrite;
-    FTIME   ftimeLastWrite;
-    ULONG   cbFile;
-    ULONG   cbFileAlloc;
-    USHORT  attrFile;
-} FILESTATUS;
-typedef FILESTATUS _far *PFILESTATUS;
-
-
-#pragma pack(2)
-
-
-typedef struct _FILESTATUS2 {  
-    FDATE   fdateCreation;
-    FTIME   ftimeCreation;
-    FDATE   fdateLastAccess;
-    FTIME   ftimeLastAccess;
-    FDATE   fdateLastWrite;
-    FTIME   ftimeLastWrite;
-    ULONG   cbFile;
-    ULONG   cbFileAlloc;
-    USHORT  attrFile;
-    ULONG   cbList;
-} FILESTATUS2;
-typedef FILESTATUS2 _far *PFILESTATUS2;
-
-
-#pragma pack()
-
-
-typedef struct _FSALLOCATE {    
-    ULONG   idFileSystem;
-    ULONG   cSectorUnit;
-    ULONG   cUnit;
-    ULONG   cUnitAvail;
-    USHORT  cbSector;
-} FSALLOCATE;
-typedef FSALLOCATE _far *PFSALLOCATE;
-
-typedef struct _VOLUMELABEL {   
-    BYTE    cch;
-    char    szVolLabel[12];
-} VOLUMELABEL;
-typedef VOLUMELABEL _far *PVOLUMELABEL;
-
-typedef struct _FSINFO {        
-    ULONG ulVSN;
-    VOLUMELABEL vol;
-} FSINFO;
-typedef FSINFO _far *PFSINFO;
-
-
-
-
-
-
-
-
-typedef struct _FILELOCK {      
-    long    lOffset;
-    long    lRange;
-} FILELOCK;
-typedef FILELOCK _far *PFILELOCK;
-
-typedef SHANDLE HDIR;           
-typedef HDIR _far *PHDIR;
-
-USHORT  _pascal _far Dos16OpenChangeNotify(PCNPATH PathBuf, ULONG LogSize, PHDIR hdir,
-                                     ULONG ulReserved);
-USHORT  _pascal _far Dos16ResetChangeNotify(PCNINFO LogBuf, ULONG BufferSize,
-                                      PULONG LogCount, HDIR hdir);
-USHORT  _pascal _far Dos16CloseChangeNotify(HDIR hdir);
-
-USHORT  _pascal _far Dos16ForceDelete(PSZ pszFName, ULONG ulReserverd);
-USHORT  _pascal _far Dos16Delete(PSZ pszFName, ULONG ulReserverd);
-USHORT  _pascal _far Dos16DupHandle(HFILE hfOld, PHFILE phfNew);
-
-USHORT  _pascal _far Dos16QFHandState(HFILE hf, PUSHORT pfsOpenMode);
-USHORT  _pascal _far Dos16ProtectQFHandState(HFILE hf, PUSHORT pfsOpenMode,
-                                       FHLOCK fhFileHandleLockID);
-USHORT  _pascal _far Dos16SetFHandState(HFILE hf, USHORT fsState);
-USHORT  _pascal _far DosProtectSetFHandState(HFILE hf, USHORT fsState,
-                                         FHLOCK fhFileHandleLockID);
-USHORT  _pascal _far Dos16QHandType(HFILE hf, PUSHORT pfsType, PUSHORT pusDevAttr);
-
-USHORT  _pascal _far Dos16ReadAsync (HFILE hf, PULONG hsemRam, PUSHORT pusErrCode,
-                              PVOID pBuf, USHORT cbBuf, PUSHORT pcbBytesRead);
-USHORT  _pascal _far Dos16WriteAsync(HFILE hf, PULONG hsemRam, PUSHORT pusErrCode,
-                              PVOID pBuf, USHORT cbBuf, PUSHORT pcbBytesWritten);
-
-USHORT  _pascal _far Dos16FindFirst(PSZ pszFSpec, PHDIR phdir, USHORT usAttr,
-                             PFILEFINDBUF pffb, USHORT cbBuf, PUSHORT pcSearch,
-                             ULONG ulReserved);
-USHORT  _pascal _far Dos16FindFirst2(PSZ pszFSpec, PHDIR phdir, USHORT usAttr,
-                              PVOID pBuf, USHORT cbBuf, PUSHORT pcSearch,
-                              USHORT usInfoLevel, ULONG ulReserved);
-USHORT  _pascal _far Dos16FindNext(HDIR hdir, PFILEFINDBUF pffb, USHORT cbBuf,
-                            PUSHORT pcSearch);
-USHORT  _pascal _far Dos16FindClose(HDIR hdir);
-USHORT  _pascal _far Dos16FindNotifyFirst(PSZ pszPath, PHDIR hdir, USHORT usAttr,
-                                   PVOID pBuf, USHORT cbBuf, PUSHORT pcChg,
-                                   USHORT usInfoLevel, ULONG ulTimeOut,
-                                   ULONG ulReserved);
-USHORT  _pascal _far Dos16FindNotifyNext(HDIR hDir, PVOID pBuf, USHORT cbBuf,
-                                  PUSHORT pcChg, ULONG ulTimeOut);
-USHORT  _pascal _far Dos16FindNotifyClose(HDIR hDir);
-
-USHORT  _pascal _far Dos16FSAttach(PSZ pszDevName, PSZ pszFSD, PVOID pData,
-                            USHORT cbData, USHORT fsOp, ULONG ulReserved);
-USHORT  _pascal _far Dos16QFSAttach(PSZ pszDev, USHORT usOrdinal, USHORT usInfoLevel,
-                             PVOID pFSAttBuf, PUSHORT cbBuf, ULONG ulReserved);
-USHORT  _pascal _far Dos16FSCtl(PVOID pData, USHORT cbData, PUSHORT pcbData,
-                         PVOID pParms, USHORT cbParms, PUSHORT pcbParms,
-                         USHORT usFunCode, PSZ pszRoute, HFILE hf,
-                         USHORT usRouteMethod, ULONG ulReserved);
-
-USHORT  _pascal _far Dos16NewSize(HFILE hf, ULONG ulNewSize);
-USHORT  _pascal _far Dos16ProtectNewSize(HFILE hf, ULONG ulNewSize,
-                                   FHLOCK fhFileHandleLockID);
-USHORT  _pascal _far Dos16BufReset(HFILE hf);
-
-USHORT  _pascal _far Dos16ChgFilePtr(HFILE hf, long lOffset, USHORT fsMethod,
-                              PULONG pulNewOffset);
-USHORT  _pascal _far Dos16ProtectChgFilePtr(HFILE hf, long lOffset, USHORT fsMethod,
-                                      PULONG pulNewOffset,
-                                      FHLOCK fhFileHandleLockID);
-
-USHORT  _pascal _far Dos16SetFilePtr(HFILE hf, long lOffset, USHORT fsMethod,
-                              PULONG pulNewOffset);
-USHORT  _pascal _far Dos16ProtectSetFilePtr(HFILE hf, long lOffset, USHORT fsMethod,
-                                      PULONG pulNewOffset,
-                                      FHLOCK fhFileHandleLockID);
-
-USHORT  _pascal _far Dos16FileLocks(HFILE hf, PFILELOCK pUnlock, PFILELOCK pLock);
-USHORT  _pascal _far Dos16ProtectFileLocks(HFILE hf, PFILELOCK pUnlock,
-                                     PFILELOCK pLock,
-                                     FHLOCK fhFileHandleLockID);
-
-USHORT  _pascal _far Dos16Move(PSZ pszOld, PSZ pszNew, ULONG ulReserved);
-USHORT  _pascal _far Dos16Copy(PSZ pszSrc, PSZ pszDst, USHORT usOpt, ULONG ulReserved);
-USHORT  _pascal _far Dos16EditName(USHORT usEditLevel, PSZ pszSrc, PSZ pszEdit,
-                            PBYTE pszDst, USHORT cbDst);
-
-USHORT  _pascal _far Dos16FileIO(HFILE hf, PVOID pbCmd, USHORT cbCmd, PUSHORT pusErr);
-USHORT  _pascal _far Dos16ProtectFileIO(HFILE hf, PVOID pbCmd, USHORT cbCmd,
-                                  PUSHORT pusErr,
-                                  FHLOCK fhFileHandleLockID);
-USHORT  _pascal _far Dos16MkDir(PSZ pszDirName, ULONG usReserved);
-USHORT  _pascal _far Dos16MkDir2(PSZ pszDir, PEAOP pBuf, ULONG ulReserved);
-USHORT  _pascal _far Dos16RmDir(PSZ pszDir, ULONG ulReserved);
-USHORT  _pascal _far Dos16SelectDisk(USHORT usDrvNum);
-USHORT  _pascal _far Dos16QCurDisk(PUSHORT pusDrvNum, PULONG pulLogDrvMap);
-
-USHORT  _pascal _far Dos16ChDir(PSZ pszDir, ULONG ulReserved);
-USHORT  _pascal _far Dos16QCurDir(USHORT usDrvNum, PBYTE pszPathBuf,
-                           PUSHORT pcbPathBuf);
-
-USHORT  _pascal _far Dos16QFSInfo(USHORT usDrvNum, USHORT usInfoLevel, PVOID pbInfo,
-                           USHORT cbInfo);
-USHORT  _pascal _far Dos16SetFSInfo(USHORT usDrvNum, USHORT usInfoLevel, PVOID pBuf,
-                             USHORT cbBuf);
-USHORT  _pascal _far Dos16QVerify(PUSHORT pfVerifyOn);
-USHORT  _pascal _far Dos16SetVerify(USHORT fVerify);
-USHORT  _pascal _far Dos16SetMaxFH(USHORT usHandles);
-
-USHORT  _pascal _far Dos16QFileInfo(HFILE hf, USHORT usInfoLevel, PVOID pInfoBuf,
-                             USHORT cbInfoBuf);
-USHORT  _pascal _far Dos16ProtectQFileInfo(HFILE hf, USHORT usInfoLevel, PVOID pInfoBuf,
-                                     USHORT cbInfoBuf,
-                                     FHLOCK fhFileHandleLockID);
-USHORT  _pascal _far Dos16SetFileInfo(HFILE hf, USHORT usInfoLevel, PVOID pInfoBuf,
-                               USHORT cbInfoBuf);
-USHORT  _pascal _far DosProtectSetFileInfo(HFILE hf, USHORT usInfoLevel, PVOID pInfoBuf,
-                                       USHORT cbInfoBuf,
-                                       FHLOCK fhFileHandleLockID);
-USHORT  _pascal _far Dos16QPathInfo(PSZ pszPath, USHORT usInfoLevel, PVOID pInfoBuf,
-                             USHORT cbInfoBuf, ULONG ulReserved);
-USHORT  _pascal _far Dos16SetPathInfo(PSZ pszPath, USHORT usInfoLevel, PVOID pInfoBuf,
-                               USHORT cbInfoBuf, USHORT usFlags,
-                               ULONG ulReserved);
-
-
-
-
-USHORT  _pascal _far Dos16QFileMode(PSZ pszFName, PUSHORT pusAttr, ULONG ulReserved);
-USHORT  _pascal _far Dos16SetFileMode(PSZ pszFName, USHORT usAttr, ULONG ulReserved);
-
-USHORT  _pascal _far Dos16EnumAttribute(USHORT fRefType, PVOID pFileRef, ULONG iStartEntry, PVOID pEnumBuf, ULONG cbBuf, PULONG pcbActual, ULONG infoLevel, ULONG reserved);
-USHORT  _pascal _far Dos16ProtectEnumAttribute(USHORT fRefType, PVOID pFileRef, ULONG iStartEntry, PVOID pEnumBuf, ULONG cbBuf, PULONG pcbActual, ULONG infoLevel, FHLOCK fhFileHandleLockID, ULONG reserved);
-
-typedef struct _DENA1 { 
-    UCHAR   reserved;         
-    UCHAR   cbName;           
-    USHORT  cbValue;          
-    UCHAR   szName[1];        
-} DENA1;
-typedef DENA1 _far *PDENA1;
-
-
-
-
-
-
-
-
-#line 1091 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-#line 1104 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-USHORT  _pascal _far Dos16AllocSeg(USHORT cbSize, PSEL pSel, USHORT fsAlloc);
-USHORT  _pascal _far Dos16FreeSeg(SEL sel);
-USHORT  _pascal _far Dos16GetSeg(SEL sel);
-USHORT  _pascal _far Dos16GiveSeg(SEL sel, PID pid, PSEL pSelRecipient);
-USHORT  _pascal _far Dos16ReallocSeg(USHORT cbNewSize, SEL sel);
-USHORT  _pascal _far Dos16SizeSeg(SEL sel, PULONG pcbSize);
-
-
-
-
-
-
-
-
-#line 1122 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 1178 "i:/ddk/base/h\\bsedos16.h"
-
-
-USHORT  _pascal _far Dos16SemClear(HSEM hsem);
-USHORT  _pascal _far Dos16SemSet(HSEM hsem);
-USHORT  _pascal _far Dos16SemWait(HSEM hsem, long lTimeOut);
-USHORT  _pascal _far Dos16SemSetWait(HSEM hsem, long lTimeOut);
-USHORT  _pascal _far Dos16SemRequest(HSEM hsem, long lTimeOut);
-
-#line 1187 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _DATETIME {      
-    UCHAR   hours;
-    UCHAR   minutes;
-    UCHAR   seconds;
-    UCHAR   hundredths;
-    UCHAR   day;
-    UCHAR   month;
-    USHORT  year;
-    short   timezone;
-    UCHAR   weekday;
-} DATETIME;
-typedef DATETIME _far *PDATETIME;
-
-
-
-
-
-#line 1289 "i:/ddk/base/h\\bsedos16.h"
-
-
-USHORT  _pascal _far Dos16GetDateTime(PDATETIME pdatetime);
-USHORT  _pascal _far Dos16SetDateTime(PDATETIME pdatetime);
-
-#line 1295 "i:/ddk/base/h\\bsedos16.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _AIMParms {  
-          ULONG  Length;
-          ULONG  Reserved;
-          ULONG  AIM_Errors;
-          BOOL   AIM_Active;
-          USHORT AIM_TimeOut;
-          ULONG  AIM_FKAccept;
-          ULONG  AIM_FKRate;
-          ULONG  AIM_FKDelay;
-          } AIMParms;
-
-typedef AIMParms _far *PAIMParms;
-#line 850 "i:/ddk/base/h\\bsesub.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-USHORT _pascal _far IMPSetAIMProfile( PAIMParms pAIMParms );
-
-
-
-
-
-
-USHORT _pascal _far IMPQueryAIMProfile( PAIMParms pAIMParms );
-
-
-
-
-
-void _pascal _far IMPResetAIMProfile();
-#line 894 "i:/ddk/base/h\\bsesub.h"
-#line 60 "i:/ddk/base/h\\bse.h"
-#line 61 "i:/ddk/base/h\\bse.h"
-#line 1 "i:/ddk/base/h\\bseerr.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 886 "i:/ddk/base/h\\bseerr.h"
-#line 62 "i:/ddk/base/h\\bse.h"
-
-
-
-
-#line 38 "i:/ddk/base/h\\os2.h"
-#line 39 "i:/ddk/base/h\\os2.h"
-
-
-
-
-
-
-#line 30 "os2ahci.h"
-#line 1 "i:/c600/include\\dos.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct WORDREGS {
-	unsigned int ax;
-	unsigned int bx;
-	unsigned int cx;
-	unsigned int dx;
-	unsigned int si;
-	unsigned int di;
-	unsigned int cflag;
-	};
-
-
-
-
-struct BYTEREGS {
-	unsigned char al, ah;
-	unsigned char bl, bh;
-	unsigned char cl, ch;
-	unsigned char dl, dh;
-	};
-
-
-
-
-
-
-union REGS {
-	struct WORDREGS x;
-	struct BYTEREGS h;
-	};
-
-
-
-
-struct SREGS {
-	unsigned int es;
-	unsigned int cs;
-	unsigned int ss;
-	unsigned int ds;
-	};
-
-
-
-#line 62 "i:/c600/include\\dos.h"
-
-
-
-
-
-
-struct DOSERROR {
-	int exterror;
-	char class;
-	char action;
-	char locus;
-	};
-
-
-
-#line 78 "i:/c600/include\\dos.h"
-
-
-
-
-
-
-struct find_t {
-	char reserved[21];
-	char attrib;
-	unsigned wr_time;
-	unsigned wr_date;
-	long size;
-	char name[13];
-	};
-
-
-
-#line 96 "i:/c600/include\\dos.h"
-
-
-
-
-
-
-struct dosdate_t {
-	unsigned char day;		
-	unsigned char month;		
-	unsigned int year;		
-	unsigned char dayofweek;	
-	};
-
-struct dostime_t {
-	unsigned char hour;	
-	unsigned char minute;	
-	unsigned char second;	
-	unsigned char hsecond;	
-	};
-
-
-
-#line 119 "i:/c600/include\\dos.h"
-
-
-
-
-
-
-struct diskfree_t {
-	unsigned total_clusters;
-	unsigned avail_clusters;
-	unsigned sectors_per_cluster;
-	unsigned bytes_per_sector;
-	};
-
-
-
-#line 135 "i:/c600/include\\dos.h"
-
-
-
-
-
-
-
-
-					
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-extern unsigned int _near _cdecl _osversion;
-
-
-
-
-
-int _cdecl bdos(int, unsigned int, unsigned int);
-void _cdecl _chain_intr(void (_cdecl _interrupt _far *)());
-void _cdecl _disable(void);
-unsigned _cdecl _dos_allocmem(unsigned, unsigned *);
-unsigned _cdecl _dos_close(int);
-unsigned _cdecl _dos_creat(const char *, unsigned, int *);
-unsigned _cdecl _dos_creatnew(const char *, unsigned, int *);
-unsigned _cdecl _dos_findfirst(const char *, unsigned, struct find_t *);
-unsigned _cdecl _dos_findnext(struct find_t *);
-unsigned _cdecl _dos_freemem(unsigned);
-void _cdecl _dos_getdate(struct dosdate_t *);
-void _cdecl _dos_getdrive(unsigned *);
-unsigned _cdecl _dos_getdiskfree(unsigned, struct diskfree_t *);
-unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
-unsigned _cdecl _dos_getftime(int, unsigned *, unsigned *);
-void _cdecl _dos_gettime(struct dostime_t *);
-void (_cdecl _interrupt _far * _cdecl _dos_getvect(unsigned))();
-void _cdecl _dos_keep(unsigned, unsigned);
-unsigned _cdecl _dos_open(const char *, unsigned, int *);
-unsigned _cdecl _dos_read(int, void _far *, unsigned, unsigned *);
-unsigned _cdecl _dos_setblock(unsigned, unsigned, unsigned *);
-unsigned _cdecl _dos_setdate(struct dosdate_t *);
-void _cdecl _dos_setdrive(unsigned, unsigned *);
-unsigned _cdecl _dos_setfileattr(const char *, unsigned);
-unsigned _cdecl _dos_setftime(int, unsigned, unsigned);
-unsigned _cdecl _dos_settime(struct dostime_t *);
-void _cdecl _dos_setvect(unsigned, void (_cdecl _interrupt _far *)());
-unsigned _cdecl _dos_write(int, const void _far *, unsigned, unsigned *);
-int _cdecl dosexterr(struct DOSERROR *);
-void _cdecl _enable(void);
-void _cdecl _harderr(void (_far *)());
-void _cdecl _hardresume(int);
-void _cdecl _hardretn(int);
-int _cdecl intdos(union REGS *, union REGS *);
-int _cdecl intdosx(union REGS *, union REGS *, struct SREGS *);
-int _cdecl int86(int, union REGS *, union REGS *);
-int _cdecl int86x(int, union REGS *, union REGS *, struct SREGS *);
-#line 208 "i:/c600/include\\dos.h"
-
-void _cdecl segread(struct SREGS *);
-#line 31 "os2ahci.h"
-#line 1 "i:/ddk/base/h\\bseerr.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 886 "i:/ddk/base/h\\bseerr.h"
-#line 32 "os2ahci.h"
-#line 1 "i:/ddk/base/h\\dskinit.h"
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _DDD_Parm_List { 
-
-  USHORT        cache_parm_list;        
-  USHORT        disk_config_table;      
-  USHORT        init_req_vec_table;     
-  USHORT        cmd_line_args;          
-  USHORT        machine_config_table;   
-
-} DDD_PARM_LIST, far *PDDD_PARM_LIST;
-
-
-
-
-
-
-
-
-
-
-typedef struct _Cacheinit_Input { 
-
-  ULONG         cache_size;             
-  ULONG         cache_addr;             
-  USHORT        cache_thresh;
-  USHORT        cache_msg_id;           
-  USHORT        cache_handle;           
-
-} CACHEINIT_INPUT, far *PCACHEINIT_INPUT;
-
-
-
-
-
-
-
-
-
-
-typedef struct _Machine_Config_Info { 
-
-  USHORT        Length;                 
-  USHORT        BusInfo;                
-  USHORT        CpuInfo;                
-  UCHAR         SubModel;               
-  UCHAR         Model;                  
-  USHORT        ABIOSRevision;          
-  USHORT        HardDriveCount;         
-  UCHAR         Reserved1[20];
-
-} MACHINE_CONFIG_INFO, far *PMACHINE_CONFIG_INFO;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 33 "os2ahci.h"
-#line 1 "i:/ddk/base/h\\scb.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _SCB      SCB;
-typedef struct _SCB _far *PSCB;
-typedef struct _SCB     *NPSCB;
-
-typedef struct _TSB      TSB;
-typedef struct _TSB _far *PTSB;
-typedef struct _TSB     *NPTSB;
-
-typedef struct _SCBHDR      SCBHDR;
-typedef struct _SCBHDR     *NPSCBHDR;
-typedef struct _SCBHDR _far *PSCBHDR;
-
-
-
-
-
-
-
-
-typedef struct _SCBFORMAT      SCBFORMAT;
-typedef struct _SCBFORMAT _far *PSCBFORMAT;
-typedef struct _SCBFORMAT     *NPSCBFORMAT;
-
-
-
-
-
-typedef struct _SCBHDR {                
-
-  USHORT        Reserved_1;             
-  PSCBHDR       pNextSCBHdr;            
-  USHORT        Reserved_2[2];          
-  PTSB          pTSB;                   
-  USHORT        Reserved_3[1];          
-} SCBHDR;
-
-
-
-
-
-
-typedef struct _SCB {                   
-
-  USHORT        Cmd;                    
-  USHORT        Enable;                 
-  ULONG         LBA;                    
-  ULONG         ppXferBuf;              
-                                        
-  ULONG         XferBufLen;             
-  ULONG         ppTSB;                  
-  ULONG         ppNxtSCB;               
-  union {
-
-      struct _BLK {                     
-
-          USHORT        BlockCnt;       
-          USHORT        BlockSize;      
-        } BLK;
-      struct _CDB {                     
-
-          UCHAR        SCSIcdb[12];
-        } CDB;
-    } EXT;
-} SCB;
-
-
-
-
-
-
-typedef struct _SCBFORMAT {             
-
-  USHORT        Cmd;                    
-  USHORT        Enable;                 
-  USHORT        ModBits;                
-  USHORT        Interleave;             
-  ULONG         ppXferBuf;              
-                                        
-  ULONG         XferBufLen;             
-  ULONG         ppTSB;                  
-  ULONG         ppNxtSCB;               
-  union {
-
-      struct _BLK2 {                    
-
-          USHORT        BlockCnt;       
-          USHORT        BlockSize;      
-        } BLK2;
-    } EXT;
-} SCBFORMAT;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-                                     
-
-                                     
-
-                                     
-
-                                     
-
-                                     
-
-                                     
-
-                                     
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _TSB {                
-
-  USHORT        Status;              
-  USHORT        Retries;             
-  ULONG         ResidCnt;            
-  ULONG         ppResidBuf;          
-  USHORT        StatusLen;           
-  UCHAR         SCSIStatus;          
-  UCHAR         CmdStatus;           
-  UCHAR         DevError;            
-  UCHAR         CmdError;            
-  USHORT        DiagMod;             
-  USHORT        CacheInfo;           
-  ULONG         ppLastSCB;           
-} TSB;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-                                              
-
-
-
-
-
-
-
-                                              
-
-
-
-
-
-
-
-
-
-                                              
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 34 "os2ahci.h"
-
-#line 1 "i:/ddk/base/h\\devhdr.h"
-
-
-
-
-
-
-
-
- 
-
-
-
-
-
-struct SysDev {
-    unsigned long SDevNext;     
-    unsigned short SDevAtt;     
-    unsigned short SDevStrat;   
-    unsigned short SDevInt;     
-
-    unsigned char  SDevName[8]; 
-
-
-
-
-    unsigned short SDevProtCS;  
-    unsigned short SDevProtDS;  
-    unsigned short SDevRealCS;  
-    unsigned short SDevRealDS;  
-};
-
-
-
-
-
-
-struct  SysDev3 {
-    struct SysDev SysDevBef3;
-    unsigned long  SDevCaps;    
-};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 36 "os2ahci.h"
-#line 1 "i:/ddk/base/src/dev/dasd/diskh\\iorb.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORBH         IORBH;
-typedef struct _IORBH         _far *PIORBH;
-typedef struct _IORBH         _near *NPIORBH;
-typedef struct _IORBH         _far *PIORB;
-typedef struct _IORBH         _near *NPIORB;
-
-typedef struct _DEVICETABLE   DEVICETABLE;
-typedef struct _DEVICETABLE   _far *PDEVICETABLE;
-typedef struct _DEVICETABLE   _near *NPDEVICETABLE;
-
-typedef struct _UNITINFO      UNITINFO;
-typedef struct _UNITINFO      _far *PUNITINFO;
-typedef struct _UNITINFO      _near *NPUNITINFO;
-
-typedef struct _ADAPTERINFO   ADAPTERINFO;
-typedef struct _ADAPTERINFO   _far *PADAPTERINFO;
-typedef struct _ADAPTERINFO   _near *NPADAPTERINFO;
-
-typedef struct _GEOMETRY      GEOMETRY;
-typedef struct _GEOMETRY      _far *PGEOMETRY;
-typedef struct _GEOMETRY      _near *NPGEOMETRY;
-
-typedef struct _SCATGATENTRY  SCATGATENTRY;
-typedef struct _SCATGATENTRY  _far *PSCATGATENTRY;
-typedef struct _SCATGATENTRY  _near *NPSCATGATENTRY;
-
-typedef struct _RESOURCE_ENTRY RESOURCE_ENTRY;
-typedef struct _RESOURCE_ENTRY _near *NPRESOURCE_ENTRY;
-typedef struct _RESOURCE_ENTRY _far *PRESOURCE_ENTRY;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORBH   {               
-
-  USHORT        Length;                 
-  USHORT        UnitHandle;             
-  USHORT        CommandCode;            
-  USHORT        CommandModifier;        
-  USHORT        RequestControl;         
-  USHORT        Status;                 
-  USHORT        ErrorCode;              
-  ULONG         Timeout;                
-  USHORT        StatusBlockLen;         
-  NPBYTE        pStatusBlock;           
-  USHORT        Reserved_1;             
-  PIORB         pNxtIORB;               
-  PIORB         (_far *NotifyAddress)(PIORB); 
-  UCHAR         DMWorkSpace[20];   
-  UCHAR         ADDWorkSpace[16]; 
-
-} IORBH;
-
-
-
-
-
-
-                                          
-                                          
-                                          
-                                          
-                                          
-                                          
-
-
-
-                                          
-
-
-
-
-                                          
-
-
-
-
-
-                                          
-
-
-
-
-
-
-                                          
-
-
-
-
-                                          
-
-
-
-
-
-                                          
-
-
-
-
-
-
-
-
-
-                                          
-                                          
-
-
-
-
-                                          
-
-
-                                          
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORB_CONFIGURATION   {  
-
-  IORBH            iorbh;               
-  DEVICETABLE far *pDeviceTable;        
-  USHORT           DeviceTableLen;      
-
-} IORB_CONFIGURATION, _far *PIORB_CONFIGURATION, _near *NPIORB_CONFIGURATION;
-
-
-
-typedef struct _DEVICETABLE  {            
-
-  UCHAR         ADDLevelMajor;            
-  UCHAR         ADDLevelMinor;            
-  USHORT        ADDHandle;                
-  USHORT        TotalAdapters;            
-  NPADAPTERINFO pAdapter[1];              
-
-} DEVICETABLE, _far *PDEVICETABLE;
-
-
-
-
-
-
-
-
-
-typedef struct _UNITINFO   {           
-
-  USHORT    AdapterIndex;              
-  USHORT    UnitIndex;                 
-  USHORT    UnitFlags;                 
-  USHORT    Reserved;                  
-  USHORT    UnitHandle;                
-  USHORT    FilterADDHandle;           
-  USHORT    UnitType;                  
-  USHORT    QueuingCount;              
-  UCHAR     UnitSCSITargetID;          
-  UCHAR     UnitSCSILUN;               
-
-} UNITINFO;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _ADAPTERINFO   {           
-
-  UCHAR            AdapterName[17];       
-  UCHAR            Reserved;              
-  USHORT           AdapterUnits;          
-  USHORT           AdapterDevBus;         
-  UCHAR            AdapterIOAccess;       
-  UCHAR            AdapterHostBus;        
-  UCHAR            AdapterSCSITargetID;   
-  UCHAR            AdapterSCSILUN;        
-  USHORT           AdapterFlags;
-  USHORT           MaxHWSGList;           
-  ULONG            MaxCDBTransferLength;  
-  UNITINFO         UnitInfo[1];           
-
-} ADAPTERINFO;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORB_UNIT_CONTROL  {     
-
-  IORBH            iorbh;                
-  USHORT           Flags;                
-  PUNITINFO        pUnitInfo;            
-  USHORT           UnitInfoLen;          
-
-} IORB_UNIT_CONTROL, _far *PIORB_UNIT_CONTROL, _near *NPIORB_UNIT_CONTROL;
-
-
-
-
-
-typedef struct _IORB_GEOMETRY  {         
-
-  IORBH            iorbh;                
-  PGEOMETRY        pGeometry;            
-  USHORT           GeometryLen;          
-
-} IORB_GEOMETRY, _far *PIORB_GEOMETRY, _near *NPIORB_GEOMETRY;
-
-typedef struct _GEOMETRY  {              
-
-  ULONG    TotalSectors;
-  USHORT   BytesPerSector;
-  USHORT   Reserved;
-  USHORT   NumHeads;
-  ULONG    TotalCylinders;
-  USHORT   SectorsPerTrack;
-
-} GEOMETRY, _far *PGEOMETRY, _near *NPGEOMETRY;
-
-
-
-
-
-
-
-typedef struct _SCATGATENTRY  {      
-
-  ULONG         ppXferBuf;           
-  ULONG         XferBufLen;          
-
-} SCATGATENTRY, _far *PSCATGATENTRY, _near *NPSCATGATENTRY;
-
-
-
-
-
-
-
-typedef struct _IORB_EXECUTEIO  {            
-
-  IORBH         iorbh;                       
-  USHORT        cSGList;                     
-  PSCATGATENTRY pSGList;                     
-  ULONG         ppSGList;                    
-  ULONG         RBA;                         
-  USHORT        BlockCount;                  
-  USHORT        BlocksXferred;               
-  USHORT        BlockSize;                   
-  USHORT        Flags;
-
-} IORB_EXECUTEIO, _far *PIORB_EXECUTEIO, _near *NPIORB_EXECUTEIO;
-
-
-
-
-
-
-typedef struct _CHS_ADDR  {                  
-
-  USHORT        Cylinder;
-  UCHAR         Head;
-  UCHAR         Sector;
-
-} CHS_ADDR, _far *PCHS_ADDR, _near *NPCHS_ADDR;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORB_FORMAT  {               
-
-  IORBH         iorbh;                       
-  USHORT        cSGList;                     
-  PSCATGATENTRY pSGList;                     
-  ULONG         ppSGList;                    
-  USHORT        FormatCmdLen;                
-  PBYTE         pFormatCmd;                  
-  UCHAR         Reserved_1[8];               
-
-} IORB_FORMAT, _far *PIORB_FORMAT, _near *NPIORB_FORMAT;
-
-
-typedef struct _FORMAT_CMD_TRACK {           
-
-  USHORT        Flags;
-  ULONG         RBA;
-  USHORT        cTrackEntries;
-  USHORT        FmtGapLength;                                        
-  USHORT        BlockSize;                                           
-
-} FORMAT_CMD_TRACK, _far *PFORMAT_CMD_TRACK, _near *NPFORMAT_CMD_TRACK;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORB_ADAPTER_PASSTHRU  {  
-
-  IORBH         iorbh;                       
-  USHORT        cSGList;                     
-  PSCATGATENTRY pSGList;                     
-  ULONG         ppSGLIST;                    
-  USHORT        ControllerCmdLen;
-  PBYTE         pControllerCmd;
-  ULONG         ppSCB;              
-  USHORT        Flags;
-
-} IORB_ADAPTER_PASSTHRU, _far *PIORB_ADAPTER_PASSTHRU, _near *NPIORB_ADAPTER_PASSTHRU;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORB_UNIT_STATUS  {        
-
-  IORBH      iorbh;
-  USHORT     UnitStatus;
-
-} IORB_UNIT_STATUS, _far *PIORB_UNIT_STATUS, _near *NPIORB_UNIT_STATUS;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORB_DEVICE_CONTROL   {   
-
-  IORBH      iorbh;                       
-  USHORT     Flags;
-  USHORT     Reserved;
-  USHORT     QueueStatus;
-  USHORT     (_far *IRQHandlerAddress)();                             
-              
-
-} IORB_DEVICE_CONTROL, _far *PIORB_DEVICE_CONTROL, _near *NPIORB_DEVICE_CONTROL;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IORB_RESOURCE  {        
-
-  IORBH           iorbh;
-  USHORT          Flags;
-  USHORT          ResourceEntryLen;
-  PRESOURCE_ENTRY pResourceEntry;
-
-} IORB_RESOURCE, _far *PIORB_RESOURCE, _near *NPIORB_RESOURCE;
-
-typedef struct _DMA_ENTRY     _near *NPDMA_ENTRY;
-typedef struct _DMA_ENTRY     _far *PDMA_ENTRY;
-typedef struct _IRQ_ENTRY     _near *NPIRQ_ENTRY;
-typedef struct _IRQ_ENTRY     _far *PIRQ_ENTRY;
-typedef struct _PORT_ENTRY    _near *NPPORT_ENTRY;
-typedef struct _PORT_ENTRY    _far *PPORT_ENTRY;
-typedef struct _MEMORY_ENTRY  _near *NPMEMORY_ENTRY;
-typedef struct _MEMORY_ENTRY  _far *PMEMORY_ENTRY;
-typedef struct _PCI_IRQ_ENTRY _near *NPPCI_IRQ_ENTRY;
-typedef struct _PCI_IRQ_ENTRY _far *PPCI_IRQ_ENTRY;
-typedef struct _UNIT_ENTRY    _near *NPUNIT_ENTRY;
-typedef struct _UNIT_ENTRY    _far *PUNIT_ENTRY;
-
-typedef struct _RESOURCE_ENTRY {        
-
-  USHORT           Max_Resource_Entry;
-  USHORT           cDMA_Entries;   
-  NPDMA_ENTRY      npDMA_Entry;    
-                                   
-  USHORT           cIRQ_Entries;   
-  NPIRQ_ENTRY      npIRQ_Entry;    
-                                   
-  USHORT           cPort_Entries;  
-  NPPORT_ENTRY     npPort_Entry;   
-                                   
-  USHORT           cMemory_Entries;
-  NPMEMORY_ENTRY   npMemory_Entry; 
-                                   
-  USHORT           cPCI_IRQ_Entries;
-  NPIRQ_ENTRY      npPCI_IRQ_Entry;
-
-  ULONG            Reserved[4];    
-
-} RESOURCE_ENTRY;
-
-typedef struct _RESOURCE_ENTRY  _near *NPRESOURCE_ENTRY;
-typedef struct _RESOURCE_ENTRY  _far *PRESOURCE_ENTRY;
-
-
-
-
-
-
-
-
-
-
-                                     
-
-                                     
-
-                                     
-
-typedef struct _DMA_ENTRY {          
-  USHORT     DMA_Flags;              
-  USHORT     DMA_Width;              
-  USHORT     DMA_Type;               
-  USHORT     DMA_Channel;            
-  USHORT     DMA_Arbitration_Level;  
-} DMA_ENTRY;
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _IRQ_ENTRY {        
-  USHORT          IRQ_Flags;       
-  USHORT          IRQ_Value;       
-} IRQ_ENTRY;
-
-
-
-
-
-
-
-
-typedef struct _PORT_ENTRY{        
-  USHORT          Port_Flags;      
-  USHORT          StartPort;       
-  USHORT          cPorts;          
-} PORT_ENTRY;
-
-typedef struct _MEMORY_ENTRY{      
-   USHORT         Memory_Flags;    
-   USHORT         Memory_Width;    
-   ULONG          StartMemory;     
-   USHORT         cMemory;         
-} MEMORY_ENTRY;
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _PCI_IRQ_ENTRY{     
-   USHORT         PCI_IRQ_Flags;   
-   USHORT         PCI_IRQ_Value;   
-} PCI_IRQ_ENTRY;
-
-#line 824 "i:/ddk/base/src/dev/dasd/diskh\\iorb.h"
-#line 37 "os2ahci.h"
-#line 1 "i:/ddk/base/h\\reqpkt.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _DDHDR  {             
-
-  PVOID  NextHeader;
-  USHORT DevAttr;
-  USHORT StrategyEP;
-  USHORT InterruptEP;
-  UCHAR  DevName[8];
-  USHORT ProtModeCS;
-  USHORT ProtModeDS;
-  USHORT RealModeCS;
-  USHORT RealModeDS;
-  ULONG  SDevCaps;                   
-} DDHDR;
-
-
-
-
-
-typedef struct _BPB  {                  
-
-  USHORT        BytesPerSector;
-  UCHAR         SectorsPerCluster;
-  USHORT        ReservedSectors;
-  UCHAR         NumFATs;
-  USHORT        MaxDirEntries;
-  USHORT        TotalSectors;
-  UCHAR         MediaType;
-  USHORT        NumFATSectors;
-  USHORT        SectorsPerTrack;
-  USHORT        NumHeads;
-  ULONG         HiddenSectors;
-  ULONG         BigTotalSectors;
-  UCHAR         Reserved_1[6];
-} BPB, _far *PBPB, *NPBPB;
-
-typedef BPB    near *BPBS[];         
-typedef BPBS   far  *PBPBS;          
-
-
-
-
-
-typedef struct _RPH  RPH;
-typedef struct _RPH  _far *PRPH;
-typedef struct _RPH  *NPRPH;
-
-typedef struct _RPH  {                  
-
-  UCHAR         Len;
-  UCHAR         Unit;
-  UCHAR         Cmd;
-  USHORT        Status;
-  UCHAR         Flags;
-  UCHAR         Reserved_1[3];
-  PRPH          Link;
-} RPH;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _RPINIT  {               
-
-  RPH           rph;
-  UCHAR         Unit;
-  PFN           DevHlpEP;
-  PSZ           InitArgs;
-  UCHAR         DriveNum;
-} RPINITIN, _far *PRPINITIN;
-
-typedef struct _RPINITOUT  {            
-
-  RPH           rph;
-  UCHAR         Unit;
-  USHORT        CodeEnd;
-  USHORT        DataEnd;
-  PBPBS         BPBArray;
-  USHORT        Status;
-} RPINITOUT, _far *PRPINITOUT;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 38 "os2ahci.h"
-#line 1 "i:/ddk/base/h\\dhcalls.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef USHORT _near *NPUSHORT;
-typedef void   _near *NPVOID;
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_GetLIDEntry ( USHORT  DeviceType,
-                                      USHORT  LIDIndex,
-                                      USHORT  LIDType,
-                                      PUSHORT LID);
-
-USHORT _pascal _far DevHelp_FreeLIDEntry( USHORT LIDNumber );
-
-USHORT _pascal _far DevHelp_ABIOSCall( USHORT Lid,
-                                   NPBYTE ReqBlk,
-                                   USHORT Entry_Type );
-
-USHORT _pascal _far DevHelp_ABIOSCommonEntry( NPBYTE ReqBlk,
-                                          USHORT Entry_Type );
-
-USHORT _pascal _far DevHelp_ABIOSGetParms( USHORT Lid,
-                                       NPBYTE ParmsBlk);
-
-USHORT _pascal _far DevHelp_GetDeviceBlock( USHORT Lid,
-                                        PPVOID DeviceBlockPtr );
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_AllocGDTSelector( PSEL   Selectors,
-                                          USHORT Count );
-
-USHORT _pascal _far DevHelp_PhysToGDTSelector( ULONG  PhysAddr,
-                                           USHORT Count,
-                                           SEL    Selector );
-
-USHORT _pascal _far DevHelp_PhysToGDTSel( ULONG PhysAddr,
-                                      ULONG Count,
-                                      SEL   Selector,
-                                      UCHAR Access );
-
-USHORT _pascal _far DevHelp_AllocPhys( ULONG  lSize,
-                                   USHORT MemType,
-                                   PULONG PhysAddr);
-
-USHORT _pascal _far DevHelp_PhysToUVirt( ULONG  PhysAddr,
-                                     USHORT Length,
-                                     USHORT Flags,
-                                     USHORT TagType,
-                                     PVOID  SelOffset);
-
-USHORT _pascal _far DevHelp_PhysToVirt( ULONG   PhysAddr,
-                                    USHORT  usLength,
-                                    PVOID   SelOffset,
-                                    PUSHORT ModeFlag );
-
-USHORT _pascal _far DevHelp_UnPhysToVirt( PUSHORT ModeFlag );
-
-USHORT _pascal _far DevHelp_FreePhys( ULONG PhysAddr );
-
-USHORT _pascal _far DevHelp_VirtToPhys( PVOID  SelOffset,
-                                    PULONG PhysAddr );
-
-USHORT _pascal _far DevHelp_Lock( SEL    Segment,
-                              USHORT LockType,
-                              USHORT WaitFlag,
-                              PULONG LockHandle );
-
-USHORT _pascal _far DevHelp_UnLock( ULONG LockHandle );
-
-USHORT _pascal _far DevHelp_VerifyAccess( SEL    MemSelector,
-                                      USHORT Length,
-                                      USHORT MemOffset,
-                                      UCHAR  AccessFlag);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_AllocReqPacket( USHORT    WaitFlag,
-                                        PBYTE _far *ReqPktAddr );
-
-USHORT _pascal _far DevHelp_FreeReqPacket( PBYTE ReqPktAddr );
-
-USHORT _pascal _far DevHelp_PullParticular( NPBYTE Queue,
-                                        PBYTE  ReqPktAddr );
-
-USHORT _pascal _far DevHelp_PullRequest( NPBYTE    Queue,
-                                     PBYTE _far *ReqPktAddr );
-
-USHORT _pascal _far DevHelp_PushRequest( NPBYTE Queue,
-                                     PBYTE  ReqPktAddr );
-
-USHORT _pascal _far DevHelp_SortRequest( NPBYTE Queue,
-                                     PBYTE  ReqPktAddr );
-
-
-
-
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_QueueInit( NPBYTE Queue );
-
-USHORT _pascal _far DevHelp_QueueRead( NPBYTE Queue,
-                                   PBYTE  Char );
-
-USHORT _pascal _far DevHelp_QueueWrite( NPBYTE Queue,
-                                    UCHAR  Char );
-
-USHORT _pascal _far DevHelp_QueueFlush( NPBYTE Queue );
-
-
-
-
-typedef struct _QUEUEHDR  {             
-
-  USHORT   QSize;
-  USHORT   QChrOut;
-  USHORT   QCount;
-  BYTE     Queue[1];
-} QUEUEHDR;
-
-typedef QUEUEHDR _far *PQUEUEHDR;                                     
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_ProtToReal();
-
-USHORT _pascal _far DevHelp_RealToProt();
-
-USHORT _pascal _far DevHelp_InternalError( PSZ    MsgText,
-                                       USHORT MsgLength );
-
-USHORT _pascal _far DevHelp_RAS( USHORT Major,
-                             USHORT Minor,
-                             USHORT Size,
-                             PBYTE Data);
-
-USHORT _pascal _far DevHelp_RegisterPerfCtrs( NPBYTE pDataBlock,
-                                          NPBYTE pTextBlock,
-                                          USHORT Flags);
-
-USHORT _pascal _far DevHelp_AttachDD( NPSZ   DDName,
-                                  NPBYTE IDCTable );
-
-typedef struct _IDCTABLE {                                 
-                                                                     
-  USHORT        Reserved[3];                                         
-  void          (_far *ProtIDCEntry)(void);                           
-  USHORT        ProtIDC_DS;                                          
-                                                                     
-} IDCTABLE;                                                          
-                                                                     
-typedef IDCTABLE _near *NPIDCTABLE;                                   
-
-
-USHORT _pascal _far DevHelp_GetDOSVar( USHORT VarNumber,
-                                   USHORT VarMember,
-                                   PPVOID KernelVar );
-
-
-
-
-
-
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_Save_Message( NPBYTE MsgTable );
-
-typedef struct _MSGTABLE {              
-
-  USHORT   MsgId;                       
-  USHORT   cMsgStrings;                 
-  PSZ      MsgStrings[1];               
-} MSGTABLE;
-
-typedef MSGTABLE _near *NPMSGTABLE;                                   
-
-
-USHORT _pascal _far DevHelp_LogEntry (PVOID, USHORT);  
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_RegisterStackUsage( PVOID StackUsageData );
-
-USHORT _pascal _far DevHelp_SetIRQ( NPFN   IRQHandler,
-                                USHORT IRQLevel,
-                                USHORT SharedFlag );
-
-USHORT _pascal _far DevHelp_UnSetIRQ( USHORT IRQLevel );
-
-USHORT _pascal _far DevHelp_EOI( USHORT IRQLevel );
-
-USHORT _pascal _far DevHelp_ProcBlock( ULONG  EventId,
-                                   ULONG  WaitTime,
-                                   USHORT IntWaitFlag );
-
-USHORT _pascal _far DevHelp_ProcRun( ULONG   EventId,
-                                 PUSHORT AwakeCount);
-
-USHORT _pascal _far DevHelp_DevDone( PBYTE ReqPktAddr );
-
-USHORT _pascal _far DevHelp_TCYield();
-
-USHORT _pascal _far DevHelp_Yield();
-
-USHORT _pascal _far DevHelp_VideoPause( USHORT OnOff );
-
-
-
-typedef struct _STACKUSAGEDATA  {       
-
-  USHORT  Size;
-  USHORT  Flags;
-  USHORT  IRQLevel;
-  USHORT  CLIStack;
-  USHORT  STIStack;
-  USHORT  EOIStack;
-  USHORT  NestingLevel;
-} STACKUSAGEDATA;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_SemHandle( ULONG  SemKey,
-                                   USHORT SemUseFlag,
-                                   PULONG SemHandle );
-
-USHORT _pascal _far DevHelp_SemClear( ULONG SemHandle );
-
-USHORT _pascal _far DevHelp_SemRequest( ULONG SemHandle,
-                                    ULONG SemTimeout );
-
-USHORT _pascal _far DevHelp_SendEvent( USHORT EventType,
-                                   USHORT Parm );
-
-USHORT _pascal _far DevHelp_OpenEventSem( ULONG hEvent );
-
-USHORT _pascal _far DevHelp_CloseEventSem( ULONG hEvent );
-
-USHORT _pascal _far DevHelp_PostEventSem( ULONG hEvent );
-
-USHORT _pascal _far DevHlp_ResetEventSem( ULONG hEvent,
-                                      PULONG pNumPosts );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_ResetTimer( NPFN TimerHandler );
-
-USHORT _pascal _far DevHelp_SchedClock( PFN _near *SchedRoutineAddr );    
-
-USHORT _pascal _far DevHelp_SetTimer( NPFN TimerHandler );
-
-USHORT _pascal _far DevHelp_TickCount( NPFN   TimerHandler,
-                                   USHORT TickCount );
-
-USHORT _pascal _far DevHelp_RegisterTmrDD( NPFN   TimerEntry,            
-                                       PULONG TmrRollover,           
-                                       PULONG Tmr          );        
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_ProtToReal();
-
-USHORT _pascal _far DevHelp_RealToProt();
-
-USHORT _pascal _far DevHelp_ROMCritSection( USHORT EnterExit);
-
-USHORT _pascal _far DevHelp_SetROMVector( NPFN   IntHandler,
-                                      USHORT INTNum,
-                                      USHORT SaveDSLoc,
-                                      PULONG LastHeader );
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_MonFlush( USHORT MonitorHandle );
-
-USHORT _pascal _far DevHelp_Register( USHORT MonitorHandle,
-                                  USHORT MonitorPID,
-                                  PBYTE  InputBuffer,
-                                  NPBYTE OutputBuffer,
-                                  USHORT ChainFlag );
-
-USHORT _pascal _far DevHelp_MonitorCreate( USHORT  MonitorHandle,
-                                       PBYTE   FinalBuffer,
-                                       NPFN    NotifyRtn,
-                                       PUSHORT MonitorChainHandle);
-
-USHORT _pascal _far DevHelp_DeRegister( USHORT  MonitorPID,              
-                                    USHORT  MonitorHandle,           
-                                    PUSHORT MonitorsLeft);
-
-USHORT _pascal _far DevHelp_MonWrite( USHORT MonitorHandle,
-                                  PBYTE  DataRecord,
-                                  USHORT Count,
-                                  ULONG  TimeStampMS,                
-                                  USHORT WaitFlag );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef ULONG   LIN;                
-typedef ULONG   _far *PLIN;         
-
-USHORT _pascal _far DevHelp_VMLock( ULONG  Flags,
-                                LIN    LinearAddr,
-                                ULONG  Length,
-                                LIN    pPagelist,
-                                LIN    pLockHandle,
-                                PULONG PageListCount );
-
-USHORT _pascal _far DevHelp_VMUnLock( LIN pLockHandle );
-
-USHORT _pascal _far DevHelp_VMAlloc( ULONG  Flags,
-                                 ULONG  Size,
-                                 ULONG  PhysAddr,
-                                 PLIN   LinearAddr,
-                                 PPVOID SelOffset );
-
-USHORT _pascal _far DevHelp_VMFree( LIN LinearAddr );
-
-USHORT _pascal _far DevHelp_VMProcessToGlobal( ULONG Flags,
-                                           LIN   LinearAddr,
-                                           ULONG Length,
-                                           PLIN  GlobalLinearAddr );
-
-USHORT _pascal _far DevHelp_VMGlobalToProcess( ULONG Flags,
-                                           LIN   LinearAddr,
-                                           ULONG Length,
-                                           PLIN  ProcessLinearAddr );
-
-USHORT _pascal _far DevHelp_VirtToLin( SEL   Selector,
-                                   ULONG Offset,
-                                   PLIN  LinearAddr );
-
-USHORT _pascal _far DevHelp_LinToGDTSelector( SEL   Selector,
-                                          LIN   LinearAddr,
-                                          ULONG Size );
-
-USHORT _pascal _far DevHelp_GetDescInfo( SEL Selector,
-                                     PBYTE SelInfo );
-
-USHORT _pascal _far DevHelp_PageListToLin( ULONG Size,
-                                       LIN   pPageList,
-                                       PLIN  LinearAddr );
-
-USHORT _pascal _far DevHelp_LinToPageList( LIN    LinearAddr,
-                                       ULONG  Size,
-                                       LIN    pPageList,
-                                       PULONG PageListCount );
-
-USHORT _pascal _far DevHelp_PageListToGDTSelector( SEL    Selector,
-                                               ULONG  Size,
-                                               USHORT Access,
-                                               LIN    pPageList );
-
-USHORT _pascal _far DevHelp_VMSetMem( LIN LinearAddr,                    
-                                  ULONG Size,                        
-                                  ULONG Flags );                     
-
-USHORT _pascal _far DevHelp_FreeGDTSelector( SEL Selector );
-
-
-
-
-
-
-
-
-
-
-
-                                                
-                                                                     
-
-
-
-
-
-
-
-
-
-
-                                      
-                                                                     
-
-
-
-
-
-                                      
-                                                                     
-
-
-
-                                            
-                                                                     
-typedef struct _SELDESCINFO {                              
-                                                                     
-  UCHAR    Type;                                                     
-  UCHAR    Granularity;                                              
-  LIN      BaseAddr;                                                 
-  ULONG    Limit;                                                    
-                                                                     
-} SELDESCINFO;                                                       
-                                                                     
-typedef SELDESCINFO _far *PSELDESCINFO;                               
-                                                                     
-typedef struct _GATEDESCINFO {                             
-                                                                     
-  UCHAR    Type;                                                     
-  UCHAR    ParmCount;                                                
-  SEL      Selector;                                                 
-  USHORT   Reserved_1;                                               
-  ULONG    Offset;                                                   
-                                                                     
-} GATEDESCINFO;                                                      
-                                                                     
-typedef GATEDESCINFO _far *PGATEDESCINFO;                             
-
-                                  
-                                  
-                                                                     
-
-
-
-
-
-
-
-                   
-
-
-                                               
-                                                                     
-
-
-
-
-                                             
-                                                                     
-typedef struct _PAGELIST {                                 
-                                                                     
-  ULONG    PhysAddr;                                                 
-  ULONG    Size;                                                     
-                                                                     
-} PAGELIST;                                                          
-                                                                     
-typedef PAGELIST _near *NPPAGELIST;                                   
-typedef PAGELIST _far  *PPAGELIST;                                    
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_AllocateCtxHook( NPFN   HookHandler,
-                                         PULONG HookHandle );
-
-USHORT _pascal _far DevHelp_FreeCtxHook( ULONG HookHandle );
-
-USHORT _pascal _far DevHelp_ArmCtxHook( ULONG HookData,
-                                    ULONG HookHandle );
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_RegisterDeviceClass( NPSZ    DeviceString,
-                                             PFN     DriverEP,
-                                             USHORT  DeviceFlags,
-                                             USHORT  DeviceClass,
-                                             PUSHORT DeviceHandle);
-
-USHORT _pascal _far DevHelp_CreateInt13VDM( PBYTE VDMInt13CtrlBlk );
-
-                                    
-                                                                     
-
-
-
-
-
-
-
-USHORT _pascal _far DevHelp_RegisterBeep( PFN BeepHandler );             
-
-USHORT _pascal _far DevHelp_Beep( USHORT Frequency,                      
-                              USHORT DurationMS );                   
-
-USHORT _pascal _far DevHelp_RegisterPDD( NPSZ PhysDevName,
-                                     PFN  HandlerRoutine );
-
-USHORT _pascal _far DevHelp_DynamicAPI( PVOID  RoutineAddress,           
-                                    USHORT ParmCount,                
-                                    USHORT Flags,                    
-                                    PSEL   CallGateSel );            
-                                                                     
-                                                                     
-                                             
-
-
-                                                                     
-
-
-
-
-
-
-typedef struct FOPEN {           
-        PSZ   FileName;
-        ULONG FileSize;
-} FILEOPEN;
-
-
-typedef struct FCLOSE {          
-        USHORT Reserved;
-} FILECLOSE;
-
-typedef struct FREAD  {          
-        PBYTE Buffer;
-        ULONG ReadSize;
-} FILEREAD;
-
-typedef struct FREADAT {         
-        PBYTE Buffer;
-        ULONG ReadSize;
-        ULONG StartPosition;
-} FILEREADAT;
-
-typedef union FILEIOOP {            
-               struct FOPEN FileOpen;
-               struct FCLOSE FileClose;
-               struct FREAD FileRead;
-               struct FREADAT FileReadAt;
-} FILEIOOP;
-
-typedef struct _DDFileIo {       
-        USHORT   Length;
-        FILEIOOP Data;
-} FILEIOINFO, _far * PFILEIOINFO;
-
-USHORT _pascal _far DevHelp_OpenFile( PFILEIOINFO pFileOpen);
-USHORT _pascal _far DevHelp_CloseFile( PFILEIOINFO pFileClose );
-USHORT _pascal _far DevHelp_ReadFile( PFILEIOINFO pFileRead );
-USHORT _pascal _far DevHelp_ReadFileAt( PFILEIOINFO pFileReadAT );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 39 "os2ahci.h"
-#line 1 "i:/ddk/base/h\\addcalls.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef struct _ADD_XFER_DATA   {             
-
-  USHORT        Mode;                         
-  USHORT        cSGList;                      
-  PSCATGATENTRY pSGList;                      
-  PBYTE         pBuffer;                      
-  ULONG         numTotalBytes;                
-  USHORT        iSGList;                      
-  ULONG         SGOffset;                     
-} ADD_XFER_DATA, _far *PADD_XFER_DATA;
-
-
-
-
-
-
-
-
-typedef struct _ADD_XFER_IO   {               
-
-  USHORT        Mode;                         
-  USHORT        cSGList;                      
-  PSCATGATENTRY pSGList;                      
-  USHORT        iPortAddress;                 
-  ULONG         numTotalBytes;                
-  USHORT        iSGList;                      
-  ULONG         SGOffset;                     
-  USHORT        iSGListStart;                 
-  ULONG         SGOffsetStart;                
-} ADD_XFER_IO, _far *PADD_XFER_IO, _near *NPADD_XFER_IO;
-
-
-
-
-
-
-
-
-
-typedef struct _ADD_TIMER_DATA   {            
-
-  ULONG        Interval;                      
-  ULONG        BackupInterval;                
-  PFN          NotifyEntry;                   
-  PVOID        Parm_1;                        
-  PVOID        Parm_2;                        
-} ADD_TIMER_DATA;
-
-
-
-
-
-
-typedef struct _ADD_TIMER_POOL   {            
-
-  USHORT         MTick;                       
-  ADD_TIMER_DATA TimerData[1];                
-} ADD_TIMER_POOL;
-
-
-
-
-
-
-
-
-
-
-
-                                              
-
-
-
-
-
-
-
-
-
-                                             
-
-
-
-
-
-
-
-
-
-
-                                             
-
-
-
-
-
-
-
-
-
-                                             
-
-
-
-
-
-
-
-
-
-
-                                             
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-                                             
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-BOOL _pascal _far f_ADD_XferBuffData(PADD_XFER_DATA);
-BOOL _pascal _far f_ADD_DMASetup(USHORT, USHORT, USHORT, ULONG);
-BOOL _pascal _far f_ADD_ConvRBAtoCHS(ULONG, PGEOMETRY, PCHS_ADDR);
-
-BOOL _pascal _far f_ADD_InitTimer(PBYTE, USHORT);
-BOOL _pascal _far f_ADD_DeInstallTimer();
-BOOL _pascal _far f_ADD_StartTimerMS(PULONG, ULONG, PFN, PVOID, PVOID);
-BOOL _pascal _far f_ADD_CancelTimer(ULONG);
-
-
-BOOL _pascal _near ADD_XferBuffData(PADD_XFER_DATA);
-BOOL _pascal _near ADD_DMASetup(USHORT, USHORT, USHORT, ULONG);
-BOOL _pascal _near ADD_ConvRBAtoCHS(ULONG, PGEOMETRY, PCHS_ADDR);
-
-BOOL _pascal _near ADD_InitTimer(PBYTE, USHORT);
-BOOL _pascal _near ADD_DeInstallTimer();
-BOOL _pascal _near ADD_StartTimerMS(PULONG, ULONG, PFN, PVOID, PVOID);
-BOOL _pascal _near ADD_CancelTimer(ULONG);
-
-BOOL _pascal _near ADD_XferIOW( NPADD_XFER_IO npADDX );
-
-
-
-
-
-
-
-
-
-
-#line 40 "os2ahci.h"
-#line 1 "i:/ddk/base/h\\devclass.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-struct DevClassTableEntry {
-        USHORT   DCOffset;
-        USHORT   DCSelector;
-        USHORT   DCFlags;
-        UCHAR    DCName[16];
-};
-
-
-struct DevClassTableStruc {
-   USHORT                     DCCount;
-   USHORT                     DCMaxCount;
-   struct DevClassTableEntry  DCTableEntries[1];
-};
-
-
-
-
-#line 41 "os2ahci.h"
-
-#line 1 "i:/c600/include\\stdarg.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#line 16 "i:/c600/include\\stdarg.h"
-
-
-
-
-
-#line 22 "i:/c600/include\\stdarg.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef char  *va_list;
-
-#line 39 "i:/c600/include\\stdarg.h"
-
-
-
-
-#line 43 "os2ahci.h"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-typedef unsigned char    u8;
-typedef unsigned short   u16;
-typedef unsigned long    u32;
-
-
-typedef struct {
-  u32   options;         
-  u32   status;          
-  u32   tbl_addr;        
-  u32   tbl_addr_high;   
-  u32   reserved[4];
-} AHCI_CMD_HDR;
-
-
-typedef struct {
-  u32   addr;            
-  u32   addr_hi;         
-  u32   reserved;
-  u32   flags_size;      
-} AHCI_SG;
-
-
-
-
-
-typedef struct {
-  u16   vendor;          
-  u16   device;          
-  u16   subvendor;       
-  u16   subdevice;       
-  u32   class;           
-  u32   class_mask;      
-  u32   board;           
-} PCI_ID;
-
-
-typedef struct D_INFO {
-  struct D_INFO  *next;         
-  char            vendor[8];    
-  char            product[8];   
-  char            revision[8];  
-  u32             sectors;      
-};
-
-
-typedef struct P_INFO {
-  struct P_INFO  *p_info;       
-} P_INFO;
-
-
-typedef struct AD_INFO {
-  struct AD_INFO  *next;        
-  PCI_ID          *pci_id;      
-  P_INFO           ports[32];   
-  int              intr;        
-  u8              *mmio;        
-  u8              *dma_buf;     
-} AD_INFO;
-
-
-
-
-
-extern int        vsprintf (char *buf, const char *fmt, va_list va);
-extern int        sprintf  (char *buf, const char *fmt, ...);
-extern void       dprintf  (const char *fmt, ...);
-extern void      *memmove  (void *v_dst, void *v_src, int len);
-extern int        strlen   (const char *s);
-extern char      *strcpy   (char *dst, const char *src);
-
-
-
-extern int         debug;          
-
-extern PCI_ID      pci_ids[];      
-extern AD_INFO    *ai_root;        
-
-#line 23 "os2ahci.c"
-
-
-
-
-
-
-
-
-
-int         debug;          
-
-PCI_ID      pci_ids[];      
-AD_INFO    *ai_root;        
-
-
-
-
-
-
-
-USHORT c_strat(REQPACKET *req)
-{ 
-  WORD rc;
-
-  switch (req->cmd) {
-
-  case DD_CMD_INIT:
-    
-    break;
-  
-  }
-
-  return(rc);
-}
-
