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 DECLARE_INSTANCE_CHECKER(SWIMDrive, SWIM_DRIVE, 26 TYPE_SWIM_DRIVE) 27 28 struct SWIMDrive { 29 DeviceState qdev; 30 int32_t unit; 31 BlockConf conf; 32 }; 33 34 #define TYPE_SWIM_BUS "swim-bus" 35 DECLARE_INSTANCE_CHECKER(SWIMBus, SWIM_BUS, 36 TYPE_SWIM_BUS) 37 38 struct SWIMBus { 39 BusState bus; 40 struct SWIMCtrl *ctrl; 41 }; 42 43 typedef struct FDrive { 44 SWIMCtrl *swimctrl; 45 BlockBackend *blk; 46 BlockConf *conf; 47 } FDrive; 48 49 struct SWIMCtrl { 50 MemoryRegion iomem; 51 FDrive drives[SWIM_MAX_FD]; 52 int mode; 53 /* IWM mode */ 54 int iwm_switch; 55 uint16_t regs[8]; 56 #define IWM_PH0 0 57 #define IWM_PH1 1 58 #define IWM_PH2 2 59 #define IWM_PH3 3 60 #define IWM_MTR 4 61 #define IWM_DRIVE 5 62 #define IWM_Q6 6 63 #define IWM_Q7 7 64 uint8_t iwm_data; 65 uint8_t iwm_mode; 66 /* SWIM mode */ 67 uint8_t swim_phase; 68 uint8_t swim_mode; 69 SWIMBus bus; 70 }; 71 72 #define TYPE_SWIM "swim" 73 typedef struct Swim Swim; 74 DECLARE_INSTANCE_CHECKER(Swim, SWIM, 75 TYPE_SWIM) 76 77 struct Swim { 78 SysBusDevice parent_obj; 79 SWIMCtrl ctrl; 80 }; 81 #endif 82