mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-12 01:46:48 +00:00
🐛 修复了键盘控制器被初始化之前,按键被按下,从而导致的收不到键盘中断的问题。
This commit is contained in:
parent
b828622ea6
commit
844e66f6bb
@ -396,6 +396,8 @@ void apic_init()
|
||||
// 初始化中断门, 中断使用rsp0防止在软中断时发生嵌套,然后处理器重新加载导致数据被抹掉
|
||||
for (int i = 32; i <= 55; ++i)
|
||||
set_intr_gate(i, 0, interrupt_table[i - 32]);
|
||||
|
||||
/*
|
||||
// 初始化主芯片
|
||||
io_out8(0x20, 0x11); // 初始化主芯片的icw1
|
||||
io_out8(0x21, 0x20); // 设置主芯片的中断向量号为0x20(0x20-0x27)
|
||||
@ -407,13 +409,13 @@ void apic_init()
|
||||
io_out8(0xa1, 0x28); // 设置从芯片的中断向量号为0x28(0x28-0x2f)
|
||||
io_out8(0xa1, 0x02); // 设置从芯片连接到主芯片的int2
|
||||
io_out8(0xa1, 0x01);
|
||||
|
||||
*/
|
||||
// 屏蔽类8259A芯片
|
||||
io_mfence();
|
||||
io_out8(0x21, 0xff);
|
||||
io_mfence();
|
||||
io_out8(0xa1, 0xff);
|
||||
io_mfence();
|
||||
io_out8(0x21, 0xff);
|
||||
io_mfence();
|
||||
|
||||
kdebug("8259A Masked.");
|
||||
|
||||
@ -449,10 +451,8 @@ void do_IRQ(struct pt_regs *rsp, ul number)
|
||||
{
|
||||
|
||||
if (number < 0x80 && number >= 32) // 以0x80为界限,低于0x80的是外部中断控制器,高于0x80的是Local APIC
|
||||
|
||||
// 外部中断控制器
|
||||
{
|
||||
|
||||
// ==========外部中断控制器========
|
||||
irq_desc_t *irq = &interrupt_desc[number - 32];
|
||||
|
||||
// 执行中断上半部处理程序
|
||||
|
@ -200,11 +200,8 @@ void ps2_keyboard_init()
|
||||
// 申请键盘循环队列缓冲区的内存
|
||||
kb_buf_ptr = (struct ps2_keyboard_input_buffer *)kmalloc(sizeof(struct ps2_keyboard_input_buffer), 0);
|
||||
|
||||
kb_buf_ptr->ptr_head = kb_buf_ptr->buffer;
|
||||
kb_buf_ptr->ptr_tail = kb_buf_ptr->buffer;
|
||||
kb_buf_ptr->count = 0;
|
||||
|
||||
memset(kb_buf_ptr->buffer, 0, ps2_keyboard_buffer_size);
|
||||
ps2_keyboard_reset_buffer(kb_buf_ptr);
|
||||
|
||||
|
||||
// ======== 初始化中断RTE entry ==========
|
||||
|
||||
@ -240,7 +237,10 @@ void ps2_keyboard_init()
|
||||
|
||||
// 注册中断处理程序
|
||||
irq_register(PS2_KEYBOARD_INTR_VECTOR, &entry, &ps2_keyboard_handler, (ul)kb_buf_ptr, &ps2_keyboard_intr_controller, "ps/2 keyboard");
|
||||
kdebug("kb registered.");
|
||||
|
||||
// 先读一下键盘的数据,防止由于在键盘初始化之前,由于按键被按下从而导致接收不到中断。
|
||||
io_in8(PORT_PS2_KEYBOARD_DATA);
|
||||
kinfo("ps/2 keyboard registered.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user