Index: trunk/src/os2ahci/ReadMe.txt
===================================================================
--- trunk/src/os2ahci/ReadMe.txt	(revision 204)
+++ trunk/src/os2ahci/ReadMe.txt	(revision 205)
@@ -1,3 +1,3 @@
-AHCI Driver for OS/2 v2.07
+AHCI Driver for OS/2 v2.08
 
 Introduction
@@ -16,5 +16,5 @@
 Copyright (c) 2011 thi.guten Software Development
 Copyright (c) 2011 Mensys B.V.
-Copyright (c) 2013-2018 David Azarewicz
+Copyright (c) 2013-2021 David Azarewicz
 
 Authors: Christian Mueller, Markus Thielen
@@ -388,4 +388,7 @@
 Change Log
 ==========
+v.2.08 01-Nov-2020 - David Azarewicz
+  Corrected RM ADD handle and unit.
+
 v.2.07 19-May-2019 - David Azarewicz
   Fixed hardware failure recovery to arm ctx hook in watchdog timer.
Index: trunk/src/os2ahci/ahci.c
===================================================================
--- trunk/src/os2ahci/ahci.c	(revision 204)
+++ trunk/src/os2ahci/ahci.c	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * ahci.c - ahci hardware access functions
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -29,6 +29,4 @@
 #include "ata.h"
 #include "atapi.h"
-
-/* -------------------------- macros and constants ------------------------- */
 
 /* produce ata/atapi function pointer with the given func name */
@@ -38,6 +36,4 @@
                               ? atapi_##func : ata_##func
 
-
-/* ------------------------ global/static variables ------------------------ */
 
 /* Initial driver status flags indexed by the board_* constants in os2ahci.h
@@ -76,6 +72,4 @@
 static u16 irq_used[MAX_IRQ_HANDLERS]; /* IRQ level for each used IRQ */
 static int irq_used_cnt; /* number of IRQs used */
-
-/* ----------------------------- start of code ----------------------------- */
 
 #ifdef DEBUG
@@ -680,5 +674,4 @@
   char dev_name[RM_MAX_PREFIX_LEN+ATA_ID_PROD_LEN+1];
   char *pDevName;
-  static u8 total_dev_cnt;
 
   if (p >= AHCI_MAX_PORTS) return;
@@ -737,6 +730,6 @@
   adj.AdjLength           = sizeof(adj);
   adj.AdjType             = ADJ_ADD_UNIT;
-  adj.Add_Unit.ADDHandle  = rm_drvh;
-  adj.Add_Unit.UnitHandle = (USHORT)total_dev_cnt;
+  adj.Add_Unit.ADDHandle  = add_handle;
+  adj.Add_Unit.UnitHandle = iorb_unit(ad_no(ai), p, d);
 
   /* create Resource Manager device key string;
@@ -759,6 +752,4 @@
 
   RMCreateDevice(rm_drvh, &dh, &ds, ai->rm_adh, NULL);
-
-  total_dev_cnt++;
 
   /* try to detect virtualbox environment to enable a hack for IRQ routing */
@@ -1420,5 +1411,5 @@
     if (rc)
     {
-      DPRINTF(3," timeout for IORB %x", vIorb);
+      DPRINTF(3," timeout for IORB %x port=%x", vIorb, p);
       iorb_seterr(pIorb, IOERR_ADAPTER_TIMEOUT);
     }
Index: trunk/src/os2ahci/ahci.h
===================================================================
--- trunk/src/os2ahci/ahci.h	(revision 204)
+++ trunk/src/os2ahci/ahci.h	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * ahci.h - AHCI-specific constants for os2ahci.h
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -26,7 +26,4 @@
  */
 
-/* ----------------------------- include files ----------------------------- */
-
-/* -------------------------- macros and constants ------------------------- */
 
 /******************************************************************************
@@ -251,6 +248,4 @@
 #define EM_CTL_ALHD                     (1UL << 26) /* Activity LED */
 
