2019-10-26 19:45:40 +03:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011-2018 Laurent Vivier
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HW_MISC_MAC_VIA_H
|
|
|
|
#define HW_MISC_MAC_VIA_H
|
|
|
|
|
|
|
|
#include "exec/memory.h"
|
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/misc/mos6522.h"
|
2023-01-05 00:59:36 +03:00
|
|
|
#include "hw/input/adb.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2019-10-26 19:45:40 +03:00
|
|
|
|
|
|
|
|
2021-08-30 13:24:44 +03:00
|
|
|
#define VIA_SIZE 0x2000
|
|
|
|
|
2019-10-26 19:45:40 +03:00
|
|
|
/* VIA 1 */
|
2022-03-05 18:09:47 +03:00
|
|
|
#define VIA1_IRQ_ONE_SECOND_BIT CA2_INT_BIT
|
|
|
|
#define VIA1_IRQ_60HZ_BIT CA1_INT_BIT
|
|
|
|
#define VIA1_IRQ_ADB_READY_BIT SR_INT_BIT
|
|
|
|
#define VIA1_IRQ_ADB_DATA_BIT CB2_INT_BIT
|
|
|
|
#define VIA1_IRQ_ADB_CLOCK_BIT CB1_INT_BIT
|
2019-10-26 19:45:40 +03:00
|
|
|
|
2022-03-05 18:09:47 +03:00
|
|
|
#define VIA1_IRQ_ONE_SECOND BIT(VIA1_IRQ_ONE_SECOND_BIT)
|
|
|
|
#define VIA1_IRQ_60HZ BIT(VIA1_IRQ_60HZ_BIT)
|
|
|
|
#define VIA1_IRQ_ADB_READY BIT(VIA1_IRQ_ADB_READY_BIT)
|
|
|
|
#define VIA1_IRQ_ADB_DATA BIT(VIA1_IRQ_ADB_DATA_BIT)
|
|
|
|
#define VIA1_IRQ_ADB_CLOCK BIT(VIA1_IRQ_ADB_CLOCK_BIT)
|
2019-10-26 19:45:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
#define TYPE_MOS6522_Q800_VIA1 "mos6522-q800-via1"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA1State, MOS6522_Q800_VIA1)
|
2019-10-26 19:45:40 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct MOS6522Q800VIA1State {
|
2019-10-26 19:45:40 +03:00
|
|
|
/*< private >*/
|
|
|
|
MOS6522State parent_obj;
|
|
|
|
|
2021-08-30 13:24:44 +03:00
|
|
|
MemoryRegion via_mem;
|
|
|
|
|
2021-10-20 16:41:27 +03:00
|
|
|
qemu_irq auxmode_irq;
|
2019-10-26 19:45:40 +03:00
|
|
|
uint8_t last_b;
|
2021-08-30 13:24:38 +03:00
|
|
|
|
|
|
|
/* RTC */
|
2019-10-26 19:45:40 +03:00
|
|
|
uint8_t PRAM[256];
|
2021-08-30 13:24:38 +03:00
|
|
|
BlockBackend *blk;
|
|
|
|
VMChangeStateEntry *vmstate;
|
2019-10-26 19:45:40 +03:00
|
|
|
|
2021-08-30 13:24:39 +03:00
|
|
|
uint32_t tick_offset;
|
|
|
|
|
|
|
|
uint8_t data_out;
|
|
|
|
int data_out_cnt;
|
|
|
|
uint8_t data_in;
|
|
|
|
uint8_t data_in_cnt;
|
|
|
|
uint8_t cmd;
|
|
|
|
int wprotect;
|
|
|
|
int alt;
|
|
|
|
|
2021-08-30 13:24:40 +03:00
|
|
|
/* ADB */
|
|
|
|
ADBBusState adb_bus;
|
|
|
|
qemu_irq adb_data_ready;
|
|
|
|
int adb_data_in_size;
|
|
|
|
int adb_data_in_index;
|
|
|
|
int adb_data_out_index;
|
|
|
|
uint8_t adb_data_in[128];
|
|
|
|
uint8_t adb_data_out[16];
|
|
|
|
uint8_t adb_autopoll_cmd;
|
|
|
|
|
2019-10-26 19:45:40 +03:00
|
|
|
/* external timers */
|
|
|
|
QEMUTimer *one_second_timer;
|
|
|
|
int64_t next_second;
|
2021-03-11 13:05:03 +03:00
|
|
|
QEMUTimer *sixty_hz_timer;
|
|
|
|
int64_t next_sixty_hz;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2019-10-26 19:45:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* VIA 2 */
|
2022-03-05 18:09:48 +03:00
|
|
|
#define VIA2_IRQ_SCSI_DATA_BIT CA2_INT_BIT
|
|
|
|
#define VIA2_IRQ_NUBUS_BIT CA1_INT_BIT
|
|
|
|
#define VIA2_IRQ_SCSI_BIT CB2_INT_BIT
|
|
|
|
#define VIA2_IRQ_ASC_BIT CB1_INT_BIT
|
2019-10-26 19:45:40 +03:00
|
|
|
|
2022-03-05 18:09:48 +03:00
|
|
|
#define VIA2_IRQ_SCSI_DATA BIT(VIA2_IRQ_SCSI_DATA_BIT)
|
|
|
|
#define VIA2_IRQ_NUBUS BIT(VIA2_IRQ_NUBUS_BIT)
|
|
|
|
#define VIA2_IRQ_UNUSED BIT(VIA2_IRQ_SCSI_BIT)
|
|
|
|
#define VIA2_IRQ_SCSI BIT(VIA2_IRQ_UNUSED_BIT)
|
|
|
|
#define VIA2_IRQ_ASC BIT(VIA2_IRQ_ASC_BIT)
|
2019-10-26 19:45:40 +03:00
|
|
|
|
2021-08-30 13:24:47 +03:00
|
|
|
#define VIA2_NUBUS_IRQ_NB 7
|
|
|
|
|
|
|
|
#define VIA2_NUBUS_IRQ_9 0
|
|
|
|
#define VIA2_NUBUS_IRQ_A 1
|
|
|
|
#define VIA2_NUBUS_IRQ_B 2
|
|
|
|
#define VIA2_NUBUS_IRQ_C 3
|
|
|
|
#define VIA2_NUBUS_IRQ_D 4
|
|
|
|
#define VIA2_NUBUS_IRQ_E 5
|
|
|
|
#define VIA2_NUBUS_IRQ_INTVIDEO 6
|
|
|
|
|
2019-10-26 19:45:40 +03:00
|
|
|
#define TYPE_MOS6522_Q800_VIA2 "mos6522-q800-via2"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA2State, MOS6522_Q800_VIA2)
|
2019-10-26 19:45:40 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct MOS6522Q800VIA2State {
|
2019-10-26 19:45:40 +03:00
|
|
|
/*< private >*/
|
|
|
|
MOS6522State parent_obj;
|
|
|
|
|
2021-08-30 13:24:44 +03:00
|
|
|
MemoryRegion via_mem;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2019-10-26 19:45:40 +03:00
|
|
|
|
|
|
|
#endif
|