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: define mvendorid CSR with macro helpers #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rmsyn
Copy link
Contributor

@rmsyn rmsyn commented Jan 11, 2025

Uses CSR macro helpers to define the mvendorid CSR register.

@rmsyn rmsyn requested a review from a team as a code owner January 11, 2025 10:39

/// Returns the JEDEC manufacturer ID
#[inline]
pub fn jedec_manufacturer(&self) -> usize {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add the jedec_manufacturer field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, I missed that function when converting to the CSR macro.

After reading the ISA again, it looks like the jedec_manufacturer implementation was incorrect.

mvendorid encodes the number of one-byte continuation codes in the Bank field, and
encodes the final byte in the Offset field, discarding the parity bit. For example, the JEDEC
manufacturer ID 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x7f 0x8a (twelve
continuation codes followed by 0x8a) would be encoded in the mvendorid CSR as 0x60a.

So, we would probably want to add bank and offset fields, along with a correct jedec_manufacturer function that decodes the ID:

pub const fn jedec_manufacturer(&self) -> (usize, usize) {
    (self.bank(), 0x80 | self.offset())
}

@rmsyn rmsyn force-pushed the riscv/mvendorid-csr-macro branch from 2a24146 to 0b6d890 Compare January 11, 2025 17:36
Uses CSR macro helpers to define the `mvendorid` CSR register.
@rmsyn rmsyn force-pushed the riscv/mvendorid-csr-macro branch from 0b6d890 to 37a87f3 Compare January 11, 2025 17:38
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.

2 participants