Exemple #1
0
int
ts_main(int argc, char *argv[])
{
	unsigned i, ntasks, n, skip;
	TaskInfo_t *ti, *info;
	bool enabled[NVCONS];
	bool check_cons = false;				// por defecto habilitar todas las consolas
	bool cursor = mt_cons_cursor(false);

	memset(enabled, 0, sizeof enabled);
	for ( i = 1 ; i < argc ; i++ )			// habilitar las consolas especificadas
	{
		unsigned cons = atoi(argv[i]);
		if ( cons < NVCONS )
			enabled[cons] = check_cons = true;
	}

	mt_cons_clear();
	cprintk(WHITE, BLUE, "%s", title);
	mt_cons_gotoxy(0, 24);
	cprintk(WHITE, BLUE, "%s", foot);
	skip = 0;
	do
	{
		info = GetTasks(&ntasks);
		for ( n = 0, i = 1, ti = info ; i < 24 && ntasks-- ; ti++ )
		{
			if ( (check_cons && !enabled[ti->consnum]) || n++ < skip )
				continue;
			mt_cons_gotoxy(0, i++);
			char namebuf[20];
			sprintf(namebuf, ti->protected ? "[%.16s]" : "%.18s", name(ti->task));
			cprintk(WHITE, BLACK, "%8x %-18s %u %10u %-9s %-18.18s", ti->task, namebuf, 
				ti->consnum, ti->priority, statename(ti->state), name(ti->waiting));
			if ( ti->is_timeout )
				cprintk(WHITE, BLACK, " %10u", ti->timeout);
			else
				mt_cons_clreol();
		}
		while ( i < 24 )
		{
			mt_cons_gotoxy(0, i++);
			mt_cons_clreol();
		}
		Free(info);
	}
	while ( getuser(&skip) );
	mt_cons_clear();
	mt_cons_cursor(cursor);	
	return 0;
}
Exemple #2
0
static void 
mputch(int x, int y, int c, unsigned fg, unsigned bg)
{
	Atomic();
	mt_cons_gotoxy(x, y);
	cprintk(fg, bg, "%c", c);
	Unatomic();
}
Exemple #3
0
void
mt_cons_clear(void)
{
	unsigned short *p1 = &vidmem[0][0];
	unsigned short *p2 = &vidmem[NUMROWS][0];

	while (p1 < p2)
		*p1++ = DEFATTR;
	mt_cons_gotoxy(0, 0);
}
Exemple #4
0
static int 
mprint(int x, int y, char *format, ...)
{
	int n;
	va_list args;

	Atomic();
	mt_cons_gotoxy(x, y);
	mt_cons_setattr(LIGHTCYAN, BLACK);
	va_start(args, format);
	n = vprintk(format, args);
	va_end(args);
	mt_cons_clreol();
	Unatomic();
	return n;
}
Exemple #5
0
unsigned
mt_getline(char *buf, unsigned size)
{
	char *p = buf, *end = buf + size - 1;
	unsigned c;
	unsigned xi, yi, si;
	
	mt_cons_getxy(&xi, &yi);
	si = mt_cons_nscrolls();

	while (p < end)
		if (mt_kbd_getch(&c))
			switch (c)
			{
				case BS:
					if (p == buf)
						break;
					if (*--p == '\t')
					{
						mt_cons_gotoxy(xi, yi - (mt_cons_nscrolls() - si));
						mt_cons_clreom();
						*p = 0;
						mt_cons_puts(buf);
					}
					else
						mt_cons_puts(ERASEBACK);
					break;

				case '\r':
				case '\n':
					mt_cons_puts("\r\n");
					*p++ = '\n';
					*p = 0;
					return p - buf;

				default:
					*p++ = c;
					mt_cons_putc(c);
					break;
			}

	mt_cons_puts("<EOB>\r\n");
	*p = 0;
	return p - buf;
}