Skip to content

Migrate to dmdrvi 2.0 (64-bit I/O contract) - #1

Merged
JohnAmadis merged 1 commit into
mainfrom
feature/dmdrvi-2.0-migration
Sep 26, 2026
Merged

JohnAmadis merged 1 commit into
mainfrom
feature/dmdrvi-2.0-migration

Conversation

@JaxCalder

Copy link
Copy Markdown
Contributor

Summary

  • Bumps every DIF registration in src/dmfmc.c (_create, _free, _open, _close, _read, _write, _ioctl, _flush, _stat) from dmod_dmdrvi_dif_api_declaration(1.0, ...) to 2.0, matching the coordinated ecosystem-wide cutover in [dmsdio 3/9] Migrate all existing dmdrvi implementations to API 2.0 dmod-ecosystem#8.
  • dmfmc_dmdrvi_read()/dmfmc_dmdrvi_write(): offset changed from uint32_t to dmdrvi_offset_t (signed 64-bit) and the return type changed from size_t to dmdrvi_ssize_t, with explicit -EINVAL (negative offset) and -EOVERFLOW (size > INT64_MAX) guards added. The existing bounds-check against context->result.memory_size_bytes was adapted to compare via dmdrvi_size_t instead of the driver's own uint32_t port-layer size field, so a large 64-bit offset can no longer silently truncate and pass a bounds check it shouldn't.
  • dmfmc_dmdrvi_stat()'s stat->size = context->result.memory_size_bytes assignment is now a safe widening uint32_t -> dmdrvi_size_t; no cast was needed or added.
  • Pre-existing bug fixed: dmfmc_dmdrvi_open() was declared as (dmdrvi_context_t context, int flags), missing the dev_num parameter that both the 1.0 and 2.0 DIF contract require. It was being called through a 3-argument function pointer while only declaring 2 parameters - undefined behavior that predated this cutover, the same class of bug found and fixed in dmclk's earlier 2.0 migration (see Migrate to dmdrvi 2.0 (64-bit I/O contract) dmclk#29). Fixed by adding the dev_num parameter (unused, since dmfmc exposes a single device per context) with a (void)dev_num cast and doc comment, matching the dmclk pattern.
  • Added/updated doc comments (@param/@return) for _open, _read, _write to describe the new signature and types.

Test plan

  • Local build against dmfmc's actual supported target (its CMakeLists.txt/config.cmake hard-code DMOD_TOOLS_NAME=arch/armv7/cortex-m7 for the default DMFMC_MCU_SERIES=stm32f7, matching its CI matrix - dmfmc has no x86_64 port since it drives a real STM32 memory controller): cmake -S . -B /tmp/build_dmfmc_test -DDMOD_MODULE_VERSION=0.0.1 && cmake --build /tmp/build_dmfmc_test --target dmfmc completed with [100%] Built target dmfmc, no new warnings, against a freshly-fetched dmdrvi 2.0 (verified dmod_dmdrvi_dif(2.0, ...) in the fetched dmdrvi.h).
  • A maintainer should validate on real STM32F7/F4 hardware with SDRAM attached, particularly the fixed _open signature (confirm callers now pass dev_num correctly) and the _read/_write bounds-check behavior at large offsets.

Part of choco-technologies/dmod-ecosystem#8.

Bumps every DIF registration to the 2.0 interface version dmdrvi.h now
requires. The functional changes are in _read/_write (offset ->
dmdrvi_offset_t, return type -> dmdrvi_ssize_t, with explicit
-EOVERFLOW/-EINVAL guards) and _stat (size -> dmdrvi_size_t).

Also fixes a pre-existing signature drift: dmfmc_dmdrvi_open() was
missing the dev_num parameter that both the 1.0 and 2.0 contract
require, so it was being called through a 3-argument function pointer
while only declaring 2 - undefined behavior even before this cutover,
the same class of bug found and fixed in dmclk's equivalent migration.

Part of choco-technologies/dmod-ecosystem#8.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 88c35e9 into main Sep 26, 2026
3 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.

2 participants