Commit ea185bbda732dae6b6a5a44699f90c83e21f1494
1 parent
83acc96b
use bdrv_media_changed()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2122 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
14 additions
and
24 deletions
hw/fdc.c
| ... | ... | @@ -66,7 +66,6 @@ typedef enum fdrive_type_t { |
| 66 | 66 | |
| 67 | 67 | typedef enum fdrive_flags_t { |
| 68 | 68 | FDRIVE_MOTOR_ON = 0x01, /* motor on/off */ |
| 69 | - FDRIVE_REVALIDATE = 0x02, /* Revalidated */ | |
| 70 | 69 | } fdrive_flags_t; |
| 71 | 70 | |
| 72 | 71 | typedef enum fdisk_flags_t { |
| ... | ... | @@ -236,7 +235,6 @@ static void fd_revalidate (fdrive_t *drv) |
| 236 | 235 | int nb_heads, max_track, last_sect, ro; |
| 237 | 236 | |
| 238 | 237 | FLOPPY_DPRINTF("revalidate\n"); |
| 239 | - drv->drflags &= ~FDRIVE_REVALIDATE; | |
| 240 | 238 | if (drv->bs != NULL && bdrv_is_inserted(drv->bs)) { |
| 241 | 239 | ro = bdrv_is_read_only(drv->bs); |
| 242 | 240 | bdrv_get_geometry_hint(drv->bs, &nb_heads, &max_track, &last_sect); |
| ... | ... | @@ -291,7 +289,6 @@ static void fd_revalidate (fdrive_t *drv) |
| 291 | 289 | drv->max_track = 0; |
| 292 | 290 | drv->flags &= ~FDISK_DBL_SIDES; |
| 293 | 291 | } |
| 294 | - drv->drflags |= FDRIVE_REVALIDATE; | |
| 295 | 292 | } |
| 296 | 293 | |
| 297 | 294 | /* Motor control */ |
| ... | ... | @@ -488,19 +485,6 @@ static CPUWriteMemoryFunc *fdctrl_mem_write[3] = { |
| 488 | 485 | fdctrl_write_mem, |
| 489 | 486 | }; |
| 490 | 487 | |
| 491 | -static void fd_change_cb (void *opaque) | |
| 492 | -{ | |
| 493 | - fdrive_t *drv = opaque; | |
| 494 | - | |
| 495 | - FLOPPY_DPRINTF("disk change\n"); | |
| 496 | - fd_revalidate(drv); | |
| 497 | -#if 0 | |
| 498 | - fd_recalibrate(drv); | |
| 499 | - fdctrl_reset_fifo(drv->fdctrl); | |
| 500 | - fdctrl_raise_irq(drv->fdctrl, 0x20); | |
| 501 | -#endif | |
| 502 | -} | |
| 503 | - | |
| 504 | 488 | fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, |
| 505 | 489 | uint32_t io_base, |
| 506 | 490 | BlockDriverState **fds) |
| ... | ... | @@ -529,10 +513,6 @@ fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, |
| 529 | 513 | } |
| 530 | 514 | for (i = 0; i < 2; i++) { |
| 531 | 515 | fd_init(&fdctrl->drives[i], fds[i]); |
| 532 | - if (fds[i]) { | |
| 533 | - bdrv_set_change_cb(fds[i], | |
| 534 | - &fd_change_cb, &fdctrl->drives[i]); | |
| 535 | - } | |
| 536 | 516 | } |
| 537 | 517 | fdctrl_reset(fdctrl, 0); |
| 538 | 518 | fdctrl->state = FD_CTRL_ACTIVE; |
| ... | ... | @@ -760,18 +740,28 @@ static void fdctrl_write_rate (fdctrl_t *fdctrl, uint32_t value) |
| 760 | 740 | // fdctrl.precomp = (value >> 2) & 0x07; |
| 761 | 741 | } |
| 762 | 742 | |
| 743 | +static int fdctrl_media_changed(fdrive_t *drv) | |
| 744 | +{ | |
| 745 | + int ret; | |
| 746 | + if (!drv->bs) | |
| 747 | + return 0; | |
| 748 | + ret = bdrv_media_changed(drv->bs); | |
| 749 | + if (ret) { | |
| 750 | + fd_revalidate(drv); | |
| 751 | + } | |
| 752 | + return ret; | |
| 753 | +} | |
| 754 | + | |
| 763 | 755 | /* Digital input register : 0x07 (read-only) */ |
| 764 | 756 | static uint32_t fdctrl_read_dir (fdctrl_t *fdctrl) |
| 765 | 757 | { |
| 766 | 758 | uint32_t retval = 0; |
| 767 | 759 | |
| 768 | - if (drv0(fdctrl)->drflags & FDRIVE_REVALIDATE || | |
| 769 | - drv1(fdctrl)->drflags & FDRIVE_REVALIDATE) | |
| 760 | + if (fdctrl_media_changed(drv0(fdctrl)) || | |
| 761 | + fdctrl_media_changed(drv1(fdctrl))) | |
| 770 | 762 | retval |= 0x80; |
| 771 | 763 | if (retval != 0) |
| 772 | 764 | FLOPPY_DPRINTF("Floppy digital input register: 0x%02x\n", retval); |
| 773 | - drv0(fdctrl)->drflags &= ~FDRIVE_REVALIDATE; | |
| 774 | - drv1(fdctrl)->drflags &= ~FDRIVE_REVALIDATE; | |
| 775 | 765 | |
| 776 | 766 | return retval; |
| 777 | 767 | } | ... | ... |