Commit 4f431960976661fc60c5e7e05df6550cc592bceb
1 parent
d8f699cb
No functional changes: remove dead code and fix indentation & wrapping lines.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3535 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
196 additions
and
199 deletions
hw/fdc.c
@@ -106,7 +106,7 @@ static void fd_init (fdrive_t *drv, BlockDriverState *bs) | @@ -106,7 +106,7 @@ static void fd_init (fdrive_t *drv, BlockDriverState *bs) | ||
106 | } | 106 | } |
107 | 107 | ||
108 | static int _fd_sector (uint8_t head, uint8_t track, | 108 | static int _fd_sector (uint8_t head, uint8_t track, |
109 | - uint8_t sect, uint8_t last_sect) | 109 | + uint8_t sect, uint8_t last_sect) |
110 | { | 110 | { |
111 | return (((track * 2) + head) * last_sect) + sect - 1; | 111 | return (((track * 2) + head) * last_sect) + sect - 1; |
112 | } | 112 | } |
@@ -124,7 +124,7 @@ static int fd_seek (fdrive_t *drv, uint8_t head, uint8_t track, uint8_t sect, | @@ -124,7 +124,7 @@ static int fd_seek (fdrive_t *drv, uint8_t head, uint8_t track, uint8_t sect, | ||
124 | int ret; | 124 | int ret; |
125 | 125 | ||
126 | if (track > drv->max_track || | 126 | if (track > drv->max_track || |
127 | - (head != 0 && (drv->flags & FDISK_DBL_SIDES) == 0)) { | 127 | + (head != 0 && (drv->flags & FDISK_DBL_SIDES) == 0)) { |
128 | FLOPPY_DPRINTF("try to read %d %02x %02x (max=%d %d %02x %02x)\n", | 128 | FLOPPY_DPRINTF("try to read %d %02x %02x (max=%d %d %02x %02x)\n", |
129 | head, track, sect, 1, | 129 | head, track, sect, 1, |
130 | (drv->flags & FDISK_DBL_SIDES) == 0 ? 0 : 1, | 130 | (drv->flags & FDISK_DBL_SIDES) == 0 ? 0 : 1, |
@@ -149,8 +149,8 @@ static int fd_seek (fdrive_t *drv, uint8_t head, uint8_t track, uint8_t sect, | @@ -149,8 +149,8 @@ static int fd_seek (fdrive_t *drv, uint8_t head, uint8_t track, uint8_t sect, | ||
149 | } | 149 | } |
150 | #endif | 150 | #endif |
151 | drv->head = head; | 151 | drv->head = head; |
152 | - if (drv->track != track) | ||
153 | - ret = 1; | 152 | + if (drv->track != track) |
153 | + ret = 1; | ||
154 | drv->track = track; | 154 | drv->track = track; |
155 | drv->sect = sect; | 155 | drv->sect = sect; |
156 | } | 156 | } |
@@ -236,58 +236,58 @@ static void fd_revalidate (fdrive_t *drv) | @@ -236,58 +236,58 @@ static void fd_revalidate (fdrive_t *drv) | ||
236 | 236 | ||
237 | FLOPPY_DPRINTF("revalidate\n"); | 237 | FLOPPY_DPRINTF("revalidate\n"); |
238 | if (drv->bs != NULL && bdrv_is_inserted(drv->bs)) { | 238 | if (drv->bs != NULL && bdrv_is_inserted(drv->bs)) { |
239 | - ro = bdrv_is_read_only(drv->bs); | ||
240 | - bdrv_get_geometry_hint(drv->bs, &nb_heads, &max_track, &last_sect); | ||
241 | - if (nb_heads != 0 && max_track != 0 && last_sect != 0) { | ||
242 | - FLOPPY_DPRINTF("User defined disk (%d %d %d)", | 239 | + ro = bdrv_is_read_only(drv->bs); |
240 | + bdrv_get_geometry_hint(drv->bs, &nb_heads, &max_track, &last_sect); | ||
241 | + if (nb_heads != 0 && max_track != 0 && last_sect != 0) { | ||
242 | + FLOPPY_DPRINTF("User defined disk (%d %d %d)", | ||
243 | nb_heads - 1, max_track, last_sect); | 243 | nb_heads - 1, max_track, last_sect); |
244 | - } else { | ||
245 | - bdrv_get_geometry(drv->bs, &nb_sectors); | ||
246 | - match = -1; | ||
247 | - first_match = -1; | ||
248 | - for (i = 0;; i++) { | ||
249 | - parse = &fd_formats[i]; | ||
250 | - if (parse->drive == FDRIVE_DRV_NONE) | ||
251 | - break; | ||
252 | - if (drv->drive == parse->drive || | ||
253 | - drv->drive == FDRIVE_DRV_NONE) { | ||
254 | - size = (parse->max_head + 1) * parse->max_track * | ||
255 | - parse->last_sect; | ||
256 | - if (nb_sectors == size) { | ||
257 | - match = i; | ||
258 | - break; | ||
259 | - } | ||
260 | - if (first_match == -1) | ||
261 | - first_match = i; | ||
262 | - } | ||
263 | - } | ||
264 | - if (match == -1) { | ||
265 | - if (first_match == -1) | ||
266 | - match = 1; | ||
267 | - else | ||
268 | - match = first_match; | ||
269 | - parse = &fd_formats[match]; | ||
270 | - } | ||
271 | - nb_heads = parse->max_head + 1; | ||
272 | - max_track = parse->max_track; | ||
273 | - last_sect = parse->last_sect; | ||
274 | - drv->drive = parse->drive; | ||
275 | - FLOPPY_DPRINTF("%s floppy disk (%d h %d t %d s) %s\n", parse->str, | 244 | + } else { |
245 | + bdrv_get_geometry(drv->bs, &nb_sectors); | ||
246 | + match = -1; | ||
247 | + first_match = -1; | ||
248 | + for (i = 0;; i++) { | ||
249 | + parse = &fd_formats[i]; | ||
250 | + if (parse->drive == FDRIVE_DRV_NONE) | ||
251 | + break; | ||
252 | + if (drv->drive == parse->drive || | ||
253 | + drv->drive == FDRIVE_DRV_NONE) { | ||
254 | + size = (parse->max_head + 1) * parse->max_track * | ||
255 | + parse->last_sect; | ||
256 | + if (nb_sectors == size) { | ||
257 | + match = i; | ||
258 | + break; | ||
259 | + } | ||
260 | + if (first_match == -1) | ||
261 | + first_match = i; | ||
262 | + } | ||
263 | + } | ||
264 | + if (match == -1) { | ||
265 | + if (first_match == -1) | ||
266 | + match = 1; | ||
267 | + else | ||
268 | + match = first_match; | ||
269 | + parse = &fd_formats[match]; | ||
270 | + } | ||
271 | + nb_heads = parse->max_head + 1; | ||
272 | + max_track = parse->max_track; | ||
273 | + last_sect = parse->last_sect; | ||
274 | + drv->drive = parse->drive; | ||
275 | + FLOPPY_DPRINTF("%s floppy disk (%d h %d t %d s) %s\n", parse->str, | ||
276 | nb_heads, max_track, last_sect, ro ? "ro" : "rw"); | 276 | nb_heads, max_track, last_sect, ro ? "ro" : "rw"); |
277 | - } | ||
278 | - if (nb_heads == 1) { | ||
279 | - drv->flags &= ~FDISK_DBL_SIDES; | ||
280 | - } else { | ||
281 | - drv->flags |= FDISK_DBL_SIDES; | ||
282 | - } | ||
283 | - drv->max_track = max_track; | ||
284 | - drv->last_sect = last_sect; | ||
285 | - drv->ro = ro; | 277 | + } |
278 | + if (nb_heads == 1) { | ||
279 | + drv->flags &= ~FDISK_DBL_SIDES; | ||
280 | + } else { | ||
281 | + drv->flags |= FDISK_DBL_SIDES; | ||
282 | + } | ||
283 | + drv->max_track = max_track; | ||
284 | + drv->last_sect = last_sect; | ||
285 | + drv->ro = ro; | ||
286 | } else { | 286 | } else { |
287 | - FLOPPY_DPRINTF("No disk in drive\n"); | 287 | + FLOPPY_DPRINTF("No disk in drive\n"); |
288 | drv->last_sect = 0; | 288 | drv->last_sect = 0; |
289 | - drv->max_track = 0; | ||
290 | - drv->flags &= ~FDISK_DBL_SIDES; | 289 | + drv->max_track = 0; |
290 | + drv->flags &= ~FDISK_DBL_SIDES; | ||
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
@@ -414,28 +414,28 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg) | @@ -414,28 +414,28 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg) | ||
414 | } else { | 414 | } else { |
415 | retval = (uint32_t)(-1); | 415 | retval = (uint32_t)(-1); |
416 | } | 416 | } |
417 | - break; | 417 | + break; |
418 | case 0x01: | 418 | case 0x01: |
419 | - retval = fdctrl_read_statusB(fdctrl); | ||
420 | - break; | 419 | + retval = fdctrl_read_statusB(fdctrl); |
420 | + break; | ||
421 | case 0x02: | 421 | case 0x02: |
422 | - retval = fdctrl_read_dor(fdctrl); | ||
423 | - break; | 422 | + retval = fdctrl_read_dor(fdctrl); |
423 | + break; | ||
424 | case 0x03: | 424 | case 0x03: |
425 | retval = fdctrl_read_tape(fdctrl); | 425 | retval = fdctrl_read_tape(fdctrl); |
426 | - break; | 426 | + break; |
427 | case 0x04: | 427 | case 0x04: |
428 | retval = fdctrl_read_main_status(fdctrl); | 428 | retval = fdctrl_read_main_status(fdctrl); |
429 | - break; | 429 | + break; |
430 | case 0x05: | 430 | case 0x05: |
431 | retval = fdctrl_read_data(fdctrl); | 431 | retval = fdctrl_read_data(fdctrl); |
432 | - break; | 432 | + break; |
433 | case 0x07: | 433 | case 0x07: |
434 | retval = fdctrl_read_dir(fdctrl); | 434 | retval = fdctrl_read_dir(fdctrl); |
435 | - break; | 435 | + break; |
436 | default: | 436 | default: |
437 | - retval = (uint32_t)(-1); | ||
438 | - break; | 437 | + retval = (uint32_t)(-1); |
438 | + break; | ||
439 | } | 439 | } |
440 | FLOPPY_DPRINTF("read reg%d: 0x%02x\n", reg & 7, retval); | 440 | FLOPPY_DPRINTF("read reg%d: 0x%02x\n", reg & 7, retval); |
441 | 441 | ||
@@ -450,19 +450,19 @@ static void fdctrl_write (void *opaque, uint32_t reg, uint32_t value) | @@ -450,19 +450,19 @@ static void fdctrl_write (void *opaque, uint32_t reg, uint32_t value) | ||
450 | 450 | ||
451 | switch (reg & 0x07) { | 451 | switch (reg & 0x07) { |
452 | case 0x02: | 452 | case 0x02: |
453 | - fdctrl_write_dor(fdctrl, value); | ||
454 | - break; | 453 | + fdctrl_write_dor(fdctrl, value); |
454 | + break; | ||
455 | case 0x03: | 455 | case 0x03: |
456 | fdctrl_write_tape(fdctrl, value); | 456 | fdctrl_write_tape(fdctrl, value); |
457 | - break; | 457 | + break; |
458 | case 0x04: | 458 | case 0x04: |
459 | fdctrl_write_rate(fdctrl, value); | 459 | fdctrl_write_rate(fdctrl, value); |
460 | - break; | 460 | + break; |
461 | case 0x05: | 461 | case 0x05: |
462 | fdctrl_write_data(fdctrl, value); | 462 | fdctrl_write_data(fdctrl, value); |
463 | - break; | 463 | + break; |
464 | default: | 464 | default: |
465 | - break; | 465 | + break; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
@@ -615,7 +615,8 @@ fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped, | @@ -615,7 +615,8 @@ fdctrl_t *fdctrl_init (qemu_irq irq, int dma_chann, int mem_mapped, | ||
615 | fdctrl_reset(fdctrl, 0); | 615 | fdctrl_reset(fdctrl, 0); |
616 | fdctrl->state = FD_CTRL_ACTIVE; | 616 | fdctrl->state = FD_CTRL_ACTIVE; |
617 | if (mem_mapped) { | 617 | if (mem_mapped) { |
618 | - io_mem = cpu_register_io_memory(0, fdctrl_mem_read, fdctrl_mem_write, fdctrl); | 618 | + io_mem = cpu_register_io_memory(0, fdctrl_mem_read, fdctrl_mem_write, |
619 | + fdctrl); | ||
619 | cpu_register_physical_memory(io_base, 0x08, io_mem); | 620 | cpu_register_physical_memory(io_base, 0x08, io_mem); |
620 | } else { | 621 | } else { |
621 | register_ioport_read((uint32_t)io_base + 0x01, 5, 1, &fdctrl_read, | 622 | register_ioport_read((uint32_t)io_base + 0x01, 5, 1, &fdctrl_read, |
@@ -665,9 +666,9 @@ static void fdctrl_raise_irq (fdctrl_t *fdctrl, uint8_t status) | @@ -665,9 +666,9 @@ static void fdctrl_raise_irq (fdctrl_t *fdctrl, uint8_t status) | ||
665 | { | 666 | { |
666 | // Sparc mutation | 667 | // Sparc mutation |
667 | if (fdctrl->sun4m && !fdctrl->dma_en) { | 668 | if (fdctrl->sun4m && !fdctrl->dma_en) { |
668 | - fdctrl->state &= ~FD_CTRL_BUSY; | ||
669 | - fdctrl->int_status = status; | ||
670 | - return; | 669 | + fdctrl->state &= ~FD_CTRL_BUSY; |
670 | + fdctrl->int_status = status; | ||
671 | + return; | ||
671 | } | 672 | } |
672 | if (~(fdctrl->state & FD_CTRL_INTR)) { | 673 | if (~(fdctrl->state & FD_CTRL_INTR)) { |
673 | qemu_set_irq(fdctrl->irq, 1); | 674 | qemu_set_irq(fdctrl->irq, 1); |
@@ -727,9 +728,9 @@ static uint32_t fdctrl_read_dor (fdctrl_t *fdctrl) | @@ -727,9 +728,9 @@ static uint32_t fdctrl_read_dor (fdctrl_t *fdctrl) | ||
727 | 728 | ||
728 | /* Drive motors state indicators */ | 729 | /* Drive motors state indicators */ |
729 | if (drv0(fdctrl)->drflags & FDRIVE_MOTOR_ON) | 730 | if (drv0(fdctrl)->drflags & FDRIVE_MOTOR_ON) |
730 | - retval |= 1 << 5; | 731 | + retval |= 1 << 5; |
731 | if (drv1(fdctrl)->drflags & FDRIVE_MOTOR_ON) | 732 | if (drv1(fdctrl)->drflags & FDRIVE_MOTOR_ON) |
732 | - retval |= 1 << 4; | 733 | + retval |= 1 << 4; |
733 | /* DMA enable */ | 734 | /* DMA enable */ |
734 | retval |= fdctrl->dma_en << 3; | 735 | retval |= fdctrl->dma_en << 3; |
735 | /* Reset indicator */ | 736 | /* Reset indicator */ |
@@ -836,9 +837,9 @@ static void fdctrl_write_rate (fdctrl_t *fdctrl, uint32_t value) | @@ -836,9 +837,9 @@ static void fdctrl_write_rate (fdctrl_t *fdctrl, uint32_t value) | ||
836 | { | 837 | { |
837 | /* Reset mode */ | 838 | /* Reset mode */ |
838 | if (fdctrl->state & FD_CTRL_RESET) { | 839 | if (fdctrl->state & FD_CTRL_RESET) { |
839 | - FLOPPY_DPRINTF("Floppy controller in RESET state !\n"); | ||
840 | - return; | ||
841 | - } | 840 | + FLOPPY_DPRINTF("Floppy controller in RESET state !\n"); |
841 | + return; | ||
842 | + } | ||
842 | FLOPPY_DPRINTF("select rate register set to 0x%02x\n", value); | 843 | FLOPPY_DPRINTF("select rate register set to 0x%02x\n", value); |
843 | /* Reset: autoclear */ | 844 | /* Reset: autoclear */ |
844 | if (value & 0x80) { | 845 | if (value & 0x80) { |
@@ -856,6 +857,7 @@ static void fdctrl_write_rate (fdctrl_t *fdctrl, uint32_t value) | @@ -856,6 +857,7 @@ static void fdctrl_write_rate (fdctrl_t *fdctrl, uint32_t value) | ||
856 | static int fdctrl_media_changed(fdrive_t *drv) | 857 | static int fdctrl_media_changed(fdrive_t *drv) |
857 | { | 858 | { |
858 | int ret; | 859 | int ret; |
860 | + | ||
859 | if (!drv->bs) | 861 | if (!drv->bs) |
860 | return 0; | 862 | return 0; |
861 | ret = bdrv_media_changed(drv->bs); | 863 | ret = bdrv_media_changed(drv->bs); |
@@ -871,7 +873,7 @@ static uint32_t fdctrl_read_dir (fdctrl_t *fdctrl) | @@ -871,7 +873,7 @@ static uint32_t fdctrl_read_dir (fdctrl_t *fdctrl) | ||
871 | uint32_t retval = 0; | 873 | uint32_t retval = 0; |
872 | 874 | ||
873 | if (fdctrl_media_changed(drv0(fdctrl)) || | 875 | if (fdctrl_media_changed(drv0(fdctrl)) || |
874 | - fdctrl_media_changed(drv1(fdctrl))) | 876 | + fdctrl_media_changed(drv1(fdctrl))) |
875 | retval |= 0x80; | 877 | retval |= 0x80; |
876 | if (retval != 0) | 878 | if (retval != 0) |
877 | FLOPPY_DPRINTF("Floppy digital input register: 0x%02x\n", retval); | 879 | FLOPPY_DPRINTF("Floppy digital input register: 0x%02x\n", retval); |
@@ -918,7 +920,7 @@ static void fdctrl_unimplemented (fdctrl_t *fdctrl) | @@ -918,7 +920,7 @@ static void fdctrl_unimplemented (fdctrl_t *fdctrl) | ||
918 | 920 | ||
919 | /* Callback for transfer end (stop or abort) */ | 921 | /* Callback for transfer end (stop or abort) */ |
920 | static void fdctrl_stop_transfer (fdctrl_t *fdctrl, uint8_t status0, | 922 | static void fdctrl_stop_transfer (fdctrl_t *fdctrl, uint8_t status0, |
921 | - uint8_t status1, uint8_t status2) | 923 | + uint8_t status1, uint8_t status2) |
922 | { | 924 | { |
923 | fdrive_t *cur_drv; | 925 | fdrive_t *cur_drv; |
924 | 926 | ||
@@ -1000,12 +1002,12 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | @@ -1000,12 +1002,12 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | ||
1000 | if (fdctrl->fifo[5] == 00) { | 1002 | if (fdctrl->fifo[5] == 00) { |
1001 | fdctrl->data_len = fdctrl->fifo[8]; | 1003 | fdctrl->data_len = fdctrl->fifo[8]; |
1002 | } else { | 1004 | } else { |
1003 | - int tmp; | 1005 | + int tmp; |
1004 | fdctrl->data_len = 128 << (fdctrl->fifo[5] > 7 ? 7 : fdctrl->fifo[5]); | 1006 | fdctrl->data_len = 128 << (fdctrl->fifo[5] > 7 ? 7 : fdctrl->fifo[5]); |
1005 | tmp = (cur_drv->last_sect - ks + 1); | 1007 | tmp = (cur_drv->last_sect - ks + 1); |
1006 | if (fdctrl->fifo[0] & 0x80) | 1008 | if (fdctrl->fifo[0] & 0x80) |
1007 | tmp += cur_drv->last_sect; | 1009 | tmp += cur_drv->last_sect; |
1008 | - fdctrl->data_len *= tmp; | 1010 | + fdctrl->data_len *= tmp; |
1009 | } | 1011 | } |
1010 | fdctrl->eot = fdctrl->fifo[6]; | 1012 | fdctrl->eot = fdctrl->fifo[6]; |
1011 | if (fdctrl->dma_en) { | 1013 | if (fdctrl->dma_en) { |
@@ -1014,9 +1016,9 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | @@ -1014,9 +1016,9 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | ||
1014 | dma_mode = DMA_get_channel_mode(fdctrl->dma_chann); | 1016 | dma_mode = DMA_get_channel_mode(fdctrl->dma_chann); |
1015 | dma_mode = (dma_mode >> 2) & 3; | 1017 | dma_mode = (dma_mode >> 2) & 3; |
1016 | FLOPPY_DPRINTF("dma_mode=%d direction=%d (%d - %d)\n", | 1018 | FLOPPY_DPRINTF("dma_mode=%d direction=%d (%d - %d)\n", |
1017 | - dma_mode, direction, | 1019 | + dma_mode, direction, |
1018 | (128 << fdctrl->fifo[5]) * | 1020 | (128 << fdctrl->fifo[5]) * |
1019 | - (cur_drv->last_sect - ks + 1), fdctrl->data_len); | 1021 | + (cur_drv->last_sect - ks + 1), fdctrl->data_len); |
1020 | if (((direction == FD_DIR_SCANE || direction == FD_DIR_SCANL || | 1022 | if (((direction == FD_DIR_SCANE || direction == FD_DIR_SCANL || |
1021 | direction == FD_DIR_SCANH) && dma_mode == 0) || | 1023 | direction == FD_DIR_SCANH) && dma_mode == 0) || |
1022 | (direction == FD_DIR_WRITE && dma_mode == 2) || | 1024 | (direction == FD_DIR_WRITE && dma_mode == 2) || |
@@ -1030,7 +1032,7 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | @@ -1030,7 +1032,7 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | ||
1030 | DMA_schedule(fdctrl->dma_chann); | 1032 | DMA_schedule(fdctrl->dma_chann); |
1031 | return; | 1033 | return; |
1032 | } else { | 1034 | } else { |
1033 | - FLOPPY_ERROR("dma_mode=%d direction=%d\n", dma_mode, direction); | 1035 | + FLOPPY_ERROR("dma_mode=%d direction=%d\n", dma_mode, direction); |
1034 | } | 1036 | } |
1035 | } | 1037 | } |
1036 | FLOPPY_DPRINTF("start non-DMA transfer\n"); | 1038 | FLOPPY_DPRINTF("start non-DMA transfer\n"); |
@@ -1070,11 +1072,11 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | @@ -1070,11 +1072,11 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | ||
1070 | if (dma_len > fdctrl->data_len) | 1072 | if (dma_len > fdctrl->data_len) |
1071 | dma_len = fdctrl->data_len; | 1073 | dma_len = fdctrl->data_len; |
1072 | if (cur_drv->bs == NULL) { | 1074 | if (cur_drv->bs == NULL) { |
1073 | - if (fdctrl->data_dir == FD_DIR_WRITE) | ||
1074 | - fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); | ||
1075 | - else | ||
1076 | - fdctrl_stop_transfer(fdctrl, 0x40, 0x00, 0x00); | ||
1077 | - len = 0; | 1075 | + if (fdctrl->data_dir == FD_DIR_WRITE) |
1076 | + fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); | ||
1077 | + else | ||
1078 | + fdctrl_stop_transfer(fdctrl, 0x40, 0x00, 0x00); | ||
1079 | + len = 0; | ||
1078 | goto transfer_error; | 1080 | goto transfer_error; |
1079 | } | 1081 | } |
1080 | rel_pos = fdctrl->data_pos % FD_SECTOR_LEN; | 1082 | rel_pos = fdctrl->data_pos % FD_SECTOR_LEN; |
@@ -1088,45 +1090,39 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | @@ -1088,45 +1090,39 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | ||
1088 | cur_drv->track, cur_drv->sect, fd_sector(cur_drv), | 1090 | cur_drv->track, cur_drv->sect, fd_sector(cur_drv), |
1089 | fd_sector(cur_drv) * 512); | 1091 | fd_sector(cur_drv) * 512); |
1090 | if (fdctrl->data_dir != FD_DIR_WRITE || | 1092 | if (fdctrl->data_dir != FD_DIR_WRITE || |
1091 | - len < FD_SECTOR_LEN || rel_pos != 0) { | 1093 | + len < FD_SECTOR_LEN || rel_pos != 0) { |
1092 | /* READ & SCAN commands and realign to a sector for WRITE */ | 1094 | /* READ & SCAN commands and realign to a sector for WRITE */ |
1093 | if (bdrv_read(cur_drv->bs, fd_sector(cur_drv), | 1095 | if (bdrv_read(cur_drv->bs, fd_sector(cur_drv), |
1094 | - fdctrl->fifo, 1) < 0) { | 1096 | + fdctrl->fifo, 1) < 0) { |
1095 | FLOPPY_DPRINTF("Floppy: error getting sector %d\n", | 1097 | FLOPPY_DPRINTF("Floppy: error getting sector %d\n", |
1096 | fd_sector(cur_drv)); | 1098 | fd_sector(cur_drv)); |
1097 | /* Sure, image size is too small... */ | 1099 | /* Sure, image size is too small... */ |
1098 | memset(fdctrl->fifo, 0, FD_SECTOR_LEN); | 1100 | memset(fdctrl->fifo, 0, FD_SECTOR_LEN); |
1099 | } | 1101 | } |
1100 | } | 1102 | } |
1101 | - switch (fdctrl->data_dir) { | ||
1102 | - case FD_DIR_READ: | ||
1103 | - /* READ commands */ | 1103 | + switch (fdctrl->data_dir) { |
1104 | + case FD_DIR_READ: | ||
1105 | + /* READ commands */ | ||
1104 | DMA_write_memory (nchan, fdctrl->fifo + rel_pos, | 1106 | DMA_write_memory (nchan, fdctrl->fifo + rel_pos, |
1105 | fdctrl->data_pos, len); | 1107 | fdctrl->data_pos, len); |
1106 | -/* cpu_physical_memory_write(addr + fdctrl->data_pos, */ | ||
1107 | -/* fdctrl->fifo + rel_pos, len); */ | ||
1108 | - break; | ||
1109 | - case FD_DIR_WRITE: | 1108 | + break; |
1109 | + case FD_DIR_WRITE: | ||
1110 | /* WRITE commands */ | 1110 | /* WRITE commands */ |
1111 | DMA_read_memory (nchan, fdctrl->fifo + rel_pos, | 1111 | DMA_read_memory (nchan, fdctrl->fifo + rel_pos, |
1112 | fdctrl->data_pos, len); | 1112 | fdctrl->data_pos, len); |
1113 | -/* cpu_physical_memory_read(addr + fdctrl->data_pos, */ | ||
1114 | -/* fdctrl->fifo + rel_pos, len); */ | ||
1115 | if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), | 1113 | if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), |
1116 | - fdctrl->fifo, 1) < 0) { | 1114 | + fdctrl->fifo, 1) < 0) { |
1117 | FLOPPY_ERROR("writting sector %d\n", fd_sector(cur_drv)); | 1115 | FLOPPY_ERROR("writting sector %d\n", fd_sector(cur_drv)); |
1118 | fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); | 1116 | fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); |
1119 | goto transfer_error; | 1117 | goto transfer_error; |
1120 | } | 1118 | } |
1121 | - break; | ||
1122 | - default: | ||
1123 | - /* SCAN commands */ | 1119 | + break; |
1120 | + default: | ||
1121 | + /* SCAN commands */ | ||
1124 | { | 1122 | { |
1125 | - uint8_t tmpbuf[FD_SECTOR_LEN]; | 1123 | + uint8_t tmpbuf[FD_SECTOR_LEN]; |
1126 | int ret; | 1124 | int ret; |
1127 | DMA_read_memory (nchan, tmpbuf, fdctrl->data_pos, len); | 1125 | DMA_read_memory (nchan, tmpbuf, fdctrl->data_pos, len); |
1128 | -/* cpu_physical_memory_read(addr + fdctrl->data_pos, */ | ||
1129 | -/* tmpbuf, len); */ | ||
1130 | ret = memcmp(tmpbuf, fdctrl->fifo + rel_pos, len); | 1126 | ret = memcmp(tmpbuf, fdctrl->fifo + rel_pos, len); |
1131 | if (ret == 0) { | 1127 | if (ret == 0) { |
1132 | status2 = 0x08; | 1128 | status2 = 0x08; |
@@ -1138,47 +1134,47 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | @@ -1138,47 +1134,47 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | ||
1138 | goto end_transfer; | 1134 | goto end_transfer; |
1139 | } | 1135 | } |
1140 | } | 1136 | } |
1141 | - break; | 1137 | + break; |
1142 | } | 1138 | } |
1143 | - fdctrl->data_pos += len; | ||
1144 | - rel_pos = fdctrl->data_pos % FD_SECTOR_LEN; | 1139 | + fdctrl->data_pos += len; |
1140 | + rel_pos = fdctrl->data_pos % FD_SECTOR_LEN; | ||
1145 | if (rel_pos == 0) { | 1141 | if (rel_pos == 0) { |
1146 | /* Seek to next sector */ | 1142 | /* Seek to next sector */ |
1147 | - FLOPPY_DPRINTF("seek to next sector (%d %02x %02x => %d) (%d)\n", | ||
1148 | - cur_drv->head, cur_drv->track, cur_drv->sect, | ||
1149 | - fd_sector(cur_drv), | ||
1150 | - fdctrl->data_pos - len); | 1143 | + FLOPPY_DPRINTF("seek to next sector (%d %02x %02x => %d) (%d)\n", |
1144 | + cur_drv->head, cur_drv->track, cur_drv->sect, | ||
1145 | + fd_sector(cur_drv), | ||
1146 | + fdctrl->data_pos - len); | ||
1151 | /* XXX: cur_drv->sect >= cur_drv->last_sect should be an | 1147 | /* XXX: cur_drv->sect >= cur_drv->last_sect should be an |
1152 | error in fact */ | 1148 | error in fact */ |
1153 | if (cur_drv->sect >= cur_drv->last_sect || | 1149 | if (cur_drv->sect >= cur_drv->last_sect || |
1154 | cur_drv->sect == fdctrl->eot) { | 1150 | cur_drv->sect == fdctrl->eot) { |
1155 | - cur_drv->sect = 1; | ||
1156 | - if (FD_MULTI_TRACK(fdctrl->data_state)) { | ||
1157 | - if (cur_drv->head == 0 && | ||
1158 | - (cur_drv->flags & FDISK_DBL_SIDES) != 0) { | 1151 | + cur_drv->sect = 1; |
1152 | + if (FD_MULTI_TRACK(fdctrl->data_state)) { | ||
1153 | + if (cur_drv->head == 0 && | ||
1154 | + (cur_drv->flags & FDISK_DBL_SIDES) != 0) { | ||
1159 | cur_drv->head = 1; | 1155 | cur_drv->head = 1; |
1160 | } else { | 1156 | } else { |
1161 | cur_drv->head = 0; | 1157 | cur_drv->head = 0; |
1162 | - cur_drv->track++; | ||
1163 | - if ((cur_drv->flags & FDISK_DBL_SIDES) == 0) | ||
1164 | - break; | 1158 | + cur_drv->track++; |
1159 | + if ((cur_drv->flags & FDISK_DBL_SIDES) == 0) | ||
1160 | + break; | ||
1165 | } | 1161 | } |
1166 | } else { | 1162 | } else { |
1167 | cur_drv->track++; | 1163 | cur_drv->track++; |
1168 | break; | 1164 | break; |
1169 | } | 1165 | } |
1170 | - FLOPPY_DPRINTF("seek to next track (%d %02x %02x => %d)\n", | ||
1171 | - cur_drv->head, cur_drv->track, | ||
1172 | - cur_drv->sect, fd_sector(cur_drv)); | 1166 | + FLOPPY_DPRINTF("seek to next track (%d %02x %02x => %d)\n", |
1167 | + cur_drv->head, cur_drv->track, | ||
1168 | + cur_drv->sect, fd_sector(cur_drv)); | ||
1173 | } else { | 1169 | } else { |
1174 | cur_drv->sect++; | 1170 | cur_drv->sect++; |
1175 | } | 1171 | } |
1176 | } | 1172 | } |
1177 | } | 1173 | } |
1178 | -end_transfer: | 1174 | + end_transfer: |
1179 | len = fdctrl->data_pos - start_pos; | 1175 | len = fdctrl->data_pos - start_pos; |
1180 | FLOPPY_DPRINTF("end transfer %d %d %d\n", | 1176 | FLOPPY_DPRINTF("end transfer %d %d %d\n", |
1181 | - fdctrl->data_pos, len, fdctrl->data_len); | 1177 | + fdctrl->data_pos, len, fdctrl->data_len); |
1182 | if (fdctrl->data_dir == FD_DIR_SCANE || | 1178 | if (fdctrl->data_dir == FD_DIR_SCANE || |
1183 | fdctrl->data_dir == FD_DIR_SCANL || | 1179 | fdctrl->data_dir == FD_DIR_SCANL || |
1184 | fdctrl->data_dir == FD_DIR_SCANH) | 1180 | fdctrl->data_dir == FD_DIR_SCANH) |
@@ -1188,7 +1184,7 @@ end_transfer: | @@ -1188,7 +1184,7 @@ end_transfer: | ||
1188 | fdctrl->data_len -= len; | 1184 | fdctrl->data_len -= len; |
1189 | // if (fdctrl->data_len == 0) | 1185 | // if (fdctrl->data_len == 0) |
1190 | fdctrl_stop_transfer(fdctrl, status0, status1, status2); | 1186 | fdctrl_stop_transfer(fdctrl, status0, status1, status2); |
1191 | -transfer_error: | 1187 | + transfer_error: |
1192 | 1188 | ||
1193 | return len; | 1189 | return len; |
1194 | } | 1190 | } |
@@ -1284,18 +1280,18 @@ static void fdctrl_format_sector (fdctrl_t *fdctrl) | @@ -1284,18 +1280,18 @@ static void fdctrl_format_sector (fdctrl_t *fdctrl) | ||
1284 | FLOPPY_ERROR("formatting sector %d\n", fd_sector(cur_drv)); | 1280 | FLOPPY_ERROR("formatting sector %d\n", fd_sector(cur_drv)); |
1285 | fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); | 1281 | fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); |
1286 | } else { | 1282 | } else { |
1287 | - if (cur_drv->sect == cur_drv->last_sect) { | ||
1288 | - fdctrl->data_state &= ~FD_STATE_FORMAT; | ||
1289 | - /* Last sector done */ | ||
1290 | - if (FD_DID_SEEK(fdctrl->data_state)) | ||
1291 | - fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00); | ||
1292 | - else | ||
1293 | - fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); | ||
1294 | - } else { | ||
1295 | - /* More to do */ | ||
1296 | - fdctrl->data_pos = 0; | ||
1297 | - fdctrl->data_len = 4; | ||
1298 | - } | 1283 | + if (cur_drv->sect == cur_drv->last_sect) { |
1284 | + fdctrl->data_state &= ~FD_STATE_FORMAT; | ||
1285 | + /* Last sector done */ | ||
1286 | + if (FD_DID_SEEK(fdctrl->data_state)) | ||
1287 | + fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00); | ||
1288 | + else | ||
1289 | + fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); | ||
1290 | + } else { | ||
1291 | + /* More to do */ | ||
1292 | + fdctrl->data_pos = 0; | ||
1293 | + fdctrl->data_len = 4; | ||
1294 | + } | ||
1299 | } | 1295 | } |
1300 | } | 1296 | } |
1301 | 1297 | ||
@@ -1423,8 +1419,8 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1423,8 +1419,8 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1423 | #endif | 1419 | #endif |
1424 | fdctrl->fifo[1] = cur_drv->track; | 1420 | fdctrl->fifo[1] = cur_drv->track; |
1425 | fdctrl_set_fifo(fdctrl, 2, 0); | 1421 | fdctrl_set_fifo(fdctrl, 2, 0); |
1426 | - fdctrl_reset_irq(fdctrl); | ||
1427 | - fdctrl->int_status = 0xC0; | 1422 | + fdctrl_reset_irq(fdctrl); |
1423 | + fdctrl->int_status = 0xC0; | ||
1428 | return; | 1424 | return; |
1429 | case 0x0E: | 1425 | case 0x0E: |
1430 | /* DUMPREG */ | 1426 | /* DUMPREG */ |
@@ -1439,7 +1435,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1439,7 +1435,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1439 | fdctrl->fifo[5] = (fdctrl->timer1 << 1) | fdctrl->dma_en; | 1435 | fdctrl->fifo[5] = (fdctrl->timer1 << 1) | fdctrl->dma_en; |
1440 | fdctrl->fifo[6] = cur_drv->last_sect; | 1436 | fdctrl->fifo[6] = cur_drv->last_sect; |
1441 | fdctrl->fifo[7] = (fdctrl->lock << 7) | | 1437 | fdctrl->fifo[7] = (fdctrl->lock << 7) | |
1442 | - (cur_drv->perpendicular << 2); | 1438 | + (cur_drv->perpendicular << 2); |
1443 | fdctrl->fifo[8] = fdctrl->config; | 1439 | fdctrl->fifo[8] = fdctrl->config; |
1444 | fdctrl->fifo[9] = fdctrl->precomp_trk; | 1440 | fdctrl->fifo[9] = fdctrl->precomp_trk; |
1445 | fdctrl_set_fifo(fdctrl, 10, 0); | 1441 | fdctrl_set_fifo(fdctrl, 10, 0); |
@@ -1507,7 +1503,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1507,7 +1503,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1507 | fdctrl->fifo[7] = fdctrl->timer1; | 1503 | fdctrl->fifo[7] = fdctrl->timer1; |
1508 | fdctrl->fifo[8] = cur_drv->last_sect; | 1504 | fdctrl->fifo[8] = cur_drv->last_sect; |
1509 | fdctrl->fifo[9] = (fdctrl->lock << 7) | | 1505 | fdctrl->fifo[9] = (fdctrl->lock << 7) | |
1510 | - (cur_drv->perpendicular << 2); | 1506 | + (cur_drv->perpendicular << 2); |
1511 | fdctrl->fifo[10] = fdctrl->config; | 1507 | fdctrl->fifo[10] = fdctrl->config; |
1512 | fdctrl->fifo[11] = fdctrl->precomp_trk; | 1508 | fdctrl->fifo[11] = fdctrl->precomp_trk; |
1513 | fdctrl->fifo[12] = fdctrl->pwrd; | 1509 | fdctrl->fifo[12] = fdctrl->pwrd; |
@@ -1584,25 +1580,25 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1584,25 +1580,25 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1584 | return; | 1580 | return; |
1585 | } | 1581 | } |
1586 | } | 1582 | } |
1587 | -enqueue: | 1583 | + enqueue: |
1588 | FLOPPY_DPRINTF("%s: %02x\n", __func__, value); | 1584 | FLOPPY_DPRINTF("%s: %02x\n", __func__, value); |
1589 | fdctrl->fifo[fdctrl->data_pos] = value; | 1585 | fdctrl->fifo[fdctrl->data_pos] = value; |
1590 | if (++fdctrl->data_pos == fdctrl->data_len) { | 1586 | if (++fdctrl->data_pos == fdctrl->data_len) { |
1591 | /* We now have all parameters | 1587 | /* We now have all parameters |
1592 | * and will be able to treat the command | 1588 | * and will be able to treat the command |
1593 | */ | 1589 | */ |
1594 | - if (fdctrl->data_state & FD_STATE_FORMAT) { | ||
1595 | - fdctrl_format_sector(fdctrl); | ||
1596 | - return; | ||
1597 | - } | ||
1598 | - switch (fdctrl->fifo[0] & 0x1F) { | ||
1599 | - case 0x06: | ||
1600 | - { | ||
1601 | - /* READ variants */ | ||
1602 | - FLOPPY_DPRINTF("treat READ command\n"); | ||
1603 | - fdctrl_start_transfer(fdctrl, FD_DIR_READ); | 1590 | + if (fdctrl->data_state & FD_STATE_FORMAT) { |
1591 | + fdctrl_format_sector(fdctrl); | ||
1604 | return; | 1592 | return; |
1605 | } | 1593 | } |
1594 | + switch (fdctrl->fifo[0] & 0x1F) { | ||
1595 | + case 0x06: | ||
1596 | + { | ||
1597 | + /* READ variants */ | ||
1598 | + FLOPPY_DPRINTF("treat READ command\n"); | ||
1599 | + fdctrl_start_transfer(fdctrl, FD_DIR_READ); | ||
1600 | + return; | ||
1601 | + } | ||
1606 | case 0x0C: | 1602 | case 0x0C: |
1607 | /* READ_DELETED variants */ | 1603 | /* READ_DELETED variants */ |
1608 | // FLOPPY_DPRINTF("treat READ_DELETED command\n"); | 1604 | // FLOPPY_DPRINTF("treat READ_DELETED command\n"); |
@@ -1657,7 +1653,7 @@ enqueue: | @@ -1657,7 +1653,7 @@ enqueue: | ||
1657 | FLOPPY_DPRINTF("treat SPECIFY command\n"); | 1653 | FLOPPY_DPRINTF("treat SPECIFY command\n"); |
1658 | fdctrl->timer0 = (fdctrl->fifo[1] >> 4) & 0xF; | 1654 | fdctrl->timer0 = (fdctrl->fifo[1] >> 4) & 0xF; |
1659 | fdctrl->timer1 = fdctrl->fifo[2] >> 1; | 1655 | fdctrl->timer1 = fdctrl->fifo[2] >> 1; |
1660 | - fdctrl->dma_en = 1 - (fdctrl->fifo[2] & 1) ; | 1656 | + fdctrl->dma_en = 1 - (fdctrl->fifo[2] & 1) ; |
1661 | /* No result back */ | 1657 | /* No result back */ |
1662 | fdctrl_reset_fifo(fdctrl); | 1658 | fdctrl_reset_fifo(fdctrl); |
1663 | break; | 1659 | break; |
@@ -1665,7 +1661,7 @@ enqueue: | @@ -1665,7 +1661,7 @@ enqueue: | ||
1665 | /* SENSE_DRIVE_STATUS */ | 1661 | /* SENSE_DRIVE_STATUS */ |
1666 | FLOPPY_DPRINTF("treat SENSE_DRIVE_STATUS command\n"); | 1662 | FLOPPY_DPRINTF("treat SENSE_DRIVE_STATUS command\n"); |
1667 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1663 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; |
1668 | - cur_drv = get_cur_drv(fdctrl); | 1664 | + cur_drv = get_cur_drv(fdctrl); |
1669 | cur_drv->head = (fdctrl->fifo[1] >> 2) & 1; | 1665 | cur_drv->head = (fdctrl->fifo[1] >> 2) & 1; |
1670 | /* 1 Byte status back */ | 1666 | /* 1 Byte status back */ |
1671 | fdctrl->fifo[0] = (cur_drv->ro << 6) | | 1667 | fdctrl->fifo[0] = (cur_drv->ro << 6) | |
@@ -1679,23 +1675,23 @@ enqueue: | @@ -1679,23 +1675,23 @@ enqueue: | ||
1679 | /* RECALIBRATE */ | 1675 | /* RECALIBRATE */ |
1680 | FLOPPY_DPRINTF("treat RECALIBRATE command\n"); | 1676 | FLOPPY_DPRINTF("treat RECALIBRATE command\n"); |
1681 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1677 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; |
1682 | - cur_drv = get_cur_drv(fdctrl); | 1678 | + cur_drv = get_cur_drv(fdctrl); |
1683 | fd_recalibrate(cur_drv); | 1679 | fd_recalibrate(cur_drv); |
1684 | - fdctrl_reset_fifo(fdctrl); | 1680 | + fdctrl_reset_fifo(fdctrl); |
1685 | /* Raise Interrupt */ | 1681 | /* Raise Interrupt */ |
1686 | - fdctrl_raise_irq(fdctrl, 0x20); | 1682 | + fdctrl_raise_irq(fdctrl, 0x20); |
1687 | break; | 1683 | break; |
1688 | case 0x0F: | 1684 | case 0x0F: |
1689 | /* SEEK */ | 1685 | /* SEEK */ |
1690 | FLOPPY_DPRINTF("treat SEEK command\n"); | 1686 | FLOPPY_DPRINTF("treat SEEK command\n"); |
1691 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1687 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; |
1692 | - cur_drv = get_cur_drv(fdctrl); | ||
1693 | - fd_start(cur_drv); | 1688 | + cur_drv = get_cur_drv(fdctrl); |
1689 | + fd_start(cur_drv); | ||
1694 | if (fdctrl->fifo[2] <= cur_drv->track) | 1690 | if (fdctrl->fifo[2] <= cur_drv->track) |
1695 | cur_drv->dir = 1; | 1691 | cur_drv->dir = 1; |
1696 | else | 1692 | else |
1697 | cur_drv->dir = 0; | 1693 | cur_drv->dir = 0; |
1698 | - fdctrl_reset_fifo(fdctrl); | 1694 | + fdctrl_reset_fifo(fdctrl); |
1699 | if (fdctrl->fifo[2] > cur_drv->max_track) { | 1695 | if (fdctrl->fifo[2] > cur_drv->max_track) { |
1700 | fdctrl_raise_irq(fdctrl, 0x60); | 1696 | fdctrl_raise_irq(fdctrl, 0x60); |
1701 | } else { | 1697 | } else { |
@@ -1740,7 +1736,7 @@ enqueue: | @@ -1740,7 +1736,7 @@ enqueue: | ||
1740 | fdctrl_start_transfer(fdctrl, FD_DIR_READ); | 1736 | fdctrl_start_transfer(fdctrl, FD_DIR_READ); |
1741 | break; | 1737 | break; |
1742 | case 0x4A: | 1738 | case 0x4A: |
1743 | - /* READ_ID */ | 1739 | + /* READ_ID */ |
1744 | FLOPPY_DPRINTF("treat READ_ID command\n"); | 1740 | FLOPPY_DPRINTF("treat READ_ID command\n"); |
1745 | /* XXX: should set main status register to busy */ | 1741 | /* XXX: should set main status register to busy */ |
1746 | cur_drv->head = (fdctrl->fifo[1] >> 2) & 1; | 1742 | cur_drv->head = (fdctrl->fifo[1] >> 2) & 1; |
@@ -1766,30 +1762,30 @@ enqueue: | @@ -1766,30 +1762,30 @@ enqueue: | ||
1766 | break; | 1762 | break; |
1767 | case 0x4D: | 1763 | case 0x4D: |
1768 | /* FORMAT_TRACK */ | 1764 | /* FORMAT_TRACK */ |
1769 | - FLOPPY_DPRINTF("treat FORMAT_TRACK command\n"); | ||
1770 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | ||
1771 | - cur_drv = get_cur_drv(fdctrl); | ||
1772 | - fdctrl->data_state |= FD_STATE_FORMAT; | ||
1773 | - if (fdctrl->fifo[0] & 0x80) | ||
1774 | - fdctrl->data_state |= FD_STATE_MULTI; | ||
1775 | - else | ||
1776 | - fdctrl->data_state &= ~FD_STATE_MULTI; | ||
1777 | - fdctrl->data_state &= ~FD_STATE_SEEK; | ||
1778 | - cur_drv->bps = | ||
1779 | - fdctrl->fifo[2] > 7 ? 16384 : 128 << fdctrl->fifo[2]; | 1765 | + FLOPPY_DPRINTF("treat FORMAT_TRACK command\n"); |
1766 | + fdctrl->cur_drv = fdctrl->fifo[1] & 1; | ||
1767 | + cur_drv = get_cur_drv(fdctrl); | ||
1768 | + fdctrl->data_state |= FD_STATE_FORMAT; | ||
1769 | + if (fdctrl->fifo[0] & 0x80) | ||
1770 | + fdctrl->data_state |= FD_STATE_MULTI; | ||
1771 | + else | ||
1772 | + fdctrl->data_state &= ~FD_STATE_MULTI; | ||
1773 | + fdctrl->data_state &= ~FD_STATE_SEEK; | ||
1774 | + cur_drv->bps = | ||
1775 | + fdctrl->fifo[2] > 7 ? 16384 : 128 << fdctrl->fifo[2]; | ||
1780 | #if 0 | 1776 | #if 0 |
1781 | - cur_drv->last_sect = | ||
1782 | - cur_drv->flags & FDISK_DBL_SIDES ? fdctrl->fifo[3] : | ||
1783 | - fdctrl->fifo[3] / 2; | 1777 | + cur_drv->last_sect = |
1778 | + cur_drv->flags & FDISK_DBL_SIDES ? fdctrl->fifo[3] : | ||
1779 | + fdctrl->fifo[3] / 2; | ||
1784 | #else | 1780 | #else |
1785 | - cur_drv->last_sect = fdctrl->fifo[3]; | 1781 | + cur_drv->last_sect = fdctrl->fifo[3]; |
1786 | #endif | 1782 | #endif |
1787 | - /* TODO: implement format using DMA expected by the Bochs BIOS | ||
1788 | - * and Linux fdformat (read 3 bytes per sector via DMA and fill | ||
1789 | - * the sector with the specified fill byte | ||
1790 | - */ | ||
1791 | - fdctrl->data_state &= ~FD_STATE_FORMAT; | ||
1792 | - fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); | 1783 | + /* TODO: implement format using DMA expected by the Bochs BIOS |
1784 | + * and Linux fdformat (read 3 bytes per sector via DMA and fill | ||
1785 | + * the sector with the specified fill byte | ||
1786 | + */ | ||
1787 | + fdctrl->data_state &= ~FD_STATE_FORMAT; | ||
1788 | + fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); | ||
1793 | break; | 1789 | break; |
1794 | case 0x8E: | 1790 | case 0x8E: |
1795 | /* DRIVE_SPECIFICATION_COMMAND */ | 1791 | /* DRIVE_SPECIFICATION_COMMAND */ |
@@ -1815,16 +1811,16 @@ enqueue: | @@ -1815,16 +1811,16 @@ enqueue: | ||
1815 | /* RELATIVE_SEEK_OUT */ | 1811 | /* RELATIVE_SEEK_OUT */ |
1816 | FLOPPY_DPRINTF("treat RELATIVE_SEEK_OUT command\n"); | 1812 | FLOPPY_DPRINTF("treat RELATIVE_SEEK_OUT command\n"); |
1817 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1813 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; |
1818 | - cur_drv = get_cur_drv(fdctrl); | ||
1819 | - fd_start(cur_drv); | ||
1820 | - cur_drv->dir = 0; | 1814 | + cur_drv = get_cur_drv(fdctrl); |
1815 | + fd_start(cur_drv); | ||
1816 | + cur_drv->dir = 0; | ||
1821 | if (fdctrl->fifo[2] + cur_drv->track >= cur_drv->max_track) { | 1817 | if (fdctrl->fifo[2] + cur_drv->track >= cur_drv->max_track) { |
1822 | - cur_drv->track = cur_drv->max_track - 1; | 1818 | + cur_drv->track = cur_drv->max_track - 1; |
1823 | } else { | 1819 | } else { |
1824 | cur_drv->track += fdctrl->fifo[2]; | 1820 | cur_drv->track += fdctrl->fifo[2]; |
1825 | } | 1821 | } |
1826 | - fdctrl_reset_fifo(fdctrl); | ||
1827 | - fdctrl_raise_irq(fdctrl, 0x20); | 1822 | + fdctrl_reset_fifo(fdctrl); |
1823 | + fdctrl_raise_irq(fdctrl, 0x20); | ||
1828 | break; | 1824 | break; |
1829 | case 0xCD: | 1825 | case 0xCD: |
1830 | /* FORMAT_AND_WRITE */ | 1826 | /* FORMAT_AND_WRITE */ |
@@ -1833,20 +1829,20 @@ enqueue: | @@ -1833,20 +1829,20 @@ enqueue: | ||
1833 | fdctrl_unimplemented(fdctrl); | 1829 | fdctrl_unimplemented(fdctrl); |
1834 | break; | 1830 | break; |
1835 | case 0xCF: | 1831 | case 0xCF: |
1836 | - /* RELATIVE_SEEK_IN */ | 1832 | + /* RELATIVE_SEEK_IN */ |
1837 | FLOPPY_DPRINTF("treat RELATIVE_SEEK_IN command\n"); | 1833 | FLOPPY_DPRINTF("treat RELATIVE_SEEK_IN command\n"); |
1838 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1834 | fdctrl->cur_drv = fdctrl->fifo[1] & 1; |
1839 | - cur_drv = get_cur_drv(fdctrl); | ||
1840 | - fd_start(cur_drv); | ||
1841 | - cur_drv->dir = 1; | 1835 | + cur_drv = get_cur_drv(fdctrl); |
1836 | + fd_start(cur_drv); | ||
1837 | + cur_drv->dir = 1; | ||
1842 | if (fdctrl->fifo[2] > cur_drv->track) { | 1838 | if (fdctrl->fifo[2] > cur_drv->track) { |
1843 | - cur_drv->track = 0; | 1839 | + cur_drv->track = 0; |
1844 | } else { | 1840 | } else { |
1845 | cur_drv->track -= fdctrl->fifo[2]; | 1841 | cur_drv->track -= fdctrl->fifo[2]; |
1846 | } | 1842 | } |
1847 | - fdctrl_reset_fifo(fdctrl); | ||
1848 | - /* Raise Interrupt */ | ||
1849 | - fdctrl_raise_irq(fdctrl, 0x20); | 1843 | + fdctrl_reset_fifo(fdctrl); |
1844 | + /* Raise Interrupt */ | ||
1845 | + fdctrl_raise_irq(fdctrl, 0x20); | ||
1850 | break; | 1846 | break; |
1851 | } | 1847 | } |
1852 | } | 1848 | } |
@@ -1856,6 +1852,7 @@ static void fdctrl_result_timer(void *opaque) | @@ -1856,6 +1852,7 @@ static void fdctrl_result_timer(void *opaque) | ||
1856 | { | 1852 | { |
1857 | fdctrl_t *fdctrl = opaque; | 1853 | fdctrl_t *fdctrl = opaque; |
1858 | fdrive_t *cur_drv = get_cur_drv(fdctrl); | 1854 | fdrive_t *cur_drv = get_cur_drv(fdctrl); |
1855 | + | ||
1859 | /* Pretend we are spinning. | 1856 | /* Pretend we are spinning. |
1860 | * This is needed for Coherent, which uses READ ID to check for | 1857 | * This is needed for Coherent, which uses READ ID to check for |
1861 | * sector interleaving. | 1858 | * sector interleaving. |