[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/23] hw/sd: Fix incorrect populated function switch status data
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 22/23] hw/sd: Fix incorrect populated function switch status data structure |
Date: |
Fri, 21 Aug 2020 19:29:15 +0200 |
From: Bin Meng <bin.meng@windriver.com>
At present the function switch status data structure bit [399:376]
are wrongly pupulated. These 3 bytes encode function switch status
for the 6 function groups, with 4 bits per group, starting from
function group 6 at bit 399, then followed by function group 5 at
bit 395, and so on.
However the codes mistakenly fills in the function group 1 status
at bit 399. This fixes the code logic.
Fixes: a1bb27b1e9 ("SD card emulation (initial implementation)")
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
Message-Id: <1598021136-49525-1-git-send-email-bmeng.cn@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/sd/sd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 7c9d956f113..805e21fc883 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -807,11 +807,12 @@ static void sd_function_switch(SDState *sd, uint32_t arg)
sd->data[11] = 0x43;
sd->data[12] = 0x80; /* Supported group 1 functions */
sd->data[13] = 0x03;
+
for (i = 0; i < 6; i ++) {
new_func = (arg >> (i * 4)) & 0x0f;
if (mode && new_func != 0x0f)
sd->function_group[i] = new_func;
- sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4);
+ sd->data[16 - (i >> 1)] |= new_func << ((i % 2) * 4);
}
memset(&sd->data[17], 0, 47);
stw_be_p(sd->data + 64, sd_crc16(sd->data, 64));
--
2.26.2
- [PULL 14/23] hw/sd: Move sdcard legacy API to 'hw/sd/sdcard_legacy.h', (continued)
- [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é, 2020/08/21
- [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é <=
- Re: [PULL 00/23] SD/MMC patches for 2020-08-21, Peter Maydell, 2020/08/23