From 0ac241b52e1f8f7c45c8153b8f4b3f758e4dd55c Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 16 Oct 2021 00:01:44 -0300 Subject: [PATCH] viakey: Add utility based on Discord source drop --- viakey/README.md | 12 ++++ viakey/VIAKEY.ASM | 172 ++++++++++++++++++++++++++++++++++++++++++++++ viakey/VIAKEY.COM | Bin 0 -> 896 bytes viakey/build.bat | 35 ++++++++++ 4 files changed, 219 insertions(+) create mode 100644 viakey/README.md create mode 100644 viakey/VIAKEY.ASM create mode 100644 viakey/VIAKEY.COM create mode 100644 viakey/build.bat diff --git a/viakey/README.md b/viakey/README.md new file mode 100644 index 0000000..94d1184 --- /dev/null +++ b/viakey/README.md @@ -0,0 +1,12 @@ +viakey +====== +DOS tool for probing VIA VT82C42N keyboard controllers. + +Usage +----- +Run `VIAKEY.COM`. If a VT82C42N keyboard controller is found (either standalone or integrated to a VIA southbridge), its revision code will be displayed. Any errors in the probing process will be displayed on screen. + +Building +-------- +* **Windows:** Run `build.bat VIAKEY` with [NewBasic](http://www.fysnet.net/newbasic.htm) present in `%PATH%`. +* **Other platforms:** This tool is only guaranteed to assemble and function properly with the (DOS- and Windows-only) NewBasic assembler, but feel free to try other assemblers. diff --git a/viakey/VIAKEY.ASM b/viakey/VIAKEY.ASM new file mode 100644 index 0000000..d8d8d69 --- /dev/null +++ b/viakey/VIAKEY.ASM @@ -0,0 +1,172 @@ +; +; 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. +; +; VIA VT82C42N keyboard controller probing tool. +; +; +; +; Authors: Miran Grca, +; +; Copyright 2021 Miran Grca. +; + +.model tiny +.386 +.code + +start: + jmp real_start + +wait_for_nibf: + 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: + 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 + +convert_to_hex: + push ax + push ax + shr al,4 + call convert_digit + pop ax + call convert_digit + pop ax + ret + +viakey_test: + xor dx,dx + mov al,0afh + out 64h,al + call wait_for_nibf + jnz gcv_stuck + call wait_for_obf + jz not_viakey + in al,60h + mov si,offset ver + call convert_to_hex + mov byte [erl],0 + jmp short viakey_ret +not_viakey: + mov byte [erl],3 + jmp short viakey_ret +gcv_stuck: + mov byte [erl],2 +viakey_ret: + ret + +disable_kbd: + mov al,0adh + out 64h,al + call wait_for_nibf + jz dkbd_ret + mov byte [erl],1 +dkbd_ret: + ret + +enable_kbd: + mov al,0aeh + out 64h,al + call wait_for_nibf + jz ekbd_ret + mov byte [erl],4 +ekbd_ret: + ret + +print_out: + mov si,[erl] + shl si,1 + add si,offset strs + mov dx,[si] + call print_string + ret + +new_cmd db 57h +saved_cmd + db 0 +erl dw 0 +strs dw offset succ,offset err_1,offset err_2,offset err_3,offset err_4 + +succ db "VIA VT82C42N detected: " +ver db "0",0dh,0ah +copr dup 512, 0 + db 0dh,0ah,'$' +err_1 db "Disable Keyboard command stuck",0dh,0ah,'$' +err_2 db "Get Controller Version command stuck",0dh,0ah,'$' +err_3 db "VIA VT82C42N not detected",0dh,0ah,'$' +err_4 db "Enable Keyboard command stuck",0dh,0ah,'$' + + +;лллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл +; +; External Entry Point +; +;лллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл + +real_start: + ; First round of tests + cli + call disable_kbd + cmp byte [erl],0 + jnz short stop_tests + call viakey_test + cmp byte [erl],0 + jnz short stop_tests +stop_tests: + call enable_kbd + sti + call print_out + mov al,[erl] + cmp al,0 + mov ah,4ch + int 21h + +.end start + +end diff --git a/viakey/VIAKEY.COM b/viakey/VIAKEY.COM new file mode 100644 index 0000000000000000000000000000000000000000..92fa2022dd97c0d9b6370fc5ac0ac8f7a25391cd GIT binary patch literal 896 zcmaDE!5pwtfFaQEoVKKK%G7$L&=@K@wRpvV@^vxsEcczDA)pgWE)|!| z;>4t!R0Z$U%B1|nq7;SX{M_8cycC7vlG5aCpaS>Q5(Ve{ypp2)oSf7mg|O73;>`R! z3}q;ZEHA$Vp3s0sxaQ%v;@1o5zYTW4gkQ?_;^7|%i{XXD-`_7(|1Ma^Xv46@=d2 +: +: 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