AW: [PATCH v3 04/11] kern_tc.c: Replace FREEBSD event mechanism by adding pointers to function
Thx, I'll send a new version of the commits today. The issue in the NTP test will also be resolved. > FREEBSD should be FreeBSD. > > On 04/05/2022 14:12, Gabriel Moyano wrote: > > --- > > cpukit/include/sys/timepps.h | 21 > > cpukit/score/src/kern_tc.c | 38 > > 2 files changed, 59 insertions(+) > > > > diff --git a/cpukit/include/sys/timepps.h > > b/cpukit/include/sys/timepps.h index 5703381ffa..b734c6f841 100644 > > --- a/cpukit/include/sys/timepps.h > > +++ b/cpukit/include/sys/timepps.h > > @@ -164,6 +164,27 @@ struct pps_state { > > int ppscap; > > struct timecounter *ppstc; > > unsignedppscount[3]; > > +#ifdef __rtems__ > > +/** > > + * @brief Wait for an event. > > + * > > + * Called internally when time_pps_fetch() is used. > > + * It is initialized with an empty function by default. > > initialized by pps_init() to a handler which just returns 0? > > Is 0 a good default? You will end up in an endless loop I guess. Why not > return ETIMEDOUT by default? Please add a test case for this > scenario. > > > + * > > + * @param pps is the pointer to the object. > > + * > > + * @param timeout > > + * > > + * @return 0 if no error otherwise a negative value. > > Please list all valid status codes. Probably: > > @retval 0 A wakeup event was received. > > @retval ETIMEDOUT A timeout occurred while waiting for the event. > > > + */ > > +int (*wait)(struct pps_state *pps, struct timespec timeout); > > Add a blank line here. > > Please review the entire patch set so that all changes are done in the coding > style of the original file. For the details see: > > https://www.freebsd.org/cgi/man.cgi?query=style&sektion=9 > > In your patches this is mostly space vs. tabs. > > > +/** > > + * @brief Wakeup the tasks waiting for an event. > > + * > > + * @param pps is the pointer to the object. > > + */ > > +void (*wakeup)(struct pps_state *pps); #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..6ca408e4ab 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,10 @@ > > pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps) > > } else { > > err = tsleep(pps, PCATCH, "ppsfch", timo); > > } > > +#else /* __rtems__ */ > > +_Assert(pps->wait != NULL); > > +err = (*pps->wait)(pps, fapi->timeout); #endif /* > > +__rtems__ */ > > if (err == EWOULDBLOCK) { > > if (fapi->timeout.tv_sec == -1) { > > continue; > > I would remove the err == EWOULDBLOCK ... block if you remove the block > above, since the wait handler has to deal with the > timeout.tv_sec == -1 condition in this case. > > > @@ -2058,9 +2071,29 @@ pps_ioctl(u_long cmd, caddr_t data, struct pps_state > > *pps) > > } > > } > > > > +#ifdef __rtems__ > > +static int > > +default_wait(struct pps_state *pps, struct timespec timeout) { > > Add a blank line. > > > +(void) pps; > > (void)
[PATCH v4 00/11] ENABLE PPS in RTEMS6
This is the 4th version of the patches for enabling the PPS API in RTEMS6. Gabriel Moyano (11): kern_ntptime.c: Disable freebsd features kern_ntptime.c: Add lmax() qmin() definitions kern_tc.c: Add atomic dependencies required by the 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.c: Add define in order to remove warning timepps.h: PPS_SYNC defined by default timecounter.h: Add _Timecounter_Discipline() testsuites/sptests: Add sppps01 test cpukit/include/rtems/score/timecounter.h | 25 +++ cpukit/include/sys/timepps.h | 35 cpukit/include/sys/timetc.h | 3 + cpukit/score/src/kern_ntptime.c | 19 +-- cpukit/score/src/kern_tc.c| 57 ++- spec/build/testsuites/sptests/grp.yml | 2 + spec/build/testsuites/sptests/sppps01.yml | 19 +++ testsuites/sptests/spntp01/init.c | 2 +- testsuites/sptests/sppps01/init.c | 191 ++ 9 files changed, 337 insertions(+), 16 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 v4 02/11] kern_ntptime.c: Add lmax() qmin() definitions
--- 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 v4 01/11] kern_ntptime.c: Disable freebsd features
--- 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 v4 04/11] kern_tc.c: Replace FreeBSD event mechanism by adding pointers to function
--- cpukit/include/sys/timepps.h | 24 + cpukit/score/src/kern_tc.c | 41 2 files changed, 65 insertions(+) diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h index 5703381ffa..2513298557 100644 --- a/cpukit/include/sys/timepps.h +++ b/cpukit/include/sys/timepps.h @@ -164,6 +164,30 @@ struct pps_state { int ppscap; struct timecounter *ppstc; unsignedppscount[3]; +#ifdef __rtems__ + /** +* @brief Wait for an event. +* +* Called internally when time_pps_fetch() is used. +* It is initialized by pps_init() to a handler which just returns ETIMEDOUT. +* +* @param pps is the pointer to the object. +* +* @param timeout +* +* @retval 0 A wakeup event was received. +* +* @retval ETIMEDOUT A timeout occurred while waiting for the event. +*/ + int (*wait)(struct pps_state *pps, struct timespec timeout); + + /** +* @brief Wakeup the tasks waiting for an event. +* +* @param pps is the pointer to the object. +*/ + void (*wakeup)(struct pps_state *pps); +#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..c22ce121a4 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, @@ -1963,6 +1972,11 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps) } else if (err != 0) { return (err); } +#else /* __rtems__ */ + _Assert(pps->wait != NULL); + err = (*pps->wait)(pps, fapi->timeout); + return (err); +#endif /* __rtems__ */ } } @@ -2058,9 +2072,31 @@ pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps) } } +#ifdef __rtems__ +static int +default_wait(struct pps_state *pps, struct timespec timeout) +{ + + (void)pps; + (void)timeout; + + return (ETIMEDOUT); +} + +static void +default_wakeup(struct pps_state *pps) +{ + + (void)pps; +} +#endif /* __rtems__ */ void pps_init(struct pps_state *pps) { +#ifdef __rtems__ + pps->wait = default_wait; + pps->wakeup = default_wakeup; +#endif /* __rtems__ */ pps->ppscap |= PPS_TSFMT_TSPEC | PPS_CANWAIT; if (pps->ppscap & PPS_CAPTUREASSERT) pps->ppscap |= PPS_OFFSETASSERT; @@ -2227,7 +2263,12 @@ pps_event(struct pps_state *pps, int event) #endif /* Wakeup anyone sleeping in pps_fetch(). */ +#ifndef __rtems__ wakeup(pps); +#else /* __rtems__ */ + _Assert(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 v4 03/11] kern_tc.c: Add atomic dependencies required by the PPS API
--- cpukit/include/sys/timepps.h | 7 +++ cpukit/score/src/kern_tc.c | 7 +++ 2 files changed, 14 insertions(+) diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h index 01212f0b43..5703381ffa 100644 --- a/cpukit/include/sys/timepps.h +++ b/cpukit/include/sys/timepps.h @@ -24,12 +24,19 @@ #include #include #include +#ifdef __rtems__ +#include +#endif /* __rtems__ */ #define PPS_API_VERS_1 1 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 v4 05/11] timecounter.h: Rename tc_getfrequency() to _Timecounter_Get_frequency()
--- cpukit/include/rtems/score/timecounter.h | 8 cpukit/include/sys/timetc.h | 3 +++ cpukit/score/src/kern_tc.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cpukit/include/rtems/score/timecounter.h b/cpukit/include/rtems/score/timecounter.h index 1ecfc02085..fdade06128 100644 --- a/cpukit/include/rtems/score/timecounter.h +++ b/cpukit/include/rtems/score/timecounter.h @@ -292,6 +292,14 @@ void _Timecounter_Set_NTP_update_second( */ void _Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec); +/** + * @brief Get the frequency in Hz of the current timecounter at some time point + * during the call. + * + * @return the frequency in Hz. + */ +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 c22ce121a4..2e2ffd8ef1 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 v4 09/11] timepps.h: PPS_SYNC defined by default
--- cpukit/include/sys/timepps.h | 1 + cpukit/score/src/kern_ntptime.c | 10 -- testsuites/sptests/spntp01/init.c | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h index 2513298557..30bca70c8d 100644 --- a/cpukit/include/sys/timepps.h +++ b/cpukit/include/sys/timepps.h @@ -26,6 +26,7 @@ #include #ifdef __rtems__ #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(); diff --git a/testsuites/sptests/spntp01/init.c b/testsuites/sptests/spntp01/init.c index 472e9d..eb5b1ca56c 100644 --- a/testsuites/sptests/spntp01/init.c +++ b/testsuites/sptests/spntp01/init.c @@ -81,7 +81,7 @@ T_TEST_CASE( NTP ) T_eq_long( tx.tolerance, 3250 ); T_eq_long( tx.ppsfreq, 0 ); T_eq_long( tx.jitter, 0 ); - T_eq_int( tx.shift, 0 ); + T_eq_int( tx.shift, 2 ); T_eq_long( tx.stabil, 0 ); T_eq_long( tx.jitcnt, 0 ); T_eq_long( tx.calcnt, 0 ); -- 2.25.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v4 06/11] kern_tc.c: Add definitions required by PPS API
--- 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 2e2ffd8ef1..25d0837b63 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 EINVAL +#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 v4 08/11] kern_ntptime.c: Add define in order to remove warning
--- 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 v4 11/11] testsuites/sptests: Add sppps01 test
--- spec/build/testsuites/sptests/grp.yml | 2 + spec/build/testsuites/sptests/sppps01.yml | 19 +++ testsuites/sptests/sppps01/init.c | 191 ++ 3 files changed, 212 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..850c21f1f2 --- /dev/null +++ b/testsuites/sptests/sppps01/init.c @@ -0,0 +1,191 @@ +/* + * 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 +#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 + +struct test_pps_device { + struct pps_state pps; + rtems_id task_waiting; +}; + +typedef struct { + rtems_id main_task; + struct test_pps_device *pps_dev; +} test_context; + +T_TEST_CASE( WaitPPSEventDefaultHandler ) +{ + int status; + struct test_pps_device pps_dev; + struct pps_fetch_args fetch; + + pps_dev.task_waiting = RTEMS_INVALID_ID; + + memset( &pps_dev.pps, 0, sizeof( pps_dev.pps ) ); + pps_dev.pps.ppscap = PPS_CAPTUREBOTH; + pps_init_abi( &pps_dev.pps ); + pps_dev.pps.ppsparam.mode = PPS_CAPTUREASSERT; + + status = pps_ioctl( PPS_IOC_FETCH, (caddr_t)&fetch, &pps_dev.pps ); + T_eq_int( status, ETIMEDOUT ); +} + +static void wakeup(struct pps_state *pps) +{ + struct test_pps_device *pps_dev; + + pps_dev = RTEMS_CONTAINER_OF( pps, struct test_pps_device, pps ); + if (pps_dev->task_waiting != RTEMS_INVALID_ID) +rtems_event_send( pps_dev->task_waiting, PPS_EVENT ); +} + +static int wait(struct pps_state *pps, struct timespec timeout) +{ + rtems_status_code sc; + rtems_event_set out; + uint32_t timeoutticks; + struct test_pps_device *pps_dev; + + pps_dev = RTEMS_CONTAINER_OF( pps, struct test_pps_device, pps ); + pps_dev->task_waiting = rtems_task_self(); + + 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; + struct pps_fetch_args fetch; + test_context *ctx; + + ctx = (test_context *) arg; + + fetch.tsformat = PPS_TSFMT_TSPEC; + fetch.timeout.tv_sec = 1; + fetch.timeout.tv_nsec = 0; +
[PATCH v4 07/11] kern_tc.c: Enable PPS API support
--- 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 25d0837b63..80b1be364c 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. */ @@ -2275,9 +2274,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 v4 10/11] timecounter.h: Add _Timecounter_Discipline()
--- cpukit/include/rtems/score/timecounter.h | 17 + cpukit/include/sys/timepps.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/cpukit/include/rtems/score/timecounter.h b/cpukit/include/rtems/score/timecounter.h index fdade06128..95e0839cff 100644 --- a/cpukit/include/rtems/score/timecounter.h +++ b/cpukit/include/rtems/score/timecounter.h @@ -300,6 +300,23 @@ void _Timecounter_NTP_update_second(int64_t *adjustment, time_t *newsec); */ uint64_t _Timecounter_Get_frequency(void); +/** + * @brief Updates the timecounter frequency adjustment used by + * _Timecounter_Set_NTP_update_second(). + * + * This function is part of the time synchronization using a PPS + * (Pulse Per Second) signal. + * + * When an event (a rising or falling edge of the PPS signal) occurs, the + * functions pps_capture() and pps_event() are executed. Only if the kernel + * consumer is configured to be PPS_KC_HARDPPS, the timecounter is disciplined. + * + * @param[in] tsp is the time at PPS event + * + * @param[i] nsec is the time in nanoseconds from the last PPS event + */ +void _Timecounter_Discipline(struct timespec *tsp, long nsec); + /** @} */ #ifdef __cplusplus diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h index 30bca70c8d..731c33cfcd 100644 --- a/cpukit/include/sys/timepps.h +++ b/cpukit/include/sys/timepps.h @@ -27,6 +27,7 @@ #ifdef __rtems__ #include #define PPS_SYNC +#define hardpps _Timecounter_Discipline #endif /* __rtems__ */ #define PPS_API_VERS_1 1 @@ -203,7 +204,9 @@ void pps_event(struct pps_state *pps, int event); void pps_init(struct pps_state *pps); void pps_init_abi(struct pps_state *pps); int pps_ioctl(unsigned long cmd, caddr_t data, struct pps_state *pps); +#ifndef __rtems__ void hardpps(struct timespec *tsp, long nsec); +#endif /* __rtems__ */ #else /* !_KERNEL */ -- 2.25.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH] bsps/stm32h7: clarify license of stm32h7b3i-dk BSP variant
The system_stm32h7xx.c file provided in the boards/stm/stm32h7b3i-dk subdirectory needs a bit of clarification as it references "root directory" in its license comment and it's not clear where this points out. Let's add clarification comment about it and also based on it and resulting license let's add SPDX license identifier. --- .../stm/stm32h7b3i-dk/system_stm32h7xx.c | 46 +++ 1 file changed, 46 insertions(+) diff --git a/bsps/arm/stm32h7/boards/stm/stm32h7b3i-dk/system_stm32h7xx.c b/bsps/arm/stm32h7/boards/stm/stm32h7b3i-dk/system_stm32h7xx.c index db11aa19b1..44c13beaf2 100644 --- a/bsps/arm/stm32h7/boards/stm/stm32h7b3i-dk/system_stm32h7xx.c +++ b/bsps/arm/stm32h7/boards/stm/stm32h7b3i-dk/system_stm32h7xx.c @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ /** ** * @filesystem_stm32h7xx.c @@ -31,6 +32,51 @@ * ** */ +/* + * RTEMS committer clarification comment on license above: + * + * This file comes from STM32CubeH7 project from its Projects + * subdirectory. There is Templates subdirectory per every supported + * BSP there. The Templates contains the file. In our case the file is + * here: + * https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Projects/STM32H7B3I-DK/Templates/Src/system_stm32h7xx.c + * + * When we go up in the directory tree starting from the file, we find + * out that the "root directory" in the sense of license claim above is Templates + * directory here: + * https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/STM32H7B3I-DK/Templates + * + * This directory contains LICENSE.md file with a following license text: + * + * Copyright 2019 STMicroelectronics. + * All rights reserved. + * + * 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. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * 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 HOLDER 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. + */ + /** @addtogroup CMSIS * @{ -- 2.25.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH rtems-docs] c-user: Update references to --enable-* configure options.
Also updated list of SMP architectures and added enough lead in to let users know the source code was the definitive answer. --- c-user/config/general.rst | 6 +++--- c-user/config/mpci.rst| 17 c-user/config/posix-api.rst | 28 +++ c-user/symmetric_multiprocessing_services.rst | 23 +++--- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/c-user/config/general.rst b/c-user/config/general.rst index a1f242a..0da7530 100644 --- a/c-user/config/general.rst +++ b/c-user/config/general.rst @@ -437,9 +437,9 @@ Each processor needs an IDLE task stack and interrupt stack for example. If there are more processors available than configured, the rest will be ignored. -This configuration option is only evaluated in SMP configurations (e.g. RTEMS -was built with the ``--enable-smp`` build configuration option). In all -other configurations it has no effect. +This configuration option is only evaluated in SMP configurations of RTEMS +(e.g. RTEMS was built with the SMP build configuration option enabled). +In all other configurations it has no effect. .. rubric:: CONSTRAINTS: diff --git a/c-user/config/mpci.rst b/c-user/config/mpci.rst index 09c541f..d40f15c 100644 --- a/c-user/config/mpci.rst +++ b/c-user/config/mpci.rst @@ -23,12 +23,13 @@ Multiprocessing Configuration = -This section describes multiprocessing related configuration options. The -options are only used if RTEMS was built with the ``--enable-multiprocessing`` -build configuration option. Additionally, this class of configuration options -are only applicable if the configuration option :ref:`CONFIGURE_MP_APPLICATION` -is defined. The multiprocessing (MPCI) support must not be confused with the -SMP support. +This section describes multiprocessing related configuration options. +The options are only used if RTEMS was built when the multiprocessing +build configuration option is enabled. The multiprocessing configuration +is distinct from the SMP configuration. Additionally, this class of +configuration options are only applicable if the configuration option +:ref:`CONFIGURE_MP_APPLICATION` is defined. The multiprocessing (MPCI) +support must not be confused with the SMP support. .. Generated from spec:/acfg/if/mp-extra-server-stack @@ -115,8 +116,8 @@ options are assumed to be provided. .. rubric:: NOTES: This configuration option shall be undefined if the multiprocessing support -is not enabled (e.g. RTEMS was built without the ``--enable-multiprocessing`` -build configuration option). Otherwise a compile time error in the +is not enabled (e.g. RTEMS was built without the multiprocessing build +configuration option enabled). Otherwise a compile time error in the configuration file will occur. .. Generated from spec:/acfg/if/mp-max-global-objects diff --git a/c-user/config/posix-api.rst b/c-user/config/posix-api.rst index 12e6410..78cb724 100644 --- a/c-user/config/posix-api.rst +++ b/c-user/config/posix-api.rst @@ -25,7 +25,7 @@ POSIX API Configuration This section describes configuration options related to the POSIX API. Most POSIX API objects are available by default since RTEMS 5.1. The queued signals -and timers are only available if RTEMS was built with the ``--enable-posix`` +and timers are only available if RTEMS was built with the enable POSIX build configuration option. .. Generated from spec:/acfg/if/max-posix-keys @@ -231,8 +231,8 @@ API Queued Signals that can be concurrently active. Unlimited objects are not available for queued signals. -Queued signals are only available if RTEMS was built with the -``--enable-posix`` build configuration option. +Queued signals are only available if RTEMS was built with the POSIX API +build configuration option enabled. .. rubric:: CONSTRAINTS: @@ -470,29 +470,33 @@ API Timers that can be concurrently active. This object class can be configured in unlimited allocation mode, see :ref:`ConfigUnlimitedObjects`. -Timers are only available if RTEMS was built with the -``--enable-posix`` build configuration option. +Timers are only available if RTEMS was built with the POSIX API build +configuration option enabled. .. rubric:: CONSTRAINTS: The following constraints apply to this configuration option: -* The value of the configuration option shall be greater than or equal to zero. +* The value of the configuration option shall be greater than or equal +to zero. -* The value of the configuration option shall be less than or equal to 65535. +* The value of the configuration option shall be less than or equal +to 65535. * The value of the configuration option shall be less than or equal to a - BSP-specific and application-specific value which depends on the size of the - memory available to the application. + BSP-specific and application-specific value which depends on the size + of