extmod/modplatform: Expose CPU features/extensions. #15268
+33
−0
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.
This PR adds the ability to expose CPU-specific features/extensions to scripts when the
platform
module is compiled in.Right now this is only available on RISC-V RV32, but I looked into extending it for other architectures. Some Cortex CPUs have a pair of registers called
ID_PFR
but no flags are defined in CMSIS. For x86/x64 accessing those flags would be OS-dependent, but still doable if you limit yourself to Linux and Windows. Finally, for Aarch64 theID_AA64PFR
registers have documented flags, but I have no Armv8 to test an eventual implementation on.The function name is still somewhat tentative as different architectures may have different names for the same thing after all.
For RISC-V, it is not implemented as a singleton with precomputed values like other functions in the
platform
module because it is technically possible to disable extensions by clearing the bits in the MISA special register rather than reading them.