2 * QEMU Floppy disk emulator (Intel 82078)
4 * Copyright (c) 2003, 2007 Jocelyn Mayer
5 * Copyright (c) 2008 Hervé Poussineau
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #ifndef HW_BLOCK_FDC_INTERNAL_H
26 #define HW_BLOCK_FDC_INTERNAL_H
28 #include "exec/memory.h"
29 #include "exec/ioport.h"
30 #include "hw/block/block.h"
31 #include "hw/block/fdc.h"
32 #include "qapi/qapi-types-block.h"
34 typedef struct FDCtrl FDCtrl
;
36 /* Floppy bus emulation */
38 typedef struct FloppyBus
{
43 /* Floppy disk drive emulation */
45 typedef enum FDriveRate
{
46 FDRIVE_RATE_500K
= 0x00, /* 500 Kbps */
47 FDRIVE_RATE_300K
= 0x01, /* 300 Kbps */
48 FDRIVE_RATE_250K
= 0x02, /* 250 Kbps */
49 FDRIVE_RATE_1M
= 0x03, /* 1 Mbps */
52 typedef enum FDriveSize
{
58 typedef struct FDFormat
{
59 FloppyDriveType drive
;
66 typedef enum FDiskFlags
{
67 FDISK_DBL_SIDES
= 0x01,
70 typedef struct FDrive
{
75 FloppyDriveType drive
; /* CMOS drive type */
76 uint8_t perpendicular
; /* 2.88 MB access mode */
82 FloppyDriveType disk
; /* Current disk type */
84 uint8_t last_sect
; /* Nb sector per track */
85 uint8_t max_track
; /* Nb of tracks */
86 uint16_t bps
; /* Bytes per sector */
87 uint8_t ro
; /* Is read-only */
88 uint8_t media_changed
; /* Is media changed */
89 uint8_t media_rate
; /* Data rate of medium */
91 bool media_validated
; /* Have we validated the media? */
97 /* Controller state */
98 QEMUTimer
*result_timer
;
102 /* Controller's identification */
108 uint8_t dor_vmstate
; /* only used as temp during vmstate */
123 uint8_t eot
; /* last wanted sector */
124 /* States kept only to be returned back */
125 /* precompensation */
129 /* Power down config (also with status regB access mode */
133 uint8_t num_floppies
;
134 FDrive drives
[MAX_FD
];
136 FloppyDriveType type
;
137 } qdev_for_drives
[MAX_FD
];
139 FloppyDriveType fallback
; /* type=auto failure fallback */
143 PortioList portio_list
;
146 extern const FDFormat fd_formats
[];
147 extern const VMStateDescription vmstate_fdc
;
149 uint32_t fdctrl_read(void *opaque
, uint32_t reg
);
150 void fdctrl_write(void *opaque
, uint32_t reg
, uint32_t value
);
151 void fdctrl_reset(FDCtrl
*fdctrl
, int do_irq
);
152 void fdctrl_realize_common(DeviceState
*dev
, FDCtrl
*fdctrl
, Error
**errp
);
154 int fdctrl_transfer_handler(void *opaque
, int nchan
, int dma_pos
, int dma_len
);
156 void fdctrl_init_drives(FloppyBus
*bus
, DriveInfo
**fds
);