[PATCH v2 01/12] kern_ntptime.c: Disable freebsd features

2022-04-29 Thread Gabriel Moyano
---
 cpukit/score/src/kern_ntptime.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cpukit/score/src/kern_ntptime.c b/cpukit/score/src/kern_ntptime.c
index cb39133408..610386833c 100644
--- a/cpukit/score/src/kern_ntptime.c
+++ b/cpukit/score/src/kern_ntptime.c
@@ -73,9 +73,11 @@ __FBSDID("$FreeBSD$");
 struct thread;
 #endif /* __rtems__ */
 
+#ifndef __rtems__
 #ifdef PPS_SYNC
 FEATURE(pps_sync, "Support usage of external PPS signal by kernel PLL");
 #endif
+#endif /* __rtems__ */
 
 /*
  * Single-precision macros for 64-bit machines
@@ -374,7 +376,6 @@ SYSCTL_NODE(_kern, OID_AUTO, ntp_pll, CTLFLAG_RW | 
CTLFLAG_MPSAFE, 0,
 SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE | CTLFLAG_RD |
 CTLFLAG_MPSAFE, 0, sizeof(struct ntptimeval) , ntp_sysctl, "S,ntptimeval",
 "");
-#endif /* __rtems__ */
 
 #ifdef PPS_SYNC
 SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shiftmax, CTLFLAG_RW,
@@ -391,6 +392,7 @@ SYSCTL_S64(_kern_ntp_pll, OID_AUTO, time_freq, CTLFLAG_RD | 
CTLFLAG_MPSAFE,
 &time_freq, 0,
 "Frequency offset (ns/sec)");
 #endif
+#endif /* __rtems__ */
 
 /*
  * ntp_adjtime() - NTP daemon application interface
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 00/12] Enable PPS API in RTEMS6

2022-04-29 Thread Gabriel Moyano
Second version of patches for enabling PPS API in RTEMS6. They have the 
following improvements:
- Add function _Timecounter_Get_frequency()
- Move hardpps to the _ namespace
- Add a test (sptest/sppps01) for testing basic behaviour of struct pps_state
- Add definition of atomic_load_int() as a relaxed atomic load
- Remove the option for PPS_SYNC and add the #define

Gabriel Moyano (12):
  kern_ntptime.c: Disable freebsd features
  kern_ntptime.c: Add lmax() qmin() definitions
  timepps.h: Add missing include for atomic type
  kern_tc.c: Add definition of atomic_load_int() required by PPS API
  kern_tc.c: Replace FREEBSD event mechanism by adding pointers to
function
  timecounter.h: Rename tc_getfrequency() to
_Timecounter_Get_frequency()
  kern_tc.c: Add definitions required by PPS API
  kern_tc.c: Enable PPS API support
  kern_ntptime: Add define in order to remove warning
  timepps.h: PPS_SYNC defined by default
  timepps.h: Move hardpps to the _ namespace
  testsuites/sptests: Add sppps01 test

 cpukit/include/rtems/score/timecounter.h  |   7 +
 cpukit/include/sys/timepps.h  |  15 ++
 cpukit/include/sys/timetc.h   |   3 +
 cpukit/score/src/kern_ntptime.c   |  19 ++-
 cpukit/score/src/kern_tc.c|  41 +-
 spec/build/testsuites/sptests/grp.yml |   2 +
 spec/build/testsuites/sptests/sppps01.yml |  19 +++
 testsuites/sptests/sppps01/init.c | 160 ++
 8 files changed, 251 insertions(+), 15 deletions(-)
 create mode 100644 spec/build/testsuites/sptests/sppps01.yml
 create mode 100644 testsuites/sptests/sppps01/init.c

-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 03/12] timepps.h: Add missing include for atomic type

2022-04-29 Thread Gabriel Moyano
---
 cpukit/include/sys/timepps.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h
index 01212f0b43..621afb08ec 100644
--- a/cpukit/include/sys/timepps.h
+++ b/cpukit/include/sys/timepps.h
@@ -24,6 +24,9 @@
 #include 
 #include 
 #include 
+#ifdef __rtems__
+#include 
+#endif /* __rtems__ */
 
 #define PPS_API_VERS_1 1
 
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 02/12] kern_ntptime.c: Add lmax() qmin() definitions

2022-04-29 Thread Gabriel Moyano
---
 cpukit/score/src/kern_ntptime.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cpukit/score/src/kern_ntptime.c b/cpukit/score/src/kern_ntptime.c
