Commit 9fea808abf6f5295b39f43f9b394ea16d65b6d46

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