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.

611 lines
15 KiB

  1. ; Copyright (c) Microsoft Corporation 1988-1991. All Rights Reserved.
  2. ;****************************************************************
  3. ;* *
  4. ;* GENDEFS.INC -- General Symbol Defintions for Dos Extender *
  5. ;* *
  6. ;****************************************************************
  7. ;* Revision History: *
  8. ;* *
  9. ;* 05/08/90 jimmat Changes for VCPI support. *
  10. ;* 01/07/90 jimmat Make DOSX version 03.00. *
  11. ;* 7/28/89 jimmat Increased GDT/LDT size yet again. *
  12. ;* 4/01/89 jimmat Increased size of GDT/LDT (again) *
  13. ;* 3/30/89 jimmat Added ChkPoint macro for debugging *
  14. ;* 3/11/89 jimmat Added support for LDT & TSS *
  15. ;* 3/09/89 jimmat Added DX_DYNALINK function *
  16. ;* 02/22/89 (GeneA): increased size of interrupt reflector *
  17. ;* stack frames (CB_STKFRAME) from 128 to 256 bytes *
  18. ;* 02/17/89 (GeneA): removed ERC_??? equates *
  19. ;* 02/10/89 (GeneA): changed form of definitions for the *
  20. ;* EXEC_??? symbols, and added ERC_??? error code symbols. *
  21. ;* 12/13/88 (GeneA): moved definitions for EXEC_??? symbols *
  22. ;* and RELOC_BUFFER here from dxinit.asm
  23. ;* 12/08/88 (GeneA): added npopf function *
  24. ;* 12/08/88 (GeneA): added HMMFUNC definition *
  25. ;* *
  26. ;****************************************************************
  27. ifndef DEBUG ;define DEBUG switch if it isn't already
  28. DEBUG = 0
  29. endif
  30. ifndef MINBUG
  31. MINBUG = 0
  32. endif
  33. ifndef VCPI
  34. VCPI = 0
  35. endif
  36. ifndef NO386
  37. NO386 = 0
  38. endif
  39. ; -------------------------------------------------------
  40. ; MISC. PROGRAM CONSTANTS
  41. ; -------------------------------------------------------
  42. DXVERSION = 030Ah ;Version 03.10
  43. DPMI_32BIT equ 0000000000000001b
  44. if VCPI
  45. CDSCGDTDEFAULT = 3072 ;default size of GDT **** temp for VCPI **** !!!
  46. CDSCLDTDEFAULT = 2
  47. else
  48. CDSCGDTDEFAULT = 3072 ;default size of GDT
  49. endif
  50. CDSCMAXLDT = 8190 ;maximum possible LDT selectors
  51. CDSCIDTDEFAULT = 256 ;default size of IDT
  52. CB_XFRBUF0 = 128 ;size of small transfer buffer
  53. ;
  54. ; Performance enhancement, by RalphL
  55. ;
  56. CB_XFRBUF1 = 8192 ;size of large transfer buffer
  57. CB_STKFRAME = 384 ;size of a stack frame
  58. CB_MEMHDR = 16 ; size of memory block header (1 paragraph)
  59. CXMSBLOCKSDX = 16 ; number of XMS blocks to allocate
  60. INTA00 = 20h ;i/o address of master 8259
  61. INTA01 = 21h
  62. INTB00 = 0A0h ;i/o address of slave 8259
  63. INTB01 = 0A1h
  64. CMOSLoc = 70h ;CMOS ram/Real-Time Clock location port
  65. CMOSValue = 71h ;CMOS ram/Real-Time Clock value port
  66. HP_VECTRA = 01h ;Running on an HP Vectra
  67. HP_CLASSIC = 02h ;Running on a 'Classic' Vectra (A & A+)
  68. CRESERVED = 32 ;Reserved interrupt numbers
  69. ; The following equates define the DOS Extender DynaLink services
  70. if DEBUG
  71. OutDebugStr = 0 ;debugging text out service
  72. TestDebugIns = 1 ;debugger installation check service
  73. NUM_DYNALINK = 2
  74. else ; !DEBUG
  75. NUM_DYNALINK = 0
  76. endif
  77. ; This structure defines the format of the Exec paramter block used
  78. ; by the MS-DOS exec function (ah=4Bh, al=01).
  79. XBLK struc
  80. segEnv dw ? ;segment address of environment to use
  81. lpchCmnd dd ? ;far pointer to command line
  82. lpFCB0 dd ? ;far pointer to first default fcb
  83. lpFCB1 dd ? ;far pointer to second default fcb
  84. lpChildStack dd ? ;return value, far pointer to child stack
  85. lpChildCode dd ? ;return value, far pointer to child code
  86. XBLK ends
  87. ; The following symbols define locations in rgbXfrBuf1 used
  88. ; during initialization. ParseCommandLine places this information
  89. ; into the buffer to be used by later programs.
  90. BUFTMP = CB_XFRBUF1 - 1024 ;use the top 1k for the temporary buffers
  91. EXEC_PROGNAME equ <DGROUP:rgbXfrBuf1+BUFTMP+0000h> ;child program's exe file name
  92. EXEC_DXNAME equ <DGROUP:rgbXfrBuf1+BUFTMP+0080h> ;Dos Extender program name
  93. EXEC_CMNDLINE equ <DGROUP:rgbXfrBuf1+BUFTMP+0100h> ;command line to pass to the child
  94. EXEC_EXEHDR equ <DGROUP:rgbXfrBuf1+BUFTMP+0180h> ;buffer for holding exe header for
  95. ; the overlay currently being
  96. ; loaded
  97. EXEC_FCB0 equ <DGROUP:rgbXfrBuf1+BUFTMP+01A0h> ;FCB0 to pass to the child
  98. EXEC_FCB1 equ <DGROUP:rgbXfrBuf1+BUFTMP+01D0h> ;FCB1 to pass to the child
  99. RELOC_BUFFER equ <DGROUP:rgbXfrBuf1+BUFTMP+0200h> ;file input buffer used to hold
  100. ; pages of the relocation table
  101. ; while relocating the current
  102. ; overlay
  103. ;
  104. ; This structure defines the stack frame used to hold the entry
  105. ; values and automatic variables for Dos Extender functions.
  106. FUNCSTACK struc
  107. fnsUserES dw ?
  108. fnsUserDS dw ?
  109. fnsUserDI dw ?
  110. fnsUserSI dw ?
  111. fnsUserBP dw ?
  112. fnsUserSPx dw ?
  113. fnsUserBX dw ?
  114. fnsUserDX dw ?
  115. fnsUserCX dw ?
  116. fnsUserAX dw ?
  117. fnsUserIP dw ?
  118. fnsUserCS dw ?
  119. fnsUserFL dw ?
  120. fnsUserSS dw ?
  121. fnsUserSP dw ?
  122. FUNCSTACK ends
  123. ; -------------------------------------------------------
  124. ; DEFINITIONS FOR MACROS
  125. ; -------------------------------------------------------
  126. ; These macros are used to switch between the protected mode
  127. ; only code segment and the mixed protected/real mode code segment.
  128. ; They are intended to be used for switching between modes in-line
  129. ; within a routine. They must be used in pairs, bracketing the
  130. ; code that needs to be in the other mode (from the initial or 'native'
  131. ; mode of the function.)
  132. ; -------------------------------------------------------
  133. ;
  134. ; This macro switches the processor and the local segment context
  135. ; to the dos extender protected mode segment.
  136. SwitchToProtectedMode macro
  137. local foo
  138. ifndef EnterProtectedMode
  139. extrn EnterProtectedMode:NEAR
  140. endif
  141. call EnterProtectedMode
  142. % ifidni <@CURSEG>,<DXCODE>
  143. ; jmp far ptr foo
  144. db 0EAh ;avoid need for fixups
  145. dw offset DXPMCODE:foo
  146. dw SEL_DXPMCODE OR STD_RING
  147. DXCODE ends
  148. DXPMCODE segment
  149. assume cs:DXPMCODE
  150. endif
  151. foo:
  152. endm
  153. ; -------------------------------------------------------
  154. ;
  155. ; This macro switches the processor and the local segment context
  156. ; to the dos extender mixed protected/real mode segment.
  157. SwitchToRealMode macro
  158. local foo
  159. % ifidni <@CURSEG>,<DXPMCODE>
  160. ; jmp far ptr foo
  161. db 0EAh ;avoid need for fixups
  162. dw offset DXCODE:foo
  163. dw SEL_DXCODE OR STD_RING
  164. DXPMCODE ends
  165. DXCODE segment
  166. assume cs:DXCODE
  167. endif
  168. ifndef EnterRealMode
  169. extrn EnterRealMode:NEAR
  170. endif
  171. foo:
  172. call EnterRealMode
  173. endm
  174. ; -------------------------------------------------------
  175. ;
  176. BeginLowSegment macro
  177. DXCODE segment
  178. assume cs:DXCODE
  179. endm
  180. EndLowSegment macro
  181. DXCODE ends
  182. endm
  183. BeginHighSegment macro
  184. DXPMCODE segment
  185. assume cs:DXPMCODE
  186. endm
  187. EndHighSegment macro
  188. DXPMCODE ends
  189. endm
  190. ; -------------------------------------------------------
  191. ;
  192. ; This macro switches the local segment context
  193. ; to the dos extender protected mode segment.
  194. ChangeToHighSegment macro
  195. local foo
  196. % ifidni <@CURSEG>,<DXCODE>
  197. .err
  198. %out Switch to high segment when already in high segment
  199. endif
  200. jmp far ptr foo
  201. DXCODE ends
  202. DXPMCODE segment
  203. assume cs:DXPMCODE
  204. foo:
  205. endm
  206. ; -------------------------------------------------------
  207. ;
  208. ; This macro switches the local segment context
  209. ; to the dos extender mixed protected/real mode segment.
  210. ChangeToLowSegment macro
  211. local foo
  212. % ifidni <@CURSEG>,<DXCODE>
  213. .err
  214. %out Switch to low segment when already in low segment
  215. endif
  216. jmp far ptr foo
  217. DXPMCODE ends
  218. DXCODE segment
  219. assume cs:DXCODE
  220. foo:
  221. endm
  222. ; -------------------------------------------------------
  223. ;
  224. PushCParams MACRO P1, P2, P3, P4, P5, P6, P7, P8, P9, P10
  225. IRP Param, <P10, P9, P8, P7, P6, P5, P4, P3, P2, P1>
  226. IFNB <Param>
  227. push Param
  228. ENDIF
  229. ENDM
  230. ENDM
  231. ClearCParams MACRO Count, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10
  232. IFNB <P1>
  233. ClearCParams %(Count+1), <P2>, <P3>, <P4>, <P5>, <P6>, <P7>, <P8>, <P9>, <P10>
  234. ELSE
  235. IF Count
  236. add sp, Count*2
  237. ENDIF
  238. ENDIF
  239. ENDM
  240. ; -------------------------------------------------------
  241. ; This macro calls one of the DX services
  242. DXcall MACRO Procedure, Param_List
  243. IFNDEF WOW_x86 ; BUGBUG
  244. PushCParams Param_List
  245. db 9Ah ;call sel:0
  246. dw 0
  247. dw SEL_DYNALINK + (Procedure SHL 3)
  248. ClearCParams 0, Param_List
  249. ENDIF
  250. ENDM
  251. ; -------------------------------------------------------
  252. ; This macro displays a string if DEBUG
  253. ;
  254. ; Note: This macro only works in PROTECT MODE! **********
  255. Trace_Out MACRO String, nocrlf
  256. LOCAL String_Offset
  257. ifndef WOW_x86 ;bugbug
  258. IF DEBUG
  259. DXDATA SEGMENT
  260. String_Offset LABEL BYTE
  261. db String
  262. IFB <nocrlf>
  263. db 0Ah, 0Dh
  264. ENDIF
  265. db 0
  266. DXDATA ENDS
  267. push ds
  268. pushf
  269. cli
  270. pusha ; save our registers
  271. pusha ; copy them for print routine
  272. mov ax,SEL_DXDATA ; make sure string is addressable
  273. mov ds,ax
  274. mov si,OFFSET DGROUP:String_Offset
  275. DXcall OutDebugStr
  276. popa ; restore our registers
  277. npopf
  278. pop ds
  279. ENDIF
  280. endif ;WOW_x86
  281. ENDM
  282. ; -------------------------------------------------------
  283. ; This macro displays a string and breaks if DEBUG
  284. ;
  285. ; Note: This macro only works in PROTECT MODE! **********
  286. Debug_Out MACRO String
  287. LOCAL Skip_Int1
  288. IF DEBUG
  289. pushf
  290. Trace_Out <String>
  291. DXcall TestDebugIns
  292. jz SHORT Skip_Int1
  293. int 1
  294. Skip_Int1:
  295. npopf
  296. ENDIF
  297. ENDM
  298. ; -------------------------------------------------------
  299. ; This macro displays a string if DEBUG
  300. ;
  301. ; Note: This macro only works in REAL MODE! **********
  302. ;
  303. ; DS must be set to the DOS Extender's DS before using, too.
  304. ;
  305. Real_Trace_Out MACRO String, nocrlf
  306. LOCAL String_Offset
  307. IF DEBUG
  308. ifndef DXOutDebugStr
  309. EXTRN DXOutDebugStr:FAR
  310. endif
  311. DXDATA SEGMENT
  312. String_Offset LABEL BYTE
  313. db String
  314. IFB <nocrlf>
  315. db 0Ah, 0Dh
  316. ENDIF
  317. db 0
  318. DXDATA ENDS
  319. pushf
  320. cli
  321. pusha ; save our registers
  322. pusha ; copy them for print routine
  323. mov si,OFFSET DGROUP:String_Offset
  324. call DXOutDebugStr
  325. popa ; restore our registers
  326. npopf
  327. ENDIF
  328. ENDM
  329. ; -------------------------------------------------------
  330. ; This macro displays a string and breaks if DEBUG
  331. ;
  332. ; Note: This macro only works in REAL MODE! **********
  333. ;
  334. ; DS must be set to the DOS Extender's DS before using, too.
  335. ;
  336. Real_Debug_Out MACRO String
  337. LOCAL Skip_Int1
  338. IF DEBUG
  339. pushf
  340. Real_Trace_Out <String>
  341. cmp fDebug,0
  342. jz SHORT Skip_Int1
  343. int 1
  344. Skip_Int1:
  345. npopf
  346. ENDIF
  347. ENDM
  348. ; -------------------------------------------------------
  349. ; Delay for I/O Instructions...
  350. IO_Delay MACRO
  351. jmp short $+2
  352. jmp short $+2
  353. jmp short $+2
  354. ENDM
  355. ; -------------------------------------------------------
  356. ;8080-style return macros due to Greg Whitten
  357. genrcc macro cc
  358. r&cc &macro labl
  359. if $-___ret gt 126d
  360. jn&cc $+3 ;;Skip around ret
  361. ___ret = $
  362. ret
  363. else
  364. j&cc ___ret ;;jmp to last ret
  365. endif
  366. &endm
  367. rn&cc &macro labl
  368. if $-___ret gt 126d
  369. j&cc $+3 ;;Skip around ret
  370. ___ret = $
  371. ret
  372. else
  373. jn&cc ___ret ;;jmp to last ret
  374. endif
  375. &endm
  376. call&cc &macro labl
  377. jn&cc $+5 ;;Skip around call
  378. call labl
  379. &endm
  380. calln&cc &macro labl
  381. j&cc $+5 ;;Skip around call
  382. call labl
  383. &endm
  384. jmp&cc &macro labl
  385. jn&cc $+5 ;;Skip around jmp
  386. jmp labl
  387. &endm
  388. jmpn&cc &macro labl
  389. j&cc $+5 ;;Skip around jmp
  390. jmp labl
  391. &endm
  392. endm
  393. ; -------------------------------------------------------
  394. ; rcc and rncc macro generators
  395. genrcc a
  396. genrcc ae
  397. genrcc b
  398. genrcc be
  399. genrcc c
  400. genrcc e
  401. genrcc g
  402. genrcc ge
  403. genrcc l
  404. genrcc le
  405. genrcc o
  406. genrcc s
  407. genrcc z
  408. return macro
  409. ___ret = $
  410. ret
  411. endm
  412. ; -------------------------------------------------------
  413. ;
  414. ; This macro is used to get around the bug in the POPF instruction in
  415. ; some early 80286 chips.
  416. IFDEF WOW
  417. npopf macro
  418. rpopf
  419. endm
  420. ELSE
  421. npopf macro
  422. local a
  423. jmp $+3 ; Fix for bug in POPF on IBM AT
  424. a: iret ; This simulates a POPF instruction
  425. push cs
  426. call a
  427. endm
  428. ENDIF
  429. ; -------------------------------------------------------
  430. ;
  431. ; MS-DOS function call macros
  432. dossvc macro fcn
  433. ifnb <fcn>
  434. mov ah,fcn
  435. endif
  436. int 21h
  437. endm
  438. pmdossvc macro fcn
  439. ifnb <fcn>
  440. mov ah,fcn
  441. endif
  442. pushf ;don't do Int 21h in case child has Int 21h
  443. cli ; hooked (like Windows)
  444. push cs
  445. call PmIntrDos
  446. endm
  447. ; -------------------------------------------------------
  448. ; This macro will request a Dos Extender funtion.
  449. dxsvc macro fcn
  450. ifnb <fcn>
  451. mov al,fcn
  452. endif
  453. mov ah,DXFUNC
  454. int 2Fh
  455. endm
  456. ; -------------------------------------------------------
  457. ; This macro is used to make calls to the XMS driver for
  458. ; extended memory management.
  459. HMMFUNC = 43h ;Himem driver Int 2Fh function code
  460. xmssvc macro fcn
  461. ifnb <fcn>
  462. mov ah,fcn
  463. endif
  464. call [lpfnXMSFunc]
  465. endm
  466. ; -------------------------------------------------------
  467. out1 macro p
  468. if1
  469. %out p
  470. endif
  471. endm
  472. ; -------------------------------------------------------
  473. errnz macro p
  474. if2
  475. .errnz p
  476. endif
  477. endm
  478. ; -------------------------------------------------------
  479. ; -------------------------------------------------------
  480. ; -------------------------------------------------------
  481. ;****************************************************************