OSDN Git Service

4fe387bc45d10dc077f4e80f4e8307631a3ba301
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz2500 / interrupt.h
1 /*
2         SHARP MZ-2500 Emulator 'EmuZ-2500'
3
4         Author : Takeda.Toshiya
5         Date   : 2007.02.11 -
6
7         [ interrupt ]
8 */
9
10 #ifndef _INTERRUPT_H_
11 #define _INTERRUPT_H_
12
13 #include "../vm.h"
14 #include "../../emu.h"
15 #include "../device.h"
16
17 #define SIG_INTERRUPT_CRTC      0
18 #define SIG_INTERRUPT_I8253     1
19 #define SIG_INTERRUPT_PRINTER   2
20 #define SIG_INTERRUPT_RP5C15    3
21
22 namespace MZ2500 {
23
24 class INTERRUPT : public DEVICE
25 {
26 private:
27         uint8_t select;
28         
29         // interrupt
30         struct {
31                 uint8_t vector;
32                 bool enb_intr;
33                 bool req_intr;
34                 bool in_service;
35         } irq[4];
36         int req_intr_ch;
37         
38         // z80 daisy chain
39         DEVICE *d_cpu, *d_child;
40         bool iei, oei;
41         uint32_t intr_bit;
42         void update_intr();
43         
44 public:
45         INTERRUPT(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
46         {
47                 d_cpu = d_child = NULL;
48                 set_device_name(_T("Interrupt"));
49         }
50         ~INTERRUPT() {}
51         
52         // common functions
53         void reset();
54         void write_io8(uint32_t addr, uint32_t data);
55         void write_signal(int id, uint32_t data, uint32_t mask);
56         bool process_state(FILEIO* state_fio, bool loading);
57         
58         // interrupt common functions
59         void set_context_intr(DEVICE* device, uint32_t bit)
60         {
61                 d_cpu = device;
62                 intr_bit = bit;
63         }
64         void set_context_child(DEVICE* device)
65         {
66                 d_child = device;
67         }
68         void set_intr_iei(bool val);
69         uint32_t get_intr_ack();
70         void notify_intr_reti();
71 };
72         
73 }
74 #endif
75