summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2015-09-30 16:26:40 +0800
committerBernard Xiong <[email protected]>2015-09-30 16:26:40 +0800
commit7e45f059dce0a7751beef09e5ac122a83d731c5b (patch)
treef12f0189df20a8541c175b144400e795483413b6 /bsp
parent4ab8ea53c220f64263207ef40ff33cb5e52bceb3 (diff)
[BSP] Update simualtor bsp for Win32/MSVC
Diffstat (limited to 'bsp')
-rw-r--r--bsp/simulator/.gitignore47
-rwxr-xr-xbsp/simulator/SConstruct4
-rwxr-xr-xbsp/simulator/applications/application.c163
-rw-r--r--bsp/simulator/applications/init.c170
-rw-r--r--bsp/simulator/applications/init.h31
-rw-r--r--bsp/simulator/applications/platform.c14
-rwxr-xr-xbsp/simulator/drivers/board.c13
-rw-r--r--bsp/simulator/drivers/module_win32.c184
-rwxr-xr-xbsp/simulator/drivers/serial.c218
-rw-r--r--bsp/simulator/drivers/serial.h32
-rw-r--r--[-rwxr-xr-x]bsp/simulator/drivers/uart_console.c (renamed from bsp/simulator/drivers/usart_sim.c)179
-rw-r--r--bsp/simulator/drivers/uart_console.h6
-rwxr-xr-xbsp/simulator/rtconfig.h378
-rwxr-xr-xbsp/simulator/rtconfig.py4
14 files changed, 780 insertions, 663 deletions
diff --git a/bsp/simulator/.gitignore b/bsp/simulator/.gitignore
new file mode 100644
index 0000000000..fef6f4cbc8
--- /dev/null
+++ b/bsp/simulator/.gitignore
@@ -0,0 +1,47 @@
+# Object files
+*.o
+*.ko
+*.mo
+*.d
+*.crf
+*.lst
+
+# Libraries
+*.lib
+*.a
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+*.pyc
+
+# Executables
+*.exe
+*.out
+*.app
+*.elf
+*.axf
+*.bin
+*.hex
+
+# Intermediate file
+*.bak
+*.swp
+*.map
+*.dblite
+*.dep
+*.lnp
+*.uvgui.*
+*.build_log.*
+build
+
+Debug
+_UpgradeReport_Files
+*.ncb
+*.suo
+*.exp
+*.XML
+*.user
+*.def
diff --git a/bsp/simulator/SConstruct b/bsp/simulator/SConstruct
index 760002d80d..4283082d04 100755
--- a/bsp/simulator/SConstruct
+++ b/bsp/simulator/SConstruct
@@ -88,7 +88,7 @@ def ObjRemove(objs, remove):
# build program -shared
if GetDepend('RT_USING_MODULE'):
# Remove module.c in $RTT_ROOT/src
- ObjRemove(objs, ['module.obj', 'module.o'])
+ ObjRemove(objs, ['module.obj', 'module.o', 'module.c'])
AddOption('--def',
dest='def',
@@ -99,7 +99,7 @@ if GetDepend('RT_USING_MODULE'):
if rtconfig.PLATFORM == 'mingw':
env['LINKFLAGS'] = rtconfig.DEFFILE_LFLAGS
else:
- rtconfig.POST_ACTION = 'createdef.py $TARGET rtthread.def'
+ rtconfig.POST_ACTION = 'python createdef.py $TARGET rtthread.def'
program = env.Program(TARGET, objs)
else:
diff --git a/bsp/simulator/applications/application.c b/bsp/simulator/applications/application.c
index a01e8d91b7..df34aa87c9 100755
--- a/bsp/simulator/applications/application.c
+++ b/bsp/simulator/applications/application.c
@@ -1,11 +1,21 @@
/*
* File : application.c
* This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
@@ -16,154 +26,15 @@
#include <stdio.h>
#include <board.h>
-#ifdef RT_USING_FINSH
-#include <finsh.h>
-#include <shell.h>
-#endif
-
-#ifdef RT_USING_LWIP
-#include <lwip/sys.h>
-#include <netif/ethernetif.h>
-extern void lwip_system_init(void);
-#endif
-
#ifdef RT_USING_DFS
-#include <dfs_init.h>
#include <dfs_fs.h>
-#ifdef RT_USING_DFS_ELMFAT
-#include <dfs_elm.h>
-#endif
-#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
-#include <dfs_nfs.h>
-#endif
-#ifdef RT_USING_DFS_ROMFS
-#include <dfs_romfs.h>
-#endif
-#ifdef RT_USING_DFS_DEVFS
-#include <devfs.h>
-#endif
-#ifdef RT_USING_DFS_UFFS
-#include <dfs_uffs.h>
-#endif
-#ifdef RT_USING_DFS_JFFS2
-#include <dfs_jffs2.h>
-#endif
-#ifdef RT_USING_DFS_YAFFS2
-#include <dfs_yaffs2.h>
-#endif
-#ifdef RT_USING_DFS_ROMFS
-#include <dfs_romfs.h>
-#endif
#endif
-#ifdef RT_USING_NEWLIB
-#include <libc.h>
-#endif
-#ifdef RT_USING_PTHREADS
-#include <pthread.h>
-#endif
-
-#ifdef RT_USING_MODULE
-#include <rtm.h>
-#endif
-
-#ifdef RT_USING_RTGUI
-#include <rtgui/rtgui_system.h>
-#endif
+#include "init.h"
void rt_init_thread_entry(void *parameter)
{
-#ifdef RT_USING_LWIP
-#ifdef RT_USING_TAPNETIF
- tap_netif_hw_init();
-#else
- pcap_netif_hw_init();
-#endif
-#endif
-
- rt_platform_init();
-
-#ifdef RT_USING_MODULE
- rt_system_module_init();
-#endif
-
-#ifdef RT_USING_FINSH
- /* initialize finsh */
- finsh_system_init();
- finsh_set_device(RT_CONSOLE_DEVICE_NAME);
-#endif
-
-#ifdef RT_USING_LWIP
- /* initialize lwip stack */
- /* register ethernetif device */
- eth_system_device_init();
-
- /* initialize lwip system */
- lwip_system_init();
- rt_kprintf("TCP/IP initialized!\n");
-#endif
-
-#ifdef RT_USING_DFS
- /* initialize the device file system */
- dfs_init();
-
-#ifdef RT_USING_DFS_ELMFAT
- /* initialize the elm chan FatFS file system*/
- elm_init();
-#endif
-
-#if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP)
- /* initialize NFSv3 client file system */
- nfs_init();
-#endif
-
-#ifdef RT_USING_DFS_YAFFS2
- dfs_yaffs2_init();
-#endif
-
-#ifdef RT_USING_DFS_UFFS
- dfs_uffs_init();
-#endif
-
-#ifdef RT_USING_DFS_JFFS2
- dfs_jffs2_init();
-#endif
-
-#ifdef RT_USING_DFS_ROMFS
- dfs_romfs_init();
-#endif
-
-#ifdef RT_USING_DFS_RAMFS
- dfs_ramfs_init();
-#endif
-
-#ifdef RT_USING_DFS_DEVFS
- devfs_init();
-#endif
-#endif /* end of RT_USING_DFS */
-
-#ifdef RT_USING_NEWLIB
- libc_system_init(RT_CONSOLE_DEVICE_NAME);
-#else
- /* the pthread system initialization will be initiallized in libc */
-#ifdef RT_USING_PTHREADS
- pthread_system_init();
-#endif
-#endif
-
-#ifdef RT_USING_RTGUI
- rtgui_system_server_init();
-#endif
-
-#ifdef RT_USING_USB_HOST
- rt_usb_host_init();
-#endif
-
-#ifdef RT_USING_RTGUI
- /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be
- * called after rt_components_init. */
- rt_hw_sdl_start();
-#endif /* RT_USING_RTGUI */
+ components_init();
/* File system Initialization */
#ifdef RT_USING_DFS
@@ -228,5 +99,3 @@ int rt_application_init()
return 0;
}
-
-/*@}*/ \ No newline at end of file
diff --git a/bsp/simulator/applications/init.c b/bsp/simulator/applications/init.c
new file mode 100644
index 0000000000..b78deefe71
--- /dev/null
+++ b/bsp/simulator/applications/init.c
@@ -0,0 +1,170 @@
+/*
+ * File : init.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2015-09-30 Bernard the first version
+ */
+
+#include <rtthread.h>
+
+#include "init.h"
+
+#ifdef RT_USING_FINSH
+#include <finsh.h>
+#include <shell.h>
+#endif
+
+#ifdef RT_USING_LWIP
+#include <lwip/sys.h>
+#include <netif/ethernetif.h>
+extern void lwip_system_init(void);
+#endif
+
+#ifdef RT_USING_DFS
+#include <dfs_init.h>
+#include <dfs_fs.h>
+#ifdef RT_USING_DFS_ELMFAT
+#include <dfs_elm.h>
+#endif
+#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
+#include <dfs_nfs.h>
+#endif
+#ifdef RT_USING_DFS_ROMFS
+#include <dfs_romfs.h>
+#endif
+#ifdef RT_USING_DFS_DEVFS
+#include <devfs.h>
+#endif
+#ifdef RT_USING_DFS_UFFS
+#include <dfs_uffs.h>
+#endif
+#ifdef RT_USING_DFS_JFFS2
+#include <dfs_jffs2.h>
+#endif
+#ifdef RT_USING_DFS_YAFFS2
+#include <dfs_yaffs2.h>
+#endif
+#ifdef RT_USING_DFS_ROMFS
+#include <dfs_romfs.h>
+#endif
+#endif
+
+#ifdef RT_USING_NEWLIB
+#include <libc.h>
+#endif
+#ifdef RT_USING_PTHREADS
+#include <pthread.h>
+#endif
+
+#ifdef RT_USING_MODULE
+#include <rtm.h>
+#endif
+
+#ifdef RT_USING_RTGUI
+#include <rtgui/rtgui_system.h>
+#endif
+
+/* components initialization for simulator */
+void components_init(void)
+{
+ platform_init();
+
+#ifdef RT_USING_MODULE
+ rt_system_module_init();
+#endif
+
+#ifdef RT_USING_FINSH
+ /* initialize finsh */
+ finsh_system_init();
+ finsh_set_device(RT_CONSOLE_DEVICE_NAME);
+#endif
+
+#ifdef RT_USING_LWIP
+ /* initialize lwip stack */
+ /* register ethernetif device */
+ eth_system_device_init();
+
+ /* initialize lwip system */
+ lwip_system_init();
+ rt_kprintf("TCP/IP initialized!\n");
+#endif
+
+#ifdef RT_USING_DFS
+ /* initialize the device file system */
+ dfs_init();
+
+#ifdef RT_USING_DFS_ELMFAT
+ /* initialize the elm chan FatFS file system*/
+ elm_init();
+#endif
+
+#if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP)
+ /* initialize NFSv3 client file system */
+ nfs_init();
+#endif
+
+#ifdef RT_USING_DFS_YAFFS2
+ dfs_yaffs2_init();
+#endif
+
+#ifdef RT_USING_DFS_UFFS
+ dfs_uffs_init();
+#endif
+
+#ifdef RT_USING_DFS_JFFS2
+ dfs_jffs2_init();
+#endif
+
+#ifdef RT_USING_DFS_ROMFS
+ dfs_romfs_init();
+#endif
+
+#ifdef RT_USING_DFS_RAMFS
+ dfs_ramfs_init();
+#endif
+
+#ifdef RT_USING_DFS_DEVFS
+ devfs_init();
+#endif
+#endif /* end of RT_USING_DFS */
+
+#ifdef RT_USING_NEWLIB
+ libc_system_init(RT_CONSOLE_DEVICE_NAME);
+#else
+ /* the pthread system initialization will be initiallized in libc */
+#ifdef RT_USING_PTHREADS
+ pthread_system_init();
+#endif
+#endif
+
+#ifdef RT_USING_RTGUI
+ rtgui_system_server_init();
+#endif
+
+#ifdef RT_USING_USB_HOST
+ rt_usb_host_init();
+#endif
+
+#ifdef RT_USING_RTGUI
+ /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be
+ * called after rt_components_init. */
+ rt_hw_sdl_start();
+#endif /* RT_USING_RTGUI */
+}
diff --git a/bsp/simulator/applications/init.h b/bsp/simulator/applications/init.h
new file mode 100644
index 0000000000..ae8c838e1e
--- /dev/null
+++ b/bsp/simulator/applications/init.h
@@ -0,0 +1,31 @@
+/*
+ * File : init.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2015-09-30 Bernard the first version
+ */
+
+#ifndef INIT_H__
+#define INIT_H__
+
+void platform_init(void);
+void components_init(void);
+
+#endif
diff --git a/bsp/simulator/applications/platform.c b/bsp/simulator/applications/platform.c
index fbc1003d2a..229c507c9a 100644
--- a/bsp/simulator/applications/platform.c
+++ b/bsp/simulator/applications/platform.c
@@ -1,8 +1,16 @@
#include <rtthread.h>
#include "board.h"
-void rt_platform_init(void)
+void platform_init(void)
{
+#ifdef RT_USING_LWIP
+#ifdef RT_USING_TAPNETIF
+ tap_netif_hw_init();
+#else
+ pcap_netif_hw_init();
+#endif
+#endif
+
#ifdef RT_USING_DFS
/* initialize sd card */
rt_hw_sdcard_init();
@@ -16,9 +24,5 @@ void rt_platform_init(void)
#endif
#endif /* RT_USING_DFS */
-
-#ifdef _WIN32
- rt_thread_idle_sethook(rt_hw_win32_low_cpu);
-#endif
}
diff --git a/bsp/simulator/drivers/board.c b/bsp/simulator/drivers/board.c
index dcb8d9a049..4e498395c9 100755
--- a/bsp/simulator/drivers/board.c
+++ b/bsp/simulator/drivers/board.c
@@ -14,9 +14,12 @@
#include <rthw.h>
#include <rtthread.h>
-#include "board.h"
+
#include <stdlib.h>
+#include "board.h"
+#include "uart_console.h"
+
/**
* @addtogroup simulator on win32
*/
@@ -93,9 +96,11 @@ void rt_hw_board_init()
/* init system memory */
heap = rt_hw_sram_init();
-//#if defined(RT_USING_USART)
- rt_hw_usart_init();
-//#endif
+ uart_console_init();
+
+#ifdef _WIN32
+ rt_thread_idle_sethook(rt_hw_win32_low_cpu);
+#endif
#if defined(RT_USING_CONSOLE)
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
diff --git a/bsp/simulator/drivers/module_win32.c b/bsp/simulator/drivers/module_win32.c
index 3f0a273746..95cb301037 100644
--- a/bsp/simulator/drivers/module_win32.c
+++ b/bsp/simulator/drivers/module_win32.c
@@ -130,6 +130,7 @@ void rt_module_unload_sethook(void (*hook)(rt_module_t module))
*/
int rt_system_module_init(void)
{
+ return 0;
}
/**
@@ -148,6 +149,7 @@ rt_module_t rt_module_self(void)
/* return current module */
return (rt_module_t)tid->module_id;
}
+RTM_EXPORT(rt_module_self);
/**
* This function will find the specified module.
@@ -191,6 +193,7 @@ rt_module_t rt_module_find(const char *name)
/* not found */
return RT_NULL;
}
+RTM_EXPORT(rt_module_find);
#ifdef RT_USING_DFS
#include <windows.h>
@@ -237,10 +240,10 @@ rt_module_t rt_module_open(const char *path)
struct dfs_filesystem *fs;
appentry_t fptr;
HINSTANCE hinstlib;
- int len;
- char * winpath;
- rt_module_t module;
- char * name;
+ rt_module_t module;
+
+ char * winpath = RT_NULL;
+ char * name = RT_NULL;
RT_DEBUG_NOT_IN_INTERRUPT;
@@ -256,10 +259,10 @@ rt_module_t rt_module_open(const char *path)
}
/* change path */
- len = strlen(path+1);
+ // len = strlen(path+1);
if ((winpath = dfs_win32_dirdup((char *)path)) == RT_NULL)
{
- rt_kprintf("out of memory, exit", path);
+ rt_kprintf("out of memory, exit");
return RT_NULL;
}
@@ -282,10 +285,8 @@ rt_module_t rt_module_open(const char *path)
name = _module_name(path);
/* allocate module */
- module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module,
- name);
- if (!module)
- return RT_NULL;
+ module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module, name);
+ if (!module) return RT_NULL;
module->nref = 0;
module->module_entry = fptr;
@@ -298,31 +299,21 @@ rt_module_t rt_module_open(const char *path)
if (module->module_entry != 0)
{
- rt_uint32_t *stack_size;
- rt_uint8_t *priority;
-
#ifdef RT_USING_SLAB
/* init module memory allocator */
module->mem_list = RT_NULL;
/* create page array */
- module->page_array =
+ module->page_array =
(void *)rt_malloc(PAGE_COUNT_MAX * sizeof(struct rt_page_info));
module->page_cnt = 0;
#endif
- /* get the main thread stack size */
- module->stack_size = 2048;
- module->thread_priority = RT_THREAD_PRIORITY_MAX - 2;
-
/* create module thread */
module->module_thread =
rt_thread_create(name,
- (void(*)(void *))module->module_entry,
- RT_NULL,
- module->stack_size,
- module->thread_priority,
- 10);
+ (void(*)(void *))module->module_entry, RT_NULL,
+ 2048, RT_THREAD_PRIORITY_MAX - 2, 10);
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("thread entry 0x%x\n",
module->module_entry));
@@ -354,12 +345,157 @@ rt_module_t rt_module_open(const char *path)
#if defined(RT_USING_FINSH)
#include <finsh.h>
-
FINSH_FUNCTION_EXPORT_ALIAS(rt_module_open, exec, exec module from a file);
#endif
#endif
+/**
+ * This function will do a excutable program with main function and parameters.
+ *
+ * @param path the full path of application module
+ * @param cmd_line the command line of program
+ * @param size the size of command line of program
+ *
+ * @return the module object
+ */
+rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int line_size)
+{
+ struct dfs_filesystem *fs;
+ appentry_t fptr;
+ HINSTANCE hinstlib;
+ rt_module_t module;
+
+ char * winpath = RT_NULL;
+ char * name = RT_NULL;
+ char *full_path = RT_NULL;
+
+ RT_DEBUG_NOT_IN_INTERRUPT;
+
+ /* check parameters */
+ RT_ASSERT(path != RT_NULL);
+
+ if (*path != '/')
+ {
+ full_path = dfs_normalize_path(RT_NULL, path);
+ }
+ else
+ {
+ full_path = (const char*)path;
+ }
+
+ /* app module should only in DFS_WIN32 */
+ fs = dfs_filesystem_lookup(full_path);
+ if ((fs == RT_NULL) || (strcmp(fs->ops->name,"wdir") != 0))
+ {
+ rt_kprintf("invalid path: %s\n", path);
+ goto __exit;
+ }
+
+ /* change path */
+ // len = strlen(full_path + 1);
+ if ((winpath = dfs_win32_dirdup((char *)full_path)) == RT_NULL)
+ {
+ rt_kprintf("out of memory, exit", path);
+ goto __exit;
+ }
+
+ hinstlib = LoadLibrary(winpath);
+ if (hinstlib == NULL)
+ {
+ rt_kprintf("error: unable to open %s\n", winpath);
+ goto __exit;
+ }
+
+ fptr = (appentry_t)GetProcAddress(hinstlib, "main");
+ if (fptr == NULL)
+ {
+ rt_kprintf("error: unable to find function in %s\n", winpath);
+ FreeLibrary(hinstlib);
+ goto __exit;
+ }
+
+ /* release winpath */
+ rt_free(winpath);
+
+ /* get the name of the module */
+ name = _module_name(path);
+
+ /* allocate module */
+ module = (struct rt_module *)rt_object_allocate(RT_Object_Class_Module, name);
+ if (!module)
+ {
+ goto __exit;
+ }
+
+ module->nref = 0;
+ module->module_entry = fptr;
+
+ /* init module object container */
+ rt_module_init_object_container(module);
+
+ /* increase module reference count */
+ module->nref ++;
+
+ if (module->module_entry != 0)
+ {
+ /* set module argument */
+ module->module_cmd_line = (rt_uint8_t*)rt_malloc(line_size + 1);
+ rt_memcpy(module->module_cmd_line, cmd_line, line_size);
+ module->module_cmd_line[line_size] = '\0';
+ module->module_cmd_size = line_size;
+
+#ifdef RT_USING_SLAB
+ /* init module memory allocator */
+ module->mem_list = RT_NULL;
+
+ /* create page array */
+ module->page_array =
+ (void *)rt_malloc(PAGE_COUNT_MAX * sizeof(struct rt_page_info));
+ module->page_cnt = 0;
+#endif
+
+ /* create module thread */
+ module->module_thread =
+ rt_thread_create(name,
+ (void(*)(void *))module->module_entry, RT_NULL,
+ 2048, RT_THREAD_PRIORITY_MAX - 2, 10);
+
+ RT_DEBUG_LOG(RT_DEBUG_MODULE, ("thread entry 0x%x\n",
+ module->module_entry));
+
+ /* set module id */
+ module->module_thread->module_id = (void *)module;
+ module->parent.flag = RT_MODULE_FLAG_WITHENTRY;
+
+ /* startup module thread */
+ rt_thread_startup(module->module_thread);
+ }
+ else
+ {
+ /* without entry point */
+ module->parent.flag |= RT_MODULE_FLAG_WITHOUTENTRY;
+ }
+
+#ifdef RT_USING_HOOK
+ if (rt_module_load_hook != RT_NULL)
+ {
+ rt_module_load_hook(module);
+ }
+#endif
+
+ rt_free(name);
+ return module;
+
+__exit:
+ if (full_path != path) rt_free(full_path);
+ if (name != RT_NULL) rt_free(full_path);
+ if (winpath != RT_NULL)rt_free(winpath);
+
+ return RT_NULL;
+ /* FreeLibrary(hinstlib); */
+}
+
rt_err_t rt_module_destroy(rt_module_t module)
{
return 0;
diff --git a/bsp/simulator/drivers/serial.c b/bsp/simulator/drivers/serial.c
deleted file mode 100755
index 72cbad3baf..0000000000
--- a/bsp/simulator/drivers/serial.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * File : serial.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2013 RT-Thread Develop Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2009-02-05 Bernard first version
- * 2009-10-25 Bernard fix rt_serial_read bug when there is no data
- * in the buffer.
- * 2010-03-29 Bernard cleanup code.
- * 2013-02-7 prife rewrite for simulator
- */
-
-#include <rthw.h>
-
-#include "serial.h"
-#include <stdio.h>
-
-#if 0
-static FILE *fp = RT_NULL;
-#endif
-
-/*@{*/
-int seial_save_byte(unsigned char ch, struct serial_device * serial)
-{
- /* save on rx buffer */
- rt_base_t level;
- struct rt_device * dev = RT_DEVICE(serial);
- /* disable interrupt */
- //��ʱ�ر��жϣ���ΪҪ����uart���ݽṹ
- level = rt_hw_interrupt_disable();
-
- /* save character */
- serial->serial_rx.rx_buffer[serial->serial_rx.save_index] = ch;
- serial->serial_rx.save_index ++;
- //����Ĵ�����save_index�Ƿ��Ѿ�����������β������������ת��ͷ������Ϊһ�����λ�����
- if (serial->serial_rx.save_index >= SERIAL_RX_BUFFER_SIZE)
- serial->serial_rx.save_index = 0;
-
- //���������ʾ��ת���save_index׷����read_index��������read_index������һ���ɵ�����
- /* if the next position is read index, discard this 'read char' */
- if (serial->serial_rx.save_index == serial->serial_rx.read_index)
- {
- serial->serial_rx.read_index ++;
- if (serial->serial_rx.read_index >= SERIAL_RX_BUFFER_SIZE)
- serial->serial_rx.read_index = 0;
- }
-
- /* enable interrupt */
- //uart���ݽṹ�Ѿ�������ɣ�����ʹ���ж�
- rt_hw_interrupt_enable(level);
-
- /* invoke callback */
- if (dev->rx_indicate != RT_NULL)
- {
- rt_size_t rx_length;
-
- /* get rx length */
- rx_length = serial->serial_rx.read_index > serial->serial_rx.save_index ?
- SERIAL_RX_BUFFER_SIZE - serial->serial_rx.read_index + serial->serial_rx.save_index :
- serial->serial_rx.save_index - serial->serial_rx.read_index;
-
- dev->rx_indicate(dev, rx_length);
- }
- return 0;
-}
-
-/* RT-Thread Device Interface */
-/**
- * This function initializes serial
- */
-static rt_err_t rt_serial_init(rt_device_t dev)
-{
- struct serial_device * serial = SERIAL_DEVICE(dev);
- if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
- {
- if (dev->flag & RT_DEVICE_FLAG_INT_RX)
- {
- rt_memset(serial->serial_rx.rx_buffer, 0,
- sizeof(serial->serial_rx.rx_buffer));
- serial->serial_rx.read_index = 0;
- serial->serial_rx.save_index = 0;
- }
-
- dev->flag |= RT_DEVICE_FLAG_ACTIVATED;
- }
- return RT_EOK;
-}
-
-static rt_err_t rt_serial_open(rt_device_t dev, rt_uint16_t oflag)
-{
- return RT_EOK;
-}
-
-static rt_err_t rt_serial_close(rt_device_t dev)
-{
- return RT_EOK;
-}
-static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
-{
- rt_uint8_t *ptr;
- rt_err_t err_code;
- struct serial_device * serial = SERIAL_DEVICE(dev);
-
- ptr = buffer;
- err_code = RT_EOK;
-
- if (dev->flag & RT_DEVICE_FLAG_INT_RX)
- {
- /* interrupt mode Rx */
- while (size)
- {
- rt_base_t level;
-
- /* disable interrupt */
- level = rt_hw_interrupt_disable();
-
- if (serial->serial_rx.read_index != serial->serial_rx.save_index)
- {
- /* read a character */
- *ptr++ = serial->serial_rx.rx_buffer[serial->serial_rx.read_index];
- size--;
-
- /* move to next position */
- serial->serial_rx.read_index ++;
- if (serial->serial_rx.read_index >= SERIAL_RX_BUFFER_SIZE)
- serial->serial_rx.read_index = 0;
- }
- else
- {
- /* set error code */
- err_code = -RT_EEMPTY;
-
- /* enable interrupt */
- rt_hw_interrupt_enable(level);
- break;
- }
-
- /* enable interrupt */
- rt_hw_interrupt_enable(level);
- }
- }
-
-
- /* set error code */
- rt_set_errno(err_code);
- return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
-}
-
-static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
-{
- int level;
-#if 0
- if (fp == NULL)
- fp = fopen("log.txt", "wb+");
-
- if (fp != NULL)
- fwrite(buffer, size, 1, fp);
-#endif
-
- level = rt_hw_interrupt_disable();
- fwrite(buffer, size, 1, stdout);
- fflush(stdout);
- rt_hw_interrupt_enable(level);
- return size;
-}
-
-static rt_err_t rt_serial_control(rt_device_t dev, rt_uint8_t cmd, void *args)
-{
- RT_ASSERT(dev != RT_NULL);
-
- switch (cmd)
- {
- case RT_DEVICE_CTRL_SUSPEND:
- /* suspend device */
- dev->flag |= RT_DEVICE_FLAG_SUSPENDED;
- break;
-
- case RT_DEVICE_CTRL_RESUME:
- /* resume device */
- dev->flag &= ~RT_DEVICE_FLAG_SUSPENDED;
- break;
- }
-
- return RT_EOK;
-}
-
-/*
- * serial register
- */
-rt_err_t rt_hw_serial_register(rt_device_t device, const char *name, rt_uint32_t flag)
-{
- RT_ASSERT(device != RT_NULL);
- device->type = RT_Device_Class_Char;
- device->rx_indicate = RT_NULL;
- device->tx_complete = RT_NULL;
- device->init = rt_serial_init;
- device->open = rt_serial_open;
- device->close = rt_serial_close;
- device->read = rt_serial_read;
- device->write = rt_serial_write;
- device->control = rt_serial_control;
- device->user_data = RT_NULL;
-
- /* register a character device */
- return rt_device_register(device, name, (rt_uint16_t)(RT_DEVICE_FLAG_RDWR | flag));
-}
-
-rt_err_t rt_hw_serial_init(struct serial_device * serial, char * name)
-{
- return rt_hw_serial_register(RT_DEVICE(serial), name,
- RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM);
-}
diff --git a/bsp/simulator/drivers/serial.h b/bsp/simulator/drivers/serial.h
deleted file mode 100644
index 7c554c3f45..0000000000
--- a/bsp/simulator/drivers/serial.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-*********************************************************************************************************
-* MC9S12DP256/DG128 Specific code
-* BANKED MEMORY MODEL
-*
-* File : rthw.c
-* By : parai
-*******************************************************************************************************/
-
-#ifndef __RT_HW_SERIAL_H__
-#define __RT_HW_SERIAL_H__
-
-#include <rtdevice.h>
-#define SERIAL_RX_BUFFER_SIZE 80
-struct serial_int_rx
-{
- rt_uint8_t rx_buffer[SERIAL_RX_BUFFER_SIZE];
- rt_uint32_t read_index, save_index;
-};
-
-struct serial_device
-{
- struct rt_device dev;
- struct serial_int_rx serial_rx;
-};
-
-#define SERIAL_DEVICE(dev) ((struct serial_device *)(dev))
-
-int seial_save_byte(unsigned char ch, struct serial_device * serial);
-rt_err_t rt_hw_serial_init(struct serial_device * serial, char * name);
-#endif
diff --git a/bsp/simulator/drivers/usart_sim.c b/bsp/simulator/drivers/uart_console.c
index 6c8209dcc0..95a9cb11dd 100755..100644
--- a/bsp/simulator/drivers/usart_sim.c
+++ b/bsp/simulator/drivers/uart_console.c
@@ -1,34 +1,29 @@
-/*
- * File : serial.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2013 RT-Thread Develop Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2012-09-25 prife first implementation
- * 2013-01-15 prife support linux
- * 2013-02-6 prife rewrite to fit the new serial.c
- */
-#include <rthw.h>
-#include <rtthread.h>
+#include <stdio.h>
+
+#include <rthw.h>
+#include <rtdevice.h>
+#include <rtthread.h>
+#include <rtdevice.h>
+
+#include <cpu_port.h>
+
+/* uart driver */
+struct console_uart
+{
+ int rx_ready;
+
+ struct rt_ringbuffer rb;
+ rt_uint8_t rx_buffer[256];
+} _console_uart;
+static struct rt_serial_device _serial;
+
+#define SAVEKEY(key) do { char ch = key; rt_ringbuffer_put_force(&(_console_uart.rb), &ch, 1); } while (0)
#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
#include <conio.h>
-#endif
-
-#include <stdio.h>
-#include "serial.h"
-struct serial_device serial1;
-
-#define SAVEKEY(key) seial_save_byte(key, &serial1)
-#ifdef _WIN32
/*
* Handler for OSKey Thread
*/
@@ -36,9 +31,8 @@ static HANDLE OSKey_Thread;
static DWORD OSKey_ThreadID;
static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam);
-void rt_hw_usart_init(void)
+void console_lowlevel_init(void)
{
- rt_hw_serial_init(&serial1, RT_CONSOLE_DEVICE_NAME);
/*
* create serial thread that receive key input from keyboard
*/
@@ -52,9 +46,9 @@ void rt_hw_usart_init(void)
if (OSKey_Thread == NULL)
{
//Display Error Message
-
return;
}
+
SetThreadPriority(OSKey_Thread,
THREAD_PRIORITY_NORMAL);
SetThreadPriorityBoost(OSKey_Thread,
@@ -67,6 +61,7 @@ void rt_hw_usart_init(void)
ResumeThread(OSKey_Thread);
}
+static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam)
#else /* POSIX version */
#include <pthread.h>
@@ -78,11 +73,11 @@ void rt_hw_usart_init(void)
static void * ThreadforKeyGet(void * lpParam);
static pthread_t OSKey_Thread;
-void rt_hw_usart_init(void)
+
+void console_lowlevel_init(void)
{
int res;
- rt_hw_serial_init(&serial1, RT_CONSOLE_DEVICE_NAME);
res = pthread_create(&OSKey_Thread, NULL, &ThreadforKeyGet, NULL);
if (res)
{
@@ -90,15 +85,10 @@ void rt_hw_usart_init(void)
exit(EXIT_FAILURE);
}
}
-#endif
-
-#ifdef _WIN32
-static DWORD WINAPI ThreadforKeyGet(LPVOID lpParam)
-#else
static struct termios oldt, newt;
/*simulate windows' getch(), it works!!*/
-void set_stty(void)
+static void set_stty(void)
{
/* get terminal input's attribute */
tcgetattr(STDIN_FILENO, &oldt);
@@ -109,22 +99,21 @@ void set_stty(void)
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
}
-void restore_stty(void)
+static void restore_stty(void)
{
/* recover terminal's attribute */
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
}
#define getch getchar
-
static void * ThreadforKeyGet(void * lpParam)
#endif /* not _WIN32*/
{
/*
- * �����(��)�� 0xe04b
- * �����(��)�� 0xe048
- * �����(��)�� 0xe04d
- * �����(��)�� 0xe050
+ * left key(��)�� 0xe04b
+ * up key(��)�� 0xe048
+ * right key(��)�� 0xe04d
+ * down key(��)�� 0xe050
*/
unsigned char key;
@@ -135,7 +124,9 @@ static void * ThreadforKeyGet(void * lpParam)
pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
set_stty();
#endif
+
(void)lpParam; //prevent compiler warnings
+
for (;;)
{
key = getch();
@@ -173,5 +164,109 @@ static void * ThreadforKeyGet(void * lpParam)
}
#endif
SAVEKEY(key);
+
+ /* Notfiy serial ISR */
+ rt_hw_serial_isr(&_serial, RT_SERIAL_EVENT_RX_IND);
}
} /*** ThreadforKeyGet ***/
+
+static rt_err_t console_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
+{
+ /* no baudrate, nothing */
+
+ return RT_EOK;
+}
+
+static rt_err_t console_control(struct rt_serial_device *serial, int cmd, void *arg)
+{
+ struct console_uart* uart;
+
+ RT_ASSERT(serial != RT_NULL);
+ uart = (struct console_uart *)serial->parent.user_data;
+
+ switch (cmd)
+ {
+ case RT_DEVICE_CTRL_CLR_INT:
+ uart->rx_ready = 0;
+ break;
+ case RT_DEVICE_CTRL_SET_INT:
+ uart->rx_ready = 1;
+ break;
+ }
+
+ return RT_EOK;
+}
+
+static int console_putc(struct rt_serial_device *serial, char c)
+{
+ int level;
+ struct console_uart* uart;
+
+ RT_ASSERT(serial != RT_NULL);
+ uart = (struct console_uart *)serial->parent.user_data;
+
+#if 0 /* Enable it if you want to save the console log */
+ {
+ static FILE* fp = NULL;
+
+ if (fp == NULL)
+ fp = fopen("log.txt", "wb+");
+
+ if (fp != NULL)
+ fwrite(buffer, size, 1, fp);
+ }
+#endif
+
+ level = rt_hw_interrupt_disable();
+ fwrite(&c, 1, 1, stdout);
+ fflush(stdout);
+ rt_hw_interrupt_enable(level);
+ return 1;
+}
+
+static int console_getc(struct rt_serial_device *serial)
+{
+ char ch;
+ struct console_uart* uart;
+
+ RT_ASSERT(serial != RT_NULL);
+ uart = (struct console_uart *)serial->parent.user_data;
+
+ if (rt_ringbuffer_getchar(&(uart->rb), &ch)) return ch;
+
+ return -1;
+}
+
+static const struct rt_uart_ops console_uart_ops =
+{
+ console_configure,
+ console_control,
+ console_putc,
+ console_getc,
+};
+
+int uart_console_init(void)
+{
+ struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
+ struct console_uart* uart;
+ struct rt_serial_device* serial;
+
+ uart = &_console_uart;
+ serial = &_serial;
+
+ uart->rx_ready = 0;
+
+ serial->ops = &console_uart_ops;
+ serial->config = config;
+ /* initialize ring buffer */
+ rt_ringbuffer_init(&uart->rb, uart->rx_buffer, sizeof(uart->rx_buffer));
+
+ /* register UART device */
+ rt_hw_serial_register(serial, "console",
+ RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
+ uart);
+
+ console_lowlevel_init();
+
+ return 0;
+}
diff --git a/bsp/simulator/drivers/uart_console.h b/bsp/simulator/drivers/uart_console.h
new file mode 100644
index 0000000000..149a7a21f8
--- /dev/null
+++ b/bsp/simulator/drivers/uart_console.h
@@ -0,0 +1,6 @@
+#ifndef UART_CONSOLE_H__
+#define UART_CONSOLE_H__
+
+int uart_console_init(void);
+
+#endif
diff --git a/bsp/simulator/rtconfig.h b/bsp/simulator/rtconfig.h
index a1f877de2e..894a5822a1 100755
--- a/bsp/simulator/rtconfig.h
+++ b/bsp/simulator/rtconfig.h
@@ -1,237 +1,241 @@
/* RT-Thread config file */
+
#ifndef __RTTHREAD_CFG_H__
#define __RTTHREAD_CFG_H__
-#define RT_HEAP_SIZE (1024*1024*2)
+// <RDTConfigurator URL="http://www.rt-thread.com/eclipse">
-#if defined(_MSC_VER)
-/* SECTION: port for visual studio */
-#undef RT_USING_NEWLIB
-#undef RT_USING_MINILIBC
-#define NORESOURCE //RT_VESRION in winuser.h
-#define _CRT_ERRNO_DEFINED //errno macro redefinition
-#define _INC_WTIME_INL//dfs_elm.c time.h conflicts with wtime.inl
-#define _INC_TIME_INL //dfs_elm.c time.h conflicts with wtime.inl
-
-/* disable some warning in MSC */
-#pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */
-#pragma warning(disable:4312) /* to ignore: warning C4312: 'type cast' : conversion from 'rt_uint32_t' to 'rt_uint32_t *' */
-#pragma warning(disable:4311) /* to ignore: warning C4311: 'type cast' : pointer truncation from 'short *__w64 ' to 'long' */
-#pragma warning(disable:4996) /* to ignore: warning C4996: The POSIX name for this item is deprecated. */
-#pragma warning(disable:4267) /* to ignore: warning C4267: conversion from 'size_t' to 'rt_size_t', possible loss of data */
-#pragma warning(disable:4244) /* to ignore: warning C4244: '=' : conversion from '__w64 int' to 'rt_size_t', possible loss of data */
-
-#elif defined(__GNUC__)
-#define RT_USING_NOLIBC
-
-#if defined(__MINGW32__)
-#define _NO_OLDNAMES /* to ignore: mode_t in sys/type.h */
-#endif
-#endif
-
-/* SECTION: basic kernel options */
-/* RT_NAME_MAX*/
-#define RT_NAME_MAX 8
-
-/* RT_ALIGN_SIZE*/
+// <integer name="RT_NAME_MAX" description="Maximal size of kernel object name length" default="6" />
+#define RT_NAME_MAX 6
+// <integer name="RT_ALIGN_SIZE" description="Alignment size for CPU architecture data access" default="4" />
#define RT_ALIGN_SIZE 4
-
-/* PRIORITY_MAX */
-#define RT_THREAD_PRIORITY_MAX 32
-
-/* Tick per Second */
+// <integer name="RT_THREAD_PRIORITY_MAX" description="Maximal level of thread priority" default="32">
+// <item description="8">8</item>
+// <item description="32">32</item>
+// <item description="256">256</item>
+// </integer>
+#define RT_THREAD_PRIORITY_MAX 32
+// <integer name="RT_TICK_PER_SECOND" description="OS tick per second" default="100" />
#define RT_TICK_PER_SECOND 100
-
-/* SECTION: RT_DEBUG */
-/* Thread Debug */
+// <section name="RT_DEBUG" description="Kernel Debug Configuration" default="true" >
#define RT_DEBUG
-//#define RT_DEBUG_SCHEDULER 1
-#define RT_THREAD_DEBUG
-
+// <bool name="RT_THREAD_DEBUG" description="Thread debug enable" default="false" />
+// #define RT_THREAD_DEBUG
+// <bool name="RT_USING_OVERFLOW_CHECK" description="Thread stack over flow detect" default="true" />
#define RT_USING_OVERFLOW_CHECK
+// </section>
-/* Using Hook */
+// <bool name="RT_USING_HOOK" description="Using hook functions" default="true" />
#define RT_USING_HOOK
-
-/* Using Software Timer */
-/* #define RT_USING_TIMER_SOFT */
-#define RT_TIMER_THREAD_PRIO 4
+// <section name="RT_USING_TIMER_SOFT" description="Using software timer which will start a thread to handle soft-timer" default="true" >
+// #define RT_USING_TIMER_SOFT
+// <integer name="RT_TIMER_THREAD_PRIO" description="The priority level of timer thread" default="4" />
+#define RT_TIMER_THREAD_PRIO 4
+// <integer name="RT_TIMER_THREAD_STACK_SIZE" description="The stack size of timer thread" default="512" />
#define RT_TIMER_THREAD_STACK_SIZE 512
-#define RT_TIMER_TICK_PER_SECOND 10
+// </section>
-/* SECTION: IPC */
-/* Using Semaphore*/
+// <section name="IPC" description="Inter-Thread communication" default="always" >
+// <bool name="RT_USING_SEMAPHORE" description="Using semaphore in the system" default="true" />
#define RT_USING_SEMAPHORE
-
-/* Using Mutex */
+// <bool name="RT_USING_MUTEX" description="Using mutex in the system" default="true" />
#define RT_USING_MUTEX
-
-/* Using Event */
+// <bool name="RT_USING_EVENT" description="Using event group in the system" default="true" />
#define RT_USING_EVENT
-
-/* Using MailBox */
+// <bool name="RT_USING_MAILBOX" description="Using mailbox in the system" default="true" />
#define RT_USING_MAILBOX
-
-/* Using Message Queue */
+// <bool name="RT_USING_MESSAGEQUEUE" description="Using message queue in the system" default="true" />
#define RT_USING_MESSAGEQUEUE
+// </section>
-/* SECTION: Memory Management */
-/* Using Memory Pool Management*/
-/* #define RT_USING_MEMPOOL */
-
-/* Using Dynamic Heap Management */
+// <section name="MM" description="Memory Management" default="always" >
+// <bool name="RT_USING_MEMPOOL" description="Using Memory Pool Management in the system" default="true" />
+#define RT_USING_MEMPOOL
+// <bool name="RT_USING_MEMHEAP" description="Using Memory Heap Object in the system" default="true" />
+#define RT_USING_MEMHEAP
+// <bool name="RT_USING_HEAP" description="Using Dynamic Heap Management in the system" default="true" />
#define RT_USING_HEAP
-
-/* Using Small MM */
+// <bool name="RT_USING_SMALL_MEM" description="Optimizing for small memory" default="false" />
#define RT_USING_SMALL_MEM
-/* #define RT_TINY_SIZE */
+// <bool name="RT_USING_SLAB" description="Using SLAB memory management for large memory" default="false" />
+// #define RT_USING_SLAB
+// </section>
-/* SECTION: Device System */
-/* Using Device System */
+// <section name="RT_USING_DEVICE" description="Using Device Driver Framework" default="true" >
#define RT_USING_DEVICE
+// <bool name="RT_USING_DEVICE_IPC" description="Using Inter-Thread communication for Device" default="true" >
#define RT_USING_DEVICE_IPC
-/* #define RT_USING_UART1 */
+// <bool name="RT_USING_SERIAL" description="Using serial device framework" default="true">
+#define RT_USING_SERIAL
+// <bool name="RT_USING_UART0" description="Using UART0" default="true" />
+#define RT_USING_UART0
+// </section>
-/* SECTION: Console options */
+// <section name="RT_USING_CONSOLE" description="Using console" default="true" >
#define RT_USING_CONSOLE
-/* the buffer size of console*/
+// <integer name="RT_CONSOLEBUF_SIZE" description="The buffer size for console output" default="128" />
#define RT_CONSOLEBUF_SIZE 128
-#define RT_CONSOLE_DEVICE_NAME "sci0"
-
-/* SECTION: APP MODULE */
-/* #define RT_USING_MODULE */
+// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart" />
+#define RT_CONSOLE_DEVICE_NAME "console"
+// </section>
-/* SECTION: MTD interface options */
-/* using mtd nand flash */
-#define RT_USING_MTD_NAND
-/* using mtd nor flash */
-/* #define RT_USING_MTD_NOR */
-
-/* SECTION: finsh, a C-Express shell */
+// <bool name="RT_USING_COMPONENTS_INIT" description="Using RT-Thread components initialization" default="true" />
+// #define RT_USING_COMPONENTS_INIT
+// <section name="RT_USING_FINSH" description="Using finsh as shell, which is a C-Express shell" default="true" >
#define RT_USING_FINSH
-/* Using symbol table */
+// <bool name="FINSH_USING_SYMTAB" description="Using symbol table in finsh shell" default="true" />
#define FINSH_USING_SYMTAB
+// <bool name="FINSH_USING_DESCRIPTION" description="Keeping description in symbol table" default="true" />
#define FINSH_USING_DESCRIPTION
+// <integer name="FINSH_THREAD_STACK_SIZE" description="The stack size for finsh thread" default="4096" />
+#define FINSH_THREAD_STACK_SIZE 4096
+// </section>
-/* SECTION: device file system */
-#define RT_USING_DFS
-#define DFS_FILESYSTEM_TYPES_MAX 8
+// <section name="LIBC" description="C Runtime library setting" default="always" >
+// <bool name="RT_USING_LIBC" description="Using C library" default="true" />
+// #define RT_USING_LIBC
+// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
+// #define RT_USING_PTHREADS
+// </section>
-/* DFS: ELM FATFS options */
+// <section name="RT_USING_DFS" description="Device file system" default="true" >
+// #define RT_USING_DFS
+// <bool name="DFS_USING_WORKDIR" description="Using working directory" default="true" />
+// #define DFS_USING_WORKDIR
+// <integer name="DFS_FILESYSTEMS_MAX" description="The maximal number of mounted file system" default="4" />
+#define DFS_FILESYSTEMS_MAX 2
+// <integer name="DFS_FD_MAX" description="The maximal number of opened files" default="4" />
+#define DFS_FD_MAX 4
+// <bool name="RT_USING_DFS_ELMFAT" description="Using ELM FatFs" default="true" />
#define RT_USING_DFS_ELMFAT
-#define RT_DFS_ELM_WORD_ACCESS
-/* Reentrancy (thread safe) of the FatFs module. */
-#define RT_DFS_ELM_REENTRANT
-/* Number of volumes (logical drives) to be used. */
-#define RT_DFS_ELM_DRIVES 2
-/* #define RT_DFS_ELM_USE_LFN 1 */
-#define RT_DFS_ELM_MAX_LFN 255
-/* Maximum sector size to be handled. */
-#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
-
-/* DFS: network file system options */
-/* #define RT_USING_DFS_NFS */
-
-/* DFS: UFFS nand file system options */
-#define RT_USING_DFS_UFFS
-/* configuration for uffs, more to see dfs_uffs.h and uffs_config.h */
-#define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO
-/* enable this ,you need provide a mark_badblock/check_block function */
-/* #define RT_UFFS_USE_CHECK_MARK_FUNCITON */
-
-/* DFS: JFFS2 nor flash file system options */
-//#define RT_USING_DFS_JFFS2
-
-/* DFS: windows share directory mounted to rt-thread/dfs */
-/* only used in bsp/simulator */
-#ifdef _WIN32
-#define RT_USING_DFS_WINSHAREDIR
-#endif
+// <integer name="RT_DFS_ELM_USE_LFN" description="Support long file name" default="0">
+// <item description="LFN with static LFN working buffer">1</item>
+// <item description="LFN with dynamic LFN working buffer on the stack">2</item>
+// <item description="LFN with dynamic LFN working buffer on the heap">3</item>
+// </integer>
+#define RT_DFS_ELM_USE_LFN 3
+// <integer name="RT_DFS_ELM_CODE_PAGE" description="OEM code page" default="437">
+#define RT_DFS_ELM_CODE_PAGE 437
+// <integer name="RT_DFS_ELM_MAX_LFN" description="Maximal size of file name length" default="256" />
+#define RT_DFS_ELM_MAX_LFN 128
+// <bool name="RT_USING_DFS_YAFFS2" description="Using YAFFS2" default="false" />
+// #define RT_USING_DFS_YAFFS2
+// <bool name="RT_USING_DFS_UFFS" description="Using UFFS" default="false" />
+// #define RT_USING_DFS_UFFS
+// <bool name="RT_USING_DFS_DEVFS" description="Using devfs for device objects" default="true" />
+// #define RT_USING_DFS_DEVFS
+// <bool name="RT_USING_DFS_NFS" description="Using NFS v3 client file system" default="false" />
+// #define RT_USING_DFS_NFS
+// <string name="RT_NFS_HOST_EXPORT" description="NFSv3 host export" default="192.168.1.5:/" />
+#define RT_NFS_HOST_EXPORT "192.168.1.5:/"
+// </section>
-/* the max number of mounted file system */
-#define DFS_FILESYSTEMS_MAX 4
-/* the max number of opened files */
-#define DFS_FD_MAX 4
-
-/* SECTION: lwip, a lightweight TCP/IP protocol stack */
-/* #define RT_USING_LWIP */
-/* LwIP uses RT-Thread Memory Management */
-#define RT_LWIP_USING_RT_MEM
-/* Enable ICMP protocol*/
+// <section name="RT_USING_LWIP" description="lwip, a lightweight TCP/IP protocol stack" default="true" >
+// #define RT_USING_LWIP
+// <bool name="RT_LWIP_ICMP" description="Enable ICMP protocol" default="true" />
#define RT_LWIP_ICMP
-/* Enable UDP protocol*/
+// <bool name="RT_LWIP_IGMP" description="Enable IGMP protocol" default="false" />
+// #define RT_LWIP_IGMP
+// <bool name="RT_LWIP_UDP" description="Enable UDP protocol" default="true" />
#define RT_LWIP_UDP
-/* Enable TCP protocol*/
+// <bool name="RT_LWIP_TCP" description="Enable TCP protocol" default="true" />
#define RT_LWIP_TCP
-/* Enable DNS */
+// <bool name="RT_LWIP_DNS" description="Enable DNS protocol" default="true" />
#define RT_LWIP_DNS
+// <bool name="RT_LWIP_SNMP" description="Enable SNMP protocol" default="false" />
+// #define RT_LWIP_SNMP
+// <bool name="RT_LWIP_DHCP" description="Enable DHCP client to get IP address" default="false" />
+// #define RT_LWIP_DHCP
+// <integer name="RT_LWIP_TCPTHREAD_PRIORITY" description="the thread priority of TCP thread" default="128" />
+#define RT_LWIP_TCPTHREAD_PRIORITY 12
+// <integer name="RT_LWIP_TCPTHREAD_MBOX_SIZE" description="the mail box size of TCP thread to wait for" default="32" />
+#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
+// <integer name="RT_LWIP_TCPTHREAD_STACKSIZE" description="the thread stack size of TCP thread" default="4096" />
+#define RT_LWIP_TCPTHREAD_STACKSIZE 4096
+// <integer name="RT_LWIP_ETHTHREAD_PRIORITY" description="the thread priority of ethnetif thread" default="144" />
+#define RT_LWIP_ETHTHREAD_PRIORITY 14
+// <integer name="RT_LWIP_ETHTHREAD_MBOX_SIZE" description="the mail box size of ethnetif thread to wait for" default="8" />
+#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
+// <integer name="RT_LWIP_ETHTHREAD_STACKSIZE" description="the stack size of ethnetif thread" default="512" />
+#define RT_LWIP_ETHTHREAD_STACKSIZE 512
+// <ipaddr name="RT_LWIP_IPADDR" description="IP address of device" default="192.168.1.30" />
+#define RT_LWIP_IPADDR0 192
+#define RT_LWIP_IPADDR1 168
+#define RT_LWIP_IPADDR2 1
+#define RT_LWIP_IPADDR3 30
+// <ipaddr name="RT_LWIP_GWADDR" description="Gateway address of device" default="192.168.1.1" />
+#define RT_LWIP_GWADDR0 192
+#define RT_LWIP_GWADDR1 168
+#define RT_LWIP_GWADDR2 1
+#define RT_LWIP_GWADDR3 1
+// <ipaddr name="RT_LWIP_MSKADDR" description="Mask address of device" default="255.255.255.0" />
+#define RT_LWIP_MSKADDR0 255
+#define RT_LWIP_MSKADDR1 255
+#define RT_LWIP_MSKADDR2 255
+#define RT_LWIP_MSKADDR3 0
+// </section>
-/* the number of simultaneously active TCP connections*/
-#define RT_LWIP_TCP_PCB_NUM 5
-
-/* Using DHCP */
-/* #define RT_LWIP_DHCP */
-
-/* ip address of target*/
-#define RT_LWIP_IPADDR0 192
-#define RT_LWIP_IPADDR1 168
-#define RT_LWIP_IPADDR2 126
-#define RT_LWIP_IPADDR3 30
+// <section name="RT_USING_RTGUI" description="RT-Thread/GUI" default="true" >
+// #define RT_USING_RTGUI
+// <integer name="RTGUI_NAME_MAX" description="the name size of RT-Thread/GUI widget/objects" default="12" />
+#define RTGUI_NAME_MAX 12
+// <bool name="RTGUI_USING_SMALL_SIZE" description="use small size in RT-Thread/GUI" default="true" />
+#define RTGUI_USING_SMALL_SIZE
+// <bool name="RTGUI_USING_FONT16" description="support 16 weight font" default="true" />
+#define RTGUI_USING_FONT16
+// <bool name="RTGUI_USING_FONT12" description="support 12 weight font" default="true" />
+// #define RTGUI_USING_FONT12
+// <bool name="RTGUI_USING_FONTHZ" description="support Chinese font" default="true" />
+#define RTGUI_USING_FONTHZ
+// <integer name="RTGUI_DEFAULT_FONT_SIZE" description="default font size in RT-Thread/GUI" default="16" />
+#define RTGUI_DEFAULT_FONT_SIZE 16
+// <bool name="RTGUI_USING_DFS_FILERW" description="use RT-Thread/DFS as file interface" default="true" />
+#define RTGUI_USING_DFS_FILERW
+// <bool name="RTGUI_USING_HZ_BMP" description="use Chinese font bitmap engine" default="true" />
+#define RTGUI_USING_HZ_BMP
+// <bool name="RTGUI_IMAGE_XPM" description="Using xpm image in RTGUI" default="true" />
+#define RTGUI_IMAGE_XPM
+// <bool name="RTGUI_IMAGE_JPEG" description="Using jpeg image in RTGUI" default="true" />
+// #define RTGUI_IMAGE_JPEG
+// <bool name="RTGUI_IMAGE_PNG" description="Using PNG image in RTGUI" default="true" />
+// #define RTGUI_IMAGE_PNG
+// <bool name="RTGUI_IMAGE_PNG" description="Using PNG image in RTGUI" default="true" />
+#define RTGUI_IMAGE_BMP
+// <bool name="RTGUI_USING_HZ_FILE" description="use font file as Chinese font" default="false" />
+ #define RTGUI_USING_HZ_FILE
+// <bool name="RTGUI_USING_MOUSE_CURSOR" description="use mouse cursor" default="false" />
+#define RTGUI_USING_MOUSE_CURSOR
+// </section>
-/* gateway address of target*/
-#define RT_LWIP_GWADDR0 192
-#define RT_LWIP_GWADDR1 168
-#define RT_LWIP_GWADDR2 126
-#define RT_LWIP_GWADDR3 1
+// </RDTConfigurator>
-/* mask address of target*/
-#define RT_LWIP_MSKADDR0 255
-#define RT_LWIP_MSKADDR1 255
-#define RT_LWIP_MSKADDR2 255
-#define RT_LWIP_MSKADDR3 0
+#define RT_HEAP_SIZE (1024*1024*2)
-/* tcp thread options */
-#define RT_LWIP_TCPTHREAD_PRIORITY 12
-#define RT_LWIP_TCPTHREAD_MBOX_SIZE 10
-#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
+#if defined(_MSC_VER)
+#define NORESOURCE //RT_VESRION in winuser.h
+#define _CRT_ERRNO_DEFINED //errno macro redefinition
+#define _INC_WTIME_INL//dfs_elm.c time.h conflicts with wtime.inl
+#define _INC_TIME_INL //dfs_elm.c time.h conflicts with wtime.inl
-/* Ethernet if thread options */
-#define RT_LWIP_ETHTHREAD_PRIORITY 15
-#define RT_LWIP_ETHTHREAD_MBOX_SIZE 10
-#define RT_LWIP_ETHTHREAD_STACKSIZE 512
+/* disable some warning in MSC */
+#pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */
+#pragma warning(disable:4312) /* to ignore: warning C4312: 'type cast' : conversion from 'rt_uint32_t' to 'rt_uint32_t *' */
+#pragma warning(disable:4311) /* to ignore: warning C4311: 'type cast' : pointer truncation from 'short *__w64 ' to 'long' */
+#pragma warning(disable:4996) /* to ignore: warning C4996: The POSIX name for this item is deprecated. */
+#pragma warning(disable:4267) /* to ignore: warning C4267: conversion from 'size_t' to 'rt_size_t', possible loss of data */
+#pragma warning(disable:4244) /* to ignore: warning C4244: '=' : conversion from '__w64 int' to 'rt_size_t', possible loss of data */
-/* TCP sender buffer space */
-#define RT_LWIP_TCP_SND_BUF 8192
-/* TCP receive window. */
-#define RT_LWIP_TCP_WND 8192
+#elif defined(__GNUC__)
+#define RT_USING_NOLIBC
-/* SECTION: RT-Thread/GUI */
-/* #define RT_USING_RTGUI */
+#if defined(__MINGW32__)
+#define _NO_OLDNAMES /* to ignore: mode_t in sys/type.h */
+#endif /* end of __MINGW32__ */
-/* name length of RTGUI object */
-#define RTGUI_NAME_MAX 12
-/* support 16 weight font */
-#define RTGUI_USING_FONT16
-/* support Chinese font */
-#define RTGUI_USING_FONTHZ
-/* use DFS as file interface */
-#define RTGUI_USING_DFS_FILERW
-/* use font file as Chinese font */
-/* #define RTGUI_USING_HZ_FILE */
-/* use Chinese bitmap font */
-#define RTGUI_USING_HZ_BMP
-/* use small size in RTGUI */
-#define RTGUI_USING_SMALL_SIZE
-/* use mouse cursor */
-/* #define RTGUI_USING_MOUSE_CURSOR */
-/* default font size in RTGUI */
-#define RTGUI_DEFAULT_FONT_SIZE 16
+#ifdef _WIN32
+#define RT_USING_DFS_WINSHAREDIR
+#endif
-/* image support */
-#define RTGUI_IMAGE_XPM
-#define RTGUI_IMAGE_BMP
-/* #define RTGUI_IMAGE_JPEG */
-/* #define RTGUI_IMAGE_PNG */
-#define RTGUI_USING_NOTEBOOK_IMAGE
+#endif /* end of _MSC_VER */
#endif
diff --git a/bsp/simulator/rtconfig.py b/bsp/simulator/rtconfig.py
index d3ed2599d5..8ccacadfd6 100755
--- a/bsp/simulator/rtconfig.py
+++ b/bsp/simulator/rtconfig.py
@@ -114,8 +114,8 @@ elif PLATFORM == 'cl':
CFLAGS += ' /MT'
LFLAGS += ''
- CFLAGS += ' /ZI /Od /W 3 /WL '
- LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 '
+ CFLAGS += ' /Zi /Od /W 3 /WL '
+ LFLAGS += ' /SUBSYSTEM:CONSOLE /MACHINE:X86 /INCREMENTAL:NO'
CPATH = ''
LPATH = ''