xref: /openbmc/qemu/include/hw/block/swim.h (revision 57004204)
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 swim;
47     MemoryRegion iwm;
48     MemoryRegion ism;
49     FDrive drives[SWIM_MAX_FD];
50     int mode;
51     /* IWM mode */
52     int iwm_switch;
53     uint8_t iwmregs[16];
54     uint8_t iwm_data;
55     uint8_t iwm_mode;
56     /* SWIM mode */
57     uint8_t ismregs[16];
58     uint8_t swim_phase;
59     uint8_t swim_mode;
60     SWIMBus bus;
61 };
62 
63 #define TYPE_SWIM "swim"
64 OBJECT_DECLARE_SIMPLE_TYPE(Swim, SWIM)
65 
66 struct Swim {
67     SysBusDevice parent_obj;
68     SWIMCtrl     ctrl;
69 };
70 #endif
71