xref: /qemu/include/hw/block/swim.h (revision 5db05230)
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 iwm_latches;
54     uint8_t iwmregs[8];
55     /* SWIM mode */
56     uint8_t ismregs[16];
57     uint8_t swim_phase;
58     uint8_t swim_mode;
59     uint8_t swim_status;
60     uint8_t pram[16];
61     uint8_t pram_idx;
62     SWIMBus bus;
63 };
64 
65 #define TYPE_SWIM "swim"
66 OBJECT_DECLARE_SIMPLE_TYPE(Swim, SWIM)
67 
68 struct Swim {
69     SysBusDevice parent_obj;
70     SWIMCtrl     ctrl;
71 };
72 #endif
73