19#ifndef _COBALT_KERNEL_VFILE_H
20#define _COBALT_KERNEL_VFILE_H
22#if defined(CONFIG_XENO_OPT_VFILE) || defined(DOXYGEN_CPP)
24#include <linux/proc_fs.h>
25#include <linux/seq_file.h>
26#include <cobalt/kernel/lock.h>
33struct xnvfile_directory;
39 struct proc_dir_entry *pde;
68 int (*
get)(
struct xnvfile *vfile);
76 void (*
put)(
struct xnvfile *vfile);
79struct xnvfile_hostlock_class {
84struct xnvfile_nklock_class {
90 const char __user *u_buf;
92 struct xnvfile *vfile;
249 ssize_t (*
store)(
struct xnvfile_input *input);
252struct xnvfile_regular {
253 struct xnvfile entry;
258struct xnvfile_regular_template {
473 ssize_t (*
store)(
struct xnvfile_input *input);
488struct xnvfile_snapshot_template {
508 struct xnvfile entry;
539struct xnvfile_directory {
540 struct xnvfile entry;
544 struct xnvfile entry;
548#define VFILE_SEQ_EMPTY ((void *)-1)
550#define VFILE_SEQ_START SEQ_START_TOKEN
552#define VFILE_SEQ_SKIP 2
554#define xnvfile_printf(it, args...) seq_printf((it)->seq, ##args)
555#define xnvfile_write(it, data, len) seq_write((it)->seq, (data),(len))
556#define xnvfile_puts(it, s) seq_puts((it)->seq, (s))
557#define xnvfile_putc(it, c) seq_putc((it)->seq, (c))
566 xnvfile_touch_tag(vfile->tag);
569#define xnvfile_noentry \
577#define xnvfile_nodir { .entry = xnvfile_noentry }
578#define xnvfile_nolink { .entry = xnvfile_noentry }
579#define xnvfile_nofile { .entry = xnvfile_noentry }
581#define xnvfile_priv(e) ((e)->entry.private)
582#define xnvfile_nref(e) ((e)->entry.refcnt)
583#define xnvfile_file(e) ((e)->entry.file)
584#define xnvfile_iterator_priv(it) ((void *)(&(it)->private))
586extern struct xnvfile_nklock_class xnvfile_nucleus_lock;
590int xnvfile_init_root(
void);
592void xnvfile_destroy_root(
void);
596 struct xnvfile_directory *parent);
599 struct xnvfile_regular *vfile,
600 struct xnvfile_directory *parent);
603 struct xnvfile_directory *vdir,
604 struct xnvfile_directory *parent);
608 struct xnvfile_link *vlink,
609 struct xnvfile_directory *parent);
614 void *data,
size_t size);
617 char *s,
size_t maxlen);
621int __vfile_hostlock_get(
struct xnvfile *vfile);
623void __vfile_hostlock_put(
struct xnvfile *vfile);
632void xnvfile_destroy_regular(
struct xnvfile_regular *vfile)
638void xnvfile_destroy_dir(
struct xnvfile_directory *vdir)
644void xnvfile_destroy_link(
struct xnvfile_link *vlink)
649#define DEFINE_VFILE_HOSTLOCK(name) \
650 struct xnvfile_hostlock_class name = { \
652 .get = __vfile_hostlock_get, \
653 .put = __vfile_hostlock_put, \
655 .mutex = __MUTEX_INITIALIZER(name.mutex), \
660#define xnvfile_touch_tag(tag) do { } while (0)
662#define xnvfile_touch(vfile) do { } while (0)
ssize_t xnvfile_get_integer(struct xnvfile_input *input, long *valp)
Evaluate the string written to the vfile as a long integer.
Definition vfile.c:907
struct xnvfile_directory cobalt_vfroot
Xenomai vfile root directory.
Definition vfile.c:88
int xnvfile_init_link(const char *from, const char *to, struct xnvfile_link *vlink, struct xnvfile_directory *parent)
Initialize a virtual link entry.
Definition vfile.c:745
void xnvfile_destroy(struct xnvfile *vfile)
Removes a virtual file entry.
Definition vfile.c:777
ssize_t xnvfile_get_blob(struct xnvfile_input *input, void *data, size_t size)
Read in a data bulk written to the vfile.
Definition vfile.c:810
int xnvfile_init_regular(const char *name, struct xnvfile_regular *vfile, struct xnvfile_directory *parent)
Initialize a regular vfile.
Definition vfile.c:653
int xnvfile_init_snapshot(const char *name, struct xnvfile_snapshot *vfile, struct xnvfile_directory *parent)
Initialize a snapshot-driven vfile.
Definition vfile.c:405
int xnvfile_init_dir(const char *name, struct xnvfile_directory *vdir, struct xnvfile_directory *parent)
Initialize a virtual directory entry.
Definition vfile.c:698
ssize_t xnvfile_get_string(struct xnvfile_input *input, char *s, size_t maxlen)
Read in a C-string written to the vfile.
Definition vfile.c:854
Vfile locking operations .
Definition vfile.h:55
void(* put)(struct xnvfile *vfile)
This handler should release the lock previously grabbed by the get() handler.
Definition vfile.h:76
int(* get)(struct xnvfile *vfile)
This handler should grab the desired lock.
Definition vfile.h:68
Regular vfile iterator .
Definition vfile.h:270
struct seq_file * seq
Backlink to the host sequential file supporting the vfile.
Definition vfile.h:274
loff_t pos
Current record position while iterating.
Definition vfile.h:272
struct xnvfile_regular * vfile
Backlink to the vfile being read.
Definition vfile.h:276
Regular vfile operation descriptor .
Definition vfile.h:104
void(* end)(struct xnvfile_regular_iterator *it)
This handler is called after all records have been output.
Definition vfile.h:191
int(* show)(struct xnvfile_regular_iterator *it, void *data)
This handler should format and output a record.
Definition vfile.h:220
ssize_t(* store)(struct xnvfile_input *input)
This handler receives data written to the vfile, likely for updating some kernel setting,...
Definition vfile.h:249
int(* rewind)(struct xnvfile_regular_iterator *it)
This handler is called only once, when the virtual file is opened, before the begin() handler is invo...
Definition vfile.h:122
Snapshot revision tag .
Definition vfile.h:483
int rev
Current revision number.
Definition vfile.h:485
Snapshot-driven vfile iterator .
Definition vfile.h:521
struct xnvfile_snapshot * vfile
Backlink to the vfile being read.
Definition vfile.h:529
int nrdata
Number of collected records.
Definition vfile.h:523
void(* endfn)(struct xnvfile_snapshot_iterator *it, void *buf)
Buffer release handler.
Definition vfile.h:531
struct seq_file * seq
Backlink to the host sequential file supporting the vfile.
Definition vfile.h:527
caddr_t databuf
Address of record buffer.
Definition vfile.h:525
Snapshot vfile operation descriptor .
Definition vfile.h:294
int(* next)(struct xnvfile_snapshot_iterator *it, void *data)
This handler fetches the next record, as part of the snapshot data to be sent back to the reader via ...
Definition vfile.h:414
ssize_t(* store)(struct xnvfile_input *input)
This handler receives data written to the vfile, likely for updating the associated Xenomai object's ...
Definition vfile.h:473
void(* end)(struct xnvfile_snapshot_iterator *it, void *buf)
This handler releases the memory buffer previously obtained from begin().
Definition vfile.h:381
int(* show)(struct xnvfile_snapshot_iterator *it, void *data)
This handler should format and output a record from the collected data.
Definition vfile.h:443
int(* rewind)(struct xnvfile_snapshot_iterator *it)
This handler (re-)initializes the data collection, moving the seek pointer at the first record.
Definition vfile.h:335
Snapshot vfile descriptor .
Definition vfile.h:507