flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Keyboard lights

Author
Thread Post new topic Reply to topic
woody



Joined: 18 Jun 2005
Posts: 14
woody 20 Jun 2005, 20:55
Hi all Smile
I have a small problem. Here goes....
As part of my boot procedure from switching from real mode to long mode I world like to use the num lock, caps lock and scroll lock light to signal when various stages of the boot have been reached (simple I thought). The routine seem to switch off the lights so I thought switch off all the lights just to make sure. Trouble is the lights just want to switch off. So here is the code.

Code:
DisableKeyboard:
J1:                     in al,0x64
                        test al,2
                        jz J2
                        jmp J1

J2:                     mov al,0xad
                        out 0x64,al
;*****************************************
L1:                     in al,0x64
                        test al,2
                        jz L2
                        jmp L1

L2:                     mov al,0xed
                        out 0x60,al

L3:                     in al,0x64
                        test al,2
                        jz L4
                        jmp L3

L4:                     mov al,0xff
                        out 0x60,al
;*****************************************
EnableKeyboard:
J3:                     in al,0x64
                        test al,2
                        jz J4
                        jmp J3

J4:                     mov al,0xad
                        out 0x64,al
    

If any body could help me with a pointer or two I would be greatfull

Thanks in advance
Woody Very Happy
Post 20 Jun 2005, 20:55
View user's profile Send private message Reply with quote
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Chewy509 20 Jun 2005, 23:24
The LOST source (which you can now download), contains:
Lost/SRC/DRIVERS/8042.asm

The file contains a function call setLEDs (down at the bottom). It reads the current bitmap of the LED status and tells the keyboard what LEDs should read. (The bitmap of the status is maintained by the driver).

The code snippet is as:
Code:
Key_Shift_Stat dw 0

;Key_Shift_Stat as follows:
; bit 15-9 reserved.
; bit 8 Capslock
; bit 7 Numlock
; bit 6 Scroll-lock
; bit 5 left Alt
; bit 4 right Alt/Alt Gr
; bit 3 left Ctrl
; bit 2 right Ctrl
; bit 1 left shift
; bit 0 right shift

.SetLEDs:
    mov ax, [Key_Shift_Stat]
    shl ax, 02h
    and ah, 07h ;led status in %ah
    mov al, 0edh ; modify leds
    out 60h, al
.S1:
    in al, 64h
    test al, 02h
    jnz .S1
    mov al, ah
    out 60h, al ;set leds
    jmp .exit
    


Just remember, the state of the LEDs has NO bearing on the state on the control logic used within the keyboard. Therefore it is possible for the actual state and the LEDs to come out of sync, if not handled correctly.
Post 20 Jun 2005, 23:24
View user's profile Send private message Visit poster's website Reply with quote
woody



Joined: 18 Jun 2005
Posts: 14
woody 21 Jun 2005, 00:57
Hi Chewy509. Smile
Looking at mine and your code the only difference seems to be that your takeing the bits from a memory location then setting the LED's and my code just sets them directly. The chances are that I'am missing the point.
Having tested the code again the lights come on then go off again. So I did a straight boot into windows and the same action didn't happen again, so it must have been my code.
My main information source is 'The undocumented PC' and that has some code which seems to refernce a memory loction and does checks to
see if the LED's are being updated. But my code has to run without any BIOS interrupts which his code seems to need (I think Confused ) for adjusting the memory loction that holds the status of the LED's.

Woody Smile
Post 21 Jun 2005, 00:57
View user's profile Send private message Reply with quote
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Chewy509 21 Jun 2005, 03:22
Hi Woody,

This is a bit of a guess, but when you enable the keyboard, I believe some models will do a full reset (and thus clearing the LEDs).

Enable the keyboard, and then toggle the LEDs?

Also I noticed in your code, that you don't clear the high bits? AFIAK these should be 0. (Instead of 0xff, use 0x7).

IIRC The Undocumented PC, is referencing the LED status info with the BIOS area (0x40:xx).
Post 21 Jun 2005, 03:22
View user's profile Send private message Visit poster's website Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio 21 Jun 2005, 09:52
Some keyboards don´t have leds, better use the screen.
Post 21 Jun 2005, 09:52
View user's profile Send private message Visit poster's website Reply with quote
woody



Joined: 18 Jun 2005
Posts: 14
woody 21 Jun 2005, 11:13
Hi Chewy509, Octavio
I think to be honest most keyboards do have LED's and the way that I'am working is to make sure it works on my set up then get it to work on other machines (if you know what I saying).
When it comes to setting the LED's 1=on and 0=off thats according "The Undocumented PC" on page 372. I thought a full reset would be on the machines post, but I will try it anyway. Thanks for your help.
Woody
Post 21 Jun 2005, 11:13
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 21 Jun 2005, 11:16
Post 21 Jun 2005, 11:16
View user's profile Send private message Visit poster's website Reply with quote
woody



Joined: 18 Jun 2005
Posts: 14
woody 21 Jun 2005, 12:33
Thanks for the help Privalov
Post 21 Jun 2005, 12:33
View user's profile Send private message Reply with quote
woody



Joined: 18 Jun 2005
Posts: 14
woody 21 Jun 2005, 21:07
Hi all.
Problem sorted out now.
Thanks for everybody's help
Woody
Post 21 Jun 2005, 21:07
View user's profile Send private message Reply with quote
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Chewy509 21 Jun 2005, 23:19
woody wrote:
Hi all.
Problem sorted out now.
Thanks for everybody's help
Woody

What was the issue, and how did you solve it?
Post 21 Jun 2005, 23:19
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 14 Jul 2005, 23:35
There is a memory location where BIOS stores the current values of the keyboard lights. BIOS does not update these unless it changes them. In real mode, if you change the keyboard lights, you should probably update these. In protected mode, putting a value here does nothing, so you have to update them through the keyboard registers yourself.
Post 14 Jul 2005, 23:35
View user's profile Send private message AIM Address 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.