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.

510 lines
14 KiB

  1. ;
  2. ; Windows-NT MVDM Japanese DOS/V Font driver
  3. ;
  4. .286
  5. include struc.inc
  6. include ntfont.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_CONF ENDS
  23. FONTCNF_SIZE equ 8
  24. CACHE_SIZE equ 260h
  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 'NTFONT$$' ; 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 ntfontList ; end of used memory: initially AtomList
  45. MaxMem dw ntfontList ; end of available memory: initially AtomList
  46. lpHeader dd 0 ; far pointer to request header
  47. org_int15_add dd 0 ; Original int15 vector
  48. ;----------------------------------------------------------------------------;
  49. ; Dispatch table for the interrupt routine command codes
  50. ;----------------------------------------------------------------------------;
  51. Dispatch:
  52. DW Init ; 0 = init driver
  53. DW Error ; 1 = Media Check (block devices only)
  54. DW Error ; 2 = build BPB (block devices only)
  55. DW Error ; 3 = I/O control read (not supported)
  56. DW Error ; 4 = read (input) from device (int 21h, 3Fh)
  57. DW Error ; 5 = nondestructive read (not supported)
  58. DW Error ; 6 = ret input status (int 21h, 4406h)
  59. DW Error ; 7 = flush device input buffer (not supportd)
  60. DW Error ; 8 = write (output) to device (int 21h, 40h)
  61. DW Error ; 9 = write with verify (== write) (21h, 40h)
  62. DW Error ; 10 = ret output status (int 21h, 4407h)
  63. DW Error ; 11 = flush output buffer (not supported)
  64. DW Error ; 12 = I/O control write (not supported)
  65. DW Success ; 13 = device open (int 21h, 3Dh)
  66. DW Success ; 14 = device close (int 21h, 3Eh)
  67. DW Error ; 15 = removable media (block devices only)
  68. DW Error ; 16 = Output until Busy (mostly for spooler)
  69. DW Error ; 17 = not used
  70. DW Error ; 18 = not used
  71. DW Error ; 19 = generic IOCTL (not supported)
  72. DW Error ; 20 = not used
  73. DW Error ; 21 = not used
  74. DW Error ; 22 = not used
  75. DW Error ; 23 = get logical device (block devices only)
  76. DW Error ; 24 = set logical device (block devices only)
  77. font_read_write_table:
  78. FONT_CONF <00h,00h,060ch,read_SBCS_06x12,0>
  79. FONT_CONF <00h,00h,0810h,read_SBCS_08x16,0>
  80. FONT_CONF <00h,00h,0813h,read_SBCS_08x19,0>
  81. FONT_CONF <00h,00h,0c18h,read_SBCS_12x24,0>
  82. FONT_CONF <00h,01h,0c0ch,read_DBCS_12x12,0>
  83. FONT_CONF <00h,01h,1010h,read_DBCS_16x16,0>
  84. FONT_CONF <00h,01h,1818h,read_DBCS_24x24,0>
  85. FONT_CONF <01h,00h,060ch,write_SBCS_06x12,0>
  86. FONT_CONF <01h,00h,0810h,write_SBCS_08x16,0>
  87. FONT_CONF <01h,00h,0813h,write_SBCS_08x19,0>
  88. FONT_CONF <01h,00h,0c18h,write_SBCS_12x24,0>
  89. FONT_CONF <01h,01h,0c0ch,write_DBCS_12x12,0>
  90. FONT_CONF <01h,01h,1010h,write_DBCS_16x16,0>
  91. FONT_CONF <01h,01h,1818h,write_DBCS_24x24,0>
  92. DW 0FFFFh
  93. ;----------------------------------------------------------------------------;
  94. ; Strategy Routine
  95. ;----------------------------------------------------------------------------;
  96. ; device driver Strategy routine, called by MS-DOS kernel with
  97. ; ES:BX = address of request header
  98. ;----------------------------------------------------------------------------;
  99. Strat PROC FAR
  100. mov word ptr cs:[lpHeader], bx ; save the address of the
  101. mov word ptr cs:[lpHeader+2], es ; request into 'lpHeader', and
  102. ret ; back to MS-DOS kernel
  103. Strat ENDP
  104. ;----------------------------------------------------------------------------;
  105. ; Intr
  106. ;----------------------------------------------------------------------------;
  107. ; Device driver interrupt routine, called by MS-DOS kernel after call to
  108. ; Strategy routine
  109. ; This routine basically calls the appropiate driver routine to handle the
  110. ; requested function.
  111. ; Routines called by Intr expect:
  112. ; ES:DI will have the address of the request header
  113. ; DS will be set to cs
  114. ; These routines should only affect ax, saving es,di,ds at least
  115. ;
  116. ; Input: NONE Output: NONE -- data is transferred through request header
  117. ;
  118. ;----------------------------------------------------------------------------;
  119. Intr PROC FAR
  120. push ds
  121. push es
  122. pusha ; save registers
  123. pushf ; save flags
  124. cld ; direction flag: go from low to high address
  125. mov si, cs ; make local data addressable
  126. mov ds, si ; by setting ds = cs
  127. les di, [lpHeader] ; ES:DI = address of req.header
  128. xor bx, bx ; erase bx
  129. mov bl,es:[di].ccode ; get BX = command code (from req.header)
  130. mov si,bx
  131. shl si,1
  132. add si,offset dispatch
  133. .IF <bx gt MaxCmd> ; check to make sure we have a valid
  134. call Error ; command code
  135. .ELSE ; else, call command-code routine,
  136. call [si] ; indexed from Dispatch table
  137. .ENDIF ; (Ebx used to allow scaling factors)
  138. or ax, fDONE ; merge Done bit into status and
  139. mov es:[di].stat,ax ; store status into request header
  140. popf ; restore registers
  141. popa ; restore flags
  142. pop es
  143. pop ds
  144. ret ; return to MS-DOS kernel
  145. Intr ENDP
  146. ;----------------------------------------------------------------------------;
  147. ; Success: When the only thing the program needs to do is set status to OK
  148. ;----------------------------------------------------------------------------;
  149. Success PROC NEAR
  150. xor ax, ax ; set status to OK
  151. ret
  152. Success ENDP
  153. ;----------------------------------------------------------------------------;
  154. ; error: set the status word to error: unknown command
  155. ;----------------------------------------------------------------------------;
  156. Error PROC NEAR
  157. mov ax, fERROR + fUNKNOWN_E ; error bit + "Unknown command" code
  158. ret
  159. Error ENDP
  160. ;----------------------------------------------------------------------------;
  161. ; Int15_dispatch:
  162. ;----------------------------------------------------------------------------;
  163. Int15_dispatch PROC FAR
  164. .IF <ah ne 50h>
  165. jmp go_org_int15
  166. .ENDIF
  167. .IF <al ne 00h> and
  168. .IF <al ne 01h>
  169. jmp go_org_int15
  170. .ENDIF
  171. .IF <bh ne 00h> and
  172. .IF <bh ne 01h>
  173. mov ah,IRREGAL_FONT_TYPE
  174. stc
  175. jmp simulate_iret
  176. .ENDIF
  177. .IF <bl ne 00h>
  178. mov ah,IRREGAL_BL
  179. stc
  180. jmp simulate_iret
  181. .ENDIF
  182. .IF <bp ne 00h>
  183. mov ah,IRREGAL_CODE_PAGE
  184. stc
  185. jmp simulate_iret
  186. .ENDIF
  187. push si
  188. mov si,offset font_read_write_table
  189. search_font_routine:
  190. .IF <cs:[si].READ_WRITE eq 0ffh>
  191. pop si
  192. jmp error_font_size
  193. .ENDIF
  194. .IF <cs:[si].READ_WRITE eq al> and
  195. .IF <cs:[si].FONT_TYPE eq bh> and
  196. .IF <cs:[si].FONT_SIZE eq dx> and
  197. .IF <cs:[si].FONT_FLAG eq FONT_ENABLE>
  198. mov ax,cs
  199. mov es,ax
  200. mov bx,cs:[si].FONT_ADDR
  201. pop si
  202. mov ah,NO_ERROR
  203. push di
  204. mov di,sp
  205. and word ptr ss:[di+6],0fffeh ; #1075 9/7/94
  206. pop di
  207. clc
  208. jmp simulate_iret
  209. .ENDIF
  210. add si,FONTCNF_SIZE
  211. jmp search_font_routine
  212. error_font_size:
  213. mov ah,IRREGAL_FONT_SIZE
  214. stc
  215. jmp simulate_iret
  216. go_org_int15:
  217. jmp cs:org_int15_add ;go to original int10
  218. Int15_dispatch ENDP
  219. read_SBCS_06x12 PROC FAR ;SBCS font read routines
  220. push bx
  221. mov bx,060ch
  222. mov ah,2
  223. BOP 43h
  224. pop bx
  225. ret
  226. read_SBCS_06x12 ENDP
  227. read_SBCS_08x16 PROC FAR
  228. push bx
  229. mov bx,0810h
  230. mov ah,2
  231. BOP 43h
  232. pop bx
  233. ret
  234. read_SBCS_08x16 ENDP
  235. read_SBCS_08x19 PROC FAR
  236. push bx
  237. mov bx,0813h
  238. mov ah,2
  239. BOP 43h
  240. pop bx
  241. ret
  242. read_SBCS_08x19 ENDP
  243. read_SBCS_12x24 PROC FAR
  244. push bx
  245. mov bx,0c18h
  246. mov ah,2
  247. BOP 43h
  248. pop bx
  249. ret
  250. read_SBCS_12x24 ENDP
  251. read_DBCS_12x12 PROC FAR ; DBCS font read routines
  252. push bx
  253. mov bx,0c0ch
  254. mov ah,2
  255. BOP 43h
  256. pop bx
  257. ret
  258. read_DBCS_12x12 ENDP
  259. read_DBCS_16x16 PROC FAR
  260. ; call search_cache
  261. ; .IF <ax eq 0>
  262. ; call get_from_cache
  263. ; mov al,0
  264. ; clc
  265. ; ret
  266. ; .ENDIF
  267. push bx
  268. mov bx,1010h
  269. mov ah,2
  270. BOP 43h
  271. pop bx
  272. ret
  273. read_DBCS_16x16 ENDP
  274. read_DBCS_24x24 PROC FAR
  275. push bx
  276. mov bx,1818h
  277. mov ah,2
  278. BOP 43h
  279. pop bx
  280. ret
  281. read_DBCS_24x24 ENDP
  282. write_SBCS_06x12 PROC FAR ; Write routines are dummy
  283. mov al,0 ; Font write execute in
  284. ret ; "font_win.sys"
  285. write_SBCS_06x12 ENDP
  286. write_SBCS_08x16 PROC FAR
  287. mov al,0
  288. ret
  289. write_SBCS_08x16 ENDP
  290. write_SBCS_08x19 PROC FAR
  291. mov al,0
  292. ret
  293. write_SBCS_08x19 ENDP
  294. write_SBCS_12x24 PROC FAR
  295. mov al,0
  296. ret
  297. write_SBCS_12x24 ENDP
  298. write_DBCS_12x12 PROC FAR
  299. mov al,0
  300. ret
  301. write_DBCS_12x12 ENDP
  302. write_DBCS_16x16 PROC FAR
  303. mov al,0
  304. ret
  305. write_DBCS_16x16 ENDP
  306. write_DBCS_24x24 PROC FAR
  307. mov al,0
  308. ret
  309. write_DBCS_24x24 ENDP
  310. ;search_cache PROC NEAR ; Cache test routine
  311. ; .IF <cx nb 8140h> and
  312. ; .IF <cx b 83a0h>
  313. ; mov ax,0
  314. ; .ELSE
  315. ; mov ax,0ffffh
  316. ; .ENDIF
  317. ; ret
  318. ;search_cache ENDP
  319. ;
  320. ;get_from_cache PROC NEAR
  321. ; push ax
  322. ; push cx
  323. ; push si
  324. ; push di
  325. ; push ds
  326. ; mov di,si
  327. ; mov si,cx
  328. ; mov ax,cs
  329. ; mov ds,ax
  330. ; sub si,8140h
  331. ; shl si,5
  332. ; add si,offset cache_area
  333. ; mov cx,32/4
  334. ; rep movsd
  335. ; pop ds
  336. ; pop di
  337. ; pop si
  338. ; pop cx
  339. ; pop ax
  340. ; ret
  341. ;get_from_cache ENDP
  342. ;
  343. ;cache_area label near
  344. ; db CACHE_SIZE*32 DUP(0)
  345. ;; DON'T EVER EVER CALL HERE!!!!!!!!!!!!!
  346. simulate_iret:
  347. FIRET
  348. ;----------------------------------------------------------------------------;
  349. ;****************************************************************************;
  350. ;----------------------------------------------------------------------------;
  351. ; ;
  352. ; BEGINNING OF SPACE TO BE USED AS DRIVER MEMORY ;
  353. ; ALL CODE AFTER ATOMLIST WILL BE ERASED BY THE DRIVER'S DATA ;
  354. ; OR BY OTHER LOADED DRIVERS ;
  355. ; ;
  356. ;----------------------------------------------------------------------------;
  357. ;****************************************************************************;
  358. ;----------------------------------------------------------------------------;
  359. ;----------------------------------------------------------------------------;
  360. ; Initialization Data and Code
  361. ; Only needed once, so after the driver is loaded and initialized it releases
  362. ; any memory that it won't use. The device allocates memory for its own use
  363. ; starting from 'ntfontList'.
  364. ;----------------------------------------------------------------------------;
  365. ntfontList label NEAR
  366. ini_msg db "Windows-NT MVDM Font Driver Version 1.00"
  367. db lf,cr,eom
  368. qbuf_size equ 64
  369. q_buf dw qbuf_size dup(0)
  370. Init PROC NEAR
  371. push ds
  372. push es
  373. pusha
  374. les di, [lpHeader] ; allow us to use the request values
  375. mov ax, MemEnd ; set ax to End of Memory relative to
  376. ; previous end of memory.
  377. mov MaxMem, ax ; store the new value in MaxMem
  378. mov es:[di].xseg,cs ; tell MS-DOS the end of our used
  379. mov es:[di].xfer,ax ; memory (the break address)
  380. ShowStr ini_msg
  381. mov cx,qbuf_size ; query support font size
  382. mov ax,cs
  383. mov es,ax
  384. mov si,offset q_buf
  385. mov ah,0
  386. BOP 43h
  387. .IF <cx ne 0>
  388. mov di,offset q_buf ; Enable font read/write routine
  389. check_font_size:
  390. mov si,offset font_read_write_table
  391. check_font_routine:
  392. .IF <[si].READ_WRITE eq 0ffh>
  393. jmp check_font_next
  394. .ENDIF
  395. mov ax,[si].FONT_SIZE
  396. xchg ah,al
  397. .IF <[di] eq ax>
  398. mov [si].FONT_FLAG,FONT_ENABLE
  399. .ENDIF
  400. add si,FONTCNF_SIZE
  401. jmp check_font_routine
  402. check_font_next:
  403. add di,2
  404. loop check_font_size
  405. .ENDIF
  406. mov ah,1 ; Load font in 32bit buffer
  407. mov al,0
  408. BOP 43h
  409. ; push es ; Get local font cache data
  410. ; mov cx,8140h
  411. ; mov ax,cs
  412. ; mov es,ax
  413. ; mov si,offset cache_area
  414. ; mov ah,2
  415. ; mov bx,1010h
  416. ;get_font_cache:
  417. ; BOP 43h
  418. ; add si,32
  419. ; inc cx
  420. ; cmp cx,83a0h
  421. ; jb get_font_cache
  422. ; pop es
  423. mov ax,VECTOR_SEG ;Get original int15 vector
  424. mov es,ax
  425. mov ax,word ptr es:[4*15h+0]
  426. mov word ptr cs:[org_int15_add+0],ax
  427. mov ax,word ptr es:[4*15h+2]
  428. mov word ptr cs:[org_int15_add+2],ax
  429. mov ax,offset cs:Int15_dispatch ;Set my int15 vector
  430. mov word ptr es:[4*15h+0],ax
  431. mov ax,cs
  432. mov word ptr es:[4*15h+2],ax
  433. popa
  434. pop es
  435. pop ds
  436. xor ax,ax
  437. ret
  438. Init ENDP
  439. TEXT ENDS
  440. END