Index: /trunk/src/os2ahci/ata.c
===================================================================
--- /trunk/src/os2ahci/ata.c	(revision 38)
+++ /trunk/src/os2ahci/ata.c	(revision 39)
@@ -2,6 +2,7 @@
  * ata.c - ATA command processing
  *
- * Copyright (c) 2010 Christian Mueller. Parts copied from/inspired by the
- * Linux AHCI driver; those parts are (c) Linux AHCI/ATA maintainers
+ * Copyright (c) 2010 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
@@ -462,5 +463,5 @@
 
   /* extract total number of sectors */
-  if (id_buf[ATA_ID_CFS_ENABLE_2] & 0x40) {
+  if (id_buf[ATA_ID_CFS_ENABLE_2] & 0x400) {
     /* 48-bit LBA supported */
     if (ATA_CAPACITY48_H(id_buf) != 0) {
@@ -483,5 +484,5 @@
       CUR_CAPACITY(id_buf) == CUR_HEADS(id_buf) *
                               CUR_CYLS(id_buf) *
-			      CUR_SECTORS(id_buf)) {
+															CUR_SECTORS(id_buf)) {
     /* use BIOS-supplied values for geometry */
     geometry->NumHeads        = CUR_HEADS(id_buf);
@@ -496,6 +497,12 @@
     geometry->TotalCylinders  = ATA_CYLS(id_buf);
 
-  } else {
-    /* construct values based on typical [SCSI] BIOS algorithms */
+  } 
+  
+  /* MT: if neither ATA nor BIOS supply valid data, or if their
+   * 	 CHS values result in a sector count lower than determined,
+   *     we use a typical [SCSI] BIOS algorithm 
+   */
+  if ((u32) geometry->NumHeads * (u32) geometry->SectorsPerTrack *
+	  (u32) geometry->TotalCylinders < geometry->TotalSectors) {
     geometry->NumHeads        = 255;
     geometry->SectorsPerTrack = 63;
Index: /trunk/src/os2ahci/ata.h
===================================================================
--- /trunk/src/os2ahci/ata.h	(revision 38)
+++ /trunk/src/os2ahci/ata.h	(revision 39)
@@ -25,7 +25,7 @@
  * Macros to access geometry values in the ATA ID buffer
  */
-#define ATA_CYLS(id_buf)            *((u32 *) (id_buf + ATA_ID_CYLS))
-#define ATA_HEADS(id_buf)           *((u32 *) (id_buf + ATA_ID_HEADS))
-#define ATA_SECTORS(id_buf)         *((u32 *) (id_buf + ATA_ID_SECTORS))
+#define ATA_CYLS(id_buf)            *((u16 *) (id_buf + ATA_ID_CYLS))
+#define ATA_HEADS(id_buf)           *((u16 *) (id_buf + ATA_ID_HEADS))
+#define ATA_SECTORS(id_buf)         *((u16 *) (id_buf + ATA_ID_SECTORS))
 #define ATA_CAPACITY(id_buf)        *((u32 *) (id_buf + ATA_ID_LBA_CAPACITY))
 
@@ -33,7 +33,7 @@
 #define ATA_CAPACITY48_H(id_buf)    *((u32 *) (id_buf + ATA_ID_LBA_CAPACITY_2 + 2))
 
-#define CUR_CYLS(id_buf)            *((u32 *) (id_buf + ATA_ID_CUR_CYLS))
-#define CUR_HEADS(id_buf)           *((u32 *) (id_buf + ATA_ID_CUR_HEADS))
-#define CUR_SECTORS(id_buf)         *((u32 *) (id_buf + ATA_ID_CUR_SECTORS))
+#define CUR_CYLS(id_buf)            *((u16 *) (id_buf + ATA_ID_CUR_CYLS))
+#define CUR_HEADS(id_buf)           *((u16 *) (id_buf + ATA_ID_CUR_HEADS))
+#define CUR_SECTORS(id_buf)         *((u16 *) (id_buf + ATA_ID_CUR_SECTORS))
 #define CUR_CAPACITY(id_buf)        *((u32 *) (id_buf + ATA_ID_CUR_CAPACITY))
 
Index: /trunk/src/os2ahci/atapi.c
===================================================================
--- /trunk/src/os2ahci/atapi.c	(revision 38)
+++ /trunk/src/os2ahci/atapi.c	(revision 39)
@@ -2,6 +2,7 @@
  * atapi.c - ATAPI command processing
  *
- * Copyright (c) 2010 Christian Mueller. Parts copied from/inspired by the
- * Linux AHCI driver; those parts are (c) Linux AHCI/ATA maintainers
+ * Copyright (c) 2010 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
Index: /trunk/src/os2ahci/os2ahci.def
===================================================================
--- /trunk/src/os2ahci/os2ahci.def	(revision 38)
+++ /trunk/src/os2ahci/os2ahci.def	(revision 39)
@@ -1,4 +1,4 @@
 library os2ahci
-Description '$@#thi.guten (www.thiguten.de):1.00.20101105#@OS/2 AHCI Adapter Device Driver'
+Description '$@#thi.guten (www.thiguten.de):1.00.20101108#@OS/2 AHCI Adapter Device Driver'
 protmode
 
Index: /trunk/src/os2ahci/pci.c
===================================================================
--- /trunk/src/os2ahci/pci.c	(revision 38)
+++ /trunk/src/os2ahci/pci.c	(revision 39)
@@ -2,6 +2,7 @@
  * PCI.c - PCI constants and detection code for os2ahci driver
  *
- * Copyright (c) 2010 Christian Mueller. Parts copied from/inspired by the
- * LINUX ahci driver; those parts are (c) Linux AHCI/ATA maintainers
+ * Copyright (c) 2010 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
Index: /trunk/tools/blddate.cmd
===================================================================
--- /trunk/tools/blddate.cmd	(revision 38)
+++ /trunk/tools/blddate.cmd	(revision 39)
@@ -1,4 +1,4 @@
 /*
- * blddate.cmd - REXX script to spit out a header file containing 
+ * blddate.cmd - REXX script to spit out a header file containing
  * #defines for the current day, month and year
  *
@@ -11,7 +11,7 @@
 
 say '/* auto generated by blddate.cmd */'
-say '#define BLD_YEAR  ' SUBSTR(d, 1, 4)
-say '#define BLD_MONTH ' SUBSTR(d, 5, 2)
-say '#define BLD_DAY   ' SUBSTR(d, 7, 2)
+say '#define BLD_YEAR  ' FORMAT(SUBSTR(d, 1, 4))
+say '#define BLD_MONTH ' FORMAT(SUBSTR(d, 5, 2))
+say '#define BLD_DAY   ' FORMAT(SUBSTR(d, 7, 2))
 
 
Index: /trunk/tools/bldlvl.cmd
===================================================================
--- /trunk/tools/bldlvl.cmd	(revision 38)
+++ /trunk/tools/bldlvl.cmd	(revision 39)
@@ -266,2 +266,3 @@
     Say "    CTRL+BRK currently disabled"
     Return 0
+
