All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] xntbase_get_jiffies in user space?
@ 2007-10-31  9:37 Thomas Necker
  2007-10-31 10:18 ` Philippe Gerum
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Necker @ 2007-10-31  9:37 UTC (permalink / raw)
  To: xenomai

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.

Thomas



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai-help] xntbase_get_jiffies in user space?
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Gerum @ 2007-10-31 10:18 UTC (permalink / raw)
  To: Thomas Necker; +Cc: xenomai

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.

> Thomas
> 
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
> 


-- 
Philippe.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai-help] xntbase_get_jiffies in user space?
  2007-10-31 10:18 ` Philippe Gerum
@ 2007-10-31 10:26   ` Philippe Gerum
  2007-10-31 14:33     ` Thomas Necker
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Gerum @ 2007-10-31 10:26 UTC (permalink / raw)
  To: rpm; +Cc: xenomai

[-- 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;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai-help] xntbase_get_jiffies in user space?
  2007-10-31 10:26   ` Philippe Gerum
@ 2007-10-31 14:33     ` Thomas Necker
  2007-10-31 14:42       ` Philippe Gerum
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Necker @ 2007-10-31 14:33 UTC (permalink / raw)
  To: rpm; +Cc: xenomai

> > 
> > 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.

Thanks for the quick patch. It seems necessary to change the call
ticks = xntbase_get_jiffies(&psos_tbase)
to
ticks = xntbase_get_jiffies(psos_tbase)
in syscall.c for the patch to work.
Will this change become part of the regular Xenomai release?

Thomas


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Xenomai-help] xntbase_get_jiffies in user space?
  2007-10-31 14:33     ` Thomas Necker
@ 2007-10-31 14:42       ` Philippe Gerum
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Gerum @ 2007-10-31 14:42 UTC (permalink / raw)
  To: Thomas Necker; +Cc: xenomai

Thomas Necker wrote:
>>> 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.
> 
> Thanks for the quick patch. It seems necessary to change the call
> ticks = xntbase_get_jiffies(&psos_tbase)
> to
> ticks = xntbase_get_jiffies(psos_tbase)

Ack.

> in syscall.c for the patch to work.
> Will this change become part of the regular Xenomai release?
>

Yes, this extension makes a lot of sense in the pSOS context.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-10-31 14:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2007-10-31 14:33     ` Thomas Necker
2007-10-31 14:42       ` Philippe Gerum

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.