1 #pragma once 2 3 #include <common/glib.h> 4 5 #define PS2_KEYBOARD_INTR_VECTOR 0x21 // 键盘的中断向量号 6 7 // 定义键盘循环队列缓冲区大小为100bytes 8 #define ps2_keyboard_buffer_size 8 9 10 #define KEYBOARD_CMD_RESET_BUFFER 1 11 12 #define PORT_PS2_KEYBOARD_DATA 0x60 13 #define PORT_PS2_KEYBOARD_STATUS 0x64 14 #define PORT_PS2_KEYBOARD_CONTROL 0x64 15 16 #define PS2_KEYBOARD_COMMAND_WRITE 0x60 // 向键盘发送配置命令 17 #define PS2_KEYBOARD_COMMAND_READ 0x20 // 读取键盘的配置值 18 #define PS2_KEYBOARD_PARAM_INIT 0x47 // 初始化键盘控制器的配置值 19 20 // ========= 检测键盘控制器输入/输出缓冲区是否已满 21 #define PS2_KEYBOARD_FLAG_OUTBUF_FULL 0x01 // 键盘的输出缓冲区已满标志位 22 #define PS2_KEYBOARD_FLAG_INBUF_FULL 0x02 // 键盘的输入缓冲区已满标志位 23 24 // 等待向键盘控制器写入信息完成 25 // todo: bugfix:在不包含ps2键盘控制器的机器上,这里会卡死 26 #define wait_ps2_keyboard_write() while (io_in8(PORT_PS2_KEYBOARD_STATUS) & PS2_KEYBOARD_FLAG_INBUF_FULL) 27 // #define wait_ps2_keyboard_write() (1) 28 // 等待从键盘控制器读取信息完成 29 #define wait_ps2_keyboard_read() while (io_in8(PORT_PS2_KEYBOARD_STATUS) & PS2_KEYBOARD_FLAG_OUTBUF_FULL) 30 // #define wait_ps2_keyboard_read() (1) 31 32 extern struct vfs_file_operations_t ps2_keyboard_fops; 33 34 /** 35 * @brief 初始化键盘驱动程序的函数 36 * 37 */ 38 void ps2_keyboard_init(); 39 40 /** 41 * @brief 键盘驱动卸载函数 42 * 43 */ 44 void ps2_keyboard_exit(); 45