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.

1048 lines
42 KiB

  1. PAGE ,132
  2. TITLE MS DOS 5.0 - NLS Support - KEYB Command
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. ; MS DOS 5.0 - NLS Support - KEYB Command
  5. ; (C) Copyright Microsoft Corp 1987-1991
  6. ;
  7. ; File Name: COMMSUBS.ASM
  8. ; ----------
  9. ;
  10. ; Description:
  11. ; ------------
  12. ; Common subroutines used by NLS support
  13. ;
  14. ; Documentation Reference:
  15. ; ------------------------
  16. ; None
  17. ;
  18. ; Procedures Contained in This File:
  19. ; ----------------------------------
  20. ;
  21. ; FIND_HW_TYPE - Determine the keyboard and system unit types and
  22. ; set the corresponding flags.
  23. ;
  24. ; Include Files Required:
  25. ; -----------------------
  26. ; None
  27. ;
  28. ; External Procedure References:
  29. ; ------------------------------
  30. ; FROM FILE ????????.ASM:
  31. ; ????????? - ???????
  32. ;
  33. ; Change History:
  34. ; ---------------
  35. ; Sept 1989 For 4.02.
  36. ; Add required JMP $+2 between OUT/IN in KEYB_SECURE,
  37. ; remove unnecessary code and re-document routine.
  38. ; Remove unnecessary PUSH/POP's around call to KEYB_SECURE.
  39. ; Fix bug in FIND_KEYB_TYPE of READ ID flags not being
  40. ; cleared on PS/2's when keyboard is security locked.
  41. ; Clean up BIOS DATA & Extended DATA area access, use ES:.
  42. ; Arrange KB type checks into special case group and 8042.
  43. ; Fix delay loop timeout bug at WT_ID with REFRESH BIT type
  44. ; fixed timeout delay of 15ms. When the KBX flag is set
  45. ; by BIOS, the READ_ID is done and PORT 60h is ID_2 byte.
  46. ; AT (FCh) type machines all have the Refresh Bit at 61h.
  47. ; Change SND_DATA_AT proc to a general send command routine
  48. ; with REFRESH BIT timout logic and move the P-Layout test
  49. ; into FIND_KEYB_TYPE. Allows P-kb on all 8042 systems.
  50. ; Add untranslated ID_2 byte to P-layout support for newer
  51. ; PS/2's with hardware logic instead of 8042 if AT type.
  52. ;
  53. ; Feb 1990 For 4.03.
  54. ; PTM 6660 Add default to PC_386 type for new/unsupported system.
  55. ; Move determination code from KEYBI9C.ASM for original PC.
  56. ; Add Patriot/Sebring determination code for HOT Replug
  57. ; so that INT 9 handler can alter keyboard Scan Code set.
  58. ; Unknown system default= PC_386 with Patriot/Sebring test.
  59. ; Add EXT_122 check for 122 key keyboard to SYSTEM_FLAG.
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. PUBLIC FIND_SYS_TYPE
  62. PUBLIC FIND_KEYB_TYPE
  63. PUBLIC HW_TYPE
  64. PUBLIC SECURE_FL
  65. ifdef JAPAN
  66. ; EXTRN's to KEYBI9C.ASM
  67. EXTRN BEEP_DELAY:WORD ; Value for error beep delay
  68. EXTRN S_122_MARKER:BYTE ; 122 key marker F8 or E0
  69. EXTRN READ_ID2:BYTE ; Second byte of last READ ID
  70. EXTRN SCAN_CODE_SET:BYTE ; 01 for non SBCS keyboard (default)
  71. ; 81h or 82h for DBCS keyboard
  72. ; This value is used at hot replug.
  73. EXTRN keyb_table:byte ; keyboard search table
  74. EXTRN FILE_NAME:byte ; keyboard definition file name
  75. endif ; JAPAN
  76. INCLUDE KEYBEQU.INC
  77. INCLUDE KEYBCPSD.INC
  78. INCLUDE KEYBSHAR.INC
  79. INCLUDE KEYBI9C.INC
  80. INCLUDE KEYBCMD.INC
  81. INCLUDE DSEG.INC
  82. INCLUDE POSTEQU.INC
  83. ifdef JAPAN
  84. INCLUDE KEYBDCL.INC
  85. endif ; JAPAN
  86. CODE SEGMENT PUBLIC 'CODE'
  87. ASSUME CS:CODE,DS:CODE
  88. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  89. ;
  90. ; Module: FIND_SYS_TYPE
  91. ;
  92. ; Description:
  93. ; Determine the type of system we are running on.
  94. ; SYSTEM_FLAG (in active SHARED_DATA) are set to
  95. ; indicate the system type.
  96. ; This routine is only called the first time KEYB is being installed.
  97. ;
  98. ;
  99. ; Input Registers:
  100. ; DS - points to our data segment
  101. ;
  102. ; Output Registers:
  103. ; NONE
  104. ;
  105. ; Logic:
  106. ;
  107. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  108. ROM SEGMENT AT 0F000H
  109. ORG 0FFFBH
  110. SYSROM_DATE DW ? ; OFFSET OF ROM YEAR DIGIT
  111. PC1DATE_ID EQU 03138H ; YEAR ROM WAS RELEASED IN ASCII
  112. ORG 0FFFEH
  113. ROMID DB ?
  114. ; SEGMENT F000. (F000:FFFE)
  115. ROMPC1 EQU 0FFH ; ID OF PC1 hardware
  116. ROMXT EQU 0FEH ; ID OF PC-XT/PORTABLE hardware
  117. ROMAT EQU 0FCH ; ID OF PCAT
  118. ROMXT_ENHAN EQU 0FBH ; ID OF ENHANCED PCXT
  119. ROMPAL EQU 0FAH ; ID FOR PALACE
  120. ROMLAP EQU 0F9H ; ID FOR PC LAP (P-14)
  121. ROM_RU_386 EQU 0F8H ; ID FOR ROUNDUP-386
  122. ROM ENDS
  123. ifdef JAPAN
  124. RTN_EXT_BIOS_DATA_SEG EQU 0C1H ; INT15H SUB FUNCTION M005 -- JP9009
  125. endif ; JAPAN
  126. ROMEXT SEGMENT AT 00000H ; ADDRESS SHOULD NOT BE FIXED AT 09FC0H
  127. ; This just a dummy segment value, as
  128. ORG 0003BH ; INT 15h - function C1 call will load
  129. KEYBID1 DB ? ; ES: dynamically depending on where
  130. ; the ROMEXT segment is located.
  131. ; (9FC0 was only for old 640K systems)
  132. ifdef JAPAN
  133. ORG 00117H ; ;JP9009
  134. EXT_BIOS_DATA_KBD_ID DW ? ; KEYBOARD ID(xxABH) ;JP9009
  135. endif ; JAPAN
  136. ROMEXT ENDS ; ( ES:003B )
  137. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  138. ; Program Code
  139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  140. FIND_SYS_TYPE PROC NEAR
  141. MOV AX,ROM ; Set segmant to look at ROM
  142. MOV DS,AX ; using the data segment
  143. ASSUME DS:ROM
  144. MOV AX,SYSROM_DATE ; Get BIOS year date
  145. PUSH AX ; save it on stack
  146. MOV AL,ROMID ; Get hardware ID
  147. PUSH AX ; save it
  148. PUSH CS ; Set data seg back to code
  149. POP DS
  150. ASSUME DS:CODE
  151. MOV AH,092H ; SET INVALID CALL FOR INT16 83 KEYS
  152. INT 16H ; CALL BIOS
  153. CMP AH,80H ; IS EXTENDED INTERFACE THERE? 101/102
  154. JA CHECK_PC_NET ; NO, SKIP FLAG
  155. OR SD.SYSTEM_FLAG,EXT_16 ; Default is extended INT 16 support
  156. MOV AH,0A2H ; SET INVALID CALL FOR INT16 101 KEYS
  157. INT 16H ; CALL BIOS
  158. CMP AH,80H ; IS EXTENDED INTERFACE THERE? 122/
  159. JA CHECK_PC_NET ; NO, SKIP FLAG
  160. OR SD.SYSTEM_FLAG,EXT_122 ; Also extended 122 keyboard support
  161. CHECK_PC_NET:
  162. MOV AH,30H ; GET DOS VERSION NUMBER
  163. INT 21H ; MAJOR # IN AL, MINOR # IN AH
  164. CMP AX,0A03H ; SENSITIVE TO 3.10 OR >
  165. JB CHECK_SYSTEM ; EARLIER VERSION OF DOS NOTHING
  166. ; WAS ESTABLISHED FOR THIS SITUATION
  167. PUSH ES ; Save ES just in case
  168. MOV AX,3509H ; GET INT VECTOR 9 CONTENTS
  169. INT 21H ; ES:BX WILL = CURRENT INT9 VECTOR
  170. ; SEE IF WE ARE THE 1ST ONES LOADED
  171. MOV CX,ES ; INTO THE INT 9. WITH DOS 3.1 WE CAN
  172. POP ES ; HANDSHAKE WITH THE PC NETWORK BUT
  173. CMP CX,0F000H ; BUT NO ONE ELSE CAN BE HOOK IN FIRST
  174. JE CHECK_SYSTEM ; INT VECTOR 9 POINTS TO ROM, OK
  175. MOV AX,0B800H ; ASK IF PC NETWORK IS INSTALLED
  176. INT 2FH
  177. or al,al ; not installed if al=0
  178. JE CHECK_SYSTEM ; SOMEBODY HAS LINKED THE INT VECTOR 9
  179. ; & I'M GOING TO DROP RIGHT IN AS USUAL
  180. OR SD.SYSTEM_FLAG,PC_NET ; INDICATE PC NET IS RUNNING
  181. CHECK_SYSTEM:
  182. ifdef JAPAN
  183. ; Determine if REFRESH BIT works OK ;AN012
  184. MOV BEEP_DELAY,36 ; Set error beep delay for XT machines ;AN012
  185. XOR CX,CX ; Clear timeout loop counter ;AN012
  186. CHECK_SYST5: ;AN012
  187. IN AL,PORT_B ; Read current system status port ;AN012
  188. AND AL,REFRESH_BIT ; Mask all but refresh bit ;AN012
  189. LOOPNZ CHECK_SYST5 ; Loop till we see the bit OFF ;AN012
  190. JCXZ CHECK_SYST7 ; Exit if it fails to go OFF ;AN012
  191. CHECK_SYST6: ;AN012
  192. IN AL,PORT_B ; Read current system status port ;AN012
  193. AND AL,REFRESH_BIT ; Mask all but refresh bit ;AN012
  194. LOOPZ CHECK_SYST6 ; Loop till we see the bit ON ;AN012
  195. JCXZ CHECK_SYST7 ; Exit if it fails to go ON ;AN012
  196. MOV BEEP_DELAY,19 ; Set Refresh delay loop constant ;AN012
  197. CHECK_SYST7: ;AN012
  198. PUSH ES ; Check for broken INT 16h BIOS ;AN013
  199. MOV AH,0C0h ; Configuration function ;AN013
  200. INT 15h ; System services call ;AN013
  201. JC CHECK_SYST8 ; Skip if not supported by system ;AN013
  202. ; Check Model/submodel/revision ;AN013
  203. CMP word ptr ES:[BX+2],019F8h ; Initial ship level of 122 broken ;AN013
  204. JNE CHECK_SYST8 ; Skip if not broken INT 16h model/sub ;AN013
  205. CMP byte ptr ES:[BX+4],005h ; Is it the bad revision level ;AN013
  206. JA CHECK_SYST8 ; Skip if not the broken code ;AN013
  207. ; ELSE ;AN013
  208. MOV S_122_MARKER,0 ; Change 122 key F8h marker to an 00h ;AN013
  209. ; F8,19,05 and below do not support F8 ;AN013
  210. CHECK_SYST8: ;AN013
  211. POP ES ; Restore ;AN013
  212. endif ; JAPAN
  213. POP AX ; get code back
  214. POP BX ; get date back off of stack
  215. ; Is the hardware a PCjr
  216. ; Is the hardware a PC1 or XT ?
  217. CMP AL,ROMXT
  218. JAE ITS_AN_XT ; IF (FE) OR (FF) THEN ITS AN XT
  219. CMP AL,ROMXT_ENHAN ; IF (FB) IT IS ALSO AN XT
  220. JNE TEST_PC_AT ; IF not then check for next type
  221. ITS_AN_XT:
  222. OR SD.SYSTEM_FLAG,PC_XT ; system type
  223. ; Check the ROM level in the system
  224. CMP BX,PC1DATE_ID ; Is it the ORIGINAL PC1 version?
  225. JNE SHORT FIND_SYS_END ; Done if not
  226. OR SD.SYSTEM_FLAG,PC_81 ; Else set the Original PC1 flag
  227. JMP SHORT FIND_SYS_END
  228. TEST_PC_AT:
  229. ; Is the hardware an AT ?
  230. CMP AL,ROMAT ; (FC)
  231. JNE TEST_P12 ; IF not then check for next type
  232. OR SD.SYSTEM_FLAG,PC_AT ; system type with 8042 V2 interface
  233. JMP SHORT FIND_SYS_END
  234. TEST_P12:
  235. CMP AL,ROMLAP ; IS this a Convertible (F9) (P12)?
  236. JNE TEST_PAL ; IF not then check for next type
  237. OR SD.SYSTEM_FLAG,PC_LAP ; system type
  238. JMP SHORT FIND_SYS_END
  239. TEST_PAL:
  240. CMP AL,ROMPAL ; IS this a Model 30 (FA) (PALACE)?
  241. JNE TEST_RU_386 ; IF not then check for next type
  242. OR SD.SYSTEM_FLAG,PC_PAL ; system type
  243. ifdef JAPAN
  244. MOV BEEP_DELAY,88 ; Set error beep delay for 8086 machine;AN012
  245. endif ; JAPAN
  246. JMP SHORT FIND_SYS_END
  247. TEST_RU_386:
  248. CMP AL,ROM_RU_386 ; IS this a PS/2 with a 386 (F8)?
  249. JNE TEST_SYS_NEW ; IF not then check for next type
  250. OR SD.SYSTEM_FLAG,PC_386 ; System type with 8042 V3
  251. CALL SP_8042 ; Determine if 8042 is Patriot/Sebring
  252. JMP SHORT FIND_SYS_END
  253. TEST_SYS_NEW:
  254. ; ASSUME 8042 TYPE IF UNKNOWN
  255. OR SD.SYSTEM_FLAG,PC_386 ; Default system type with 8042 V3
  256. CALL SP_8042 ; Determine if 8042 is Patriot/Sebring
  257. FIND_SYS_END:
  258. RET
  259. FIND_SYS_TYPE ENDP
  260. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  261. ;
  262. ; Module: FIND_KEYB_TYPE
  263. ;
  264. ; Description:
  265. ; Determine the type of keyboard we are running on.
  266. ; KEYB_TYPE (in SHARED_DATA) is set to indicate the keyboard type.
  267. ; This routine is only called the first time KEYB is being installed.
  268. ; It is called after the new Interrupt 9 handler is installed.
  269. ;
  270. ; Input Registers:
  271. ; DS - points to our data segment
  272. ;
  273. ; Output Registers:
  274. ; NONE
  275. ;
  276. ; Logic:
  277. ;
  278. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  279. HW_TYPE DW 0
  280. SECURE_FL DB 0
  281. ifndef JAPAN
  282. ;RESERVED ADDRESS 013h BITS 1 & 2
  283. PASS_MODE equ 00000001B
  284. SERVER_MODE equ 00000010B
  285. SECRET_ADD equ 13h
  286. PORT_70 equ 70h ; CMOS ADDRESS PORT
  287. PORT_71 equ 71h ; CMOS DATA PORT
  288. endif ; !JAPAN
  289. ID_1 EQU 0ABh ; Keyboard ID_1 for FERRARI
  290. TID_2 EQU 041h ;;AB41 ; Keyboard ID_2 for FERRARI_G
  291. ID_2U EQU 083h ;;AB83 ; Keyboard ID_2 for FERRARI_G
  292. TID_2A EQU 054h ;;AB54 ; Keyboard ID_2 for FERRARI_P
  293. ID_2AU EQU 084h ;;AB84 ; Keyboard ID_2 for FERRARI_P
  294. ID_2JG EQU 090h ;;AB90 ; Keyboard ID_2 for JPN G
  295. ID_2JP EQU 091h ;;AB91 ; Keyboard ID_2 for JPN P
  296. ID_2JA EQU 092h ;;AB92 ; Keyboard ID_2 for JPN A
  297. P_KB_ID DB 08
  298. extrn pswitches:byte
  299. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  300. ; Program Code
  301. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  302. FIND_KEYB_TYPE PROC NEAR
  303. ; we need these code until be prepared code for NTVDM (MSKK)
  304. ; KKFIX Make it KK specific 10/17/96
  305. ifdef JAPAN
  306. ;if 1
  307. ;ifdef NOT_NTVDM
  308. PUSH ES
  309. PUSH DS
  310. MOV AX,DATA
  311. MOV ES,AX ; ES points to BIOS data
  312. ASSUME ES:DATA
  313. MOV AX,ROM ; Set segmant to look at ROM
  314. MOV DS,AX ; using the data segment
  315. ASSUME DS:ROM
  316. MOV AL,ROMID ; Get hardware ID
  317. PUSH CS ; Set data segment to CODE
  318. POP DS
  319. ASSUME DS:CODE
  320. test pswitches,2 ; /e switch true?
  321. jz no_force_enh
  322. or es:KB_FLAG_3,KBX ; force enhanced kbd support on
  323. no_force_enh:
  324. MOV HW_TYPE,G_KB ; Default keyboard is G_KB
  325. CMP AL,ROMLAP ; IS this a P12? (CONVERTABLE)
  326. JNE TEST_PC_XT_2 ; IF not then check for next type
  327. MOV HW_TYPE,P12_KB ; IF yes then set flag
  328. JMP FIND_KEYB_END ; Done
  329. TEST_PC_XT_2:
  330. ; Is the hardware a PC1 or XT ?
  331. CMP AL,ROMXT
  332. JAE ITS_AN_XT_2 ; IF FE OR FF THEN ITS AN XT
  333. CMP AL,ROMXT_ENHAN ; IF FB IT IS ALSO AN XT
  334. JNE TEST_PS_30_2 ; IF not then check for next type
  335. ITS_AN_XT_2:
  336. TEST ES:KB_FLAG_3,KBX ; IS THE ENHANCED KEYBOARD INSTALLED?
  337. JZ ITS_AN_XT_3
  338. ifndef JAPAN
  339. JMP SHORT FIND_KEYB_END ; Yes, exit
  340. else ; JAPAN
  341. JMP FIND_KEYB_END ; Yes, exit
  342. endif ; JAPAN
  343. ITS_AN_XT_3:
  344. MOV HW_TYPE,XT_KB ; NO, normal XT keyboard
  345. ifndef JAPAN
  346. JMP SHORT FIND_KEYB_END
  347. else ; JAPAN
  348. JMP FIND_KEYB_END
  349. endif ; JAPAN
  350. TEST_PS_30_2:
  351. CMP AL,ROMPAL ; IS this a PS/2 MODEL 30 or 25
  352. JNE TEST_PC_AT_2 ; IF not then check for next type
  353. MOV AH,0C1H ; Make extended bios data area call to
  354. INT 15H ; get the segment address for accessing
  355. JNC ITS_AN_PS2_30 ; the PALACE (only) keyboard byte area.
  356. ifndef JAPAN
  357. JMP SHORT FIND_KEYB_END ; JC Assume Keyboard type G if error,
  358. else ; JAPAN
  359. JMP FIND_KEYB_END ; JC Assume Keyboard type G if error,
  360. endif ; JAPAN
  361. ; Otherwise EXTENDED BIOS DATA RETURNED
  362. ; in the ES: and ES:003Bh is keyboard
  363. ITS_AN_PS2_30: ; ID byte reserved for PALACE.
  364. ; Set segment to look at extended ROM
  365. ASSUME ES:ROMEXT ; using the ES: segment
  366. ; SEG ES: value returned by INT15h - C1
  367. MOV AL,KEYBID1 ; Get keyboard ID
  368. ASSUME ES:NOTHING ; Don't use ES: for anything else
  369. AND AL,0FH ; Remove high nibble
  370. CMP AL,P_KB_ID ; IF keyboard is a FERRARI P THEN
  371. JNE ITS_AN_PS2_30G
  372. OR HW_TYPE,P_KB ; Set the HW_TYPE flag to P keyboard
  373. ITS_AN_PS2_30G:
  374. JMP SHORT FIND_KEYB_END ; Done
  375. ; (Insert any more special cases here.)
  376. ; At this point, all special case or older keyboard/system
  377. ; types have been determined and HW_TYPE correctly set.
  378. ; (PC, XT, XT Enhansed, CONVERTABLE, Model 30/25)
  379. ;
  380. ; Assume now that the system has an 8042 type keyboard
  381. ; interface and can be sent a READ ID command to determine
  382. ifndef JAPAN
  383. ; the type of keyboard installed. The old AT keyboard is
  384. ; handled as a special case of no security bits set and no
  385. ; response to a READ ID command. If security bits are set
  386. ; and no KBX flag is set as a result of the READ ID, then
  387. ; the interface is assumed to be locked and the default of
  388. ; G-keyboard is taken as the keyboard ID can not be read.
  389. else ; JAPAN
  390. ; the type of keyboard installed. First we check to see if the ;AN011
  391. ; interface is inhibited by either the password lock (PS/2) or a ;AN011
  392. ; keylock. If not, we set Read ID in process, clear last ID byte 2 ;AN011
  393. ; read by the KEYBI9C INT 9h handler, send a READ ID command to the ;AN011
  394. ; keyboard and wait for the second ID byte save location to change. ;AN011
  395. ; A timeout of this operation indicates either an old AT style keyboard ;M000
  396. ; or no keyboard attached and we set the type of keyboard to AT_KB, ;AN011
  397. ; unless the KBX flag has been turned on by the /E switch, default G_KB. ;AN011
  398. ; Any E0 will force KBX on, but APPS will not see it unless /E was used. ;AN011
  399. ; Mouse/AUX conflicts are handled by an extra long delay here and a ;AN011
  400. ; retry loop, checking that the returned value for ID 2 is not invalid. ;AN011
  401. ; ;AN011
  402. ; However if the interface is inhibited we will check to see if this ;AN011
  403. ; is a DBCS enabled machine, that does a READ ID during POST and saves ;AN011
  404. ; the keyboard ID in the extended data area, and use this data. We ;AN011
  405. ; also set a flag indicating the security mode is set, so that the ;AN011
  406. ; correct Scan Code Set can be sent to the keyboard when it is unlocked. ;AN011
  407. ; If not a DBCS machine we will again default to the G-keyboard. ;M000
  408. endif ; JAPAN
  409. TEST_PC_AT_2:
  410. ASSUME ES:DATA ; READ ID COMMAND TO TEST FOR A KBX
  411. ifndef JAPAN
  412. MOV ES:KB_FLAG_3,RD_ID ; INDICATE THAT A READ ID IS BEING DONE
  413. ; and clear KBX flag if set
  414. MOV AL,0F2H ; SEND THE READ ID COMMAND
  415. CALL SND_DATA_AT
  416. ; Wait 40ms for READ ID to complete
  417. MOV CX,DLY_15ms ; Load count for 15ms (15,000/15.086)
  418. WT_ID: ; Fixed time wait loop on AT's
  419. TEST ES:KB_FLAG_3,KBX ; TEST FOR KBX SET by BIOS interrupt 9h
  420. JNZ DONE_AT_2 ; Exit wait loop if/when flag gets set
  421. else ; JAPAN
  422. AND ES:KB_FLAG_3,NOT LC_E0+LC_AB ; Clear hidden code and first ID ;AN011
  423. ; Do not clear the KBX flag (/E) ;AN011
  424. MOV BL,5 ; Set READ ID retry count to 5 tries ;AN011
  425. ;AN011
  426. IN AL,STATUS_PORT ; Check for the KEYBOARD INHIBIT bit ;AN011
  427. TEST AL,KYBD_INH ; to see if server mode or keylocked. ;AN011
  428. JNZ ASK_KEYBOARD ; If not inhibited, ask the keyboard ID;AN011
  429. JMP ASK_ROM_BIOS ; If inhibited, see if POST read the ID;AN011
  430. ASK_KEYBOARD: ; ASK keyboard it's ID ;AN011
  431. MOV READ_ID2,0 ; Clear READ ID byte 2 save location ;AN011
  432. ; INT 9h will now set it to ID byte 2 ;AN011
  433. OR ES:KB_FLAG_3,RD_ID ; INDICATE THAT A READ ID IS BEING DONE;AN011
  434. ; and do not clear KBX flag set by /E ;AN011
  435. if 0 ; can not send read id command. (MSKK)
  436. MOV AL,0F2H ; SEND THE READ ID COMMAND
  437. CALL SND_DATA_AT
  438. endif
  439. ; Wait 30ms for READ ID to complete ;AN011
  440. MOV CX,DLY_15ms*2 ; Load count for 30ms (15,000/15.086)*2;AN011
  441. WT_ID: ; Fixed time wait loop on AT's
  442. CMP READ_ID2,0 ; TEST FOR BIOS interrupt 9h to set ID ;AN011
  443. JNZ DONE_AT_2 ; Exit wait loop if/when flag gets set
  444. TEST ES:KB_FLAG_3,RD_ID+LC_AB; Test for unexpected scan code ending ;AN012
  445. JZ ID_ERROR ; READ ID or clearing hang condition ;AN012
  446. endif ; JAPAN
  447. IN AL,PORT_B ; Read current system status port
  448. AND AL,REFRESH_BIT ; Mask all but refresh bit
  449. CMP AL,AH ; Did it change? (or first pass thru)
  450. JZ WT_ID ; No, wait for change, else continue
  451. ifdef JAPAN
  452. ID_ERROR: ; Read ID error exit, must clear CX ;AN011
  453. endif ; JAPAN
  454. MOV AH,AL ; Save new refresh bit state
  455. LOOP WT_ID ; WAIT OTHERWISE
  456. ; BE SURE READ ID FLAGS GOT RESET
  457. AND ES:KB_FLAG_3,NOT RD_ID+LC_AB ; Clear READ ID state flags
  458. ifdef JAPAN
  459. ; As no ID byte 2 was read/set ;AN011
  460. DEC BL ; Decrement retry counter ;AN011
  461. JNZ ASK_KEYBOARD ; Try five times to get a valid ID ;AN011
  462. TEST ES:KB_FLAG_3,KBX ; Is the KBX flag ON from /E switch ;AN011
  463. JNZ KBX_OK ; If ON, use default G_KB as keyboard ;AN011
  464. MOV HW_TYPE,AT_KB ; NO, AT KBD if no KBX and no security ;AN011
  465. KBX_OK: ;AN011
  466. JMP SHORT FIND_KEYB_END ; EXIT :AN011
  467. else ; !JAPAN
  468. ; As no KBX flag set
  469. CALL KEYB_SECURE ; SEE IF THE KEYBOARD SECURITY IS
  470. ; ACTIVATED AT THIS POINT
  471. JNC ASSUME_AT ; SECURITY UNAVAILABLE OR AN AT KB
  472. MOV SECURE_FL,1 ; SECURITY IS ACTIVE
  473. JMP SHORT FIND_KEYB_END ; ASSUME IT IS A G_KB WITH
  474. ; NUM LOCK OFF
  475. ASSUME_AT:
  476. MOV HW_TYPE,AT_KB ; NO, AT KBD if no KBX and no security
  477. JMP SHORT FIND_KEYB_END ; EXIT
  478. endif ; !JAPAN
  479. DONE_AT_2: ; LAST PORT 60h VALUE IS ID_2 BYTE
  480. ifndef JAPAN
  481. IN AL,PORT_A ; Re-read last byte from keyboard input
  482. else ; JAPAN
  483. ;AN011 ; IN al,60h here causes missed ID2's
  484. MOV AL,READ_ID2 ; Get the ID2 byte just read by KEYBI9C;AN011
  485. DEC BL ; Decrement READ ID retry counter ;AN011
  486. JZ ID_USE ; Skip range check if retries exhausted;AN011
  487. CMP AL,ID_1 ; Did we get the ID1 byte twice ;AN011
  488. JE ASK_KEYBOARD ; Retry read ID if this happens ;AN011
  489. CMP AL,TID_2 ; Check that the ID read is valid range;AN011
  490. JB ASK_KEYBOARD ; Try again if not 41h or greater ;AN011
  491. ID_USE: ;AN011
  492. ; M005 -- begin changed section
  493. CALL SET_KBD_ID_TO_ROM_EXT ; This is DBCS requirement. There are ;JP9009
  494. ; five kinds of DBCS keyboards. We ;JP9009
  495. ; need to distinguish them. ;JP9009
  496. CMP AL, ID_2JG ; Was it old DBCS keyboards? ;JP9009
  497. JAE CHECK_WHAT_DBCS_KBD ; Check what it is. ;JP9009
  498. DONE_AT_FOR_G_P_TYPE: ;JP9011
  499. ; M005 -- end changed section
  500. endif ; JAPAN
  501. CMP AL,TID_2A ; Was it the P-layout keyboard
  502. JE DONE_AT_3 ; Go set P type keyboard
  503. CMP AL,ID_2AU ; Was it the P-layout untranslated
  504. JNE DONE_AT_4 ; Continue if not
  505. DONE_AT_3:
  506. OR HW_TYPE,P_KB ; Set HW_TYPE for P-layout keyboard
  507. DONE_AT_4:
  508. ; EXIT
  509. FIND_KEYB_END: ; EXIT POINT
  510. MOV AX,HW_TYPE ; Get default or determined type
  511. ifndef JAPAN
  512. MOV SD.KEYB_TYPE,AX ; Place into shared data area
  513. POP DS
  514. POP ES
  515. else ; JAPAN
  516. ; M005 -- begin changed section
  517. ; ;JP9009
  518. ; New DBCS keyboards' ID is the same as that of SBCS 101/102 key ;JP9009
  519. ; keyboard. So, we can distinguish them only by the language parameter ;JP9009
  520. ; string. ;JP9009
  521. ; ;JP9009
  522. ;+ AN015-- Delete this out for now per request of Japanese.
  523. ;+ They can not assume ID's for other countries. Actually we
  524. ;+ need a better way to determine if DBCS mode should be made active.
  525. ;+ This really need to be handled in the KEYBOARD.SYS files and set here.
  526. ;+
  527. ;AN015 MOV CX, WORD PTR [BP].LANGUAGE_PARM; Get language specified. ;JP9009
  528. ;AN015 CMP CX, 'PJ' ; Japanese keyboard? ;JP9009
  529. ;AN015 JE DBCS_KEYBOARD ;JP9009
  530. ;AN015 CMP CX, 'OK' ; Korea keyboard? ;JP9009
  531. ;AN015 JE DBCS_KEYBOARD ;JP9009
  532. ;AN015 CMP CX, 'RP' ; PRC keyboard? ;JP9009
  533. ;AN015 JE DBCS_KEYBOARD ;JP9009
  534. ;AN015 CMP CX, 'AT' ; Taiwan keyboard? ;JP9009
  535. ;AN015 JNE SBCS_KEYBOARD ;JP9009
  536. ;AN015 DBCS_KEYBOARD: ;JP9009
  537. ;JP9110 CMP WORD PTR [BP].LANGUAGE_PARM,'PJ' ; Japanese keyboard language ;AN015
  538. CALL IS_DBCS_KEYBOARD_LAYOUT ; DBCS layout? ;JP9110
  539. JNE SBCS_KEYBOARD ; Skip DBCS if not ;AN015
  540. OR AX, DBCS_KB ; Set it as DBCS keyboard ;JP9009
  541. OR SD.SYSTEM_FLAG,DBCS_OK ; Set DBCS flag for INT 9 handler ;AN013
  542. ; Determine keyboard sub type for Japanese keyboard
  543. push si
  544. push ds
  545. pop es
  546. ASSUME ES:CODE
  547. MOV si,offset FILE_NAME
  548. xor dx,dx
  549. push ax
  550. find_filename:
  551. lodsb
  552. and al,al ; extract only file name
  553. jz check_def_file
  554. cmp al,'\'
  555. jnz find_filename
  556. mov dx,si
  557. jmp short find_filename
  558. check_def_file:
  559. and dx,dx
  560. jz check_end
  561. lea si,keyb_table
  562. check_file2:
  563. xor cx,cx
  564. lodsb
  565. and al,al
  566. jz check_end
  567. mov cl,al
  568. mov di,dx
  569. repe cmpsb ; find match driver name
  570. jz match_driver
  571. add si,cx
  572. inc si
  573. jmp check_file2
  574. match_driver:
  575. mov cl,[si]
  576. check_end:
  577. pop ax ; key type
  578. or al,cl ; add keyboard sub type
  579. pop si
  580. SBCS_KEYBOARD: ;JP9009
  581. ; M005 -- end changed section
  582. MOV SD.KEYB_TYPE,AX ; Place into shared data area
  583. POP DS
  584. POP ES
  585. RET
  586. ; M005 -- begin changed section
  587. ASK_ROM_BIOS: ;JP9010
  588. OR SD.SYSTEM_FLAG, SECURITY_ACTIVE ; Set keyboard LOCK active, ;AN011
  589. ; it will clear when password entered ;AN011
  590. MOV SECURE_FL,1 ; SECURITY IS ACTIVE ;AN011
  591. PUSH ES ; ;JP9011
  592. MOV AH, RTN_EXT_BIOS_DATA_SEG; GET EXTENDED BIOS DATA AREA SEGMENT ;JP9010
  593. INT 15H ; ;JP9010
  594. ASSUME ES:ROMEXT ; ;JP9009
  595. ;AN011 MOV AL, BYTE PTR ES:EXT_BIOS_DATA_KBD_ID + 1; ;JP9010
  596. MOV AX,ES:EXT_BIOS_DATA_KBD_ID ; Get both bytes of ID ;AN011
  597. ASSUME ES:DATA ; ;JP9009
  598. POP ES ; AH = HIGH BYTE OF KEYBOARD ID ;JP9011
  599. JC FIND_KEYB_END ; 0 IF NOT SUPPORTED ;JP9011
  600. CMP AL,ID_1 ; Is this valid READ ID data ;AN011
  601. JNE FIND_KEYB_END ; Exit if not supported on this system ;AN011
  602. MOV AL,AH ; Move READ ID byte 2 into register ;AN011
  603. CMP AL, ID_2JG ; ;JP9010
  604. JB DONE_AT_FOR_G_P_TYPE ; WE GOT KEYB_TYPE FROM ROM BIOS, SO ;JP9011
  605. ; RETURN TO NORMAL PROCEDURE ;JP9011
  606. CHECK_WHAT_DBCS_KBD: ;JP9009
  607. ;JP9110 MOV HW_TYPE, (DBCS_OLD_G_KB or DBCS_OLD_P_KB) ;JP9009
  608. OR HW_TYPE, (DBCS_OLD_G_KB or DBCS_OLD_P_KB) ;JP9110
  609. CMP AL, ID_2JA ; Was it old DBCS A keyboard? ;JP9009
  610. JNE SET_SCAN_TABLE ; Go if old DBCS G/P keyboard. ;JP9009
  611. ;JP9110 MOV HW_TYPE, DBCS_OLD_A_KB ;JP9009
  612. AND HW_TYPE, NOT (DBCS_OLD_G_KB or DBCS_OLD_P_KB) ;JP9110
  613. OR HW_TYPE, DBCS_OLD_A_KB ;JP9110
  614. SET_SCAN_TABLE: ;JP9009
  615. MOV AL,82h ; SELECT SCAN CODE SET 82 ;JP9009
  616. TEST SD.SYSTEM_FLAG,PS_8042 ; If in passthru mode without 8042 ;JP9009
  617. JZ CHANGE_SCAN_TABLE ; then set scan code set 81 ;JP9009
  618. MOV AL,81h ; SELECT SCAN CODE SET 81 ;JP9009
  619. CHANGE_SCAN_TABLE: ;JP9009
  620. MOV SCAN_CODE_SET, AL ; 81h or 82h for old DBCS keyboard ;JP9009
  621. ; This is also used at hot replug. ;JP9009
  622. CMP SECURE_FL, 1 ; IF SECURITY ACTIVE, RETURN ;JP9010
  623. ; JE FIND_KEYB_END ; ;JP9010
  624. JNE FIND_KEYB_SCAN ; QFESP4
  625. JMP FIND_KEYB_END ; QFESP4
  626. FIND_KEYB_SCAN: ; QFESP4
  627. MOV AL,SCAN_CODE_CMD ; SELECT SCAN CODE SET COMMAND ;JP9009
  628. CALL SND_DATA_AT ; SEND IT DIRECTLY TO THE KEYBOARD ;JP9009
  629. MOV AL, SCAN_CODE_SET ; SCAN CODE SET ;JP9009
  630. CALL SND_DATA_AT ; SEND IT TO THE KEYBOARD ;JP9009
  631. ; JMP SHORT DONE_AT_4 ;JP9009
  632. JMP DONE_AT_4 ; QFESP4
  633. ; Module: SET_KBD_ID_TO_ROM_EXT
  634. ; Description:
  635. ; This routine sets keyboard ID to the corresponding extended BIOS
  636. ; data area, even if ROM BIOS does not support 'Return Keyboard ID
  637. ; (INT16H, AH=0AH)'. DBCS DOS supports it by some software if ROM
  638. ; BIOS does not support it.
  639. ; Input:
  640. ; AL = High byte of keyboard ID
  641. ; Assumes low byte is 'ABH'.
  642. ; Output:
  643. ; none
  644. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;JP9009
  645. SET_KBD_ID_TO_ROM_EXT PROC NEAR ; ;JP9009
  646. PUSH ES ; ;JP9009
  647. PUSH AX ; ;JP9009
  648. MOV AH, RTN_EXT_BIOS_DATA_SEG; ;JP9009
  649. INT 15H ; Get extended BIOS data area ;JP9009
  650. JC NOT_SET_KBD_ID ; ;JP9009
  651. ASSUME ES:ROMEXT ; EXTENDED BIOS DATA AREA ;JP9009
  652. MOV AH, AL ; AH = KBD ID 2ND BYTE ;JP9009
  653. MOV AL, 0ABH ; ASSUME KBD ID = xxABH ;JP9009
  654. MOV ES:EXT_BIOS_DATA_KBD_ID, AX; Set KBD ID to ext. BIOS data ;JP9009
  655. ASSUME ES:DATA ; NORMAL BIOS DATA AREA ;JP9009
  656. NOT_SET_KBD_ID: ;JP9009
  657. POP AX ; ;JP9009
  658. POP ES ; ;JP9009
  659. RET ; ;JP9009
  660. SET_KBD_ID_TO_ROM_EXT ENDP ; ;JP9009
  661. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;JP9009
  662. ; M005 -- end changed section
  663. ; ;JP9110
  664. ; Check if the specified keyboard layout is DBCS one or not. ;JP9110
  665. ; ;JP9110
  666. ; Input: BP = CMD_PARM_LIST ;JP9110
  667. ; Output: ZF = Zero if DBCS layout ;JP9110
  668. ; Non-Zero if not ;JP9110
  669. ; ;JP9110
  670. IS_DBCS_KEYBOARD_LAYOUT PROC NEAR ;JP9110
  671. CMP WORD PTR [BP].LANGUAGE_PARM,'PJ' ; Japanese layout? ;JP9110
  672. RET ;JP9110
  673. IS_DBCS_KEYBOARD_LAYOUT ENDP ;JP9110
  674. endif ; JAPAN
  675. else
  676. ;; BUGBUG
  677. ;; don't do the read id under nt because the keyboard h/w interrupt is
  678. ;; disabled at this moment. We should be able to get the keyboard type
  679. ;; from GetKeyboardType API after beta.
  680. ;; We simply pretend the keyboard is a 101/102 keyboard whithout checking
  681. ;; -- softpc only support 101/102 keys keyboard.
  682. PUSH ES
  683. push ds
  684. mov ax, cs
  685. mov ds, ax
  686. assume ds:CODE
  687. MOV AX,DATA
  688. MOV ES,AX ; ES points to BIOS data
  689. assume es:DATA
  690. or es:KB_FLAG_3,KBX ; force enhanced kbd support on
  691. ;;Set this to one will turn on the NUM lock when we are going to exit and keep
  692. ;; resident. This is not necessary because ntvdm host code controls num lock
  693. ;; states and the rest of system.
  694. ;; mov SECURE_FL, 1
  695. ;;
  696. mov ax, G_KB ; enhanced keyboard
  697. mov HW_TYPE, ax
  698. mov SD.KEYB_TYPE, ax
  699. pop ds
  700. POP ES
  701. assume ES:nothing
  702. endif
  703. RET
  704. FIND_KEYB_TYPE ENDP
  705. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  706. ;
  707. ; Module: SND_DATA_AT
  708. ;
  709. ; Description:
  710. ; THIS ROUTINE HANDLES TRANSMISSION OF PC/AT COMMAND AND DATA BYTES
  711. ; TO THE KEYBOARD AND RECEIPT OF ACKNOWLEDGEMENTS. IT ALSO
  712. ; HANDLES ANY RETRIES IF REQUIRED
  713. ;
  714. ;
  715. ; Input Registers:
  716. ; DS - points to our data segment
  717. ; ES - points to the BIOS data segment
  718. ;
  719. ; Output Registers:
  720. ;
  721. ; Logic:
  722. ;
  723. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  724. SND_DATA_AT PROC NEAR
  725. PUSH AX ; SAVE REGISTERS
  726. PUSH BX ; *
  727. PUSH CX
  728. MOV BH,AL ; SAVE TRANSMITTED BYTE FOR RETRIES
  729. MOV BL,3 ; LOAD RETRY COUNT
  730. ;---- WAIT FOR 8042 INTERFACE NOT BUSY
  731. SD0: ; RETRY entry
  732. CALL CHK_IBF ; Wait for command to be accepted
  733. CLI ; DISABLE INTERRUPTS
  734. AND ES:KB_FLAG_2,NOT (KB_FE+KB_FA+KB_ERR) ; CLEAR ACK, RESEND AND
  735. ; ERROR FLAGS
  736. MOV AL,BH ; REESTABLISH BYTE TO TRANSMIT
  737. OUT PORT_A,AL ; SEND BYTE
  738. JMP $+2 ; Delay for 8042 to accept command
  739. STI ; ENABLE INTERRUPTS
  740. ;----- WAIT FOR COMMAND TO BE ACCEPTED BY KEYBOARD
  741. MOV CX,DLY_15ms ; Timout for 15 ms (15,000/15.086)
  742. SD1: ; Fixed timout wait loop on AT's
  743. TEST ES:KB_FLAG_2,KB_FE+KB_FA; SEE IF EITHER BIT SET
  744. JNZ SD3 ; IF SET, SOMETHING RECEIVED GO PROCESS
  745. IN AL,PORT_B ; Read current system status port
  746. AND AL,REFRESH_BIT ; Mask all but refresh bit
  747. CMP AL,AH ; Did it change? (or first pass thru)
  748. JE SD1 ; No, wait for change, else continue
  749. MOV AH,AL ; Save new refresh bit state
  750. LOOP SD1 ; OTHERWISE WAIT
  751. SD2:
  752. DEC BL ; DECREMENT RETRY COUNT
  753. JNZ SD0 ; RETRY TRANSMISSION
  754. OR ES:KB_FLAG_2,KB_ERR ; TURN ON TRANSMIT ERROR FLAG
  755. JMP SHORT SD4 ; RETRIES EXHAUSTED FORGET TRANSMISSION
  756. SD3:
  757. TEST ES:KB_FLAG_2,KB_FA ; SEE IF THIS IS AN ACKNOWLEDGE
  758. JZ SD2 ; IF NOT, GO RESEND
  759. SD4:
  760. POP CX ; RESTORE REGISTERS
  761. POP BX
  762. POP AX ; *
  763. RET ; RETURN, GOOD TRANSMISSION
  764. SND_DATA_AT ENDP
  765. ifndef JAPAN
  766. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  767. ;
  768. ; KEYBOARD SECURITY LOGIC
  769. ;
  770. ; CHECK THE CMOS RAM BYTE AT CMOS LOCATION HEX 013H
  771. ; CHECK TO SEE IF EITHER BITS 1 (PASSWORD) OR 2 (SERVER MODE) ARE SET ON
  772. ; IF EITHER BIT IS SET ON THE SYSTEM IS A MOD 50 on up
  773. ; RETurn CARRY FLAG ON indicating keyboard interface may be disabled.
  774. ; OTHERWISE NO SECURITY ENABLED OR THE SYSTEM IS AN OLD AT.
  775. ; RETurn CARRY FLAG OFF indicating keyboard interface not disabled.
  776. ;
  777. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  778. KEYB_SECURE PROC NEAR
  779. CLI ; DISABLE INTERRUPTS WHILE DOING
  780. ; ADDRESS WRITE AND CMOS READ
  781. MOV AL,SECRET_ADD ; WRITE ADDRESS OF CMOS BYTE WITH
  782. OUT PORT_70,AL ; BITS FOR THE PASSWORD AND SERVER
  783. ; MODE STATE TO PORT 70H
  784. JMP $+2 ; I/O Delay required
  785. IN AL,PORT_71 ; READ CMOS DATA BYTE WITH THE
  786. ; PASSWORD AND SERVER SECURITY
  787. STI ; ENABLE THE INTERRUPTS
  788. TEST AL,PASS_MODE+SERVER_MODE; CHECK & SEE IF THE BITS ARE ON
  789. ; TEST clears CARRY flag
  790. JZ SECURE_RET ; EXIT NO CARRY if neither set
  791. STC ; SET THE SECURITY FLAG ON
  792. ; System is NOT an AT but the
  793. SECURE_RET: ; keyboard interface maybe locked
  794. RET
  795. KEYB_SECURE ENDP
  796. endif ; !JAPAN
  797. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  798. ;
  799. ; 8042 TYPE DETERMINATION
  800. ;
  801. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  802. SP_8042 PROC NEAR ; Determine if 8042 is Patriot/Sebring
  803. PUSH AX ; Save work register
  804. PUSH CX ; Save count register
  805. ifdef JAPAN
  806. ; M005 -- begin changed section
  807. IN AL, STATUS_PORT ; In server password mode, no answer ;JP9010
  808. TEST AL, KYBD_INH ; is returned from the following logic.;JP9010
  809. JZ GET_FROM_ROM_BIOS ; So, ask ROM BIOS. ;JP9010
  810. ; M005 -- end changed section
  811. endif ; JAPAN
  812. MOV CX,24 ; Limit AUX inputs if they are playing
  813. ; with the mouse while loading KEYB
  814. SP__2:
  815. MOV AL,DIS_KBD ; Disable command to clear 8042 output
  816. OUT STATUS_PORT,AL ; Sending allows receive to complete
  817. STI ; Allow any pending AUX interrupt
  818. CALL CHK_IBF ; Wait for command to be accepted
  819. CLI ; Block interrupts until password set
  820. IN AL,STATUS_PORT ; Read 8042 status byte
  821. TEST AL,MOUSE_OBF ; Check for AUX data pending at output
  822. LOOPNZ SP__2 ; Loop till AUX inputs are cleared
  823. IN AL,PORT_A ; Read to clear int's on SX ;PTR660243
  824. MOV AL,20h ; Read 8042 controller's command byte
  825. OUT STATUS_PORT,AL ; Send command to 8042 interface
  826. CALL CHK_IBF ; Wait for command to be accepted
  827. MOV CX,DLY_15ms ; Timeout 15 milliseconds (15000/15.086
  828. SP__5:
  829. ifdef JAPAN
  830. IN AL,STATUS_PORT ; Read status (command) port ;AN012
  831. TEST AL,OUT_BUF_FULL ; Check for output buffer empty ;AN012
  832. JNZ SP__6 ; Loop until OBF is ON ;AN012
  833. endif ; JAPAN
  834. IN AL,PORT_B ; Read current refresh output bit
  835. AND AL,REFRESH_BIT ; Mask all but refresh bit
  836. CMP AL,AH ; Did it change? (or first pass thru)
  837. JZ SHORT SP__5 ; No?, wait for change, else continue
  838. MOV AH,AL ; Save new refresh bit state
  839. ifndef JAPAN
  840. IN AL,STATUS_PORT ; Read status (command) port
  841. TEST AL,OUT_BUF_FULL ; Check for output buffer empty
  842. LOOPZ SP__5 ; Loop until OBF is on or timeout
  843. else ; JAPAN
  844. LOOP SP__5 ; Loop until OBF is ON or timeout ;AN012
  845. SP__6: ;AN012
  846. endif ; JAPAN
  847. IN AL,PORT_A ; Get the command byte
  848. TEST AL,01000000b ; Check for translate bit on
  849. JNZ SP_EXIT ; Done if it is on to begin with
  850. ifdef JAPAN
  851. SP_EXIT_0: ; M005 ;JP9010
  852. endif ; JAPAN
  853. OR SD.SYSTEM_FLAG,PS_8042 ; Set PATRIOT/SEBRING type 8042
  854. ; with Translate scan codes set OFF
  855. SP_EXIT:
  856. MOV AL,ENA_KBD ; Enable command for keyboard
  857. OUT STATUS_PORT,AL ; Send to 8042
  858. CALL CHK_IBF ; Wait for command to be accepted
  859. IN AL,PORT_A ; Read to clear int's on SX ;PTR660243
  860. POP CX ; Recover user register
  861. POP AX ; Recover user register
  862. STI ; Enable inteerutps again
  863. RET ; Return to caller
  864. ifdef JAPAN
  865. ; M005 -- begin added section
  866. RTN_SYSTEM_CONFIG EQU 0C0H ; INT15H SUB FUNCTION ;JP9010
  867. FEATURE_INFO_2 EQU 006H ; FEATURE INFO2 OFFSET IN CONFIG DATA ;JP9010
  868. NON_8042_CONTROLLER EQU 004H ; THIS BIT ON IF NON-8042 CONTROLLER ;JP9010
  869. GET_FROM_ROM_BIOS: ; WE CAN ONLY ASK ROM BIOS WHICH TYPE ;JP9010
  870. PUSH ES ; OF KEYBOARD CONTROLLER IS ATTACHED. ;JP9010
  871. PUSH BX ; ;JP9010
  872. MOV AH, RTN_SYSTEM_CONFIG ; ;JP9010
  873. INT 15H ; ;JP9010
  874. JC RTN_SYS_CONFIG_NOT_SUPPORTED; IN CASE NOT SUPPORTED, IT MUST ;JP9010
  875. ; BE 8042. BELIEVE IT. ;JP9010
  876. TEST BYTE PTR ES:[BX+FEATURE_INFO_2], NON_8042_CONTROLLER ;JP9010
  877. POP BX ; ;JP9010
  878. POP ES ; ;JP9010
  879. JNZ SP_EXIT_0 ; IF NON-8042, SET THE FLAG ;JP9010
  880. JMP SHORT SP_EXIT ; ;JP9010
  881. RTN_SYS_CONFIG_NOT_SUPPORTED: ; ;JP9010
  882. POP BX ; ;JP9010
  883. POP ES ; ;JP9010
  884. JMP SHORT SP_EXIT ; ;JP9010
  885. ; M005 -- end added section
  886. endif ; JAPAN
  887. SP_8042 ENDP
  888. CODE ENDS
  889. END