git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11379 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
isiora 2018-01-20 22:40:27 +00:00
parent 837c6f9717
commit f084dd04e7
3 changed files with 46 additions and 25 deletions

View File

@ -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");
}
/**

View File

@ -35,7 +35,7 @@
/*===========================================================================*/
/* Module exported variables. */
/*===========================================================================*/
thread_reference_t _ns_thread;
thread_reference_t _ns_thread = NULL;
/*===========================================================================*/
/* Module local types. */
@ -60,29 +60,20 @@ 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);
svcp = (smc_service_t *)(rop->objp);
chFactoryReleaseObject(rop);
return svcp;
}
#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 */
}
#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;
}
/** @} */

View File

@ -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