Index: trunk/src/os2ahci/Makefile
===================================================================
--- trunk/src/os2ahci/Makefile	(revision 184)
+++ trunk/src/os2ahci/Makefile	(revision 185)
@@ -156,5 +156,5 @@
   cd ..
 
-release: $(O)\os2ahci.add $(O)\os2ahci.sym .symbolic
+release: .symbolic
   @if exist $(WPIFILE) @del $(WPIFILE)
   @!rm -rf $(ZIPDIR)
@@ -163,6 +163,6 @@
 
   @md $(ZIPDIR)\pkg1
-  @copy /b $(ROOT)\src\os2ahci\$(O)\os2ahci.add $(ZIPDIR)\pkg1 >NUL
-  @copy /b $(ROOT)\src\os2ahci\$(O)\os2ahci.sym $(ZIPDIR)\pkg1 >NUL
+  copy /b $(ROOT)\src\os2ahci\$(O)\os2ahci.add $(ZIPDIR)\pkg1 >NUL
+  copy /b $(ROOT)\src\os2ahci\$(O)\os2ahci.sym $(ZIPDIR)\pkg1 >NUL
 
   @md $(ZIPDIR)\pkg2
Index: trunk/src/os2ahci/ReadMe.txt
===================================================================
--- trunk/src/os2ahci/ReadMe.txt	(revision 184)
+++ trunk/src/os2ahci/ReadMe.txt	(revision 185)
@@ -118,5 +118,5 @@
                        [Intel] AHCI controller was found to be
                        initialized by the BIOS in SATA mode, ports will
-                       always be reset even when /!R was specified
+                       always be reset even when /!R is specified
 
 /A:n                   Set adapter to n for adapter-specific options
Index: trunk/src/os2ahci/ahci.c
===================================================================
--- trunk/src/os2ahci/ahci.c	(revision 184)
+++ trunk/src/os2ahci/ahci.c	(revision 185)
@@ -295,5 +295,5 @@
     /* more ports in port_map than in HOST_CAP & 0x1f */
     ports = ai->hw_ports;
-    DPRINTF(1,"implemented port map (0x%x) contains more ports than nr_ports (%d), using nr_ports\n", ai->port_map, ports);
+    DPRINTF(1,"implemented port map (0x%x) contains more ports than hw_ports (%d), using hw_ports\n", ai->port_map, ports);
     ai->port_map = (1UL << ports) - 1UL;
   }
@@ -371,5 +371,5 @@
     int p;
 
