port 60h wonder

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

port 60h wonder

Post by Philip »

after my kernel switch to protected mode
and try to read port 60h to print out the keyboard input to screen but
the result is always AAh
i really wonder why? :?
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Post by Stevo14 »

AFAIK, In protected mode, the keyboard will send you an interrupt when it has data for you to read. It should be interrupt request number one. (number zero is the timer's interrupt.)
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: port 60h wonder

Post by egos »

Adam wrote:At power-on or software reset (see the "Reset" command) the keyboard performs a diagnostic self-test referred to as BAT (Basic Assurance Test) and loads the following default values:
Typematic delay 500 ms.
Typematic rate 10.9 cps.
Scan code set 2.
Set all keys typematic/make/break.
When entering BAT, the keyboard enables its three LED indicators, and turns them off when BAT has completed. At this time, a BAT completion code of either 0xAA (BAT successful) or 0xFC (Error) is sent to the host.
Source: Computer-Engineering.org
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Post by Philip »

Stevo14 wrote:AFAIK, In protected mode, the keyboard will send you an interrupt when it has data for you to read. It should be interrupt request number one. (number zero is the timer's interrupt.)
i already used CLI before entering protected mode
so do i have to write all interrupts myself including the int 9?
(my building kernal hasnt an interrupt descriptor table yet)
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Re: port 60h wonder

Post by Philip »

egos wrote:
Adam wrote:At power-on or software reset (see the "Reset" command) the keyboard performs a diagnostic self-test referred to as BAT (Basic Assurance Test) and loads the following default values:
Typematic delay 500 ms.
Typematic rate 10.9 cps.
Scan code set 2.
Set all keys typematic/make/break.
When entering BAT, the keyboard enables its three LED indicators, and turns them off when BAT has completed. At this time, a BAT completion code of either 0xAA (BAT successful) or 0xFC (Error) is sent to the host.
Source: Computer-Engineering.org
but how does that AAh from BAT relate to the AAh i receive from port 60h?
User avatar
Stevo14
Member
Member
Posts: 179
Joined: Fri Mar 07, 2008 3:40 am
Location: Arad, Romania

Post by Stevo14 »

Philip wrote: so do i have to write all interrupts myself including the int 9?
(my building kernal hasnt an interrupt descriptor table yet)
Again, according to my limited knowledge, the answer is yes. In protected mode you have the privilege (or responsibility or whatever) to handle all interrupts yourself. I would suggest looking through some basic kernel tutorials as most of them give a good walk-through of getting interrupts (and other goodies that rely on interrupts like timers and of course the keyboard) setup.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Post by egos »

Philip wrote:i already used CLI before entering protected mode
so do i have to write all interrupts myself including the int 9?
(my building kernal hasnt an interrupt descriptor table yet)
IRQ1 handler??? Firstly you have to reprogram the PIC.
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Post by Philip »

but port 60h is the keyboard port
what the hck why i can't read from this port?
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

To poll the keyboard you do not need IDT set up in pmode.
Something like this should work

Code: Select all

;************************************
; Test key input.
; By Dex
;************************************
; Assemble with fasm
; c:\fasm TestKey.asm TestKey.bin
;
; Keys = (UpArrow)
; Keys = (DownArrow)
; Keys = (Enter)
;************************************
org 0x7C00

use16
;****************************
; Realmode startup code.
;****************************
start:
        xor   ax,ax
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   sp,0x7C00
;*****************************
; Setting up, to enter pmode.
;*****************************
        cli
        lgdt  [gdtr]

        mov   eax, cr0
        or    al,0x1
        mov   cr0,eax

        jmp   0x10: protected
;*****************************
; Pmode. ;-)
;*****************************
use32
protected:
        mov   ax,0x8 
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   esp,0x7C00
;*****************************
; Turn floppy off
;*****************************
        mov   dx,3F2h
        mov   al,0
        out   dx,al
;*********************************
; Main keyboard loop.
;*********************************
NoKey:
        xor   eax,eax
        in    al,60h
        cmp   al,0x50
        jne   TryNext1
        mov   byte [es:0xB8000], "D"
	     jmp   NoKey
TryNext1:
        cmp   al,0x48
        jne   TryNext2
        mov   byte [es:0xB8000], "U"
	     jmp   NoKey
TryNext2:
        cmp   al,0x1c
        jne   NoKey
        mov   byte [es:0xB8000], "E"
	     jmp   NoKey

;*************************************
; GDT.
;*************************************

gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000
sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:

gdtr:	    dw gdt_end - gdt - 1	                                  
	    dd gdt

;*************************************
; Make program 510 byte's + 0xaa55
;*************************************

times 510- ($-start)  db 0
dw 0xaa55
Use the ArrowUp, ArrowDown, Enter key to print U, D, or E on screen in pmode, use rawrite to put on a floppy.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Post by egos »

Philip, what you want to read from this port? If 0x60 isn't changing its state, when keyboard must send the data, perhaps keyboard interface disabled (see Command Byte, bit 4).
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Post by egos »

Pooling mode... It's cool :lol:
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Post by Philip »

oh Dex, you're great
you must be a very good system programmer :)
but wait, my code is the same

in al,60h
call printHexAL

but it just doesnt work -- all the time is a certain value
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Post by Zenith »

Do you even understand how Dex's code works?

If you copy it word for word, then it'll only print out the letters 'D', 'U' or 'E' (but i have to say, the compared values don't seem right...) when you press them.

Other than that, maybe show us your printHexAL function?
"Sufficiently advanced stupidity is indistinguishable from malice."
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

I can not say why your code does not work (maybe your print hex ?), but the demo i made works fine on all my test PC.
As for the good sys programmer, it's just i have been though the same problem's as you, many times.
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Post by Philip »

i found out the problem,
it is because of my tablet pc compaq tc1000
port 60h is not the keyboard port as i tried
to write a small program in real mode and run under dos to check but
the value from port 60h is also always AAh

i wonder which port is the keyboard port on compaq tc1000?


the keyboard buffer is set by int 9, but not available once
tune in to protected mode
i tried to trace int 16h function 0 but can not find out the port

anybody knows which port should it be?
Post Reply