Module: xenomai-rpm Branch: queue/vfile Commit: 421dfe3deb68b84aefc3247e010f28b42150e6e0 URL: http://git.xenomai.org/?p=xenomai-rpm.git;a=commit;h=421dfe3deb68b84aefc3247e010f28b42150e6e0
Author: Philippe Gerum <r...@xenomai.org> Date: Wed Jun 9 18:36:17 2010 +0200 nucleus/pod: convert to vfile --- ksrc/nucleus/pod.c | 263 +++++++++++++++++++++++++++++++++++---------------- 1 files changed, 180 insertions(+), 83 deletions(-) diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c index 7e8a3b7..f346cf4 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,183 @@ 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, +}; - nklatency = xnarch_ns_to_tsc(ns); +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 count; + return 0; } -static int version_read_proc(char *page, - char **start, - off_t off, int count, int *eof, void *data) +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 len; - - len = sprintf(page, "%s\n", XENO_VERSION_STRING); - len -= off; - if (len <= off + count) - *eof = 1; - *start = page + off; - if (len > count) - len = count; - if (len < 0) - len = 0; - - return len; + 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", + rthal_realtime_faults[cpu][trap]); + + xnvfile_printf(it, " (%s)", + rthal_fault_labels[trap]); + } + + xnvfile_putc(it, '\n'); + + return 0; } -int xnpod_init_proc(void) +static struct xnvfile_regular_ops faults_vfile_ops = { + .show = faults_vfile_show, +}; + +static struct xnvfile_regular faults_vfile = { + .ops = &faults_vfile_ops, +}; + +static int apc_vfile_show(struct xnvfile_regular_iterator *it, void *data) +{ + int cpu, apc; + + /* We assume the entire output fits in a single page. */ + + xnvfile_puts(it, "APC "); + + for_each_online_cpu(cpu) + xnvfile_printf(it, " CPU%d", cpu); + + for (apc = 0; apc < BITS_PER_LONG; apc++) { + if (!test_bit(apc, &rthal_apc_map)) + continue; /* Not hooked. */ + + xnvfile_printf(it, "\n%3d: ", apc); + + for_each_online_cpu(cpu) + xnvfile_printf(it, "%12lu", + rthal_apc_table[apc].hits[cpu]); + + if (rthal_apc_table[apc].name) + xnvfile_printf(it, " (%s)", + rthal_apc_table[apc].name); + } + + xnvfile_putc(it, '\n'); + + return 0; +} + +static struct xnvfile_regular_ops apc_vfile_ops = { + .show = apc_vfile_show, +}; + +static struct xnvfile_regular apc_vfile = { + .ops = &apc_vfile_ops, +}; + +#ifdef CONFIG_XENO_HW_NMI_DEBUG_LATENCY + +static int nmi_vfile_show(struct xnvfile_regular_iterator *it, void *data) +{ + xnvfile_printf(it, "%u\n", rthal_maxlat_us); + + return 0; +} + +static ssize_t nmi_vfile_store(struct xnvfile_input *input) +{ + ssize_t ret; + long val; + + ret = xnvfile_get_integer(input, &val); + if (ret < 0) + return ret; + + if ((int)val < 0) + return -EINVAL; + + rthal_nmi_set_maxlat((unsigned int)val); + + return ret; +} + +static struct xnvfile_regular_ops nmi_vfile_ops = { + .show = nmi_vfile_show, + .store = nmi_vfile_store, +}; + +static struct xnvfile_regular nmi_vfile = { + .ops = &nmi_vfile_ops, +}; + +#endif /* CONFIG_XENO_HW_NMI_DEBUG_LATENCY */ + +int __init xnpod_init_proc(void) { int ret; - if (rthal_proc_root == NULL) - return -ENOMEM; + ret = xnvfile_init_root(); + if (ret) + return ret; ret = xnsched_init_proc(); if (ret) @@ -3220,27 +3310,32 @@ int xnpod_init_proc(void) xnintr_init_proc(); xnshadow_init_proc(); - rthal_add_proc_leaf("latency", - &latency_read_proc, - &latency_write_proc, NULL, rthal_proc_root); - - rthal_add_proc_leaf("version", &version_read_proc, NULL, NULL, - rthal_proc_root); - + xnvfile_init_regular("latency", &latency_vfile, NULL); + xnvfile_init_regular("version", &version_vfile, NULL); + xnvfile_init_regular("faults", &faults_vfile, NULL); + xnvfile_init_regular("apc", &apc_vfile, NULL); +#ifdef CONFIG_XENO_HW_NMI_DEBUG_LATENCY + xnvfile_init_regular("nmi_maxlat", &nmi_vfile, NULL); +#endif #if XENO_DEBUG(XNLOCK) - rthal_add_proc_leaf("lock", &lock_read_proc, NULL, NULL, - rthal_proc_root); + xnvfile_init_regular("lock", &lock_vfile, NULL); #endif /* XENO_DEBUG(XNLOCK) */ + return 0; } void xnpod_cleanup_proc(void) { #if XENO_DEBUG(XNLOCK) - remove_proc_entry("lock", rthal_proc_root); + xnvfile_destroy_regular(&lock_vfile); #endif /* XENO_DEBUG(XNLOCK) */ - remove_proc_entry("version", rthal_proc_root); - remove_proc_entry("latency", rthal_proc_root); +#ifdef CONFIG_XENO_HW_NMI_DEBUG_LATENCY + xnvfile_destroy_regular(&nmi_vfile); +#endif + xnvfile_destroy_regular(&apc_vfile); + xnvfile_destroy_regular(&faults_vfile); + xnvfile_destroy_regular(&version_vfile); + xnvfile_destroy_regular(&latency_vfile); xnshadow_cleanup_proc(); xnintr_cleanup_proc(); @@ -3248,6 +3343,8 @@ void xnpod_cleanup_proc(void) xntimer_cleanup_proc(); xntbase_cleanup_proc(); xnsched_cleanup_proc(); + + xnvfile_destroy_root(); } #endif /* CONFIG_PROC_FS */ _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git