Commit 9fea808abf6f5295b39f43f9b394ea16d65b6d46
1 parent
b6d3abda
Give names to magic numbers (Herv�oussineau)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4000 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
222 additions
and
125 deletions
hw/fdc.c
@@ -360,6 +360,102 @@ enum { | @@ -360,6 +360,102 @@ enum { | ||
360 | FD_STATE_FORMAT = 0x40, | 360 | FD_STATE_FORMAT = 0x40, |
361 | }; | 361 | }; |
362 | 362 | ||
363 | +enum { | ||
364 | + FD_REG_0 = 0x00, | ||
365 | + FD_REG_STATUSB = 0x01, | ||
366 | + FD_REG_DOR = 0x02, | ||
367 | + FD_REG_TDR = 0x03, | ||
368 | + FD_REG_MSR = 0x04, | ||
369 | + FD_REG_DSR = 0x04, | ||
370 | + FD_REG_FIFO = 0x05, | ||
371 | + FD_REG_DIR = 0x07, | ||
372 | +}; | ||
373 | + | ||
374 | +enum { | ||
375 | + FD_CMD_SPECIFY = 0x03, | ||
376 | + FD_CMD_SENSE_DRIVE_STATUS = 0x04, | ||
377 | + FD_CMD_RECALIBRATE = 0x07, | ||
378 | + FD_CMD_SENSE_INTERRUPT_STATUS = 0x08, | ||
379 | + FD_CMD_DUMPREG = 0x0e, | ||
380 | + FD_CMD_SEEK = 0x0f, | ||
381 | + FD_CMD_VERSION = 0x10, | ||
382 | + FD_CMD_PERPENDICULAR_MODE = 0x12, | ||
383 | + FD_CMD_CONFIGURE = 0x13, | ||
384 | + FD_CMD_UNLOCK = 0x14, | ||
385 | + FD_CMD_POWERDOWN_MODE = 0x17, | ||
386 | + FD_CMD_PART_ID = 0x18, | ||
387 | + FD_CMD_SAVE = 0x2c, | ||
388 | + FD_CMD_OPTION = 0x33, | ||
389 | + FD_CMD_READ_TRACK = 0x42, | ||
390 | + FD_CMD_WRITE = 0x45, | ||
391 | + FD_CMD_READ = 0x46, | ||
392 | + FD_CMD_WRITE_DELETED = 0x49, | ||
393 | + FD_CMD_READ_ID = 0x4a, | ||
394 | + FD_CMD_READ_DELETED = 0x4c, | ||
395 | + FD_CMD_RESTORE = 0x4c, | ||
396 | + FD_CMD_FORMAT_TRACK = 0x4d, | ||
397 | + FD_CMD_SCAN_EQUAL = 0x50, | ||
398 | + FD_CMD_VERIFY = 0x56, | ||
399 | + FD_CMD_SCAN_LOW_OR_EQUAL = 0x59, | ||
400 | + FD_CMD_SCAN_HIGH_OR_EQUAL = 0x5d, | ||
401 | + FD_CMD_DRIVE_SPECIFICATION_COMMAND = 0x8e, | ||
402 | + FD_CMD_RELATIVE_SEEK_OUT = 0x8f, | ||
403 | + FD_CMD_LOCK = 0x94, | ||
404 | + FD_CMD_FORMAT_AND_WRITE = 0xcd, | ||
405 | + FD_CMD_RELATIVE_SEEK_IN = 0xcf, | ||
406 | +}; | ||
407 | + | ||
408 | +enum { | ||
409 | + FD_CONFIG_PRETRK = 0xff, /* Pre-compensation set to track 0 */ | ||
410 | + FD_CONFIG_FIFOTHR = 0x0f, /* FIFO threshold set to 1 byte */ | ||
411 | + FD_CONFIG_POLL = 0x10, /* Poll enabled */ | ||
412 | + FD_CONFIG_EFIFO = 0x20, /* FIFO disabled */ | ||
413 | + FD_CONFIG_EIS = 0x40, /* No implied seeks */ | ||
414 | +}; | ||
415 | + | ||
416 | +enum { | ||
417 | + FD_SR0_EQPMT = 0x10, | ||
418 | + FD_SR0_SEEK = 0x20, | ||
419 | + FD_SR0_ABNTERM = 0x40, | ||
420 | + FD_SR0_INVCMD = 0x80, | ||
421 | + FD_SR0_RDYCHG = 0xc0, | ||
422 | +}; | ||
423 | + | ||
424 | +enum { | ||
425 | + FD_DOR_SELMASK = 0x01, | ||
426 | + FD_DOR_nRESET = 0x04, | ||
427 | + FD_DOR_DMAEN = 0x08, | ||
428 | + FD_DOR_MOTEN0 = 0x10, | ||
429 | + FD_DOR_MOTEN1 = 0x20, | ||
430 | + FD_DOR_MOTEN2 = 0x40, | ||
431 | + FD_DOR_MOTEN3 = 0x80, | ||
432 | +}; | ||
433 | + | ||
434 | +enum { | ||
435 | + FD_TDR_BOOTSEL = 0x0c, | ||
436 | +}; | ||
437 | + | ||
438 | +enum { | ||
439 | + FD_DSR_DRATEMASK= 0x03, | ||
440 | + FD_DSR_PWRDOWN = 0x40, | ||
441 | + FD_DSR_SWRESET = 0x80, | ||
442 | +}; | ||
443 | + | ||
444 | +enum { | ||
445 | + FD_MSR_DRV0BUSY = 0x01, | ||
446 | + FD_MSR_DRV1BUSY = 0x02, | ||
447 | + FD_MSR_DRV2BUSY = 0x04, | ||
448 | + FD_MSR_DRV3BUSY = 0x08, | ||
449 | + FD_MSR_CMDBUSY = 0x10, | ||
450 | + FD_MSR_NONDMA = 0x20, | ||
451 | + FD_MSR_DIO = 0x40, | ||
452 | + FD_MSR_RQM = 0x80, | ||
453 | +}; | ||
454 | + | ||
455 | +enum { | ||
456 | + FD_DIR_DSKCHG = 0x80, | ||
457 | +}; | ||
458 | + | ||
363 | #define FD_STATE(state) ((state) & FD_STATE_STATE) | 459 | #define FD_STATE(state) ((state) & FD_STATE_STATE) |
364 | #define FD_SET_STATE(state, new_state) \ | 460 | #define FD_SET_STATE(state, new_state) \ |
365 | do { (state) = ((state) & ~FD_STATE_STATE) | (new_state); } while (0) | 461 | do { (state) = ((state) & ~FD_STATE_STATE) | (new_state); } while (0) |
@@ -411,7 +507,7 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg) | @@ -411,7 +507,7 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg) | ||
411 | uint32_t retval; | 507 | uint32_t retval; |
412 | 508 | ||
413 | switch (reg & 0x07) { | 509 | switch (reg & 0x07) { |
414 | - case 0x00: | 510 | + case FD_REG_0: |
415 | if (fdctrl->sun4m) { | 511 | if (fdctrl->sun4m) { |
416 | // Identify to Linux as S82078B | 512 | // Identify to Linux as S82078B |
417 | retval = fdctrl_read_statusB(fdctrl); | 513 | retval = fdctrl_read_statusB(fdctrl); |
@@ -419,22 +515,22 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg) | @@ -419,22 +515,22 @@ static uint32_t fdctrl_read (void *opaque, uint32_t reg) | ||
419 | retval = (uint32_t)(-1); | 515 | retval = (uint32_t)(-1); |
420 | } | 516 | } |
421 | break; | 517 | break; |
422 | - case 0x01: | 518 | + case FD_REG_STATUSB: |
423 | retval = fdctrl_read_statusB(fdctrl); | 519 | retval = fdctrl_read_statusB(fdctrl); |
424 | break; | 520 | break; |
425 | - case 0x02: | 521 | + case FD_REG_DOR: |
426 | retval = fdctrl_read_dor(fdctrl); | 522 | retval = fdctrl_read_dor(fdctrl); |
427 | break; | 523 | break; |
428 | - case 0x03: | 524 | + case FD_REG_TDR: |
429 | retval = fdctrl_read_tape(fdctrl); | 525 | retval = fdctrl_read_tape(fdctrl); |
430 | break; | 526 | break; |
431 | - case 0x04: | 527 | + case FD_REG_MSR: |
432 | retval = fdctrl_read_main_status(fdctrl); | 528 | retval = fdctrl_read_main_status(fdctrl); |
433 | break; | 529 | break; |
434 | - case 0x05: | 530 | + case FD_REG_FIFO: |
435 | retval = fdctrl_read_data(fdctrl); | 531 | retval = fdctrl_read_data(fdctrl); |
436 | break; | 532 | break; |
437 | - case 0x07: | 533 | + case FD_REG_DIR: |
438 | retval = fdctrl_read_dir(fdctrl); | 534 | retval = fdctrl_read_dir(fdctrl); |
439 | break; | 535 | break; |
440 | default: | 536 | default: |
@@ -453,16 +549,16 @@ static void fdctrl_write (void *opaque, uint32_t reg, uint32_t value) | @@ -453,16 +549,16 @@ static void fdctrl_write (void *opaque, uint32_t reg, uint32_t value) | ||
453 | FLOPPY_DPRINTF("write reg%d: 0x%02x\n", reg & 7, value); | 549 | FLOPPY_DPRINTF("write reg%d: 0x%02x\n", reg & 7, value); |
454 | 550 | ||
455 | switch (reg & 0x07) { | 551 | switch (reg & 0x07) { |
456 | - case 0x02: | 552 | + case FD_REG_DOR: |
457 | fdctrl_write_dor(fdctrl, value); | 553 | fdctrl_write_dor(fdctrl, value); |
458 | break; | 554 | break; |
459 | - case 0x03: | 555 | + case FD_REG_TDR: |
460 | fdctrl_write_tape(fdctrl, value); | 556 | fdctrl_write_tape(fdctrl, value); |
461 | break; | 557 | break; |
462 | - case 0x04: | 558 | + case FD_REG_DSR: |
463 | fdctrl_write_rate(fdctrl, value); | 559 | fdctrl_write_rate(fdctrl, value); |
464 | break; | 560 | break; |
465 | - case 0x05: | 561 | + case FD_REG_FIFO: |
466 | fdctrl_write_data(fdctrl, value); | 562 | fdctrl_write_data(fdctrl, value); |
467 | break; | 563 | break; |
468 | default: | 564 | default: |
@@ -621,21 +717,21 @@ static fdctrl_t *fdctrl_init_common (qemu_irq irq, int dma_chann, | @@ -621,21 +717,21 @@ static fdctrl_t *fdctrl_init_common (qemu_irq irq, int dma_chann, | ||
621 | fdctrl->irq = irq; | 717 | fdctrl->irq = irq; |
622 | fdctrl->dma_chann = dma_chann; | 718 | fdctrl->dma_chann = dma_chann; |
623 | fdctrl->io_base = io_base; | 719 | fdctrl->io_base = io_base; |
624 | - fdctrl->config = 0x60; /* Implicit seek, polling & FIFO enabled */ | 720 | + fdctrl->config = FD_CONFIG_EIS | FD_CONFIG_EFIFO; /* Implicit seek, polling & FIFO enabled */ |
625 | if (fdctrl->dma_chann != -1) { | 721 | if (fdctrl->dma_chann != -1) { |
626 | fdctrl->dma_en = 1; | 722 | fdctrl->dma_en = 1; |
627 | DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl); | 723 | DMA_register_channel(dma_chann, &fdctrl_transfer_handler, fdctrl); |
628 | } else { | 724 | } else { |
629 | fdctrl->dma_en = 0; | 725 | fdctrl->dma_en = 0; |
630 | } | 726 | } |
631 | - for (i = 0; i < 2; i++) { | 727 | + for (i = 0; i < MAX_FD; i++) { |
632 | fd_init(&fdctrl->drives[i], fds[i]); | 728 | fd_init(&fdctrl->drives[i], fds[i]); |
633 | } | 729 | } |
634 | fdctrl_reset(fdctrl, 0); | 730 | fdctrl_reset(fdctrl, 0); |
635 | fdctrl->state = FD_CTRL_ACTIVE; | 731 | fdctrl->state = FD_CTRL_ACTIVE; |
636 | register_savevm("fdc", io_base, 1, fdc_save, fdc_load, fdctrl); | 732 | register_savevm("fdc", io_base, 1, fdc_save, fdc_load, fdctrl); |
637 | qemu_register_reset(fdctrl_external_reset, fdctrl); | 733 | qemu_register_reset(fdctrl_external_reset, fdctrl); |
638 | - for (i = 0; i < 2; i++) { | 734 | + for (i = 0; i < MAX_FD; i++) { |
639 | fd_revalidate(&fdctrl->drives[i]); | 735 | fd_revalidate(&fdctrl->drives[i]); |
640 | } | 736 | } |
641 | 737 | ||
@@ -734,7 +830,7 @@ static void fdctrl_reset (fdctrl_t *fdctrl, int do_irq) | @@ -734,7 +830,7 @@ static void fdctrl_reset (fdctrl_t *fdctrl, int do_irq) | ||
734 | fd_reset(&fdctrl->drives[i]); | 830 | fd_reset(&fdctrl->drives[i]); |
735 | fdctrl_reset_fifo(fdctrl); | 831 | fdctrl_reset_fifo(fdctrl); |
736 | if (do_irq) | 832 | if (do_irq) |
737 | - fdctrl_raise_irq(fdctrl, 0xc0); | 833 | + fdctrl_raise_irq(fdctrl, FD_SR0_RDYCHG); |
738 | } | 834 | } |
739 | 835 | ||
740 | static inline fdrive_t *drv0 (fdctrl_t *fdctrl) | 836 | static inline fdrive_t *drv0 (fdctrl_t *fdctrl) |
@@ -766,13 +862,15 @@ static uint32_t fdctrl_read_dor (fdctrl_t *fdctrl) | @@ -766,13 +862,15 @@ static uint32_t fdctrl_read_dor (fdctrl_t *fdctrl) | ||
766 | 862 | ||
767 | /* Drive motors state indicators */ | 863 | /* Drive motors state indicators */ |
768 | if (drv0(fdctrl)->drflags & FDRIVE_MOTOR_ON) | 864 | if (drv0(fdctrl)->drflags & FDRIVE_MOTOR_ON) |
769 | - retval |= 1 << 5; | 865 | + retval |= FD_DOR_MOTEN0; |
770 | if (drv1(fdctrl)->drflags & FDRIVE_MOTOR_ON) | 866 | if (drv1(fdctrl)->drflags & FDRIVE_MOTOR_ON) |
771 | - retval |= 1 << 4; | 867 | + retval |= FD_DOR_MOTEN1; |
772 | /* DMA enable */ | 868 | /* DMA enable */ |
773 | - retval |= fdctrl->dma_en << 3; | 869 | + if (fdctrl->dma_en) |
870 | + retval |= FD_DOR_DMAEN; | ||
774 | /* Reset indicator */ | 871 | /* Reset indicator */ |
775 | - retval |= (fdctrl->state & FD_CTRL_RESET) == 0 ? 0x04 : 0; | 872 | + if (!(fdctrl->state & FD_CTRL_RESET)) |
873 | + retval |= FD_DOR_nRESET; | ||
776 | /* Selected drive */ | 874 | /* Selected drive */ |
777 | retval |= fdctrl->cur_drv; | 875 | retval |= fdctrl->cur_drv; |
778 | FLOPPY_DPRINTF("digital output register: 0x%02x\n", retval); | 876 | FLOPPY_DPRINTF("digital output register: 0x%02x\n", retval); |
@@ -784,28 +882,28 @@ static void fdctrl_write_dor (fdctrl_t *fdctrl, uint32_t value) | @@ -784,28 +882,28 @@ static void fdctrl_write_dor (fdctrl_t *fdctrl, uint32_t value) | ||
784 | { | 882 | { |
785 | /* Reset mode */ | 883 | /* Reset mode */ |
786 | if (fdctrl->state & FD_CTRL_RESET) { | 884 | if (fdctrl->state & FD_CTRL_RESET) { |
787 | - if (!(value & 0x04)) { | 885 | + if (!(value & FD_DOR_nRESET)) { |
788 | FLOPPY_DPRINTF("Floppy controller in RESET state !\n"); | 886 | FLOPPY_DPRINTF("Floppy controller in RESET state !\n"); |
789 | return; | 887 | return; |
790 | } | 888 | } |
791 | } | 889 | } |
792 | FLOPPY_DPRINTF("digital output register set to 0x%02x\n", value); | 890 | FLOPPY_DPRINTF("digital output register set to 0x%02x\n", value); |
793 | /* Drive motors state indicators */ | 891 | /* Drive motors state indicators */ |
794 | - if (value & 0x20) | 892 | + if (value & FD_DOR_MOTEN1) |
795 | fd_start(drv1(fdctrl)); | 893 | fd_start(drv1(fdctrl)); |
796 | else | 894 | else |
797 | fd_stop(drv1(fdctrl)); | 895 | fd_stop(drv1(fdctrl)); |
798 | - if (value & 0x10) | 896 | + if (value & FD_DOR_MOTEN0) |
799 | fd_start(drv0(fdctrl)); | 897 | fd_start(drv0(fdctrl)); |
800 | else | 898 | else |
801 | fd_stop(drv0(fdctrl)); | 899 | fd_stop(drv0(fdctrl)); |
802 | /* DMA enable */ | 900 | /* DMA enable */ |
803 | #if 0 | 901 | #if 0 |
804 | if (fdctrl->dma_chann != -1) | 902 | if (fdctrl->dma_chann != -1) |
805 | - fdctrl->dma_en = 1 - ((value >> 3) & 1); | 903 | + fdctrl->dma_en = value & FD_DOR_DMAEN ? 1 : 0; |
806 | #endif | 904 | #endif |
807 | /* Reset */ | 905 | /* Reset */ |
808 | - if (!(value & 0x04)) { | 906 | + if (!(value & FD_DOR_nRESET)) { |
809 | if (!(fdctrl->state & FD_CTRL_RESET)) { | 907 | if (!(fdctrl->state & FD_CTRL_RESET)) { |
810 | FLOPPY_DPRINTF("controller enter RESET state\n"); | 908 | FLOPPY_DPRINTF("controller enter RESET state\n"); |
811 | fdctrl->state |= FD_CTRL_RESET; | 909 | fdctrl->state |= FD_CTRL_RESET; |
@@ -818,7 +916,7 @@ static void fdctrl_write_dor (fdctrl_t *fdctrl, uint32_t value) | @@ -818,7 +916,7 @@ static void fdctrl_write_dor (fdctrl_t *fdctrl, uint32_t value) | ||
818 | } | 916 | } |
819 | } | 917 | } |
820 | /* Selected drive */ | 918 | /* Selected drive */ |
821 | - fdctrl->cur_drv = value & 1; | 919 | + fdctrl->cur_drv = value & FD_DOR_SELMASK; |
822 | } | 920 | } |
823 | 921 | ||
824 | /* Tape drive register : 0x03 */ | 922 | /* Tape drive register : 0x03 */ |
@@ -843,7 +941,7 @@ static void fdctrl_write_tape (fdctrl_t *fdctrl, uint32_t value) | @@ -843,7 +941,7 @@ static void fdctrl_write_tape (fdctrl_t *fdctrl, uint32_t value) | ||
843 | } | 941 | } |
844 | FLOPPY_DPRINTF("tape drive register set to 0x%02x\n", value); | 942 | FLOPPY_DPRINTF("tape drive register set to 0x%02x\n", value); |
845 | /* Disk boot selection indicator */ | 943 | /* Disk boot selection indicator */ |
846 | - fdctrl->bootsel = (value >> 2) & 1; | 944 | + fdctrl->bootsel = (value & FD_TDR_BOOTSEL) >> 2; |
847 | /* Tape indicators: never allow */ | 945 | /* Tape indicators: never allow */ |
848 | } | 946 | } |
849 | 947 | ||
@@ -855,16 +953,16 @@ static uint32_t fdctrl_read_main_status (fdctrl_t *fdctrl) | @@ -855,16 +953,16 @@ static uint32_t fdctrl_read_main_status (fdctrl_t *fdctrl) | ||
855 | fdctrl->state &= ~(FD_CTRL_SLEEP | FD_CTRL_RESET); | 953 | fdctrl->state &= ~(FD_CTRL_SLEEP | FD_CTRL_RESET); |
856 | if (!(fdctrl->state & FD_CTRL_BUSY)) { | 954 | if (!(fdctrl->state & FD_CTRL_BUSY)) { |
857 | /* Data transfer allowed */ | 955 | /* Data transfer allowed */ |
858 | - retval |= 0x80; | 956 | + retval |= FD_MSR_RQM; |
859 | /* Data transfer direction indicator */ | 957 | /* Data transfer direction indicator */ |
860 | if (fdctrl->data_dir == FD_DIR_READ) | 958 | if (fdctrl->data_dir == FD_DIR_READ) |
861 | - retval |= 0x40; | 959 | + retval |= FD_MSR_DIO; |
862 | } | 960 | } |
863 | - /* Should handle 0x20 for SPECIFY command */ | 961 | + /* Should handle FD_MSR_NONDMA for SPECIFY command */ |
864 | /* Command busy indicator */ | 962 | /* Command busy indicator */ |
865 | if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA || | 963 | if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA || |
866 | FD_STATE(fdctrl->data_state) == FD_STATE_STATUS) | 964 | FD_STATE(fdctrl->data_state) == FD_STATE_STATUS) |
867 | - retval |= 0x10; | 965 | + retval |= FD_MSR_CMDBUSY; |
868 | FLOPPY_DPRINTF("main status register: 0x%02x\n", retval); | 966 | FLOPPY_DPRINTF("main status register: 0x%02x\n", retval); |
869 | 967 | ||
870 | return retval; | 968 | return retval; |
@@ -880,16 +978,15 @@ static void fdctrl_write_rate (fdctrl_t *fdctrl, uint32_t value) | @@ -880,16 +978,15 @@ static void fdctrl_write_rate (fdctrl_t *fdctrl, uint32_t value) | ||
880 | } | 978 | } |
881 | FLOPPY_DPRINTF("select rate register set to 0x%02x\n", value); | 979 | FLOPPY_DPRINTF("select rate register set to 0x%02x\n", value); |
882 | /* Reset: autoclear */ | 980 | /* Reset: autoclear */ |
883 | - if (value & 0x80) { | 981 | + if (value & FD_DSR_SWRESET) { |
884 | fdctrl->state |= FD_CTRL_RESET; | 982 | fdctrl->state |= FD_CTRL_RESET; |
885 | fdctrl_reset(fdctrl, 1); | 983 | fdctrl_reset(fdctrl, 1); |
886 | fdctrl->state &= ~FD_CTRL_RESET; | 984 | fdctrl->state &= ~FD_CTRL_RESET; |
887 | } | 985 | } |
888 | - if (value & 0x40) { | 986 | + if (value & FD_DSR_PWRDOWN) { |
889 | fdctrl->state |= FD_CTRL_SLEEP; | 987 | fdctrl->state |= FD_CTRL_SLEEP; |
890 | fdctrl_reset(fdctrl, 1); | 988 | fdctrl_reset(fdctrl, 1); |
891 | } | 989 | } |
892 | -// fdctrl.precomp = (value >> 2) & 0x07; | ||
893 | } | 990 | } |
894 | 991 | ||
895 | static int fdctrl_media_changed(fdrive_t *drv) | 992 | static int fdctrl_media_changed(fdrive_t *drv) |
@@ -912,7 +1009,7 @@ static uint32_t fdctrl_read_dir (fdctrl_t *fdctrl) | @@ -912,7 +1009,7 @@ static uint32_t fdctrl_read_dir (fdctrl_t *fdctrl) | ||
912 | 1009 | ||
913 | if (fdctrl_media_changed(drv0(fdctrl)) || | 1010 | if (fdctrl_media_changed(drv0(fdctrl)) || |
914 | fdctrl_media_changed(drv1(fdctrl))) | 1011 | fdctrl_media_changed(drv1(fdctrl))) |
915 | - retval |= 0x80; | 1012 | + retval |= FD_DIR_DSKCHG; |
916 | if (retval != 0) | 1013 | if (retval != 0) |
917 | FLOPPY_DPRINTF("Floppy digital input register: 0x%02x\n", retval); | 1014 | FLOPPY_DPRINTF("Floppy digital input register: 0x%02x\n", retval); |
918 | 1015 | ||
@@ -945,13 +1042,13 @@ static void fdctrl_unimplemented (fdctrl_t *fdctrl) | @@ -945,13 +1042,13 @@ static void fdctrl_unimplemented (fdctrl_t *fdctrl) | ||
945 | fdrive_t *cur_drv; | 1042 | fdrive_t *cur_drv; |
946 | 1043 | ||
947 | cur_drv = get_cur_drv(fdctrl); | 1044 | cur_drv = get_cur_drv(fdctrl); |
948 | - fdctrl->fifo[0] = 0x60 | (cur_drv->head << 2) | fdctrl->cur_drv; | 1045 | + fdctrl->fifo[0] = FD_SR0_ABNTERM | FD_SR0_SEEK | (cur_drv->head << 2) | fdctrl->cur_drv; |
949 | fdctrl->fifo[1] = 0x00; | 1046 | fdctrl->fifo[1] = 0x00; |
950 | fdctrl->fifo[2] = 0x00; | 1047 | fdctrl->fifo[2] = 0x00; |
951 | fdctrl_set_fifo(fdctrl, 3, 1); | 1048 | fdctrl_set_fifo(fdctrl, 3, 1); |
952 | #else | 1049 | #else |
953 | // fdctrl_reset_fifo(fdctrl); | 1050 | // fdctrl_reset_fifo(fdctrl); |
954 | - fdctrl->fifo[0] = 0x80; | 1051 | + fdctrl->fifo[0] = FD_SR0_INVCMD; |
955 | fdctrl_set_fifo(fdctrl, 1, 0); | 1052 | fdctrl_set_fifo(fdctrl, 1, 0); |
956 | #endif | 1053 | #endif |
957 | } | 1054 | } |
@@ -988,7 +1085,7 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | @@ -988,7 +1085,7 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | ||
988 | uint8_t kh, kt, ks; | 1085 | uint8_t kh, kt, ks; |
989 | int did_seek; | 1086 | int did_seek; |
990 | 1087 | ||
991 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1088 | + fdctrl->cur_drv = fdctrl->fifo[1] & FD_DOR_SELMASK; |
992 | cur_drv = get_cur_drv(fdctrl); | 1089 | cur_drv = get_cur_drv(fdctrl); |
993 | kt = fdctrl->fifo[2]; | 1090 | kt = fdctrl->fifo[2]; |
994 | kh = fdctrl->fifo[3]; | 1091 | kh = fdctrl->fifo[3]; |
@@ -1000,21 +1097,21 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | @@ -1000,21 +1097,21 @@ static void fdctrl_start_transfer (fdctrl_t *fdctrl, int direction) | ||
1000 | switch (fd_seek(cur_drv, kh, kt, ks, fdctrl->config & 0x40)) { | 1097 | switch (fd_seek(cur_drv, kh, kt, ks, fdctrl->config & 0x40)) { |
1001 | case 2: | 1098 | case 2: |
1002 | /* sect too big */ | 1099 | /* sect too big */ |
1003 | - fdctrl_stop_transfer(fdctrl, 0x40, 0x00, 0x00); | 1100 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x00, 0x00); |
1004 | fdctrl->fifo[3] = kt; | 1101 | fdctrl->fifo[3] = kt; |
1005 | fdctrl->fifo[4] = kh; | 1102 | fdctrl->fifo[4] = kh; |
1006 | fdctrl->fifo[5] = ks; | 1103 | fdctrl->fifo[5] = ks; |
1007 | return; | 1104 | return; |
1008 | case 3: | 1105 | case 3: |
1009 | /* track too big */ | 1106 | /* track too big */ |
1010 | - fdctrl_stop_transfer(fdctrl, 0x40, 0x80, 0x00); | 1107 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x80, 0x00); |
1011 | fdctrl->fifo[3] = kt; | 1108 | fdctrl->fifo[3] = kt; |
1012 | fdctrl->fifo[4] = kh; | 1109 | fdctrl->fifo[4] = kh; |
1013 | fdctrl->fifo[5] = ks; | 1110 | fdctrl->fifo[5] = ks; |
1014 | return; | 1111 | return; |
1015 | case 4: | 1112 | case 4: |
1016 | /* No seek enabled */ | 1113 | /* No seek enabled */ |
1017 | - fdctrl_stop_transfer(fdctrl, 0x40, 0x00, 0x00); | 1114 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x00, 0x00); |
1018 | fdctrl->fifo[3] = kt; | 1115 | fdctrl->fifo[3] = kt; |
1019 | fdctrl->fifo[4] = kh; | 1116 | fdctrl->fifo[4] = kh; |
1020 | fdctrl->fifo[5] = ks; | 1117 | fdctrl->fifo[5] = ks; |
@@ -1086,7 +1183,7 @@ static void fdctrl_start_transfer_del (fdctrl_t *fdctrl, int direction) | @@ -1086,7 +1183,7 @@ static void fdctrl_start_transfer_del (fdctrl_t *fdctrl, int direction) | ||
1086 | /* We don't handle deleted data, | 1183 | /* We don't handle deleted data, |
1087 | * so we don't return *ANYTHING* | 1184 | * so we don't return *ANYTHING* |
1088 | */ | 1185 | */ |
1089 | - fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); | 1186 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00); |
1090 | } | 1187 | } |
1091 | 1188 | ||
1092 | /* handlers for DMA transfers */ | 1189 | /* handlers for DMA transfers */ |
@@ -1111,9 +1208,9 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | @@ -1111,9 +1208,9 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | ||
1111 | dma_len = fdctrl->data_len; | 1208 | dma_len = fdctrl->data_len; |
1112 | if (cur_drv->bs == NULL) { | 1209 | if (cur_drv->bs == NULL) { |
1113 | if (fdctrl->data_dir == FD_DIR_WRITE) | 1210 | if (fdctrl->data_dir == FD_DIR_WRITE) |
1114 | - fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); | 1211 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00); |
1115 | else | 1212 | else |
1116 | - fdctrl_stop_transfer(fdctrl, 0x40, 0x00, 0x00); | 1213 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x00, 0x00); |
1117 | len = 0; | 1214 | len = 0; |
1118 | goto transfer_error; | 1215 | goto transfer_error; |
1119 | } | 1216 | } |
@@ -1126,7 +1223,7 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | @@ -1126,7 +1223,7 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | ||
1126 | "(%d-0x%08x 0x%08x)\n", len, dma_len, fdctrl->data_pos, | 1223 | "(%d-0x%08x 0x%08x)\n", len, dma_len, fdctrl->data_pos, |
1127 | fdctrl->data_len, fdctrl->cur_drv, cur_drv->head, | 1224 | fdctrl->data_len, fdctrl->cur_drv, cur_drv->head, |
1128 | cur_drv->track, cur_drv->sect, fd_sector(cur_drv), | 1225 | cur_drv->track, cur_drv->sect, fd_sector(cur_drv), |
1129 | - fd_sector(cur_drv) * 512); | 1226 | + fd_sector(cur_drv) * FD_SECTOR_LEN); |
1130 | if (fdctrl->data_dir != FD_DIR_WRITE || | 1227 | if (fdctrl->data_dir != FD_DIR_WRITE || |
1131 | len < FD_SECTOR_LEN || rel_pos != 0) { | 1228 | len < FD_SECTOR_LEN || rel_pos != 0) { |
1132 | /* READ & SCAN commands and realign to a sector for WRITE */ | 1229 | /* READ & SCAN commands and realign to a sector for WRITE */ |
@@ -1151,7 +1248,7 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | @@ -1151,7 +1248,7 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | ||
1151 | if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), | 1248 | if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), |
1152 | fdctrl->fifo, 1) < 0) { | 1249 | fdctrl->fifo, 1) < 0) { |
1153 | FLOPPY_ERROR("writting sector %d\n", fd_sector(cur_drv)); | 1250 | FLOPPY_ERROR("writting sector %d\n", fd_sector(cur_drv)); |
1154 | - fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); | 1251 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00); |
1155 | goto transfer_error; | 1252 | goto transfer_error; |
1156 | } | 1253 | } |
1157 | break; | 1254 | break; |
@@ -1218,7 +1315,7 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | @@ -1218,7 +1315,7 @@ static int fdctrl_transfer_handler (void *opaque, int nchan, | ||
1218 | fdctrl->data_dir == FD_DIR_SCANH) | 1315 | fdctrl->data_dir == FD_DIR_SCANH) |
1219 | status2 = 0x08; | 1316 | status2 = 0x08; |
1220 | if (FD_DID_SEEK(fdctrl->data_state)) | 1317 | if (FD_DID_SEEK(fdctrl->data_state)) |
1221 | - status0 |= 0x20; | 1318 | + status0 |= FD_SR0_SEEK; |
1222 | fdctrl->data_len -= len; | 1319 | fdctrl->data_len -= len; |
1223 | // if (fdctrl->data_len == 0) | 1320 | // if (fdctrl->data_len == 0) |
1224 | fdctrl_stop_transfer(fdctrl, status0, status1, status2); | 1321 | fdctrl_stop_transfer(fdctrl, status0, status1, status2); |
@@ -1257,7 +1354,7 @@ static uint32_t fdctrl_read_data (fdctrl_t *fdctrl) | @@ -1257,7 +1354,7 @@ static uint32_t fdctrl_read_data (fdctrl_t *fdctrl) | ||
1257 | * then from status mode to command mode | 1354 | * then from status mode to command mode |
1258 | */ | 1355 | */ |
1259 | if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) { | 1356 | if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) { |
1260 | - fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00); | 1357 | + fdctrl_stop_transfer(fdctrl, FD_SR0_SEEK, 0x00, 0x00); |
1261 | } else { | 1358 | } else { |
1262 | fdctrl_reset_fifo(fdctrl); | 1359 | fdctrl_reset_fifo(fdctrl); |
1263 | fdctrl_reset_irq(fdctrl); | 1360 | fdctrl_reset_irq(fdctrl); |
@@ -1274,7 +1371,7 @@ static void fdctrl_format_sector (fdctrl_t *fdctrl) | @@ -1274,7 +1371,7 @@ static void fdctrl_format_sector (fdctrl_t *fdctrl) | ||
1274 | uint8_t kh, kt, ks; | 1371 | uint8_t kh, kt, ks; |
1275 | int did_seek; | 1372 | int did_seek; |
1276 | 1373 | ||
1277 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1374 | + fdctrl->cur_drv = fdctrl->fifo[1] & FD_DOR_SELMASK; |
1278 | cur_drv = get_cur_drv(fdctrl); | 1375 | cur_drv = get_cur_drv(fdctrl); |
1279 | kt = fdctrl->fifo[6]; | 1376 | kt = fdctrl->fifo[6]; |
1280 | kh = fdctrl->fifo[7]; | 1377 | kh = fdctrl->fifo[7]; |
@@ -1283,24 +1380,24 @@ static void fdctrl_format_sector (fdctrl_t *fdctrl) | @@ -1283,24 +1380,24 @@ static void fdctrl_format_sector (fdctrl_t *fdctrl) | ||
1283 | fdctrl->cur_drv, kh, kt, ks, | 1380 | fdctrl->cur_drv, kh, kt, ks, |
1284 | _fd_sector(kh, kt, ks, cur_drv->last_sect)); | 1381 | _fd_sector(kh, kt, ks, cur_drv->last_sect)); |
1285 | did_seek = 0; | 1382 | did_seek = 0; |
1286 | - switch (fd_seek(cur_drv, kh, kt, ks, fdctrl->config & 0x40)) { | 1383 | + switch (fd_seek(cur_drv, kh, kt, ks, fdctrl->config & FD_CONFIG_EIS)) { |
1287 | case 2: | 1384 | case 2: |
1288 | /* sect too big */ | 1385 | /* sect too big */ |
1289 | - fdctrl_stop_transfer(fdctrl, 0x40, 0x00, 0x00); | 1386 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x00, 0x00); |
1290 | fdctrl->fifo[3] = kt; | 1387 | fdctrl->fifo[3] = kt; |
1291 | fdctrl->fifo[4] = kh; | 1388 | fdctrl->fifo[4] = kh; |
1292 | fdctrl->fifo[5] = ks; | 1389 | fdctrl->fifo[5] = ks; |
1293 | return; | 1390 | return; |
1294 | case 3: | 1391 | case 3: |
1295 | /* track too big */ | 1392 | /* track too big */ |
1296 | - fdctrl_stop_transfer(fdctrl, 0x40, 0x80, 0x00); | 1393 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x80, 0x00); |
1297 | fdctrl->fifo[3] = kt; | 1394 | fdctrl->fifo[3] = kt; |
1298 | fdctrl->fifo[4] = kh; | 1395 | fdctrl->fifo[4] = kh; |
1299 | fdctrl->fifo[5] = ks; | 1396 | fdctrl->fifo[5] = ks; |
1300 | return; | 1397 | return; |
1301 | case 4: | 1398 | case 4: |
1302 | /* No seek enabled */ | 1399 | /* No seek enabled */ |
1303 | - fdctrl_stop_transfer(fdctrl, 0x40, 0x00, 0x00); | 1400 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x00, 0x00); |
1304 | fdctrl->fifo[3] = kt; | 1401 | fdctrl->fifo[3] = kt; |
1305 | fdctrl->fifo[4] = kh; | 1402 | fdctrl->fifo[4] = kh; |
1306 | fdctrl->fifo[5] = ks; | 1403 | fdctrl->fifo[5] = ks; |
@@ -1316,13 +1413,13 @@ static void fdctrl_format_sector (fdctrl_t *fdctrl) | @@ -1316,13 +1413,13 @@ static void fdctrl_format_sector (fdctrl_t *fdctrl) | ||
1316 | if (cur_drv->bs == NULL || | 1413 | if (cur_drv->bs == NULL || |
1317 | bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) { | 1414 | bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) { |
1318 | FLOPPY_ERROR("formatting sector %d\n", fd_sector(cur_drv)); | 1415 | FLOPPY_ERROR("formatting sector %d\n", fd_sector(cur_drv)); |
1319 | - fdctrl_stop_transfer(fdctrl, 0x60, 0x00, 0x00); | 1416 | + fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK, 0x00, 0x00); |
1320 | } else { | 1417 | } else { |
1321 | if (cur_drv->sect == cur_drv->last_sect) { | 1418 | if (cur_drv->sect == cur_drv->last_sect) { |
1322 | fdctrl->data_state &= ~FD_STATE_FORMAT; | 1419 | fdctrl->data_state &= ~FD_STATE_FORMAT; |
1323 | /* Last sector done */ | 1420 | /* Last sector done */ |
1324 | if (FD_DID_SEEK(fdctrl->data_state)) | 1421 | if (FD_DID_SEEK(fdctrl->data_state)) |
1325 | - fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00); | 1422 | + fdctrl_stop_transfer(fdctrl, FD_SR0_SEEK, 0x00, 0x00); |
1326 | else | 1423 | else |
1327 | fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); | 1424 | fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); |
1328 | } else { | 1425 | } else { |
@@ -1360,43 +1457,43 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1360,43 +1457,43 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1360 | * then from status mode to command mode | 1457 | * then from status mode to command mode |
1361 | */ | 1458 | */ |
1362 | if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) | 1459 | if (FD_STATE(fdctrl->data_state) == FD_STATE_DATA) |
1363 | - fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00); | 1460 | + fdctrl_stop_transfer(fdctrl, FD_SR0_SEEK, 0x00, 0x00); |
1364 | return; | 1461 | return; |
1365 | } | 1462 | } |
1366 | if (fdctrl->data_pos == 0) { | 1463 | if (fdctrl->data_pos == 0) { |
1367 | /* Command */ | 1464 | /* Command */ |
1368 | switch (value & 0x5F) { | 1465 | switch (value & 0x5F) { |
1369 | - case 0x46: | 1466 | + case FD_CMD_READ: |
1370 | /* READ variants */ | 1467 | /* READ variants */ |
1371 | FLOPPY_DPRINTF("READ command\n"); | 1468 | FLOPPY_DPRINTF("READ command\n"); |
1372 | /* 8 parameters cmd */ | 1469 | /* 8 parameters cmd */ |
1373 | fdctrl->data_len = 9; | 1470 | fdctrl->data_len = 9; |
1374 | goto enqueue; | 1471 | goto enqueue; |
1375 | - case 0x4C: | 1472 | + case FD_CMD_READ_DELETED: |
1376 | /* READ_DELETED variants */ | 1473 | /* READ_DELETED variants */ |
1377 | FLOPPY_DPRINTF("READ_DELETED command\n"); | 1474 | FLOPPY_DPRINTF("READ_DELETED command\n"); |
1378 | /* 8 parameters cmd */ | 1475 | /* 8 parameters cmd */ |
1379 | fdctrl->data_len = 9; | 1476 | fdctrl->data_len = 9; |
1380 | goto enqueue; | 1477 | goto enqueue; |
1381 | - case 0x50: | 1478 | + case FD_CMD_SCAN_EQUAL: |
1382 | /* SCAN_EQUAL variants */ | 1479 | /* SCAN_EQUAL variants */ |
1383 | FLOPPY_DPRINTF("SCAN_EQUAL command\n"); | 1480 | FLOPPY_DPRINTF("SCAN_EQUAL command\n"); |
1384 | /* 8 parameters cmd */ | 1481 | /* 8 parameters cmd */ |
1385 | fdctrl->data_len = 9; | 1482 | fdctrl->data_len = 9; |
1386 | goto enqueue; | 1483 | goto enqueue; |
1387 | - case 0x56: | 1484 | + case FD_CMD_VERIFY: |
1388 | /* VERIFY variants */ | 1485 | /* VERIFY variants */ |
1389 | FLOPPY_DPRINTF("VERIFY command\n"); | 1486 | FLOPPY_DPRINTF("VERIFY command\n"); |
1390 | /* 8 parameters cmd */ | 1487 | /* 8 parameters cmd */ |
1391 | fdctrl->data_len = 9; | 1488 | fdctrl->data_len = 9; |
1392 | goto enqueue; | 1489 | goto enqueue; |
1393 | - case 0x59: | 1490 | + case FD_CMD_SCAN_LOW_OR_EQUAL: |
1394 | /* SCAN_LOW_OR_EQUAL variants */ | 1491 | /* SCAN_LOW_OR_EQUAL variants */ |
1395 | FLOPPY_DPRINTF("SCAN_LOW_OR_EQUAL command\n"); | 1492 | FLOPPY_DPRINTF("SCAN_LOW_OR_EQUAL command\n"); |
1396 | /* 8 parameters cmd */ | 1493 | /* 8 parameters cmd */ |
1397 | fdctrl->data_len = 9; | 1494 | fdctrl->data_len = 9; |
1398 | goto enqueue; | 1495 | goto enqueue; |
1399 | - case 0x5D: | 1496 | + case FD_CMD_SCAN_HIGH_OR_EQUAL: |
1400 | /* SCAN_HIGH_OR_EQUAL variants */ | 1497 | /* SCAN_HIGH_OR_EQUAL variants */ |
1401 | FLOPPY_DPRINTF("SCAN_HIGH_OR_EQUAL command\n"); | 1498 | FLOPPY_DPRINTF("SCAN_HIGH_OR_EQUAL command\n"); |
1402 | /* 8 parameters cmd */ | 1499 | /* 8 parameters cmd */ |
@@ -1406,13 +1503,13 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1406,13 +1503,13 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1406 | break; | 1503 | break; |
1407 | } | 1504 | } |
1408 | switch (value & 0x7F) { | 1505 | switch (value & 0x7F) { |
1409 | - case 0x45: | 1506 | + case FD_CMD_WRITE: |
1410 | /* WRITE variants */ | 1507 | /* WRITE variants */ |
1411 | FLOPPY_DPRINTF("WRITE command\n"); | 1508 | FLOPPY_DPRINTF("WRITE command\n"); |
1412 | /* 8 parameters cmd */ | 1509 | /* 8 parameters cmd */ |
1413 | fdctrl->data_len = 9; | 1510 | fdctrl->data_len = 9; |
1414 | goto enqueue; | 1511 | goto enqueue; |
1415 | - case 0x49: | 1512 | + case FD_CMD_WRITE_DELETED: |
1416 | /* WRITE_DELETED variants */ | 1513 | /* WRITE_DELETED variants */ |
1417 | FLOPPY_DPRINTF("WRITE_DELETED command\n"); | 1514 | FLOPPY_DPRINTF("WRITE_DELETED command\n"); |
1418 | /* 8 parameters cmd */ | 1515 | /* 8 parameters cmd */ |
@@ -1422,25 +1519,25 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1422,25 +1519,25 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1422 | break; | 1519 | break; |
1423 | } | 1520 | } |
1424 | switch (value) { | 1521 | switch (value) { |
1425 | - case 0x03: | 1522 | + case FD_CMD_SPECIFY: |
1426 | /* SPECIFY */ | 1523 | /* SPECIFY */ |
1427 | FLOPPY_DPRINTF("SPECIFY command\n"); | 1524 | FLOPPY_DPRINTF("SPECIFY command\n"); |
1428 | /* 1 parameter cmd */ | 1525 | /* 1 parameter cmd */ |
1429 | fdctrl->data_len = 3; | 1526 | fdctrl->data_len = 3; |
1430 | goto enqueue; | 1527 | goto enqueue; |
1431 | - case 0x04: | 1528 | + case FD_CMD_SENSE_DRIVE_STATUS: |
1432 | /* SENSE_DRIVE_STATUS */ | 1529 | /* SENSE_DRIVE_STATUS */ |
1433 | FLOPPY_DPRINTF("SENSE_DRIVE_STATUS command\n"); | 1530 | FLOPPY_DPRINTF("SENSE_DRIVE_STATUS command\n"); |
1434 | /* 1 parameter cmd */ | 1531 | /* 1 parameter cmd */ |
1435 | fdctrl->data_len = 2; | 1532 | fdctrl->data_len = 2; |
1436 | goto enqueue; | 1533 | goto enqueue; |
1437 | - case 0x07: | 1534 | + case FD_CMD_RECALIBRATE: |
1438 | /* RECALIBRATE */ | 1535 | /* RECALIBRATE */ |
1439 | FLOPPY_DPRINTF("RECALIBRATE command\n"); | 1536 | FLOPPY_DPRINTF("RECALIBRATE command\n"); |
1440 | /* 1 parameter cmd */ | 1537 | /* 1 parameter cmd */ |
1441 | fdctrl->data_len = 2; | 1538 | fdctrl->data_len = 2; |
1442 | goto enqueue; | 1539 | goto enqueue; |
1443 | - case 0x08: | 1540 | + case FD_CMD_SENSE_INTERRUPT_STATUS: |
1444 | /* SENSE_INTERRUPT_STATUS */ | 1541 | /* SENSE_INTERRUPT_STATUS */ |
1445 | FLOPPY_DPRINTF("SENSE_INTERRUPT_STATUS command (%02x)\n", | 1542 | FLOPPY_DPRINTF("SENSE_INTERRUPT_STATUS command (%02x)\n", |
1446 | fdctrl->int_status); | 1543 | fdctrl->int_status); |
@@ -1458,9 +1555,9 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1458,9 +1555,9 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1458 | fdctrl->fifo[1] = cur_drv->track; | 1555 | fdctrl->fifo[1] = cur_drv->track; |
1459 | fdctrl_set_fifo(fdctrl, 2, 0); | 1556 | fdctrl_set_fifo(fdctrl, 2, 0); |
1460 | fdctrl_reset_irq(fdctrl); | 1557 | fdctrl_reset_irq(fdctrl); |
1461 | - fdctrl->int_status = 0xC0; | 1558 | + fdctrl->int_status = FD_SR0_RDYCHG; |
1462 | return; | 1559 | return; |
1463 | - case 0x0E: | 1560 | + case FD_CMD_DUMPREG: |
1464 | /* DUMPREG */ | 1561 | /* DUMPREG */ |
1465 | FLOPPY_DPRINTF("DUMPREG command\n"); | 1562 | FLOPPY_DPRINTF("DUMPREG command\n"); |
1466 | /* Drives position */ | 1563 | /* Drives position */ |
@@ -1478,13 +1575,13 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1478,13 +1575,13 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1478 | fdctrl->fifo[9] = fdctrl->precomp_trk; | 1575 | fdctrl->fifo[9] = fdctrl->precomp_trk; |
1479 | fdctrl_set_fifo(fdctrl, 10, 0); | 1576 | fdctrl_set_fifo(fdctrl, 10, 0); |
1480 | return; | 1577 | return; |
1481 | - case 0x0F: | 1578 | + case FD_CMD_SEEK: |
1482 | /* SEEK */ | 1579 | /* SEEK */ |
1483 | FLOPPY_DPRINTF("SEEK command\n"); | 1580 | FLOPPY_DPRINTF("SEEK command\n"); |
1484 | /* 2 parameters cmd */ | 1581 | /* 2 parameters cmd */ |
1485 | fdctrl->data_len = 3; | 1582 | fdctrl->data_len = 3; |
1486 | goto enqueue; | 1583 | goto enqueue; |
1487 | - case 0x10: | 1584 | + case FD_CMD_VERSION: |
1488 | /* VERSION */ | 1585 | /* VERSION */ |
1489 | FLOPPY_DPRINTF("VERSION command\n"); | 1586 | FLOPPY_DPRINTF("VERSION command\n"); |
1490 | /* No parameters cmd */ | 1587 | /* No parameters cmd */ |
@@ -1492,19 +1589,19 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1492,19 +1589,19 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1492 | fdctrl->fifo[0] = fdctrl->version; | 1589 | fdctrl->fifo[0] = fdctrl->version; |
1493 | fdctrl_set_fifo(fdctrl, 1, 1); | 1590 | fdctrl_set_fifo(fdctrl, 1, 1); |
1494 | return; | 1591 | return; |
1495 | - case 0x12: | 1592 | + case FD_CMD_PERPENDICULAR_MODE: |
1496 | /* PERPENDICULAR_MODE */ | 1593 | /* PERPENDICULAR_MODE */ |
1497 | FLOPPY_DPRINTF("PERPENDICULAR_MODE command\n"); | 1594 | FLOPPY_DPRINTF("PERPENDICULAR_MODE command\n"); |
1498 | /* 1 parameter cmd */ | 1595 | /* 1 parameter cmd */ |
1499 | fdctrl->data_len = 2; | 1596 | fdctrl->data_len = 2; |
1500 | goto enqueue; | 1597 | goto enqueue; |
1501 | - case 0x13: | 1598 | + case FD_CMD_CONFIGURE: |
1502 | /* CONFIGURE */ | 1599 | /* CONFIGURE */ |
1503 | FLOPPY_DPRINTF("CONFIGURE command\n"); | 1600 | FLOPPY_DPRINTF("CONFIGURE command\n"); |
1504 | /* 3 parameters cmd */ | 1601 | /* 3 parameters cmd */ |
1505 | fdctrl->data_len = 4; | 1602 | fdctrl->data_len = 4; |
1506 | goto enqueue; | 1603 | goto enqueue; |
1507 | - case 0x14: | 1604 | + case FD_CMD_UNLOCK: |
1508 | /* UNLOCK */ | 1605 | /* UNLOCK */ |
1509 | FLOPPY_DPRINTF("UNLOCK command\n"); | 1606 | FLOPPY_DPRINTF("UNLOCK command\n"); |
1510 | /* No parameters cmd */ | 1607 | /* No parameters cmd */ |
@@ -1512,20 +1609,20 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1512,20 +1609,20 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1512 | fdctrl->fifo[0] = 0; | 1609 | fdctrl->fifo[0] = 0; |
1513 | fdctrl_set_fifo(fdctrl, 1, 0); | 1610 | fdctrl_set_fifo(fdctrl, 1, 0); |
1514 | return; | 1611 | return; |
1515 | - case 0x17: | 1612 | + case FD_CMD_POWERDOWN_MODE: |
1516 | /* POWERDOWN_MODE */ | 1613 | /* POWERDOWN_MODE */ |
1517 | FLOPPY_DPRINTF("POWERDOWN_MODE command\n"); | 1614 | FLOPPY_DPRINTF("POWERDOWN_MODE command\n"); |
1518 | /* 2 parameters cmd */ | 1615 | /* 2 parameters cmd */ |
1519 | fdctrl->data_len = 3; | 1616 | fdctrl->data_len = 3; |
1520 | goto enqueue; | 1617 | goto enqueue; |
1521 | - case 0x18: | 1618 | + case FD_CMD_PART_ID: |
1522 | /* PART_ID */ | 1619 | /* PART_ID */ |
1523 | FLOPPY_DPRINTF("PART_ID command\n"); | 1620 | FLOPPY_DPRINTF("PART_ID command\n"); |
1524 | /* No parameters cmd */ | 1621 | /* No parameters cmd */ |
1525 | fdctrl->fifo[0] = 0x41; /* Stepping 1 */ | 1622 | fdctrl->fifo[0] = 0x41; /* Stepping 1 */ |
1526 | fdctrl_set_fifo(fdctrl, 1, 0); | 1623 | fdctrl_set_fifo(fdctrl, 1, 0); |
1527 | return; | 1624 | return; |
1528 | - case 0x2C: | 1625 | + case FD_CMD_SAVE: |
1529 | /* SAVE */ | 1626 | /* SAVE */ |
1530 | FLOPPY_DPRINTF("SAVE command\n"); | 1627 | FLOPPY_DPRINTF("SAVE command\n"); |
1531 | /* No parameters cmd */ | 1628 | /* No parameters cmd */ |
@@ -1549,49 +1646,49 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1549,49 +1646,49 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1549 | fdctrl->fifo[14] = 0; | 1646 | fdctrl->fifo[14] = 0; |
1550 | fdctrl_set_fifo(fdctrl, 15, 1); | 1647 | fdctrl_set_fifo(fdctrl, 15, 1); |
1551 | return; | 1648 | return; |
1552 | - case 0x33: | 1649 | + case FD_CMD_OPTION: |
1553 | /* OPTION */ | 1650 | /* OPTION */ |
1554 | FLOPPY_DPRINTF("OPTION command\n"); | 1651 | FLOPPY_DPRINTF("OPTION command\n"); |
1555 | /* 1 parameter cmd */ | 1652 | /* 1 parameter cmd */ |
1556 | fdctrl->data_len = 2; | 1653 | fdctrl->data_len = 2; |
1557 | goto enqueue; | 1654 | goto enqueue; |
1558 | - case 0x42: | 1655 | + case FD_CMD_READ_TRACK: |
1559 | /* READ_TRACK */ | 1656 | /* READ_TRACK */ |
1560 | FLOPPY_DPRINTF("READ_TRACK command\n"); | 1657 | FLOPPY_DPRINTF("READ_TRACK command\n"); |
1561 | /* 8 parameters cmd */ | 1658 | /* 8 parameters cmd */ |
1562 | fdctrl->data_len = 9; | 1659 | fdctrl->data_len = 9; |
1563 | goto enqueue; | 1660 | goto enqueue; |
1564 | - case 0x4A: | 1661 | + case FD_CMD_READ_ID: |
1565 | /* READ_ID */ | 1662 | /* READ_ID */ |
1566 | FLOPPY_DPRINTF("READ_ID command\n"); | 1663 | FLOPPY_DPRINTF("READ_ID command\n"); |
1567 | /* 1 parameter cmd */ | 1664 | /* 1 parameter cmd */ |
1568 | fdctrl->data_len = 2; | 1665 | fdctrl->data_len = 2; |
1569 | goto enqueue; | 1666 | goto enqueue; |
1570 | - case 0x4C: | 1667 | + case FD_CMD_RESTORE: |
1571 | /* RESTORE */ | 1668 | /* RESTORE */ |
1572 | FLOPPY_DPRINTF("RESTORE command\n"); | 1669 | FLOPPY_DPRINTF("RESTORE command\n"); |
1573 | /* 17 parameters cmd */ | 1670 | /* 17 parameters cmd */ |
1574 | fdctrl->data_len = 18; | 1671 | fdctrl->data_len = 18; |
1575 | goto enqueue; | 1672 | goto enqueue; |
1576 | - case 0x4D: | 1673 | + case FD_CMD_FORMAT_TRACK: |
1577 | /* FORMAT_TRACK */ | 1674 | /* FORMAT_TRACK */ |
1578 | FLOPPY_DPRINTF("FORMAT_TRACK command\n"); | 1675 | FLOPPY_DPRINTF("FORMAT_TRACK command\n"); |
1579 | /* 5 parameters cmd */ | 1676 | /* 5 parameters cmd */ |
1580 | fdctrl->data_len = 6; | 1677 | fdctrl->data_len = 6; |
1581 | goto enqueue; | 1678 | goto enqueue; |
1582 | - case 0x8E: | 1679 | + case FD_CMD_DRIVE_SPECIFICATION_COMMAND: |
1583 | /* DRIVE_SPECIFICATION_COMMAND */ | 1680 | /* DRIVE_SPECIFICATION_COMMAND */ |
1584 | FLOPPY_DPRINTF("DRIVE_SPECIFICATION_COMMAND command\n"); | 1681 | FLOPPY_DPRINTF("DRIVE_SPECIFICATION_COMMAND command\n"); |
1585 | /* 5 parameters cmd */ | 1682 | /* 5 parameters cmd */ |
1586 | fdctrl->data_len = 6; | 1683 | fdctrl->data_len = 6; |
1587 | goto enqueue; | 1684 | goto enqueue; |
1588 | - case 0x8F: | 1685 | + case FD_CMD_RELATIVE_SEEK_OUT: |
1589 | /* RELATIVE_SEEK_OUT */ | 1686 | /* RELATIVE_SEEK_OUT */ |
1590 | FLOPPY_DPRINTF("RELATIVE_SEEK_OUT command\n"); | 1687 | FLOPPY_DPRINTF("RELATIVE_SEEK_OUT command\n"); |
1591 | /* 2 parameters cmd */ | 1688 | /* 2 parameters cmd */ |
1592 | fdctrl->data_len = 3; | 1689 | fdctrl->data_len = 3; |
1593 | goto enqueue; | 1690 | goto enqueue; |
1594 | - case 0x94: | 1691 | + case FD_CMD_LOCK: |
1595 | /* LOCK */ | 1692 | /* LOCK */ |
1596 | FLOPPY_DPRINTF("LOCK command\n"); | 1693 | FLOPPY_DPRINTF("LOCK command\n"); |
1597 | /* No parameters cmd */ | 1694 | /* No parameters cmd */ |
@@ -1599,13 +1696,13 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1599,13 +1696,13 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1599 | fdctrl->fifo[0] = 0x10; | 1696 | fdctrl->fifo[0] = 0x10; |
1600 | fdctrl_set_fifo(fdctrl, 1, 1); | 1697 | fdctrl_set_fifo(fdctrl, 1, 1); |
1601 | return; | 1698 | return; |
1602 | - case 0xCD: | 1699 | + case FD_CMD_FORMAT_AND_WRITE: |
1603 | /* FORMAT_AND_WRITE */ | 1700 | /* FORMAT_AND_WRITE */ |
1604 | FLOPPY_DPRINTF("FORMAT_AND_WRITE command\n"); | 1701 | FLOPPY_DPRINTF("FORMAT_AND_WRITE command\n"); |
1605 | /* 10 parameters cmd */ | 1702 | /* 10 parameters cmd */ |
1606 | fdctrl->data_len = 11; | 1703 | fdctrl->data_len = 11; |
1607 | goto enqueue; | 1704 | goto enqueue; |
1608 | - case 0xCF: | 1705 | + case FD_CMD_RELATIVE_SEEK_IN: |
1609 | /* RELATIVE_SEEK_IN */ | 1706 | /* RELATIVE_SEEK_IN */ |
1610 | FLOPPY_DPRINTF("RELATIVE_SEEK_IN command\n"); | 1707 | FLOPPY_DPRINTF("RELATIVE_SEEK_IN command\n"); |
1611 | /* 2 parameters cmd */ | 1708 | /* 2 parameters cmd */ |
@@ -1630,38 +1727,38 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1630,38 +1727,38 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1630 | return; | 1727 | return; |
1631 | } | 1728 | } |
1632 | switch (fdctrl->fifo[0] & 0x1F) { | 1729 | switch (fdctrl->fifo[0] & 0x1F) { |
1633 | - case 0x06: | 1730 | + case FD_CMD_READ & 0x1F: |
1634 | { | 1731 | { |
1635 | /* READ variants */ | 1732 | /* READ variants */ |
1636 | FLOPPY_DPRINTF("treat READ command\n"); | 1733 | FLOPPY_DPRINTF("treat READ command\n"); |
1637 | fdctrl_start_transfer(fdctrl, FD_DIR_READ); | 1734 | fdctrl_start_transfer(fdctrl, FD_DIR_READ); |
1638 | return; | 1735 | return; |
1639 | } | 1736 | } |
1640 | - case 0x0C: | 1737 | + case FD_CMD_READ_DELETED & 0x1F: |
1641 | /* READ_DELETED variants */ | 1738 | /* READ_DELETED variants */ |
1642 | // FLOPPY_DPRINTF("treat READ_DELETED command\n"); | 1739 | // FLOPPY_DPRINTF("treat READ_DELETED command\n"); |
1643 | FLOPPY_ERROR("treat READ_DELETED command\n"); | 1740 | FLOPPY_ERROR("treat READ_DELETED command\n"); |
1644 | fdctrl_start_transfer_del(fdctrl, FD_DIR_READ); | 1741 | fdctrl_start_transfer_del(fdctrl, FD_DIR_READ); |
1645 | return; | 1742 | return; |
1646 | - case 0x16: | 1743 | + case FD_CMD_VERIFY & 0x1F: |
1647 | /* VERIFY variants */ | 1744 | /* VERIFY variants */ |
1648 | // FLOPPY_DPRINTF("treat VERIFY command\n"); | 1745 | // FLOPPY_DPRINTF("treat VERIFY command\n"); |
1649 | FLOPPY_ERROR("treat VERIFY command\n"); | 1746 | FLOPPY_ERROR("treat VERIFY command\n"); |
1650 | - fdctrl_stop_transfer(fdctrl, 0x20, 0x00, 0x00); | 1747 | + fdctrl_stop_transfer(fdctrl, FD_SR0_SEEK, 0x00, 0x00); |
1651 | return; | 1748 | return; |
1652 | - case 0x10: | 1749 | + case FD_CMD_SCAN_EQUAL & 0x1F: |
1653 | /* SCAN_EQUAL variants */ | 1750 | /* SCAN_EQUAL variants */ |
1654 | // FLOPPY_DPRINTF("treat SCAN_EQUAL command\n"); | 1751 | // FLOPPY_DPRINTF("treat SCAN_EQUAL command\n"); |
1655 | FLOPPY_ERROR("treat SCAN_EQUAL command\n"); | 1752 | FLOPPY_ERROR("treat SCAN_EQUAL command\n"); |
1656 | fdctrl_start_transfer(fdctrl, FD_DIR_SCANE); | 1753 | fdctrl_start_transfer(fdctrl, FD_DIR_SCANE); |
1657 | return; | 1754 | return; |
1658 | - case 0x19: | 1755 | + case FD_CMD_SCAN_LOW_OR_EQUAL & 0x1F: |
1659 | /* SCAN_LOW_OR_EQUAL variants */ | 1756 | /* SCAN_LOW_OR_EQUAL variants */ |
1660 | // FLOPPY_DPRINTF("treat SCAN_LOW_OR_EQUAL command\n"); | 1757 | // FLOPPY_DPRINTF("treat SCAN_LOW_OR_EQUAL command\n"); |
1661 | FLOPPY_ERROR("treat SCAN_LOW_OR_EQUAL command\n"); | 1758 | FLOPPY_ERROR("treat SCAN_LOW_OR_EQUAL command\n"); |
1662 | fdctrl_start_transfer(fdctrl, FD_DIR_SCANL); | 1759 | fdctrl_start_transfer(fdctrl, FD_DIR_SCANL); |
1663 | return; | 1760 | return; |
1664 | - case 0x1D: | 1761 | + case FD_CMD_SCAN_HIGH_OR_EQUAL & 0x1F: |
1665 | /* SCAN_HIGH_OR_EQUAL variants */ | 1762 | /* SCAN_HIGH_OR_EQUAL variants */ |
1666 | // FLOPPY_DPRINTF("treat SCAN_HIGH_OR_EQUAL command\n"); | 1763 | // FLOPPY_DPRINTF("treat SCAN_HIGH_OR_EQUAL command\n"); |
1667 | FLOPPY_ERROR("treat SCAN_HIGH_OR_EQUAL command\n"); | 1764 | FLOPPY_ERROR("treat SCAN_HIGH_OR_EQUAL command\n"); |
@@ -1671,12 +1768,12 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1671,12 +1768,12 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1671 | break; | 1768 | break; |
1672 | } | 1769 | } |
1673 | switch (fdctrl->fifo[0] & 0x3F) { | 1770 | switch (fdctrl->fifo[0] & 0x3F) { |
1674 | - case 0x05: | 1771 | + case FD_CMD_WRITE & 0x3F: |
1675 | /* WRITE variants */ | 1772 | /* WRITE variants */ |
1676 | FLOPPY_DPRINTF("treat WRITE command (%02x)\n", fdctrl->fifo[0]); | 1773 | FLOPPY_DPRINTF("treat WRITE command (%02x)\n", fdctrl->fifo[0]); |
1677 | fdctrl_start_transfer(fdctrl, FD_DIR_WRITE); | 1774 | fdctrl_start_transfer(fdctrl, FD_DIR_WRITE); |
1678 | return; | 1775 | return; |
1679 | - case 0x09: | 1776 | + case FD_CMD_WRITE_DELETED & 0x3F: |
1680 | /* WRITE_DELETED variants */ | 1777 | /* WRITE_DELETED variants */ |
1681 | // FLOPPY_DPRINTF("treat WRITE_DELETED command\n"); | 1778 | // FLOPPY_DPRINTF("treat WRITE_DELETED command\n"); |
1682 | FLOPPY_ERROR("treat WRITE_DELETED command\n"); | 1779 | FLOPPY_ERROR("treat WRITE_DELETED command\n"); |
@@ -1686,7 +1783,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1686,7 +1783,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1686 | break; | 1783 | break; |
1687 | } | 1784 | } |
1688 | switch (fdctrl->fifo[0]) { | 1785 | switch (fdctrl->fifo[0]) { |
1689 | - case 0x03: | 1786 | + case FD_CMD_SPECIFY: |
1690 | /* SPECIFY */ | 1787 | /* SPECIFY */ |
1691 | FLOPPY_DPRINTF("treat SPECIFY command\n"); | 1788 | FLOPPY_DPRINTF("treat SPECIFY command\n"); |
1692 | fdctrl->timer0 = (fdctrl->fifo[1] >> 4) & 0xF; | 1789 | fdctrl->timer0 = (fdctrl->fifo[1] >> 4) & 0xF; |
@@ -1695,10 +1792,10 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1695,10 +1792,10 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1695 | /* No result back */ | 1792 | /* No result back */ |
1696 | fdctrl_reset_fifo(fdctrl); | 1793 | fdctrl_reset_fifo(fdctrl); |
1697 | break; | 1794 | break; |
1698 | - case 0x04: | 1795 | + case FD_CMD_SENSE_DRIVE_STATUS: |
1699 | /* SENSE_DRIVE_STATUS */ | 1796 | /* SENSE_DRIVE_STATUS */ |
1700 | FLOPPY_DPRINTF("treat SENSE_DRIVE_STATUS command\n"); | 1797 | FLOPPY_DPRINTF("treat SENSE_DRIVE_STATUS command\n"); |
1701 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1798 | + fdctrl->cur_drv = fdctrl->fifo[1] & FD_DOR_SELMASK; |
1702 | cur_drv = get_cur_drv(fdctrl); | 1799 | cur_drv = get_cur_drv(fdctrl); |
1703 | cur_drv->head = (fdctrl->fifo[1] >> 2) & 1; | 1800 | cur_drv->head = (fdctrl->fifo[1] >> 2) & 1; |
1704 | /* 1 Byte status back */ | 1801 | /* 1 Byte status back */ |
@@ -1709,20 +1806,20 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1709,20 +1806,20 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1709 | 0x28; | 1806 | 0x28; |
1710 | fdctrl_set_fifo(fdctrl, 1, 0); | 1807 | fdctrl_set_fifo(fdctrl, 1, 0); |
1711 | break; | 1808 | break; |
1712 | - case 0x07: | 1809 | + case FD_CMD_RECALIBRATE: |
1713 | /* RECALIBRATE */ | 1810 | /* RECALIBRATE */ |
1714 | FLOPPY_DPRINTF("treat RECALIBRATE command\n"); | 1811 | FLOPPY_DPRINTF("treat RECALIBRATE command\n"); |
1715 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1812 | + fdctrl->cur_drv = fdctrl->fifo[1] & FD_DOR_SELMASK; |
1716 | cur_drv = get_cur_drv(fdctrl); | 1813 | cur_drv = get_cur_drv(fdctrl); |
1717 | fd_recalibrate(cur_drv); | 1814 | fd_recalibrate(cur_drv); |
1718 | fdctrl_reset_fifo(fdctrl); | 1815 | fdctrl_reset_fifo(fdctrl); |
1719 | /* Raise Interrupt */ | 1816 | /* Raise Interrupt */ |
1720 | - fdctrl_raise_irq(fdctrl, 0x20); | 1817 | + fdctrl_raise_irq(fdctrl, FD_SR0_SEEK); |
1721 | break; | 1818 | break; |
1722 | - case 0x0F: | 1819 | + case FD_CMD_SEEK: |
1723 | /* SEEK */ | 1820 | /* SEEK */ |
1724 | FLOPPY_DPRINTF("treat SEEK command\n"); | 1821 | FLOPPY_DPRINTF("treat SEEK command\n"); |
1725 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1822 | + fdctrl->cur_drv = fdctrl->fifo[1] & FD_DOR_SELMASK; |
1726 | cur_drv = get_cur_drv(fdctrl); | 1823 | cur_drv = get_cur_drv(fdctrl); |
1727 | fd_start(cur_drv); | 1824 | fd_start(cur_drv); |
1728 | if (fdctrl->fifo[2] <= cur_drv->track) | 1825 | if (fdctrl->fifo[2] <= cur_drv->track) |
@@ -1731,14 +1828,14 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1731,14 +1828,14 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1731 | cur_drv->dir = 0; | 1828 | cur_drv->dir = 0; |
1732 | fdctrl_reset_fifo(fdctrl); | 1829 | fdctrl_reset_fifo(fdctrl); |
1733 | if (fdctrl->fifo[2] > cur_drv->max_track) { | 1830 | if (fdctrl->fifo[2] > cur_drv->max_track) { |
1734 | - fdctrl_raise_irq(fdctrl, 0x60); | 1831 | + fdctrl_raise_irq(fdctrl, FD_SR0_ABNTERM | FD_SR0_SEEK); |
1735 | } else { | 1832 | } else { |
1736 | cur_drv->track = fdctrl->fifo[2]; | 1833 | cur_drv->track = fdctrl->fifo[2]; |
1737 | /* Raise Interrupt */ | 1834 | /* Raise Interrupt */ |
1738 | - fdctrl_raise_irq(fdctrl, 0x20); | 1835 | + fdctrl_raise_irq(fdctrl, FD_SR0_SEEK); |
1739 | } | 1836 | } |
1740 | break; | 1837 | break; |
1741 | - case 0x12: | 1838 | + case FD_CMD_PERPENDICULAR_MODE: |
1742 | /* PERPENDICULAR_MODE */ | 1839 | /* PERPENDICULAR_MODE */ |
1743 | FLOPPY_DPRINTF("treat PERPENDICULAR_MODE command\n"); | 1840 | FLOPPY_DPRINTF("treat PERPENDICULAR_MODE command\n"); |
1744 | if (fdctrl->fifo[1] & 0x80) | 1841 | if (fdctrl->fifo[1] & 0x80) |
@@ -1746,7 +1843,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1746,7 +1843,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1746 | /* No result back */ | 1843 | /* No result back */ |
1747 | fdctrl_reset_fifo(fdctrl); | 1844 | fdctrl_reset_fifo(fdctrl); |
1748 | break; | 1845 | break; |
1749 | - case 0x13: | 1846 | + case FD_CMD_CONFIGURE: |
1750 | /* CONFIGURE */ | 1847 | /* CONFIGURE */ |
1751 | FLOPPY_DPRINTF("treat CONFIGURE command\n"); | 1848 | FLOPPY_DPRINTF("treat CONFIGURE command\n"); |
1752 | fdctrl->config = fdctrl->fifo[2]; | 1849 | fdctrl->config = fdctrl->fifo[2]; |
@@ -1754,26 +1851,26 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1754,26 +1851,26 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1754 | /* No result back */ | 1851 | /* No result back */ |
1755 | fdctrl_reset_fifo(fdctrl); | 1852 | fdctrl_reset_fifo(fdctrl); |
1756 | break; | 1853 | break; |
1757 | - case 0x17: | 1854 | + case FD_CMD_POWERDOWN_MODE: |
1758 | /* POWERDOWN_MODE */ | 1855 | /* POWERDOWN_MODE */ |
1759 | FLOPPY_DPRINTF("treat POWERDOWN_MODE command\n"); | 1856 | FLOPPY_DPRINTF("treat POWERDOWN_MODE command\n"); |
1760 | fdctrl->pwrd = fdctrl->fifo[1]; | 1857 | fdctrl->pwrd = fdctrl->fifo[1]; |
1761 | fdctrl->fifo[0] = fdctrl->fifo[1]; | 1858 | fdctrl->fifo[0] = fdctrl->fifo[1]; |
1762 | fdctrl_set_fifo(fdctrl, 1, 1); | 1859 | fdctrl_set_fifo(fdctrl, 1, 1); |
1763 | break; | 1860 | break; |
1764 | - case 0x33: | 1861 | + case FD_CMD_OPTION: |
1765 | /* OPTION */ | 1862 | /* OPTION */ |
1766 | FLOPPY_DPRINTF("treat OPTION command\n"); | 1863 | FLOPPY_DPRINTF("treat OPTION command\n"); |
1767 | /* No result back */ | 1864 | /* No result back */ |
1768 | fdctrl_reset_fifo(fdctrl); | 1865 | fdctrl_reset_fifo(fdctrl); |
1769 | break; | 1866 | break; |
1770 | - case 0x42: | 1867 | + case FD_CMD_READ_TRACK: |
1771 | /* READ_TRACK */ | 1868 | /* READ_TRACK */ |
1772 | -// FLOPPY_DPRINTF("treat READ_TRACK command\n"); | 1869 | + FLOPPY_DPRINTF("treat READ_TRACK command\n"); |
1773 | FLOPPY_ERROR("treat READ_TRACK command\n"); | 1870 | FLOPPY_ERROR("treat READ_TRACK command\n"); |
1774 | fdctrl_start_transfer(fdctrl, FD_DIR_READ); | 1871 | fdctrl_start_transfer(fdctrl, FD_DIR_READ); |
1775 | break; | 1872 | break; |
1776 | - case 0x4A: | 1873 | + case FD_CMD_READ_ID: |
1777 | /* READ_ID */ | 1874 | /* READ_ID */ |
1778 | FLOPPY_DPRINTF("treat READ_ID command\n"); | 1875 | FLOPPY_DPRINTF("treat READ_ID command\n"); |
1779 | /* XXX: should set main status register to busy */ | 1876 | /* XXX: should set main status register to busy */ |
@@ -1781,7 +1878,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1781,7 +1878,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1781 | qemu_mod_timer(fdctrl->result_timer, | 1878 | qemu_mod_timer(fdctrl->result_timer, |
1782 | qemu_get_clock(vm_clock) + (ticks_per_sec / 50)); | 1879 | qemu_get_clock(vm_clock) + (ticks_per_sec / 50)); |
1783 | break; | 1880 | break; |
1784 | - case 0x4C: | 1881 | + case FD_CMD_RESTORE: |
1785 | /* RESTORE */ | 1882 | /* RESTORE */ |
1786 | FLOPPY_DPRINTF("treat RESTORE command\n"); | 1883 | FLOPPY_DPRINTF("treat RESTORE command\n"); |
1787 | /* Drives position */ | 1884 | /* Drives position */ |
@@ -1798,10 +1895,10 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1798,10 +1895,10 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1798 | fdctrl->pwrd = fdctrl->fifo[13]; | 1895 | fdctrl->pwrd = fdctrl->fifo[13]; |
1799 | fdctrl_reset_fifo(fdctrl); | 1896 | fdctrl_reset_fifo(fdctrl); |
1800 | break; | 1897 | break; |
1801 | - case 0x4D: | 1898 | + case FD_CMD_FORMAT_TRACK: |
1802 | /* FORMAT_TRACK */ | 1899 | /* FORMAT_TRACK */ |
1803 | FLOPPY_DPRINTF("treat FORMAT_TRACK command\n"); | 1900 | FLOPPY_DPRINTF("treat FORMAT_TRACK command\n"); |
1804 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1901 | + fdctrl->cur_drv = fdctrl->fifo[1] & FD_DOR_SELMASK; |
1805 | cur_drv = get_cur_drv(fdctrl); | 1902 | cur_drv = get_cur_drv(fdctrl); |
1806 | fdctrl->data_state |= FD_STATE_FORMAT; | 1903 | fdctrl->data_state |= FD_STATE_FORMAT; |
1807 | if (fdctrl->fifo[0] & 0x80) | 1904 | if (fdctrl->fifo[0] & 0x80) |
@@ -1825,7 +1922,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1825,7 +1922,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1825 | fdctrl->data_state &= ~FD_STATE_FORMAT; | 1922 | fdctrl->data_state &= ~FD_STATE_FORMAT; |
1826 | fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); | 1923 | fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00); |
1827 | break; | 1924 | break; |
1828 | - case 0x8E: | 1925 | + case FD_CMD_DRIVE_SPECIFICATION_COMMAND: |
1829 | /* DRIVE_SPECIFICATION_COMMAND */ | 1926 | /* DRIVE_SPECIFICATION_COMMAND */ |
1830 | FLOPPY_DPRINTF("treat DRIVE_SPECIFICATION_COMMAND command\n"); | 1927 | FLOPPY_DPRINTF("treat DRIVE_SPECIFICATION_COMMAND command\n"); |
1831 | if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x80) { | 1928 | if (fdctrl->fifo[fdctrl->data_pos - 1] & 0x80) { |
@@ -1845,10 +1942,10 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1845,10 +1942,10 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1845 | fdctrl_set_fifo(fdctrl, 1, 1); | 1942 | fdctrl_set_fifo(fdctrl, 1, 1); |
1846 | } | 1943 | } |
1847 | break; | 1944 | break; |
1848 | - case 0x8F: | 1945 | + case FD_CMD_RELATIVE_SEEK_OUT: |
1849 | /* RELATIVE_SEEK_OUT */ | 1946 | /* RELATIVE_SEEK_OUT */ |
1850 | FLOPPY_DPRINTF("treat RELATIVE_SEEK_OUT command\n"); | 1947 | FLOPPY_DPRINTF("treat RELATIVE_SEEK_OUT command\n"); |
1851 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1948 | + fdctrl->cur_drv = fdctrl->fifo[1] & FD_DOR_SELMASK; |
1852 | cur_drv = get_cur_drv(fdctrl); | 1949 | cur_drv = get_cur_drv(fdctrl); |
1853 | fd_start(cur_drv); | 1950 | fd_start(cur_drv); |
1854 | cur_drv->dir = 0; | 1951 | cur_drv->dir = 0; |
@@ -1858,18 +1955,18 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1858,18 +1955,18 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1858 | cur_drv->track += fdctrl->fifo[2]; | 1955 | cur_drv->track += fdctrl->fifo[2]; |
1859 | } | 1956 | } |
1860 | fdctrl_reset_fifo(fdctrl); | 1957 | fdctrl_reset_fifo(fdctrl); |
1861 | - fdctrl_raise_irq(fdctrl, 0x20); | 1958 | + fdctrl_raise_irq(fdctrl, FD_SR0_SEEK); |
1862 | break; | 1959 | break; |
1863 | - case 0xCD: | 1960 | + case FD_CMD_FORMAT_AND_WRITE: |
1864 | /* FORMAT_AND_WRITE */ | 1961 | /* FORMAT_AND_WRITE */ |
1865 | -// FLOPPY_DPRINTF("treat FORMAT_AND_WRITE command\n"); | 1962 | + FLOPPY_DPRINTF("treat FORMAT_AND_WRITE command\n"); |
1866 | FLOPPY_ERROR("treat FORMAT_AND_WRITE command\n"); | 1963 | FLOPPY_ERROR("treat FORMAT_AND_WRITE command\n"); |
1867 | fdctrl_unimplemented(fdctrl); | 1964 | fdctrl_unimplemented(fdctrl); |
1868 | break; | 1965 | break; |
1869 | - case 0xCF: | 1966 | + case FD_CMD_RELATIVE_SEEK_IN: |
1870 | /* RELATIVE_SEEK_IN */ | 1967 | /* RELATIVE_SEEK_IN */ |
1871 | FLOPPY_DPRINTF("treat RELATIVE_SEEK_IN command\n"); | 1968 | FLOPPY_DPRINTF("treat RELATIVE_SEEK_IN command\n"); |
1872 | - fdctrl->cur_drv = fdctrl->fifo[1] & 1; | 1969 | + fdctrl->cur_drv = fdctrl->fifo[1] & FD_DOR_SELMASK; |
1873 | cur_drv = get_cur_drv(fdctrl); | 1970 | cur_drv = get_cur_drv(fdctrl); |
1874 | fd_start(cur_drv); | 1971 | fd_start(cur_drv); |
1875 | cur_drv->dir = 1; | 1972 | cur_drv->dir = 1; |
@@ -1880,7 +1977,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | @@ -1880,7 +1977,7 @@ static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) | ||
1880 | } | 1977 | } |
1881 | fdctrl_reset_fifo(fdctrl); | 1978 | fdctrl_reset_fifo(fdctrl); |
1882 | /* Raise Interrupt */ | 1979 | /* Raise Interrupt */ |
1883 | - fdctrl_raise_irq(fdctrl, 0x20); | 1980 | + fdctrl_raise_irq(fdctrl, FD_SR0_SEEK); |
1884 | break; | 1981 | break; |
1885 | } | 1982 | } |
1886 | } | 1983 | } |