Index: /trunk/src/ioctltest/Makefile
===================================================================
--- /trunk/src/ioctltest/Makefile	(revision 177)
+++ /trunk/src/ioctltest/Makefile	(revision 177)
@@ -0,0 +1,75 @@
+###############################################################################
+# Makefile - makefile for os2ahci test program, gcc tool chain
+#
+# Copyright (c) 2010 Christian Mueller, Markus Thielen.
+#
+#  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
+#
+
+###############################################################################
+# Tool Chain
+#
+
+CC         = gcc
+LD         = gcc
+
+CFLAGS     = -c
+LFLAGS     =
+
+###############################################################################
+# Environment
+
+CC_INCLUDE   =
+
+AS_INCLUDE   =
+
+LIB_DIRS     =
+
+
+###############################################################################
+# Main dependencies
+
+TARGET   = ioctl_test.exe
+
+LIBS     = -los2
+
+SRCS     = ioctl_test.c
+
+OBJS     = ioctl_test.o
+
+INCS     =
+
+
+all: $(TARGET)
+
+clean:
+	rm -f $(OBJS) $(TARGET)
+
+
+###############################################################################
+# Object/source dependencies
+
+ioctl_test.o: ioctl_test.c Makefile
+
+###############################################################################
+# Action definitions (compile/link commands)
+
+.c.o:
+	$(CC) $(CFLAGS) $(CC_INCLUDE) $*.c
+
+$(TARGET): $(OBJS) Makefile
+	$(LD) -o $(TARGET) $(OBJS) $(LIB_DIRS) $(LIBS)
+
+
Index: /trunk/src/ioctltest/ioctl_test.c
===================================================================
--- /trunk/src/ioctltest/ioctl_test.c	(revision 177)
+++ /trunk/src/ioctltest/ioctl_test.c	(revision 177)
@@ -0,0 +1,188 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <memory.h>
+
+#define INCL_DOS
+#include <os2.h>
+#include "../ioctl.h"
+
+void phex(const void *p, int len);
+
+int main(int arhc, char *argv[])
+{
+  OS2AHCI_DEVLIST *dl;
+  OS2AHCI_PASSTHROUGH pt;
+  APIRET rc;
+  HFILE fh;
+  ULONG at;
+  ULONG cnt;
+  ULONG plen;
+  ULONG dlen;
+  char sense_buf[64];
+  char id_buf[512];
+  int i;
+  int n;
+
+  /* open OS2AHCI character device driver */
+  rc = DosOpen("\\DEV\\OS2AHCI$", &fh, &at, 0, FILE_SYSTEM,
+               OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE |
+               OPEN_FLAGS_NOINHERIT | OPEN_ACCESS_READONLY, NULL);
+
+  if (rc != 0) {
+    printf("couldn't open OS2AHCI$; rc = %ld\n", rc);
+    return(1);
+  }
+
+  /* get device information */
+  cnt = 20;
+  plen = sizeof(cnt);
+  dlen = offsetof(OS2AHCI_DEVLIST, devs) + cnt * sizeof(dl->devs);
+  dl = malloc(dlen);
+  rc = DosDevIOCtl(fh, OS2AHCI_IOCTL_CATEGORY, OS2AHCI_IOCTL_GET_DEVLIST,
+                   &cnt, plen, &plen, dl, dlen, &dlen);
+
+  if (rc != 0) {
+    printf("couldn't get device list; rc = %ld\n", rc);
+    return(1);
+  }
+
+  for (i = 0; i < dl->cnt; i++) {
+    printf("connection: %d.%d.%d, type: %d, ncq_max: %d, flags: 0x%04x\n",
+           dl->devs[i].adapter, dl->devs[i].port, dl->devs[i].device,
+           dl->devs[i].type, dl->devs[i].ncq_max, dl->devs[i].flags);
+  }
+
+  printf("\n");
+
+  /* get ATA ID buffer for each device */
+  for (i = 0; i < dl->cnt; i++) {
+    memset(&pt, 0x00, sizeof(pt));
+    memset(sense_buf, 0x00, sizeof(sense_buf));
+    pt.adapter   = dl->devs[i].adapter;
+    pt.port      = dl->devs[i].port;
+    pt.device    = dl->devs[i].device;
+    pt.flags     = 0;
+    pt.timeout   = 0;
+
+    pt.cmdlen    = sizeof(pt.cmd.ata);
+    pt.cmd.ata.cmd = (dl->devs[i].flags & DF_ATAPI) ? 0xa1 : 0xec;
+
+    pt.buflen    = sizeof(id_buf);
+    pt.buf       = id_buf;
+    pt.sense_len = sizeof(sense_buf);
+
+    plen = sizeof(pt);
+    dlen = sizeof(sense_buf);
+    rc = DosDevIOCtl(fh, OS2AHCI_IOCTL_CATEGORY, OS2AHCI_IOCTL_PASSTHROUGH,
+                     &pt, plen, &plen, sense_buf, dlen, &dlen);
+
+    if (rc == 0) {
+      printf("ID for %d.%d.%d: ", dl->devs[i].adapter, dl->devs[i].port,
+             dl->devs[i].device);
+      for (n = 54; n < 94; n += 2) {
+        printf("%c%c", id_buf[n+1], id_buf[n]);
+      }
+      printf("\n");
+
+    } else {
+      printf("\nID command failed (rc = %ld); sense code:\n", rc);
+      phex(sense_buf, sizeof(sense_buf));
+    }
+
+    if (dl->devs[i].type == 5) {
+      /* Test sense buffer handling by ejecting the drive tray, then
+       * checking whether the unit is ready.
+       */
+      printf("ejecting drive tray\n");
+      memset(&pt, 0x00, sizeof(pt));
+      memset(sense_buf, 0x00, sizeof(sense_buf));
+      pt.adapter    = dl->devs[i].adapter;
+      pt.port       = dl->devs[i].port;
+      pt.device     = dl->devs[i].device;
+      pt.flags      = PT_ATAPI;
+      pt.timeout    = 0;
+
+      pt.cmdlen     = 6;
+      pt.cmd.cdb[0] = 0x1b;
+      pt.cmd.cdb[4] = 0x02;
+
+      pt.buflen     = 0;
+      pt.buf        = NULL;
+      pt.sense_len  = sizeof(sense_buf);
+
+      plen = sizeof(pt);
+      dlen = sizeof(sense_buf);
+      rc = DosDevIOCtl(fh, OS2AHCI_IOCTL_CATEGORY, OS2AHCI_IOCTL_PASSTHROUGH,
+                       &pt, plen, &plen, sense_buf, dlen, &dlen);
+
+      if (rc != 0) {
+        printf("\neject command failed (rc = %ld); sense code:\n", rc);
+        phex(sense_buf, sizeof(sense_buf));
+        break;
+      }
+
+      printf("test unit ready\n");
+      memset(&pt, 0x00, sizeof(pt));
+      memset(sense_buf, 0x00, sizeof(sense_buf));
+      pt.adapter    = dl->devs[i].adapter;
+      pt.port       = dl->devs[i].port;
+      pt.device     = dl->devs[i].device;
+      pt.flags      = PT_ATAPI;
+      pt.timeout    = 0;
+
+      pt.cmdlen     = 6;
+      pt.cmd.cdb[0] = 0x00;
+
+      pt.buflen     = 0;
+      pt.buf        = NULL;
+      pt.sense_len  = sizeof(sense_buf);
+
+      plen = sizeof(pt);
+      dlen = sizeof(sense_buf);
+      rc = DosDevIOCtl(fh, OS2AHCI_IOCTL_CATEGORY, OS2AHCI_IOCTL_PASSTHROUGH,
+                       &pt, plen, &plen, sense_buf, dlen, &dlen);
+
+      if (rc != 0) {
+        printf("\ntest unit ready command failed as expected (rc = %ld); sense code:\n", rc);
+        phex(sense_buf, sizeof(sense_buf));
+        break;
+      }
+    }
+  }
+
+  return(0);
+}
+
+void phex(const void *p, int len)
+{
+  const unsigned char *buf = p;
+  long pos = 0;
+  int i;
+
+  /* print hex block */
+  while (len > 0) {
+    printf("%08X ", pos);
+
+    /* print hex block */
+    for (i = 0; i < 16; i++) {
+      if (i < len) {
+        printf("%c%02x", ((i == 8) ? '-' : ' '), buf[i]);
+      } else {
+        printf("   ");
+      }
+    }
+
+    /* print ASCII block */
+    printf("   ");
+    for (i = 0; i < ((len > 16) ? 16 : len); i++) {
+      printf("%c", (buf[i] >= 32 && buf[i] < 128) ? buf[i] : '.');
+    }
+    printf("\n");
+
+    pos += 16;
+    buf += 16;
+    len -= 16;
+  }
+}
+
Index: unk/src/os2ahci/Makefile.old
===================================================================
--- /trunk/src/os2ahci/Makefile.old	(revision 176)
+++ 	(revision )
@@ -1,148 +1,0 @@
-###############################################################################
-# Makefile.old - makefile for os2ahci driver, c600 tool chain
-# NOTICE: This makefile is depreciated and is not guaranteed to work anymore.
-#
-# Copyright (c) 2011 thi.guten Software Development
-# Copyright (c) 2011 Mensys B.V.
-#
-# Authors: Christian Mueller, Markus Thielen
-#
-#  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
-#
-
-###############################################################################
-# Tool Chain
-#
-
-AS         = $(DDK)\tools\alp.exe
-CC         = $(DDK)\base\tools\cl.exe
-LD         = $(DDK)\base\tools\link.exe
-MAPSYM     = $(DDK)\base\tools\mapsym.exe
-ADDTOFILE  = ..\..\tools\AddToFile.cmd
-
-AFLAGS     = -Mb
-# In order to build the SMP safe version you must have the updated DDK and define OS2AHCI_SMP
-CFLAGS     = -c -nologo -Asnw -W2 -G2ms -Zlpd -Fc -Zi #-DOS2AHCI_SMP
-LFLAGS     = /noe /nod /packd /a:16 /batch /map /line
-
-###############################################################################
-# Environment
-
-# main path to OS/2 DDK; this needs to be set before this makefile will work
-!ifndef DDK
-!error DDK must be set in the environment.
-!endif
-
-!ifndef VENDOR
-VENDOR=Mensys BV
-!endif
-
-BLD_MAJOR=1
-BLD_MINOR=26 # must be 2 digits
-BLD_REV=0 # not used at this time
-
-CC_INCLUDE   = -I..\include \
-               -I$(DDK)\base\h \
-               -I$(DDK)\base\ibmh \
-               -I$(DDK)\base\src\dev\dasd\diskh \
-               -I$(DDK)\base\src\dev\thinkpad\dockii\apmcalls
-
-AS_INCLUDE   = -I:$(DDK)\base\inc \
-               -I:$(DDK)\base\src\dev\dasd\diskinc
-
-LIB_DIRS     = $(DDK)\base\lib\ \
-               $(DDK)\base\src\dev\dasd\devhlp\ \
-               $(DDK)\base\src\dev\thinkpad\dockii\apmcalls\ \
-
-###############################################################################
-# Main dependencies
-
-TARGET   = os2ahci.add
-
-LIBS     = addcalls dhcalls doscalls slibcep rmcalls apmcalls
-
-SRCS     = init.asm libc.c os2ahci.c pci.c ahci.c ata.c atapi.c ctxhook.c \
-           apm.c ioctl.c trace.c
-
-OBJS     = init.obj libc.obj os2ahci.obj pci.obj ahci.obj ata.obj atapi.obj \
-           ctxhook.obj apm.obj ioctl.obj trace.obj
-
-INCS     = os2ahci.h ahci.h version.h ioctl.h ..\include\ahci-idc.h
-
-
-all: $(TARGET)
-
-clean:
-    rm -f $(OBJS) $(TARGET) *.cod *.lst *.def *.map *.sym *.err *.lnk version.h
-
-###############################################################################
-# Object/source dependencies
-
-init.obj:     init.asm   Makefile.old
-
-libc.obj:     libc.c     Makefile.old $(INCS)
-
-os2ahci.obj:  os2ahci.c  Makefile.old $(INCS) version.h ioctl.h
-
-pci.obj:      pci.c      Makefile.old $(INCS)
-
-ahci.obj:     ahci.c     Makefile.old $(INCS) ata.h atapi.h
-
-ata.obj:      ata.c      Makefile.old $(INCS) ata.h
-
-atapi.obj:    atapi.c    Makefile.old $(INCS) ata.h atapi.h
-
-ctxhook.obj:  ctxhook.c  Makefile.old $(INCS) ata.h atapi.h
-
-apm.obj:      apm.c      Makefile.old $(INCS)
-
-ioctl.obj:    ioctl.c    Makefile.old $(INCS) ata.h atapi.h ioctl.h
-
-trace.obj:    trace.c    Makefile.old $(INCS)
-
-###############################################################################
-# Action definitions (compile/link commands)
-
-# emacs TAGS file creation
-# NOTE: OS/2 emacs etags.exe expects an empty file named c:\dev\null...
-tags:   $(SRCS) $(INCS) Makefile.old
-    etags.exe $(SRCS) $(INCS) $(DDK)\base\src\dev\dasd\diskh\dhcalls.h \
-    $(DDK)\base\src\dev\dasd\diskh\iorb.h \
-    $(DDK)\base\h\bsedos16.h \
-    $(DDK)\base\h\devcmd.h \
-    $(DDK)\base\h\reqpkt.h
-
-version.h: Makefile.old
-    @echo /* Autogenerated by Makefile.old */ >version.h
-    @echo #define VERSION $(BLD_MAJOR)$(BLD_MINOR) /* driver version (2 implied decimals) */ >>version.h
-    @$(ADDTOFILE) version.h,#define BLD_YEAR,DATEYEAR
-    @$(ADDTOFILE) version.h,#define BLD_MONTH,DATEMONTH
-    @$(ADDTOFILE) version.h,#define BLD_DAY,DATEDAY
-
-.asm.obj:
-    $(AS) $(AFLAGS) $(AS_INCLUDE) $*.asm
-#    wdis -l $*.obj
-
-.c.obj:
-    $(CC) $(CFLAGS) $(CC_INCLUDE) $*.c
-#    wdis -l $*.obj
-
-os2ahci.def: os2ahci.def.template Makefile.old
-    copy os2ahci.def.template os2ahci.def
-	@$(ADDTOFILE) os2ahci.def,Description,BLDLEVEL,$(VENDOR),$(BLD_MAJOR).$(BLD_MINOR),AHCI Driver (c) Mensys BV 2013
-
-$(TARGET): $(OBJS) os2ahci.def Makefile.old
-    $(LD) $(LFLAGS) $(OBJS),$(TARGET),$*.map,$(LIB_DIRS) $(LIBS),$*.def
-    $(MAPSYM) os2ahci
Index: /trunk/src/os2ahci/README
===================================================================
--- /trunk/src/os2ahci/README	(revision 176)
+++ /trunk/src/os2ahci/README	(revision 177)
@@ -243,6 +243,6 @@
       DANIS506.ADD 1.8.8 or later is required for this to work.
 
