100
100
" ldr r1, [r0] \n" /* r1 = Location of saved context in TCB. */
101
101
" \n"
102
102
" restore_special_regs_first_task: \n"
103
+ #if ( configENABLE_PAC == 1 )
104
+ " ldmdb r1!, {r2-r5} \n" /* Read task's dedicated PAC key from the task's context. */
105
+ " msr PAC_KEY_P_0, r2 \n" /* Write the task's dedicated PAC key to the PAC key registers. */
106
+ " msr PAC_KEY_P_1, r3 \n"
107
+ " msr PAC_KEY_P_2, r4 \n"
108
+ " msr PAC_KEY_P_3, r5 \n"
109
+ " clrm {r2-r5} \n" /* Clear r2-r5. */
110
+ #endif /* configENABLE_PAC */
103
111
" ldmdb r1!, {r2-r4, lr} \n" /* r2 = original PSP, r3 = PSPLIM, r4 = CONTROL, LR restored. */
104
112
" msr psp, r2 \n"
105
113
" msr psplim, r3 \n"
130
138
" ldr r1, [r2] \n" /* Read pxCurrentTCB. */
131
139
" ldr r0, [r1] \n" /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */
132
140
" \n"
141
+ #if ( configENABLE_PAC == 1 )
142
+ " ldmia r0!, {r1-r4} \n" /* Read task's dedicated PAC key from stack. */
143
+ " msr PAC_KEY_P_3, r1 \n" /* Write the task's dedicated PAC key to the PAC key registers. */
144
+ " msr PAC_KEY_P_2, r2 \n"
145
+ " msr PAC_KEY_P_1, r3 \n"
146
+ " msr PAC_KEY_P_0, r4 \n"
147
+ " clrm {r1-r4} \n" /* Clear r1-r4. */
148
+ #endif /* configENABLE_PAC */
149
+ " \n"
133
150
" ldm r0!, {r1-r2} \n" /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */
134
151
" msr psplim, r1 \n" /* Set this task's PSPLIM value. */
135
152
" mrs r1, control \n" /* Obtain current control register value. */
@@ -270,7 +287,6 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
270
287
" vstmiaeq r1!, {s0-s16} \n" /* Store hardware saved FP context. */
271
288
" sub r2, r2, #0x20 \n" /* Set r2 back to the location of hardware saved context. */
272
289
#endif /* configENABLE_FPU || configENABLE_MVE */
273
- " \n"
274
290
" stmia r1!, {r4-r11} \n" /* Store r4-r11. */
275
291
" ldmia r2, {r4-r11} \n" /* Copy the hardware saved context into r4-r11. */
276
292
" stmia r1!, {r4-r11} \n" /* Store the hardware saved context. */
@@ -279,6 +295,14 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
279
295
" mrs r3, psplim \n" /* r3 = PSPLIM. */
280
296
" mrs r4, control \n" /* r4 = CONTROL. */
281
297
" stmia r1!, {r2-r4, lr} \n" /* Store original PSP (after hardware has saved context), PSPLIM, CONTROL and LR. */
298
+ #if ( configENABLE_PAC == 1 )
299
+ " mrs r2, PAC_KEY_P_0 \n" /* Read task's dedicated PAC key from the PAC key registers. */
300
+ " mrs r3, PAC_KEY_P_1 \n"
301
+ " mrs r4, PAC_KEY_P_2 \n"
302
+ " mrs r5, PAC_KEY_P_3 \n"
303
+ " stmia r1!, {r2-r5} \n" /* Store the task's dedicated PAC key on the task's context. */
304
+ " clrm {r2-r5} \n" /* Clear r2-r5. */
305
+ #endif /* configENABLE_PAC */
282
306
" str r1, [r0] \n" /* Save the location from where the context should be restored as the first member of TCB. */
283
307
" \n"
284
308
" select_next_task: \n"
@@ -337,6 +361,14 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
337
361
" ldr r1, [r0] \n" /* r1 = Location of saved context in TCB. */
338
362
" \n"
339
363
" restore_special_regs: \n"
364
+ #if ( configENABLE_PAC == 1 )
365
+ " ldmdb r1!, {r2-r5} \n" /* Read task's dedicated PAC key from the task's context. */
366
+ " msr PAC_KEY_P_0, r2 \n" /* Write the task's dedicated PAC key to the PAC key registers. */
367
+ " msr PAC_KEY_P_1, r3 \n"
368
+ " msr PAC_KEY_P_2, r4 \n"
369
+ " msr PAC_KEY_P_3, r5 \n"
370
+ " clrm {r2-r5} \n" /* Clear r2-r5. */
371
+ #endif /* configENABLE_PAC */
340
372
" ldmdb r1!, {r2-r4, lr} \n" /* r2 = original PSP, r3 = PSPLIM, r4 = CONTROL, LR restored. */
341
373
" msr psp, r2 \n"
342
374
" msr psplim, r3 \n"
@@ -381,6 +413,15 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
381
413
" mov r3, lr \n" /* r3 = LR/EXC_RETURN. */
382
414
" stmdb r0!, {r2-r11} \n" /* Store on the stack - PSPLIM, LR and registers that are not automatically saved. */
383
415
" \n"
416
+ #if ( configENABLE_PAC == 1 )
417
+ " mrs r1, PAC_KEY_P_3 \n" /* Read task's dedicated PAC key from the PAC key registers. */
418
+ " mrs r2, PAC_KEY_P_2 \n"
419
+ " mrs r3, PAC_KEY_P_1 \n"
420
+ " mrs r4, PAC_KEY_P_0 \n"
421
+ " stmdb r0!, {r1-r4} \n" /* Store the task's dedicated PAC key on the stack. */
422
+ " clrm {r1-r4} \n" /* Clear r1-r4. */
423
+ #endif /* configENABLE_PAC */
424
+ " \n"
384
425
" ldr r2, =pxCurrentTCB \n" /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
385
426
" ldr r1, [r2] \n" /* Read pxCurrentTCB. */
386
427
" str r0, [r1] \n" /* Save the new top of stack in TCB. */
@@ -397,6 +438,15 @@ void vClearInterruptMask( __attribute__( ( unused ) ) uint32_t ulMask ) /* __att
397
438
" ldr r1, [r2] \n" /* Read pxCurrentTCB. */
398
439
" ldr r0, [r1] \n" /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */
399
440
" \n"
441
+ #if ( configENABLE_PAC == 1 )
442
+ " ldmia r0!, {r2-r5} \n" /* Read task's dedicated PAC key from stack. */
443
+ " msr PAC_KEY_P_3, r2 \n" /* Write the task's dedicated PAC key to the PAC key registers. */
444
+ " msr PAC_KEY_P_2, r3 \n"
445
+ " msr PAC_KEY_P_1, r4 \n"
446
+ " msr PAC_KEY_P_0, r5 \n"
447
+ " clrm {r2-r5} \n" /* Clear r2-r5. */
448
+ #endif /* configENABLE_PAC */
449
+ " \n"
400
450
" ldmia r0!, {r2-r11} \n" /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r11 restored. */
401
451
" \n"
402
452
#if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
0 commit comments