From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Alistair Francis <alistair.francis@xilinx.com>,
"Edgar E . Iglesias" <edgar.iglesias@xilinx.com>,
Peter Maydell <peter.maydell@linaro.org>,
Andrew Baumann <Andrew.Baumann@microsoft.com>,
Prasad J Pandit <pjp@fedoraproject.org>,
Clement Deschamps <clement.deschamps@antfield.fr>,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-devel@nongnu.org,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
"Sai Pavan Boddu" <saipava@xilinx.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PATCH 03/26] sdcard: use ldst API
Date: Wed, 13 Dec 2017 20:20:02 -0300 [thread overview]
Message-ID: <20171213232025.24503-4-f4bug@amsat.org> (raw)
In-Reply-To: <20171213232025.24503-1-f4bug@amsat.org>
To keep the code way easier to review!
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/sd/sd.c | 51 ++++++++++++++-------------------------------------
1 file changed, 14 insertions(+), 37 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 8e12b07ee4..9b3745a019 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -352,10 +352,7 @@ static int sd_req_crc_validate(SDRequest *req)
{
uint8_t buffer[5];
buffer[0] = 0x40 | req->cmd;
- buffer[1] = (req->arg >> 24) & 0xff;
- buffer[2] = (req->arg >> 16) & 0xff;
- buffer[3] = (req->arg >> 8) & 0xff;
- buffer[4] = (req->arg >> 0) & 0xff;
+ stl_be_p(buffer + 1, req->arg);
return 0;
return sd_crc7(buffer, 5) != req->crc; /* TODO */
}
@@ -365,19 +362,12 @@ static void sd_response_r1_make(SDState *sd, uint8_t *response)
uint32_t status = sd->card_status;
/* Clear the "clear on read" status bits */
sd->card_status &= ~CARD_STATUS_C;
-
- response[0] = (status >> 24) & 0xff;
- response[1] = (status >> 16) & 0xff;
- response[2] = (status >> 8) & 0xff;
- response[3] = (status >> 0) & 0xff;
+ stl_be_p(response, status);
}
static void sd_response_r3_make(SDState *sd, uint8_t *response)
{
- response[0] = (sd->ocr >> 24) & 0xff;
- response[1] = (sd->ocr >> 16) & 0xff;
- response[2] = (sd->ocr >> 8) & 0xff;
- response[3] = (sd->ocr >> 0) & 0xff;
+ stl_be_p(response, sd->ocr);
}
static void sd_response_r6_make(SDState *sd, uint8_t *response)
@@ -390,19 +380,14 @@ static void sd_response_r6_make(SDState *sd, uint8_t *response)
((sd->card_status >> 6) & 0x2000) |
(sd->card_status & 0x1fff);
sd->card_status &= ~(CARD_STATUS_C & 0xc81fff);
+ stw_be_p(response + 0, arg);
+ stw_be_p(response + 2, status);
- response[0] = (arg >> 8) & 0xff;
- response[1] = arg & 0xff;
- response[2] = (status >> 8) & 0xff;
- response[3] = status & 0xff;
}
static void sd_response_r7_make(SDState *sd, uint8_t *response)
{
- response[0] = (sd->vhs >> 24) & 0xff;
- response[1] = (sd->vhs >> 16) & 0xff;
- response[2] = (sd->vhs >> 8) & 0xff;
- response[3] = (sd->vhs >> 0) & 0xff;
+ stl_be_p(response, sd->vhs);
}
static inline uint64_t sd_addr_to_wpnum(uint64_t addr)
@@ -644,20 +629,13 @@ static void sd_function_switch(SDState *sd, uint32_t arg)
int i, mode, new_func, crc;
mode = !!(arg & 0x80000000);
- sd->data[0] = 0x00; /* Maximum current consumption */
- sd->data[1] = 0x01;
- sd->data[2] = 0x80; /* Supported group 6 functions */
- sd->data[3] = 0x01;
- sd->data[4] = 0x80; /* Supported group 5 functions */
- sd->data[5] = 0x01;
- sd->data[6] = 0x80; /* Supported group 4 functions */
- sd->data[7] = 0x01;
- sd->data[8] = 0x80; /* Supported group 3 functions */
- sd->data[9] = 0x01;
- sd->data[10] = 0x80; /* Supported group 2 functions */
- sd->data[11] = 0x43;
- sd->data[12] = 0x80; /* Supported group 1 functions */
- sd->data[13] = 0x03;
+ stw_be_p(sd->data + 0, 1); /* Maximum current consumption */
+ stw_be_p(sd->data + 2, 0x8001); /* Supported group 6 functions */
+ stw_be_p(sd->data + 4, 0x8001); /* Supported group 5 functions */
+ stw_be_p(sd->data + 6, 0x8001); /* Supported group 4 functions */
+ stw_be_p(sd->data + 8, 0x8001); /* Supported group 3 functions */
+ stw_be_p(sd->data + 10, 0x8043); /* Supported group 2 functions */
+ stw_be_p(sd->data + 12, 0x8003); /* Supported group 1 functions */
for (i = 0; i < 6; i ++) {
new_func = (arg >> (i * 4)) & 0x0f;
if (mode && new_func != 0x0f)
@@ -666,8 +644,7 @@ static void sd_function_switch(SDState *sd, uint32_t arg)
}
memset(&sd->data[17], 0, 47);
crc = sd_crc16(sd->data, 64);
- sd->data[65] = crc >> 8;
- sd->data[66] = crc & 0xff;
+ stw_be_p(sd->data + 65, crc);
}
static inline bool sd_wp_addr(SDState *sd, uint64_t addr)
--
2.15.1
next prev parent reply other threads:[~2017-12-13 23:21 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-13 23:19 [Qemu-devel] [PATCH 00/26] SDCard housekeeping Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 01/26] sdbus: add a QMP command to access a SDBus Philippe Mathieu-Daudé
2017-12-14 9:06 ` Kevin Wolf
2017-12-14 9:34 ` Paolo Bonzini
2017-12-14 13:25 ` Philippe Mathieu-Daudé
2017-12-15 8:13 ` Paolo Bonzini
2017-12-14 13:18 ` Philippe Mathieu-Daudé
2017-12-15 19:53 ` Eric Blake
2017-12-13 23:20 ` [Qemu-devel] [RFC PATCH 02/26] sdcard: add a Python qtest Philippe Mathieu-Daudé
2017-12-14 9:34 ` Paolo Bonzini
2017-12-13 23:20 ` Philippe Mathieu-Daudé [this message]
2017-12-13 23:20 ` [Qemu-devel] [PATCH 04/26] sdcard: replace fprintf() -> qemu_log_mask() Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 05/26] sdcard: rename sd_set_mode() -> sd_update_mode() Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 06/26] sdcard: add sd_set_mode() Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 07/26] sdcard: add sdcard_set_mode() trace event Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 08/26] sdcard: add sd_set_state() Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 09/26] sdcard: add a sdcard_set_state() trace event Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 10/26] sdcard: use more detailled state/mode trace events Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 11/26] sdcard: use warn_report() instead of fprintf() Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 12/26] sdcard: replace DPRINTF() by trace events Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 13/26] sdcard: add more " Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [RFC PATCH 14/26] sdcard: use qemu_hexbuf_strdup() to trace command response Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 15/26] sdcard: use PW_LEN define instead of '16' magic Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 16/26] sdcard: let cmd_valid_while_locked() returns a bool Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 17/26] sdcard: rename sd_set_REG() functions called by sd_reset() as sd_reset_REG() Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 18/26] sdcard: move Memory Card registers together Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 19/26] sdcard: add DSR register Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 20/26] sdcard: add/use SD_CMD_MAX to check valid SD commands Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 21/26] sdcard: add sd_cmd_abbreviation() to resolve the SD command id Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 22/26] sdcard: reduce sd_cmd traces Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 23/26] sdcard: add ACMD trace events Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 24/26] sdcard: use a 16-bit type for the 16-bit RCA register Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 25/26] sdcard: add/use a SDCardCommandClass enum instead of magic numbers Philippe Mathieu-Daudé
2017-12-13 23:20 ` [Qemu-devel] [PATCH 26/26] sdcard: add/use a ccc_spi enum for the commands supported in SPI mode Philippe Mathieu-Daudé
2017-12-14 1:29 ` [Qemu-devel] [PATCH 00/26] SDCard housekeeping Philippe Mathieu-Daudé
2017-12-16 0:13 ` Alistair Francis
2018-01-02 16:40 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171213232025.24503-4-f4bug@amsat.org \
--to=f4bug@amsat.org \
--cc=Andrew.Baumann@microsoft.com \
--cc=alistair.francis@xilinx.com \
--cc=clement.deschamps@antfield.fr \
--cc=crosthwaite.peter@gmail.com \
--cc=edgar.iglesias@xilinx.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
--cc=saipava@xilinx.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).