-
Notifications
You must be signed in to change notification settings - Fork 2
/
keyboard.c
39 lines (34 loc) · 1.13 KB
/
keyboard.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "bootpack.h"
int keydata0;
void wait_KBC_sendready(void){
// 等待键盘控制电路准备完毕
for (;;) {
if ((io_in8(PORT_KEYSTA) & KEYSTA_SEND_NOTREADY) == 0) {
break;
}
}
return;
}
void init_keyboard(struct FIFO32 *fifo, int data0){
keyfifo = fifo;
keydata0 = data0;
wait_KBC_sendready();
io_out8(PORT_KEYCMD, KEYCMD_WRITE_MODE);
wait_KBC_sendready(); // 等到可以接收
io_out8(PORT_KEYDAT, KBC_MODE);
return;
}
void inthandler21(int *esp){
// 来自键盘的中断0x21
int data; // 键盘中断数据
//struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
io_out8(PIC0_OCW2, 0x61); //通知IRQ-1已经受理完毕
data = io_in8(PORT_KEYDAT);
fifo32_put(keyfifo, data + keydata0);
// 不把屏幕渲染放入中断处理中
//boxfill8(binfo->vram, binfo->scrnx, COL8_BLACK, 0, 0, 32 * 8 - 1, 15);
//putfont8_asc(binfo->vram, binfo->scrnx, 123, 3, COL8_WHITE, "INT 21 (IQR-1) : PS/2 Keyboard");
//
//putfont8_hex(binfo->vram, binfo->scrnx, 3, 3, COL8_WHITE, (unsigned char *)&data);
return;
}