Пример #1
0
static void real_start(void *param) {
	dbgio_printk_func old;
	
	/* Set debug output to the serial console again */
	old = dbgio_set_printk(dbgio_write_str);

	/* Make a semaphore */
	/* chr_ready = sem_create(0); */

	/* Hook the serial IRQ */
	/* irq_set_handler(EXC_SCIF_RXI, ser_irq);
	*SCSCR2 |= 1 << 6;
	*iprc |= 0x000e << 4; */

	/* Do the shell */
	interact();
	dbgio_write_str("shell exiting\n");

	/* Unhook serial IRQ */
	/* *iprc &= ~(0x000e << 4);
	*SCSCR2 &= ~(1 << 6);
	irq_set_handler(EXC_SCIF_RXI, NULL); */

	/* Destroy the semaphore */
	/* sem_destroy(chr_ready); */

	dbgio_set_printk(old);
}
Пример #2
0
static char *read_line() {
	int q = 0, ch;
	
	while(1) {
		while ( (ch = dbgio_read()) == -1)
			/* sem_wait(chr_ready); */
			thd_pass();
		if (ch == '\r') {
			buffer[q] = 0;
			dbgio_write_str("\n");
			return buffer;
		}
		
		if (ch == '\x08') {
			q--;
			dbgio_write_str("\x08 \x08");
			continue;
		}
		
		buffer[q++] = ch;
		dbgio_write(ch);
	}
}
Пример #3
0
static void interact() {
	char tmp[16];
	char *buf;
	int cnt=0;

	curdir[0] = '/'; curdir[1] = 0;

	while(1) {
		sprintf(tmp, "%d", cnt); dbgio_write_str(tmp);
		dbgio_write(' ');
		dbgio_write_str(curdir);
		dbgio_write('>');
		/*write_str("%d %s> ", cnt, curdir); */
		buf = read_line();

		if (buf[0] == 0) {
			cnt++;
			continue;
		}
					
		if (!strcmp(buf, "quit") || !strcmp(buf, "exit")) {
			break;
		} else if (!strcmp(buf, "die")) {
			arch_exit();
		} else if (!strcmp(buf, "ps")) {
			thd_pslist();
		} else if (!strcmp(buf, "reboot")) {
			arch_reboot();
		} else if (!strcmp(buf, "menu")) {
		        (*(void(**)())0x8c0000e0)(1);
		} else {
			dbgio_write_str("commands: die quit/exit reboot menu ps\n");
		}
		
		cnt++;
	}
}
Пример #4
0
/* VP : added this */
int dbgio_vprintf(const char *fmt, va_list args) {
	int i;

	/* XXX This isn't correct. We could be inside an int with IRQs
	  enabled, and we could be outside an int with IRQs disabled, which
	  would cause a deadlock here. We need an irq_is_enabled()! */
	if (!irq_inside_int())
		spinlock_lock(&lock);

	i = vsprintf(printf_buf, fmt, args);

	dbgio_write_str(printf_buf);

	if (!irq_inside_int())
		spinlock_unlock(&lock);

	return i;
}
Пример #5
0
/* Kernel debug logging facility */
void dbglog(int level, const char *fmt, ...) {
    va_list args;

    /* If this log level is blocked out, don't even bother */
    if(level > dbglog_level)
        return;

    /* We only try to lock if the message isn't urgent */
    if(level >= DBG_ERROR && !irq_inside_int())
        spinlock_lock(&mutex);

    va_start(args, fmt);
    (void)vsprintf(printf_buf, fmt, args);
    va_end(args);

    if(irq_inside_int())
        dbgio_write_str(printf_buf);
    else
        fs_write(1, printf_buf, strlen(printf_buf));

    if(level >= DBG_ERROR && !irq_inside_int())
        spinlock_unlock(&mutex);
}
Пример #6
0
static void fputs(const char * str, FILE * f)
{
  if (str && *str)
    dbgio_write_str(str);
}