feat: VIM driver implementation and host unit tests #103

Closed
opened 2026-07-23 18:20:49 +00:00 by hoogv · 0 comments
Owner

Description

Adds hal/mss/vim/hal_vim.c — the VIM (Vectored Interrupt Manager) driver implementation, completing the header-only stub landed with ESM (#77/#78). hal_vim_init() resets the VIM and masks every channel; hal_vim_set_priority()/hal_vim_enable()/hal_vim_disable() configure per-channel IRQ/FIQ routing and arm/mask individual channels; the non-weak IRQ_Handler()/FIQ_Handler() decode VIM_IRQINDEX/VIM_FIQINDEX and forward to the weak hal_vim_process_irq()/hal_vim_process_fiq() hooks, whose default implementations are a fixed per-channel dispatch switch routing to every landed peripheral's own named raw device handler (ESM, GPIO, UART, SPI, I2C, MCAN/MCANB, DMM1/DMM2, CBUFF, EDMA_TPCC0/TPTC0/TPTC1, Mailbox).

This driver was deliberately deferred until now — its dispatch table references handler symbols from ESM, GPIO, UART, SPI, I2C, DMM, MCAN, CBUFF, Mailbox, and EDMA, so it couldn't link (let alone be meaningfully tested) until all ten of those drivers landed. With EDMA (#101/#102) — the last dependency — merged, every symbol the switch references now exists.

Use Case / Rationale

As a firmware developer, I need the VIM configured and its dispatch table wired to every peripheral driver's raw handler, so a real interrupt from any landed peripheral actually reaches its handler through the CPU's two exception lines.

As a QMS reviewer, I need two separate host-native Catch2 test targets: one overriding the weak dispatch hooks with a strong recorder to test IRQ_Handler()/FIQ_Handler()'s decode-and-forward logic in isolation, and one linking the real (non-overridden) dispatch switch to exercise its actual per-channel routing — a hard C-linkage constraint (a strong override wins the link for its whole binary) makes both concerns impossible to test in a single target.

Acceptance Criteria

  • hal/mss/vim/hal_vim.c implemented against this project's current hal/registers/component/vim.h/instance/vim.h
  • testing/mss/unit/hal_functionality/test_vim.c (IRQ_Handler/FIQ_Handler decode, via a strong hook override) passes under ctest
  • testing/mss/unit/hal_functionality/test_vim_dispatch.c (the real dispatch switch, no override) passes under ctest
  • Sanity-checked by deliberately breaking a register field/formula and confirming the test suite catches it, then reverting

Functional Impact

None — self-contained addition; completes VIM's header-only stub from #78 now that every peripheral its dispatch table references is landed.

Regulatory Impact

None

QMS Impact

None

Risk Impact

No — existing risk coverage sufficient.

Relates to #4, relates to #77, relates to #99, relates to #101

### Description Adds `hal/mss/vim/hal_vim.c` — the VIM (Vectored Interrupt Manager) driver implementation, completing the header-only stub landed with ESM (#77/#78). `hal_vim_init()` resets the VIM and masks every channel; `hal_vim_set_priority()`/`hal_vim_enable()`/`hal_vim_disable()` configure per-channel IRQ/FIQ routing and arm/mask individual channels; the non-weak `IRQ_Handler()`/`FIQ_Handler()` decode `VIM_IRQINDEX`/`VIM_FIQINDEX` and forward to the weak `hal_vim_process_irq()`/`hal_vim_process_fiq()` hooks, whose default implementations are a fixed per-channel dispatch `switch` routing to every landed peripheral's own named raw device handler (ESM, GPIO, UART, SPI, I2C, MCAN/MCANB, DMM1/DMM2, CBUFF, EDMA_TPCC0/TPTC0/TPTC1, Mailbox). This driver was deliberately deferred until now — its dispatch table references handler symbols from ESM, GPIO, UART, SPI, I2C, DMM, MCAN, CBUFF, Mailbox, and EDMA, so it couldn't link (let alone be meaningfully tested) until all ten of those drivers landed. With EDMA (#101/#102) — the last dependency — merged, every symbol the switch references now exists. ### Use Case / Rationale As a firmware developer, I need the VIM configured and its dispatch table wired to every peripheral driver's raw handler, so a real interrupt from any landed peripheral actually reaches its handler through the CPU's two exception lines. As a QMS reviewer, I need two separate host-native Catch2 test targets: one overriding the weak dispatch hooks with a strong recorder to test `IRQ_Handler()`/`FIQ_Handler()`'s decode-and-forward logic in isolation, and one linking the real (non-overridden) dispatch switch to exercise its actual per-channel routing — a hard C-linkage constraint (a strong override wins the link for its whole binary) makes both concerns impossible to test in a single target. ### Acceptance Criteria - [ ] `hal/mss/vim/hal_vim.c` implemented against this project's current `hal/registers/component/vim.h`/`instance/vim.h` - [ ] `testing/mss/unit/hal_functionality/test_vim.c` (IRQ_Handler/FIQ_Handler decode, via a strong hook override) passes under `ctest` - [ ] `testing/mss/unit/hal_functionality/test_vim_dispatch.c` (the real dispatch switch, no override) passes under `ctest` - [ ] Sanity-checked by deliberately breaking a register field/formula and confirming the test suite catches it, then reverting ### Functional Impact None — self-contained addition; completes VIM's header-only stub from #78 now that every peripheral its dispatch table references is landed. ### Regulatory Impact None ### QMS Impact None ### Risk Impact No — existing risk coverage sufficient. ### Related Issues / PRs Relates to #4, relates to #77, relates to #99, relates to #101
hoogv closed this issue 2026-07-23 18:26:51 +00:00
hoogv self-assigned this 2026-07-23 19:10:01 +00:00
hoogv added this to the Development project 2026-07-23 19:10:04 +00:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
opendutchsolutions.public/hal_awr6843#103
No description provided.