index 610386833c..da6b425064 100644
--- a/cpukit/score/src/kern_ntptime.c
+++ b/cpukit/score/src/kern_ntptime.c
@@ -71,6 +71,8 @@ __FBSDID("$FreeBSD$");
 #definentp_update_second _Timecounter_NTP_update_second
 #definetime_uptime _Timecounter_Time_uptime
 struct thread;
+static __inline long lmax(long a, long b) { return (a > b ? a : b); }
+static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); }
 #endif /* __rtems__ */
 
 #ifndef __rtems__
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 04/12] kern_tc.c: Add definition of atomic_load_int() required by PPS API

2022-04-29 Thread Gabriel Moyano
---
 cpukit/include/sys/timepps.h | 4 
 cpukit/score/src/kern_tc.c   | 7 +++
 2 files changed, 11 insertions(+)

diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h
index 621afb08ec..5703381ffa 100644
--- a/cpukit/include/sys/timepps.h
+++ b/cpukit/include/sys/timepps.h
@@ -32,7 +32,11 @@
 
 typedef int pps_handle_t;  
 
+#ifndef __rtems__
 typedef unsigned pps_seq_t;
+#else /* __rtems__ */
+typedef Atomic_Uintpps_seq_t;
+#endif /* __rtems__ */
 
 typedef struct ntp_fp {
unsigned intintegral;
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index e57da2c0ca..f7d0a0b4ba 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -114,6 +114,13 @@ atomic_thread_fence_rel(void)
_Atomic_Fence(ATOMIC_ORDER_RELEASE);
 }
 
+static inline u_int
+atomic_load_int(Atomic_Uint *i)
+{
+
+   return (_Atomic_Load_uint(i, ATOMIC_ORDER_RELAXED));
+}
+
 static inline u_int
 atomic_load_acq_int(Atomic_Uint *i)
 {
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 05/12] kern_tc.c: Replace FREEBSD event mechanism by adding pointers to function

2022-04-29 Thread Gabriel Moyano
---
 cpukit/include/sys/timepps.h |  6 ++
 cpukit/score/src/kern_tc.c   | 25 +
 2 files changed, 31 insertions(+)

diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h
index 5703381ffa..0d666a4f2e 100644
--- a/cpukit/include/sys/timepps.h
+++ b/cpukit/include/sys/timepps.h
@@ -26,6 +26,7 @@
 #include 
 #ifdef __rtems__
 #include 
+#include 
 #endif /* __rtems__ */
 
 #define PPS_API_VERS_1 1
@@ -164,6 +165,11 @@ struct pps_state {
int ppscap;
struct timecounter *ppstc;
unsignedppscount[3];
+#ifdef __rtems__
+rtems_id task_waiting;
+int (*wait)(struct pps_state *pps, struct timespec timeout); /* Wait for 
an event. Called internally when time_pps_fetch() is used. It shall not be 
NULL*/
+void (*wakeup)(struct pps_state *pps); /* Used to wakeup tasks waiting for 
an event. It shall not be NULL*/
+#endif /* __rtems__ */
/*
 * The following fields are valid if the driver calls pps_init_abi().
 */
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index f7d0a0b4ba..76e3e056de 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -1917,9 +1917,15 @@ abi_aware(struct pps_state *pps, int vers)
 static int
 pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps)
 {
+#ifndef __rtems__
int err, timo;
+#else /* __rtems__ */
+   int err;
+#endif /* __rtems__ */
pps_seq_t aseq, cseq;
+#ifndef __rtems__
struct timeval tv;
+#endif /* __rtems__ */
 
if (fapi->tsformat && fapi->tsformat != PPS_TSFMT_TSPEC)
return (EINVAL);
@@ -1932,6 +1938,7 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state 
*pps)
 * sleep a long time.
 */
