From patchwork Thu Jun 27 16:27:19 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: 807826 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp890958wrn; Thu, 27 Jun 2024 09:28:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWLGNID0UsISkAGWW8zVPof0D22mfT4scDF08T+7D8gKYBBsF8J0n39RLq0MkLxen+5nai2D7tWxKLazDobH4Wb X-Google-Smtp-Source: AGHT+IHkGPmewEsJn+0eOuw4w8vODh+SvoWRbkMVCnAMY7zxuaOZ7oJE4FESThvkXON15H9A9Cpq X-Received: by 2002:a05:6102:41a7:b0:48f:95aa:ae2b with SMTP id ada2fe7eead31-48f95aab13fmr1887578137.28.1719505690440; Thu, 27 Jun 2024 09:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505690; cv=none; d=google.com; s=arc-20160816; b=qhp9A51l/8U/esBNneYK+TKVuizj7oB8m/SHBawos+3KRnOqRvpSlewvmxzrZ/EDtk GnoZSwC73KY348mioK2pYsMHq2W28W9Xq7PqtpqScL2xeDhAfkSONbA97MJFWUE82kyw TggpV+GeOfSFOIOjb7jquGlei1o1CP9Aw4/kkXfYWFqdh3ME1bgDPmcRZLGZCX3DEIkp kF96BBDIV9BRxQmZfg74D2rfQpX0ginb0JED9hvA5iqHe5Nq8u8Na23SiM/t2kTvDRgo ISYqNF+ddUg8wMV7mm1PWnyW8IT74UwYijZQhcPjNu8WpD8TstmTHjDXkS555hyPVTMQ Lyag== 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=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=SLEG+iV8lPriYWMrci9E/pQkWvp7ev7sRByihDhpY1iiMmog8wQcNoLWQ5LBf73jho iHkeztSovvdC5wA8Bd6DVz3db5hczCEWaQSTJYg+5MNTO0kpRXVmm7eweA2txAzSEpL7 aPJeiLO/qQhEmSczJPXUbFq+hQziZj3zgGXwSu/FpPhYWFTGEt6D8UEWaxk6A8KZHS9g sTdiivsWpGvn6SFAAr65wBsIeCqH8h+6QmjezB11Qvqo0DQV2dwGbiVZGkA7G5ft9Fap tA/CVM0p4VE0Vcd8o0eve29TAeOUUms4VmyJqwjrLm6DGBXsIJ2Xiop8htMzyZw6WbaS mH0Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QEeCDpnn; 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-6b59e3637dasi89386d6.94.2024.06.27.09.28.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:28:10 -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=QEeCDpnn; 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 1sMryT-0000YW-NI; Thu, 27 Jun 2024 12:27:53 -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 1sMryR-0000Vy-58 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:27:51 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMryO-0003Le-JW for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:27:50 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-36743a79dceso553688f8f.0 for ; Thu, 27 Jun 2024 09:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505667; x=1720110467; 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=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; b=QEeCDpnnxzodhiI+YlDudza8dfO+H9e5eSCLHeZz59J+MHjRKF4sWK3se+ydq8Or2C WEUuYsatW0ekNd7OhYsx9d9Rc82dVtc7dLywp0nBVSCeO+hFm6YxxJmcVWaxENWToTr2 3megdtH1bibyKptzl2IOTpeUhivUn3Tn3P3ydNS1b/19FUTyK3Ie1QabYEZkT4QynO8i KPESup6Uzhi0Hs06df7W2FRGIDt48Phu0DhnO9/4gHn0hdq2dpA/cErr5MF8heRFDkZl P4R7SkBUrgp5lYb3OlqhjWbZUowAaV3bf210uzkhL0YgNrIKcq+HpjNVhUeAJBA41XwE AWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505667; x=1720110467; 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=/dkdp8a0v1eDrwEVEV8e/ROv9nmNjtoGPC9rjoBe3Zg=; b=sgrGIlhSPTT1iTP8GHtYyg1uGAJAoCe48lauuXAru4xGDJvs/C0wgQPJyqFPkliGEF ZNUECC/0BuexGCutMjA5ZBcNZ+oJNxRC0PbAJIVpyqaRuFdd38UrAcN/q5juEPVg/tas OMpVzeziD2yB7wIpe8VDsdBk0VNg4jKucV3Sgca/vg2I0r6Dw68hrJktOaVs1Hcapg06 n5erdQNyMkPgzb1UeLereTJqUsZV990b4BWkUaSNgwQoYew6KW1UhuFVblFGwvwUDM5s k91o25UWf3+n0kPAtL4IjWblXgD2BCGnoIVaS/Fidm4Yk0Kz3hAXsmhTTwgESJCPFX07 gHBg== X-Gm-Message-State: AOJu0YyuoUPIH7PJ1uY6MwLK7C1zzPxv5wyiiwz/Sv0X3jsKgJdJEXgf joXIhld2k/IP4LVTnxKquDwNTSn/UcrbaOBZVDeb+oFZjzH/fgRg91a/kB1LM4bjUc7bXt805KD pAgM= X-Received: by 2002:a05:6000:1748:b0:362:363a:9594 with SMTP id ffacd0b85a97d-3674178975cmr2208517f8f.11.1719505666928; Thu, 27 Jun 2024 09:27:46 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357fcb2sm2379487f8f.30.2024.06.27.09.27.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:27:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 01/11] hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte Date: Thu, 27 Jun 2024 18:27:19 +0200 Message-ID: <20240627162729.80909-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d85b2906f4..1a8d06804d 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]; @@ -1083,6 +1085,29 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +/* Configure fields for following sd_generic_read_byte() calls */ +__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) { @@ -1920,6 +1945,20 @@ send_response: return rsplen; } +/* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdata() */ +__attribute__((unused)) +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 Thu Jun 27 16:27:20 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: 807827 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891007wrn; Thu, 27 Jun 2024 09:28:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVjZSoEQnPMIC08i1hxJhHb97eNZvtWy4x0Ak2x5900oqFk1Mx1nCNG1ZXVONLWuoK8GcXohH/ed0wlq5yoENEr X-Google-Smtp-Source: AGHT+IHSLV6XgEHeQ74NPJ8venmj+a9M2omrrFt05ZhapyGzClAsGAi3MewDi9DrWROFsfS7ExRU X-Received: by 2002:a0c:e291:0:b0:6b5:420:bffc with SMTP id 6a1803df08f44-6b5409e0bfamr133874796d6.29.1719505697589; Thu, 27 Jun 2024 09:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505697; cv=none; d=google.com; s=arc-20160816; b=HgYqSE51Edi9s57CD+tb/PXSKYE/Hw9hQnUiTtT290faB5hFaDMSyxd0hO7Ypz0UEv SQ0A2w77TwRW7F7Cq7vama/TV4kJF/9jM7k7CnKKWnCdrS8FOf1IYzt9OPt+yQg8ON5C OsCA5EM8kdAj830ik0Uie3Sdt5icRCKEWuPJVIAqwoWqfT4EJrTBpNprETwRaKCWm0hQ OeYELpvRH6pvnYfvj0hSxj1keIdIpF+whP81gQqt+ov54V05GbdRCPZGtls7Wf6t+Onn 4M4RBlaceJ2v1s1DnIyRJVZNAupQ7Ny4faLvnI54crxJ+Yx9OhtmEuDXZwBFcufGQMZH 5Zug== 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=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=zmFF0yba4FeQK2yYtj0p6HyH1wvHpeVhfkvOBsfR8HBqfvnUixgxJz4NvHtTfv5BMJ tthg91rDvE/HAKy4ncmV3huks7xKoG2Wd+PdpAVagfFcJ/P4MXSFIM4YfrXtbGqk36TN baI4znLMxGf/0tV/86bEryj9h1ZEo4h9/FQ5C+BfEclrdsu1zueZWRznqLFLBYqpwgJF XOR2Wd2NtGx2tG0TG3ekLVuoovHbE2V4wBbMcXQCtRb0Mb+pTGcB1v1lgu9YeU7JBlRw /PYR70OduM1cjqWuS7lhmGNhNnDTcCdIcQrZdV8AqRx0bJ/zj34k9MGJ0leU8PeJX2b2 vmpw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ow85t6zG; 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-6b592933791si15499066d6.601.2024.06.27.09.28.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:28:17 -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=Ow85t6zG; 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 1sMryi-0000lW-PN; Thu, 27 Jun 2024 12:28:08 -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 1sMryg-0000j0-Ls for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:06 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrya-0003OO-FN for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:06 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4256788e13bso4423195e9.2 for ; Thu, 27 Jun 2024 09:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505678; x=1720110478; 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=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; b=Ow85t6zGoMZL5rfAibEj2gYXtKbN8uiqbfc3odrqkW27S4g1qyYAOr/o4s8wmZFVv8 OsaM82RjZirRqE7l9PmoKGOtauUOoP1z/J+zh/ln2pKgkIVfKhoHLfpFeT7M9Wj6ibv/ Ohm788b80Qt38XaL6uUjfuhEye96VyAu0CmtBdrQz5n9E+jKCvN6g6d6DD7ecRJNyty1 4k5m4TJltj5NfMHegpDlzKqjBrCBUBkgGkzNkzuvy96e0UUQt9T8lOY030ffjcbsS6gr ofwWydo1HaLzbfkWOx2Uo4BUUkHFAtiwzB6/9Ldf7Q3r//3A+kiXlD2jOiwFcXzOFlWo 0Pog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505678; x=1720110478; 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=PCAoLc7mb3MX2dHo327SeM2P71tXBpRF4C3PP6PydTI=; b=dw0MQaE3GgxrCithlXL2vHgEcyj5Nivnch1FPY9hCNz0PG+97+XHc+g3BSw2lsvkEF 4kvDboZvyVHbpPfiLlnrw9CfOzK1/aKmaZJeaxyOYMH/YSAL5pBn1EUL4CF6PW6UcXsw q7abs66FcJ7jRlPupxXqSmkiD4E33rK0VRN2gyife1JBwrLYtY1oirN0nFTfTMvzVJ45 DAmyn+DxRzYGMwkP5t+sEAxLxV2waFwINBfxPSoS9pB4kzbMEhsle/CH4JzgBWnzUOqW ozh/qh6JAXyvW7bppPf04zUD3zV4xqBtn5I4FldC5UCM4C8ivJVzhVy5o9RF6GDOYXLm DmGA== X-Gm-Message-State: AOJu0YyXJyGG756VfHr/YA7Yxd7CeM1D9oJjtJ4cVONYHuRAOLK8uUld zyyK3/2UGoDE+LvgFoGaASm0e5V0Mob6cr4tWw1Sdm1q6w9mB5YWD1zyIp1JQnMNiTR5Rj9ujUu tV8o= X-Received: by 2002:a05:600c:1d01:b0:425:6927:5f6a with SMTP id 5b1f17b1804b1-4256927620cmr3528425e9.19.1719505678287; Thu, 27 Jun 2024 09:27:58 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8424606sm73979315e9.30.2024.06.27.09.27.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:27:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 02/11] hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6) Date: Thu, 27 Jun 2024 18:27:20 +0200 Message-ID: <20240627162729.80909-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.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 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1a8d06804d..f7735c39a8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1086,7 +1086,6 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) } /* Configure fields for following sd_generic_read_byte() calls */ -__attribute__((unused)) static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, uint64_t start, const void *data, size_t size) @@ -1243,10 +1242,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); @@ -1946,7 +1942,6 @@ send_response: } /* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdata() */ -__attribute__((unused)) static bool sd_generic_read_byte(SDState *sd, uint8_t *value) { *value = sd->data[sd->data_offset]; @@ -2135,10 +2130,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 Thu Jun 27 16:27:21 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: 807828 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891091wrn; Thu, 27 Jun 2024 09:28:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVgTRMvh8VRHamMS20qcu2/G6pwpa2dW0XDNs7FYJEpBNLxb48BSQv2Zd0hH7chk0s6MPNBfPTG9Hm9tBPuR6UN X-Google-Smtp-Source: AGHT+IFAeHyjttlYytSCAcod/YIIKu+x8wMONx4VxNwreSoF0r7+wd1wXc79WdBK/sk2UO5wlcXU X-Received: by 2002:a05:6122:c85:b0:4ef:554c:144e with SMTP id 71dfb90a1353d-4ef6a5a39a1mr13111031e0c.1.1719505706755; Thu, 27 Jun 2024 09:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505706; cv=none; d=google.com; s=arc-20160816; b=NGWHOMTgQaC6Wv4oXhFKr4U2+XvzVHYBvI4h+6/qILnSDHTSrtNiKXHStEHqwZ5dmu QnKZqL6LT/lBZfLj0mlPLBsd0kMCeZzcnJ1oV+Xu9x4u/+u30KoMSUScbzGacro9QgXj W3nprdeAsXfs1xEhP6VJ3ctq/br4mofjzamQhC+8MnU+Ipx7QgxC6WyIFkEIHYWRIPjO cKr0JniLJaXPV0lSe9PoMxjJUhbvvuMFHvszsK1C3VJsEOcmQl8wM3W9mZO8Q31bWBaB VUjUce9U498B2f2lkvIZDdej+9y5B1PxWLtXBeZWeCjwUAPalnlA7H6U9e0H1K6aMztp WZzg== 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=L78DEkAbiZk4g5l5bieI9G3pq1quTielmVGwRkKOrNQ=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=vxAuqcmE1ieWoMloXXZjFgCuaK81xheaqQNf/SyI3yk1Urze3Kbw7gYUJ1IOaa9QQm Q4dpEkto8GgxPIcvBFDi+55NAWHJX4T1ZL67pC6wDprkH4plETpzfTXI1xELf5YhXcQG jcy7qrl1eDy/l3/c4ILFeczMPKnIbAKBnNA6P5NnDy60NFy5FueF10TIPJlBuRRCY+Zs +HNRLxww6XBgyta1Gp0gHKoGQKfIEPOesDoexmgGI8m2I1IT3/RRb9X1lN3OAoePGO6q goKF0dSvyiQRWqKhSh7eZgPs6KzLUdfkPmh1ihCFY5L2tuRmcOrhyY8XKRcnGkWsUEgM gkZg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TPYZ0s4p; 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 d75a77b69052e-4464202ea7bsi15933071cf.369.2024.06.27.09.28.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:28:26 -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=TPYZ0s4p; 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 1sMryp-0001Dp-Vs; Thu, 27 Jun 2024 12:28:16 -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 1sMrym-000183-U8 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:12 -0400 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMryl-0003QO-5j for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:12 -0400 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2ebe40673e8so91455771fa.3 for ; Thu, 27 Jun 2024 09:28:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505688; x=1720110488; 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=L78DEkAbiZk4g5l5bieI9G3pq1quTielmVGwRkKOrNQ=; b=TPYZ0s4pa17D9zpVItFqHQSK1/KG3cvEIvhXDIYGa+7CVF0iCq0V+SrACcwIMkolGq aUJLz/ZQy1z5JDaa/HOes8WNFGWDr9YBAj3IzkmFhjkdEoBZpB92epRiuaaMwEj+Ilub iE+sb9BISjJ2p4SQ6dSCU7Nh9kQLAnfkB6WJd47TB+v3slERjb8vO+JltZy6Zv1kZevX IXveoUE1TJaUJX5lWQOTJ0O5TYqHkUwx3FjK+4zxeFzcv4ATkFrFlRCqO8JEhQvAgab7 m5L/4CQLd+o0q9jE0CB6d/a6kkwf2At5HEDhUaF0+1spBCJwAlXwfYD2F04n2reyq905 Zl6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505688; x=1720110488; 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=L78DEkAbiZk4g5l5bieI9G3pq1quTielmVGwRkKOrNQ=; b=BrSXnWJLfxivwY9B3QeJFVnDh8rZFS5F7r0TiQHy0GUR1tEI0G0rChr4xTzrTka2g0 pH9MJeQv93KNCgPOiH0oSRiXxoBIYUVC07qltUhMG36267RBCGsJF7R9guOyYkACiPG7 tDVnfc7qeGFQrsrVAHcwu21fI90LMHZa0WdgnlT2IgXvowb1p3mCDGdjBH6ViMDR40fw jtwXrPivCjVhy1WyRkuJdzwSg/YLGmoP9aSO4eU9I8oaBkPKQdub7uLM6p1pM509HNf5 4cVZ7WAwXfkV3JhnXBOktlmlK+fhNxOaN7vU+32mYCHCHguczdcRSPloN/40VSMk2xyH sQfw== X-Gm-Message-State: AOJu0YwcFhRR/E7yIJRVyrso/IQ7tA/DCNlmZHw8oPRm11iueZszIuaH 1NRxwmAqHTqEGsHHleTRA9ZIWQvY4eTmBApWiIxS12ayofbN1Ujp/QFxibvYk4UuiL3O5cijxUa Y94I= X-Received: by 2002:a2e:9895:0:b0:2eb:e177:14f8 with SMTP id 38308e7fff4ca-2ec5b38ac24mr80911641fa.27.1719505688107; Thu, 27 Jun 2024 09:28:08 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8424554sm73694685e9.37.2024.06.27.09.28.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 03/11] hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 & 10) Date: Thu, 27 Jun 2024 18:27:21 +0200 Message-ID: <20240627162729.80909-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22d; envelope-from=philmd@linaro.org; helo=mail-lj1-x22d.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 f7735c39a8..8201f3245c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1312,11 +1312,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; @@ -1336,11 +1333,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; @@ -2130,15 +2124,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 Thu Jun 27 16:27:22 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: 807829 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891210wrn; Thu, 27 Jun 2024 09:28:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWealBrMOsOhY9BbV6pkIPB6i79MbKBOt0kW/9nTDg3s7yQUNV945m/Dwwn84MUtGXIqVrMSBPcaplVJ0HFbA6C X-Google-Smtp-Source: AGHT+IFlAi2lnxtm3LDHoZu5VB5IJGoJAu8oIf+hoLxT3tGrn6A8ct8tALJ2t2pBG5YxStda1TZR X-Received: by 2002:a05:620a:4549:b0:795:fc7b:4bcc with SMTP id af79cd13be357-79be0bfa768mr1778193885a.6.1719505722149; Thu, 27 Jun 2024 09:28:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505722; cv=none; d=google.com; s=arc-20160816; b=DD1TbYpjk9tRT/GCiHSTl9ZZUbYpdtlQCyDzwRhDUbaelJ0gEZ4GGCCWHtHW+ruFAQ G9gznuX6PFblYd9/gWsUqGRnWyTIhaecVCOQcRuUrTHYeJaSBoO401gxITAMtnienOJJ idAVVSLAO4TBDZt97oMX02VwNA3QKcAFmrH1JF0SW7QfCDzM4WubMwrMRvnA+x8LaT3M RmpyToDCsOs5Rc4/WTMtKrZ5qOsvME9TwIdkIw20c2j5TopOPc6HCkm5LQfUf3/JbUv9 mnkIPWjvJFM9twzRmoe0KtLxR1nsgclt3TxNtQ/nrxpYYi2l+mZgfNZD1Yds2yhMapLx GShg== 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=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=DeOiP3fwP1AcczQTTVMfM2pO+JJfIm9eTGmuQ2cU68cqV97ymVi4JZpKR5hI48vKuU watzxyN8VYbrYhPSC9buJjFgtb0lxYy5nifXCbGSlSB1AX3lIwsnlVbOQeB7qbEm1ZsE ThYuIahlSiVu3JNHfJYrmgp+LtzeQNW2fogN3tdgtMH6JcGXUv87U8WM2fqVCnnLxptc j0bVWugeMDEpJ8gRRV7MsMbrobed4WdS6NTZo3XjbqvpZdGLjYR6AFADNlGwck2mk2lr EsPJwzmmMC/6QWJGnWGY/N/9d4LrXv5DCtJ29+zkMUI4by8hgPivOggY+yopPOhDasWu rokw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kbq85n7A; 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-79d5c789da1si163591285a.136.2024.06.27.09.28.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:28:42 -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=kbq85n7A; 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 1sMrz1-00026J-Fq; Thu, 27 Jun 2024 12:28:27 -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 1sMryz-0001zt-A1 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:25 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMryu-0003RW-Gx for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:25 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52ce6a9fd5cso5040659e87.3 for ; Thu, 27 Jun 2024 09:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505698; x=1720110498; 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=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; b=kbq85n7ApPOGi9S5wvgOjM4bpa9bC6cpI56kHkVC7EUJPmVsVmJZ2BI6Rmvq45h1JO uD1mGAgAHFjskqrenjCXup5o84H53Lalv/JGz8CN225rRS1It8ldpW9ZMd61d1jJ1UY2 UkX7LukTWpwj2INhuXXHTVY1pDu4VKkT1dljG07eA/0Aj3oalK7thOUMoSKmlr4j6p50 0RLUH/rkn6fvMomc25qOk3nCPbxWH0KjmYYByn4W6UIz0PLalVIysPDoV+DACLvdHEVP GmClgJWbhgqc3rxxEPmGALBL2aMjuBeLzq7mbb4sAYpaW7fwWngTCpo/0/Yrtr8HZnCD Gwjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505698; x=1720110498; 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=Nu8acyjpOBs616osR1RalX8TR2/NJv3m9AnCQgylDWw=; b=WzMAmvWGP4i63f2nvBwivQu8/AJ7Oek5CWuWHYvX2+rotx05s1to+y6S7/QyHeRbmf HHXcq+2OCOvfduHuFryFEUnDr00ocICdbkkxMGGflCnsMkDo77RoCDGkDboVNgdnUXLj RNA1kVBcyhwwkpFRitONFx38qf2dDxAXfRtvWcDRTmuxkoJkahENai/COg/e2l8s5F7j e+g3Vr71g76x97vzEoa7q5bAv5LZqD+OfxajXJQHxM8PgPrSm5gWk4dS060+28nNM767 dvfeuwFmvoXwmt1BSVpUVTYXgCIJnoUpns+oWKWYZdfzTW5QlX1dhbfxOpj0E3CD+d43 hfWQ== X-Gm-Message-State: AOJu0Yzxk2VKiqb4hcUCQhiEHdLLsg62IzNxhdHlu4COe6k71gAbFapH 2uLlIdwzvMpglArE8uo6Nzy3b7159LHiBx98QPB2ZMoU59UTKego7yY0PdnzYzQpxbLuw8O0NeO 0tfI= X-Received: by 2002:ac2:5490:0:b0:52c:9e51:c3f with SMTP id 2adb3069b0e04-52ce185cfb0mr9045412e87.42.1719505698287; Thu, 27 Jun 2024 09:28:18 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8245e87sm76229945e9.9.2024.06.27.09.28.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 04/11] hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases Date: Thu, 27 Jun 2024 18:27:22 +0200 Message-ID: <20240627162729.80909-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=philmd@linaro.org; helo=mail-lf1-x134.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 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 8201f3245c..dfcb213aa9 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1398,6 +1398,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 Thu Jun 27 16:27:23 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: 807830 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891226wrn; Thu, 27 Jun 2024 09:28:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXAWqxb9B5d7EqQFIAueXZiCdUPnOshiYFz270KCvNeCjs+PDbUVV1mlUcncM+w1Nml74rvk/qb9n/8LpflY08u X-Google-Smtp-Source: AGHT+IEfGl6hvxZxn3LRx0s8JJBTPstmJS3JV2j04bjTlu2B3jG+E+UPyEWDxTEpWSmyCBK7TW2h X-Received: by 2002:a05:620a:254e:b0:795:b289:bf35 with SMTP id af79cd13be357-79be47cce1amr1485449985a.65.1719505726191; Thu, 27 Jun 2024 09:28:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505726; cv=none; d=google.com; s=arc-20160816; b=J6fWlZS5KGvmkAUck2rc3sFnu13t6dk+F350yfERpVZS8/AFiivs5BhCVq8KYJP0oe grvTNfUuXC/qVKZ2/NTtJhDxlEz6ZDVZ9ZmVZi1oY757k9daC5MZXY1gFX+XnU3p5/Lq YtoAFB9n2j3ezJXISqH0RT2M46+OvQnhyo81y89HwMW9OK8iL9LYukhxnOi1Zsnca0nT GddzYtfc84v+YHsLjDSV3idXt91mJImExG6h5yO2jRPbgiWe+aco5ZAzQthmqYSMT1Wo Y2WDeRXoUb0TiK4k4a0I5DEa6iCyYX2bWFPBqAmG5U7mFmcsbccJVpDpCjajJDs42wtp WuWg== 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=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=J/vnsx5tTBHBmnk7pBA4+j+yWL2B6reDo7sF6GjpseGkgro6eq3YJeMpFV088B2NN5 SGWPBTJuEAoYWEgQw5sm0AlGHskfq+e6zHv7erERL60TtY9pYMZCvESijfn0N7mbU4Xr 43arRDevIfZuSmYRrZAsW6l9JUQkHeRDaAmiR9LU7r1Sh6Y+J9eYbqlpRFoNDrIBpZol DsPkc0G9jZMAPME7O6woFlFbtxjR0Aq4L9GT0SN/Zp7LzFDAPfPX6g776kSXc23MJTbS ZevVZuAzrsjZkl6t+fbwMngFAy24qVV/bxkUGbrRoWoDmEgpyPrZnnCto35aWU68lgUE H7Jg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p6VBLk6S; 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-79d5c7aa4absi166725585a.96.2024.06.27.09.28.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:28:46 -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=p6VBLk6S; 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 1sMrz9-0002Ry-6H; Thu, 27 Jun 2024 12:28:35 -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 1sMrz6-0002Kw-Uw for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:33 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrz4-0003Sz-6v for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:31 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-364a3d5d901so5382498f8f.0 for ; Thu, 27 Jun 2024 09:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505708; x=1720110508; 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=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; b=p6VBLk6SzLc8jyl2mIYxsz2jOv2+5CE/LYekPRKVsWZuP60H+BdfPdClSvhU3JiN9T JonknX+PHpwWPGIyID01yIMfKG78veT/p89nNV9QONccS9pc+le66sZIw6M4+YiQhp9O eyV+BdB4vw7z7NjNJX6FWmE1csT31aeQOhZ6BCBqIAisjqnMqqpeDPUKlIhXWi+HuLCQ n3sueN1gM3fjkeNUMJcmhhop9u1XrTNezOf2MVUnrqfucEUH1i72pSzABeHouCSNqj+5 P9nF6GV7ND++q1lXujpJkWZGpZdhsS8UY7tsJTDT+LkKWEpa9C83CSW0zbU+4XG1yF1k J0xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505708; x=1720110508; 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=2/Nk+VBMPqpf8y4oh8kBjAzH+GIdB3yLjf9fq0VMabc=; b=sDfVuayQqjTEFRV0utCUlv1PCYuq7lQMxtLKJOUc0pRkcA8zt4INVj6pid8CfWTYV1 NeARguE9/PJ9NQmCDeogZ8NVoYIca0ObEPKeuEF8nIDpHnKRSXoq0cKX9mAdX7k8UMQi nQtUDL2YyiW7+nDHftr5P+iz8RatNzDKABGxAyc5V2rq3Iea3TRdNfU87OGWG3ik8K/z Om/jkeE9KGcOcga3p80zKEqdrnj2feLw+wr0IXvMZ+6aOV320EZy6LGaPtICqLFIkLYr TqxPCEhIetVaJBg055dMzxJ8K2JnGmhfWX8bfW+aVxal1hPtqsd0/ksqPkl3D17pEkBh W0fA== X-Gm-Message-State: AOJu0YzXfY77Ksl6FIPsdQb8TT5eLvPBwpkhfdxOXJOwtHKp3+QbT4HT BCVhNLLZBCa3L6ta6D0gGlNmtz1CN3nHiA977lIgxyn84eVTpjBsHRHQhtbY1IPOjbj224GW12x CUwM= X-Received: by 2002:a5d:58c7:0:b0:362:69f1:a08 with SMTP id ffacd0b85a97d-366e948fa96mr9537647f8f.19.1719505708589; Thu, 27 Jun 2024 09:28:28 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357c1c8sm2402704f8f.9.2024.06.27.09.28.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 05/11] hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17) Date: Thu, 27 Jun 2024 18:27:23 +0200 Message-ID: <20240627162729.80909-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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 dfcb213aa9..605269163d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1405,11 +1405,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; @@ -2144,6 +2141,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; @@ -2154,16 +2152,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 Thu Jun 27 16:27:24 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: 807831 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891345wrn; Thu, 27 Jun 2024 09:29:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV/BqfLXYcGJpflxhi3/tXIL7ZoB5dzP0KFAH7XE1NYBgWUqG9mCLOrr/Fz50HCdxEMNb/lsATyRX/sQbdaQkR2 X-Google-Smtp-Source: AGHT+IGoK0FLvTNJnn6ehyEyqtHarZCvWfcGSVT8qMct81QJicWcgLLQZ8z4tE5TWL+7E9n4eClX X-Received: by 2002:a9d:744e:0:b0:700:b1aa:bea6 with SMTP id 46e09a7af769-700b1aabf46mr14899957a34.23.1719505743648; Thu, 27 Jun 2024 09:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505743; cv=none; d=google.com; s=arc-20160816; b=MVhtJBL32EcCk5uqXwu+as33Ib8eNsnbS1lVojX5yE7wW7FoM/novuCA7pFvGfxQFi KidXQnwctMI2SiBXHqMTPQ04I0aXwT/tiuSnxj469avXd726cT60XZ0uOyxooY/YoCbi 7aoZR8AkhOH9eNIpzSUC6ULR5Ms6syvOZh3ZgGgiuiEMbZfuql08UMNFEH8U9uA/iE9U 5n+DIA6ZNyXW51ScXLoLGmURDXNXFyQTujnBLOgAnUoI4GBUkDvKF7X7+COAeHmktTq8 RYFHcYXIsKy7gzYjSH5j8ZNtsTvwVT8VsbhojNxcY6E4bcCb+MERhV6GIHoTX8seR0OW AmPA== 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=Xyhvw/6qmXFus9eORwXzq1Iu5gU3BghWHGLoDUVW4O4=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=mCRF4kV1YGv+iT6ttaa1G/AIgP8FXmLAG4DabUedojBUyk4sDniehu0Xx0ttWqzSaS Se6e3Gw0f7G+hRZU4H9SLymMCjITqwbyML3o4sr/HyFbPcnyJekf2KDmu7XRJMuXLx0G eG4xgOMdJe7FFlHXvzQx8nNdILv6fMarohoQ83cog8BfKGL6u/I4YZ2tlZYf8PLzzbjn 3KhEENTbhjtSSX5BA60+bW+HSoYMCJJPrmUdG5BssEruktmSZXSHgdGY4ySKfH335S/A fh5Na0487IsibKoq0gy3ai8aYh3gzyBkG3GelqcdxKriPJY8yCQy5fMObdsvAIBL7p/R SFNw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G7uzp2qr; 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-79d5c789d96si164892085a.12.2024.06.27.09.29.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:29:03 -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=G7uzp2qr; 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 1sMrzI-0002lX-R5; Thu, 27 Jun 2024 12:28:45 -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 1sMrzD-0002fK-2J for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:39 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrzB-0003UK-BL for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:38 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4248ff53f04so35300975e9.0 for ; Thu, 27 Jun 2024 09:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505715; x=1720110515; 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=Xyhvw/6qmXFus9eORwXzq1Iu5gU3BghWHGLoDUVW4O4=; b=G7uzp2qrNIcGqlouSW4SF+VIDuGX6y1EmnUeCs3txzGzI2//5IRpo67FvokbnB0Fs8 6NxCybFLaT/4R0rXbv2ZBo45E0GF1UrKcQtosQ8DKGQZw2rmtsnJ07QwBIEQFv/2jyb5 mtZEmNmUgsi/E+WJvboTV/+bdjGrUzeGdDssc7OWGVLkioTGQedmRZfmiOO+m6RxrBfR UllzfeIr482v3SSEdCrSNzhrhm2ee2ALsA62yzpXqkqKBgdrA7z7QZVOnujo52mo1O86 KQC2HK5UTpNmMMIdciIjWDXbNUmB0iA2UDTDdb0VEKPuuR/hDnIuIbcT9GtAzTOYKSUl 1ltw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505715; x=1720110515; 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=Xyhvw/6qmXFus9eORwXzq1Iu5gU3BghWHGLoDUVW4O4=; b=M39DxUq9ufK4J/qJWo6ID3BIX3hqOC4VARmKy1tpH2RAT+vsGRR148H1OdHL4c0L68 2W9bMfaX0vdtofKVS6RbJ0j9ta2Q5cehIIa8hCv5VeBgBxBXlGfbTAuODs4yOCeQzW75 jBAy8xmPDzAgJhaZKU5U9PkzcQHGqTr3Zlrqj5yIeA57N2N5YOBD/XefM/fVrza0/0wQ YkDNF52ppiJJbPslM7UIzdtOiimoAAV+y/L67XOia6xggyS8ET8TSrG6FZas+d3bEYUB Yyz9qr35yRUUTOQYaznTrZtFz6g/F4tDP3l+3jvykFlFxXMmCj6VBGkSoQgzaJMH9x5s m/zA== X-Gm-Message-State: AOJu0Yyi5DVSIJBmVX7gGc8NhG3lnP3zYsynJEutQuOdf/QkVSfNxYXS 1QwGkc1zIo2LNWTJsq1PFH2NiTj5GGtMnZa3cboo9YbQkR8Du/A6W4tS1QO+6QvWQCa1vX/K+T/ V2xE= X-Received: by 2002:a05:600c:25a:b0:425:6001:6637 with SMTP id 5b1f17b1804b1-4256001679fmr30535685e9.1.1719505715590; Thu, 27 Jun 2024 09:28:35 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8246828sm76479825e9.5.2024.06.27.09.28.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 06/11] hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19) Date: Thu, 27 Jun 2024 18:27:24 +0200 Message-ID: <20240627162729.80909-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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 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 605269163d..eece33194a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -568,6 +568,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]; @@ -1161,14 +1176,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 */ @@ -2100,20 +2110,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 */ @@ -2142,6 +2138,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; @@ -2176,13 +2173,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 Thu Jun 27 16:27:25 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: 807832 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891367wrn; Thu, 27 Jun 2024 09:29:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWfs0CudlS1YDpK6mLG6RRd9lBZZPcmcEv3Hl8Yg2diBx04Wrd7dEaH5EF9FihYXNIl2d/bzQ8tWj3qLdb+SYp7 X-Google-Smtp-Source: AGHT+IHPEx9Qndm8KwgQDXSGtpEwiI50kpDpfHEGa8O6flQwwJOfzQ/PWRDzXvYMrZCLXO9cZeDK X-Received: by 2002:a05:620a:b05:b0:795:59ed:21e3 with SMTP id af79cd13be357-79d5cfc4756mr291124485a.3.1719505747625; Thu, 27 Jun 2024 09:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505747; cv=none; d=google.com; s=arc-20160816; b=dTxYFbTrQK44jcfJ7zf96FopqJVNOdDxe28SGc4YF/81wIAfZySM6zgo70uHXIL83K kKt9Cm5GBZ5Ed6Vx6kE1mvhl13YO5elR73uxRkeolalRH+xIR3Kw07Q5Sops95ZRSGx7 ZoFxMLroxLR3L7InYtj8eAaVG47AG8fztxkkeMaIJTFnJO4G2q2y6PJxwb0oVt0c+Flk Xc0AJHYQDlRMp2yTswqNpnRL/4vqsPksNKxGkzXIqCbBELhT3bpbLRx9PBo/kH1eP/0k rKLE7GSH8JwmjSM9Gk6ERFtOnQCaohfplTgSiVNiSfHlupxJgaJ8cHd9IbaxSg29DQ2i 6Vag== 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=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=ZeyuM2cg8P8wDfpId/6fSWdo0kDZcDtbP+s7J1bgs+njSmBCV96SaAyQgniB/KGR2G n+py/9hFws4Aw/3AGpFP/WbLp3e/GXCJsEp2iG83EYqgvIA6sPssekLbWe2ApoeoAI+X W2MzzSPVemzE5tYFxlw7lSI8rWMCEbCSgPY+zbJ67BUVtAsvI9tcIJhJet95F9WBfNos WEaIcdpaZWfEzSHasEDQAZMry7DJd1kPPvpHZHeWKeQP8vxOuiPJFyEVRAv7Gdd7pkDI jM0lNfimTqrxqzuDXj5Dr2JuQhsPGIHwySOt7uJq2RiTmYNVfjPtObQ0iwXD65MROXKm q0xQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OFKGwD0i; 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-79d5c8b7821si162980685a.491.2024.06.27.09.29.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:29:07 -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=OFKGwD0i; 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 1sMrzS-0003LZ-1q; Thu, 27 Jun 2024 12:28: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 1sMrzO-00037o-5z for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:50 -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 1sMrzK-0003VJ-LO for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:48 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-424f2b73629so22835875e9.2 for ; Thu, 27 Jun 2024 09:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505724; x=1720110524; 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=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; b=OFKGwD0ivlbZnWH7p/QMvodQqcn6r59QTHglZw5G+H8SurDq5B73ZHRwEIihVMtvfG odkgMD7Rip0OlN88IJDuQWtGRlhGYaGNQwJhroJHlz9QEQhvDiT3eHxJTXNLdKEyEcwW E0arsNdaBXJB6HFxp0u0SsGil4eNx1TvRA9cmeTlUHx5u3Av7/JLKT3gnQtPRQVDevbe N9i7Fbrp42xkX4XiWgrxNwxWJaKInwWHi7xPtP3vwKifK2yxZ/ycPV//DTzPM4DywPYh UC1h6YzmWtRwSqfqaCfdrrIbexY/VqQMKOQ08mVtZtLjEr4U/oGKz0bMiNCS/i7QhpRR qgEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505724; x=1720110524; 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=cXnvSPEQ0479Kw/NHZLng3szLmllyhp62LGUqGmd/0w=; b=mXQwGsRYYPwKi2cARDHoyoquTkPd3QCF+WUCn/7Y2Uyk8HtzI/U/uIwpnE7bIitO8J l61Gm38oFMZ8ba9BMzw7zx3RVQMlHwkaEFxzP7yMhkPUu9DTYxS/EfzvfnZmd7qaZuVn Y973GUjAIbGynfwyg/MZmA+LPkd/Z985K0R6sMu6BqAulwTQZBNZTWn5k2hCQzlhXlMg WOqdpruq/mhJ5vYJWtEbE+VD7zQzsIqTffVbS+eFVQZxFQ5tK7CdlDNRPPsSqBJEnQVr 8K+cG0YilJZG7qednVVts0lCyy/x2qjrjYDx8Sf9YmQy4SWeyZ1qTdXFn6Yz+w9zuuqQ enuA== X-Gm-Message-State: AOJu0YwzEqZJ/l6bvVI/PEO1VZVM1CClJIsfgL5VXsNSeMfB5e6+K7LU +sZ29f9642iuzmsEJdaNxxiAtcGme24WeJtuMLqYk7UK/Tcw2OSvUs6BPcDQcCU//Hr1XMctqDh M1Cs= X-Received: by 2002:a05:6000:2ab:b0:366:eb00:9ddf with SMTP id ffacd0b85a97d-366eb009e92mr13900341f8f.3.1719505723851; Thu, 27 Jun 2024 09:28:43 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357c1fcsm2379809f8f.20.2024.06.27.09.28.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 07/11] hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30) Date: Thu, 27 Jun 2024 18:27:25 +0200 Message-ID: <20240627162729.80909-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-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=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 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 eece33194a..bf922da2cc 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1202,6 +1202,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. @@ -1555,12 +1556,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; @@ -2139,6 +2136,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; @@ -2180,13 +2178,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 Thu Jun 27 16:27:26 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: 807833 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891433wrn; Thu, 27 Jun 2024 09:29:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUrqCU9970LCJSlHkb0HHl8ZIRejRqWjKTxMgUOsh7y5f7inSuLdKIb7Fg6p+NADjxPyQbgvBPNkl8MucoNFzHd X-Google-Smtp-Source: AGHT+IF4EjdAi5/y35fWnDaVhxtNHMByc/C1m45fc66DfhpcGQY4Vf9XvZDy1QCWK72jkR42J7qF X-Received: by 2002:a05:620a:564b:b0:79d:5b0e:fa9f with SMTP id af79cd13be357-79d5b0eff82mr284291685a.29.1719505756479; Thu, 27 Jun 2024 09:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505756; cv=none; d=google.com; s=arc-20160816; b=AFHF4Z6EWX3dzFuNM5hTZVG1p06+sK6o/Hk7sCE/FIZScvRR/Uac3Ikj89Rx/LjF2u fP9QyAq8dSlUDDe7Hyk7LbsSsuRtVazpkZWMFZF6APeyKhKTDzQeBKOb7pyNa3ygpC5s YYIhxE/YzKa5sxCrGhbmKZXhc8jsQUgqtgLvRax4Thj8cThxFKByhSXTCUY6w4CvPfTF anRaVV5aahhtegkSoQfzIn0Xh8ogmEi9+shU+QBqDK4hdQ5SPY+9onlX1pyDxvRJkWs/ Ue460CqoGmSlT6nblwiY1cXe++MYPSN5j8lUk1Zfq6RTJ+eF0NF5/mnRM6dJp4JcjSme iHLA== 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=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=YFcu17tDfahEqd0nWcM4QNDjKuDYW6mA06GxH1+cI+qo6ImIkGk32efVwa8ohrtsSz LXwcTKJs5HQOHpGs4bMM9SmhUVNxDujjiqVXy8IK026KE5ewseUDc6f9ocK3jpGaGeIY GmR9qX8YRJKIcSfVh//GCc8unv7jitQnnO5cnHnqZoHZ4qRXouEEebpf89rYE6EedeUV xKjKTougedrOVNWMusVTqL2PYyR9AERofbysS6wCF4D4Z0IBg/9FNOvvMq8v2bKfrnB6 66YLVQ5La0kghVRLThq4PjF/9liPz5q9okUmnx5vfz53QqnVQ1PpLDYpBq1MsMM7qwWr +bSw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NkximAbf; 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-79d5c8b681dsi169410085a.452.2024.06.27.09.29.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:29: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=NkximAbf; 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 1sMrzZ-0004Ft-1C; Thu, 27 Jun 2024 12:29:01 -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 1sMrzX-00042I-7W for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:59 -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 1sMrzT-0003W4-0f for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:28:57 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so12999345e9.1 for ; Thu, 27 Jun 2024 09:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505733; x=1720110533; 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=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; b=NkximAbfHZwrsZZoe9aAeCHIaepMoqrCaL2jukDcY5odVc5+ojfRdJzRY36C+BJJ2m iN332BWvqs3VM+Ii6/lwYsI8Q94jnu1aL1kA4aoPqDSEyuXqfI04MrNo+SwqKqh+km1M 7pYuoo8fSON8WYWoCxsq1s+pggqRgXWnuWIyrBENLXKQxsk9PfSjEG28HrqGPwKAdwmN KsJDAJHlfWW3h94bkD3aa/FyLEckTQQ80V2Zti5Z6FNGLu7tuBcsha+gEzhUoWxjkAEP /onhrHWa0le9XOUGWeDCk1tFEG34OMGJ/Fffo+khIPW6dlpbZjoxVGl3PLESZbaFrILY Ljzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505733; x=1720110533; 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=K0OGAnFsplarXOIRkfzB/tBQTFE1QX5yc3lFvHsUa30=; b=tpFi2lPqiKp2S4jBeICmq08F09/yqfTnPhSreg7GF2+wIcUAKUMNHjkW28mn7uoJMT SVV7ZMcCU99e7IoVJzy60CeG/8i8/XysQICEWMLWKxbw41lIFVIH1ZUjSCrBdeFLDcF7 PFUkfTQktH7T5FMSkWYlWo5EMHHA8YwEWGNG00HEnPMSXkEEWOwzaRa/wsvaQ1cbprTR FTrc86PWGXTJwD28Ss68WDEZoOiHG3aOWDwV0esUHmRFGGOkT1qTlXa4spWieotoyRfR TI8fpaXXFOg6UQaJVBEXSpv68m442EP+IDhsq+K3ZWCXKGOCoBIkjW8mSeBPwor+aPlZ nElA== X-Gm-Message-State: AOJu0YyvjlEOZcE86GIDTj5oCLMPc55j4JqHpBKyok5FLQWrEF9ftHCM /I+q90xF9x9kwgg51sjUdM9rUiCWx9a2TxIkog1+8LpPTxU5VT9+P4w5RQv7GHFmqb+KKGivY1E AatQ= X-Received: by 2002:a05:600c:5104:b0:424:8836:310c with SMTP id 5b1f17b1804b1-42564316399mr24158445e9.5.1719505733307; Thu, 27 Jun 2024 09:28:53 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564bc59f5sm35576815e9.42.2024.06.27.09.28.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:28:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 08/11] hw/sd/sdcard: Convert GEN_CMD to generic_read_byte (CMD56) Date: Thu, 27 Jun 2024 18:27:26 +0200 Message-ID: <20240627162729.80909-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-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 bf922da2cc..ccf81b9e59 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1648,10 +1648,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: @@ -2137,6 +2139,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; @@ -2185,14 +2188,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 Thu Jun 27 16:27:27 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: 807834 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891456wrn; Thu, 27 Jun 2024 09:29:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXj/gQN8O3sm5oQARuozPfCh1WUTwBzvn8kRwqDyWa7zoCCgDDxdYeteDH8AV0pqTTRVefNA9x/faTd15zGr2VP X-Google-Smtp-Source: AGHT+IEQU+XliqUNz+ZvF8tJuD07yWQdi8niWcHWEasHWF6bqIli24kT+NX67AVHxMnQZlLafyoe X-Received: by 2002:a05:6808:14c6:b0:3d2:2703:2573 with SMTP id 5614622812f47-3d543acb10cmr18350575b6e.8.1719505760025; Thu, 27 Jun 2024 09:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505759; cv=none; d=google.com; s=arc-20160816; b=OE4ZrWbHAPC46GExVUAAPMyxiOUwbJYlsIGtofFkWxsoNBwwcwdcuJ4bosBz9eypVJ 1cWz2UyodNETRo5JSllu3hGpSinF0ZtDymy458bod8j8xfn9rlVOOl82kurqtFZf0GxX cPgMlIZCLlFkRtgQY2tbkdFpCFEhBQwKE4zlN+LveQ554VKqhn0alHpxJz2chVLKboD7 63ED5f0LBAbs5mkn2xGQ8En0ZyJXsH7czElDJfyBXP6bz5bbUcC7qJY5i3D2ovQpbPne SMLRBZIT2XiF3zZ+ctR3vWDZmCrTfTptFS1EYEofDSgsawSUSuUtBTK/SXEnH+MPm4Ou /fAQ== 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=1KciARHbIYi2vnj7HB8fhMsqIK9cJrPhhDCahh6cG1M=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=hbDa4g2SrdMI4HIEyEqUca+Grah2ECu6hp1gj3W6YGXNAozq4OxpQjk9UyChQEL9Rf SfWxC23s6SL1upJC1BEXtEVenbnvFsZQQufHa56Iat4INTRLzA6cuMZfqj8c1XQ+WzpL xarKrgfA+U1iFNduj0s5FVQlECSLvGp/HZzbQ9R4MIfGui2Q/EBiEEA6N06YiodDzME2 +QJrmaOI4TlF4JWoe6V3QM4nJ6y+TmiUzyLffYIfw8sKnkNhpGOPITX8EZHSD+DqhJCw r6nyeKOru/owtaIMnetPw+7+D2SOuNoGZzAxXCfY7SpRBgarLS4YhdygLwBLQkIqs+s3 SYDw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qvke0LxH; 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 d75a77b69052e-44642245665si16080301cf.778.2024.06.27.09.29.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:29:19 -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=qvke0LxH; 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 1sMrzg-0004yX-6M; Thu, 27 Jun 2024 12:29:08 -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 1sMrze-0004sE-Uz for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:06 -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 1sMrzd-0003ZC-7C for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:06 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-424720e73e1so65536935e9.1 for ; Thu, 27 Jun 2024 09:29:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505743; x=1720110543; 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=1KciARHbIYi2vnj7HB8fhMsqIK9cJrPhhDCahh6cG1M=; b=qvke0LxHfA+oPmBvXwOWvEECPBfNBGeoJPSfT13JCrK0MbyDQAWGiVpCvPwqkQnBpy gdyMcIQMh2vo8xCEz8Gq7tJ3s7aUdXN2UkC9/6Q9dWXcMhSH69WfHTY8FLEuypzWudM8 zfwtzMDF5slvINtAAV/nZj1bUTb/2NRF/uLHqv9YbYNqPr3OMi0TU3OlId8V6pgkEAXY qUNyopUNeH8XUieIu/SrjFyR10DvZgNQGU+UDrsgPYin8CCCLtXQi/Kyvnbb2n/YABde Yf1mnIl076USdpYDqgSzp5vR9JrEZtWI0o760f/+RvpzmqRzxiXNiSqCEbytrple5YBt Paow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505743; x=1720110543; 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=1KciARHbIYi2vnj7HB8fhMsqIK9cJrPhhDCahh6cG1M=; b=b0vmKCK8y89errjVjrzMdS4s6IFzcq50o6+1Dv/6CntCEXD0QxHff/fuBmcTfBTKTK RKrcmjNi58I1hm26MnLnFAjoIXTT0njxpilLCuUQ5g4rl8pAoueBLBUeSxoXYOzDydPe 9Gf/npzeL7GnzjiASNk3WYm6R4KNarkTlb7HHTiMec7UBaGbC5IvKIAteILZXF4YlBBW ESo9MN7G7oxnnwBEpGG6ZvuNhie1jtndl1vQxoegx3FJ0ylUvnuNMDFtVB4HyuOB+Upr zYq4QExkEDZ1JA7bpe94B/ahvshgqo9DarXTQBpx0AXE3QBbeolXTRdywM20wuFFB5kE 9+OQ== X-Gm-Message-State: AOJu0YzV71LhTxNQG1jCA9yJbtcsCbKR8sNxNcpEkgMmGjzqhT5oeFpJ yvSHJcBKYF/76yeUwlDh+kHZ8BRy86AJvdSOZBAGR8812v0tPipkPZghouWtaexbOu7M4Ua6mlD /S/8= X-Received: by 2002:a05:600c:a:b0:424:ad14:6b79 with SMTP id 5b1f17b1804b1-424ad146e41mr34288125e9.8.1719505743684; Thu, 27 Jun 2024 09:29:03 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367436998fbsm2359860f8f.84.2024.06.27.09.28.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:29:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 09/11] hw/sd/sdcard: Convert SD_STATUS to generic_read_byte (ACMD13) Date: Thu, 27 Jun 2024 18:27:27 +0200 Message-ID: <20240627162729.80909-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-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 | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ccf81b9e59..1c4811f410 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1703,10 +1703,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; @@ -2136,6 +2135,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 */ @@ -2143,13 +2143,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 Thu Jun 27 16:27:28 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: 807835 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891510wrn; Thu, 27 Jun 2024 09:29:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUJrZ9Z5hIRiWqmZme7Bn2NBK5Uec7sY6XrfmHX7YQBn1S11sEDauPZafV9mMuKfR4oO8ddUujgonVzZwMwieV+ X-Google-Smtp-Source: AGHT+IFYLKFbbCl/Xxbh1ceIGMmZbQZbkGmG1sSaOCBIcnB8AfmUjIAajB4vUcqDkQnnZByEVJb+ X-Received: by 2002:a0c:cb8c:0:b0:6b5:7e79:8b8a with SMTP id 6a1803df08f44-6b57e798c11mr51487706d6.50.1719505768261; Thu, 27 Jun 2024 09:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505768; cv=none; d=google.com; s=arc-20160816; b=ZU2a/qolxFWOsQ/9XnGYzg6ZaLV4XNLGJxfereCnaLmiAoGDyivVWbljpNEVnSDNC+ /8vtVtOEQRPEoY4ZpRbyXpKCw0YdYXG58UBzy+TCJRtXKmNH+yNKwHbPxL3oHSjVJ0OI ptez8Yzkf+pPe0lY8g2KczrYGoTtWwSkACN7X2ii2JSOJzuKNTzzAMpMvBrzjSHQOeiu WV3lzSlLc4k+jvH64w8kebVnALzoWLwBuNGunMUasxNwsAvjTSWcHJvcqm/zyhrKNIVs L1wymKIgNeFw49rtMbd3Bg6c/R/Ph3m+Du/LOWBOMFauoHB2x8ki8LN4VJptBFK6vzBe 3jhQ== 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=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=F9gNZfOKcu6q5V+g3G1B7g7iuDHFfReqDowCbj1J3Nr6JYfWjyORckLJXl1vDQa9vz ChIjf+mm5XFmoxO1KsRkb4F1QClm04ddO3h48RRbPOWdXmo1u2rWs7Knw2n/N//Kj/3+ q06p/8MXhscCPIYcMtp0F/fd7PthdLHoiqf0TkbcStts8TuWz4FWPkZB4FpciJfsTSU1 ubCrJB+eiANKkHygOsCHgP0miv/Mxg0/6/+gGX29MQdfIVED6IeqU05dzpv99/YVQHM4 RC/5t6Z55IM8AFkZQS0Gt20REjPJTy8dgz2d+SU8xRVtRVNPWSBUKzjSdi7/Xoc8L1tb D1xA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TqP9ojXb; 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-6b59e3639f4si109416d6.115.2024.06.27.09.29.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:29:28 -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=TqP9ojXb; 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 1sMrzz-0006vI-00; Thu, 27 Jun 2024 12:29:27 -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 1sMrzx-0006q2-IO for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:25 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrzq-0003aI-4W for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:25 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52ce01403f6so5520727e87.0 for ; Thu, 27 Jun 2024 09:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505756; x=1720110556; 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=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; b=TqP9ojXbJFcm1yNC/pr4FP1p946PY4m1Y+0dm6be54VvGs9u8DRH3Rtb646ouGkBZC 0nq2k9Ih4/zo2Di3frvKD3Wh07Ej7FGWQziQr3tZ7E2br43uQMhqg3DkucFYWDaQGbiS 2NDPdrZ6MDItKWc4Fx/he1vWKb/w7ycvkkzW33J4zh2QHyihwoAw2VoLLIIMsYs6sOvK DDyWECjZS0CtkR5tzsGJeaQX014PNh2Ke/hLx4E5q6iBnsIfRw01W8iVg1PMNCzEusBj zPyGedHcy5ZgkUb73TAWx0W6wXcJna7xFk/dQh74y7hWe5CkzFB2ZS0iEmJex8TJjgrt 21Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505756; x=1720110556; 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=sU/k2Rks1jINZkUZw0aLSNYbtB22cqllnIk+1At/gmc=; b=xJkzD9g35yl77afFrrYVQndkyIG85TsFGzWQ+6mGbSa/69lLnJkYNOcuEx7TLmoj4t lfONqZ5FWBmIqxOikGFlSagp3M2eTk47HISxwL3C3U/+8ENd0OU95m6Q/tPCv40PL743 F5a/6Z4za3j7sCa4tvNyBpoA+t7w41usR8ep0btnsRODwYIiudbkndGnC75DdUB/xUIz pd3xjZFlCmh71Mf9kwgCgZGqBvjMvhMVZd+Z/O8Ai/fy+uClgTjM/C+yV5yhLRZzXFbg nFLuNjo+ZKu8QOcu+o8TNx5b002dr/BFPvmv07aoj5g9YfT7QY/b9YHhGfj59s+2zCwt m6PQ== X-Gm-Message-State: AOJu0YzziWd6rMMXJEwWFUwAbiaoNmsNGOeQ5S65pvCEBLEnruhQQHLY UkFGWJIZ96zfOoe1y4ETOe6D7pnG6ewDMq1rxQ1RczPYYe2kO1bsi6O3MpH6hhH1jqs3w3oxrnk qMkU= X-Received: by 2002:a05:6512:2509:b0:52d:b0a5:cf3c with SMTP id 2adb3069b0e04-52db0a5e327mr5459783e87.40.1719505755838; Thu, 27 Jun 2024 09:29:15 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357c089sm2415473f8f.7.2024.06.27.09.29.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:29:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 10/11] hw/sd/sdcard: Convert SEND_NUM_WR_BLOCKS to generic_read_byte (ACMD22) Date: Thu, 27 Jun 2024 18:27:28 +0200 Message-ID: <20240627162729.80909-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=philmd@linaro.org; helo=mail-lf1-x133.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 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 1c4811f410..8d02cd9a26 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1715,11 +1715,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; @@ -2138,6 +2136,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); @@ -2167,13 +2166,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 Thu Jun 27 16:27:29 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: 807836 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp891553wrn; Thu, 27 Jun 2024 09:29:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVCEsYTkfjXt9JbyrSFJL3KUCBSzFiP8fmRIdtihsYu1ux9MLxowSwMa//12j63CZaLyAa66l8VTb05PD18R2Yo X-Google-Smtp-Source: AGHT+IG0dwfuTQvOV7ogOF2NSV8vppbhMgUnBIky2IbUJtaREQS0fsKjrXG+LGV1CAdFDdwfR9cq X-Received: by 2002:ac8:7e8f:0:b0:445:3f1:4715 with SMTP id d75a77b69052e-44503f14c47mr66290031cf.36.1719505774385; Thu, 27 Jun 2024 09:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719505774; cv=none; d=google.com; s=arc-20160816; b=fm4U1Ip9VyGdlA8wznFQXfwHOuMoG4ogamV3+im0tUK+ovaN7CY7Lky1WgK8/1GC+k mSz4J6uLs9KyG4A4UQ3SwZC4jKpX/qgm2c529ZFFvn33K6bd05aG/9e7KCaymWDIxS0Z cwTDupjlf5lGLLWPxba5MIaJRH7NYq6yOTSgG83gM5HIpFVUwrsL2jiBULslsbbSlq+9 45qd+p9S6cOkNNzutR7XKU9DkH3iddk0uU2N8RUP83LZjmgf+criO0trEn5k610A+Ljl K0143YJ4veyMR95+TRwZZI4vHIcnoOW+otGXr5hYKAj6rbLa1d4ZNmpz+b1v73et1xuX udOw== 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=SsWzBaT42Pcps68Pqu01vvv+C6po3s8FyjpSWrBt7mI=; fh=CQ9QAhiPZZ1APu1JLxgbtxAnzrroUJn9RCDrjAjVXrk=; b=lTsf5bdpLf7WhteEsNEOQ4B5uGBsjx3C8E1HjWjJ/Z/m961VuVyzVmkdQpfxeI/il8 WU75eGLCKo1XgrWPqZZAS1Hyk0qO4NIwcKIt7U4mjoIRXWSYWch0qHrnB72Bc5sklkQZ jmL5jW71HkiEuPYz8l2T7U3FTDq5Bw+gbFq6n5kScz+QqclD6bvRcJi2zLrM/nrIZOJh XpVEtFo3WzgN3mYk53sAlvOnD5+gPNV5LBDm/QJJbdss0YD5zRqcjC6m3C5bhUI4KwL+ 2Dur2PoiYRJC+u4a/r7vUDYgjjFYCLzhN3LsUP1HTe4RrdIPgbPCXIbZgg95tI7XLMmQ 6MAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Dcfd+7nl; 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 d75a77b69052e-4464221c49fsi15766491cf.676.2024.06.27.09.29.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:29: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=Dcfd+7nl; 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 1sMs02-0007AM-Sg; Thu, 27 Jun 2024 12:29:30 -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 1sMs01-00074B-1n for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:29 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrzz-0003bX-HC for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:29:28 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-424a3ccd0c0so27143405e9.1 for ; Thu, 27 Jun 2024 09:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505766; x=1720110566; 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=SsWzBaT42Pcps68Pqu01vvv+C6po3s8FyjpSWrBt7mI=; b=Dcfd+7nlE+ewoAwUDSjc/r/mqsb3XPO8/+oXQ56IWGPFPKdqLhRvqHmYl8CcTXo4ak yHUWHtg7JaMIB3SR5j78jMboWsk0hBPyHUoQGYQi1f3/V18M2XfdNpHdfjZklHjfsEGh lNzCxsgjOEtkfudVR16vfmWCieT1QmrKQQOt7Ivbcth2xxVVf6vZBqZlEXiZRs7M+YCA R2H8k+MtfdEC9sb/IuHcPx20wItTZX0WuKDJiGntrX+r449qJ072cMKg5Tar52y74/ql xf/iHAENHPfumpn/2Eg1djK7y5EV14nm+rHUEvUqBbBgYRFkLAbcRyfqo849l/hpfx1P iZcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505766; x=1720110566; 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=SsWzBaT42Pcps68Pqu01vvv+C6po3s8FyjpSWrBt7mI=; b=fp5+N7emuU5Zj/vdrOGoOhrE1wxHVAE5zUYKLEZ4LPdM+6r7FLvSS18OmzEog1QvLE rrqiF+d430wGKF/Szm+r5Uc/xNK6HeAroZwXLoDIPsaUh5V9EiOI6SL5frZnjQohYR53 nJw3AvVfG4nGeE+Cns2aBldjmC1X2n9TrhpDcchG6ksB2PIpQ13oKWm+J2pwZntgDdxd rSqHHmdq3Q/hTTZlJSOvKjRrLWgGiipdt+jl9Vh0pglR6Vrfn6DjlYtG+zuJWjmb8b7L a+UHfnfmkR+g4eR5zeH4L6j9POXTf22qY6IO5/u4WFQaCj8PGfXtT/oIeYEsGJRAUpR9 qAlQ== X-Gm-Message-State: AOJu0Yz2yh9L+ZBo+4tLnUc6gtg3SunhiBAQ9nNpNJYoKcDKbf1ag3O2 fun3trwgklWh39B8RNx7TO95Y5qjLm6ysTDSeZdLVGz15ShBEiZrm69XTdmFQWbYOHxRF7wlteM lt1w= X-Received: by 2002:a05:600c:3b8b:b0:425:69b7:3361 with SMTP id 5b1f17b1804b1-42569b7352bmr1511495e9.18.1719505765858; Thu, 27 Jun 2024 09:29:25 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c82515a1sm74222825e9.12.2024.06.27.09.29.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:29:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Francisco Iglesias , Bin Meng , Sai Pavan Boddu , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Luc Michel Subject: [PATCH v2 11/11] hw/sd/sdcard: Convert SEND_SCR to generic_read_byte (ACMD51) Date: Thu, 27 Jun 2024 18:27:29 +0200 Message-ID: <20240627162729.80909-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162729.80909-1-philmd@linaro.org> References: <20240627162729.80909-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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 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 8d02cd9a26..cd308e9a89 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1785,10 +1785,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; @@ -2138,6 +2135,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; @@ -2166,13 +2164,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;