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 /* VIA 1 */ 19 #define VIA1_IRQ_ONE_SECOND_BIT 0 20 #define VIA1_IRQ_60HZ_BIT 1 21 #define VIA1_IRQ_ADB_READY_BIT 2 22 #define VIA1_IRQ_ADB_DATA_BIT 3 23 #define VIA1_IRQ_ADB_CLOCK_BIT 4 24 25 #define VIA1_IRQ_NB 8 26 27 #define VIA1_IRQ_ONE_SECOND (1 << VIA1_IRQ_ONE_SECOND_BIT) 28 #define VIA1_IRQ_60HZ (1 << VIA1_IRQ_60HZ_BIT) 29 #define VIA1_IRQ_ADB_READY (1 << VIA1_IRQ_ADB_READY_BIT) 30 #define VIA1_IRQ_ADB_DATA (1 << VIA1_IRQ_ADB_DATA_BIT) 31 #define VIA1_IRQ_ADB_CLOCK (1 << 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 qemu_irq irqs[VIA1_IRQ_NB]; 42 uint8_t last_b; 43 44 /* RTC */ 45 uint8_t PRAM[256]; 46 BlockBackend *blk; 47 VMChangeStateEntry *vmstate; 48 49 /* external timers */ 50 QEMUTimer *one_second_timer; 51 int64_t next_second; 52 QEMUTimer *sixty_hz_timer; 53 int64_t next_sixty_hz; 54 }; 55 56 57 /* VIA 2 */ 58 #define VIA2_IRQ_SCSI_DATA_BIT 0 59 #define VIA2_IRQ_SLOT_BIT 1 60 #define VIA2_IRQ_UNUSED_BIT 2 61 #define VIA2_IRQ_SCSI_BIT 3 62 #define VIA2_IRQ_ASC_BIT 4 63 64 #define VIA2_IRQ_NB 8 65 66 #define VIA2_IRQ_SCSI_DATA (1 << VIA2_IRQ_SCSI_DATA_BIT) 67 #define VIA2_IRQ_SLOT (1 << VIA2_IRQ_SLOT_BIT) 68 #define VIA2_IRQ_UNUSED (1 << VIA2_IRQ_SCSI_BIT) 69 #define VIA2_IRQ_SCSI (1 << VIA2_IRQ_UNUSED_BIT) 70 #define VIA2_IRQ_ASC (1 << VIA2_IRQ_ASC_BIT) 71 72 #define TYPE_MOS6522_Q800_VIA2 "mos6522-q800-via2" 73 OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA2State, MOS6522_Q800_VIA2) 74 75 struct MOS6522Q800VIA2State { 76 /*< private >*/ 77 MOS6522State parent_obj; 78 }; 79 80 81 #define TYPE_MAC_VIA "mac_via" 82 OBJECT_DECLARE_SIMPLE_TYPE(MacVIAState, MAC_VIA) 83 84 struct MacVIAState { 85 SysBusDevice busdev; 86 87 /* MMIO */ 88 MemoryRegion mmio; 89 MemoryRegion via1mem; 90 MemoryRegion via2mem; 91 92 /* VIAs */ 93 MOS6522Q800VIA1State mos6522_via1; 94 MOS6522Q800VIA2State mos6522_via2; 95 96 /* RTC */ 97 uint32_t tick_offset; 98 99 uint8_t data_out; 100 int data_out_cnt; 101 uint8_t data_in; 102 uint8_t data_in_cnt; 103 uint8_t cmd; 104 int wprotect; 105 int alt; 106 107 /* ADB */ 108 ADBBusState adb_bus; 109 qemu_irq adb_data_ready; 110 int adb_data_in_size; 111 int adb_data_in_index; 112 int adb_data_out_index; 113 uint8_t adb_data_in[128]; 114 uint8_t adb_data_out[16]; 115 uint8_t adb_autopoll_cmd; 116 }; 117 118 #endif 119