Index: trunk/src/os2ahci/Makefile
===================================================================
--- trunk/src/os2ahci/Makefile	(revision 196)
+++ trunk/src/os2ahci/Makefile	(revision 198)
@@ -12,5 +12,5 @@
 # Define default build version if not specified in environment
 BLD_MAJOR=2
-BLD_MINOR=05 # must be 2 digits
+BLD_MINOR=06 # must be 2 digits
 BLD_REV=0 # not used at this time
 
Index: trunk/src/os2ahci/ReadMe.txt
===================================================================
--- trunk/src/os2ahci/ReadMe.txt	(revision 196)
+++ trunk/src/os2ahci/ReadMe.txt	(revision 198)
@@ -1,3 +1,3 @@
-AHCI Driver for OS/2 v2.05
+AHCI Driver for OS/2 v2.06
 
 Introduction
@@ -123,4 +123,8 @@
                        Otherwise, ignore the current port on the current adapter.
 
+/U                     Check for usable disks and ignore disks that are not
+                       usable. To be usable a disk must be an MBR disk or wiped.
+                       (default = on) Can be turned off with /!U.
+
 Port-specific Options
 
@@ -164,4 +168,10 @@
   - Disable NCQ for hard disk on adapter #0, port #5
   - Disable NCQ for all hard disks on adapter #1
+
+Another example:
+
+  BASEDEV=OS2AHCI.ADD /A:0 /P:0 /I
+
+Means to ingore the disk plugged into port 0 on adapeter 0.
 
 
@@ -379,4 +389,8 @@
 ==========
 
+v.2.06 19-Sep-2018 - David Azarewicz
+  Added Usable Disk check to ignore non-usable (e.g. non-MBR) disks.
+  Added /U switch to enable/disable Usable Disk check.
+
 v.2.05 05-Apr-2018 - David Azarewicz
   Changes to debug output for debug versions.
Index: trunk/src/os2ahci/ahci.c
===================================================================
--- trunk/src/os2ahci/ahci.c	(revision 196)
+++ trunk/src/os2ahci/ahci.c	(revision 198)
@@ -38,10 +38,4 @@
                               ? atapi_##func : ata_##func
 
-
-/* ------------------------ typedefs and structures ------------------------ */
-
-/* -------------------------- function prototypes -------------------------- */
-
-static void ahci_setup_device(AD_INFO *ai, int p, int d, u16 *id_buf);
 
 /* ------------------------ global/static variables ------------------------ */
