This repository was archived by the owner on Jun 7, 2023. It is now read-only.
Commit db5aa93
feat: use vectoring to jump straight to interruptN (#11)
* feat: use vectoring to jump straight to interruptN
Previously, the vector table was set up in a pseudo-direct mode where
all interrupts were redirected to a single `_start_trap` handler
regardless of number.
This change introduces 31 new `_start_trapN` targets that encode which
`interruptN` function to jump to, at a cost of 180 bytes per function
(~5kb total).
Not shown (because the linker scripts live in the HAL) are the big block
of `PROVIDES`:
```ld
PROVIDE(_start_trap1 = default_start_trap1)
PROVIDE(_start_trap2 = default_start_trap2)
...
PROVIDE(_start_trap31 = default_start_trap31)
```
As a side benefit, this does enable overriding on a per-irq basis and
could even allow someone to switch back to the current psuedo-direct
mode if they so chose (though, I think they wouldn't see anything get
GC'd yet).
Potential improvements include:
* Shrinking the saved register set to just being the callee-save parts
of the C ABI, since only `default_start_trap` really has a use for the
full frame
* Finer-grained control around which interrupts are vectored, and which
are semi-direct: maybe we can get away with just three modes at the
start (all direct, only 1-16 vectored, all vectored), but I'm curious
if we could find a way to precisely express in a downstream crate "I
want precisely 1, 2, 4..." to be vectored. Maybe a proc macro or other
generator script?
* fix(ci): use nightly clippy
Required if we want to use `#![feature(...)]`s, else clippy complains:
```
error[E0554]: `#![feature]` may not be used on the stable release channel
--> src/lib.rs:18:1
|
18 | #![feature(naked_functions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0554`.
error: could not compile `esp-riscv-rt` due to previous error
Error: Process completed with exit code 101.
```
* Revert "feat: use vectoring to jump straight to interruptN"
This reverts commit 9b77193.
* feat: allow vectoring per-slot overrides
Previously, the vector table was set up in a pseudo-direct mode where
all interrupts were redirected to a single `_start_trap` handler
regardless of number.
This change introduces 31 new `_start_trapN` targets that, by default,
retain the pseudo-direct behavior. However, they're weak symbols, so
they allow for individually overriding entries in the _vector_table, as
well as overriding the entire _vector_table itself.
This is in contrast with the earlier attempt in 9b77193 that jumped
straight to the corresponding `extern "C" interruptN`; instead, this
defers that work to the HAL and other downstream crates.
* fix: restore per-slot handlers
Unless any of the `.weak` symbols are overridden, this produces the
exact same assembly as before. But it permits overriding handlers on a
slot-by-slot basis by overriding those `.weak` symbols individually.
Co-Authored-By: onsdagens <[email protected]>
Co-Authored-By: sethp <[email protected]>
---------
Co-authored-by: onsdagens <[email protected]>1 parent 9281af2 commit db5aa93
2 files changed
+102
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | | - | |
432 | | - | |
| 431 | + | |
| 432 | + | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
436 | | - | |
437 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
438 | 501 | | |
439 | 502 | | |
440 | 503 | | |
| |||
534 | 597 | | |
535 | 598 | | |
536 | 599 | | |
537 | | - | |
| 600 | + | |
538 | 601 | | |
539 | 602 | | |
540 | 603 | | |
| |||
544 | 607 | | |
545 | 608 | | |
546 | 609 | | |
547 | | - | |
548 | | - | |
549 | | - | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
550 | 641 | | |
551 | 642 | | |
552 | 643 | | |
| |||
0 commit comments