fdc: Use phase in fdctrl_write_data()
Instead of relying on a flag in the MSR to distinguish controller phases, use the explicit phase that we store now. Assertions of the right MSR flags are added. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 1432214378-31891-5-git-send-email-kwolf@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
This commit is contained in:
parent
85d291a08c
commit
5b0a25e8d2
|
@ -2059,8 +2059,12 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
|
|||
return;
|
||||
}
|
||||
fdctrl->dsr &= ~FD_DSR_PWRDOWN;
|
||||
/* Is it write command time ? */
|
||||
if (fdctrl->msr & FD_MSR_NONDMA) {
|
||||
|
||||
switch (fdctrl->phase) {
|
||||
case FD_PHASE_EXECUTION:
|
||||
/* For DMA requests, RQM should be cleared during execution phase, so
|
||||
* we would have errored out above. */
|
||||
assert(fdctrl->msr & FD_MSR_NONDMA);
|
||||
/* FIFO data write */
|
||||
pos = fdctrl->data_pos++;
|
||||
pos %= FD_SECTOR_LEN;
|
||||
|
@ -2072,12 +2076,12 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
|
|||
< 0) {
|
||||
FLOPPY_DPRINTF("error writing sector %d\n",
|
||||
fd_sector(cur_drv));
|
||||
return;
|
||||
break;
|
||||
}
|
||||
if (!fdctrl_seek_to_next_sect(fdctrl, cur_drv)) {
|
||||
FLOPPY_DPRINTF("error seeking to next sector %d\n",
|
||||
fd_sector(cur_drv));
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Switch from transfer mode to status mode
|
||||
|
@ -2085,8 +2089,11 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
|
|||
*/
|
||||
if (fdctrl->data_pos == fdctrl->data_len)
|
||||
fdctrl_stop_transfer(fdctrl, 0x00, 0x00, 0x00);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case FD_PHASE_COMMAND:
|
||||
assert(!(fdctrl->msr & FD_MSR_NONDMA));
|
||||
|
||||
if (fdctrl->data_pos == 0) {
|
||||
/* Command */
|
||||
pos = command_to_handler[value & 0xff];
|
||||
|
@ -2106,13 +2113,19 @@ static void fdctrl_write_data(FDCtrl *fdctrl, uint32_t value)
|
|||
fdctrl->phase = FD_PHASE_EXECUTION;
|
||||
if (fdctrl->data_state & FD_STATE_FORMAT) {
|
||||
fdctrl_format_sector(fdctrl);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
pos = command_to_handler[fdctrl->fifo[0] & 0xff];
|
||||
FLOPPY_DPRINTF("treat %s command\n", handlers[pos].name);
|
||||
(*handlers[pos].handler)(fdctrl, handlers[pos].direction);
|
||||
}
|
||||
break;
|
||||
|
||||
case FD_PHASE_RESULT:
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static void fdctrl_result_timer(void *opaque)
|
||||
|
|
Loading…
Reference in a new issue