@@ -531,4 +525,250 @@
 
 /******************************************************************************
+ * Complete initialization of adapter. This includes restarting all active
+ * ports and initializing interrupt processing. This is called when receiving
+ * the IOCM_COMPLETE_INIT request.
+ */
+int ahci_complete_init(AD_INFO *ai)
+{
+  int rc;
+  u32 p;
+  int i;
+
+  DPRINTF(1,"ahci_complete_init: completing initialization of adapter #%d\n", ad_no(ai));
+
+  if (!ai->int_set)
+  {
+    /* register IRQ handler; each IRQ level is registered only once */
+    p = 1; /* int count */
+    if (!(ai->flags & AHCI_HFLAG_NO_MSI))
+    {
+      if (PsdMsiAlloc(ai->bus_dev_func, &p, &ai->irq)) p = 1; /* shared flag */
+      else
+      {
+        /* we have an msi interrupt */
+        ai->irq_pin = 0;
+        p = 0; /* exclusive flag */
+      }
+    }
+    for (i = 0; i < irq_used_cnt; i++)
+    {
+      if (irq_used[i] == ai->irq) break; /* we already have this IRQ registered */
+    }
+    if (i >= irq_used_cnt)
+    {
+      if (i >= MAX_IRQ_HANDLERS) return -1; /* no more handlers available */
+      DPRINTF(2,"registering interrupt #%d\n", ai->irq);
+
+      rc = Dev32Help_SetIRQ(ahci_intr, ai->irq, p, ai->irq);
+      if (rc && p) /* if failed and was shared */
+      {
+        p = 0; /* try exclusive */
+        rc = Dev32Help_SetIRQ(ahci_intr, ai->irq, p, ai->irq);
+      }
+      if (rc)
+      {
+        dprintf(0,"failed to register interrupt %d\n", ai->irq);
+        return(-1);
+      }
+      irq_used[irq_used_cnt++] = ai->irq;
+      ai->int_set = 1;
+      RmUpdateAddIrq(rm_drvh, ai->rm_adh, ai->irq, ai->irq_pin, p?RS_IRQ_SHARED:RS_IRQ_EXCLUSIVE);
+    }
+  }
+
+  /* enable AHCI mode */
+  if ((rc = ahci_enable_ahci(ai)) != 0) return(rc);
+
+  /* Start all ports. The main purpose is to set the command list and FIS
+   * receive area addresses properly and to enable port-level interrupts; we
+   * don't really care about the return status because we'll find out soon
+   * enough if a previously detected device has problems.
+   */
+  for (p = 0; p <= ai->port_max; p++)
+  {
+    if (ai->port_map & (1UL << p))
+    {
+      if (init_reset)
+      {
+        DPRINTF(3,"ahci_complete_init: resetting port %d\n", p);
+        ahci_reset_port(ai, p, 1);
+      }
+      else
+      {
+        DPRINTF(3,"ahci_complete_init: restarting port #%d\n", p);
+        ahci_stop_port(ai, p);
+        ahci_start_port(ai, p, 1);
+      }
+    }
+  }
+
+  /* clear pending interrupt status */
+  writel(ai->mmio + HOST_IRQ_STAT, readl(ai->mmio + HOST_IRQ_STAT));
+  readl(ai->mmio + HOST_IRQ_STAT); /* flush */
+
+  /* enable adapter-level interrupts */
+  writel(ai->mmio + HOST_CTL, readl(ai->mmio + HOST_CTL) | HOST_IRQ_EN);
+  readl(ai->mmio + HOST_CTL); /* flush */
+
+  /* enable interrupts on PCI-level (PCI 2.3 added a feature to disable INTs) */
+  /* pci_enable_int(ai->bus, ai->dev_func); */
+
+  DPRINTF(1,"ahci_complete_init: done\n");
+  return(0);
+}
+
+static int IsUsableDisk(AD_INFO *ai, int p, int d)
+{
+  union {
+    u8 b[512];
+    u16 w[256];
+    u32 l[128];
+  } *pSector0;
+  int iRetVal;
+
+  if (!use_mbr_test) return 1;
+  if (ai->ports[p].devs[d].removable) return 1;
+
+  do
+  {
+    iRetVal = 0;
+    pSector0 = MemAlloc(512);
+    if (!pSector0) break;
+
+    if (ahci_exec_polled_cmd(ai, p, 0, 500, ATA_CMD_READ,
+         AP_SECTOR_28, 0,
+         AP_COUNT, 1,
+         AP_VADDR, (void *)pSector0, 512,
+         AP_DEVICE, 0x40,
+         AP_END)) break;
+
+    DHEXDUMP(5, pSector0, 512, "Sector0:\n");
+
+    /* check for wiped disk */
+    if ((pSector0->l[0] == 0) && (pSector0->l[127] == 0))
+    {
+      iRetVal = 1;
+      break;
+    }
+
+    /* check for a valid MBR */
+    if (pSector0->w[255] != 0xaa55) break; /* Not valid if no MBR signature */
+    if (pSector0->b[0x1c2] == 0xee) break; /* Not valid if guard partition */
+    if (pSector0->b[0x1d2] == 0xee) break; /* Not valid if guard partition */
+    if (pSector0->b[0x1e2] == 0xee) break; /* Not valid if guard partition */
+    if (pSector0->b[0x1f2] == 0xee) break; /* Not valid if guard partition */
+    iRetVal = 1;
+  } while (0);
+
+  if (pSector0) MemFree(pSector0);
+  return iRetVal;
+}
+
+/******************************************************************************
+ * Set up device attached to the specified port based on ATA_IDENTFY_DEVICE or
+ * ATA_IDENTFY_PACKET_DEVICE data.
+ *
+ * NOTE: Port multipliers are not supported, yet, thus the device number is
+ *       expected to be 0 for the time being.
+ */
+static void ahci_setup_device(AD_INFO *ai, int p, int d, u16 *id_buf)
+{
+  DEVICESTRUCT ds;
+  ADJUNCT adj;
+  HDEVICE dh;
+  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;
+  if (d >= AHCI_MAX_DEVS) return;
+
+  if (ai->port_max < p) ai->port_max = p;
+  if (ai->ports[p].dev_max < d) ai->ports[p].dev_max = d;
+  memset(ai->ports[p].devs + d, 0x00, sizeof(*ai->ports[p].devs));
+
+  /* set generic device information (assuming an ATA disk device for now) */
+  ai->ports[p].devs[d].present   = 1;
+  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;
+  strlcpy(pDevName, ata_dev_name(id_buf), sizeof(ai->ports[0].devs[0].dev_name));
+
+  if (id_buf[ATA_ID_CONFIG] & 0x8000U)
+  {
+    /* this is an ATAPI device; augment device information */
+    ai->ports[p].devs[d].atapi     = 1;
+    ai->ports[p].devs[d].atapi_16  = (id_buf[ATA_ID_CONFIG] & 0x0001U) != 0;
+    ai->ports[p].devs[d].dev_type  = (id_buf[ATA_ID_CONFIG] & 0x1f00U) >> 8;
+    ai->ports[p].devs[d].ncq_max   = 1;
+
+  }
+  else
+  {
+    /* complete ATA-specific device information */
+    if (enable_ncq[ad_no(ai)][p])
+    {
+      ai->ports[p].devs[d].ncq_max = id_buf[ATA_ID_QUEUE_DEPTH] & 0x001fU;
+    }
+    if (ai->ports[p].devs[d].ncq_max < 1)
+    {
+      /* NCQ not enabled for this device, or device doesn't support NCQ */
+      ai->ports[p].devs[d].ncq_max = 1;
+    }
+    if (id_buf[ATA_ID_CFS_ENABLE_2] & 0x0400U)
+    {
+      ai->ports[p].devs[d].lba48   = 1;
+    }
+  }
+
+  DPRINTF(2,"found device %d.%d.%d: removable=%d dev_type=%d atapi=%d ncq_max=%d\n",
+          ad_no(ai), p, d,
+          ai->ports[p].devs[d].removable,
+          ai->ports[p].devs[d].dev_type,
+          ai->ports[p].devs[d].atapi,
+          ai->ports[p].devs[d].ncq_max);
+
+  /* add device to resource manager; we don't really care about errors here */
+  memset(&ds, 0x00, sizeof(ds));
+  memset(&adj, 0x00, sizeof(adj));
+
+  adj.pNextAdj            = NULL;
+  adj.AdjLength           = sizeof(adj);
+  adj.AdjType             = ADJ_ADD_UNIT;
+  adj.Add_Unit.ADDHandle  = rm_drvh;
+  adj.Add_Unit.UnitHandle = (USHORT)total_dev_cnt;
+
+  /* create Resource Manager device key string;
+   * we distinguish only HDs and CD drives for now
+   */
+  if (ai->ports[p].devs[d].removable)
+  {
+    snprintf(dev_name, sizeof(dev_name), RM_CD_PREFIX "%s", p, d, pDevName);
+  }
+  else
+  {
+    snprintf(dev_name, sizeof(dev_name), RM_HD_PREFIX "%s", p, d, pDevName);
+  }
+
+  ds.DevDescriptName = dev_name;
+  ds.DevFlags        = (ai->ports[p].devs[d].removable) ? DS_REMOVEABLE_MEDIA
+                                                        : DS_FIXED_LOGICALNAME;
+  ds.DevType         = ai->ports[p].devs[d].dev_type;
+  ds.pAdjunctList    = &adj;
+
+  RMCreateDevice(rm_drvh, &dh, &ds, ai->rm_adh, NULL);
+
+  total_dev_cnt++;
+
+  /* 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(pDevName, "VBOX HARDDISK", 13))
+  {
+    /* running inside virtualbox */
+    pci_hack_virtualbox();
+  }
+}
+
+/******************************************************************************
  * Scan all ports for connected devices and fill in the corresponding device
  * information.
@@ -546,4 +786,6 @@
  *    the corresponding adapter's busy flag set. It will aquire the spinlock
  *    temporarily to allocate/free memory for the ATA identify buffer.
+ *
+ * Called from iocm_device_table()
  */
 int ahci_scan_ports(AD_INFO *ai)
