Skip to contentSkip to conversation

Fix handling of AVR interrupts above 33.

PATCH In review Lucas Dietrich 2 participants 2 messages Jun 13, 2023 – Jun 14, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix handling of AVR interrupts above 33.

This commit addresses a bug in the AVR interrupt handling code. The modification involves replacing the usage of the ctz32 function with ctz64 to ensure proper handling of interrupts above 33 in the AVR target.

Previously, timers 3, 4, and 5 interrupts were not functioning correctly because most of their interrupt vectors are numbered above 33.

---
 capstone                      | 1 +
 dtc                           | 1 +
 meson                         | 1 +
 roms/sgabios                  | 1 +
 slirp                         | 1 +
 target/avr/helper.c           | 4 ++--
 tests/fp/berkeley-softfloat-3 | 1 +
 tests/fp/berkeley-testfloat-3 | 1 +
 ui/keycodemapdb               | 1 +
 9 files changed, 10 insertions(+), 2 deletions(-)
 create mode 160000 capstone
 create mode 160000 dtc
 create mode 160000 meson
 create mode 160000 roms/sgabios
 create mode 160000 slirp
 create mode 160000 tests/fp/berkeley-softfloat-3
 create mode 160000 tests/fp/berkeley-testfloat-3
 create mode 160000 ui/keycodemapdb
capstone new file +1 -0
new file mode 160000
index 0000000000..f8b1b83301
@@ -0,0 +1 @@
+Subproject commit f8b1b833015a4ae47110ed068e0deb7106ced66d
dtc new file +1 -0
new file mode 160000
index 0000000000..b6910bec11
@@ -0,0 +1 @@
+Subproject commit b6910bec11614980a21e46fbccc35934b671bd81
meson new file +1 -0
new file mode 160000
index 0000000000..12f9f04ba0
@@ -0,0 +1 @@
+Subproject commit 12f9f04ba0decfda425dbbf9a501084c153a2d18
roms/sgabios new file +1 -0
new file mode 160000
index 0000000000..cbaee52287
@@ -0,0 +1 @@
+Subproject commit cbaee52287e5f32373181cff50a00b6c4ac9015a
slirp new file +1 -0
new file mode 160000
index 0000000000..a88d9ace23
@@ -0,0 +1 @@
+Subproject commit a88d9ace234a24ce1c17189642ef9104799425e0
target/avr/helper.c +2 -2
index 2bad242a66..e6e7d51487 100644
@@ -52,7 +52,7 @@ bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
     }
     if (interrupt_request & CPU_INTERRUPT_HARD) {
         if (cpu_interrupts_enabled(env) && env->intsrc != 0) {
-            int index = ctz32(env->intsrc);
+            int index = ctz64(env->intsrc);
             cs->exception_index = EXCP_INT(index);
             avr_cpu_do_interrupt(cs);
 
@@ -79,7 +79,7 @@ void avr_cpu_do_interrupt(CPUState *cs)
     if (cs->exception_index == EXCP_RESET) {
         vector = 0;
     } else if (env->intsrc != 0) {
-        vector = ctz32(env->intsrc) + 1;
+        vector = ctz64(env->intsrc) + 1;
     }
 
     if (avr_feature(env, AVR_FEATURE_3_BYTE_PC)) {
tests/fp/berkeley-softfloat-3 new file +1 -0
new file mode 160000
index 0000000000..b64af41c32
@@ -0,0 +1 @@
+Subproject commit b64af41c3276f97f0e181920400ee056b9c88037
tests/fp/berkeley-testfloat-3 new file +1 -0
new file mode 160000
index 0000000000..5a59dcec19
@@ -0,0 +1 @@
+Subproject commit 5a59dcec19327396a011a17fd924aed4fec416b3
ui/keycodemapdb new file +1 -0
new file mode 160000
index 0000000000..d21009b1c9
@@ -0,0 +1 @@
+Subproject commit d21009b1c9f94b740ea66be8e48a1d8ad8124023
Signature · 1 line
2.40.1
#1 lore raw
Quoted 9 lines · Lucas Dietrich

This commit addresses a bug in the AVR interrupt handling code. The modification involves replacing the usage of the ctz32 function with ctz64 to ensure proper handling of interrupts above 33 in the AVR target.

Previously, timers 3, 4, and 5 interrupts were not functioning correctly because most of their interrupt vectors are numbered above 33.

The change to target/avr/ looks right, but you shouldn't have all the subproject changes.

r~

Quoted 19 lines
---
  capstone                      | 1 +
  dtc                           | 1 +
  meson                         | 1 +
  roms/sgabios                  | 1 +
  slirp                         | 1 +
  target/avr/helper.c           | 4 ++--
  tests/fp/berkeley-softfloat-3 | 1 +
  tests/fp/berkeley-testfloat-3 | 1 +
  ui/keycodemapdb               | 1 +
  9 files changed, 10 insertions(+), 2 deletions(-)

create mode 160000 capstone
create mode 160000 dtc
create mode 160000 meson
create mode 160000 roms/sgabios
create mode 160000 slirp
create mode 160000 tests/fp/berkeley-softfloat-3 create mode 160000 tests/fp/berkeley-testfloat-3 create mode 160000 ui/keycodemapdb