if (fapi->timeout.tv_sec || fapi->timeout.tv_nsec) {
+#ifndef __rtems__
if (fapi->timeout.tv_sec == -1)
timo = 0x7fff;
else {
@@ -1939,10 +1946,12 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state 
*pps)
tv.tv_usec = fapi->timeout.tv_nsec / 1000;
timo = tvtohz(&tv);
}
+#endif /* __rtems__ */
aseq = atomic_load_int(&pps->ppsinfo.assert_sequence);
cseq = atomic_load_int(&pps->ppsinfo.clear_sequence);
while (aseq == atomic_load_int(&pps->ppsinfo.assert_sequence) &&
cseq == atomic_load_int(&pps->ppsinfo.clear_sequence)) {
+#ifndef __rtems__
if (abi_aware(pps, 1) && pps->driver_mtx != NULL) {
if (pps->flags & PPSFLAG_MTX_SPIN) {
err = msleep_spin(pps, pps->driver_mtx,
@@ -1954,6 +1963,12 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state 
*pps)
} else {
err = tsleep(pps, PCATCH, "ppsfch", timo);
}
+#else /* __rtems__ */
+if (pps->wait != NULL)
+err = (*pps->wait)(pps, fapi->timeout);
+else
+err = EAGAIN;
+#endif /* __rtems__ */
if (err == EWOULDBLOCK) {
if (fapi->timeout.tv_sec == -1) {
continue;
@@ -2061,6 +2076,11 @@ pps_ioctl(u_long cmd, caddr_t data, struct pps_state 
*pps)
 void
 pps_init(struct pps_state *pps)
 {
+#ifdef __rtems__
+if (pps->wait != NULL)
+_Assert(pps->wakeup != NULL);
+pps->task_waiting = RTEMS_INVALID_ID;
+#endif /* __rtems__ */
pps->ppscap |= PPS_TSFMT_TSPEC | PPS_CANWAIT;
if (pps->ppscap & PPS_CAPTUREASSERT)
pps->ppscap |= PPS_OFFSETASSERT;
@@ -2227,7 +2247,12 @@ pps_event(struct pps_state *pps, int event)
 #endif
 
/* Wakeup anyone sleeping in pps_fetch().  */
+#ifndef __rtems__
wakeup(pps);
+#else /* __rtems__ */
+if (pps->wakeup != NULL)
+(*pps->wakeup)(pps);
+#endif /* __rtems__ */
 }
 #else /* __rtems__ */
 /* FIXME: https://devel.rtems.org/ticket/2349 */
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 07/12] kern_tc.c: Add definitions required by PPS API

2022-04-29 Thread Gabriel Moyano
---
 cpukit/score/src/kern_tc.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 7c2feb5be3..7e030c50d4 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -56,6 +56,11 @@
 #definetimecounter _Timecounter
 #definetime_second _Timecounter_Time_second
 #definetime_uptime _Timecounter_Time_uptime
+
+#define ENOIOCTL -3
+#include 
+#define KASSERT(exp, arg) _Assert(exp)
+
 #include 
 #include 
 #include 
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 06/12] timecounter.h: Rename tc_getfrequency() to _Timecounter_Get_frequency()

2022-04-29 Thread Gabriel Moyano
---
 cpukit/include/rtems/score/timecounter.h | 7 +++
 cpukit/include/sys/timetc.h  | 3 +++
 cpukit/score/src/kern_tc.c   | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/cpukit/include/rtems/score/timecounter.h 
b/cpukit/include/rtems/score/timecounter.h
index 1ecfc02085..a674d3867a 100644
--- a/cpukit/include/rtems/score/timecounter.h
+++ b/cpukit/include/rtems/score/timecounter.h
@@ -292,6 +292,13 @@ void _Timecounter_Set_NTP_update_second(
  */
 void _Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec);
 
+/**
+ * @brief Report the frequency of the current timecounter.
+ *
+ * @return time counter frequency.
+ */
+uint64_t _Timecounter_Get_frequency(void);
+
 /** @} */
 
 #ifdef __cplusplus
diff --git a/cpukit/include/sys/timetc.h b/cpukit/include/sys/timetc.h
index 5cdfdfe9b3..7cc3284b4d 100644
--- a/cpukit/include/sys/timetc.h
+++ b/cpukit/include/sys/timetc.h
@@ -36,6 +36,7 @@ struct vdso_timehands32;
 typedef u_int timecounter_get_t(struct timecounter *);
 #else /* __rtems__ */
 typedef uint32_t timecounter_get_t(struct timecounter *);
+#define tc_getfrequency _Timecounter_Get_frequency
 #endif /* __rtems__ */
 typedef void timecounter_pps_t(struct timecounter *);
 typedef uint32_t timecounter_fill_vdso_timehands_t(struct vdso_timehands *,
@@ -94,7 +95,9 @@ extern int tc_min_ticktock_freq; /*
  * required to handle counter wraps.
  */
 
+#ifndef __rtems__
 u_int64_t tc_getfrequency(void);
+#endif /* __rtems__ */
 void   tc_init(struct timecounter *tc);
 void   tc_setclock(struct timespec *ts);
 void   tc_ticktock(int cnt);
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 76e3e056de..7c2feb5be3 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -1513,7 +1513,6 @@ unlock:
 #endif /* __rtems__ */
 }
 
-#ifndef __rtems__
 /* Report the frequency of the current timecounter. */
 uint64_t
 tc_getfrequency(void)
@@ -1522,6 +1521,7 @@ tc_getfrequency(void)
return (timehands->th_counter->tc_frequency);
 }
 
+#ifndef __rtems__
 static bool
 sleeping_on_old_rtc(struct thread *td)
 {
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 08/12] kern_tc.c: Enable PPS API support

2022-04-29 Thread Gabriel Moyano
---
 cpukit/score/src/kern_tc.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index 7e030c50d4..1b794fd0e3 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -1903,7 +1903,6 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, choice,
 "Timecounter hardware detected");
 #endif /* __rtems__ */
 
