-
Notifications
You must be signed in to change notification settings - Fork 78
fix(IDL): implement Smctr/Ssctr in IDL #1164
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
4674bdf
dfe4494
8c95734
c133198
74e6237
f5fad42
dcc0552
23e433d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,25 @@ description: | | |
| which logical entry in the buffer it wishes to read or write. | ||
| Logical entry 0 always corresponds to the youngest recorded transfer, followed by entry 1 as the | ||
| next youngest, and so on. | ||
| params: | ||
| CTR_CYCLE_COUNTER: | ||
| description: | | ||
| The elapsed cycle counter includes a count of CPU cycles elapsed since the prior CTR record. | ||
| It is represented by the CC field, which has a 12-bit mantissa component | ||
| (Cycle Count Mantissa, or CCM) and a 4-bit exponent component (Cycle Count Exponent, or CCE). | ||
| It increments at the same rate as the mcycle counter. | ||
| The CtrCycleCounter is reset on writes to xctrctl , and on execution of SCTRCLR, to ensure that any | ||
| accumulated cycle counts do not persist across a context switch. | ||
| schema: | ||
| type: integer | ||
| CCV: | ||
|
||
| description: | | ||
| The CC value is valid only when the Cycle Count Valid (CCV) bit is set. The next record will | ||
| have CCV=0 after a write to xctrctl , or execution of SCTRCLR, since CtrCycleCounter is reset. CCV | ||
| should additionally be cleared after any other implementation-specific scenarios where active cycles | ||
| might not be counted in CtrCycleCounter. | ||
| schema: | ||
| type: boolean | ||
| type: privileged | ||
| versions: | ||
| - version: "1.0.0" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to represent the optionality of the the CC field in the
ctrdataCSR? If so, this seems like this should be a boolean?Also, it's not clear that this is what the parameter is for, so maybe include a bit more about the purpose of the parameter:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit vague in the spec. From what I've understood. CtrCycleCounter and ctrdata.CC are different. CtrCycleCounter is an independant counter whose value is stored in ctrdata in case of a control transfer. From
section 11.5.3
ctrdata for each entry is just a copy of CtrCycleCounter at the time of control transfer. Also,
Here, zeroing out entry registers meaning zeroing out ctrdata as well. But it explicitly states to zero out CTR cycle counter and CCV.
As it's a counter therefore, it's type would be integer, right?
I'll improve the description of the param as it seems a bit unclear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following, sorry. The purpose of parameters is for configurations to resolve optionality in the spec. (For example, when the spec says "should", "may", or recommends a behavior, but does not mandate it with "must".) What optionality is being resolved with this parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I might be using parameters the wrong way.
Spec states that STRCLR zeros out the CTR cycle counter.
Therefore, I used params to represent the hardware counter and CCV flag. What would be the correct way to represent the counter so that I could zero it out in IDL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so "CCV" is a field in the
ctrdataregister. This register is not yet defined in UDB, but needs to be for this work to proceed. It would probably be defined much like other CSRs, but it might be a little weird in that I think it can only be accessed indirectly (siselect+sireg3). And there isn't a single set of CTR registers, it's a buffer of up to 256 records that can be accessed by being mapped to indirect register selections 0x200-0x2ff. And, how many records are actually supported is implementation-dependent (needs a configuration parameter) -- seesctrdepth.So, it's a little complicated. #554 is a start on defining the extension, but isn't merged, and doesn't have the parameters defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The response was essentially that CtrCycleCounter is not directly visible machine state, only indirectly through
ctrdataregister(s). So, I think this needs to be implemented using a callout to a builtin function, akin to the use ofread_mcycle()incycle.yaml.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. What about clearing out the entry registers? We don't have direct access to those registers. Should I use a builtin for that as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, I don't think it's terribly important whether it is represented as a set of (indirect) actual CSRs, or as a set of indirect CSRs that have
sw_write()andsw_read()methods that access some builtin memory buffer. The former is pretty straight-forward. The latter would require defining a builtin accessor function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, my current approach makes sense, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are talking about configuration parameters, then no. :-)
Flipping through the extension documentation, I see at least these as needed parameters:
For registers, you'll need to use indirect access as noted previously.
For CtrCycleCounter, you should implement as a call to a builtin function.
For CCV, each of those bits is contained in each Control Transfer Record, shadowed by the
ctrdataregister, accessed indirectly throughsireg3(whensiselect= buffer offset/register index), so if you're already setting the register to zero, you have also set CCV to zero.I hope that makes sense. :-)