xref: /openbmc/qemu/include/hw/misc/mac_via.h (revision a6caeee8)
1 /*
2  *
3  * Copyright (c) 2011-2018 Laurent Vivier
4  *
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  */
8 
9 #ifndef HW_MISC_MAC_VIA_H
10 #define HW_MISC_MAC_VIA_H
11 
12 #include "exec/memory.h"
13 #include "hw/sysbus.h"
14 #include "hw/misc/mos6522.h"
15 #include "qom/object.h"
16 
17 
18 #define VIA_SIZE   0x2000
19 
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
26 
27 #define VIA1_IRQ_ONE_SECOND     BIT(VIA1_IRQ_ONE_SECOND_BIT)
28 #define VIA1_IRQ_60HZ           BIT(VIA1_IRQ_60HZ_BIT)
29 #define VIA1_IRQ_ADB_READY      BIT(VIA1_IRQ_ADB_READY_BIT)
30 #define VIA1_IRQ_ADB_DATA       BIT(VIA1_IRQ_ADB_DATA_BIT)
31 #define VIA1_IRQ_ADB_CLOCK      BIT(VIA1_IRQ_ADB_CLOCK_BIT)
32 
33 
34 #define TYPE_MOS6522_Q800_VIA1 "mos6522-q800-via1"
35 OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA1State, MOS6522_Q800_VIA1)
36 
37 struct MOS6522Q800VIA1State {
38     /*< private >*/
39     MOS6522State parent_obj;
40 
41     MemoryRegion via_mem;
42 
43     qemu_irq auxmode_irq;
44     uint8_t last_b;
45 
46     /* RTC */
47     uint8_t PRAM[256];
48     BlockBackend *blk;
49     VMChangeStateEntry *vmstate;
50 
51     uint32_t tick_offset;
52 
53     uint8_t data_out;
54     int data_out_cnt;
55     uint8_t data_in;
56     uint8_t data_in_cnt;
57     uint8_t cmd;
58     int wprotect;
59     int alt;
60 
61     /* ADB */
62     ADBBusState adb_bus;
63     qemu_irq adb_data_ready;
64     int adb_data_in_size;
65     int adb_data_in_index;
66     int adb_data_out_index;
67     uint8_t adb_data_in[128];
68     uint8_t adb_data_out[16];
69     uint8_t adb_autopoll_cmd;
70 
71     /* external timers */
72     QEMUTimer *one_second_timer;
73     int64_t next_second;
74     QEMUTimer *sixty_hz_timer;
75     int64_t next_sixty_hz;
76 };
77 
78 
79 /* VIA 2 */
80 #define VIA2_IRQ_SCSI_DATA_BIT  CA2_INT_BIT
81 #define VIA2_IRQ_NUBUS_BIT      CA1_INT_BIT
82 #define VIA2_IRQ_SCSI_BIT       CB2_INT_BIT
83 #define VIA2_IRQ_ASC_BIT        CB1_INT_BIT
84 
85 #define VIA2_IRQ_SCSI_DATA      BIT(VIA2_IRQ_SCSI_DATA_BIT)
86 #define VIA2_IRQ_NUBUS          BIT(VIA2_IRQ_NUBUS_BIT)
87 #define VIA2_IRQ_UNUSED         BIT(VIA2_IRQ_SCSI_BIT)
88 #define VIA2_IRQ_SCSI           BIT(VIA2_IRQ_UNUSED_BIT)
89 #define VIA2_IRQ_ASC            BIT(VIA2_IRQ_ASC_BIT)
90 
91 #define VIA2_NUBUS_IRQ_NB       7
92 
93 #define VIA2_NUBUS_IRQ_9        0
94 #define VIA2_NUBUS_IRQ_A        1
95 #define VIA2_NUBUS_IRQ_B        2
96 #define VIA2_NUBUS_IRQ_C        3
97 #define VIA2_NUBUS_IRQ_D        4
98 #define VIA2_NUBUS_IRQ_E        5
99 #define VIA2_NUBUS_IRQ_INTVIDEO 6
100 
101 #define TYPE_MOS6522_Q800_VIA2 "mos6522-q800-via2"
102 OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA2State, MOS6522_Q800_VIA2)
103 
104 struct MOS6522Q800VIA2State {
105     /*< private >*/
106     MOS6522State parent_obj;
107 
108     MemoryRegion via_mem;
109 };
110 
111 #endif
112