@@ -41,6 +41,8 @@ GDATA(_kernel)
41
41
* already been taken. In other words , when z_arm_pendsv() runs , we * know * we
42
42
* have to swap * something * .
43
43
*
44
+ * For Cortex - M , z_arm_pendsv() is invoked with no arguments.
45
+ *
44
46
* For Cortex - R , PendSV exception is not supported by the architecture and this
45
47
* function is directly called either by _IntExit in case of preemption , or
46
48
* z_arm_svc in case of cooperative switching.
@@ -163,7 +165,9 @@ out_fp_endif:
163
165
str v3 , [ v4 , # 0 ]
164
166
#endif
165
167
166
- / * Restore previous interrupt disable state (irq_lock key) * /
168
+ / * Restore previous interrupt disable state (irq_lock key)
169
+ * (We clear the arch.basepri field after restoring state)
170
+ * /
167
171
#if (defined(CONFIG_CPU_CORTEX_M0PLUS) || defined(CONFIG_CPU_CORTEX_M0)) && \
168
172
_thread_offset_to_basepri > 124
169
173
/ * Doing it this way since the offset to thread - >arch.basepri can in
@@ -410,13 +414,21 @@ _oops:
410
414
* @return N/A
411
415
* /
412
416
SECTION_FUNC(TEXT , z_arm_svc)
417
+ / * Use EXC_RETURN state to find out if stack frame is on the
418
+ * MSP or PSP
419
+ * /
413
420
tst lr , # 0x4 / * did we come from thread mode ? * /
414
421
ite eq / * if zero (equal) , came from handler mode * /
415
422
mrseq r0 , MSP / * handler mode , stack frame is on MSP * /
416
423
mrsne r0 , PSP / * thread mode , stack frame is on PSP * /
417
424
425
+
426
+ / * Figure out wh at SVC call number was invoked * /
427
+
418
428
ldr r1 , [ r0 , # 24 ] / * grab address of PC from stack frame * /
419
- / * SVC is a two - byte instruction , point to it and read encoding * /
429
+ / * SVC is a two - byte instruction , point to it and read the
430
+ * SVC number (lower byte of SCV instruction)
431
+ * /
420
432
ldrh r1 , [ r1 , # - 2 ]
421
433
422
434
/ *
@@ -425,8 +437,6 @@ SECTION_FUNC(TEXT, z_arm_svc)
425
437
* 1 : irq_offload (if configured)
426
438
* 2 : kernel panic or oops (software generated fatal exception)
427
439
* 3 : System call (if user mode supported)
428
- * Planned implementation of system calls for memory protection will
429
- * expand this case.
430
440
* /
431
441
ands r1 , # 0xff
432
442
#if defined(CONFIG_USERSPACE)
@@ -442,7 +452,7 @@ SECTION_FUNC(TEXT, z_arm_svc)
442
452
tst r2 , # 0x1
443
453
bne _oops
444
454
445
- #endif
455
+ #endif / * CONFIG_USERSPACE * /
446
456
447
457
cmp r1 , # 2
448
458
beq _oops
0 commit comments