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

Detecting the extension #40

Closed
timsifive opened this issue Mar 16, 2023 · 6 comments
Closed

Detecting the extension #40

timsifive opened this issue Mar 16, 2023 · 6 comments

Comments

@timsifive
Copy link

How can a debugger (or other software) detect which CSRs are available, without trying to access each CSR individually?

I think if miselect is can be read without getting an exception, then miselect, mireg, mtopei, mtopi, mvien, and mvip are all implemented, and if XLEN=32 then midelegh, mieh, mvienh, mviph, and miph are also implemented.

Then if misa.S is set, the Section 2.2. CSRs are also implemented, and if misa.H is set, then the Section 2.3 CSRs are also implemented.

So I can detect everything I need by just attempting to read miselect. Is that right?

@timsifive
Copy link
Author

Looks like at least I need to also read mtopei because that's only readable with an IMSIC.

@ved-rivos
Copy link

ved-rivos commented Mar 16, 2023 via email

@timsifive
Copy link
Author

@timsifive
Copy link
Author

Presumably by accessing extension state you mean writing a CSR and seeing if the new value is accepted. For a debugger, that means:

  1. Read the CSR
  2. Write a new value
  3. Read it back to see if the value was accepted
  4. Write back the original value, so we don't interfere with the running code.
    That's quite a process. I much prefer a single read (and even that will grow out of control if the debugger has to do a read for every extension that adds CSRs). Hopefully some day Unified Discovery can streamline this process.

Personally I'm only interested in whether the CSRs are implemented or not (so the debugger can show them to the user or not.) Would it still be necessary to try to access the state to see which CSRs are implemented?

@ved-rivos
Copy link

Personally I'm only interested in whether the CSRs are implemented or not (so the debugger can show them to the user or not.) Would it still be necessary to try to access the state to see which CSRs are implemented?

It depends on what the goal is. If the goal is to show that miselect/mireg are implemented then just accessing them suffices. If the goal is to show that the IMSIC is implemented based on existence of miselect/mireg then it may not be sufficient as these may be implemented to support a different extension than IMSIC. From the PR you posted seems like you are discovering mtopi and using that to infer existence of miselect/mireg as well as AIA. That sounds okay to me.

@timsifive
Copy link
Author

It depends on what the goal is. If the goal is to show that miselect/mireg are implemented then just accessing them suffices.

That is my goal. Thanks for looking over my PR.

I imagine a more sophisticated debugger would like to show whether IMSIC is supported.

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

No branches or pull requests

2 participants