diff --git a/15_day/bootpack.c b/15_day/bootpack.c index 42ea912..224c5de 100644 --- a/15_day/bootpack.c +++ b/15_day/bootpack.c @@ -22,7 +22,7 @@ void HariMain(void) struct FIFO32 fifo; char s[40]; int fifobuf[128]; - struct TIMER *timer, *timer2, *timer3; + struct TIMER *timer, *timer2, *timer3, *timer_ts; int mx, my, i, cursor_x, cursor_c, task_b_esp; unsigned int memtotal; struct MOUSE_DEC mdec; @@ -60,6 +60,9 @@ void HariMain(void) timer3 = timer_alloc(); timer_init(timer3, &fifo, 1); timer_settime(timer3, 50); + timer_ts = timer_alloc(); + timer_init(timer_ts, &fifo, 2); + timer_settime(timer_ts, 2); memtotal = memtest(0x00400000, 0xbfffffff); memman_init(memman); @@ -128,7 +131,10 @@ void HariMain(void) } else { i = fifo32_get(&fifo); io_sti(); - if (256 <= i && i <= 511) { /* 键盘数据*/ + if (i == 2) { + farjmp(0, 4 * 8); + timer_settime(timer_ts, 2); + } else if (256 <= i && i <= 511) { /* 键盘数据*/ sprintf(s, "%02X", i - 256); putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2); if (i < 0x54 + 256) { @@ -185,7 +191,6 @@ void HariMain(void) } } else if (i == 10) { /* 10秒定时器 */ putfonts8_asc_sht(sht_back, 0, 64, COL8_FFFFFF, COL8_008484, "10[sec]", 7); - taskswitch4(); } else if (i == 3) { /* 3秒定时器 */ putfonts8_asc_sht(sht_back, 0, 80, COL8_FFFFFF, COL8_008484, "3[sec]", 6); } else if (i <= 1) { /* 光标用定时器*/ @@ -279,12 +284,12 @@ void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c) void task_b_main(void) { struct FIFO32 fifo; - struct TIMER *timer; + struct TIMER *timer_ts; int i, fifobuf[128]; fifo32_init(&fifo, 128, fifobuf); - timer = timer_alloc(); - timer_init(timer, &fifo, 1); - timer_settime(timer, 500); + timer_ts = timer_alloc(); + timer_init(timer_ts, &fifo, 1); + timer_settime(timer_ts, 2); for (;;) { io_cli(); @@ -293,8 +298,9 @@ void task_b_main(void) } else { i = fifo32_get(&fifo); io_sti(); - if (i == 1) { /*超时时间为5秒 */ - taskswitch3(); /*返回任务A */ + if (i == 1) { /*任务切换*/ + farjmp(0, 3 * 8); + timer_settime(timer_ts, 2); } } } diff --git a/15_day/bootpack.h b/15_day/bootpack.h index 5868890..14fe41c 100644 --- a/15_day/bootpack.h +++ b/15_day/bootpack.h @@ -28,8 +28,7 @@ void asm_inthandler21(void); void asm_inthandler27(void); void asm_inthandler2c(void); unsigned int memtest_sub(unsigned int start, unsigned int end); -void taskswitch3(void); -void taskswitch4(void); +void farjmp(int eip, int cs); /* fifo.c */ struct FIFO32 { diff --git a/15_day/naskfunc.nas b/15_day/naskfunc.nas index d7194a7..6901d26 100644 --- a/15_day/naskfunc.nas +++ b/15_day/naskfunc.nas @@ -16,7 +16,7 @@ GLOBAL _asm_inthandler20, _asm_inthandler21 GLOBAL _asm_inthandler27, _asm_inthandler2c GLOBAL _memtest_sub - GLOBAL _taskswitch3, _taskswitch4 + GLOBAL _farjmp EXTERN _inthandler20, _inthandler21 EXTERN _inthandler27, _inthandler2c @@ -207,10 +207,6 @@ mts_fin: POP EDI RET -_taskswitch3: ; void taskswitch3(void); - JMP 3*8:0 - RET - -_taskswitch4: ; void taskswitch4(void); - JMP 4*8:0 - RET +_farjmp: ; void farjmp(int eip, int cs); + JMP FAR [ESP+4] ; eip, cs + RET \ No newline at end of file