-#ifndef __rtems__
 /*
  * RFC 2783 PPS-API implementation.
  */
@@ -2259,9 +2258,6 @@ pps_event(struct pps_state *pps, int event)
 (*pps->wakeup)(pps);
 #endif /* __rtems__ */
 }
-#else /* __rtems__ */
-/* FIXME: https://devel.rtems.org/ticket/2349 */
-#endif /* __rtems__ */
 
 /*
  * Timecounters need to be updated every so often to prevent the hardware
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 09/12] kern_ntptime: Add define in order to remove warning

2022-04-29 Thread Gabriel Moyano
---
 cpukit/score/src/kern_ntptime.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/score/src/kern_ntptime.c b/cpukit/score/src/kern_ntptime.c
index da6b425064..c1b4013e9b 100644
--- a/cpukit/score/src/kern_ntptime.c
+++ b/cpukit/score/src/kern_ntptime.c
@@ -58,6 +58,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#ifdef __rtems__
+#define_KERNEL
+#endif /* __rtems__ */
 #include 
 #ifndef __rtems__
 #include 
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 10/12] timepps.h: PPS_SYNC defined by default

2022-04-29 Thread Gabriel Moyano
---
 cpukit/include/sys/timepps.h|  1 +
 cpukit/score/src/kern_ntptime.c | 10 --
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h
index 0d666a4f2e..b13ac6bf26 100644
--- a/cpukit/include/sys/timepps.h
+++ b/cpukit/include/sys/timepps.h
@@ -27,6 +27,7 @@
 #ifdef __rtems__
 #include 
 #include 
+#define PPS_SYNC
 #endif /* __rtems__ */
 
 #define PPS_API_VERS_1 1
diff --git a/cpukit/score/src/kern_ntptime.c b/cpukit/score/src/kern_ntptime.c
index c1b4013e9b..8a16702736 100644
--- a/cpukit/score/src/kern_ntptime.c
+++ b/cpukit/score/src/kern_ntptime.c
@@ -538,16 +538,6 @@ kern_ntp_adjtime(struct thread *td, struct timex *ntv, int 
*retvalp)
ntv->jitcnt = pps_jitcnt;
ntv->stbcnt = pps_stbcnt;
 #endif /* PPS_SYNC */
-#ifdef __rtems__
-   ntv->ppsfreq = 0;
-   ntv->jitter = 0;
-   ntv->shift = 0;
-   ntv->stabil = 0;
-   ntv->jitcnt = 0;
-   ntv->calcnt = 0;
-   ntv->errcnt = 0;
-   ntv->stbcnt = 0;
-#endif /* __rtems__ */
retval = ntp_is_time_error(time_status) ? TIME_ERROR : time_state;
NTP_UNLOCK();
 
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 11/12] timepps.h: Move hardpps to the _ namespace

2022-04-29 Thread Gabriel Moyano
---
 cpukit/include/sys/timepps.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h
index b13ac6bf26..25370f3f4b 100644
--- a/cpukit/include/sys/timepps.h
+++ b/cpukit/include/sys/timepps.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #define PPS_SYNC
+#define hardpps _PPS_Discipline_cpu_clock
 #endif /* __rtems__ */
 
 #define PPS_API_VERS_1 1
-- 
2.25.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2 12/12] testsuites/sptests: Add sppps01 test

2022-04-29 Thread Gabriel Moyano
---
 spec/build/testsuites/sptests/grp.yml |   2 +
 spec/build/testsuites/sptests/sppps01.yml |  19 +++
 testsuites/sptests/sppps01/init.c | 160 ++
 3 files changed, 181 insertions(+)
 create mode 100644 spec/build/testsuites/sptests/sppps01.yml
 create mode 100644 testsuites/sptests/sppps01/init.c

diff --git a/spec/build/testsuites/sptests/grp.yml 
b/spec/build/testsuites/sptests/grp.yml
index a69a4d20f7..3264ba5450 100644
--- a/spec/build/testsuites/sptests/grp.yml
+++ b/spec/build/testsuites/sptests/grp.yml
@@ -349,6 +349,8 @@ links:
   uid: sppercpudata01
 - role: build-dependency
   uid: spporterr01