@@ -564,5 +806,5 @@
 
   /* perform port scan */
-  DPRINTF(1,"ahci_scan_ports: scanning ports on adapter %d\n", ad_no(ai));
+  DPRINTF(1,__func__": scanning ports on adapter %d\n", ad_no(ai));
   for (p = 0; p < AHCI_MAX_PORTS; p++)
   {
@@ -572,5 +814,5 @@
     // DAZ allocate port structure here
 
-    DPRINTF(3,"ahci_scan_ports: Wait till not busy on port %d\n", p);
+    DPRINTF(3,__func__": Wait till not busy on port %d\n", p);
     /* wait until all active commands have completed on this port */
     TimerInit(&Timer, 250);
@@ -592,5 +834,5 @@
     else
     {
-      DPRINTF(3,"ahci_scan_ports: (re)starting port %d\n", p);
+      DPRINTF(3,__func__": (re)starting port %d\n", p);
       ahci_stop_port(ai, p);
       rc = ahci_start_port(ai, p, 0);
@@ -600,5 +842,5 @@
     {
       /* this port seems to have a device attached and ready for commands */
-      DPRINTF(1,"ahci_scan_ports: port %d seems to be attached to a device; probing...\n", p);
+      DPRINTF(1,__func__": port %d seems to be attached to a device; probing...\n", p);
 
       #ifdef DAZ_NEW_CODE
@@ -633,4 +875,5 @@
       DHEXDUMP(5,id_buf, ATA_ID_WORDS * sizeof(u16), "ATA_IDENTIFY%s results:\n", (is_ata) ? "" : "_PACKET");
       ahci_setup_device(ai, p, 0, id_buf);
+      if (!IsUsableDisk(ai, p, 0)) ai->ports[p].devs[0].ignored = 1;
     }
     else
@@ -653,98 +896,4 @@
   }
   MemFree(id_buf);
-  return(0);
-}
-
-/******************************************************************************
- * Complete initialization of adapter. This includes restarting all active
- * ports and initializing interrupt processing. This is called when receiving
- * the IOCM_COMPLETE_INIT request.
- */
-int ahci_complete_init(AD_INFO *ai)
-{
-  int rc;
-  u32 p;
-  int i;
-
-  DPRINTF(1,"ahci_complete_init: completing initialization of adapter #%d\n", ad_no(ai));
-
-  if (!ai->int_set)
-  {
-    /* register IRQ handler; each IRQ level is registered only once */
-    p = 1; /* int count */
-    if (!(ai->flags & AHCI_HFLAG_NO_MSI))
-    {
-      if (PsdMsiAlloc(ai->bus_dev_func, &p, &ai->irq)) p = 1; /* shared flag */
-      else
-      {
-        /* we have an msi interrupt */
-        ai->irq_pin = 0;
-        p = 0; /* exclusive flag */
-      }
-    }
-    for (i = 0; i < irq_used_cnt; i++)
-    {
-      if (irq_used[i] == ai->irq) break; /* we already have this IRQ registered */
-    }
-    if (i >= irq_used_cnt)
-    {
-      if (i >= MAX_IRQ_HANDLERS) return -1; /* no more handlers available */
-      DPRINTF(2,"registering interrupt #%d\n", ai->irq);
-
-      rc = Dev32Help_SetIRQ(ahci_intr, ai->irq, p, ai->irq);
-      if (rc && p) /* if failed and was shared */
-      {
-        p = 0; /* try exclusive */
-        rc = Dev32Help_SetIRQ(ahci_intr, ai->irq, p, ai->irq);
-      }
-      if (rc)
-      {
-        dprintf(0,"failed to register interrupt %d\n", ai->irq);
-        return(-1);
-      }
-      irq_used[irq_used_cnt++] = ai->irq;
-      ai->int_set = 1;
-      RmUpdateAddIrq(rm_drvh, ai->rm_adh, ai->irq, ai->irq_pin, p?RS_IRQ_SHARED:RS_IRQ_EXCLUSIVE);
-    }
-  }
-
-  /* enable AHCI mode */
-  if ((rc = ahci_enable_ahci(ai)) != 0) return(rc);
-
-  /* Start all ports. The main purpose is to set the command list and FIS
-   * receive area addresses properly and to enable port-level interrupts; we
-   * don't really care about the return status because we'll find out soon
-   * enough if a previously detected device has problems.
-   */
-  for (p = 0; p <= ai->port_max; p++)
-  {
-    if (ai->port_map & (1UL << p))
-    {
-      if (init_reset)
-      {
-        DPRINTF(3,"ahci_complete_init: resetting port %d\n", p);
-        ahci_reset_port(ai, p, 1);
-      }
-      else
-      {
-        DPRINTF(3,"ahci_complete_init: restarting port #%d\n", p);
-        ahci_stop_port(ai, p);
-        ahci_start_port(ai, p, 1);
-      }
-    }
-  }
-
-  /* clear pending interrupt status */
-  writel(ai->mmio + HOST_IRQ_STAT, readl(ai->mmio + HOST_IRQ_STAT));
-  readl(ai->mmio + HOST_IRQ_STAT); /* flush */
-
-  /* enable adapter-level interrupts */
-  writel(ai->mmio + HOST_CTL, readl(ai->mmio + HOST_CTL) | HOST_IRQ_EN);
-  readl(ai->mmio + HOST_CTL); /* flush */
-
-  /* enable interrupts on PCI-level (PCI 2.3 added a feature to disable INTs) */
-  /* pci_enable_int(ai->bus, ai->dev_func); */
-
-  DPRINTF(1,"ahci_complete_init: done\n");
   return(0);
 }
