DPMI.H 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. Copyright (C) 1994-1995 Apogee Software, Ltd.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /**********************************************************************
  16. module: DPMI.H
  17. author: James R. Dose
  18. date: March 31, 1994
  19. Inline functions for performing DPMI calls.
  20. (c) Copyright 1994 James R. Dose. All Rights Reserved.
  21. **********************************************************************/
  22. #ifndef __DPMI_H
  23. #define __DPMI_H
  24. enum DPMI_Errors
  25. {
  26. DPMI_Warning = -2,
  27. DPMI_Error = -1,
  28. DPMI_Ok = 0
  29. };
  30. typedef struct
  31. {
  32. unsigned long EDI;
  33. unsigned long ESI;
  34. unsigned long EBP;
  35. unsigned long Reserved;
  36. unsigned long EBX;
  37. unsigned long EDX;
  38. unsigned long ECX;
  39. unsigned long EAX;
  40. unsigned short Flags;
  41. unsigned short ES;
  42. unsigned short DS;
  43. unsigned short FS;
  44. unsigned short GS;
  45. unsigned short IP;
  46. unsigned short CS;
  47. unsigned short SP;
  48. unsigned short SS;
  49. } dpmi_regs;
  50. unsigned long DPMI_GetRealModeVector( int num );
  51. void DPMI_SetRealModeVector( int num, unsigned long vector );
  52. int DPMI_CallRealModeFunction( dpmi_regs *callregs );
  53. int DPMI_GetDOSMemory( void **ptr, int *descriptor, unsigned length );
  54. int DPMI_FreeDOSMemory( int descriptor );
  55. int DPMI_LockMemory( void *address, unsigned length );
  56. int DPMI_LockMemoryRegion( void *start, void *end );
  57. int DPMI_UnlockMemory( void *address, unsigned length );
  58. int DPMI_UnlockMemoryRegion( void *start, void *end );
  59. #define DPMI_Lock( variable ) \
  60. ( DPMI_LockMemory( &( variable ), sizeof( variable ) ) )
  61. #define DPMI_Unlock( variable ) \
  62. ( DPMI_UnlockMemory( &( variable ), sizeof( variable ) ) )
  63. #pragma aux DPMI_GetDOSMemory = \
  64. "mov eax, 0100h", \
  65. "add ebx, 15", \
  66. "shr ebx, 4", \
  67. "int 31h", \
  68. "jc DPMI_Exit", \
  69. "movzx eax, ax", \
  70. "shl eax, 4", \
  71. "mov [ esi ], eax", \
  72. "mov [ edi ], edx", \
  73. "sub eax, eax", \
  74. "DPMI_Exit:", \
  75. parm [ esi ] [ edi ] [ ebx ] modify exact [ eax ebx edx ];
  76. #pragma aux DPMI_FreeDOSMemory = \
  77. "mov eax, 0101h", \
  78. "int 31h", \
  79. "jc DPMI_Exit", \
  80. "sub eax, eax", \
  81. "DPMI_Exit:", \
  82. parm [ edx ] modify exact [ eax ];
  83. #endif