xref: /openbmc/qemu/include/hw/block/swim.h (revision f0984d40)
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 "hw/block/block.h"
15 #include "hw/sysbus.h"
16 #include "qom/object.h"
17 
18 #define SWIM_MAX_FD            2
19 
20 typedef struct SWIMCtrl SWIMCtrl;
21 
22 #define TYPE_SWIM_DRIVE "swim-drive"
23 OBJECT_DECLARE_SIMPLE_TYPE(SWIMDrive, SWIM_DRIVE)
24 
25 struct SWIMDrive {
26     DeviceState qdev;
27     int32_t     unit;
28     BlockConf   conf;
29 };
30 
31 #define TYPE_SWIM_BUS "swim-bus"
32 OBJECT_DECLARE_SIMPLE_TYPE(SWIMBus, SWIM_BUS)
33 
34 struct SWIMBus {
35     BusState bus;
36     struct SWIMCtrl *ctrl;
37 };
38 
39 typedef struct FDrive {
40     SWIMCtrl *swimctrl;
41     BlockBackend *blk;
42     BlockConf *conf;
43 } FDrive;
44 
45 struct SWIMCtrl {
46     MemoryRegion iomem;
47     FDrive drives[SWIM_MAX_FD];
48     int mode;
49     /* IWM mode */
50     int iwm_switch;
51     uint16_t regs[8];
52 #define IWM_PH0   0
53 #define IWM_PH1   1
54 #define IWM_PH2   2
55 #define IWM_PH3   3
56 #define IWM_MTR   4
57 #define IWM_DRIVE 5
58 #define IWM_Q6    6
59 #define IWM_Q7    7
60     uint8_t iwm_data;
61     uint8_t iwm_mode;
62     /* SWIM mode */
63     uint8_t swim_phase;
64     uint8_t swim_mode;
65     SWIMBus bus;
66 };
67 
68 #define TYPE_SWIM "swim"
69 OBJECT_DECLARE_SIMPLE_TYPE(Swim, SWIM)
70 
71 struct Swim {
72     SysBusDevice parent_obj;
73     SWIMCtrl     ctrl;
74 };
75 #endif
76