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