Merge patch from master to prepare release v2.0.2
This commit is contained in:
parent
8483352591
commit
1bebbecd22
|
@ -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 <rtthread.h>
|
||||||
#include "crt.h"
|
#include "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_
|
#ifndef CRT_H_
|
||||||
#define CRT_H_
|
#define CRT_H_
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* File : crt_init.c
|
* File : crt_init.c
|
||||||
* This file is part of Device File System in RT-Thread RTOS
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2005-02-22 Bernard The first version.
|
* 2005-02-22 Bernard The first version.
|
||||||
* 2011-12-08 Bernard Merges rename patch from iamcacy.
|
* 2011-12-08 Bernard Merges rename patch from iamcacy.
|
||||||
|
* 2015-05-27 Bernard Fix the fd clear issue.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dfs.h>
|
#include <dfs.h>
|
||||||
|
@ -97,7 +98,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||||
{
|
{
|
||||||
/* clear fd */
|
/* clear fd */
|
||||||
rt_free(fd->path);
|
rt_free(fd->path);
|
||||||
rt_memset(fd, 0, sizeof(*fd));
|
fd->path = RT_NULL;
|
||||||
|
|
||||||
return -DFS_STATUS_ENOSYS;
|
return -DFS_STATUS_ENOSYS;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +107,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||||
{
|
{
|
||||||
/* clear fd */
|
/* clear fd */
|
||||||
rt_free(fd->path);
|
rt_free(fd->path);
|
||||||
rt_memset(fd, 0, sizeof(*fd));
|
fd->path = RT_NULL;
|
||||||
|
|
||||||
dfs_log(DFS_DEBUG_INFO, ("open failed"));
|
dfs_log(DFS_DEBUG_INFO, ("open failed"));
|
||||||
|
|
||||||
|
@ -143,7 +144,7 @@ int dfs_file_close(struct dfs_fd *fd)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
rt_free(fd->path);
|
rt_free(fd->path);
|
||||||
rt_memset(fd, 0, sizeof(struct dfs_fd));
|
fd->path = RT_NULL;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +166,7 @@ int dfs_file_ioctl(struct dfs_fd *fd, int cmd, void *args)
|
||||||
return -DFS_STATUS_EINVAL;
|
return -DFS_STATUS_EINVAL;
|
||||||
|
|
||||||
fs = fd->fs;
|
fs = fd->fs;
|
||||||
if (fs->ops->ioctl != RT_NULL)
|
if (fs->ops->ioctl != RT_NULL)
|
||||||
return fs->ops->ioctl(fd, cmd, args);
|
return fs->ops->ioctl(fd, cmd, args);
|
||||||
|
|
||||||
return -DFS_STATUS_ENOSYS;
|
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;
|
struct dfs_filesystem *fs;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
if (fd == RT_NULL)
|
if (fd == RT_NULL)
|
||||||
return -DFS_STATUS_EINVAL;
|
return -DFS_STATUS_EINVAL;
|
||||||
|
|
||||||
fs = (struct dfs_filesystem *)fd->fs;
|
fs = (struct dfs_filesystem *)fd->fs;
|
||||||
if (fs->ops->read == RT_NULL)
|
if (fs->ops->read == RT_NULL)
|
||||||
return -DFS_STATUS_ENOSYS;
|
return -DFS_STATUS_ENOSYS;
|
||||||
|
|
||||||
if ((result = fs->ops->read(fd, buf, len)) < 0)
|
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;
|
struct dfs_filesystem *fs;
|
||||||
|
|
||||||
/* parameter check */
|
/* parameter check */
|
||||||
if (fd == RT_NULL || fd->type != FT_DIRECTORY)
|
if (fd == RT_NULL || fd->type != FT_DIRECTORY)
|
||||||
return -DFS_STATUS_EINVAL;
|
return -DFS_STATUS_EINVAL;
|
||||||
|
|
||||||
fs = (struct dfs_filesystem *)fd->fs;
|
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));
|
result = fs->ops->unlink(fs, dfs_subdir(fs->path, fullpath));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result = fs->ops->unlink(fs, fullpath);
|
result = fs->ops->unlink(fs, fullpath);
|
||||||
}
|
}
|
||||||
else result = -DFS_STATUS_ENOSYS;
|
else result = -DFS_STATUS_ENOSYS;
|
||||||
|
|
||||||
|
@ -528,7 +529,7 @@ void ls(const char *pathname)
|
||||||
|
|
||||||
/* build full path for each file */
|
/* build full path for each file */
|
||||||
fullpath = dfs_normalize_path(path, dirent.d_name);
|
fullpath = dfs_normalize_path(path, dirent.d_name);
|
||||||
if (fullpath == RT_NULL)
|
if (fullpath == RT_NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (dfs_file_stat(fullpath, &stat) == 0)
|
if (dfs_file_stat(fullpath, &stat) == 0)
|
||||||
|
@ -555,7 +556,7 @@ void ls(const char *pathname)
|
||||||
{
|
{
|
||||||
rt_kprintf("No such directory\n");
|
rt_kprintf("No such directory\n");
|
||||||
}
|
}
|
||||||
if (pathname == RT_NULL)
|
if (pathname == RT_NULL)
|
||||||
rt_free(path);
|
rt_free(path);
|
||||||
}
|
}
|
||||||
FINSH_FUNCTION_EXPORT(ls, list directory contents);
|
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);
|
read_bytes = dfs_file_read(&src_fd, block_ptr, BUF_SZ);
|
||||||
if (read_bytes > 0)
|
if (read_bytes > 0)
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
length = dfs_file_write(&fd, block_ptr, read_bytes);
|
length = dfs_file_write(&fd, block_ptr, read_bytes);
|
||||||
if (length != read_bytes)
|
if (length != read_bytes)
|
||||||
{
|
{
|
||||||
/* write failed. */
|
/* write failed. */
|
||||||
rt_kprintf("Write file data failed, errno=%d\n", length);
|
rt_kprintf("Write file data failed, errno=%d\n", length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (read_bytes > 0);
|
} 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);
|
extern int mkdir(const char *path, mode_t mode);
|
||||||
static void copydir(const char * src, const char * dst)
|
static void copydir(const char * src, const char * dst)
|
||||||
{
|
{
|
||||||
struct dfs_fd fd;
|
|
||||||
struct dirent dirent;
|
struct dirent dirent;
|
||||||
struct stat stat;
|
struct stat stat;
|
||||||
int length;
|
int length;
|
||||||
|
|
|
@ -230,6 +230,7 @@ off_t lseek(int fd, off_t offset, int whence)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
fd_put(d);
|
||||||
rt_set_errno(-DFS_STATUS_EINVAL);
|
rt_set_errno(-DFS_STATUS_EINVAL);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -237,6 +238,7 @@ off_t lseek(int fd, off_t offset, int whence)
|
||||||
|
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
{
|
{
|
||||||
|
fd_put(d);
|
||||||
rt_set_errno(-DFS_STATUS_EINVAL);
|
rt_set_errno(-DFS_STATUS_EINVAL);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -374,6 +376,36 @@ int fstat(int fildes, struct stat *buf)
|
||||||
}
|
}
|
||||||
RTM_EXPORT(fstat);
|
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
|
* this function is a POSIX compliant version, which will return the
|
||||||
* information about a mounted file system.
|
* information about a mounted file system.
|
||||||
|
@ -427,6 +459,7 @@ int mkdir(const char *path, mode_t mode)
|
||||||
|
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
|
fd_put(d);
|
||||||
fd_put(d);
|
fd_put(d);
|
||||||
rt_set_errno(result);
|
rt_set_errno(result);
|
||||||
|
|
||||||
|
@ -435,6 +468,7 @@ int mkdir(const char *path, mode_t mode)
|
||||||
|
|
||||||
dfs_file_close(d);
|
dfs_file_close(d);
|
||||||
fd_put(d);
|
fd_put(d);
|
||||||
|
fd_put(d);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||||
serial->config.bufsz);
|
serial->config.bufsz);
|
||||||
RT_ASSERT(rx_fifo != RT_NULL);
|
RT_ASSERT(rx_fifo != RT_NULL);
|
||||||
rx_fifo->buffer = (rt_uint8_t*) (rx_fifo + 1);
|
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->put_index = 0;
|
||||||
rx_fifo->get_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));
|
tx_dma = (struct rt_serial_tx_dma*) rt_malloc (sizeof(struct rt_serial_tx_dma));
|
||||||
RT_ASSERT(tx_dma != RT_NULL);
|
RT_ASSERT(tx_dma != RT_NULL);
|
||||||
|
tx_dma->activated = RT_FALSE;
|
||||||
|
|
||||||
rt_data_queue_init(&(tx_dma->data_queue), 8, 4, RT_NULL);
|
rt_data_queue_init(&(tx_dma->data_queue), 8, 4, RT_NULL);
|
||||||
serial->serial_tx = tx_dma;
|
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;
|
rt_base_t level;
|
||||||
struct rt_serial_rx_fifo* rx_fifo;
|
struct rt_serial_rx_fifo* rx_fifo;
|
||||||
|
|
||||||
|
/* interrupt mode receive */
|
||||||
rx_fifo = (struct rt_serial_rx_fifo*)serial->serial_rx;
|
rx_fifo = (struct rt_serial_rx_fifo*)serial->serial_rx;
|
||||||
RT_ASSERT(rx_fifo != RT_NULL);
|
RT_ASSERT(rx_fifo != RT_NULL);
|
||||||
|
|
||||||
/* interrupt mode receive */
|
|
||||||
RT_ASSERT(serial->parent.open_flag & RT_DEVICE_FLAG_INT_RX);
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
ch = serial->ops->getc(serial);
|
ch = serial->ops->getc(serial);
|
||||||
|
|
|
@ -39,6 +39,7 @@ void rt_completion_init(struct rt_completion *completion)
|
||||||
rt_list_init(&completion->suspended_list);
|
rt_list_init(&completion->suspended_list);
|
||||||
rt_hw_interrupt_enable(level);
|
rt_hw_interrupt_enable(level);
|
||||||
}
|
}
|
||||||
|
RTM_EXPORT(rt_completion_init);
|
||||||
|
|
||||||
rt_err_t rt_completion_wait(struct rt_completion *completion,
|
rt_err_t rt_completion_wait(struct rt_completion *completion,
|
||||||
rt_int32_t timeout)
|
rt_int32_t timeout)
|
||||||
|
@ -105,6 +106,7 @@ __exit:
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
RTM_EXPORT(rt_completion_wait);
|
||||||
|
|
||||||
void rt_completion_done(struct rt_completion *completion)
|
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);
|
rt_hw_interrupt_enable(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RTM_EXPORT(rt_completion_done);
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,7 @@ int system(const char *command)
|
||||||
{
|
{
|
||||||
return msh_exec_module(command, rt_strlen(command));
|
return msh_exec_module(command, rt_strlen(command));
|
||||||
}
|
}
|
||||||
|
RTM_EXPORT(system);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp)
|
static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp)
|
||||||
|
|
|
@ -123,6 +123,10 @@ void finsh_set_device(const char *device_name)
|
||||||
rt_device_set_rx_indicate(shell->device, RT_NULL);
|
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;
|
shell->device = dev;
|
||||||
rt_device_set_rx_indicate(dev, finsh_rx_ind);
|
rt_device_set_rx_indicate(dev, finsh_rx_ind);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,9 @@
|
||||||
#ifndef FINSH_THREAD_STACK_SIZE
|
#ifndef FINSH_THREAD_STACK_SIZE
|
||||||
#define FINSH_THREAD_STACK_SIZE 2048
|
#define FINSH_THREAD_STACK_SIZE 2048
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef FINSH_CMD_SIZE
|
||||||
#define FINSH_CMD_SIZE 80
|
#define FINSH_CMD_SIZE 80
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FINSH_OPTION_ECHO 0x01
|
#define FINSH_OPTION_ECHO 0x01
|
||||||
#if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR))
|
#if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR))
|
||||||
|
|
|
@ -103,5 +103,9 @@ void sys_arch_assert(const char* file, int line);
|
||||||
|
|
||||||
#include "string.h"
|
#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__ */
|
#endif /* __ARCH_CC_H__ */
|
||||||
|
|
||||||
|
|
|
@ -695,3 +695,17 @@ RTM_EXPORT(dhcp_stop);
|
||||||
#include <lwip/netifapi.h>
|
#include <lwip/netifapi.h>
|
||||||
RTM_EXPORT(netifapi_netif_set_addr);
|
RTM_EXPORT(netifapi_netif_set_addr);
|
||||||
#endif
|
#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);
|
||||||
|
|
|
@ -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_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)
|
#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
|
#ifndef LWIP_NO_TX_THREAD
|
||||||
/**
|
/**
|
||||||
* Tx message structure for Ethernet interface
|
* 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_mailbox eth_tx_thread_mb;
|
||||||
static struct rt_thread eth_tx_thread;
|
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_mb_pool[32 * 4];
|
||||||
static char eth_tx_thread_stack[512];
|
static char eth_tx_thread_stack[512];
|
||||||
#else
|
#else
|
||||||
|
@ -91,12 +97,10 @@ static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
|
||||||
#ifndef LWIP_NO_RX_THREAD
|
#ifndef LWIP_NO_RX_THREAD
|
||||||
static struct rt_mailbox eth_rx_thread_mb;
|
static struct rt_mailbox eth_rx_thread_mb;
|
||||||
static struct rt_thread eth_rx_thread;
|
static struct rt_thread eth_rx_thread;
|
||||||
#ifndef RT_LWIP_ETHTHREAD_PRIORITY
|
#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE
|
||||||
#define RT_ETHERNETIF_THREAD_PREORITY 0x90
|
|
||||||
static char eth_rx_thread_mb_pool[48 * 4];
|
static char eth_rx_thread_mb_pool[48 * 4];
|
||||||
static char eth_rx_thread_stack[1024];
|
static char eth_rx_thread_stack[1024];
|
||||||
#else
|
#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_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4];
|
||||||
static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
|
static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
|
||||||
#endif
|
#endif
|
||||||
|
@ -318,7 +322,7 @@ static void eth_tx_thread_entry(void* parameter)
|
||||||
/* call driver's interface */
|
/* call driver's interface */
|
||||||
if (enetif->eth_tx(&(enetif->parent), msg->buf) != RT_EOK)
|
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,
|
result = rt_thread_init(ð_rx_thread, "erx", eth_rx_thread_entry, RT_NULL,
|
||||||
ð_rx_thread_stack[0], sizeof(eth_rx_thread_stack),
|
ð_rx_thread_stack[0], sizeof(eth_rx_thread_stack),
|
||||||
RT_LWIP_ETHTHREAD_PRIORITY, 16);
|
RT_ETHERNETIF_THREAD_PREORITY, 16);
|
||||||
RT_ASSERT(result == RT_EOK);
|
RT_ASSERT(result == RT_EOK);
|
||||||
result = rt_thread_startup(ð_rx_thread);
|
result = rt_thread_startup(ð_rx_thread);
|
||||||
RT_ASSERT(result == RT_EOK);
|
RT_ASSERT(result == RT_EOK);
|
||||||
|
|
|
@ -50,7 +50,7 @@ extern "C" {
|
||||||
/* RT-Thread version information */
|
/* RT-Thread version information */
|
||||||
#define RT_VERSION 2L /**< major version number */
|
#define RT_VERSION 2L /**< major version number */
|
||||||
#define RT_SUBVERSION 0L /**< minor version number */
|
#define RT_SUBVERSION 0L /**< minor version number */
|
||||||
#define RT_REVISION 1L /**< revise version number */
|
#define RT_REVISION 2L /**< revise version number */
|
||||||
|
|
||||||
/* RT-Thread version */
|
/* RT-Thread version */
|
||||||
#define RTTHREAD_VERSION ((RT_VERSION * 10000) + \
|
#define RTTHREAD_VERSION ((RT_VERSION * 10000) + \
|
||||||
|
|
|
@ -183,13 +183,11 @@ rt_hw_context_switch_to PROC
|
||||||
LDR r0, =NVIC_INT_CTRL
|
LDR r0, =NVIC_INT_CTRL
|
||||||
LDR r1, =NVIC_PENDSVSET
|
LDR r1, =NVIC_PENDSVSET
|
||||||
STR r1, [r0]
|
STR r1, [r0]
|
||||||
NOP
|
|
||||||
|
|
||||||
; restore MSP
|
; restore MSP
|
||||||
LDR r0, =SCB_VTOR
|
LDR r0, =SCB_VTOR
|
||||||
LDR r0, [r0]
|
LDR r0, [r0]
|
||||||
LDR r0, [r0]
|
LDR r0, [r0]
|
||||||
NOP
|
|
||||||
MSR msp, r0
|
MSR msp, r0
|
||||||
|
|
||||||
; enable interrupts at processor level
|
; enable interrupts at processor level
|
||||||
|
@ -216,4 +214,6 @@ HardFault_Handler PROC
|
||||||
POP {pc}
|
POP {pc}
|
||||||
ENDP
|
ENDP
|
||||||
|
|
||||||
|
ALIGN 4
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
|
@ -177,7 +177,6 @@ rt_hw_context_switch_to PROC
|
||||||
rt_hw_interrupt_thread_switch PROC
|
rt_hw_interrupt_thread_switch PROC
|
||||||
EXPORT rt_hw_interrupt_thread_switch
|
EXPORT rt_hw_interrupt_thread_switch
|
||||||
BX lr
|
BX lr
|
||||||
NOP
|
|
||||||
ENDP
|
ENDP
|
||||||
|
|
||||||
IMPORT rt_hw_hard_fault_exception
|
IMPORT rt_hw_hard_fault_exception
|
||||||
|
@ -203,4 +202,6 @@ HardFault_Handler PROC
|
||||||
BX lr
|
BX lr
|
||||||
ENDP
|
ENDP
|
||||||
|
|
||||||
|
ALIGN 4
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
|
@ -205,7 +205,6 @@ rt_hw_context_switch_to PROC
|
||||||
LDR r0, =SCB_VTOR
|
LDR r0, =SCB_VTOR
|
||||||
LDR r0, [r0]
|
LDR r0, [r0]
|
||||||
LDR r0, [r0]
|
LDR r0, [r0]
|
||||||
NOP
|
|
||||||
MSR msp, r0
|
MSR msp, r0
|
||||||
|
|
||||||
; enable interrupts at processor level
|
; enable interrupts at processor level
|
||||||
|
@ -218,7 +217,6 @@ rt_hw_context_switch_to PROC
|
||||||
rt_hw_interrupt_thread_switch PROC
|
rt_hw_interrupt_thread_switch PROC
|
||||||
EXPORT rt_hw_interrupt_thread_switch
|
EXPORT rt_hw_interrupt_thread_switch
|
||||||
BX lr
|
BX lr
|
||||||
NOP
|
|
||||||
ENDP
|
ENDP
|
||||||
|
|
||||||
IMPORT rt_hw_hard_fault_exception
|
IMPORT rt_hw_hard_fault_exception
|
||||||
|
@ -235,4 +233,6 @@ HardFault_Handler PROC
|
||||||
BX lr
|
BX lr
|
||||||
ENDP
|
ENDP
|
||||||
|
|
||||||
|
ALIGN 4
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
|
@ -1072,8 +1072,8 @@ rt_device_t rt_console_set_device(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set new console device */
|
/* set new console device */
|
||||||
|
rt_device_open(new, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_STREAM);
|
||||||
_console_device = new;
|
_console_device = new;
|
||||||
rt_device_open(_console_device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_STREAM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return old;
|
return old;
|
||||||
|
|
|
@ -304,6 +304,7 @@ void *rt_malloc(rt_size_t size)
|
||||||
|
|
||||||
/* create mem2 struct */
|
/* create mem2 struct */
|
||||||
mem2 = (struct heap_mem *)&heap_ptr[ptr2];
|
mem2 = (struct heap_mem *)&heap_ptr[ptr2];
|
||||||
|
mem2->magic = HEAP_MAGIC;
|
||||||
mem2->used = 0;
|
mem2->used = 0;
|
||||||
mem2->next = mem->next;
|
mem2->next = mem->next;
|
||||||
mem2->prev = ptr;
|
mem2->prev = ptr;
|
||||||
|
@ -540,7 +541,7 @@ void rt_free(void *rmem)
|
||||||
RT_ASSERT(mem->magic == HEAP_MAGIC);
|
RT_ASSERT(mem->magic == HEAP_MAGIC);
|
||||||
/* ... and is now unused. */
|
/* ... and is now unused. */
|
||||||
mem->used = 0;
|
mem->used = 0;
|
||||||
mem->magic = 0;
|
mem->magic = HEAP_MAGIC;
|
||||||
|
|
||||||
if (mem < lfree)
|
if (mem < lfree)
|
||||||
{
|
{
|
||||||
|
|
|
@ -401,8 +401,8 @@ rt_bool_t rt_object_is_systemobject(rt_object_t object)
|
||||||
*/
|
*/
|
||||||
rt_object_t rt_object_find(const char *name, rt_uint8_t type)
|
rt_object_t rt_object_find(const char *name, rt_uint8_t type)
|
||||||
{
|
{
|
||||||
struct rt_object *object;
|
struct rt_object *object = RT_NULL;
|
||||||
struct rt_list_node *node;
|
struct rt_list_node *node = RT_NULL;
|
||||||
struct rt_object_information *information = RT_NULL;
|
struct rt_object_information *information = RT_NULL;
|
||||||
|
|
||||||
/* parameter check */
|
/* parameter check */
|
||||||
|
|
|
@ -371,6 +371,7 @@ void rt_enter_critical(void)
|
||||||
/* enable interrupt */
|
/* enable interrupt */
|
||||||
rt_hw_interrupt_enable(level);
|
rt_hw_interrupt_enable(level);
|
||||||
}
|
}
|
||||||
|
RTM_EXPORT(rt_enter_critical);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will unlock the thread scheduler.
|
* This function will unlock the thread scheduler.
|
||||||
|
@ -398,6 +399,7 @@ void rt_exit_critical(void)
|
||||||
rt_hw_interrupt_enable(level);
|
rt_hw_interrupt_enable(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RTM_EXPORT(rt_exit_critical);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the scheduler lock level
|
* Get the scheduler lock level
|
||||||
|
@ -408,5 +410,6 @@ rt_uint16_t rt_critical_level(void)
|
||||||
{
|
{
|
||||||
return rt_scheduler_lock_nest;
|
return rt_scheduler_lock_nest;
|
||||||
}
|
}
|
||||||
|
RTM_EXPORT(rt_critical_level);
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,21 @@ def MDK4AddGroupForFN(ProjectFiles, parent, name, filename, project_path):
|
||||||
file = SubElement(files, 'File')
|
file = SubElement(files, 'File')
|
||||||
file_name = SubElement(file, 'FileName')
|
file_name = SubElement(file, 'FileName')
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
if ProjectFiles.count(name):
|
|
||||||
|
if name.find('.cpp') != -1:
|
||||||
|
obj_name = name.replace('.cpp', '.o')
|
||||||
|
elif name.find('.c') != -1:
|
||||||
|
obj_name = name.replace('.c', '.o')
|
||||||
|
elif name.find('.s') != -1:
|
||||||
|
obj_name = name.replace('.s', '.o')
|
||||||
|
elif name.find('.S') != -1:
|
||||||
|
obj_name = name.replace('.s', '.o')
|
||||||
|
else:
|
||||||
|
obj_name = name
|
||||||
|
|
||||||
|
if ProjectFiles.count(obj_name):
|
||||||
name = basename + '_' + name
|
name = basename + '_' + name
|
||||||
ProjectFiles.append(name)
|
ProjectFiles.append(obj_name)
|
||||||
file_name.text = name.decode(fs_encoding)
|
file_name.text = name.decode(fs_encoding)
|
||||||
file_type = SubElement(file, 'FileType')
|
file_type = SubElement(file, 'FileType')
|
||||||
file_type.text = '%d' % _get_filetype(name)
|
file_type.text = '%d' % _get_filetype(name)
|
||||||
|
@ -98,9 +110,19 @@ def MDK4AddGroup(ProjectFiles, parent, name, files, project_path):
|
||||||
file = SubElement(files, 'File')
|
file = SubElement(files, 'File')
|
||||||
file_name = SubElement(file, 'FileName')
|
file_name = SubElement(file, 'FileName')
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
if ProjectFiles.count(name):
|
|
||||||
|
if name.find('.cpp') != -1:
|
||||||
|
obj_name = name.replace('.cpp', '.o')
|
||||||
|
elif name.find('.c') != -1:
|
||||||
|
obj_name = name.replace('.c', '.o')
|
||||||
|
elif name.find('.s') != -1:
|
||||||
|
obj_name = name.replace('.s', '.o')
|
||||||
|
elif name.find('.S') != -1:
|
||||||
|
obj_name = name.replace('.s', '.o')
|
||||||
|
|
||||||
|
if ProjectFiles.count(obj_name):
|
||||||
name = basename + '_' + name
|
name = basename + '_' + name
|
||||||
ProjectFiles.append(name)
|
ProjectFiles.append(obj_name)
|
||||||
file_name.text = name.decode(fs_encoding)
|
file_name.text = name.decode(fs_encoding)
|
||||||
file_type = SubElement(file, 'FileType')
|
file_type = SubElement(file, 'FileType')
|
||||||
file_type.text = '%d' % _get_filetype(name)
|
file_type.text = '%d' % _get_filetype(name)
|
||||||
|
@ -201,9 +223,19 @@ def MDK5AddGroupForFN(ProjectFiles, parent, name, filename, project_path):
|
||||||
file = SubElement(files, 'File')
|
file = SubElement(files, 'File')
|
||||||
file_name = SubElement(file, 'FileName')
|
file_name = SubElement(file, 'FileName')
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
if ProjectFiles.count(name):
|
|
||||||
|
if name.find('.cpp') != -1:
|
||||||
|
obj_name = name.replace('.cpp', '.o')
|
||||||
|
elif name.find('.c') != -1:
|
||||||
|
obj_name = name.replace('.c', '.o')
|
||||||
|
elif name.find('.s') != -1:
|
||||||
|
obj_name = name.replace('.s', '.o')
|
||||||
|
elif name.find('.S') != -1:
|
||||||
|
obj_name = name.replace('.s', '.o')
|
||||||
|
|
||||||
|
if ProjectFiles.count(obj_name):
|
||||||
name = basename + '_' + name
|
name = basename + '_' + name
|
||||||
ProjectFiles.append(name)
|
ProjectFiles.append(obj_name)
|
||||||
file_name.text = name.decode(fs_encoding)
|
file_name.text = name.decode(fs_encoding)
|
||||||
file_type = SubElement(file, 'FileType')
|
file_type = SubElement(file, 'FileType')
|
||||||
file_type.text = '%d' % _get_filetype(name)
|
file_type.text = '%d' % _get_filetype(name)
|
||||||
|
@ -233,9 +265,21 @@ def MDK5AddGroup(ProjectFiles, parent, name, files, project_path):
|
||||||
file = SubElement(files, 'File')
|
file = SubElement(files, 'File')
|
||||||
file_name = SubElement(file, 'FileName')
|
file_name = SubElement(file, 'FileName')
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
if ProjectFiles.count(name):
|
|
||||||
|
if name.find('.cpp') != -1:
|
||||||
|
obj_name = name.replace('.cpp', '.o')
|
||||||
|
elif name.find('.c') != -1:
|
||||||
|
obj_name = name.replace('.c', '.o')
|
||||||
|
elif name.find('.s') != -1:
|
||||||
|
obj_name = name.replace('.s', '.o')
|
||||||
|
elif name.find('.S') != -1:
|
||||||
|
obj_name = name.replace('.s', '.o')
|
||||||
|
else:
|
||||||
|
obj_name = name
|
||||||
|
|
||||||
|
if ProjectFiles.count(obj_name):
|
||||||
name = basename + '_' + name
|
name = basename + '_' + name
|
||||||
ProjectFiles.append(name)
|
ProjectFiles.append(obj_name)
|
||||||
file_name.text = name.decode(fs_encoding)
|
file_name.text = name.decode(fs_encoding)
|
||||||
file_type = SubElement(file, 'FileType')
|
file_type = SubElement(file, 'FileType')
|
||||||
file_type.text = '%d' % _get_filetype(name)
|
file_type.text = '%d' % _get_filetype(name)
|
||||||
|
@ -266,6 +310,7 @@ def MDK5Project(target, script):
|
||||||
groups = tree.find('Targets/Target/Groups')
|
groups = tree.find('Targets/Target/Groups')
|
||||||
if groups is None:
|
if groups is None:
|
||||||
groups = SubElement(tree.find('Targets/Target'), 'Groups')
|
groups = SubElement(tree.find('Targets/Target'), 'Groups')
|
||||||
|
groups.clear() # clean old groups
|
||||||
for group in script:
|
for group in script:
|
||||||
group_xml = MDK4AddGroup(ProjectFiles, groups, group['name'], group['src'], project_path)
|
group_xml = MDK4AddGroup(ProjectFiles, groups, group['name'], group['src'], project_path)
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ SConscript_com = '''# RT-Thread building script for component
|
||||||
from building import *
|
from building import *
|
||||||
|
|
||||||
cwd = GetCurrentDir()
|
cwd = GetCurrentDir()
|
||||||
src = Glob('*.c')
|
src = Glob('*.c') + Glob('*.cpp')
|
||||||
CPPPATH = [cwd]
|
CPPPATH = [cwd]
|
||||||
|
|
||||||
group = DefineGroup('COMPONENT_NAME', src, depend = [''], CPPPATH = CPPPATH)
|
group = DefineGroup('COMPONENT_NAME', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
Loading…
Reference in New Issue