All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: rpm@xenomai.org
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] xntbase_get_jiffies in user space?
Date: Wed, 31 Oct 2007 11:26:32 +0100	[thread overview]
Message-ID: <47285858.3030204@domain.hid> (raw)
In-Reply-To: <47285666.4080108@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 921 bytes --]

Philippe Gerum wrote:
> Thomas Necker wrote:
>> A few weeks ago I was asking about a global variable available that just
>> counts the system ticks (for pSOS skin) and that could be read by the
>> application. Philippe suggested xntbase_get_jiffies for that purpose.
>> Now it seems to me that this function can only be called in kernel
>> space. Is that correct? And if so, is there a way to get this
>> information in user space? Basically I want to get rid of kernel code in
>> this context completely if possible.
>>
> 
> The pSOS skin supports tm_get() which converts the current count of
> jiffies to calendar date and time, but this may not be handy for your
> calculations.
> 
> The other option would be to extend this skin with a Xenomai-specific
> syscall returning this value, in a similar way than tm_getm(), which
> returns the TSC converted to nanoseconds.
> 

Like the attached patch does.

-- 
Philippe.

[-- Attachment #2: tm_getc.patch --]
[-- Type: text/x-patch, Size: 2236 bytes --]

Index: include/psos+/syscall.h
===================================================================
--- include/psos+/syscall.h	(revision 3133)
+++ include/psos+/syscall.h	(working copy)
@@ -71,6 +71,8 @@
 /* Xenomai extension: send a Linux signal after a specified time */
 #define __psos_tm_signal    44
 #define __psos_as_send      45
+/* Xenomai extension: get raw count of jiffies */
+#define __psos_tm_getc      46
 
 #ifdef __KERNEL__
 
Index: include/psos+/psos.h
===================================================================
--- include/psos+/psos.h	(revision 3133)
+++ include/psos+/psos.h	(working copy)
@@ -419,6 +419,8 @@
 		 int signo,
 		 u_long *tmid_r);
 
+u_long tm_getc(unsigned long long *ticks_r); /* Xenomai extension. */
+
 #ifdef __cplusplus
 };
 #endif /* __cplusplus */
Index: src/skins/psos+/tm.c
===================================================================
--- src/skins/psos+/tm.c	(revision 3133)
+++ src/skins/psos+/tm.c	(working copy)
@@ -83,3 +83,8 @@
 {
 	return XENOMAI_SKINCALL4(__psos_muxid, __psos_tm_signal, value, interval, signo, tmid_r);
 }
+
+u_long tm_getc(unsigned long long *ticks_r) /* Xenomai extension. */
+{
+	return XENOMAI_SKINCALL1(__psos_muxid, __psos_tm_getc, ticks_r);
+}
Index: ksrc/skins/psos+/syscall.c
===================================================================
--- ksrc/skins/psos+/syscall.c	(revision 3133)
+++ ksrc/skins/psos+/syscall.c	(working copy)
@@ -1071,6 +1071,26 @@
 }
 
 /*
+ * u_long tm_getc(u_long_long *ticks_r)
+ */
+
+static int __tm_getc(struct task_struct *curr, struct pt_regs *regs)
+{
+	xnticks_t ticks;
+
+	if (!__xn_access_ok
+	    (curr, VERIFY_WRITE, __xn_reg_arg1(regs), sizeof(ticks)))
+		return -EFAULT;
+
+	ticks = xntbase_get_jiffies(&psos_tbase);
+
+	__xn_copy_to_user(curr, (void __user *)__xn_reg_arg1(regs), &ticks,
+			  sizeof(ticks));
+
+	return 0;
+}
+
+/*
  * u_long tm_signal(u_long value, u_long interval, int signo, u_long *tmid_r)
  */
 
@@ -1503,6 +1523,7 @@
 	[__psos_tm_getm] = {&__tm_getm, __xn_exec_any},
 	[__psos_tm_signal] = {&__tm_signal, __xn_exec_primary},
 	[__psos_as_send] = {&__as_send, __xn_exec_conforming},
+	[__psos_tm_getc] = {&__tm_getc, __xn_exec_any},
 };
 
 extern xntbase_t *psos_tbase;

  reply	other threads:[~2007-10-31 10:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31  9:37 [Xenomai-help] xntbase_get_jiffies in user space? Thomas Necker
2007-10-31 10:18 ` Philippe Gerum
2007-10-31 10:26   ` Philippe Gerum [this message]
2007-10-31 14:33     ` Thomas Necker
2007-10-31 14:42       ` Philippe Gerum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47285858.3030204@domain.hid \
    --to=rpm@xenomai.org \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.