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.

2393 lines
72 KiB

  1. ;******************************************************************************
  2. ;
  3. ; Copyright (c) 1992 Insignia Solutions Ltd.
  4. ;
  5. ; Program:
  6. ;
  7. ; Purpose:
  8. ;
  9. ; Version:
  10. ;
  11. ; Author: Dave Bartlett
  12. ; Modifications:
  13. ; 1) Tim June 92. Changes to get DEC PC working. Take over
  14. ; IVT entries 6h (illegal instruction), 11h (equipment
  15. ; check), 16h (keyboard BIOS), 17h (printer),
  16. ; 42h (default video).
  17. ; 2) Tim June 92. Changed version to 1.11
  18. ; 3) Tim June 92. Avoid accesses to host ROM as far as
  19. ; possible. Take over lots of IVT entries and continue to
  20. ; point them at this driver.
  21. ; 4) Tim July 92. Version num 1.12, put pseudo ROM stuff back in.
  22. ; 5) Tim July 92. v 1.13, use SoftPC video BIOS when windowed.
  23. ;
  24. ; 6) 12-Sep-1992 Jonle, Merged with ntio.sys
  25. ; cleanup usage of assumes espcially with ES
  26. ; optimized loading of IVT
  27. ; other general cleanup
  28. ;
  29. ; This obj module is intially loaded in a temporary memory location
  30. ; along with ntio.sys. Ntio.sys will copy the resident code (marked by
  31. ; SpcKbdBeg, SpcKbdEnd) into the permanent memory location which resides
  32. ; just below the normal device drivers loaded by config.sys.
  33. ;
  34. ; The nonresident intialization code is run with CS= temp seg
  35. ; and DS= final seg.
  36. ;
  37. ;******************************************************************************
  38. .286
  39. ;================================================================
  40. ; Macros and includes
  41. ;================================================================
  42. include vint.inc
  43. include bop.inc
  44. include syscall.inc
  45. include msequ.inc
  46. BIOS_CPU_QUIT equ 0FEh
  47. BIOS_KB_INT equ 9
  48. BIOS_INT15 equ 15h
  49. BIOS_PRINTER_IO equ 17h
  50. UNEXP_BOP equ 2
  51. RTC_WAIT_FLAG equ 0a0h ; offset of rtc_wait_flag in bios data seg
  52. VERSIONID equ 0BEEFh
  53. FULLSCREEN equ 1
  54. STREAM_IO equ 2
  55. MAX_VIDEO_FUNC equ 1Ch
  56. GET_FONT_FUNC equ 11h
  57. VID_MODECHANGE equ 0
  58. VID_VESA_BIOS equ 4fh
  59. MOUSE_LIGHT_PEN equ 4
  60. MIN_MOUSE_FUNC equ 0F0H
  61. MAX_MOUSE_FUNC equ 0F7H
  62. XTRA_MOUSE_FUNC equ 0FAH
  63. MS_VIDEO_STRING equ 13FFH
  64. MOUSE_VID_BOP equ 0BEh
  65. EGA_VIDEO_BOP equ 42h
  66. PRT_NOTBUSY equ 80h
  67. PRT_NUM_PORTS equ 3
  68. PRT_STATE_READY equ 0
  69. PRT_IRQ equ 10h
  70. PRT_LPT_BUSY equ 1
  71. TIMER_LOW equ 6ch
  72. TIMER_HIGH equ 6eh
  73. TIMER_OVFL equ 70h
  74. MOTOR_STATUS equ 3fh
  75. MOTOR_COUNT equ 40h
  76. ; Keyboard buf ptrs
  77. BUFFER_HEAD equ 1ah
  78. BUFFER_TAIL equ 1ch
  79. BUFFER_START equ 80h
  80. BUFFER_END equ 82h
  81. ; kb_flag and LED bits
  82. KB_FLAG equ 17h
  83. CAPS_STATE equ 40h
  84. NUM_STATE equ 20h
  85. SCROLL_STATE equ 10h
  86. KB_FLAG_1 equ 18h
  87. KB_FLAG_2 equ 97h
  88. KB_LEDS equ 07h ; Keyboard LED state bits
  89. KB_PR_LED equ 40h ; Mode indicator update
  90. KB_FLAG_3 equ 96h
  91. KBF3_ALT_CTRL equ 0ch
  92. ;..............................................keyboard constants
  93. ; bits in kb_flag
  94. RIGHT_SHIFT = 1
  95. LEFT_SHIFT = 2
  96. CTL_SHIFT = 4
  97. ALT_SHIFT = 8
  98. ; bit in kb_flag_1
  99. HOLD_STATE = 8
  100. SCROLL_SHIFT = 10h
  101. NUM_SHIFT = 20h
  102. CAPS_SHIFT = 40h
  103. INS_SHIFT = 80h
  104. SYS_SHIFT = 04h
  105. ; IBM scan codes
  106. CTL_KEY = 29
  107. LEFT_SHIFTKEY = 42
  108. RIGHT_SHIFTKEY = 54
  109. ALT_KEY = 56
  110. CAPS_KEY = 58
  111. NUM_KEY = 69
  112. SCROLL_KEY = 70
  113. INS_KEY = 82
  114. ;
  115. ; Segment definitions for ntio.sys,
  116. ;
  117. include biosseg.inc
  118. SpcKbdSeg segment
  119. assume cs:SpcKbdSeg,ds:nothing,es:nothing
  120. ;
  121. ; SpcKbdBeg - SpcKbdEnd
  122. ;
  123. ; Marks the resident code, anything outside of these markers
  124. ; is discarded after intialization
  125. ; 13-Sep-1992 Jonle
  126. ;
  127. public SpcKbdBeg
  128. SpcKbdBeg label byte
  129. ;
  130. ; Reduced data table for Video 7 modes 0 and 2.
  131. ; This table is extracted from our video7 ROM. Only text modes are
  132. ; required, mode 0 and 1 are identical as are modes 2 and 3.
  133. ;
  134. ega_parm_setup:
  135. ;--40x25--
  136. DB 40,24,16 ; width,height,character height
  137. DW 00800H ; Page size in bytes
  138. DB 008H, 003H, 000H, 002H ; Sequencer Parameters
  139. DB 067H ;Misc Reg
  140. ; CRTC Parameters
  141. DB 02dH, 027H, 028H, 090H, 02bH
  142. DB 0a0H, 0bfH, 01fH, 000H, 04fH
  143. DB 00dH, 00eH, 000H, 000H, 000H
  144. DB 000H, 09cH, 0aeH, 08fH, 014H
  145. DB 01fH, 096H, 0b9H, 0a3H, 0ffH
  146. ; Attribute parameters
  147. DB 000H, 001H, 002H, 003H, 004H
  148. DB 005H, 014H, 007H, 038H, 039H
  149. DB 03aH, 03bH, 03cH, 03dH, 03eH
  150. DB 03fH, 00cH, 000H, 00fH, 008H
  151. ; Graph parameters
  152. DB 000H, 000H, 000H, 000H, 000H
  153. DB 010H, 00eH, 000H, 0ffH
  154. ;--80x25--
  155. DB 80,24,16 ; width,height,character height
  156. DW 01000H ; Page size in bytes
  157. DB 000H, 003H, 000H, 002H ; Sequencer Parameters
  158. DB 067H ;Misc Reg
  159. ; CRTC Parameters
  160. DB 05fH, 04fH, 050H, 082H, 055H
  161. DB 081H, 0bfH, 01fH, 000H, 04fH
  162. DB 00dH, 00eH, 000H, 000H, 000H
  163. DB 000H, 09cH, 08eH, 08fH, 028H
  164. DB 01fH, 096H, 0b9H, 0a3H, 0ffH
  165. ; Attribute parameters
  166. DB 000H, 001H, 002H, 003H, 004H
  167. DB 005H, 014H, 007H, 038H, 039H
  168. DB 03aH, 03bH, 03cH, 03dH, 03eH
  169. DB 03fH, 00cH, 000H, 00fH, 008H
  170. ; Graph parameters
  171. DB 000H, 000H, 000H, 000H, 000H
  172. DB 010H, 00eH, 000H, 0ffH
  173. ;--80x25 mono--
  174. DB 80,24,16 ; width,height,character height
  175. DW 01000H ; Page size in bytes
  176. DB 000H, 003H, 000H, 003H ; Sequencer Parameters
  177. DB 0a6H ;Misc Reg
  178. ; CRTC Parameters
  179. DB 05fH, 04fH, 050H, 082H, 055H
  180. DB 081H, 0bfH, 01fH, 000H, 04dH
  181. DB 00bH, 00cH, 000H, 000H, 000H
  182. DB 000H, 083H, 0a5H, 05dH, 028H
  183. DB 00dH, 063H, 0baH, 0a3H, 0ffH
  184. ; Attribute parameters
  185. DB 000H, 008H, 008H, 008H, 008H
  186. DB 008H, 008H, 008H, 010H, 018H
  187. DB 018H, 018H, 018H, 018H, 018H
  188. DB 018H, 00eH, 000H, 00fH, 008H
  189. ; Graph parameters
  190. DB 000H, 000H, 000H, 000H, 000H
  191. DB 010H, 00aH, 000H, 0ffH
  192. ; Mode b (font load)
  193. DB 5eh,32H,8 ; width,height,character height
  194. DW 09700H ; Page size in bytes
  195. DB 001H, 00fH, 000H, 006H ; Sequencer Parameters
  196. DB 0e7H ;Misc Reg
  197. ; CRTC Parameters
  198. DB 06dH, 05dH, 05eH, 090H, 061H
  199. DB 08fH, 0bfH, 01fH, 000H, 040H
  200. DB 000H, 000H, 000H, 000H, 000H
  201. DB 000H, 0a2H, 08eH, 099H, 02fH
  202. DB 000H, 0a1H, 0b9H, 0e3H, 0ffH
  203. ; Attribute parameters
  204. DB 000H, 001H, 002H, 003H, 004H
  205. DB 005H, 014H, 007H, 038H, 039H
  206. DB 03aH, 03bH, 03cH, 03dH, 03eH
  207. DB 03fH, 001H, 000H, 00fH, 000H
  208. ; Graph parameters
  209. DB 000H, 000H, 000H, 000H, 000H
  210. DB 000H, 005H, 00fH, 0ffH
  211. ;--350 scanline 40x25
  212. DB 40,24,14 ; width,height,character height
  213. DW 00800H ; Page size in bytes
  214. DB 009H, 003H, 000H, 002H ; Sequencer Parameters
  215. DB 0a3H ;Misc Reg
  216. ; CRTC Parameters
  217. DB 02dH, 027H, 028H, 090H, 02bH
  218. DB 0a0H, 0bfH, 01fH, 000H, 04dH
  219. DB 00bH, 00cH, 000H, 000H, 000H
  220. DB 000H, 083H, 0a5H, 05dH, 014H
  221. DB 01fH, 063H, 0baH, 0a3H, 0ffH
  222. ; Attribute parameters
  223. DB 000H, 001H, 002H, 003H, 004H
  224. DB 005H, 014H, 007H, 038H, 039H
  225. DB 03aH, 03bH, 03cH, 03dH, 03eH
  226. DB 03fH, 008H, 000H, 00fH, 000H
  227. ; Graph parameters
  228. DB 000H, 000H, 000H, 000H, 000H
  229. DB 010H, 00eH, 000H, 0ffH
  230. ;--350 scanline 80x25
  231. DB 80,24,14 ; width,height,character height
  232. DW 01000H ; Page size in bytes
  233. DB 001H, 003H, 000H, 002H ; Sequencer Parameters
  234. DB 0a3H ;Misc Reg
  235. ; CRTC Parameters
  236. DB 05fH, 04fH, 050H, 082H, 055H
  237. DB 081H, 0bfH, 01fH, 000H, 04dH
  238. DB 00bH, 00cH, 000H, 000H, 000H
  239. DB 000H, 083H, 0a5H, 05dH, 028H
  240. DB 01fH, 063H, 0baH, 0a3H, 0ffH
  241. ; Attribute parameters
  242. DB 000H, 001H, 002H, 003H, 004H
  243. DB 005H, 014H, 007H, 038H, 039H
  244. DB 03aH, 03bH, 03cH, 03dH, 03eH
  245. DB 03fH, 008H, 000H, 00fH, 000H
  246. ; Graph parameters
  247. DB 000H, 000H, 000H, 000H, 000H
  248. DB 010H, 00eH, 000H, 0ffH
  249. ;
  250. ; End of baby mode table.
  251. ;
  252. ; Table of VGA bios 'capability' info for func 1b to point at.
  253. vga_1b_table db 07fh, 060h, 00fh, 000h, 000h, 000h, 000h, 007h
  254. db 002h, 008h, 0ffh, 00eh, 000h, 000h, 03fh, 000h
  255. ; Configuration table for INT 15 Func C0 to point at.
  256. conf_table dw 008h
  257. ;; db 0fch, 002h, 000h, 070h, 000h, 000h, 000h, 000h
  258. db 0fch, 002h, 074h, 070h, 000h, 000h, 000h, 000h
  259. PRT_BUF_SIZE equ 255
  260. ;================================================================
  261. ; Printer status table
  262. ;================================================================
  263. prt_status db PRT_NUM_PORTS dup (?)
  264. prt_state db PRT_NUM_PORTS dup (?)
  265. prt_control db PRT_NUM_PORTS dup (?)
  266. prt_lpt_stat db PRT_NUM_PORTS dup (?)
  267. cur_buf_size dw PRT_BUF_SIZE
  268. prt_data_buf db PRT_BUF_SIZE dup (?) ; buffer in the 16bit side for perf.
  269. cur_lpt db 0ffh ; buffer is not being used
  270. cur_count dw ?
  271. cur_busy db 0 ; initially not busy
  272. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  273. ; Keyboard tables
  274. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  275. shift_keys: ;K6
  276. DB INS_KEY,CAPS_KEY,NUM_KEY,SCROLL_KEY
  277. DB ALT_KEY,CTL_KEY,LEFT_SHIFTKEY,RIGHT_SHIFTKEY
  278. shift_masks: ;K7
  279. DB INS_SHIFT,CAPS_SHIFT,NUM_SHIFT,SCROLL_SHIFT
  280. DB ALT_SHIFT,CTL_SHIFT,LEFT_SHIFT,RIGHT_SHIFT
  281. ctl_n_table: ;K8
  282. DB 27, -1, 0, -1, -1, -1, 30, -1
  283. DB -1, -1, -1, 31, -1, 127, 148, 17
  284. DB 23, 5, 18, 20, 25, 21, 9, 15
  285. DB 16, 27, 29, 10, -1, 1, 19, 4
  286. DB 6, 7, 8, 10, 11, 12, -1, -1
  287. DB -1, -1, 28, 26, 24, 3, 22, 2
  288. DB 14, 13, -1, -1, -1, -1, 150, -1
  289. DB ' ', -1
  290. ctl_f_table: ;K9
  291. DB 94, 95, 96, 97, 98, 99, 100, 101
  292. DB 102, 103, -1, -1, 119, 141, 132, 142
  293. DB 115, 143, 116, 144, 117, 145, 118, 146
  294. DB 147, -1, -1, -1, 137, 138
  295. lowercase:
  296. DB 27, '1', '2', '3', '4', '5', '6', '7', '8', '9' ;K10
  297. DB '0', '-', '=', 8, 9, 'q', 'w', 'e', 'r', 't'
  298. DB 'y', 'u', 'i', 'o', 'p', '[', ']', 13, -1, 'a'
  299. DB 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 39
  300. DB 96, -1, 92, 'z', 'x', 'c', 'v', 'b', 'n', 'm'
  301. DB ',', '.', '/', -1, '*', -1, ' ', -1
  302. lc_tbl_scan:
  303. DB 59, 60, 61, 62, 63, 64, 65, 66, 67, 68
  304. DB -1, -1
  305. base_case:
  306. DB 71, 72, 73, -1, 75, -1, 77, -1, 79, 80
  307. DB 81, 82, 83, -1, -1, 92, 133, 134 ;K15
  308. uppercase: ;K11
  309. DB 27, '!', '@', '#', '$', '%', '^', '&', '*', '('
  310. DB ')', '_', '+', 8, 0, 'Q', 'W', 'E', 'R', 'T'
  311. DB 'Y', 'U', 'I', 'O', 'P', '{', '}', 13, -1, 'A'
  312. DB 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"'
  313. DB 126, -1, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M'
  314. DB '<', '>', '?', -1, 0, -1, ' ', -1;
  315. ucase_scan:
  316. DB 84, 85, 86, 87, 88, 89, 90, 91, 92, 93
  317. DB -1, -1
  318. numb_state:
  319. DB '7', '8', '9', '-', '4', '5', '6', '+', '1', '2' ;K14
  320. DB '3', '0', '.' , -1, -1, 124, 135, 136
  321. alt_table:
  322. DB 82, 79, 80, 81, 75, 76, 77, 71, 72, 73 ;K30
  323. DB 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
  324. DB 30, 31, 32, 33, 34, 35, 36, 37, 38, 44
  325. DB 45, 46, 47, 48, 49, 50
  326. ;================================================================
  327. ; Keyboard break caller
  328. ;================================================================
  329. keyboard_break_caller:
  330. int 1bh ;keyboard break
  331. bop %BIOS_CPU_QUIT
  332. ;================================================================
  333. ; Print screen caller
  334. ;================================================================
  335. print_screen_caller:
  336. int 5h ;print screen
  337. bop %BIOS_CPU_QUIT
  338. ;================================================================
  339. ; Int 15 caller
  340. ;================================================================
  341. ; Tim modified int 15 caller. Copied from BIOS2. It gives CPU
  342. ; a chance to take other interrupts. Suspect the extra jumps are
  343. ; now harmless with IRET hooking.
  344. ;int15h_caller:
  345. ;int 15h
  346. ;bop %BIOS_CPU_QUIT
  347. int15h_caller:
  348. int 15h ; Cassette I/O.
  349. jmp k1
  350. k1: jmp k2
  351. k2: jmp k3
  352. k3: BOP %BIOS_CPU_QUIT
  353. ;================================================================
  354. ; Unexpected interrupt handler
  355. ;================================================================
  356. unexp_int:
  357. bop %UNEXP_BOP
  358. jmp iret_com
  359. ;================================================================
  360. ;Int 13 caller
  361. ;================================================================
  362. int13h_caller:
  363. int 13h
  364. bop %BIOS_CPU_QUIT
  365. ifdef JAPAN
  366. ;================================================================
  367. ;int 16 caller
  368. ;================================================================
  369. int16h_caller:
  370. int 16h
  371. bop %BIOS_CPU_QUIT
  372. endif ; JAPAN
  373. ;================================================================
  374. ; New interrupt 9h handler
  375. ;================================================================
  376. int09h_vector:
  377. push ax
  378. xor ax, ax
  379. bop %BIOS_KB_INT
  380. pop ax
  381. jmp iret_com
  382. ; CarbonCopy traces int 9 in order to gain control
  383. ; over where the kbd data is coming from (the physical kbd
  384. ; or the serial link) The kbd_inb instruction must be visible
  385. ; in the 16 bit code via int 1 tracing, for CarbonCopy to work.
  386. ; Softpc assumes the exact location of the first nop
  387. ; relative to the bop just above.
  388. nop
  389. nop
  390. in al, 60h ; keyba_io_buffers
  391. nop
  392. nop
  393. BOP %BIOS_CPU_QUIT
  394. ;=================================================================
  395. ; IRET hooks bop table
  396. ;=================================================================
  397. IRET_HOOK = 5dh ;IRET hook BOP
  398. iret_bop_table:
  399. bop %IRET_HOOK
  400. db 0
  401. iret_end_first_entry:
  402. bop %IRET_HOOK
  403. db 1
  404. bop %IRET_HOOK
  405. db 2
  406. bop %IRET_HOOK
  407. db 3
  408. bop %IRET_HOOK
  409. db 4
  410. bop %IRET_HOOK
  411. db 5
  412. bop %IRET_HOOK
  413. db 6
  414. bop %IRET_HOOK
  415. db 7
  416. bop %IRET_HOOK
  417. db 8
  418. bop %IRET_HOOK
  419. db 9
  420. bop %IRET_HOOK
  421. db 10
  422. bop %IRET_HOOK
  423. db 11
  424. bop %IRET_HOOK
  425. db 12
  426. bop %IRET_HOOK
  427. db 13
  428. bop %IRET_HOOK
  429. db 14
  430. bop %IRET_HOOK
  431. db 15
  432. ;================================================================
  433. ; New interrupt 13h handler
  434. ;================================================================
  435. int13h_vector:
  436. cmp dl,80h ; 0 - 7f are floppy commands
  437. jb int40h_vector
  438. cmp ah,2 ; we fail the direct access commands
  439. jb diskcmd ; read/write/seek/verify/format
  440. cmp ah,5 ; but let others go through (disk tables etc)
  441. jbe faildisk
  442. cmp ah,0ah
  443. jb diskcmd
  444. cmp ah,0ch
  445. ja diskcmd
  446. faildisk:
  447. push ax
  448. mov ax,1 ; direct access error panel
  449. bop 59h
  450. pop ax ; preserve AL for safety sake
  451. mov ah, 80h ; error - timeout
  452. stc
  453. retf 2
  454. diskcmd:
  455. bop 13h
  456. retf 2
  457. ;================================================================
  458. ; New interrupt 40h handler
  459. ;================================================================
  460. int40h_vector:
  461. ; cmp ah,2 ; we fail the direct access commands
  462. ; jb flopcmd ; read/write/seek/verify/format
  463. ; cmp ah,5 ; but let others go through (disk tables etc)
  464. ; jbe failflop
  465. ; cmp ah,0ah
  466. ; jb flopcmd
  467. ; cmp ah,0ch
  468. ; ja flopcmd
  469. failflop:
  470. ; push ax
  471. ; mov ax,0 ; direct access error panel
  472. ; bop 59h
  473. ; pop ax
  474. ; mov ah, 80h ; error - timeout
  475. ; stc
  476. ; retf 2
  477. flopcmd:
  478. bop 40h
  479. retf 2
  480. ;; waiting for diskette interrupt
  481. wait_int:
  482. push ds
  483. push ax
  484. push cx
  485. mov ax, 40h
  486. mov ds, ax
  487. mov cx, 10h
  488. wait_int_loop:
  489. mov al, [3Eh]
  490. test al, 80h
  491. loopz wait_int_loop
  492. pop cx
  493. pop ax
  494. pop ds
  495. bop %BIOS_CPU_QUIT
  496. ;; floppy parameters table
  497. floppy_table label byte
  498. DB 01 ;; 360KB in 360KB
  499. DW OFFSET md_tbl1
  500. DB 82H ;; 360KB in 1,2MB
  501. DW OFFSET md_tbl2
  502. DB 02 ;; 1.2MB in 1.2MB
  503. DW OFFSET md_tbl3
  504. DB 03 ;; 720KB in 720KB
  505. DW OFFSET md_tbl4
  506. DB 84H ;; 720KB in 1.44MB
  507. DW OFFSET md_tbl5
  508. DB 04 ;; 1.44MB in 1.44MB
  509. DW OFFSET md_tbl6
  510. DB 85h ;; 720KB in 2.88MB
  511. DW OFFSET md_tbl7
  512. DB 85h ;; 1.44MB in 2.88MB
  513. DW OFFSET md_tbl8
  514. DB 5 ;; 2.88MB in 2.88MB
  515. DW OFFSET md_tbl9
  516. md_tbl1:
  517. ; MEDIA = 40 track low data rate; DRIVE = 40 track low data rate
  518. DB 0DFh ; 1st specify byte
  519. DB 2 ; 2nd specify byte
  520. DB 25H ; motor off wait time
  521. DB 2 ; ie 2 bytes/sector
  522. DB 9 ; sectors/track
  523. DB 02Ah ; gap length
  524. DB 0FFh ; data length
  525. DB 050h ; gap length for format
  526. DB 0F6h ; fill byte for format
  527. DB 15 ; head settle time/ms
  528. DB 8 ; ie 1s motor start time
  529. DB 39 ; maximum track number
  530. DB 80H ; transfer rate
  531. md_tbl2:
  532. ; MEDIA = 40 track low data rate; DRIVE = 80 track high data rate
  533. DB 0DFh ; 1st specify byte
  534. DB 2 ; 2nd specify byte
  535. DB 25H ; motor off wait time
  536. DB 2 ; ie 2 bytes/sector
  537. DB 9 ; sectors/track
  538. DB 02Ah ; gap length
  539. DB 0FFh ; data length
  540. DB 050h ; gap length for format
  541. DB 0F6h ; fill byte for format
  542. DB 15 ; head settle time/ms
  543. DB 8 ; ie 1s motor start time
  544. DB 39 ; maximum track number
  545. DB 40H ; transfer rate
  546. md_tbl3:
  547. ; MEDIA = 80 track high data rate; DRIVE = 80 track high data rate
  548. DB 0DFh ; 1st specify byte
  549. DB 2 ; 2nd specify byte
  550. DB 25H ; motor off wait time
  551. DB 2 ; ie 2 bytes/sector
  552. DB 15 ; sectors/track
  553. DB 01Bh ; gap length
  554. DB 0FFh ; data length
  555. DB 054h ; gap length for format
  556. DB 0F6h ; fill byte for format
  557. DB 15 ; head settle time/ms
  558. DB 8 ; ie 1s motor start time
  559. DB 79 ; maximum track number
  560. DB 0 ; transfer rate
  561. md_tbl4:
  562. ; MEDIA = 80 track low data rate; DRIVE = 80 track low data rate
  563. DB 0DFh ; 1st specify byte
  564. DB 2 ; 2nd specify byte
  565. DB 25H ; motor off wait time
  566. DB 2 ; ie 2 bytes/sector
  567. DB 9 ; sectors/track
  568. DB 02Ah ; gap length
  569. DB 0FFh ; data length
  570. DB 050h ; gap length for format
  571. DB 0F6h ; fill byte for format
  572. DB 15 ; head settle time/ms
  573. DB 8 ; ie 1s motor start ime
  574. DB 79 ; maximum track number
  575. DB 80H ; transfer rate
  576. md_tbl5:
  577. ; MEDIA = 80 track low data rate; DRIVE = 80 track high data rate
  578. DB 0DFh ; 1st specify byte
  579. DB 2 ; 2nd specify byte
  580. DB 25H ; motor off wait time
  581. DB 2 ; ie 2 bytes/sector
  582. DB 9 ; sectors/track
  583. DB 02Ah ; gap length
  584. DB 0FFh ; data length
  585. DB 050h ; gap length for format
  586. DB 0F6h ; fill byte for format
  587. DB 15 ; head settle time/ms
  588. DB 8 ; ie 1s motor start time
  589. DB 79 ; maximum track number
  590. DB 80H ; transfer rate
  591. md_tbl6:
  592. ; MEDIA = 80 track high data rate; DRIVE = 80 track high data rate
  593. DB 0AFh ; 1st specify byte
  594. DB 2 ; 2nd specify byte
  595. DB 25H ; motor off wait time
  596. DB 2 ; ie 2 bytes/sector
  597. DB 18 ; sectors/track
  598. DB 01Bh ; gap length
  599. DB 0FFh ; data length
  600. DB 06Ch ; gap length for format
  601. DB 0F6h ; fill byte for format
  602. DB 15 ; head settle time/ms
  603. DB 8 ; ie 1s motor start time
  604. DB 79 ; maximum track number
  605. DB 0 ; transfer rate
  606. md_tbl7:
  607. ;MEDIA = 80 tracks, 9 sectors/track; DRIVE = 80 tracks, 36 sectotrs per track
  608. DB 0E1h ; 1st specify byte
  609. DB 2 ; 2nd specify byte
  610. DB 25H ; motor off wait time
  611. DB 2 ; ie 2 bytes/sector
  612. DB 9 ; sectors/track
  613. DB 02Ah ; gap length
  614. DB 0FFh ; data length
  615. DB 050h ; gap length for format
  616. DB 0F6h ; fill byte for format
  617. DB 15 ; head settle time/ms
  618. DB 8 ; ie 1s motor start ime
  619. DB 79 ; maximum track number
  620. DB 80H ; transfer rate
  621. md_tbl8:
  622. ;MEDIA = 80 tracks, 18 sectors/track; DRIVE = 80 tracks, 36 sectotrs per track
  623. DB 0D1h ; 1st specify byte
  624. DB 2 ; 2nd specify byte
  625. DB 25H ; motor off wait time
  626. DB 2 ; ie 2 bytes/sector
  627. DB 18 ; sectors/track
  628. DB 01Bh ; gap length
  629. DB 0FFh ; data length
  630. DB 065h ; gap length for format
  631. DB 0F6h ; fill byte for format
  632. DB 15 ; head settle time/ms
  633. DB 8 ; ie 1s motor start time
  634. DB 79 ; maximum track number
  635. DB 0 ; transfer rate
  636. md_tbl9:
  637. ;MEDIA = 80 tracks, 36 sectors/track; DRIVE = 80 tracks, 36 sectotrs per track
  638. DB 0A1h ; 1st specify byte
  639. DB 2 ; 2nd specify byte
  640. DB 25H ; motor off wait time
  641. DB 2 ; ie 2 bytes/sector
  642. DB 36 ; sectors/track
  643. DB 038h ; gap length
  644. DB 0FFh ; data length
  645. DB 053h ; gap length for format
  646. DB 0F6h ; fill byte for format
  647. DB 15 ; head settle time/ms
  648. DB 8 ; ie 1s motor start time
  649. DB 79 ; maximum track number
  650. DB 0C0h ; transfer rate
  651. floppy_table_len equ $ - floppy_table
  652. bios_floppy_table label byte
  653. DB 0DFh ; 1st specify byte
  654. DB 2 ; 2nd specify byte
  655. DB 25H ; motor off wait time
  656. DB 2 ; ie 2 bytes/sector
  657. DB 18 ; sectors/track
  658. DB 01Bh ; gap length
  659. DB 0FFh ; data length
  660. DB 054h ; gap length for format
  661. DB 0F6h ; fill byte for format
  662. DB 15 ; head settle time/ms
  663. DB 8 ; ie 1s motor start time
  664. bios_floppy_table_len equ $ - bios_floppy_table
  665. ;===============================================================
  666. ; New interrupt 15h handler
  667. ;================================================================
  668. ; Tim, modified this to be like a "normal" SoftPC ROM.
  669. ; Copied from BIOS2, but rtc_wait_flag is now referenced via ES not
  670. ; DS.
  671. ;
  672. ; 17-Sep-1992 Jonle , ES ref to rtc_wait was change from assume ES
  673. ; to seg overides to prevent accidents in assuming.
  674. ;
  675. ;int15h_vector:
  676. ;bop %BIOS_INT15
  677. ;iret
  678. ;;;;;;;;;STF hide this int15h_vector:
  679. int15h_vector:
  680. call DOSTI
  681. cmp ah, 88h
  682. je lbl1
  683. cmp ah, 91h
  684. je lbl1
  685. cmp ah, 86h
  686. je lbl2
  687. BOP 15h
  688. RETF 2
  689. lbl1: BOP 15h
  690. jmp iret_com
  691. lbl2: BOP 15h
  692. jc lbl5
  693. push cx
  694. push dx
  695. push es ; Tim, save ES not DS.
  696. mov ax, 40h ; point es to biosdata
  697. mov es, ax
  698. xchg dx, cx
  699. lbl3:
  700. test byte ptr es:[RTC_WAIT_FLAG], 080h ; check for end of wait
  701. loopz lbl3 ; dec timeout delay
  702. jnz lbl4 ; exit if wait ended
  703. sub dx, 1 ; dec error timeout counter
  704. jnc lbl3 ; loop till counters timeout
  705. lbl4:
  706. mov byte ptr es:[RTC_WAIT_FLAG], 0 ; set function inactive
  707. pop es ; Kipper, restore ES not DS.
  708. pop dx
  709. pop cx
  710. clc
  711. lbl5:
  712. RETF 2
  713. ;=================================================================
  714. ; Regular SoftPC int 17 handler (especially important for DEC PCs)
  715. ;=================================================================
  716. int17h_vector:
  717. ;
  718. ; Do a get status purely in 16-bit code but only if the printer is ready and
  719. ;we don't have interrupts turned on. Otherwise we must do a BOP and let 32-bit
  720. ;code handle it.
  721. ;
  722. push si
  723. push dx
  724. push ax
  725. mov ax, dx ; dx = adapter no., ensure it is no
  726. xor dx, dx ; greater than PRT_NUM_PORTS.
  727. mov si, PRT_NUM_PORTS
  728. div si
  729. mov si, dx
  730. pop ax
  731. cmp ah, 2
  732. je do_prt_status
  733. or ah,ah
  734. je do_write
  735. jmp do_print_bop
  736. do_prt_status:
  737. cmp byte ptr cs:[si + prt_state], PRT_STATE_READY
  738. jne do_print_bop
  739. test byte ptr cs:[si + prt_control], PRT_IRQ
  740. je get_status
  741. jmp short do_print_bop
  742. do_write:
  743. cmp byte ptr cs:[cur_lpt],0ffh
  744. jne check_lpti
  745. mov byte ptr cs:[cur_lpt],dl
  746. mov word ptr cs:[cur_count],0
  747. mov byte ptr cs:[cur_busy],0ffh
  748. jmp short do_print_bop
  749. check_lpti:
  750. cmp byte ptr cs:[cur_lpt],dl
  751. je buf_ok
  752. push si
  753. xor si,si
  754. bop %BIOS_PRINTER_IO
  755. pop si
  756. mov word ptr cs:[cur_count],0
  757. mov byte ptr cs:[cur_lpt],dl
  758. jmp short do_print_bop
  759. buf_ok:
  760. mov dx,word ptr cs:[cur_count]
  761. mov si,dx
  762. mov byte ptr cs:[si + prt_data_buf],al
  763. inc word ptr cs:[cur_count]
  764. cmp word ptr cs:[cur_count],PRT_BUF_SIZE
  765. jne no_flushing
  766. xor si,si ; sub-function 0 for this bop
  767. bop %BIOS_PRINTER_IO
  768. test ah,08h
  769. jz flush_ok
  770. dec word ptr cs:[cur_count]
  771. jmp short int17h_end
  772. flush_ok:
  773. mov word ptr cs:[cur_count],0
  774. no_flushing:
  775. mov ah,90h
  776. jmp short int17h_end
  777. ;
  778. ; Risc int17 entry point, provided to cope with si subfunctions
  779. ;
  780. int17h_RiscVector:
  781. push si
  782. push dx
  783. do_print_bop:
  784. mov si,0ffffh ; sub-function 1
  785. bop %BIOS_PRINTER_IO
  786. jmp int17h_end
  787. get_status:
  788. test byte ptr cs:[si + prt_lpt_stat], PRT_LPT_BUSY
  789. jne noset
  790. or byte ptr cs:[si + prt_status], PRT_NOTBUSY
  791. noset:
  792. mov ah, cs:[si + prt_status]
  793. and ah, 0f8h
  794. xor ah, 48h
  795. int17h_end:
  796. pop dx
  797. pop si
  798. iret_com:
  799. FIRET
  800. ;=================================================================
  801. ; Pseudo-ROM vectuz, copied from BIOS2.ASM
  802. ;=================================================================
  803. dummy_vector: ; Copied from BIOS2.ASM
  804. jmp iret_com
  805. illegal_bop_vector:
  806. bop 72h
  807. jmp iret_com
  808. intD11_vector:
  809. bop 72h
  810. jmp iret_com
  811. int05h_vector: ; Print Screen func. copied from BIOS2.ASM
  812. call DOSTI
  813. PUSH AX
  814. PUSH BX
  815. PUSH CX
  816. PUSH DX
  817. PUSH DS
  818. ;::::::::::::::::::::::::::::::::: Setup DS to point to BIOS data area
  819. MOV AX,40H
  820. MOV DS,AX
  821. ;::::::::::::::::::::::::::::::: Print screen already in progress ????
  822. CMP BYTE PTR DS:[100H],1
  823. JE end_print
  824. ;::::::::::::::::::::::::::::::::::::::::::::::: Set print screen busy
  825. MOV BYTE PTR DS:[100h],1
  826. ;::::: fetch no rows, columns, curr page from bios data area
  827. mov ch, byte ptr ds:[4ah] ; cols
  828. mov cl, byte ptr ds:[84h] ; rows
  829. mov bh, byte ptr ds:[62h] ; curr page num
  830. ;::::::::::::::::::::::::::::::::::: Print line feed / carriage return
  831. CALL print_crlf
  832. ;:::::::::::::::::::::::::::::::::::::::::: Get current cursor postion
  833. PUSH CX
  834. MOV AH,3
  835. INT 10H
  836. POP CX
  837. ;::::::::::::::::::::::::::::::::::::::::::::::::: Save cursor postion
  838. PUSH DX ;save current cursor postion
  839. XOR DH,DH ;current row being processed
  840. start_print_col:
  841. XOR DL,DL ;current column being processed
  842. ;::::::::::::::::::::::::::::::::::::::::::::::: Start printing screen
  843. start_print_row:
  844. ;:::::::::::::::::::::::::::::::::::::::::::::::::: Set cursor postion
  845. PUSH DX ;save current row,column
  846. MOV AH,2
  847. INT 10H
  848. ;::::::::::::::::::::::::::::::::::: Read character at current postion
  849. MOV AH,8
  850. INT 10H
  851. ;::::::::::::::::::::::::::::::::::::::::::::::::::::: Print character
  852. OR al,al
  853. JNZ print_char
  854. MOV AL,20H
  855. print_char:
  856. XOR DX,DX
  857. XOR AH,AH
  858. INT 17H
  859. ;:::::::::::::::::::::::::::::::::::::::::::: Check for printer errors
  860. POP DX ;Restore current row,column
  861. AND AH,25H
  862. JZ cont2
  863. MOV BYTE PTR DS:[100H],0FFH
  864. JMP short exit_print
  865. ;::::::::::::::::::::::::::::::::::::::::::: Move to mext print column
  866. cont2:
  867. INC DL ;Inc current column
  868. CMP DL,CH ;Current col compared to no. of cols
  869. JB start_print_row
  870. ;:::::::::::::::::::::::::::::::::::::::::: End of column, print CR/LF
  871. CALL print_crlf
  872. ;:::::::::::::::::::::::::::::::::::::::::::::::::: More rows to print
  873. INC DH ;Inc current row
  874. CMP DH,CL ;Current row compared to no. of rows
  875. JBE start_print_col
  876. MOV BYTE PTR DS:[0100H],0
  877. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Exit print
  878. exit_print:
  879. ;:::::::::::::::::::::::::::::::::::::; Restore orginal cursor postion
  880. POP DX
  881. MOV AH,2
  882. INT 10H
  883. ;:::::::::::::::::::::::::::::::::::::::::::::::::::: Tidy up and exit
  884. end_print:
  885. POP DS
  886. POP DX
  887. POP CX
  888. POP BX
  889. POP AX
  890. jmp iret_com
  891. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Print CR/LF
  892. print_crlf:
  893. PUSH DX
  894. XOR DX,DX
  895. MOV AX,0DH
  896. INT 17H
  897. XOR DX,DX
  898. MOV AX,0AH
  899. INT 17H
  900. POP DX
  901. RET
  902. ; End of int05_vector (print screen).
  903. int06h_vector:
  904. bop 06h
  905. jmp iret_com
  906. ; IVT 7 is set to unexpected interrupt.
  907. int08h_vector:
  908. ; The usual int8 handler modified for optimum performance.
  909. ; - stays in 16 bit code (no BOP)
  910. ; - keeps interrupts off when not needed
  911. ; - calls int 1c directly
  912. ;
  913. call DOCLI ; make sure interrupts stay off until iret
  914. push es
  915. push ds ; save some registers
  916. push ax
  917. push dx
  918. mov ax, 40h ; set ds to bios data area
  919. mov ds, ax
  920. xor ax, ax
  921. mov es, ax ; set es to IVT seg for i1c callout
  922. inc word ptr ds:[TIMER_LOW] ; inc time counters
  923. jnz i8v1
  924. inc word ptr ds:[TIMER_HIGH]
  925. i8v1:
  926. cmp word ptr ds:[TIMER_HIGH], 018h ; check for 24 hours, wrap point
  927. jnz i8v2
  928. cmp word ptr ds:[TIMER_LOW], 0b0h
  929. jnz i8v2
  930. mov word ptr ds:[TIMER_HIGH], ax ; 24 hour wrap, set OVFL bit
  931. mov word ptr ds:[TIMER_LOW], ax
  932. mov byte ptr ds:[TIMER_OVFL], 1
  933. or al, 8 ; set Overflow bit for fake flags
  934. ;--- ; skip floppy motor stuff
  935. i8v2: ; handle the floppy motor stuff
  936. push ax
  937. dec byte ptr ds:[MOTOR_COUNT]
  938. jnz i8v3
  939. and byte ptr ds:[MOTOR_STATUS], 0f0h
  940. mov al, 0ch
  941. mov dx, 03f2h ; costly outb happens 1/256 timer tics...
  942. out dx, al
  943. i8v3:
  944. pop ax
  945. ; if a dpmi app has interrupts hooked in PM, then we have to do a real
  946. ; INT 1C so that the dpmi host has a chance to switch to PM
  947. test word ptr ds:[FIXED_NTVDMSTATE_REL40], VDM_INTS_HOOKED_IN_PM
  948. jnz i8v4
  949. ; call int1c user routine directly
  950. lahf ; get lobyte of flags for fake flags
  951. xchg ah,al
  952. push ax ; put fake flags on the stack
  953. call dword ptr es:[1ch*4] ; do it!
  954. jmp i8v5
  955. i8v4:
  956. int 1ch ; do real int1C
  957. i8v5:
  958. call DOCLI ; make sure interrupts stay off until iret
  959. mov al, 20h ; send eoi
  960. out 20h, al
  961. pop dx ;restore the stack
  962. pop ax
  963. pop ds
  964. pop es
  965. jmp iret_com
  966. int0e_vector:
  967. bop 0eh
  968. jmp iret_com
  969. DOCLI:
  970. FCLI
  971. ret
  972. DOSTI:
  973. FSTI
  974. ret
  975. ;-----------------------------------------------------------------------
  976. ;function: sw_video_io
  977. ;
  978. ;description:
  979. ; int10 ah=0e and ax=13ffh handler for "well-behaved" applications which
  980. ; do their video i/o through dos/file or WriteTTy call
  981. ; Since the output won't go to the video hardware, it was called software
  982. ; video.
  983. ;
  984. ;input: whatever to int10
  985. ;
  986. ;output: carry flag = 1 if we have done the function
  987. ; carry flag = 0 if we have not done anything, the caller has
  988. ; to carry on the operation
  989. ;
  990. ;modified: none
  991. ;-----------------------------------------------------------------------
  992. sw_temp db 0
  993. SW_VIDEO_BUFFER_SEGMENT = 0B000h
  994. SW_VIDEO_BUFFER_SIZE = 82 * 2
  995. ;; make sure we are in word boundary because they are accessed from
  996. ;; 32bits code
  997. EVEN
  998. sw_video_dirty_count dw 0
  999. sw_video_busy dw 0
  1000. sw_video_io proc near
  1001. ;stop 32bits code from accessing shared variables.
  1002. ;We do not bop to 32bits at all unless our buffer doesn't have
  1003. ;enough space for the new data. The 32 bits code would refresh
  1004. ;our buffer contents to the console periodically.
  1005. ;
  1006. inc cs:sw_video_busy ;indicate we are busy
  1007. ;this is the basic sync mechanism
  1008. ;with 32bits stream_io update code
  1009. cmp ax,13ffh ;secret write string?
  1010. jne sw_check_write_tty ;no, check for write tty
  1011. cmp cx, 1
  1012. je sw_video_string_1
  1013. push si
  1014. mov si, SW_VIDEO_BUFFER_SIZE
  1015. sub si, cs:sw_video_dirty_count
  1016. cmp cx, si
  1017. jae sw_video_overflow
  1018. push di
  1019. push cx
  1020. push dx
  1021. push ds
  1022. push es
  1023. mov dx, es ;ds:di ptr to the string
  1024. mov ds, dx
  1025. mov dx, SW_VIDEO_BUFFER_SEGMENT
  1026. mov es, dx
  1027. mov dx, cx
  1028. mov si, di
  1029. mov di, cs:sw_video_dirty_count
  1030. cld ;ds:si ptr to the string
  1031. shr cx, 1 ;cs has the byte count
  1032. rep movsw
  1033. adc cl, 0
  1034. rep movsb
  1035. add cs:sw_video_dirty_count, dx
  1036. pop es
  1037. pop ds
  1038. pop dx
  1039. pop cx
  1040. pop di
  1041. pop si
  1042. stc ;tell the caller we've done it
  1043. dec cs:sw_video_busy
  1044. ret
  1045. sw_video_string_1:
  1046. push ax
  1047. mov ah, 0eh
  1048. mov al, es:[di]
  1049. call sw_video_write_tty
  1050. pop ax
  1051. ret
  1052. ;; this should be a rare case as we have a big buffer
  1053. ;; we go directly to 32bits and we will take care of it there
  1054. sw_video_overflow:
  1055. pop si
  1056. dec cs:sw_video_busy
  1057. bop EGA_VIDEO_BOP ;not free buffer space
  1058. stc ;do it on 32bits
  1059. ret
  1060. sw_check_write_tty:
  1061. cmp ah, 0eh
  1062. jne sw_mode_change ;we have to enable video h/w
  1063. sw_video_write_tty:
  1064. push si
  1065. mov si, cs:sw_video_dirty_count ;the current count(index)
  1066. cmp si, SW_VIDEO_BUFFER_SIZE
  1067. jae sw_video_overflow
  1068. push ds
  1069. mov si, SW_VIDEO_BUFFER_SEGMENT
  1070. mov ds, si
  1071. mov si, cs:sw_video_dirty_count
  1072. mov ds:[si], al ;put it in the buffer
  1073. inc si
  1074. mov cs:sw_video_dirty_count, si ;new count, new index
  1075. pop ds
  1076. pop si
  1077. sw_video_done:
  1078. stc
  1079. dec cs:sw_video_busy
  1080. ret
  1081. sw_mode_change:
  1082. push ax
  1083. mov ax, 013FEh ;tell 32bits to initialize
  1084. bop EGA_VIDEO_BOP ;video hardware for us
  1085. pop ax
  1086. clc ;tell caller we didn't do any
  1087. dec cs:sw_video_busy
  1088. ret
  1089. sw_video_io endp
  1090. ;
  1091. ; Tim August 92. Video BIOS grabber.
  1092. ; Call SPC BIOS when in windowed mode and the host BIOS when in full-screen.
  1093. ; Controled by value of 'use_host_int10'.
  1094. ; Try to limit bops by validating calling values. Mouse has to get first shot
  1095. ; and then video bios.
  1096. ;
  1097. use_host_int10 db 01h ; native/softpc bios flag
  1098. changing_mode db 01h ; delay handshake if in bios mode change
  1099. PUBLIC int10h_vector
  1100. int10h_vector:
  1101. cmp use_host_int10, STREAM_IO
  1102. jne hw_video_io
  1103. call sw_video_io
  1104. jc viddone
  1105. hw_video_io:
  1106. cmp use_host_int10, FULLSCREEN
  1107. je nativebios
  1108. cmp ah,VID_MODECHANGE ; mode change??
  1109. je modechange
  1110. cmp ah,MAX_VIDEO_FUNC ; range check
  1111. ja mousecheck ; not a vid func but mouse has higher
  1112. cmp ah,MOUSE_LIGHT_PEN ; light pen special case
  1113. je mousebios
  1114. spcbios:
  1115. bop EGA_VIDEO_BOP ; regular windowed Int 10
  1116. jmp viddone
  1117. mousecheck:
  1118. cmp ah,VID_VESA_BIOS ; Is VESA bios call?
  1119. jne short @f ; ne, no, proceed normally
  1120. bop MOUSE_VID_BOP ; yes, will go fullscreen
  1121. jmp jmp_native ; and handle the int10 by native bios
  1122. @@:
  1123. cmp ah,MIN_MOUSE_FUNC ; range check mouse fn f0-f7 + fa.
  1124. jb badvid
  1125. cmp ah,MAX_MOUSE_FUNC
  1126. jbe mousebios
  1127. cmp ah,XTRA_MOUSE_FUNC
  1128. jne badvid
  1129. mousebios: ; call softpc mouse video entrypoint
  1130. bop MOUSE_VID_BOP
  1131. jmp viddone
  1132. modechange: ; windowed modechange. Mouse gets a look
  1133. mov changing_mode,1 ; then softpc video bios. If gfx mode then
  1134. bop MOUSE_VID_BOP ; will go fullscreen
  1135. ;;;nop
  1136. ;;;nop ; nops aid debugging
  1137. ;;;bop EGA_VIDEO_BOP ; will go fullscreen here
  1138. nop
  1139. nop
  1140. push ax ; save video mode which may have top bit set
  1141. and ax,7fh
  1142. cmp al,3
  1143. jbe endmode ; if graphics mode, repeat modechange to setup
  1144. cmp al,7 ; video card, else fall through
  1145. je endmode
  1146. pop ax
  1147. jmp nativebios
  1148. endmode:
  1149. pop ax
  1150. mov changing_mode,0 ; Clear 'mode changing' flag.
  1151. viddone:
  1152. jmp iret_com
  1153. badvid: ; unrecognised video func
  1154. stc
  1155. jmp viddone
  1156. nativebios:
  1157. mov changing_mode,0 ; Clear 'mode changing' flag.
  1158. cmp ax,MS_VIDEO_STRING ; ensure not MS special video string fn
  1159. je ms_wrt_string
  1160. cmp ah,MIN_MOUSE_FUNC ; could be a mouse call
  1161. jb chk_mse_vid
  1162. cmp ah,MAX_MOUSE_FUNC ; range check mouse fn f0-f7 + fa.
  1163. jbe mousebios
  1164. cmp ah,XTRA_MOUSE_FUNC
  1165. je mousebios
  1166. jmp jmp_native ; probably bad func but...
  1167. chk_mse_vid:
  1168. cmp ah,MOUSE_LIGHT_PEN ; mouse handles light pen
  1169. je mousebios
  1170. cmp ah,VID_MODECHANGE
  1171. jne chk_font_change
  1172. bop MOUSE_VID_BOP ; mouse wants first sniff at mode changes
  1173. jmp jmp_native ; then fall through
  1174. chk_font_change:
  1175. cmp ah,GET_FONT_FUNC
  1176. jne jmp_native
  1177. bop MOUSE_VID_BOP ; select mouse buffer for new no. of lines
  1178. ; then fall through
  1179. jmp_native:
  1180. db 0EAh ; far jump
  1181. host_int10 dd ? ; to native int 10 vector
  1182. ms_wrt_string:
  1183. push si
  1184. push di
  1185. push bp
  1186. go_loop1:
  1187. mov dx,46h ; looks a good value for flags
  1188. push dx ; make an iret frame
  1189. push cs
  1190. mov bx, offset go_cont
  1191. push bx
  1192. mov bx,7 ; set foreground color
  1193. mov ah,0eh ; set command to write a character
  1194. mov al,es:[di] ; get char
  1195. inc di
  1196. jmp jmp_native ; make far jmp to int 10 vector
  1197. go_cont:
  1198. loop go_loop1 ;repeat until all through
  1199. pop bp
  1200. pop di
  1201. pop si
  1202. mov ax,1 ; return success
  1203. goto_viddone:
  1204. jmp viddone
  1205. ;
  1206. ; int 42 - 'old' video bios entry point. Use same windowed/fullscreen
  1207. ; redirection as Int 10 above.
  1208. ;
  1209. int42h_vector:
  1210. cmp use_host_int10, STREAM_IO
  1211. jne hw_video_io_42
  1212. call sw_video_io
  1213. jc goto_viddone
  1214. hw_video_io_42:
  1215. cmp use_host_int10, FULLSCREEN
  1216. jz maybe_host_42_bios
  1217. bop 10h ; old video bop
  1218. jmp iret_com
  1219. ; If it's the special BIOS print string function, don't call the
  1220. ; host video BIOS cos it won't know what we are talking about.
  1221. ; It's only in our video BIOS.
  1222. maybe_host_42_bios:
  1223. cmp AH, 013h
  1224. jnz gogo_host_42_bios
  1225. cmp AL, 0ffh
  1226. jz ms_wrt_string ; reuse path from Int 10
  1227. gogo_host_42_bios:
  1228. db 0EAh ; far jump
  1229. host_int42 dd ? ; to native int 42 vector
  1230. int10h_caller:
  1231. int 10h ; Re-entrant video entry point.
  1232. bop 0feh
  1233. int11h_vector: ; Equipment check.
  1234. bop 11h
  1235. jmp iret_com
  1236. int12h_vector: ; Get memory size, copied from BIOS2.ASM
  1237. bop 12h
  1238. jmp iret_com
  1239. ; IVT 13 is floppy io, grabbed above to fake error status.
  1240. int14h_vector: ; RS-232 serial comms, copied from BIOS2
  1241. bop 14h
  1242. jmp iret_com
  1243. ; Int 15 cassette io, is done above.
  1244. ; Idle indicators- All word sized, and dword aligned
  1245. ; Int 16 keyboard vector
  1246. align 4
  1247. public Icounter,CharsPerTick,MinTicks
  1248. Icounter dw 0
  1249. dw 0
  1250. CharsPerTick dw 0
  1251. dw 0
  1252. MinTicks dw 50
  1253. dw 0
  1254. int16h_vector:
  1255. push ds
  1256. push bx
  1257. mov bx, 40h ; bios data adressable
  1258. mov ds, bx
  1259. cmp ah, 10h
  1260. call DOCLI ; make sure interrupts are off
  1261. jb i16vStdFns
  1262. jmp i16vExtFns
  1263. ; The dispatch code must preserve the jz,dec,dec pattern
  1264. ; to return the same ah value as is returned by the
  1265. ; standard bios (0 for supported unless otherwise documented
  1266. ; and nonzero for unsupported). This is because some apps look
  1267. ; at the ret value of ah even tho it is a side effect of the
  1268. ; original dispatch code in the rom bios.
  1269. i16vStdFns:
  1270. or ah, ah
  1271. jz i16v00h ; read key, wait
  1272. dec ah
  1273. jz i16v01h ; read key no wait
  1274. dec ah
  1275. jz i16v02h ; get shift state
  1276. dec ah
  1277. jz i16viret ; we don't support ah=3, set kbd rate
  1278. dec ah
  1279. jz i16viret ; undefined function
  1280. dec ah
  1281. jz i16v05h ; push char into kbd buffer
  1282. ; the rest are undefined\unsupported
  1283. ; normal iret exit
  1284. i16viret:
  1285. pop bx
  1286. pop ds
  1287. jmp iret_com
  1288. ; return shift state in al
  1289. i16v02h:
  1290. mov al, ds:[KB_FLAG]
  1291. jmp i16viret
  1292. i16v05h:
  1293. push si
  1294. mov bx, word ptr ds:[BUFFER_TAIL]
  1295. mov si, bx
  1296. call IncrBuffPtr
  1297. cmp bx, word ptr ds:[BUFFER_HEAD]
  1298. je i16v05h1
  1299. mov word ptr ds:[si], cx
  1300. mov word ptr ds:[BUFFER_TAIL], bx
  1301. mov al, 0
  1302. pop si
  1303. jmp i16viret
  1304. i16v05h1:
  1305. mov al, 1
  1306. pop si
  1307. jmp i16viret
  1308. ; read a character, wait if none available
  1309. i16v00h:
  1310. mov bx, word ptr ds:[BUFFER_HEAD]
  1311. cmp bx, word ptr ds:[BUFFER_TAIL]
  1312. jne i16v00h1
  1313. call DOSTI
  1314. mov ax, 09002h
  1315. int 15h ; wait device
  1316. i16v00h0:
  1317. call DOCLI
  1318. mov bx, word ptr ds:[BUFFER_HEAD]
  1319. cmp bx, word ptr ds:[BUFFER_TAIL]
  1320. i16v00h1:
  1321. call UpdateLed
  1322. jne i16v00h2
  1323. call IdlePoll
  1324. jmp i16v00h0
  1325. i16v00h2: ; translate.....
  1326. mov ax, [bx]
  1327. call IncrBuffPtr
  1328. mov word ptr ds:[BUFFER_HEAD], bx
  1329. call TranslateStd
  1330. jc i16v00h0
  1331. call IdleInit
  1332. jmp i16viret
  1333. ; read a character, nowait if none available
  1334. i16v01h:
  1335. mov bx, word ptr ds:[BUFFER_HEAD] ;;maybe should turn IF on ??
  1336. cmp bx, word ptr ds:[BUFFER_TAIL]
  1337. mov ax, [bx]
  1338. call UpdateLed
  1339. je i16vretf1
  1340. call IdleInit
  1341. call TranslateStd
  1342. call DOSTI
  1343. jnc i16vretf5 ; got a key, all done!
  1344. call IncrBuffPtr ; throw away key
  1345. mov word ptr ds:[BUFFER_HEAD], bx
  1346. jmp i16v01h ; go for the next one
  1347. ; ExtKbd read a character, nowait if none available
  1348. i16v11h:
  1349. mov bx, word ptr ds:[BUFFER_HEAD] ;;maybe should turn IF on ??
  1350. cmp bx, word ptr ds:[BUFFER_TAIL]
  1351. mov ax, [bx]
  1352. call UpdateLed
  1353. je i16vretf1 ; common retf stuff for nowait
  1354. call IdleInit
  1355. call TranslateExt
  1356. call DOSTI
  1357. jmp i16vretf5
  1358. ; retf2 exit preserving flags
  1359. i16vretf1:
  1360. call DOSTI
  1361. push ax
  1362. lahf
  1363. push ax
  1364. mov ax, cs:Icounter
  1365. cmp ax, cs:MinTicks
  1366. jb i16vretf2
  1367. mov ah, 1 ; polling kbd, idle now
  1368. BOP 16h
  1369. jmp i16vretf4
  1370. i16vretf2:
  1371. inc cs:CharsPerTick
  1372. i16vretf4:
  1373. pop ax
  1374. sahf
  1375. pop ax
  1376. i16vretf5:
  1377. pop bx
  1378. pop ds
  1379. retf 2
  1380. i16vExtFns:
  1381. sub ah, 10h
  1382. jz i16v10h ; extended read key, wait
  1383. dec ah
  1384. jz i16v11h ; extended read key, nowait
  1385. dec ah
  1386. jz i16v12h ; extended shift status
  1387. jmp i16viret ; undefined
  1388. ; return extended shift state
  1389. i16v12h:
  1390. mov al, ds:[KB_FLAG_1]
  1391. mov ah, al
  1392. and al, SYS_SHIFT
  1393. push cx
  1394. mov cl, 5
  1395. shl al, cl
  1396. pop cx
  1397. and ah, NOT (SYS_SHIFT+HOLD_STATE+INS_SHIFT)
  1398. or al, ah
  1399. mov ah, ds:[KB_FLAG_3]
  1400. and ah, KBF3_ALT_CTRL
  1401. or ah, al
  1402. mov al, ds:[KB_FLAG]
  1403. jmp i16viret
  1404. ; ExtKbd read a character, wait if none available
  1405. i16v10h:
  1406. mov bx, word ptr ds:[BUFFER_HEAD]
  1407. cmp bx, word ptr ds:[BUFFER_TAIL]
  1408. jne i16v10h1
  1409. call DOSTI
  1410. mov ax, 09002h
  1411. int 15h ; wait device
  1412. i16v10h0:
  1413. call DOCLI
  1414. mov bx, word ptr ds:[BUFFER_HEAD]
  1415. cmp bx, word ptr ds:[BUFFER_TAIL]
  1416. i16v10h1:
  1417. call UpdateLed
  1418. jne i16v10h2
  1419. call IdlePoll
  1420. jmp i16v10h0
  1421. i16v10h2: ; translate.....
  1422. mov ax, [bx]
  1423. call IncrBuffPtr
  1424. mov word ptr ds:[BUFFER_HEAD], bx
  1425. call TranslateExt
  1426. call IdleInit
  1427. jmp i16viret
  1428. ; IdlePoll - Spins waiting for a key, doing idle callouts as needed
  1429. ; flags trashed, all registers preserved
  1430. ; interrupts are left on upon exit
  1431. ;
  1432. IdlePoll proc near
  1433. push ax
  1434. call DOSTI
  1435. mov ah, 2 ; Idle_waitio
  1436. BOP 16h
  1437. IPoll1:
  1438. mov bx, word ptr ds:[BUFFER_HEAD]
  1439. cmp bx, word ptr ds:[BUFFER_TAIL] ; interrupts are off only
  1440. jne IPoll3 ; safe to peek for change
  1441. mov ax, cs:Icounter
  1442. cmp ax, cs:MinTicks
  1443. jae IPoll2
  1444. inc cs:CharsPerTick
  1445. jmp IPoll1
  1446. IPoll2:
  1447. mov ah, 1 ; idle now
  1448. BOP 16h
  1449. IPoll3:
  1450. pop ax
  1451. ret
  1452. IdlePoll endp
  1453. ; IdleInit - reinits the idle indicators, dups functionality
  1454. ; of IDLE_init()
  1455. ;
  1456. IdleInit proc near
  1457. mov cs:Icounter, 0
  1458. mov cs:CharsPerTick, 0
  1459. ret
  1460. IdleInit endp
  1461. ; TranslateExt - Retrieves and translates next scan code
  1462. ; pair for extended kbd
  1463. ;
  1464. ; input: ax - raw scan code pair
  1465. ; output: ax - translated scan code pair
  1466. ;
  1467. ; all other flags,registers preserved
  1468. TranslateExt proc near
  1469. push bx
  1470. push ax
  1471. lahf
  1472. mov bx, ax
  1473. pop ax
  1474. push bx
  1475. cmp al, 0f0h
  1476. jne TExt1
  1477. or ah, ah
  1478. jz TExt1
  1479. xor al, al
  1480. TExt1:
  1481. mov bx, ax
  1482. pop ax
  1483. sahf
  1484. mov ax, bx
  1485. pop bx
  1486. ret
  1487. TranslateExt endp
  1488. ; TranslateStd - Retrieves and translates next scan code
  1489. ; pair for standard kbd
  1490. ;
  1491. ; input: ax - raw scan code pair
  1492. ; output: ax - translated scan code pair
  1493. ; returns carry for throw away
  1494. ; all other flags,registers preserved
  1495. TranslateStd proc near
  1496. push bx
  1497. push ax
  1498. lahf
  1499. mov bx, ax
  1500. pop ax
  1501. push bx
  1502. cmp ah, 0e0h
  1503. jne TStd1
  1504. ; keypad enter or '/'
  1505. mov ah, 1ch ; assume enter key
  1506. cmp al, 0dh
  1507. je TStdNoCarry
  1508. cmp al, 0ah
  1509. je TStdNoCarry
  1510. mov ah, 35h ; oops it was key pad!
  1511. jmp TStdNoCarry
  1512. TStd1:
  1513. cmp ah, 84h
  1514. ja TStdCarry ; extended key ?
  1515. cmp al, 0f0h ; fill in key ?
  1516. jne TStd2
  1517. or ah, ah ; ah = 0 is special
  1518. jz TStdNoCarry
  1519. jmp TStdCarry
  1520. TStd2:
  1521. cmp al, 0e0h ; convert to compatible output
  1522. jne TStdNoCarry
  1523. or ah, ah
  1524. jz TStdNoCarry
  1525. xor al, al
  1526. TStdNoCarry:
  1527. mov bx, ax
  1528. pop ax
  1529. sahf
  1530. mov ax, bx
  1531. pop bx
  1532. clc
  1533. ret
  1534. TStdCarry:
  1535. mov bx, ax
  1536. pop ax
  1537. sahf
  1538. mov ax, bx
  1539. pop bx
  1540. stc
  1541. ret
  1542. TranslateStd endp
  1543. ; IncrBuffPtr - increments the buffer pointer
  1544. ;
  1545. ; input: ds:bx - curr buf ptr
  1546. ; output: ds:bx - new buf ptr
  1547. ; does not update the bios buf ptr
  1548. IncrBuffPtr proc near
  1549. inc bx
  1550. inc bx
  1551. cmp bx, word ptr ds:[BUFFER_END]
  1552. jne ibpExit
  1553. mov bx, word ptr ds:[BUFFER_START]
  1554. ibpExit:
  1555. ret
  1556. IncrBuffPtr endp
  1557. ; UpdateLed - forms the data byte for the mode indicators
  1558. ; updates the led bits (MAKE_LED,SEND_LED)
  1559. ;
  1560. ; input: none
  1561. ; output: led bits updated
  1562. ;
  1563. ; Caveats: all low flags,registers preserved
  1564. ; MUST be called with interrupts off
  1565. ; does not update the kbd hardware (send_led)
  1566. ;
  1567. UpdateLed proc near
  1568. push bx
  1569. push cx
  1570. push ax
  1571. lahf
  1572. push ax
  1573. ; make_led
  1574. mov al, byte ptr ds:[KB_FLAG] ; get led bits
  1575. and al, CAPS_STATE+NUM_STATE+SCROLL_STATE
  1576. mov cl, 4
  1577. shr al, cl ; shift for kb_flag_2
  1578. and al, KB_LEDS ; only led mode bits
  1579. mov bl, byte ptr ds:[KB_FLAG_2]
  1580. xor bl, al ; see if different
  1581. and bl, KB_LEDS ; only led mode bits
  1582. jz UledExit
  1583. test byte ptr ds:[KB_FLAG_2], KB_PR_LED ;if update under way
  1584. jnz ULedExit ; skip update
  1585. or byte ptr ds:[KB_FLAG_2], KB_PR_LED ;else upd in progress
  1586. shl bl, cl ; add in changebits
  1587. or al, bl ; to hi nibble of al
  1588. mov ah, 3 ; inform softpc to set lights
  1589. BOP 16h
  1590. and byte ptr ds:[KB_FLAG_2], NOT KB_LEDS ; clear led bits
  1591. and al, 0fh ; remove change bits
  1592. or byte ptr ds:[KB_FLAG_2], al ; stick in new led bits
  1593. and byte ptr ds:[KB_FLAG_2], NOT KB_PR_LED ; clear upd bit
  1594. ULedExit:
  1595. pop ax
  1596. sahf
  1597. pop ax
  1598. pop cx
  1599. pop bx
  1600. ret
  1601. UpdateLed endp
  1602. ; IVT 17 is printer IO, done above.
  1603. int18h_vector: ; ROM BASIC, copied from BIOS2.ASM
  1604. bop 18h
  1605. jmp iret_com
  1606. int19h_vector: ; reboot vector, we terminate vdm!
  1607. bop 19h
  1608. jmp iret_com
  1609. IdleTicLo dw 0
  1610. IdleTicHi dw 0
  1611. IdleTicNum db 0
  1612. int1Ah_vector: ; Time of day.
  1613. call DOSTI
  1614. cmp ah, 2
  1615. jb i1aTic1
  1616. bop 1ah
  1617. jmp iret_com
  1618. i1aTic1:
  1619. push ds ; bios data adressable
  1620. push bx
  1621. push ax
  1622. mov ax, 40h
  1623. mov ds, ax
  1624. pop ax
  1625. call DOCLI
  1626. or ah, ah ; fn 0 or fn 1 ?
  1627. jnz i1aTic5
  1628. i1aTic2:
  1629. mov al, byte ptr ds:[TIMER_OVFL] ; GetTickCount
  1630. mov cx, word ptr ds:[TIMER_HIGH]
  1631. mov dx, word ptr ds:[TIMER_LOW]
  1632. ; If time stamp is within 1 tic of curr tic count
  1633. ; do idle polling managment
  1634. cmp cs:IdleTicHi, cx ; check TIMER_HIGH
  1635. jnz i1aTic8
  1636. mov bx, cs:IdleTicLo ; check TIMER_LOW
  1637. cmp bx, dx
  1638. jz i1aTic3
  1639. inc bx
  1640. cmp bx, dx
  1641. jnz i1aTic8
  1642. i1aTic3:
  1643. inc cs:IdleTicNum ; Yes, inc poll count
  1644. cmp cs:IdleTicNum, 16 ; Is poll count too hi ?
  1645. jb i1aTic9
  1646. call DOSTI
  1647. xor ax,ax ; Yes, do idle BOP
  1648. dec cs:IdleTicLo ; make sure only bop once
  1649. BOP 5ah
  1650. call DOCLI
  1651. jmp short i1aTic2
  1652. i1aTic5:
  1653. mov word ptr ds:[TIMER_LOW], dx ; SetTickCount
  1654. mov word ptr ds:[TIMER_HIGH], cx
  1655. i1aTic8:
  1656. mov cs:IdleTicNum, 0 ; reset idle indicators
  1657. i1aTic9:
  1658. mov cs:IdleTicLo, dx ; store time stamp
  1659. mov cs:IdleTicHi, cx
  1660. mov byte ptr ds:[TIMER_OVFL], 0 ; common TicCount exit
  1661. pop bx
  1662. pop ds
  1663. jmp iret_com
  1664. ; IVT 1B is keyboard break, set to dummy.
  1665. int1Eh_vector:
  1666. bop 1eh
  1667. jmp iret_com
  1668. int70h_vector: ; Real time clock, copied from BIOS1.ASM
  1669. bop 70h ; rtc_bios.c:rtc_int()
  1670. jmp iret_com
  1671. int4Ah_caller:
  1672. call DOSTI ; Called from base\bios\rtc_bios.c:rtc_int()
  1673. int 4ah ; User installed alarm.
  1674. jmp r1
  1675. r1: jmp r2
  1676. r2: jmp r3
  1677. r3:
  1678. call DOCLI
  1679. bop 0feh
  1680. int71h_vector: ; redirect, copied from BIOS1.ASM
  1681. bop 71h
  1682. int 0Ah
  1683. jmp iret_com
  1684. int75h_vector: ; NPX 287.
  1685. bop 75h
  1686. int 02h
  1687. jmp iret_com
  1688. ;=================================================================
  1689. ; End of pseudo-ROM vectuz.
  1690. ;=================================================================
  1691. ;================================================================
  1692. ; Wait for interrupts
  1693. ;================================================================
  1694. cpu_nop_code:
  1695. call DOSTI
  1696. jmp short nxt1
  1697. nxt1: jmp short nxt2
  1698. nxt2: jmp short nxt3
  1699. nxt3: bop %BIOS_CPU_QUIT
  1700. public SpcKbdEnd
  1701. SpcKbdEnd label byte
  1702. align 4 ;; makes MIPS happy
  1703. ; offset table for redirected functions
  1704. ifdef JAPAN
  1705. kio_table dw 34 dup(?)
  1706. else ; !JAPAN
  1707. kio_table dw 33 dup(?)
  1708. endif ; !JAPAN
  1709. public InstSpcKbd
  1710. ;
  1711. ; InstSpcKbd - Installs the softpc custom interrupt hooks
  1712. ;
  1713. ; Inputs: ds == Resident location of SysInitSeg
  1714. ; Outputs: None
  1715. ;
  1716. InstSpcKbd proc near
  1717. pusha
  1718. call DOCLI
  1719. ; The following vectors are used for both x86\mips
  1720. ; The dos interrupts Int 25\Int26 are handled by the dos kerenl
  1721. xor ax, ax
  1722. mov es, ax
  1723. mov word ptr es:[08h*4], offset int08h_vector
  1724. mov word ptr es:[(08h*4)+2], ds
  1725. mov word ptr es:[09h*4], offset int09h_vector
  1726. mov word ptr es:[(09h*4)+2], ds
  1727. mov word ptr es:[13h*4], offset int13h_vector
  1728. mov word ptr es:[(13h*4)+2], ds
  1729. mov word ptr es:[16h*4], offset int16h_vector
  1730. mov word ptr es:[(16h*4)+2], ds
  1731. mov word ptr es:[40h*4], offset int40h_vector
  1732. mov word ptr es:[(40h*4)+2], ds
  1733. mov word ptr es:[19h*4], offset int19h_vector
  1734. mov word ptr es:[(19h*4)+2], ds
  1735. mov word ptr es:[1ah*4], offset int1Ah_vector
  1736. mov word ptr es:[(1ah*4)+2], ds
  1737. ; BOP 5F - send interesting addresses to softpc C BIOS
  1738. ; CS seg of kio_table
  1739. ; DS seg of resident keyboard code
  1740. ; DI offset of bop table
  1741. ; CX size of bop table entry
  1742. ; SI offset of kio_table
  1743. mov si,offset sysinitgrp:kio_table
  1744. push ds
  1745. push cs
  1746. pop ds
  1747. mov word ptr [si], offset shift_keys ;K6
  1748. mov word ptr [si+2], offset shift_masks ;K7
  1749. mov word ptr [si+4], offset ctl_n_table ;K8
  1750. mov word ptr [si+6], offset ctl_f_table ;K9
  1751. mov word ptr [si+8], offset lowercase ;K10
  1752. mov word ptr [si+10], offset uppercase ;K11
  1753. mov word ptr [si+12], offset alt_table ;K30
  1754. mov word ptr [si+14], offset dummy_vector
  1755. mov word ptr [si+16], offset print_screen_caller
  1756. mov word ptr [si+18], offset int15h_caller
  1757. mov word ptr [si+20], offset cpu_nop_code
  1758. mov word ptr [si+22], offset int15h_vector
  1759. mov word ptr [si+24], offset Icounter
  1760. mov word ptr [si+26], offset int4Ah_caller
  1761. mov word ptr [si+28], offset keyboard_break_caller
  1762. mov word ptr [si+30], offset int10h_caller
  1763. mov word ptr [si+32], offset int10h_vector
  1764. mov word ptr [si+34], offset use_host_int10
  1765. mov word ptr [si+36], offset ega_parm_setup
  1766. mov word ptr [si+38], offset changing_mode
  1767. mov word ptr [si+40], offset prt_status
  1768. mov word ptr [si+42], offset wait_int
  1769. mov word ptr [si+44], offset floppy_table
  1770. mov word ptr [si+46], offset vga_1b_table
  1771. mov word ptr [si+48], offset conf_table
  1772. mov word ptr [si+50], offset int08h_vector
  1773. mov word ptr [si+52], offset int13h_vector
  1774. mov word ptr [si+54], offset int13h_caller
  1775. mov word ptr [si+56], SW_VIDEO_BUFFER_SIZE
  1776. mov word ptr [si+58], SW_VIDEO_BUFFER_SEGMENT
  1777. mov word ptr [si+60], offset sw_video_dirty_count
  1778. mov word ptr [si+62], offset sw_video_busy
  1779. ifdef JAPAN
  1780. mov word ptr [si+64], offset int16h_caller
  1781. endif ; JAPAN
  1782. ; Pass DOS_FLAG to 32 bit side
  1783. push es
  1784. push bx
  1785. mov ah, GET_IN_VARS
  1786. int 21h
  1787. mov ax, es
  1788. pop bx
  1789. pop es
  1790. ; The last entry is reserved for assertion checking
  1791. ifdef JAPAN
  1792. mov word ptr [si+66], ax
  1793. mov word ptr [si+68], DOS_FLAG_OFFSET
  1794. mov word ptr [si+70], VERSIONID
  1795. else ; !JAPAN
  1796. mov word ptr [si+64], ax
  1797. mov word ptr [si+66], DOS_FLAG_OFFSET
  1798. mov word ptr [si+68], VERSIONID
  1799. endif ; !JAPAN
  1800. pop ds
  1801. ; mov si, offset kio_table
  1802. mov di, offset iret_bop_table
  1803. mov cx, offset iret_end_first_entry - offset iret_bop_table
  1804. mov ax, VERSIONID
  1805. bop BOP_UNIMPINT
  1806. jc isk_int9
  1807. ;
  1808. ; Risc only
  1809. ;
  1810. xor ax, ax
  1811. mov es, ax
  1812. mov word ptr es:[17h*4], offset int17h_RiscVector
  1813. mov word ptr es:[(17h*4)+2], ds
  1814. ;
  1815. ; End Risc only
  1816. ;
  1817. jmp isk_Exit
  1818. isk_int9:
  1819. ;
  1820. ; X86 only
  1821. ;
  1822. ; save old video int
  1823. xor ax, ax
  1824. mov es, ax
  1825. mov bx, es:[40h]
  1826. mov si, offset host_int10
  1827. mov word ptr ds:[si], bx
  1828. mov bx, es:[42h]
  1829. mov word ptr ds:[si+2], bx
  1830. ; save old secondary video int (42h)
  1831. mov bx, es:[108h]
  1832. mov si, offset host_int42
  1833. mov word ptr ds:[si], bx
  1834. mov bx, es:[10ah]
  1835. mov word ptr ds:[si+2], bx
  1836. ;-----------------------------------------------------------
  1837. ;
  1838. ; Crazy vector grabber
  1839. ;
  1840. ; Works OK on DEC PC when grab INT's 6, 11, 16, 17, 42.
  1841. ; Now try and avoid all accesses to host ROM.
  1842. ;
  1843. ; At this point we assume ES=0
  1844. ;-----------------------------------------------------------
  1845. ; Grab some prominent vectors for pseudo-ROM routines.
  1846. ; start at Int 0h and work our way up as needed
  1847. cld
  1848. mov di, 20
  1849. mov ax, offset int05h_vector ; INT 05h
  1850. stosw ; Print screen
  1851. mov ax, ds
  1852. stosw
  1853. mov ax, offset int06h_vector ; INT 06h
  1854. stosw ; Illegal instruction.
  1855. mov ax, ds
  1856. stosw
  1857. mov ax, offset unexp_int ; INT 07h
  1858. stosw
  1859. mov ax, ds
  1860. stosw
  1861. ; int 8h Timer hardware vector already done for both x86\mips
  1862. ; int 9h kbd hardware vector already done for both x86\mips
  1863. add di, 8
  1864. mov ax, offset unexp_int ; INT 0ah
  1865. stosw
  1866. mov ax, ds
  1867. stosw
  1868. mov ax, offset unexp_int ; INT 0bh
  1869. stosw
  1870. mov ax, ds
  1871. stosw
  1872. mov ax, offset unexp_int ; INT 0ch
  1873. stosw
  1874. mov ax, ds
  1875. stosw
  1876. mov ax, offset unexp_int ; INT 0dh
  1877. stosw
  1878. mov ax, ds
  1879. stosw
  1880. mov ax, offset int0e_vector ; INT 0eh
  1881. stosw ; Floppy hardware int.
  1882. mov ax, ds
  1883. stosw
  1884. mov ax, offset unexp_int ; INT 0fh
  1885. stosw
  1886. mov ax, ds
  1887. stosw
  1888. mov ax, offset int10h_vector ; INT 10h
  1889. stosw
  1890. mov ax, ds
  1891. stosw
  1892. mov ax, offset int11h_vector ; INT 11h
  1893. stosw ; Equipment check.
  1894. mov ax, ds
  1895. stosw
  1896. mov ax, offset int12h_vector ; INT 12h
  1897. stosw ; Get memory size.
  1898. mov ax, ds
  1899. stosw
  1900. ; int 13h already done (see above) for both mips\x86
  1901. mov di, 14h*4 ; Communications.
  1902. mov ax, offset int14h_vector
  1903. stosw
  1904. mov ax, ds
  1905. stosw
  1906. mov ax, offset int15h_vector ; INT 15h
  1907. stosw
  1908. mov ax, ds
  1909. stosw
  1910. ; int 16h kbd hardware vector already done for both x86\mips
  1911. add di, 4
  1912. mov ax, offset int17h_vector ; INT 17h
  1913. stosw
  1914. mov ax, ds
  1915. stosw
  1916. mov ax, offset int18h_vector ; INT 18h
  1917. stosw ; ROM BASIC.
  1918. mov ax, ds
  1919. stosw
  1920. ; int 19h (reboot vector) already done for both x86\mips
  1921. ; int 1ah, time of day, already done for both x86\mips
  1922. mov di, 1Bh*4
  1923. mov ax, offset dummy_vector ; INT 1Bh
  1924. stosw ; Keyboard break.
  1925. mov ax, ds
  1926. stosw
  1927. mov ax, offset dummy_vector ; INT 1Ch
  1928. stosw ; Timer tick.
  1929. mov ax, ds
  1930. stosw
  1931. mov di, 1Eh*4 ; Floppy parameters.
  1932. mov ax, offset bios_floppy_table
  1933. stosw
  1934. mov ax, ds
  1935. stosw
  1936. ; int 40h already done (see above) for both mips\x86
  1937. mov di, 41h*4
  1938. mov ax, offset unexp_int ; INT 41h
  1939. stosw ; Hard disk parameters.
  1940. mov ax, ds
  1941. stosw
  1942. mov ax, offset int42h_vector ; INT 42h
  1943. stosw ; Default video.
  1944. mov ax, ds
  1945. stosw
  1946. mov di, 70h*4 ; Real time clock init.
  1947. mov ax, offset int70h_vector
  1948. stosw
  1949. mov ax, ds
  1950. stosw
  1951. mov ax, offset int71h_vector ; INT 71h Redirect.
  1952. stosw
  1953. mov ax, ds
  1954. stosw
  1955. mov ax, offset intD11_vector ; INT 72h D11 int
  1956. stosw
  1957. mov ax, ds
  1958. stosw
  1959. mov ax, offset intD11_vector ; INT 73h D11 int
  1960. stosw
  1961. mov ax, ds
  1962. stosw
  1963. mov ax, offset intD11_vector ; INT 74h D11 int
  1964. stosw
  1965. mov ax, ds
  1966. stosw
  1967. mov ax, offset int75h_vector ; INT 75h 287 int
  1968. stosw
  1969. mov ax, ds
  1970. stosw
  1971. mov ax, offset intD11_vector ; INT 76h D11 int
  1972. stosw
  1973. mov ax, ds
  1974. stosw
  1975. mov ax, offset intD11_vector ; INT 77h D11 int
  1976. stosw
  1977. mov ax, ds
  1978. stosw
  1979. isk_Exit:
  1980. ;;
  1981. ;; williamh, May 16, 1996
  1982. ;; Photostyler blindly calls EMS function without even checking
  1983. ;; if EMS driver ever exists at all. On most x86 machines, we are fine because
  1984. ;; the ROM BIOS sets the vector to a valid address. On certain x86 machines
  1985. ;; and all RISC machines, the vector is 0:0. This hack is to repoint
  1986. ;; the vector to our dummy iret routine if it is not initialized. Windows 3.1
  1987. ;; Windows 95 ALWAYS redirect this vector to their own, so they don't have
  1988. ;; the problem as we do.
  1989. ;; Also note that the application may skip the EMS calls if the system has
  1990. ;; big memory(more than 16MB, maybe). In this case, the problem won't get hit
  1991. ;; at all.
  1992. ;;
  1993. ;; ds = segment of ntio.sys resident portion. It is the segment of our
  1994. ;; iret_com rountine
  1995. ;;
  1996. xor di, di
  1997. mov es, di
  1998. mov di, 067h * 4 ; the EMS vector
  1999. mov ax, es:[di]
  2000. or ax, es:[di + 2] ;; anything set for the vector?
  2001. jnz i67_patch_done
  2002. mov word ptr es:[di], offset iret_com
  2003. mov es:[di + 2], ds
  2004. i67_patch_done:
  2005. call DOSTI
  2006. popa
  2007. ret
  2008. InstSpcKbd endp
  2009. SpcKbdSeg ends
  2010. end