提交 06b95b1e 编写于 作者: P Paolo Bonzini 提交者: Kevin Wolf

ide: start extracting ide_restart_dma out of bmdma_restart_dma

This patch begins refactoring the restart dma functions
out of bmdma to be shared with AHCI and other future
IDE HBA implementations.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NJohn Snow <jsnow@redhat.com>
Message-id: 1424708286-16483-2-git-send-email-jsnow@redhat.com
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 0eb28a42
...@@ -184,18 +184,24 @@ static void bmdma_set_inactive(IDEDMA *dma, bool more) ...@@ -184,18 +184,24 @@ static void bmdma_set_inactive(IDEDMA *dma, bool more)
} }
} }
static void bmdma_restart_dma(BMDMAState *bm, enum ide_dma_cmd dma_cmd) static void bmdma_restart_dma(BMDMAState *bm)
{ {
IDEState *s = bmdma_active_if(bm); IDEState *s = bmdma_active_if(bm);
ide_set_sector(s, bm->sector_num); ide_set_sector(s, bm->sector_num);
s->nsector = bm->nsector;
bm->cur_addr = bm->addr;
}
static void ide_restart_dma(IDEState *s, enum ide_dma_cmd dma_cmd)
{
BMDMAState *bm = DO_UPCAST(BMDMAState, dma, s->bus->dma);
bmdma_restart_dma(bm);
s->io_buffer_index = 0; s->io_buffer_index = 0;
s->io_buffer_size = 0; s->io_buffer_size = 0;
s->nsector = bm->nsector;
s->dma_cmd = dma_cmd; s->dma_cmd = dma_cmd;
bm->cur_addr = bm->addr; bmdma_start_dma(&bm->dma, s, ide_dma_cb);
bm->dma_cb = ide_dma_cb;
bmdma_start_dma(&bm->dma, s, bm->dma_cb);
} }
/* TODO This should be common IDE code */ /* TODO This should be common IDE code */
...@@ -203,6 +209,7 @@ static void bmdma_restart_bh(void *opaque) ...@@ -203,6 +209,7 @@ static void bmdma_restart_bh(void *opaque)
{ {
BMDMAState *bm = opaque; BMDMAState *bm = opaque;
IDEBus *bus = bm->bus; IDEBus *bus = bm->bus;
IDEState *s;
bool is_read; bool is_read;
int error_status; int error_status;
...@@ -213,6 +220,7 @@ static void bmdma_restart_bh(void *opaque) ...@@ -213,6 +220,7 @@ static void bmdma_restart_bh(void *opaque)
return; return;
} }
s = bmdma_active_if(bm);
is_read = (bus->error_status & IDE_RETRY_READ) != 0; is_read = (bus->error_status & IDE_RETRY_READ) != 0;
/* The error status must be cleared before resubmitting the request: The /* The error status must be cleared before resubmitting the request: The
...@@ -223,18 +231,18 @@ static void bmdma_restart_bh(void *opaque) ...@@ -223,18 +231,18 @@ static void bmdma_restart_bh(void *opaque)
if (error_status & IDE_RETRY_DMA) { if (error_status & IDE_RETRY_DMA) {
if (error_status & IDE_RETRY_TRIM) { if (error_status & IDE_RETRY_TRIM) {
bmdma_restart_dma(bm, IDE_DMA_TRIM); ide_restart_dma(s, IDE_DMA_TRIM);
} else { } else {
bmdma_restart_dma(bm, is_read ? IDE_DMA_READ : IDE_DMA_WRITE); ide_restart_dma(s, is_read ? IDE_DMA_READ : IDE_DMA_WRITE);
} }
} else if (error_status & IDE_RETRY_PIO) { } else if (error_status & IDE_RETRY_PIO) {
if (is_read) { if (is_read) {
ide_sector_read(bmdma_active_if(bm)); ide_sector_read(s);
} else { } else {
ide_sector_write(bmdma_active_if(bm)); ide_sector_write(s);
} }
} else if (error_status & IDE_RETRY_FLUSH) { } else if (error_status & IDE_RETRY_FLUSH) {
ide_flush_cache(bmdma_active_if(bm)); ide_flush_cache(s);
} else { } else {
IDEState *s = bmdma_active_if(bm); IDEState *s = bmdma_active_if(bm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册