Commit da5af7e
Add SMP (Symmetric Multi-Processing) support
Implements the core SMP infrastructure from FreeRTOS v11.0.0+, enabling
multi-core support with the `smp` Cargo feature.
Kernel changes (src/kernel/tasks.rs):
- TCB extended with SMP fields: xTaskRunState, uxCoreAffinityMask, uxTaskAttributes
- Global pxCurrentTCB replaced with pxCurrentTCBs[configNUMBER_OF_CORES] array
- Added accessor functions: prvGetCurrentTaskTCB(), prvSetCurrentTaskTCB(),
prvGetCurrentTaskTCBForCore(), prvSetCurrentTaskTCBForCore()
- Updated 20+ functions to use accessors instead of direct pxCurrentTCB access
- Added tskNO_AFFINITY constant for core-affinity feature
Port layer (src/port/):
- mod.rs: Added SMP port function stubs (portGET_CORE_ID, portYIELD_CORE,
portGET_TASK_LOCK, portRELEASE_TASK_LOCK, etc.)
- cortex_a9.rs: Added SMP-aware assembly that reads MPIDR register for core ID
and indexes into pxCurrentTCBs array during context save/restore
Configuration:
- Cargo.toml: Added `smp` and `core-affinity` feature flags
- config.rs: Added conditional configNUMBER_OF_CORES (1 for non-SMP, 2 for SMP)
- config.rs: Added configUSE_CORE_AFFINITY conditional
Demo (demo/cortex-a9/):
- Added `smp` feature flag
- Added get_core_id() and println_core() for core ID tracking
- Secondary cores wait for scheduler start in SMP mode
- Tasks print their executing core ID
Tested on QEMU vexpress-a9 with -smp 2:
- Both cores recognized (Core 1 waits, Core 0 initializes)
- Tasks execute correctly with SMP data structures
- Non-SMP builds unaffected (no overhead)
Future work for full multi-core execution:
- Secondary core wake-up via SEV/IPI after scheduler starts
- Multiple idle tasks (one per core)
- portYIELD_CORE() implementation using GIC SGI
- Per-core spinlocks (currently uses global critical sections)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 967cef7 commit da5af7e
File tree
8 files changed
+1028
-47
lines changed- demo/cortex-a9
- src
- src
- kernel
- port
8 files changed
+1028
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | | - | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
146 | 167 | | |
147 | 168 | | |
148 | 169 | | |
| |||
283 | 304 | | |
284 | 305 | | |
285 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
286 | 325 | | |
287 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
288 | 330 | | |
289 | 331 | | |
290 | 332 | | |
| |||
444 | 486 | | |
445 | 487 | | |
446 | 488 | | |
447 | | - | |
| 489 | + | |
448 | 490 | | |
449 | 491 | | |
450 | 492 | | |
| |||
453 | 495 | | |
454 | 496 | | |
455 | 497 | | |
456 | | - | |
| 498 | + | |
457 | 499 | | |
458 | 500 | | |
459 | 501 | | |
460 | | - | |
| 502 | + | |
461 | 503 | | |
462 | 504 | | |
463 | | - | |
| 505 | + | |
464 | 506 | | |
465 | 507 | | |
466 | 508 | | |
467 | 509 | | |
468 | 510 | | |
469 | 511 | | |
470 | | - | |
| 512 | + | |
471 | 513 | | |
472 | 514 | | |
473 | 515 | | |
| |||
480 | 522 | | |
481 | 523 | | |
482 | 524 | | |
483 | | - | |
| 525 | + | |
484 | 526 | | |
485 | 527 | | |
486 | 528 | | |
| |||
489 | 531 | | |
490 | 532 | | |
491 | 533 | | |
492 | | - | |
| 534 | + | |
493 | 535 | | |
494 | 536 | | |
495 | 537 | | |
496 | | - | |
| 538 | + | |
497 | 539 | | |
498 | 540 | | |
499 | 541 | | |
500 | | - | |
| 542 | + | |
501 | 543 | | |
502 | 544 | | |
503 | 545 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
| |||
289 | 293 | | |
290 | 294 | | |
291 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
292 | 300 | | |
293 | 301 | | |
294 | 302 | | |
| |||
0 commit comments