Source code of Windows XP (NT5)
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.

558 lines
10 KiB

  1. ; SCCSID = @(#)uf.bios1.asm 1.16 7/3/95
  2. ; Author: J. Box, Jerry Kramskoy
  3. ;
  4. ; Purpose:
  5. ; provides Intel BIOS for the following:
  6. ; RTC interrupt
  7. ; fixed disk (on dual card)
  8. ;
  9. ; C-services (through 'bop' instruction)
  10. BIOS_UNEXP_INT = 2
  11. BIOS_RTC_INT = 70h
  12. BIOS_REDIRECT_INT = 71h
  13. BIOS_D11_INT = 72h
  14. BIOS_X287_INT = 75h
  15. BIOS_DISK_IO = 13h
  16. BIOS_MOUSE_INT1 = 0BAh
  17. BIOS_MOUSE_INT2 = 0BBh
  18. BIOS_MOUSE_IO_LANGUAGE = 0BCh
  19. BIOS_MOUSE_IO_INTERRUPT = 0BDh
  20. BIOS_MOUSE_VIDEO_IO = 0BEh
  21. BIOS_CPU_RETURN = 0feh
  22. BIOS_IRET_HOOK = 52h
  23. ; ICA registers
  24. ICA_MASTER_CMD = 020h
  25. ICA_MASTER_IMR = 021h
  26. ICA_SLAVE_CMD = 0A0h
  27. ICA_SLAVE_IMR = 0A1h
  28. ; and commands
  29. ICA_EOI = 020h
  30. ; CMOS registers
  31. CMOS_addr = 070h
  32. CMOS_data = 071h
  33. NMI_DISABLE = 080h
  34. CMOS_StatusA = NMI_DISABLE + 0Ah
  35. CMOS_StatusB = NMI_DISABLE + 0Bh
  36. CMOS_StatusC = NMI_DISABLE + 0Ch
  37. CMOS_Shutdown = 0Fh
  38. ; CMOS constants (bits in StatusB or StatusC)
  39. CMOS_PI = 01000000b ; Periodic interrupt
  40. CMOS_AI = 00100000b ; Alarm interrupt
  41. ; microseconds at 1024Hz
  42. CMOS_PERIOD_USECS = 976
  43. include bebop.inc
  44. ; DUE TO LIMITATIONS IN EXE2BIN, we define
  45. ; the region 0 - 0xdfff (segment 0xf000) in this file
  46. ; and the region 0xe000 - 0xffff in file 'bios2.asm'
  47. ;
  48. ; each file should be SEPARATELY put through
  49. ; MASM,LINK, and EXE2BIN to produce 2 binary image files
  50. ; which get loaded into the appropriate regions during
  51. ; SoftPC startup.
  52. ;------------------------;
  53. ; bios data area ;
  54. ;------------------------;
  55. ; BIOS variables area
  56. BIOS_VAR_SEGMENT SEGMENT at 40h
  57. ORG 098h
  58. rtc_user_flag DD ? ; 98
  59. rtc_micro_secs DD ? ; 9c
  60. rtc_wait_flag DB ? ; a0
  61. ORG 8eh
  62. hf_int_flag db ? ; 8e
  63. BIOS_VAR_SEGMENT ENDS
  64. code segment
  65. assume cs:code, ds:BIOS_VAR_SEGMENT
  66. ;----------------------------------------------------;
  67. ; D11 ;
  68. ; services unused interrupt vectors ;
  69. ; ;
  70. ;----------------------------------------------------;
  71. ORG 01BE0h
  72. D11: bop BIOS_D11_INT
  73. iret
  74. ;----------------------------------------------------;
  75. ; IRET HOOK ;
  76. ; Return control to the monitor after an ISR ;
  77. ; returns to here. ;
  78. ;----------------------------------------------------;
  79. ORG 01C00h
  80. bop BIOS_IRET_HOOK
  81. iret
  82. ;----------------------------------------------------;
  83. ; re_direct ;
  84. ; This routine fields level 9 interrupts ;
  85. ; control is passed to Master int level 2 ;
  86. ;----------------------------------------------------;
  87. ORG 01C2Fh
  88. re_direct: bop BIOS_REDIRECT_INT
  89. int 0ah
  90. iret
  91. ;----------------------------------------------------;
  92. ; int_287 ;
  93. ; service X287 interrupts ;
  94. ; ;
  95. ;----------------------------------------------------;
  96. ORG 01C38h
  97. int_287: bop BIOS_X287_INT
  98. int 02
  99. iret
  100. ;----------------------------------------------------;
  101. ; rtc_int ;
  102. ; rtc interrupt handler ;
  103. ;----------------------------------------------------;
  104. ORG 04B1Bh
  105. rtc_int: push ax
  106. push ds
  107. mov ax, BIOS_VAR_SEGMENT
  108. mov ds, ax
  109. rtc_test_pending:
  110. ;; Check for pending interrupt
  111. mov al, CMOS_StatusC
  112. out CMOS_addr, al
  113. in al, CMOS_data ; reads then clears pending interrupts
  114. ;; Mask with enabled interrupts
  115. mov ah, al ; save pending interrupts
  116. mov al, CMOS_StatusB
  117. out CMOS_addr, al
  118. in al, CMOS_data
  119. and ah, al
  120. ;; Test pending, enabled interrupts (in ah) for work to do
  121. test ah, (CMOS_PI+CMOS_AI)
  122. jnz rtc_test_enabled
  123. ;; Deselecting the cmos
  124. mov al, CMOS_Shutdown
  125. out CMOS_addr, al
  126. ;; Send eoi to ICA
  127. mov al, ICA_EOI
  128. out ICA_SLAVE_CMD, al
  129. out ICA_MASTER_CMD, al
  130. ;; And return
  131. pop ds
  132. pop ax
  133. iret
  134. rtc_test_enabled:
  135. ;; Test for periodic interrupt triggered
  136. test ah, CMOS_PI
  137. jz rtc_test_alarm
  138. ;; Decrement the microsecond count
  139. .386
  140. sub ds:[rtc_micro_secs], CMOS_PERIOD_USECS
  141. .286
  142. jnc rtc_test_alarm
  143. ;; Disable PI interrupt in CMOS if count expired
  144. mov al, CMOS_StatusB
  145. out CMOS_addr, al
  146. in al, CMOS_data
  147. and al, 10111111b ; Disable PI interrupt
  148. out CMOS_data, al
  149. ;; Update the flag byte to say time has expired
  150. push es
  151. push bx
  152. les bx, rtc_user_flag
  153. or byte ptr es:[bx], 080h
  154. pop bx
  155. pop es
  156. ;; Mark timer-in-use flag in-active
  157. and rtc_wait_flag, 0feh; Show wait is not active
  158. rtc_test_alarm:
  159. ;; Test for alarm interrupt triggered
  160. test ah, CMOS_AI
  161. jz rtc_test_pending
  162. ;; Call users alarm function (first deselecting the cmos)
  163. mov al, CMOS_Shutdown
  164. out CMOS_addr, al
  165. int 04Ah
  166. ;; Repeat in case a new interrupt occurred
  167. jmp rtc_test_pending
  168. ;----------------------------------------------------;
  169. ; disk_io
  170. ; route to disk/diskette i/o service ;
  171. ;----------------------------------------------------;
  172. org 2e86h ;(must match DISKO_OFFSET in diskbios.c)
  173. disk_io proc far
  174. ; is this request for fixed disk or diskette?
  175. cmp dl,80h
  176. jae p0
  177. ; for diskette.
  178. int 40h
  179. bye:
  180. retf 2
  181. p0:
  182. sti
  183. ; reset? (ah = 0). reset diskette also
  184. or ah,ah
  185. jnz p1
  186. int 40h
  187. sub ah,ah
  188. cmp dl,81h
  189. ja bye
  190. p1:
  191. ; carry out the disk service requested from 'C'.
  192. ; those requests which expect to cause a
  193. ; disk interrupt will 'call' wait below,
  194. ; which returns back to 'C'. Eventually
  195. ; 'C' returns after the bop.
  196. push ds
  197. bop BIOS_DISK_IO
  198. pop ds
  199. retf 2
  200. disk_io endp
  201. ;----------------------------------------------------;
  202. ; wait ;
  203. ; wait for disk interrupt ;
  204. ; ('called' from waitint() in diskbios.c ;
  205. ;----------------------------------------------------;
  206. org 329fh ;(must match DISKWAIT_OFFSET in diskbios.c)
  207. wate proc
  208. sti
  209. clc
  210. mov ax,9000h
  211. int 15h
  212. push ds
  213. push cx
  214. mov ax, 40h
  215. mov ds, ax
  216. xor cx, cx
  217. not_yet: cmp byte ptr ds:[8eh], 0
  218. loopz not_yet
  219. pop cx
  220. pop ds
  221. bop BIOS_CPU_RETURN
  222. wate endp
  223. ;----------------------------------------------------;
  224. ; hd_int ;
  225. ; field fixed disk controller's interrupt ;
  226. ;----------------------------------------------------;
  227. org 33b7h ; (must match DISKISR_OFFSET in diskbios.c)
  228. hd_int proc near
  229. push ds
  230. mov ax,BIOS_VAR_SEGMENT
  231. mov ds,ax
  232. ; inform everybody that a fixed disk interrupt
  233. ; occurred
  234. mov hf_int_flag,0ffh
  235. ; clear down the interrupt with the ica's
  236. mov al, ICA_EOI
  237. out ICA_SLAVE_CMD, al
  238. out ICA_MASTER_CMD, al
  239. sti
  240. mov ax,9100h
  241. int 15h
  242. pop ds
  243. iret
  244. hd_int endp
  245. ; read bytes 0 - 3fff in from binary image
  246. ; when accessing bios1.rom.
  247. ; if need more than this, change value here
  248. ; to 'n' and in sas_init(), change read of bios1.rom
  249. ; to have transfer count of 'n'+1
  250. org 3fffh
  251. insignia_endmark db 0
  252. ifdef SUN_VA
  253. ;
  254. ; NB. the following addresses are allocated to SUN for DOS Windows 3.0.
  255. ; They are not to be used by anyone else.
  256. ; THIS AREA IS SUN PROPERTY - TRESPASSERS WILL BE PROSECUTED
  257. ; However please note that only the ranges below are reserved.
  258. ;
  259. ORG 04000h
  260. sunroms_2 LABEL FAR
  261. db 512 dup (0) ; reserved
  262. ORG 05000h
  263. sunroms_3 LABEL FAR
  264. db 512 dup (0) ; reserved
  265. endif
  266. ORG 06000h
  267. ; this is a fake IFS header to make DOS 4.01
  268. ; happy with HFX. Do not move/alter.
  269. hfx_ifs_hdr LABEL FAR
  270. DB 0ffh, 0ffh, 0ffh, 0ffh
  271. DB "HFXREDIR"
  272. DB 00h, 02ch
  273. DB 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h
  274. ifndef GISP_SVGA
  275. ORG 06020h
  276. ifndef SUN_VA
  277. write_teletype proc far
  278. retf
  279. write_teletype endp
  280. else
  281. write_teletype proc far
  282. push ds
  283. push si
  284. mov si, 0f000h
  285. mov ds, si
  286. mov si, 06400h
  287. push ax
  288. mov ah, 0eh
  289. push bp
  290. mov bp, 2
  291. push dx
  292. push bx
  293. mov bx, 0
  294. start_write:
  295. cmp bp, [si]
  296. je finish_write
  297. mov al, ds:[bp+si]
  298. inc bp
  299. int 010h
  300. jmp start_write
  301. finish_write:
  302. mov word ptr [si], 2
  303. pop bx
  304. pop dx
  305. pop bp
  306. pop ax
  307. pop si
  308. pop ds
  309. retf
  310. write_teletype endp
  311. ORG 06200h
  312. ; mouse_io_interrupt
  313. mouse_io:
  314. JMP hopover
  315. BOP BIOS_MOUSE_IO_LANGUAGE
  316. RETF 8
  317. hopover:
  318. BOP BIOS_MOUSE_IO_INTERRUPT
  319. IRET
  320. ORG 06220h
  321. ; mouse_int1
  322. mouse_int1:
  323. BOP BIOS_MOUSE_INT1
  324. IRET
  325. ORG 06240h
  326. ; mouse_video_io
  327. mouse_video_io:
  328. BOP BIOS_MOUSE_VIDEO_IO
  329. IRET
  330. ORG 06260h
  331. ; mouse_int2
  332. mouse_int2:
  333. BOP BIOS_MOUSE_INT2
  334. IRET
  335. ORG 06280h
  336. ; mouse_version
  337. mouse_version: ; dummy, for compatibility
  338. DB 042h,042h,00h,00h
  339. ORG 062a0h
  340. ; mouse_copyright
  341. mouse_copyright: ; dummy, for compatibility
  342. DB "Copyright 1987-91 Insignia Solutions Inc"
  343. ORG 06400h
  344. ; scratch pad area - this is where the messages go!
  345. endif
  346. endif ; GISP_SVGA
  347. ;; To cope with Helix SoftWare "Netroom 2.20" DOS extender
  348. ;; which only maps in pages of the BIOS that have vectors
  349. ;; we must ensure that something points at page F6xxx
  350. ;; else we end up with the scratch area on top of some
  351. ;; DOS program or driver!
  352. ORG 06f00h ; UNEXP_INT_OFFSET
  353. BOP BIOS_UNEXP_INT
  354. IRET
  355. .386
  356. ; These are the virtualisation instructions needed for the 386.
  357. ORG 3000h ; BIOS_STI_OFFSET
  358. STI
  359. BOP 0feh
  360. ORG 3010h ; BIOS_CLI_OFFSET
  361. CLI
  362. BOP 0feh
  363. ORG 3020h ; BIOS_INB_OFFSET
  364. IN al,dx
  365. BOP 0feh
  366. ORG 3030h ; BIOS_INW_OFFSET
  367. IN ax,dx
  368. BOP 0feh
  369. ORG 3040h ; BIOS_IND_OFFSET
  370. IN eax,dx
  371. BOP 0feh
  372. ORG 3050h ; BIOS_OUTB_OFFSET
  373. OUT dx,al
  374. BOP 0feh
  375. ORG 3060h ; BIOS_OUTW_OFFSET
  376. OUT dx,ax
  377. BOP 0feh
  378. ORG 3070h ; BIOS_OUTD_OFFSET
  379. OUT dx,eax
  380. BOP 0feh
  381. ORG 3080h ; BIOS_WRTB_OFFSET
  382. MOV [edx],al
  383. BOP 0feh
  384. ORG 3090h ; BIOS_WRTW_OFFSET
  385. MOV [edx],ax
  386. BOP 0feh
  387. ORG 30a0h ; BIOS_WRTD_OFFSET
  388. MOV [edx],eax
  389. BOP 0feh
  390. ORG 30b0h ; BIOS_RDB_OFFSET
  391. MOV al, [edx]
  392. BOP 0feh
  393. ORG 30c0h ; BIOS_RDW_OFFSET
  394. MOV ax, [edx]
  395. BOP 0feh
  396. ORG 30d0h ; BIOS_RDD_OFFSET
  397. MOV eax, [edx]
  398. BOP 0feh
  399. ORG 30e0h ; BIOS_YIELD_VM_OFFSET
  400. MOV AX, 1680h ; Yeild VM time slice
  401. INT 2fh
  402. BOP 0feh
  403. ORG 30f0h ; BIOS_STOSB_OFFSET
  404. push es
  405. push ds
  406. pop es
  407. xchg edx,edi ; dest lin addr
  408. db 67h
  409. db 66h
  410. rep stosb
  411. xchg edx,edi
  412. pop es
  413. BOP 0feh
  414. ORG 3110h ; BIOS_STOSW_OFFSET
  415. push es
  416. push ds
  417. pop es
  418. xchg edx,edi ; dest lin addr
  419. db 67h
  420. rep stosw
  421. xchg edx,edi
  422. pop es
  423. BOP 0feh
  424. ORG 3130h ; BIOS_STOSD_OFFSET
  425. push es
  426. push ds
  427. pop es
  428. xchg edx,edi ; dest lin addr
  429. db 67h
  430. db 66h
  431. rep stosw
  432. xchg edx,edi
  433. pop es
  434. BOP 0feh
  435. ORG 3200h ; BIOS_BAD_OFFSET
  436. db 0c5h
  437. db 0c5h ; illegal instruction
  438. BOP 0feh
  439. ;; N.B. DISKWAIT_OFFSET is at "org 329fh"
  440. code ends
  441. end