Skip to content

Commit 1ed15f8

Browse files
author
Deepika
committed
Updating trustzone functions for IAR
1 parent 508037e commit 1ed15f8

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

platform/mbed_tz_context.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ uint32_t TZ_InitContextSystem_S (void)
6464
ProcessStackFreeSlot = 0U;
6565

6666
// Default process stack pointer and stack limit
67+
#if defined(__ICCARM__)
68+
asm volatile("MSR PSPLIM, %0" :: "r" ((uint32_t)ProcessStackMemory));
69+
asm volatile("MSR PSP, %0" :: "r" ((uint32_t)ProcessStackMemory));
70+
#else
6771
__set_PSPLIM ((uint32_t)ProcessStackMemory);
6872
__set_PSP ((uint32_t)ProcessStackMemory);
73+
#endif
6974

7075
// Privileged Thread Mode using PSP
7176
__set_CONTROL(0x02U);
@@ -154,8 +159,13 @@ uint32_t TZ_LoadContext_S (TZ_MemoryId_t id)
154159
}
155160

156161
// Setup process stack pointer and stack limit
162+
#if defined(__ICCARM__)
163+
asm volatile("MSR PSPLIM, %0" :: "r" ((uint32_t)ProcessStackInfo[slot].sp_limit));
164+
asm volatile("MSR PSP, %0" :: "r" ((uint32_t)ProcessStackInfo[slot].sp));
165+
#else
157166
__set_PSPLIM(ProcessStackInfo[slot].sp_limit);
158167
__set_PSP (ProcessStackInfo[slot].sp);
168+
#endif
159169

160170
return 1U; // Success
161171
}
@@ -192,8 +202,13 @@ uint32_t TZ_StoreContext_S (TZ_MemoryId_t id)
192202
ProcessStackInfo[slot].sp = sp;
193203

194204
// Default process stack pointer and stack limit
195-
__set_PSPLIM((uint32_t)ProcessStackMemory);
196-
__set_PSP ((uint32_t)ProcessStackMemory);
205+
#if defined(__ICCARM__)
206+
asm volatile("MSR PSPLIM, %0" :: "r" ((uint32_t)ProcessStackMemory));
207+
asm volatile("MSR PSP, %0" :: "r" ((uint32_t)ProcessStackMemory));
208+
#else
209+
__set_PSPLIM ((uint32_t)ProcessStackMemory);
210+
__set_PSP ((uint32_t)ProcessStackMemory);
211+
#endif
197212

198213
return 1U; // Success
199214
}

0 commit comments

Comments
 (0)