[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/23] hw/sd: Add sdbus_write_data() to write multiples bytes on t
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 18/23] hw/sd: Add sdbus_write_data() to write multiples bytes on the data line |
Date: |
Fri, 21 Aug 2020 19:29:11 +0200 |
Add a sdbus_write_data() method to write 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-5-f4bug@amsat.org>
---
include/hw/sd/sd.h | 9 +++++++++
hw/sd/core.c | 15 +++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h
index 14ffc7f4758..3ae3e8939b3 100644
--- a/include/hw/sd/sd.h
+++ b/include/hw/sd/sd.h
@@ -175,6 +175,15 @@ void sdbus_write_byte(SDBus *sd, uint8_t value);
* Return: byte value read
*/
uint8_t sdbus_read_byte(SDBus *sd);
+/**
+ * Write data to a SD bus.
+ * @sdbus: bus
+ * @buf: data to write
+ * @length: number of bytes to write
+ *
+ * Write multiple bytes of data on the data lines of a SD bus.
+ */
+void sdbus_write_data(SDBus *sdbus, const void *buf, size_t length);
bool sdbus_data_ready(SDBus *sd);
bool sdbus_get_inserted(SDBus *sd);
bool sdbus_get_readonly(SDBus *sd);
diff --git a/hw/sd/core.c b/hw/sd/core.c
index a3b620b802b..9c2781ebf96 100644
--- a/hw/sd/core.c
+++ b/hw/sd/core.c
@@ -114,6 +114,21 @@ void sdbus_write_byte(SDBus *sdbus, uint8_t value)
}
}
+void sdbus_write_data(SDBus *sdbus, const void *buf, size_t length)
+{
+ SDState *card = get_card(sdbus);
+ const uint8_t *data = buf;
+
+ if (card) {
+ SDCardClass *sc = SD_CARD_GET_CLASS(card);
+
+ for (size_t i = 0; i < length; i++) {
+ trace_sdbus_write(sdbus_name(sdbus), data[i]);
+ sc->write_byte(card, data[i]);
+ }
+ }
+}
+
uint8_t sdbus_read_byte(SDBus *sdbus)
{
SDState *card = get_card(sdbus);
--
2.26.2
- [PULL 07/23] hw/sd/pl181: Rename pl181_send_command() as pl181_do_command(), (continued)
- [PULL 07/23] hw/sd/pl181: Rename pl181_send_command() as pl181_do_command(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 08/23] hw/sd/pl181: Add TODO to use Fifo32 API, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 09/23] hw/sd/pl181: Use named GPIOs, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 10/23] hw/sd/pl181: Expose a SDBus and connect the SDCard to it, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 11/23] hw/sd/pl181: Do not create SD card within the SD host controller, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 12/23] hw/sd/pl181: Replace disabled fprintf()s by trace events, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 14/23] hw/sd: Move sdcard legacy API to 'hw/sd/sdcard_legacy.h', Philippe Mathieu-Daudé, 2020/08/21
- [PULL 13/23] hw/sd/sdcard: Make sd_data_ready() static, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 15/23] hw/sd: Rename read/write_data() as read/write_byte(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 16/23] hw/sd: Rename sdbus_write_data() as sdbus_write_byte(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 18/23] hw/sd: Add sdbus_write_data() to write multiples bytes on the data line,
Philippe Mathieu-Daudé <=
- [PULL 20/23] hw/sd: Add sdbus_read_data() to read multiples bytes on the data line, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 17/23] hw/sd: Rename sdbus_read_data() as sdbus_read_byte(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 21/23] hw/sd: Use sdbus_read_data() instead of sdbus_read_byte() when possible, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 19/23] hw/sd: Use sdbus_write_data() instead of sdbus_write_byte when possible, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 23/23] hw/sd: Correct the maximum size of a Standard Capacity SD Memory Card, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 22/23] hw/sd: Fix incorrect populated function switch status data structure, Philippe Mathieu-Daudé, 2020/08/21
- Re: [PULL 00/23] SD/MMC patches for 2020-08-21, Peter Maydell, 2020/08/23