From patchwork Fri Jun 28 07:00:56 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: 808174 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223033wrr; Fri, 28 Jun 2024 00:07:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXziALEGUm1BCc1BdVeUo2TFi4xJtAsphN0FqNIOnLjXds3kPwUqH7FmMr3+RJEFokhcTpCiZVhbsX/vqdEMMQ1 X-Google-Smtp-Source: AGHT+IH5n5DWazgaZzPBijwaXPNqDfE814QSVo/e8IZwxr5QT8kVdezzhzgUgpUB8O1mQzH0h+WT X-Received: by 2002:a05:622a:19a3:b0:440:5275:d435 with SMTP id d75a77b69052e-444d922ade0mr184541501cf.30.1719558463373; Fri, 28 Jun 2024 00:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558463; cv=none; d=google.com; s=arc-20160816; b=Y0pVw6bFC2hyPG3t3Ad3qkeXuV7VD9Y0XIluQ5RZ3vF9Gd9tu2HvSPlW0bNquNdWtb QHqk9U/WCs7pbwoVOehkEDdk7cXlmn94UqtEZYG9pPQT3eJFhEbWjUQg6zLuRrKGzN3O 59TIa0lsa12UQfT3cDc2ywukkbJSqwFBPBPnjHU0TQRadwUzGurc/O9mjVTGitfgfdWc DajLt3oX1amMpGcALVflOgnUMucDrdqgXBDE2JrVhqN3xRU7jS8wyKrL5V9ZOb6Y8zBL IYx7oCER8mzXIa/eNZJqRhyzLE4R0FgLqnPwW9irlOre15v/jvlUE72lb7tu/YNu/PGq LAAw== 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:to:from :dkim-signature; bh=IMgFwh1ILCldQYzDAsSnCsrKfQsCDMsdI1Fnj4dwB/k=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=g9KqtFlsOEthl+okeo9bfvatXiPvjCWjJDV5oXQyZeDscYOjWB1ZHuXF8NcjsO35VA +V/qGA1SAYWib2EWNWG6ziiYVZxMJoipHcO4/CZLOx8pHgR4S8B7bnMJNpOJ8mW+vBi9 +vkpM6G4eSUUBS4d0I3ca0ffVlRq/e4fdSgtSkyRlIox9+vNwoW74ZDDEX3WJ8kO8Zx1 S/3tLa0aKGjYW8YieY1l9cSZRFs44SK2CGxYDDzWY7IBGELcq9tQj2tilosQ6veOIxGi Dsop//O/PlN5CSPMVgn1iiXHjX/UgGu58fDVxIOebhCnWTOQNk2s5HvDq8Kyw0JFcfwR Fmpg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EPBdaDQr; 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-446512cc5b6si13213141cf.106.2024.06.28.00.07.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:07:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EPBdaDQr; 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 1sN5fD-0004NM-Hd; Fri, 28 Jun 2024 03:04:55 -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 1sN5ew-0003p2-Jy for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:40 -0400 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5eu-0007Ac-9V for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:04:37 -0400 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-52ccc40e72eso230025e87.3 for ; Fri, 28 Jun 2024 00:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558274; x=1720163074; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=IMgFwh1ILCldQYzDAsSnCsrKfQsCDMsdI1Fnj4dwB/k=; b=EPBdaDQr766xiiVG2RZhY1wvuoupD0fx4WQ4NLiv72wlKmKwisnXn/z2Fz71MFN5UT NFSOqdLyqUhxBsc2JMk7YB4El9D8B3pQJ0yIMJJgkZkkXAz6hjy3j+827Ac9cD3NULSk GdnwZgEi7g5SJHyGYVmuiDKRMpevJPd8JPIJ75Yn5lVIQXWnl2AGMTBYgJl6T4gdaXjR Ay/4j1bafxc01CobRTamX/MFq4NrZFb5ZRXM7Gy3tV2lF0J/ZdL8GgVRM8ZPdXnGHq/s g1oDLaVh9soQt82nPEzOt9oaJG/9a2hT+p/TTqKOgugu4J83cPPAlrTpd3FM7DvQZWdk zW+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558274; x=1720163074; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IMgFwh1ILCldQYzDAsSnCsrKfQsCDMsdI1Fnj4dwB/k=; b=TUpB9k4dtIzd72oRAUxH+GTTvcYxfdIH8AfGQV2z8s256XKL4SlfPPZeIYASr1QBmU I/C6Zj9EeuI2/roo52zH+FvxUnoX0L9+7+FbBrbEanrYEAVanW5rjP1Q5aRawX8/8l/4 xhloNwABSK6TbuqvmpdLiiSrCJZWfYV9iftEMe4HsxffU+WCrZ6P6Ai+Jv8PvxOHK3nA AWYmFNZ3wVJ2utIr2Z+JWBwIGwzYKzskqW0I/OFw8jGFEQUeinDiOV76DgTDczCdbcio 9uEGVPC3xv/sUD5EfTQnTWwIp6HyU7pYhzyOAokZ3oFQnxrMTXOOqevXhWAZkaPfmOto rknQ== X-Gm-Message-State: AOJu0YzlYHpfvzC3rQ+Rsvonnw0ag+eK8mQL+G4HJleeSInH+6gi51h/ 7z0bu2Ahm534gCrMQbQWrtxBwXVqtacRe2hStcpSBX8yBfBOyhMsFx0dfGTFzAOeVjRecYwhO8N VQEo= X-Received: by 2002:a05:6512:1154:b0:52c:9942:b008 with SMTP id 2adb3069b0e04-52ce18325femr14285825e87.2.1719558274074; Fri, 28 Jun 2024 00:04:34 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5a3b0sm21459575e9.13.2024.06.28.00.04.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:04:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 20/98] hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 & 10) Date: Fri, 28 Jun 2024 09:00:56 +0200 Message-ID: <20240628070216.92609-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=philmd@linaro.org; helo=mail-lf1-x130.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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 */