1 /* 2 * QEMU Macintosh floppy disk controller emulator (SWIM) 3 * 4 * Copyright (c) 2014-2018 Laurent Vivier <laurent@vivier.eu> 5 * 6 * This work is licensed under the terms of the GNU GPL, version 2. See 7 * the COPYING file in the top-level directory. 8 * 9 */ 10 11 #ifndef SWIM_H 12 #define SWIM_H 13 14 #include "qemu/osdep.h" 15 #include "hw/sysbus.h" 16 #include "qom/object.h" 17 18 #define SWIM_MAX_FD 2 19 20 typedef struct SWIMDrive SWIMDrive; 21 typedef struct SWIMBus SWIMBus; 22 typedef struct SWIMCtrl SWIMCtrl; 23 24 #define TYPE_SWIM_DRIVE "swim-drive" 25 #define SWIM_DRIVE(obj) OBJECT_CHECK(SWIMDrive, (obj), TYPE_SWIM_DRIVE) 26 27 struct SWIMDrive { 28 DeviceState qdev; 29 int32_t unit; 30 BlockConf conf; 31 }; 32 33 #define TYPE_SWIM_BUS "swim-bus" 34 #define SWIM_BUS(obj) OBJECT_CHECK(SWIMBus, (obj), TYPE_SWIM_BUS) 35 36 struct SWIMBus { 37 BusState bus; 38 struct SWIMCtrl *ctrl; 39 }; 40 41 typedef struct FDrive { 42 SWIMCtrl *swimctrl; 43 BlockBackend *blk; 44 BlockConf *conf; 45 } FDrive; 46 47 struct SWIMCtrl { 48 MemoryRegion iomem; 49 FDrive drives[SWIM_MAX_FD]; 50 int mode; 51 /* IWM mode */ 52 int iwm_switch; 53 uint16_t regs[8]; 54 #define IWM_PH0 0 55 #define IWM_PH1 1 56 #define IWM_PH2 2 57 #define IWM_PH3 3 58 #define IWM_MTR 4 59 #define IWM_DRIVE 5 60 #define IWM_Q6 6 61 #define IWM_Q7 7 62 uint8_t iwm_data; 63 uint8_t iwm_mode; 64 /* SWIM mode */ 65 uint8_t swim_phase; 66 uint8_t swim_mode; 67 SWIMBus bus; 68 }; 69 70 #define TYPE_SWIM "swim" 71 typedef struct Swim Swim; 72 #define SWIM(obj) OBJECT_CHECK(Swim, (obj), TYPE_SWIM) 73 74 struct Swim { 75 SysBusDevice parent_obj; 76 SWIMCtrl ctrl; 77 }; 78 #endif 79