Message ID | 20240628070216.92609-26-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/sd/sdcard: Add eMMC support | expand |
On 6/28/24 9:01 AM, Philippe Mathieu-Daudé wrote: > From: Philippe Mathieu-Daudé <f4bug@amsat.org> > > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Cédric Le Goater <clg@redhat.com> Thanks, C. > --- > hw/sd/sd.c | 19 +++++++------------ > 1 file changed, 7 insertions(+), 12 deletions(-) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index bf922da2cc..ccf81b9e59 100644 > --- a/hw/sd/sd.c > +++ b/hw/sd/sd.c > @@ -1648,10 +1648,12 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > switch (sd->state) { > case sd_transfer_state: > sd->data_offset = 0; > - if (req.arg & 1) > - sd->state = sd_sendingdata_state; > - else > - sd->state = sd_receivingdata_state; > + if (req.arg & 1) { > + return sd_cmd_to_sendingdata(sd, req, 0, > + sd->vendor_data, > + sizeof(sd->vendor_data)); > + } > + sd->state = sd_receivingdata_state; > return sd_r1; > > default: > @@ -2137,6 +2139,7 @@ uint8_t sd_read_byte(SDState *sd) > case 17: /* CMD17: READ_SINGLE_BLOCK */ > case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ > case 30: /* CMD30: SEND_WRITE_PROT */ > + case 56: /* CMD56: GEN_CMD */ > sd_generic_read_byte(sd, &ret); > break; > > @@ -2185,14 +2188,6 @@ uint8_t sd_read_byte(SDState *sd) > sd->state = sd_transfer_state; > break; > > - case 56: /* CMD56: GEN_CMD */ > - ret = sd->vendor_data[sd->data_offset ++]; > - > - if (sd->data_offset >= sizeof(sd->vendor_data)) { > - sd->state = sd_transfer_state; > - } > - break; > - > default: > qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); > return 0x00;
diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bf922da2cc..ccf81b9e59 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1648,10 +1648,12 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (sd->state) { case sd_transfer_state: sd->data_offset = 0; - if (req.arg & 1) - sd->state = sd_sendingdata_state; - else - sd->state = sd_receivingdata_state; + if (req.arg & 1) { + return sd_cmd_to_sendingdata(sd, req, 0, + sd->vendor_data, + sizeof(sd->vendor_data)); + } + sd->state = sd_receivingdata_state; return sd_r1; default: @@ -2137,6 +2139,7 @@ uint8_t sd_read_byte(SDState *sd) case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ case 30: /* CMD30: SEND_WRITE_PROT */ + case 56: /* CMD56: GEN_CMD */ sd_generic_read_byte(sd, &ret); break; @@ -2185,14 +2188,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 56: /* CMD56: GEN_CMD */ - ret = sd->vendor_data[sd->data_offset ++]; - - if (sd->data_offset >= sizeof(sd->vendor_data)) { - sd->state = sd_transfer_state; - } - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); return 0x00;