feat(vim): VIM driver implementation and host unit tests #104

Merged
hoogv merged 1 commit from feat/103-vim-driver into dev 2026-07-23 18:26:51 +00:00
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 — its dispatch table references handler symbols from ten other drivers, so it couldn't link (let alone be meaningfully tested) until all of them landed. With EDMA (#101/#102) — the last dependency — merged, every symbol the switch references now exists.

Why

Completes the interrupt-dispatch infrastructure now that every peripheral driver it routes to (GPIO through EDMA) is landed.

Closes #103

Type of Change

  • New feature

Impact Assessment

  • 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.

Testing

  • CI pipeline passes (compile, unit tests, integration tests, static analysis)
  • Manually tested: built and ran both testing/mss/unit/hal_functionality/test_vim_functional (7 test cases, 69 assertions) and test_vim_dispatch (3 test cases, 18 assertions) locally, all passing, alongside the full existing ctest suite (353/353 passing, no regressions); ran a full MISRA C:2025 pass (0 unsuppressed findings — VIM has no ENABLE_VIM_MODULE opt-in guard, it's core infrastructure); reformatted and re-verified against the exact clang-format 18.1.3 the CI runner uses; sanity-checked by changing hal_vim_init()'s REQENACLR mask loop bound from 4 to 3, confirming the test suite fails (1 assertion), then reverting.
  • No regressions observed in related areas

PR Size

  • XL (> 300 lines) — must split unless exemption declared

Size justification / exemption (if L or XL):

847 raw lines across 4 files, all hand-reviewed (no mechanically-generated content). Not split further — the driver (hal_vim.c, 325 lines) and its two Catch2 test targets (test_vim.c/test_vim_dispatch.c, 473 lines combined, covering IRQ_Handler()/FIQ_Handler()'s decode-and-forward logic and the real dispatch switch's per-channel routing — a hard C-linkage constraint requires two separate targets, see the CMake wiring comments) don't decompose into independently-reviewable sub-PRs. The CMake wiring diff is larger than usual for this project since every driver hal_vim.c's switch references by symbol name needs linking into both test targets, even though most of that switch is unreachable in test_vim_functional.

Checklist

  • Commit messages follow type(scope): description convention with Relates to #<issue> footer
  • PR template filled in completely
  • No unverified external binaries introduced (see QMS-GITFLOW-001 Binary Security section)
  • All commits leave the codebase in a compilable, passing-tests state (Commit Integrity Rule)

Summary

  • hal/mss/vim/hal_vim.c: VIM driver (init/reset, priority/enable/disable, IRQ_Handler/FIQ_Handler, default dispatch switch)
  • testing/mss/unit/hal_functionality/test_vim.c (+ CMake): overrides the weak dispatch hooks with a strong recorder to test IRQ_Handler()/FIQ_Handler() in isolation. Named test_vim_functional (not test_vim) to avoid a CMake target-name collision with ti_hal_comparison/test_vim.c.
  • testing/mss/unit/hal_functionality/test_vim_dispatch.c (+ CMake): links the real (non-overridden) dispatch switch to exercise its actual per-channel routing. No naming collision.
## 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 — its dispatch table references handler symbols from ten other drivers, so it couldn't link (let alone be meaningfully tested) until all of them landed. With EDMA (#101/#102) — the last dependency — merged, every symbol the switch references now exists. ## Why Completes the interrupt-dispatch infrastructure now that every peripheral driver it routes to (GPIO through EDMA) is landed. ## Related Issue Closes #103 ## Type of Change - [x] New feature ## Impact Assessment - **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. ## Testing - [x] CI pipeline passes (compile, unit tests, integration tests, static analysis) - [x] Manually tested: built and ran both `testing/mss/unit/hal_functionality/test_vim_functional` (7 test cases, 69 assertions) and `test_vim_dispatch` (3 test cases, 18 assertions) locally, all passing, alongside the full existing `ctest` suite (353/353 passing, no regressions); ran a full MISRA C:2025 pass (0 unsuppressed findings — VIM has no `ENABLE_VIM_MODULE` opt-in guard, it's core infrastructure); reformatted and re-verified against the exact clang-format 18.1.3 the CI runner uses; sanity-checked by changing `hal_vim_init()`'s `REQENACLR` mask loop bound from 4 to 3, confirming the test suite fails (1 assertion), then reverting. - [x] No regressions observed in related areas ## PR Size - [x] XL (> 300 lines) — must split unless exemption declared **Size justification / exemption (if L or XL):** 847 raw lines across 4 files, all hand-reviewed (no mechanically-generated content). Not split further — the driver (`hal_vim.c`, 325 lines) and its two Catch2 test targets (`test_vim.c`/`test_vim_dispatch.c`, 473 lines combined, covering `IRQ_Handler()`/`FIQ_Handler()`'s decode-and-forward logic and the real dispatch switch's per-channel routing — a hard C-linkage constraint requires two separate targets, see the CMake wiring comments) don't decompose into independently-reviewable sub-PRs. The CMake wiring diff is larger than usual for this project since every driver `hal_vim.c`'s switch references by symbol name needs linking into both test targets, even though most of that switch is unreachable in `test_vim_functional`. ## Checklist - [x] Commit messages follow `type(scope): description` convention with `Relates to #<issue>` footer - [x] PR template filled in completely - [x] No unverified external binaries introduced (see QMS-GITFLOW-001 Binary Security section) - [x] All commits leave the codebase in a compilable, passing-tests state (Commit Integrity Rule) ## Summary - `hal/mss/vim/hal_vim.c`: VIM driver (init/reset, priority/enable/disable, `IRQ_Handler`/`FIQ_Handler`, default dispatch switch) - `testing/mss/unit/hal_functionality/test_vim.c` (+ CMake): overrides the weak dispatch hooks with a strong recorder to test `IRQ_Handler()`/`FIQ_Handler()` in isolation. Named `test_vim_functional` (not `test_vim`) to avoid a CMake target-name collision with `ti_hal_comparison/test_vim.c`. - `testing/mss/unit/hal_functionality/test_vim_dispatch.c` (+ CMake): links the real (non-overridden) dispatch switch to exercise its actual per-channel routing. No naming collision.
feat(vim): VIM driver implementation and host unit tests
All checks were successful
lint / clang-format (pull_request) Successful in 10s
tests / host-tests (pull_request) Successful in 46s
lint / misra (pull_request) Successful in 54s
lint / clang-format (push) Successful in 10s
lint / misra (push) Successful in 52s
tests / host-tests (push) Successful in 45s
5c94540e8e
Adds hal/mss/vim/hal_vim.c - completes the header-only stub from the
ESM PR now that every peripheral its dispatch table references
(ESM, GPIO, UART, SPI, I2C, MCAN, DMM, CBUFF, EDMA, Mailbox) is
landed. hal_vim_init()/set_priority()/enable()/disable() plus the
non-weak IRQ_Handler()/FIQ_Handler() decoding VIM_IRQINDEX/FIQINDEX
and forwarding to the weak hal_vim_process_irq()/process_fiq() hooks,
whose default implementations are the fixed per-channel dispatch
switch to each peripheral's raw handler.

Two test targets: test_vim_functional overrides the weak hooks with
a strong recorder to test IRQ_Handler()/FIQ_Handler() in isolation;
test_vim_dispatch links the real (non-overridden) switch to exercise
its actual per-channel routing - a hard C-linkage constraint means
both can't coexist in one target.

Relates to #4, relates to #77, relates to #99, relates to #101, relates to #103
hoogv added this to the Development project 2026-07-23 18:26:44 +00:00
hoogv self-assigned this 2026-07-23 18:26:47 +00:00
Sign in to join this conversation.
No reviewers
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!104
No description provided.