Skip to content

Add weak interrupt handler prototypes for RTOS-essential ISRs#20

Merged
JohnAmadis merged 3 commits intomainfrom
copilot/add-weak-prototypes-for-interrupts
Feb 22, 2026
Merged

Add weak interrupt handler prototypes for RTOS-essential ISRs#20
JohnAmadis merged 3 commits intomainfrom
copilot/add-weak-prototypes-for-interrupts

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 22, 2026

RTOS implementations require specific interrupt handlers (context switch, supervisor call, system tick) that are named differently across architectures and RTOS vendors. This adds architecture-independent, dmosi-standardized weak (no-op) prototypes so RTOS ports can override them with strong implementations without needing to know the underlying naming conventions.

Changes

  • include/dmosi.h — New Interrupt Handler API section with DMOD_BUILTIN_API declarations using architecture-independent names:

    • dmosi_context_switch_handler() — RTOS context switching (ARM Cortex-M: PendSV_Handler; RISC-V: software interrupt ISR)
    • dmosi_syscall_handler() — RTOS system/supervisor call (ARM Cortex-M: SVC_Handler; RISC-V: ecall / machine-mode trap handler)
    • dmosi_tick_handler() — RTOS periodic time tick (ARM Cortex-M: SysTick_Handler; RISC-V: machine timer interrupt handler)
  • src/dmosi.c — Empty weak implementations via DMOD_INPUT_WEAK_API_DECLARATION, consistent with all other APIs in the file.

  • README.md — Documents the new API as section 7 with a cross-architecture mapping table.

Usage

An RTOS port overrides the relevant handlers as strong symbols:

// In your dmosi-freertos port for ARM Cortex-M, e.g. dmosi_freertos.c
void dmosi_context_switch_handler(void) { xPortPendSVHandler();  }
void dmosi_syscall_handler(void)        { vPortSVCHandler();     }
void dmosi_tick_handler(void)           { xPortSysTickHandler(); }
// In your dmosi-freertos port for RISC-V
void dmosi_context_switch_handler(void) { vPortSoftwareInterruptHandler(); }
void dmosi_syscall_handler(void)        { vPortEcallHandler();             }
void dmosi_tick_handler(void)           { vPortMachineTimerInterruptHandler(); }

The startup/vector table then aliases the architecture-specific ISR names to the dmosi names, keeping all RTOS integration behind the dmosi interface regardless of the target architecture.

Original prompt

This section details on the original issue you should resolve

<issue_title>dodać weak prototypy do przerwan</issue_title>
<issue_description>Są takie przerwania, które są niezbędne do funkcjonowania RTOS. Np dla ARM: PendSV, SVC i SysTick. Nazywają się one jednak różnie w zależności od wybranej architektury i wybranego RTOS. Celem tego zadania jest stworzenie prototypów typu weak dla takich niezbędnych funkcji aby ustandaryzować to nazewnictwem dmosi. </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…c, systick)

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add weak prototypes for essential interrupts Add weak interrupt handler prototypes for RTOS-essential ISRs Feb 22, 2026
Copilot AI requested a review from JohnAmadis February 22, 2026 17:40
Copy link
Copy Markdown
Contributor

@JohnAmadis JohnAmadis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include/dmosi.h Outdated
* Override this weak implementation with the RTOS-specific context-switch
* handler.
*/
DMOD_BUILTIN_API( dmosi, 1.0, void, _pendsv_handler, (void) );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Przecież pisalem o uniwersalnych nazwach niezależnych od architektury. To co - na riscv tak samo to nazwiesz? Postaraj się bardziej, tak to każdy głupi potrafi zrobić

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to architecture-independent functional names (cc2170f):

  • dmosi_context_switch_handler — context switch (ARM: PendSV_Handler, RISC-V: software interrupt)
  • dmosi_syscall_handler — system/supervisor call (ARM: SVC_Handler, RISC-V: ecall / machine-mode trap)
  • dmosi_tick_handler — RTOS time tick (ARM: SysTick_Handler, RISC-V: machine timer interrupt)

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
@JohnAmadis JohnAmadis marked this pull request as ready for review February 22, 2026 17:54
@JohnAmadis JohnAmadis merged commit e6d025e into main Feb 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dodać weak prototypy do przerwan

2 participants