aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdemos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/Makefile3
-rwxr-xr-xdemos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/chconf.h5
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/debug/RT-SAMA5D2-XPLAINED-SEC (DDRAM).launch2
-rwxr-xr-xdemos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/main.c109
-rw-r--r--demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/tservices.c94
5 files changed, 107 insertions, 106 deletions
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/Makefile b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/Makefile
index 12a653790..60a233b6d 100755
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/Makefile
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/Makefile
@@ -116,7 +116,7 @@ include $(CHIBIOS)/os/common/startup/ARMCAx-TZ/compilers/GCC/mk/startup_sama5d2.
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/SAMA/SAMA5D2x/platform.mk
-include $(CHIBIOS)/os/hal/boards/ATSAMA5D2_XULT/board.mk
+include $(CHIBIOS)/os/hal/boards/ATSAMA5D2_XULT_SEC/board.mk
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
@@ -140,6 +140,7 @@ CSRC = $(STARTUPSRC) \
$(BOARDSRC) \
$(TESTSRC) \
$(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ tservices.c \
main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/chconf.h b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/chconf.h
index 2e08d695b..6db52ba06 100755
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/chconf.h
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/chconf.h
@@ -49,7 +49,8 @@
* @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit.
*/
-#define CH_CFG_ST_FREQUENCY 1000
+//#define CH_CFG_ST_FREQUENCY 1000 /* periodic tick.*/
+#define CH_CFG_ST_FREQUENCY (83000000 / 32) /* tick-less.*/
/**
* @brief Time intervals data size.
@@ -71,7 +72,7 @@
* The value one is not valid, timeouts are rounded up to
* this value.
*/
-#define CH_CFG_ST_TIMEDELTA 0
+#define CH_CFG_ST_TIMEDELTA 2
/** @} */
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/debug/RT-SAMA5D2-XPLAINED-SEC (DDRAM).launch b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/debug/RT-SAMA5D2-XPLAINED-SEC (DDRAM).launch
index 645b16afb..a8b4f953a 100644
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/debug/RT-SAMA5D2-XPLAINED-SEC (DDRAM).launch
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/debug/RT-SAMA5D2-XPLAINED-SEC (DDRAM).launch
@@ -11,7 +11,7 @@
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
-<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value="20100000"/>
+<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value="27000000"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="2331"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="true"/>
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/main.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/main.c
index 0d04b0a17..300509671 100755
--- a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/main.c
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/main.c
@@ -16,10 +16,10 @@
#include "ch.h"
#include "hal.h"
+#include "chtssi.h"
#include "rt_test_root.h"
#include "oslib_test_root.h"
#include "chprintf.h"
-#include "chsmc.h"
/*
* LED blinker thread, times are in milliseconds.
@@ -52,51 +52,11 @@ static const SerialConfig sdcfg = {
UART_MR_PAR_NO
};
-/**
- * Dummy trust service thread.
- */
-static THD_WORKING_AREA(waDummyTrustedService, 512);
-static THD_FUNCTION(DummyTrustedService, arg) {
- (void) arg;
-
- msg_t msg;
- smc_service_t *svcp;
- chRegSetThreadName("DTS");
-
- /* Register the trust service.*/
- svcp = smcRegisterMeAsService("DummyTrustedService");
- if (svcp == NULL) {
-
- /* Error: the service is already registered
- * or memory is exhausted.*/
- return;
- }
-
- /* Wait and process requests.*/
- while (true) {
- msg = smcServiceWaitRequest(svcp, MSG_OK);
- if (msg == MSG_OK && svcp->svc_datalen > 0) {
- *((char *)svcp->svc_data + svcp->svc_datalen - 1) = '\0';
-#if 1
- chprintf((BaseSequentialStream*)&SD1,
- "My non secure 'alter ego' has a request.\r\n");
- chprintf((BaseSequentialStream*)&SD1,
- "She tells: '");
-#endif
- chprintf((BaseSequentialStream*)&SD1, (char *)svcp->svc_data);
- chprintf((BaseSequentialStream*)&SD1, "'\r\n");
- }
- chThdSleepMilliseconds(500);
- }
-}
-
/*
* Application entry point.
*/
int main(void) {
- uint32_t n;
-
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
@@ -107,7 +67,6 @@ int main(void) {
*/
halInit();
chSysInit();
- smcInit();
/*
* Activates the serial driver 0 using the driver default configuration.
@@ -117,72 +76,18 @@ int main(void) {
/* Redirecting UART0 RX on PD2 and UART0 TX on PD3. */
palSetGroupMode(PIOD, PAL_PORT_BIT(2) | PAL_PORT_BIT(3), 0U,
PAL_SAMA_FUNC_PERIPH_A | PAL_MODE_SECURE);
- /*
- * Creates the blinker thread.
- */
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-64, Thread1, NULL);
- /*
- * Creates the dummy service thread.
- */
- n = 0;
- chThdCreateStatic(waDummyTrustedService, sizeof(waDummyTrustedService), NORMALPRIO-32,
- DummyTrustedService, (void *)n);
- ++n;
/*
- * The DDR memory is divided in 4 regions. Each region is 2MB large.
- * The first region is split in two areas, each 1MB large.
- * The lower area of this first region is non secure.
- * All the rest of the regions space is secured.
+ * Creates the blinker thread (and any other ancillary thread).
*/
- mtxSetSlaveRegionSize(MATRIX0, H64MX_SLAVE_DDR_PORT0, MATRIX_AREA_SIZE_2M, REGION_0_MSK);
- mtxSetSlaveRegionSize(MATRIX0, H64MX_SLAVE_DDR_PORT1, MATRIX_AREA_SIZE_2M, REGION_0_MSK);
-
- mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT0, MATRIX_AREA_SIZE_1M, REGION_0_MSK);
- mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT0, MATRIX_AREA_SIZE_2M,
- REGION_1_MSK | REGION_2_MSK | REGION_3_MSK);
- mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT1, MATRIX_AREA_SIZE_1M, REGION_0_MSK);
- mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT1, MATRIX_AREA_SIZE_2M,
- REGION_1_MSK | REGION_2_MSK | REGION_3_MSK);
-
- mtxConfigSlaveSec(MATRIX0, H64MX_SLAVE_DDR_PORT0,
- mtxRegionLansech(REGION_0, UPPER_AREA_SECURABLE) |
- mtxRegionLansech(REGION_1, UPPER_AREA_SECURABLE) |
- mtxRegionLansech(REGION_2, UPPER_AREA_SECURABLE) |
- mtxRegionLansech(REGION_3, UPPER_AREA_SECURABLE),
- mtxRegionRdnsech(REGION_0, NOT_SECURE_READ) |
- mtxRegionRdnsech(REGION_1, NOT_SECURE_READ) |
- mtxRegionRdnsech(REGION_2, NOT_SECURE_READ) |
- mtxRegionRdnsech(REGION_3, NOT_SECURE_READ),
- mtxRegionWrnsech(REGION_0, NOT_SECURE_WRITE) |
- mtxRegionWrnsech(REGION_1, NOT_SECURE_WRITE) |
- mtxRegionWrnsech(REGION_2, NOT_SECURE_WRITE) |
- mtxRegionWrnsech(REGION_3, NOT_SECURE_WRITE));
- mtxConfigSlaveSec(MATRIX0, H64MX_SLAVE_DDR_PORT1,
- mtxRegionLansech(REGION_0, UPPER_AREA_SECURABLE) |
- mtxRegionLansech(REGION_1, UPPER_AREA_SECURABLE) |
- mtxRegionLansech(REGION_2, UPPER_AREA_SECURABLE) |
- mtxRegionLansech(REGION_3, UPPER_AREA_SECURABLE),
- mtxRegionRdnsech(REGION_0, NOT_SECURE_READ) |
- mtxRegionRdnsech(REGION_1, NOT_SECURE_READ) |
- mtxRegionRdnsech(REGION_2, NOT_SECURE_READ) |
- mtxRegionRdnsech(REGION_3, NOT_SECURE_READ),
- mtxRegionWrnsech(REGION_0, NOT_SECURE_WRITE) |
- mtxRegionWrnsech(REGION_1, NOT_SECURE_WRITE) |
- mtxRegionWrnsech(REGION_2, NOT_SECURE_WRITE) |
- mtxRegionWrnsech(REGION_3, NOT_SECURE_WRITE));
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+10, Thread1, NULL);
/*
- * Wait that all services are initialized
- */
- smcWaitServicesStarted(n);
- /*
- * Jump in the NON SECURE world
- * This 'main' thread become the non secure environment as view by
- * the secure world.
+ * System initializations.
+ * - TSSI initialization, the trusted services are created and started.
+ * Lastly, the thread "main" becomes the non secure execution environment.
*/
- chprintf((BaseSequentialStream*)&SD1, "Jumping in the non secure world\n\r");
- _ns_trampoline(NSEC_IMAGE_START_ADDR);
+ tssiInit();
/*
* It never goes here
*/
diff --git a/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/tservices.c b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/tservices.c
new file mode 100644
index 000000000..5c52fabfc
--- /dev/null
+++ b/demos/ATSAMA5D2/RT-SAMA5D2-XPLAINED-SEC/tservices.c
@@ -0,0 +1,94 @@
+/*
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file tservices.c
+ * @brief Trusted services application file.
+ *
+ * @addtogroup TSSI
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "chtssi.h"
+#include "chprintf.h"
+
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+static THD_WORKING_AREA(waTsSimpleService, 1024);
+static THD_FUNCTION(TsSimpleService, tsstate) {
+
+ /* WARNING: do not put blocking call out of the cycle,
+ * i.e. no calls that suspend
+ * the current thread!.*/
+
+ ts_state_t *svcp = tsstate;
+
+ /* Start the request/process/response cycle.*/
+ while (tssiWaitRequest(tsstate) == SMC_SVC_OK) {
+ int i;
+ chprintf((BaseSequentialStream*)&SD1,
+ "TsSimpleService received a new request.\r\n");
+ if (svcp->ts_datalen > 0) {
+ *(TS_GET_DATA(svcp) + TS_GET_DATALEN(svcp) - 1) = '\0';
+ chprintf((BaseSequentialStream*)&SD1,
+ "My non secure 'alter ego' has a request.\r\n");
+ chprintf((BaseSequentialStream*)&SD1,
+ "She tells: '");
+ chprintf((BaseSequentialStream*)&SD1, TS_GET_DATA(svcp));
+ chprintf((BaseSequentialStream*)&SD1, "'\r\n");
+ }
+ for (i = 0; i < 100000; ++i)
+ ;
+ TS_SET_STATUS(svcp, i);
+ }
+
+ /* It never goes here.*/
+}
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief TSSI services table definition
+ * @note This table is filled by the user.
+ */
+TS_STATE_TABLE
+TS_CONF_TABLE_BEGIN
+ TS_CONF_TABLE_ENTRY("TsSimpleService", waTsSimpleService, TS_BASE_PRIO, TsSimpleService, TS_STATE(0))
+TS_CONF_TABLE_END
+
+/** @} */