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.

539 lines
12 KiB

  1. PAGE ,132
  2. TITLE ANSI Console device CON$INIT routine
  3. ;******************************************************************************
  4. ; Change Log:
  5. ; Date Who # Description
  6. ; -------- --- --- ------------------------------------------------------
  7. ; 06/05/90 MKS C03 Bug#234. ANSI was not recognizing the presence of a
  8. ; VGA if there was another video board in the system.
  9. ;******************************************************************************
  10. ; MODULE_NAME: CON$INIT
  11. ; FUNCTION:
  12. ; THIS PROCEDURE PERFORMS ALL NECESSARY INITIALIZATION ROUTINES
  13. ; FOR ANSI.SYS.
  14. ; THIS ROUTINE WAS SPLIT FROM THE ORIGINAL ANSI.ASM SOURCE FILE
  15. ; FOR RELEASE 4.00 OF DOS. ALL CHANGED LINES HAVE BEEN MARKED WITH
  16. ; . NEW PROCS HAVE BEEN MARKED AS SUCH.
  17. ; P1767 VIDEO_MODE_TABLE not initialized correctly 10/16/87 J.K.
  18. ; P2617 Order dependecy problem with Display.sys 11/23/87 J.K.
  19. ; D479 An option to disable the extended keyboard functions 02/12/88 J.K.
  20. ; D493 New INIT request structure for error message 02/25/88 J.K.
  21. ; P5699 Moving selecting alternate print screen routine to only when it
  22. ; 10/26/88 is needed. OEM EGA cards don't support the call it, so they
  23. ; K. Sayers couldn't (shift) print screen at all.
  24. ;-------------------------------------------------------------------------------
  25. INCLUDE ANSI.INC ; equates and strucs
  26. PUBLIC CON$INIT
  27. CODE SEGMENT PUBLIC BYTE
  28. ASSUME CS:CODE,DS:CODE
  29. EXTRN VIDEO_MODE_TABLE:BYTE
  30. EXTRN FUNC_INFO:BYTE
  31. EXTRN HDWR_FLAG:WORD
  32. EXTRN VIDEO_TABLE_MAX:ABS
  33. EXTRN SCAN_LINES:BYTE
  34. EXTRN PTRSAV:DWORD
  35. EXTRN PARSE_PARM:NEAR
  36. EXTRN ERR2:NEAR
  37. EXTRN EXT_16:BYTE
  38. EXTRN BRKKY:NEAR
  39. EXTRN COUT:NEAR
  40. EXTRN BASE:WORD
  41. EXTRN MODE:BYTE
  42. EXTRN MAXCOL:BYTE
  43. EXTRN EXIT:NEAR
  44. EXTRN MAX_SCANS:BYTE
  45. EXTRN ROM_INT10:WORD
  46. EXTRN INT10_COM:NEAR
  47. EXTRN ROM_INT2F:WORD
  48. EXTRN INT2F_COM:NEAR
  49. EXTRN ABORT:BYTE
  50. EXTRN Display_Loaded_Before_me:byte ;Defined in IOCTL.ASM
  51. EXTRN Switch_K:Byte
  52. EXTRN fhavek09:BYTE ; M006
  53. EXTRN Switch_S:BYTE ; M008
  54. ifdef DBCS
  55. EXTRN DBCSLeadByteTable:dword
  56. endif
  57. INCLUDE ANSIVID.INC ; video tables data
  58. CON$INIT:
  59. lds bx,cs:[PTRSAV] ; establish addressability to request header
  60. lds si,[BX].ARG_PTR ; ds:SI now points to rest of DEVICE=statement
  61. call PARSE_PARM ; parse DEVICE= command line
  62. jnc CONT_INIT ; no error in parse...continue install
  63. lds bx,cs:[PTRSAV] ; prepare to abort install
  64. xor ax,ax ;
  65. mov [BX].NUM_UNITS,al ; set number of units to zero
  66. mov [BX].END_ADDRESS_O,ax ; set ending address offset to 0
  67. mov [BX].END_ADDRESS_S,cs ; set ending address segment to CS
  68. mov word ptr [bx].CONFIG_ERRMSG, -1 ; Let IBMBIO display "Error in CONFIG.SYS..".
  69. mov ax,UNKNOWN_CMD ; set error in status
  70. mov WORD PTR [BX].STATUS,ax ; set error status
  71. jmp ERR2 ; prepare to exit
  72. CONT_INIT:
  73. push cs
  74. pop ds ; restore DS to ANSI segment
  75. mov ax,ROM_BIOS
  76. mov es,ax ; ES now points to BIOS data area
  77. cmp Switch_S,OFF ; M008
  78. jz noscreensizesw ; M008
  79. mov BYTE PTR es:[84h],24 ; M008 ; Use default value
  80. noscreensizesw: ; M008
  81. mov ah,es:[KBD_FLAG_3] ; load AH with KBD_FLAG_3
  82. test ah,EXT16_FLAG ; if extended Int16 available
  83. jz tlab01
  84. cmp Switch_K,OFF ; and user didn't disable it
  85. jnz tlab01
  86. mov EXT_16,ON ; then enable extended int16
  87. tlab01:
  88. call DET_HDWR ; procedure to determine video hardware status
  89. call LOAD_INT10 ; load interrupt 10h handler
  90. call LOAD_INT2F ; load interrupt 2Fh handler
  91. ; M006 - begin
  92. push ds
  93. pop es
  94. xor di,di ; es:di points to begining of driver
  95. mov ax,4101h ; wait for bh=es:[di]
  96. mov bl,1 ; wait for 1 clock tick
  97. mov bh,byte ptr es:[di]
  98. stc ; Assume we will fail
  99. int 15h
  100. jc CheckColor
  101. mov fhavek09,ON ; remember we have a k09 type
  102. CheckColor:
  103. ; M006 - end
  104. int 11h
  105. and al,00110000b
  106. cmp al,00110000b
  107. jnz iscolor
  108. mov [base],0b000h ;look for bw card
  109. iscolor:
  110. cmp al,00010000b ;look for 40 col mode
  111. ja setbrk
  112. mov [mode],0
  113. mov [maxcol],39
  114. setbrk:
  115. xor bx,bx
  116. mov ds,bx
  117. mov bx,BRKADR
  118. mov WORD PTR [BX],OFFSET BRKKY
  119. mov WORD PTR [BX+2],cs
  120. mov bx,29H*4
  121. mov WORD PTR [BX],OFFSET COUT
  122. mov WORD PTR [BX+2],cs
  123. ifdef DBCS
  124. mov ax,6300h
  125. int 21h ; get DBCS lead byte table
  126. mov word ptr cs:DBCSLeadByteTable,si
  127. mov word ptr cs:DBCSLeadByteTable+2,ds
  128. endif
  129. lds bx,cs:[PTRSAV]
  130. mov WORD PTR [BX].TRANS,OFFSET CON$INIT ;SET BREAK ADDRESS
  131. mov [BX].TRANS+2,cs
  132. jmp EXIT
  133. ; PROCEDURE_NAME: DET_HDWR
  134. ; FUNCTION:
  135. ; THIS CODE DETERMINES WHAT VIDEO HARDWARE IS AVAILABLE. THIS INFORMATION
  136. ; IS USED TO LOAD APPROPRIATE VIDEO TABLES INTO MEMORY FOR USE IN THE
  137. ; GENERIC IOCTL.
  138. ; AT ENTRY:
  139. ; AT EXIT:
  140. ; NORMAL: FLAG WORD WILL CONTAIN BITS SET FOR THE APPROPRIATE
  141. ; TABLES. IN ADDITION, FOR VGA SUPPORT, A FLAG BYTE
  142. ; WILL CONTAIN THE AVAILABLE SCAN LINE SETTINGS FOR THE
  143. ; INSTALLED ADAPTER.
  144. ; VIDEO TABLES WILL BE LOADED INTO MEMORY REFLECTING
  145. ; APPLICABLE MODE SETTINGS AND SCREEN LINE LENGTHS.
  146. ; ERROR: N/A
  147. DET_HDWR PROC NEAR
  148. mov ah,GET_SYS_ID ; see if this is a Convertible
  149. int 15h
  150. cmp es:[BX].MODEL_BYTE,LCD_MODEL ; and it has an LCD attached
  151. jnz tlab04
  152. mov ah,GET_STATUS ; system status will tell us
  153. int 15h
  154. test al,1 ; if bit 0 = 0 then LCD..
  155. jnz tlab04
  156. or HDWR_FLAG,LCD_ACTIVE ; so ...set hdwr flag and...
  157. lea si,COLOR_TABLE
  158. mov cx,COLOR_NUM ; load color table (for LCD)
  159. call LOAD_TABLE
  160. lea si,MONO_TABLE ; and mono table
  161. mov cx,MONO_NUM
  162. call LOAD_TABLE
  163. jmp short tlab05
  164. ; not LCD... check for CGA and mono
  165. tlab04:
  166. mov ax,MONO_ADDRESS ; write to mono buffer to see if present
  167. call CHECK_BUF
  168. cmp ah,al
  169. jnz tlab03 ; if present then,
  170. or HDWR_FLAG,MONO_ACTIVE ; set hdwr flag and..
  171. lea si,MONO_TABLE
  172. mov cx,MONO_NUM ; load mono table
  173. call LOAD_TABLE
  174. tlab03:
  175. mov ax,COLOR_ADDRESS ; write to CGA buffer to see if present
  176. call CHECK_BUF
  177. cmp ah,al
  178. jnz tlab02 ; if present then,
  179. or HDWR_FLAG,CGA_ACTIVE ; set hdwr flag and...
  180. lea si,COLOR_TABLE
  181. mov cx,COLOR_NUM ; load color table
  182. call LOAD_TABLE
  183. tlab02:
  184. tlab05:
  185. push cs ; setup addressiblity for
  186. pop es ; functionality call
  187. xor ax,ax
  188. mov ah,FUNC_call ; functionality call
  189. xor bx,bx ; implementation type 0
  190. lea DI,FUNC_INFO ; block to hold data
  191. int 10H
  192. cmp al,FUNC_call ; if call supported, then...
  193. jne tlab11
  194. mov ax,1A00h ; alternate check for VGA ;C03
  195. int 10h ; C03
  196. cmp bl,8 ; test for color VGA or mono VGA
  197. jz tlab08
  198. cmp bl,7
  199. jnz tlab09
  200. tlab08:
  201. or HDWR_FLAG,VGA_ACTIVE ; yes ....so
  202. lea si,COLOR_TABLE ; set hdwr flag and...
  203. mov cx,COLOR_NUM ; load color table +..
  204. call LOAD_TABLE
  205. lea si,VGA_TABLE ; load VGA table
  206. mov cx,VGA_NUM
  207. call LOAD_TABLE
  208. jmp short tlab07
  209. ; not VGA, must be MCGA
  210. tlab09:
  211. cmp [DI].ACTIVE_DISPLAY,MOD30_MONO
  212. jz tlab06
  213. cmp [DI].ACTIVE_DISPLAY,MOD30_COLOR
  214. jz tlab06
  215. cmp [DI].ALT_DISPLAY,MOD30_MONO
  216. jz tlab06
  217. cmp [DI].ALT_DISPLAY,MOD30_COLOR
  218. jnz tlab07
  219. tlab06:
  220. or HDWR_FLAG,MCGA_ACTIVE ; so...set hdwr flag and...
  221. lea si,COLOR_TABLE
  222. mov cx,COLOR_NUM ; load color table +..
  223. call LOAD_TABLE
  224. lea si,MCGA_TABLE ; load MCGA table
  225. mov cx,MCGA_NUM
  226. call LOAD_TABLE
  227. tlab07:
  228. mov al,[DI].CURRENT_SCANS ; copy current scan line setting..
  229. mov MAX_SCANS,al ; as maximum text mode scan setting.
  230. les DI,[DI].STATIC_ADDRESS ; point to static functionality table
  231. mov al,es:[DI].SCAN_TEXT ; load available scan line flag byte..
  232. mov SCAN_LINES,al ; and store it in resident data.
  233. jmp short DET_HDWR_DONE
  234. ; call not supported, try EGA
  235. tlab11:
  236. mov ah,alT_SELECT ; alternate select call
  237. mov BL,EGA_INFO ; get EGA information subcall
  238. int 10H
  239. cmp bl,EGA_INFO ; see if call was valid
  240. jz DET_HDWR_DONE
  241. cmp bh,MONOCHROME ; yes, check for monochrome
  242. jnz tlab17
  243. or HDWR_FLAG,E5151_ACTIVE ; ..5151 found so set hdwr flag and..
  244. lea si,EGA_5151_TABLE
  245. mov cx,EGA_5151_NUM ; load 5151 table.
  246. call LOAD_TABLE
  247. jmp short DET_HDWR_DONE
  248. tlab17:
  249. and CL,0FH ; clear upper nibble of switch setting byte
  250. cmp cl,9 ; test for switch settings of 5154
  251. jz tlab13
  252. cmp cl,3
  253. jnz tlab14
  254. tlab13:
  255. or HDWR_FLAG,E5154_ACTIVE ; so..set hdwr flag and...
  256. lea si,COLOR_TABLE
  257. mov cx,COLOR_NUM ; load color table +..
  258. call LOAD_TABLE
  259. lea si,EGA_5154_TABLE ; load 5154 table
  260. mov cx,EGA_5154_NUM
  261. call LOAD_TABLE
  262. jmp short DET_HDWR_DONE
  263. ; 5154 not found, must be 5153
  264. tlab14:
  265. or HDWR_FLAG,E5153_ACTIVE ; so..set hdwr flag and...
  266. lea si,COLOR_TABLE
  267. mov cx,COLOR_NUM ; load color table +..
  268. call LOAD_TABLE
  269. lea si,EGA_5153_TABLE ; load 5153 table
  270. mov cx,EGA_5153_NUM
  271. call LOAD_TABLE
  272. DET_HDWR_DONE:
  273. ret
  274. DET_HDWR ENDP
  275. ; PROCEDURE_NAME: CHECK_BUF
  276. ; FUNCTION:
  277. ; THIS PROCEDURE WRITES TO THE VIDEO BUFFER AND READS THE DATA BACK
  278. ; AGAIN TO DETERMINE THE EXISTANCE OF THE VIDEO CARD.
  279. ; AT ENTRY:
  280. ; AT EXIT:
  281. ; NORMAL: AH EQ AL IF BUFFER PRESENT
  282. ; AH NE AL IF NO BUFFER
  283. ; ERROR: N/A
  284. CHECK_BUF PROC NEAR ; write to video buffer to see if it is present
  285. push ds
  286. mov ds,ax ; load DS with address of buffer
  287. mov CH,ds:0 ; save buffer information (if present)
  288. mov al,55H ; prepare to write sample data
  289. mov ds:0,al ; write to buffer
  290. push BX ; terminate the bus so that lines..
  291. pop BX ; are reset
  292. mov ah,ds:0 ; bring sample data back...
  293. mov ds:0,CH ; repair damage to buffer
  294. pop ds
  295. ret
  296. CHECK_BUF ENDP
  297. ; PROCEDURE_NAME: LOAD_TABLE
  298. ; FUNCTION:
  299. ; THIS PROCEDURE COPIES ONE OF THE VIDEO TABLES INTO RESIDENT DATA.
  300. ; IT MAY BE REPEATED TO LOAD SEVERAL TABLES INTO THE SAME DATA SPACE.
  301. ; MATCHING MODES WILL BE OVERWRITTEN...THEREFORE..CARE MUST BE TAKEN
  302. ; IN LOAD ORDERING.
  303. ; AT ENTRY:
  304. ; SI: POINTS TO TOP OF TABLE TO COPY
  305. ; CX: NUMBER OF RECORDS TO COPY
  306. ; AT EXIT:
  307. ; NORMAL: TABLE POINTED TO BY SI IS COPIED INTO RESIDENT DATA AREA
  308. ; ERROR: N/A
  309. LOAD_TABLE PROC NEAR
  310. push DI ; save DI
  311. push es ; and ES
  312. push cs ; setup ES to code segment
  313. pop es
  314. lea DI,VIDEO_MODE_TABLE ; point DI to resident video table
  315. while01:
  316. cmp cx,0 ; do for as many records as there are
  317. jz while01_exit
  318. cmp di,VIDEO_TABLE_MAX ; check to ensure other data not overwritten
  319. jge while01_exit ; cas --- signed compare!!!
  320. mov al,[DI].V_MODE ; prepare to check resident table
  321. cmp al,UNOCCUPIED ; if this spot is occupied
  322. jz tlab20
  323. cmp al,[si].V_MODE ; and is not the same mode then
  324. jz tlab20
  325. add DI,TYPE MODE_TABLE ; do not touch...go to next mode
  326. jmp short while01
  327. ; can write at this location
  328. tlab20:
  329. push cx ; save record count
  330. mov cx,TYPE MODE_TABLE ; load record length
  331. rep movsb ; copy record to resident data
  332. lea DI,VIDEO_MODE_TABLE ; Set DI to the top of the target again.
  333. pop cx ; restore record count and..
  334. dec cx ; decrement
  335. jmp short while01
  336. while01_exit:
  337. pop es ; restore..
  338. pop DI ; registers
  339. ret
  340. LOAD_TABLE ENDP
  341. ; PROCEDURE_NAME: LOAD_INT10
  342. ; FUNCTION:
  343. ; THIS PROCEDURE LOADS THE INTERRUPT HANDLER FOR INT10H
  344. ; AT ENTRY:
  345. ; AT EXIT:
  346. ; NORMAL: INTERRUPT 10H VECTOR POINTS TO INT10_COM. OLD INT 10H
  347. ; VECTOR STORED.
  348. ; ERROR: N/A
  349. LOAD_INT10 PROC NEAR
  350. push es
  351. xor ax,ax ; point ES to low..
  352. mov es,ax ; memory.
  353. mov cx,es:WORD PTR INT10_LOW; store original..
  354. mov cs:ROM_INT10,cx ; interrupt 10h..
  355. mov cx,es:WORD PTR INT10_HI ; location..
  356. mov cs:ROM_INT10+2,cx
  357. cli
  358. mov es:WORD PTR INT10_LOW,OFFSET INT10_COM ; replace vector..
  359. mov es:WORD PTR INT10_HI,cs ; with our own..
  360. sti
  361. mov ax, DISPLAY_CHECK ;DISPLAY.SYS already loaded?
  362. int 2fh
  363. cmp al, INSTALLED
  364. jne L_INT10_Ret
  365. mov cs:Display_Loaded_Before_Me,1
  366. L_INT10_Ret:
  367. pop es
  368. ret
  369. LOAD_INT10 ENDP
  370. ; PROCEDURE_NAME: LOAD_INT2F
  371. ; FUNCTION:
  372. ; THIS PROCEDURE LOADS THE INTERRUPT HANDLER FOR INT2FH
  373. ; AT ENTRY:
  374. ; AT EXIT:
  375. ; NORMAL: INTERRUPT 2FH VECTOR POINTS TO INT2F_COM. OLD INT 2FH
  376. ; VECTOR STORED.
  377. ; ERROR: N/A
  378. LOAD_INT2F PROC NEAR
  379. push es
  380. xor ax,ax ; point ES to low..
  381. mov es,ax ; memory.
  382. mov ax,es:WORD PTR INT2F_LOW; store original..
  383. mov cs:ROM_INT2F,ax ; interrupt 2Fh..
  384. mov cx,es:WORD PTR INT2F_HI ; location..
  385. mov cs:ROM_INT2F+2,cx
  386. or ax,cx ; check if old int2F is 0
  387. jnz tlab21
  388. mov ax,OFFSET ABORT ; yes....point to..
  389. mov cs:ROM_INT2F,ax ; IRET.
  390. mov ax,cs
  391. mov cs:ROM_INT2F+2,ax
  392. tlab21:
  393. cli
  394. mov es:WORD PTR INT2F_LOW,OFFSET INT2F_COM ; replace vector..
  395. mov es:WORD PTR INT2F_HI,cs ; with our own..
  396. sti
  397. pop es
  398. ret
  399. LOAD_INT2F ENDP
  400. CODE ENDS
  401. END
  402.