Repository navigation
[reg, test] Use 32-bit register accesses on all targets - #62
Open
night1rider wants to merge 3 commits into
Open
night1rider wants to merge 3 commits into
night1rider wants to merge 3 commits into
Conversation
This was referenced Nov 5, 2026
night1rider
force-pushed
the
reg-32bit
branch
2 times, most recently
from
November 5, 2026 17:57
95ffd84 to
0f6bdaf
Compare
The whal_Reg_* helpers read and wrote through size_t, which is 64 bits on AArch64, so a write also changed the next register. They now always access one 32-bit register, as the header already said. Value and mask bits above bit 31 are dropped; reg.h and the driver guide say so. Adds core reg tests that check each helper touches only its own register and drops bits above bit 31, that an update clears field bits, and that a poll ignores bits outside the mask, retries until the field matches, waits for bits to clear, and times out. Builds src/reg.c in the core tests.
…opt-in whal_Reg32_* and whal_Reg64_* take a uintptr_t base, a uint32_t offset and values of the register's width, so the access width is explicit and no value is cast. whal_Reg64_* exists only where a 64-bit access is one access (WHAL_HAVE_REG64). The size_t whal_Reg_* API is now only built with WHAL_CFG_REG_LEGACY. It does 32-bit accesses through whal_Reg32_*. Where size_t is 64 bits, a value or mask above bit 31 returns WHAL_EINVAL and nothing is written; Write, Update and Get now return whal_Error. Where size_t is 32 bits there is no check, and the code is the same as before. The boards in boards/ define WHAL_CFG_REG_LEGACY, so the existing drivers build unchanged. Core tests cover Reg32, Reg64 and the legacy API, including the range checks, and check that whal_Reg_* is not defined without WHAL_CFG_REG_LEGACY. The driver and test guides use whal_Reg32_*.
night1rider
force-pushed
the
reg-32bit
branch
from
November 5, 2026 21:16
0f6bdaf to
065c98f
Compare
AlexLanzano
reviewed
Nov 6, 2026
| OBJCOPY = $(GCC_PATH)arm-none-eabi-objcopy | ||
|
|
||
| # Drivers here use the legacy whal_Reg_* API | ||
| CFLAGS += -DWHAL_CFG_REG_LEGACY |
Member
There was a problem hiding this comment.
Since wolfHAL is relatively new I'm not super concerned with retaining the legacy size_t interface. I think we should just rip the band-aid off now while we can and only provide the whal_Reg32/64 interface
Per review, keep only whal_Reg32_* and whal_Reg64_*. All drivers, board files and tests now call whal_Reg32_*. Device base fields and base locals are uintptr_t. Variables read with whal_Reg32_Get are uint32_t.
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.
The whal_Reg_* helpers read and wrote through size_t, which is 64 bits on AArch64, so a write also changed the next register. They now always access one 32-bit register, as the header already said.
Adds core reg tests that check a write leaves the next register alone, and builds src/reg.c in the core tests.