aboutsummaryrefslogtreecommitdiffstats
path: root/demos/ATSAMA5D2
diff options
context:
space:
mode:
authorisiora <none@example.com>2018-03-15 12:16:56 +0000
committerisiora <none@example.com>2018-03-15 12:16:56 +0000
commit188c45b6208e54b49f9974a4787eb1e112c756b3 (patch)
tree0adcbb50a79b78021871a0fb894afb6c5c4aa7b5 /demos/ATSAMA5D2
parent18f1b739fc90590e9927af66b6ddf7216c0b831e (diff)
downloadChibiOS-188c45b6208e54b49f9974a4787eb1e112c756b3.tar.gz
ChibiOS-188c45b6208e54b49f9974a4787eb1e112c756b3.tar.bz2
ChibiOS-188c45b6208e54b49f9974a4787eb1e112c756b3.zip
Modified the signature of tsInvokeService. Added to the api an invoke without yield.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11765 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'demos/ATSAMA5D2')
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.c58
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.h55
2 files changed, 82 insertions, 31 deletions
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.c
index b6d621b5c..dcf3ed064 100644
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.c
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.c
@@ -20,9 +20,6 @@
/**
* @file tsclient.c
* @brief TSSI client module code.
- *
- * @addtogroup TSSI
- * @{
*/
#include "ch.h"
@@ -35,6 +32,7 @@
/*===========================================================================*/
/* Module exported variables. */
/*===========================================================================*/
+EVENTSOURCE_DECL(stubsEventSource);
/*===========================================================================*/
/* Module local types. */
@@ -63,7 +61,11 @@ void tsIdle(void) {
}
/**
- * @brief Call a service via smc instruction.
+ * @brief Call a service via smc instruction with yield times.
+ * @details a time slice will be yielded also to the lower prio NSEC threads,
+ * whenever the service call is interrupted.
+ * This avoids the starvation of NSEC threads that run to lower prio,
+ * due to continue polling of the called service status.
*
* @param[in] handle The handle of the service to invoke.
* The handle is obtained by an invoke to discovery
@@ -74,8 +76,9 @@ void tsIdle(void) {
* @param[in] svc_nsec_time The time slice that will be yielded to the lower
* prio NSEC threads, whenever the service call is
* interrupted, in microseconds.
- * This avoids the starvation of lower NSEC thread due
- * to continue polling of the called service status.
+ * This avoids the starvation of NSEC threads that run
+ * to lower prio, due to continue polling of the
+ * called service status.
* 0 means no time slice is yielded.
*
* @return The service status. The value depends on the service.
@@ -89,17 +92,46 @@ void tsIdle(void) {
* @api
*/
msg_t tsInvokeService(ts_service_t handle, ts_params_area_t data,
- size_t size, sysinterval_t svc_nsec_time)
+ size_t size)
{
- int64_t result;
+ msg_t result;
result = tsInvoke1(handle, data, size, TS_GRANTED_TIMESLICE);
- while ((msg_t)result == SMC_SVC_INTR) {
- if (svc_nsec_time != 0)
- chThdSleepMicroseconds(svc_nsec_time);
+ while (result == SMC_SVC_INTR) {
+ chThdSleepMicroseconds(TS_GRANTED_TIMESLICE);
result = tsInvoke1(TS_HND_STQRY, handle, 0, TS_GRANTED_TIMESLICE);
}
- return (msg_t)result;
+ return result;
}
-/** @} */
+/**
+ * @brief Call a service via smc instruction without yield time to NSEC.
+ *
+ * @param[in] handle The handle of the service to invoke.
+ * The handle is obtained by an invoke to discovery
+ * service.
+ * @param[in,out] svc_data Service request data, often a reference to a more
+ * complex structure.
+ * @param[in] svc_datalen Size of the svc_data memory area.
+ *
+ * @return The service status. The value depends on the service.
+ *
+ * @retval SMC_SVC_OK generic success value.
+ * @retval SMC_SVC_BUSY the service has a pending request.
+ * @retval SMC_SVC_INVALID bad parameters.
+ * @retval SMC_SVC_NOENT no such service.
+ * @retval SMC_SVC_BADH bad handle.
+ *
+ * @api
+ */
+msg_t tsInvokeServiceNoYield(ts_service_t handle, ts_params_area_t data,
+ size_t size)
+{
+ msg_t result;
+
+ result = tsInvoke1(handle, data, size, TS_GRANTED_TIMESLICE);
+ while (result == SMC_SVC_INTR) {
+ result = tsInvoke1(TS_HND_STQRY, handle, 0, TS_GRANTED_TIMESLICE);
+ }
+ return result;
+}
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.h b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.h
index b0ce522c1..e92c732db 100644
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.h
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-NSEC/tsclient.h
@@ -20,9 +20,6 @@
/**
* @file tsclient.h
* @brief TSSI client module macros and structures.
- *
- * @addtogroup TSSI
- * @{
*/
#ifndef TSCLIENT_H
@@ -53,9 +50,13 @@
#define TS_GRANTED_TIMESLICE 1000 /* Microseconds.*/
+#if !defined(TS_CHECK_EVENT_HOOK)
#define TS_CHECK_EVENT_HOOK(f) { \
- (void)f; \
+ extern event_source_t stubsEventSource; \
+ if (f) \
+ chEvtBroadcastFlags(&stubsEventSource, f); \
}
+#endif
/*===========================================================================*/
/* Derived constants and error checks. */
@@ -78,7 +79,27 @@ typedef void * ts_service_t;
/**
* @brief Call a service via smc instruction.
- * @note see tsInvoke1()
+ * @details call a given service via smc.
+ *
+ * @param[in] handle The handle of the service to invoke.
+ * The handle is obtained by an invoke to discovery
+ * service.
+ * @param[in,out] svc_data Service request data, often a reference to a more
+ * complex structure.
+ * @param[in] svc_datalen Size of the svc_data memory area.
+ * @param[in] yieldtime The time yield to SEC service to run, in microsec.
+ *
+ * @return A 64bit value. It is composed by the 32bit service
+ * status in the lo-word with the 32bit event mask in
+ * the hi-word.
+ * The retval values are returned in the lower word
+ * as 32bit int.
+ * @retval SMC_SVC_OK generic success value.
+ * @retval SMC_SVC_INTR call interrupted.
+ * @retval SMC_SVC_BUSY the service has a pending request.
+ * @retval SMC_SVC_INVALID bad parameters.
+ * @retval SMC_SVC_NOENT no such service.
+ * @retval SMC_SVC_BADH bad handle.
*
* @notapi
*/
@@ -110,11 +131,8 @@ static inline int64_t tsInvoke0(ts_service_t handle, ts_params_area_t data,
* @param[in] svc_datalen Size of the svc_data memory area.
* @param[in] yieldtime The time yield to SEC service to run, in microsec.
*
- * @return A 64bit value. It is composed by the 32bit service
- * status in the lo-word with the 32bit event mask in
- * the hi-word.
- * The retval values are returned in the lower word
- * as 32bit int.
+ * @return The service status. The value depends on the service.
+ *
* @retval SMC_SVC_OK generic success value.
* @retval SMC_SVC_INTR call interrupted.
* @retval SMC_SVC_BUSY the service has a pending request.
@@ -124,15 +142,15 @@ static inline int64_t tsInvoke0(ts_service_t handle, ts_params_area_t data,
*
* @api
*/
-static inline int64_t tsInvoke1(ts_service_t handle, ts_params_area_t data,
- size_t size, sysinterval_t timeslice) {
+static inline msg_t tsInvoke1(ts_service_t handle, ts_params_area_t data,
+ size_t size, sysinterval_t yieldtime) {
int64_t result;
eventflags_t f;
- result = tsInvoke0(handle, data, size, timeslice);
+ result = tsInvoke0(handle, data, size, yieldtime);
f = (eventflags_t)(result >> 32);
TS_CHECK_EVENT_HOOK(f);
- return result;
+ return (msg_t)result;
}
/*===========================================================================*/
@@ -142,8 +160,11 @@ static inline int64_t tsInvoke1(ts_service_t handle, ts_params_area_t data,
#ifdef __cplusplus
extern "C" {
#endif
-msg_t tsInvokeService(ts_service_t handle, ts_params_area_t data,
- size_t size, sysinterval_t svc_nsec_time);
+ msg_t tsInvokeService(ts_service_t handle, ts_params_area_t data,
+ size_t size);
+ msg_t tsInvokeServiceNoYield(ts_service_t handle, ts_params_area_t data,
+ size_t size);
+ extern event_source_t stubsEventSource;
#ifdef __cplusplus
}
#endif
@@ -153,5 +174,3 @@ msg_t tsInvokeService(ts_service_t handle, ts_params_area_t data,
/*===========================================================================*/
#endif /* TSCLIENT_H */
-
-/** @} */