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.

167 lines
4.1 KiB

  1. ;
  2. ; spcemm.asm,
  3. ;
  4. ; 10-Dec-1992 Jonle , adapted from em_drvr.asm from Insignia solutions
  5. ;
  6. ; This code serves as a stub device driver for emm memory manager.
  7. ; Its sole purpose is for apps to be able to identify that an emm driver is
  8. ; loaded and that LIM services are available. This code is linked into the
  9. ; device driver chain contains a strategy, interrupt and device header
  10. ;
  11. ; The driver should only be loaded if emm memory is available
  12. ; from NTVDM.
  13. ;
  14. BOP MACRO callid
  15. db 0c4h, 0c4h, callid
  16. endm
  17. ;
  18. ; Request Header, for initialization
  19. ;
  20. REQHEAD STRUC
  21. ReqLen DB ? ; Length in bytes of request block
  22. ReqUnit DB ? ; Block Device unit number
  23. ReqFunc DB ? ; Type of request
  24. ReqStat DW ? ; Status Word
  25. REQHEAD ENDS
  26. ;
  27. ; Segment definitions for ntio.sys,
  28. ;
  29. include biosseg.inc
  30. include vint.inc
  31. SpcEmmSeg segment
  32. assume cs:SpcEmmSeg,ds:nothing,es:nothing
  33. ;
  34. ; SpcEmmBeg - SpcEmmEnd
  35. ;
  36. ; Marks the resident code, anything outside of these markers
  37. ; is discarded after intialization
  38. ; 11-Dec-1992 Jonle
  39. ;
  40. public SpcEmmBeg
  41. SpcEmmBeg label byte
  42. ;
  43. ; character device Header
  44. ; must be first in the .sys file
  45. ;
  46. dd -1 ;pointer to next device driver
  47. dw 8000H ;attribute (plain character device)
  48. dw offset STRATEGY ;pointer to device "strategy" routine
  49. dw offset Interrupt ;pointer to device "interrupt" routine
  50. db 'EMMXXXX0' ;8 byte name DO NOT CHANGE THE NAME
  51. ;
  52. ; Request Header address, saved here by strategy routine
  53. ;
  54. pReqHdr dd ?
  55. ;
  56. ; Device "strategy" entry point, save request header address
  57. ;
  58. Strategy proc far
  59. mov word ptr cs:pReqHdr, bx
  60. mov word ptr cs:pReqHdr+2, es
  61. ret
  62. Strategy endp
  63. ; EmmIsr - int 67h isr
  64. ;
  65. EmmIsr: ; LIM Isr
  66. bop 67h
  67. emmiret:
  68. FIRET
  69. ; ret trap for em function 'alter page map & call'
  70. EmmRet:
  71. bop 68h
  72. jmp emmiret
  73. ;----------------------------------------------------------------------
  74. ; Device "interrupt" entry point
  75. ;----------------------------------------------------------------------
  76. Interrupt PROC FAR
  77. push es
  78. push di
  79. les di, cs:pReqHdr ; check for valid commands
  80. cmp es:[di.ReqFunc], 0ah
  81. je validcmd
  82. cmp es:[di.ReqFunc], 0
  83. je validcmd
  84. mov ax, 8003h ; we don't handle anything else
  85. jmp short irptexit
  86. validcmd:
  87. xor ax,ax
  88. irptexit:
  89. or ax, 0100h ;tell em we finished
  90. mov es:[di.ReqStat],AX ;store status in request header
  91. pop di
  92. pop es
  93. ret
  94. Interrupt ENDP
  95. public SpcEmmEnd
  96. SpcEmmEnd label byte
  97. public InitSpcEmm
  98. ;
  99. ; InitSpcEmm Initializes Spc 32 bit memory manager
  100. ; returns ax=0 for success
  101. ;
  102. ; Inputs: ds is expected seg for drv code, cs is temporary sysinitseg
  103. ; Outputs: ax zero for success
  104. ;
  105. InitSpcEmm proc near
  106. ; BOP 66 - initialize LIM memory
  107. ; pass the address of bop 68 to the em manager
  108. ; in ds:dx and to return the number of em pages in BX
  109. ;
  110. ; NOTE: All EMM options come from pif file
  111. ; There are NO command line options
  112. xor bx, bx
  113. mov dx, offset EmmRet
  114. bop 66h
  115. cmp bx, 0ffffh ;ffff means incorrect config (eg no 64K gap)
  116. je fail
  117. cmp bx, 0 ;check expanded memory is available
  118. je fail
  119. ; set up IVT for INT 67h
  120. FCLI
  121. xor ax, ax
  122. mov es, ax
  123. mov bx, offset EmmIsr
  124. mov word ptr es:[67h*4], bx
  125. mov word ptr es:[(67h*4)+2], ds
  126. FSTI
  127. ret
  128. fail:
  129. mov ax, 0ffffh
  130. ret
  131. InitSpcEmm endp
  132. SpcEmmSeg ends
  133. end