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.

509 lines
15 KiB

  1. ;
  2. ; Windows-NT MVDM Japanese DOS/V $FONT.SYS Dispatch Driver
  3. ;
  4. .286
  5. include struc.inc
  6. include font_win.inc
  7. include vint.inc
  8. NO_ERROR equ 00h
  9. IRREGAL_FONT_TYPE equ 01h
  10. IRREGAL_BL equ 02h
  11. IRREGAL_FONT_SIZE equ 03h
  12. IRREGAL_CODE_PAGE equ 04h
  13. IRREGAL_CODE_NUMBER equ 05h
  14. READ_ONLY_FONT equ 06h
  15. FONT_ENABLE equ 0001h
  16. FONT_CONF STRUC
  17. READ_WRITE DB ? ; Read=0, Write=1
  18. FONT_TYPE DB ? ; SBCS=0, DBCS=1
  19. FONT_SIZE DW ?
  20. FONT_ADDR DW ? ; Font read/write routine
  21. FONT_FLAG DW ? ; Font flag(Now Enable bit only)
  22. FONT_ORG DW ? ; Original Font write routine
  23. FONT_CONF ENDS
  24. FONTCNF_SIZE equ 10
  25. ;----------------------------------------------------------------------------;
  26. ; Code Segment
  27. ;----------------------------------------------------------------------------;
  28. TEXT segment byte public
  29. assume cs:TEXT,ds:TEXT,es:TEXT
  30. org 0 ; drivers should start at address 0000h
  31. ; this will cause a linker warning - ignore it.
  32. Header: ; device driver header
  33. DD fNEXTLINK ; link to next device driver
  34. DW fCHARDEVICE+fOPENCLOSE ; device attribute word:
  35. ; char.device+open/close
  36. DW Strat ; 'Strat' entry point
  37. DW Intr ; 'Intr' entry point
  38. DB 'NTDISP1$' ; logical device name (needs to be 8 chars)
  39. ;----------------------------------------------------------------------------;
  40. ; data variables
  41. ;----------------------------------------------------------------------------;
  42. null dw 0 ; dummy to do a quick erase of pAtomValue
  43. pAtomVal dw offset null ; pointer to value of result of atom search
  44. MemEnd dw ddddlList ; end of used memory: initially AtomList
  45. MaxMem dw ddddlList ; end of available memory: initially AtomList
  46. lpHeader dd 0 ; far pointer to request header
  47. org_int10_add dd 0 ; Original int10 vector
  48. org_int15_add dd 0 ; Original int15 vector
  49. mode12cnt dw 1 ; mode 12h call count
  50. read_offset dw 0 ; read count
  51. org_SBCS_06x12 dd 0 ; Fornt write routine address
  52. org_SBCS_08x16 dd 0
  53. org_SBCS_08x19 dd 0
  54. org_SBCS_12x24 dd 0
  55. org_DBCS_12x12 dd 0
  56. org_DBCS_16x16 dd 0
  57. org_DBCS_24x24 dd 0
  58. ;----------------------------------------------------------------------------;
  59. ; Dispatch table for the interrupt routine command codes
  60. ;----------------------------------------------------------------------------;
  61. Dispatch:
  62. DW Init ; 0 = init driver
  63. DW Error ; 1 = Media Check (block devices only)
  64. DW Error ; 2 = build BPB (block devices only)
  65. DW Error ; 3 = I/O control read (not supported)
  66. DW Read ; 4 = read (input) from device (int 21h, 3Fh)
  67. DW Error ; 5 = nondestructive read (not supported)
  68. DW Error ; 6 = ret input status (int 21h, 4406h)
  69. DW Error ; 7 = flush device input buffer (not supportd)
  70. DW Error ; 8 = write (output) to device (int 21h, 40h)
  71. DW Error ; 9 = write with verify (== write) (21h, 40h)
  72. DW Error ; 10 = ret output status (int 21h, 4407h)
  73. DW Error ; 11 = flush output buffer (not supported)
  74. DW Error ; 12 = I/O control write (not supported)
  75. DW Success ; 13 = device open (int 21h, 3Dh)
  76. DW Success ; 14 = device close (int 21h, 3Eh)
  77. DW Error ; 15 = removable media (block devices only)
  78. DW Error ; 16 = Output until Busy (mostly for spooler)
  79. DW Error ; 17 = not used
  80. DW Error ; 18 = not used
  81. DW Error ; 19 = generic IOCTL (not supported)
  82. DW Error ; 20 = not used
  83. DW Error ; 21 = not used
  84. DW Error ; 22 = not used
  85. DW Error ; 23 = get logical device (block devices only)
  86. DW Error ; 24 = set logical device (block devices only)
  87. font_write_table:
  88. FONT_CONF <01h,00h,060ch,SBCS_06x12,0,offset org_SBCS_06x12>
  89. FONT_CONF <01h,00h,0810h,SBCS_08x16,0,offset org_SBCS_08x16>
  90. FONT_CONF <01h,00h,0813h,SBCS_08x19,0,offset org_SBCS_08x19>
  91. FONT_CONF <01h,00h,0c18h,SBCS_12x24,0,offset org_SBCS_12x24>
  92. FONT_CONF <01h,01h,0c0ch,DBCS_12x12,0,offset org_DBCS_12x12>
  93. FONT_CONF <01h,01h,1010h,DBCS_16x16,0,offset org_DBCS_16x16>
  94. FONT_CONF <01h,01h,1818h,DBCS_24x24,0,offset org_DBCS_24x24>
  95. DW 0FFFFh
  96. ;----------------------------------------------------------------------------;
  97. ; Strategy Routine
  98. ;----------------------------------------------------------------------------;
  99. ; device driver Strategy routine, called by MS-DOS kernel with
  100. ; ES:BX = address of request header
  101. ;----------------------------------------------------------------------------;
  102. Strat PROC FAR
  103. mov word ptr cs:[lpHeader], bx ; save the address of the
  104. mov word ptr cs:[lpHeader+2], es ; request into 'lpHeader', and
  105. ret ; back to MS-DOS kernel
  106. Strat ENDP
  107. ;----------------------------------------------------------------------------;
  108. ; Intr
  109. ;----------------------------------------------------------------------------;
  110. ; Device driver interrupt routine, called by MS-DOS kernel after call to
  111. ; Strategy routine
  112. ; This routine basically calls the appropiate driver routine to handle the
  113. ; requested function.
  114. ; Routines called by Intr expect:
  115. ; ES:DI will have the address of the request header
  116. ; DS will be set to cs
  117. ; These routines should only affect ax, saving es,di,ds at least
  118. ;
  119. ; Input: NONE Output: NONE -- data is transferred through request header
  120. ;
  121. ;----------------------------------------------------------------------------;
  122. Intr PROC FAR
  123. pusha
  124. pushf ; save flags
  125. cld ; direction flag: go from low to high address
  126. mov si, cs ; make local data addressable
  127. mov ds, si ; by setting ds = cs
  128. les di, [lpHeader] ; ES:DI = address of req.header
  129. xor bx, bx ; erase bx
  130. mov bl,es:[di].ccode ; get BX = command code (from req.header)
  131. mov si,bx
  132. shl si,1
  133. add si,offset dispatch
  134. .IF <bx gt MaxCmd> ; check to make sure we have a valid
  135. call Error ; command code
  136. .ELSE ; else, call command-code routine,
  137. call [si] ; indexed from Dispatch table
  138. .ENDIF ; (Ebx used to allow scaling factors)
  139. or ax, fDONE ; merge Done bit into status and
  140. mov es:[di].stat,ax ; store status into request header
  141. popf ; restore registers
  142. popa ; restore flags
  143. ret ; return to MS-DOS kernel
  144. Intr ENDP
  145. ;----------------------------------------------------------------------------;
  146. ; Success: When the only thing the program needs to do is set status to OK
  147. ;----------------------------------------------------------------------------;
  148. Success PROC NEAR
  149. xor ax, ax ; set status to OK
  150. ret
  151. Success ENDP
  152. ;----------------------------------------------------------------------------;
  153. ; error: set the status word to error: unknown command
  154. ;----------------------------------------------------------------------------;
  155. Error PROC NEAR
  156. mov ax, fERROR + fUNKNOWN_E ; error bit + "Unknown command" code
  157. ret
  158. Error ENDP
  159. ;----------------------------------------------------------------------------;
  160. ; read: put org_int10_add to ddddh.sys
  161. ;----------------------------------------------------------------------------;
  162. Read PROC NEAR
  163. lds si, [lpHeader] ; put request header address in DS:SI
  164. mov cx, [si].cmd_off ; load cx with the size of buffer
  165. mov es, [si].xseg ; load es with segment of buffer
  166. mov di, [si].xfer ; load di with offset of buffer
  167. mov ax,cs
  168. mov ds,ax
  169. mov si,offset org_int10_add
  170. add si,[read_offset]
  171. mov ax,4
  172. sub ax,[read_offset]
  173. .IF <cx gt ax>
  174. mov cx,ax
  175. .ENDIF
  176. .IF <cx gt 0>
  177. xor bx,bx
  178. tfr_loop: movsb
  179. inc read_offset
  180. inc bx
  181. loop tfr_loop
  182. .ENDIF
  183. les di, [lpHeader] ; re-load the request header
  184. mov es:[di].cmd_off, bx ; store the number of chars transferred
  185. xor ax,ax
  186. ret
  187. Read ENDP
  188. ;----------------------------------------------------------------------------;
  189. ; Int10_dispatch:
  190. ;----------------------------------------------------------------------------;
  191. Int10_dispatch PROC FAR
  192. .IF <ax eq 0012h>
  193. .IF <cs:[mode12cnt] ne 0>
  194. mov al,03h ; Use mode 3
  195. dec cs:[mode12cnt]
  196. jmp simulate_iret ; Ignore mode 12
  197. .ENDIF
  198. .ENDIF
  199. IFNDEF _X86_
  200. ;support mouse_video_io DEC-J Dec. 20 1993 TakeS
  201. ;; updated Mar. 24 1994 TakeS
  202. ;; BUG in using IME. change also mouse_video_io()
  203. ; .IF< ah ge 0f0h > and
  204. ; .IF< ah be 0fah >
  205. ;;; mvdm subsystem error with NT4.0
  206. ;;; BOP 0beh ;call mouse_video_io()
  207. ; .ENDIF
  208. ENDIF ; !_X86_
  209. jmp cs:org_int10_add ;go to original int10
  210. Int10_dispatch ENDP
  211. ;----------------------------------------------------------------------------;
  212. ; Int15_dispatch:
  213. ;----------------------------------------------------------------------------;
  214. Int15_dispatch PROC FAR
  215. .IF <ah ne 50h>
  216. jmp go_org_int15
  217. .ENDIF
  218. .IF <al ne 01h>
  219. jmp go_org_int15
  220. .ENDIF
  221. .IF <bh ne 00h> and
  222. .IF <bh ne 01h>
  223. mov ah,IRREGAL_FONT_TYPE
  224. stc
  225. ret 2
  226. .ENDIF
  227. .IF <bl ne 00h>
  228. mov ah,IRREGAL_BL
  229. stc
  230. ret 2
  231. .ENDIF
  232. .IF <bp ne 00h>
  233. mov ah,IRREGAL_CODE_PAGE
  234. stc
  235. ret 2
  236. .ENDIF
  237. push si
  238. mov si,offset font_write_table
  239. search_font_routine:
  240. .IF <cs:[si].READ_WRITE eq 0ffh>
  241. pop si
  242. jmp error_font_size
  243. .ENDIF
  244. .IF <cs:[si].READ_WRITE eq al> and
  245. .IF <cs:[si].FONT_TYPE eq bh> and
  246. .IF <cs:[si].FONT_SIZE eq dx> and
  247. .IF <cs:[si].FONT_FLAG eq FONT_ENABLE>
  248. mov ax,cs
  249. mov es,ax
  250. mov bx,cs:[si].FONT_ADDR
  251. pop si
  252. mov ah,NO_ERROR
  253. clc
  254. ret 2
  255. .ENDIF
  256. add si,FONTCNF_SIZE
  257. jmp search_font_routine
  258. error_font_size:
  259. mov ah,IRREGAL_FONT_SIZE
  260. stc
  261. ret 2
  262. go_org_int15:
  263. jmp cs:org_int15_add ;go to original int15
  264. Int15_dispatch ENDP
  265. SBCS_06x12 PROC FAR ; SBCS font write routines
  266. call cs:[org_SBCS_06x12]
  267. .IF <al eq 0>
  268. push bx
  269. mov bx,060ch
  270. mov ah,3
  271. BOP 43h
  272. pop bx
  273. .ENDIF
  274. ret
  275. SBCS_06x12 ENDP
  276. SBCS_08x16 PROC FAR
  277. call cs:[org_SBCS_08x16]
  278. .IF <al eq 0>
  279. push bx
  280. mov bx,0810h
  281. mov ah,3
  282. BOP 43h
  283. pop bx
  284. .ENDIF
  285. ret
  286. SBCS_08x16 ENDP
  287. SBCS_08x19 PROC FAR
  288. call cs:[org_SBCS_08x19]
  289. .IF <al eq 0>
  290. push bx
  291. mov bx,0813h
  292. mov ah,3
  293. BOP 43h
  294. pop bx
  295. .ENDIF
  296. ret
  297. SBCS_08x19 ENDP
  298. SBCS_12x24 PROC FAR
  299. call cs:[org_SBCS_12x24]
  300. .IF <al eq 0>
  301. push bx
  302. mov bx,0c18h
  303. mov ah,3
  304. BOP 43h
  305. pop bx
  306. .ENDIF
  307. ret
  308. SBCS_12x24 ENDP
  309. DBCS_12x12 PROC FAR ; DBCS font write routines
  310. call cs:[org_DBCS_12x12]
  311. .IF <al eq 0>
  312. push bx
  313. mov bx,0c0ch
  314. mov ah,3
  315. BOP 43h
  316. pop bx
  317. .ENDIF
  318. ret
  319. DBCS_12x12 ENDP
  320. DBCS_16x16 PROC FAR
  321. call cs:[org_DBCS_16x16]
  322. .IF <al eq 0>
  323. push bx
  324. mov bx,1010h
  325. mov ah,3
  326. BOP 43h
  327. pop bx
  328. .ENDIF
  329. ret
  330. DBCS_16x16 ENDP
  331. DBCS_24x24 PROC FAR
  332. call cs:[org_DBCS_24x24]
  333. .IF <al eq 0>
  334. push bx
  335. mov bx,1818h
  336. mov ah,3
  337. BOP 43h
  338. pop bx
  339. .ENDIF
  340. ret
  341. DBCS_24x24 ENDP
  342. ; DON'T EVER EVER CALL HERE!!!!!!!!!
  343. simulate_iret:
  344. IRET
  345. ;----------------------------------------------------------------------------;
  346. ;****************************************************************************;
  347. ;----------------------------------------------------------------------------;
  348. ; ;
  349. ; BEGINNING OF SPACE TO BE USED AS DRIVER MEMORY ;
  350. ; ALL CODE AFTER ATOMLIST WILL BE ERASED BY THE DRIVER'S DATA ;
  351. ; OR BY OTHER LOADED DRIVERS ;
  352. ; ;
  353. ;----------------------------------------------------------------------------;
  354. ;****************************************************************************;
  355. ;----------------------------------------------------------------------------;
  356. ;----------------------------------------------------------------------------;
  357. ; Initialization Data and Code
  358. ; Only needed once, so after the driver is loaded and initialized it releases
  359. ; any memory that it won't use. The device allocates memory for its own use
  360. ; starting from 'ddddlList'.
  361. ;----------------------------------------------------------------------------;
  362. ddddlList label NEAR
  363. ifndef KOREA
  364. ini_msg db "Windows-NT MVDM Font Dispatch Driver Version 1.00"
  365. db lf,cr,eom
  366. endif
  367. Init PROC NEAR
  368. les di, [lpHeader] ; allow us to use the request values
  369. mov ax, MemEnd ; set ax to End of Memory relative to
  370. ; previous end of memory.
  371. mov MaxMem, ax ; store the new value in MaxMem
  372. mov es:[di].xseg,cs ; tell MS-DOS the end of our used
  373. mov es:[di].xfer,ax ; memory (the break address)
  374. push es
  375. push ds
  376. pusha
  377. mov ax,0003h ; Clear display
  378. int 10h
  379. ifndef KOREA
  380. ShowStr ini_msg
  381. endif
  382. mov ax,6300h ; Get DBCS Vector address
  383. int 21h
  384. mov ax,[si]
  385. .IF <ax eq 0>
  386. mov cs:[mode12cnt],0
  387. .ENDIF
  388. mov ah,10h ; Tell NTVDM DOS DBCS Vector address
  389. BOP 43h
  390. mov si,offset font_write_table
  391. check_font_routine:
  392. .IF <cs:[si].READ_WRITE eq 0ffh>
  393. jmp check_font_end
  394. .ENDIF
  395. mov ah,50h
  396. mov al,cs:[si].READ_WRITE
  397. mov bh,cs:[si].FONT_TYPE
  398. xor bl,bl
  399. mov dx,cs:[si].FONT_SIZE
  400. mov bp,0
  401. int 15h
  402. .IF <nc> and
  403. .IF <ah eq 0>
  404. mov cs:[si].FONT_FLAG,FONT_ENABLE
  405. mov di,cs:[si].FONT_ORG
  406. mov ax,es
  407. mov word ptr cs:[di],bx
  408. mov word ptr cs:[di+2],ax
  409. .ENDIF
  410. add si,FONTCNF_SIZE
  411. jmp check_font_routine
  412. check_font_end:
  413. mov ax,VECTOR_SEG ;Get original int10 vector
  414. mov es,ax
  415. mov ax,word ptr es:[4*10h+0]
  416. mov word ptr cs:[org_int10_add+0],ax
  417. mov ax,word ptr es:[4*10h+2]
  418. mov word ptr cs:[org_int10_add+2],ax
  419. mov ax,offset cs:Int10_dispatch ;Set my int10 vector
  420. mov word ptr es:[4*10h+0],ax
  421. mov ax,cs
  422. mov word ptr es:[4*10h+2],ax
  423. mov ax,word ptr es:[4*15h+0]
  424. mov word ptr cs:[org_int15_add+0],ax
  425. mov ax,word ptr es:[4*15h+2]
  426. mov word ptr cs:[org_int15_add+2],ax
  427. mov ax,offset cs:Int15_dispatch ;Set my int15 vector
  428. mov word ptr es:[4*15h+0],ax
  429. mov ax,cs
  430. mov word ptr es:[4*15h+2],ax
  431. popa
  432. pop ds
  433. pop es
  434. xor ax,ax
  435. ret
  436. Init ENDP
  437. TEXT ENDS
  438. END