+- role: build-dependency
+  uid: sppps01
 - role: build-dependency
   uid: spprintk
 - role: build-dependency
diff --git a/spec/build/testsuites/sptests/sppps01.yml 
b/spec/build/testsuites/sptests/sppps01.yml
new file mode 100644
index 00..55770eceb9
--- /dev/null
+++ b/spec/build/testsuites/sptests/sppps01.yml
@@ -0,0 +1,19 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+build-type: test-program
+cflags: []
+copyrights:
+- Copyright (C) 2022 German Aerospace Center (DLR)
+cppflags: []
+cxxflags: []
+enabled-by: true
+features: c cprogram
+includes: []
+ldflags: []
+links: []
+source:
+- testsuites/sptests/sppps01/init.c
+stlib: []
+target: testsuites/sptests/sppps01.exe
+type: build
+use-after: []
+use-before: []
diff --git a/testsuites/sptests/sppps01/init.c 
b/testsuites/sptests/sppps01/init.c
new file mode 100644
index 00..b36c25ae65
--- /dev/null
+++ b/testsuites/sptests/sppps01/init.c
@@ -0,0 +1,160 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (C) 2022 German Aerospace Center (DLR)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#define _KERNEL
+#include 
+
+const char rtems_test_name[] = "SPPPS 1";
+
+#define PPS_EVENT RTEMS_EVENT_0
+#define TASK_WAITING RTEMS_EVENT_1
+#define PPS_EVENT_RECEIVED RTEMS_EVENT_2
+
+typedef struct {
+  rtems_id main_task;
+  struct pps_state *pps;
+} test_context;
+
+static void wakeup(struct pps_state *pps)
+{
+  if (pps->task_waiting != RTEMS_INVALID_ID)
+rtems_event_send( pps->task_waiting, PPS_EVENT );
+}
+
+static int wait(struct pps_state *pps, struct timespec timeout)
+{
+  rtems_status_code sc;
+  rtems_event_set out;
+
+  pps->task_waiting = rtems_task_self();
+  uint32_t timeoutticks = rtems_timespec_to_ticks(&timeout);
+  sc = rtems_event_receive( PPS_EVENT, RTEMS_DEFAULT_OPTIONS, timeoutticks, 
&out );
+  return rtems_status_code_to_errno(sc);
+}
+
+static void pps_task(rtems_task_argument arg)
+{
+  int status;
+  rtems_status_code sc;
+
+  test_context *ctx;
+  ctx = (test_context *) arg;
+
+  struct pps_fetch_args fetch;
+  fetch.tsformat = PPS_TSFMT_TSPEC;
+  fetch.timeout.tv_sec = 1;
+  fetch.timeout.tv_nsec = 0;
+
+  sc = rtems_event_send( ctx->main_task, TASK_WAITING );
+  T_rsc_success( sc );
+  status = pps_ioctl( PPS_IOC_FETCH, (caddr_t)&fetch, ctx->pps );
+  T_eq_int( status, 0 );
+  sc = rtems_event_send( ctx->main_task, PPS_EVENT_RECEIVED );
+  T_rsc_success( sc );
+
+  rtems_task_delete(rtems_task_self());
+}
+
+T_TEST_CASE( PPS )
+{
+  int status;
+  rtems_status_code sc;
+  struct pps_state pps;
+
+  memset( &pps, 0, sizeof( pps ) );
+  pps.ppscap = PPS_CAPTUREBOTH;
+  pps.wait = wait;
+  pps.wakeup = wakeup;
+  pps_init_abi( &pps );
+  pps.ppsparam.mode = PPS_CAPTUREASSERT;
+
+  struct pps_kcbind_args kcbind;
+  kcbind.kernel_consumer = PPS_KC_HARDPPS;
+  kcbind.edge = PPS_CAPTUREASSERT;
+  kcbind.tsformat = PPS_TSFMT_TSPEC;
+  status = pps_ioctl( PPS_IOC_KCBIND, (caddr_t)&kcbind, &pps );
+  T_eq_int

Re: GCC version for RTEMS 6?

2022-04-29 Thread Karel Gardas

On 4/28/22 10:04, Sebastian Huber wrote:
More releases means more maintenance overhead. Since GCC 12 is under 
active upstream maintenance, compiler issues can be fixed by the GCC 
maintainers in contrast to GCC 10.


JFYI: gcc 12 was branched, rc1 is being built. More info here:
https://gcc.gnu.org/pipermail/gcc/2022-April/238617.html

Karel


___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel