Index: trunk/src/os2ahci/Makefile
===================================================================
--- trunk/src/os2ahci/Makefile	(revision 152)
+++ trunk/src/os2ahci/Makefile	(revision 153)
@@ -46,5 +46,5 @@
 VENDOR=$(%VENDOR)
 !else
-VENDOR=Mensys BV
+VENDOR=Unknown
 !endif
 
@@ -79,7 +79,7 @@
 
 %PATH=..\..\tools;$(WATCOM)\BINP;$(WATCOM)\BINW;
-AS         = wasm
-CC         = wcc
-MAPSYM     = $(DDK)\base\tools\mapsym.exe
+AS     = wasm
+CC     = wcc
+MAPSYM = $(DDK)\base\tools\mapsym.exe
 
 !ifdef __LOADDLL__
@@ -89,8 +89,7 @@
 
 AFLAGS = -q
-#CFLAGS = -ei -5 -d3 -hc -bt=os2 -ms -zu -w3 -wcd=138 -wcd=300 -ecc -zp1 -q -s -zgp -zfp -oi
 # In order to build the SMP safe version you must have the updated devhelp.h and define OS2AHCI_SMP.
-CFLAGS = -ei -5 -d0 -bt=os2 -ms -zu -w=0 -ecc -zp=1 -q -s -zgp -zfp -oi -DOS2AHCI_SMP
-CFLAGS_DEBUG = -ei -5 -d3 -hc -bt=os2 -ms -zu -ecc -zp=1 -q -s -zgp -zfp -od
+CFLAGS = -ei -6 -d0 -bt=os2 -ms -zu -wx -ecc -zp=1 -q -s -zgp -zfp -oi -DOS2AHCI_SMP
+CFLAGS_DEBUG = -ei -6 -d3 -hc -bt=os2 -ms -zu -ecc -zp=1 -q -s -zgp -zfp -od
 
 ###############################################################################
@@ -150,5 +149,5 @@
     @AddToFile $^@,$#define BLD_MONTH,DATEMONTH
     @AddToFile $^@,$#define BLD_DAY,DATEDAY
-	@AddToFile.cmd $^@,$#define BLDLEVEL,BLDLEVEL2,$(VENDOR),$(BLD_MAJOR).$(BLD_MINOR),AHCI Driver (c) Mensys BV 2013
+	@AddToFile $^@,$#define BLDLEVEL,BLDLEVEL2,$(VENDOR),$(BLD_MAJOR).$(BLD_MINOR),AHCI Driver (c) Mensys BV 2013
 
 .asm.obj: .autodepend
Index: trunk/src/os2ahci/README
===================================================================
--- trunk/src/os2ahci/README	(revision 152)
+++ trunk/src/os2ahci/README	(revision 153)
@@ -62,5 +62,5 @@
 
  - IBM OS/2 DDK version 9.23 or later (see ddk\base\h\version.mak)
-   (Used for include files and qgrep)
+   and that has been updated for SMP systems. (Used for include files)
  - Open Watcom C/C++ package
    (available from: http://www.openwatcom.org/index.php/Downloads)
Index: trunk/src/os2ahci/apm.c
===================================================================
--- trunk/src/os2ahci/apm.c	(revision 152)
+++ trunk/src/os2ahci/apm.c	(revision 153)
@@ -105,4 +105,5 @@
   int d;
 
+  if (suspended) return;
   dprintf("apm_suspend()\n");
 
@@ -140,4 +141,5 @@
   }
 
+  suspended = 1;
   dprintf("apm_suspend() finished\n");
 }
@@ -151,4 +153,5 @@
   int a;
 
+  if (!suspended) return;
   dprintf("apm_resume()\n");
 
@@ -172,4 +175,5 @@
   }
 
+  suspended = 0;
   dprintf("apm_resume() finished\n");
 }
Index: trunk/src/os2ahci/ata.c
===================================================================
--- trunk/src/os2ahci/ata.c	(revision 152)
+++ trunk/src/os2ahci/ata.c	(revision 153)
@@ -1065,5 +1065,5 @@
                  AP_END);
   }
-  
+
   return(rc);
 }
Index: trunk/src/os2ahci/init.asm
===================================================================
--- trunk/src/os2ahci/init.asm	(revision 152)
+++ trunk/src/os2ahci/init.asm	(revision 153)
@@ -40,7 +40,9 @@
                 db      "OS2AHCI$"              ; name of character device
                 dq      0                       ; 8 reserved bytes
