Esempio n. 1
0
void timer_settimer ( struct TIMER *timer, unsigned int timeout )
{
	int e;
	struct TIMER *t, *s;
	timer->timeout = timeout + timerctl.count;
	timer->flags = TIMER_FLAGS_USING;
	e = io_load_eflags();
	io_cli();
//	timerctl.using ++;

	t = timerctl.t0;
	if ( timer->timeout <= t->timeout ) {
	/* Inserting to the fisrt place*/
		timerctl.t0 = timer;
		timer->next = t;
		timerctl.next = timer->timeout;
		io_store_eflags(e);
		return ;
	}
	while (1) {
		s = t;
		t = t->next;
		if ( timer->timeout <= t->timeout ) {
		/*between t and s */
			s->next = timer;
			timer->next = t;
			io_store_eflags(e);
			return ;
		}
	}
	return ;	
}
Esempio n. 2
0
void task_b_main(LAYER *layer)
{
	FIFO fifo;
	TIMER *timer_1s;
	int i, fifobuf[128], count = 0, count0 = 0;
	char s[12];

	init_fifo(&fifo, 128, fifobuf, 0);
	timer_1s = timer_alloc();
	timer_init(timer_1s, &fifo, 100);
	timer_set(timer_1s, 100);

	for (;;) {
		count++;
		io_cli();
		if (fifo_status(&fifo) == 0) 
		{
			io_sti();
		} 
		else 
		{
			i = fifo_get(&fifo);
			io_sti();
			if (i == 100)
			{
				sprintf(s, "%11d", count - count0);
				displayStrings_atLayer(layer, 24, 28, COL8_000000, COL8_C6C6C6, s);
				count0 = count;
				timer_set(timer_1s, 100);
			}
		}
	}
}
Esempio n. 3
0
void HariMain(void)
{
	struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
	char s[40], mcursor[256], keybuf[32];
	int mx, my, i;

	init_gdtidt();
	init_pic();
	io_sti(); 

	fifo8_init(&keyfifo, 32, keybuf);
	io_out8(PIC0_IMR, 0xf9); 
	io_out8(PIC1_IMR, 0xef); 

	init_palette();
	init_screen8(binfo->vram, binfo->scrnx, binfo->scrny);
	mx = (binfo->scrnx - 16) / 2; 
	my = (binfo->scrny - 28 - 16) / 2;
	init_mouse_cursor8(mcursor, COL8_008484);
	putblock8_8(binfo->vram, binfo->scrnx, 16, 16, mx, my, mcursor, 16);
	putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FFFFFF, s);

	for (;;) {
		io_cli();
		if (fifo8_status(&keyfifo) == 0) {
			io_stihlt();
		} else {
			i = fifo8_get(&keyfifo);
			io_sti();
			boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
			putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
		}
	}  
 
}
Esempio n. 4
0
void timer_settime(struct TIMER *timer, unsigned int timeout)
{
	/*
	* timeout: 0.01s
	*/
	int e;
	struct TIMER *t, *s;
	timer->timeout = timeout + timerctl.count;
	timer->flags = TIMER_FLAGS_USING;
	e = io_load_eflags();
	io_cli();
	t = timerctl.t0;
	if (timer->timeout <= t->timeout) {
		/* 插入最前面的情况下 */
		timerctl.t0 = timer;
		timer->nextTimer = t;									/* 下面是t */
		timerctl.nextTime = timer->timeout;
		io_store_eflags(e);
		return;
	}
	/* 搜寻插入位置 */
	for (;;) {
		s = t;
		t = t->nextTimer;
		if (timer->timeout <= t->timeout) {
			/* 插入到s和t之间时 */
			s->nextTimer = timer;								/* s的下一个是timer */
			timer->nextTimer = t;								/* timer的下一个是t */
			io_store_eflags(e);
			return;
		}
	}
}
Esempio n. 5
0
int timer_cancel(struct TIMER *timer)
{
	int e;
	struct TIMER *t;
	e = io_load_eflags();
	io_cli();	/* 在设置过程中禁止改变定时器状态 */
	if (timer->flags == TIMER_FLAGS_USING) {	/* 是否要取消? */
		if (timer == timerctl.t0) {
			/* 第一个定时器的取消处理 */
			t = timer->next;
			timerctl.t0 = t;
			timerctl.next = t->timeout;
		} else {
			/* 非第一个定时器的取消处理 */
			/* 找到timer前一个定时器 */
			t = timerctl.t0;
			for (;;) {
				if (t->next == timer) {
					break;
				}
				t = t->next;
			}
			t->next = timer->next; /* 将之前“timer的下一个”指向“timer的下一个” */
		}
		timer->flags = TIMER_FLAGS_ALLOC;
		io_store_eflags(e);
		return 1;	/* 取消处理成功 */
	}
	io_store_eflags(e);
	return 0; /* 不需要取消处理 */
}
Esempio n. 6
0
void task_b_main (struct SHEET *sht_back)
{
  struct FIFO32 fifo;
  struct TIMER *timer_ts, *timer_put;
  int i, fifobuf[128], count = 0;

  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_init(timer_put, &fifo, 1);
  timer_settime(timer_put, 1);
  
  for (;;) {
    count++;
    io_cli();
    if (fifo32_status(&fifo) == 0) {
      io_stihlt();
    } else {
      i = fifo32_get(&fifo);
      io_sti();
      if (i == 1) {
        char s[11];
        sprintf (s, "%d", count);
        putfonts8_asc_sht (sht_back, 0, 144, COL8_FFFFFF, COL8_008484, s, 11);
        timer_settime (timer_put, 1);
      } else if (i == 2) {  // timeout 5 sec
        farjmp(0, 3 * 8);
        timer_settime(timer_ts, 2);
      }
    }
  }
}
Esempio n. 7
0
void timer_settime(UI_Timer *timer, uint timeout)
{
	int ef;
	UI_Timer *t, *s;

	timer->timeout = timeout + system.ui.timer.ctrl.count;
	timer->flags = inuse;
	ef = io_load_eflags();
	io_cli();
	t = system.ui.timer.ctrl.timers;
	if(timer->timeout <= t->timeout){
		system.ui.timer.ctrl.timers = timer;
		timer->next_timer = t;
		system.ui.timer.ctrl.next_count = timer->timeout;
		io_store_eflags(ef);
		return;
	}
	for(;;){
		s = t;
		t = t->next_timer;
		if(timer->timeout <= t->timeout){
			s->next_timer = timer;
			timer->next_timer = t;
			io_store_eflags(ef);
			return;				
		}
	}
}
Esempio n. 8
0
int timer_cancel (struct TIMER *timer)
{
    int e;
    struct TIMER *t;
    e = io_load_eflags();
    io_cli();
    if (timer->flags == TIMER_FLAGS_USING) {
        if (timer == timerctl.t0) {
            t = timer->next;

            timerctl.t0 = t;
            timerctl.next = t->timeout;
        } else {
            t = timerctl.t0;
            for (;;) {
                if (t->next == timer) break;
                t = t->next;
            }
            t->next = timer->next;
        }
        timer->flags = TIMER_FLAGS_ALLOC;
        io_store_eflags(e);
        return 1;
    }
    io_store_eflags(e);
    return 0;
}
Esempio n. 9
0
int timer_cancel(timer_t* timer)
{
    int e;
    timer_t* t;
    e = io_load_eflags();
    io_cli(); /* 在设置过程中禁止改变定时器状态 */
    if (timer->flags == TIMER_FLAGS_USING) { /* 是否需要取消? */
        if (timer == timerctl.t0) {
            /* 第一个定时器的取消 */
            t = timer->next;
            timerctl.t0 = t;
            timerctl.next = t->timeout;
        } else {
            /* 其他定时器的取消 */
            /* 找到前一个定时器 */
            t = timerctl.t0;
            for (;;) {
                if (t->next == timer) {
                    break;
                }
                t = t->next;
            }
            t->next = timer->next; /* 将「timerの直前」的下一个指向「timerの次」 */
        }
        timer->flags = TIMER_FLAGS_ALLOC;
        io_store_eflags(e);
        return 1; /* 取消成功 */
    }
    io_store_eflags(e);
    return 0; /* 不需要取消处理 */
}
Esempio n. 10
0
void task_b_main(void)
{
    struct FIFO32 fifo;
    struct TIMER *timer;
    int i, fifobuf[128];

    fifo32_init(&fifo, 128, fifobuf);
    timer = timer_alloc();
    timer_init(timer, &fifo, 1);
    timer_settime(timer, 500);
  
    for (;;) {
	io_cli();
	if (fifo32_status(&fifo) == 0) {
	    io_sti();
	    io_hlt();
	} else {
	    i = fifo32_get(&fifo);
	    io_sti();
	    if (i == 1) {
		taskswitch3();
	    }
	}
    }
}
Esempio n. 11
0
void set_palette(int start, int end, unsigned char *rgb){
	int i, eflags;
	eflags = io_load_eflags();
	io_cli();					/* During initalization, the interruption should not take place*/
	/*
	Access pallete:
	Set color:
	1. Cli
	2. Write the color number to 0x03c8, then write to 0x03c9 in RGB order.
	3. If you want to set the color next to the previous, then write to 0x03c9 in RGB order.
	   If you want to set another color, goto step 2.
	4. Sti
	
	Read color:
	Steps are similar, and you just need to read 0x03c9 insted of writing.
	*/
	io_out8(0x03c8, start);
	for (i = start; i <= end; i++) {
		io_out8(0x03c9, rgb[0] / 4);
		io_out8(0x03c9, rgb[1] / 4);
		io_out8(0x03c9, rgb[2] / 4);
		rgb += 3;
	}
	io_store_eflags(eflags);
	return;
}
Esempio n. 12
0
void clock_set_time(struct CLOCK *clock, unsigned int time_out)
{
	int e;
	struct CLOCK *c, *s;
	clock->time_out = time_out + clock_ctl->count;
	clock->flag_usage = CLOCK_FLAGS_USING;
	e = io_load_eflags();
	io_cli();
	c = clock_ctl->c0;
	if (clock->time_out <= c->time_out) {
		clock_ctl->c0 = clock;
		clock->next = c;
		clock_ctl->next = clock->time_out;
		io_store_eflags(e);
		return;
	}
	for (;;) {
		s = c;
		c = c->next;
		if (clock->time_out <= c->time_out) {
			s->next = clock;
			clock->next = c;
			io_store_eflags(e);
			return;
		}
	}
}
Esempio n. 13
0
static void 
task_b_main(layer_t* win_layer_b)
{
  fifo32_t fifo;
  timer_t* timer_1s;
  int data, count = 0, count1 = 0;
  int fifobuf[128];
  char buf[32];

  fifo_init(&fifo, fifobuf, 128, 0);
  timer_1s = timer_alloc();
  timer_init(timer_1s, &fifo, 100);
  timer_settimer(timer_1s, 100);

  for ( ; ; ) {
    ++count;
    io_cli();

    if (0 == fifo_size(&fifo))
      io_sti();
    else {
      data = fifo_get(&fifo);
      io_sti();

      if (100 == data) {
        sprintf(buf, "%011d", count - count1);
        drawstring_and_refresh(win_layer_b, 24, 28, 
            COLOR8_000000, COLOR8_C6C6C6, buf, 11);
        count1 = count;

        timer_settimer(timer_1s, 100);
      }
    }
  }
}
Esempio n. 14
0
void task_b_main(LAYER *layer_bg)
{
	FIFO fifo;
	TIMER *timer_display;
	int i, fifobuf[128], count = 0;
	char strings[20];
	
	init_fifo(&fifo, 128, fifobuf);
	
	timer_display = timer_alloc();
	timer_init(timer_display, &fifo, 1);
	timer_set(timer_display, 1);
	for(;;)
	{
		count++;
		io_cli();
		if(0 == fifo_status(&fifo))
		{
			io_sti();
		}
		else
		{
			i = fifo_get(&fifo);
			io_sti();
			if(1 == i)
			{
				sprintf(strings, "%11d", count);
				displayStrings_atLayer(layer_bg, 0, 144, COL8_FFFFFF, COL8_008484, strings);
				timer_set(timer_display, 1);
			}
		}
	}
}
Esempio n. 15
0
File: timer.c Progetto: huu12/testOS
void timer_settime(struct TIMER *timer, unsigned int timeout)
{
	int e;
	struct TIMER *t, *s;
	timer->timeout = timeout + timerctl.count;
	timer->flags = TIMER_FLAGS_USING;
	e = io_load_eflags();
	io_cli();
	t = timerctl.t0;
	if (timer->timeout <= t->timeout) {
		/* 先頭に入れる場合 */
		timerctl.t0 = timer;
		timer->next = t; /* 次はt */
		timerctl.next = timer->timeout;
		io_store_eflags(e);
		return;
	}
	/* どこに入れればいいかを探す */
	for (;;) {
		s = t;
		t = t->next;
		if (timer->timeout <= t->timeout) {
			/* sとtの間に入れる場合 */
			s->next = timer; /* sの次はtimer */
			timer->next = t; /* timerの次はt */
			io_store_eflags(e);
			return;
		}
	}
}
Esempio n. 16
0
void timer_set(struct TIMER * timer,unsigned int timeout,struct FIFO *fifo,int data)
{
int e;
struct TIMER *s,*t;
timer->timeout = timerctl.count + timeout;  // compare with count
timer->flag = TIMER_FLAG_USING;
timer->fifo = fifo;
timer->data = data;
e = io_load_eflags();
io_cli();
t = timerctl.t0;
if(timeout <= t->timeout)
{
timerctl.t0 = timer;
timer->next = t;  
timerctl.next = timeout;
io_store_eflags(e);
return;
}

for(;;)
{
	s = t;  // s:p t:p+1
 	t = t->next;
	if(timeout <= t->timeout)
	{
	s->next = timer;
	timer->next = t;
	io_store_eflags(e);
	return;
	}
}

}
Esempio n. 17
0
void task_b_main(struct SHEET *sht_win_b)
{
	struct FIFO32 fifo;
	struct TIMER  *timer_1s;
	int i, fifobuf[128], count = 0, count0 = 0;
	char s[12];

	fifo32_init(&fifo, 128, fifobuf,0);
	timer_1s = timer_alloc();
	timer_init(timer_1s, &fifo, 100);
	timer_settime(timer_1s, 100);

	for (;;) {
		count++;
		io_cli();
		if (fifo32_status(&fifo) == 0) {
			io_sti();
		} else {
			i = fifo32_get(&fifo);
			io_sti();
			if (i == 100) {
				sprintf(s, "%11d", count - count0);
				putfonts8_asc_sht(sht_win_b, 24, 28, COL8_000000, COL8_C6C6C6, s, 11);
				count0 = count;
				timer_settime(timer_1s, 100);
			}
		}
	}
}
Esempio n. 18
0
void timer_settime(struct TIMER *timer, unsigned int timeout)
{
	int e;
	struct TIMER *t, *s;
	timer->timeout = timeout + timerctl.count;
	timer->flags = TIMER_FLAGS_USING;
	e = io_load_eflags();
	io_cli();
	t = timerctl.t0;
	if (timer->timeout <= t->timeout) {
	/* 插入最前面的情况 */
		timerctl.t0 = timer;
		timer->next = t; /* 下面是设定t */
		timerctl.next = timer->timeout;
		io_store_eflags(e);
		return;
	}
	for (;;) {
		s = t;
		t = t->next;
		if (timer->timeout <= t->timeout) {
		/* 插入s和t之间的情况 */
			s->next = timer; /* s下一个是timer */
			timer->next = t; /* timer的下一个是t */
			io_store_eflags(e);
			return;
		}
	}
}
Esempio n. 19
0
void inthandler20(int *esp)
{
	int flag_switch = 0;
	struct CLOCK *clock;
	io_cli();
	io_out8(PIC0_OCW2, 0x60);
	clock_ctl->count++;
	if (clock_ctl->next > clock_ctl->count) {
		return;
	}
	clock = clock_ctl->c0;
	
	for (;;) {
		if (clock->time_out > clock_ctl->count) {
			break;
		}
		if(clock != task_clock){
			fifo32_put(clock->fifo, clock->data);
		}else{
			flag_switch = 1;
		}
		clock->flag_usage = CLOCK_FLAGS_ALLOC;
		clock = clock->next;
	}
	clock_ctl->c0 = clock;
	clock_ctl->next = clock->time_out;
	io_sti();
	if(flag_switch == 1){
		task_switch();
	}
	return;
}
Esempio n. 20
0
void task_b_main(void)
{
	struct FIFO32 fifo;
	struct TIMER *timer_ts;
	int i, fifobuf[128];

	fifo32_init(&fifo, 128, fifobuf);
	timer_ts = timer_alloc();
	timer_init(timer_ts, &fifo, 1);
	timer_settime(timer_ts, 2);

	for (;;) {
		io_cli();
		if (fifo32_status(&fifo) == 0) {
			io_sti();
			io_hlt();
		} else {
			i = fifo32_get(&fifo);
			io_sti();
			if (i == 1) { /* タスクスイッチ */
				farjmp(0, 3 * 8);
				timer_settime(timer_ts, 2);
			}
		}
	}
}
Esempio n. 21
0
void timer_settime(struct TIMER *timer, unsigned int timeout)
{
	int e; 
	struct TIMER *t, *s;
	timer->timeout = timeout + timerctl.count;
	timer->flags = TIMER_FLAGS_USING;
	e = io_load_eflags();
	io_cli();
	/*t = timerctl.t0;
	if (1==timerctl.using){
		timerctl.t0 = timer;
		timer->next = 0;
		timerctl.next = timer->timeout;
		io_store_eflags(e);
		return;
	}*/
	t = timerctl.t0;
	if (timer->timeout<=t->timeout){
		timerctl.t0 = timer;
		timer->next = t;
		timerctl.next = timer->timeout;
		io_store_eflags(e);
		return;
	}
	for (;;){
		s = t;
		t = t->next;
		if (timer->timeout<=t->timeout){
			s->next = timer;
			timer->next = t;
			io_store_eflags(e);
			return;
		}
	}
}
Esempio n. 22
0
void timer_settime(timer_t* timer, unsigned int timeout)
{
    timer->timeout = timeout + timerctl.count;
    timer->flags = TIMER_FLAGS_USING;
    int e = io_load_eflags();
    io_cli();
    timer_t *t = timerctl.t0, *s;
    if (timer->timeout <= t->timeout) {
        /* 插入前面 */
        timerctl.t0 = timer;
        timer->next = t; /* 下个是t */
        timerctl.next = timer->timeout;
        io_store_eflags(e);
        return;
    }
    /* 寻找插入位置 */
    for (;;) {
        s = t;
        t = t->next;
        if (timer->timeout <= t->timeout) {
            /* 插入s和t之间 */
            s->next = timer; /* s下个是timer */
            timer->next = t; /* timer下个是t */
            io_store_eflags(e);
            return;
        }
    }
}
Esempio n. 23
0
void console_task(struct SHEET *sheet)
{
	struct TIMER *timer;
	struct TASK *task = task_now();
	int i, fifobuf[128], cursor_x = 16, cursor_c = COL8_000000;
	char s[2];

	fifo32_init(&task->fifo, 128, fifobuf, task);
	
	timer = timer_alloc();
	timer_init(timer, &task->fifo, 1);
	timer_settime(timer, 50);

	/* 显示提示符 */
	putfonts8_asc_sht(sheet, 8, 28, COL8_FFFFFF, COL8_000000, ">", 1);

	for (;;) {
		io_cli();
		if (fifo32_status(&task->fifo) == 0) {
			task_sleep(task);
			io_sti();
		} else {
			i = fifo32_get(&task->fifo);
			io_sti();
			if (i <= 1) {                                       /* 光标用定时器 */
				if (i != 0) {
					timer_init(timer, &task->fifo, 0);          /* 下次置0 */
					cursor_c = COL8_FFFFFF;
				} else {
					timer_init(timer, &task->fifo, 1);          /* 下次置1 */
					cursor_c = COL8_000000;
				}
				timer_settime(timer, 50);
			}
			if (256 <= i && i <= 511) {                         /* 键盘数据(通过任务A) */
				if (i == 8 + 256) {
					/* 退格键 */
					if (cursor_x > 16) {
						/* 用空白擦除光标后将光标前移一位 */
						putfonts8_asc_sht(sheet, cursor_x, 28, COL8_FFFFFF, COL8_000000, " ", 1);
						cursor_x -= 8;
					}
				} else {
					/* 一般字符 */
					if (cursor_x < 240) {
						/* 显示一个字符之后将光标后移一位 */
						s[0] = i - 256;
						s[1] = 0;
						putfonts8_asc_sht(sheet, cursor_x, 28, COL8_FFFFFF, COL8_000000, s, 1);
						cursor_x += 8;
					}
				}
			}
			/* 重新显示光标 */
			boxfill8(sheet->buf, sheet->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43);
			sheet_refresh(sheet, cursor_x, 28, cursor_x + 8, 44);
		}
	}
}
Esempio n. 24
0
void console_task(struct SHEET *sheet)
{
	struct TIMER *timer;
	struct TASK *task = task_now();
	int i, fifobuf[128], cursor_x = 16, cursor_c = COL8_000000;
	char s[2];

	fifo32_init(&task->fifo, 128, fifobuf, task);
	timer = timer_alloc();
	timer_init(timer, &task->fifo, 1);
	timer_settime(timer, 50);

	/* プロンプト表示 */
	putfonts8_asc_sht(sheet, 8, 28, COL8_FFFFFF, COL8_000000, ">", 1);

	for (;;) {
		io_cli();
		if (fifo32_status(&task->fifo) == 0) {
			task_sleep(task);
			io_sti();
		} else {
			i = fifo32_get(&task->fifo);
			io_sti();
			if (i <= 1) { /* カーソル用タイマ */
				if (i != 0) {
					timer_init(timer, &task->fifo, 0); /* 次は0を */
					cursor_c = COL8_FFFFFF;
				} else {
					timer_init(timer, &task->fifo, 1); /* 次は1を */
					cursor_c = COL8_000000;
				}
				timer_settime(timer, 50);
			}
			if (256 <= i && i <= 511) { /* キーボードデータ(タスクA経由) */
				if (i == 8 + 256) {
					/* バックスペース */
					if (cursor_x > 16) {
						/* カーソルをスペースで消してから、カーソルを1つ戻す */
						putfonts8_asc_sht(sheet, cursor_x, 28, COL8_FFFFFF, COL8_000000, " ", 1);
						cursor_x -= 8;
					}
				} else {
					/* 一般文字 */
					if (cursor_x < 240) {
						/* 一文字表示してから、カーソルを1つ進める */
						s[0] = i - 256;
						s[1] = 0;
						putfonts8_asc_sht(sheet, cursor_x, 28, COL8_FFFFFF, COL8_000000, s, 1);
						cursor_x += 8;
					}
				}
			}
			/* カーソル再表示 */
			boxfill8(sheet->buf, sheet->bxsize, cursor_c, cursor_x, 28, cursor_x + 7, 43);
			sheet_refresh(sheet, cursor_x, 28, cursor_x + 8, 44);
		}
	}
}
Esempio n. 25
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  char debug_info[64], mouse_cursor[256], keybuf[32];
  int mouse_x, mouse_y;

  init_gdt_idt();
  init_pic();
  io_sti();

  fifo_init(&g_keybuf, keybuf, 32);
  io_out8(PIC0_IMR, 0xf9);
  io_out8(PIC1_IMR, 0xef);

  init_keyboard();    /* initialize keyboard */

  init_palette();
  init_screen(binfo->vram, binfo->screen_x, binfo->screen_y);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  init_mouse_cursor8(mouse_cursor, COLOR8_848484);
  draw_block8_8(binfo->vram, binfo->screen_x, 16, 16, 
      mouse_x, mouse_y, mouse_cursor, 16);

  draw_font8_asc(binfo->vram, binfo->screen_x, 8, 8, 
      COLOR8_FFFFFF, "HELLO BOYS:");
  draw_font8_asc(binfo->vram, binfo->screen_x, 9, 9, 
      COLOR8_000000, "HELLO BOYS:");
  draw_font8_asc(binfo->vram, binfo->screen_x, 31, 31, 
      COLOR8_000000, "WELCOME TO THE LOVELY TOY-OS.");
  draw_font8_asc(binfo->vram, binfo->screen_x, 30, 30, 
      COLOR8_FFFFFF, "WELCOME TO THE LOVELY TOY-OS.");

  sprintf(debug_info, "screen=>{%d, %d}", binfo->screen_x, binfo->screen_y);
  draw_font8_asc(binfo->vram, binfo->screen_x, 16, 64, 
      COLOR8_FF0000, debug_info);

  enable_mouse();   /* enabled mouse */

  for ( ; ; ) {
    int data;

    io_cli();

    if (0 == fifo_size(&g_keybuf)) 
      io_stihlt();
    else {
      data = fifo_get(&g_keybuf);

      io_sti();
      sprintf(debug_info, "%02X", data);
      fill_box8(binfo->vram, binfo->screen_x, COLOR8_008484, 0, 16, 15, 31);
      draw_font8_asc(binfo->vram, binfo->screen_x, 
          0, 16, COLOR8_FFFFFF, debug_info);
    }
  }
}
Esempio n. 26
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  char debug_info[64], mouse_cursor[256];
  int mouse_x, mouse_y;

  init_gdt_idt();
  init_pic();
  io_sti();

  io_out8(PIC0_IMR, 0xf9);
  io_out8(PIC1_IMR, 0xef);

  init_palette();
  init_screen(binfo->vram, binfo->screen_x, binfo->screen_y);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  init_mouse_cursor8(mouse_cursor, COLOR8_848484);
  draw_block8_8(binfo->vram, binfo->screen_x, 16, 16, 
      mouse_x, mouse_y, mouse_cursor, 16);

  draw_font8_asc(binfo->vram, binfo->screen_x, 8, 8, 
      COLOR8_FFFFFF, "HELLO BOYS:");
  draw_font8_asc(binfo->vram, binfo->screen_x, 9, 9, 
      COLOR8_000000, "HELLO BOYS:");
  draw_font8_asc(binfo->vram, binfo->screen_x, 31, 31, 
      COLOR8_000000, "WELCOME TO THE LOVELY TOY-OS.");
  draw_font8_asc(binfo->vram, binfo->screen_x, 30, 30, 
      COLOR8_FFFFFF, "WELCOME TO THE LOVELY TOY-OS.");

  sprintf(debug_info, "screen=>{%d, %d}", binfo->screen_x, binfo->screen_y);
  draw_font8_asc(binfo->vram, binfo->screen_x, 16, 64, 
      COLOR8_FF0000, debug_info);


  for ( ; ; ) {
    int data, i;

    io_cli();

    if (0 == g_keybuf.next) 
      io_stihlt();
    else {
      data = g_keybuf.data[0];
      --g_keybuf.next;
      for (i = 0; i < g_keybuf.next; ++i) 
        g_keybuf.data[i] = g_keybuf.data[i + 1];

      io_sti();
      sprintf(debug_info, "%02X", data);
      fill_box8(binfo->vram, binfo->screen_x, COLOR8_008484, 0, 16, 15, 31);
      draw_font8_asc(binfo->vram, binfo->screen_x, 
          0, 16, COLOR8_FFFFFF, debug_info);
    }
  }
}
Esempio n. 27
0
void settimer(unsigned int timeout, struct FIFO8 *fifo, unsigned char data)
{
	int eflags;
	eflags = io_load_eflags();
	io_cli();
	timerctl.timeout = timeout;
	timerctl.fifo = fifo;
	timerctl.data = data;
	io_store_eflags(eflags);
	return;
}
Esempio n. 28
0
void timer_cancelall(FIFO* fifo) {
  int e = io_load_eflags();
  io_cli();
  for (int i = 0; i < MAX_TIMER; ++i) {
    TIMER* t = &timerctl.timers0[i];
    if (t->flags != 0 && t->flags2 != 0 && t->fifo == fifo) {
      timer_cancel(t);
      timer_free(t);
    }
  }
  io_store_eflags(e);
}
Esempio n. 29
0
int put_fifo32(Fifo32* fi,i32 dat)
{
    if((fi->rpos-fi->wpos+fi->len)%fi->len==1)
        return -1;
    io_cli();
    fi->buf[fi->wpos]=dat;
    ++(fi->wpos);
    if(fi->wpos>=fi->len)
        fi->wpos=0;
    io_sti();
    return 0;
}
Esempio n. 30
0
void HariMain(void)
{
	struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
	char s[40], mcursor[256], keybuf[32], mousebuf[128];
	int mx, my, i;

	init_gdtidt();
	init_pic();
	io_sti(); /* IDT/PIC的初始化结束,开启CPU中断 */

	fifo8_init(&keyfifo, 32, keybuf);
	fifo8_init(&mousefifo, 128, mousebuf);
	io_out8(PIC0_IMR, 0xf9); /* 许可PIC1和键盘(11111001) */
	io_out8(PIC1_IMR, 0xef); /* 许可鼠标(11101111) */

	init_keyboard();

	init_palette();
	init_screen8(binfo->vram, binfo->scrnx, binfo->scrny);
	mx = (binfo->scrnx - 16) / 2;
	my = (binfo->scrny - 28 - 16) / 2;
	init_mouse_cursor8(mcursor, COL8_008484);
	putblock8_8(binfo->vram, binfo->scrnx, 16, 16, mx, my, mcursor, 16);
	sprintf(s, "(%d, %d)", mx, my);
	putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FFFFFF, s);

	enable_mouse();

	for (;;) {
		io_cli();
		if (fifo8_status(&keyfifo) + fifo8_status(&mousefifo) == 0) {
			/* J
			char ss[10];
			sprintf(ss, "%c", "J");
			putfonts8_asc(binfo->vram, binfo->scrnx, 100, 100, COL8_FFFFFF, ss);
			*/
			io_stihlt();
		} else if (fifo8_status(&keyfifo) != 0) {
			i = fifo8_get(&keyfifo);
			io_sti();
			sprintf(s, "%02X", i);
			boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
			putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
		} else if (fifo8_status(&mousefifo) != 0) {
			i = fifo8_get(&mousefifo);
			io_sti();
			sprintf(s, "%02X", i);
			boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 32, 16, 47, 31);
			putfonts8_asc(binfo->vram, binfo->scrnx, 32, 16, COL8_FFFFFF, s);
		}
	}
}