@@ -1768,107 +1917,2 @@
 }
 
-/******************************************************************************
- * Set up device attached to the specified port based on ATA_IDENTFY_DEVICE or
- * ATA_IDENTFY_PACKET_DEVICE data.
- *
- * NOTE: Port multipliers are not supported, yet, thus the device number is
- *       expected to be 0 for the time being.
- */
-static void ahci_setup_device(AD_INFO *ai, int p, int d, u16 *id_buf)
-{
-  DEVICESTRUCT ds;
-  ADJUNCT adj;
-  HDEVICE dh;
-  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;
-  if (d >= AHCI_MAX_DEVS) return;
-
-  if (ai->port_max < p) ai->port_max = p;
-  if (ai->ports[p].dev_max < d) ai->ports[p].dev_max = d;
-  memset(ai->ports[p].devs + d, 0x00, sizeof(*ai->ports[p].devs));
-
-  /* set generic device information (assuming an ATA disk device for now) */
-  ai->ports[p].devs[d].present   = 1;
-  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;
-  strlcpy(pDevName, ata_dev_name(id_buf), sizeof(ai->ports[0].devs[0].dev_name));
-
-  if (id_buf[ATA_ID_CONFIG] & 0x8000U)
-  {
-    /* this is an ATAPI device; augment device information */
-    ai->ports[p].devs[d].atapi     = 1;
-    ai->ports[p].devs[d].atapi_16  = (id_buf[ATA_ID_CONFIG] & 0x0001U) != 0;
-    ai->ports[p].devs[d].dev_type  = (id_buf[ATA_ID_CONFIG] & 0x1f00U) >> 8;
-    ai->ports[p].devs[d].ncq_max   = 1;
-
-  }
-  else
-  {
-    /* complete ATA-specific device information */
-    if (enable_ncq[ad_no(ai)][p])
-    {
-      ai->ports[p].devs[d].ncq_max = id_buf[ATA_ID_QUEUE_DEPTH] & 0x001fU;
-    }
-    if (ai->ports[p].devs[d].ncq_max < 1)
-    {
-      /* NCQ not enabled for this device, or device doesn't support NCQ */
-      ai->ports[p].devs[d].ncq_max = 1;
-    }
-    if (id_buf[ATA_ID_CFS_ENABLE_2] & 0x0400U)
-    {
-      ai->ports[p].devs[d].lba48   = 1;
-    }
-  }
-
-  DPRINTF(2,"found device %d.%d.%d: removable=%d dev_type=%d atapi=%d ncq_max=%d\n",
-          ad_no(ai), p, d,
-          ai->ports[p].devs[d].removable,
-          ai->ports[p].devs[d].dev_type,
-          ai->ports[p].devs[d].atapi,
-          ai->ports[p].devs[d].ncq_max);
-
-  /* add device to resource manager; we don't really care about errors here */
-  memset(&ds, 0x00, sizeof(ds));
-  memset(&adj, 0x00, sizeof(adj));
-
-  adj.pNextAdj            = NULL;
-  adj.AdjLength           = sizeof(adj);
-  adj.AdjType             = ADJ_ADD_UNIT;
-  adj.Add_Unit.ADDHandle  = rm_drvh;
-  adj.Add_Unit.UnitHandle = (USHORT)total_dev_cnt;
-
-  /* create Resource Manager device key string;
-   * we distinguish only HDs and CD drives for now
-   */
-  if (ai->ports[p].devs[d].removable)
-  {
-    snprintf(dev_name, sizeof(dev_name), RM_CD_PREFIX "%s", p, d, pDevName);
-  }
-  else
-  {
-    snprintf(dev_name, sizeof(dev_name), RM_HD_PREFIX "%s", p, d, pDevName);
-  }
-
-  ds.DevDescriptName = dev_name;
-  ds.DevFlags        = (ai->ports[p].devs[d].removable) ? DS_REMOVEABLE_MEDIA
-                                                        : DS_FIXED_LOGICALNAME;
-  ds.DevType         = ai->ports[p].devs[d].dev_type;
-  ds.pAdjunctList    = &adj;
-
-  RMCreateDevice(rm_drvh, &dh, &ds, ai->rm_adh, NULL);
-
-  total_dev_cnt++;
-
-  /* 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(pDevName, "VBOX HARDDISK", 13))
-  {
-    /* running inside virtualbox */
-    pci_hack_virtualbox();
-  }
-}
-
Index: trunk/src/os2ahci/apm.c
===================================================================
--- trunk/src/os2ahci/apm.c	(revision 196)
+++ trunk/src/os2ahci/apm.c	(revision 198)
@@ -122,6 +122,8 @@
 
       /* flush cache on all attached devices */