-      When using earlier versions of DANI1S506.ADD, the options "/A:x /I"
-      will be required to tell DANI1S506.ADD to ignore adapters to be
+      When using earlier versions of DANIS506.ADD, the options "/A:x /I"
+      will be required to tell DANIS506.ADD to ignore adapters to be
       driven by OS2AHCI.ADD. The same applies to IBM1S506.ADD
 
@@ -255,5 +255,5 @@
 
  1. Drive HDD and CDROM via DANIS506.ADD
- 2. Drive HDD via OS2AHCI.ADD and CDROM via DANI1S506.ADD
+ 2. Drive HDD via OS2AHCI.ADD and CDROM via DANIS506.ADD
 
 OS2AHCI.ADD can't drive the CDROM because it's attached to a legacy PATA
@@ -289,5 +289,5 @@
 The big advantage of AHCI controllers, apart from being vendor-neutral,
 is that they take care of a lot of things which previous-generation
-drivers like DANI1S506 would have to do step by step. For example, in
+drivers like DANIS506 would have to do step by step. For example, in
 order to send an ATAPI command, DANIS506 would have to do the following:
 
Index: unk/tag.cmd
===================================================================
--- /trunk/tag.cmd	(revision 176)
+++ 	(revision )
@@ -1,21 +1,0 @@
-@echo off
-setlocal
-SET TRUNK_URL=https://svn.ecomstation.nl/repos/ahci/trunk
-SET TAGS_URL=https://svn.ecomstation.nl/repos/ahci/tags 
-
-if %1empty == empty goto usage
-
-echo tagging %1...
-svn copy %TRUNK_URL% %TAGS_URL%/%1 -m "tagging %1"
-goto end
-
-:usage
-echo.
-echo %0 - create tag in OS2AHCI subversion repository.
-echo.
-echo Usage: %0 [tag]
-echo where [tag] usually is the release version number (e.g. 1.01)"
-
-
-:end
-endlocal
