[Xenomai-git] Philippe Gerum : nucleus/timebase: convert to vfile

2010-07-04 Thread GIT version control
Module: xenomai-rpm
Branch: queue/rtipc
Commit: 6d822e82521f8784720f6a955e875b86d1088b64
URL:
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=6d822e82521f8784720f6a955e875b86d1088b64

Author: Philippe Gerum r...@xenomai.org
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 nucleus/vfile.h
+
 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..87cde0b 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 linux/proc_fs.h
+struct xnvfile_rev_tag tbaselist_tag;
 
-#ifdef CONFIG_XENO_OPT_STATS
+static struct xnvfile_snapshot_ops tbase_vfile_ops;
 
-#include linux/seq_file.h
-
-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_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_iterator_priv(it);
+   struct tbase_vfile_data *p = data;
+   struct xntbase *base;
 
-   ++*pos;
+   if (priv-curr == NULL)
+   return 0;
 
-   if (*pos  iter-nentries)
-   return 

[Xenomai-git] Philippe Gerum : nucleus/timebase: convert to vfile

2010-07-03 Thread GIT version control
Module: xenomai-rpm
Branch: queue/vfile
Commit: 6d822e82521f8784720f6a955e875b86d1088b64
URL:
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=6d822e82521f8784720f6a955e875b86d1088b64

Author: Philippe Gerum r...@xenomai.org
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 nucleus/vfile.h
+
 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..87cde0b 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 linux/proc_fs.h
+struct xnvfile_rev_tag tbaselist_tag;
 
-#ifdef CONFIG_XENO_OPT_STATS
+static struct xnvfile_snapshot_ops tbase_vfile_ops;
 
-#include linux/seq_file.h
-
-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_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_iterator_priv(it);
+   struct tbase_vfile_data *p = data;
+   struct xntbase *base;
 
-   ++*pos;
+   if (priv-curr == NULL)
+   return 0;
 
-   if (*pos  iter-nentries)
-   return 

[Xenomai-git] Philippe Gerum : nucleus/timebase: convert to vfile

2010-06-27 Thread GIT version control
Module: xenomai-rpm
Branch: queue/vfile
Commit: 406bf077e9119a86f837a4c7904ff622e652d3fe
URL:
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=406bf077e9119a86f837a4c7904ff622e652d3fe

Author: Philippe Gerum r...@xenomai.org
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 nucleus/vfile.h
+
 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..87cde0b 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 linux/proc_fs.h
+struct xnvfile_rev_tag tbaselist_tag;
 
-#ifdef CONFIG_XENO_OPT_STATS
+static struct xnvfile_snapshot_ops tbase_vfile_ops;
 
-#include linux/seq_file.h
-
-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_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_iterator_priv(it);
+   struct tbase_vfile_data *p = data;
+   struct xntbase *base;
 
-   ++*pos;
+   if (priv-curr == NULL)
+   return 0;
 
-   if (*pos  iter-nentries)
-   return 

[Xenomai-git] Philippe Gerum : nucleus/timebase: convert to vfile

2010-06-18 Thread GIT version control
Module: xenomai-rpm
Branch: queue/vfile
Commit: 54a104951be5a45deeaa886384ea6d4d4015f6c2
URL:
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=54a104951be5a45deeaa886384ea6d4d4015f6c2

Author: Philippe Gerum r...@xenomai.org
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 nucleus/vfile.h
+
 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..d648fe1 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 linux/proc_fs.h
+struct xnvfile_rev_tag tbaselist_tag;
 
-#ifdef CONFIG_XENO_OPT_STATS
+static struct xnvfile_snapshot_ops tbase_vfile_ops;
 
-#include linux/seq_file.h
-
-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_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_iterator_priv(it);
+   struct tbase_vfile_data *p = data;
+   struct xntbase *base;
 
-   ++*pos;
+   if (priv-curr == NULL)
+   return 0;
 
-   if (*pos  iter-nentries)
-   return 

[Xenomai-git] Philippe Gerum : nucleus/timebase: convert to vfile

2010-06-17 Thread GIT version control
Module: xenomai-rpm
Branch: queue/vfile
Commit: 64fa7116c764135b3a737d43040659d715db44d2
URL:
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=64fa7116c764135b3a737d43040659d715db44d2

Author: Philippe Gerum r...@xenomai.org
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 nucleus/vfile.h
+
 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..d648fe1 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 linux/proc_fs.h
+struct xnvfile_rev_tag tbaselist_tag;
 
-#ifdef CONFIG_XENO_OPT_STATS
+static struct xnvfile_snapshot_ops tbase_vfile_ops;
 
-#include linux/seq_file.h
-
-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_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_iterator_priv(it);
+   struct tbase_vfile_data *p = data;
+   struct xntbase *base;
 
-   ++*pos;
+   if (priv-curr == NULL)
+   return 0;
 
-   if (*pos  iter-nentries)
-   return 

[Xenomai-git] Philippe Gerum : nucleus/timebase: convert to vfile

2010-06-11 Thread GIT version control
Module: xenomai-rpm
Branch: queue/vfile
Commit: b7d27bba6f62498330a4e4f1d6d998b29749f6d4
URL:
http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=b7d27bba6f62498330a4e4f1d6d998b29749f6d4

Author: Philippe Gerum r...@xenomai.org
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 nucleus/vfile.h
+
 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 linux/proc_fs.h
+struct xnvfile_rev_tag tbaselist_tag;
 
-#ifdef CONFIG_XENO_OPT_STATS
+static struct xnvfile_snapshot_ops tbase_vfile_ops;
 
-#include linux/seq_file.h
-
-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)
-