代码整理

This commit is contained in:
Yourtion
2016-04-20 14:10:39 +08:00
parent 36f64a7650
commit 5204ca9f32
4 changed files with 8 additions and 10 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}
/* 应该不可能到这里来 */

View File

@@ -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) {