home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Include / DEVHELP.H next >
C/C++ Source or Header  |  2002-04-27  |  26KB  |  834 lines

  1. /* $Id: DEVHELP.H,v 1.2 2002/04/26 23:08:59 smilcke Exp $ */
  2.  
  3. /************************************************************************\
  4. **                                                                      **
  5. **               OS/2(r) Physical Device Driver Libraries               **
  6. **                         for Watcom C/C++ 10                          **
  7. **                                                                      **
  8. **  COPYRIGHT:                                                          **
  9. **                                                                      **
  10. **    (C) Copyright Advanced Gravis Computer Technology Ltd 1994.       **
  11. **        All Rights Reserved.                                          **
  12. **                                                                      **
  13. **  DISCLAIMER OF WARRANTIES:                                           **
  14. **                                                                      **
  15. **    The following [enclosed] code is provided to you "AS IS",         **
  16. **    without warranty of any kind.  You have a royalty-free right to   **
  17. **    use, modify, reproduce and distribute the following code (and/or  **
  18. **    any modified version) provided that you agree that Advanced       **
  19. **    Gravis has no warranty obligations and shall not be liable for    **
  20. **    any damages arising out of your use of this code, even if they    **
  21. **    have been advised of the possibility of such damages.  This       **
  22. **    Copyright statement and Disclaimer of Warranties may not be       **
  23. **    removed.                                                          **
  24. **                                                                      **
  25. \************************************************************************/
  26.  
  27.  
  28. // DevHelp.h
  29. //
  30. // Watcom C++ callable entry points to the OS/2 DevHlp interface.
  31. //
  32. // All of the DevHlp functions in this library are prefaced with the string
  33. // "Dev" rather than "DevHlp_" which is used by the IBM DDK libraries.  The
  34. // names were made incompatible so that calls to the IBM DevHlp routines
  35. // are not confused with calls to these routines (which may have different
  36. // calling signatures).  If you need the IBM calling signatures, just use
  37. // some inline functions which call the Dev* functions.
  38. //
  39. // Also, the ordering of words in multi-word names has been changed so that
  40. // the object of an operation is the first word, and the operation name is
  41. // the second word.  For example, "DevHlp_AllocPhys" has been renamed to
  42. // "DevPhysAlloc".
  43. //
  44. // This DevHlp library does not include certain categories of DevHlps that
  45. // are available in the IBM DDK.  In particular, ABIOS specific functions
  46. // (function codes 29h and 34h to 37h), monitors (function codes 31h to
  47. // 35h), and some virtual memory functions (function codes 55h to 5Ah and
  48. // 66h) are not (yet) supported.  Also, functions which are no longer
  49. // meaningful under OS/2 2.1, such as UnPhysToVirt and SetRomVector are not
  50. // included either.  However, some undocumented or only partially
  51. // documented DevHlps such as the RAS tracing facility (DevSysTrace,
  52. // function code 28h) are included in this library.
  53. //
  54. // History:
  55. //
  56. // Sep 30, 94  David Bollo    Initial version
  57.  
  58. // Prevent multiple inclusion
  59. #if !defined(DevHelp_h)
  60. #define DevHelp_h 1
  61.  
  62. #if !defined(__WATCOMC__) || !defined(__cplusplus)
  63. #error Watcom C++ must be used for the inline DevHlp interface.
  64. #endif
  65.  
  66.  
  67. #include "devtype.h"
  68. #include <stacktoflat.h>
  69.  
  70.  
  71. // Calling conventions for device driver functions
  72. //
  73. //
  74.  
  75. // Strategy call calling convention
  76. #pragma aux STRATEGY parm [fs ebx];
  77.  
  78. #pragma aux VDD __far loadds parm [ax] modify [bx cx dx si di];
  79.  
  80. // Dynamic API calling convention
  81. #pragma aux DYNAMIC __far loadds parm [si] value [ax];
  82.  
  83. // Interface to the OS/2 Ring 0 Device Helper functions
  84. //
  85. //
  86.  
  87. extern void DevHelp();
  88. #pragma aux DevHelp "DevHlp"
  89.  
  90. extern void DevHelp_ModifiedDS();
  91. #pragma aux DevHelp_ModifiedDS "DevHlp_ModifiedDS"
  92.  
  93. VOID DevCli                   // Disable interrupts
  94.   (
  95.   );                          // Returns: Nothing
  96.  
  97. #pragma aux DevCli =          \
  98.   "cli";
  99.  
  100. VOID DevSti                   // Enable interrupts
  101.   (
  102.   );                          // Returns: Nothing
  103.  
  104. #pragma aux DevSti =          \
  105.   "sti";
  106.  
  107. VOID DevPushfCli(DWORD *cpuflags);
  108. #pragma aux DevPushfCli =       \
  109.   "pushfd"                         \
  110.   "cli"                \
  111.   "pop edx"            \
  112.   "mov dword ptr [eax], edx"    \
  113.   modify [edx]            \
  114.   parm [eax];
  115.  
  116. VOID DevPopf(DWORD cpuflags);
  117. #pragma aux DevPopf =             \
  118.   "push eax"            \
  119.   "popfd"            \
  120.    parm [eax];
  121.  
  122. WORD16 DevBlock               // Block the current thread
  123.   (
  124.   WORD32 Id,                  // Id to be used by DevRun call
  125.   WORD32 WaitMilliSec,        // Milliseconds to wait for (-1 = forever)
  126.   BYTE InterruptableFlag      // 0 if block is interruptable, else 1
  127.   );                          // Returns: 0 = Ran, 1 = Timeout, 2 = Ctrl+C
  128.  
  129. #pragma aux DevBlock =        \
  130.   "mov bx, ax"                \
  131.   "shr eax,16"                \
  132.   "mov cx, di"                \
  133.   "shr edi,16"                \
  134.   "mov dl,04h"                \
  135.   "call DevHelp"              \
  136.   "setnz al"                  \
  137.   "setc bl"                   \
  138.   "inc al"                    \
  139.   "neg bl"                    \
  140.   "and al,bl"                 \
  141.   "xor ah,ah"                 \
  142.   modify [edx ebx ecx]        \
  143.   parm [eax] [edi] [dh]       \
  144.   value [ax];
  145.  
  146.  
  147.  
  148. WORD16 DevRun                 // Run a blocked thread
  149.   (
  150.   WORD32 Id                   // Id used in DevBlock call
  151.   );                          // Returns: Count of awakened threads
  152.  
  153. #pragma aux DevRun =          \
  154.   "mov bx, ax"                \
  155.   "shr eax, 16"               \
  156.   "mov dl,05h"                \
  157.   "call DevHelp"              \
  158.   modify [edx ebx]            \
  159.   parm [eax]                  \
  160.   value [ax];
  161.  
  162. WORD16 DevSegLock             // Lock a segment down in memory
  163.   (
  164.   SEL Selector,               // Selector of memory to lock down
  165.   WORD16 Type,                // Type (0 = short, 1 = long, 3 = long & hi,
  166.                               //       4 = short & verify)
  167.   WORD16 NoWaitFlag,          // 0 to wait for lock or 1 to return immediately
  168.   HLOCK *Handle               // Storage for segment lock handle
  169.   );                          // Returns: 0 = success, 1 = error
  170.  
  171. #pragma aux DevSegLock =      \
  172.   "push edx"                  \
  173.   "mov bh,cl"                 \
  174.   "mov dl,13h"                \
  175.   "call DevHelp"              \
  176.   "setc cl"                   \
  177.   "xor ch,ch"                 \
  178.   "pop edx"                   \
  179.   "mov [edx],bx"              \
  180.   "mov [edx+2],ax"            \
  181.   parm [ax] [cx] [bx] [edx]   \
  182.   modify [eax ebx]            \
  183.   value [cx];
  184.  
  185.  
  186.  
  187. WORD16 DevSegUnlock           // Unlock a segment locked by DevSegLock
  188.   (
  189.   HLOCK Handle                // Handle of locked segment
  190.   );                          // Returns: 0 = success, other = error code
  191.  
  192. #pragma aux DevSegUnlock =    \
  193.   "mov  bx, ax"               \
  194.   "shr eax,16"                \
  195.   "mov dl,14h"                \
  196.   "call DevHelp"              \
  197.   "setc dl"                   \
  198.   "xor dh,dh"                 \
  199.   "neg dx"                    \
  200.   "and ax,dx"                 \
  201.   modify [edx ebx]            \
  202.   parm [eax]                  \
  203.   value [ax];
  204.  
  205. #define VMDHL_NOBLOCK           0x0001 // Bit 0
  206. #define VMDHL_CONTIGUOUS        0x0002 // Bit 1
  207. #define VMDHL_16M               0x0004 // Bit 2
  208. #define VMDHL_WRITE             0x0008 // Bit 3
  209. #define VMDHL_LONG              0x0010 // Bit 4
  210. #define VMDHL_VERIFY            0x0020 // Bit 5
  211.  
  212. int DevVMLock
  213. (
  214.         unsigned long flags,
  215.         unsigned long lin,
  216.         unsigned long length,
  217.         LINEAR        pPageList,
  218.         LINEAR        pLockHandle,
  219.         LINEAR          pPageListCount
  220. );                          // Returns: 0 = success, 1 = error
  221.  
  222. #pragma aux DevVMLock =       \
  223.   "push edx"                  \
  224.   "mov  dl,55h"               \
  225.   "call DevHelp"            \
  226.   "setc dl"              \
  227.   "pop  ebx"                  \
  228.   "mov  dword ptr [ebx], eax" \
  229.   "xor  eax, eax"             \
  230.   "mov  al, dl"               \
  231.   parm [eax] [ebx] [ecx] [edi] [esi] [edx] \
  232.   modify [edx ebx] \
  233.   value [eax];
  234.  
  235. #define VMDHA_16M               0x0001 // Bit 0
  236. #define VMDHA_FIXED             0x0002 // Bit 1
  237. #define VMDHA_SWAP              0x0004 // Bit 2
  238. #define VMDHA_CONTIG            0x0008 // Bit 3
  239. #define VMDHA_PHYS              0x0010 // Bit 4
  240. #define VMDHA_PROCESS           0x0020 // Bit 5
  241. #define VMDHA_SGSCONT           0x0040 // Bit 6
  242. #define VMDHA_VIRTUAL           0x0080 // Bit 7
  243. #define VMDHA_GETSEL            0x0080 // Bit 7 (Alias)
  244. #define VMDHA_RESERVE           0x0100 // Bit 8
  245. #define VMDHA_USEHIGHMEM        0x0800 // Bit 11
  246.  
  247. int DevVMAlloc(ULONG flags, ULONG size, LINEAR physaddr, LINEAR addr);
  248. #pragma aux DevVMAlloc = \
  249.   "mov  dl,57h" \
  250.   "call DevHelp"             \
  251.   "setc dl"               \
  252.   "mov  dword ptr [esi], eax"  \
  253.   "xor  eax, eax"              \
  254.   "mov  al, dl"                \
  255.   parm [eax] [ecx] [edi] [esi] \
  256.   modify [edx] \
  257.   value [eax];
  258.  
  259. ULONG DevVMFree(LINEAR LinearAddr);
  260. #pragma aux DevVMFree = \
  261.   "mov  dl,58h" \
  262.   "call DevHelp"             \
  263.   "setc dl"               \
  264.   "xor  eax, eax"              \
  265.   "mov  al, dl"                \
  266.   parm [eax] \
  267.   modify [edx] \
  268.   value [eax];
  269.  
  270. #define VMDHGP_WRITE            0x0001
  271. #define VMDHGP_SELMAP           0x0002
  272. #define VMDHGP_SGSCONTROL       0x0004
  273. #define VMDHGP_4MEG             0x0008
  274.  
  275. ULONG DevVMGlobalToProcess(ULONG Flags, LINEAR LinearAddr, ULONG Length,
  276.                LINEAR ProcessLinearAddr);
  277. #pragma aux DevVMGlobalToProcess = \
  278.   "mov  dl,5Ah" \
  279.   "call DevHelp"             \
  280.   "setc dl"               \
  281.   "mov  dword ptr [edi], eax"  \
  282.   "xor  eax, eax"              \
  283.   "mov  al, dl"                \
  284.   parm [eax] [ebx] [ecx] [edi]\
  285.   modify [edx] \
  286.   value [eax];
  287.  
  288. #define VMDHPG_READONLY         0x0000
  289. #define VMDHPG_WRITE            0x0001
  290.  
  291. ULONG DevVMProcessToGlobal(ULONG Flags, LINEAR LinearAddr, ULONG Length,
  292.                LINEAR GlobalLinearAddr);
  293. #pragma aux DevVMProcessToGlobal = \
  294.   "mov  dl,59h"                \
  295.   "call DevHelp"             \
  296.   "setc dl"               \
  297.   "mov  dword ptr [edi], eax"  \
  298.   "xor  eax, eax"              \
  299.   "mov  al, dl"                \
  300.   parm [eax] [ebx] [ecx] [edi] \
  301.   modify [edx]                 \
  302.   value [eax];
  303.  
  304. #define VMDHS_DECOMMIT          0x0001
  305. #define VMDHS_RESIDENT          0x0002
  306. #define VMDHS_SWAP              0x0004
  307.  
  308. ULONG DevVMSetMem(ULONG Flags, LINEAR LinearAddr, ULONG Size);
  309. #pragma aux DevHelp_VMSetMem = \
  310.   "mov  dl,66h"                \
  311.   "call DevHelp"             \
  312.   parm [eax] [ebx] [ecx]       \
  313.   modify [edx]                 \
  314.   value [eax];
  315.  
  316. ULONG DevVMUnLock(LINEAR pLockHandle);
  317. #pragma aux DevVMUnLock = \
  318.   "mov  dl,56h"      \
  319.   "call DevHelp"     \
  320.   "setc dl"         \
  321.   "xor  eax, eax"    \
  322.   "mov  al, dl"      \
  323.   parm [esi]         \
  324.   modify [edx]       \
  325.   value [eax];
  326.     
  327.  
  328. WORD16 DevPhysToVirt          // Convert a physical address to a 16:16 address
  329.   (
  330.   PHYSICAL PhysAddr,          // Physical address to convert
  331.   WORD16 Length,              // Length of virtual segment
  332.   VIRTUAL FAR *VirtAddr           // Storage for virtual address
  333.   );                          // Returns: 0 = success, other = error code
  334.  
  335. #pragma aux DevPhysToVirt =   \
  336.   "xchg ax,bx"                \
  337.   "mov dx,0115h"              \
  338.   "call DevHelp"              \
  339.   "setc dl"                   \
  340.   "xor dh,dh"                 \
  341.   "neg dx"                    \
  342.   "mov fs:[esi],di"           \
  343.   "mov fs:[esi+2],es"         \
  344.   "and ax,dx"                 \
  345.   modify [dx es di]           \
  346.   parm [bx ax] [cx] [fs esi]  \
  347.   value [ax];
  348.  
  349.  
  350.  
  351. WORD16 DevVirtToPhys            // Convert a locked 16:16 address to physical
  352.   (
  353.   VIRTUAL VirtAddr,           // Virtual address to convert (must be locked)
  354.   PHYSICAL FAR *PhysAddr      // Storage for physical address
  355.   );                          // Returns: Nothing
  356.  
  357. #pragma aux DevVirtToPhys =   \
  358.   "push ecx"                  \
  359.   "push ds"              \
  360.   "mov si, ax"               \
  361.   "shr eax, 16"               \
  362.   "mov ds, ax"                \
  363.   "mov dl,16h"                \
  364.   "call DevHelp_ModifiedDS"   \
  365.   "setc dl"                   \
  366.   "xor dh,dh"                 \
  367.   "pop ds"              \
  368.   "pop ecx"                   \
  369.   "mov fs:[ecx],bx"           \
  370.   "mov fs:[ecx+2],ax"         \
  371.   "mov ax,dx"                 \
  372.   modify [edx ebx esi]        \
  373.   parm [eax] [fs ecx]         \
  374.   value [ax];
  375.  
  376.  
  377.  
  378. WORD16 DevPhysToUVirt         // Convert a physical address to an LDT address
  379.   (
  380.   PHYSICAL PhysAddr,          // Physical address to convert
  381.   WORD16 Length,              // Length of virtual segment
  382.   BYTE Type,                  // Type (0 = code, 1 = data, 2 = free, 5 = video)
  383.   BYTE Tag,                   // Tag (only with type 5)
  384.   VIRTUAL FAR *VirtAddr       // Storage for virtual address
  385.   );                          // Returns: 0 = success, 1 = error
  386.  
  387. #pragma aux DevPhysToUVirt =  \
  388.   "push es"                   \
  389.   "push edi"                  \
  390.   "mov bx,ax"                 \
  391.   "shr eax, 16"               \
  392.   "mov dl,17h"                \
  393.   "call DevHelp"              \
  394.   "setc dl"                   \
  395.   "xor dh,dh"                 \
  396.   "pop edi"                   \
  397.   "mov word ptr fs:[edi], bx"   \
  398.   "mov word ptr fs:[edi+2], es" \
  399.   "pop es"                    \
  400.   modify [ebx eax]            \
  401.   parm [eax] [cx] [dh] [si] [fs edi] \
  402.   value [dx];
  403.  
  404.  
  405.  
  406. WORD16 DevPhysAlloc           // Allocate a block of physical memory
  407.   (
  408.   WORD32 Size,                // Size of memory to allocate
  409.   BYTE LoFlag,                // Flag: 0 = above 1 MB, 1 = below 1 MB
  410.   PHYSICAL FAR *PhysAddr      // Storage for address of memory block
  411.   );                          // Returns: 0 = success, other = error code
  412.  
  413. #pragma aux DevPhysAlloc =    \
  414.   "mov bx, ax"                \
  415.   "shr eax,16"                \
  416.   "mov dl,18h"                \
  417.   "call DevHelp"              \
  418.   "setc dl"                   \
  419.   "xor dh,dh"                 \
  420.   "neg dx"                    \
  421.   "mov fs:[esi],bx"           \
  422.   "mov fs:[esi+2],ax"         \
  423.   "and ax,dx"                 \
  424.   modify [edx ebx]            \
  425.   parm [eax] [dh] [fs esi]    \
  426.   value [ax];
  427.  
  428.  
  429.  
  430. WORD16 DevPhysFree            // Free a block of physical memory
  431.   (
  432.   PHYSICAL PhysAddr           // Address of memory block to be freed
  433.   );                          // Returns: 0 = success, 1 = error
  434.  
  435. #pragma aux DevPhysFree =     \
  436.   "xchg ax,bx"                \
  437.   "mov dl,19h"                \
  438.   "call DevHelp"  \
  439.   "setc dl"                   \
  440.   "xor dh,dh"                 \
  441.   parm [bx ax]                \
  442.   value [dx];
  443.  
  444.  
  445.  
  446. WORD16 DevIRQSet              // Register an interrupt handler for an IRQ
  447.   (
  448.   WORD16 IRQ,                 // IRQ Number to handle
  449.   FUNCTION Handler,           // Handler function entry-point
  450.   BYTE SharableFlag           // Sharable: 1 = sharable, 0 = exclusive
  451.   );                          // Returns: 0 = success, other = error code
  452.  
  453. #pragma aux DevIRQSet =       \
  454.   "mov dl,1Bh"                \
  455.   "call DevHelp"  \
  456.   "setc dl"                   \
  457.   "xor dh,dh"                 \
  458.   "neg dx"                    \
  459.   "and ax,dx"                 \
  460.   modify [dl]                 \
  461.   parm [bx] [ax] [dh]         \
  462.   value [ax];
  463.  
  464.  
  465.  
  466. WORD16 DevIRQClear            // Remove a registered IRQ handler
  467.   (
  468.   WORD16 IRQ                  // IRQ Number to release
  469.   );                          // Returns: 0 = success, 1 = error
  470.  
  471. #pragma aux DevIRQClear =     \
  472.   "mov dl,1Ch"                \
  473.   "call DevHelp"  \
  474.   "setc dl"                   \
  475.   "xor dh,dh"                 \
  476.   parm [bx]                   \
  477.   value [dx];
  478.  
  479. WORD16 DevVerifyAccess        // Verify that the caller has access to memory
  480.   (
  481.   VIRTUAL Address,            // Address of memory to verify
  482.   WORD16 Length,              // Length of memory to verify
  483.   BYTE Type                   // Type of access (0 = read, 1 = read/write)
  484.   );                          // Returns: 0 = success, 1 = error
  485.  
  486. #pragma aux DevVerifyAccess = \
  487.   "mov di, ax"                \
  488.   "shr eax, 16"               \
  489.   "mov dl,27h"                \
  490.   "call DevHelp"              \
  491.   "setc dl"                   \
  492.   "xor dh,dh"                 \
  493.   modify [edx edi]            \
  494.   parm [eax] [cx] [dh]        \
  495.   value [dx];
  496.  
  497.  
  498.  
  499. #pragma pack(1)
  500. struct _IDCTABLE
  501. {
  502.  USHORT Reserved[3];
  503.  VOID (FAR *ProtIDCEntry)(VOID);
  504.  USHORT ProtIDC_DS;
  505. };
  506. typedef struct _IDCTABLE IDCTABLE;
  507. typedef struct _IDCTABLE* PIDCTABLE;
  508. #pragma pack()
  509. WORD16 DevAttachDD             // Attach to another device driver for IDC
  510. (
  511.   WORD32 DriverName,           // Device driver name (from device header)
  512.   WORD32 IDCData               // Storage for IDC data
  513. );                             // Returns: 0 = success, 1 = error
  514.  
  515. #pragma aux DevAttachDD =     \
  516.   "mov dl,2Ah"                \
  517.   "call DevHelp"              \
  518.   "setc dl"                   \
  519.   "xor dh,dh"                 \
  520.   parm [ebx] [edi]            \
  521.   value [dx];
  522.  
  523. WORD16 DevAllocGDTSel         // Allocate GDT selectors at Init time
  524.   (
  525.   WORD32 SelectorArray,       // Storage for allocated GDT selectors (16:16)
  526.   WORD16 Count                // Number of GDT selectors to allocate
  527.   );                          // Returns: 0 = success, other = error code
  528.  
  529. #pragma aux DevAllocGDTSel =  \
  530.   "push es"                   \
  531.   "mov eax, edi"          \
  532.   "shr eax, 16"               \
  533.   "mov es, ax"                \
  534.   "mov dl,2Dh"                \
  535.   "call DevHelp"              \
  536.   "setc dl"                   \
  537.   "xor dh,dh"                 \
  538.   "neg dx"                    \
  539.   "and ax,dx"                 \
  540.   "pop es"                    \
  541.   modify [edx eax]            \
  542.   parm [edi] [cx]             \
  543.   value [ax];
  544.  
  545.  
  546.  
  547.  
  548. WORD16 DevPhysToGDTSelector   // Convert a 32 bit address to a GDT selector
  549.   (
  550.   PHYSICAL Address,           // 32 bit physical address to convert
  551.   WORD16 Length,              // Length of fabricated segment
  552.   SEL Selector                // Selector to refer to 32 bit address
  553.   );                          // Returns: 0 = success, other = error code
  554.  
  555. #pragma aux DevPhysToGDTSelector = \
  556.   "mov bx, ax"                \
  557.   "shr eax,16"                \
  558.   "mov dl,2Eh"                \
  559.   "call DevHelp"              \
  560.   "setc dl"                   \
  561.   "xor dh,dh"                 \
  562.   "neg dx"                    \
  563.   "and ax,dx"                 \
  564.   modify [dx bx]              \
  565.   parm [eax] [cx] [si]        \
  566.   value [ax];
  567.  
  568.  
  569.  
  570.  
  571. VOID DevEOI                   // Signal end of interrupt processing to PIC
  572.   (
  573.   WORD16 IRQ                  // IRQ number to end
  574.   );                          // Returns: Nothing
  575.  
  576. #pragma aux DevEOI =          \
  577.   "mov dl,31h"                \
  578.   "call DevHelp"  \
  579.   modify [dl]                 \
  580.   parm [ax];
  581.  
  582.  
  583. WORD16 DevRegisterPDD           // Register driver for PDD-VDD communications
  584.   (
  585.   WORD32 Name,                // Device driver name
  586.   WORD32 EntryPoint           // Entry point for PDD-VDD communications
  587.   );                          // Returns: 0 = success, 1 = error
  588.  
  589. #pragma aux DevRegisterPDD =  \
  590.   "push ds"              \
  591.   "push es"              \
  592.   "mov si,ax"                 \
  593.   "shr eax, 16"               \
  594.   "mov ds, ax"                \
  595.   "mov di, bx"                \
  596.   "shr ebx, 16"               \
  597.   "mov es, bx"                \
  598.   "mov dl,50h"                \
  599.   "call DevHelp"              \
  600.   "setc dl"                   \
  601.   "xor dh,dh"                 \
  602.   "pop es"                    \
  603.   "pop ds"              \
  604.   modify [esi edi ebx]        \
  605.   parm [eax] [ebx]            \
  606.   value [dx];
  607.  
  608.  
  609.  
  610. WORD16 DevBeep                // Generate a beep
  611.   (
  612.   WORD16 Frequency,           // Beep pitch in hz
  613.   WORD16 Duration             // Beep duration
  614.   );                          // Returns: 0 = success, other = error code
  615.  
  616. #pragma aux DevBeep =         \
  617.   "mov dl,52h"                \
  618.   "call DevHelp"  \
  619.   "setc dl"                   \
  620.   "xor dh,dh"                 \
  621.   "neg dx"                    \
  622.   "and ax,dx"                 \
  623.   modify [dx]                 \
  624.   parm [bx] [cx]              \
  625.   value [ax];
  626.  
  627.  
  628.  
  629. WORD16 DevFreeGDTSel          // Free an allocated GDT selector at task time
  630.   (
  631.   SEL Selector                // Selector to free
  632.   );                          // Returns: 0 = success, other = error code
  633.  
  634. #pragma aux DevFreeGDTSel =   \
  635.   "mov dl,53h"                \
  636.   "call DevHelp"  \
  637.   "setc dl"                   \
  638.   "xor dh,dh"                 \
  639.   "neg dx"                    \
  640.   "and ax,dx"                 \
  641.   modify [dx]                 \
  642.   parm [ax]                   \
  643.   value [ax];
  644.  
  645.  
  646.  
  647. WORD16 DevPhysToGDTSel        // Map a physical address to a GDT selector
  648.   (
  649.   PHYSICAL Address,           // 32 bit physical address to convert
  650.   WORD32 Length,              // Length of fabricated segment
  651.   SEL Selector,               // Selector to refer to 32 bit address
  652.   BYTE Access                 // Descriptor access priviledges
  653.   );                          // Returns: 0 = success, other = error code
  654.  
  655. #pragma aux DevPhysToGDTSel = \
  656.   "and ecx,0000FFFFh"         \
  657.   "mov dl,54h"                \
  658.   "call DevHelp"              \
  659.   "setc dl"                   \
  660.   "xor dh,dh"                 \
  661.   "neg dx"                    \
  662.   "and ax,dx"                 \
  663.   parm [eax] [ecx] [si] [dh]  \
  664.   modify [ecx edx]            \
  665.   value [ax];
  666.  
  667.  
  668.  
  669. WORD16 DevVirtToLin           // Convert a virtual address to linear
  670.   (
  671.   SEL Selector,               // Selector to convert
  672.   WORD32 Offset,              // Offset to convert
  673.   LINEAR FAR *Linear              // Storage for linear address
  674.   );                          // Returns: 0 = success, other = error code
  675.  
  676. #pragma aux DevVirtToLin =    \
  677.   "mov dl,5Bh"                \
  678.   "call DevHelp"              \
  679.   "setc dl"                   \
  680.   "mov fs:[edi], eax"         \
  681.   "xor dh,dh"                 \
  682.   "neg dx"                    \
  683.   "and ax,dx"                 \
  684.   modify [edx]              \
  685.   parm [ax] [esi] [fs edi]    \
  686.   value [ax];
  687.  
  688.  
  689. ULONG DevResetEventSem(ULONG hEvent, FARPTR16 pNumPosts);
  690. #pragma aux DevResetEventSem = \
  691.   "mov  dl,6Ah"      \
  692.   "call DevHelp"     \
  693.   "setc dl"         \
  694.   "xor  eax, eax"    \
  695.   "mov  al, dl"      \
  696.   parm [eax] [edi]   \
  697.   modify [edx]       \
  698.   value [eax];
  699.  
  700. ULONG DevCloseEventSem(ULONG hEvent);
  701. #pragma aux DevCloseEventSem = \
  702.   "mov  dl,68h" \
  703.   "call DevHelp"     \
  704.   "setc dl"         \
  705.   "xor  eax, eax"    \
  706.   "mov  al, dl"      \
  707.   parm [eax]         \
  708.   modify [edx]       \
  709.   value [eax];
  710.  
  711. ULONG DevOpenEventSem(ULONG hEvent);
  712. #pragma aux DevOpenEventSem = \
  713.   "mov  dl,67h" \
  714.   "call DevHelp"     \
  715.   "setc dl"         \
  716.   "xor  eax, eax"    \
  717.   "mov  al, dl"      \
  718.   parm [eax]         \
  719.   modify [edx]       \
  720.   value [eax];
  721.  
  722. ULONG DevPostEventSem(ULONG hEvent);
  723. #pragma aux DevPostEventSem = \
  724.   "mov  dl,69h" \
  725.   "call DevHelp"     \
  726.   "setc dl"         \
  727.   "xor  eax, eax"    \
  728.   "mov  al, dl"      \
  729.   parm [eax]         \
  730.   modify [edx]       \
  731.   value [eax];
  732.  
  733. ULONG DevFreeCtxHook(ULONG HookHandle);
  734. #pragma aux DevFreeCtxHook = \
  735.   "mov  dl,64h",     \
  736.   "call DevHelp"     \
  737.   "setc dl"         \
  738.   "xor  eax, eax"    \
  739.   "mov  al, dl"      \
  740.   parm [eax]         \
  741.   modify [edx]       \
  742.   value [eax];
  743.  
  744. ULONG DevAllocateCtxHook(ULONG HookHandler, LINEAR HookHandle);
  745. #pragma aux DevAllocateCtxHook = \
  746.   "mov  ebx,-1"      \
  747.   "mov  dl,63h"      \
  748.   "call DevHelp"     \
  749.   "setc dl"         \
  750.   "mov  dword ptr [edi], eax" \
  751.   "xor  eax, eax"    \
  752.   "mov  al, dl"      \
  753.   parm [eax] [edi]   \
  754.   modify [edx ebx] \
  755.   value [eax];
  756.  
  757. ULONG DevArmCtxHook(ULONG HookData, ULONG HookHandle);
  758. #pragma aux DevArmCtxHook = \
  759.   "mov  ecx, -1"     \
  760.   "mov  dl,65h",     \
  761.   "call DevHelp"     \
  762.   "setc dl"         \
  763.   "xor  eax, eax"    \
  764.   "mov  al, dl"      \
  765.   parm [eax] [ebx]   \
  766.   modify [edx ecx] \
  767.   value [eax];
  768.  
  769. typedef struct {
  770.   DWORD physaddr;
  771.   DWORD size;
  772. } PAGELIST;
  773.  
  774. ULONG DevPageListToLin(ULONG Size, PAGELIST NEAR *pPageList, LINEAR NEAR *LinearAddr);
  775. #pragma aux DevPageListToLin = \
  776.   "mov  dl,5Fh" \
  777.   "call DevHelp"     \
  778.   "setc dl"         \
  779.   "mov  [esi], eax"  \
  780.   "xor  eax, eax"    \
  781.   "mov  al, dl"      \
  782.   parm [ecx] [edi] [esi] \
  783.   modify [edx]       \
  784.   value [eax];
  785.  
  786. ULONG DevLinToPageList(LINEAR LinearAddr, ULONG Size, PAGELIST NEAR *pPageList);
  787. #pragma aux DevLinToPageList = \
  788.   "mov  dl,5Eh" \
  789.   "call DevHelp"     \
  790.   "setc dl"         \
  791.   "xor  eax, eax"    \
  792.   "mov  al, dl"      \
  793.   parm [eax] [ecx] [edi] \
  794.   modify [edx]       \
  795.   value [eax];
  796.  
  797. ULONG DevGetDOSVar(ULONG VarNumber, ULONG VarMember, VOID NEAR *KernalVar);
  798. #pragma aux DevGetDOSVar = \
  799.   "xor  ebx, ebx" \
  800.   "mov  dl,24h" \
  801.   "call DevHelp"     \
  802.   "setc dl"         \
  803.   "mov  word ptr [edi],bx" \
  804.   "mov  word ptr [edi+2],ax" \
  805.   "xor  eax, eax"    \
  806.   "mov  al, dl"      \
  807.   value [eax] \
  808.   parm [eax] [ecx] [edi] \
  809.   modify [edx ebx];
  810.  
  811. ULONG DevSetTimer(DWORD TimerHandler);
  812. #pragma aux DevSetTimer = \
  813.   "mov  dl,1Dh" \
  814.   "call DevHelp"     \
  815.   "setc dl"         \
  816.   "xor  eax, eax"    \
  817.   "mov  al, dl"      \
  818.    value [eax] \
  819.    parm [eax] \
  820.    modify [eax edx];
  821.  
  822. ULONG DevTickCount(DWORD TimerHandler, DWORD TickCount);
  823. #pragma aux DevTickCount = \
  824.   "mov  dl,33h" \
  825.   "call DevHelp"     \
  826.   "setc dl"         \
  827.   "xor  eax, eax"    \
  828.   "mov  al, dl"      \
  829.    value [eax] \
  830.    parm [eax] [ebx] \
  831.    modify [eax edx];
  832.  
  833. #endif // DevHelp_h
  834.