Index: trunk/src/include/devhelp.h
===================================================================
--- trunk/src/include/devhelp.h	(revision 148)
+++ trunk/src/include/devhelp.h	(revision 149)
@@ -1,10 +1,13 @@
-/* DEVHELP.H - DevHelp header file for Watcom-based device drivers
+/*
+ *  devhelp.h  OS/2 device help calls for DD 16-bit development.
  *
- * Markus Thielen 09/2010:
- *    some modifications for OpenWatcom/os2ahci.add
+ *                          Open Watcom Project
  *
- * TODO: the Watcom build is broken - the resulting ADD does not work.
+ * Copyright (c) 2004-2007 The Open Watcom Contributors. All Rights Reserved.
  *
-*/
+ * This file was copied from the updated DDK.
+ *
+ * =========================================================================
+ */
 
 #ifndef DEVHELP_INCLUDED
@@ -26,10 +29,21 @@
 
 typedef struct _PAGELIST {
-  ULONG    PhysAddr;
-  ULONG    Size;
+    ULONG    PhysAddr;
+    ULONG    Size;
 } PAGELIST, __near *NPPAGELIST, __far *PPAGELIST;
 
+typedef ULONG HSpinLock;
+
+// Device_Help: dev help offset from INIT
 extern PFN Device_Help;
 
+// 11 Jun 07 SHL change from far ptr to dword ptr
+// MKG - Due to Lars Erdmann comment:
+// Explanation: "CALL DWORD PTR" calls a far routine indirectly through the
+// function pointer saved in the address passed to the call (which is
+// correct since the devhelps use a function pointer) while "CALL FAR PTR"
+// calls a far routine directly, that is, the address passed to the call is
+// the far routine address (which is wrong for the devhelp calls).
+
 #define DEVHELP_CALL \
    "call dword ptr [Device_Help]" \
@@ -39,4 +53,7 @@
    value [ax]
 
+/* This service starts an ABIOS function for the Operating System Transfer
+ * Convention.
+ */
 USHORT DevHelp_ABIOSCall(USHORT Lid, NPBYTE ReqBlk, USHORT Entry_Type);
 #pragma aux DevHelp_ABIOSCall = \
@@ -46,4 +63,7 @@
    modify exact [ax dl];
 
+/* This service starts an ABIOS common entry point according to the Advanced
+ * BIOS Transfer Convention.
+ */
 USHORT DevHelp_ABIOSCommonEntry(NPBYTE ReqBlk, USHORT Entry_Type);
 #pragma aux DevHelp_ABIOSCommonEntry = \
@@ -52,4 +72,12 @@
    parm caller [si] [dh] \
    modify exact [ax dl];
+
+USHORT DevHelp_AcquireSpinLock(HSpinLock spl);
+#pragma aux DevHelp_AcquireSpinLock = \
+   "mov  ax,dx" \
+   "mov  dl,71h" \
+   DEVHELP_CALL \
+   parm caller nomemory [dx bx] \
+   modify nomemory exact [ax bx cx dx si di];
 
 USHORT DevHelp_AllocateCtxHook(NPFN HookHandler, PULONG HookHandle);
@@ -157,4 +185,12 @@
    modify nomemory exact [ax dl];
 
+USHORT DevHelp_CreateSpinLock(HSpinLock FAR * pSpl);
+#pragma aux DevHelp_CreateSpinLock = \
+   "mov  ax,dx" \
+   "mov  dl,79h" \
+   DEVHELP_CALL \
+   parm caller [dx bx] \
+   modify exact [ax bx cx dx si di];
+
 USHORT DevHelp_DeRegister(USHORT MonitorPID, USHORT MonitorHandle, PUSHORT MonitorsLeft);
 #pragma aux DevHelp_DeRegister = \
@@ -226,4 +262,12 @@
    parm caller nomemory [ax] \
    modify nomemory exact [ax dl];
+
+USHORT DevHelp_FreeSpinLock(HSpinLock spl);
+#pragma aux DevHelp_FreeSpinLock = \
+   "mov  ax,dx" \
+   "mov  dl,7ah" \
+   DEVHELP_CALL \
+   parm caller nomemory [dx bx] \
+   modify nomemory exact [ax bx cx dx si di];
 
 USHORT DevHelp_FreePhys(ULONG PhysAddr);
@@ -295,4 +339,5 @@
 #define DHGETDOSV_YIELDFLAG             7                            /*@V76282*/
 #define DHGETDOSV_TCYIELDFLAG           8                            /*@V76282*/
+#define DHGETDOSV_DOSTABLES             9  // Undocumented by IBM, gets the dostables.
 #define DHGETDOSV_DOSCODEPAGE           11                           /*@V76282*/
 #define DHGETDOSV_INTERRUPTLEV          13
@@ -331,5 +376,5 @@
    "pop  es" \
    "mov  dl,2Bh" \
-   "jmp far ptr es:[Device_Help]" \
+   "jmp dword ptr es:[Device_Help]" \
    parm [es si] [di] \
    modify nomemory exact [];
@@ -532,6 +577,6 @@
 #define WAIT_IS_NOT_INTERRUPTABLE  1
 
-#define WAIT_INTERRUPTED           0x8003
-#define WAIT_TIMED_OUT             0x8001
+#define WAIT_INTERRUPTED           0x2
+#define WAIT_TIMED_OUT             0x1
 
 USHORT DevHelp_ProcBlock(ULONG EventId, ULONG WaitTime, USHORT IntWaitFlag);
@@ -541,7 +586,10 @@
    "xchg cx,di" \
    "call dword ptr [Device_Help]" \
-   "jc   error" \
-   "mov  ax,0"       /* doesn't affect zero flag like sub ax,ax does */ \
-   "error:" \
+   "setnz al"                  \
+   "setc bl"                   \
+   "inc al"                    \
+   "neg bl"                    \
+   "and al,bl"                 \
+   "xor ah,ah"                 \
    value [ax] \
    parm caller nomemory [ax bx] [di cx] [dh] \
@@ -733,5 +781,13 @@
    modify exact [ax bx cx di dl es];
 
-USHORT DevHlp_ResetEventSem(ULONG hEvent, PULONG pNumPosts);
+USHORT DevHelp_ReleaseSpinLock(HSpinLock spl);
+#pragma aux DevHelp_ReleaseSpinLock = \
+   "mov  ax,dx" \
+   "mov  dl,72h" \
+   DEVHELP_CALL \
+   parm caller nomemory [dx bx] \
+   modify nomemory exact [ax bx cx dx si di];
+
+USHORT DevHelp_ResetEventSem(ULONG hEvent, LIN pNumPosts);
 #pragma aux DevHelp_ResetEventSem = \
    "mov  eax,[esp]" \
@@ -919,5 +975,4 @@
 USHORT DevHelp_VirtToPhys(PVOID SelOffset, PULONG PhysAddr);
 #pragma aux DevHelp_VirtToPhys = \
-   ";int 3" \
    "push ds" \
    "mov  dl,16h" \
@@ -1025,5 +1080,5 @@
 
 USHORT DevHelp_VMProcessToGlobal(ULONG Flags, LIN LinearAddr, ULONG Length, PLIN GlobalLinearAddr);
-#pragma aux DevHelp_ProcessToGlobal = \
+#pragma aux DevHelp_VMProcessToGlobal = \
    "mov  dl,59h" \
    "mov  eax,[esp]" \
@@ -1086,4 +1141,5 @@
 #endif
 
-#endif
-#endif
+#endif // end __WATCOMC__
+#endif // end DEVHELP_INCLUDED
+