-    for (p = 0; p < AHCI_MAX_PORTS; p++)
+    for (p = 0; p <= ai->port_max; p++)
     {
       if (ai->port_map & (1UL << p))
@@ -729,5 +729,5 @@
    * enough if a previously detected device has problems.
    */
-  for (p = 0; p < AHCI_MAX_PORTS; p++)
+  for (p = 0; p <= ai->port_max; p++)
   {
     if (ai->port_map & (1UL << p))
@@ -1791,4 +1791,5 @@
   HDEVICE dh;
   char dev_name[RM_MAX_PREFIX_LEN+ATA_ID_PROD_LEN+1];
+  char *pDevName;
   static u8 total_dev_cnt;
 
@@ -1804,4 +1805,6 @@
   ai->ports[p].devs[d].removable = (id_buf[ATA_ID_CONFIG] & 0x0080U) != 0;
   ai->ports[p].devs[d].dev_type  = UIB_TYPE_DISK;
+  pDevName = ai->ports[p].devs[d].dev_name;
+  strncpy(pDevName, ata_dev_name(id_buf), sizeof(ai->ports[0].devs[0].dev_name));
 
   if (id_buf[ATA_ID_CONFIG] & 0x8000U)
@@ -1847,5 +1850,5 @@
   adj.AdjType             = ADJ_ADD_UNIT;
   adj.Add_Unit.ADDHandle  = rm_drvh;
-  adj.Add_Unit.UnitHandle = (USHORT) total_dev_cnt;
+  adj.Add_Unit.UnitHandle = (USHORT)total_dev_cnt;
 
   /* create Resource Manager device key string;
@@ -1854,9 +1857,9 @@
   if (ai->ports[p].devs[d].removable)
   {
-    sprintf(dev_name, RM_CD_PREFIX "%s", p, d, ata_dev_name(id_buf));
+    sprintf(dev_name, RM_CD_PREFIX "%s", p, d, pDevName);
   }
   else
   {
-    sprintf(dev_name, RM_HD_PREFIX "%s", p, d, ata_dev_name(id_buf));
+    sprintf(dev_name, RM_HD_PREFIX "%s", p, d, pDevName);
   }
 
@@ -1873,5 +1876,5 @@
   /* try to detect virtualbox environment to enable a hack for IRQ routing */
   if (ai == ad_infos && ai->pci_vendor == 0x8086 && ai->pci_device == 0x2829 &&
-      !memcmp(ata_dev_name(id_buf), "VBOX HARDDISK", 13))
+      !memcmp(pDevName, "VBOX HARDDISK", 13))
   {
     /* running inside virtualbox */
Index: trunk/src/os2ahci/ahci.h
===================================================================
--- trunk/src/os2ahci/ahci.h	(revision 184)
+++ trunk/src/os2ahci/ahci.h	(revision 185)
@@ -59,9 +59,10 @@
 #define AHCI_PCI_BAR            5
 #define AHCI_MAX_PORTS          16 /* Spec says 32, but we only support 16 */
-#define AHCI_MAX_DEVS           8
+#define AHCI_MAX_DEVS           1 /* was 8. we only support 1 drive per port */
 #define AHCI_MAX_SG             48 /* hardware max is 64K */
 #define AHCI_MAX_SG_ELEMENT_LEN (1UL << 22)
 #define AHCI_MAX_CMDS           32
 #define AHCI_RX_FIS_SZ          256
+#define AHCI_DEV_NAME_LEN       40
 
 /* port-specific DMA scratch buffer aligned to 1024 bytes */
Index: trunk/src/os2ahci/ata.c
===================================================================
--- trunk/src/os2ahci/ata.c	(revision 184)
+++ trunk/src/os2ahci/ata.c	(revision 185)
@@ -272,5 +272,5 @@
       if ((sg_addr & 1) || (chunk & 1))
       {
-        dprintf(0,"error: ata_cmd() called with unaligned S/G element(s)\n");
+        dprintf(1,"error: ata_cmd() called with unaligned S/G element(s)\n");
         return(ATA_CMD_UNALIGNED_ADDR);
       }
Index: trunk/src/os2ahci/ata.h
===================================================================
--- trunk/src/os2ahci/ata.h	(revision 184)
+++ trunk/src/os2ahci/ata.h	(revision 185)
@@ -491,15 +491,9 @@
 /* -------------------------- function prototypes -------------------------- */
 
-extern int       ata_cmd                  (AD_INFO *ai, int port, int device,
-                                           int slot, int cmd, ...);
-extern int       v_ata_cmd                (AD_INFO *ai, int port, int device,
-                                           int slot, int cmd, va_list va);
-extern void      ata_cmd_to_fis           (u8 *fis, ATA_CMD *cmd,
-                                           int device);
-extern USHORT    ata_get_sg_indx          (IORB_EXECUTEIO *io);
-extern void      ata_max_sg_cnt           (IORB_EXECUTEIO *io,
-                                           USHORT sg_indx, USHORT sg_max,
-                                           USHORT *sg_cnt,
-                                           USHORT *sector_cnt);
+extern int ata_cmd(AD_INFO *ai, int port, int device, int slot, int cmd, ...);
+extern int v_ata_cmd(AD_INFO *ai, int port, int device, int slot, int cmd, va_list va);
+extern void ata_cmd_to_fis(u8 *fis, ATA_CMD *cmd, int device);
+extern USHORT ata_get_sg_indx(IORB_EXECUTEIO *io);
+extern void ata_max_sg_cnt(IORB_EXECUTEIO *io, USHORT sg_indx, USHORT sg_max, USHORT *sg_cnt, USHORT *sector_cnt);
 
 extern int ata_get_geometry(IORBH FAR16DATA *iorb, IORBH *pIorb, int slot);
@@ -517,4 +511,4 @@
 extern int ata_req_sense(IORBH FAR16DATA *vIorb, IORBH *pIorb, int slot);
 
-extern char     *ata_dev_name             (u16 *id_buf);
-
+extern char *ata_dev_name(u16 *id_buf);
+
Index: trunk/src/os2ahci/os2ahci.c
===================================================================
--- trunk/src/os2ahci/os2ahci.c	(revision 184)
+++ trunk/src/os2ahci/os2ahci.c	(revision 185)
@@ -1366,5 +1366,4 @@
     if (_vIorb == vIorb)
     {
-
       /* found the IORB to be removed */
       if (_vPrev != NULL)
Index: trunk/src/os2ahci/os2ahci.h
===================================================================
--- trunk/src/os2ahci/os2ahci.h	(revision 184)
+++ trunk/src/os2ahci/os2ahci.h	(revision 185)
@@ -243,15 +243,15 @@
 /* port information structure */
 typedef struct {
-  IORB_QUEUE    iorb_queue;            /* IORB queue for this port */
-  unsigned      dev_max     : 4;       /* maximum device number on this port (0..AHCI_MAX_DEVS-1) */
-  unsigned      cmd_slot    : 5;       /* current command slot index (using round-
-                                        * robin indexes to prevent starvation) */
-
-  volatile u32  ncq_cmds;              /* bitmap for NCQ commands issued */
-  volatile u32  reg_cmds;              /* bitmap for regular commands issued */
-  u32           dma_buf_phys;          /* physical address of DMA scratch buffer */
-  u8           *dma_buf;               /* DMA scatch buffers */
-
-  struct {
+  IORB_QUEUE    iorb_queue;            /* 00 IORB queue for this port */
+  unsigned      dev_max     : 4;       /* 08 maximum device number on this port (0..AHCI_MAX_DEVS-1) */
+  unsigned      cmd_slot    : 5;       /*    current command slot index (using round-
+                                        *    robin indexes to prevent starvation) */
+
+  volatile u32  ncq_cmds;              /* 0c bitmap for NCQ commands issued */
+  volatile u32  reg_cmds;              /* 10 bitmap for regular commands issued */
+  u32           dma_buf_phys;          /* 14 physical address of DMA scratch buffer */
+  u8           *dma_buf;               /* 18 DMA scatch buffers */
+
+  struct {                             /* 1c */
     unsigned allocated :1;        /* if != 0, device is allocated */
     unsigned present   :1;        /* if != 0, device is present */
@@ -264,4 +264,5 @@
     UNITINFO *unit_info;          /* pointer to modified unit info */
     DEV_INFO dev_info;
+    char dev_name[AHCI_DEV_NAME_LEN];
   } devs[AHCI_MAX_DEVS];
 
@@ -272,36 +273,35 @@
 /* adapter information structure */
 typedef struct {
-  PCI_ID       *pci;                   /* pointer to corresponding PCI ID */
-
-  unsigned      port_max : 5;          /* maximum port number (0..AHCI_MAX_PORTS-1) */
-  unsigned      cmd_max : 5;           /* maximum cmd slot number (0-31) */
-  unsigned      port_scan_done : 1;    /* if != 0, port scan already done */
-  unsigned      busy : 1;              /* if != 0, adapter is busy */
-
-  unsigned      hw_ports : 6;          /* number of ports as reported by the hardware */
-
-  u32           port_map;              /* bitmap of active ports */
-  u16           pci_vendor;
-  u16           pci_device;
+  PCI_ID       *pci;                   /* 00 pointer to corresponding PCI ID */
+
+  unsigned      port_max : 5;          /* 04 maximum port number (0..AHCI_MAX_PORTS-1) */
+  unsigned      cmd_max : 5;           /*    maximum cmd slot number (0-31) */
+  unsigned      port_scan_done : 1;    /*    if != 0, port scan already done */
+  unsigned      busy : 1;              /*    if != 0, adapter is busy */
+  unsigned      hw_ports : 6;          /*    number of ports as reported by the hardware */
+
+  u32           port_map;              /* 08   bitmap of active ports */
+  u16           pci_vendor;            /* 0c */
+  u16           pci_device;            /* 0e */
 
   /* initial adapter configuration from BIOS */
-  u32           bios_config[HOST_CAP2 / sizeof(u32) + 1];
-
-  u32           cap;                   /* working copy of CAP register */
-  u32           cap2;                  /* working copy of CAP2 register */
-  u32           flags;                 /* adapter flags */
-
-  HRESOURCE     rm_adh;                /* resource handle for adapter */
-  HRESOURCE     rm_bars[6];            /* resource handle for MMIO and I/O BARs */
-  HRESOURCE     rm_irq;                /* resource handle for IRQ */
-
-  u16           bus_dev_func;          /* PCI bus number PCI device and function number */
-  u16           irq;                   /* interrupt number */
-
-  u32           mmio_phys;             /* physical address of MMIO region */
-  u32           mmio_size;             /* size of MMIO region */
-  u8           *mmio;                  /* pointer to this adapter's MMIO region */
-
-  P_INFO        ports[AHCI_MAX_PORTS]; /* SATA ports on this adapter */
+  u32           bios_config[HOST_CAP2 / sizeof(u32) + 1];  /* 10  0x24 / 4 + 1 = 0x0a dwords = 0x28 bytes*/
+
+  u32           cap;                   /* 38 working copy of CAP register */
+  u32           cap2;                  /* 3c working copy of CAP2 register */
+  u32           flags;                 /* 40 adapter flags */
+
+  HRESOURCE     rm_adh;                /* 44 resource handle for adapter */
+  HRESOURCE     rm_bars[6];            /* 48 resource handle for MMIO and I/O BARs */
+  HRESOURCE     rm_irq;                /* 60 resource handle for IRQ */
+
+  u16           bus_dev_func;          /* 64 PCI bus number PCI device and function number */
+  u16           irq;                   /* 66 interrupt number */
+
+  u32           mmio_phys;             /* 68 physical address of MMIO region */
+  u32           mmio_size;             /* 6c size of MMIO region */
+  u8           *mmio;                  /* 70 pointer to this adapter's MMIO region */
+
+  P_INFO        ports[AHCI_MAX_PORTS]; /* 74 SATA ports on this adapter */
 } AD_INFO;
 
Index: trunk/src/os2ahci/pci.c
===================================================================
--- trunk/src/os2ahci/pci.c	(revision 184)
+++ trunk/src/os2ahci/pci.c	(revision 185)
@@ -631,6 +631,8 @@
   #ifndef DAZ_NEW_CODE
   /* fill in DMA scratch buffer addresses in adapter info */
-  for (i = 0; i < ad_info->hw_ports; i++)
-  {
+  for (i = 0; i < AHCI_MAX_PORTS; i++)
+  {
+    if (!(ad_info->port_map & (1UL << i))) continue;
+
     ad_info->ports[i].dma_buf = MemAllocAlign(AHCI_PORT_PRIV_DMA_SZ, 1024);
     ad_info->ports[i].dma_buf_phys = MemPhysAdr(ad_info->ports[i].dma_buf);
Index: trunk/src/os2ahci/trace.c
===================================================================
--- trunk/src/os2ahci/trace.c	(revision 184)
+++ trunk/src/os2ahci/trace.c	(revision 185)
@@ -1,27 +1,6 @@
 /******************************************************************************
- * trace.c - code for our internal trace ring buffer
  *
- * Copyright (c) 2011 thi.guten Software Development
- * Copyright (c) 2011 Mensys B.V.
  * Copyright (c) 2013-2016 David Azarewicz
  *
- * Authors: Christian Mueller, Markus Thielen
- *
- * Parts copied from/inspired by the Linux AHCI driver;
- * those parts are (c) Linux AHCI/ATA maintainers
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -58,5 +37,5 @@
       ai->bios_config[HOST_VERSION / sizeof(u32)]);
 
-    for (p = 0; p < ai->hw_ports; p++)
+    for (p = 0; p <= ai->port_max; p++)
     {
       P_INFO *pi = &ai->ports[p];
@@ -80,4 +59,5 @@
           }
           dprintf(0,"\n");
+          dprintf(0,"             Model: %s\n", pi->devs[d].dev_name);
         } /* if */
       } /* for d */
