Repository navigation
Migrate to dmdrvi 2.0 (64-bit I/O contract) - #1
Merged
Merged
Conversation
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
approved these changes
Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/dmfmc.c(_create,_free,_open,_close,_read,_write,_ioctl,_flush,_stat) fromdmod_dmdrvi_dif_api_declaration(1.0, ...)to2.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():offsetchanged fromuint32_ttodmdrvi_offset_t(signed 64-bit) and the return type changed fromsize_ttodmdrvi_ssize_t, with explicit-EINVAL(negative offset) and-EOVERFLOW(size > INT64_MAX) guards added. The existing bounds-check againstcontext->result.memory_size_byteswas adapted to compare viadmdrvi_size_tinstead of the driver's ownuint32_tport-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()'sstat->size = context->result.memory_size_bytesassignment is now a safe wideninguint32_t->dmdrvi_size_t; no cast was needed or added.dmfmc_dmdrvi_open()was declared as(dmdrvi_context_t context, int flags), missing thedev_numparameter 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 thedev_numparameter (unused, since dmfmc exposes a single device per context) with a(void)dev_numcast and doc comment, matching the dmclk pattern.@param/@return) for_open,_read,_writeto describe the new signature and types.Test plan
CMakeLists.txt/config.cmakehard-codeDMOD_TOOLS_NAME=arch/armv7/cortex-m7for the defaultDMFMC_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 dmfmccompleted with[100%] Built target dmfmc, no new warnings, against a freshly-fetched dmdrvi 2.0 (verifieddmod_dmdrvi_dif(2.0, ...)in the fetcheddmdrvi.h)._opensignature (confirm callers now passdev_numcorrectly) and the_read/_writebounds-check behavior at large offsets.Part of choco-technologies/dmod-ecosystem#8.