-      for (d = 0; d <= ai->ports[p].dev_max; d++) {
-        if (ai->ports[p].devs[d].present) {
+      for (d = 0; d <= ai->ports[p].dev_max; d++)
+      {
+        if (ai->ports[p].devs[d].present && !ai->ports[p].devs[d].ignored)
+        {
           ahci_flush_cache(ai, p, d);
         }
@@ -250,5 +252,5 @@
       for (d = 0; d <= ai->ports[p].dev_max; d++)
       {
-        if (ai->ports[p].devs[d].present)
+        if (ai->ports[p].devs[d].present && !ai->ports[p].devs[d].ignored)
         {
           ahci_flush_cache(ai, p, d);
Index: trunk/src/os2ahci/ata.c
===================================================================
--- trunk/src/os2ahci/ata.c	(revision 196)
+++ trunk/src/os2ahci/ata.c	(revision 198)
@@ -546,6 +546,7 @@
   DHEXDUMP(5,pDLA, sizeof(DLA_Table_Sector), "DLA sector %d:\n", sector-1);
 
-  if ((pDLA->DLA_Signature1 == DLA_TABLE_SIGNATURE1) && (pDLA->DLA_Signature2 == DLA_TABLE_SIGNATURE2)) {
-    DPRINTF(3,"is_lvm_geometry found at sector %d\n", sector-1);
+  if ((pDLA->DLA_Signature1 == DLA_TABLE_SIGNATURE1) && (pDLA->DLA_Signature2 == DLA_TABLE_SIGNATURE2))
+  {
+    DPRINTF(3,__func__": DLA found at sector %d\n", sector-1);
     geometry->TotalCylinders = pDLA->Cylinders;
     geometry->NumHeads = pDLA->Heads_Per_Cylinder;
@@ -571,21 +572,18 @@
   if (init_complete) return 0; /* We cannot use ahci_exec_polled_cmd() after init_complete */
 
-  if (use_lvm_info)
-  {
-    #ifdef DEBUG
-    AD_INFO *ai = ad_infos + iorb_unit_adapter(pIorb);
-    int p = iorb_unit_port(pIorb);
-    int d = iorb_unit_device(pIorb);
-    DPRINTF(3,"is_lvm_geometry (%d.%d.%d)\n", ad_no(ai), p, d);
-    #endif
-
-    /* First check the sector reported by the hardware */
-    if (check_lvm(pIorb, geometry->SectorsPerTrack)) return 1;
-
-    for (sector = 255; sector >= 63; sector >>= 1)
-    {
-      if (sector == geometry->SectorsPerTrack) continue;
-      if (check_lvm(pIorb, sector)) return 1;
-    }
+  #ifdef DEBUG
+  AD_INFO *ai = ad_infos + iorb_unit_adapter(pIorb);
+  int p = iorb_unit_port(pIorb);
+  int d = iorb_unit_device(pIorb);
+  DPRINTF(3,__func__" (%d.%d.%d)\n", ad_no(ai), p, d);
+  #endif
+
+  /* First check the sector reported by the hardware */
+  if (check_lvm(pIorb, geometry->SectorsPerTrack)) return 1;
+
+  for (sector = 255; sector >= 63; sector >>= 1)
+  {
+    if (sector == geometry->SectorsPerTrack) continue;
+    if (check_lvm(pIorb, sector)) return 1;
   }
 
@@ -632,4 +630,8 @@
    * difference. Maybe there's something in later DDKs that allows more than
    * 32 bits?
+   *
+   * Warning: Do not change the algorithm for calculating disk geometry without
+   * fully understaing the consequences. Side effects of even slight changes
+   * can be unexpected and catastrophic.
    */
   memset(geometry, 0x00, geometry_len);
Index: trunk/src/os2ahci/ioctl.c
===================================================================
--- trunk/src/os2ahci/ioctl.c	(revision 196)
+++ trunk/src/os2ahci/ioctl.c	(revision 198)
@@ -98,5 +98,5 @@
       for (d = 0; d <= pi->dev_max; d++)
       {
-        if (pi->devs[d].present)
+        if (pi->devs[d].present && !pi->devs[d].ignored)
         {
           /* add this device to the device list */
@@ -148,6 +148,8 @@
   p = req->port;
   d = req->device;
-  if (a >= ad_info_cnt || p > ad_infos[a].port_max ||
-      d > ad_infos[a].ports[p].dev_max || !ad_infos[a].ports[p].devs[d].present)
+  if (a >= ad_info_cnt || p > ad_infos[a].port_max
+     || d > ad_infos[a].ports[p].dev_max
+     || !ad_infos[a].ports[p].devs[d].present
+     || ad_infos[a].ports[p].devs[d].ignored)
   {
     return(RPDONE | RPERR_UNIT);
@@ -545,5 +547,5 @@
       for (_d = 0; _d <= pi->dev_max; _d++)
       {
-        if (pi->devs[_d].present)
+        if (pi->devs[_d].present && !pi->devs[_d].ignored)
         {
           if (unit-- == 0)
Index: trunk/src/os2ahci/os2ahci.c
===================================================================
--- trunk/src/os2ahci/os2ahci.c	(revision 196)
+++ trunk/src/os2ahci/os2ahci.c	(revision 198)
@@ -67,5 +67,5 @@
 int force_write_cache; /* if != 0, force write cache */
 int verbosity = 0;     /* default is quiet. 1=show sign on banner, >1=show adapter info during boot */
-int use_lvm_info = 1;
+int use_mbr_test = 1;
 long com_baud = 0;
 
@@ -383,12 +383,11 @@
     }
 
-    if (ArgCmp(pszCmdLine, "Z"))
+    if (ArgCmp(pszCmdLine, "U"))
     {
       pszCmdLine++;
-      /* Specify to not use the LVM information. There is no reason why anyone would
-       * want to do this, but previous versions of this driver did not have LVM capability,
-       * so this switch is here temporarily just in case.
+      /* Specify to use the MBR test to ignore non-MBR disks.
+       * Default is on.
        */
-      use_lvm_info = !iInvertOption;
+      use_mbr_test = !iInvertOption;
       continue;
     }
@@ -1128,5 +1127,5 @@
         for (d = 0; d <= ad_info->ports[p].dev_max; d++)
         {
-          if (ad_info->ports[p].devs[d].present)
+          if (ad_info->ports[p].devs[d].present && !ad_info->ports[p].devs[d].ignored)
           {
             if (ad_info->ports[p].devs[d].atapi && emulate_scsi[dta][p])
@@ -1167,5 +1166,6 @@
           for (d = 0; d <= ad_info->ports[p].dev_max; d++)
           {
-            if (ad_info->ports[p].devs[d].present && ad_info->ports[p].devs[d].atapi && emulate_scsi[a][p])
+            if (ad_info->ports[p].devs[d].present && !ad_info->ports[p].devs[d].ignored
+                && ad_info->ports[p].devs[d].atapi && emulate_scsi[a][p])
             {
               if (add_unit_info(pIorb_conf, dta, a, p, d, scsi_id++))
Index: trunk/src/os2ahci/os2ahci.h
===================================================================
--- trunk/src/os2ahci/os2ahci.h	(revision 196)
+++ trunk/src/os2ahci/os2ahci.h	(revision 198)
@@ -262,4 +262,5 @@
     unsigned dev_type  :5;        /* device type (UIB_TYPE_* in iorb.h) */
     unsigned ncq_max   :5;        /* maximum tag number for queued commands */
+    unsigned ignored   :1;        /* if != 0, device is not MBR */
     UNITINFO *unit_info;          /* pointer to modified unit info */
     DEV_INFO dev_info;
@@ -477,5 +478,5 @@
 extern int force_write_cache; /* if != 0, force write cache */
 extern int verbosity; /* if != 0, show some info during boot */
-extern int use_lvm_info;
+extern int use_mbr_test;
 
 extern HDRIVER rm_drvh; /* resource manager driver handle */
Index: trunk/src/os2ahci/trace.c
===================================================================
--- trunk/src/os2ahci/trace.c	(revision 196)
+++ trunk/src/os2ahci/trace.c	(revision 198)
@@ -58,4 +58,5 @@
               pi->devs[d].dev_info.TotalSectors/2048, pi->devs[d].dev_info.Method);
           }
+          if (pi->devs[d].ignored) dprintf(0," Not a usable disk");
           dprintf(0,"\n");
           dprintf(0,"             Model: %s\n", pi->devs[d].dev_name);
