diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2020-08-14 11:23:45 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2020-08-21 16:35:35 +0200 |
commit | 6505a91a77d4efcc6d54b35851abcb137cdca30a (patch) | |
tree | 8543fa20445bc3eefd30cfa9588f77cbeab4f2b3 /hw/sd/core.c | |
parent | 62a21be60f8fdf0223fa099fb4e7a495eaf55cf9 (diff) |
hw/sd: Add sdbus_read_data() to read multiples bytes on the data line
Add a sdbus_read_data() method to read multiple bytes on the
data line of a SD bus.
We might improve the tracing later, for now keep logging each
byte individually.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200814092346.21825-7-f4bug@amsat.org>
Diffstat (limited to 'hw/sd/core.c')
-rw-r--r-- | hw/sd/core.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/hw/sd/core.c b/hw/sd/core.c index 9c2781ebf9..957d116f1a 100644 --- a/hw/sd/core.c +++ b/hw/sd/core.c @@ -144,6 +144,21 @@ uint8_t sdbus_read_byte(SDBus *sdbus) return value; } +void sdbus_read_data(SDBus *sdbus, void *buf, size_t length) +{ + SDState *card = get_card(sdbus); + uint8_t *data = buf; + + if (card) { + SDCardClass *sc = SD_CARD_GET_CLASS(card); + + for (size_t i = 0; i < length; i++) { + data[i] = sc->read_byte(card); + trace_sdbus_read(sdbus_name(sdbus), data[i]); + } + } +} + bool sdbus_data_ready(SDBus *sdbus) { SDState *card = get_card(sdbus); |