flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Setting keyboard scan code set

Author
Thread Post new topic Reply to topic
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 20 Jul 2009, 15:10
Just made a scan code set 2 driver to find that the VMs I'm using default to set 1 Evil or Very Mad so I'm trying to force set 2 but when writing 0xF0 (set scan code set) to port 0x0064 (keyboard command register) it returns 0x03 (keyboard clock stuck low?) in 0x0060 (keyboard data register) instead of 0xFA (ACK). Any ideas what this means? AFAIK setting scan codes does not require any other prior processing.


Here is the relevant code:
Code:
;;;; loader.asm (truncated)
; 32 bit protected mode, interrupts disabled
stdcall IRQ_WriteKeyboard,i804x_COMMAND_SETSCANCODESET,i804x_SCANCODE_SET2


;;;; i804x.ash (truncated)
; Port Designations
i804x_PORT_READ                                         equ 0x0060      ; R
i804x_PORT_WRITE                                        equ 0x0060      ; W
i804x_PORT_STATUS                                       equ 0x0064      ; R
i804x_PORT_COMMAND                                      equ 0x0064      ; RW 

; Status Register (Read i804x_PORT_STATUS) 
i804x_STATUS_INPUTBUFFERFULL                            equ 0x02
i804x_STATUS_OUTPUTBUFFERFULL                           equ 0x01  

; Command List (Write i804x_PORT_COMMAND)
i804x_COMMAND_SETSCANCODESET                            equ 0xF0        ; PS2 only
      i804x_SCANCODE_GET                      equ 0x00                    ; Read set from i804x_PORT_READ
 i804x_SCANCODE_SET1                     equ 0x01
    i804x_SCANCODE_SET2                     equ 0x02;DEFAULT
    i804x_SCANCODE_SET3                     equ 0x03  


;;;; irq.asm (truncated)
proc IRQ_ReadKeyboard

         xor eax,eax

     .loop:

              in al,i804x_PORT_STATUS

         test al,i804x_STATUS_INPUTBUFFERFULL
                jnz .loop

               in al,i804x_PORT_READ

           ret
endp

proc IRQ_WriteKeyboard,k,v

   .loop:

              in al,i804x_PORT_STATUS

         test al,i804x_STATUS_OUTPUTBUFFERFULL
               jnz .loop

               mov eax,dword [k]
           out i804x_PORT_COMMAND,al

               stdcall IRQ_ReadKeyboard ; <<< ERROR HERE returns 0x03 not 0xFA

                mov eax,dword [v]
           out i804x_PORT_WRITE,al

         stdcall IRQ_ReadKeyboard

                ret
endp    


Thanks Cool
Post 20 Jul 2009, 15:10
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 28 Jul 2009, 15:22
Simply try to clear the translation bit in the command byte (byte 0 in controller RAM):
Code:
  call keyb.wait_for_empty
  jnz @f

  mov al,0F0h
  out 60h,al

  call keyb.wait_for_empty
  jnz @f

  mov al,02h
  out 60h,al

  call keyb.wait_for_empty
  jnz @f

  mov al,60h ; "write to command byte" command
  out 64h,al

  call keyb.wait_for_empty
  jnz @f

  mov al,00100001b ; translation bit (bit 6) is clear
  out 60h,al

  call keyb.wait_for_empty
  jnz @f    

Edited: "set/get scancode set" (0F0h) is a keyboard command, not a controller one Smile
Post 28 Jul 2009, 15:22
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 30 Jul 2009, 01:27
Thank you for taking a look; I gave this code a very quick try but it still didn't seem to work. I'll give it another go tomorrow when I have more time.

I don't have much info on the 804x, so I'm not sure what the translate bit actually does Question
Post 30 Jul 2009, 01:27
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 30 Jul 2009, 09:16
Take attention on my last note. It will solve the problem described by you.
Post 30 Jul 2009, 09:16
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.