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 "oslib_test_root.h"
|
||||
#include "chprintf.h"
|
||||
#include "smcclient.h"
|
||||
/*
|
||||
* LED blinker thread, times are in milliseconds.
|
||||
*/
|
||||
|
@ -50,14 +51,11 @@ static const SerialConfig sdcfg = {
|
|||
UART_MR_PAR_NO
|
||||
};
|
||||
|
||||
msg_t smcInvokeService(msg_t handle, void *data);
|
||||
|
||||
/*
|
||||
* Application entry point.
|
||||
*/
|
||||
int main(void) {
|
||||
|
||||
asm("bkpt #0\n\t");
|
||||
smc_service_t smcsvc;
|
||||
/*
|
||||
* System initializations.
|
||||
* - HAL initialization, this also initializes the configured device drivers
|
||||
|
@ -82,16 +80,24 @@ int main(void) {
|
|||
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");
|
||||
//smcInvokeService(1, (void *)2);
|
||||
chprintf((BaseSequentialStream*)&SD0, "Calling the 'dummy' secure service\n\r");
|
||||
|
||||
/* 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
|
||||
* sleeping in a loop and check the button state.
|
||||
* calling periodically the dummy service and check the button state.
|
||||
*/
|
||||
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 1
|
||||
test_execute((BaseSequentialStream *)&SD0, &rt_test_suite);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "smcclient.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
|
@ -50,14 +51,14 @@
|
|||
/*===========================================================================*/
|
||||
/* Module exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
msg_t smcInvokeService(msg_t handle, void *data)
|
||||
msg_t smcInvokeService(smc_service_t handle, smc_params_area_t data,
|
||||
size_t size)
|
||||
{
|
||||
msg_t result;
|
||||
|
||||
do {
|
||||
asm volatile("smc #0" : "=r" (result) : "r" (handle), "r" (data));
|
||||
} while (result == MSG_RESET);
|
||||
asm volatile("smc #0" : "=r" (result) : "r" (handle), "r" (data), "r" (size));
|
||||
} while (result == MSG_TIMEOUT);
|
||||
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