From 6fcbaa124df901d2002591315dc72eb9f87834c9 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Fri, 15 Oct 2021 23:53:11 -0300 Subject: [PATCH] multikey: Add utility based on Discord source drop --- multikey/MULTIKEY.ASM | 322 ++++++++++++++++++++++++++++++++++++++++++ multikey/MULTIKEY.COM | Bin 0 -> 1024 bytes multikey/README.md | 12 ++ multikey/build.bat | 35 +++++ 4 files changed, 369 insertions(+) create mode 100644 multikey/MULTIKEY.ASM create mode 100644 multikey/MULTIKEY.COM create mode 100644 multikey/README.md create mode 100644 multikey/build.bat diff --git a/multikey/MULTIKEY.ASM b/multikey/MULTIKEY.ASM new file mode 100644 index 0000000..4a5f2c4 --- /dev/null +++ b/multikey/MULTIKEY.ASM @@ -0,0 +1,322 @@ +; +; 86Box A hypervisor and IBM PC system emulator that specializes in +; running old operating systems and software designed for IBM +; PC systems and compatibles from 1981 through fairly recent +; system designs based on the PCI bus. +; +; This file is part of the 86Box Probing Tools distribution. +; +; Phoenix MultiKey keyboard controller probing tool. +; +; +; +; Authors: Miran Grca, +; +; Copyright 2021 Miran Grca. +; + +.model tiny +.286 +.code + +start: + jmp real_start + +store_erl: + push ax + mov al,[erl] + mov [di],al + inc di + inc word [dmp_sz] + pop ax + ret + +store_cmd: + mov [di],al + inc di + inc word [dmp_sz] + ret + +open_file: + mov ah,3ch + mov cx,0020h + mov dx,offset filename + int 21h + jnc short open_file_succ + mov byte [erl],9 + jmp short open_file_ret +open_file_succ: + mov [fileh],ax +open_file_ret: + ret + +write_file: + mov ah,40h + mov bx,[fileh] + int 21h + jnc short write_file_ret + mov byte [erl],10 +write_file_ret: + ret + +close_file: + mov ah,3eh + mov bx,[fileh] + int 21h + jnc short close_file_succ + mov byte [erl],11 + jmp short close_file_ret +close_file_succ: + mov word [fileh],0 +close_file_ret: + ret + +wait_for_nibf: + xor cx,cx + push ax + mov cx,0010h +nibf_push_cx: + push cx + xor cx,cx +nibf_in: + in al,64h + test al,2 + loopne nibf_in + pop cx + loopne nibf_push_cx + pop ax + ret + +wait_for_obf: + or al,al + push ax + mov cx,0010h +obf_push_cx: + push cx + xor cx,cx +obf_in: + in al,64h + test al,1 + loope obf_in + pop cx + loope obf_push_cx + pop ax + ret + +print_string: + mov ah,9 + int 21h + ret + +convert_digit: + and al,0fh + add al,30h + cmp al,39h + ja short digit_is_letter + jmp short output_digit +digit_is_letter: + add al,7 +output_digit: + mov [si],al + inc si + ret + +cmd_d5: + mov al,0d5h + call store_cmd + pusha + out 64h,al + call wait_for_nibf + jnz short cmd_d5_stuck + call wait_for_obf + jz short cmd_d5_no_out + in al,60h + mov [si],al + inc si + call wait_for_obf + jz short cmd_d5_no_out + in al,60h + mov [si],al + mov byte [erl],0 + jmp short cmd_d5_ret +cmd_d5_no_out: + mov byte [erl],3 + jmp short cmd_d5_ret +cmd_d5_stuck: + mov byte [erl],2 +cmd_d5_ret: + popa + call store_erl + ret + +cmd_d6: + mov al,0d6h + call store_cmd + pusha + out 64h,al + call wait_for_nibf + jnz short cmd_d6_stuck + call wait_for_obf + jz short cmd_d6_no_out + in al,60h + mov [si],al + inc si + call wait_for_obf + jz short cmd_d6_no_out + in al,60h + mov [si],al + mov byte [erl],0 + jmp short cmd_d6_ret +cmd_d6_no_out: + mov byte [erl],5 + jmp short cmd_d6_ret +cmd_d6_stuck: + mov byte [erl],4 +cmd_d6_ret: + popa + call store_erl + ret + +cmd_d7: + mov al,0d7h + call store_cmd + pusha + out 64h,al + call wait_for_nibf + jnz short cmd_d7_stuck + call wait_for_obf + jz short cmd_d7_no_out + in al,60h + mov [si],al + inc si + call wait_for_obf + jz short cmd_d7_no_out + in al,60h + mov [si],al + inc si + call wait_for_obf + jz short cmd_d7_no_out + in al,60h + mov [si],al + mov byte [erl],0 + jmp short cmd_d7_ret +cmd_d7_no_out: + mov byte [erl],7 + jmp short cmd_d7_ret +cmd_d7_stuck: + mov byte [erl],6 +cmd_d7_ret: + popa + call store_erl + ret + +disable_kbd: + mov al,0adh + call store_cmd + pusha + out 64h,al + call wait_for_nibf + jz short dkbd_ret + mov byte [erl],1 +dkbd_ret: + popa + call store_erl + ret + +enable_kbd: + mov al,0aeh + call store_cmd + pusha + out 64h,al + call wait_for_nibf + jz short ekbd_ret + mov byte [erl],8 +ekbd_ret: + popa + call store_erl + ret + +print_out: + mov si,[erl] + shl si,1 + add si,offset strs + mov dx,[si] + call print_string + ret + +dmp_sz dw 0 +dmp_arr dup 10, 0 +d5_sz dw 2 +d5_data dup 2, 0 +d6_sz dw 2 +d6_data dup 2, 0 +d7_sz dw 3 +d7_data dup 3, 0 +fileh dw 0000h +erl dw 0 +; String table organized by error level +strs dw offset err_00,offset err_01,offset err_02,offset err_03 + dw offset err_04,offset err_05,offset err_06,offset err_07 + dw offset err_08,offset err_09,offset err_0a,offset err_0b + +err_00 db "Phoenix MultiKey/42 series detected",0dh,0ah,'$' +err_01 db "Disable Keyboard command stuck",0dh,0ah,'$' +err_02 db "Read MultiKey Code Revision Level command stuck",0dh,0ah,'$' +err_03 db "Read MultiKey Code Revision Level command not returning bytes",0dh,0ah,'$' +err_04 db "Read Version Information command stuck",0dh,0ah,'$' +err_05 db "Read Version Information command not returning bytes",0dh,0ah,'$' +err_06 db "Read MultiKey Model Numbers command stuck",0dh,0ah,'$' +err_07 db "Read MultiKey Model Numbers command not returning bytes",0dh,0ah,'$' +err_08 db "Enable Keyboard command stuck",0dh,0ah,'$' +err_09 db "Error opening file " +filename + db "MULTIKEY.BIN",0,0dh,0ah,'$' +err_0a db "Error writing file",0dh,0ah,'$' +err_0b db "Error closing file",0dh,0ah,'$' + +;лллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл +; +; External Entry Point +; +;лллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл + +real_start: + ; First round of tests + cli + mov di,offset dmp_arr + call disable_kbd + mov si,offset d5_data + call cmd_d5 + mov si,offset d6_data + call cmd_d6 + mov si,offset d7_data + call cmd_d7 + call enable_kbd + ; 06 - Enable Keyboard + sti + call print_out + call open_file + mov cx,2 + mov dx,offset dmp_sz + call write_file + mov cx,[dmp_sz] + mov dx,offset dmp_arr + call write_file + mov cx,4 + mov dx,offset d5_sz + call write_file + mov cx,4 + mov dx,offset d6_sz + call write_file + mov cx,5 + mov dx,offset d7_sz + call write_file + call close_file + mov al,[erl] +errorlevel_not_0: + mov ah,4ch + int 21h + +.end start + +end diff --git a/multikey/MULTIKEY.COM b/multikey/MULTIKEY.COM new file mode 100644 index 0000000000000000000000000000000000000000..e8d086c02118e72fea5344102502e21d2c507d08 GIT binary patch literal 1024 zcmbu8O=uHA7>1{_o1{Pf9qLsl(3_yPh_p~tS`#g8N-R~=i*%En>e6Iab|#T5t;^xe0d%2tc|(4M*9t>xzanP+hrg_Dy)d-SS-N4xZ?^0gk9T&A<2)99 zQ)19u_zdIr@TLrJ?W7-;Y<6&Cm~(h%vnFTdM5Fv3=Og6ZMz93!wz=>HPP@Kaj_+R8 zcW0;1Q}&4xAnyALKG%2NP9A~FHalF-3soz0@2ub}SMW-ZE13(g;bY0^*lRPlp*jg( zay$?7F8*06<9Z3EOJ?fi9A4eLz4#2Ln!zfWXxqbwhn!caunhi&kdu;FP%7cqKz0-SExZ`%4m#Hd2eIOS;df|aZ0!#s!6&`Vp<|0 zsWLHGGB(Nu15}c$HAuH6Q!+ru6hqNe(nrT={68G3#)wW?QdbrADv3@oYE%+0QQeK` zQAadAAu%Uz*VbwYYt*kyg@pKt;-o*Bi1NhUBmSY?Jtd&lo@+qYHJxbJ`5p1Ik0|^O zLKpi6dwK&yN4t9Z5g$ZZGOjDEBB{byTr;-8!uz`zW{SD{7`|J%hZvfRxfu+>B0MSn zhBrkBTN#Y9lNhd8seO|;%jJVsMnu_Z4888+0fsIs<3ZU+7& +: +: Copyright 2021 RichardG. +: + +: Check for NBASM presence. +set NBASMBIN=nbasm32 +%NBASMBIN% /v > NUL 2> NUL +if not errorlevel 100 goto build +set NBASMBIN=nbasm64 +%NBASMBIN% /v > NUL 2> NUL +if not errorlevel 100 goto build +set NBASMBIN=nbasm16 +%NBASMBIN% /v > NUL 2> NUL +if not errorlevel 100 goto build + +: No NBASM found. +echo NewBasic not found. Make sure NBASM16/32/64 is present in PATH. +exit /b 1 + +:build +%NBASMBIN% %1.ASM %1.COM