aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisiora <none@example.com>2018-01-20 22:40:27 +0000
committerisiora <none@example.com>2018-01-20 22:40:27 +0000
commitf084dd04e7554e1d985ff96ac3fafade4840bdb1 (patch)
tree7f0c73166c30c3657ff71266ffd800011933d9f4
parent837c6f9717e6d2102e4a76bb502ca84799b0cbc9 (diff)
downloadChibiOS-f084dd04e7554e1d985ff96ac3fafade4840bdb1.tar.gz
ChibiOS-f084dd04e7554e1d985ff96ac3fafade4840bdb1.tar.bz2
ChibiOS-f084dd04e7554e1d985ff96ac3fafade4840bdb1.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11379 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/common/ports/ARMCAx-TZ/chcore.h17
-rw-r--r--os/common/ports/ARMCAx-TZ/chsmc.c51
-rw-r--r--os/common/ports/ARMCAx-TZ/chsmc.h3
3 files changed, 46 insertions, 25 deletions
diff --git a/os/common/ports/ARMCAx-TZ/chcore.h b/os/common/ports/ARMCAx-TZ/chcore.h
index 2a7a99c12..ba49735a2 100644
--- a/os/common/ports/ARMCAx-TZ/chcore.h
+++ b/os/common/ports/ARMCAx-TZ/chcore.h
@@ -67,7 +67,7 @@
/**
* @brief Macro defining a generic ARM architecture.
*/
-#define PORT_ARCHITECTURE_ARM
+#define PORT_ARCHITECTURE_ARM_TZ
/* The following code is not processed when the file is included from an
asm module because those intrinsic macros are not necessarily defined
@@ -153,7 +153,7 @@
/* ARM core check.*/
#if (ARM_CORE == ARM_CORE_CORTEX_A5) || defined(__DOXYGEN__)
#define PORT_ARCHITECTURE_ARM_ARM7
-#define PORT_ARCHITECTURE_NAME "ARMv7"
+#define PORT_ARCHITECTURE_NAME "ARMv7 (TZ)"
#define PORT_CORE_VARIANT_NAME "ARM Cortex-A5"
#elif ARM_CORE == ARM_CORE_CORTEX_A8
@@ -433,20 +433,23 @@ static inline bool port_is_isr_context(void) {
/**
* @brief Kernel-lock action.
- * @details In this port it disables the FIQ sources and keeps IRQ state.
+ * @details In this port it disables the FIQ and IRQ sources.
*/
static inline void port_lock(void) {
- __asm volatile ("cpsid f" : : : "memory");
+ __asm volatile ("cpsid if" : : : "memory");
}
/**
* @brief Kernel-unlock action.
- * @details In this port it enables the FIQ sources and keeps IRQ state.
+ * @details In this port it enables the FIQ and IRQ sources.
*/
static inline void port_unlock(void) {
-
- __asm volatile ("cpsie f" : : : "memory");
+extern thread_reference_t _ns_thread;
+ if (_ns_thread)
+ __asm volatile ("cpsie if" : : : "memory");
+ else
+ __asm volatile ("cpsie f" : : : "memory");
}
/**
diff --git a/os/common/ports/ARMCAx-TZ/chsmc.c b/os/common/ports/ARMCAx-TZ/chsmc.c
index 3de57a1cf..0dac3abff 100644
--- a/os/common/ports/ARMCAx-TZ/chsmc.c
+++ b/os/common/ports/ARMCAx-TZ/chsmc.c
@@ -35,7 +35,7 @@
/*===========================================================================*/
/* Module exported variables. */
/*===========================================================================*/
-thread_reference_t _ns_thread;
+thread_reference_t _ns_thread = NULL;
/*===========================================================================*/
/* Module local types. */
@@ -60,28 +60,19 @@ static bool isAddrSpaceValid(uint8_t *addr, size_t size)
static smc_service_t *smcGetService(const char *name, size_t namelen) {
registered_object_t *rop;
+ smc_service_t *svcp;
if (!isAddrSpaceValid((uint8_t *)name, namelen))
return NULL;
- if (*(name + namelen) != '\0')
+ if (*(name + namelen - 1) != '\0')
return NULL;
rop = chFactoryFindObject(name);
if (rop == NULL)
return NULL;
- return (smc_service_t *)(rop->objp);
-}
-
-#if 0 /* not used yet */
-static void smcReleaseService(smc_service_t *svc_handle) {
- registered_object_t *rop;
-
- rop = chFactoryFindObjectByPointer(svc_handle);
- if (rop == NULL)
- return;
- chFactoryReleaseObject(rop); /* our ref */
- chFactoryReleaseObject(rop); /* original ref */
+ svcp = (smc_service_t *)(rop->objp);
+ chFactoryReleaseObject(rop);
+ return svcp;
}
-#endif
/*===========================================================================*/
/* Module exported functions. */
@@ -118,7 +109,6 @@ msg_t smcEntry(smc_service_t *svc_handle, smc_params_area_t svc_data, size_t svc
smc_service_t *svcp;
msg_t r;
- asm("bkpt #0\n\t");
if (!isAddrSpaceValid(svc_data, svc_datalen))
return MSG_RESET;
if (svc_handle == SMC_HND_GET) {
@@ -185,7 +175,7 @@ msg_t smcServiceWaitRequest(smc_service_t *svcp)
chSysLock();
if (_ns_thread) {
- /* Ack the previous service invocation */
+ /* Ack the previous service invocation. Not schedule. */
chThdResumeI(&_ns_thread, MSG_OK);
}
r = chThdSuspendTimeoutS(&svcp->svct, TIME_INFINITE);
@@ -193,4 +183,31 @@ msg_t smcServiceWaitRequest(smc_service_t *svcp)
return r;
}
+/**
+ * @brief The calling thread is a service and wait the arrival of a request.
+ * @post the service object is filled with the parameters of the requestor.
+ *
+ * @param[in] svcp the service object reference.
+ *
+ * @return the reason of the awakening
+ * @retval MSG_OK a success value.
+ * @retval MSG_TIMEOUT a success value.
+ *
+ * @sclass
+ * @notapi
+ */
+msg_t smcServiceWaitRequestS(smc_service_t *svcp)
+{
+ msg_t r;
+
+ chDbgCheck(svcp != NULL);
+
+ if (_ns_thread) {
+ /* Ack the previous service invocation. Not schedule. */
+ chThdResumeI(&_ns_thread, MSG_OK);
+ }
+ r = chThdSuspendTimeoutS(&svcp->svct, TIME_INFINITE);
+ return r;
+}
+
/** @} */
diff --git a/os/common/ports/ARMCAx-TZ/chsmc.h b/os/common/ports/ARMCAx-TZ/chsmc.h
index 14d24b243..170ead317 100644
--- a/os/common/ports/ARMCAx-TZ/chsmc.h
+++ b/os/common/ports/ARMCAx-TZ/chsmc.h
@@ -86,10 +86,11 @@ typedef struct ch_smc_service {
extern "C" {
#endif
extern thread_reference_t _ns_thread;
-CC_NO_RETURN void _ns_trampoline(uint32_t addr);
+CC_NO_RETURN void _ns_trampoline(uint8_t *addr);
void smcInit(void);
registered_object_t * smcRegisterMeAsService(const char *svc_name);
msg_t smcServiceWaitRequest(smc_service_t *svcp);
+msg_t smcServiceWaitRequestS(smc_service_t *svcp);
#ifdef __cplusplus
}
#endif