-/* ------------------------ typedefs and structures ------------------------ */
-
 /* Primitive types
  *
Index: trunk/src/os2ahci/apm.c
===================================================================
--- trunk/src/os2ahci/apm.c	(revision 204)
+++ trunk/src/os2ahci/apm.c	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * apm.c - Functions to interface with the legacy APM driver, and suspend / resume functions.
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Portions copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
Index: trunk/src/os2ahci/ata.c
===================================================================
--- trunk/src/os2ahci/ata.c	(revision 204)
+++ trunk/src/os2ahci/ata.c	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * ata.c - ATA command processing
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -29,8 +29,4 @@
 #include "ata.h"
 
-/* -------------------------- macros and constants ------------------------- */
-
-/* ------------------------ typedefs and structures ------------------------ */
-
 /* -------------------------- function prototypes -------------------------- */
 
@@ -42,8 +38,4 @@
                          ULONG sector, ULONG count, SCATGATENTRY *sg_list,
                          ULONG sg_cnt, int write_through);
-
-/* ------------------------ global/static variables ------------------------ */
-
-/* ----------------------------- start of code ----------------------------- */
 
 /******************************************************************************
Index: trunk/src/os2ahci/ata.h
===================================================================
--- trunk/src/os2ahci/ata.h	(revision 204)
+++ trunk/src/os2ahci/ata.h	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * ata.h - ATA structures and macros for os2ahci driver
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -25,6 +25,4 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
-/* -------------------------- macros and constants ------------------------- */
 
 /******************************************************************************
Index: trunk/src/os2ahci/atapi.c
===================================================================
--- trunk/src/os2ahci/atapi.c	(revision 204)
+++ trunk/src/os2ahci/atapi.c	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * atapi.c - ATAPI command processing
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -33,16 +33,6 @@
 #include <Dev32scsi.h>
 
-/* -------------------------- macros and constants ------------------------- */
-
-/* ------------------------ typedefs and structures ------------------------ */
-
-/* -------------------------- function prototypes -------------------------- */
-
 static void atapi_req_sense_pp(IORBH FAR16DATA *vIorb, IORBH *pIorb);
 static int atapi_pad_cdb(u8 *cmd_in, u16 cmd_in_len, u8 *cmd_out, u16 *cmd_out_len);
-
-/* ------------------------ global/static variables ------------------------ */
-
-/* ----------------------------- start of code ----------------------------- */
 
 /******************************************************************************
Index: trunk/src/os2ahci/atapi.h
===================================================================
--- trunk/src/os2ahci/atapi.h	(revision 204)
+++ trunk/src/os2ahci/atapi.h	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * atapi.h - ATAPI structures and macros for os2ahci driver
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -25,6 +25,4 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
-/* -------------------------- macros and constants ------------------------- */
 
 #define ATAPI_MIN_CDB_LEN   12   /* minimum ATAPI CDB len acc to AHCI spec */
@@ -104,6 +102,4 @@
 #define ATAPI_GET_SENSE(p_) (u8)(p_->sense.sense_key & 0x0f)
 
-/* ------------------------ typedefs and structures ------------------------ */
-
 /******************************************************************************
  * ATAPI_SENSE_DATA - define layout of ATAPI sense data
@@ -163,8 +159,4 @@
 
 
-/* ---------------------------- global variables --------------------------- */
-
-/* -------------------------- function prototypes -------------------------- */
-
 extern int atapi_get_geometry(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot);
 extern int atapi_unit_ready(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot);
Index: trunk/src/os2ahci/ctxhook.c
===================================================================
--- trunk/src/os2ahci/ctxhook.c	(revision 204)
+++ trunk/src/os2ahci/ctxhook.c	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * ctxhook.c - context hooks (kernel thread functions) for os2ahci
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -29,12 +29,4 @@
 #include "ata.h"
 #include "atapi.h"
