Index: trunk/src/os2ahci/README
===================================================================
--- trunk/src/os2ahci/README	(revision 126)
+++ trunk/src/os2ahci/README	(revision 128)
@@ -57,4 +57,8 @@
  - ALP Assembler (part of DDK)
  - link.exe (part of DDK)
+
+Please note that builds other than the official binary delivered as
+part of eComStation releases or downloaded from ecomstation.nl are
+not officially supported by Mensys.
 
 
@@ -101,7 +105,10 @@
 /t                     Perform thorough PCI ID scan; default = on, can be
                        turned off with /!t to perform only a PCI class scan
+/f                     Force the use of the HW write cache when using NCQ
+                       commands; see "Native Command Queuing" below for
+                       further explanation
 /r                     Reset ports during initialization (default = off
                        unless the [Intel] AHCI controller was found to be
-                       initialized by the BIOS to SATA mode)
+                       initialized by the BIOS in SATA mode)
 /a                     Set adapter for adapter-specific options
                        (default = -1, all adapters)
@@ -173,4 +180,31 @@
 option "/n" to OS2AHCI.ADD.
 
+NCQ and HW Caches
+-----------------
+
+In NCQ mode, OS2AHCI supports a request flag which allows upstream code
+(e.g. file systems) to force writes to go directly to the disk instead
+of being buffered in the HW disk cache. However, at least JFS doesn't
+support this flag properly which effectively disables the HW disk cache
+for write operations across the board, resulting in a substantial
+performance loss. In order to prevent OS2AHCI from disabling the HW
+cache when so requested by upstream code, please use the command line
+option "/f".
+
+This may, of course, result in data loss in case of power failures but
+apparently this was the situation with previous IDE drivers as well thus
+shouldn't make much difference in the field. The JFS code also seems to
+imply that this flag has never been widely supported by [IDE] drivers;
+otherwise, the JFS developers should have stumbled over the performance
+loss a long time ago and fixed the code.
+
+NOTES:
+
+ - Without NCQ, OS2AHCI behaves like former IDE drivers, i.e. the HW
+   cache will always be enabled (on modern disks).
+
+ - When suspending, rebooting or shutting down, OS2AHCI always flushes
+   the HW disk cache regardless of the "/f" or "/n" command line options.
+
 
 Interoperability With IDE Drivers
@@ -278,2 +312,40 @@
 always done via DMA.
 
+
+SMART Support
+=============
+
+Starting with version 1.22, OS2AHCI supports the IOCTL interface required by
+existing SMART monitoring tools. Since those tools are hard-coded to open
+the character device named "IBMS506$", OS2AHCI will now register a device
+with this name, too.
+
+NOTES:
+
+ - If multiple drivers exporting this character device name are loaded at
+   the same time, the driver loaded last will receive all [SMART] requests.
+   This means that if both DANIS506 and OS2AHCI are loaded and SMART support
+   for OS2AHCI-controlled hard disks is desired, OS2AHCI will have to be
+   loaded after DANIS506. It also means that DANIS506 may have to be told
+   to ignore type 2 controllers (i.e. controllers supporting both SATA and
+   AHCI) using the command line options "/A:x /I".
+ 
+ - The IOCTL interface for SMART is based on the idea of IDE controllers
+   with a master and a slave drive. OS2AHCI maps all devices (ATA or ATAPI)
+   sequentially to this pattern. If, for example, you have 4 hard disks and
+   one CDROM attached to a single controller on ports 1, 2, 5, 7, and 11,
+   SMART tools will see 3 controllers as follows:
+
+    - controller 0, master: HD on port 1
+    - controller 0, slave:  HD on port 2
+    - controller 1, master: HD on port 5
+    - controller 1, slave:  HD on port 7
+    - controller 2, master: CDROM on port 11
+
+ - The DSKSP_GEN_GET_COUNTERS interface is currently unsupported; calls to
+   the corresponding IOCTL will return 0 for all counters. SMART counters
+   are not affected by this limitation, i.e. SMART tools will be able to
+   report counters from the physical disk; this limitation only affects
+   the software counters maintained by ADD drivers which do support the
+   DSKSP_GEN_GET_COUNTERS IOCTL request.
+
Index: trunk/src/os2ahci/init.asm
===================================================================
--- trunk/src/os2ahci/init.asm	(revision 126)
+++ trunk/src/os2ahci/init.asm	(revision 128)
@@ -28,11 +28,20 @@
 
 DEVHDR          SEGMENT WORD PUBLIC 'DATA'
