git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11351 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
d1fbd41782
commit
9b492024bd
|
@ -19,6 +19,7 @@
|
||||||
#include "rt_test_root.h"
|
#include "rt_test_root.h"
|
||||||
#include "oslib_test_root.h"
|
#include "oslib_test_root.h"
|
||||||
#include "chprintf.h"
|
#include "chprintf.h"
|
||||||
|
#include "smcclient.h"
|
||||||
/*
|
/*
|
||||||
* LED blinker thread, times are in milliseconds.
|
* LED blinker thread, times are in milliseconds.
|
||||||
*/
|
*/
|
||||||
|
@ -50,14 +51,11 @@ static const SerialConfig sdcfg = {
|
||||||
UART_MR_PAR_NO
|
UART_MR_PAR_NO
|
||||||
};
|
};
|
||||||
|
|
||||||
msg_t smcInvokeService(msg_t handle, void *data);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Application entry point.
|
* Application entry point.
|
||||||
*/
|
*/
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
smc_service_t smcsvc;
|
||||||
asm("bkpt #0\n\t");
|
|
||||||
/*
|
/*
|
||||||
* System initializations.
|
* System initializations.
|
||||||
* - HAL initialization, this also initializes the configured device drivers
|
* - HAL initialization, this also initializes the configured device drivers
|
||||||
|
@ -82,16 +80,24 @@ int main(void) {
|
||||||
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);
|
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call the null secure service
|
* Call the dummy secure service
|
||||||
*/
|
*/
|
||||||
chprintf((BaseSequentialStream*)&SD0, "Calling the 'null' secure service\n\r");
|
chprintf((BaseSequentialStream*)&SD0, "Calling the 'dummy' secure service\n\r");
|
||||||
//smcInvokeService(1, (void *)2);
|
|
||||||
|
|
||||||
|
/* Retrieve the service handle by name */
|
||||||
|
smcsvc = (smc_service_t) smcInvokeService(
|
||||||
|
SMC_HND_GET, (smc_params_area_t)"DummyTrustedService",
|
||||||
|
sizeof "DummyTrustedService");
|
||||||
/*
|
/*
|
||||||
* Normal main() thread activity, in this demo it does nothing except
|
* Normal main() thread activity, in this demo it does nothing except
|
||||||
* sleeping in a loop and check the button state.
|
* calling periodically the dummy service and check the button state.
|
||||||
*/
|
*/
|
||||||
while (true) {
|
while (true) {
|
||||||
|
msg_t r;
|
||||||
|
|
||||||
|
/* Invoke the service */
|
||||||
|
r = smcInvokeService(smcsvc, (smc_params_area_t)"HELO", sizeof "HELO");
|
||||||
|
chprintf((BaseSequentialStream*)&SD0, "Call result: %d\r\n", r);
|
||||||
if(!palReadPad(PIOB, PIOB_USER_PB)) {
|
if(!palReadPad(PIOB, PIOB_USER_PB)) {
|
||||||
#if 1
|
#if 1
|
||||||
test_execute((BaseSequentialStream *)&SD0, &rt_test_suite);
|
test_execute((BaseSequentialStream *)&SD0, &rt_test_suite);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
|
#include "smcclient.h"
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module local definitions. */
|
/* Module local definitions. */
|
||||||
|
@ -50,14 +51,14 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Module exported functions. */
|
/* Module exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
msg_t smcInvokeService(smc_service_t handle, smc_params_area_t data,
|
||||||
msg_t smcInvokeService(msg_t handle, void *data)
|
size_t size)
|
||||||
{
|
{
|
||||||
msg_t result;
|
msg_t result;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
asm volatile("smc #0" : "=r" (result) : "r" (handle), "r" (data));
|
asm volatile("smc #0" : "=r" (result) : "r" (handle), "r" (data), "r" (size));
|
||||||
} while (result == MSG_RESET);
|
} while (result == MSG_TIMEOUT);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS.
|
||||||
|
|
||||||
|
ChibiOS is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file smcclient.h
|
||||||
|
* @brief smc Module macros and structures.
|
||||||
|
*
|
||||||
|
* @addtogroup SMC
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SMCCLIENT_H
|
||||||
|
#define SMCCLIENT_H
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
/*
|
||||||
|
* Service registry errors
|
||||||
|
*/
|
||||||
|
#define SMC_SVC_OK MSG_OK /* No error */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special service handles
|
||||||
|
*/
|
||||||
|
#define SMC_HND_TRAMP ((smc_service_t)0)
|
||||||
|
#define SMC_HND_GET ((smc_service_t)1)
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module pre-compile time settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Derived constants and error checks. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module data structures and types. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
typedef uint8_t * smc_params_area_t;
|
||||||
|
typedef void * smc_service_t;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* External declarations. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
msg_t smcInvokeService(smc_service_t handle, smc_params_area_t data,
|
||||||
|
size_t size);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Module inline functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#endif /* SMCCLIENT_H */
|
||||||
|
|
||||||
|
/** @} */
|
Loading…
Reference in New Issue