From 7e45f059dce0a7751beef09e5ac122a83d731c5b Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Wed, 30 Sep 2015 16:26:40 +0800 Subject: [PATCH] [BSP] Update simualtor bsp for Win32/MSVC --- bsp/simulator/.gitignore | 47 +++ bsp/simulator/SConstruct | 4 +- bsp/simulator/applications/application.c | 163 +------- bsp/simulator/applications/init.c | 170 ++++++++ bsp/simulator/applications/init.h | 31 ++ bsp/simulator/applications/platform.c | 14 +- bsp/simulator/drivers/board.c | 13 +- bsp/simulator/drivers/module_win32.c | 184 ++++++-- bsp/simulator/drivers/serial.c | 218 ---------- bsp/simulator/drivers/serial.h | 32 -- .../drivers/{usart_sim.c => uart_console.c} | 179 ++++++-- bsp/simulator/drivers/uart_console.h | 6 + bsp/simulator/rtconfig.h | 392 +++++++++--------- bsp/simulator/rtconfig.py | 4 +- 14 files changed, 787 insertions(+), 670 deletions(-) create mode 100644 bsp/simulator/.gitignore create mode 100644 bsp/simulator/applications/init.c create mode 100644 bsp/simulator/applications/init.h delete mode 100755 bsp/simulator/drivers/serial.c delete mode 100644 bsp/simulator/drivers/serial.h rename bsp/simulator/drivers/{usart_sim.c => uart_console.c} (52%) mode change 100755 => 100644 create mode 100644 bsp/simulator/drivers/uart_console.h 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 #include -#ifdef RT_USING_FINSH -#include -#include -#endif - -#ifdef RT_USING_LWIP -#include -#include -extern void lwip_system_init(void); -#endif - #ifdef RT_USING_DFS -#include #include -#ifdef RT_USING_DFS_ELMFAT -#include -#endif -#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS) -#include -#endif -#ifdef RT_USING_DFS_ROMFS -#include -#endif -#ifdef RT_USING_DFS_DEVFS -#include -#endif -#ifdef RT_USING_DFS_UFFS -#include -#endif -#ifdef RT_USING_DFS_JFFS2 -#include -#endif -#ifdef RT_USING_DFS_YAFFS2 -#include -#endif -#ifdef RT_USING_DFS_ROMFS -#include -#endif #endif -#ifdef RT_USING_NEWLIB -#include -#endif -#ifdef RT_USING_PTHREADS -#include -#endif - -#ifdef RT_USING_MODULE -#include -#endif - -#ifdef RT_USING_RTGUI -#include -#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 + +#include "init.h" + +#ifdef RT_USING_FINSH +#include +#include +#endif + +#ifdef RT_USING_LWIP +#include +#include +extern void lwip_system_init(void); +#endif + +#ifdef RT_USING_DFS +#include +#include +#ifdef RT_USING_DFS_ELMFAT +#include +#endif +#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS) +#include +#endif +#ifdef RT_USING_DFS_ROMFS +#include +#endif +#ifdef RT_USING_DFS_DEVFS +#include +#endif +#ifdef RT_USING_DFS_UFFS +#include +#endif +#ifdef RT_USING_DFS_JFFS2 +#include +#endif +#ifdef RT_USING_DFS_YAFFS2 +#include +#endif +#ifdef RT_USING_DFS_ROMFS +#include +#endif +#endif + +#ifdef RT_USING_NEWLIB +#include +#endif +#ifdef RT_USING_PTHREADS +#include +#endif + +#ifdef RT_USING_MODULE +#include +#endif + +#ifdef RT_USING_RTGUI +#include +#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 #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 #include -#include "board.h" + #include +#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 @@ -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_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 - -#include "serial.h" -#include - -#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 -* email:parai@foxmail.com -*******************************************************************************************************/ - -#ifndef __RT_HW_SERIAL_H__ -#define __RT_HW_SERIAL_H__ - -#include -#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 old mode 100755 new mode 100644 similarity index 52% rename from bsp/simulator/drivers/usart_sim.c rename to bsp/simulator/drivers/uart_console.c index 6c8209dcc0..95a9cb11dd --- 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 -#include +#include + +#include +#include +#include +#include + +#include + +/* 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 #include #include -#endif - -#include -#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 @@ -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) - -#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*/ +// +#define RT_NAME_MAX 6 +// #define RT_ALIGN_SIZE 4 - -/* PRIORITY_MAX */ -#define RT_THREAD_PRIORITY_MAX 32 - -/* Tick per Second */ +// +// 8 +// 32 +// 256 +// +#define RT_THREAD_PRIORITY_MAX 32 +// #define RT_TICK_PER_SECOND 100 - -/* SECTION: RT_DEBUG */ -/* Thread Debug */ +//
#define RT_DEBUG -//#define RT_DEBUG_SCHEDULER 1 -#define RT_THREAD_DEBUG - +// +// #define RT_THREAD_DEBUG +// #define RT_USING_OVERFLOW_CHECK +//
-/* Using Hook */ +// #define RT_USING_HOOK - -/* Using Software Timer */ -/* #define RT_USING_TIMER_SOFT */ -#define RT_TIMER_THREAD_PRIO 4 +//
+// #define RT_USING_TIMER_SOFT +// +#define RT_TIMER_THREAD_PRIO 4 +// #define RT_TIMER_THREAD_STACK_SIZE 512 -#define RT_TIMER_TICK_PER_SECOND 10 +//
-/* SECTION: IPC */ -/* Using Semaphore*/ +//
+// #define RT_USING_SEMAPHORE - -/* Using Mutex */ +// #define RT_USING_MUTEX - -/* Using Event */ +// #define RT_USING_EVENT - -/* Using MailBox */ +// #define RT_USING_MAILBOX - -/* Using Message Queue */ +// #define RT_USING_MESSAGEQUEUE - -/* SECTION: Memory Management */ -/* Using Memory Pool Management*/ -/* #define RT_USING_MEMPOOL */ - -/* Using Dynamic Heap Management */ +//
+ +//
+// +#define RT_USING_MEMPOOL +// +#define RT_USING_MEMHEAP +// #define RT_USING_HEAP - -/* Using Small MM */ +// #define RT_USING_SMALL_MEM -/* #define RT_TINY_SIZE */ +// +// #define RT_USING_SLAB +//
-/* SECTION: Device System */ -/* Using Device System */ +//
#define RT_USING_DEVICE +// #define RT_USING_DEVICE_IPC -/* #define RT_USING_UART1 */ +// +#define RT_USING_SERIAL +// +#define RT_USING_UART0 +//
-/* SECTION: Console options */ +//
#define RT_USING_CONSOLE -/* the buffer size of console*/ +// #define RT_CONSOLEBUF_SIZE 128 -#define RT_CONSOLE_DEVICE_NAME "sci0" - -/* SECTION: APP MODULE */ -/* #define RT_USING_MODULE */ +// +#define RT_CONSOLE_DEVICE_NAME "console" +//
-/* 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 */ +// +// #define RT_USING_COMPONENTS_INIT +//
#define RT_USING_FINSH -/* Using symbol table */ +// #define FINSH_USING_SYMTAB +// #define FINSH_USING_DESCRIPTION - -/* SECTION: device file system */ -#define RT_USING_DFS -#define DFS_FILESYSTEM_TYPES_MAX 8 - -/* DFS: ELM FATFS options */ +// +#define FINSH_THREAD_STACK_SIZE 4096 +//
+ +//
+// +// #define RT_USING_LIBC +// +// #define RT_USING_PTHREADS +//
+ +//
+// #define RT_USING_DFS +// +// #define DFS_USING_WORKDIR +// +#define DFS_FILESYSTEMS_MAX 2 +// +#define DFS_FD_MAX 4 +// #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 - -/* 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*/ +// +// 1 +// 2 +// 3 +// +#define RT_DFS_ELM_USE_LFN 3 +// +#define RT_DFS_ELM_CODE_PAGE 437 +// +#define RT_DFS_ELM_MAX_LFN 128 +// +// #define RT_USING_DFS_YAFFS2 +// +// #define RT_USING_DFS_UFFS +// +// #define RT_USING_DFS_DEVFS +// +// #define RT_USING_DFS_NFS +// +#define RT_NFS_HOST_EXPORT "192.168.1.5:/" +//
+ +//
+// #define RT_USING_LWIP +// #define RT_LWIP_ICMP -/* Enable UDP protocol*/ +// +// #define RT_LWIP_IGMP +// #define RT_LWIP_UDP -/* Enable TCP protocol*/ +// #define RT_LWIP_TCP -/* Enable DNS */ +// #define RT_LWIP_DNS - -/* 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 - -/* gateway address of target*/ -#define RT_LWIP_GWADDR0 192 -#define RT_LWIP_GWADDR1 168 -#define RT_LWIP_GWADDR2 126 -#define RT_LWIP_GWADDR3 1 - -/* mask address of target*/ -#define RT_LWIP_MSKADDR0 255 -#define RT_LWIP_MSKADDR1 255 -#define RT_LWIP_MSKADDR2 255 -#define RT_LWIP_MSKADDR3 0 - -/* tcp thread options */ -#define RT_LWIP_TCPTHREAD_PRIORITY 12 -#define RT_LWIP_TCPTHREAD_MBOX_SIZE 10 -#define RT_LWIP_TCPTHREAD_STACKSIZE 1024 - -/* Ethernet if thread options */ -#define RT_LWIP_ETHTHREAD_PRIORITY 15 -#define RT_LWIP_ETHTHREAD_MBOX_SIZE 10 -#define RT_LWIP_ETHTHREAD_STACKSIZE 512 - -/* TCP sender buffer space */ -#define RT_LWIP_TCP_SND_BUF 8192 -/* TCP receive window. */ -#define RT_LWIP_TCP_WND 8192 - -/* SECTION: RT-Thread/GUI */ -/* #define RT_USING_RTGUI */ - -/* name length of RTGUI object */ -#define RTGUI_NAME_MAX 12 -/* support 16 weight font */ +// +// #define RT_LWIP_SNMP +// +// #define RT_LWIP_DHCP +// +#define RT_LWIP_TCPTHREAD_PRIORITY 12 +// +#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8 +// +#define RT_LWIP_TCPTHREAD_STACKSIZE 4096 +// +#define RT_LWIP_ETHTHREAD_PRIORITY 14 +// +#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8 +// +#define RT_LWIP_ETHTHREAD_STACKSIZE 512 +// +#define RT_LWIP_IPADDR0 192 +#define RT_LWIP_IPADDR1 168 +#define RT_LWIP_IPADDR2 1 +#define RT_LWIP_IPADDR3 30 +// +#define RT_LWIP_GWADDR0 192 +#define RT_LWIP_GWADDR1 168 +#define RT_LWIP_GWADDR2 1 +#define RT_LWIP_GWADDR3 1 +// +#define RT_LWIP_MSKADDR0 255 +#define RT_LWIP_MSKADDR1 255 +#define RT_LWIP_MSKADDR2 255 +#define RT_LWIP_MSKADDR3 0 +//
+ +//
+// #define RT_USING_RTGUI +// +#define RTGUI_NAME_MAX 12 +// +#define RTGUI_USING_SMALL_SIZE +// #define RTGUI_USING_FONT16 -/* support Chinese font */ +// +// #define RTGUI_USING_FONT12 +// #define RTGUI_USING_FONTHZ -/* use DFS as file interface */ +// +#define RTGUI_DEFAULT_FONT_SIZE 16 +// #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 - -/* image support */ +// #define RTGUI_IMAGE_XPM +// +// #define RTGUI_IMAGE_JPEG +// +// #define RTGUI_IMAGE_PNG +// #define RTGUI_IMAGE_BMP -/* #define RTGUI_IMAGE_JPEG */ -/* #define RTGUI_IMAGE_PNG */ -#define RTGUI_USING_NOTEBOOK_IMAGE +// + #define RTGUI_USING_HZ_FILE +// +#define RTGUI_USING_MOUSE_CURSOR +//
+ +//
+ +#define RT_HEAP_SIZE (1024*1024*2) + +#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 + +/* 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 /* end of __MINGW32__ */ + +#ifdef _WIN32 +#define RT_USING_DFS_WINSHAREDIR +#endif + +#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 = '' -- GitLab