diff --git a/12_day/bootpack.c b/12_day/bootpack.c index a2468c9..811e2ef 100644 --- a/12_day/bootpack.c +++ b/12_day/bootpack.c @@ -10,7 +10,7 @@ void HariMain(void) struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; char s[40], keybuf[32], mousebuf[128]; int mx, my, i; - unsigned int memtotal, count = 0; + unsigned int memtotal; struct MOUSE_DEC mdec; struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR; struct SHTCTL *shtctl; @@ -62,8 +62,7 @@ void HariMain(void) sheet_refresh(sht_back, 0, 0, binfo->scrnx, 48); /* 刷新文字 */ for (;;) { - count++; /* 从这里开始 */ - sprintf(s, "%010d", count); + sprintf(s, "%010d", timerctl.count); boxfill8(buf_win, 160, COL8_C6C6C6, 40, 28, 119, 43); putfonts8_asc(buf_win, 160, 40, 28, COL8_000000, s); sheet_refresh(sht_win, 40, 28, 120, 44); /* 到这里结束 */ diff --git a/12_day/bootpack.h b/12_day/bootpack.h index dd81c9b..4453c10 100644 --- a/12_day/bootpack.h +++ b/12_day/bootpack.h @@ -169,5 +169,10 @@ void sheet_slide(struct SHEET *sht, int vx0, int vy0); void sheet_free(struct SHEET *sht); /* timer.c */ +struct TIMERCTL { + unsigned int count; +}; +extern struct TIMERCTL timerctl; + void init_pit(void); void inthandler20(int *esp); diff --git a/12_day/timer.c b/12_day/timer.c index 1020139..41b7e81 100644 --- a/12_day/timer.c +++ b/12_day/timer.c @@ -5,16 +5,20 @@ #define PIT_CTRL 0x0043 #define PIT_CNT0 0x0040 +struct TIMERCTL timerctl; + void init_pit(void) { io_out8(PIT_CTRL, 0x43); io_out8(PIT_CNT0, 0x9c); io_out8(PIT_CNT0, 0x2e); + timerctl.count = 0; + return; } void inthandler20(int *esp) { io_out8(PIC0_OCW2, 0x60); /* 把IRQ-00信号接收完了的信息通知给PIC */ - /* 暂时什么也不做 */ + timerctl.count++; return; }