-
-/* -------------------------- macros and constants ------------------------- */
-
-/* ------------------------ typedefs and structures ------------------------ */
-
-/* -------------------------- function prototypes -------------------------- */
-
-/* ------------------------ global/static variables ------------------------ */
 
 /* port restart context hook and input data */
@@ -50,6 +42,4 @@
 /* trigger engine context hook and input data */
 ULONG           engine_ctxhook_h;
-
-/* ----------------------------- start of code ----------------------------- */
 
 /******************************************************************************
Index: trunk/src/os2ahci/ioctl.c
===================================================================
--- trunk/src/os2ahci/ioctl.c	(revision 204)
+++ trunk/src/os2ahci/ioctl.c	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * ioctl.c - Generic IOCTL command processing
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -34,8 +34,4 @@
 
 #pragma pack(1)
-
-/* -------------------------- macros and constants ------------------------- */
-
-/* ------------------------ typedefs and structures ------------------------ */
 
 /* Memory area for IOCTLs which send IORBs downstream; currently only
@@ -58,14 +54,8 @@
 } IOCTL_CONTEXT;
 
-/* -------------------------- function prototypes -------------------------- */
-
 static USHORT do_smart(BYTE unit, BYTE sub_func, BYTE cnt, BYTE lba_l, void *buf);
 static int map_unit(BYTE unit, USHORT *a, USHORT *p, USHORT *d);
 
 extern IORBH FAR16DATA * (__far16 *Far16AdrOfIoctlWakeup16)(IORBH FAR16DATA*);
-
-/* ------------------------ global/static variables ------------------------ */
-
-/* ----------------------------- start of code ----------------------------- */
 
 /******************************************************************************
Index: trunk/src/os2ahci/ioctl.h
===================================================================
--- trunk/src/os2ahci/ioctl.h	(revision 204)
+++ trunk/src/os2ahci/ioctl.h	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * ioctl.h - IOCTL structures and constants for os2ahci driver
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -25,6 +25,4 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
-/* -------------------------- macros and constants ------------------------- */
 
 /* IOCTL categories and functions */
@@ -71,6 +69,4 @@
 #define PT_WRITE            0x0001U    /* transfer direction host -> device */
 #define PT_ATAPI            0x0002U    /* ATAPI command (ATA if not set) */
-
-/* ------------------------ typedefs and structures ------------------------ */
 
 #ifndef VMDHL_WRITE
Index: trunk/src/os2ahci/os2ahci.c
===================================================================
--- trunk/src/os2ahci/os2ahci.c	(revision 204)
+++ trunk/src/os2ahci/os2ahci.c	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * os2ahci.c - main file for os2ahci driver
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -30,6 +30,4 @@
 #include "version.h"
 #include "devhdr.h"
-
-/* -------------------------- macros and constants ------------------------- */
 
 /* set two-dimensional array of port options */
@@ -55,12 +53,7 @@
 #define TYPE_KRNL_EXIT_INT13      0x0004  /* enable int13 IO */
 
-/* ------------------------ typedefs and structures ------------------------ */
-
-/* -------------------------- function prototypes -------------------------- */
-
 extern int SetPsdPutc(void);
 static int add_unit_info(IORB_CONFIGURATION *iorb_conf, int dt_ai, int a, int p, int d, int scsi_id);
 
-/* ------------------------ global/static variables ------------------------ */
 int thorough_scan = 1; /* if != 0, perform thorough PCI scan */
 int init_reset = 1;    /* if != 0, reset ports during init */
@@ -106,6 +99,4 @@
 
 char BldLevel[] = BLDLEVEL;
