[Xenomai-git] Alexis Berlemont : analogy: fix a missing setting of the buf field in subdevice (broken)
Module: xenomai-abe Branch: experimental Commit: 7b3d8b48cc7cc869b0f2e4070832a2b5a5e7a2b2 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=7b3d8b48cc7cc869b0f2e4070832a2b5a5e7a2b2 Author: Alexis Berlemont Date: Sat Jun 12 01:34:12 2010 +0200 analogy: fix a missing setting of the buf field in subdevice (broken) --- ksrc/drivers/analogy/buffer.c | 15 --- ksrc/drivers/analogy/command.c |7 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index a72b4ad..1134b8e 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -124,6 +124,12 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) return -EINVAL; } + if (a4l_reserve_subd(buf_desc->subd) < 0) { + __a4l_err("a4l_setup_buffer: subdevice %d already busy\n", + cmd->idx_subd); + return -EBUSY; + } + /* Checks if the transfer system has to work in bulk mode */ if (cmd->flags & A4L_CMD_BULK) set_bit(A4L_BUF_BULK_NR, &buf_desc->flags); @@ -131,6 +137,9 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) /* Sets the working command */ buf_desc->cur_cmd = cmd; + /* Link the subdevice with the context's buffer */ + buf_desc->subd->buf = buf_desc; + /* Computes the count to reach, if need be */ if (cmd->stop_src == TRIG_COUNT) { for (i = 0; i < cmd->nb_chan; i++) { @@ -167,9 +176,6 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) __a4l_err("a4l_cancel: cancel handler failed (err=%d)\n", err); } - a4l_release_subd(subd); - subd->buf = NULL; - if (buf_desc->cur_cmd != NULL) { a4l_free_cmddesc(buf_desc->cur_cmd); rtdm_free(buf_desc->cur_cmd); @@ -178,6 +184,9 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) a4l_init_buffer(buf_desc); + a4l_release_subd(subd); + subd->buf = NULL; + return err; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index 51aad35..da89c9a 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -354,14 +354,11 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) goto out_ioctl_cmd; } - /* Sets the concerned subdevice as busy */ - ret = a4l_reserve_subd(subd); + /* Gets the transfer system ready */ + ret = a4l_setup_buffer(cxt, cmd_desc); if (ret < 0) goto out_ioctl_cmd; - /* Gets the transfer system ready */ - a4l_setup_buffer(cxt, cmd_desc); - /* Eventually launches the command */ ret = subd->do_cmd(subd, cmd_desc); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: [pcimio] fix a huge hack in the mite initialization (broken)
Module: xenomai-abe Branch: experimental Commit: 8cc939da0dcf8456e3046fe5fca5a6dfef309fab URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=8cc939da0dcf8456e3046fe5fca5a6dfef309fab Author: Alexis Berlemont Date: Thu Jun 10 23:59:00 2010 +0200 analogy: [pcimio] fix a huge hack in the mite initialization (broken) --- .../analogy/national_instruments/mio_common.c | 28 +-- ksrc/drivers/analogy/national_instruments/mite.c | 10 +++--- ksrc/drivers/analogy/national_instruments/mite.h |2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ksrc/drivers/analogy/national_instruments/mio_common.c b/ksrc/drivers/analogy/national_instruments/mio_common.c index 46efd03..ead64b8 100644 --- a/ksrc/drivers/analogy/national_instruments/mio_common.c +++ b/ksrc/drivers/analogy/national_instruments/mio_common.c @@ -511,7 +511,7 @@ static int ni_ao_wait_for_dma_load(a4l_subd_t *subd) static const int timeout = 1; a4l_dev_t *dev = subd->dev; - a4l_buf_t *buf = dev->transfer.bufs[subd->idx]; + a4l_buf_t *buf = subd->buf; int i; @@ -522,7 +522,7 @@ static int ni_ao_wait_for_dma_load(a4l_subd_t *subd) b_status = devpriv->stc_readw(dev, AO_Status_1_Register); - buffer_filled = test_bit(A4L_BUF_EOA_NR, &buf->evt_flags); + buffer_filled = test_bit(A4L_BUF_EOA_NR, &buf->flags); buffer_filled |= (b_status & AO_FIFO_Half_Full_St); if (buffer_filled) @@ -727,10 +727,9 @@ static void ni_handle_eos(a4l_subd_t *subd) static void ni_event(a4l_subd_t * subd) { /* Temporary hack */ - a4l_dev_t *dev = subd->dev; - a4l_buf_t *buf = dev->transfer.bufs[subd->idx]; + a4l_buf_t *buf = subd->buf; - if(test_bit(A4L_BUF_ERROR_NR, &buf->evt_flags)) { + if(test_bit(A4L_BUF_ERROR_NR, &buf->flags)) { if (subd->cancel != NULL) subd->cancel(subd); } @@ -1426,17 +1425,16 @@ static void ni_ai_munge32(a4l_subd_t *subd, void *buf, unsigned long size) #if (defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE) || \ defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE_MODULE)) -static int ni_ai_setup_MITE_dma(a4l_dev_t *dev) +static int ni_ai_setup_MITE_dma(a4l_subd_t *subd) { + a4l_dev_t *dev = subd->dev; int retval; retval = ni_request_ai_mite_channel(dev); if (retval) return retval; - /* Huge hack */ - mite_buf_change(devpriv->ai_mite_chan->ring, - dev->transfer.bufs[NI_AI_SUBDEV]); + mite_buf_change(devpriv->ai_mite_chan->ring, subd); switch (boardtype.reg_type) { case ni_reg_611x: @@ -1457,8 +1455,10 @@ static int ni_ai_setup_MITE_dma(a4l_dev_t *dev) return 0; } -static int ni_ao_setup_MITE_dma(a4l_dev_t *dev) +static int ni_ao_setup_MITE_dma(a4l_subd_t *subd) { + a4l_dev_t *dev = subd->dev; + int retval; unsigned long flags; @@ -1466,9 +1466,7 @@ static int ni_ao_setup_MITE_dma(a4l_dev_t *dev) if (retval) return retval; - /* Huge hack */ - mite_buf_change(devpriv->ao_mite_chan->ring, - dev->transfer.bufs[NI_AO_SUBDEV]); + mite_buf_change(devpriv->ao_mite_chan->ring, subd); a4l_lock_irqsave(&devpriv->mite_channel_lock, flags); if (devpriv->ao_mite_chan) { @@ -2436,7 +2434,7 @@ static int ni_ai_cmd(a4l_subd_t *subd, a4l_cmd_t *cmd) #if (defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE) || \ defined(CONFIG_XENO_DRIVERS_ANALOGY_NI_MITE_MODULE)) { - int retval = ni_ai_setup_MITE_dma(dev); + int retval = ni_ai_setup_MITE_dma(subd); if (retval) return retval; } @@ -2846,7 +2844,7 @@ int ni_ao_inttrig(a4l_subd_t *subd, lsampl_t trignum) devpriv->stc_writew(dev, 1, DAC_FIFO_Clear); if (boardtype.reg_type & ni_reg_6xxx_mask) ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x); - ret = ni_ao_setup_MITE_dma(dev); + ret = ni_ao_setup_MITE_dma(subd); if (ret) return ret; ret = ni_ao_wait_for_dma_load(subd); diff --git a/ksrc/drivers/analogy/national_instruments/mite.c b/ksrc/drivers/analogy/national_instruments/mite.c index d1a7813..da1f6a5 100644 --- a/ksrc/drivers/analogy/national_instruments/mite.c +++ b/ksrc/drivers/analogy/national_instruments/mite.c @@ -379,8 +379,9 @@ void mite_dma_disarm(struct mite_channel *mite_chan) writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel)); } -int mite_buf_change(struct mite_dma_descriptor_ring *ring, a4l_buf_t *buf) +int mite_buf_change(struct mite_dma_descriptor_ring *ring, a4l_subd_t *subd) { + a4l_buf_t *buf = subd->buf; unsigned int n_links; int i; @@ -587,10 +588,9 @@ int mite_sync_input_dma(struct mite_ch
[Xenomai-git] Alexis Berlemont : analogy: cosmetic change (broken)
Module: xenomai-abe Branch: experimental Commit: 9f4043c3837cd63c8e71d61f7b0b626c8811339f URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=9f4043c3837cd63c8e71d61f7b0b626c8811339f Author: Alexis Berlemont Date: Thu Jun 10 22:41:53 2010 +0200 analogy: cosmetic change (broken) --- include/analogy/device.h |4 ++-- ksrc/drivers/analogy/buffer.c | 14 +++--- ksrc/drivers/analogy/command.c |2 +- ksrc/drivers/analogy/device.c | 16 ksrc/drivers/analogy/instruction.c |4 ++-- .../analogy/national_instruments/mio_common.c |2 +- ksrc/drivers/analogy/subdevice.c | 10 +- ksrc/drivers/analogy/testing/loop.c|2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/analogy/device.h b/include/analogy/device.h index 6930a38..fca40cc 100644 --- a/include/analogy/device.h +++ b/include/analogy/device.h @@ -33,7 +33,7 @@ #define A4L_NB_DEVICES 10 -#define A4L_DEV_ATTACHED 0 +#define A4L_DEV_ATTACHED_NR 0 struct a4l_device { @@ -81,7 +81,7 @@ typedef struct a4l_dev_info a4l_dvinfo_t; #ifdef __KERNEL__ /* --- Device related macro --- */ -#define a4l_check_dev(x) test_bit(A4L_DEV_ATTACHED, &(x->flags)) +#define a4l_dev_is_attached(x) test_bit(A4L_DEV_ATTACHED_NR, &(x->flags)) /* --- Devices tab related functions --- */ void a4l_init_devs(void); diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 0826a93..ac1abce 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -513,7 +513,7 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) a4l_subd_t *subd; /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_ioctl_cancel: operation not supported on " "an unattached device\n"); return -EINVAL; @@ -556,7 +556,7 @@ int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) } /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_ioctl_bufcfg: unattached device\n"); return -EINVAL; } @@ -603,7 +603,7 @@ int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg) return -ENOSYS; /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_ioctl_bufinfo: unattached device\n"); return -EINVAL; } @@ -703,7 +703,7 @@ ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_read: unattached device\n"); return -EINVAL; } @@ -803,7 +803,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_write: unattached device\n"); return -EINVAL; } @@ -893,7 +893,7 @@ int a4l_select(a4l_cxt_t *cxt, /* Basic checkings */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_select: unattached device\n"); return -EINVAL; } @@ -942,7 +942,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) /* Basic checking */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_poll: unattached device\n"); return -EINVAL; } diff --git a/ksrc/drivers/analogy/command.c b/ksrc/drivers/analogy/command.c index 94d6137..51aad35 100644 --- a/ksrc/drivers/analogy/command.c +++ b/ksrc/drivers/analogy/command.c @@ -303,7 +303,7 @@ int a4l_ioctl_cmd(a4l_cxt_t * cxt, void *arg) return -ENOSYS; /* Basically check the device */ - if (!test_bit(A4L_DEV_ATTACHED, &dev->flags)) { + if (!test_bit(A4L_DEV_ATTACHED_NR, &dev->flags)) { __a4l_err("a4l_ioctl_cmd: cannot command " "an unattached device\n"); return -EINVAL; diff --git a/ksrc/drivers/analogy/device.c b/ksrc/drivers/analogy/device.c index a2d23c8..99b9098 100644 --- a/ksrc/drivers/analogy/device.c +++ b/ksrc/drivers/analogy/device.c @@ -51,7 +51,7 @@ int a4l_check_cleanup_devs(void) int i, ret = 0; for (i = 0; i < A4L_NB_DEVICES && ret == 0; i++) - if (test_bit(A4L_DEV_ATTACHED, &a4l_
[Xenomai-git] Alexis Berlemont : analogy: fix buffer's compilation issues (broken)
Module: xenomai-abe Branch: experimental Commit: e8201cd4afd10d7b2536b1d7aae03265724ae4b2 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=e8201cd4afd10d7b2536b1d7aae03265724ae4b2 Author: Alexis Berlemont Date: Thu Jun 10 22:42:40 2010 +0200 analogy: fix buffer's compilation issues (broken) --- include/analogy/buffer.h | 21 + 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 4846a4e..4bd5db0 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -32,6 +32,7 @@ #include +#include #include /* Events bits */ @@ -179,11 +180,11 @@ static inline int __handle_event(a4l_buf_t * buf) /* The event "End of acquisition" must not be cleaned before the complete flush of the buffer */ - if (test_bit(A4L_BUF_EOA_NR, &buf->evt_flags)) { + if (test_bit(A4L_BUF_EOA_NR, &buf->flags)) { ret = -ENOENT; } - if (test_bit(A4L_BUF_ERROR_NR, &buf->evt_flags)) { + if (test_bit(A4L_BUF_ERROR_NR, &buf->flags)) { ret = -EPIPE; } @@ -195,7 +196,7 @@ static inline int __handle_event(a4l_buf_t * buf) static inline int __pre_abs_put(a4l_buf_t * buf, unsigned long count) { if (count - buf->tmp_count > buf->size) { - set_bit(A4L_BUF_ERROR_NR, &buf->evt_flags); + set_bit(A4L_BUF_ERROR_NR, &buf->flags); return -EPIPE; } @@ -235,7 +236,7 @@ static inline int __pre_abs_get(a4l_buf_t * buf, unsigned long count) was not greater a few cycles before; in such case, the DMA channel would have retrieved the wrong data */ if ((long)(count - buf->tmp_count) > 0) { - set_bit(A4L_BUF_ERROR_NR, &buf->evt_flags); + set_bit(A4L_BUF_ERROR_NR, &buf->flags); return -EPIPE; } @@ -260,10 +261,10 @@ static inline int __abs_put(a4l_buf_t * buf, unsigned long count) buf->prd_count = count; if ((old / buf->size) != (count / buf->size)) - set_bit(A4L_BUF_EOBUF_NR, &buf->evt_flags); + set_bit(A4L_BUF_EOBUF_NR, &buf->flags); if (buf->end_count != 0 && (long)(count - buf->end_count) >= 0) - set_bit(A4L_BUF_EOA_NR, &buf->evt_flags); + set_bit(A4L_BUF_EOA_NR, &buf->flags); return 0; } @@ -283,10 +284,10 @@ static inline int __abs_get(a4l_buf_t * buf, unsigned long count) buf->cns_count = count; if ((old / buf->size) != count / buf->size) - set_bit(A4L_BUF_EOBUF_NR, &buf->evt_flags); + set_bit(A4L_BUF_EOBUF_NR, &buf->flags); if (buf->end_count != 0 && (long)(count - buf->end_count) >= 0) - set_bit(A4L_BUF_EOA_NR, &buf->evt_flags); + set_bit(A4L_BUF_EOA_NR, &buf->flags); return 0; } @@ -329,6 +330,10 @@ static inline unsigned long __count_to_get(a4l_buf_t * buf) /* --- Buffer internal functions --- */ +int a4l_alloc_buffer(a4l_buf_t *buf_desc, int buf_size); + +void a4l_free_buffer(a4l_buf_t *buf_desc); + void a4l_init_buffer(a4l_buf_t * buf_desc); int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the last compilation problems
Module: xenomai-abe Branch: experimental Commit: 22d51109d439e882fffb2637748724e1e7542ff9 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=22d51109d439e882fffb2637748724e1e7542ff9 Author: Alexis Berlemont Date: Fri Jun 11 00:01:01 2010 +0200 analogy: fix the last compilation problems --- include/analogy/buffer.h | 22 -- include/analogy/subdevice.h |6 +++--- ksrc/drivers/analogy/buffer.c | 25 - ksrc/drivers/analogy/rtdm_interface.c | 13 + ksrc/drivers/analogy/transfer.c |3 +-- 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/include/analogy/buffer.h b/include/analogy/buffer.h index 4bd5db0..148c07f 100644 --- a/include/analogy/buffer.h +++ b/include/analogy/buffer.h @@ -35,20 +35,23 @@ #include #include -/* Events bits */ +/* --- Events bits / flags --- */ + #define A4L_BUF_EOBUF_NR 0 -#define A4L_BUF_ERROR_NR 1 -#define A4L_BUF_EOA_NR 2 -/* Events flags */ #define A4L_BUF_EOBUF (1 << A4L_BUF_EOBUF_NR) + +#define A4L_BUF_ERROR_NR 1 #define A4L_BUF_ERROR (1 << A4L_BUF_ERROR_NR) + +#define A4L_BUF_EOA_NR 2 #define A4L_BUF_EOA (1 << A4L_BUF_EOA_NR) -/* Status bits */ +/* --- Status bits / flags --- */ + #define A4L_BUF_BULK_NR 8 -#define A4L_BUF_MAP_NR 9 -/* Status flags */ #define A4L_BUF_BULK (1 << A4L_BUF_BULK_NR) + +#define A4L_BUF_MAP_NR 9 #define A4L_BUF_MAP (1 << A4L_BUF_MAP_NR) struct a4l_subdevice; @@ -391,9 +394,8 @@ int a4l_ioctl_mmap(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_bufinfo(a4l_cxt_t * cxt, void *arg); int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg); -ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes); -ssize_t a4l_write(a4l_cxt_t * cxt, - const void *bufdata, size_t nbytes); +ssize_t a4l_read_buffer(a4l_cxt_t * cxt, void *bufdata, size_t nbytes); +ssize_t a4l_write_buffer(a4l_cxt_t * cxt, const void *bufdata, size_t nbytes); int a4l_select(a4l_cxt_t *cxt, rtdm_selector_t *selector, enum rtdm_selecttype type, unsigned fd_index); diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 8649c8a..4223748 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -286,10 +286,10 @@ int a4l_check_chanlist(a4l_subd_t * subd, static inline int a4l_reserve_subd(a4l_subd_t *subd) { -return test_and_set_bit(A4L_SUBD_BUSY, &subd->status) ? -EBUSY : 0; +return test_and_set_bit(A4L_SUBD_BUSY_NR, &subd->status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, &((x)->status)) -#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY, &((x)->status))) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY_NR, &((x)->flags)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY_NR, &((x)->flags))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0) /* The following macro considers that a DIO subdevice is firstly an diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index ac1abce..a72b4ad 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -436,13 +436,13 @@ unsigned long a4l_buf_count(a4l_subd_t *subd) void a4l_map(struct vm_area_struct *area) { unsigned long *status = (unsigned long *)area->vm_private_data; - set_bit(A4L_TSF_MMAP, status); + set_bit(A4L_BUF_MAP_NR, status); } void a4l_unmap(struct vm_area_struct *area) { unsigned long *status = (unsigned long *)area->vm_private_data; - clear_bit(A4L_TSF_MMAP, status); + clear_bit(A4L_BUF_MAP_NR, status); } static struct vm_operations_struct a4l_vm_ops = { @@ -454,6 +454,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) { a4l_mmap_t map_cfg; a4l_dev_t *dev; + a4l_buf_t *buf; int ret; /* The mmap operation cannot be performed in a @@ -463,6 +464,7 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) } dev = a4l_get_dev(cxt); + buf = cxt->buffer; /* Basic checkings */ @@ -487,12 +489,10 @@ int a4l_ioctl_mmap(a4l_cxt_t *cxt, void *arg) /* All the magic is here */ ret = rtdm_mmap_to_user(cxt->user_info, - dev->transfer.bufs[map_cfg.idx_subd]->buf, + buf->buf, map_cfg.size, PROT_READ | PROT_WRITE, - &map_cfg.ptr, - &a4l_vm_ops, - &(dev->transfer.status[map_cfg.idx_subd])); + &map_cfg.ptr, &a4l_vm_ops, &buf->flags); if (ret < 0) { __a4l_err("a4l_ioctl_mmap: internal error, " @@ -545,7 +545,7 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) int a4l_ioctl_bufcfg(a4l_cxt_t * cxt, void *arg) { a4l_dev_t *dev = a4l_get_dev(cx
[Xenomai-git] Alexis Berlemont : analogy: prettify some subdevice tests (broken)
Module: xenomai-abe Branch: experimental Commit: bc5ba2bff03268f80312a021c1de3f811a22a316 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=bc5ba2bff03268f80312a021c1de3f811a22a316 Author: Alexis Berlemont Date: Thu Jun 10 22:44:21 2010 +0200 analogy: prettify some subdevice tests (broken) --- include/analogy/subdevice.h | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/analogy/subdevice.h b/include/analogy/subdevice.h index 0337092..8649c8a 100644 --- a/include/analogy/subdevice.h +++ b/include/analogy/subdevice.h @@ -277,21 +277,19 @@ typedef struct a4l_rng_info_arg a4l_rnginfo_arg_t; #ifdef __KERNEL__ -/* --- Subdevice related functions --- */ +/* --- Subdevice related functions and macros --- */ + a4l_chan_t *a4l_get_chfeat(a4l_subd_t * sb, int idx); -a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, - int chidx, int rngidx); +a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx); int a4l_check_chanlist(a4l_subd_t * subd, unsigned char nb_chan, unsigned int *chans); -/* --- Upper layer functions --- */ - static inline int a4l_reserve_subd(a4l_subd_t *subd) { return test_and_set_bit(A4L_SUBD_BUSY, &subd->status) ? -EBUSY : 0; } -#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, &(x)->status)) -#define a4l_subd_is_busy(x) test_bit(A4L_SUBD_BUSY, &(x)->status)) +#define a4l_release_subd(x) clear_bit(A4L_SUBD_BUSY, &((x)->status)) +#define a4l_subd_is_busy(x) (test_bit(A4L_SUBD_BUSY, &((x)->status))) #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0) /* The following macro considers that a DIO subdevice is firstly an @@ -300,6 +298,8 @@ static inline int a4l_reserve_subd(a4l_subd_t *subd) ((A4L_SUBD_MASK_WRITE & (x)->flags) != 0 || \ (A4L_SUBD_DIO & (x)->flags) != 0) +/* --- Upper layer functions --- */ + a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx); a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void (*setup)(a4l_subd_t *)); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix the declaration of the structure a4l_context (broken)
Module: xenomai-abe Branch: experimental Commit: 153584ccba0bf6ba90d5abb34b5c0a884f8d12f1 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=153584ccba0bf6ba90d5abb34b5c0a884f8d12f1 Author: Alexis Berlemont Date: Sun Jun 6 16:21:44 2010 +0200 analogy: fix the declaration of the structure a4l_context (broken) In the structure a4l_context, replace the field buffer by a pointer to the structure a4l_buffer (a4l_buf_t -> a4l_buf_t *). That fixes a bug in the headers dependencies. --- include/analogy/context.h |3 ++- ksrc/drivers/analogy/buffer.c | 12 ++-- ksrc/drivers/analogy/rtdm_interface.c | 14 ++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/analogy/context.h b/include/analogy/context.h index 2442b6c..3e61697 100644 --- a/include/analogy/context.h +++ b/include/analogy/context.h @@ -42,8 +42,9 @@ struct a4l_device_context { /* The buffer structure contains everything to transfer data from asynchronous acquisition operations on a specific subdevice */ - struct buffer buffer; + struct a4l_buffer *buffer; }; +typedef struct a4l_device_context a4l_cxt_t; static inline int a4l_get_minor(a4l_cxt_t *cxt) { diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index d3db892..1b413cc 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -493,10 +493,10 @@ int a4l_ioctl_cancel(a4l_cxt_t * cxt, void *arg) subd = dev->transfer.subds[idx_subd]; - if (subd != cxt->buffer.subd) { + if (subd != cxt->buffer->subd) { __a4l_err("a4l_ioctl_cancel: " "current context works on another subdevice " - "(%d!=%d)\n", cxt->buffer.subd->idx, subd->idx); + "(%d!=%d)\n", cxt->buffer->subd->idx, subd->idx); return -EINVAL; } @@ -658,7 +658,7 @@ a4l_ioctl_bufinfo_out: ssize_t a4l_read(a4l_cxt_t * cxt, void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_buf_t *subd = buf->subd; ssize_t count = 0; @@ -758,7 +758,7 @@ ssize_t a4l_write(a4l_cxt_t *cxt, const void *bufdata, size_t nbytes) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_subd_t *subd = buf->subd; ssize_t count = 0; @@ -849,7 +849,7 @@ int a4l_select(a4l_cxt_t *cxt, enum rtdm_selecttype type, unsigned fd_index) { a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_subd_t *subd = buf->subd; /* Basic checkings */ @@ -894,7 +894,7 @@ int a4l_ioctl_poll(a4l_cxt_t * cxt, void *arg) int ret = 0; unsigned long tmp_cnt = 0; a4l_dev_t *dev = a4l_get_dev(cxt); - a4l_buf_t *buf = &cxt->buffer; + a4l_buf_t *buf = cxt->buffer; a4l_buf_t *subd = buf->subd; a4l_poll_t poll; diff --git a/ksrc/drivers/analogy/rtdm_interface.c b/ksrc/drivers/analogy/rtdm_interface.c index 6525425..8cfdf04 100644 --- a/ksrc/drivers/analogy/rtdm_interface.c +++ b/ksrc/drivers/analogy/rtdm_interface.c @@ -131,14 +131,15 @@ int a4l_open(struct rtdm_dev_context *context, a4l_set_dev(cxt); /* Initialize the buffer structure */ - a4l_init_buffer(&cxt->buffer); + cxt->buffer = rtdm_malloc(sizeof(a4l_buf_t)); + a4l_init_buffer(cxt->buffer); /* Allocate the asynchronous buffer NOTE: it should be interesting to allocate the buffer only on demand especially if the system is short of memory NOTE2: the default buffer size could be configured via kernel config*/ - a4l_alloc_buffer(&cxt->buffer, A4L_DEFAULT_BFSIZE); + a4l_alloc_buffer(cxt->buffer, A4L_DEFAULT_BFSIZE); return 0; } @@ -149,15 +150,20 @@ int a4l_close(struct rtdm_dev_context *context, rtdm_user_info_t * user_info) a4l_cxt_t *cxt = (a4l_cxt_t *)rtdm_context_to_private(context); /* Cancel the maybe occuring asynchronous transfer */ - err = a4l_cancel_buffer(&cxt->buffer); + err = a4l_cancel_buffer(cxt->buffer); if (err < 0) { __a4l_err("close: unable to stop the asynchronous transfer\n"); return err; } /* Free the buffer which was linked with this context */ - err = a4l_free_buffer(&cxt->buffer); + err = a4l_free_buffer(cxt->buffer); + if (err < 0) + goto out; + rtdm_free(cxt->buffer); + +out: return err; } ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Alexis Berlemont : analogy: fix compilation issues and review the mmap ioctl handler (broken)
Module: xenomai-abe Branch: experimental Commit: 01b05464428575b33c0dfa17c033fd7cb2620577 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=01b05464428575b33c0dfa17c033fd7cb2620577 Author: Alexis Berlemont Date: Thu Jun 10 22:35:06 2010 +0200 analogy: fix compilation issues and review the mmap ioctl handler (broken) --- ksrc/drivers/analogy/buffer.c | 200 - 1 files changed, 119 insertions(+), 81 deletions(-) diff --git a/ksrc/drivers/analogy/buffer.c b/ksrc/drivers/analogy/buffer.c index 1b413cc..0826a93 100644 --- a/ksrc/drivers/analogy/buffer.c +++ b/ksrc/drivers/analogy/buffer.c @@ -121,7 +121,7 @@ int a4l_setup_buffer(a4l_cxt_t *cxt, a4l_cmd_t *cmd) if (buf_desc->subd == NULL) { __a4l_err("a4l_setup_buffer: subdevice index " "out of range (%d)\n", cmd->idx_subd); - goto -EINVAL; + return -EINVAL; } /* Checks if the transfer system has to work in bulk mode */ @@ -155,7 +155,7 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) int err = 0; - if (!subd || !a4l_check_subd(subd)) + if (!subd || !a4l_subd_is_busy(subd)) return 0; /* If a "cancel" function is registered, call it @@ -164,12 +164,11 @@ int a4l_cancel_buffer(a4l_cxt_t *cxt) the "cancel" function can be used as as to (re)initialize some component) */ if (subd->cancel != NULL && (err = subd->cancel(subd)) < 0) { - __a4l_err("a4l_cancel: " - "subdevice %d cancel handler failed (err=%d)\n", - idx_subd, err); + __a4l_err("a4l_cancel: cancel handler failed (err=%d)\n", err); } a4l_release_subd(subd); + subd->buf = NULL; if (buf_desc->cur_cmd != NULL) { a4l_free_cmddesc(buf_desc->cur_cmd); @@ -208,7 +207,7 @@ int a4l_get_chan(a4l_subd_t *subd) /* Translation bits -> bytes */ tmp_size /= 8; - tmp_count = dev->transfer.bufs[subd->idx]->mng_count % tmp_size; + tmp_count = subd->buf->mng_count % tmp_size; /* Translation bytes -> bits */ tmp_count *= 8; @@ -231,116 +230,174 @@ int a4l_get_chan(a4l_subd_t *subd) int a4l_buf_prepare_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_abs_put(subd->buf, count); + return __pre_abs_put(buf, count); } int a4l_buf_commit_absput(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __abs_put(subd->buf, count); + return __abs_put(buf, count); } int a4l_buf_prepare_put(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __pre_put(subd->buf, count); + return __pre_put(buf, count); } int a4l_buf_commit_put(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - return __put(subd->buf, count); + return __put(buf, count); } int a4l_buf_put(a4l_subd_t *subd, void *bufdata, unsigned long count) { + a4l_buf_t *buf = subd->buf; int err; - if ((subd->flags & A4L_SUBD_MASK_READ) == 0 || !subd->buf) + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_input(subd)) return -EINVAL; - if (__count_to_put(subd->buf) < count) + if (__count_to_put(buf) < count) return -EAGAIN; - err = __produce(NULL, subd->buf, bufdata, count); + err = __produce(NULL, buf, bufdata, count); if (err < 0) return err; - err = __put(subd->buf, count); + err = __put(buf, count); return err; } int a4l_buf_prepare_absget(a4l_subd_t *subd, unsigned long count) { - if ((subd->flags & A4L_SUBD_MASK_WRITE) == 0 || !subd->buf) + a4l_buf_t *buf = subd->buf; + + if (!buf || !a4l_subd_is_busy(subd)) + return -ENOENT; + + if (!a4l_subd_is_output(subd
[Xenomai-git] Philippe Gerum : psos: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 1a277a62d437fc75808d315b3fbc66fd2c59d8b2 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=1a277a62d437fc75808d315b3fbc66fd2c59d8b2 Author: Philippe Gerum Date: Mon Jun 7 19:41:23 2010 +0200 psos: convert to vfile --- ksrc/skins/psos+/module.c |9 +--- ksrc/skins/psos+/queue.c | 131 ksrc/skins/psos+/rn.c | 122 +++--- ksrc/skins/psos+/sem.c| 117 +--- 4 files changed, 236 insertions(+), 143 deletions(-) diff --git a/ksrc/skins/psos+/module.c b/ksrc/skins/psos+/module.c index bdba58b..33ac213 100644 --- a/ksrc/skins/psos+/module.c +++ b/ksrc/skins/psos+/module.c @@ -52,14 +52,7 @@ xntbase_t *psos_tbase; psos_rholder_t __psos_global_rholder; -#ifdef CONFIG_PROC_FS -xnptree_t __psos_ptree = { - - .dir = NULL, - .name = "psos", - .entries = 0, -}; -#endif /* CONFIG_PROC_FS */ +DEFINE_XNPTREE(__psos_ptree, "psos"); void k_fatal(u_long err_code, u_long flags) { diff --git a/ksrc/skins/psos+/queue.c b/ksrc/skins/psos+/queue.c index 703ca3b..8993b28 100644 --- a/ksrc/skins/psos+/queue.c +++ b/ksrc/skins/psos+/queue.c @@ -31,67 +31,102 @@ static u_long q_destroy_internal(psosqueue_t *queue); #ifdef CONFIG_PROC_FS -static int msgq_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) -{ - psosqueue_t *queue = (psosqueue_t *)data; - char *p = page; - int len; - spl_t s; - - p += sprintf(p, "maxnum=%lu:maxlen=%lu:mcount=%d\n", -queue->maxnum, queue->maxlen, countq(&queue->inq)); +struct vfile_priv { + struct xnpholder *curr; + unsigned long maxnum; + unsigned long maxlen; + int msgcount; +}; - xnlock_get_irqsave(&nklock, s); +struct vfile_data { + char name[XNOBJECT_NAME_LEN]; +}; - if (xnsynch_nsleepers(&queue->synchbase) > 0) { - xnpholder_t *holder; +static int vfile_rewind(struct xnvfile_snapshot_iterator *it) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + psosqueue_t *queue = xnvfile_priv(it->vfile); - /* Pended queue -- dump waiters. */ + queue = psos_h2obj_active((u_long)queue, PSOS_QUEUE_MAGIC, psosqueue_t); + if (queue == NULL) + return -EIDRM; - holder = getheadpq(xnsynch_wait_queue(&queue->synchbase)); + priv->curr = getheadpq(xnsynch_wait_queue(&queue->synchbase)); + priv->maxnum = queue->maxnum; + priv->maxlen = queue->maxlen; + priv->msgcount = countq(&queue->inq); - while (holder) { - xnthread_t *sleeper = link2thread(holder, plink); - p += sprintf(p, "+%s\n", xnthread_name(sleeper)); - holder = - nextpq(xnsynch_wait_queue(&queue->synchbase), - holder); - } - } + return xnsynch_nsleepers(&queue->synchbase); +} - xnlock_put_irqrestore(&nklock, s); +static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + psosqueue_t *queue = xnvfile_priv(it->vfile); + struct vfile_data *p = data; + struct xnthread *thread; + + if (priv->curr == NULL) + return 0; /* We are done. */ + + /* Fetch current waiter, advance list cursor. */ + thread = link2thread(priv->curr, plink); + priv->curr = nextpq(xnsynch_wait_queue(&queue->synchbase), + priv->curr); + /* Collect thread name to be output in ->show(). */ + strncpy(p->name, xnthread_name(thread), sizeof(p->name)); + + return 1; +} - len = (p - page) - off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; +static int vfile_show(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct vfile_data *p = data; + + if (p == NULL) {/* Dump header. */ + xnvfile_printf(it, + "maxnum=%lu:maxlen=%lu:mcount=%d\n", + priv->maxnum, + priv->maxlen, + priv->msgcount); + if (it->nrdata > 0) + /* Queue is pended -- dump waiters */ + xnvfile_printf(it, "---\n"); + } else + xnvfile_printf(it, "%.*s\n", + (int)sizeof(p->name), p->name); - return len; + return 0; } -extern xnp
[Xenomai-git] Philippe Gerum : vrtx: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: c1d2d2a1a54e635bd5549db47465914f77d19ef7 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=c1d2d2a1a54e635bd5549db47465914f77d19ef7 Author: Philippe Gerum Date: Tue Jun 8 08:43:19 2010 +0200 vrtx: convert to vfile --- ksrc/skins/vrtx/event.c | 130 -- ksrc/skins/vrtx/heap.c | 75 +++--- ksrc/skins/vrtx/mb.c | 111 --- ksrc/skins/vrtx/module.c |9 +--- ksrc/skins/vrtx/mx.c | 129 -- ksrc/skins/vrtx/pt.c | 77 --- ksrc/skins/vrtx/queue.c | 115 +--- ksrc/skins/vrtx/sem.c| 112 --- 8 files changed, 457 insertions(+), 301 deletions(-) diff --git a/ksrc/skins/vrtx/event.c b/ksrc/skins/vrtx/event.c index d0d30ec..8ff0857 100644 --- a/ksrc/skins/vrtx/event.c +++ b/ksrc/skins/vrtx/event.c @@ -27,72 +27,102 @@ static xnqueue_t vrtx_event_q; #ifdef CONFIG_PROC_FS -static int __event_read_proc(char *page, -char **start, -off_t off, int count, int *eof, void *data) -{ - vrtxevent_t *evgroup = (vrtxevent_t *)data; - char *p = page; - int len; - spl_t s; +struct vfile_priv { + struct xnpholder *curr; + int value; +}; - xnlock_get_irqsave(&nklock, s); +struct vfile_data { + int opt; + int mask; + char name[XNOBJECT_NAME_LEN]; +}; - p += sprintf(p, "=0x%x\n", evgroup->events); +static int vfile_rewind(struct xnvfile_snapshot_iterator *it) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct vrtxevent *evgroup = xnvfile_priv(it->vfile); - if (xnsynch_nsleepers(&evgroup->synchbase) > 0) { - xnpholder_t *holder; + priv->curr = getheadpq(xnsynch_wait_queue(&evgroup->synchbase)); + priv->value = evgroup->events; - /* Pended event -- dump waiters. */ + return xnsynch_nsleepers(&evgroup->synchbase); +} - holder = getheadpq(xnsynch_wait_queue(&evgroup->synchbase)); +static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct vrtxevent *evgroup = xnvfile_priv(it->vfile); + struct vfile_data *p = data; + struct xnthread *thread; + struct vrtxtask *task; - while (holder) { - xnthread_t *sleeper = link2thread(holder, plink); - vrtxtask_t *task = thread2vrtxtask(sleeper); - const char *mode = - (task->waitargs.evgroup. -opt & 1) ? "all" : "any"; - int mask = task->waitargs.evgroup.mask; - p += sprintf(p, "+%s (mask=0x%x, %s)\n", -xnthread_name(sleeper), mask, mode); - holder = - nextpq(xnsynch_wait_queue(&evgroup->synchbase), - holder); - } - } + priv->value = evgroup->events; /* Refresh as we collect. */ - xnlock_put_irqrestore(&nklock, s); + if (priv->curr == NULL) + return 0; /* We are done. */ + + /* Fetch current waiter, advance list cursor. */ + thread = link2thread(priv->curr, plink); + priv->curr = nextpq(xnsynch_wait_queue(&evgroup->synchbase), + priv->curr); - len = (p - page) - off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; + /* Collect thread name to be output in ->show(). */ + strncpy(p->name, xnthread_name(thread), sizeof(p->name)); + task = thread2vrtxtask(thread); + p->opt = task->waitargs.evgroup.opt; + p->mask = task->waitargs.evgroup.mask; - return len; + return 1; } -extern xnptree_t __vrtx_ptree; +static int vfile_show(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct vfile_data *p = data; + + if (p == NULL) {/* Dump header. */ + /* Always dump current event mask value. */ + xnvfile_printf(it, "=0x%x\n", priv->value); + if (it->nrdata > 0) + xnvfile_printf(it, "\n%10s %4s %s\n", + "MASK", "MODE", "WAITER"); + } else + xnvfile_printf(it, "0x%-8x %4s %.*s\n", + p->mask, + p->opt & 1 ? "all" : "any", + (int)sizeof(p->name), p->name);
[Xenomai-git] Philippe Gerum : rtai: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 269bf7db68d667eca7ae672f21a970d58fb46c5c URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=269bf7db68d667eca7ae672f21a970d58fb46c5c Author: Philippe Gerum Date: Mon Jun 7 19:41:15 2010 +0200 rtai: convert to vfile --- ksrc/skins/rtai/fifo.c | 78 ++-- ksrc/skins/rtai/module.c |9 + ksrc/skins/rtai/shm.c| 81 +++--- 3 files changed, 95 insertions(+), 73 deletions(-) diff --git a/ksrc/skins/rtai/fifo.c b/ksrc/skins/rtai/fifo.c index d2724ff..49d6f27 100644 --- a/ksrc/skins/rtai/fifo.c +++ b/ksrc/skins/rtai/fifo.c @@ -27,49 +27,63 @@ static RT_FIFO __fifo_table[CONFIG_XENO_OPT_PIPE_NRDEV]; #ifdef CONFIG_PROC_FS -extern xnptree_t __rtai_ptree; +struct vfile_priv { + size_t bufsz; + size_t fillsz; + void *handler; + int refcnt; +}; -static int __fifo_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) +static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { - RT_FIFO *p = data; - char *ptrW = page; - int len; + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + RT_FIFO *fifo = xnvfile_priv(it->vfile); + + priv->bufsz = fifo->bufsz; + priv->fillsz = fifo->fillsz; + priv->handler = fifo->handler; + priv->refcnt = fifo->refcnt; + + return 0; +} - ptrW += sprintf(ptrW, "Size - Written - F - Handler - Ref\n"); +static int vfile_show(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + xnvfile_printf(it, "Size - Written - F - Handler - Ref\n"); /* Output buffer: xnpipe_mh_t *buffer; */ - ptrW += sprintf(ptrW, "%08zX - %08zX - %p - %i\n", - p->bufsz, p->fillsz, p->handler, p->refcnt); - - len = ptrW - page - off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; - - return len; + xnvfile_printf(it, "%08zX - %08zX - %p - %i\n", + priv->bufsz, priv->fillsz, priv->handler, priv->refcnt); + + return 0; } -static xnpnode_t __fifo_pnode = { +static struct xnvfile_snapshot_ops vfile_ops = { + .rewind = vfile_rewind, + .show = vfile_show, +}; - .dir = NULL, - .type = "fifo", - .entries = 0, - .read_proc = &__fifo_read_proc, - .write_proc = NULL, - .root = &__rtai_ptree, +extern struct xnptree __rtai_ptree; + +static struct xnpnode_file __fifo_pnode = { + .node = { + .dirname = "fifo", + .root = &__rtai_ptree, + .ops = &xnregistry_vfile_ops, + }, + .vfile = { + .privsz = sizeof(struct vfile_priv), + .ops = &vfile_ops, + }, }; #else /* !CONFIG_PROC_FS */ -static xnpnode_t __fifo_pnode = { - - .type = "fifo" +static struct xnpnode_file __fifo_pnode = { + .node = { + .dirname = "fifo", + }, }; #endif /* !CONFIG_PROC_FS */ @@ -240,7 +254,7 @@ int rtf_create(unsigned minor, int size) fifo->handle = 0; snprintf(fifo->name, sizeof(fifo->name), "rtf%u", minor); - xnregistry_enter(fifo->name, fifo, &fifo->handle, &__fifo_pnode); + xnregistry_enter(fifo->name, fifo, &fifo->handle, &__fifo_pnode.node); return minor; diff --git a/ksrc/skins/rtai/module.c b/ksrc/skins/rtai/module.c index 13367b5..32e35bb 100644 --- a/ksrc/skins/rtai/module.c +++ b/ksrc/skins/rtai/module.c @@ -42,14 +42,7 @@ MODULE_PARM_DESC(sync_time, "Set non-zero to synchronize on master time base"); xntbase_t *rtai_tbase; -#ifdef CONFIG_PROC_FS -xnptree_t __rtai_ptree = { - - .dir = NULL, - .name = "rtai", - .entries = 0, -}; -#endif /* CONFIG_PROC_FS */ +DEFINE_XNPTREE(__rtai_ptree, "rtai"); static void rtai_shutdown(int xtype) { diff --git a/ksrc/skins/rtai/shm.c b/ksrc/skins/rtai/shm.c index 96b7ae1..9c1c026 100644 --- a/ksrc/skins/rtai/shm.c +++ b/ksrc/skins/rtai/shm.c @@ -55,47 +55,62 @@ xnqueue_t xnshm_allocq; #ifdef CONFIG_PROC_FS -extern xnptree_t __rtai_ptree; +struct vfile_priv { + int size; + char szName[6]; + unsigned long name; + unsigned int refcnt; +}; -static int __shm_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) +static int vfile_rewind(struct xnvfile_snapshot_iterator *it) { - xnshm_a_t *p = data; - char *ptrW = page; - int len; - - ptrW += sprintf(ptrW, "Name - Ptr - Size - Ref\n"); - ptrW += sprintf(ptrW, "%s - %08lX - %08X - %i\n", - p->szName,
[Xenomai-git] Philippe Gerum : vxworks: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: a0c8728fac5ac207492fb892398117d21765cfbf URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=a0c8728fac5ac207492fb892398117d21765cfbf Author: Philippe Gerum Date: Sun Jun 6 19:06:33 2010 +0200 vxworks: convert to vfile --- ksrc/skins/vxworks/module.c |9 +-- ksrc/skins/vxworks/msgQLib.c | 133 -- ksrc/skins/vxworks/semLib.c | 147 +++--- ksrc/skins/vxworks/wdLib.c | 121 ++- 4 files changed, 256 insertions(+), 154 deletions(-) diff --git a/ksrc/skins/vxworks/module.c b/ksrc/skins/vxworks/module.c index 830df76..632f5d2 100644 --- a/ksrc/skins/vxworks/module.c +++ b/ksrc/skins/vxworks/module.c @@ -39,14 +39,7 @@ xntbase_t *wind_tbase; wind_rholder_t __wind_global_rholder; -#ifdef CONFIG_PROC_FS -xnptree_t __vxworks_ptree = { - - .dir = NULL, - .name = "vxworks", - .entries = 0, -}; -#endif /* CONFIG_PROC_FS */ +DEFINE_XNPTREE(__vxworks_ptree, "vxworks"); int SKIN_INIT(vxworks) { diff --git a/ksrc/skins/vxworks/msgQLib.c b/ksrc/skins/vxworks/msgQLib.c index 0acb574..590668c 100644 --- a/ksrc/skins/vxworks/msgQLib.c +++ b/ksrc/skins/vxworks/msgQLib.c @@ -24,69 +24,102 @@ static int msgq_destroy_internal(wind_msgq_t *queue); #ifdef CONFIG_PROC_FS -static int msgq_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) -{ - wind_msgq_t *queue = (wind_msgq_t *)data; - char *p = page; - int len; - spl_t s; - - p += sprintf(p, "porder=%s:mlength=%u:mcount=%d\n", -xnsynch_test_flags(&queue->synchbase, - XNSYNCH_PRIO) ? "prio" : "fifo", -queue->msg_length, countq(&queue->msgq)); - - xnlock_get_irqsave(&nklock, s); - - if (xnsynch_nsleepers(&queue->synchbase) > 0) { - xnpholder_t *holder; +struct vfile_priv { + struct xnpholder *curr; + int flags; + unsigned int mlength; + int mcount; +}; - /* Pended queue -- dump waiters. */ +struct vfile_data { + char name[XNOBJECT_NAME_LEN]; +}; - holder = getheadpq(xnsynch_wait_queue(&queue->synchbase)); +static int vfile_rewind(struct xnvfile_snapshot_iterator *it) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + wind_msgq_t *q = xnvfile_priv(it->vfile); - while (holder) { - xnthread_t *sleeper = link2thread(holder, plink); - p += sprintf(p, "+%s\n", xnthread_name(sleeper)); - holder = - nextpq(xnsynch_wait_queue(&queue->synchbase), - holder); - } - } + q = wind_h2obj_active((MSG_Q_ID)q, WIND_MSGQ_MAGIC, wind_msgq_t); + if (q == NULL) + return -EIDRM; - xnlock_put_irqrestore(&nklock, s); + priv->curr = getheadpq(xnsynch_wait_queue(&q->synchbase)); + priv->flags = xnsynch_test_flags(&q->synchbase, XNSYNCH_PRIO); + priv->mlength = q->msg_length; + priv->mcount = countq(&q->msgq); - len = (p - page) - off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; + return xnsynch_nsleepers(&q->synchbase); +} - return len; +static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + wind_msgq_t *q = xnvfile_priv(it->vfile); + struct vfile_data *p = data; + struct xnthread *thread; + + if (priv->curr == NULL) + return 0; /* We are done. */ + + /* Fetch current waiter, advance list cursor. */ + thread = link2thread(priv->curr, plink); + priv->curr = nextpq(xnsynch_wait_queue(&q->synchbase), + priv->curr); + /* Collect thread name to be output in ->show(). */ + strncpy(p->name, xnthread_name(thread), sizeof(p->name)); + + return 1; } -extern xnptree_t __vxworks_ptree; +static int vfile_show(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct vfile_data *p = data; + + if (p == NULL) {/* Dump header. */ + xnvfile_printf(it, + "porder=%s:mlength=%u:mcount=%d\n", + priv->flags ? "prio" : "fifo", + priv->mlength, + priv->mcount); + if (it->nrdata > 0) + /* Queue is pended -- dump waiters */ + xnvfile_printf(it, "--
[Xenomai-git] Philippe Gerum : native: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 1c33fe0a4f3e6722cd39b2f693df0a5a3f498089 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=1c33fe0a4f3e6722cd39b2f693df0a5a3f498089 Author: Philippe Gerum Date: Thu Apr 29 18:22:32 2010 +0200 native: convert to vfile --- ksrc/nucleus/heap.c|2 +- ksrc/skins/native/alarm.c | 127 +- ksrc/skins/native/buffer.c | 168 +++- ksrc/skins/native/cond.c | 110 + ksrc/skins/native/event.c | 132 ++- ksrc/skins/native/heap.c | 142 +++-- ksrc/skins/native/intr.c | 137 ++-- ksrc/skins/native/module.c |9 +-- ksrc/skins/native/mutex.c | 147 -- ksrc/skins/native/pipe.c | 40 +++ ksrc/skins/native/queue.c | 139 - ksrc/skins/native/sem.c| 124 + 12 files changed, 792 insertions(+), 485 deletions(-) diff --git a/ksrc/nucleus/heap.c b/ksrc/nucleus/heap.c index 64e2b7c..422d8ca 100644 --- a/ksrc/nucleus/heap.c +++ b/ksrc/nucleus/heap.c @@ -144,7 +144,7 @@ static int vfile_show(struct xnvfile_snapshot_iterator *it, void *data) p->usable_mem, p->used_mem, p->page_size, - sizeof(p->label), + (int)sizeof(p->label), p->label); return 0; } diff --git a/ksrc/skins/native/alarm.c b/ksrc/skins/native/alarm.c index 1130dfb..351fa8b 100644 --- a/ksrc/skins/native/alarm.c +++ b/ksrc/skins/native/alarm.c @@ -45,67 +45,98 @@ #ifdef CONFIG_PROC_FS -static int __alarm_read_proc(char *page, -char **start, -off_t off, int count, int *eof, void *data) -{ - RT_ALARM *alarm = (RT_ALARM *)data; - char *p = page; - int len; - spl_t s; +struct vfile_priv { + struct xnpholder *curr; + RTIME interval; + unsigned long expiries; +}; - xnlock_get_irqsave(&nklock, s); +struct vfile_data { + char name[XNOBJECT_NAME_LEN]; +}; - p += sprintf(p, "interval=%Lu:expiries=%lu\n", -rt_timer_tsc2ns(xntimer_interval(&alarm->timer_base)), -alarm->expiries); +static int vfile_rewind(struct xnvfile_snapshot_iterator *it) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + RT_ALARM *alarm = xnvfile_priv(it->vfile); -#ifdef CONFIG_XENO_OPT_PERVASIVE - { - xnpholder_t *holder = - getheadpq(xnsynch_wait_queue(&alarm->synch_base)); - - while (holder) { - xnthread_t *sleeper = link2thread(holder, plink); - p += sprintf(p, "+%s\n", xnthread_name(sleeper)); - holder = - nextpq(xnsynch_wait_queue(&alarm->synch_base), - holder); - } - } -#endif /* CONFIG_XENO_OPT_PERVASIVE */ + alarm = xeno_h2obj_validate(alarm, XENO_ALARM_MAGIC, RT_ALARM); + if (alarm == NULL) + return -EIDRM; - xnlock_put_irqrestore(&nklock, s); + priv->curr = getheadpq(xnsynch_wait_queue(&alarm->synch_base)); + priv->interval = rt_timer_tsc2ns(xntimer_interval(&alarm->timer_base)); + priv->expiries = alarm->expiries; - len = (p - page) - off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; + return xnsynch_nsleepers(&alarm->synch_base); +} - return len; +static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + RT_ALARM *alarm = xnvfile_priv(it->vfile); + struct vfile_data *p = data; + struct xnthread *thread; + + if (priv->curr == NULL) + return 0; /* We are done. */ + + /* Fetch current waiter, advance list cursor. */ + thread = link2thread(priv->curr, plink); + priv->curr = nextpq(xnsynch_wait_queue(&alarm->synch_base), + priv->curr); + /* Collect thread name to be output in ->show(). */ + strncpy(p->name, xnthread_name(thread), sizeof(p->name)); + + return 1; } -extern xnptree_t __native_ptree; +static int vfile_show(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct vfile_data *p = data; + + if (p == NULL) {/* Dump header. */ + xnvfile_printf(it, "%8s %s\n", "INTERVAL", "EXPIRIES"); +
[Xenomai-git] Philippe Gerum : uitron: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 8e7747c4b2225e281a17c3067425a9c0cc808260 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=8e7747c4b2225e281a17c3067425a9c0cc808260 Author: Philippe Gerum Date: Tue Jun 1 16:47:00 2010 +0200 uitron: convert to vfile --- ksrc/skins/uitron/flag.c | 123 --- ksrc/skins/uitron/mbx.c| 119 +++ ksrc/skins/uitron/module.c |9 +--- ksrc/skins/uitron/sem.c| 118 +++--- 4 files changed, 231 insertions(+), 138 deletions(-) diff --git a/ksrc/skins/uitron/flag.c b/ksrc/skins/uitron/flag.c index c7f3c0d..1d74741 100644 --- a/ksrc/skins/uitron/flag.c +++ b/ksrc/skins/uitron/flag.c @@ -25,65 +25,102 @@ static xnmap_t *ui_flag_idmap; #ifdef CONFIG_PROC_FS -static int __flag_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) -{ - uiflag_t *flag = (uiflag_t *)data; - char *p = page; - int len; - spl_t s; +struct vfile_priv { + struct xnpholder *curr; + unsigned long value; +}; - xnlock_get_irqsave(&nklock, s); +struct vfile_data { + UINT wfmode; + UINT waiptn; + char name[XNOBJECT_NAME_LEN]; +}; - p += sprintf(p, "=0x%x, attr=%s\n", flag->flgvalue, -flag->flgatr & TA_WMUL ? "TA_WMUL" : "TA_WSGL"); +static int vfile_rewind(struct xnvfile_snapshot_iterator *it) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct uiflag *flag = xnvfile_priv(it->vfile); - if (xnsynch_nsleepers(&flag->synchbase) > 0) { - xnpholder_t *holder; + priv->curr = getheadpq(xnsynch_wait_queue(&flag->synchbase)); + priv->value = flag->flgvalue; - /* Pended flag -- dump waiters. */ + return xnsynch_nsleepers(&flag->synchbase); +} - holder = getheadpq(xnsynch_wait_queue(&flag->synchbase)); +static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct uiflag *flag = xnvfile_priv(it->vfile); + struct vfile_data *p = data; + struct xnthread *thread; + struct uitask *task; - while (holder) { - xnthread_t *sleeper = link2thread(holder, plink); - p += sprintf(p, "+%s\n", xnthread_name(sleeper)); - holder = nextpq(xnsynch_wait_queue(&flag->synchbase), holder); - } - } + priv->value = flag->flgvalue; /* Refresh as we collect. */ - xnlock_put_irqrestore(&nklock, s); + if (priv->curr == NULL) + return 0; /* We are done. */ + + /* Fetch current waiter, advance list cursor. */ + thread = link2thread(priv->curr, plink); + priv->curr = nextpq(xnsynch_wait_queue(&flag->synchbase), + priv->curr); - len = (p - page) - off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; + /* Collect thread name to be output in ->show(). */ + strncpy(p->name, xnthread_name(thread), sizeof(p->name)); + task = thread2uitask(thread); + p->wfmode = task->wargs.flag.wfmode; + p->waiptn = task->wargs.flag.waiptn; - return len; + return 1; } -extern xnptree_t __uitron_ptree; +static int vfile_show(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct vfile_data *p = data; + + if (p == NULL) {/* Dump header. */ + /* Always dump current flag value. */ + xnvfile_printf(it, "=0x%lx\n", priv->value); + if (it->nrdata > 0) + xnvfile_printf(it, "\n%10s %4s %s\n", + "WAITPN", "WFMODE", "WAITER"); + } else + xnvfile_printf(it, "0x%-8x %4s %.*s\n", + p->waiptn, + p->wfmode & TWF_ORW ? "OR" : "AND", + (int)sizeof(p->name), p->name); + + return 0; +} -static xnpnode_t __flag_pnode = { +static struct xnvfile_snapshot_ops vfile_ops = { + .rewind = vfile_rewind, + .next = vfile_next, + .show = vfile_show, +}; - .dir = NULL, - .type = "flags", - .entries = 0, - .read_proc = &__flag_read_proc, - .write_proc = NULL, - .root = &__uitron_ptree, +extern struct xnptree __uitron_ptree; + +static struct xnpnode_file __flag_pnode = { + .node = { + .dirname = "flags", + .root = &__uitron_ptree, + .ops = &xnregistry_vfile_ops, + }, +
[Xenomai-git] Philippe Gerum : rtipc: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 67d5384971693de5524aad6e1b2339895948269a URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=67d5384971693de5524aad6e1b2339895948269a Author: Philippe Gerum Date: Thu May 27 15:47:14 2010 +0200 rtipc: convert to vfile --- ksrc/drivers/ipc/bufp.c | 38 +- ksrc/drivers/ipc/iddp.c | 38 +- ksrc/drivers/ipc/rtipc.c |9 + ksrc/drivers/ipc/xddp.c | 38 +- 4 files changed, 76 insertions(+), 47 deletions(-) diff --git a/ksrc/drivers/ipc/bufp.c b/ksrc/drivers/ipc/bufp.c index 7517b79..714849f 100644 --- a/ksrc/drivers/ipc/bufp.c +++ b/ksrc/drivers/ipc/bufp.c @@ -76,26 +76,38 @@ static struct xnmap *portmap; #ifdef CONFIG_PROC_FS -static ssize_t __bufp_link_proc(char *buf, int count, void *data) +static char *__bufp_link_target(void *obj) { - struct bufp_socket *sk = data; - return snprintf(buf, count, "%d", sk->name.sipc_port); + struct bufp_socket *sk = obj; + char *buf; + + /* XXX: older kernels don't have kasprintf(). */ + buf = kmalloc(32, GFP_KERNEL); + if (buf == NULL) + return buf; + + snprintf(buf, 32, "%d", sk->name.sipc_port); + + return buf; } -static struct xnpnode __bufp_pnode = { +extern struct xnptree rtipc_ptree; - .dir = NULL, - .type = "bufp", - .entries = 0, - .link_proc = &__bufp_link_proc, - .root = &rtipc_ptree, +static struct xnpnode_link __bufp_pnode = { + .node = { + .dirname = "bufp", + .root = &rtipc_ptree, + .ops = &xnregistry_vlink_ops, + }, + .target = __bufp_link_target, }; #else /* !CONFIG_PROC_FS */ -static struct xnpnode __bufp_pnode = { - - .type = "bufp" +static struct xnpnode_link __bufp_pnode = { + .node = { + .dirname = "bufp", + }, }; #endif /* !CONFIG_PROC_FS */ @@ -717,7 +729,7 @@ static int __bufp_bind_socket(struct rtipc_private *priv, if (*sk->label) { ret = xnregistry_enter(sk->label, sk, - &sk->handle, &__bufp_pnode); + &sk->handle, &__bufp_pnode.node); if (ret) { xnarch_free_host_mem(sk->bufmem, sk->bufsz); goto fail; diff --git a/ksrc/drivers/ipc/iddp.c b/ksrc/drivers/ipc/iddp.c index 8a1b079..706c119 100644 --- a/ksrc/drivers/ipc/iddp.c +++ b/ksrc/drivers/ipc/iddp.c @@ -81,26 +81,38 @@ static int poolwait; #ifdef CONFIG_PROC_FS -static ssize_t __iddp_link_proc(char *buf, int count, void *data) +static char *__iddp_link_target(void *obj) { - struct iddp_socket *sk = data; - return snprintf(buf, count, "%d", sk->name.sipc_port); + struct iddp_socket *sk = obj; + char *buf; + + /* XXX: older kernels don't have kasprintf(). */ + buf = kmalloc(32, GFP_KERNEL); + if (buf == NULL) + return buf; + + snprintf(buf, 32, "%d", sk->name.sipc_port); + + return buf; } -static struct xnpnode __iddp_pnode = { +extern struct xnptree rtipc_ptree; - .dir = NULL, - .type = "iddp", - .entries = 0, - .link_proc = &__iddp_link_proc, - .root = &rtipc_ptree, +static struct xnpnode_link __iddp_pnode = { + .node = { + .dirname = "iddp", + .root = &rtipc_ptree, + .ops = &xnregistry_vlink_ops, + }, + .target = __iddp_link_target, }; #else /* !CONFIG_PROC_FS */ -static struct xnpnode __iddp_pnode = { - - .type = "iddp" +static struct xnpnode_link __iddp_pnode = { + .node = { + .dirname = "iddp", + }, }; #endif /* !CONFIG_PROC_FS */ @@ -578,7 +590,7 @@ static int __iddp_bind_socket(struct rtipc_private *priv, if (*sk->label) { ret = xnregistry_enter(sk->label, sk, - &sk->handle, &__iddp_pnode); + &sk->handle, &__iddp_pnode.node); if (ret) { if (poolsz > 0) xnheap_destroy(&sk->privpool, diff --git a/ksrc/drivers/ipc/rtipc.c b/ksrc/drivers/ipc/rtipc.c index 71629cb..e5a0bc0 100644 --- a/ksrc/drivers/ipc/rtipc.c +++ b/ksrc/drivers/ipc/rtipc.c @@ -35,14 +35,7 @@ static struct rtipc_protocol *protocols[IPCPROTO_MAX] = { #endif }; -#ifdef CONFIG_PROC_FS -struct xnptree rtipc_ptree = { - - .dir = NULL, - .name = "rtipc", - .entries = 0, -}; -#endif /* CONFIG_PROC_FS */ +DEFINE_XNPTREE(rtipc_ptree, "rtipc"); int rtipc_get_arg(rtdm_user_info_t *user_info, void *dst, const void *src, size_t len) diff --git a/ksrc/drivers/ipc/xddp.c b/ksrc/drivers/ipc/xddp.c index c2a65e9..bcf272f 100644 --- a/ksrc/drivers/ipc/xddp.c +++ b/ksrc/dr
[Xenomai-git] Philippe Gerum : hal: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 54da7c72e2f9018de1442f416506fb5d0d0e6428 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=54da7c72e2f9018de1442f416506fb5d0d0e6428 Author: Philippe Gerum Date: Thu Jun 10 12:23:58 2010 +0200 hal: convert to vfile Moved all vfiles to the nucleus. --- include/asm-generic/hal.h | 40 +++- ksrc/arch/generic/hal.c | 222 +--- ksrc/arch/generic/nmi.c | 99 - 3 files changed, 38 insertions(+), 323 deletions(-) diff --git a/include/asm-generic/hal.h b/include/asm-generic/hal.h index 84c1a4d..e8f101c 100644 --- a/include/asm-generic/hal.h +++ b/include/asm-generic/hal.h @@ -400,6 +400,13 @@ struct rthal_calibration_data { unsigned long clock_freq; }; +struct rthal_apc_desc { + void (*handler)(void *cookie); + void *cookie; + const char *name; + unsigned long hits[RTHAL_NR_CPUS]; +}; + typedef int (*rthal_trap_handler_t)(unsigned trapno, unsigned domid, void *data); @@ -418,7 +425,11 @@ extern volatile int rthal_sync_op; extern rthal_trap_handler_t rthal_trap_handler; -extern unsigned rthal_realtime_faults[RTHAL_NR_CPUS][RTHAL_NR_FAULTS]; +extern unsigned int rthal_realtime_faults[RTHAL_NR_CPUS][RTHAL_NR_FAULTS]; + +extern unsigned long rthal_apc_map; + +extern struct rthal_apc_desc rthal_apc_table[RTHAL_NR_APCS]; extern int rthal_arch_init(void); @@ -432,7 +443,7 @@ void rthal_critical_exit(unsigned long flags); #ifdef CONFIG_XENO_HW_NMI_DEBUG_LATENCY -extern unsigned rthal_maxlat_us; +extern unsigned int rthal_maxlat_us; extern unsigned long rthal_maxlat_tsc; @@ -446,15 +457,11 @@ void rthal_nmi_arm(unsigned long delay); void rthal_nmi_disarm(void); -void rthal_nmi_proc_register(void); - -void rthal_nmi_proc_unregister(void); +void rthal_nmi_set_maxlat(unsigned int maxlat_us); #else /* !CONFIG_XENO_HW_NMI_DEBUG_LATENCY */ #define rthal_nmi_init(efn)do { } while(0) #define rthal_nmi_release()do { } while(0) -#define rthal_nmi_proc_register() do { } while(0) -#define rthal_nmi_proc_unregister()do { } while(0) #endif /* CONFIG_XENO_HW_NMI_DEBUG_LATENCY */ /* Public interface */ @@ -541,25 +548,8 @@ static inline int rthal_cpu_supported(int cpu) } #endif /* !CONFIG_SMP */ -#ifdef CONFIG_PROC_FS - -#include - -extern struct proc_dir_entry *rthal_proc_root; - -struct proc_dir_entry *rthal_add_proc_leaf(const char *name, - read_proc_t rdproc, - write_proc_t wrproc, - void *data, - struct proc_dir_entry *parent); - -struct proc_dir_entry *rthal_add_proc_seq(const char *name, - struct file_operations *fops, - size_t size, - struct proc_dir_entry *parent); -#endif /* CONFIG_PROC_FS */ - #ifdef CONFIG_IPIPE_TRACE + #include static inline int rthal_trace_max_begin(unsigned long v) diff --git a/ksrc/arch/generic/hal.c b/ksrc/arch/generic/hal.c index 8a5ec39..6239b0f 100644 --- a/ksrc/arch/generic/hal.c +++ b/ksrc/arch/generic/hal.c @@ -42,12 +42,7 @@ #endif #include #include -#include -#include #include -#ifdef CONFIG_PROC_FS -#include -#endif /* CONFIG_PROC_FS */ #include MODULE_LICENSE("GPL"); @@ -69,21 +64,10 @@ cpumask_t rthal_supported_cpus; EXPORT_SYMBOL(rthal_supported_cpus); #endif /* CONFIG_SMP */ -static struct { - -void (*handler) (void *cookie); -void *cookie; -const char *name; -unsigned long hits[RTHAL_NR_CPUS]; - -} rthal_apc_table[RTHAL_NR_APCS]; - static int rthal_init_done; static unsigned rthal_apc_virq; -static unsigned long rthal_apc_map; - static unsigned long rthal_apc_pending[RTHAL_NR_CPUS]; static rthal_spinlock_t rthal_apc_lock = RTHAL_SPIN_LOCK_UNLOCKED; @@ -98,6 +82,10 @@ rthal_trap_handler_t rthal_trap_handler; unsigned rthal_realtime_faults[RTHAL_NR_CPUS][RTHAL_NR_FAULTS]; +unsigned long rthal_apc_map; + +struct rthal_apc_desc rthal_apc_table[RTHAL_NR_APCS]; + volatile int rthal_sync_op; unsigned long rthal_critical_enter(void (*synch) (void)) @@ -615,190 +603,6 @@ int rthal_apc_schedule(int apc) return 0; } -#ifdef CONFIG_PROC_FS - -struct proc_dir_entry *rthal_proc_root; - -static int hal_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) -{ -int len, major, minor, patchlevel; - -major = IPIPE_MAJOR_NUMBER; -minor = IPIPE_MINOR_NUMBER; -patchlevel = IPIPE_PATCH_NUMBER; - -len = sprintf(page, "%d.%d-%.2d\n", major, minor, patchlevel); -len -= off; -if (len <= off + count) -*eof = 1; -*start = page + off; -i
[Xenomai-git] Philippe Gerum : nucleus/timebase: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: b7d27bba6f62498330a4e4f1d6d998b29749f6d4 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=b7d27bba6f62498330a4e4f1d6d998b29749f6d4 Author: Philippe Gerum Date: Thu Jun 10 12:22:48 2010 +0200 nucleus/timebase: convert to vfile --- include/nucleus/timebase.h | 14 ++- ksrc/nucleus/timebase.c| 345 ksrc/nucleus/timer.c | 51 +++ 3 files changed, 189 insertions(+), 221 deletions(-) diff --git a/include/nucleus/timebase.h b/include/nucleus/timebase.h index 5c8678e..40dc54a 100644 --- a/include/nucleus/timebase.h +++ b/include/nucleus/timebase.h @@ -30,6 +30,8 @@ #if defined(__KERNEL__) || defined(__XENO_SIM__) +#include + struct xntimer; typedef struct xntbops { @@ -75,9 +77,9 @@ typedef struct xntbase { #define link2tbase(ln) container_of(ln, xntbase_t, link) #ifdef CONFIG_XENO_OPT_STATS - xnqueue_t timerq; /* !< Timer holder in timebase. */ - - int timerq_rev; /* !< Revision (for non-atomic list walks). */ + struct xnvfile_snapshot vfile; /* !< Virtual file for access. */ + struct xnvfile_rev_tag revtag; /* !< Revision (for non-atomic list walks). */ + struct xnqueue timerq; /* !< Timer holder in timebase. */ #endif /* CONFIG_XENO_OPT_STATS */ } xntbase_t; @@ -322,8 +324,6 @@ do {\ removeq(&nktimebaseq, &nktbase.link); \ } while (0) -#endif /* __KERNEL__ || __XENO_SIM__ */ - void xntbase_init_proc(void); void xntbase_cleanup_proc(void); @@ -336,6 +336,10 @@ static inline void xntbase_declare_proc(xntbase_t *base) { } static inline void xntbase_remove_proc(xntbase_t *base) { } #endif /* !CONFIG_XENO_OPT_STATS */ +extern struct xnvfile_rev_tag tbaselist_tag; + +#endif /* __KERNEL__ || __XENO_SIM__ */ + /*...@}*/ #endif /* !_XENO_NUCLEUS_TIMEBASE_H */ diff --git a/ksrc/nucleus/timebase.c b/ksrc/nucleus/timebase.c index 48be711..1b951df 100644 --- a/ksrc/nucleus/timebase.c +++ b/ksrc/nucleus/timebase.c @@ -165,6 +165,7 @@ int xntbase_alloc(const char *name, u_long period, u_long flags, xntbase_declare_proc(base); xnlock_get_irqsave(&nklock, s); appendq(&nktimebaseq, &base->link); + xnvfile_touch_tag(&tbaselist_tag); xnlock_put_irqrestore(&nklock, s); xnarch_declare_tbase(base); @@ -209,6 +210,7 @@ void xntbase_free(xntbase_t *base) xnlock_get_irqsave(&nklock, s); removeq(&nktimebaseq, &base->link); + xnvfile_touch_tag(&tbaselist_tag); xnlock_put_irqrestore(&nklock, s); xnarch_free_host_mem(base, sizeof(*base)); @@ -620,256 +622,225 @@ EXPORT_SYMBOL_GPL(xntbase_adjust_time); #ifdef CONFIG_PROC_FS -#include +struct xnvfile_rev_tag tbaselist_tag; -#ifdef CONFIG_XENO_OPT_STATS +static struct xnvfile_snapshot_ops tbase_vfile_ops; -#include - -static struct proc_dir_entry *tmstat_proc_root; - -struct tmstat_seq_iterator { - int nentries; - struct tmstat_seq_info { - int cpu; - unsigned int scheduled; - unsigned int fired; - xnticks_t timeout; - xnticks_t interval; - xnflags_t status; - char handler[12]; - char name[XNOBJECT_NAME_LEN]; - } stat_info[1]; +struct tbase_vfile_priv { + struct xnholder *curr; }; -static void *tmstat_seq_start(struct seq_file *seq, loff_t *pos) -{ - struct tmstat_seq_iterator *iter = seq->private; +struct tbase_vfile_data { + unsigned int enabled : 1; + unsigned int set : 1; + unsigned int isolated : 1; + unsigned int periodic : 1; + xnticks_t jiffies; + unsigned long tickvalue; + char name[XNOBJECT_NAME_LEN]; +}; - if (*pos > iter->nentries) - return NULL; +static struct xnvfile_snapshot tbase_vfile = { + .privsz = sizeof(struct tbase_vfile_priv), + .datasz = sizeof(struct tbase_vfile_data), + .tag = &tbaselist_tag, + .ops = &tbase_vfile_ops, +}; - if (*pos == 0) - return SEQ_START_TOKEN; +static int tbase_vfile_rewind(struct xnvfile_snapshot_iterator *it) +{ + struct tbase_vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + + priv->curr = getheadq(&nktimebaseq); - return iter->stat_info + *pos - 1; + return countq(&nktimebaseq); } -static void *tmstat_seq_next(struct seq_file *seq, void *v, loff_t *pos) +static int tbase_vfile_next(struct xnvfile_snapshot_iterator *it, void *data) { - struct tmstat_seq_iterator *iter = seq->private; + struct tbase_vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct tbase_vfile_data *p = data; + struct xntbase *base; - ++*pos; + if (priv->curr == NULL) + return 0; - if (*pos > iter->nentries) - return NULL; +
[Xenomai-git] Philippe Gerum : nucleus/intr: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: a21686c025f268e8d69b571e6cf1e35c148b89e0 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=a21686c025f268e8d69b571e6cf1e35c148b89e0 Author: Philippe Gerum Date: Thu Jun 10 12:23:12 2010 +0200 nucleus/intr: convert to vfile --- ksrc/nucleus/intr.c | 153 +++--- 1 files changed, 70 insertions(+), 83 deletions(-) diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c index a6de4ea..bdaa4ed 100644 --- a/ksrc/nucleus/intr.c +++ b/ksrc/nucleus/intr.c @@ -983,28 +983,27 @@ int xnintr_query_next(int irq, xnintr_iterator_t *iterator, char *name_buf) #ifdef CONFIG_PROC_FS -#include -#include +#include -static int format_irq_proc(unsigned int irq, char *str) +static inline int format_irq_proc(unsigned int irq, + struct xnvfile_regular_iterator *it) { - xnintr_t *intr; - char *p = str; + struct xnintr *intr; spl_t s; if (rthal_virtual_irq_p(irq)) { - p += sprintf(p, " [virtual]"); - return p - str; + xnvfile_puts(it, " [virtual]"); + return 0; } else if (irq == XNARCH_TIMER_IRQ) { - p += sprintf(p, " [timer]"); - return p - str; + xnvfile_puts(it, " [timer]"); + return 0; #ifdef CONFIG_SMP } else if (irq == RTHAL_SERVICE_IPI0) { - p += sprintf(p, " [IPI]"); - return p - str; + xnvfile_puts(it, " [IPI]"); + return 0; } else if (irq == RTHAL_CRITICAL_IPI) { - p += sprintf(p, " [critical sync]"); - return p - str; + xnvfile_puts(it, " [critical sync]"); + return 0; #endif /* CONFIG_SMP */ } @@ -1012,134 +1011,122 @@ static int format_irq_proc(unsigned int irq, char *str) intr = xnintr_shirq_first(irq); if (intr) { - strcpy(p, ""); p += 8; + xnvfile_puts(it, ""); do { - *p = ' '; p += 1; - strcpy(p, intr->name); p += strlen(intr->name); - + xnvfile_putc(it, ' '); + xnvfile_puts(it, intr->name); intr = xnintr_shirq_next(intr); } while (intr); } xnlock_put_irqrestore(&intrlock, s); - return p - str; + return 0; } -static int irq_read_proc(char *page, -char **start, -off_t off, int count, int *eof, void *data) +static int irq_vfile_show(struct xnvfile_regular_iterator *it, + void *data) { - int len = 0, cpu, irq; - char *p = page; + int cpu, irq; - p += sprintf(p, "IRQ "); + xnvfile_puts(it, "IRQ "); - for_each_online_cpu(cpu) { - p += sprintf(p, "CPU%d", cpu); - } + for_each_online_cpu(cpu) + xnvfile_printf(it, "CPU%d", cpu); for (irq = 0; irq < XNARCH_NR_IRQS; irq++) { if (rthal_irq_handler(&rthal_domain, irq) == NULL) continue; - p += sprintf(p, "\n%3d:", irq); + xnvfile_printf(it, "\n%3d:", irq); for_each_online_cpu(cpu) { - p += sprintf(p, "%12lu", -rthal_cpudata_irq_hits(&rthal_domain, cpu, - irq)); + xnvfile_printf(it, "%12lu", + rthal_cpudata_irq_hits(&rthal_domain, cpu, + irq)); } - p += format_irq_proc(irq, p); + format_irq_proc(irq, it); } - p += sprintf(p, "\n"); + xnvfile_putc(it, '\n'); - len = p - page - off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; - - return len; + return 0; } +static struct xnvfile_regular_ops irq_vfile_ops = { + .show = irq_vfile_show, +}; + +static struct xnvfile_regular irq_vfile = { + .ops = &irq_vfile_ops, +}; + #ifdef CONFIG_SMP -static int affinity_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) + +static int affinity_vfile_show(struct xnvfile_regular_iterator *it, + void *data) { unsigned long val = 0; - int len, cpu; + int cpu; - for (cpu = 0; cpu < sizeof(val) * 8; cpu++) + for (cpu = 0; cpu < BITS_PER_LONG; cpu++) if (xnarch_
[Xenomai-git] Philippe Gerum : nucleus/sched: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 9bf8d636ecee8095b79fb95be32ca6ecbd013c62 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=9bf8d636ecee8095b79fb95be32ca6ecbd013c62 Author: Philippe Gerum Date: Tue May 25 16:27:57 2010 +0200 nucleus/sched: convert to vfile --- include/nucleus/pod.h | 13 +- include/nucleus/sched.h |9 +- ksrc/nucleus/pod.c| 16 +- ksrc/nucleus/sched-idle.c |1 - ksrc/nucleus/sched-rt.c | 213 +- ksrc/nucleus/sched-sporadic.c | 232 ++- ksrc/nucleus/sched-tp.c | 208 +- ksrc/nucleus/sched.c | 653 - 8 files changed, 522 insertions(+), 823 deletions(-) diff --git a/include/nucleus/pod.h b/include/nucleus/pod.h index bab9f07..1ad6014 100644 --- a/include/nucleus/pod.h +++ b/include/nucleus/pod.h @@ -71,8 +71,9 @@ struct xnpod { xnsched_t sched[XNARCH_NR_CPUS];/*!< Per-cpu scheduler slots. */ xnqueue_t threadq; /*!< All existing threads. */ - int threadq_rev;/*!< Modification counter of threadq. */ - +#ifdef CONFIG_PROC_FS + struct xnvfile_rev_tag threadlist_tag; +#endif xnqueue_t tstartq, /*!< Thread start hook queue. */ tswitchq, /*!< Thread switch hook queue. */ tdeleteq; /*!< Thread delete hook queue. */ @@ -104,17 +105,17 @@ extern xnarch_cpumask_t nkaffinity; extern xnpod_t nkpod_struct; #ifdef CONFIG_PROC_FS -void xnpod_init_proc(void); +int xnpod_init_proc(void); void xnpod_cleanup_proc(void); #else /* !CONFIG_PROC_FS */ -static inline void xnpod_init_proc(void) {} +static inline int xnpod_init_proc(void) { return 0; } static inline void xnpod_cleanup_proc(void) {} #endif /* !CONFIG_PROC_FS */ -static inline void xnpod_mount(void) +static inline int xnpod_mount(void) { xnsched_register_classes(); - xnpod_init_proc(); + return xnpod_init_proc(); } static inline void xnpod_umount(void) diff --git a/include/nucleus/sched.h b/include/nucleus/sched.h index 441a3a2..f8cc059 100644 --- a/include/nucleus/sched.h +++ b/include/nucleus/sched.h @@ -35,6 +35,7 @@ #include #include #include +#include /* Sched status flags */ #define XNKCOUT0x8000 /* Sched callout context */ @@ -141,9 +142,9 @@ struct xnsched_class { void (*sched_resume_rpi)(struct xnthread *thread); #endif #ifdef CONFIG_PROC_FS - void (*sched_init_proc)(struct proc_dir_entry *root); - void (*sched_cleanup_proc)(struct proc_dir_entry *root); - struct proc_dir_entry *proc; + int (*sched_init_vfile)(struct xnsched_class *schedclass, + struct xnvfile_directory *vfroot); + void (*sched_cleanup_vfile)(struct xnsched_class *schedclass); #endif int nthreads; struct xnsched_class *next; @@ -242,7 +243,7 @@ static inline void xnsched_reset_watchdog(struct xnsched *sched) #include #include -void xnsched_init_proc(void); +int xnsched_init_proc(void); void xnsched_cleanup_proc(void); diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c index 7002a73..7e8a3b7 100644 --- a/ksrc/nucleus/pod.c +++ b/ksrc/nucleus/pod.c @@ -652,7 +652,7 @@ int xnpod_init_thread(struct xnthread *thread, xnlock_get_irqsave(&nklock, s); appendq(&nkpod->threadq, &thread->glink); - nkpod->threadq_rev++; + xnvfile_touch_tag(&nkpod->threadlist_tag); xnpod_suspend_thread(thread, XNDORMANT | (attr->flags & XNSUSP), XN_INFINITE, XN_RELATIVE, NULL); xnlock_put_irqrestore(&nklock, s); @@ -1174,7 +1174,7 @@ void xnpod_delete_thread(xnthread_t *thread) thread, xnthread_name(thread)); removeq(&nkpod->threadq, &thread->glink); - nkpod->threadq_rev++; + xnvfile_touch_tag(&nkpod->threadlist_tag); if (xnthread_test_state(thread, XNREADY)) { XENO_BUGON(NUCLEUS, xnthread_test_state(thread, XNTHREAD_BLOCK_BITS)); @@ -3203,12 +3203,17 @@ static int version_read_proc(char *page, return len; } -void xnpod_init_proc(void) +int xnpod_init_proc(void) { + int ret; + if (rthal_proc_root == NULL) - return; + return -ENOMEM; + + ret = xnsched_init_proc(); + if (ret) + return ret; - xnsched_init_proc(); xntbase_init_proc(); xntimer_init_proc(); xnheap_init_proc(); @@ -3226,6 +3231,7 @@ void xnpod_init_proc(void) rthal_add_proc_leaf("lock", &lock_read_proc, NULL, NULL, rthal_proc_root); #endif /* XENO_DEBUG(XNLOCK) */ + return 0; } void xnpod_cleanup_proc(void) diff --git a/ksrc/nucleus/sched-idle.c b/ksrc/nucleus/sched-idle.c index 39faa6a..124cd67 100644 --- a/ksrc/nucleus/sched-idle.c +++ b/ksrc/nucleus/sched-idle.c @@ -48,7 +48,6 @@ void xnsched_idle_
[Xenomai-git] Philippe Gerum : nucleus/pod: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 7b94b2d03ffb2223b9c61e699ce16697593b2eaa URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=7b94b2d03ffb2223b9c61e699ce16697593b2eaa Author: Philippe Gerum Date: Wed Jun 9 18:36:17 2010 +0200 nucleus/pod: convert to vfile --- ksrc/nucleus/pod.c | 263 +++- 1 files changed, 179 insertions(+), 84 deletions(-) diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c index 7e8a3b7..1e5d8c5 100644 --- a/ksrc/nucleus/pod.c +++ b/ksrc/nucleus/pod.c @@ -3094,16 +3094,13 @@ EXPORT_SYMBOL_GPL(xnpod_set_thread_tslice); #if XENO_DEBUG(XNLOCK) -xnlockinfo_t xnlock_stats[RTHAL_NR_CPUS]; +xnlockinfo_t xnlock_stats[XNARCH_NR_CPUS]; +EXPORT_SYMBOL_GPL(xnlock_stats); -static int lock_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) +static int lock_vfile_show(struct xnvfile_regular_iterator *it, void *data) { xnlockinfo_t lockinfo; - int cpu, len = 0; - char *p = page; - spl_t s; + int cpu; for_each_online_cpu(cpu) { @@ -3112,11 +3109,11 @@ static int lock_read_proc(char *page, xnlock_put_irqrestore(&nklock, s); if (cpu > 0) - p += sprintf(p, "\n"); + xnvfile_printf(it, "\n"); - p += sprintf(p, "CPU%d:\n", cpu); + xnvfile_printf(it, "CPU%d:\n", cpu); - p += sprintf(p, + xnvfile_printf(it, " longest locked section: %llu ns\n" " spinning time: %llu ns\n" " section entry: %s:%d (%s)\n", @@ -3125,90 +3122,181 @@ static int lock_read_proc(char *page, lockinfo.file, lockinfo.line, lockinfo.function); } - len = p - page - off; + return 0; +} - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; +static struct xnvfile_regular_ops lock_vfile_ops = { + .show = lock_vfile_show, +}; - return len; -} -EXPORT_SYMBOL_GPL(xnlock_stats); +static struct xnvfile_regular lock_vfile = { + .ops = &lock_vfile_ops, +}; #endif /* XENO_DEBUG(XNLOCK) */ -static int latency_read_proc(char *page, -char **start, -off_t off, int count, int *eof, void *data) +static int latency_vfile_show(struct xnvfile_regular_iterator *it, void *data) { - int len; - - len = sprintf(page, "%Lu\n", xnarch_tsc_to_ns(nklatency)); - len -= off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; - - return len; + xnvfile_printf(it, "%Lu\n", xnarch_tsc_to_ns(nklatency)); + + return 0; } -static int latency_write_proc(struct file *file, - const char __user * buffer, - unsigned long count, void *data) +static ssize_t latency_vfile_store(struct xnvfile_input *input) { - char *end, buf[16]; - long ns; - int n; + ssize_t ret; + long val; - n = count > sizeof(buf) - 1 ? sizeof(buf) - 1 : count; + ret = xnvfile_get_integer(input, &val); + if (ret < 0) + return ret; - if (copy_from_user(buf, buffer, n)) - return -EFAULT; + nklatency = xnarch_ns_to_tsc(val); - buf[n] = '\0'; - ns = simple_strtol(buf, &end, 0); + return ret; +} - if ((*end != '\0' && !isspace(*end)) || ns < 0) - return -EINVAL; +static struct xnvfile_regular_ops latency_vfile_ops = { + .show = latency_vfile_show, + .store = latency_vfile_store, +}; + +static struct xnvfile_regular latency_vfile = { + .ops = &latency_vfile_ops, +}; + +static int version_vfile_show(struct xnvfile_regular_iterator *it, void *data) +{ + xnvfile_printf(it, "%s\n", XENO_VERSION_STRING); + + return 0; +} + +static struct xnvfile_regular_ops version_vfile_ops = { + .show = version_vfile_show, +}; + +static struct xnvfile_regular version_vfile = { + .ops = &version_vfile_ops, +}; + +static int faults_vfile_show(struct xnvfile_regular_iterator *it, void *data) +{ + int cpu, trap; + + xnvfile_puts(it, "TRAP "); + + for_each_online_cpu(cpu) + xnvfile_printf(it, "CPU%d", cpu); + + for (trap = 0; rthal_fault_labels[trap]; trap++) { + if (*rthal_fault_labels[trap] == '\0') + continue; + + xnvfile_printf(it, "\n%3d: ", trap); + + for_each_online_cpu(cpu) + xnvfile_printf(it, "%12u", +
[Xenomai-git] Philippe Gerum : nucleus/heap: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 29c9b9208fd9a1a4f7ecaadc1b6a2cfc3b788953 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=29c9b9208fd9a1a4f7ecaadc1b6a2cfc3b788953 Author: Philippe Gerum Date: Wed Apr 28 17:01:42 2010 +0200 nucleus/heap: convert to vfile --- ksrc/nucleus/heap.c | 171 --- 1 files changed, 95 insertions(+), 76 deletions(-) diff --git a/ksrc/nucleus/heap.c b/ksrc/nucleus/heap.c index afcc4f8..64e2b7c 100644 --- a/ksrc/nucleus/heap.c +++ b/ksrc/nucleus/heap.c @@ -66,18 +66,106 @@ HEAP { #include #include #include +#include #include #include -xnheap_t kheap;/* System heap */ +struct xnheap kheap; /* System heap */ EXPORT_SYMBOL_GPL(kheap); #if CONFIG_XENO_OPT_SYS_STACKPOOLSZ > 0 -xnheap_t kstacks; /* Private stack pool */ +struct xnheap kstacks; /* Private stack pool */ #endif -static DEFINE_XNQUEUE(heapq); /* Heap list for /proc reporting */ -static unsigned long heapq_rev; +static DEFINE_XNQUEUE(heapq); /* Heap list for v-file dump */ + +#ifdef CONFIG_PROC_FS + +static struct xnvfile_rev_tag vfile_tag; + +static struct xnvfile_snapshot_ops vfile_ops; + +struct vfile_priv { + struct xnholder *curr; +}; + +struct vfile_data { + size_t usable_mem; + size_t used_mem; + size_t page_size; + char label[XNOBJECT_NAME_LEN+16]; +}; + +static struct xnvfile_snapshot vfile = { + .privsz = sizeof(struct vfile_priv), + .datasz = sizeof(struct vfile_data), + .tag = &vfile_tag, + .ops = &vfile_ops, +}; + +static int vfile_rewind(struct xnvfile_snapshot_iterator *it) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + + priv->curr = getheadq(&heapq); + + return countq(&heapq); +} + +static int vfile_next(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_priv *priv = xnvfile_snapshot_iterator_priv(it); + struct vfile_data *p = data; + struct xnheap *heap; + + if (priv->curr == NULL) + return 0; /* We are done. */ + + heap = container_of(priv->curr, struct xnheap, stat_link); + priv->curr = nextq(&heapq, priv->curr); + + p->usable_mem = xnheap_usable_mem(heap); + p->used_mem = xnheap_used_mem(heap); + p->page_size = xnheap_page_size(heap); + strncpy(p->label, heap->label, sizeof(p->label)); + + return 1; +} + +static int vfile_show(struct xnvfile_snapshot_iterator *it, void *data) +{ + struct vfile_data *p = data; + + if (p == NULL) + xnvfile_printf(it, "%9s %9s %6s %s\n", + "TOTAL", "USED", "PAGESZ", "NAME"); + else + xnvfile_printf(it, "%9Zu %9Zu %6Zu %.*s\n", + p->usable_mem, + p->used_mem, + p->page_size, + sizeof(p->label), + p->label); + return 0; +} + +static struct xnvfile_snapshot_ops vfile_ops = { + .rewind = vfile_rewind, + .next = vfile_next, + .show = vfile_show, +}; + +void xnheap_init_proc(void) +{ + xnvfile_init_snapshot("heap", &vfile, NULL); +} + +void xnheap_cleanup_proc(void) +{ + xnvfile_destroy_snapshot(&vfile); +} + +#endif /* CONFIG_PROC_FS */ static void init_extent(xnheap_t *heap, xnextent_t *extent) { @@ -241,7 +329,7 @@ int xnheap_init(xnheap_t *heap, xnlock_get_irqsave(&nklock, s); appendq(&heapq, &heap->stat_link); - heapq_rev++; + xnvfile_touch_tag(&vfile_tag); xnlock_put_irqrestore(&nklock, s); xnarch_init_display_context(heap); @@ -325,7 +413,7 @@ void xnheap_destroy(xnheap_t *heap, xnlock_get_irqsave(&nklock, s); removeq(&heapq, &heap->stat_link); - heapq_rev++; + xnvfile_touch_tag(&vfile_tag); xnlock_put_irqrestore(&nklock, s); if (!flushfn) @@ -1298,7 +1386,7 @@ void xnheap_destroy_mapped(xnheap_t *heap, xnlock_get_irqsave(&nklock, s); removeq(&heapq, &heap->stat_link); - heapq_rev++; + xnvfile_touch_tag(&vfile_tag); xnlock_put_irqrestore(&nklock, s); len = xnheap_extentsize(heap); @@ -1408,75 +1496,6 @@ void xnheap_destroy_mapped(xnheap_t *heap, } #endif /* !CONFIG_XENO_OPT_PERVASIVE */ -#ifdef CONFIG_PROC_FS - -#include - -static int heap_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) -{ - unsigned long rev; - xnholder_t *entry; - xnheap_t *heap; - int len; - spl_t s; - - if (!xnpod_active_p()) - return -ESRCH; - - xnlock_get_irqsave(&nklock, s); - -restart: - len = 0; - - entry = getheadq(&heapq); - while (entry) { - heap = container_of(entry, xnheap_t, stat_link)
[Xenomai-git] Philippe Gerum : nucleus/registry: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: 7aacae151ede87aa0e70b8a8ac281d5f98f7d7f6 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=7aacae151ede87aa0e70b8a8ac281d5f98f7d7f6 Author: Philippe Gerum Date: Tue May 25 17:37:11 2010 +0200 nucleus/registry: convert to vfile --- include/nucleus/registry.h | 168 +--- ksrc/nucleus/Makefile |2 + ksrc/nucleus/registry.c| 475 3 files changed, 357 insertions(+), 288 deletions(-) diff --git a/include/nucleus/registry.h b/include/nucleus/registry.h index 6bd5ec9..34780f6 100644 --- a/include/nucleus/registry.h +++ b/include/nucleus/registry.h @@ -31,37 +31,33 @@ #if defined(__KERNEL__) || defined(__XENO_SIM__) #include +#include struct xnpnode; typedef struct xnobject { - -xnholder_t link; - -#define link2xnobj(ln) container_of(ln, xnobject_t, link) - -void *objaddr; - -const char *key; /* !< Hash key. */ - -xnsynch_t safesynch; /* !< Safe synchronization object. */ - -u_long safelock;/* !< Safe lock count. */ - -u_long cstamp; /* !< Creation stamp. */ - -struct xnobject *hnext;/* !< Next in h-table */ - + void *objaddr; + const char *key; /* !< Hash key. */ + struct xnsynch safesynch; /* !< Safe synchronization object. */ + u_long safelock; /* !< Safe lock count. */ + u_long cstamp;/* !< Creation stamp. */ #ifdef CONFIG_PROC_FS - -struct xnpnode *pnode; /* !< /proc information class. */ - -struct proc_dir_entry *proc; /* !< /proc entry. */ - + struct xnpnode *pnode; /* !< v-file information class. */ + union { + struct { + struct xnvfile_rev_tag tag; + struct xnvfile_snapshot vfile; + } file; /* !< virtual file. */ + struct xnvfile_link link; /* !< virtual link. */ + } vfile_u; + struct xnvfile *vfilp; #endif /* CONFIG_PROC_FS */ - + struct xnobject *hnext; /* !< Next in h-table */ + struct xnholder link; } xnobject_t; +#define link2xnobj(ln) container_of(ln, struct xnobject, link) + #ifdef __cplusplus extern "C" { #endif @@ -72,41 +68,65 @@ void xnregistry_cleanup(void); #ifdef CONFIG_PROC_FS -#include - -#define XNOBJECT_PROC_RESERVED1 ((struct proc_dir_entry *)1) -#define XNOBJECT_PROC_RESERVED2 ((struct proc_dir_entry *)2) - -typedef ssize_t link_proc_t(char *buf, - int count, - void *data); -typedef struct xnptree { - -struct proc_dir_entry *dir; -const char *name; -int entries; - -} xnptree_t; +#define XNOBJECT_PNODE_RESERVED1 ((struct xnvfile *)1) +#define XNOBJECT_PNODE_RESERVED2 ((struct xnvfile *)2) + +struct xnptree { + const char *dirname; + /* hidden */ + int entries; + struct xnvfile_directory vdir; +}; + +#define DEFINE_XNPTREE(__var, __name) \ + struct xnptree __var = {\ + .dirname = __name, \ + .entries = 0, \ + .vdir = xnvfile_nodir, \ + } -typedef struct xnpnode { +struct xnpnode_ops { + int (*export)(struct xnobject *object, struct xnpnode *pnode); + void (*unexport)(struct xnobject *object, struct xnpnode *pnode); + void (*touch)(struct xnobject *object); +}; + +struct xnpnode { + const char *dirname; + struct xnptree *root; + struct xnpnode_ops *ops; + /* hidden */ + int entries; + struct xnvfile_directory vdir; +}; + +struct xnpnode_file { + struct xnpnode node; + struct xnvfile_snapshot_template vfile; +}; + +struct xnpnode_link { + struct xnpnode node; + char *(*target)(void *obj); +}; -struct proc_dir_entry *dir; -const char *type; -int entries; -read_proc_t *read_proc; -write_proc_t *write_proc; -link_proc_t *link_proc; -xnptree_t *root; +#else /* !CONFIG_PROC_FS */ -} xnpnode_t; +#define DEFINE_XNPTREE(__var, __name); -#else /* !CONFIG_PROC_FS */ +/* Placeholders. */ -typedef struct xnpnode { /* Placeholder. */ +struct xnpnode { + const char *dirname; +}; -const char *type; +struct xnpnode_file { + struct xnpnode node; +}; -} xnpnode_t; +struct xnpnode_link { + struct xnpnode node; +}; #endif /* !CONFIG_PROC_FS */ @@ -114,26 +134,7 @@ extern struct xnobject *registry_obj_slots; /* Public interface. */ -int xnregistry_enter(const char *key, -void *objaddr, -xnhandle_t *phandle, -xnpnode_t *pnode); - -int xnregistry_bind(const char *key, - xnticks_t timeout, - int timeout_mode, - xnhandle_t *phandle); - -int xnregistry_remove(xnhandle_t handle); - -int xnregistry_remove_safe(xnhandle_t handle, -
[Xenomai-git] Philippe Gerum : nucleus/shadow: convert to vfile
Module: xenomai-rpm Branch: queue/vfile Commit: b4d79515b97c0c1d6a9be6a43c0734ae2d1155b4 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=b4d79515b97c0c1d6a9be6a43c0734ae2d1155b4 Author: Philippe Gerum Date: Sun May 16 13:34:34 2010 +0200 nucleus/shadow: convert to vfile --- include/nucleus/shadow.h | 11 ksrc/nucleus/shadow.c| 151 +++-- 2 files changed, 77 insertions(+), 85 deletions(-) diff --git a/include/nucleus/shadow.h b/include/nucleus/shadow.h index b6971da..764a7c8 100644 --- a/include/nucleus/shadow.h +++ b/include/nucleus/shadow.h @@ -54,11 +54,6 @@ struct xnskin_props { struct module *module; }; -struct xnskin_slot { - struct xnskin_props *props; - atomic_counter_t refcnt; -}; - int xnshadow_mount(void); void xnshadow_cleanup(void); @@ -103,8 +98,6 @@ void xnshadow_send_sig(struct xnthread *thread, void xnshadow_rpi_check(void); -extern struct xnskin_slot muxtable[]; - int xnshadow_mark_sig(struct xnthread *thread, unsigned muxid); void xnshadow_clear_sig(struct xnthread *thread, unsigned muxid); @@ -118,13 +111,9 @@ void xnshadow_clear_sig(struct xnthread *thread, unsigned muxid); #if defined(CONFIG_XENO_OPT_PERVASIVE) && defined(CONFIG_PROC_FS) void xnshadow_init_proc(void); void xnshadow_cleanup_proc(void); -void xnshadow_declare_proc(struct xnskin_slot *iface); -void xnshadow_remove_proc(const char *iface); #else static inline void xnshadow_init_proc(void) { } static inline void xnshadow_cleanup_proc(void) { } -#define xnshadow_declare_proc(iface) do { (void)iface; } while(0) -#define xnshadow_remove_proc(iface)do { (void)name; } while(0) #endif /* CONFIG_XENO_OPT_PERVASIVE && CONFIG_PROC_FS */ #endif /* !_XENO_NUCLEUS_SHADOW_H */ diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c index 1a32527..160ff80 100644 --- a/ksrc/nucleus/shadow.c +++ b/ksrc/nucleus/shadow.c @@ -64,7 +64,13 @@ EXPORT_SYMBOL_GPL(nkthrptd); int nkerrptd; EXPORT_SYMBOL_GPL(nkerrptd); -struct xnskin_slot muxtable[XENOMAI_MUX_NR]; +struct xnskin_slot { + struct xnskin_props *props; + atomic_counter_t refcnt; +#ifdef CONFIG_PROC_FS + struct xnvfile_regular vfile; +#endif +} muxtable[XENOMAI_MUX_NR]; static int lostage_apc; @@ -100,6 +106,8 @@ static int nucleus_muxid = -1; static DECLARE_MUTEX(completion_mutex); +static DECLARE_MUTEX(registration_mutex); + static inline struct task_struct *get_switch_lock_owner(void) { return switch_lock_owner[task_cpu(current)]; @@ -2637,6 +2645,44 @@ static inline void do_cleanup_event(struct mm_struct *mm) RTHAL_DECLARE_CLEANUP_EVENT(cleanup_event); +#ifdef CONFIG_PROC_FS + +static struct xnvfile_directory iface_vfroot; + +static int iface_vfile_show(struct xnvfile_regular_iterator *it, void *data) +{ + struct xnskin_slot *iface; + int refcnt; + + iface = container_of(it->vfile, struct xnskin_slot, vfile); + refcnt = xnarch_atomic_get(&iface->refcnt); + xnvfile_printf(it, "%d\n", refcnt); + + return 0; +} + +static struct xnvfile_regular_ops iface_vfile_ops = { + .show = iface_vfile_show, +}; + +void xnshadow_init_proc(void) +{ + xnvfile_init_dir("interfaces", &iface_vfroot, NULL); +} + +void xnshadow_cleanup_proc(void) +{ + int muxid; + + for (muxid = 0; muxid < XENOMAI_MUX_NR; muxid++) + if (muxtable[muxid].props && muxtable[muxid].props->name) + xnvfile_destroy_regular(&muxtable[muxid].vfile); + + xnvfile_destroy_dir(&iface_vfroot); +} + +#endif /* CONFIG_PROC_FS */ + /* * xnshadow_register_interface() -- Register a new skin/interface. * NOTE: an interface can be registered without its pod being @@ -2661,6 +2707,7 @@ RTHAL_DECLARE_CLEANUP_EVENT(cleanup_event); int xnshadow_register_interface(struct xnskin_props *props) { + struct xnskin_slot *iface; int muxid; spl_t s; @@ -2671,22 +2718,34 @@ int xnshadow_register_interface(struct xnskin_props *props) if (XENOMAI_MAX_SYSENT < props->nrcalls || 0 > props->nrcalls) return -EINVAL; + down(®istration_mutex); + xnlock_get_irqsave(&nklock, s); for (muxid = 0; muxid < XENOMAI_MUX_NR; muxid++) { - if (muxtable[muxid].props == NULL) { - muxtable[muxid].props = props; - xnarch_atomic_set(&muxtable[muxid].refcnt, 0); + iface = muxtable + muxid; + if (iface->props == NULL) { + iface->props = props; + xnarch_atomic_set(&iface->refcnt, 0); break; } } xnlock_put_irqrestore(&nklock, s); - if (muxid >= XENOMAI_MUX_NR) + if (muxid >= XENOMAI_MUX_NR) { + up(®istration_mutex); return -ENOBUFS; + } - xnshadow_declare_proc(muxtable + muxid); +#ifdef CO
[Xenomai-git] Philippe Gerum : nucleus: introduce virtual file support
Module: xenomai-rpm Branch: queue/vfile Commit: 2ca77b4777a3b8a9171ed2db4c8df5aedec39d2b URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=2ca77b4777a3b8a9171ed2db4c8df5aedec39d2b Author: Philippe Gerum Date: Tue May 25 17:36:56 2010 +0200 nucleus: introduce virtual file support Virtual files provide a mean to export Xenomai object states to user-space, based on common kernel interfaces. This encapsulation is aimed at: - supporting consistent collection of very large record-based output, without encurring latency peaks for undergoing real-time activities. - in the future, hiding discrepancies between linux kernel releases, regarding the proper way to export kernel object states to userland, either via the /proc interface or by any other mean. This virtual file implementation offers record-based read support based on seq_files, single-buffer write support, directory and link handling, all visible from the /proc namespace. --- include/nucleus/vfile.h | 285 ksrc/nucleus/vfile.c| 658 +++ 2 files changed, 943 insertions(+), 0 deletions(-) diff --git a/include/nucleus/vfile.h b/include/nucleus/vfile.h new file mode 100644 index 000..ab1fd91 --- /dev/null +++ b/include/nucleus/vfile.h @@ -0,0 +1,285 @@ +/** + * @file + * This file is part of the Xenomai project. + * + * @note Copyright (C) 2010 Philippe Gerum + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * \ingroup vfile + */ + +#ifndef _XENO_NUCLEUS_VFILE_H +#define _XENO_NUCLEUS_VFILE_H + +#ifdef CONFIG_PROC_FS + +#include +#include +#include + +struct xnvfile_directory; +struct xnvfile_regular_iterator; +struct xnvfile_snapshot_iterator; +struct xnvfile_lock_ops; + +struct xnvfile { + struct proc_dir_entry *pde; + struct xnvfile_directory *parent; + struct xnvfile_lock_ops *lockops; + void *private; +}; + +struct xnvfile_lock_ops { + void (*get)(struct xnvfile *vfile); + void (*put)(struct xnvfile *vfile); +}; + +/* + * XXX: struct semaphore is legacy for mutual exclusion, but supported + * on both 2.4 and 2.6 kernels. Will be changed to mutex when 2.4 + * support is dropped from Xenomai. + */ +struct xnvfile_hostlock_class { + struct xnvfile_lock_ops ops; + struct semaphore sem; +}; + +struct xnvfile_nklock_class { + struct xnvfile_lock_ops ops; + spl_t s; +}; + +struct xnvfile_input { + const char __user *u_buf; + size_t size; + struct xnvfile *vfile; +}; + +struct xnvfile_regular_ops { + void *(*begin)(struct xnvfile_regular_iterator *it); + void *(*next)(struct xnvfile_regular_iterator *it); + void (*end)(struct xnvfile_regular_iterator *it); + int (*show)(struct xnvfile_regular_iterator *it, void *data); + ssize_t (*store)(struct xnvfile_input *input); +}; + +struct xnvfile_regular { + struct xnvfile entry; + size_t privsz; + struct xnvfile_regular_ops *ops; +}; + +struct xnvfile_regular_template { + size_t privsz; + struct xnvfile_regular_ops *ops; + struct xnvfile_lock_ops *lockops; +}; + +struct xnvfile_regular_iterator { + loff_t pos; + struct seq_file *seq; + struct xnvfile_regular *vfile; + char private[0]; +}; + +struct xnvfile_snapshot_ops { + int (*rewind)(struct xnvfile_snapshot_iterator *it); + void *(*begin)(struct xnvfile_snapshot_iterator *it); + int (*next)(struct xnvfile_snapshot_iterator *it, void *data); + void (*end)(struct xnvfile_snapshot_iterator *it, void *buf); + int (*show)(struct xnvfile_snapshot_iterator *it, void *data); + ssize_t (*store)(struct xnvfile_input *input); +}; + +struct xnvfile_rev_tag { + int rev; +}; + +struct xnvfile_snapshot_template { + size_t privsz; + size_t datasz; + struct xnvfile_rev_tag *tag; + struct xnvfile_snapshot_ops *ops; + struct xnvfile_lock_ops *lockops; +}; + +struct xnvfile_snapshot { + struct xnvfile entry; + size_t privsz; + size_t datasz; + struct xnvfile_rev_tag *tag; + struct xnvfile_snapshot_ops *ops; +}; + +struct xnvfile_snapshot_iterator { + int nrdata; + caddr_t databuf; + struct seq_file *seq; + struct xnvfile_