aboutsummaryrefslogtreecommitdiffstats
path: root/z80irq.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-10-29 21:59:09 -0700
committerH. Peter Anvin <hpa@zytor.com>2018-10-29 21:59:09 -0700
commit8ffd9584a896906871a31359dbc11d84b3acf550 (patch)
tree53cac40c277e867fb8a7a9334564765dc35e5223 /z80irq.h
parent7d8a51b69c9a49435d39494e44824133261013fd (diff)
downloadabc80sim-8ffd9584a896906871a31359dbc11d84b3acf550.tar.gz
abc80sim-8ffd9584a896906871a31359dbc11d84b3acf550.tar.xz
abc80sim-8ffd9584a896906871a31359dbc11d84b3acf550.zip
Better, asynchronous IRQ handling; move SDL handling to sep. thread
Make the IRQ system significantly more accurate with regards to how a real Z80 system works. Make the system reentrant. Move the SDL event and video handling into a separate thread.
Diffstat (limited to 'z80irq.h')
-rw-r--r--z80irq.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/z80irq.h b/z80irq.h
new file mode 100644
index 0000000..9e2c1dc
--- /dev/null
+++ b/z80irq.h
@@ -0,0 +1,31 @@
+#ifndef Z80IRQ_H
+#define Z80IRQ_H
+
+#include "compiler.h"
+#include "z80.h"
+
+typedef int (*irq_func)(unsigned int prio, struct z80_irq *irq);
+
+struct z80_irq {
+ irq_func intack;
+ irq_func eoi;
+ void *pvt; /* Available for user */
+ int vector; /* Available for user if intack defined */
+ unsigned int prio; /* Available for user after register_irq */
+};
+
+#define MAX_IRQ 32
+
+extern volatile unsigned int irq_pending;
+static inline bool poll_irq(void)
+{
+ return unlikely(irq_pending != 0);
+}
+
+void z80_register_irq(struct z80_irq *irq);
+int z80_intack(void);
+void z80_eoi(void);
+bool z80_interrupt(unsigned int prio);
+bool z80_clear_interrupt(unsigned int prio);
+
+#endif /* Z80IRQ_H */