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 "hw/block/block.h"
29 #include "hw/block/fdc.h"
30 #include "qapi/qapi-types-block.h"
32 typedef struct FDCtrl FDCtrl
;
34 /* Floppy bus emulation */
36 typedef struct FloppyBus
{
41 /* Floppy disk drive emulation */
43 typedef enum FDriveRate
{
44 FDRIVE_RATE_500K
= 0x00, /* 500 Kbps */
45 FDRIVE_RATE_300K
= 0x01, /* 300 Kbps */
46 FDRIVE_RATE_250K
= 0x02, /* 250 Kbps */
47 FDRIVE_RATE_1M
= 0x03, /* 1 Mbps */
50 typedef enum FDriveSize
{
56 typedef struct FDFormat
{
57 FloppyDriveType drive
;
64 typedef enum FDiskFlags
{
65 FDISK_DBL_SIDES
= 0x01,
68 typedef struct FDrive
{
73 FloppyDriveType drive
; /* CMOS drive type */
74 uint8_t perpendicular
; /* 2.88 MB access mode */
80 FloppyDriveType disk
; /* Current disk type */
82 uint8_t last_sect
; /* Nb sector per track */
83 uint8_t max_track
; /* Nb of tracks */
84 uint16_t bps
; /* Bytes per sector */
85 uint8_t ro
; /* Is read-only */
86 uint8_t media_changed
; /* Is media changed */
87 uint8_t media_rate
; /* Data rate of medium */
89 bool media_validated
; /* Have we validated the media? */
94 /* Controller state */
95 QEMUTimer
*result_timer
;
99 /* Controller's identification */
105 uint8_t dor_vmstate
; /* only used as temp during vmstate */
120 uint8_t eot
; /* last wanted sector */
121 /* States kept only to be returned back */
122 /* precompensation */
126 /* Power down config (also with status regB access mode */
130 uint8_t num_floppies
;
131 FDrive drives
[MAX_FD
];
133 FloppyDriveType type
;
134 } qdev_for_drives
[MAX_FD
];
136 FloppyDriveType fallback
; /* type=auto failure fallback */
142 extern const FDFormat fd_formats
[];
143 extern const VMStateDescription vmstate_fdc
;
145 uint32_t fdctrl_read(void *opaque
, uint32_t reg
);
146 void fdctrl_write(void *opaque
, uint32_t reg
, uint32_t value
);
147 void fdctrl_reset(FDCtrl
*fdctrl
, int do_irq
);
148 void fdctrl_realize_common(DeviceState
*dev
, FDCtrl
*fdctrl
, Error
**errp
);
150 int fdctrl_transfer_handler(void *opaque
, int nchan
, int dma_pos
, int dma_len
);
152 void fdctrl_init_drives(FloppyBus
*bus
, DriveInfo
**fds
);