On 10 May 2013 17:10, Igor Mitsyanko <i.mitsya...@gmail.com> wrote: > Signed-off-by: Igor Mitsyanko <i.mitsya...@gmail.com> > --- > hw/sd/sd.c | 145 > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 133 insertions(+), 12 deletions(-) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index 659ec56..615ab61 100644 > --- a/hw/sd/sd.c > +++ b/hw/sd/sd.c > @@ -958,6 +958,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, > sd->state = sd_programming_state; > /* Bzzzzzzztt .... Operation complete. */ > sd->state = sd_transfer_state; > + sd->transf_cnt = 0; > + if (sd->aiocb) { > + bdrv_aio_cancel(sd->aiocb); > + sd->aiocb = NULL; > + } > return sd_r1b; > > default: > @@ -1600,6 +1605,90 @@ static void sd_blk_write(SDState *sd, uint64_t addr, > uint32_t len) > #define APP_READ_BLOCK(a, len) memset(sd->data, 0xec, len) > #define APP_WRITE_BLOCK(a, len) > > +static void sd_write_done(void *opaque, int ret) > +{ > + SDState *sd = opaque; > + > + DPRINTF("sd_write_done: ret = %d\n", ret); > + sd->aiocb = NULL; > + > + if (ret != 0) { > + return; > + } > + > + switch (sd->current_cmd) { > + case 24: /* CMD24: WRITE_SINGLE_BLOCK */ > + sd->blk_written++; > + sd->csd[14] |= 0x40; > + /* Bzzzzzzztt .... Operation complete. */
These 'bzzzzt' comments don't really apply to the async interface, I think -- they're a kind of joke about the fact that some of these commands which take a long time on hardware are (were) completely synchronous in the QEMU model and so the 'operation' is indicated as taking place via the 'bzzzt' sound effect. -- PMM