Patchwork [13/22] i8259: Fix poll command

login
register
mail settings
Submitter Jan Kiszka
Date Sept. 28, 2011, 11 a.m.
Message ID <427b81df30d7184247afd666bc196ee1b04485fc.1317207666.git.jan.kiszka@siemens.com>
Download mbox | patch
Permalink /patch/116762/
State New
Headers show

Comments

Jan Kiszka - Sept. 28, 2011, 11 a.m.
This was probably never used so far: According to the spec, polling
means ack'ing the pending IRQ and setting its corresponding bit in isr.
Moreover, we have to signal a pending IRQ via bit 7 of the returned
value, and we must not return a spurious IRQ if none is pending.

This implements the poll command without the help of pic_poll_read which
is left untouched as pic_intack_read is still using it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/i8259.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/i8259.c b/hw/i8259.c
index 53b86dd..849c82e 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
@@ -388,7 +388,13 @@  static uint64_t pic_ioport_read(void *opaque, target_phys_addr_t addr1,
     int ret;
 
     if (s->poll) {
-        ret = pic_poll_read(s);
+        ret = pic_get_irq(s);
+        if (ret >= 0) {
+            pic_intack(s, ret);
+            ret |= 0x80;
+        } else {
+            ret = 0;
+        }
         s->poll = 0;
     } else {
         if (addr == 0) {