home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cl5sr386.zip / GO32 / XMS.H < prev   
C/C++ Source or Header  |  1992-04-13  |  6KB  |  207 lines

  1. /*
  2. ** xms.h -- C bindings for xms API
  3. ** Author: Kent Williams william@umaxc.weeg.uiowa.edu
  4. **
  5. ** This is an attempt to provide a complete C binding
  6. ** for the XMS calls.
  7. **
  8. ** All calls will store the error code in xms_error.  I have
  9. ** tried to document how the calls work in this file where their
  10. ** prototypes are given.
  11. */
  12. #ifndef __XMS_H
  13. #define __XMS_H
  14.  
  15. /*
  16. ** extended memory block types
  17. */
  18. typedef unsigned short emb_size_K_t;
  19. typedef unsigned long  emb_off_t;
  20. typedef short emb_handle_t;
  21.  
  22. /*
  23. ** upper memory block types.
  24. */
  25. typedef unsigned short umb_segment_t;
  26. typedef unsigned short umb_size_t;
  27.  
  28. /*
  29. ** structure defining information returned
  30. ** from xms_query_extended_memory
  31. */
  32. typedef struct _xms_extended_info {
  33.     emb_size_K_t max_free_block;
  34.     emb_size_K_t total_extended_memory;
  35. } xms_extended_info;
  36.  
  37. /*
  38. ** structure defining information returned
  39. ** from xms_get_version_info
  40. */
  41. typedef struct _xms_version_info {
  42.     unsigned xms_ver;
  43.     unsigned xmm_ver;
  44.     unsigned hma_present;
  45. } xms_version_info;
  46.  
  47. /*
  48. ** structure defining information returned from
  49. ** xms_get_emb_handle_info
  50. */
  51. typedef struct _emb_handle_info {
  52.     unsigned char lock_count;
  53.     unsigned char handles_available;
  54.     emb_size_K_t block_size;
  55. } emb_handle_info;
  56.  
  57. /*
  58. ** move parameter block for extended memory moves.
  59. */
  60. typedef struct _xms_move_param {
  61.     emb_off_t length;
  62.     emb_handle_t source_handle;
  63.     emb_off_t source_offset;
  64.     emb_handle_t dest_handle;
  65.     emb_off_t dest_offset;
  66. } xms_move_param;
  67.  
  68. /*
  69. ** upper memory block info blockblock
  70. */
  71. typedef struct _umb_info {
  72.     umb_segment_t segment;
  73.     umb_size_t block_size;
  74. } umb_info;
  75.  
  76. extern char xms_error;
  77. /*
  78. ** xms error codes
  79. */
  80. #define XMS_NOT_IMPLEMENTED        0x80
  81. #define XMS_VDISK_DETECTED        0x81
  82. #define XMS_A20_ERROR            0x82
  83. #define XMS_DRIVER_ERROR        0x8e
  84. #define XMS_FATAL_DRIVER_ERROR    0x8f
  85. #define XMS_NO_HMA                0x90
  86. #define XMS_HMA_INUSE            0x91
  87. #define XMS_HMA_DX_TOO_SMALL    0x92
  88. #define XMS_HMA_NOT_ALLOCATED    0x93
  89. #define XMS_A20_STILL_ENABLED    0x94
  90. #define XMS_EXT_NO_MEM            0xa0
  91. #define XMS_EXT_NO_HANDLES        0xa1
  92. #define XMS_EXT_BAD_HANDLE        0xa2
  93. #define XMS_EXT_BAD_SRC_HANDLE    0xa3
  94. #define XMS_EXT_BAD_SRC_OFFSET    0xa4
  95. #define XMS_EXT_BAD_DST_HANDLE    0xa5
  96. #define XMS_EXT_BAD_DST_OFFSET    0xa6
  97. #define XMS_EXT_BAD_LENGTH        0xa7
  98. #define XMS_EXT_OVERLAP            0xa8
  99. #define XMS_EXT_PARITY            0xa9
  100. #define XMS_EXT_NOT_LOCKED        0xaa
  101. #define XMS_EXT_LOCKED            0xab
  102. #define XMS_EXT_NO_LOCKS        0xac
  103. #define XMS_EXT_LOCK_FAILED        0xad
  104. #define XMS_UMB_SMALLER_AVAIL    0xb0
  105. #define XMS_UMB_NO_MEM            0xb1
  106. #define XMS_UMB_BAD_SEG            0xb2
  107.  
  108.  
  109. /* xms function 00H 
  110. ** returns pointer to static info block
  111. */
  112. xms_version_info * xms_get_version_info(void);
  113.  
  114. /* xms function 01H
  115. ** returns 0 on success, non-zero on failure
  116. ** if it succeeds, the address of the hma is 0xffff:0010H
  117. ** the size parameter is screwy; it is documented to be 0xffff for an
  118. ** application,or the actual size needed for a driver.
  119. */
  120. int xms_hma_allocate(unsigned size);
  121.  
  122. /* xms function 02H
  123. ** returns 0 on success, non-zero on failure
  124. */
  125. int xms_hma_free(void);
  126.  
  127. /*
  128. ** The following functions diddle the A20 address line.  A20 has to
  129. ** be enabled in order to address memory > 1Mbyte, i.e. the HMA
  130. ** You are supposed to use the global functions if you are 'the owner'
  131. ** of the HMA, the local functions if you are not. You own the HMA
  132. ** if your call to xms_hma_allocate succeeded.
  133. ** The distinction between global and local aren't really explained
  134. ** in the stuff I have;  my inclination would be to try to get the hma
  135. ** with xms_hma_allocate and then just use the global functions.
  136. */
  137. /* xms function 03H */
  138. int xms_global_enable_a20(void);
  139. /* xms function 04H */
  140. int xms_global_disable_a20(void);
  141. /* xms function 05H */
  142. int xms_local_enable_a20(void);
  143. /* xms function 06H */
  144. int xms_local_disable_a20(void);
  145.  
  146. /* xms function 07H
  147. ** returns 1 if the line is enabled, 0 if it isn't.
  148. ** actually (!xms_a20_status && !xms_error) would indicate disabled
  149. ** status; if the error is non-zero, then the call failed for some screwy
  150. ** reason
  151. */
  152. int xms_a20_status(void);
  153.  
  154. /* xms function 08H
  155. ** this call returns a pointer to a static info area
  156. */
  157. xms_extended_info *xms_query_extended_memory(void);
  158.  
  159. /* xms function 09H
  160. ** returns an emb handle, or -1 if allocation fails
  161. */
  162. int xms_emb_allocate(emb_size_K_t size);
  163.  
  164. /* xms function 0AH
  165. ** returns 0 on success non-zero on failure
  166. */
  167. int xms_emb_free(emb_handle_t handle);
  168.  
  169. /* xms function 0BH
  170. ** returns 0 on success non-zero on failure
  171. */
  172. int xms_move_emb(xms_move_param *x);
  173.  
  174. /* xms function 0CH
  175. ** returns 32 bit linear address of emb specified by handle,
  176. ** 0 otherwise.
  177. */
  178. emb_off_t xms_lock_emb(emb_handle_t handle);
  179.  
  180. /* xms function 0DH
  181. ** returns 0 on success non-zero on failure
  182. */
  183. int xms_unlock_emb(emb_handle_t handle);
  184.  
  185. /* xms function 0EH
  186. ** returns poitner to static information buffer, or null on failure
  187. */
  188. emb_handle_info *xms_get_emb_handle_info(emb_handle_t handle);
  189.  
  190. /* xms function 0FH
  191. ** returns 0 on success, non-zero on failure
  192. */
  193. int xms_emb_resize(emb_handle_t handle,emb_size_K_t size);
  194.  
  195. /* xms function 10H 
  196. ** returns pointer to static umb info block, or NULL
  197. ** if call fails
  198. */
  199. umb_info * xms_umb_allocate(umb_size_t size);
  200.  
  201. /* xms function 11H 
  202. ** returns 0 on success, non-zero on failure
  203. */
  204. int xms_umb_free(umb_segment_t segment);
  205.  
  206. #endif /* XMS_H */
  207.