agileRTOS (zrtos)  Version 0.8.0 (ghostbuster)
vfs_notify.h File Reference
#include <zrtos/bitfield.h>
#include <zrtos/vfs_fd.h>
Include dependency graph for vfs_notify.h:

Go to the source code of this file.

Data Structures

struct  _zrtos_vfs_notify_entry_t
 
struct  _zrtos_vfs_notify_t
 

Typedefs

typedef void(* zrtos_vfs_notify_callback_t) (struct _zrtos_vfs_notify_t *thiz, zrtos_vfs_fd_t fd, zrtos_vfs_notify_event_type_t event_type)
 
typedef struct _zrtos_vfs_notify_entry_t zrtos_vfs_notify_entry_t
 
typedef struct _zrtos_vfs_notify_t zrtos_vfs_notify_t
 

Enumerations

enum  zrtos_vfs_notify_event_type_t {
  ZRTOS_VFS_NOTIFY_EVENT_TYPE__READ,
  ZRTOS_VFS_NOTIFY_EVENT_TYPE__WRITE
}
 

Functions

bool zrtos_vfs_notify__init (zrtos_vfs_notify_t *thiz)
 
void zrtos_vfs_notify__add (zrtos_vfs_notify_t *thiz, zrtos_vfs_fd_t fd, zrtos_vfs_notify_callback_t callback)
 
void zrtos_vfs_notify__remove (zrtos_vfs_notify_t *thiz, zrtos_vfs_fd_t fd)
 
void zrtos_vfs_notify__start (zrtos_vfs_notify_t *thiz)
 
void zrtos_vfs_notify__stop (zrtos_vfs_notify_t *thiz)
 

Typedef Documentation

◆ zrtos_vfs_notify_callback_t

typedef void(* zrtos_vfs_notify_callback_t) (struct _zrtos_vfs_notify_t *thiz,zrtos_vfs_fd_t fd,zrtos_vfs_notify_event_type_t event_type)

Definition at line 24 of file vfs_notify.h.

◆ zrtos_vfs_notify_entry_t

◆ zrtos_vfs_notify_t

Enumeration Type Documentation

◆ zrtos_vfs_notify_event_type_t

Enumerator
ZRTOS_VFS_NOTIFY_EVENT_TYPE__READ 
ZRTOS_VFS_NOTIFY_EVENT_TYPE__WRITE 

Definition at line 19 of file vfs_notify.h.

Function Documentation

◆ zrtos_vfs_notify__add()

void zrtos_vfs_notify__add ( zrtos_vfs_notify_t thiz,
zrtos_vfs_fd_t  fd,
zrtos_vfs_notify_callback_t  callback 
)

Definition at line 51 of file vfs_notify.h.

55  {
56  zrtos_vfs_fd_set__set(&thiz->fdset,fd);
57  zrtos_vfs_notify_entry_t *entry = &thiz->data[fd.fd];
58  entry->callback = callback;
59 }
void zrtos_vfs_fd_set__set(zrtos_vfs_fd_set_t *thiz, zrtos_vfs_fd_t fd)
Definition: vfs_fd.h:42
zrtos_vfs_fd_set_t fdset
Definition: vfs_notify.h:35
size_t fd
Definition: vfs_fd.h:18
zrtos_vfs_notify_callback_t callback
Definition: vfs_notify.h:31
zrtos_vfs_notify_entry_t data[ZRTOS_VFS_FILE_DESCRIPTOR__CFG_MAX]
Definition: vfs_notify.h:36
Definition: vfs_notify.h:30
Here is the call graph for this function:

◆ zrtos_vfs_notify__init()

bool zrtos_vfs_notify__init ( zrtos_vfs_notify_t thiz)

Definition at line 40 of file vfs_notify.h.

40  {
43  &thiz->data
45  );
47 
48  return true;
49 }
#define ZRTOS_VFS_FILE_DESCRIPTOR__CFG_MAX
Definition: cfg.h:26
zrtos_vfs_fd_set_t fdset
Definition: vfs_notify.h:35
void zrtos_mem__zero(void *dest, size_t len)
Definition: mem.h:144
Successful program execution status.
Definition: error.h:22
zrtos_vfs_notify_entry_t data[ZRTOS_VFS_FILE_DESCRIPTOR__CFG_MAX]
Definition: vfs_notify.h:36
zrtos_error_t error
Definition: vfs_notify.h:37
Definition: vfs_notify.h:30
bool zrtos_vfs_fd_set__init(zrtos_vfs_fd_set_t *thiz)
Definition: vfs_fd.h:65
Here is the call graph for this function:

