io - How to determine whether the computer has an XT/AT keyboard in assembly? -


i finished writing 16 bit operating system used int 0x16 tell key user pressed. want write own keyboard driver , don't want use interrupts. (so can enter long mode). realized there 2 scan codes, @ , xt. how can determine keyboard computer use in nasm x86 assembly?

should ask user press key , determine using scan code in port 0x60 when os boots?
eg: key - 0x1c(make) @ , 0x1e(make) xt
linux not that.......

i used following code , discovered virtual box uses xt keyboard....

 [org 0x2e00]  mov bx, 0x1000 mov ds, bx      ;the program loaded @ 0x12e00 or 1000:2e00 operating system      xor ax, ax  ;set ax 0     mov bl, 0x0e    ;set text color   loop:           ;main loop      in al, 0x60 ;read ports , display them     mov cx, ax     call hex_print  ;print content of port in hex     in al, 0x61     mov cx, ax     call hex_print     in al, 0x62     mov cx, ax     call hex_print     in al, 0x63     mov cx, ax     call hex_print     in al, 0x64     call hex_print     call com_cls    ;clear screen after printing content     jmp loop    ;jump loop   ;print hex values;;;;;;;;;;;;;;;;; hex_print:     push ax     push cx     mov ah, 0x0e     mov al, ' '     int 0x10     mov al, '0'     int 0x10     mov al, 'x'     int 0x10 hex_print_start:     mov al, ch     , al, 0xf0     call hex_map     int 0x10     shl cx, 0x04     mov al, ch     , al, 0xf0     call hex_map     int 0x10     shl cx, 0x04     mov al, ch     , al, 0xf0     call hex_map     int 0x10     shl cx, 0x04     mov al, ch     , al, 0xf0     call hex_map     int 0x10 hex_print_end:     pop cx     pop ax     ret  hex_map:     cmp al, 0x00     jne zero_end     mov al, '0'     ret zero_end:     cmp al, 0x10     jne one_end     mov al, '1'     ret one_end:     cmp al, 0x20     jne two_end     mov al, '2'     ret two_end:     cmp al, 0x30     jne three_end     mov al, '3'     ret three_end:     cmp al, 0x40     jne four_end     mov al, '4'     ret four_end:     cmp al, 0x50     jne five_end     mov al, '5'     ret five_end:     cmp al, 0x60     jne six_end     mov al, '6'     ret six_end:     cmp al, 0x70     jne seven_end     mov al, '7'     ret seven_end:     cmp al, 0x80     jne eight_end     mov al, '8'     ret eight_end:     cmp al, 0x90     jne nine_end     mov al, '9'     ret nine_end:     cmp al, 0xa0     jne a_end     mov al, 'a'     ret a_end:     cmp al, 0xb0     jne b_end     mov al, 'b'     ret b_end:     cmp al, 0xc0     jne c_end     mov al, 'c'     ret c_end:     cmp al, 0xd0     jne d_end     mov al, 'd'     ret d_end:     cmp al, 0xe0     jne e_end     mov al, 'e'     ret e_end:     cmp al, 0xf0     jne f_end     mov al, 'f'     ret f_end:     ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   ;the "cls" command;;;;;;;;;;;;;;;;;;;;;;;;;;;; com_cls:     push ax     push bx     push cx     push dx     mov ax, 0x0700      ; function 07, al=0 means scroll whole window     mov bh, 0x00        ; character attribute = black     mov cx, 0x0000      ; row = 0, col = 0     mov dx, 0x1e54      ; row = 30 (0x1e), col = 79 (0x4f)     int 0x10            ; call bios video interrupt     mov ah, 0x02        ;function 02, set curser position     mov dx, 0x00     int 0x10     pop dx     pop cx     pop bx     pop ax     ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  ret 

scan code 0x9e: xt! scan code 0x9e: break 'a' key in xt keyboard!

in advance help.

whenever need advice programming os, take @ osdev wiki great!
these 2 pages you:


it unlikely have deal xt keyboard because used in pc-xt didn't have 8042 8255 (ppi) chip.
, ppi responds ports 60h-63h only, leaving out 64h think using.
see this listing.


don't confused between keyboard commands , controller commands, os both translate writes same data port firsts make way down keyboard, latter stop @ 8042.

consider there 3 scan code sets (named set 1, 2 , 3).
xt used first, second 1 supported every keyboard, third used.
have check scan code set keyboard using, by default second.
use keyboard command 0f0h payload of 00h known current scan code (after usual keyboard ack 0fah).
if use payload of 01h, 02h or 03h can set scan code set in use.

beware 8082 default translate scan code set 2 scan code set 1, disable translation use controller commands 20h , 60h clear bit 6 of controller configuration byte.


so in short:

  1. you dealing scan code translation, rather (emulated) xt keyboard.
  2. disable translation.
  3. explicitly set scan code set support.

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -