mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-11 05:45:04 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44c9f8c227 | ||
|
|
991f1056ad |
@@ -1,5 +1,5 @@
|
|||||||
OBJS_BOOTPACK = bootpack.obj naskfunc.obj hankaku.obj graphic.obj dsctbl.obj \
|
OBJS_BOOTPACK = bootpack.obj naskfunc.obj hankaku.obj graphic.obj dsctbl.obj \
|
||||||
int.obj fifo.obj keyboard.obj mouse.obj memory.obj sheet.obj timer.obj
|
int.obj fifo.obj keyboard.obj mouse.obj memory.obj sheet.obj timer.obj mtask.obj
|
||||||
|
|
||||||
TOOLPATH = ../z_tools/
|
TOOLPATH = ../z_tools/
|
||||||
INCPATH = ../z_tools/haribote/
|
INCPATH = ../z_tools/haribote/
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void HariMain(void)
|
|||||||
struct FIFO32 fifo;
|
struct FIFO32 fifo;
|
||||||
char s[40];
|
char s[40];
|
||||||
int fifobuf[128];
|
int fifobuf[128];
|
||||||
struct TIMER *timer, *timer2, *timer3, *timer_ts;
|
struct TIMER *timer, *timer2, *timer3;
|
||||||
int mx, my, i, cursor_x, cursor_c, task_b_esp;
|
int mx, my, i, cursor_x, cursor_c, task_b_esp;
|
||||||
unsigned int memtotal;
|
unsigned int memtotal;
|
||||||
struct MOUSE_DEC mdec;
|
struct MOUSE_DEC mdec;
|
||||||
@@ -60,9 +60,6 @@ void HariMain(void)
|
|||||||
timer3 = timer_alloc();
|
timer3 = timer_alloc();
|
||||||
timer_init(timer3, &fifo, 1);
|
timer_init(timer3, &fifo, 1);
|
||||||
timer_settime(timer3, 50);
|
timer_settime(timer3, 50);
|
||||||
timer_ts = timer_alloc();
|
|
||||||
timer_init(timer_ts, &fifo, 2);
|
|
||||||
timer_settime(timer_ts, 2);
|
|
||||||
|
|
||||||
memtotal = memtest(0x00400000, 0xbfffffff);
|
memtotal = memtest(0x00400000, 0xbfffffff);
|
||||||
memman_init(memman);
|
memman_init(memman);
|
||||||
@@ -124,6 +121,7 @@ void HariMain(void)
|
|||||||
tss_b.fs = 1 * 8;
|
tss_b.fs = 1 * 8;
|
||||||
tss_b.gs = 1 * 8;
|
tss_b.gs = 1 * 8;
|
||||||
*((int *) (task_b_esp + 4)) = (int) sht_back;
|
*((int *) (task_b_esp + 4)) = (int) sht_back;
|
||||||
|
mt_init();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
io_cli();
|
io_cli();
|
||||||
@@ -132,10 +130,7 @@ void HariMain(void)
|
|||||||
} else {
|
} else {
|
||||||
i = fifo32_get(&fifo);
|
i = fifo32_get(&fifo);
|
||||||
io_sti();
|
io_sti();
|
||||||
if (i == 2) {
|
if (256 <= i && i <= 511) { /* 键盘数据*/
|
||||||
farjmp(0, 4 * 8);
|
|
||||||
timer_settime(timer_ts, 2);
|
|
||||||
} else if (256 <= i && i <= 511) { /* 键盘数据*/
|
|
||||||
sprintf(s, "%02X", i - 256);
|
sprintf(s, "%02X", i - 256);
|
||||||
putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2);
|
putfonts8_asc_sht(sht_back, 0, 16, COL8_FFFFFF, COL8_008484, s, 2);
|
||||||
if (i < 0x54 + 256) {
|
if (i < 0x54 + 256) {
|
||||||
@@ -285,22 +280,20 @@ void make_textbox8(struct SHEET *sht, int x0, int y0, int sx, int sy, int c)
|
|||||||
void task_b_main(struct SHEET *sht_back)
|
void task_b_main(struct SHEET *sht_back)
|
||||||
{
|
{
|
||||||
struct FIFO32 fifo;
|
struct FIFO32 fifo;
|
||||||
struct TIMER *timer_ts, *timer_put;
|
struct TIMER *timer_put, *timer_1s;
|
||||||
int i, fifobuf[128], count = 0;
|
int i, fifobuf[128], count = 0, count0 = 0;
|
||||||
char s[12];
|
char s[12];
|
||||||
|
|
||||||
fifo32_init(&fifo, 128, fifobuf);
|
fifo32_init(&fifo, 128, fifobuf);
|
||||||
timer_ts = timer_alloc();
|
|
||||||
timer_init(timer_ts, &fifo, 2);
|
|
||||||
timer_settime(timer_ts, 2);
|
|
||||||
timer_put = timer_alloc();
|
timer_put = timer_alloc();
|
||||||
timer_init(timer_put, &fifo, 1);
|
timer_init(timer_put, &fifo, 1);
|
||||||
timer_settime(timer_put, 1);
|
timer_settime(timer_put, 1);
|
||||||
|
timer_1s = timer_alloc();
|
||||||
|
timer_init(timer_1s, &fifo, 100);
|
||||||
|
timer_settime(timer_1s, 100);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
count++;
|
count++;
|
||||||
sprintf(s, "%10d", count);
|
|
||||||
putfonts8_asc_sht(sht_back, 0, 144, COL8_FFFFFF, COL8_008484, s, 10);
|
|
||||||
io_cli();
|
io_cli();
|
||||||
if (fifo32_status(&fifo) == 0) {
|
if (fifo32_status(&fifo) == 0) {
|
||||||
io_sti();
|
io_sti();
|
||||||
@@ -311,9 +304,11 @@ void task_b_main(struct SHEET *sht_back)
|
|||||||
sprintf(s, "%11d", count);
|
sprintf(s, "%11d", count);
|
||||||
putfonts8_asc_sht(sht_back, 0, 144, COL8_FFFFFF, COL8_008484, s, 11);
|
putfonts8_asc_sht(sht_back, 0, 144, COL8_FFFFFF, COL8_008484, s, 11);
|
||||||
timer_settime(timer_put, 1);
|
timer_settime(timer_put, 1);
|
||||||
} else if (i == 2) {
|
} else if (i == 100) {
|
||||||
farjmp(0, 3 * 8);
|
sprintf(s, "%11d", count - count0);
|
||||||
timer_settime(timer_ts, 2);
|
putfonts8_asc_sht(sht_back, 0, 128, COL8_FFFFFF, COL8_008484, s, 11);
|
||||||
|
count0 = count;
|
||||||
|
timer_settime(timer_1s, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,3 +183,8 @@ void timer_free(struct TIMER *timer);
|
|||||||
void timer_init(struct TIMER *timer, struct FIFO32 *fifo, int 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);
|
||||||
|
|
||||||
|
/* mtask.c */
|
||||||
|
extern struct TIMER *mt_timer;
|
||||||
|
void mt_init(void);
|
||||||
|
void mt_taskswitch(void);
|
||||||
|
|||||||
27
15_day/mtask.c
Normal file
27
15_day/mtask.c
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* 多任务管理 */
|
||||||
|
|
||||||
|
#include "bootpack.h"
|
||||||
|
|
||||||
|
struct TIMER *mt_timer;
|
||||||
|
int mt_tr;
|
||||||
|
|
||||||
|
void mt_init(void)
|
||||||
|
{
|
||||||
|
mt_timer = timer_alloc();
|
||||||
|
/*这里没有必要使用timer_init */
|
||||||
|
timer_settime(mt_timer, 2);
|
||||||
|
mt_tr = 3 * 8;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mt_taskswitch(void)
|
||||||
|
{
|
||||||
|
if (mt_tr == 3 * 8) {
|
||||||
|
mt_tr = 4 * 8;
|
||||||
|
} else {
|
||||||
|
mt_tr = 3 * 8;
|
||||||
|
}
|
||||||
|
timer_settime(mt_timer, 2);
|
||||||
|
farjmp(0, mt_tr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
@@ -88,6 +88,7 @@ void timer_settime(struct TIMER *timer, unsigned int timeout)
|
|||||||
void inthandler20(int *esp)
|
void inthandler20(int *esp)
|
||||||
{
|
{
|
||||||
struct TIMER *timer;
|
struct TIMER *timer;
|
||||||
|
char ts = 0;
|
||||||
io_out8(PIC0_OCW2, 0x60); /* 把IRQ-00接收信号结束的信息通知给PIC */
|
io_out8(PIC0_OCW2, 0x60); /* 把IRQ-00接收信号结束的信息通知给PIC */
|
||||||
timerctl.count++;
|
timerctl.count++;
|
||||||
if (timerctl.next > timerctl.count) {
|
if (timerctl.next > timerctl.count) {
|
||||||
@@ -101,10 +102,17 @@ void inthandler20(int *esp)
|
|||||||
}
|
}
|
||||||
/* 超时 */
|
/* 超时 */
|
||||||
timer->flags = TIMER_FLAGS_ALLOC;
|
timer->flags = TIMER_FLAGS_ALLOC;
|
||||||
fifo32_put(timer->fifo, timer->data);
|
if (timer != mt_timer) {
|
||||||
|
fifo32_put(timer->fifo, timer->data);
|
||||||
|
} else {
|
||||||
|
ts = 1; /* mt_timer超时*/
|
||||||
|
}
|
||||||
timer = timer->next; /* 将下一个定时器的地址赋给timer*/
|
timer = timer->next; /* 将下一个定时器的地址赋给timer*/
|
||||||
}
|
}
|
||||||
timerctl.t0 = timer;
|
timerctl.t0 = timer;
|
||||||
timerctl.next = timer->timeout;
|
timerctl.next = timer->timeout;
|
||||||
|
if (ts != 0) {
|
||||||
|
mt_taskswitch();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user