Index: trunk/src/os2ahci/ReadMe.txt
===================================================================
--- trunk/src/os2ahci/ReadMe.txt	(revision 190)
+++ trunk/src/os2ahci/ReadMe.txt	(revision 191)
@@ -1,4 +1,3 @@
 AHCI Driver for OS/2 v2.03
-
 
 Introduction
@@ -366,6 +365,5 @@
 ===================
 
-- Run the included update.cmd,
-  or copy the driver file, OS2AHCI.ADD, to \OS2\BOOT on your boot disk.
+- Copy the driver file, OS2AHCI.ADD, to \OS2\BOOT on your boot disk.
 
 - Add the following line to CONFIG.SYS:
@@ -381,5 +379,5 @@
    to build this driver.)
  - Open Watcom version 1.9 or later
- - The Drv32 kit.
+ - The Drv32 kit. (You must have a DDK license to use the Drv32 kit.)
 
 Define DDK, WATCOM, and DRV32KIT in the environment.
@@ -391,5 +389,5 @@
 
 v.2.03 15-Jul-2017 - David Azarewicz
-  Added MSI support.
+  Added MSI support. PSD 3.23.06 or higher is required for MSI.
 
 v.2.02 07-Jun-2017 - David Azarewicz
Index: trunk/src/os2ahci/ahci.c
===================================================================
--- trunk/src/os2ahci/ahci.c	(revision 190)
+++ trunk/src/os2ahci/ahci.c	(revision 191)
@@ -692,5 +692,5 @@
       if (rc)
       {
-       dprintf(0,"failed to register interrupt %d\n", ai->irq);
+        dprintf(0,"failed to register interrupt %d\n", ai->irq);
         return(-1);
       }
@@ -1498,5 +1498,5 @@
   IORB_QUEUE done_queue;
   IORBH FAR16DATA *vIorb;
-  IORBH FAR16DATA *vNext = NULL;
+  IORBH FAR16DATA *vNext = FAR16NULL;
   u8 *port_mmio = port_base(ai, p);
   u32 irq_stat;
@@ -1555,5 +1555,5 @@
    *        processed after releasing the spinlock.
    */
-  for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != NULL; vIorb = vNext)
+  for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != FAR16NULL; vIorb = vNext)
   {
     IORBH *pIorb = Far16ToFlat(vIorb);
@@ -1584,5 +1584,5 @@
 
   /* complete all IORBs in the done queue */
-  for (vIorb = done_queue.vRoot; vIorb != NULL; vIorb = vNext)
+  for (vIorb = done_queue.vRoot; vIorb != FAR16NULL; vIorb = vNext)
   {
     IORBH *pIorb = Far16ToFlat(vIorb);
Index: trunk/src/os2ahci/ctxhook.c
===================================================================
--- trunk/src/os2ahci/ctxhook.c	(revision 190)
+++ trunk/src/os2ahci/ctxhook.c	(revision 191)
@@ -104,5 +104,5 @@
   D32ThunkStackTo32();
 
-  vNext = NULL;
+  vNext = FAR16NULL;
   rearm_ctx_hook = 0;
 
@@ -131,5 +131,5 @@
         /* restart this port */
         port_mmio = port_base(ai, p);
-        vProblemIorb = NULL;
+        vProblemIorb = FAR16NULL;
         need_reset = 0;
 
@@ -140,5 +140,5 @@
         DPRINTF(8," PORT_CMD      = 0x%x\n", ccs);
 
-        for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != NULL; vIorb = vNext)
+        for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != FAR16NULL; vIorb = vNext)
         {
           IORBH *pIorb = Far16ToFlat(vIorb);
@@ -180,5 +180,5 @@
               {
                 /* no further analysis -- we're done with this one */
-                vProblemIorb = NULL;
+                vProblemIorb = FAR16NULL;
               }
             }
@@ -223,5 +223,5 @@
         ai->ports[p].cmd_slot = 0;
 
