Closed timsifive closed 1 year ago
Looks like at least I need to also read mtopei
because that's only readable with an IMSIC.
Tim Newsome wrote:
I think if
miselect
is can be read without getting an exception, thenmiselect
,mireg
,mtopei
,mtopi
,mvien
, andmvip
are all implemented, and if XLEN=32 thenmidelegh
,mieh
,mvienh
,mviph
, andmiph
are also implemented.
There has been discussion about generalizing the miselect/mireg to apply to extensions besides AiA. So a stronger detection may be to not just detect presence of iselect/ireg CSRs but to detect if the specific extensions state can be accessed using these CSRs.
regards ved
If someone could double check my logic at https://github.com/riscv/riscv-openocd/pull/815/files#diff-b4aa16f9e42cb8f0934baa7c8e0ec9c70a369bef98b99b26ae2e896c8aa95d6aR5402 that'd be very helpful.
Presumably by accessing extension state you mean writing a CSR and seeing if the new value is accepted. For a debugger, that means:
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?
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.
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.
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, thenmiselect
,mireg
,mtopei
,mtopi
,mvien
, andmvip
are all implemented, and if XLEN=32 thenmidelegh
,mieh
,mvienh
,mviph
, andmiph
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?