mac_via: use IFR bit flag constants for VIA1 IRQs
[qemu/armbru.git] / include / hw / misc / mac_via.h
blobb0535c84da8b8e7ac21bdaef2e1a7a7d213f97bb
1 /*
3 * Copyright (c) 2011-2018 Laurent Vivier
5 * This work is licensed under the terms of the GNU GPL, version 2 or later.
6 * See the COPYING file in the top-level directory.
7 */
9 #ifndef HW_MISC_MAC_VIA_H
10 #define HW_MISC_MAC_VIA_H
12 #include "exec/memory.h"
13 #include "hw/sysbus.h"
14 #include "hw/misc/mos6522.h"
15 #include "qom/object.h"
18 #define VIA_SIZE 0x2000
20 /* VIA 1 */
21 #define VIA1_IRQ_ONE_SECOND_BIT CA2_INT_BIT
22 #define VIA1_IRQ_60HZ_BIT CA1_INT_BIT
23 #define VIA1_IRQ_ADB_READY_BIT SR_INT_BIT
24 #define VIA1_IRQ_ADB_DATA_BIT CB2_INT_BIT
25 #define VIA1_IRQ_ADB_CLOCK_BIT CB1_INT_BIT
27 #define VIA1_IRQ_NB 8
29 #define VIA1_IRQ_ONE_SECOND BIT(VIA1_IRQ_ONE_SECOND_BIT)
30 #define VIA1_IRQ_60HZ BIT(VIA1_IRQ_60HZ_BIT)
31 #define VIA1_IRQ_ADB_READY BIT(VIA1_IRQ_ADB_READY_BIT)
32 #define VIA1_IRQ_ADB_DATA BIT(VIA1_IRQ_ADB_DATA_BIT)
33 #define VIA1_IRQ_ADB_CLOCK BIT(VIA1_IRQ_ADB_CLOCK_BIT)
36 #define TYPE_MOS6522_Q800_VIA1 "mos6522-q800-via1"
37 OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA1State, MOS6522_Q800_VIA1)
39 struct MOS6522Q800VIA1State {
40 /*< private >*/
41 MOS6522State parent_obj;
43 MemoryRegion via_mem;
45 qemu_irq irqs[VIA1_IRQ_NB];
46 qemu_irq auxmode_irq;
47 uint8_t last_b;
49 /* RTC */
50 uint8_t PRAM[256];
51 BlockBackend *blk;
52 VMChangeStateEntry *vmstate;
54 uint32_t tick_offset;
56 uint8_t data_out;
57 int data_out_cnt;
58 uint8_t data_in;
59 uint8_t data_in_cnt;
60 uint8_t cmd;
61 int wprotect;
62 int alt;
64 /* ADB */
65 ADBBusState adb_bus;
66 qemu_irq adb_data_ready;
67 int adb_data_in_size;
68 int adb_data_in_index;
69 int adb_data_out_index;
70 uint8_t adb_data_in[128];
71 uint8_t adb_data_out[16];
72 uint8_t adb_autopoll_cmd;
74 /* external timers */
75 QEMUTimer *one_second_timer;
76 int64_t next_second;
77 QEMUTimer *sixty_hz_timer;
78 int64_t next_sixty_hz;
82 /* VIA 2 */
83 #define VIA2_IRQ_SCSI_DATA_BIT 0
84 #define VIA2_IRQ_NUBUS_BIT 1
85 #define VIA2_IRQ_UNUSED_BIT 2
86 #define VIA2_IRQ_SCSI_BIT 3
87 #define VIA2_IRQ_ASC_BIT 4
89 #define VIA2_IRQ_NB 8
91 #define VIA2_IRQ_SCSI_DATA (1 << VIA2_IRQ_SCSI_DATA_BIT)
92 #define VIA2_IRQ_NUBUS (1 << VIA2_IRQ_NUBUS_BIT)
93 #define VIA2_IRQ_UNUSED (1 << VIA2_IRQ_SCSI_BIT)
94 #define VIA2_IRQ_SCSI (1 << VIA2_IRQ_UNUSED_BIT)
95 #define VIA2_IRQ_ASC (1 << VIA2_IRQ_ASC_BIT)
97 #define VIA2_NUBUS_IRQ_NB 7
99 #define VIA2_NUBUS_IRQ_9 0
100 #define VIA2_NUBUS_IRQ_A 1
101 #define VIA2_NUBUS_IRQ_B 2
102 #define VIA2_NUBUS_IRQ_C 3
103 #define VIA2_NUBUS_IRQ_D 4
104 #define VIA2_NUBUS_IRQ_E 5
105 #define VIA2_NUBUS_IRQ_INTVIDEO 6
107 #define TYPE_MOS6522_Q800_VIA2 "mos6522-q800-via2"
108 OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA2State, MOS6522_Q800_VIA2)
110 struct MOS6522Q800VIA2State {
111 /*< private >*/
112 MOS6522State parent_obj;
114 MemoryRegion via_mem;
117 #endif