Comments (5)
I found the following description in Section 3.9, 'Top External Interrupt CSRs,' of the RISC-V Advanced Interrupt Architecture Version 1.0, revised on June 30, 2023.
A read of a *topei CSR returns zero either if no interrupt is both pending in the interrupt file’s eip
array and enabled in its eie array, or if eithreshold is not zero and no pending-and-enabled interrupt
has an identity number less than the value of eithreshold. Otherwise, the value returned from a read
of *topei has this format:
It is almost always a mistake to write to a *topei CSR without a simultaneous read to
learn which interrupt was claimed.
So, I believe the scrrw
instruction is used to read and claim the highest-priority pending-and-enabled interrupt, and topei
will not be written to zero, but will change to indicate the next highest-priority pending-and-enabled interrupt.
Is my understanding correct?
from opensbi.
I don't think it's necessary. You can just return from the interrupt but if there is another pending you'll just take an interrupt again. So you may as well process all that are available and avoid the extra privilege switch.
Linux does the same thing with stopi.
https://github.com/torvalds/linux/blob/master/drivers/irqchip/irq-riscv-intc.c#L41
from opensbi.
What confuses me the most is the behavior of TOPEI and STOPEI after executing csrrw rd, mtopei/stopei, x0. It seems that mtopei/stopei will be set to 0. Is the while loop used to handle interrupts that occur during the ISR process?
from opensbi.
What confuses me the most is the behavior of TOPEI and STOPEI after executing csrrw rd, mtopei/stopei, x0. It seems that mtopei/stopei will be set to 0.
The write is ignored. This is what the spec says:
A write to a *topei CSR claims the reported interrupt identity by clearing its pending bit in the interrupt file. The value written is ignored; rather, the current readable value of the register determines which interrupt-pending bit is cleared.
Is the while loop used to handle interrupts that occur during the ISR process?
Yes.
from opensbi.
I am examining the function of TOPEI in QEMU. The read-modify-write operation on TOPEI involves two steps: first, it reads the highest-priority pending-and-enabled interrupt, and second, it writes an ignore value to clear the top pending interrupt. Therefore, on the second access, TOPEI should report the next highest-priority pending-and-enabled interrupt.
https://github.com/qemu/qemu/blob/master/hw/intc/riscv_imsic.c#L112
static int riscv_imsic_topei_rmw(RISCVIMSICState *imsic, uint32_t page,
target_ulong *val, target_ulong new_val,
target_ulong wr_mask)
{
uint32_t base, topei = riscv_imsic_topei(imsic, page);
/* Read pending and enabled interrupt with highest priority */
if (val) {
*val = topei;
}
/* Writes ignore value and clear top pending interrupt */
if (topei && wr_mask) {
topei >>= IMSIC_TOPEI_IID_SHIFT;
base = page * imsic->num_irqs;
if (topei) {
imsic->eistate[base + topei] &= ~IMSIC_EISTATE_PENDING;
}
riscv_imsic_update(imsic, page);
}
return 0;
}
Thanks very much with best regards!
from opensbi.
Related Issues (20)
- fw_start and fw_rw_offset not aligned
- Is there any upper memory bound for initramfs or opensbi or kernel?
- Handling interrupts with multiple privileges on multiple harts in OpenSBI HOT 1
- [help] K210 serial port has no output HOT 1
- build issue - functions do not get linked HOT 1
- System freezes when setting smp value to 54 or higher with qemu-system-riscv64
- Firmware SMP boot bug HOT 2
- sbi_hsm_hart_start_finish: ERR: The hart is in invalid state [2147774600] HOT 1
- firmware base is not the value of FW_TEXT_START( but 0x80000000) HOT 1
- How to get symtab from elf?
- qemu-system-riscv64: -append only allowed with -kernel option HOT 1
- Writing drivers for Timer peripheral
- questions about OpenSBI Version 1.5 HOT 10
- opensbi failed to build HOT 1
- error: "__always_inline" redefined [-Werror]
- Why ld is leaving a hole in memory?
- understanding -PIE HOT 2
- Access to time CSR is trap-emulated even when scounteren.TM is clear HOT 1
- Regarding support for NACL on the SBI side
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opensbi.