Skip to content

Commit

Permalink
devices: add control io operation a.k.a. ioctl
Browse files Browse the repository at this point in the history
JIRA: RTOS-848
  • Loading branch information
gerard5 committed Jun 25, 2024
1 parent 1272e7d commit 4bb5c31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions devices/devs.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ int devs_map(unsigned int major, unsigned int minor, addr_t addr, size_t sz, int
}


int devs_control(unsigned int major, unsigned int minor, int cmd, void *args)
{
const dev_ops_t *ops = devs_ops(major, minor);

return ((ops != NULL) && (ops->control != NULL)) ?
ops->control(minor, cmd, args) :
-ENOSYS;
}


void devs_done(void)
{
const dev_t *dev;
Expand Down
5 changes: 5 additions & 0 deletions devices/devs.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum { dev_isMappable = 0, dev_isNotMappable };
typedef struct {
int (*sync)(unsigned int minor);
int (*map)(unsigned int minor, addr_t addr, size_t sz, int mode, addr_t memaddr, size_t memsz, int memmode, addr_t *a);
int (*control)(unsigned int minor, int cmd, void *args);
ssize_t (*read)(unsigned int minor, addr_t offs, void *buff, size_t len, time_t timeout);
ssize_t (*write)(unsigned int minor, addr_t offs, const void *buff, size_t len);
ssize_t (*erase)(unsigned int minor, addr_t offs, size_t len, unsigned int flags);
Expand Down Expand Up @@ -74,6 +75,10 @@ extern int devs_sync(unsigned int major, unsigned int minor);
extern int devs_map(unsigned int major, unsigned int minor, addr_t addr, size_t sz, int mode, addr_t memaddr, size_t memsz, int memmode, addr_t *a);


/* Control and manipulate the underlying device functions, parameters */
extern int devs_control(unsigned int major, unsigned int minor, int cmd, void *args);


/* Read data from device */
extern ssize_t devs_read(unsigned int major, unsigned int minor, addr_t offs, void *buff, size_t len, time_t timeout);

Expand Down

0 comments on commit 4bb5c31

Please sign in to comment.