Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[silicon_creator] Consider refactoring the FLASH_CTRL_MP_REGIONS X-macro in flash_ctrl #24514

Open
cfrantz opened this issue Sep 4, 2024 · 0 comments
Labels
SW:ROM_EXT ROM_EXT related issues SW:ROM ROM related issues Type:Cleanup Cleanup tasks

Comments

@cfrantz
Copy link
Contributor

cfrantz commented Sep 4, 2024

Description

Consider refactoring the uses of the FLASH_CTRL_MP_REGIONS X-macros in the flash_ctrl driver.

Currently, these X-macros expand to a switch/case statement to cover adjusting the various properties of the flash memory protection region registers. The expansion use macro-pasting to generate the register index and field names (like FLASH_CTRL_MP_REGION_##arg##_REG_RESVAL. These values can probably be calculated from base register and an index rather than register pasting.

Each case of the switch-case includes a HARDENED_CHECK; it is probably sufficient to use hardened checks to ensure the index is in range before performing the index register calculation.

  1. Examine the generated code for the flash_ctrl_mp_region functions with the current X-macro expansions.
  2. Change the code to calculate the register offsets from the index. Examine the generated code from that method.
  3. If the savings is significant, the code is cleaner and the hardening properties are maintained, use the index calculation method in favor of the X-macro method.
@cfrantz cfrantz added Type:Cleanup Cleanup tasks SW:ROM ROM related issues SW:ROM_EXT ROM_EXT related issues labels Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SW:ROM_EXT ROM_EXT related issues SW:ROM ROM related issues Type:Cleanup Cleanup tasks
Projects
None yet
Development

No branches or pull requests

1 participant