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

riscv: register: exports macros for custom CSRs #203

Merged
merged 1 commit into from
May 2, 2024

Conversation

rmsyn
Copy link
Contributor

@rmsyn rmsyn commented May 1, 2024

Exports macros from the riscv::register::macros module for external users.

This allows external users to define custom CSR accessor functions.

This is useful for platforms and SoCs with custom CSR registers not defined in the riscv crate.

Resolves: #187

@rmsyn rmsyn requested a review from a team as a code owner May 1, 2024 02:14
@rmsyn rmsyn force-pushed the register/export-macros branch from 4aa288e to 1564199 Compare May 1, 2024 02:16
@@ -1,3 +1,9 @@
/// `RV64`: Convenience macro to wrap the `csrrs` assembly instruction for reading a CSR register.
///
/// This macro should generally not be called directly.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is actually correct, as some of the existing register definitions directly call this macro.

Open to wording suggestions about correct usage here, and other similar locations.

riscv/src/register/macros.rs Outdated Show resolved Hide resolved
Exports macros from the `riscv::register::macros` module for external users.

This allows external users to define custom CSR accessor functions.

This is useful for platforms and SoCs with custom CSR registers not
defined in the `riscv` crate.

Resolves: rust-embedded#187
@rmsyn rmsyn force-pushed the register/export-macros branch from 1564199 to d72d7a3 Compare May 1, 2024 04:12
Copy link
Contributor

@romancardenas romancardenas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@romancardenas romancardenas added this pull request to the merge queue May 2, 2024
Merged via the queue into rust-embedded:master with commit a9d3e33 May 2, 2024
95 checks passed
@@ -1,3 +1,9 @@
/// `RV64`: Convenience macro to wrap the `csrrs` assembly instruction for reading a CSR register.
Copy link
Contributor

@taiki-e taiki-e May 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This macro is for both RV32 and RV64. (Other non-*_rv32 macros are the same.)
For example:

read_csr_as!(Mstatus, 0x300);
write_csr!(0x300);
set!(0x300);
clear!(0x300);

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.

riscv: Pub macros for non-standard CSRs
3 participants