Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 1 | // 16bit code to access floppy drives. |
| 2 | // |
Kevin O'Connor | c892b13 | 2009-08-11 21:59:37 -0400 | [diff] [blame] | 3 | // Copyright (C) 2008,2009 Kevin O'Connor <kevin@koconnor.net> |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 4 | // Copyright (C) 2002 MandrakeSoft S.A. |
| 5 | // |
Kevin O'Connor | b1b7c2a | 2009-01-15 20:52:58 -0500 | [diff] [blame] | 6 | // This file may be distributed under the terms of the GNU LGPLv3 license. |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 7 | |
Kevin O'Connor | 9521e26 | 2008-07-04 13:04:29 -0400 | [diff] [blame] | 8 | #include "biosvar.h" // SET_BDA |
Kevin O'Connor | 135f3f6 | 2013-09-14 23:57:26 -0400 | [diff] [blame] | 9 | #include "block.h" // struct drive_s |
Kevin O'Connor | 2d2fa31 | 2013-09-14 21:55:26 -0400 | [diff] [blame] | 10 | #include "bregs.h" // struct bregs |
Kevin O'Connor | 2d2fa31 | 2013-09-14 21:55:26 -0400 | [diff] [blame] | 11 | #include "config.h" // CONFIG_FLOPPY |
Kevin O'Connor | 9dea590 | 2013-09-14 20:23:54 -0400 | [diff] [blame] | 12 | #include "malloc.h" // malloc_fseg |
Kevin O'Connor | 2d2fa31 | 2013-09-14 21:55:26 -0400 | [diff] [blame] | 13 | #include "output.h" // dprintf |
Kevin O'Connor | 4d8510c | 2016-02-03 01:28:20 -0500 | [diff] [blame] | 14 | #include "pcidevice.h" // pci_find_class |
Kevin O'Connor | 031ef55 | 2010-12-27 19:26:57 -0500 | [diff] [blame] | 15 | #include "pci_ids.h" // PCI_CLASS_BRIDGE_ISA |
Kevin O'Connor | 2d2fa31 | 2013-09-14 21:55:26 -0400 | [diff] [blame] | 16 | #include "pic.h" // pic_eoi1 |
Kevin O'Connor | 41639f8 | 2013-09-14 19:37:36 -0400 | [diff] [blame] | 17 | #include "romfile.h" // romfile_loadint |
Kevin O'Connor | 8b7861c | 2013-09-15 02:29:06 -0400 | [diff] [blame] | 18 | #include "rtc.h" // rtc_read |
Kevin O'Connor | 3df600b | 2013-09-14 19:28:55 -0400 | [diff] [blame] | 19 | #include "stacks.h" // yield |
Kevin O'Connor | 135f3f6 | 2013-09-14 23:57:26 -0400 | [diff] [blame] | 20 | #include "std/disk.h" // DISK_RET_SUCCESS |
Kevin O'Connor | fa9c66a | 2013-09-14 19:10:40 -0400 | [diff] [blame] | 21 | #include "string.h" // memset |
Kevin O'Connor | 2d2fa31 | 2013-09-14 21:55:26 -0400 | [diff] [blame] | 22 | #include "util.h" // timer_calc |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 23 | |
Kevin O'Connor | 4ade523 | 2013-09-18 21:41:48 -0400 | [diff] [blame] | 24 | #define PORT_FD_BASE 0x03f0 |
| 25 | #define PORT_FD_DOR 0x03f2 |
| 26 | #define PORT_FD_STATUS 0x03f4 |
| 27 | #define PORT_FD_DATA 0x03f5 |
| 28 | #define PORT_FD_DIR 0x03f7 |
| 29 | |
Kevin O'Connor | 7b184d8 | 2009-08-23 11:56:55 -0400 | [diff] [blame] | 30 | #define FLOPPY_SIZE_CODE 0x02 // 512 byte sectors |
| 31 | #define FLOPPY_DATALEN 0xff // Not used - because size code is 0x02 |
| 32 | #define FLOPPY_MOTOR_TICKS 37 // ~2 seconds |
| 33 | #define FLOPPY_FILLBYTE 0xf6 |
| 34 | #define FLOPPY_GAPLEN 0x1B |
| 35 | #define FLOPPY_FORMAT_GAPLEN 0x6c |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 36 | #define FLOPPY_PIO_TIMEOUT 1000 |
Nikolay Nikolov | 4a6dbce | 2018-02-04 17:27:01 +0200 | [diff] [blame] | 37 | #define FLOPPY_IRQ_TIMEOUT 5000 |
Nikolay Nikolov | f9cc969 | 2018-02-10 13:52:14 +0200 | [diff] [blame] | 38 | #define FLOPPY_SPECIFY1 0xAF // step rate 12ms, head unload 240ms |
| 39 | #define FLOPPY_SPECIFY2 0x02 // head load time 4ms, DMA used |
Nikolay Nikolov | 2611db4 | 2018-02-10 13:52:16 +0200 | [diff] [blame^] | 40 | #define FLOPPY_STARTUP_TIME 8 // 1 second |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 41 | |
Nikolay Nikolov | 53fc631 | 2018-02-04 17:26:58 +0200 | [diff] [blame] | 42 | #define FLOPPY_DOR_MOTOR_D 0x80 // Set to turn drive 3's motor ON |
| 43 | #define FLOPPY_DOR_MOTOR_C 0x40 // Set to turn drive 2's motor ON |
| 44 | #define FLOPPY_DOR_MOTOR_B 0x20 // Set to turn drive 1's motor ON |
| 45 | #define FLOPPY_DOR_MOTOR_A 0x10 // Set to turn drive 0's motor ON |
| 46 | #define FLOPPY_DOR_MOTOR_MASK 0xf0 |
| 47 | #define FLOPPY_DOR_IRQ 0x08 // Set to enable IRQs and DMA |
| 48 | #define FLOPPY_DOR_RESET 0x04 // Clear = enter reset mode, Set = normal operation |
| 49 | #define FLOPPY_DOR_DSEL_MASK 0x03 // "Select" drive number for next access |
| 50 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 51 | // New diskette parameter table adding 3 parameters from IBM |
| 52 | // Since no provisions are made for multiple drive types, most |
| 53 | // values in this table are ignored. I set parameters for 1.44M |
| 54 | // floppy here |
Kevin O'Connor | 89a2f96 | 2013-02-18 23:36:03 -0500 | [diff] [blame] | 55 | struct floppy_ext_dbt_s diskette_param_table2 VARFSEG = { |
Kevin O'Connor | 44c631d | 2008-03-02 11:24:36 -0500 | [diff] [blame] | 56 | .dbt = { |
Nikolay Nikolov | f9cc969 | 2018-02-10 13:52:14 +0200 | [diff] [blame] | 57 | .specify1 = FLOPPY_SPECIFY1, |
| 58 | .specify2 = FLOPPY_SPECIFY2, |
Kevin O'Connor | 7b184d8 | 2009-08-23 11:56:55 -0400 | [diff] [blame] | 59 | .shutoff_ticks = FLOPPY_MOTOR_TICKS, // ~2 seconds |
| 60 | .bps_code = FLOPPY_SIZE_CODE, |
Kevin O'Connor | 44c631d | 2008-03-02 11:24:36 -0500 | [diff] [blame] | 61 | .sectors = 18, |
Kevin O'Connor | 7b184d8 | 2009-08-23 11:56:55 -0400 | [diff] [blame] | 62 | .interblock_len = FLOPPY_GAPLEN, |
| 63 | .data_len = FLOPPY_DATALEN, |
| 64 | .gap_len = FLOPPY_FORMAT_GAPLEN, |
| 65 | .fill_byte = FLOPPY_FILLBYTE, |
| 66 | .settle_time = 0x0F, // 15ms |
Nikolay Nikolov | 2611db4 | 2018-02-10 13:52:16 +0200 | [diff] [blame^] | 67 | .startup_time = FLOPPY_STARTUP_TIME, |
Kevin O'Connor | 44c631d | 2008-03-02 11:24:36 -0500 | [diff] [blame] | 68 | }, |
| 69 | .max_track = 79, // maximum track |
| 70 | .data_rate = 0, // data transfer rate |
| 71 | .drive_type = 4, // drive type in cmos |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 72 | }; |
| 73 | |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 74 | struct floppyinfo_s { |
| 75 | struct chs_s chs; |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 76 | u8 floppy_size; |
| 77 | u8 data_rate; |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 78 | }; |
| 79 | |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 80 | #define FLOPPY_SIZE_525 0x01 |
| 81 | #define FLOPPY_SIZE_350 0x02 |
| 82 | |
| 83 | #define FLOPPY_RATE_500K 0x00 |
| 84 | #define FLOPPY_RATE_300K 0x01 |
| 85 | #define FLOPPY_RATE_250K 0x02 |
| 86 | #define FLOPPY_RATE_1M 0x03 |
| 87 | |
Kevin O'Connor | 89a2f96 | 2013-02-18 23:36:03 -0500 | [diff] [blame] | 88 | struct floppyinfo_s FloppyInfo[] VARFSEG = { |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 89 | // Unknown |
| 90 | { {0, 0, 0}, 0x00, 0x00}, |
| 91 | // 1 - 360KB, 5.25" - 2 heads, 40 tracks, 9 sectors |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 92 | { {2, 40, 9}, FLOPPY_SIZE_525, FLOPPY_RATE_300K}, |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 93 | // 2 - 1.2MB, 5.25" - 2 heads, 80 tracks, 15 sectors |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 94 | { {2, 80, 15}, FLOPPY_SIZE_525, FLOPPY_RATE_500K}, |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 95 | // 3 - 720KB, 3.5" - 2 heads, 80 tracks, 9 sectors |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 96 | { {2, 80, 9}, FLOPPY_SIZE_350, FLOPPY_RATE_250K}, |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 97 | // 4 - 1.44MB, 3.5" - 2 heads, 80 tracks, 18 sectors |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 98 | { {2, 80, 18}, FLOPPY_SIZE_350, FLOPPY_RATE_500K}, |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 99 | // 5 - 2.88MB, 3.5" - 2 heads, 80 tracks, 36 sectors |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 100 | { {2, 80, 36}, FLOPPY_SIZE_350, FLOPPY_RATE_1M}, |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 101 | // 6 - 160k, 5.25" - 1 heads, 40 tracks, 8 sectors |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 102 | { {1, 40, 8}, FLOPPY_SIZE_525, FLOPPY_RATE_250K}, |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 103 | // 7 - 180k, 5.25" - 1 heads, 40 tracks, 9 sectors |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 104 | { {1, 40, 9}, FLOPPY_SIZE_525, FLOPPY_RATE_300K}, |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 105 | // 8 - 320k, 5.25" - 2 heads, 40 tracks, 8 sectors |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 106 | { {2, 40, 8}, FLOPPY_SIZE_525, FLOPPY_RATE_250K}, |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 107 | }; |
| 108 | |
Kevin O'Connor | 77d227b | 2009-10-22 21:48:39 -0400 | [diff] [blame] | 109 | struct drive_s * |
Kevin O'Connor | ca2bc1c | 2010-12-29 21:41:19 -0500 | [diff] [blame] | 110 | init_floppy(int floppyid, int ftype) |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 111 | { |
| 112 | if (ftype <= 0 || ftype >= ARRAY_SIZE(FloppyInfo)) { |
| 113 | dprintf(1, "Bad floppy type %d\n", ftype); |
Kevin O'Connor | 77d227b | 2009-10-22 21:48:39 -0400 | [diff] [blame] | 114 | return NULL; |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 115 | } |
| 116 | |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 117 | struct drive_s *drive = malloc_fseg(sizeof(*drive)); |
| 118 | if (!drive) { |
Kevin O'Connor | d7e998f | 2010-02-15 22:48:28 -0500 | [diff] [blame] | 119 | warn_noalloc(); |
Kevin O'Connor | 77d227b | 2009-10-22 21:48:39 -0400 | [diff] [blame] | 120 | return NULL; |
Kevin O'Connor | d7e998f | 2010-02-15 22:48:28 -0500 | [diff] [blame] | 121 | } |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 122 | memset(drive, 0, sizeof(*drive)); |
| 123 | drive->cntl_id = floppyid; |
| 124 | drive->type = DTYPE_FLOPPY; |
| 125 | drive->blksize = DISK_SECTOR_SIZE; |
| 126 | drive->floppy_type = ftype; |
| 127 | drive->sectors = (u64)-1; |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 128 | |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 129 | memcpy(&drive->lchs, &FloppyInfo[ftype].chs |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 130 | , sizeof(FloppyInfo[ftype].chs)); |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 131 | return drive; |
Kevin O'Connor | ca2bc1c | 2010-12-29 21:41:19 -0500 | [diff] [blame] | 132 | } |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 133 | |
Kevin O'Connor | ca2bc1c | 2010-12-29 21:41:19 -0500 | [diff] [blame] | 134 | static void |
| 135 | addFloppy(int floppyid, int ftype) |
| 136 | { |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 137 | struct drive_s *drive = init_floppy(floppyid, ftype); |
| 138 | if (!drive) |
Kevin O'Connor | ca2bc1c | 2010-12-29 21:41:19 -0500 | [diff] [blame] | 139 | return; |
| 140 | char *desc = znprintf(MAXDESCSIZE, "Floppy [drive %c]", 'A' + floppyid); |
Kevin O'Connor | 0cd7005 | 2011-07-02 14:04:19 -0400 | [diff] [blame] | 141 | struct pci_device *pci = pci_find_class(PCI_CLASS_BRIDGE_ISA); /* isa-to-pci bridge */ |
Kevin O'Connor | 03e589c | 2011-07-09 14:35:37 -0400 | [diff] [blame] | 142 | int prio = bootprio_find_fdc_device(pci, PORT_FD_BASE, floppyid); |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 143 | boot_add_floppy(drive, desc, prio); |
Kevin O'Connor | 51fd0a1 | 2009-09-12 13:20:14 -0400 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | void |
Kevin O'Connor | 1ca05b0 | 2010-01-03 17:43:37 -0500 | [diff] [blame] | 147 | floppy_setup(void) |
Kevin O'Connor | 3bbcc14 | 2008-04-13 17:07:33 -0400 | [diff] [blame] | 148 | { |
Kevin O'Connor | ef71989 | 2012-11-26 11:14:00 -0500 | [diff] [blame] | 149 | memcpy(&diskette_param_table, &diskette_param_table2 |
| 150 | , sizeof(diskette_param_table)); |
| 151 | SET_IVT(0x1E, SEGOFF(SEG_BIOS |
| 152 | , (u32)&diskette_param_table2 - BUILD_BIOS_ADDR)); |
| 153 | |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 154 | if (! CONFIG_FLOPPY) |
Kevin O'Connor | f54c150 | 2008-06-14 15:56:16 -0400 | [diff] [blame] | 155 | return; |
Kevin O'Connor | 35192dd | 2008-06-08 19:18:33 -0400 | [diff] [blame] | 156 | dprintf(3, "init floppy drives\n"); |
Kevin O'Connor | 88c00ee | 2008-05-18 00:14:13 -0400 | [diff] [blame] | 157 | |
Kevin O'Connor | 897fb11 | 2013-02-07 23:32:48 -0500 | [diff] [blame] | 158 | if (CONFIG_QEMU) { |
Kevin O'Connor | 8b7861c | 2013-09-15 02:29:06 -0400 | [diff] [blame] | 159 | u8 type = rtc_read(CMOS_FLOPPY_DRIVE_TYPE); |
Kevin O'Connor | 897fb11 | 2013-02-07 23:32:48 -0500 | [diff] [blame] | 160 | if (type & 0xf0) |
| 161 | addFloppy(0, type >> 4); |
| 162 | if (type & 0x0f) |
| 163 | addFloppy(1, type & 0x0f); |
| 164 | } else { |
Kevin O'Connor | 8b73b83 | 2012-11-26 11:18:11 -0500 | [diff] [blame] | 165 | u8 type = romfile_loadint("etc/floppy0", 0); |
| 166 | if (type) |
| 167 | addFloppy(0, type); |
| 168 | type = romfile_loadint("etc/floppy1", 0); |
| 169 | if (type) |
| 170 | addFloppy(1, type); |
Kevin O'Connor | 88c00ee | 2008-05-18 00:14:13 -0400 | [diff] [blame] | 171 | } |
Kevin O'Connor | 88c00ee | 2008-05-18 00:14:13 -0400 | [diff] [blame] | 172 | |
Kevin O'Connor | cc9e1bf | 2010-07-28 21:31:38 -0400 | [diff] [blame] | 173 | enable_hwirq(6, FUNC16(entry_0e)); |
Kevin O'Connor | 3bbcc14 | 2008-04-13 17:07:33 -0400 | [diff] [blame] | 174 | } |
| 175 | |
Kevin O'Connor | a3855ad | 2009-08-16 21:59:40 -0400 | [diff] [blame] | 176 | // Find a floppy type that matches a given image size. |
| 177 | int |
| 178 | find_floppy_type(u32 size) |
| 179 | { |
| 180 | int i; |
| 181 | for (i=1; i<ARRAY_SIZE(FloppyInfo); i++) { |
| 182 | struct chs_s *c = &FloppyInfo[i].chs; |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 183 | if (c->cylinder * c->head * c->sector * DISK_SECTOR_SIZE == size) |
Kevin O'Connor | a3855ad | 2009-08-16 21:59:40 -0400 | [diff] [blame] | 184 | return i; |
| 185 | } |
| 186 | return -1; |
| 187 | } |
| 188 | |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 189 | |
| 190 | /**************************************************************** |
| 191 | * Low-level floppy IO |
| 192 | ****************************************************************/ |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 193 | |
Kevin O'Connor | 402f9a4 | 2013-12-07 12:48:11 -0500 | [diff] [blame] | 194 | u8 FloppyDOR VARLOW; |
| 195 | |
Nikolay Nikolov | 3ddb42f | 2018-02-04 17:26:56 +0200 | [diff] [blame] | 196 | static inline u8 |
| 197 | floppy_dor_read(void) |
| 198 | { |
| 199 | return GET_LOW(FloppyDOR); |
| 200 | } |
| 201 | |
Kevin O'Connor | 402f9a4 | 2013-12-07 12:48:11 -0500 | [diff] [blame] | 202 | static inline void |
| 203 | floppy_dor_write(u8 val) |
| 204 | { |
| 205 | outb(val, PORT_FD_DOR); |
| 206 | SET_LOW(FloppyDOR, val); |
| 207 | } |
| 208 | |
Nikolay Nikolov | 5157a78 | 2018-02-04 17:26:57 +0200 | [diff] [blame] | 209 | static inline void |
| 210 | floppy_dor_mask(u8 off, u8 on) |
| 211 | { |
| 212 | floppy_dor_write((floppy_dor_read() & ~off) | on); |
| 213 | } |
| 214 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 215 | static void |
Kevin O'Connor | 6e529bd | 2013-03-02 20:30:50 -0500 | [diff] [blame] | 216 | floppy_disable_controller(void) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 217 | { |
Kevin O'Connor | 402f9a4 | 2013-12-07 12:48:11 -0500 | [diff] [blame] | 218 | dprintf(2, "Floppy_disable_controller\n"); |
Nikolay Nikolov | 53d82f0 | 2018-02-04 17:26:59 +0200 | [diff] [blame] | 219 | // Clear the reset bit (enter reset state) and clear 'enable IRQ and DMA' |
| 220 | floppy_dor_mask(FLOPPY_DOR_IRQ | FLOPPY_DOR_RESET, 0); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 221 | } |
| 222 | |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 223 | static int |
Kevin O'Connor | 6e529bd | 2013-03-02 20:30:50 -0500 | [diff] [blame] | 224 | floppy_wait_irq(void) |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 225 | { |
Kevin O'Connor | 6e529bd | 2013-03-02 20:30:50 -0500 | [diff] [blame] | 226 | u8 frs = GET_BDA(floppy_recalibration_status); |
| 227 | SET_BDA(floppy_recalibration_status, frs & ~FRS_IRQ); |
Nikolay Nikolov | 4a6dbce | 2018-02-04 17:27:01 +0200 | [diff] [blame] | 228 | u32 end = timer_calc(FLOPPY_IRQ_TIMEOUT); |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 229 | for (;;) { |
Nikolay Nikolov | 4a6dbce | 2018-02-04 17:27:01 +0200 | [diff] [blame] | 230 | if (timer_check(end)) { |
Kevin O'Connor | b66456c | 2013-12-04 10:31:51 -0500 | [diff] [blame] | 231 | warn_timeout(); |
Kevin O'Connor | 6e529bd | 2013-03-02 20:30:50 -0500 | [diff] [blame] | 232 | floppy_disable_controller(); |
| 233 | return DISK_RET_ETIMEOUT; |
| 234 | } |
Kevin O'Connor | e51316d | 2012-06-10 09:09:22 -0400 | [diff] [blame] | 235 | frs = GET_BDA(floppy_recalibration_status); |
Kevin O'Connor | 6e529bd | 2013-03-02 20:30:50 -0500 | [diff] [blame] | 236 | if (frs & FRS_IRQ) |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 237 | break; |
Kevin O'Connor | 94c749c | 2012-05-28 11:44:02 -0400 | [diff] [blame] | 238 | // Could use yield_toirq() here, but that causes issues on |
Kevin O'Connor | 7a98fd0 | 2010-01-17 13:00:49 -0500 | [diff] [blame] | 239 | // bochs, so use yield() instead. |
| 240 | yield(); |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 241 | } |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 242 | |
Kevin O'Connor | 6e529bd | 2013-03-02 20:30:50 -0500 | [diff] [blame] | 243 | SET_BDA(floppy_recalibration_status, frs & ~FRS_IRQ); |
| 244 | return DISK_RET_SUCCESS; |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 245 | } |
| 246 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 247 | // Floppy commands |
| 248 | #define FCF_WAITIRQ 0x10000 |
| 249 | #define FC_CHECKIRQ (0x08 | (0<<8) | (2<<12)) |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 250 | #define FC_SEEK (0x0f | (2<<8) | (0<<12) | FCF_WAITIRQ) |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 251 | #define FC_RECALIBRATE (0x07 | (1<<8) | (0<<12) | FCF_WAITIRQ) |
| 252 | #define FC_READID (0x4a | (1<<8) | (7<<12) | FCF_WAITIRQ) |
| 253 | #define FC_READ (0xe6 | (8<<8) | (7<<12) | FCF_WAITIRQ) |
| 254 | #define FC_WRITE (0xc5 | (8<<8) | (7<<12) | FCF_WAITIRQ) |
| 255 | #define FC_FORMAT (0x4d | (5<<8) | (7<<12) | FCF_WAITIRQ) |
Nikolay Nikolov | f9cc969 | 2018-02-10 13:52:14 +0200 | [diff] [blame] | 256 | #define FC_SPECIFY (0x03 | (2<<8) | (0<<12)) |
Kevin O'Connor | 9ba374c | 2013-03-02 18:37:04 -0500 | [diff] [blame] | 257 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 258 | // Send the specified command and it's parameters to the floppy controller. |
Kevin O'Connor | a68aeaf | 2008-07-07 21:37:10 -0400 | [diff] [blame] | 259 | static int |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 260 | floppy_pio(int command, u8 *param) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 261 | { |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 262 | dprintf(9, "Floppy pio command %x\n", command); |
| 263 | // Send command and parameters to controller. |
Kevin O'Connor | 018bdd7 | 2013-07-20 18:22:57 -0400 | [diff] [blame] | 264 | u32 end = timer_calc(FLOPPY_PIO_TIMEOUT); |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 265 | int send = (command >> 8) & 0xf; |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 266 | int i = 0; |
| 267 | for (;;) { |
| 268 | u8 sts = inb(PORT_FD_STATUS); |
| 269 | if (!(sts & 0x80)) { |
Kevin O'Connor | 018bdd7 | 2013-07-20 18:22:57 -0400 | [diff] [blame] | 270 | if (timer_check(end)) { |
Kevin O'Connor | b66456c | 2013-12-04 10:31:51 -0500 | [diff] [blame] | 271 | warn_timeout(); |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 272 | floppy_disable_controller(); |
| 273 | return DISK_RET_ETIMEOUT; |
| 274 | } |
Kevin O'Connor | ca08777 | 2014-11-29 13:04:46 -0500 | [diff] [blame] | 275 | yield(); |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 276 | continue; |
| 277 | } |
| 278 | if (sts & 0x40) { |
| 279 | floppy_disable_controller(); |
| 280 | return DISK_RET_ECONTROLLER; |
| 281 | } |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 282 | if (i == 0) |
| 283 | outb(command & 0xff, PORT_FD_DATA); |
| 284 | else |
| 285 | outb(param[i-1], PORT_FD_DATA); |
| 286 | if (i++ >= send) |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 287 | break; |
| 288 | } |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 289 | |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 290 | // Wait for command to complete. |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 291 | if (command & FCF_WAITIRQ) { |
Kevin O'Connor | 6e529bd | 2013-03-02 20:30:50 -0500 | [diff] [blame] | 292 | int ret = floppy_wait_irq(); |
| 293 | if (ret) |
| 294 | return ret; |
Kevin O'Connor | 06ad44e | 2008-04-05 19:30:02 -0400 | [diff] [blame] | 295 | } |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 296 | |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 297 | // Read response from controller. |
Kevin O'Connor | 018bdd7 | 2013-07-20 18:22:57 -0400 | [diff] [blame] | 298 | end = timer_calc(FLOPPY_PIO_TIMEOUT); |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 299 | int receive = (command >> 12) & 0xf; |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 300 | i = 0; |
| 301 | for (;;) { |
| 302 | u8 sts = inb(PORT_FD_STATUS); |
| 303 | if (!(sts & 0x80)) { |
Kevin O'Connor | 018bdd7 | 2013-07-20 18:22:57 -0400 | [diff] [blame] | 304 | if (timer_check(end)) { |
Kevin O'Connor | b66456c | 2013-12-04 10:31:51 -0500 | [diff] [blame] | 305 | warn_timeout(); |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 306 | floppy_disable_controller(); |
| 307 | return DISK_RET_ETIMEOUT; |
| 308 | } |
Kevin O'Connor | ca08777 | 2014-11-29 13:04:46 -0500 | [diff] [blame] | 309 | yield(); |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 310 | continue; |
| 311 | } |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 312 | if (i >= receive) { |
| 313 | if (sts & 0x40) { |
| 314 | floppy_disable_controller(); |
| 315 | return DISK_RET_ECONTROLLER; |
| 316 | } |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 317 | break; |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 318 | } |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 319 | if (!(sts & 0x40)) { |
| 320 | floppy_disable_controller(); |
| 321 | return DISK_RET_ECONTROLLER; |
| 322 | } |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 323 | param[i++] = inb(PORT_FD_DATA); |
Kevin O'Connor | 068cb4f | 2013-03-03 11:05:19 -0500 | [diff] [blame] | 324 | } |
Kevin O'Connor | 9ba374c | 2013-03-02 18:37:04 -0500 | [diff] [blame] | 325 | |
| 326 | return DISK_RET_SUCCESS; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 327 | } |
| 328 | |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 329 | static int |
| 330 | floppy_enable_controller(void) |
| 331 | { |
Kevin O'Connor | 402f9a4 | 2013-12-07 12:48:11 -0500 | [diff] [blame] | 332 | dprintf(2, "Floppy_enable_controller\n"); |
Nikolay Nikolov | 53d82f0 | 2018-02-04 17:26:59 +0200 | [diff] [blame] | 333 | // Clear the reset bit (enter reset state), but set 'enable IRQ and DMA' |
| 334 | floppy_dor_mask(FLOPPY_DOR_RESET, FLOPPY_DOR_IRQ); |
Nikolay Nikolov | b00a03a | 2018-02-10 13:52:13 +0200 | [diff] [blame] | 335 | // Real hardware needs a 4 microsecond delay |
| 336 | usleep(4); |
Nikolay Nikolov | 53d82f0 | 2018-02-04 17:26:59 +0200 | [diff] [blame] | 337 | // Set the reset bit (normal operation) and keep 'enable IRQ and DMA' on |
| 338 | floppy_dor_mask(0, FLOPPY_DOR_IRQ | FLOPPY_DOR_RESET); |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 339 | int ret = floppy_wait_irq(); |
| 340 | if (ret) |
| 341 | return ret; |
| 342 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 343 | u8 param[2]; |
| 344 | return floppy_pio(FC_CHECKIRQ, param); |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 345 | } |
| 346 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 347 | // Activate a drive and send a command to it. |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 348 | static int |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 349 | floppy_drive_pio(u8 floppyid, int command, u8 *param) |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 350 | { |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 351 | // Enable controller if it isn't running. |
Nikolay Nikolov | 53fc631 | 2018-02-04 17:26:58 +0200 | [diff] [blame] | 352 | if (!(floppy_dor_read() & FLOPPY_DOR_RESET)) { |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 353 | int ret = floppy_enable_controller(); |
| 354 | if (ret) |
| 355 | return ret; |
| 356 | } |
| 357 | |
Nikolay Nikolov | 4a6dbce | 2018-02-04 17:27:01 +0200 | [diff] [blame] | 358 | // set the disk motor timeout value of INT 08 to the highest value |
| 359 | SET_BDA(floppy_motor_counter, 255); |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 360 | |
Nikolay Nikolov | 2611db4 | 2018-02-10 13:52:16 +0200 | [diff] [blame^] | 361 | // Check if the motor is already running |
| 362 | u8 motor_mask = FLOPPY_DOR_MOTOR_A << floppyid; |
| 363 | int motor_already_running = floppy_dor_read() & motor_mask; |
| 364 | |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 365 | // Turn on motor of selected drive, DMA & int enabled, normal operation |
Nikolay Nikolov | 2611db4 | 2018-02-10 13:52:16 +0200 | [diff] [blame^] | 366 | floppy_dor_write(motor_mask | FLOPPY_DOR_IRQ | FLOPPY_DOR_RESET | floppyid); |
| 367 | |
| 368 | // If the motor was just started, wait for it to get up to speed |
| 369 | if (!motor_already_running && !CONFIG_QEMU) |
| 370 | msleep(FLOPPY_STARTUP_TIME * 125); |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 371 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 372 | // Send command. |
| 373 | int ret = floppy_pio(command, param); |
Nikolay Nikolov | 488ede2 | 2018-02-04 17:27:00 +0200 | [diff] [blame] | 374 | SET_BDA(floppy_motor_counter, FLOPPY_MOTOR_TICKS); // reset motor timeout |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 375 | if (ret) |
| 376 | return ret; |
| 377 | |
| 378 | // Check IRQ command is needed after irq commands with no results |
| 379 | if ((command & FCF_WAITIRQ) && ((command >> 12) & 0xf) == 0) |
| 380 | return floppy_pio(FC_CHECKIRQ, param); |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 381 | return DISK_RET_SUCCESS; |
| 382 | } |
| 383 | |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 384 | |
| 385 | /**************************************************************** |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 386 | * Floppy media sense and seeking |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 387 | ****************************************************************/ |
| 388 | |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 389 | static int |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 390 | floppy_drive_recal(u8 floppyid) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 391 | { |
Kevin O'Connor | 402f9a4 | 2013-12-07 12:48:11 -0500 | [diff] [blame] | 392 | dprintf(2, "Floppy_drive_recal %d\n", floppyid); |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 393 | // send Recalibrate command to controller |
| 394 | u8 param[2]; |
| 395 | param[0] = floppyid; |
| 396 | int ret = floppy_drive_pio(floppyid, FC_RECALIBRATE, param); |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 397 | if (ret) |
| 398 | return ret; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 399 | |
Kevin O'Connor | e51316d | 2012-06-10 09:09:22 -0400 | [diff] [blame] | 400 | u8 frs = GET_BDA(floppy_recalibration_status); |
| 401 | SET_BDA(floppy_recalibration_status, frs | (1<<floppyid)); |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 402 | SET_BDA(floppy_track[floppyid], 0); |
Kevin O'Connor | 1f711d2 | 2013-03-02 21:26:54 -0500 | [diff] [blame] | 403 | return DISK_RET_SUCCESS; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 404 | } |
| 405 | |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 406 | static int |
Nikolay Nikolov | f9cc969 | 2018-02-10 13:52:14 +0200 | [diff] [blame] | 407 | floppy_drive_specify(void) |
| 408 | { |
| 409 | u8 param[2]; |
| 410 | param[0] = FLOPPY_SPECIFY1; |
| 411 | param[1] = FLOPPY_SPECIFY2; |
| 412 | return floppy_pio(FC_SPECIFY, param); |
| 413 | } |
| 414 | |
| 415 | static int |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 416 | floppy_drive_readid(u8 floppyid, u8 data_rate, u8 head) |
| 417 | { |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 418 | // Set data rate. |
| 419 | outb(data_rate, PORT_FD_DIR); |
| 420 | |
| 421 | // send Read Sector Id command |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 422 | u8 param[7]; |
| 423 | param[0] = (head << 2) | floppyid; // HD DR1 DR2 |
| 424 | int ret = floppy_drive_pio(floppyid, FC_READID, param); |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 425 | if (ret) |
| 426 | return ret; |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 427 | if (param[0] & 0xc0) |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 428 | return -1; |
| 429 | return 0; |
| 430 | } |
| 431 | |
| 432 | static int |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 433 | floppy_media_sense(struct drive_s *drive_gf) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 434 | { |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 435 | u8 ftype = GET_GLOBALFLAT(drive_gf->floppy_type), stype = ftype; |
| 436 | u8 floppyid = GET_GLOBALFLAT(drive_gf->cntl_id); |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 437 | |
| 438 | u8 data_rate = GET_GLOBAL(FloppyInfo[stype].data_rate); |
| 439 | int ret = floppy_drive_readid(floppyid, data_rate, 0); |
| 440 | if (ret) { |
| 441 | // Attempt media sense. |
| 442 | for (stype=1; ; stype++) { |
| 443 | if (stype >= ARRAY_SIZE(FloppyInfo)) |
| 444 | return DISK_RET_EMEDIA; |
| 445 | if (stype==ftype |
| 446 | || (GET_GLOBAL(FloppyInfo[stype].floppy_size) |
| 447 | != GET_GLOBAL(FloppyInfo[ftype].floppy_size)) |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 448 | || (GET_GLOBAL(FloppyInfo[stype].chs.head) |
| 449 | > GET_GLOBAL(FloppyInfo[ftype].chs.head)) |
| 450 | || (GET_GLOBAL(FloppyInfo[stype].chs.cylinder) |
| 451 | > GET_GLOBAL(FloppyInfo[ftype].chs.cylinder)) |
| 452 | || (GET_GLOBAL(FloppyInfo[stype].chs.sector) |
| 453 | > GET_GLOBAL(FloppyInfo[ftype].chs.sector))) |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 454 | continue; |
| 455 | data_rate = GET_GLOBAL(FloppyInfo[stype].data_rate); |
| 456 | ret = floppy_drive_readid(floppyid, data_rate, 0); |
| 457 | if (!ret) |
| 458 | break; |
| 459 | } |
| 460 | } |
Kevin O'Connor | 402f9a4 | 2013-12-07 12:48:11 -0500 | [diff] [blame] | 461 | dprintf(2, "Floppy_media_sense on drive %d found rate %d\n" |
| 462 | , floppyid, data_rate); |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 463 | |
| 464 | u8 old_data_rate = GET_BDA(floppy_media_state[floppyid]) >> 6; |
| 465 | SET_BDA(floppy_last_data_rate, (old_data_rate<<2) | (data_rate<<6)); |
| 466 | u8 media = (stype == 1 ? 0x04 : (stype == 2 ? 0x05 : 0x07)); |
| 467 | u8 fms = (data_rate<<6) | FMS_MEDIA_DRIVE_ESTABLISHED | media; |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 468 | if (GET_GLOBAL(FloppyInfo[stype].chs.cylinder) |
| 469 | < GET_GLOBAL(FloppyInfo[ftype].chs.cylinder)) |
Kevin O'Connor | e7c5a7e | 2013-03-03 13:59:58 -0500 | [diff] [blame] | 470 | fms |= FMS_DOUBLE_STEPPING; |
| 471 | SET_BDA(floppy_media_state[floppyid], fms); |
| 472 | |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 473 | return DISK_RET_SUCCESS; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 474 | } |
| 475 | |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 476 | // Prepare a floppy for a data transfer. |
Kevin O'Connor | a68aeaf | 2008-07-07 21:37:10 -0400 | [diff] [blame] | 477 | static int |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 478 | floppy_prep(struct drive_s *drive_gf, u8 cylinder) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 479 | { |
Kevin O'Connor | 1902c94 | 2013-10-26 11:48:06 -0400 | [diff] [blame] | 480 | u8 floppyid = GET_GLOBALFLAT(drive_gf->cntl_id); |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 481 | if (!(GET_BDA(floppy_recalibration_status) & (1<<floppyid)) || |
| 482 | !(GET_BDA(floppy_media_state[floppyid]) & FMS_MEDIA_DRIVE_ESTABLISHED)) { |
| 483 | // Recalibrate drive. |
| 484 | int ret = floppy_drive_recal(floppyid); |
| 485 | if (ret) |
| 486 | return ret; |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 487 | |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 488 | // Sense media. |
| 489 | ret = floppy_media_sense(drive_gf); |
| 490 | if (ret) |
| 491 | return ret; |
Nikolay Nikolov | f9cc969 | 2018-02-10 13:52:14 +0200 | [diff] [blame] | 492 | |
| 493 | // Execute a SPECIFY command (sets the Step Rate Time, |
| 494 | // Head Load Time, Head Unload Time and the DMA enable/disable bit). |
| 495 | ret = floppy_drive_specify(); |
| 496 | if (ret) |
| 497 | return ret; |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 498 | } |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 499 | |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 500 | // Seek to cylinder if needed. |
| 501 | u8 lastcyl = GET_BDA(floppy_track[floppyid]); |
| 502 | if (cylinder != lastcyl) { |
| 503 | u8 param[2]; |
| 504 | param[0] = floppyid; |
| 505 | param[1] = cylinder; |
| 506 | int ret = floppy_drive_pio(floppyid, FC_SEEK, param); |
| 507 | if (ret) |
| 508 | return ret; |
| 509 | SET_BDA(floppy_track[floppyid], cylinder); |
| 510 | } |
| 511 | |
| 512 | return DISK_RET_SUCCESS; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 513 | } |
| 514 | |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 515 | |
| 516 | /**************************************************************** |
Kevin O'Connor | 7b9f297 | 2013-09-18 21:04:03 -0400 | [diff] [blame] | 517 | * Floppy DMA transfer |
Kevin O'Connor | c849405 | 2013-03-03 10:27:30 -0500 | [diff] [blame] | 518 | ****************************************************************/ |
| 519 | |
| 520 | // Perform a floppy transfer command (setup DMA and issue PIO). |
| 521 | static int |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 522 | floppy_dma_cmd(struct disk_op_s *op, int count, int command, u8 *param) |
Kevin O'Connor | c849405 | 2013-03-03 10:27:30 -0500 | [diff] [blame] | 523 | { |
Kevin O'Connor | 7b9f297 | 2013-09-18 21:04:03 -0400 | [diff] [blame] | 524 | // Setup DMA controller |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 525 | int isWrite = command != FC_READ; |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 526 | int ret = dma_floppy((u32)op->buf_fl, count, isWrite); |
Kevin O'Connor | 7b9f297 | 2013-09-18 21:04:03 -0400 | [diff] [blame] | 527 | if (ret) |
Kevin O'Connor | c849405 | 2013-03-03 10:27:30 -0500 | [diff] [blame] | 528 | return DISK_RET_EBOUNDARY; |
| 529 | |
Kevin O'Connor | 7b9f297 | 2013-09-18 21:04:03 -0400 | [diff] [blame] | 530 | // Invoke floppy controller |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 531 | u8 floppyid = GET_GLOBALFLAT(op->drive_fl->cntl_id); |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 532 | ret = floppy_drive_pio(floppyid, command, param); |
Kevin O'Connor | c849405 | 2013-03-03 10:27:30 -0500 | [diff] [blame] | 533 | if (ret) |
| 534 | return ret; |
| 535 | |
| 536 | // Populate floppy_return_status in BDA |
| 537 | int i; |
| 538 | for (i=0; i<7; i++) |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 539 | SET_BDA(floppy_return_status[i], param[i]); |
Kevin O'Connor | c849405 | 2013-03-03 10:27:30 -0500 | [diff] [blame] | 540 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 541 | if (param[0] & 0xc0) { |
| 542 | if (param[1] & 0x02) |
Kevin O'Connor | c849405 | 2013-03-03 10:27:30 -0500 | [diff] [blame] | 543 | return DISK_RET_EWRITEPROTECT; |
Kevin O'Connor | 8413b32 | 2013-03-09 20:07:38 -0500 | [diff] [blame] | 544 | dprintf(1, "floppy error: %02x %02x %02x %02x %02x %02x %02x\n" |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 545 | , param[0], param[1], param[2], param[3] |
| 546 | , param[4], param[5], param[6]); |
Kevin O'Connor | c849405 | 2013-03-03 10:27:30 -0500 | [diff] [blame] | 547 | return DISK_RET_ECONTROLLER; |
| 548 | } |
| 549 | |
Kevin O'Connor | c849405 | 2013-03-03 10:27:30 -0500 | [diff] [blame] | 550 | return DISK_RET_SUCCESS; |
| 551 | } |
| 552 | |
| 553 | |
| 554 | /**************************************************************** |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 555 | * Floppy handlers |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 556 | ****************************************************************/ |
| 557 | |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 558 | static struct chs_s |
| 559 | lba2chs(struct disk_op_s *op) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 560 | { |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 561 | struct chs_s res = { }; |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 562 | |
Kevin O'Connor | 302a6e8 | 2013-12-07 11:46:37 -0500 | [diff] [blame] | 563 | u32 tmp = op->lba; |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 564 | u16 nls = GET_GLOBALFLAT(op->drive_fl->lchs.sector); |
Kevin O'Connor | 302a6e8 | 2013-12-07 11:46:37 -0500 | [diff] [blame] | 565 | res.sector = (tmp % nls) + 1; |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 566 | |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 567 | tmp /= nls; |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 568 | u16 nlh = GET_GLOBALFLAT(op->drive_fl->lchs.head); |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 569 | res.head = tmp % nlh; |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 570 | |
| 571 | tmp /= nlh; |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 572 | res.cylinder = tmp; |
| 573 | |
| 574 | return res; |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | // diskette controller reset |
| 578 | static int |
| 579 | floppy_reset(struct disk_op_s *op) |
| 580 | { |
Kevin O'Connor | 5bb7552 | 2013-03-03 15:32:31 -0500 | [diff] [blame] | 581 | SET_BDA(floppy_recalibration_status, 0); |
| 582 | SET_BDA(floppy_media_state[0], 0); |
| 583 | SET_BDA(floppy_media_state[1], 0); |
| 584 | SET_BDA(floppy_track[0], 0); |
| 585 | SET_BDA(floppy_track[1], 0); |
| 586 | SET_BDA(floppy_last_data_rate, 0); |
| 587 | floppy_disable_controller(); |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 588 | return floppy_enable_controller(); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | // Read Diskette Sectors |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 592 | static int |
| 593 | floppy_read(struct disk_op_s *op) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 594 | { |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 595 | struct chs_s chs = lba2chs(op); |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 596 | int ret = floppy_prep(op->drive_fl, chs.cylinder); |
Kevin O'Connor | b7558a3 | 2013-12-17 18:15:46 -0500 | [diff] [blame] | 597 | if (ret) |
| 598 | return ret; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 599 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 600 | // send read-normal-data command to controller |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 601 | u8 floppyid = GET_GLOBALFLAT(op->drive_fl->cntl_id); |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 602 | u8 param[8]; |
| 603 | param[0] = (chs.head << 2) | floppyid; // HD DR1 DR2 |
| 604 | param[1] = chs.cylinder; |
| 605 | param[2] = chs.head; |
| 606 | param[3] = chs.sector; |
| 607 | param[4] = FLOPPY_SIZE_CODE; |
| 608 | param[5] = chs.sector + op->count - 1; // last sector to read on track |
| 609 | param[6] = FLOPPY_GAPLEN; |
| 610 | param[7] = FLOPPY_DATALEN; |
Kevin O'Connor | b7558a3 | 2013-12-17 18:15:46 -0500 | [diff] [blame] | 611 | return floppy_dma_cmd(op, op->count * DISK_SECTOR_SIZE, FC_READ, param); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | // Write Diskette Sectors |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 615 | static int |
| 616 | floppy_write(struct disk_op_s *op) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 617 | { |
Kevin O'Connor | 8ab9a34 | 2013-09-28 23:34:49 -0400 | [diff] [blame] | 618 | struct chs_s chs = lba2chs(op); |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 619 | int ret = floppy_prep(op->drive_fl, chs.cylinder); |
Kevin O'Connor | b7558a3 | 2013-12-17 18:15:46 -0500 | [diff] [blame] | 620 | if (ret) |
| 621 | return ret; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 622 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 623 | // send write-normal-data command to controller |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 624 | u8 floppyid = GET_GLOBALFLAT(op->drive_fl->cntl_id); |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 625 | u8 param[8]; |
| 626 | param[0] = (chs.head << 2) | floppyid; // HD DR1 DR2 |
| 627 | param[1] = chs.cylinder; |
| 628 | param[2] = chs.head; |
| 629 | param[3] = chs.sector; |
| 630 | param[4] = FLOPPY_SIZE_CODE; |
| 631 | param[5] = chs.sector + op->count - 1; // last sector to write on track |
| 632 | param[6] = FLOPPY_GAPLEN; |
| 633 | param[7] = FLOPPY_DATALEN; |
Kevin O'Connor | b7558a3 | 2013-12-17 18:15:46 -0500 | [diff] [blame] | 634 | return floppy_dma_cmd(op, op->count * DISK_SECTOR_SIZE, FC_WRITE, param); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | // Verify Diskette Sectors |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 638 | static int |
| 639 | floppy_verify(struct disk_op_s *op) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 640 | { |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 641 | struct chs_s chs = lba2chs(op); |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 642 | int ret = floppy_prep(op->drive_fl, chs.cylinder); |
Kevin O'Connor | b7558a3 | 2013-12-17 18:15:46 -0500 | [diff] [blame] | 643 | if (ret) |
| 644 | return ret; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 645 | |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 646 | // This command isn't implemented - just return success. |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 647 | return DISK_RET_SUCCESS; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | // format diskette track |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 651 | static int |
| 652 | floppy_format(struct disk_op_s *op) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 653 | { |
Kevin O'Connor | b84899e | 2013-12-11 19:15:45 -0500 | [diff] [blame] | 654 | struct chs_s chs = lba2chs(op); |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 655 | int ret = floppy_prep(op->drive_fl, chs.cylinder); |
Kevin O'Connor | b7558a3 | 2013-12-17 18:15:46 -0500 | [diff] [blame] | 656 | if (ret) |
| 657 | return ret; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 658 | |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 659 | // send format-track command to controller |
Kevin O'Connor | e5a0b61 | 2017-07-11 12:24:50 -0400 | [diff] [blame] | 660 | u8 floppyid = GET_GLOBALFLAT(op->drive_fl->cntl_id); |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 661 | u8 param[7]; |
Kevin O'Connor | b84899e | 2013-12-11 19:15:45 -0500 | [diff] [blame] | 662 | param[0] = (chs.head << 2) | floppyid; // HD DR1 DR2 |
Kevin O'Connor | cd891f1 | 2013-12-11 18:32:12 -0500 | [diff] [blame] | 663 | param[1] = FLOPPY_SIZE_CODE; |
| 664 | param[2] = op->count; // number of sectors per track |
| 665 | param[3] = FLOPPY_FORMAT_GAPLEN; |
| 666 | param[4] = FLOPPY_FILLBYTE; |
Kevin O'Connor | 8615f62 | 2013-12-11 19:38:15 -0500 | [diff] [blame] | 667 | return floppy_dma_cmd(op, op->count * 4, FC_FORMAT, param); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 668 | } |
| 669 | |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 670 | int |
Kevin O'Connor | 1785645 | 2015-07-07 14:56:20 -0400 | [diff] [blame] | 671 | floppy_process_op(struct disk_op_s *op) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 672 | { |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 673 | if (!CONFIG_FLOPPY) |
| 674 | return 0; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 675 | |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 676 | switch (op->command) { |
| 677 | case CMD_RESET: |
| 678 | return floppy_reset(op); |
| 679 | case CMD_READ: |
| 680 | return floppy_read(op); |
| 681 | case CMD_WRITE: |
| 682 | return floppy_write(op); |
| 683 | case CMD_VERIFY: |
| 684 | return floppy_verify(op); |
| 685 | case CMD_FORMAT: |
| 686 | return floppy_format(op); |
| 687 | default: |
Kevin O'Connor | af5aabb | 2009-08-16 18:48:38 -0400 | [diff] [blame] | 688 | return DISK_RET_EPARAM; |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 689 | } |
| 690 | } |
| 691 | |
Kevin O'Connor | a3b612e | 2009-02-07 11:25:29 -0500 | [diff] [blame] | 692 | |
| 693 | /**************************************************************** |
| 694 | * HW irqs |
| 695 | ****************************************************************/ |
| 696 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 697 | // INT 0Eh Diskette Hardware ISR Entry Point |
Kevin O'Connor | 1978676 | 2008-03-05 21:09:59 -0500 | [diff] [blame] | 698 | void VISIBLE16 |
Kevin O'Connor | 1297e5d | 2012-06-02 20:30:58 -0400 | [diff] [blame] | 699 | handle_0e(void) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 700 | { |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 701 | if (! CONFIG_FLOPPY) |
Kevin O'Connor | ff5e005 | 2012-12-07 11:25:58 -0500 | [diff] [blame] | 702 | return; |
| 703 | debug_isr(DEBUG_ISR_0e); |
Kevin O'Connor | 4096702 | 2008-07-21 22:23:05 -0400 | [diff] [blame] | 704 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 705 | // diskette interrupt has occurred |
Kevin O'Connor | e51316d | 2012-06-10 09:09:22 -0400 | [diff] [blame] | 706 | u8 frs = GET_BDA(floppy_recalibration_status); |
Kevin O'Connor | 6e529bd | 2013-03-02 20:30:50 -0500 | [diff] [blame] | 707 | SET_BDA(floppy_recalibration_status, frs | FRS_IRQ); |
Kevin O'Connor | 4096702 | 2008-07-21 22:23:05 -0400 | [diff] [blame] | 708 | |
Kevin O'Connor | aa7c234 | 2013-07-14 15:07:21 -0400 | [diff] [blame] | 709 | pic_eoi1(); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | // Called from int08 handler. |
| 713 | void |
Kevin O'Connor | 1ca05b0 | 2010-01-03 17:43:37 -0500 | [diff] [blame] | 714 | floppy_tick(void) |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 715 | { |
Kevin O'Connor | 0a0e42e | 2009-08-16 12:09:44 -0400 | [diff] [blame] | 716 | if (! CONFIG_FLOPPY) |
Kevin O'Connor | 4096702 | 2008-07-21 22:23:05 -0400 | [diff] [blame] | 717 | return; |
| 718 | |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 719 | // time to turn off drive(s)? |
| 720 | u8 fcount = GET_BDA(floppy_motor_counter); |
| 721 | if (fcount) { |
| 722 | fcount--; |
| 723 | SET_BDA(floppy_motor_counter, fcount); |
| 724 | if (fcount == 0) |
| 725 | // turn motor(s) off |
Nikolay Nikolov | 53fc631 | 2018-02-04 17:26:58 +0200 | [diff] [blame] | 726 | floppy_dor_mask(FLOPPY_DOR_MOTOR_MASK, 0); |
Kevin O'Connor | f076a3e | 2008-02-25 22:25:15 -0500 | [diff] [blame] | 727 | } |
| 728 | } |