mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-04-14 10:21:06 +08:00
代码整理
This commit is contained in:
@@ -13,7 +13,7 @@ void HariMain(void)
|
|||||||
char s[40];
|
char s[40];
|
||||||
int fifobuf[128];
|
int fifobuf[128];
|
||||||
struct TIMER *timer, *timer2, *timer3;
|
struct TIMER *timer, *timer2, *timer3;
|
||||||
int mx, my, i, count;
|
int mx, my, i, count = 0;
|
||||||
unsigned int memtotal;
|
unsigned int memtotal;
|
||||||
struct MOUSE_DEC mdec;
|
struct MOUSE_DEC mdec;
|
||||||
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
|
||||||
@@ -25,11 +25,11 @@ void HariMain(void)
|
|||||||
init_pic();
|
init_pic();
|
||||||
io_sti(); /* IDT/PIC的初始化已经完成,于是开放CPU的中断 */
|
io_sti(); /* IDT/PIC的初始化已经完成,于是开放CPU的中断 */
|
||||||
fifo32_init(&fifo, 128, fifobuf);
|
fifo32_init(&fifo, 128, fifobuf);
|
||||||
|
init_pit();
|
||||||
init_keyboard(&fifo, 256);
|
init_keyboard(&fifo, 256);
|
||||||
enable_mouse(&fifo, 512, &mdec);
|
enable_mouse(&fifo, 512, &mdec);
|
||||||
io_out8(PIC0_IMR, 0xf8); /* 设定PIT和PIC1以及键盘为许可(11111000) */
|
io_out8(PIC0_IMR, 0xf8); /* 设定PIT和PIC1以及键盘为许可(11111000) */
|
||||||
io_out8(PIC1_IMR, 0xef); /* 开放鼠标中断(11101111) */
|
io_out8(PIC1_IMR, 0xef); /* 开放鼠标中断(11101111) */
|
||||||
init_pit();
|
|
||||||
|
|
||||||
timer = timer_alloc();
|
timer = timer_alloc();
|
||||||
timer_init(timer, &fifo, 10);
|
timer_init(timer, &fifo, 10);
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ extern struct TIMERCTL timerctl;
|
|||||||
void init_pit(void);
|
void init_pit(void);
|
||||||
struct TIMER *timer_alloc(void);
|
struct TIMER *timer_alloc(void);
|
||||||
void timer_free(struct TIMER *timer);
|
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 timer_settime(struct TIMER *timer, unsigned int timeout);
|
||||||
void inthandler20(int *esp);
|
void inthandler20(int *esp);
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ struct FIFO32 *mousefifo;
|
|||||||
int mousedata0;
|
int mousedata0;
|
||||||
|
|
||||||
void inthandler2c(int *esp)
|
void inthandler2c(int *esp)
|
||||||
|
/* 来自PS/2鼠标的中断 */
|
||||||
{
|
{
|
||||||
/* 来自PS/2鼠标的中断 */
|
|
||||||
int data;
|
int data;
|
||||||
io_out8(PIC1_OCW2, 0x64); /* 把IRQ-12接收信号结束的信息通知给PIC1 */
|
io_out8(PIC1_OCW2, 0x64); /* 把IRQ-12接收信号结束的信息通知给PIC1 */
|
||||||
io_out8(PIC0_OCW2, 0x62); /* 把IRQ-02接收信号结束的信息通知给PIC0 */
|
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) {
|
if ((mdec->buf[0] & 0x20) != 0) {
|
||||||
mdec->y |= 0xffffff00;
|
mdec->y |= 0xffffff00;
|
||||||
}
|
}
|
||||||
/* 鼠标的y方向与画面符号相反 */
|
mdec->y = - mdec->y; /* 鼠标的y方向与画面符号相反 */
|
||||||
mdec->y = - mdec->y;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* 应该不可能到这里来 */
|
/* 应该不可能到这里来 */
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ void init_pit(void)
|
|||||||
timerctl.next = 0xffffffff; /* 因为最初没有正在运行的定时器 */
|
timerctl.next = 0xffffffff; /* 因为最初没有正在运行的定时器 */
|
||||||
timerctl.using = 0;
|
timerctl.using = 0;
|
||||||
for (i = 0; i < MAX_TIMER; i++) {
|
for (i = 0; i < MAX_TIMER; i++) {
|
||||||
timerctl.timers0[i].flags = 0; /* 未使用 */
|
timerctl.timers0[i].flags = 0; /* 未使用 */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ void timer_free(struct TIMER *timer)
|
|||||||
return;
|
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->fifo = fifo;
|
||||||
timer->data = data;
|
timer->data = data;
|
||||||
@@ -83,7 +83,6 @@ void inthandler20(int *esp)
|
|||||||
if (timerctl.next > timerctl.count) {
|
if (timerctl.next > timerctl.count) {
|
||||||
return; /* 还不到下一个时刻,所以结束*/
|
return; /* 还不到下一个时刻,所以结束*/
|
||||||
}
|
}
|
||||||
timerctl.next = 0xffffffff;
|
|
||||||
for (i = 0; i < timerctl.using; i++) {
|
for (i = 0; i < timerctl.using; i++) {
|
||||||
/* timers的定时器都处于动作中,所以不确认flags */
|
/* timers的定时器都处于动作中,所以不确认flags */
|
||||||
if (timerctl.timers[i]->timeout > timerctl.count) {
|
if (timerctl.timers[i]->timeout > timerctl.count) {
|
||||||
|
|||||||
Reference in New Issue
Block a user