Index: asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c
===================================================================
--- asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c	(revision 364)
+++ asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c	(revision 374)
@@ -59,10 +59,6 @@
 #include "ntshell_main.h"
 #include "socket_stub.h"
-#include "usb_hbth.h"
-
-extern int bt_bnep_mode;
 
 char command[NTOPT_TEXT_MAXLEN];
-ntstdio_t ntstdio;
 
 extern uint8_t mac_addr[6];
@@ -87,33 +83,8 @@
 volatile int ntshell_state;
 jmp_buf process_exit;
-void sys_init(void);
-NTSHELL_SERIAL_READ ntshell_serial_read = 0;
-NTSHELL_SERIAL_WRITE ntshell_serial_write = 0;
-void *ntshell_serial_extobj;
-
-unsigned char ntstdio_xi(struct ntstdio_t *handle)
-{
-	unsigned char buf[1];
-	ntshell_serial_read((char *)buf, 1, ntshell_serial_extobj);
-	return buf[0];
-}
-
-void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
-{
-	char buf[1];
-	buf[0] = c;
-	ntshell_serial_write(buf, 1, ntshell_serial_extobj);
-}
-
-void ntshell_task_init(NTSHELL_SERIAL_READ func_read,
-	NTSHELL_SERIAL_WRITE func_write, void *extobj)
-{
-	ntshell_serial_read = func_read;
-	ntshell_serial_write = func_write;
-	ntshell_serial_extobj = extobj;
-
-	sys_init();
-
-	ntstdio_init(&ntstdio, NTSTDIO_OPTION_LINE_ECHO | NTSTDIO_OPTION_CANON | NTSTDIO_OPTION_LF_CRLF | NTSTDIO_OPTION_LF_CR, ntstdio_xi, ntstdio_xo);
+
+void ntshell_task_init(ID portid)
+{
+	serial_ctl_por(portid, IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV);
 }
 
@@ -177,8 +148,7 @@
 	const cmd_table_t *p = cmd_table_info.table;
 	for (int i = 0; i < cmd_table_info.count; i++) {
-		ntstdio_puts(&ntstdio, p->cmd);
-		ntstdio_puts(&ntstdio, "\t:");
-		ntstdio_puts(&ntstdio, p->desc);
-		ntstdio_puts(&ntstdio, "\n");
+		fwrite(p->cmd, strlen(p->cmd), 1, stdout);
+		fwrite("\t:", strlen("\t:"), 1, stdout);
+		puts(p->desc);
 		p++;
 	}
@@ -206,4 +176,5 @@
 int execute_command(int wait)
 {
+	T_RTSK rtsk;
 	ER ret;
 
@@ -228,4 +199,8 @@
 	do {
 		tslp_tsk(100000);
+
+		ret = ref_tsk(NTSHELL_TASK, &rtsk);
+		if ((ret != E_OK) || (rtsk.tskstat == TTS_DMT))
+			ntshell_state = 3;
 	} while(ntshell_state == 1);
 
@@ -237,83 +212,4 @@
 	ntlibc_strlcpy(command, text, sizeof(command));
 	return execute_command(1);
-}
-
-int stdio_close(struct _IO_FILE *fp)
-{
-	return -EPERM;
-}
-
-size_t stdio_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
-{
-	return -EPERM;
-}
-
-size_t stdio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
-{
-	return -EPERM;
-}
-
-size_t stdin_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
-{
-	int i = 0;
-	while (i < len) {
-		int c = ntstdio_getc(&ntstdio);
-		data[i++] = c;
-		if ((c == EOF) || (c == '\n'))
-			break;
-	}
-	return i;
-}
-
-size_t stdout_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
-{
-	for (int i = 0; i < len; i++) {
-		ntstdio_putc(&ntstdio, data[i]);
-	}
-	return len;
-}
-
-size_t stderr_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
-{
-	for (int i = 0; i < len; i++) {
-		ntstdio_putc(&ntstdio, data[i]);
-	}
-	return len;
-}
-
-int sio_close(struct _IO_FILE *fp)
-{
-	return -EPERM;
-}
-
-size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
-{
-	return -EPERM;
-}
-
-size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
-{
-	return -EPERM;
-}
-
-off_t sio_seek(struct _IO_FILE *fp, off_t ofs, int org)
-{
-	return -EPERM;
-}
-
-int sio_ioctl(struct _IO_FILE *fp, int request, void *arg)
-{
-	switch (request) {
-	case TIOCGWINSZ:
-		return 0;
-	case TCGETS:
-		return sio_tcgetattr(fp->fd, (struct termios *)arg);
-	case TCSETS + TCSANOW:
-	case TCSETS + TCSADRAIN:
-	case TCSETS + TCSAFLUSH:
-		return sio_tcsetattr(fp->fd, request - TCSETS, (const struct termios *)arg);
-	}
-
-	return -EINVAL;
 }
 
@@ -456,2 +352,18 @@
 }
 
+int shell_kill(int pid, int sig)
+{
+	DebugBreak();
+	return -1;
+}
+
+int shell_gettimeofday(struct timeval *tv, void *tzvp)
+{
+	SYSTIM time;
+	if (!tv) return 0;
+	get_tim(&time);
+	tv->tv_sec = time / 1000000;
+	tv->tv_usec = time - (tv->tv_sec * 1000000);
+	return 0;
+}
+
