Skip to content

Conversation

@christian-herber-nxp
Copy link
Collaborator

No description provided.

@mark-honman
Copy link

I may be missing something, but can't see the use-case for this - mtopei already provides this information for IMSIC and ACLIC.
Unless CSR accesses are very expensive, the cost of extracting minor ID from the modified mcause.exccode is not significantly different from reading mtopei. (our implementation has +1 cycle for the CSR read).

@christian-herber-nxp
Copy link
Collaborator Author

I may be missing something, but can't see the use-case for this - mtopei already provides this information for IMSIC and ACLIC. Unless CSR accesses are very expensive, the cost of extracting minor ID from the modified mcause.exccode is not significantly different from reading mtopei. (our implementation has +1 cycle for the CSR read).

It is not about the cost. It is about the atomicity. When you are in a vectored handler, you need the minor identity of the interrupt that triggered the handler. If you read the minor identity later (with interrupts still disabled), you can read the identity of a higher priority pending-enabled interrupt.

@mark-honman
Copy link

OK, got it!

That is certainly of value to SW; a typical use case is several peripherals of the same type - multiple interrupt table entries may point to the same interrupt handler SW, but that SW needs to know which peripheral to service.

@christian-herber-nxp
Copy link
Collaborator Author

christian-herber-nxp commented Oct 13, 2025

OK, got it!

That is certainly of value to SW; a typical use case is several peripherals of the same type - multiple interrupt table entries may point to the same interrupt handler SW, but that SW needs to know which peripheral to service.

although your reply did lead me to the alternative: If reading topei after enabling interrupts, you will read your own identity. Does not seem to bad to me to be honest. It would have to be done before claiming the interrupt.


The major identity is held in bits 15:0 of the exception code field,
while the minor identity is held in bits XLEN-1:16 of the exception code field.
Together, the two identities form the full exception code, which is a WLRL field.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

needs to specify value of minor identity for major interrupts that are not external

an OS may want to handle several interrupts with a common trampoline,
and therefore needs to know the major identity as well.

The major identity is held in bits 15:0 of the exception code field,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Restrict change to xtvec.mode = ivt

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.

Mcause should latch the major and minor interrupt id in case of a vectored interrupt

2 participants