Merge branch 'feature/update_vfs_for_fatfs' into 'master'

feat(vfs): update vfs for ESP8266

See merge request sdk/ESP8266_RTOS_SDK!1317
This commit is contained in:
Dong Heng
2020-07-23 11:33:15 +08:00
32 changed files with 2887 additions and 551 deletions

View File

@@ -21,28 +21,35 @@
#include "esp_vfs.h"
#include "esp_vfs_dev.h"
#include "esp_attr.h"
#include "esp8266/uart_struct.h"
#include "lwip/sockets.h"
#include "sdkconfig.h"
#include "lwip/sys.h"
_Static_assert(MAX_FDS >= CONFIG_LWIP_MAX_SOCKETS, "MAX_FDS < CONFIG_LWIP_MAX_SOCKETS");
static void lwip_stop_socket_select()
static void lwip_stop_socket_select(void *sem)
{
sys_sem_signal(sys_thread_sem_get()); //socket_select will return
sys_sem_signal(sem); //socket_select will return
}
static void lwip_stop_socket_select_isr(BaseType_t *woken)
static void lwip_stop_socket_select_isr(void *sem, BaseType_t *woken)
{
if (sys_sem_signal_isr(sys_thread_sem_get()) && woken) {
if (sys_sem_signal_isr(sem) && woken) {
*woken = pdTRUE;
}
}
static int lwip_fcntl_r_wrapper(int fd, int cmd, va_list args)
static void *lwip_get_socket_select_semaphore(void)
{
return lwip_fcntl(fd, cmd, va_arg(args, int));
/* Calling this from the same process as select() will ensure that the semaphore won't be allocated from
* ISR (lwip_stop_socket_select_isr).
*/
return (void *) sys_thread_sem_get();
}
static int lwip_fcntl_r_wrapper(int fd, int cmd, int arg)
{
return lwip_fcntl(fd, cmd, arg);
}
static int lwip_ioctl_r_wrapper(int fd, int cmd, va_list args)
@@ -62,6 +69,7 @@ void esp_vfs_lwip_sockets_register(void)
.fcntl = &lwip_fcntl_r_wrapper,
.ioctl = &lwip_ioctl_r_wrapper,
.socket_select = &lwip_select,
.get_socket_select_semaphore = &lwip_get_socket_select_semaphore,
.stop_socket_select = &lwip_stop_socket_select,
.stop_socket_select_isr = &lwip_stop_socket_select_isr,
};