mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-04 22:36:32 +02:00
IDF release/v4.0 08219f3cf
This commit is contained in:
@ -66,6 +66,16 @@ extern "C" {
|
||||
*/
|
||||
typedef int esp_vfs_id_t;
|
||||
|
||||
/**
|
||||
* @brief VFS semaphore type for select()
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool is_sem_local; /*!< type of "sem" is SemaphoreHandle_t when true, defined by socket driver otherwise */
|
||||
void *sem; /*!< semaphore instance */
|
||||
} esp_vfs_select_sem_t;
|
||||
|
||||
/**
|
||||
* @brief VFS definition structure
|
||||
*
|
||||
@ -102,6 +112,14 @@ typedef struct
|
||||
ssize_t (*read_p)(void* ctx, int fd, void * dst, size_t size);
|
||||
ssize_t (*read)(int fd, void * dst, size_t size);
|
||||
};
|
||||
union {
|
||||
ssize_t (*pread_p)(void *ctx, int fd, void * dst, size_t size, off_t offset);
|
||||
ssize_t (*pread)(int fd, void * dst, size_t size, off_t offset);
|
||||
};
|
||||
union {
|
||||
ssize_t (*pwrite_p)(void *ctx, int fd, const void *src, size_t size, off_t offset);
|
||||
ssize_t (*pwrite)(int fd, const void *src, size_t size, off_t offset);
|
||||
};
|
||||
union {
|
||||
int (*open_p)(void* ctx, const char * path, int flags, int mode);
|
||||
int (*open)(const char * path, int flags, int mode);
|
||||
@ -163,8 +181,8 @@ typedef struct
|
||||
int (*rmdir)(const char* name);
|
||||
};
|
||||
union {
|
||||
int (*fcntl_p)(void* ctx, int fd, int cmd, va_list args);
|
||||
int (*fcntl)(int fd, int cmd, va_list args);
|
||||
int (*fcntl_p)(void* ctx, int fd, int cmd, int arg);
|
||||
int (*fcntl)(int fd, int cmd, int arg);
|
||||
};
|
||||
union {
|
||||
int (*ioctl_p)(void* ctx, int fd, int cmd, va_list args);
|
||||
@ -186,7 +204,7 @@ typedef struct
|
||||
int (*utime_p)(void* ctx, const char *path, const struct utimbuf *times);
|
||||
int (*utime)(const char *path, const struct utimbuf *times);
|
||||
};
|
||||
#ifdef CONFIG_SUPPORT_TERMIOS
|
||||
#ifdef CONFIG_VFS_SUPPORT_TERMIOS
|
||||
union {
|
||||
int (*tcsetattr_p)(void *ctx, int fd, int optional_actions, const struct termios *p);
|
||||
int (*tcsetattr)(int fd, int optional_actions, const struct termios *p);
|
||||
@ -215,20 +233,20 @@ typedef struct
|
||||
int (*tcsendbreak_p)(void *ctx, int fd, int duration);
|
||||
int (*tcsendbreak)(int fd, int duration);
|
||||
};
|
||||
#endif // CONFIG_SUPPORT_TERMIOS
|
||||
#endif // CONFIG_VFS_SUPPORT_TERMIOS
|
||||
|
||||
/** start_select is called for setting up synchronous I/O multiplexing of the desired file descriptors in the given VFS */
|
||||
esp_err_t (*start_select)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, SemaphoreHandle_t *signal_sem);
|
||||
esp_err_t (*start_select)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, esp_vfs_select_sem_t sem, void **end_select_args);
|
||||
/** socket select function for socket FDs with the functionality of POSIX select(); this should be set only for the socket VFS */
|
||||
int (*socket_select)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout);
|
||||
/** called by VFS to interrupt the socket_select call when select is activated from a non-socket VFS driver; set only for the socket driver */
|
||||
void (*stop_socket_select)();
|
||||
void (*stop_socket_select)(void *sem);
|
||||
/** stop_socket_select which can be called from ISR; set only for the socket driver */
|
||||
void (*stop_socket_select_isr)(BaseType_t *woken);
|
||||
void (*stop_socket_select_isr)(void *sem, BaseType_t *woken);
|
||||
/** end_select is called to stop the I/O multiplexing and deinitialize the environment created by start_select for the given VFS */
|
||||
void* (*get_socket_select_semaphore)();
|
||||
/** get_socket_select_semaphore returns semaphore allocated in the socket driver; set only for the socket driver */
|
||||
void (*end_select)();
|
||||
esp_err_t (*end_select)(void *end_select_args);
|
||||
} esp_vfs_t;
|
||||
|
||||
|
||||
@ -373,9 +391,9 @@ int esp_vfs_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds
|
||||
* This function is called when the VFS driver detects a read/write/error
|
||||
* condition as it was requested by the previous call to start_select.
|
||||
*
|
||||
* @param signal_sem semaphore handle which was passed to the driver by the start_select call
|
||||
* @param sem semaphore structure which was passed to the driver by the start_select call
|
||||
*/
|
||||
void esp_vfs_select_triggered(SemaphoreHandle_t *signal_sem);
|
||||
void esp_vfs_select_triggered(esp_vfs_select_sem_t sem);
|
||||
|
||||
/**
|
||||
* @brief Notification from a VFS driver about a read/write/error condition (ISR version)
|
||||
@ -383,10 +401,10 @@ void esp_vfs_select_triggered(SemaphoreHandle_t *signal_sem);
|
||||
* This function is called when the VFS driver detects a read/write/error
|
||||
* condition as it was requested by the previous call to start_select.
|
||||
*
|
||||
* @param signal_sem semaphore handle which was passed to the driver by the start_select call
|
||||
* @param sem semaphore structure which was passed to the driver by the start_select call
|
||||
* @param woken is set to pdTRUE if the function wakes up a task with higher priority
|
||||
*/
|
||||
void esp_vfs_select_triggered_isr(SemaphoreHandle_t *signal_sem, BaseType_t *woken);
|
||||
void esp_vfs_select_triggered_isr(esp_vfs_select_sem_t sem, BaseType_t *woken);
|
||||
|
||||
/**
|
||||
* @brief Implements the VFS layer for synchronous I/O multiplexing by poll()
|
||||
@ -404,6 +422,35 @@ void esp_vfs_select_triggered_isr(SemaphoreHandle_t *signal_sem, BaseType_t *wok
|
||||
*/
|
||||
int esp_vfs_poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Implements the VFS layer of POSIX pread()
|
||||
*
|
||||
* @param fd File descriptor used for read
|
||||
* @param dst Pointer to the buffer where the output will be written
|
||||
* @param size Number of bytes to be read
|
||||
* @param offset Starting offset of the read
|
||||
*
|
||||
* @return A positive return value indicates the number of bytes read. -1 is return on failure and errno is
|
||||
* set accordingly.
|
||||
*/
|
||||
ssize_t esp_vfs_pread(int fd, void *dst, size_t size, off_t offset);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Implements the VFS layer of POSIX pwrite()
|
||||
*
|
||||
* @param fd File descriptor used for write
|
||||
* @param src Pointer to the buffer from where the output will be read
|
||||
* @param size Number of bytes to write
|
||||
* @param offset Starting offset of the write
|
||||
*
|
||||
* @return A positive return value indicates the number of bytes written. -1 is return on failure and errno is
|
||||
* set accordingly.
|
||||
*/
|
||||
ssize_t esp_vfs_pwrite(int fd, const void *src, size_t size, off_t offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
46
tools/sdk/include/vfs/esp_vfs_semihost.h
Normal file
46
tools/sdk/include/vfs/esp_vfs_semihost.h
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_vfs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief add virtual filesystem semihosting driver
|
||||
*
|
||||
* @param base_path VFS path to mount host directory
|
||||
* @param host_path host path to mount; if NULL default dirctory will be used (see OpenOCD configuration)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if esp_vfs_semihost_register was already called for specified VFS path
|
||||
* - ESP_ERR_NO_MEM if there are no slots to register new mount point
|
||||
*/
|
||||
esp_err_t esp_vfs_semihost_register(const char* base_path, const char* host_path);
|
||||
|
||||
/**
|
||||
* @brief Un-register semihosting driver from VFS
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if semihosting driver is not registered in VFS at that path
|
||||
*/
|
||||
esp_err_t esp_vfs_semihost_unregister(const char* base_path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user