◆ zrtos_vfs_notify__remove()

void zrtos_vfs_notify__remove ( zrtos_vfs_notify_t thiz,
zrtos_vfs_fd_t  fd 
)

Definition at line 61 of file vfs_notify.h.

64  {
65  zrtos_vfs_fd_set__clear(&thiz->fdset,fd);
66  zrtos_vfs_notify_entry_t *entry = &thiz->data[fd.fd];
67  entry->callback = 0;
68 }
zrtos_vfs_fd_set_t fdset
Definition: vfs_notify.h:35
size_t fd
Definition: vfs_fd.h:18
zrtos_vfs_notify_callback_t callback
Definition: vfs_notify.h:31
zrtos_vfs_notify_entry_t data[ZRTOS_VFS_FILE_DESCRIPTOR__CFG_MAX]
Definition: vfs_notify.h:36
Definition: vfs_notify.h:30
void zrtos_vfs_fd_set__clear(zrtos_vfs_fd_set_t *thiz, zrtos_vfs_fd_t fd)
Definition: vfs_fd.h:27
Here is the call graph for this function:

◆ zrtos_vfs_notify__start()

void zrtos_vfs_notify__start ( zrtos_vfs_notify_t thiz)

Definition at line 70 of file vfs_notify.h.

72  {
73  zrtos_vfs_fd_set_t fdset_can_read;
74  zrtos_vfs_fd_set_t fdset_can_write;
75 
76  while(zrtos_error__is_success(thiz->error)){
77  zrtos_vfs_fd_set__copy(&fdset_can_read,&thiz->fdset);
78  zrtos_vfs_fd_set__copy(&fdset_can_write,&thiz->fdset);
79  if(zrtos_vfs_fd__select(&fdset_can_read,&fdset_can_write)>0){
80  ZRTOS_VFS_FD_SET__EACH_BEGIN(&fdset_can_read,fd){
81  if(thiz->data[fd.fd].callback){
82  thiz->data[fd.fd].callback(
83  thiz
84  ,fd
86  );
87  }
89 
90  ZRTOS_VFS_FD_SET__EACH_BEGIN(&fdset_can_write,fd){
91  if(thiz->data[fd.fd].callback){
92  thiz->data[fd.fd].callback(
93  thiz
94  ,fd
96  );
97  }
99  }
100  }
101 }
size_t zrtos_vfs_fd__select(zrtos_vfs_fd_set_t *readfds, zrtos_vfs_fd_set_t *writefds)
Definition: vfs_fd.h:308
zrtos_vfs_fd_set_t fdset
Definition: vfs_notify.h:35
void zrtos_vfs_fd_set__copy(zrtos_vfs_fd_set_t *thiz, zrtos_vfs_fd_set_t *src)
Definition: vfs_fd.h:57
#define ZRTOS_VFS_FD_SET__EACH_BEGIN(thiz, fd_)
Definition: vfs_fd.h:341
bool zrtos_error__is_success(zrtos_error_t thiz)
Definition: error.h:152
zrtos_vfs_notify_callback_t callback
Definition: vfs_notify.h:31
#define ZRTOS_VFS_FD_SET__EACH_END
Definition: vfs_fd.h:349
zrtos_vfs_notify_entry_t data[ZRTOS_VFS_FILE_DESCRIPTOR__CFG_MAX]
Definition: vfs_notify.h:36
zrtos_error_t error
Definition: vfs_notify.h:37
Here is the call graph for this function:

◆ zrtos_vfs_notify__stop()

void zrtos_vfs_notify__stop ( zrtos_vfs_notify_t thiz)

Definition at line 103 of file vfs_notify.h.

105  {
106  thiz->error = ZRTOS_ERROR__INTR;
107 }
Interrupted system call.
Definition: error.h:28
zrtos_error_t error
Definition: vfs_notify.h:37