Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
devtab.h
Go to the documentation of this file.
1
36#ifndef _FREERTOS_DRIVERS_COMMON_DEVTAB_H_
37#define _FREERTOS_DRIVERS_COMMON_DEVTAB_H_
38
39#include <sys/types.h>
40
43typedef struct file file_t;
46typedef struct node node_t;
47
50typedef struct devops
51{
53 int (*open)(file_t *, const char *, int, int);
55 int (*close)(file_t *, node_t*);
57 ssize_t (*read)(file_t *, void *, size_t);
59 ssize_t (*write)(file_t *, const void *, size_t);
61 int (*ioctl)(file_t *, node_t *, int, void *);
62} devops_t;
63
66typedef struct devtab
67{
68 const char *name;
69 int (*init)(struct devtab *);
71 void *priv;
72} devtab_t;
73
76typedef struct node
77{
78 void *priv;
79 unsigned int references;
80} node_t;
81
84typedef struct file
85{
88 off_t offset;
89 int flags;
90 char inuse;
91} file_t;
92
94extern devtab_t DEVTAB[];
96extern devtab_t DEVTAB_END;
97
99#define __string(_x) #_x
101#define __xstring(_x) __string(_x)
102
111#define DEVOPS(_label, _open, _close, _read, _write, _ioctl) \
112 devops_t _label = \
113 { \
114 _open, \
115 _close, \
116 _read, \
117 _write, \
118 _ioctl \
119 };
120
124#define TABLE_ENTRY(_name) \
125 __attribute__((section((".device.table." __xstring(_name) ".data")))) \
126 __attribute__((used))
127
135#define DEVTAB_ENTRY(_label, _name, _init, _devops, _priv) \
136 devtab_t _label TABLE_ENTRY(devtab) = \
137 { \
138 _name, \
139 _init, \
140 _devops, \
141 _priv \
142 };
143
144#endif /* _FREERTOS_DRIVERS_COMMON_DEVTAB_H_ */
int ioctl(int fd, unsigned long int key,...)
Request and ioctl transaction.
Definition Fileio.cxx:452
devtab_t DEVTAB_END
Linker generated device table end.
devtab_t DEVTAB[]
Linker generated device table.
Device operations pointer structure.
Definition devtab.h:51
Device tab structure.
Definition devtab.h:67
devops_t * devops
device operations
Definition devtab.h:70
const char * name
device name
Definition devtab.h:68
void * priv
device private data
Definition devtab.h:71
File information.
Definition devtab.h:85
int flags
open flags
Definition devtab.h:89
devtab_t * dev
file operations
Definition devtab.h:86
char inuse
is this file in use
Definition devtab.h:90
off_t offset
current offset within file
Definition devtab.h:88
node_t * node
node this file information refers to
Definition devtab.h:87
Node information.
Definition devtab.h:77
void * priv
node private data
Definition devtab.h:78
unsigned int references
number of open references
Definition devtab.h:79