-_dev_hdr        dd      -1                      ; no headers after this one
+_dev_hdr        dd      _legacy_hdr             ; next device header
                 dw      DEVLEV_3 + DEV_CHAR_DEV ; flags for ADD drivers
-                dw      _asm_strat              ; strategy routine
+                dw      OFFSET _asm_strat       ; strategy routine
                 dw      0                       ; no IDC routine
                 db      "OS2AHCI$"              ; name of character device
                 dq      0                       ; 8 reserved bytes
                 dd      DEV_IOCTL2 + DEV_ADAPTER_DD + DEV_INITCOMPLETE + 20h ; ADD flags
+                dw      0
+
+_legacy_hdr     dd      -1                      ; no headers after this one
+                dw      DEVLEV_3 + DEV_CHAR_DEV ; flags for ADD drivers
+                dw      OFFSET _asm_strat       ; strategy routine
+                dw      0                       ; no IDC routine
+                db      "IBMS506$"              ; name of character device
+                dq      0                       ; 8 reserved bytes
+                dd      0
                 dw      0
 DEVHDR          ENDS
Index: trunk/src/os2ahci/ioctl.c
===================================================================
--- trunk/src/os2ahci/ioctl.c	(revision 126)
+++ trunk/src/os2ahci/ioctl.c	(revision 128)
@@ -462,7 +462,4 @@
   UCHAR parm;
 
-  /* this is not sufficiently tested so far */
-  return(STDON | STATUS_ERR_UNKCMD);
-
   /* verify addressability of parm buffer (DSKSP_CommandParameters) */
   if (DevHelp_VerifyAccess((SEL) ((ULONG) cp >> 16),
Index: trunk/src/os2ahci/os2ahci.c
===================================================================
--- trunk/src/os2ahci/os2ahci.c	(revision 126)
+++ trunk/src/os2ahci/os2ahci.c	(revision 128)
@@ -161,4 +161,6 @@
 USHORT init_drv(RPINITIN _far *req)
 {
+  static int init_drv_called;
+  static int init_drv_failed;
   RPINITOUT _far *rsp = (RPINITOUT _far *) req;
   DDD_PARM_LIST _far *ddd_pl = (DDD_PARM_LIST _far *) req->InitArgs;
@@ -172,4 +174,15 @@
   u16 vendor;
   u16 device;
+
+  if (init_drv_called) {
+    /* This is the init call for the second (legacy IBMS506$) character
+     * device driver. If the main driver failed initialization, fail this
+     * one as well.
+     */
+    rsp->CodeEnd = (u16) end_of_code;
+    rsp->DataEnd = (u16) &end_of_data;
+    return(STDON | ((init_drv_failed) ? ERROR_I24_QUIET_INIT_FAIL : 0));
+  }
+  init_drv_called = 1;
 
   /* set device helper entry point */
@@ -375,4 +388,5 @@
   rsp->CodeEnd = 0;
   rsp->DataEnd = 0;
+  init_drv_failed = 1;
 
   /* free context hooks */
Index: trunk/src/os2ahci/version.h
===================================================================
--- trunk/src/os2ahci/version.h	(revision 126)
+++ trunk/src/os2ahci/version.h	(revision 128)
@@ -14,4 +14,4 @@
 
 
-#define VERSION            121       /* driver version (2 implied decimals) */
+#define VERSION            122       /* driver version (2 implied decimals) */
 
