chtssi.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Isidoro Orabona
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file chtssi.c
  15. * @brief Trusted services related API and definition.
  16. *
  17. * @addtogroup TSSI
  18. * @{
  19. */
  20. #include "ch.h"
  21. #include "hal.h"
  22. #include "chtssi.h"
  23. #include "ARMCA5.h"
  24. #if defined(__GNUC__) || defined(__DOXYGEN__)
  25. #include "cmsis_gcc.h"
  26. #else
  27. #include "cmsis_armcc.h"
  28. #endif
  29. #include "ccportab.h"
  30. #include <string.h>
  31. /*===========================================================================*/
  32. /* Module local definitions. */
  33. /*===========================================================================*/
  34. /* Granted timeslices to trusted service. DO NOT modify those values.
  35. They have non secure world counterparts.*/
  36. typedef enum {
  37. TS_TIMEINT_1000_US = 1000,
  38. TS_TIMEINT_10000_US = 10000
  39. } ts_timeint_t;
  40. #define LOWORD(in64) ((int64_t)in64 & 0x0FFFFFFFF)
  41. #define TS_TIME2I(tmo) \
  42. (tmo == TS_TIMEINT_10000_US ? TIME_US2I(TS_TIMEINT_10000_US) : \
  43. TIME_US2I(TS_TIMEINT_1000_US))
  44. #define FDT_MAGIC 0xd00dfeed
  45. /*===========================================================================*/
  46. /* Module exported variables. */
  47. /*===========================================================================*/
  48. /* If a services file is missing in the user application.*/
  49. CC_WEAK ts_state_t ts_state[TS_MAX_SVCS];
  50. CC_WEAK const thread_descriptor_t ts_configs[TS_MAX_SVCS];
  51. CC_WEAK const fc_descriptor_t ts_fc_configs[1];
  52. uint32_t ts_fc_configs_n;
  53. /* The reference to the suspended NSEC main thread.*/
  54. thread_reference_t _ns_thread = NULL;
  55. /* The services may broadcast and listen event flags via this object.*/
  56. EVENTSOURCE_DECL(tsEventSource);
  57. extern uint32_t __ram0_start__;
  58. /*===========================================================================*/
  59. /* Module local types. */
  60. /*===========================================================================*/
  61. struct fdt_header {
  62. uint32_t magic; /* magic word FDT_MAGIC */
  63. uint32_t totalsize; /* total size of DT block */
  64. uint32_t off_dt_struct; /* offset to structure */
  65. uint32_t off_dt_strings; /* offset to strings */
  66. uint32_t off_mem_rsvmap; /* offset to memory reserve map */
  67. uint32_t version; /* format version */
  68. uint32_t last_comp_version; /* last compatible version */
  69. /* version 2 fields below */
  70. uint32_t boot_cpuid_phys; /* Which physical CPU id we're
  71. booting on */
  72. /* version 3 fields below */
  73. uint32_t size_dt_strings; /* size of the strings block */
  74. /* version 17 fields below */
  75. uint32_t size_dt_struct; /* size of the structure block */
  76. };
  77. /*===========================================================================*/
  78. /* Module local variables. */
  79. /*===========================================================================*/
  80. /* The ts module listen to the tsEventSource via this object.*/
  81. static event_listener_t tsEventListener;
  82. /*===========================================================================*/
  83. /* Module local functions. */
  84. /*===========================================================================*/
  85. static inline uint32_t uswap32(uint32_t v)
  86. {
  87. uint32_t result;
  88. __asm volatile ("rev %0, %1" : "=r" (result) : "r" (v));
  89. return result;
  90. }
  91. static bool isAddrSpaceValid(uint8_t *addr, size_t size)
  92. {
  93. if (size == 0)
  94. return TRUE;
  95. return (bool)((addr - NSEC_MEMORY_START_ADDR) <
  96. (NSEC_MEMORY_END_ADDR - NSEC_MEMORY_START_ADDR)) &&
  97. (bool)((addr + size - NSEC_MEMORY_START_ADDR) <
  98. (NSEC_MEMORY_END_ADDR - NSEC_MEMORY_START_ADDR));
  99. }
  100. static bool isHndlValid(ts_state_t *handle)
  101. {
  102. if ((handle < TS_STATE(0)) || (handle >= TS_STATE(TS_MAX_SVCS)))
  103. return FALSE;
  104. if (((char *)handle - (char *)TS_STATE(0)) % sizeof *TS_STATE(0))
  105. return FALSE;
  106. return TRUE;
  107. }
  108. static ts_state_t *findSvcsEntry(const char *name)
  109. {
  110. int i;
  111. for (i = 0; i < TS_MAX_SVCS; ++i) {
  112. if (TS_CONF_TABLE(i)->name == NULL)
  113. continue;
  114. if (!strcmp(TS_CONF_TABLE(i)->name, name))
  115. return TS_CONF_TABLE(i)->arg;
  116. }
  117. return NULL;
  118. }
  119. /*===========================================================================*/
  120. /* Module exported functions. */
  121. /*===========================================================================*/
  122. /**
  123. * @brief The trusted service call entry point.
  124. * @pre The foreign interrupts are disabled.
  125. * @post A request is passed to the thread registered for the service.
  126. * @post The service thread is resumed.
  127. *
  128. * @param[in] svc_handle the handle of the service to be invoked.
  129. * @param[in,out] svc_data service request data, often a reference to a more
  130. * complex structure.
  131. * @param[in] svc_datalen size of the svc_data memory area.
  132. * @param[in] svc_timeout after this time interval, the service execution
  133. * will be interrupted. Time is in microseconds.
  134. * This interval represents the time slice granted
  135. * to the services to continue their work.
  136. *
  137. * @return A 64bit value. It is the OR of the 32bit service
  138. * status combined with a 32bit event mask (in the
  139. * hi-word).
  140. * The retval values are returned in the lower word
  141. * as 32bit int.
  142. * @retval SMC_SVC_OK generic success value.
  143. * @retval SMC_SVC_INTR call interrupted.
  144. * @retval SMC_SVC_BUSY the service has a pending request.
  145. * @retval SMC_SVC_INVALID bad parameters.
  146. * @retval SMC_SVC_NOENT no such service.
  147. * @retval SMC_SVC_BADH bad handle.
  148. *
  149. * @notapi
  150. */
  151. int64_t smcEntry(ts_state_t *svc_handle, ts_params_area_t svc_data,
  152. size_t svc_datalen, ts_timeint_t svc_timeout) {
  153. ts_state_t *tssp = NULL;
  154. msg_t r;
  155. if (svc_handle == TS_HND_STQRY) {
  156. /* Internal query status service.*/
  157. ts_state_t *tsqryd;
  158. /* svc_data is the handle of the service to whom 'query' the state.*/
  159. tsqryd = (ts_state_t *)svc_data;
  160. /* handle argument validation.*/
  161. if (!isHndlValid(tsqryd))
  162. return LOWORD(SMC_SVC_BADH);
  163. /* if the service has done, return its last status.*/
  164. if (tsqryd->ts_thdp != NULL) {
  165. r = tsqryd->ts_status;
  166. return LOWORD(r);
  167. }
  168. }
  169. else if (svc_handle != TS_HND_IDLE) {
  170. if (!isAddrSpaceValid(svc_data, svc_datalen))
  171. return LOWORD(SMC_SVC_INVALID);
  172. uint32_t i = (uint32_t)svc_handle;
  173. if ((i & TS_FASTCALL_MASK) == TS_FASTCALL_MASK) {
  174. /* Fast call user service.*/
  175. i &= ~TS_FASTCALL_MASK;
  176. if (i >= ts_fc_configs_n)
  177. return LOWORD(SMC_SVC_BADH);
  178. return TS_FC_CONF_TABLE(i)->funcp(svc_data, svc_datalen);
  179. }
  180. else if (svc_handle == TS_HND_VERSION) {
  181. /* Internal get version service.*/
  182. return LOWORD(TSSI_VERSION);
  183. }
  184. else if (svc_handle == TS_HND_DISCOVERY) {
  185. /* Internal discovery service.*/
  186. if (svc_datalen) {
  187. *((char *)svc_data + svc_datalen - 1) = '\0';
  188. tssp = findSvcsEntry((char *)svc_data);
  189. }
  190. if (tssp == NULL)
  191. return LOWORD(SMC_SVC_NOENT);
  192. return LOWORD((int32_t)tssp);
  193. }
  194. else {
  195. /* User service.*/
  196. if (!isHndlValid(svc_handle))
  197. return LOWORD(SMC_SVC_BADH);
  198. tssp = svc_handle;
  199. /* If the service is not waiting requests, it's busy.*/
  200. if (tssp->ts_thdp == NULL)
  201. return LOWORD(SMC_SVC_BUSY);
  202. tssp->ts_datap = svc_data;
  203. tssp->ts_datalen = svc_datalen;
  204. }
  205. }
  206. #if (CH_DBG_SYSTEM_STATE_CHECK == TRUE)
  207. _dbg_check_lock();
  208. #endif
  209. /* Limit the max timeout interval.*/
  210. if (svc_timeout > TS_MAX_TMO)
  211. svc_timeout = TS_MAX_TMO;
  212. if (tssp)
  213. chThdResumeS(&tssp->ts_thdp, MSG_OK);
  214. r = chThdSuspendTimeoutS(&_ns_thread, TS_TIME2I(svc_timeout));
  215. /* Map MSG_TIMEOUT to SMC_SVC_INTR.*/
  216. if (r == MSG_TIMEOUT)
  217. r = SMC_SVC_INTR;
  218. /* Get and clear any pending event flags.*/
  219. eventflags_t f = chEvtGetAndClearFlagsI(&tsEventListener);
  220. #if (CH_DBG_SYSTEM_STATE_CHECK == TRUE)
  221. _dbg_check_unlock();
  222. #endif
  223. return LOWORD(r) | ((int64_t)f << 32);
  224. }
  225. /**
  226. * @brief The calling thread is a service and wait the arrival of
  227. * a request.
  228. * @post The service object state is filled with the parameters of
  229. * the requester.
  230. *
  231. * @param[in] svcp the service object reference.
  232. *
  233. * @return The wakeup message.
  234. * @retval MSG_OK a new request has to be processed.
  235. *
  236. * @api
  237. */
  238. msg_t tssiWaitRequest(ts_state_t *svcp)
  239. {
  240. msg_t r;
  241. chDbgCheck(svcp != NULL);
  242. chSysLock();
  243. if (_ns_thread) {
  244. /* Ack a previous service invocation. Not schedule.*/
  245. chThdResumeI(&_ns_thread, SMC_SVC_INTR);
  246. }
  247. r = chThdSuspendS(&svcp->ts_thdp);
  248. chSysUnlock();
  249. return r;
  250. }
  251. /**
  252. * @brief Check that the specified memory space is a subspace of
  253. * the non secure memory space.
  254. *
  255. * @param[in] addr start address of the memory space.
  256. * @param[in] size size of the memory space.
  257. *
  258. * @return TRUE, if the space is valid.
  259. *
  260. * @api
  261. */
  262. bool tsIsAddrSpaceValid(void *addr, size_t size)
  263. {
  264. return isAddrSpaceValid((uint8_t *)addr, size);
  265. }
  266. /**
  267. * @brief Initializes the trusted services and jumps in the NSEC world.
  268. *
  269. * @init
  270. */
  271. CC_NO_RETURN void tssiInit(void)
  272. {
  273. int32_t i;
  274. uint32_t d;
  275. uint32_t *tt;
  276. struct fdt_header *pfdt = (struct fdt_header *)NSEC_MEMORY_START_ADDR;
  277. void *moveto = NULL;
  278. /*
  279. * The main DDR memory, PORT0, is divided in 4 region, each 32MB large.
  280. * The last region is split in two areas, each 16MB large.
  281. * The first 3 region and the lower area of this last region is non secure.
  282. * All the rest of the regions space is secured.
  283. * The same applies to AESB view of the DDR, PORT1, and LCDC view.
  284. *
  285. * Those settings depend on the designed memory mapping.
  286. */
  287. mtxSetSlaveRegionSize(MATRIX0, H64MX_SLAVE_DDR_PORT0, MATRIX_AREA_SIZE_32M, REGION_0_MSK);
  288. mtxSetSlaveRegionSize(MATRIX0, H64MX_SLAVE_DDR_PORT1, MATRIX_AREA_SIZE_32M, REGION_0_MSK);
  289. mtxSetSlaveRegionSize(MATRIX0, H64MX_SLAVE_DDR_PORT2, MATRIX_AREA_SIZE_32M, REGION_0_MSK);
  290. mtxSetSlaveRegionSize(MATRIX0, H64MX_SLAVE_DDR_PORT3, MATRIX_AREA_SIZE_32M, REGION_0_MSK);
  291. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT0, MATRIX_AREA_SIZE_32M,
  292. REGION_0_MSK | REGION_1_MSK | REGION_2_MSK);
  293. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT1, MATRIX_AREA_SIZE_32M,
  294. REGION_0_MSK | REGION_1_MSK | REGION_2_MSK);
  295. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT2, MATRIX_AREA_SIZE_32M,
  296. REGION_0_MSK | REGION_1_MSK | REGION_2_MSK);
  297. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT3, MATRIX_AREA_SIZE_32M,
  298. REGION_0_MSK | REGION_1_MSK | REGION_2_MSK);
  299. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT0, MATRIX_AREA_SIZE_16M, REGION_3_MSK);
  300. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT1, MATRIX_AREA_SIZE_16M, REGION_3_MSK);
  301. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT2, MATRIX_AREA_SIZE_16M, REGION_3_MSK);
  302. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_DDR_PORT3, MATRIX_AREA_SIZE_16M, REGION_3_MSK);
  303. mtxConfigSlaveSec(MATRIX0, H64MX_SLAVE_DDR_PORT0,
  304. mtxRegionLansech(REGION_0, UPPER_AREA_SECURABLE) |
  305. mtxRegionLansech(REGION_1, UPPER_AREA_SECURABLE) |
  306. mtxRegionLansech(REGION_2, UPPER_AREA_SECURABLE) |
  307. mtxRegionLansech(REGION_3, UPPER_AREA_SECURABLE),
  308. mtxRegionRdnsech(REGION_0, NOT_SECURE_READ) |
  309. mtxRegionRdnsech(REGION_1, NOT_SECURE_READ) |
  310. mtxRegionRdnsech(REGION_2, NOT_SECURE_READ),
  311. mtxRegionWrnsech(REGION_0, NOT_SECURE_WRITE) |
  312. mtxRegionWrnsech(REGION_1, NOT_SECURE_WRITE) |
  313. mtxRegionWrnsech(REGION_2, NOT_SECURE_WRITE));
  314. mtxConfigSlaveSec(MATRIX0, H64MX_SLAVE_DDR_PORT1,
  315. mtxRegionLansech(REGION_0, UPPER_AREA_SECURABLE) |
  316. mtxRegionLansech(REGION_1, UPPER_AREA_SECURABLE) |
  317. mtxRegionLansech(REGION_2, UPPER_AREA_SECURABLE) |
  318. mtxRegionLansech(REGION_3, UPPER_AREA_SECURABLE),
  319. mtxRegionRdnsech(REGION_0, NOT_SECURE_READ) |
  320. mtxRegionRdnsech(REGION_1, NOT_SECURE_READ) |
  321. mtxRegionRdnsech(REGION_2, NOT_SECURE_READ),
  322. mtxRegionWrnsech(REGION_0, NOT_SECURE_WRITE) |
  323. mtxRegionWrnsech(REGION_1, NOT_SECURE_WRITE) |
  324. mtxRegionWrnsech(REGION_2, NOT_SECURE_WRITE));
  325. mtxConfigSlaveSec(MATRIX0, H64MX_SLAVE_DDR_PORT2,
  326. mtxRegionLansech(REGION_0, UPPER_AREA_SECURABLE) |
  327. mtxRegionLansech(REGION_1, UPPER_AREA_SECURABLE) |
  328. mtxRegionLansech(REGION_2, UPPER_AREA_SECURABLE) |
  329. mtxRegionLansech(REGION_3, UPPER_AREA_SECURABLE),
  330. mtxRegionRdnsech(REGION_0, NOT_SECURE_READ) |
  331. mtxRegionRdnsech(REGION_1, NOT_SECURE_READ) |
  332. mtxRegionRdnsech(REGION_2, NOT_SECURE_READ),
  333. mtxRegionWrnsech(REGION_0, NOT_SECURE_WRITE) |
  334. mtxRegionWrnsech(REGION_1, NOT_SECURE_WRITE) |
  335. mtxRegionWrnsech(REGION_2, NOT_SECURE_WRITE));
  336. mtxConfigSlaveSec(MATRIX0, H64MX_SLAVE_DDR_PORT3,
  337. mtxRegionLansech(REGION_0, UPPER_AREA_SECURABLE) |
  338. mtxRegionLansech(REGION_1, UPPER_AREA_SECURABLE) |
  339. mtxRegionLansech(REGION_2, UPPER_AREA_SECURABLE) |
  340. mtxRegionLansech(REGION_3, UPPER_AREA_SECURABLE),
  341. mtxRegionRdnsech(REGION_0, NOT_SECURE_READ) |
  342. mtxRegionRdnsech(REGION_1, NOT_SECURE_READ) |
  343. mtxRegionRdnsech(REGION_2, NOT_SECURE_READ),
  344. mtxRegionWrnsech(REGION_0, NOT_SECURE_WRITE) |
  345. mtxRegionWrnsech(REGION_1, NOT_SECURE_WRITE) |
  346. mtxRegionWrnsech(REGION_2, NOT_SECURE_WRITE));
  347. #if !SAMA_USE_SDMMC
  348. /* Configure the SDMMCx regions as non secure.*/
  349. mtxSetSlaveSplitAddr(MATRIX0, H64MX_SLAVE_SDMMC, MATRIX_AREA_SIZE_128M, REGION_1_MSK|REGION_2_MSK);
  350. mtxConfigSlaveSec(MATRIX0, H64MX_SLAVE_SDMMC,
  351. mtxRegionLansech(REGION_1, UPPER_AREA_SECURABLE) |
  352. mtxRegionLansech(REGION_2, UPPER_AREA_SECURABLE),
  353. mtxRegionRdnsech(REGION_1, NOT_SECURE_READ) |
  354. mtxRegionRdnsech(REGION_2, NOT_SECURE_READ),
  355. mtxRegionWrnsech(REGION_1, NOT_SECURE_WRITE) |
  356. mtxRegionWrnsech(REGION_2, NOT_SECURE_WRITE));
  357. #endif
  358. /* Mark the whole non secure memory region non executable
  359. by the secure side, and set the Non-Secure access bit, so that
  360. any access to this region is in the non-secure physical
  361. space. This ensures the coherence of the cache between
  362. secure and non secure accesses.*/
  363. tt = (uint32_t *)(__get_TTBR0() & 0xFFFFC000);
  364. for (d = ((uint32_t)NSEC_MEMORY_START_ADDR >> 20);
  365. d < ((uint32_t)NSEC_MEMORY_END_ADDR >> 20); d += 1) {
  366. MMU_SecureSection(tt + d, NON_SECURE);
  367. MMU_XNSection(tt + d, NON_EXECUTE);
  368. }
  369. /* The same, but for the AESB view of the DDR memory region.*/
  370. for (d = ((uint32_t)(NSEC_MEMORY_START_ADDR + 0x20000000) >> 20);
  371. d < ((uint32_t)(NSEC_MEMORY_END_ADDR + 0x20000000) >> 20); d += 1) {
  372. MMU_SecureSection(tt + d, NON_SECURE);
  373. MMU_XNSection(tt + d, NON_EXECUTE);
  374. }
  375. MMU_InvalidateTLB();
  376. /* Flush the modified MMU table.*/
  377. cacheCleanRegion(tt, d * sizeof (uint32_t));
  378. __DSB();
  379. __ISB();
  380. /* Make sure that prio is NORMALPRIO.*/
  381. chThdSetPriority(NORMALPRIO);
  382. /* Initialize the services.*/
  383. for (i = 0; i < TS_MAX_SVCS; ++i) {
  384. if (TS_CONF_TABLE(i)->arg == NULL)
  385. continue;
  386. /* Check that the initialization of the TS_TABLE against TS_STATE_TABLE
  387. has been set right.*/
  388. if (TS_CONF_TABLE(i)->arg != TS_STATE(i)) {
  389. chSysHalt("Bad TS_STATE setting in the services configuration table.");
  390. }
  391. /* Check that the service priority has been set right.*/
  392. if ((TS_CONF_TABLE(i)->prio <= NORMALPRIO) ||
  393. (TS_CONF_TABLE(i)->prio >= HIGHPRIO)) {
  394. chSysHalt("Bad prio setting in the services configuration table.");
  395. }
  396. /* Create the service thread.*/
  397. chThdCreate(TS_CONF_TABLE(i));
  398. }
  399. /* Fast call services.*/
  400. for (i = 0; TS_FC_CONF_TABLE(i)->name; ++i) {
  401. /* Check that the 'code' field of the
  402. fast call table has been set right.*/
  403. if ((TS_FC_CONF_TABLE(i)->code &~ TS_FASTCALL_MASK) != (uint32_t)i) {
  404. chSysHalt("Bad 'code' setting in the fast call configuration table.");
  405. }
  406. }
  407. ts_fc_configs_n = i;
  408. /* Register to the daemon services events. All flags.*/
  409. chEvtRegister(&tsEventSource, &tsEventListener, EVT_DAEMON_REQ_ATN);
  410. /* Now set the priority at the max.*/
  411. chThdSetPriority(HIGHPRIO);
  412. /* Allow non secure access to CP10 and CP11.*/
  413. asm volatile (
  414. "mrc p15, 0, r0, c1, c1, 2 \n"
  415. "orr r0, r0, #0b11<<10 \n"
  416. "mcr p15, 0, r0, c1, c1, 2 \n"
  417. );
  418. /* Check if a fdt image exists at the start
  419. of the non secure memory region.*/
  420. if (uswap32(pfdt->magic) == FDT_MAGIC) {
  421. uint32_t fdtsize;
  422. /* Detected a fdt structure.
  423. Move it to the end of non secure area.*/
  424. fdtsize = uswap32(pfdt->totalsize);
  425. fdtsize = (fdtsize + 4095) &~ 4095;
  426. moveto = (void *)(SEC_MEMORY_START_ADDR - fdtsize);
  427. memmove(moveto, pfdt, fdtsize);
  428. /* Invalidate the original fdt image.*/
  429. pfdt->magic = 0;
  430. }
  431. /* Jump in the NON SECURE world.
  432. This thread becomes the non secure environment as view by
  433. the secure world.*/
  434. /* r2 address of the moved fdt, if any.*/
  435. asm volatile (
  436. "mov r2, %0 \n" :: "r" (moveto)
  437. );
  438. _ns_trampoline(NSEC_MEMORY_START_ADDR + NSEC_MEMORY_EXE_OFFSET);
  439. /* It never goes here.*/
  440. }
  441. /** @} */