简体   繁体   English

在自定义内核中打开/关闭PS / 2键盘的Caps Lock LED

[英]Turn PS/2 keyboard Caps Lock LED on/off in custom kernel

I'm developing a kernel with Assembly and C and in the boot up process, I want the kernel to turn the Caps lock key on then off. 我正在使用Assembly和C开发内核,并且在启动过程中,我希望内核先打开然后关闭Caps lock键。 I have found the reference for the LED on the key here . 我已经找到了该按键上的LED参考这里 How could I call that function with C or assembly (nasm style)? 如何用C或汇编语言(nasm样式)调用该函数?

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

eg: 例如:

   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). 其中keyBoardStatus是一个字节(它将保存当前键盘LED状态)。

You can read my code for reference: irq_ex2.c: An interrupt handler example. 您可以阅读我的代码以供参考:irq_ex2.c:中断处理程序示例。 This code binds itself to IRQ 1, which is the IRQ of the keyboard controlled under Intel architectures. 此代码将自身绑定到IRQ 1,IRQ 1是受英特尔架构控制的键盘的IRQ。 Then, when it receives a keyboard interrupt, it reads the information about status led and keycode into the work queue. 然后,当它收到键盘中断时,它将有关状态指示灯和键码的信息读入工作队列。 Pressing: 紧迫:

  • ESC ---> Caps Lock Led OFF ESC --->大写锁定指示灯关闭

  • F1,F2 ---> Caps Lock ON F1,F2->大写锁定

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM