Index: EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c
===================================================================
--- EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c	(revision 435)
+++ EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c	(revision 441)
@@ -33,12 +33,11 @@
 #include "shellif.h"
 #include <kernel.h>
-//#include <string.h>
 #include <t_syslog.h>
 #include <t_stdlib.h>
 #include <sil.h>
 #include "syssvc/syslog.h"
+#include "target_syssvc.h"
 #include "kernel_cfg.h"
 #include "main.h"
-#include "rza1.h"
 #include "ffarch.h"
 #include "ff.h"
@@ -48,5 +47,5 @@
 #include "util/ntstdio.h"
 
-extern ntstdio_t ntstdio;
+extern ntstdio_t *ntstdio;
 extern int ntshell_exit;
 
@@ -147,20 +146,4 @@
 }
 
-int shell_kill(int pid, int sig)
-{
-	asm("bkpt #0");
-	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;
-}
-
 void put_rc(const char *func, FRESULT rc)
 {
@@ -175,5 +158,5 @@
 		while (*p++);
 	}
-	ntstdio_printf(&ntstdio, "%s() =>%u FR_%s\n", func, (UINT)rc, p);
+	ntstdio_printf(ntstdio, "%s() =>%u FR_%s\n", func, (UINT)rc, p);
 }
 
@@ -187,5 +170,5 @@
 		while (*p++);
 	}
-	ntstdio_printf(&ntstdio, "%s() =>%u %s\n", func, (UINT)rc, p);
+	ntstdio_printf(ntstdio, "%s() =>%u %s\n", func, (UINT)rc, p);
 }
 
@@ -210,5 +193,5 @@
 	for (; s[i] == '/'; i--) if (!i) return (s == _s) ? "/" : _s;
 	for (; s[i] != '/'; i--) if (!i) return (s == _s) ? "." : _s;
-	for (; s[i] == '/'; i--) if (!i) if (s == _s) return "/"; else break;
+	for (; s[i] == '/'; i--) if (!i) { if (s == _s) return "/"; else break; }
 	s[i + 1] = 0;
 	return _s;
@@ -237,5 +220,5 @@
 
 	ntlibc_strlcat(path, "\n", sizeof(path));
-	ntstdio_printf(&ntstdio, path);
+	ntstdio_printf(ntstdio, path);
 
 	return 0;