-        if (vProblemIorb != NULL)
+        if (vProblemIorb != FAR16NULL)
         {
           IORBH *pProblemIorb = Far16ToFlat(vProblemIorb);
@@ -271,5 +271,5 @@
 
   /* call notification routine on all IORBs which have completed */
-  for (vIorb = done_queue.vRoot; vIorb != NULL; vIorb = vNext)
+  for (vIorb = done_queue.vRoot; vIorb != FAR16NULL; vIorb = vNext)
   {
     IORBH *pIorb = Far16ToFlat(vIorb);
@@ -339,5 +339,5 @@
   D32ThunkStackTo32();
 
-  vNext = NULL;
+  vNext = FAR16NULL;
   rearm_ctx_hook = 0;
 
@@ -355,5 +355,5 @@
 
   /* add ports of active IORBs from the abort queue to ports_to_reset[] */
-  for (vIorb = abort_queue.vRoot; vIorb != NULL; vIorb = vNext)
+  for (vIorb = abort_queue.vRoot; vIorb != FAR16NULL; vIorb = vNext)
   {
     IORBH *pIorb = Far16ToFlat(vIorb);
@@ -417,5 +417,5 @@
 
         /* retry or abort all remaining active commands on this port */
-        for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != NULL; vIorb = vNext)
+        for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != FAR16NULL; vIorb = vNext)
         {
           IORBH *pIorb = Far16ToFlat(vIorb);
@@ -448,5 +448,5 @@
 
   /* complete all aborted IORBs */
-  for (vIorb = done_queue.vRoot; vIorb != NULL; vIorb = vNext)
+  for (vIorb = done_queue.vRoot; vIorb != FAR16NULL; vIorb = vNext)
   {
     IORBH *pIorb = Far16ToFlat(vIorb);
Index: trunk/src/os2ahci/ioctl.c
===================================================================
--- trunk/src/os2ahci/ioctl.c	(revision 190)
+++ trunk/src/os2ahci/ioctl.c	(revision 191)
@@ -65,5 +65,5 @@
                          USHORT *d);
 
-extern IORBH FAR16DATA * __far16 IoctlWakeup16(IORBH FAR16DATA*);
+extern IORBH FAR16DATA * (__far16 *Far16AdrOfIoctlWakeup16)(IORBH FAR16DATA*);
 
 /* ------------------------ global/static variables ------------------------ */
@@ -175,5 +175,5 @@
   ic->iorb.iorbh.RequestControl   = IORB_ASYNC_POST;
   ic->iorb.iorbh.Timeout          = req->timeout;
-  ic->iorb.iorbh.NotifyAddress    = IoctlWakeup16;
+  ic->iorb.iorbh.NotifyAddress    = Far16AdrOfIoctlWakeup16;
 
   ic->iorb.cSGList = ic->sg_cnt;
Index: trunk/src/os2ahci/os2ahci.c
===================================================================
--- trunk/src/os2ahci/os2ahci.c	(revision 190)
+++ trunk/src/os2ahci/os2ahci.c	(revision 191)
@@ -463,5 +463,4 @@
 
     return(RPDONE);
-
   }
   else
@@ -500,5 +499,4 @@
     switch (ioctl->ioctl.bFunction)
     {
-
     case OS2AHCI_IOCTL_GET_DEVLIST:
       return(ioctl_get_devlist(ioctl));
@@ -506,5 +504,4 @@
     case OS2AHCI_IOCTL_PASSTHROUGH:
       return(ioctl_passthrough(ioctl));
-
     }
     break;
@@ -592,9 +589,9 @@
 {
   IORBH FAR16DATA *vIorb;
-  IORBH FAR16DATA *vNext = NULL;
+  IORBH FAR16DATA *vNext = FAR16NULL;
 
   spin_lock(drv_lock);
 
-  for (vIorb=vFirstIorb; vIorb!=NULL; vIorb=vNext)
+  for (vIorb=vFirstIorb; vIorb!=FAR16NULL; vIorb=vNext)
   {
     IORBH *pIorb = Far16ToFlat(vIorb);
@@ -622,5 +619,4 @@
       pIorb->UnitHandle = 0;
       iorb_queue_add(&driver_queue, vIorb, pIorb);
-
     }
     else
@@ -636,5 +632,4 @@
           (ad_infos[a].port_map & (1UL << p)) == 0)
       {
-
         /* unit handle outside of the allowed range */
         dprintf(0,"warning: IORB for %d.%d.%d out of range\n", a, p, d);
@@ -745,5 +740,5 @@
 
   /* process driver-level IORBs */
-  if ((vIorb = driver_queue.vRoot) != NULL)
+  if ((vIorb = driver_queue.vRoot) != FAR16NULL)
   {
     pIorb = Far16ToFlat(vIorb);
@@ -768,6 +763,6 @@
     {
       /* send all queued IORBs on this port */
-      vNext = NULL;
-      for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != NULL; vIorb = vNext)
+      vNext = FAR16NULL;
+      for (vIorb = ai->ports[p].iorb_queue.vRoot; vIorb != FAR16NULL; vIorb = vNext)
       {
         pIorb = Far16ToFlat(vIorb);
@@ -904,5 +899,5 @@
   AD_INFO *ai = ad_infos + iorb_unit_adapter(pIorb);
   IORBH FAR16DATA *vPtr;
-  IORBH FAR16DATA *vNext = NULL;
+  IORBH FAR16DATA *vNext = FAR16NULL;
   int p = iorb_unit_port(pIorb);
   int d = iorb_unit_device(pIorb);
@@ -910,9 +905,8 @@
   switch (pIorb->CommandModifier)
   {
-
   case IOCM_ABORT:
     /* abort all pending commands on specified port and device */
     spin_lock(drv_lock);
-    for (vPtr = ai->ports[p].iorb_queue.vRoot; vPtr != NULL; vPtr = vNext)
+    for (vPtr = ai->ports[p].iorb_queue.vRoot; vPtr != FAR16NULL; vPtr = vNext)
     {
       IORBH *pPtr = Far16ToFlat(vPtr);
@@ -1271,5 +1265,4 @@
   switch (pIorb->CommandModifier)
   {
-
   case IOCM_EXECUTE_CDB:
     add_workspace(pIorb)->idempotent = 0;
@@ -1303,7 +1296,7 @@
   {
     /* append IORB to end of queue */
-    pIorb->pNxtIORB = NULL;
-
-    if (queue->vRoot == NULL)
+    pIorb->pNxtIORB = FAR16NULL;
+
+    if (queue->vRoot == FAR16NULL)
     {
       queue->vRoot = vIorb;
@@ -1330,10 +1323,8 @@
       queue_type = "local";
       min_debug = 8;
-
     }
     else if (queue == &driver_queue)
     {
       queue_type = "driver";
-
     }
     else if (queue == &abort_queue)
@@ -1341,5 +1332,4 @@
       queue_type = "abort";
       min_debug = 8;
-
     }
     else
@@ -1362,8 +1352,8 @@
 {
   IORBH FAR16DATA *_vIorb;
-  IORBH FAR16DATA *_vPrev = NULL;
+  IORBH FAR16DATA *_vPrev = FAR16NULL;
   int found = 0;
 
-  for (_vIorb = queue->vRoot; _vIorb != NULL; )
+  for (_vIorb = queue->vRoot; _vIorb != FAR16NULL; )
   {
     IORBH *_pIorb = Far16ToFlat(_vIorb);
@@ -1371,5 +1361,5 @@
     {
       /* found the IORB to be removed */
-      if (_vPrev != NULL)
+      if (_vPrev != FAR16NULL)
       {
         ((IORBH*)Far16ToFlat(_vPrev))->pNxtIORB = _pIorb->pNxtIORB;
Index: trunk/src/os2ahci/thunk.asm
===================================================================
--- trunk/src/os2ahci/thunk.asm	(revision 190)
+++ trunk/src/os2ahci/thunk.asm	(revision 191)
@@ -10,5 +10,4 @@
 _TEXT16 SEGMENT byte PUBLIC USE16 'CODE'
         assume ds:nothing, es:nothing
-        public IoctlWakeup16
 IoctlWakeup16 Proc far
         jmp     far ptr FLAT:IoctlWakeup32
@@ -16,4 +15,15 @@
 
 _TEXT16 ENDS
+
+;==========================================================
+; 32 bit data segment
+;
+_DATA     segment dword public use32 'DATA'
+
+Far16AdrOfIoctlWakeup16 dw offset _TEXT16:IoctlWakeup16
+                        dw seg _TEXT16:IoctlWakeup16
+        public Far16AdrOfIoctlWakeup16
+
+_DATA       ends
 
 ;==========================================================
