summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Kühndel <frank.kuehndel@embedded-brains.de>2021-05-17 07:20:33 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-12 14:01:24 +0200
commitd16a95e69bbabefd09197bc284f4bc311fa558e0 (patch)
tree64bf44fe44289efef752b4a6efc6256dcaeebf8c
parentbb2ee6c34011491fed5571bf77a3e01768434e2e (diff)
testsuites/validation/tx-support.h
-rw-r--r--testsuites/validation/tx-support.h88
-rw-r--r--testsuites/validation/tx-timer-server.c83
2 files changed, 171 insertions, 0 deletions
diff --git a/testsuites/validation/tx-support.h b/testsuites/validation/tx-support.h
index 530606dc34..5d4824cef0 100644
--- a/testsuites/validation/tx-support.h
+++ b/testsuites/validation/tx-support.h
@@ -203,6 +203,19 @@ uint32_t GetTimecountCounter( void );
uint32_t SetTimecountCounter( uint32_t counter );
/**
+ * @brief Return the task id of the timer server task
+ *
+ * This function is an attempt to avoid using RTEMS internal global
+ * _Timer_server throughout the validation test code.
+ *
+ * @return Returns the task id of the timer server task, if
+ * rtems_timer_initiate_server() has been invoked before,
+ * otherwise - if the timer server task does not exist -
+ * RTEMS_INVALID_ID is returned.
+ */
+rtems_id GetTimerServerTaskId( void );
+
+/**
* @brief Undo the effects of rtems_timer_initiate_server()
*
* If rtems_timer_initiate_server() was never called before,
@@ -265,6 +278,81 @@ rtems_vector_number GetValidInterruptVectorNumber(
bool HasInterruptVectorEntriesInstalled( rtems_vector_number vector );
+/**
+ * @brief Get the clock and context of a timer from RTEMS internal data.
+ *
+ * With exception of TIMER_DORMANT, the return values are bits or-ed together.
+ *
+ * @param id The timer ID.
+ *
+ * @retval TIMER_DORMANT Either the id argument is invalid or the timer has
+ * never been used before.
+ * @return The TIMER_CLASS_BIT_ON_TASK is set, if the timer server routine
+ * was or will be executed in task context, otherwise it was or will be
+ * executed in interrupt context.
+ *
+ * The TIMER_CLASS_BIT_TIME_OF_DAY is set, if the clock used is or was the
+ * ${/glossary/clock-realtime:/term}, otherwise the
+ * ${/glossary/clock-tick:/term} based clock is or was used.
+ */
+Timer_Classes GetTimerClass( rtems_id id );
+
+/**
+ * @brief This structure provides data used by RTEMS to schedule a timer
+ * service routine.
+ */
+typedef struct {
+ /**
+ * @brief This member contains a reference to the timer service routine.
+ */
+ rtems_timer_service_routine_entry routine;
+ /**
+ * @brief This member contains a reference to the user data to be provided
+ * to the timer service routine.
+ */
+ void *user_data;
+ /**
+ * @brief This member contains the timer interval in ticks or seconds.
+ */
+ Watchdog_Interval interval;
+} Timer_Scheduling_Data;
+
+/**
+ * @brief Get data related to scheduling a timer service routine
+ * from RTEMS internal structures.
+ *
+ * @param id The timer ID.
+ * @param[out] data If the reference is not NULL, the data retrieved from
+ * internal RTEMS structures is stored here.
+ */
+void GetTimerSchedulingData(
+ rtems_id id,
+ Timer_Scheduling_Data *data
+);
+
+/**
+ * @brief The various states of a timer.
+ */
+typedef enum {
+ TIMER_INVALID,
+ TIMER_INACTIVE,
+ TIMER_SCHEDULED,
+ TIMER_PENDING
+} Timer_States;
+
+/**
+ * @brief Get the state of a timer from RTEMS internal data.
+ *
+ * @param id The timer ID.
+ *
+ * @retval TIMER_INVALID The id argument is invalid.
+ * @retval TIMER_INACTIVE The timer is not scheduled (i.e. it is
+ * new, run off, or canceled).
+ * @retval TIMER_SCHEDULED The timer is scheduled.
+ * @retval TIMER_PENDING The timer is pending.
+ */
+Timer_States GetTimerState( rtems_id id );
+
/** @} */
#ifdef __cplusplus
diff --git a/testsuites/validation/tx-timer-server.c b/testsuites/validation/tx-timer-server.c
index c62f480398..26a0902e0f 100644
--- a/testsuites/validation/tx-timer-server.c
+++ b/testsuites/validation/tx-timer-server.c
@@ -42,6 +42,14 @@
#include <rtems/test.h>
#include <rtems/rtems/timerimpl.h>
+rtems_id GetTimerServerTaskId( void )
+{
+ if ( _Timer_server == NULL ) {
+ return RTEMS_INVALID_ID;
+ }
+ return _Timer_server->server_id;
+}
+
bool DeleteTimerServer( void )
{
Timer_server_Control *server;
@@ -59,3 +67,78 @@ bool DeleteTimerServer( void )
return true;
}
+
+Timer_Classes GetTimerClass( rtems_id id )
+{
+ /* This code is derived from rtems_timer_get_information() */
+ Timer_Classes result = TIMER_DORMANT;
+ Timer_Control *the_timer;
+ ISR_lock_Context lock_context;
+ Per_CPU_Control *cpu;
+
+ the_timer = _Timer_Get( id, &lock_context );
+ if ( the_timer != NULL ) {
+ cpu = _Timer_Acquire_critical( the_timer, &lock_context );
+ result = the_timer->the_class;
+ _Timer_Release( cpu, &lock_context );
+ }
+
+ return result;
+}
+
+void GetTimerSchedulingData(
+ rtems_id id,
+ Timer_Scheduling_Data *data
+)
+{
+ /* This code is derived from rtems_timer_get_information() */
+ Timer_Control *the_timer;
+ ISR_lock_Context lock_context;
+ Per_CPU_Control *cpu;
+
+ if ( data == NULL ) {
+ return;
+ }
+
+ the_timer = _Timer_Get( id, &lock_context );
+ if ( the_timer != NULL ) {
+ cpu = _Timer_Acquire_critical( the_timer, &lock_context );
+ data->routine = the_timer->routine;
+ data->user_data = the_timer->user_data;
+ data->interval = the_timer->initial;
+ _Timer_Release( cpu, &lock_context );
+ }
+}
+
+Timer_States GetTimerState( rtems_id id )
+{
+ /* This code is derived from rtems_timer_cancel() and _timer_cancel() */
+ Timer_States result = TIMER_INVALID;
+ Timer_Control *the_timer;
+ ISR_lock_Context lock_context;
+ Per_CPU_Control *cpu;
+ Timer_Classes the_class;
+ Timer_server_Control *timer_server = _Timer_server;
+ ISR_lock_Context lock_context_server;
+
+ the_timer = _Timer_Get( id, &lock_context );
+ if ( the_timer != NULL ) {
+ result = TIMER_INACTIVE;
+ cpu = _Timer_Acquire_critical( the_timer, &lock_context );
+ the_class = the_timer->the_class;
+
+ if ( _Watchdog_Is_scheduled( &the_timer->Ticker ) ) {
+ result = TIMER_SCHEDULED;
+ } else if ( _Timer_Is_on_task_class( the_class ) ) {
+ _Assert( timer_server != NULL );
+ _Timer_server_Acquire_critical( timer_server, &lock_context_server );
+ if ( _Watchdog_Get_state( &the_timer->Ticker ) == WATCHDOG_PENDING ) {
+ result = TIMER_PENDING;
+ }
+ _Timer_server_Release_critical( timer_server, &lock_context_server );
+ }
+ _Timer_Release( cpu, &lock_context );
+ }
+
+ return result;
+}