mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-05 19:13:21 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96a714a9be |
@@ -29,13 +29,14 @@ void HariMain(void)
|
||||
|
||||
for (;;) {
|
||||
io_cli();
|
||||
if (keybuf.next == 0) {
|
||||
if (keybuf.len == 0) {
|
||||
io_stihlt();
|
||||
} else {
|
||||
i = keybuf.data[0];
|
||||
keybuf.next--;
|
||||
for (j = 0; j < keybuf.next; j++) {
|
||||
keybuf.data[j] = keybuf.data[j + 1];
|
||||
i = keybuf.data[keybuf.next_r];
|
||||
keybuf.len--;
|
||||
keybuf.next_r++;
|
||||
if (keybuf.next_r == 32) {
|
||||
keybuf.next_r = 0;
|
||||
}
|
||||
io_sti();
|
||||
sprintf(s, "%02X", i);
|
||||
|
||||
@@ -76,7 +76,7 @@ void set_gatedesc(struct GATE_DESCRIPTOR *gd, int offset, int selector, int ar);
|
||||
/* int.c */
|
||||
struct KEYBUF {
|
||||
unsigned char data[32];
|
||||
int next;
|
||||
int next_r, next_w, len;
|
||||
};
|
||||
void init_pic(void);
|
||||
void inthandler21(int *esp);
|
||||
|
||||
10
07_day/int.c
10
07_day/int.c
@@ -35,9 +35,13 @@ void inthandler21(int *esp)
|
||||
unsigned char data, s[4];
|
||||
io_out8(PIC0_OCW2, 0x61); /* 通知PIC IRQ-01 已经受理完毕 */
|
||||
data = io_in8(PORT_KEYDAT);
|
||||
if (keybuf.next < 32) {
|
||||
keybuf.data[keybuf.next] = data;
|
||||
keybuf.next++;
|
||||
if (keybuf.len < 32) {
|
||||
keybuf.data[keybuf.next_w] = data;
|
||||
keybuf.len++;
|
||||
keybuf.next_w++;
|
||||
if (keybuf.next_w == 32) {
|
||||
keybuf.next_w = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user