Reputation:
I'm developing a kernel with assembly language and C and in the boot up process, I want the kernel to turn the Caps Lock key on and then off. I have found the reference for the LED on the key here. How could I call that function with C or assembly (NASM style)?
Upvotes: 1
Views: 1390
Reputation: 21
You can read my code for reference:
irq_ex2.c: An interrupt handler example. This code binds itself to IRQ 1, which is the IRQ of the keyboard controlled under Intel architectures. Then, when it receives a keyboard interrupt, it reads the information about the status LED and keycode into the work queue.
Pressing:
ESC → Caps Lock LED OFF
F1,F2 → Caps Lock ON
Upvotes: 0
Reputation: 1272
SetKeyBoardLeds:
push eax
mov al,0xed
out 60h,al
KeyBoardWait:
in al,64h
test al,10b
jne KeyBoardWait
mov al,byte [keyBoardStatus]
and al,111b
out 60h,al
pop eax
ret
For example,
mov [keyBoardStatus],0xb0 ; Initialise keyboard LED state
call SetKeyBoardLeds
;--------------------------------- This will toggle CapsLock LED
xor [keyBoardStatus],4
call SetKeyBoardLeds
;---------------------------------
and [keyBoardStatus],0xfb
call SetKeyBoardLeds
where keyBoardStatus is a byte (it will hold the current keyboard LED state).
Upvotes: 1