Leaked source code of windows server 2003
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.

374 lines
10 KiB

  1. ;*** dxvcpi.inc - include file for vcpi functions/maintenance
  2. ;
  3. ; Copyright <C> 1990-1991, Microsoft Corporation
  4. ;
  5. ; Purpose:
  6. ;
  7. ; Revision History:
  8. ;
  9. ; 08-07-90 earleh rearranged things to allow building Pmode data
  10. ; structures with total size exceeding that of LIM 3.2 page
  11. ; frame
  12. ; 05/09/90 jimmat Started incorporating VCPI changes from languages group.
  13. ;
  14. ; [] 20-Feb-1990 Dans Created
  15. ;
  16. ;************************************************************************/
  17. CurrentCpu = @Cpu ;select 386 assembly if not already
  18. ife (CurrentCpu AND 0008h)
  19. .386
  20. endif
  21. ;
  22. ; Hungarian used:
  23. ; la Linear Address
  24. ; za Physical Address
  25. ;
  26. ;
  27. ;
  28. ; Miscellaneous equates
  29. ;
  30. EMS_INT = 067h
  31. VCPIINT = 067h
  32. CBEMMSTR = 8h
  33. CPTDX = 1h ; count of user page tables dx uses
  34. CPTDXEXT = (CPTDX+1) ; count of total page tables dx uses
  35. CBPAGE386 = 1000h ; bytes in 386 page
  36. CBPAGE386LIM = 1000h-1
  37. DXINDOS = 00000001b
  38. DXINEMS = 00000010b ; obsolete
  39. DXINVCPI = 00000100b
  40. DXINXMS = 00001000b
  41. ;
  42. ; See dxvcpi.asm for a rough sketch of the memory block that the
  43. ; following variables describe
  44. DXLINEARBASE = 80000000h ; Linear base of DX system memory
  45. VCPIPTOFF = 0 * CBPAGE386 ; vcpi's 0th page table
  46. DXPT1OFF = 1 * CBPAGE386 ; dx's first user page table
  47. DXPTSYSOFF = DXPT1OFF + (CPTDX * CBPAGE386)
  48. ; dx's system page table
  49. DXPDOFF = DXPTSYSOFF + CBPAGE386 ; page directory
  50. DXLASTPTOFF = DXPDOFF
  51. DXBOOTPTOFF = DXPTSYSOFF
  52. ;
  53. ; Last user page table is used to bootstrap our protected mode
  54. ; data into extended memory.
  55. ;
  56. DXTEMPPTOFF = DXPTSYSOFF - CBPAGE386
  57. DX_TEMP_LINEARBASE = (DXTEMPPTOFF - VCPIPTOFF) shl 10
  58. ;
  59. ; The next number comes from the dosx.map file, and is equal to the
  60. ; offset of the CODEENDPM symbol, plus whatever padding we want to use
  61. ; so we don't have to update this include file too often.
  62. ;
  63. if DEBUG
  64. DXPMCODESIZE = 04900H
  65. else ; DEBUG
  66. DXPMCODESIZE = 04000H
  67. endif ; DEBUG
  68. IDTOFF = DXLASTPTOFF + CBPAGE386
  69. IDTSIZE = CDSCIDTDEFAULT * 8
  70. IDTLIM = IDTSIZE - 1
  71. TSSOFF = IDTOFF + IDTSIZE
  72. TSSTOP = TSSOFF + (type TSS386)
  73. GDTOFF = ((TSSTOP + 0fh) shr 4) shl 4 ; paragraph align
  74. GDTLIM = GDT_SIZE - 1
  75. GDTTOP = GDTOFF + GDT_SIZE
  76. DXPMCODEOFF = ((GDTTOP + 0fh) shr 4) shl 4 ; paragraph align
  77. LDTOFF = ((DXPMCODEOFF + DXPMCODESIZE + CBPAGE386 - 1) shr 12) shl 12
  78. LDTSIZE = CDSCMAXLDT * 8
  79. LDTLIM = LDTSIZE - 1
  80. LDTTOP = LDTOFF + LDTSIZE
  81. ;
  82. ; Final place where page tables are mapped in Protected mode is
  83. ; at the first linear page boundary after the end of the LDT.
  84. ;
  85. USERPT = (LDTTOP + CBPAGE386 - 1) shr 12
  86. USERPTOFF = ((LDTTOP + CBPAGE386 - 1) shr 12) shl 12
  87. ;
  88. ; The total number of 386 pages we need for the block that holds our
  89. ; system tables and protected mode code.
  90. ;
  91. DXPMPAGES = (LDTTOP + (CBPAGE386 - 1)) shr 12
  92. DXPMBYTES = DXPMPAGES shl 12
  93. DXPMPARAGRAPHS = DXPMBYTES shr 4
  94. ;
  95. ; compile time asserts for sizes/offsets/alignment
  96. ;
  97. .ERRE (type TSS386) GE 104
  98. .ERRE TSSTOP LE GDTOFF
  99. .ERRE IDTOFF EQ ((IDTOFF SHR 4) SHL 4)
  100. ;
  101. ; Limits of tables
  102. ;
  103. DXPTMAX = CPTDX * CBPAGE386 ; space we allocate for
  104. ; user page tables
  105. ;
  106. ; Linear pointers to bases of various tables when running under vcpi
  107. ;
  108. ; For a selDXPD descriptor (dos extender's page directory)
  109. ;
  110. LADXPDBASE = DXLINEARBASE + DXPDOFF
  111. ; For a selDXPT descriptor (dos extender's page tables)
  112. ;
  113. LADXPTBASE = DXLINEARBASE + USERPTOFF ; (Plus runtime value.)
  114. ; For a selGDT descriptor
  115. ;
  116. LADXGDTBASE = DXLINEARBASE + GDTOFF
  117. ; For a selLDT descriptor
  118. ;
  119. LADXLDTBASE = DXLINEARBASE + LDTOFF
  120. ; For a selIDT descriptor
  121. ;
  122. LADXIDTBASE = DXLINEARBASE + IDTOFF
  123. ; For a selTSS descriptor
  124. ;
  125. LADXTSS1BASE = DXLINEARBASE + TSSOFF
  126. LADXTSS2BASE = DXLINEARBASE + TSSOFF + type TSS386
  127. ; For a SEL_DXPMCODE descriptor
  128. ;
  129. LADXPMCODEBASE = DXLINEARBASE + DXPMCODEOFF
  130. ;
  131. ; vcpi/ems service macros
  132. ;
  133. RMvcpi macro fCode
  134. ifnb <fCode>
  135. mov ax, fCode
  136. endif
  137. int VCPIINT
  138. endm
  139. PMvcpi macro fCode
  140. ifnb <fCode>
  141. mov ax, fCode
  142. endif
  143. cCall CallVCPIPM
  144. endm
  145. emscall macro fCode
  146. ifnb <fCode>
  147. mov ax, fCode
  148. endif
  149. int EMS_INT
  150. endm
  151. ; EMS functions/subfunctions
  152. GETFRAMEADDRESS = 04100h
  153. ALLOCATEPAGES = 05A00h
  154. GETNUMOFPAGES = 04200h
  155. MAPHANDLEPAGE = 04400h
  156. DEALLOCATEPAGES = 04500h
  157. GETEMSVER = 04600h
  158. SETHANDLENAME = 05301h
  159. GETPAGEADDRS = 05800h
  160. GETNUMPAGEMAP = 05801h
  161. page
  162. ;
  163. ; VCPI functions/subfunctions
  164. ; all functions take the vcpi function code in ax as input
  165. ; all functions return ah=0 if successful, ah != 0 if failure
  166. ; if function return has no ah value, it can't fail (ah == 0)
  167. ;
  168. ;
  169. ; vcpi version, presence
  170. ;
  171. vcpiVER = 0de00h
  172. ;
  173. ; input:
  174. ; return: ah = 0, bl = vcpi minor revision, bh = major revision
  175. ;
  176. ; get protect mode interface
  177. ;
  178. vcpiPMINTERFACE = 0de01h
  179. ;
  180. ; input: es:di = ptr to 4k page table,
  181. ; ds:si = ptr to 3 entries in GDT
  182. ; return: di = 1st unused page table entry,
  183. ; ebx = offset in server CS of PM entry point
  184. ;
  185. ; get max physical address in system
  186. ;
  187. vcpiMAXPHYSADDR = 0de02h
  188. ;
  189. ; input:
  190. ; return: edx = physical addr of highest 4k page that
  191. ; could ever be allocated
  192. ;
  193. ; count of free 4k pages
  194. ;
  195. ; Note: This call gives the total 386 pages available to all tasks
  196. ; in the system from the VCPI server. According to VCPI version 1.0,
  197. ; however, we should only allocate as much memory as there is EMS
  198. ; memory available. The following call, therefore, is not real useful
  199. ; to us.
  200. ;
  201. vcpiCFREEPAGES = 0de03h
  202. ;
  203. ; input:
  204. ; return: edx = number of free 4k pages
  205. ;
  206. ; allocate a 4k page
  207. ;
  208. vcpiALLOCPAGE = 0de04h
  209. ;
  210. ; input:
  211. ; return: ah = 0, edx = physical address of allocated 4k page
  212. ; ah != 0, edx = trashed
  213. ;
  214. ; free a 4k page
  215. ;
  216. vcpiFREEPAGE = 0de05h
  217. ;
  218. ; input: edx = physical address of page to free
  219. ; return: ah = 0
  220. ; ah != 0
  221. ;
  222. ; physical address of page in 1st meg
  223. ;
  224. vcpiPHYSADDRPAGE= 0de06h
  225. ;
  226. ; input: cx = page number (linear addr of page SHR by 12)
  227. ; return: ah = 0, edx = physical address of 4k page
  228. ; ah != 0
  229. ;
  230. ; read cr0
  231. ;
  232. vcpiREADCR0 = 0de07h
  233. ;
  234. ; input:
  235. ; return: ebx = cr0 value
  236. ;
  237. ; read debug registers
  238. ;
  239. vcpiREADDRx = 0de08h
  240. ;
  241. ; input: es:di = ptr to 8 dwords, dr0 first, dr4, dr5 not present
  242. ; return:
  243. ;
  244. ; load debug registers
  245. ;
  246. vcpiLOADDRx = 0de09h
  247. ;
  248. ; input: es:di = ptr to 8 dwords, dr0 first, dr4, dr5 not present
  249. ; return:
  250. ;
  251. ; get mapping of hardware interrupts
  252. ;
  253. vcpiGET8259MAP = 0de0ah
  254. ;
  255. ; input:
  256. ; return: bx = 1st vector mapping for master 8259a
  257. ; cx = 1st vector mapping for slave 8259a
  258. ; set mapping of hardware interrupts
  259. ;
  260. vcpiSET8259MAP = 0de0bh
  261. ;
  262. ; input: interrupts disabled
  263. ; bx = 1st vector mapping for master 8259a
  264. ; cx = 1st vector mapping for slave 8259a
  265. ; return:
  266. ;
  267. ; switch from v86 mode to protect mode or protect mode to v86 mode
  268. ;
  269. vcpiSWITCHTOPM = 0de0ch
  270. ;
  271. ; input: interrupts disabled
  272. ; esi = linear address (in first megabyte) of data
  273. ; structure (v86topm struc)
  274. ;
  275. ; return: (output in pm)
  276. ; gdtr, idtr, ldtr, tr loaded
  277. ; ss:esp must have 16 bytes of space on it, pm must
  278. ; set up it's stack
  279. ; eax = trashed
  280. ; esi = trashed
  281. ; ds, es, fs, gs all modified
  282. ; interrupts disabled
  283. ;
  284. vcpiSWITCHTOV86 = 0de0ch
  285. ;
  286. ; input: interrupts disabled
  287. ; STACK: 28 dword gs
  288. ; 24 dword fs
  289. ; 20 dword ds
  290. ; 1c dword es
  291. ; 18 dword ss
  292. ; 14 dword esp
  293. ; 10 dword eflags reserved
  294. ; 0c dword cs xfer to
  295. ; 08 dword eip xfer to
  296. ; 00 qword far32 return (garbage)
  297. ;
  298. ;
  299. ; return: (output in rm)
  300. ; ss:esp loaded with values from stack
  301. ; segment registers loaded with stack values
  302. ; eax = trashed
  303. ; interrupts disabled
  304. ;
  305. ; structures
  306. ;
  307. VTP struc
  308. zaCr3VTP dd 0 ; physical addr of page directory
  309. laGdtrVTP dd 0 ; linear addr in first meg of gdtr
  310. laIdtrVTP dd 0 ; linear addr in first meg of idtr
  311. selLdtVTP dw 0 ; selector of ldt
  312. selTrVTP dw 0 ; selector of tr
  313. ipVTP dw 0 ; 48-bit address of protect
  314. unusedVTP dw 0 ; mode entry point to xfer to
  315. csVTP dw 0 ;
  316. VTP ends
  317. ife (CurrentCpu AND 0008h) ;restore cpu type if not 386
  318. if (CurrentCpu AND 0080h)
  319. .286p
  320. else
  321. .286
  322. endif
  323. endif