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