|
| 1 | +# yaml-language-server: $schema=../../../schemas/csr_schema.json |
| 2 | + |
| 3 | +$schema: csr_schema.json# |
| 4 | +kind: csr |
| 5 | +name: scountovf |
| 6 | +long_name: Supervisor Count Overflow |
| 7 | +address: 0xDA0 |
| 8 | +priv_mode: S |
| 9 | +length: 32 |
| 10 | +definedBy: Sscofpmf |
| 11 | +description: | |
| 12 | + A 32-bit read-only register that contains shadow copies of the OF bits in the 29 `mhpmevent` CSRs |
| 13 | + (`mhpmevent3` - `mhpmevent31`) — where `scountovf` bit X corresponds to `mhpmeventX`. |
| 14 | + |
| 15 | + This register enables supervisor-level overflow interrupt handler |
| 16 | + software to quickly and easily determine which counter(s) have overflowed |
| 17 | + without needing to make an execution environment call up to M-mode. |
| 18 | + |
| 19 | + Read access to bit X is subject to the same `mcounteren` (or `mcounteren` and `hcounteren`) |
| 20 | + CSRs that mediate access to the `hpmcounter` CSRs by S-mode (or VS-mode). |
| 21 | + |
| 22 | + In M-mode, `scountovf` bit X is always readable. |
| 23 | + In S/HS-mode, `scountovf` bit X is readable when `mcounteren` bit X is set, and otherwise reads as zero. |
| 24 | + Similarly, in VS-mode, it is readable when both `mcounteren` and `hcounteren` bit X are set. |
| 25 | + |
| 26 | +fields: |
| 27 | +<%- (3..31).each do |of_num| -%> |
| 28 | + OF<%= of_num %>: |
| 29 | + alias: mhpmevent<%= of_num %>.OF |
| 30 | + location: <%= of_num %> |
| 31 | + description: | |
| 32 | + [when="HPM_COUNTER_EN[<%= of_num %>] == true"] |
| 33 | + Shadow copy of mhpmevent<%= of_num %> overflow (OF) bit. |
| 34 | + |
| 35 | + [when="HPM_COUNTER_EN[<%= of_num %>] == false"] |
| 36 | + This field is read-only zero because the counter is not enabled. |
| 37 | + type(): | |
| 38 | + return HPM_COUNTER_EN[<%= of_num %>] ? CsrFieldType::RO : CsrFieldType::ROH; |
| 39 | + reset_value(): | |
| 40 | + return HPM_COUNTER_EN[<%= of_num %>] ? UNDEFINED_LEGAL : 0; |
| 41 | +<%- end -%> |
| 42 | + |
| 43 | +sw_read(): | |
| 44 | + Bits<32> mask; |
| 45 | + if (mode() == PrivilegeMode::VS) { |
| 46 | + # In VS-mode, scountovf.OFX access is determined by mcounteren/hcounteren |
| 47 | + mask = $bits(CSR[mcounteren]) & $bits(CSR[hcounteren]); |
| 48 | + } else { |
| 49 | + # In M-mode and S-mode, scountovf.OFX access is determined by mcounteren/scounteren |
| 50 | + mask = $bits(CSR[mcounteren]) & $bits(CSR[scounteren]); |
| 51 | + } |
| 52 | + |
| 53 | + Bits<32> value = 0; |
| 54 | + <%- (3..31).each do |num| -%> |
| 55 | + value = value | (CSR[mhpmevent<%= num %>].OF << <%= num %>); |
| 56 | + <%- end -%> |
| 57 | + |
| 58 | + return value & mask; |
0 commit comments