-                dd      DEV_IOCTL2 + DEV_ADAPTER_DD + DEV_INITCOMPLETE + 20h ; ADD flags
+                dd      DEV_IOCTL2 + DEV_ADAPTER_DD + DEV_INITCOMPLETE + DEV_SAVERESTORE ; ADD flags
                 dw      0
 
+; This is here to support old SMART tools. This is a really bad thing to do as it will
+; cause problems in the future. The SMART tools should be fixed instead.
 _legacy_hdr     dd      -1                      ; no headers after this one
                 dw      DEVLEV_3 + DEV_CHAR_DEV ; flags for ADD drivers
@@ -51,4 +53,5 @@
                 dd      0
                 dw      0
+
 DEVHDR          ENDS
 
Index: trunk/src/os2ahci/libc.c
===================================================================
--- trunk/src/os2ahci/libc.c	(revision 152)
+++ trunk/src/os2ahci/libc.c	(revision 153)
@@ -375,6 +375,6 @@
   vsprintf(buf, fmt, va);
 
-  if (debug && com_base != 0) {
-    /* print the same message to COM1 as well */
+  if (debug) {
+    /* print the same message to COM1/trace as well */
     printf("%s", buf);
   }
Index: trunk/src/os2ahci/os2ahci.c
===================================================================
--- trunk/src/os2ahci/os2ahci.c	(revision 152)
+++ trunk/src/os2ahci/os2ahci.c	(revision 153)
@@ -121,4 +121,5 @@
 u16             ad_ignore;         /* bitmap with adapter indexes to ignore */
 int             init_complete;     /* if != 0, initialization has completed */
+int             suspended;
 
 /* apapter/port-specific options saved when parsing the command line */
@@ -163,4 +164,8 @@
   case CMDINPUT:
     rc = char_dev_input((RP_RWV _far *) req);
+    break;
+
+  case CMDSaveRestore:
+    rc = sr_drv(((RPSAVERESTORE _far *) req)->FuncCode);
     break;
 
@@ -203,4 +208,5 @@
   }
   init_drv_called = 1;
+  suspended = 0;
 
   /* set device helper entry point */
@@ -373,4 +379,6 @@
     trace_init();
   }
+  dprintf("BldLevel: %s\n", BldLevel);
+  dprintf("CmdLine: %Fs\n", cmd_line);
 
   /* scan PCI bus for supported devices */
@@ -518,4 +526,18 @@
 
   apm_suspend();
+  return(STDON);
+}
+
+/******************************************************************************
+ * Device driver suspend/resume handler. This handler is called when ACPI is
+ * executing a suspend or resume.
+ */
+USHORT sr_drv(int func)
+{
+  dprintf("sr_drv(%d) called\n", func);
+
+  if (func) apm_resume();
+  else apm_suspend();
+
   return(STDON);
 }
Index: trunk/src/os2ahci/os2ahci.h
===================================================================
--- trunk/src/os2ahci/os2ahci.h	(revision 152)
+++ trunk/src/os2ahci/os2ahci.h	(revision 153)
@@ -404,4 +404,5 @@
 extern USHORT  char_dev_input         (RP_RWV _far *rwrb);
 extern USHORT  exit_drv               (int func);
+extern USHORT  sr_drv                 (int func);
 extern void _cdecl _far _loadds add_entry    (IORBH _far *iorb);
 extern void    trigger_engine         (void);
@@ -557,4 +558,5 @@
 extern u16           ad_ignore;     /* bitmap with adapters to be ignored */
 extern int           init_complete; /* if != 0, initialization has completed */
+extern int           suspended;     /* indicates if the driver is suspended */
 
 extern u16           com_base;      /* debug COM port base address */
Index: trunk/src/os2ahci/pci.c
===================================================================
--- trunk/src/os2ahci/pci.c	(revision 152)
+++ trunk/src/os2ahci/pci.c	(revision 153)
@@ -610,6 +610,5 @@
 
   /* found a supported AHCI device */
-  ciiprintf("found AHCI device: %s %s (%04x:%04x)\n"
-            " class:0x%06lx bus:%d devfunc:0x%02x\n",
+  ciiprintf("found AHCI device: %s %s (%04x:%04x) class:0x%06lx bus:%d devfunc:0x%02x\n",
             vendor_from_id(vendor), device_from_id(device),
             vendor, device,
Index: trunk/src/os2ahci/trace.c
===================================================================
--- trunk/src/os2ahci/trace.c	(revision 152)
+++ trunk/src/os2ahci/trace.c	(revision 153)
@@ -169,5 +169,4 @@
 u16 trace_read(u8 _far *buf, u16 cb_buf)
 {
-  u16 cb_avail;
   u16 cb_read;
 
