此代码:Linux内核模块,可直接控制PS/2键盘的LED(Num Lock,Caps Lock和Scroll Lock)
#include <linux/module.h>
#include <linux/kernel.h>
int check_bit(unsigned char status, int i) {
return (status & (1<<(i)));
}
unsigned char kbd_read_status() { // <== ERROR first appears on this line
return inb(0x64);
}
unsigned char kbd_read_data() {
unsigned char status;
do
{
status = kbd_read_status();
}
while(!check_bit(status, 0));
return inb(0x60);
}
Run Code Online (Sandbox Code Playgroud)
运行makefile时:
make -C /lib/modules/3.19.0-15-generic/build M=/home/fyousry/Desktop/hellokernel modules
make[1]: Entering directory '/usr/src/linux-headers-3.19.0-15-generic'
CC [M] /home/fyousry/Desktop/hellokernel/New.o
/home/fyousry/Desktop/hellokernel/New.c:9:15: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
unsigned char kbd_read_status() {
^
/home/fyousry/Desktop/hellokernel/New.c:13:15: …Run Code Online (Sandbox Code Playgroud)