Example #1
0
int  sdTerminalIn( void )
{
	int c;
//	return getchar();
	while(1) {
		c = user_getc();
		if(c!=(-1)) {
			user_putc(c);
			if(c==0x0d) 
				user_putc(0x0a);
			return c;
		}
	}
}
Example #2
0
int stdin_getc()
{
	int c;
	if( _stdin_ungetch ) {
		c = _stdin_ungetch;
		_stdin_ungetch = 0;
		return c;
	}
	while(1) {
		c = user_getc();
		if(c!=(-1)) {
			user_putc(c);
			if(c==0x0d) 
				user_putc(0x0a);
			return c;
		}
	}
}
Example #3
0
/**
 * @ingroup shell
 *
 * Take a system call number and run that system call.  This is only for
 * demonstration.
 * @param nargs number of arguments
 * @param args  array of arguments
 * @return non-zero value on error
 */
shellcmd xsh_user(int nargs, char **args)
{
    static mailbox mybox;
    int call_num;
    char buffer[BUF_LENGTH];

    if (nargs != 2)
    {
        printf("Insufficient arguments.\n");
        printf("Try again later.\n");
        return 1;
    }

    call_num = atoi(args[1]);

    switch (call_num)
    {
    case 0:
        user_none();
        break;
    case 1:
        user_yield();
        break;
    case 2:
        user_sleep(4000);
        break;
    case 3:
        user_kill(5);           // pick a better number
        break;
    case 4:
        user_open(LOOP, 0);
        break;
    case 5:
        user_control(LOOP, 0, 1, 2);
        break;
    case 6:
        sprintf(buffer, "Process %d\n", gettid());
        user_write(LOOP, buffer, BUF_LENGTH);
        break;
    case 7:
        user_read(LOOP, buffer, BUF_LENGTH);
        printf("%s\n", buffer);
        break;
    case 8:
        user_putc(LOOP, 'm');
        break;
    case 9:
        printf("%c\n", user_getc(LOOP));
        break;
    case 10:
        user_seek(LOOP, 5);
        break;
    case 11:
        user_close(LOOP);
        break;
    case 12:
        printf("%d\n", user_getdev("LOOP"));
        break;
    case 13:
        mybox = user_mboxalloc(50);
        printf("Mailbox %d assigned.\n", mybox);
        break;
    case 14:
        user_mboxfree(mybox);
        break;
    case 15:
        user_mboxsend(mybox, 0xa5a5a5a5);
        break;
    case 16:
        printf("0x%08x\n", user_mboxrecv(mybox));
        break;
    default:
        printf("No corresponding call.\n");
    }

    return 0;
}