From 5204ca9f328ff6bb77ca8a8a21ec4e993e7441d7 Mon Sep 17 00:00:00 2001 From: Yourtion Date: Wed, 20 Apr 2016 14:10:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 13_day/bootpack.c | 4 ++-- 13_day/bootpack.h | 2 +- 13_day/mouse.c | 7 +++---- 13_day/timer.c | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/13_day/bootpack.c b/13_day/bootpack.c index 9f7bb8e..18cd32c 100644 --- a/13_day/bootpack.c +++ b/13_day/bootpack.c @@ -13,7 +13,7 @@ void HariMain(void) char s[40]; int fifobuf[128]; struct TIMER *timer, *timer2, *timer3; - int mx, my, i, count; + int mx, my, i, count = 0; unsigned int memtotal; struct MOUSE_DEC mdec; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; @@ -25,11 +25,11 @@ void HariMain(void) init_pic(); io_sti(); /* IDT/PIC的初始化已经完成,于是开放CPU的中断 */ fifo32_init(&fifo, 128, fifobuf); + init_pit(); init_keyboard(&fifo, 256); enable_mouse(&fifo, 512, &mdec); io_out8(PIC0_IMR, 0xf8); /* 设定PIT和PIC1以及键盘为许可(11111000) */ io_out8(PIC1_IMR, 0xef); /* 开放鼠标中断(11101111) */ - init_pit(); timer = timer_alloc(); timer_init(timer, &fifo, 10); diff --git a/13_day/bootpack.h b/13_day/bootpack.h index 0d3a105..1ca75e6 100644 --- a/13_day/bootpack.h +++ b/13_day/bootpack.h @@ -183,7 +183,7 @@ extern struct TIMERCTL timerctl; void init_pit(void); struct TIMER *timer_alloc(void); void timer_free(struct TIMER *timer); -void timer_init(struct TIMER *timer, struct FIFO32 *fifo, unsigned char data); +void timer_init(struct TIMER *timer, struct FIFO32 *fifo, int data); void timer_settime(struct TIMER *timer, unsigned int timeout); void inthandler20(int *esp); diff --git a/13_day/mouse.c b/13_day/mouse.c index 625a899..0c6403e 100644 --- a/13_day/mouse.c +++ b/13_day/mouse.c @@ -6,8 +6,8 @@ struct FIFO32 *mousefifo; int mousedata0; void inthandler2c(int *esp) +/* 来自PS/2鼠标的中断 */ { - /* 来自PS/2鼠标的中断 */ int data; io_out8(PIC1_OCW2, 0x64); /* 把IRQ-12接收信号结束的信息通知给PIC1 */ io_out8(PIC0_OCW2, 0x62); /* 把IRQ-02接收信号结束的信息通知给PIC0 */ @@ -67,9 +67,8 @@ int mouse_decode(struct MOUSE_DEC *mdec, unsigned char dat) } if ((mdec->buf[0] & 0x20) != 0) { mdec->y |= 0xffffff00; - } - /* 鼠标的y方向与画面符号相反 */ - mdec->y = - mdec->y; + } + mdec->y = - mdec->y; /* 鼠标的y方向与画面符号相反 */ return 1; } /* 应该不可能到这里来 */ diff --git a/13_day/timer.c b/13_day/timer.c index a8977d4..a987db8 100644 --- a/13_day/timer.c +++ b/13_day/timer.c @@ -20,7 +20,7 @@ void init_pit(void) timerctl.next = 0xffffffff; /* 因为最初没有正在运行的定时器 */ timerctl.using = 0; for (i = 0; i < MAX_TIMER; i++) { - timerctl.timers0[i].flags = 0; /* 未使用 */ + timerctl.timers0[i].flags = 0; /* 未使用 */ } return; } @@ -43,7 +43,7 @@ void timer_free(struct TIMER *timer) return; } -void timer_init(struct TIMER *timer, struct FIFO32 *fifo, unsigned char data) +void timer_init(struct TIMER *timer, struct FIFO32 *fifo, int data) { timer->fifo = fifo; timer->data = data; @@ -83,7 +83,6 @@ void inthandler20(int *esp) if (timerctl.next > timerctl.count) { return; /* 还不到下一个时刻,所以结束*/ } - timerctl.next = 0xffffffff; for (i = 0; i < timerctl.using; i++) { /* timers的定时器都处于动作中,所以不确认flags */ if (timerctl.timers[i]->timeout > timerctl.count) {