Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

309 lines
12 KiB

  1. /*/****************************************************************************
  2. * name: mgai.h
  3. *
  4. * description: Description des MACROS d'interface a MGA
  5. *
  6. * designed: Alain Bouchard, 2 juillet 1992
  7. * last modified: $Author: ctoutant $, $Date: 93/12/15 14:36:39 $
  8. *
  9. * version: $Id: MGAI.H 1.11 93/12/15 14:36:39 ctoutant Exp $
  10. *
  11. ******************************************************************************/
  12. #ifdef MGA_INTERFACE_IN
  13. void mgaInitSimulation_in (unsigned long);
  14. void mgaSetSimulationModel_in (unsigned long);
  15. void mgaCloseSimulation_in (void);
  16. void mgaSuspendSimulation_in (void);
  17. void mgaResumeSimulation_in (void);
  18. void mgaWriteDWORD_in (unsigned long, unsigned long);
  19. void mgaWriteWORD_in (unsigned long, unsigned short);
  20. void mgaWriteBYTE_in (unsigned long, unsigned char);
  21. void mgaPollDWORD_in (unsigned long, unsigned long, unsigned long);
  22. void mgaPollWORD_in (unsigned long, unsigned short, unsigned short);
  23. void mgaPollBYTE_in (unsigned long, unsigned char, unsigned char);
  24. static volatile unsigned char _Far *mgaiFarPtr;
  25. #define mgaInitSimulation(m) mgaInitSimulation_in((m))
  26. #define mgaSetSimulationModel(m) mgaSetSimulationModel_in((m))
  27. #define mgaCloseSimulation() mgaCloseSimulation_in()
  28. #define mgaSuspendSimulation() mgaSuspendSimulation_in()
  29. #define mgaResumeSimulation() mgaResumeSimulation_in()
  30. #define mgaWriteDWORD(a, d) mgaiFarPtr = &((a)); \
  31. mgaWriteDWORD_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d))
  32. #define mgaWriteWORD(a, d) mgaiFarPtr = &((a)); \
  33. mgaWriteWORD_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d))
  34. #define mgaWriteBYTE(a, d) mgaiFarPtr = &((a)); \
  35. mgaWriteBYTE_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d))
  36. #define mgaReadDWORD(a, d)
  37. #define mgaReadWORD(a, d)
  38. #define mgaReadBYTE(a, d)
  39. #define mgaPollDWORD(a, d, m) mgaiFarPtr = &((a)); \
  40. mgaPollDWORD_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d), (m))
  41. #define mgaPollWORD(a, d, m) mgaiFarPtr = &((a)); \
  42. mgaPollWORD_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d), (m))
  43. #define mgaPollBYTE(a, d, m) mgaiFarPtr = &((a)); \
  44. mgaPollBYTE_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d), (m))
  45. #endif
  46. /*****************************************************************************/
  47. #ifdef MGA_INTERFACE_EMA
  48. void mgaInitSimulation_ema (unsigned long);
  49. void mgaCloseSimulation_ema (void);
  50. void mgaSuspendSimulation_ema (void);
  51. void mgaResumeSimulation_ema (void);
  52. void mgaWriteDWORD_ema (unsigned long, unsigned long);
  53. static volatile unsigned char _Far *mgaiFarPtr;
  54. #define mgaInitSimulation(m) mgaInitSimulation_ema((m))
  55. #define mgaSetSimulationModel(m)
  56. #define mgaCloseSimulation() mgaCloseSimulation_ema()
  57. #define mgaSuspendSimulation() mgaSuspendSimulation_ema()
  58. #define mgaResumeSimulation() mgaResumeSimulation_ema()
  59. #define mgaWriteDWORD(a, d) mgaiFarPtr = &((a)); \
  60. mgaWriteDWORD_ema(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d))
  61. #define mgaWriteWORD(a, d)
  62. #define mgaWriteBYTE(a, d)
  63. #define mgaReadDWORD(a, d)
  64. #define mgaReadWORD(a, d)
  65. #define mgaReadBYTE(a, d)
  66. #define mgaPollDWORD(a, d, m)
  67. #define mgaPollWORD(a, d, m)
  68. #define mgaPollBYTE(a, d, m)
  69. #endif
  70. /*****************************************************************************/
  71. #ifdef MGA_INTERFACE_EMGA
  72. void mgaInitSimulation_emga (unsigned long);
  73. void mgaCloseSimulation_emga (void);
  74. void mgaSuspendSimulation_emga (void);
  75. void mgaResumeSimulation_emga (void);
  76. void mgaWriteDWORD_emga (unsigned long, unsigned long);
  77. void mgaReadDWORD_emga (unsigned long, unsigned long*);
  78. static volatile unsigned char _Far *mgaiFarPtr;
  79. #define mgaInitSimulation(m) mgaInitSimulation_emga((m))
  80. #define mgaSetSimulationModel(m)
  81. #define mgaCloseSimulation() mgaCloseSimulation_emga()
  82. #define mgaSuspendSimulation() mgaCloseSimulation_emga()
  83. #define mgaResumeSimulation() mgaCloseSimulation_emga()
  84. #define mgaWriteDWORD(a, d) mgaiFarPtr = &((a)); \
  85. mgaWriteDWORD_emga(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d))
  86. #define mgaWriteWORD(a, d)
  87. #define mgaWriteBYTE(a, d)
  88. #define mgaReadDWORD(a, d) mgaiFarPtr = &((a)); \
  89. mgaReadDWORD_emga(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, &(d))
  90. #define mgaReadWORD(a, d)
  91. #define mgaReadBYTE(a, d)
  92. #define mgaPollDWORD(a, d, m)
  93. #define mgaPollWORD(a, d, m)
  94. #define mgaPollBYTE(a, d, m)
  95. #endif
  96. /*****************************************************************************/
  97. #ifdef MGA_INTERFACE_MGA
  98. #define mgaInitSimulation(m)
  99. #define mgaSetSimulationModel(m)
  100. #define mgaCloseSimulation()
  101. #define mgaSuspendSimulation()
  102. #define mgaResumeSimulation()
  103. /* --------------- Debug Write macro echoes ----------------------------- */
  104. #define MACRO_ECHO 0
  105. #ifndef WINDOWS_NT
  106. #if !(MACRO_ECHO) /* silent, optimized operation */
  107. #define mgaWriteDWORD(a, d) *((volatile unsigned long _Far *) &((a))) = (d)
  108. #define mgaWriteWORD(a, d) *((volatile unsigned short _Far *) &((a))) = (d)
  109. #define mgaWriteBYTE(a, d) *((volatile unsigned char _Far *) &((a))) = (d)
  110. #else /* verbose operation */
  111. #include <stdio.h>
  112. extern FILE *mgaFileOut;
  113. #define mgaWriteDWORD(a, d) { \
  114. \
  115. auto volatile unsigned long _Far *__FarPtr = (volatile unsigned long _Far *) &((a)); \
  116. \
  117. *((volatile unsigned long _Far *) &((a))) = (d); \
  118. if (mgaFileOut != NULL) { \
  119. fprintf(mgaFileOut, "selector:offset= 0x%x:", ((struct {unsigned long o; short s;}*) &__FarPtr )->s ); \
  120. fprintf(mgaFileOut, "0x%lx",((struct {unsigned long o; short s;}*) &__FarPtr )->o ); \
  121. fprintf(mgaFileOut, " Write DWORD = 0x%lx\n", (d) ); \
  122. } \
  123. else { \
  124. printf("selector:offset= 0x%x:", ((struct {unsigned long o; short s;}*) &__FarPtr )->s ); \
  125. printf("0x%lx ",((struct {unsigned long o; short s;}*) &__FarPtr )->o ); \
  126. printf("Write DWORD = 0x%lx\n", (d) ); \
  127. } \
  128. }
  129. #define mgaWriteWORD(a, d) { \
  130. \
  131. auto volatile unsigned short _Far *__FarPtr = (volatile unsigned short _Far *) &((a)); \
  132. \
  133. *((volatile unsigned short _Far *) &((a))) = (d); \
  134. if (mgaFileOut != NULL) { \
  135. fprintf(mgaFileOut, "selector:offset= 0x%x", ((struct {unsigned long o; short s;}*) &__FarPtr )->s ); \
  136. fprintf(mgaFileOut, ":0x%lx",((struct {unsigned long o; short s;}*) &__FarPtr )->o ); \
  137. fprintf(mgaFileOut, " Write WORD = 0x%hx\n", (d) ); \
  138. } \
  139. else { \
  140. printf("selector:offset= 0x%x", ((struct {unsigned long o; short s;}*) &__FarPtr )->s ); \
  141. printf(":0x%lx ",((struct {unsigned long o; short s;}*) &__FarPtr )->o ); \
  142. printf("Write WORD = 0x%hx\n", (d) ); \
  143. } \
  144. }
  145. #define mgaWriteBYTE(a, d) { \
  146. \
  147. auto volatile unsigned char _Far *__FarPtr = (volatile unsigned char _Far *) &((a)); \
  148. \
  149. *((volatile unsigned char _Far *) &((a))) = (d); \
  150. if (mgaFileOut != NULL) { \
  151. fprintf(mgaFileOut, "selector:offset= 0x%x", ((struct {unsigned long o; short s;}*) &__FarPtr )->s ); \
  152. fprintf(mgaFileOut, ":0x%lx",((struct {unsigned long o; short s;}*) &__FarPtr )->o ); \
  153. fprintf(mgaFileOut, " Write BYTE = 0x%x\n", (d) ); \
  154. } \
  155. else { \
  156. printf("selector:offset= 0x%x", ((struct {unsigned long o; short s;}*) &__FarPtr )->s ); \
  157. printf(":0x%lx ",((struct {unsigned long o; short s;}*) &__FarPtr )->o ); \
  158. printf("Write BYTE = 0x%x\n", (d) ); \
  159. } \
  160. }
  161. #endif /* #if !(MACRO_ECHO) */
  162. /* ----------- end Debug Write macro echoes ----------------------------- */
  163. #else /* #ifndef WINDOWS_NT */
  164. /* [dlee] On the DEC Alpha, we can't use *pointer to access h/w registers */
  165. /* #if !MGA_ALPHA */ /* ORIGINAL VERSION CAUSED WARNING */
  166. #if !defined(MGA_ALPHA) /* __DDK_SRC__ */
  167. #define mgaWriteDWORD(a, d) *((volatile unsigned long _Far *) &((a))) = (d)
  168. #define mgaWriteWORD(a, d) *((volatile unsigned short _Far *) &((a))) = (d)
  169. #define mgaWriteBYTE(a, d) *((volatile unsigned char _Far *) &((a))) = (d)
  170. #define mgaReadDWORD(a, d) (d) = *((volatile unsigned long _Far *) &((a)))
  171. #define mgaReadWORD(a, d) (d) = *((volatile unsigned short _Far *) &((a)))
  172. #define mgaReadBYTE(a, d) (d) = *((volatile unsigned char _Far *) &((a)))
  173. #define mgaPollDWORD(a, d, m) while ((*((volatile unsigned long _Far *) &((a))) & (m)) != (((d)) & ((m))))
  174. #define mgaPollWORD(a, d, m) while ((*((volatile unsigned short _Far *) &((a))) & (m)) != (((d)) & ((m))))
  175. #define mgaPollBYTE(a, d, m) while ((*((volatile unsigned char _Far *) &((a))) & (m)) != (((d)) & ((m))))
  176. #else /* #if !defined(MGA_ALPHA) */
  177. #define mgaWriteDWORD(a, d) VideoPortWriteRegisterUlong((PULONG) &((a)), (d))
  178. #define mgaWriteWORD(a, d) VideoPortWriteRegisterUshort((PUSHORT) &((a)), (d))
  179. #define mgaWriteBYTE(a, d) VideoPortWriteRegisterUchar((PUCHAR) &((a)), (UCHAR)(d))
  180. #define mgaReadDWORD(a, d) (d) = VideoPortReadRegisterUlong((PULONG) &((a)))
  181. #define mgaReadWORD(a, d) (d) = VideoPortReadRegisterUshort((PUSHORT) &((a)))
  182. #define mgaReadBYTE(a, d) (d) = VideoPortReadRegisterUchar((PUCHAR) &((a)))
  183. #define mgaPollDWORD(a, d, m) while ((VideoPortReadRegisterUlong((PULONG) &((a))) & (m)) != (((d)) & ((m))))
  184. #define mgaPollWORD(a, d, m) while ((VideoPortReadRegisterUshort((PUSHORT) &((a))) & (m)) != (((d)) & ((m))))
  185. #define mgaPollBYTE(a, d, m) while ((VideoPortReadRegisterUchar((PUCHAR) &((a))) & (m)) != (((d)) & ((m))))
  186. #endif /* #if !defined(MGA_ALPHA) */
  187. #endif /* #ifndef WINDOWS_NT */
  188. #endif
  189. /*****************************************************************************/
  190. #ifdef MGA_INTERFACE_EMGA_IN
  191. void mgaInitSimulation_emga (unsigned long);
  192. void mgaSetSimulationModel_in (unsigned long);
  193. void mgaCloseSimulation_emga (void);
  194. void mgaSuspendSimulation_emga (void);
  195. void mgaResumeSimulation_emga (void);
  196. void mgaWriteDWORD_emga (unsigned long, unsigned long);
  197. void mgaReadDWORD_emga (unsigned long, unsigned long*);
  198. void mgaInitSimulation_in (unsigned long);
  199. void mgaCloseSimulation_in (void);
  200. void mgaSuspendSimulation_in (void);
  201. void mgaResumeSimulation_in (void);
  202. void mgaWriteDWORD_in (unsigned long, unsigned long);
  203. static volatile unsigned char _Far *mgaiFarPtr;
  204. #define mgaInitSimulation(m) mgaInitSimulation_emga((m)); \
  205. mgaInitSimulation_in((m))
  206. #define mgaSetSimulationModel(m) mgaSetSimulationModel_in((m))
  207. #define mgaCloseSimulation() mgaCloseSimulation_emga(); \
  208. mgaCloseSimulation_in()
  209. #define mgaSuspendSimulation() mgaSuspendSimulation_emga(); \
  210. mgaSuspendSimulation_in()
  211. #define mgaResumeSimulation() mgaResumeSimulation_emga(); \
  212. mgaResumeSimulation_in()
  213. #define mgaWriteDWORD(a, d) mgaiFarPtr = &((a)); \
  214. mgaWriteDWORD_emga(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d)); \
  215. mgaWriteDWORD_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d))
  216. #define mgaWriteWORD(a, d) mgaiFarPtr = &((a)); \
  217. mgaWriteWORD_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d))
  218. #define mgaWriteBYTE(a, d) mgaiFarPtr = &((a)); \
  219. mgaWriteBYTE_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d))
  220. #define mgaReadDWORD(a, d) mgaiFarPtr = &((a)); \
  221. mgaReadDWORD_emga(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, &(d))
  222. #define mgaReadWORD(a, d)
  223. #define mgaReadBYTE(a, d)
  224. #define mgaPollDWORD(a, d, m) mgaiFarPtr = &((a)); \
  225. mgaPollDWORD_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d), (m))
  226. #define mgaPollWORD(a, d, m) mgaiFarPtr = &((a)); \
  227. mgaPollWORD_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d), (m))
  228. #define mgaPollBYTE(a, d, m) mgaiFarPtr = &((a)); \
  229. mgaPollBYTE_in(((struct {unsigned long o; short s;}*) &mgaiFarPtr)->o, (d), (m))
  230. #endif
  231. /*****************************************************************************/