@@ -260,5 +243,5 @@
 
 	if (list_option & LS_LONG) {
-		ntstdio_printf(&ntstdio, "%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
+		ntstdio_printf(ntstdio, "%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
 			(fno->fattrib & AM_DIR) ? 'd' : '-',
 			(fno->fattrib & AM_RDO) ? 'r' : '-',
@@ -274,16 +257,16 @@
 
 		if (fno->fattrib & AM_DIR) {                    /* It is a directory */
-			ntstdio_printf(&ntstdio, "%10S ", " ");
+			ntstdio_printf(ntstdio, "%10s ", " ");
 		}
 		else {
-			ntstdio_printf(&ntstdio, "%10d ", fno->fsize);
+			ntstdio_printf(ntstdio, "%10lu ", fno->fsize);
 		}
 	}
 
 	if (fno->fattrib & AM_DIR) {                    /* It is a directory */
-		ntstdio_printf(&ntstdio, "\x1B[32m%s\x1B[0m\n", fn);
+		ntstdio_printf(ntstdio, "\x1B[32m%s\x1B[0m\n", fn);
 	}
 	else {
-		ntstdio_printf(&ntstdio, "%s\n", fn);
+		ntstdio_printf(ntstdio, "%s\n", fn);
 	}
 }
@@ -304,5 +287,5 @@
 	path_backup = ff_memalloc(LFN_BUF_SIZE);
 	if (path_backup == NULL) {
-		ntstdio_printf(&ntstdio, "ff_memalloc err.\n");
+		ntstdio_printf(ntstdio, "ff_memalloc err.\n");
 		return;
 	}
@@ -312,5 +295,5 @@
 	lfn = ff_memalloc(LFN_BUF_SIZE);
 	if (lfn == NULL) {
-		ntstdio_printf(&ntstdio, "ff_memalloc err.\n");
+		ntstdio_printf(ntstdio, "ff_memalloc err.\n");
 		ff_memfree(path_backup);
 		return;
@@ -340,23 +323,23 @@
 			}
 
-			if ((res = f_chdrive(path_p)) != RES_OK) {
+			if ((res = f_chdrive(path_p)) != FR_OK) {
 				put_rc("f_chdrive", res);
 			}
 
-			if ((res = f_chdir(path_p)) != RES_OK) {
+			if ((res = f_chdir(path_p)) != FR_OK) {
 				put_rc("f_chdir", res);
 			}
 
-			ntstdio_printf(&ntstdio, "\n%s/%s:\n", path_p, fn);
+			ntstdio_printf(ntstdio, "\n%s/%s:\n", path_p, fn);
 
 			print_ls(fn, NULL, list_option);
 
-			ntstdio_printf(&ntstdio, "\n");
-
-			if ((res = f_chdrive(path_backup)) != RES_OK) {
+			ntstdio_printf(ntstdio, "\n");
+
+			if ((res = f_chdrive(path_backup)) != FR_OK) {
 				put_rc("f_chdrive", res);
 			}
 
-			if ((res = f_chdir(path_backup)) != RES_OK) {
+			if ((res = f_chdir(path_backup)) != FR_OK) {
 				put_rc("f_chdir", res);
 			}
@@ -449,5 +432,5 @@
 	lfn = ff_memalloc(LFN_BUF_SIZE);
 	if (lfn == NULL) {
-		ntstdio_printf(&ntstdio, "alloc err.\n");
+		ntstdio_printf(ntstdio, "alloc err.\n");
 		goto cp_end;
 	}
@@ -459,5 +442,5 @@
 	local_buff = ff_memalloc(64);
 	if (local_buff == NULL) {
-		ntstdio_printf(&ntstdio, "alloc err.\n");
+		ntstdio_printf(ntstdio, "alloc err.\n");
 		goto cp_end;
 	}
@@ -469,7 +452,7 @@
 	if (res != FR_OK) {
 		if (res == FR_NO_FILE)
-			ntstdio_printf(&ntstdio, "src no file.\n", res);
+			ntstdio_printf(ntstdio, "src no file.\n");
 		else
-			ntstdio_printf(&ntstdio, "src stat err(%d).\n", res);
+			ntstdio_printf(ntstdio, "src stat err(%d).\n", res);
 		goto cp_end;
 	}
@@ -480,5 +463,5 @@
 		res = f_open(&src_fp, src_str_p, (FA_OPEN_EXISTING | FA_READ));
 		if (res != FR_OK) {
-			ntstdio_printf(&ntstdio, "src open err(%d).\n", res);
+			ntstdio_printf(ntstdio, "src open err(%d).\n", res);
 			goto cp_end;
 		}
@@ -495,5 +478,5 @@
 				dst_mod_str_p = ff_memalloc(LFN_BUF_SIZE);
 				if (dst_mod_str_p == NULL) {
-					ntstdio_printf(&ntstdio, "alloc err.\n");
+					ntstdio_printf(ntstdio, "alloc err.\n");
 					goto cp_end;
 				}
@@ -502,10 +485,10 @@
 			}
 			else {
-				ntstdio_printf(&ntstdio, "dst file exists.\n");
+				ntstdio_printf(ntstdio, "dst file exists.\n");
 				goto cp_end_1;
 			}
 		}
 		else {
-			ntstdio_printf(&ntstdio, "src stat err(%d).\n", res);
+			ntstdio_printf(ntstdio, "src stat err(%d).\n", res);
 			goto cp_end_1;
 		}
@@ -513,5 +496,5 @@
 	res = f_open(&dst_fp, dst_str_p, (FA_CREATE_NEW | FA_WRITE));
 	if (res != FR_OK) {
-		ntstdio_printf(&ntstdio, "dst open err(%d).\n", res);
+		ntstdio_printf(ntstdio, "dst open err(%d).\n", res);
 		goto cp_end_1;
 	}
@@ -524,5 +507,5 @@
 		res = f_read(&src_fp, local_buff, sizeof(local_buff), &read_size);
 		if (res != FR_OK) {
-			ntstdio_printf(&ntstdio, "src read err(%d).\n", res);
+			ntstdio_printf(ntstdio, "src read err(%d).\n", res);
 			goto cp_end_2;
 		}
@@ -531,9 +514,9 @@
 		res = f_write(&dst_fp, local_buff, read_size, &write_size);
 		if (res != FR_OK) {
-			ntstdio_printf(&ntstdio, "dst write err(%d).\n", res);
+			ntstdio_printf(ntstdio, "dst write err(%d).\n", res);
 			goto cp_end_2;
 		}
 		if (read_size != write_size) {
-			ntstdio_printf(&ntstdio, "dst write err(disk full).\n", res);
+			ntstdio_printf(ntstdio, "dst write err(disk full).\n");
 			goto cp_end_2;
 		}
@@ -594,6 +577,4 @@
 }
 
-extern WCHAR Utf8_to_Utf16(const char *, int *); /* in ff.c */
-extern void Utf16_to_Utf8(unsigned char *, int *, UINT); /* in ff.c */
 #define HEXDUMP_EXTRA_FOR_UTF8 3 /* need extra buffer size */
 #define CCOLOR_RESET	0
@@ -626,10 +607,10 @@
 		switch (op) {
 		case 'h': /* help */
-			ntstdio_printf(&ntstdio, " hexdump [OPTION] file\n");
-			ntstdio_printf(&ntstdio, "  -h : help\n");
-			ntstdio_printf(&ntstdio, "  -d : print all byte with convert and color [in character area] (default)\n");
-			ntstdio_printf(&ntstdio, "  -u : try print UTF-8 code [in character area]\n");
-			ntstdio_printf(&ntstdio, "  -oOFFSET : print start offset address from top\n");
-			ntstdio_printf(&ntstdio, "  -sSIZE   : print size\n");
+			ntstdio_printf(ntstdio, " hexdump [OPTION] file\n");
+			ntstdio_printf(ntstdio, "  -h : help\n");
+			ntstdio_printf(ntstdio, "  -d : print all byte with convert and color [in character area] (default)\n");
+			ntstdio_printf(ntstdio, "  -u : try print UTF-8 code [in character area]\n");
+			ntstdio_printf(ntstdio, "  -oOFFSET : print start offset address from top\n");
+			ntstdio_printf(ntstdio, "  -sSIZE   : print size\n");
 			break;
 		case 'd': /* print one byte character [in character area] (default) */
@@ -662,5 +643,5 @@
 	/* position adjusting */
 	if (op_offset >= fsrc.fsize) {
-		ntstdio_printf(&ntstdio, "error : input offset is bigger than file size(0x%X).\n", fsrc.fsize);
+		ntstdio_printf(ntstdio, "error : input offset is bigger than file size(0x%lX).\n", fsrc.fsize);
 		return 0;
 	}
@@ -689,5 +670,5 @@
 		if (br > 16) br = 16;
 
-		char *apos = ascii;
+		unsigned char *apos = ascii;
 		int arst = sizeof(ascii);
 		for (int j = 0; j < br; j++) {
@@ -784,5 +765,5 @@
 		rst -= len;
 
-		ntstdio_puts(&ntstdio, line);
+		ntstdio_puts(ntstdio, line);
 	}
 
@@ -799,5 +780,5 @@
 	ret = shell_clock_gettime(CLOCK_REALTIME, &tp);
 	if (ret != 0) {
-		ntstdio_printf(&ntstdio, "clock_gettime error %d", ret);
+		ntstdio_printf(ntstdio, "clock_gettime error %d", ret);
 		return 0;
 	}
@@ -805,5 +786,5 @@
 	memset(buf, 0, sizeof(buf));
 	if (ctime_r(&tp.tv_sec, buf) == NULL) {
-		ntstdio_printf(&ntstdio, "ctime_r error");
+		ntstdio_printf(ntstdio, "ctime_r error");
 		return 0;
 	}
@@ -813,5 +794,5 @@
 	buf[ret - 1] = '\0';
 
-	ntstdio_printf(&ntstdio, "%s .%09ld\n", buf, tp.tv_nsec);
+	ntstdio_printf(ntstdio, "%s .%09ld\n", buf, tp.tv_nsec);
 	return 0;
 }
@@ -820,10 +801,10 @@
 {
 	if (argc != 2) {
-		ntstdio_printf(&ntstdio, "info sys\n");
-		ntstdio_printf(&ntstdio, "info ver\n");
+		ntstdio_printf(ntstdio, "info sys\n");
+		ntstdio_printf(ntstdio, "info ver\n");
 		return 0;
 	}
 	if (ntlibc_strcmp(argv[1], "sys") == 0) {
-		ntstdio_printf(&ntstdio, "GR-PEACH Monitor\n");
+		ntstdio_printf(ntstdio, TARGET_NAME" Monitor\n");
 		return 0;
 	}
@@ -831,8 +812,8 @@
 		int mj, mn, bd;
 		ntshell_version(&mj, &mn, &bd);
-		ntstdio_printf(&ntstdio, "Version %d.%d.%d\n", mj, mn, bd);
-		return 0;
-	}
-	ntstdio_printf(&ntstdio, "Unknown sub command found\n");
+		ntstdio_printf(ntstdio, "Version %d.%d.%d\n", mj, mn, bd);
+		return 0;
+	}
+	ntstdio_printf(ntstdio, "Unknown sub command found\n");
 	return -1;
 }
