diff options
Diffstat (limited to 'components')
| -rw-r--r-- | components/cplusplus/crt.cpp | 24 | ||||
| -rw-r--r-- | components/cplusplus/crt.h | 24 | ||||
| -rw-r--r-- | components/cplusplus/crt_init.c | 2 | ||||
| -rw-r--r-- | components/dfs/src/dfs_file.c | 38 | ||||
| -rw-r--r-- | components/dfs/src/dfs_posix.c | 34 | ||||
| -rw-r--r-- | components/drivers/serial/serial.c | 9 | ||||
| -rw-r--r-- | components/drivers/src/completion.c | 4 | ||||
| -rw-r--r-- | components/finsh/msh.c | 1 | ||||
| -rw-r--r-- | components/finsh/shell.c | 4 | ||||
| -rw-r--r-- | components/finsh/shell.h | 2 | ||||
| -rw-r--r-- | components/net/lwip-1.4.1/src/arch/include/arch/cc.h | 4 | ||||
| -rw-r--r-- | components/net/lwip-1.4.1/src/arch/sys_arch.c | 14 | ||||
| -rw-r--r-- | components/net/lwip-1.4.1/src/netif/ethernetif.c | 16 |
13 files changed, 145 insertions, 31 deletions
diff --git a/components/cplusplus/crt.cpp b/components/cplusplus/crt.cpp index 6fa540b9e7..b6455f73f4 100644 --- a/components/cplusplus/crt.cpp +++ b/components/cplusplus/crt.cpp @@ -1,3 +1,27 @@ +/* +* File : crt.cpp +* This file is part of Device File System in RT-Thread RTOS +* COPYRIGHT (C) 2008-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-03-07 Bernard Add copyright header. +*/ + #include <rtthread.h> #include "crt.h" diff --git a/components/cplusplus/crt.h b/components/cplusplus/crt.h index fd287c2ad5..105aa0e4fc 100644 --- a/components/cplusplus/crt.h +++ b/components/cplusplus/crt.h @@ -1,3 +1,27 @@ +/* +* File : crt.h +* This file is part of Device File System in RT-Thread RTOS +* COPYRIGHT (C) 2008-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-03-07 Bernard Add copyright header. +*/ + #ifndef CRT_H_ #define CRT_H_ diff --git a/components/cplusplus/crt_init.c b/components/cplusplus/crt_init.c index 958177c1f2..9a823e394c 100644 --- a/components/cplusplus/crt_init.c +++ b/components/cplusplus/crt_init.c @@ -1,7 +1,7 @@ /* * File : crt_init.c * This file is part of Device File System in RT-Thread RTOS -* COPYRIGHT (C) 2008-2011, RT-Thread Development Team +* COPYRIGHT (C) 2008-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 diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index 614a349494..aebe2996c6 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -21,6 +21,7 @@ * Date Author Notes * 2005-02-22 Bernard The first version. * 2011-12-08 Bernard Merges rename patch from iamcacy. + * 2015-05-27 Bernard Fix the fd clear issue. */ #include <dfs.h> @@ -97,7 +98,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags) { /* clear fd */ rt_free(fd->path); - rt_memset(fd, 0, sizeof(*fd)); + fd->path = RT_NULL; return -DFS_STATUS_ENOSYS; } @@ -106,7 +107,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags) { /* clear fd */ rt_free(fd->path); - rt_memset(fd, 0, sizeof(*fd)); + fd->path = RT_NULL; dfs_log(DFS_DEBUG_INFO, ("open failed")); @@ -143,7 +144,7 @@ int dfs_file_close(struct dfs_fd *fd) return result; rt_free(fd->path); - rt_memset(fd, 0, sizeof(struct dfs_fd)); + fd->path = RT_NULL; return result; } @@ -165,7 +166,7 @@ int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args) return -DFS_STATUS_EINVAL; fs = fd->fs; - if (fs->ops->ioctl != RT_NULL) + if (fs->ops->ioctl != RT_NULL) return fs->ops->ioctl(fd, cmd, args); return -DFS_STATUS_ENOSYS; @@ -186,11 +187,11 @@ int dfs_file_read(struct dfs_fd *fd, void *buf, rt_size_t len) struct dfs_filesystem *fs; int result = 0; - if (fd == RT_NULL) + if (fd == RT_NULL) return -DFS_STATUS_EINVAL; fs = (struct dfs_filesystem *)fd->fs; - if (fs->ops->read == RT_NULL) + if (fs->ops->read == RT_NULL) return -DFS_STATUS_ENOSYS; if ((result = fs->ops->read(fd, buf, len)) < 0) @@ -213,7 +214,7 @@ int dfs_file_getdents(struct dfs_fd *fd, struct dirent *dirp, rt_size_t nbytes) struct dfs_filesystem *fs; /* parameter check */ - if (fd == RT_NULL || fd->type != FT_DIRECTORY) + if (fd == RT_NULL || fd->type != FT_DIRECTORY) return -DFS_STATUS_EINVAL; fs = (struct dfs_filesystem *)fd->fs; @@ -267,7 +268,7 @@ int dfs_file_unlink(const char *path) result = fs->ops->unlink(fs, dfs_subdir(fs->path, fullpath)); } else - result = fs->ops->unlink(fs, fullpath); + result = fs->ops->unlink(fs, fullpath); } else result = -DFS_STATUS_ENOSYS; @@ -528,7 +529,7 @@ void ls(const char *pathname) /* build full path for each file */ fullpath = dfs_normalize_path(path, dirent.d_name); - if (fullpath == RT_NULL) + if (fullpath == RT_NULL) break; if (dfs_file_stat(fullpath, &stat) == 0) @@ -555,7 +556,7 @@ void ls(const char *pathname) { rt_kprintf("No such directory\n"); } - if (pathname == RT_NULL) + if (pathname == RT_NULL) rt_free(path); } FINSH_FUNCTION_EXPORT(ls, list directory contents); @@ -632,15 +633,15 @@ static void copyfile(const char *src, const char *dst) read_bytes = dfs_file_read(&src_fd, block_ptr, BUF_SZ); if (read_bytes > 0) { - int length; - + int length; + length = dfs_file_write(&fd, block_ptr, read_bytes); - if (length != read_bytes) - { - /* write failed. */ - rt_kprintf("Write file data failed, errno=%d\n", length); - break; - } + if (length != read_bytes) + { + /* write failed. */ + rt_kprintf("Write file data failed, errno=%d\n", length); + break; + } } } while (read_bytes > 0); @@ -652,7 +653,6 @@ static void copyfile(const char *src, const char *dst) extern int mkdir(const char *path, mode_t mode); static void copydir(const char * src, const char * dst) { - struct dfs_fd fd; struct dirent dirent; struct stat stat; int length; diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c index c1a6a5beb6..c379d5c969 100644 --- a/components/dfs/src/dfs_posix.c +++ b/components/dfs/src/dfs_posix.c @@ -230,6 +230,7 @@ off_t lseek(int fd, off_t offset, int whence) break; default: + fd_put(d); rt_set_errno(-DFS_STATUS_EINVAL); return -1; @@ -237,6 +238,7 @@ off_t lseek(int fd, off_t offset, int whence) if (offset < 0) { + fd_put(d); rt_set_errno(-DFS_STATUS_EINVAL); return -1; @@ -375,6 +377,36 @@ int fstat(int fildes, struct stat *buf) RTM_EXPORT(fstat); /** + * this function is a POSIX compliant version, which shall request that all data + * for the open file descriptor named by fildes is to be transferred to the storage + * device associated with the file described by fildes. + * + * @param fildes the file description + * + * @return 0 on successful completion. Otherwise, -1 shall be returned and errno + * set to indicate the error. + */ +int fsync(int fildes) +{ + int ret; + struct dfs_fd *d; + + /* get the fd */ + d = fd_get(fildes); + if (d == RT_NULL) + { + rt_set_errno(-DFS_STATUS_EBADF); + return -1; + } + + ret = dfs_file_flush(d); + + fd_put(d); + return ret; +} +RTM_EXPORT(fsync); + +/** * this function is a POSIX compliant version, which will return the * information about a mounted file system. * @@ -428,6 +460,7 @@ int mkdir(const char *path, mode_t mode) if (result < 0) { fd_put(d); + fd_put(d); rt_set_errno(result); return -1; @@ -435,6 +468,7 @@ int mkdir(const char *path, mode_t mode) dfs_file_close(d); fd_put(d); + fd_put(d); return 0; } diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index bcdd4db519..4e29b041a5 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -279,7 +279,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag) serial->config.bufsz); RT_ASSERT(rx_fifo != RT_NULL); rx_fifo->buffer = (rt_uint8_t*) (rx_fifo + 1); - rt_memset(rx_fifo->buffer, 0, RT_SERIAL_RB_BUFSZ); + rt_memset(rx_fifo->buffer, 0, serial->config.bufsz); rx_fifo->put_index = 0; rx_fifo->get_index = 0; @@ -302,6 +302,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag) tx_dma = (struct rt_serial_tx_dma*) rt_malloc (sizeof(struct rt_serial_tx_dma)); RT_ASSERT(tx_dma != RT_NULL); + tx_dma->activated = RT_FALSE; rt_data_queue_init(&(tx_dma->data_queue), 8, 4, RT_NULL); serial->serial_tx = tx_dma; @@ -519,12 +520,10 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event) rt_base_t level; struct rt_serial_rx_fifo* rx_fifo; + /* interrupt mode receive */ rx_fifo = (struct rt_serial_rx_fifo*)serial->serial_rx; RT_ASSERT(rx_fifo != RT_NULL); - - /* interrupt mode receive */ - RT_ASSERT(serial->parent.open_flag & RT_DEVICE_FLAG_INT_RX); - + while (1) { ch = serial->ops->getc(serial); diff --git a/components/drivers/src/completion.c b/components/drivers/src/completion.c index 48afc2ee34..ef0b2911a7 100644 --- a/components/drivers/src/completion.c +++ b/components/drivers/src/completion.c @@ -39,6 +39,7 @@ void rt_completion_init(struct rt_completion *completion) rt_list_init(&completion->suspended_list); rt_hw_interrupt_enable(level); } +RTM_EXPORT(rt_completion_init); rt_err_t rt_completion_wait(struct rt_completion *completion, rt_int32_t timeout) @@ -105,6 +106,7 @@ __exit: return result; } +RTM_EXPORT(rt_completion_wait); void rt_completion_done(struct rt_completion *completion) { @@ -139,3 +141,5 @@ void rt_completion_done(struct rt_completion *completion) rt_hw_interrupt_enable(level); } } +RTM_EXPORT(rt_completion_done); + diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 02cbeea196..6d747b40db 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -253,6 +253,7 @@ int system(const char *command) { return msh_exec_module(command, rt_strlen(command)); } +RTM_EXPORT(system); #endif static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 450733353d..8962a7333f 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -123,6 +123,10 @@ void finsh_set_device(const char *device_name) rt_device_set_rx_indicate(shell->device, RT_NULL); } + /* clear line buffer before switch to new device */ + memset(shell->line, 0, sizeof(shell->line)); + shell->line_curpos = shell->line_position = 0; + shell->device = dev; rt_device_set_rx_indicate(dev, finsh_rx_ind); } diff --git a/components/finsh/shell.h b/components/finsh/shell.h index 92fa4bccb2..751590366a 100644 --- a/components/finsh/shell.h +++ b/components/finsh/shell.h @@ -50,7 +50,9 @@ #ifndef FINSH_THREAD_STACK_SIZE #define FINSH_THREAD_STACK_SIZE 2048 #endif +#ifndef FINSH_CMD_SIZE #define FINSH_CMD_SIZE 80 +#endif #define FINSH_OPTION_ECHO 0x01 #if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)) diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h index 0633494d1a..88786c280c 100644 --- a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h +++ b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h @@ -103,5 +103,9 @@ void sys_arch_assert(const char* file, int line); #include "string.h" +#define SYS_ARCH_DECL_PROTECT(level) +#define SYS_ARCH_PROTECT(level) rt_enter_critical() +#define SYS_ARCH_UNPROTECT(level) rt_exit_critical() + #endif /* __ARCH_CC_H__ */ diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c index 287c861f04..d3a69f9ac3 100644 --- a/components/net/lwip-1.4.1/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c @@ -695,3 +695,17 @@ RTM_EXPORT(dhcp_stop); #include <lwip/netifapi.h> RTM_EXPORT(netifapi_netif_set_addr); #endif + +#if LWIP_NETIF_LINK_CALLBACK +RTM_EXPORT(netif_set_link_callback); +#endif + +#if LWIP_NETIF_STATUS_CALLBACK +RTM_EXPORT(netif_set_status_callback); +#endif + +RTM_EXPORT(netif_find); +RTM_EXPORT(netif_set_addr); +RTM_EXPORT(netif_set_ipaddr); +RTM_EXPORT(netif_set_gw); +RTM_EXPORT(netif_set_netmask); diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index ab7743290a..2e0ef2f8bd 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -67,6 +67,12 @@ #define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL) #define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL) +#ifndef RT_LWIP_ETHTHREAD_PRIORITY +#define RT_ETHERNETIF_THREAD_PREORITY 0x90 +#else +#define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY +#endif + #ifndef LWIP_NO_TX_THREAD /** * Tx message structure for Ethernet interface @@ -79,7 +85,7 @@ struct eth_tx_msg static struct rt_mailbox eth_tx_thread_mb; static struct rt_thread eth_tx_thread; -#ifndef RT_LWIP_ETHTHREAD_PRIORITY +#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE static char eth_tx_thread_mb_pool[32 * 4]; static char eth_tx_thread_stack[512]; #else @@ -91,12 +97,10 @@ static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; #ifndef LWIP_NO_RX_THREAD static struct rt_mailbox eth_rx_thread_mb; static struct rt_thread eth_rx_thread; -#ifndef RT_LWIP_ETHTHREAD_PRIORITY -#define RT_ETHERNETIF_THREAD_PREORITY 0x90 +#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE static char eth_rx_thread_mb_pool[48 * 4]; static char eth_rx_thread_stack[1024]; #else -#define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; #endif @@ -318,7 +322,7 @@ static void eth_tx_thread_entry(void* parameter) /* call driver's interface */ if (enetif->eth_tx(&(enetif->parent), msg->buf) != RT_EOK) { - rt_kprintf("transmit eth packet failed\n"); + /* transmit eth packet failed */ } } @@ -397,7 +401,7 @@ int eth_system_device_init(void) result = rt_thread_init(ð_rx_thread, "erx", eth_rx_thread_entry, RT_NULL, ð_rx_thread_stack[0], sizeof(eth_rx_thread_stack), - RT_LWIP_ETHTHREAD_PRIORITY, 16); + RT_ETHERNETIF_THREAD_PREORITY, 16); RT_ASSERT(result == RT_EOK); result = rt_thread_startup(ð_rx_thread); RT_ASSERT(result == RT_EOK); |
