From patchwork Tue Jun 25 06:10:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807261 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2200131wrt; Mon, 24 Jun 2024 23:12:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVT9zh77qZEOe1OSeofSFXl3j6qE1C7nbhqbilEPv7r1D6g+Sj+XyB7ifWTv9yP679iU8U9AzJTaBQCLQ4jf8na X-Google-Smtp-Source: AGHT+IGXDQJYjbScQBfAYB+S/lWl0VpRz3VVjqyhzLETwGBaRhHbmtt9CizYcj7XrRAOHF7dq+FE X-Received: by 2002:a05:620a:4412:b0:79b:b9a4:a0d3 with SMTP id af79cd13be357-79bfd67ffadmr431330385a.29.1719295936779; Mon, 24 Jun 2024 23:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295936; cv=none; d=google.com; s=arc-20160816; b=G5b9UMz8TAfDMlobtaiMkOBYXnT8qDcLKvcVY5qbB3ApVdvByxew98+l8SE+9OZNwP NRjpZGX48lHwTfNfQ7wHuwBXjmXA1BoCdn96qaXxdi2D345xh0GefwSxtSUu5U8pXSJj S5WioZhoeIsCusxMZEt82A/NT7udeaYLahhah0ODQYAGCeGQUpIX/ppW89t/6Ty66L6B 5pcWkIXXKML+AR/q3v2UE2A6Te0DzAVHTW+7UE+cJ1QMyvQAXH/TZ4E1bBHh7lbRbJW1 3o7uYUIovTl6dGp//G0kShkeVSaeQGkZtqL4jrotQ43gLEXWkRmC3zKgsFlu8DwVMMNr M+GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OOp+gWdjMuwGu4rb7U+zCds5Wp19J2oG3xmA1hxsBHQ=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=K36MK0e/0y/B4XncHqoGS6TSsc4ubWAU/ARd3zTGYPXQVZaEM6PrGGf/NcCgJgTuQT vt8K/Z3EiqO/Huao9HBWqD3F5mSvnLMxZhOvaJXvf6XAH1u2Z7zUi1fMzyLrUJCKlhSf /x/PMp9ohSHhZE/4bIfTIQm0g+knHRV/zfRTS4Kiw9I8+OA7maJ7zkwBSPpg72dRNOex mWGZtDg2EYhQaJa5H71dyPRnx3cgkeSaLpapWs+5r6LONSn+GHcKtYExxBh/KfzMd7XU KwrtSPwd5cMmmFPry4PwxFQ5CKurrJ21rQFCkutGcJa9+ErWRPfo+1JeswADlA6xg9D/ rSKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n630eRWu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce942073si995061685a.634.2024.06.24.23.12.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n630eRWu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzNx-000839-1R; Tue, 25 Jun 2024 02:10:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzNv-00080d-Ij for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:31 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzNs-0005af-Fz for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:31 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42499b98d4cso5023205e9.2 for ; Mon, 24 Jun 2024 23:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295825; x=1719900625; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OOp+gWdjMuwGu4rb7U+zCds5Wp19J2oG3xmA1hxsBHQ=; b=n630eRWumUcz3g4Lm0UQ7noSKshd8ihucYStq9prsPprgbe4NtxJUzvA7eFKn/SbhZ TGtwZ2MuR3ljsBg+iKrIZkrN5c0qBz3ie1fp3QbmY8MEOEpNq+q1QHezPqzusf2y/Cca ktiHR8R1wQEJGCw0V5099AL7F/Q4NBVM9RyGuCN1IO400+HTGl9u/tCZtUziZlW1ySJ9 2sgSN0Xh4O2eQpi9a6d4krivVK7VGxCIgabI+3HFOZBz8qoEdvSNQc0bog1YAngT7zQR Yz8Aoawf8ipx5bSFMnd0LqO6DKar1gpm4/AmTnU+p3hxgTcTpGIlFn9pI1uDlPGeqxi7 kWlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295825; x=1719900625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OOp+gWdjMuwGu4rb7U+zCds5Wp19J2oG3xmA1hxsBHQ=; b=qu8kxhB+SZAGqILo6cYNunSDI9NCG9ZI8lp/JyKNw/qQanKbxI+cBXWEMN5Vy7PBq5 P9SSh9hNAaBsVLQOJQoeqTmvW2tmQwDUpXfPuB33wZKTYWJO4JsQSaQmOsuECH9FpqWB Nz9zPs3yPo/QCxKapynGashxn9QOC2VOjogNvoDJWWEV2Fu2NNgzv1H8r+oeMJaC6Ab3 WMVoidADWhcdtn3U1Ynk2doI/0r2roPP02BzvaOYdKqDyx4MJPN8c36z4Eq4l5fcWmmS 8gaCLzxbPzxMNZd7i2fqqiFzFLgAB95LIgbZ5Up4WiCMi88etLTr1rAh9wFBcn3LZdos TGqQ== X-Gm-Message-State: AOJu0YxuvZ8gr93rpZq6SaLwqnJVkFl6fEKVyIO+epsDMVl1BqBQ9VLT t66Z+3np0rD32BPx5i7ge1vSgSjDFUDrkQQ85m+FZUgCiP62DUinoqrK1QEV6jtDQmPGhOlAXgy 0 X-Received: by 2002:a7b:cc16:0:b0:424:8e3a:d020 with SMTP id 5b1f17b1804b1-42498ced472mr16457305e9.29.1719295825612; Mon, 24 Jun 2024 23:10:25 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d208b27sm199003165e9.30.2024.06.24.23.10.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:10:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 01/11] hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte Date: Tue, 25 Jun 2024 08:10:05 +0200 Message-ID: <20240625061015.24095-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org All commands switching from TRANSFER state to (sending)DATA do the same: send stream of data on the DAT lines. Instead of duplicating the same code many times, introduce 2 helpers: - sd_cmd_to_sendingdata() on the I/O line setup the data to be transferred, - sd_generic_read_byte() on the DAT lines to fetch the data. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6685fba4bb..89006ba1b6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -142,8 +142,10 @@ struct SDState { */ bool expecting_acmd; uint32_t blk_written; + uint64_t data_start; uint32_t data_offset; + size_t data_size; uint8_t data[512]; uint8_t vendor_data[512]; @@ -1064,6 +1066,28 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +__attribute__((unused)) +static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, + uint64_t start, + const void *data, size_t size) +{ + if (sd->state != sd_transfer_state) { + sd_invalid_state_for_cmd(sd, req); + } + + sd->state = sd_sendingdata_state; + sd->data_start = start; + sd->data_offset = 0; + if (data) { + assert(size); + memcpy(sd->data, data, size); + } + if (size) { + sd->data_size = size; + } + return sd_r1; +} + /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { @@ -1898,6 +1922,20 @@ send_response: return rsplen; } +__attribute__((unused)) +/* Return true when buffer consumed */ +static bool sd_generic_read_byte(SDState *sd, uint8_t *value) +{ + *value = sd->data[sd->data_offset]; + + if (++sd->data_offset >= sd->data_size) { + sd->state = sd_transfer_state; + return true; + } + + return false; +} + void sd_write_byte(SDState *sd, uint8_t value) { int i; From patchwork Tue Jun 25 06:10:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807251 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2199680wrt; Mon, 24 Jun 2024 23:10:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUvoo72xDkeEfFwCZKzFJf1qoDMpYJXFaVZ/uAexy8+XwTXfbOSsHMQg8+Z+BgC6mScrs5D5qhWG4CJq19S4eEQ X-Google-Smtp-Source: AGHT+IEcSpKJCrQspjCUJD4BIpBARG1/ynBu3GQ6o90iHSlVY4B+uyzuIZKf/aj5rov56jg+u8Bd X-Received: by 2002:a05:620a:1a0f:b0:795:2391:bc36 with SMTP id af79cd13be357-79bdeccba2fmr1152274585a.21.1719295839943; Mon, 24 Jun 2024 23:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295839; cv=none; d=google.com; s=arc-20160816; b=dyFpFXs45VWBoY4sW+x8dLZ3Wx6AIyxkFZrRYNimpyeF1Cp/sNdnC/lDXerwXMqroI BUCnHZFlRokRCGk5+YvrXq7JL51H7f4omc0FvVDCFK+iw2ilC0oOC3sI2HfcoNhiza0P SOCJkSEF06iqkHpyzT9jIKHTS1z8hRTExUnH7+o83sCW46CfglgwjNKl81jCO5iszgJJ /lO+N339hNXZCdefpqPuDNd4lhI3q9Yc86nSSTK0atpcD/hNzTYG4wRvWzXpV8Lqq8+f Boz8HZDtmvU3zqfA2ZP0PaRczu5UoTBeAudQ+3dIcxnKn9Nb71Ag2qHRcl26Iwiu5VTT vXFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jdZ/gPYJlqHWcokRVsRKXJeHIx3TF27J1xoEuLRI7JQ=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=tkVVc7Zf4EGRihYC15ZRbC+BKqTL7LacDmMjOIlnVZ0d5IdW5YX4rPX6NnNPy4aUO2 Rwt7grC44+eFeMIJoiQp71R56KA4mERPKyKds2TQDJFpTCE/F0Y14m2hHvL1R8jaEAxb ydfsWkbAqcFsn1xizCbUF+WEwJ+d9PGHVhVNCmfhlWEwKvooNDUy+Zp4RomwU46jEgrN 55HKAtsMudE+WHL7BFP5ltUhZhZI5IBA3k/DXOws0qCXEfNXbc2vpMp1e4hq4j4zP0rW oJ9/K+LRbTAbObKoebeFHXckl/L7YRu9dsfNzk/JGGA6tvzw1MXTmJ6dmdRlXRx4aub2 Veww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=chsc79MQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce9140ffsi1011360385a.271.2024.06.24.23.10.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:10:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=chsc79MQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzO0-00085q-43; Tue, 25 Jun 2024 02:10:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzNz-00083c-1W for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:35 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzNx-0005cA-FR for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:34 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42189d3c7efso56281255e9.2 for ; Mon, 24 Jun 2024 23:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295832; x=1719900632; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jdZ/gPYJlqHWcokRVsRKXJeHIx3TF27J1xoEuLRI7JQ=; b=chsc79MQYpn8x+DQ2JQyZfnY15SOH3PJyyjYOsDWsadJhnQj+t1UtzqvB49oBY63zb o7PGTjjjK0/eE+f/iRoM1S1t9wNRduQj7doer0K8A0er1jj8r5VDofIu5/dc1Ky+MEw6 NGqhqX1/HMtwD6HdJ8w5jH5fKzYx7VzC5Zk/EyPsVV3+m2GOQc8t5xwum3l7RgUwtaRD bWyNSs/0JK4i6TERb2M6u/WhJDEfU63/DJS5OVqUliwuNH/w4eXZyCC+gKKmEl/ukxOJ uQaP12Or6mAB6B5OzDOUjBbj2Mn25lRBMcZr7ZtTt9tepfD/lexdGjFJeJluGw6W2ONV K1Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295832; x=1719900632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jdZ/gPYJlqHWcokRVsRKXJeHIx3TF27J1xoEuLRI7JQ=; b=ZP9c+prs2vysX/U9IyfLfDAzz0qzrH1AkqOFaBdT78nIzKpvlL2PWbulb0dU/xQtKL g1AbFygkTxMgwBpoSS8EaNSXiRcEFBZgsrtZGrXvxSB6fEaHocvl8fJBcSEV3KAAzynD R2F9wdLfdJTtwC1W59ox/7kNCxIfyyLhn+1WZcIg+T7jBjLJxSp+XWz1DJFqZnpdTKPl 7G1CUCAdYwOM+JVlAEfOLavcexhyj4BbMQnvsOZQSp1d5NCURmVvC8oR0Bstq+Xo+dHW 2b+s49XAZZLu3yzLllhyhN2JCbjuuIYarYJPbGPXb2pcZvwD+5l2VqG4tg8ne/dszXc8 0ZiA== X-Gm-Message-State: AOJu0YznmPrFwHUm3bUL/Ki3QcNLMMZviXs+4KvygV1kAQgsTW6AyoQ+ 70clEbgBJAz/J4WvvvZFwBGvmiN4aMPyN2I7GDwgY7S51pJd+Yp43n5JI5IhX5NO+8A0C+kilu6 X X-Received: by 2002:a05:600c:5713:b0:421:29cd:5c95 with SMTP id 5b1f17b1804b1-4248cc27143mr57459815e9.10.1719295831872; Mon, 24 Jun 2024 23:10:31 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248179d8e0sm166542555e9.3.2024.06.24.23.10.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:10:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 02/11] hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6) Date: Tue, 25 Jun 2024 08:10:06 +0200 Message-ID: <20240625061015.24095-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 89006ba1b6..0011aa86da 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1220,10 +1220,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd_function_switch(sd, req.arg); - sd->state = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); case 7: /* CMD7: SELECT/DESELECT_CARD */ rca = sd_req_get_rca(sd, req); @@ -1922,7 +1919,6 @@ send_response: return rsplen; } -__attribute__((unused)) /* Return true when buffer consumed */ static bool sd_generic_read_byte(SDState *sd, uint8_t *value) { @@ -2112,10 +2108,7 @@ uint8_t sd_read_byte(SDState *sd) sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 64) - sd->state = sd_transfer_state; + sd_generic_read_byte(sd, &ret); break; case 9: /* CMD9: SEND_CSD */ From patchwork Tue Jun 25 06:10:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807252 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2199743wrt; Mon, 24 Jun 2024 23:10:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVwj4oELznrCwehYvgeH4XdqdYJYtkWBIa3I/uORu9HCckp2f27w+YCi0eWUHKQ8wmsTY56YV7n2uvTi6Oxci6E X-Google-Smtp-Source: AGHT+IFSn3pFLncfc9fRKHgDOIkCliOSWqs1zJBH2tWY6GoggQ8GI5rAxQ6MXlJR5FvxTHpiO8Ih X-Received: by 2002:a05:620a:2913:b0:795:5473:999e with SMTP id af79cd13be357-79be47e26f3mr930583185a.68.1719295855992; Mon, 24 Jun 2024 23:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295855; cv=none; d=google.com; s=arc-20160816; b=TRDgadIO/7cD1JcMAfl/tIo4/eHClcbdzoCiZTpgdiM5qzoZycOg7HvMZTjiFwXXD0 XIfvxr2G+6VhoSin9Fl/Fysaj5hHR+HIRJhKw0h0GtML7NV8MT+hjFBsutH5w0lJATfa H+D+8V2I9Q1kU598Qh33mmxoHHzbtYJqrtvY8V8LLwM1yF2kYsIQ4WRI+sS4F4CRUBKO QtYOTXdEdv/Dw0gIQJYKGkrqU8LT+lGgjYfTwsE94urimbkLzmvuppATai6l6GIKDEQw XKh+Or9OSgXhoShof0mfRBrRRAE4ZsDbQzSIfJWcT8vLxcMaTVUJWkv3vTaZaXJxASjp T1Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XvMkaMqLM5PVpCv4Vd4dHYUlgMEEODMLVtAtegzf7mU=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=wNNkm295TkvSHqCnoefe+Z2pOR+tAoTa/XetlzLbxppPbAvBo9NTYHYAuKENkekrCb kXYl5f/VeUVqDSbR+IJP8MRy/GYY/xha8zbEom4wfVk4VYOv3rtSPzaZTXDczM0RNt3t Ne2d/0QPTHsLutMX4uvDuZdXtfzGAX2ync3KaT0QsBoi74mBcnQKWtB5hoCERcSb/Q/U lExsHXwIRnMnDce3cd9RlXQoRwC5qvab3M1lw/TCUB+TrfzlmyC2TyxN09drqjDn+4zs rYSxl6k7wuG91MiXDgKC+/PZ4NaBvRohASJiV7Z8oAKAZi8J7JHnzX+sQCV/DdQQRtEv ac0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SWZw5uz7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79c04997eddsi65194585a.116.2024.06.24.23.10.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:10:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SWZw5uz7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzO6-0008Em-VL; Tue, 25 Jun 2024 02:10:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzO4-0008DW-TU for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:41 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzO3-0005cf-AG for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:40 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-424a2ad06f1so1883105e9.1 for ; Mon, 24 Jun 2024 23:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295837; x=1719900637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XvMkaMqLM5PVpCv4Vd4dHYUlgMEEODMLVtAtegzf7mU=; b=SWZw5uz7p2tQ5yhkbMCjHfe3a2wRxEw+YbwAZ0D1BcVa2l1KGM5W9ejzcXXeH6T42U q+lKbY19QjE3VpSmprW7toFJoW4ZECDpbhC5zYxDPEKmzvbTiyhK071DUVl0x4NjPmZ/ di+Tjc27055GBld8lunUG1BmWqZuQrc5EILtwM/D005PtOyo5jY5DqXiLCbKGSKLmawQ OnrPzU+CqCHeJiNoE9ZYahR/UgilpySaecKnNlgKyM99A/Puo+K68G4Iqva9ItX/A6iv QJI92nggMGy/nhz0sOcYTZZWL2yb0Z0DAUErlE2Zi/mffcF0KtjJEqFMXmFtDpVSEF6c zvYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295837; x=1719900637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XvMkaMqLM5PVpCv4Vd4dHYUlgMEEODMLVtAtegzf7mU=; b=qsNth5IzF40BXgTgD+79lWLJr6soxEXh+MPCglNlTrHSKxK1MfINsF9T2ORx+foauv ebnC0CssDbSsyvQTeWuOiqazp/FuhjaA4ZbVU/wrYeFLher0tdCUfWuyxUL/ecLmRYQw /nsUxFRoj/3/VCBR6VCJ5Ty6KD+rAge6I/wC8eOliJGVpxNZKNildQUdXNbPLhvMKsSK pUWgjBU2tmHC5US1jXzfHR93FXoyl/jpIyYlVpm64xFigA5usldwjTxuSzGAkpCZoEcE AyyQoa0INmMynv/Eui7y9K+c6n/GApCsDWhcvLNaVEk/LkLfxxWs3Cv9/V14nDgs+Rnw W50Q== X-Gm-Message-State: AOJu0Yyp3MZ5opYcx9wn7dUfyjwH+/5pgKCR9KAIm1EE8wkeYNZztzKf e8gWDs6UfDS+mfcF5JIqO8YXN/46ovPcCnrnaHDvj5Huxnf24YaH6lCDB9jCZ9yPhHVQYfq5+aF 5 X-Received: by 2002:a05:600c:2212:b0:424:a2d9:67c5 with SMTP id 5b1f17b1804b1-424a2d96a8emr4209055e9.16.1719295837690; Mon, 24 Jun 2024 23:10:37 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3663a8c83e9sm11890515f8f.94.2024.06.24.23.10.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:10:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 03/11] hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 & 10) Date: Tue, 25 Jun 2024 08:10:07 +0200 Message-ID: <20240625061015.24095-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0011aa86da..346bd657a7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1290,11 +1290,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (!sd_is_spi(sd)) { break; } - sd->state = sd_sendingdata_state; - memcpy(sd->data, sd->csd, 16); - sd->data_start = sd_req_get_address(sd, req); - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->csd, 16); default: break; @@ -1314,11 +1311,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (!sd_is_spi(sd)) { break; } - sd->state = sd_sendingdata_state; - memcpy(sd->data, sd->cid, 16); - sd->data_start = sd_req_get_address(sd, req); - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->cid, 16); default: break; @@ -2108,15 +2102,9 @@ uint8_t sd_read_byte(SDState *sd) sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ - sd_generic_read_byte(sd, &ret); - break; - case 9: /* CMD9: SEND_CSD */ - case 10: /* CMD10: SEND_CID */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 16) - sd->state = sd_transfer_state; + case 10: /* CMD10: SEND_CID */ + sd_generic_read_byte(sd, &ret); break; case 13: /* ACMD13: SD_STATUS */ From patchwork Tue Jun 25 06:10:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807256 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2199943wrt; Mon, 24 Jun 2024 23:11:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXbtHi6WuGq3mKK0d5REKW+iJJE5k45wBTS0p213mJHJj9nnmWho6yqQB+SjiwpdkjKcxSpkOk0LiQnRPSWTV/W X-Google-Smtp-Source: AGHT+IG2lDAtsULVb8uQfclBWqBrgqkTFBXnvTQlVDc0anHKXFcbS3bKSpXReBVbExOix36l4kaP X-Received: by 2002:a05:620a:2484:b0:794:e711:953d with SMTP id af79cd13be357-79be6e8b076mr645720885a.41.1719295895511; Mon, 24 Jun 2024 23:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295895; cv=none; d=google.com; s=arc-20160816; b=uoBdXGBtpZrzsyQ3ctYGlsC+TDKjQzV+Bg75IbwpNmYWTI6fvbqSC8YD2XKs4bwERc O4Reig3p7iNysGzvFwj+dR5FZ+0ucRp0ShPw0WQnp0vmxd97UPDG+0bvJWRgUH1TcWBl sCdD3R9ABRmKMKLcofP+agOehW9zMbo8aLGEmoHRQxQBub6BgiG3YR7xANj3aYwGXHDX 8LTMtv461CVbl+qULj9ZoIt9NIzuV6+VGPv/sLKTcDcpdVycw21bcc2WQ+dhMrQ5wKBW AcKdMJGSHoH8y/BOh3C3B0APKHBoKeJfdD1nEefb2TmJ2bEA3xrvJlaUhYTSSEIfmUrp t9Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uU8msdfI4FBbYYSxzgmdaaqhmtNKe2zgeh42ZfcMs0o=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=jQSse5mfJIX30FutgoOYoOBVjpmbtKZ5bG+ggb3MAatIH2vgBTlfnnvXzG8q87cU3u EfEqCQy2UJ/2oSXmAfDvssu4gVrKP08VNBvgi3RKOcMeV5hx4/o49rMNyIZ+qzg4R6Jq 63V9HJcI1j0k8ItiV3t/iGClY6a5Q0DCszcwVXkF+qVUtmGbEv3a88VU4ws64k+IX0U7 +IAEcutLWB6iy1PhJnta4RWsuMgTlypyNIy+chpdBlF7rWiSlfJ/hXKAIEpUxgYp9ot6 htTyPPYmAiXcovFGMfTLE2DVYu2YchJJlTYdMCJxnpX+sgeC0+wgwDd8C+eEyC5iHeZD LTxA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GatTWml4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce92df09si989725285a.494.2024.06.24.23.11.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GatTWml4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzOI-0000Ci-3Q; Tue, 25 Jun 2024 02:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzOB-0008GJ-Ab for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:49 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzO9-0005dC-MA for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:47 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42189d3c7efso56282325e9.2 for ; Mon, 24 Jun 2024 23:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295844; x=1719900644; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uU8msdfI4FBbYYSxzgmdaaqhmtNKe2zgeh42ZfcMs0o=; b=GatTWml4m5ZLmjyEyDSV3UPo5zFfadDGOTt9lhrPn3dwsvp1KY6FEufVnpR/xdMEfD vCIZK9HK8wp0c2pSoI1aH10HMVrmdAExL2qdIpPGRjyac8VvP/PfMqgHo7+c9ORncXtk MErqLwCLA6GZD+bRgBbAGwYOp8TvZvPn+oa0u+h3N8CCkeLNsva2AWrdN46zRPogbc6e rOLsni7FNVJ3YdJbVdMncakhQYIITYDCRUT8rTNsi0NpKWLkbruJjNLKNlZaYSwusWRX LOtOypQeWVDnrPZMaobS793lEBjgII6OWGo7otiB7Y9n1+r7bojdJWBmpdPz/b8AdRJe SmvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295844; x=1719900644; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uU8msdfI4FBbYYSxzgmdaaqhmtNKe2zgeh42ZfcMs0o=; b=wWWCXo6M8mt2rnuMoUM+W3tyuUUaoN4304MKTMsCFLe5yyevri4dPgMnqgoO6vWrry Mh9uNW2ntFtt7rzMKHfNNy1d5BYDS8PiqNKmfod65oiIkLmohQq9+10STAKDFZd49iO2 EpFyoA0e5T3wJNk7s5BfBdqTF9/ocBQYnfZ08NyYwbTJfOMck8lmA7dEM6DfWfm1nzOG p2JlAWIfe+BhCixeFqkaBvofpIW2gM+svfDWuC+y3a0Nqm6uFUuNtpvfc3l0t+ZuZKnP IDDI1G2SccOtRs0SUUbkYr9flwGnvFh4Zyw8NoE/F6ezKL0tkN8IRMhdYs1dbUkQSKBg 2q/g== X-Gm-Message-State: AOJu0Yw9g5LLLq/FJvDZ6ENIWR1EwRtBXRSVMZ7TX75oUHPc2gkTDpL2 vkgdYHWQaCAWy6NXY9Om1AEgkUf1XEabOZEb4RH/ODOMhRf8zbSXw+WmdqqeSDYXqjk2XmQfOVF e X-Received: by 2002:a05:600c:5692:b0:424:8dba:4a43 with SMTP id 5b1f17b1804b1-4248dba4d52mr51090685e9.5.1719295843947; Mon, 24 Jun 2024 23:10:43 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42481910f64sm162488035e9.34.2024.06.24.23.10.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:10:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 04/11] hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases Date: Tue, 25 Jun 2024 08:10:08 +0200 Message-ID: <20240625061015.24095-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to modify the READ_SINGLE_BLOCK case in the next commit, duplicate it first. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 346bd657a7..9aaa78a334 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1376,6 +1376,24 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 17: /* CMD17: READ_SINGLE_BLOCK */ + addr = sd_req_get_address(sd, req); + switch (sd->state) { + case sd_transfer_state: + + if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + sd->state = sd_sendingdata_state; + sd->data_start = addr; + sd->data_offset = 0; + return sd_r1; + + default: + break; + } + break; + case 18: /* CMD18: READ_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { From patchwork Tue Jun 25 06:10:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807253 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2199810wrt; Mon, 24 Jun 2024 23:11:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV0mNvJSzkN8xnKFiJ89HIE4QCBZln8HUxWAk+8PADUMXqEk2spGSd6hXqf+xWWhy7ljgcXeJhwUe952+uAUFun X-Google-Smtp-Source: AGHT+IGn/hJ1mAUmwEJeOx8RrvWm5s3C4xw/Et16zuJanJ2yOSPiOj+Ebgog5ZXUvTs8WdW+shGa X-Received: by 2002:a05:620a:4402:b0:795:233c:6985 with SMTP id af79cd13be357-79be6cdbc11mr737128885a.4.1719295865939; Mon, 24 Jun 2024 23:11:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295865; cv=none; d=google.com; s=arc-20160816; b=Yhv/OEchd2FW7cMTuDflTXRX6Jw+7FnxtUWGDNqTu03L36702zaGVRSffm+36jwPWV zkCSo9Q/hEpJNOcbPzzMI0nSFncK2HAxlDZFsApdPbX700RlZvM0dkrpcK6770ahYn9O JcdMAQlvIonD4IusWlA4P5FG0Qme3O2EK07DwwLJZnSMtUVDkncEMxAylfUqzZegScEq ujNfDK+INosUPLsYMAi4mU6aSkjtm0LSGTyE15A5eQinv8R5ij1OrmFaoA9tOSIeu0O+ 5u0JRAB1yFhlGgRXKD/FDLw0SZdRJBMHuBnx21CHn5Q1/10pmQBOLzfxZ6g994dLEoh+ FAsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NaCEUe06tl61OBfIHTaSsFr8m9A3Vd4SzjwSutNDx7I=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=YqqOGjhZ44CdD4vfEM0o5U8ZOAnXzked9g+3c1S21A/gvW96MB9pvDeu1QAvgfrLDG CkWEDe+aNpZKIZFmn1oMEmpcraOziTxllv/ZG5JaPvzOVTqsJwW0nDRhI8qLqS9Sv1A7 osRuIfSytQ1xtSi/3doyjsZoeQvQwCIOjbtSe/WTpxd2jl+GvNE+h8w2+F8aDhG8BwRA qVgnbjeVwWzQ/dPvODLZKdJWo+MSqnDeQhlAWnP1Z7ikzts4PWcoXxrcFJRPbbrz6+Yj 0YIqUyYLQqv55eQQ6IaVpL8tMF2twKOvyqs8jFq6C79OOMm0k/xCFdhLDobhqTG7VLT7 Tsww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2pfJpHV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce914669si1003633685a.226.2024.06.24.23.11.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:11:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2pfJpHV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzOM-0000Xh-VV; Tue, 25 Jun 2024 02:10:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzOJ-0000M8-5M for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:55 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzOG-0005dd-VS for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:10:54 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52cdd893e5cso3030702e87.1 for ; Mon, 24 Jun 2024 23:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295849; x=1719900649; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NaCEUe06tl61OBfIHTaSsFr8m9A3Vd4SzjwSutNDx7I=; b=S2pfJpHV+X9pSnPinj3hyf+z9NkMANKrMb1Uo0prf1ww3eE+yg4D0xIOw2JAu0iani Su/2Cap/ITjj8YyVSnpyM3cCqoVHrOOcbCHK+XQG+r6tVCncOG/U8iEOZOvPZpiCMN1a TV25utjgCWrytau9+Sp4Ou1ZLWoYyVJIyQfODxWMXlUeNNuPqtFL1h3pojefvG1RUnE9 RZzDWMSp8+gm0X6ri3ygPIGJin7iLXytt86BnHrFDBXthLdEE9vaAnMW4FjknUFZ5RlD C9PYUSbTNhMfS982xiT2wM2Uen/vCvvjVuaDLNkArpX+sppygQrdGBhMmDDRW0UFm9DJ B7Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295849; x=1719900649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NaCEUe06tl61OBfIHTaSsFr8m9A3Vd4SzjwSutNDx7I=; b=mQA55KY2sCqzcxAxvR1qMSMcE8Ci3ZdVbQr7cTlZIsBG6vN9nKhHqXtqUQO5m54ysh BWp8OxA/3JMkwgw2loSuYHoZqdOoe4uZlocHuSVm4eygD+U1QoTjks8ndQebdSUt79zb D6o+bK/0jkVKUlofqM/V71/8mt7bnezsZktQ/f4TcPs15aAYijHIUQCiEFHrf7lRizjn YmRhOx1aD1HRGO4thFXz1J90Xxlskok1cytxXIykLqtL6+UfZkm7E0+kKiv/9Jhv/BSQ QH7tQ2KlTPxNs+Hk/vS3yhKPNz2AAwrctxKnTBhTBFBfOj2g5T3MBZpwbOWhYCABKo9i ml+Q== X-Gm-Message-State: AOJu0YwLWXD+cgnXNnMcBz8mHE+ZTVZjavAV8X+LSO+N4HLokTsjXIyT JYm1VJ6dXw3Q6vrhXSY1+hWNQFyI8xNQ9t5GzxUlSXkPGl1d6zFs3QETmZfz3AdEg06lOLJOsRc i X-Received: by 2002:a05:6512:2254:b0:52c:df55:e11a with SMTP id 2adb3069b0e04-52ce18325f3mr6040195e87.9.1719295849686; Mon, 24 Jun 2024 23:10:49 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366388c4282sm11956753f8f.31.2024.06.24.23.10.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:10:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 05/11] hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17) Date: Tue, 25 Jun 2024 08:10:09 +0200 Message-ID: <20240625061015.24095-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=philmd@linaro.org; helo=mail-lf1-x12f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9aaa78a334..6af7b3f034 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1383,11 +1383,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { return sd_r1; } - - sd->state = sd_sendingdata_state; - sd->data_start = addr; - sd->data_offset = 0; - return sd_r1; + sd_blk_read(sd, addr, sd->blk_len); + return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); default: break; @@ -2122,6 +2119,7 @@ uint8_t sd_read_byte(SDState *sd) case 6: /* CMD6: SWITCH_FUNCTION */ case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ + case 17: /* CMD17: READ_SINGLE_BLOCK */ sd_generic_read_byte(sd, &ret); break; @@ -2132,16 +2130,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 17: /* CMD17: READ_SINGLE_BLOCK */ - if (sd->data_offset == 0) { - sd_blk_read(sd, sd->data_start, io_len); - } - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= io_len) - sd->state = sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset == 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK", From patchwork Tue Jun 25 06:10:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807260 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2200110wrt; Mon, 24 Jun 2024 23:12:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWBeIpy23giqV3PSeTdYwOsQACsaNNLR9e6Z57n46xY7sgO15tGY0Lw58EW8Z8ueVUGM3DFqQKmjPqFuObrHgoZ X-Google-Smtp-Source: AGHT+IFdRfgQyhJfXYBCeUQdkDj18i25a7XAPoExdELmHCFNmlP1e3XXePgOiEjvAgqacM0nGswP X-Received: by 2002:ad4:4581:0:b0:6b0:6711:851e with SMTP id 6a1803df08f44-6b53635e01emr79786186d6.7.1719295934394; Mon, 24 Jun 2024 23:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295934; cv=none; d=google.com; s=arc-20160816; b=PNkqa+BG30QHv4qrJc2qDYDbOFFFK5/fGpm/Bs1PXoUPf927Up13pNPG9ONe219wMZ HTO0yF7MGCMmtB5LnCxOCwhdguzVWAwRTorXrh/PsZe1/21usyK3Lm47S75Hwh65QmpI 0fFidVLgeV/XUPS4XJruWyE8yom//EX1wVhkZ9gBXA4FoKbwv8ZxJxqIibKYpla4rwIg yIpu7cZsneSiUQSZ4u65Ncs9exuqkkrGDxvii6l00aSighqhzAnTf29+/1lEIwnmCAWq cyLGgeUfq3itts8b3je2Nqehmjk2igj9W9T5jtXkntsHZtBUh0zChIUFaIY0KiHXVGnt Gixg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WXyQ3ONsL6quYLnxVI/IWP+VnsFMKTPDSRWLpcs4CQU=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=Ru8WDzEe70WyUKyj0xGojp121TzSy1nrXZlEyWwHk/psW5r6ePxb9PY+vvc3Kvus6x e/FbvTRo8LInV4vEA53aMkjAoDoohrQPS2HWwktcaSJd4WlMrtEib1GJGkeFWC0CFe2H LCJ7WOgjyuJ1catDYVMe1LglpIzXUryRwT7+3v/b3/nUn2W0LFafciAcx7LCEGRJAm/2 Lrr1hDt04a35Ouri0OcAdhqFkS2OGeo7Fg17eyi9sPWMk+lc7bzNM1kjXnfVom6/c2qu +Lw1aJOH2jDA24Xjvo6w2pA1Wm5fqetcuNQoTQjLhVuKjbcAILiAuxOhtyNxw8g1F8c5 13GQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OerGHbpW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b5265bc8e6si90764786d6.454.2024.06.24.23.12.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OerGHbpW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzOR-0000op-Ds; Tue, 25 Jun 2024 02:11:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzOP-0000gu-5q for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:01 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzOM-0005eJ-Lp for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:00 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4248ea53493so14996465e9.3 for ; Mon, 24 Jun 2024 23:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295856; x=1719900656; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WXyQ3ONsL6quYLnxVI/IWP+VnsFMKTPDSRWLpcs4CQU=; b=OerGHbpWiNXKdkfeK2U3ADPObM4NAF5xbI+0WTHssPGw4YGD7287cB6T4CPxsBCC67 TY+Yk5mliZEvJr8jfcI63zkp5WAnohNvEMlUj3jyFRt1zUM9V3PsvLt/VLN8oHuAUDH+ dtd7nArmYrVMhcMjUKfcecKtqGg1UtDaWfWCheqIsINncFdRje1p+LJIUAU7j5WD6Vrf BUZIt8K12kQZj5elSxksl6nD6Fxd3gILvKHluLBilCQuyMqyglf0wzO4Wh0PvxDkfWtH VT2oFO/DEGOt6RE2DDt81HZa8zEDLD/QMmVLJOW7c/x9jpLKawSqmxpmC1revtJU8Nt/ 1R5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295856; x=1719900656; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WXyQ3ONsL6quYLnxVI/IWP+VnsFMKTPDSRWLpcs4CQU=; b=licyLiFetNF0hA2MD0r6x2ajHpgKuW2Goi4wYY363IWfAlnCaFOrna4Z/l29snZi2V 1SxdiSZVg3v8p6m1DtiWTeBObHWO8ygvOB6t7STvf2eYCw+jrMVixwqQI2TUPo3V6B3c aiQLj03MkWT+T3fAtWzgi0/WG/ZE7zvKm5DYpc/ZBh1iqADadHxbibDnpiXswuiTp7Tb c3HQap8/pCkVin9WuPNqR0+qLtyxevPMRnOALR46B25oSkBHNvKzJ3Jacw33D5DLql3y /QMEJanqeDUy7SOUHTI4A6VKvUxyDue7kW0PtGnGD8JfhtTRzh5ZDdIoZjo/shiEfMJB w2Kg== X-Gm-Message-State: AOJu0YwWGivix9f05DCaPptA5tyz0aXzgDMOn2fePcTrJyAvXSVxCVuo N+J2CrNhDZj/UBFs7PWhupGN9MYCkKHcjDRp8L3dINOkxSvlSrWKMYh2Jh+HAKm038HpLZqL5hR U X-Received: by 2002:a05:600c:434c:b0:424:7e68:99ff with SMTP id 5b1f17b1804b1-4248cc2a78dmr50826455e9.15.1719295856204; Mon, 24 Jun 2024 23:10:56 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424819224fasm163677795e9.46.2024.06.24.23.10.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:10:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 06/11] hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19) Date: Tue, 25 Jun 2024 08:10:10 +0200 Message-ID: <20240625061015.24095-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6af7b3f034..3d341495e9 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -562,6 +562,21 @@ static void sd_set_sdstatus(SDState *sd) memset(sd->sd_status, 0, 64); } +static const uint8_t sd_tuning_block_pattern4[64] = { + /* + * See: Physical Layer Simplified Specification Version 3.01, + * Table 4-2. + */ + 0xff, 0x0f, 0xff, 0x00, 0x0f, 0xfc, 0xc3, 0xcc, + 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, + 0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb, + 0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef, + 0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c, + 0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee, + 0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff, + 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde +}; + static int sd_req_crc_validate(SDRequest *req) { uint8_t buffer[5]; @@ -1139,14 +1154,9 @@ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) return sd_cmd_illegal(sd, req); } - if (sd->state != sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } - - sd->state = sd_sendingdata_state; - sd->data_offset = 0; - - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + sd_tuning_block_pattern4, + sizeof(sd_tuning_block_pattern4)); } /* CMD23 */ @@ -2078,20 +2088,6 @@ void sd_write_byte(SDState *sd, uint8_t value) } } -#define SD_TUNING_BLOCK_SIZE 64 - -static const uint8_t sd_tuning_block_pattern[SD_TUNING_BLOCK_SIZE] = { - /* See: Physical Layer Simplified Specification Version 3.01, Table 4-2 */ - 0xff, 0x0f, 0xff, 0x00, 0x0f, 0xfc, 0xc3, 0xcc, - 0xc3, 0x3c, 0xcc, 0xff, 0xfe, 0xff, 0xfe, 0xef, - 0xff, 0xdf, 0xff, 0xdd, 0xff, 0xfb, 0xff, 0xfb, - 0xbf, 0xff, 0x7f, 0xff, 0x77, 0xf7, 0xbd, 0xef, - 0xff, 0xf0, 0xff, 0xf0, 0x0f, 0xfc, 0xcc, 0x3c, - 0xcc, 0x33, 0xcc, 0xcf, 0xff, 0xef, 0xff, 0xee, - 0xff, 0xfd, 0xff, 0xfd, 0xdf, 0xff, 0xbf, 0xff, - 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde, -}; - uint8_t sd_read_byte(SDState *sd) { /* TODO: Append CRCs */ @@ -2120,6 +2116,7 @@ uint8_t sd_read_byte(SDState *sd) case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ case 17: /* CMD17: READ_SINGLE_BLOCK */ + case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ sd_generic_read_byte(sd, &ret); break; @@ -2154,13 +2151,6 @@ uint8_t sd_read_byte(SDState *sd) } break; - case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ - if (sd->data_offset >= SD_TUNING_BLOCK_SIZE - 1) { - sd->state = sd_transfer_state; - } - ret = sd_tuning_block_pattern[sd->data_offset++]; - break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ ret = sd->data[sd->data_offset ++]; From patchwork Tue Jun 25 06:10:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807254 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2199903wrt; Mon, 24 Jun 2024 23:11:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPMgyc8kJUM7h0/Kke+X3aPwYz2Vw1PVhERH8AIoPz7rWXsGUPNpGL6lDNsO2v4ac63RACkWJ4w71ZAceVMe/0 X-Google-Smtp-Source: AGHT+IHZz6/QT/oL0OCrZkfCTfJjQNFD1Kb+v9i5vF2s7lUxyNlyvjhi5WjDFIV2ceQtYLcCAwk/ X-Received: by 2002:a0c:e910:0:b0:6b5:4aa9:9682 with SMTP id 6a1803df08f44-6b54aa99d93mr45352196d6.41.1719295887099; Mon, 24 Jun 2024 23:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295887; cv=none; d=google.com; s=arc-20160816; b=E8G5zB75xV2I3XKcnDUA/jYdnxHNoy++EBu4adSe2J5T7xwC5bnhPNN3cvwnr9/2yB qvrYLH0op7tUaJct6HK2Lyiki8jHRty4T995ACSM0y5Zfh7plgOPZwUKi6y0hPSd5m5g 9j6rSROvPoEu9kxRfA+zXSPMPR5aUemB0ih5BuxcODKiA1gnHyiZMOntcYiUV3J3lDDw 3ac9kJPMrDg97by2K51Rhsv/ajrYBJtPXi/5M8bwwNGgxWWrthi5uNpaGVLZwdrJY5d5 KLlO7exUr8AEF9kw5sGBjbb3bhKfwZazs7HNHuhzQpnmUdcqyBObBqMOojU3LcDMpahw Tzxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NtW0nRzwV3BVpB0w4GeNN0Pmc1dXKuFE2etuFwf0o1Q=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=BGKiSiikA56tRvm9snJOBXG/Ai47+ojUzm2M0n4YX39Ql/k681qV5Pkg2N0bC3g00z HaG/AZST+3z8bi6PazshKRCfp0SR1+ffvGyMZMpkSguVeabEOHo8LJHxQ6KuRM8Ow1pH Nx8aBqg3RL0VJGTQPLK2lW10uf1nmQZHhMIo1kYnOC6fLGBd8BZP0R7pNLwqNzRujvxr OPwimZC0Jszw5MIG8ziJ1JoqUxvX5LmGacUW/5bJ0n6BaWWLGDBVynKZ1RJiJ2rE4QI+ Z5uYcpt8++MwsYPKyRlR6m665rozRHDYy4DbZhNcMef5fpBtDGQ3Xoi0PLweBItWwrEP 9QSg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSWhSlSM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ed15eb6si98883986d6.173.2024.06.24.23.11.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:11:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSWhSlSM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzOg-00018U-9B; Tue, 25 Jun 2024 02:11:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzOT-0000zZ-Uq for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:06 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzOS-0005f3-8w for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:05 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ec5779b423so29115491fa.0 for ; Mon, 24 Jun 2024 23:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295862; x=1719900662; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NtW0nRzwV3BVpB0w4GeNN0Pmc1dXKuFE2etuFwf0o1Q=; b=CSWhSlSMPiOUzQhaBuD0LpM57tybOCsODpjtihXJMBH31yH8u7cO7wVpH1bm4QKupQ PPciyayqcI5moLlA4iCBgLWBxjK1uja3AtAwqYN/GtWO5R9WIb0gu+HpMWyzao3lIauc zPdRlf+ZdiKQBDbdh50vOkbro6nNHmOo77Cm9hx8BqJTlWDLY8v/xJXwYNcY1qYpX5A5 XzphS2YovXbIXw+4liXfxhyT1YYu9LeuVTzYA2RvYBSM38VhBaLnPvYzedyKtlo45riu Xg2rfGUvFI0AVWV2RyYKC5OvzifPbyk9oj955Q+e7ktdhoI2Rr1zu9olLqLCVv6udG/g g7tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295862; x=1719900662; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NtW0nRzwV3BVpB0w4GeNN0Pmc1dXKuFE2etuFwf0o1Q=; b=uHafSCHZgcAJw3jRTs4fZg6sak1C1bImmi9lXncZOv3DR2mO4CCdcwQvEvMlQEbBjO 0VfOQ1IfsurNezKlYf5g4+4bPD7i2amSIgUQT2NknxQXfndnc0ROJCAHA5zHfnKZTgC2 LdgACNMm0+KwdskHF9e/Ekt0l5fVepKaOr6qOr4FS/VPSw2M0jLGKG0FVJ8QCqSDmMTP GL1z+vbSkpzZ0XCzqQTGe2tx7T/xNxqkJ24GXj3n2rjomtaruNo31tP/rjy146Ic51M/ 3InMqm6M+o7QwAPjmFPJcaoQ2yc9wapXC5BHwYUW9ZJS17hsgTaX+ypupekjLOOI9Hgw EBXA== X-Gm-Message-State: AOJu0YxigvUmiACeVGjehPyejUl/cM9tbXzL7uPr6xojg3vrjTX/F3/h Rn6EyErmcDTV2jrU5PNGTYV8REwNMwZ8u3/tkURl58hChCDlAW5slzT2aVs0zjUMU2rsiqOZ9Ic f X-Received: by 2002:a2e:91c7:0:b0:2ec:27e6:39ba with SMTP id 38308e7fff4ca-2ec5938a759mr51691381fa.53.1719295862238; Mon, 24 Jun 2024 23:11:02 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42481910f91sm157628785e9.38.2024.06.24.23.11.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:11:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 07/11] hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30) Date: Tue, 25 Jun 2024 08:10:11 +0200 Message-ID: <20240625061015.24095-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=philmd@linaro.org; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 3d341495e9..6e6b37bd2d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1180,6 +1180,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; uint64_t addr; + uint32_t data; sd->last_cmd_name = sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1533,12 +1534,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) req.arg, sd->blk_len)) { return sd_r1; } - - sd->state = sd_sendingdata_state; - stl_be_p(sd->data, sd_wpbits(sd, req.arg)); - sd->data_start = addr; - sd->data_offset = 0; - return sd_r1; + data = sd_wpbits(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); default: break; @@ -2117,6 +2114,7 @@ uint8_t sd_read_byte(SDState *sd) case 10: /* CMD10: SEND_CID */ case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ + case 30: /* CMD30: SEND_WRITE_PROT */ sd_generic_read_byte(sd, &ret); break; @@ -2158,13 +2156,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 30: /* CMD30: SEND_WRITE_PROT */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 4) - sd->state = sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret = sd->scr[sd->data_offset ++]; From patchwork Tue Jun 25 06:10:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807259 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2200107wrt; Mon, 24 Jun 2024 23:12:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVXWOeTEy1qz5lISgWJaa2/6SgFoJTuO/ipa5b2qJ9LNDphKruKhk8mYJsuA0izdKf5uWrr3mDyu9q1irj51cdg X-Google-Smtp-Source: AGHT+IEDeR8K+dHxP6AQDhbivrZO2VNOY0tAICzfhj5/n7keiI49rIo8xKZ9ucXWvOUc+BcG3RoZ X-Received: by 2002:a05:6214:3012:b0:6b5:480f:b592 with SMTP id 6a1803df08f44-6b5480fb797mr80704656d6.20.1719295934076; Mon, 24 Jun 2024 23:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295934; cv=none; d=google.com; s=arc-20160816; b=0eOSLeyXovyijizMuAXD5Ifpld893FUY7g1XXwKAI3Q7FUBqw63kN5JufsRAa2zPUS sVApEhZNJCKzfKP7fF+icxgHpCDoOdd3z1bLKK9qrt85aRsWWHhKMEcgA5/qHLcGYTP+ YMvneI4Ubds5tn6FXBy9sv+2aeA9W0190H15QtGTYTNYgNzqst2BS+9R6ZHTipdnjhAL Nwj+5OezgVTXk+JxvUZjgel3wtiTCQoO7i0iONhQ6iGblsI8wLFKdYVcpS3eXeANrEyo sIT0bVg/nw307btbXl4N6pI7HsHc6ch312LurfsdOmf2ne4ZURb9QfeF57JicMHif4jf w6sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0rzBRaI/ZYbZ2jDlEcvd1eH3g2vJ/qZ3lsOwA042yyE=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=y6oOi7XqumrH960cuJPI+CNkkqfOMCeqhCcDG9YgriZlLbKEOY8v3bklBj0ql/KINq sKHDwCYyicoUzSJx9eBDC49FCam6/DyWP9C2gNUvvTFEU9lNsQ371SozbDIUIZMJ4GbL 2DVaOYQAo5MzoCiZN/5BRwTG6AcCUGOIDgSOAozx/xLj4IkyN1pn7u91U52XWCcZbJ6U jvFYHYQ2y+shiIpK6pLfG/+bqpFKWXbYoLh+AYIwaFvHgtGGYg5uyEtokaqZP1wNHYe1 7dR1IypFsZu9CWQNVk1OAy8kVnJhK5dPGbYqAWCIbaMOSC4yQ3kqnp0diHqDO1G5hHWJ yYEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gutgh3Mk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51ef2e82esi98365556d6.469.2024.06.24.23.12.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gutgh3Mk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzOi-0001TQ-FX; Tue, 25 Jun 2024 02:11:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzOa-00016Q-SQ for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:16 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzOY-0005hI-F5 for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:12 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4217136a74dso42276715e9.2 for ; Mon, 24 Jun 2024 23:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295868; x=1719900668; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0rzBRaI/ZYbZ2jDlEcvd1eH3g2vJ/qZ3lsOwA042yyE=; b=Gutgh3Mkf7/a3886owZbmEZJrEPLjFvOoskBGQsH0bNRIdchiSRgt9hZK5JrR5B8Kv DIk8v+rZ1RXWFoS2Gb49neYcnSCYoL5ydk+ALrY1VzBxFw5I+WIe3QUk2cn9123G80gk AZHrmxStSLYe1bj7TTdJgztFC+ebRD1ucEryzAexIxX/JBh01D3UnQYrjvcBrv1KEnXi /6Ux7JUnMbgR0p0FP31i2/e6hLb0VqiMk+pAVcKUVmPH74O7Q4b6NIcpSA19B8XcwkKf aXNDD2WweUCGaziedkZqCG3Kna+kOxqFm6uyQg1OkbxLQtHKaDy0If7UxoKuFtWIjsnR qZ0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295868; x=1719900668; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0rzBRaI/ZYbZ2jDlEcvd1eH3g2vJ/qZ3lsOwA042yyE=; b=dO2oYo8odhShKVkNrGKT4k0kiRRw9QY1y/tWEqrKYwcyP8Cb1ciw29KgfzgNKNHqpa HwSmf+W+24i/7ULmuqchoNJe136HeMJDS4yB7BbjfZ9dtc490/BgAy9j82QQd+OAxdYs DrG/5T5Yp2PbR0FLIDi7vlfEZPUkgvwsh82qws7du1fxOiNxH4jyvsxzq5lRJVSxU0J3 2F/gyu3aPlvfPunR0ofdIND/Z/LbWheB8iKktLkLb8rUKhGWOaMBrRj4UO5bFcZCvD7T h+mcWvA7WJj5lFY9tmOodFGRZp5i+zv99rjcW+TeiwP3DTcjFqksDat+kPrjypyXuRih esbA== X-Gm-Message-State: AOJu0Yzy6wAY/YAOwrwTRre+IeqMt5M9Hpfz/L3Kjs82OuRSEFEfrcYI QSAIZTEeYScN9boPVwgiW9QAd/krinKLmZ7bkZKyu2oTFLlJlgL6SZZ3wHNUKESl8D+Kv79mDp+ 2 X-Received: by 2002:a05:600c:3204:b0:421:7296:ba3f with SMTP id 5b1f17b1804b1-4248cc340e9mr42008765e9.22.1719295867776; Mon, 24 Jun 2024 23:11:07 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424817a8d8esm161294755e9.12.2024.06.24.23.11.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:11:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 08/11] hw/sd/sdcard: Convert GEN_CMD to generic_read_byte (CMD56) Date: Tue, 25 Jun 2024 08:10:12 +0200 Message-ID: <20240625061015.24095-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- 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 6e6b37bd2d..bf78f06b5c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1626,10 +1626,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: @@ -2115,6 +2117,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; @@ -2163,14 +2166,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; From patchwork Tue Jun 25 06:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807255 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2199937wrt; Mon, 24 Jun 2024 23:11:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUGWAOWU8RPOl4aUV7r+xsNTTrZv3tAqD9iCG+SnTm2P5owBXWiYOxEIHMqfZCD5ns1NOQbSBGYCfM3jgib5i+Z X-Google-Smtp-Source: AGHT+IHcH15oG0bFZ5ij7MZIibwG2YBbxBdzVMD6AxlarNc0oAmTFD29yGE1iXAUmkB2bayh/Rxw X-Received: by 2002:a05:6214:84c:b0:6b2:afad:7fec with SMTP id 6a1803df08f44-6b5632e41d7mr40694836d6.2.1719295894535; Mon, 24 Jun 2024 23:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295894; cv=none; d=google.com; s=arc-20160816; b=D5azssDiReMMwT7cW4JuE5ns6enqS4jRHjo2OXslqXBVbwWBBEW5BxzjQtSMnvfco8 I0uuAM+cvMStqEObKAismf5KJMkaLGvYtx7KgUHu4q5IyYkEBFOV9/xyulPVzAv2wM7u c47uANZagwLTmXK/qPDnKRMgD/eP1PvMKgcW2ipy2Wl7B8f0tbsuuIvOeX1lVzSs+AN/ 4WJND7q4Jsaob56nmZ7lMPbCQrOhXMkZqrUwmew/XlS1gavCUT4SzY/V7mlBqrvXvr8c uOspbycUMnH2+i07PJC33pmf/DWNLsUx9YB4THZ4HG4ovPuncdQoXPvchb8XfiEYjNpg 0UOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rg76PJz13yQ4blnaKM+Id2Hp7ZcBNraiQTaF1NSzcFU=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=THH+9p6dhIIzYGgKqcpl1qpZheVAbrbsQkre0aqr7s2KLiKF64I3Vw+yM8c8Ztm3KO SH8vnPQ72F3jxAqh/psQga/x1HYiJtXvHtrdgndLLCAFmorkAh2CoZB2kWCvTRUo6AKa bMr5yDof1Vid0aB/SsaqC867yNEao6V5UAwGHY0Ss0iICMMEbQlPoLpSxrQDYlIPGXn/ ZDm8xqfMyP3uMZwUQnF1TUztpVHqeFk8Uo096SObwwF/THkgjI8B7g+28uK1UBKNmcAJ fMgPTjcJGWLihB/iVUn1Mi3an7j8nETTMVowtUl+H+wFY2nqrMwfEgAsTtFFNAmxLNwg iBYA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOTsUU4V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b51edbd951si98022776d6.228.2024.06.24.23.11.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:11:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOTsUU4V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzOi-0001Ss-B5; Tue, 25 Jun 2024 02:11:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzOg-0001Bx-9G for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:18 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzOd-0005kl-BK for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:16 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so29938225e9.1 for ; Mon, 24 Jun 2024 23:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295873; x=1719900673; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rg76PJz13yQ4blnaKM+Id2Hp7ZcBNraiQTaF1NSzcFU=; b=QOTsUU4VQcBwK7n8esfW1nxdufy5YhdUcB1fc3KlQIUYiGyDyyEWu0eR+JnjpCc60F fNWXBp0vFqnS8u2n7PkONOuVTVN4igHPDBiKcsShsRQ3vjKdNmwWEnPq1x7bYQ+wO+nY AlFWPLoA8yIrri3q/FugMp5GOgXhuBVA5itRH95NHGv2x4HTLEQq+EJyp0WlNbCVVAIO XqoecCWlv8NmO6FSjVkLeyP9QHBS6A3ncefQQoE0KQbiRB/i68tr0XaXl5jZGUR8orM0 Erom7e3bSm33QQj+I79gQdRrSJ6xjkLWH3oDBqjhqgSdwjFLmYzso6hoeGW4IugimtbW J1Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295873; x=1719900673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rg76PJz13yQ4blnaKM+Id2Hp7ZcBNraiQTaF1NSzcFU=; b=fSvayi9842VfWLS4RlZwK+QepXIFKroYVPsr5auVIbSSn8Me/qh96VeGcIxAv8zKFv 32SOyS8p4nx5xE87jV8hEjc8jno4Q4Kur1nKqeEHYHinfwJSA+bCbY2IPSPOHt6INeQ2 TGZtctX8XeFAUVt5+hg3ozNljrWsOH8PW+Kl/RehBLb0c3vwq2q9gU9lWuyY+wRUbiMV vgEL/f/XTJ0J5acYlK9q2qcpm7JnBidwsGB0KxRtdZRPh/9DBJtO5NuflvZX1Jaedb/+ o+kl/TMH/V/dIzgf+qpc50IxoQtxnBYs6iKRI/9MwB3HHuFfTP5M21r0xPIn0YcS6Lyn 14qw== X-Gm-Message-State: AOJu0Ywh5+diO6uPPoqiQ+4CFMbXm8F+zMlWhygLLxBIcmwIVa3YxLVM 4fWag+JqcpxiVHPWgguRbwT+IdnKSqPfDawaAHwMWIG/MytoVrcek6/Ra2NyphxNS3u3koQUJqN E X-Received: by 2002:a05:600c:1c03:b0:424:895c:b84b with SMTP id 5b1f17b1804b1-424895cb8afmr68828375e9.4.1719295873296; Mon, 24 Jun 2024 23:11:13 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366388c401asm11961960f8f.45.2024.06.24.23.11.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:11:12 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 09/11] hw/sd/sdcard: Convert SD_STATUS to generic_read_byte (ACMD13) Date: Tue, 25 Jun 2024 08:10:13 +0200 Message-ID: <20240625061015.24095-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bf78f06b5c..2f00184bb3 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1681,10 +1681,9 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 13: /* ACMD13: SD_STATUS */ switch (sd->state) { case sd_transfer_state: - sd->state = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + sd->sd_status, + sizeof(sd->sd_status)); default: break; @@ -2114,6 +2113,7 @@ uint8_t sd_read_byte(SDState *sd) case 6: /* CMD6: SWITCH_FUNCTION */ case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ + case 13: /* ACMD13: SD_STATUS */ case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ case 30: /* CMD30: SEND_WRITE_PROT */ @@ -2121,13 +2121,6 @@ uint8_t sd_read_byte(SDState *sd) sd_generic_read_byte(sd, &ret); break; - case 13: /* ACMD13: SD_STATUS */ - ret = sd->sd_status[sd->data_offset ++]; - - if (sd->data_offset >= sizeof(sd->sd_status)) - sd->state = sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset == 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK", From patchwork Tue Jun 25 06:10:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807257 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2199986wrt; Mon, 24 Jun 2024 23:11:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU9YA5ApoEPTmVFLOcVBt67kZXk3FYTrrpwhppA1DwEMxhTl4iZe6tMBrT4WJh+G3HVRmlASkn8LPHwrd42MjU0 X-Google-Smtp-Source: AGHT+IExZO4j4RpJyylL7vWiuTRzXJaEfgR7QtJpdP1NRUXovx3gf4sC8lm16zadok+PkPATYAzz X-Received: by 2002:a81:a514:0:b0:627:956b:dbca with SMTP id 00721157ae682-643abe445a6mr58999717b3.40.1719295903154; Mon, 24 Jun 2024 23:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295903; cv=none; d=google.com; s=arc-20160816; b=p53bWU4mdW4ea8N3jjZmhcfKwda4R2jSTVigx5Og+4vbQ9UtLtBphJnUyVQA3Un8OK rJDY21i4vzbSvIvvtKW9+Hh7EipY/uw2rIKPjcnB8XLC0UrIqH8kpgYxFU0DmasBPixM V85HwINPtMQ10B2VjhPviQBUFxUXNXK14ihXNHCKDgea5Z5pw7MYeZD/MY3SvhIiq4pR bn0259CeYAldPGqSGgVXCQib/qTziVCrr7lyCOvF2E5ZCi09ovWCzrmmIsNgv5QAKSW7 SBNnM42IlqBQLY6LnCLITtIw0YmRKGDDAgSFMWdhUeYabK0s4jn7hA22um7ZuHFZSYlU ji5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/LWLsRRbYaLOv+/TgGcQ+HiQIJoOeLaCOvEip4a3OYs=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=E5rnIuMRYycTfK3qd1jq/pHpeUTdY9J7k0aSDbzmgNKWUaCEn5ZagwnKVwBWGwh8ZH fSVU21pXxE98sMePDuuAZBq5E9uxGT4uHBjoEmOQzm1T6CQ66kMhdun0/IoD4jnt9oJ6 xczrhAND0BjR43xFBgB+6+5v88ptpYo0cE6W7zqHBwPVlM7mL0giRTvuPHizFnvX4DHA wBUPt+aYnWiL2uLbLM2OlNPgTj/IgclTNZttGjb+HhL3TfPNur3unbToqRCPqJT13ltY r+ss0KHLaWRhX9WI/xS3do/XMhsjm5LFo8PqoPAHjAQzDjjwpp/Yvy70eQe3ZrW11DM9 TqWg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZpYtu0Xv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce881616si1024858085a.54.2024.06.24.23.11.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:11:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZpYtu0Xv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzOl-0001r5-Ni; Tue, 25 Jun 2024 02:11:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzOk-0001g2-A9 for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:22 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzOi-0005nO-Mo for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:22 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-424a2dabfefso2607065e9.3 for ; Mon, 24 Jun 2024 23:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295879; x=1719900679; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/LWLsRRbYaLOv+/TgGcQ+HiQIJoOeLaCOvEip4a3OYs=; b=ZpYtu0XvWi/pN2eiul66Q/tdOhf+bZq+cs8aQLUJ6Gcy76odXV+ll5DjWmyVv7DV6z 9xYvT0EBaadt9oZPVc9B8K3onz+0pHX/m/ZEVXNZj2Oz5svmuzt8OmVUEv9NPqeLxLTC Oo3eKqSj/3H86xjEOfsu9eQOPSjWUgULW89JUpKRLD6We2qW7lvDS+8EZXrzmBOg9gz4 0oCk+lpzqMI71fuy9aZLBv2v3QnV2xsBoN1c4oQRNzHEMs6r6EqBS+Y5rwOEiU/9sCoy fZ9LIU04Ubjw6t7br3kEfNerA9eY2PIr4omKSwVTfA8wgI8Cb0k1aj5JLbuIh2oXW09x KnnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295879; x=1719900679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/LWLsRRbYaLOv+/TgGcQ+HiQIJoOeLaCOvEip4a3OYs=; b=HcAO1R5GADk2VCQtel1J4fHu4VPb+fknVRJErLo6qC3/z2ocP+kZdPoZNg6VP2CEA9 gqsOLVus6QRZzf2P2cIQDpGw/0zWPcm6zNcG2VpNDSpqpkLLgzWhBVBvhspiT5dgqGgK RE6fL6EoUDeFKeMeU/ClmdOOxfc/wFhgG6Yrx6BHKoki+exc/5VGF6qGElHJLrkF1TlW IuzTdmNZtzyBoamGdZ8vLoIVbZQdZGYI397IibgP3A5jpmZHU1X9YdMMNRifhqlyBWrC lSshfJqPNOwKG3uG5kJt3vPW164eeNfvbVp8gwLF0VqQ8z7UHyahvf8RGVlgKB7COLpU uMow== X-Gm-Message-State: AOJu0YwONu73RCTusmLr/HQ4xBp5n57mQStTxipSLNcLYJiQYBKLyiju kP8AjVA2AbIqMnKIon5jfuvwClblbEdEgFVC9lD8F7u812+dfIgZ76p2i57i94Cht9DuqITg+cO N X-Received: by 2002:a05:6000:2c5:b0:366:e9dc:6dcf with SMTP id ffacd0b85a97d-366e9dc6ddcmr6726438f8f.42.1719295879001; Mon, 24 Jun 2024 23:11:19 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366383f687dsm11948295f8f.15.2024.06.24.23.11.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:11:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 10/11] hw/sd/sdcard: Convert SEND_NUM_WR_BLOCKS to generic_read_byte (ACMD22) Date: Tue, 25 Jun 2024 08:10:14 +0200 Message-ID: <20240625061015.24095-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2f00184bb3..023fcc63ac 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1693,11 +1693,9 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: - stl_be_p(sd->data, sd->blk_written); - sd->state = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, + &sd->blk_written, + sizeof(sd->blk_written)); default: break; @@ -2116,6 +2114,7 @@ uint8_t sd_read_byte(SDState *sd) case 13: /* ACMD13: SD_STATUS */ case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ + case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ case 30: /* CMD30: SEND_WRITE_PROT */ case 56: /* CMD56: GEN_CMD */ sd_generic_read_byte(sd, &ret); @@ -2145,13 +2144,6 @@ uint8_t sd_read_byte(SDState *sd) } break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 4) - sd->state = sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret = sd->scr[sd->data_offset ++]; From patchwork Tue Jun 25 06:10:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807258 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2200100wrt; Mon, 24 Jun 2024 23:12:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKao1tE0gSZaJjARM4e4UNjgvWMDrDRpoww+KYiSxPlCzzrZqiBkxsaIjBapZe0fkwkhntXMSn9ZrPltnJItpL X-Google-Smtp-Source: AGHT+IFmXHFBJrLHquKRTtyciITnury3QNrRIu1IKgcSIpm4Qy/3LzkVaAuUFGRIZDYv7rNyNBk0 X-Received: by 2002:a05:620a:454b:b0:794:f330:6caa with SMTP id af79cd13be357-79be6f19cbdmr706183085a.58.1719295931958; Mon, 24 Jun 2024 23:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719295931; cv=none; d=google.com; s=arc-20160816; b=uKpIHaZYEABX2hr8Yr8iWPQ8DmNitqj9XWZpQkfmNzUl/GT7h9QtyTpukixIiKkP/+ YQRTEQ54VYpfUt0Kt4Qje7d/s6+l563jF3QlwqtKoNNad774/x2VGpDJNll7fzkaqlO3 MhUNIsPoDoyCAwvaIEiNM/hPOqzeczfu/idOX5wZKgfKXrPzeNeTMKXjLpjDthbbqzm9 5qu7ZuS5mkKy9YXzXVJbPb4p6rE29Ax1XJnLBipNu/+8Ly3aqt75laEV67E79Iu/4NYq obx/2mZtFXxFx9acGccYh+TcO3W8173gVVF6QIySVqgwIX1OjUmjlhzysqDgCT4xrOBJ NY8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8JtzAqyOt7dnHFt5cCK1r6A59kYlBOq6vAwEqcU/vdY=; fh=/JlK2oR+rOwYm4wA2OuQV1gEZ6kNvrQcYuDHZ182k9M=; b=FEviwy8Ft1dSGpvdxMgpMLcxO2TdTjAr0gKiyTaV80DDq79mLQneXfDsxHoe/gn04X N99dGLnt25Xm5bZ1VdhIz23W2GpFsytzPlPtfR18dwSTKOzGTn0mI0A2FRl12ioQj0bo MNM5t58FdHbl9INI/NzaB8gAdwD+F39goPwDMJ6mVebsp4pqgc/80ayod9iBV0xUjSLk qUof8PFCQ1YznuIjovcT/TdO7H8GlYM9769zKCA2+RPTlMhJkeyq5/FdgSnCrO46PtYy HtKGghHDZ1DUuJfPg4zZLGhjkl7qulkVHsyGvOVPyN0m+mPBg/Uk+Pr3M3WYtNyfLNQp 2/7A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I+IhfaEz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79bce940917si1011960385a.566.2024.06.24.23.12.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 23:12:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I+IhfaEz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLzOt-0002XP-7Z; Tue, 25 Jun 2024 02:11:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLzOq-0002F8-1s for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:28 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLzOo-0005ns-8j for qemu-devel@nongnu.org; Tue, 25 Jun 2024 02:11:27 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4217c7eb6b4so42133505e9.2 for ; Mon, 24 Jun 2024 23:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719295884; x=1719900684; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8JtzAqyOt7dnHFt5cCK1r6A59kYlBOq6vAwEqcU/vdY=; b=I+IhfaEzs5oBXlat9JgwpDVqyQ7r/sRQ3LpHvKw01dIG5TwQ5ehpPP2gp5VuT2Okni 5nJ9esPi5MESBfw+LuAw4bqwXzTIx+rVVCmipCgyJIq4cu5UExjRhp1NkHpqtOlTKJ2P 3mKoUqYuCNNX61lUgJ+Rz2QNlW1Y+Gh9aoB+Q7IUw7zEWd5CuEUKU//JxL+MqRT8Rrhe cC576jvY0JJqh8GdVuuNuSngZZLReg5BxWn5IuzQyFaQcMJmfRz4ul3etAvnv5SwNmBp ok3gUBIWOqNFmbyLoRw4nbY+WwyKhKuQP6C7mH2n0yyid9VO06Hzji54OkoQDrSK+Bm4 XrbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719295884; x=1719900684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8JtzAqyOt7dnHFt5cCK1r6A59kYlBOq6vAwEqcU/vdY=; b=e/kveKD/iWiFQla4HZXhm9RT+Ijrv8F0yuJ5bTEwxLkvKr9WLxNM2mdABJABjWVvzX qzlbUnRt6L5ruS2m6YAWZ69rdwuDhnjsbPPisW/4AM5oB/besi3GnRViNiVzM2gtjy1b Gg2H7Nu9tX3EolkCcnuJ9hfW5fy99zTe9ehMiZFo+z3Se6vjUoNmbje0HO7v6jGQa1pO SjnvI8rr4apHCJQTyNn/GocTDGl8GxzMj/vnI9fpRAgS5XXMHQjSId2DcbrbBA+hTexB jKyjSO0rp6jLWNh/fvxK8YbUdghY/unDelCZDXzigFsTwb28begPJGYO3wE5rIAaYAcN 6Vdg== X-Gm-Message-State: AOJu0Yxv8F4yCmpIBC5HufaBAAPmu0Rn06WAZqhpXEcyHoz1DfNNoXqV N75sy58b3hGcHUtvCvSUUt62u/1ohYCk7SrraP7UbtmE8aMCp4mYK6jwC6/PaIo5UHb4G9BT7MU d X-Received: by 2002:a05:600c:2212:b0:424:a2d9:67c5 with SMTP id 5b1f17b1804b1-424a2d96a8emr4220655e9.16.1719295884588; Mon, 24 Jun 2024 23:11:24 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424a5a2683csm1746045e9.28.2024.06.24.23.11.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 23:11:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 11/11] hw/sd/sdcard: Convert SEND_SCR to generic_read_byte (ACMD51) Date: Tue, 25 Jun 2024 08:10:15 +0200 Message-ID: <20240625061015.24095-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625061015.24095-1-philmd@linaro.org> References: <20240625061015.24095-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 023fcc63ac..af3a46373f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1763,10 +1763,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 51: /* ACMD51: SEND_SCR */ switch (sd->state) { case sd_transfer_state: - sd->state = sd_sendingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; + return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->scr)); default: break; @@ -2116,6 +2113,7 @@ uint8_t sd_read_byte(SDState *sd) case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ case 30: /* CMD30: SEND_WRITE_PROT */ + case 51: /* ACMD51: SEND_SCR */ case 56: /* CMD56: GEN_CMD */ sd_generic_read_byte(sd, &ret); break; @@ -2144,13 +2142,6 @@ uint8_t sd_read_byte(SDState *sd) } break; - case 51: /* ACMD51: SEND_SCR */ - ret = sd->scr[sd->data_offset ++]; - - if (sd->data_offset >= sizeof(sd->scr)) - sd->state = sd_transfer_state; - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); return 0x00;