-
-/* ----------------------------- start of code ----------------------------- */
 
 /******************************************************************************
@@ -1550,5 +1541,5 @@
 
   Timer_CancelTimer(timer_handle);
-  dprintf(0,"timeout for IORB %x\n", vIorb);
+  dprintf(0,"timeout for IORB %x port=%x\n", vIorb, p);
 
   /* Move the timed-out IORB to the abort queue. Since it's possible that the
Index: trunk/src/os2ahci/os2ahci.h
===================================================================
--- trunk/src/os2ahci/os2ahci.h	(revision 204)
+++ trunk/src/os2ahci/os2ahci.h	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * os2ahci.h - main header file for os2ahci driver
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -25,6 +25,4 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
-/* ----------------------------- include files ----------------------------- */
 
 /* IMPORTANT NOTE: The DDK headers require tight structure packing and this
@@ -48,6 +46,4 @@
 #include "ahci.h"
 #include "ahci-idc.h"
-
-/* -------------------------- macros and constants ------------------------- */
 
 #define MAX_AD 8 /* maximum number of adapters */
@@ -358,6 +354,4 @@
                                    /* These are the four entries which correspond to the entries in the partition table. */
 } DLA_Table_Sector, *PDLA_Table_Sector;
-
-/* -------------------------- function prototypes -------------------------- */
 
 static inline unsigned long readl(void *a)
@@ -473,6 +467,4 @@
 
 
-/* ---------------------------- global variables --------------------------- */
-
 extern int thorough_scan; /* if != 0, perform thorough PCI scan */
 extern int init_reset; /* if != 0, reset ports during init */
Index: trunk/src/os2ahci/pci.c
===================================================================
--- trunk/src/os2ahci/pci.c	(revision 204)
+++ trunk/src/os2ahci/pci.c	(revision 205)
@@ -1,8 +1,8 @@
-/******************************************************************************
+/**
  * PCI.c - PCI constants and detection code for os2ahci driver
  *
  * Copyright (c) 2011 thi.guten Software Development
  * Copyright (c) 2011 Mensys B.V.
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  * Authors: Christian Mueller, Markus Thielen
@@ -28,18 +28,10 @@
 #include "os2ahci.h"
 
-/* -------------------------- macros and constants ------------------------- */
-
 /* offset of PCI base address register (BAR) in the PCI config space */
 #define PCI_BAR(reg)   (UCHAR) (0x10 + (reg) * sizeof(u32))
-
-/* ------------------------ typedefs and structures ------------------------ */
-
-/* -------------------------- function prototypes -------------------------- */
 
 static void  add_pci_device(PCI_ID *pci_id, USHORT BusDevFunc);
 static long  bar_resource(USHORT BusDevFunc, RESOURCESTRUCT *resource, int i);
 static char *rmerr(APIRET ret);
-
-/* ------------------------ global/static variables ------------------------ */
 
 /******************************************************************************
@@ -245,6 +237,4 @@
 };
 
-/* ----------------------------- start of code ----------------------------- */
-
 /******************************************************************************
  * Add specified PCI vendor and device ID to the list of supported AHCI
Index: trunk/src/os2ahci/thunk.asm
===================================================================
--- trunk/src/os2ahci/thunk.asm	(revision 204)
+++ trunk/src/os2ahci/thunk.asm	(revision 205)
@@ -1,4 +1,4 @@
 ; Thunking for ahci32 driver
-; Copyright (c) 2018 David Azarewicz
+; Copyright (c) 2018-2021 David Azarewicz
 ; Author: David Azarewicz <david@88watts.net>
 
Index: trunk/src/os2ahci/trace.c
===================================================================
--- trunk/src/os2ahci/trace.c	(revision 204)
+++ trunk/src/os2ahci/trace.c	(revision 205)
@@ -1,5 +1,5 @@
-/******************************************************************************
+/**
  *
- * Copyright (c) 2013-2018 David Azarewicz
+ * Copyright (c) 2013-2021 David Azarewicz <david@88watts.net>
  *
  */
@@ -7,15 +7,5 @@
 #include "os2ahci.h"
 
-/* -------------------------- macros and constants ------------------------- */
-
-/* ------------------------ typedefs and structures ------------------------ */
-
-/* -------------------------- function prototypes -------------------------- */
-
-/* ------------------------ global/static variables ------------------------ */
-
-/* ----------------------------- start of code ----------------------------- */
-
-/******************************************************************************
+/**
  * Create adapter/port/device list for user output.
  */
