From patchwork Tue Jul 2 09:19:44 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: 809051 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116571wru; Tue, 2 Jul 2024 02:23:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUOE7CmGsxDZhrL3QlaNngvZ0AO20AVdhaewRlS1j5rpbLbLH+RnnRKlvs6mIrjWt0no7zldJAKHMX2Vt6XFN1c X-Google-Smtp-Source: AGHT+IHQJBgIU8EcKXkUzlnuvf2ZX4Tx4H/5eBmCCWJ3Nb4W4h+/zAu4BiBAeGu6EA9pxOiETV7P X-Received: by 2002:a05:620a:2415:b0:79d:6860:4d83 with SMTP id af79cd13be357-79d7b99cdddmr1026967385a.16.1719912188381; Tue, 02 Jul 2024 02:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912188; cv=none; d=google.com; s=arc-20160816; b=RtGHCLpJs1gL7OTIod0SnA4t5K5hzK+3hDvAyzpDNG8/MkCauFLW5iX5tUQqkvzGTY swJyh1gbDVLa6SfK0Yk++xxn6mSZWR82tlhYsUa3JJhRP//S5c7h9z3lGN3Fdat/LotB 9kDKYTucM/ovoltRmvlboIkZ2oayV3J2zzKnyOqlYnuEqjzA1UPFLVEfL2L4GlgfFqtp ZW6rNQRfag6ytYkHtqG4/ULq+VOPkFxLykUQYvR0btOI3bL72j3yHdkH8ttNhOSSWhED o2K959kby3vAllEKJbcNICzXm7aFmZ51oam/aBuFtPTCBP5E/VSrX6nLvRzmwS4s/ftJ DDKQ== 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=cnrpgaba+viPx04OXDYFrUGjYb7FyAmcjVlf/y5TLg0=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=E6Wlpioq3krQt+UBTMAmbxBUtDqKfGmmldXTJQz17fZA0LkWS+VWsR4UxaUroLByAo Di7C1d8+rKr2He8dKBIqlvCVcqMnAY93DYp2CLmbIJ1UwxjLpnHCjcVNs8qQOfcAhcq5 j685KxRy6VDEuvn3ZV32DIbn9pLf1ZEJ2QaWFd9xXxP6VoxO0/efH/oT5PlHWWIVKQNV /X4ECoj+FBjmTbM49pP5rpafCOF5vwHpoQXwRzyoNTsrYd3m3nUF+7MAuJocZv2xgwFz wMCvkG7l+++vAi9PUP5c2XBYFm9aq+gngpHHvshJ8ABxuZCloTTiP8JSP/8jQSISb6XS n22Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Se7sgW/8"; 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-79d692892e3si988629085a.168.2024.07.02.02.23.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:08 -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="Se7sgW/8"; 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 1sOZhQ-00013p-0x; Tue, 02 Jul 2024 05:21:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZhK-000138-Dz for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:14 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhH-0006MT-P3 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:13 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4256eec963eso27749145e9.1 for ; Tue, 02 Jul 2024 02:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912060; x=1720516860; 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=cnrpgaba+viPx04OXDYFrUGjYb7FyAmcjVlf/y5TLg0=; b=Se7sgW/8/xFjnSfrFqKP66hNIrboEBT3Icew00IcMVU5iBcOw88GMBNG+SpGS8a21c MvrWJjdrW3jljhGWvcSgIneLaj4gjlNWH+UBtTp+j9cff+UrNsCA/9eKXUtCPjq+OIzr LgkdFXKld/9WH/U1p5hDT5x74K7+pgTyB/zKrJc0aCqtqQQbWrKsz0Ra1obnUZLCFZzm NWNKPSSv3BWXWPRLbDtOkfRmI/6jraxXd93DD7ZYW1LsCVu8EEMIBE6fRBlnMHLB9gCV SwWFukWD7m45N8FCul2bXcoN0elWGpeHL1+jOoYKd1Q0x29dWJqWRdh5H/HoL98vW30B N7aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912060; x=1720516860; 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=cnrpgaba+viPx04OXDYFrUGjYb7FyAmcjVlf/y5TLg0=; b=llogNf55xGtUxxwzy3I+x1zF4kpo/GZT3ePHVwyt9LTCE3P3q3gexesG996OYy3iLE +nMyfaLPId1ZxHUcYvmn+6A0lkMh4NAuEhCHVoFaVmM6Ld2f0w8FOlxVPUSw04AztoDj 8LasGUvb1gWFy5yXzkL6nbLXcnVweDsU8g64Ruzzb0sHglDQTCZ2+1Qpl4DQk0wH4wdI uD35phVoIRpPOOZyNhMdP2k0T46dhwMkXJZwsuKn5umjHeVY9NoGJ8BrX72kcsjzhisz 9olCelZMgJGCfJQxtzSF5oUghOCnV/ukl7GDRm0JLyegn4G4kiC9W/jurx52mtovTigw By0g== X-Gm-Message-State: AOJu0Yxts+EWZqYeh1y6Xzvn0SLFigDi5i9ErlgIZ/lXhjFiGMj/oMZd GOtDmq9XgCDtqPH6pBu/u3C2S7SpwXbae0T/U+EV+Ujs4EAqH8Nz8HQU8h3gXUbM6VHlc3WXXQw C X-Received: by 2002:a05:600c:3501:b0:424:a3d7:2a89 with SMTP id 5b1f17b1804b1-4257a02c817mr49545515e9.4.1719912060238; Tue, 02 Jul 2024 02:21:00 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5b91bsm190794595e9.20.2024.07.02.02.20.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:20:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 01/67] hw/sd/sdcard: Deprecate support for spec v1.10 Date: Tue, 2 Jul 2024 11:19:44 +0200 Message-ID: <20240702092051.45754-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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 We use the v2.00 spec by default since commit 2f0939c234 ("sdcard: Add a 'spec_version' property, default to Spec v2.00"). Time to deprecate the v1.10 which doesn't bring much, and is not tested. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240627071040.36190-2-philmd@linaro.org> --- docs/about/deprecated.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index ff3da68208..02cdef14aa 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -362,6 +362,12 @@ recommending to switch to their stable counterparts: - "Zve64f" should be replaced with "zve64f" - "Zve64d" should be replaced with "zve64d" +``-device sd-card,spec_version=1`` (since 9.1) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +SD physical layer specification v2.00 supersedes the v1.10 one. +v2.00 is the default since QEMU 3.0.0. + Block device options '''''''''''''''''''' From patchwork Tue Jul 2 09:19:45 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: 809047 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116358wru; Tue, 2 Jul 2024 02:22:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXi+Rki4+APVPXHXG/jIbQRSpNBdgiPE9ksNo0zrCiiP0TxcJOO0BXRrD+z+OFZsPouxBKo4K3AKDuAOT0guQQ5 X-Google-Smtp-Source: AGHT+IHsd6Q63KWukIV/UkGS/Gk1Ymbuuj7GlfMe9XdektCdO0VDgsEZez8dCjkCbHUWfwau52Z+ X-Received: by 2002:a05:6102:e14:b0:48f:b1d3:4890 with SMTP id ada2fe7eead31-48fb1d34bb0mr11182870137.31.1719912134724; Tue, 02 Jul 2024 02:22:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912134; cv=none; d=google.com; s=arc-20160816; b=Pc9ELyUvr9c4sgC5f0SbT6o88r6qxf0go44TwdZh7kXv+9t9kqSrTRVbVzQN2lL/WJ 2WrC1cYsgi6AnInq0K0uWc+tJCzti91IZMv+5hAFdAT5ZiKLjgo76LHfDbdQQpRjP9tW 7+m5siDAhU+dcvPWBehBfspnJ+X+76tH6sCVqG+rrWDRgO1Ee6ICQsLOVai81oL2Kk/m 56m/ndg2lfCy1wSjYFtE9ZNSMW68oDpp5NwlFg7/AkKdZQ9HNogzCGa1hRxyTDPisngx DT/iuN86MefcQVcIN6pbgWVLS/jkqM6bEeTZoVAcLrW8bm3mFmyu6NqPyl8WEMJbCVA1 cq3g== 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=9WSx0o0NoRwLFVmVIU2eDisxkgWjS2aVMQINVCuPfpI=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=wCoC/CPpOzBOSs2JCeiccYMDjyCxyJ1YIYFv8ACk1xyMzqzCfZCW4glZZZ4cSblYgb iVPslgvAjS6fx73Iwgw6UGX6Ue1a8Y1MZU4zn9K8/nKiNa42gRSdLpxAJV0W8hvrnny4 R/pSCUUj/UVwOGAJFkXcXZrfpJQm2T3b4qmmHp4tWWUG5WBXV0+4NYi+anDMi9vFaKSq cWQUN0VXOTHimr1E+RwkBOTC8vY6ca+63/0/r5bsF7FXwAB+S9E+Y8SMLKMncBY8zs/t tFwYpUJ4Ayu236vgWXDUv9uEx9vuK9NY7LETfZEFgEiV61E6r5ho8nLyYP1Q3aFSYyc2 CO3A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMIHQ1Pc; 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-79d69339fb5si965510085a.628.2024.07.02.02.22.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:22:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMIHQ1Pc; 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 1sOZhR-00014A-7F; Tue, 02 Jul 2024 05:21:21 -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 1sOZhK-00013A-EL for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:14 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhH-0006Mp-SN for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:14 -0400 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ebe40673d8so52306031fa.3 for ; Tue, 02 Jul 2024 02:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912066; x=1720516866; 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=9WSx0o0NoRwLFVmVIU2eDisxkgWjS2aVMQINVCuPfpI=; b=XMIHQ1Pc3lsDySUScGW8Qxm8t0/LEgjWpzGCoHUzLO91eVKq3QF/8VwBVTSuU5pjSs tbDH2FSAX8sRAja6rWnJq1p/uXLHdpFG/1kPaqvrhhfg4wFAANq6nKVUNzEABi4niHuH GbqGwmyuj++0i1Bw0bscBGK2d0f1d1I8F+sDHAuIKGFNnuvUIxtfGL9fjLay0wo+t5Bi P97lQTmbyJL9rq6uy5Ik8n+3GbwY5mdi/8l6Z52/iwXtNxORMOXkTqSzhHO+v3JOyctS vDK/fubtDPpBJYM02T+Qv5tPsx6cWpgmfzPX/L0gOFWoqZ9fRonELV99wAHpO0K2LdA1 Pxyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912066; x=1720516866; 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=9WSx0o0NoRwLFVmVIU2eDisxkgWjS2aVMQINVCuPfpI=; b=olVby9j+t9KRiNOsVJ+BRUvFUgaexy0og8RZLYlp1ZV1EWHjwWgsGPjV3PB5ykEe6K tRWV0+dJqKR/JBNOkNv2xFXYwhlyyi5RGcZHby9R8qjk7G3hw1xXSL8VoUAGuSy4GMXm U1yH301mNh/R1H5i+KZtd/b8AyqRty4J0IP7SNcRJ1r+7RltlpZeDVdhU7xv3ga9A2I/ q2SJp8W8p1cAcwEL3ukupu1/8ejapPOQhBaAgboQyPVl1FlInqbPMwolBgdOaMV7n3py VSTpDHIelF0QuQB9IFe64THr8gTm5hvTkeGOoH3iTM91gElTuEUV6W8r71cJfEWVS+7V Hd7A== X-Gm-Message-State: AOJu0Yy1ZQkfRw41dmjeLhibBh8Eryc3ZQUDdNPMBJarZ+ja9qrlsY76 8hJKFuAP8LIeKQksYsl/CQJD+6UFFfSGr7dSpRESdsf5mrBCSZYU3D3VhcROkxsjqIAG29qyI65 2 X-Received: by 2002:a05:651c:88a:b0:2ee:6cda:637b with SMTP id 38308e7fff4ca-2ee6cda6515mr35005801fa.35.1719912065944; Tue, 02 Jul 2024 02:21:05 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257cdf4982sm110219655e9.47.2024.07.02.02.21.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 02/67] hw/sd/sdcard: Track last command used to help logging Date: Tue, 2 Jul 2024 11:19:45 +0200 Message-ID: <20240702092051.45754-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=philmd@linaro.org; helo=mail-lj1-x233.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 The command is selected on the I/O lines, and further processing might be done on the DAT lines via the sd_read_byte() and sd_write_byte() handlers. Since these methods can't distinct between normal and APP commands, keep the name of the current command in the SDState and use it in the DAT handlers. This fixes a bug that all normal commands were displayed as APP commands. Fixes: 2ed61fb57b ("sdcard: Display command name when tracing CMD/ACMD") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-4-philmd@linaro.org> --- hw/sd/sd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a48010cfc1..aa011fc892 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -133,6 +133,7 @@ struct SDState { uint32_t pwd_len; uint8_t function_group[6]; uint8_t current_cmd; + const char *last_cmd_name; /* True if we will handle the next command as an ACMD. Note that this does * *not* track the APP_CMD status bit! */ @@ -1154,12 +1155,13 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) uint16_t rca; uint64_t addr; + sd->last_cmd_name = sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular case. */ if (req.cmd != 55 || sd->expecting_acmd) { trace_sdcard_normal_command(sd_proto(sd)->name, - sd_cmd_name(req.cmd), req.cmd, + sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } @@ -1620,7 +1622,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { - trace_sdcard_app_command(sd_proto(sd)->name, sd_acmd_name(req.cmd), + sd->last_cmd_name = sd_acmd_name(req.cmd); + trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; @@ -1913,7 +1916,7 @@ void sd_write_byte(SDState *sd, uint8_t value) return; trace_sdcard_write_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ @@ -2069,7 +2072,7 @@ uint8_t sd_read_byte(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; trace_sdcard_read_data(sd_proto(sd)->name, - sd_acmd_name(sd->current_cmd), + sd->last_cmd_name, sd->current_cmd, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ @@ -2214,6 +2217,7 @@ static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); + sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd); } From patchwork Tue Jul 2 09:19:46 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: 809045 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116337wru; Tue, 2 Jul 2024 02:22:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWOS9fVIgWcjH75KIMQXP0C6d/pkF14eHk66cKv8ky2y8Z1HGleLVGCMGcc3s6U+c+zcHlu51nkTBk2JHD2Lt5W X-Google-Smtp-Source: AGHT+IEcdvZb5JEg6mxW/QgUpIfrCCATsUyzi9dSe3/wXPh1BorO47bUlVk7lno5gV9M0xFXAQGh X-Received: by 2002:a05:620a:4445:b0:79d:532a:fcc5 with SMTP id af79cd13be357-79d7b9ee7d1mr1062757985a.6.1719912132087; Tue, 02 Jul 2024 02:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912132; cv=none; d=google.com; s=arc-20160816; b=YElyMC5jHkaEKQqWAIuyi3mtY7C75BHgiNfkrBsi1DPQ/DXCCvp88RIef26sErRH7h PgtJULwJQ4YyS7yacZz+KfekZIr7VKuTuupu94JlQ5njLBJ6OT0Z095e92bWl2sDdv2i Tup1u18PXh0roP8Swiu67hEtlI7p2ugIgEVJPm8/RkLlyLJN0GuwYEkM4ZHGTC9SEVUv mLBdgzLIAaVme18XjudrK9Gxl1YpESvBfG2f4ONUVpd8Z0hx+70GGt1gMFc81qsOsWme hXcU+lxw7RwXyzqK6Ut3Gv9oSgI2gXDD3checWbCUv+cO45kopYJ8sHpyj+zWGThZmdc Hkxg== 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=1tcC9Y5NWB8z03lpw+6038sronrJ1UL/8sqiqucfx+g=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=p3tztQjqA+i4SuhmDvsnacZM9YOlMgxNH97hvaj7gNWT0Tk9EjrLPchtWGPid1z7Ms eRqRPZSYfGwaU9xVYDnp0SVjfP/2hzxnJKPyjJhpv4YW4crtj21cXD4MBQhBDzHV5RUz eTaLfHYePquZSyApK8lSDL95z8AROuk40ROaHEVYbnmzBsGg0vhBBDG0dl0UtgU/zp2D YrsOHftju0npuEoXf84yMYazwp3+iwv4Pnz1FkB5vCEynLTRBXq7Rw9XBNOa8KQ3CWvi 423QO3ivKNW2wGVvA7B/8zfShqen5h6zEZa9XEpH/41gJwgC41W8H86lCH2aPmbcDuoR C0Ow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ud2BNiOF; 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-79d692f0caasi1074293585a.285.2024.07.02.02.22.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:22:12 -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=Ud2BNiOF; 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 1sOZhY-00015L-BC; Tue, 02 Jul 2024 05:21:29 -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 1sOZhN-00013k-3x for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:18 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhK-0006NH-HQ for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:16 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a6fe81a5838so373974966b.3 for ; Tue, 02 Jul 2024 02:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912072; x=1720516872; 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=1tcC9Y5NWB8z03lpw+6038sronrJ1UL/8sqiqucfx+g=; b=Ud2BNiOFIdpDOAG4pBHaguQ199Wx4x7NgK1eREkyW1oBVCtNJHvx4400Q/3S9KrYR1 b+EQWh9+IlVQOZZSuQnefXCQ3o0utRHAZKhz1uEJDZQsnrjDQehThqZFbpwHOMarnFHo Q2U+zV9s0JhRKiSHPkA+qx6EeSYzpyf/whJrYcGFHU4jcwGPFG6f7nMpjy/kYskJMJL9 q927LBelfEOnm3ENx2DzDMwUXBf0osXPyDiW2fqKFiECjYA9ibNMtUMmdJEoJh6VBfYw Y+IO8+4pgVSyruFqsEhnIwm9Li06nxbNjspo/C0GgY//pH9fDX0awYRPfnat5ieSfgAE 44yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912072; x=1720516872; 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=1tcC9Y5NWB8z03lpw+6038sronrJ1UL/8sqiqucfx+g=; b=xLuATznzid2rR4/wnhvVVsfW0drMC+ik8TFxFVHD9vmtlL15ozc1c963wvUhuIfMEF mDQCahWqIX+V6I30AP4jUbseuS6vSHFcryPKLBUgXCAppDGACI3LVg6m8ohUIqCBa3KL UMO4Tz0bEOo+T3vtLcdQvZk6Z3AXm5WEAPhDvjMG9GQOhwsURX8lNUhaoWyPsSxqnvmr Gir8xERsdrYrVqhZuS8Roo8AGuymgzOBFCwIUgrTcrTzvPAUiHqG71gsooG2g66taCyY 8oszY7O+Cd/Y5zuhUM8g21TRHCfgNnc4BiY56f9gcd8A6D/jyi4jXWWFEz5MDiB+4s6h z54g== X-Gm-Message-State: AOJu0YzTnAXjRWV4lAykM0VJ7PS3+sb2pHh48UqNTY6pA+XtmB95bmuk yp3D1fou+Idad/V2gf9JnVOzsNHtWBMFSnZhLzLDj8miZPYQUZauJ3k2Ubk40ddX10USC3BNTx4 4 X-Received: by 2002:a17:906:a02:b0:a72:840d:9ecd with SMTP id a640c23a62f3a-a75145120ffmr465071966b.64.1719912071705; Tue, 02 Jul 2024 02:21:11 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e16b3sm12563292f8f.61.2024.07.02.02.21.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 03/67] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses Date: Tue, 2 Jul 2024 11:19:46 +0200 Message-ID: <20240702092051.45754-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=philmd@linaro.org; helo=mail-ej1-x636.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 Useful to detect out of bound accesses. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240628070216.92609-5-philmd@linaro.org> --- hw/sd/sd.c | 4 ++-- hw/sd/trace-events | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index aa011fc892..bed5966ea7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1917,7 +1917,7 @@ void sd_write_byte(SDState *sd, uint8_t value) trace_sdcard_write_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, value); + sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ sd->data[sd->data_offset ++] = value; @@ -2073,7 +2073,7 @@ uint8_t sd_read_byte(SDState *sd) trace_sdcard_read_data(sd_proto(sd)->name, sd->last_cmd_name, - sd->current_cmd, io_len); + sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ ret = sd->data[sd->data_offset ++]; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 724365efc3..0eee98a646 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,8 +52,8 @@ sdcard_lock(void) "" sdcard_unlock(void) "" sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" -sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint8_t value) "%s %20s/ CMD%02d value 0x%02x" -sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 +sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint32_t length) "%s %20s/ CMD%02d ofs %"PRIu32" len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # pxa2xx_mmci.c From patchwork Tue Jul 2 09:19:47 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: 809044 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116331wru; Tue, 2 Jul 2024 02:22:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVeVnzQR3m03Igg2750u6shS+VdP9EfY8515Y9RWphdKYGbBFCD742n7rwBelUVCWfQok+Wm05FpbNOVg2f1sjn X-Google-Smtp-Source: AGHT+IE8csfW6EiXo/gFgxVLA/bs1NUzsUm0axttNb6wiTU6ZmRtlgXf9VU+4Pb/xyeyWeopECVe X-Received: by 2002:a05:620a:4611:b0:79d:70b8:98ee with SMTP id af79cd13be357-79d7ba5fef7mr932835985a.34.1719912131680; Tue, 02 Jul 2024 02:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912131; cv=none; d=google.com; s=arc-20160816; b=yV01P+3qyqCx/TDHvA7zIP4stlTIAzrDMLJbHnxyxBIYHNLyVv0owOVcae83p7vVhN LL8y4Bu3SQ1245WNIe5STaY8qCRhE8q5FYSJlcRUSZZtSZ6TPyY85ZRr769hhn3htH7t EPnvwHMFwxLF53FKkSAOmZ0RSOoPNwmxtX4mMj5sl7dAXul2OodNcXHQgW/jDnC6JGhH npcJGiAXw4/fyOjzl1bMioDjQAZvCMQAbskCFuNA468iPAUAcH6y03tSnG5I/LR0rHhT jmnWkBckcRyeeUOwuKfqLsY6z+JYB7Bmq2DMVAg/efELkA1Qczd54I1B0EtrjwXv1RBx WxCA== 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=iQfrPXIVuGN0oE79GXpdgy4bI5RsbRBBNBkn9X4U1bk=; fh=Tt93bhVNlXtWAm4WDmZ3QxjgH42FcpeuPbuXiLS6EzI=; b=g0qcHfINB0oTOXZSiB1j8JUpNKEMUvAmIPa+o/EhzUGSB7O6fzsJ+bL/RH/i/UU8v7 +9Rr9cj/7PWL+p65jIX47RjsVJkrI3/euQV4i9K/RE3SlidsdKitSrYZRUHz2YyMqQmd IosqccMhwyZGlc75OxoL98/RRdl7Gf78IGIlQA5mYgNFKWZnXSVBFQUet30TOgogY1ov 6k5qqhwHHPR/nJRRwglO7tHxd/ticmyOzB0lqUM2RsAbPb95u12wHFVOXZSbnDVqK24B gIUlSvb1wcppyNawORCNyVd9jApYyw2UZtFTcOnJe5GYcjsm01W79VrEw2V3zRV/hNUI mdmg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FNKx9hpy; 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-79d8000b4d0si689050585a.22.2024.07.02.02.22.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:22:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FNKx9hpy; 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 1sOZhe-00015k-Uz; Tue, 02 Jul 2024 05:21:37 -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 1sOZhR-00014Q-GR for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:21 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhP-0006PP-PQ for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:21 -0400 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52e8cdc6a89so1784596e87.3 for ; Tue, 02 Jul 2024 02:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912077; x=1720516877; 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=iQfrPXIVuGN0oE79GXpdgy4bI5RsbRBBNBkn9X4U1bk=; b=FNKx9hpylo872ESTWUhp+xvNhIA53R05exbCosIliovQ3FRqVF4MCkjOoxSV9zHjlH 60gd2er+5KuilRgvYxAAtHB3JC2Wgp+RgkKWK2pYVtLI7pARleawAEoiaKgUPRI1y1v1 LAwv30CBFBdZi5K4DWUIzzGXPEWP7XO4SSvGsTA2BEoyhdBRxPQPp/DwjLWwHi6s12YO rSxqSQB7IkQngiRzISFbcQB9U5btQhsUhl1qXd5wm4n8DY3/n1JRPx3f2nFYNvSJL86e zmLqKL4Kf6x9fMvbR6t9MCVq04GxSCf8fDWSatFFPdvUy2du/lDPHCwShqU9TMA7BRbr rFBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912077; x=1720516877; 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=iQfrPXIVuGN0oE79GXpdgy4bI5RsbRBBNBkn9X4U1bk=; b=T66nwAErTHEZ3gCEaJbLIIrqsJzJEyNtDd7ZgsPG7CmZjFhQoA+Cc6yomjJW3HN7cm bbJ+m5yBzfOHhSwMSg7s51zcpcggE0pqJQnRRWGxI773NuOfsB3xyTxa16nyza0BOluD IqhyTbYkjuKJnzDebz6JodWtDLgV7YqcvhK0cA52JywYTCZuK7N1u5MJt1J7W7e3lgqQ Iax0JX7LIMHccEr6QsrJnyCFCKM2KSePzUCZCi4pAZ3EJqwyHlFLaGntKlg6Aru0dpaT Vt2gRZytqT9UH1jm3hZESh/gp/d2iWBmwvPK0vX6ClUsDAb/4+NO5DPYeKos6iLWxVhH DpgA== X-Gm-Message-State: AOJu0YyEMMoahrOIs0fK13FH02CfCqWEt91S2SNvPC+c2M4I9mVJMfq5 M/NloFrStegPOi9h3DCUl3Cx9+8WK7uWi0jqdT95zxlNcqM5CJ5oF72OoqDoYfBi5aJUgoF9RYt y X-Received: by 2002:a05:6512:3d1d:b0:52e:767a:ada3 with SMTP id 2adb3069b0e04-52e8270ea83mr6302268e87.47.1719912077534; Tue, 02 Jul 2024 02:21:17 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b065316sm186926295e9.26.2024.07.02.02.21.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Luc Michel Subject: [PULL 04/67] hw/sd/sdcard: Trace requested address computed by sd_req_get_address() Date: Tue, 2 Jul 2024 11:19:47 +0200 Message-ID: <20240702092051.45754-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=philmd@linaro.org; helo=mail-lf1-x12a.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é Tested-by: Cédric Le Goater Reviewed-by: Luc Michel Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-6-philmd@linaro.org> --- hw/sd/sd.c | 9 +++++++-- hw/sd/trace-events | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bed5966ea7..396185f240 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -608,10 +608,15 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) static uint64_t sd_req_get_address(SDState *sd, SDRequest req) { + uint64_t addr; + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { - return (uint64_t) req.arg << HWBLOCK_SHIFT; + addr = (uint64_t) req.arg << HWBLOCK_SHIFT; + } else { + addr = req.arg; } - return req.arg; + trace_sdcard_req_addr(req.arg, addr); + return addr; } static inline uint64_t sd_addr_to_wpnum(uint64_t addr) diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 0eee98a646..43eaeba149 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -50,6 +50,7 @@ sdcard_ejected(void) "" sdcard_erase(uint32_t first, uint32_t last) "addr first 0x%" PRIx32" last 0x%" PRIx32 sdcard_lock(void) "" sdcard_unlock(void) "" +sdcard_req_addr(uint32_t req_arg, uint64_t addr) "req 0x%" PRIx32 " addr 0x%" PRIx64 sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" From patchwork Tue Jul 2 09:19:48 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: 809054 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116602wru; Tue, 2 Jul 2024 02:23:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3vHXMqY+JxgvkPLYDbeOMOjl1Ci71yQ0vX8bf6Woe3S9yylEBPsNLyI6GCYmdg453Am223EBQjEBnBus7nkoD X-Google-Smtp-Source: AGHT+IHtKeiG4KM9e9WP5ZQFBWKZF7+DH2oSO8HbljdF2VWrDwrN+ADb9KxrZBEP2yc5EVWqX7SC X-Received: by 2002:ac8:58ca:0:b0:446:448d:8e26 with SMTP id d75a77b69052e-44662eaab9dmr104401221cf.54.1719912192653; Tue, 02 Jul 2024 02:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912192; cv=none; d=google.com; s=arc-20160816; b=SebpVjpWd1KKCMsXuRDpubdmYxSZgvEufQpERREz7uV/52wqiM0fi8yiCMGUlCqDCK IgtT/tWu0dXH4g6wY+cSTPALJJnm/EQFges1mZLT/2osYJtzxi3ypxbnidVweTzTDsQb r9XgnJIinjcUn2YFpmMPKvapAGNGDT5r0sWThsaWI+0NOUMo8yARgjEHRb4/BYORA8eJ ZNmgiNzlLzyyLkpt7RIhBzUwNUA+uUkk9xI+bL3CoEtLpSjwjxmDthb3py6xc3/NH+Kp q+eDKbNqTQerMRKnFiEGXGcMyzr7hryTHe/ylI6u1p0qsGCDFN0J+tXZ+1a4Lbnbf6r1 V3iQ== 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=c2posFVIHwJJjgAbr7iDjUeWrApT5m+MP8zp28Zi0QY=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=Gz7T5Ptt4HLi3pxKIdfQpqTKPZA9sJHxEW3rpSedOkUo8Bas/IYm50/57pmixNqzR/ X8xh4Y07Z8DnfX2a3jNIw5kj8l34sDgRbtV4ui1lEocAidLEtiVwS5Vhz7/vYLZcBkzn ReJH4S4i+R+x7oziOm2HMtIVCwBXn8PCv4vtOBnRBlvVu9vzg1QGI0THIC4Wsi4FH+Yr +dgE3Xk6Kyh97zP+/pstltK9TileQApg3COyOiJuxzcrnx0NotjZUg8Ld8oHIimAXkTa 8+K6JLhr7/tKaeT3rPnp2I1kxWNVJCuAc1iCGIDBVo70tHqhF61CfkY/tzlzhYR1EHie ln+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wnU6ueup; 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-44651489ee0si95218181cf.335.2024.07.02.02.23.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:12 -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=wnU6ueup; 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 1sOZht-00017z-Ae; Tue, 02 Jul 2024 05:21:49 -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 1sOZhn-00017F-23 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:44 -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 1sOZhY-0006QB-9V for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:42 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4256f102e89so26449405e9.0 for ; Tue, 02 Jul 2024 02:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912083; x=1720516883; 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=c2posFVIHwJJjgAbr7iDjUeWrApT5m+MP8zp28Zi0QY=; b=wnU6ueupR7UviJVu5I+ll/Mp37YvmIKMeTcxNrwzSH7TGnw+1IGYWx9bI+rbMdLAqV /orqb7tba2FmrNvKCyjuaDDcDmso0epaamgDmJB71BNHkQIhD3ufkd0HaPWY7lzFcYzm S7tbDWA9aGKZg63Y9IFQj9RZrVR64vfLHkPqZYxoNL/mOSfBl5xcAdrXyKpCNTFOBcFd 4au5a2SrpC8IoNAShFVFB68l1fqra0DuxEVfgxINUWuCdjocREB96RYo1THIBhFr2x8X jJZ3H+4lMB7fdTiiJA5LMNrANKBLc/N7zQzrzf8MPobd6H4wyklt0hDEmTfLOsqNM8Ei ES4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912083; x=1720516883; 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=c2posFVIHwJJjgAbr7iDjUeWrApT5m+MP8zp28Zi0QY=; b=KynFcKJFZC39byPyl/ePPDcyBfkPrfeguTFP+1eKZ2ogizbcjIcRLdVVJZZjeZQLc4 5qO9WVNCLi8mxCTjDKK9mT5/tPBxwxXbS48NX9wiik/NbpNO6P5U2xqgAO8H0QC93ELP Ls3obVXswhv9SMRmQEpejX2EqWHOOAIOWjguLaonQM0w9rm+FpCMYiUW6vfsYR0rKd7R g+3hN1kC9KPnv5Ui7WulypXlPLCjDq1JNZypLxQ0eszuyJoBhWs2yKSp3GjWUXqwLsaL EV+qdQdfBgsasxHbp8KDP+fXF+hOkQM08ucmrCAmDgH1LuxDRLkZwxV+g+pyfh8ZDiXv SqMw== X-Gm-Message-State: AOJu0YxXw+LKmK0iOY/JYACHB7Pq697DYf9wrk067QZ4AKkajpycMJ4F O/DryTlN2dHysauPW4VqygNg+CGSNN+2McM7LdLO6iBzh39uXCX1Z6LOi9wob6MfH9cUaEMoLQX P X-Received: by 2002:a05:600c:5cb:b0:424:a4c1:6ee7 with SMTP id 5b1f17b1804b1-4257a010baamr52164595e9.18.1719912083293; Tue, 02 Jul 2024 02:21:23 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a102bc5sm12637966f8f.92.2024.07.02.02.21.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 05/67] hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6) Date: Tue, 2 Jul 2024 11:19:48 +0200 Message-ID: <20240702092051.45754-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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 SWITCH_FUNCTION is only allowed in TRANSFER state (See 4.8 "Card State Transition Table). Fixes: a1bb27b1e9 ("Initial SD card emulation") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-13-philmd@linaro.org> --- hw/sd/sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 396185f240..b5d002e6d7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1204,6 +1204,10 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd_function_switch(sd, req.arg); sd->state = sd_sendingdata_state; sd->data_start = 0; From patchwork Tue Jul 2 09:19:49 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: 809061 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116797wru; Tue, 2 Jul 2024 02:23:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWolcf3ih6jZVvX6jKFo6r8MS/ubMuXS3jEnP+HaV8rNAQJTRTc9uMR8OF0a+KB8zvvkm/DmDmxwTzM/gh/01/M X-Google-Smtp-Source: AGHT+IH8FaNzIqcJHpSdQKwGPatxvT3+mlyQsXcAwjRqSIAuFbhBUtzi9nRz1T7Zt0F5Md/zN1WK X-Received: by 2002:ad4:5d4c:0:b0:6b5:752e:a345 with SMTP id 6a1803df08f44-6b5b71a2223mr88233076d6.63.1719912236631; Tue, 02 Jul 2024 02:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912236; cv=none; d=google.com; s=arc-20160816; b=QUGzk4SHe2PBCJdfZXOrVNGK1hgwpREsxfT3Kw65UPVFMseMR4jyGJtnyz5OTW+Qaz OqxzyKWFYTnJL1LeXq7PjiL2QV/6AXCqdPCI/kMrad5r6EtBjpB8lsyanmbBaSk81De5 BsS4FLYiPhPDlNFToqZBcdwN/8kcQXjiTOILDgAXt/ZSrMCqMmWICN3c2wAqH2f63Pgf SMWH978aPQp6KGBs9jYQiYLA/lF+TZjKzbHjvNmV7kp3PaohdtSotgJuq4zPfNdlkKwQ jSB8SgnLYO03Aci+exVC0lXDxiR9KxVqDv4nZxO+EE7LWUPRWXk/vVMWyT3diUgLyGmB 6w0A== 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=ZmproyIzBvgthgzgc+ED5AQDlzk9eDrpZD0ggY0YeFY=; fh=ewxdS7CPFYTNGqGRyltnxNKJTn3/a8RG3KK2A4AdeHA=; b=uoZgzfwH8aVBpLkTOmTReEcFXS5xOmk0Urd+9PcE1XIxtUOZUecULRgtf2E73Yt/yQ ZXfyHOFoU/eioeQhRtoVLq8LLmo3HFL4kBg+qDMSaI7qlMfCvQ7r0jlDhA5ixsc6VjRw sja1IKhKhQLM4l7Fs/b8nK+Uy2SOJlM9E0gzNV/oTVCCVbtwMNPF2CUmz6z+9nu0Pb9A nCiSJ2FJ2Pvnxa7Tnes7mwFGRaTsWginbWeIqigjjuMGw7SWizUEzVRPn1JkipzUO23j 3MGS2wRjYzRCstSyt5Xjbvq4J7d45kh/lpUTdUFXf/fESYhsOQC3HjcezAb3nxZRN0B1 B0jA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FY0qDnMc; 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-6b59e617ff7si99867736d6.577.2024.07.02.02.23.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:56 -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=FY0qDnMc; 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 1sOZhu-000185-4J; Tue, 02 Jul 2024 05:21:50 -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 1sOZhq-00017Y-Ur for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:48 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhk-0006QR-1A for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:44 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42138eadf64so28144995e9.3 for ; Tue, 02 Jul 2024 02:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912089; x=1720516889; 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=ZmproyIzBvgthgzgc+ED5AQDlzk9eDrpZD0ggY0YeFY=; b=FY0qDnMcAh/sB3kwJNrEV+Rvx34EV8btGzMGUWyfDjOyGWOfPWju8ZR9OfkKNZp2En Fdd8L1ZU+ypsw5hioN7wT2pAEq6b9xRtAvte9yKm55fBgFGozCDU/AERYFaqLhQ0vL4P kG5KR4uXgHfkaa0sxveqs9hm4OUw3iau5SRRDTbImxLfdsO7eE37I19e5MK2DAoLSM4y 85S9t/0xzAm2Ctz5lC8Lo1n83lc0jdQVf39GS8j2d5lMQ1dnnjgiBIdjhUj8t/heQ34h fDVYe7HBVWcL5lecr4tV07mu/CteGTtQJ6hmmeXYuZKKvfSZ/pjPhUoWArWxUBIwx2fz dnQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912089; x=1720516889; 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=ZmproyIzBvgthgzgc+ED5AQDlzk9eDrpZD0ggY0YeFY=; b=f2RCZhp9+uIbWjVcXDHEnf7nkPGVz3wt26hNI9AqU9Y5v4VnvE0S8GwmKTYjGDRnFo XOP0O+9I2D4zn9Aweb2EPOVeJVPv8NOYCcypV6kBjQI68ujAoqHfO2b0r5P61e6ixINH 0iAkl5dnd5B/PESkqbQcNIyVR12ZdSksHItN1JUlu15tu5rNg6iyqF3stjqXucZKve2B vEqKBkl4erNBFs8IlAOAAEfYFZWy8cuwpbsjM5o3CEtQ5IkqLj6CslmyXOMCP1cE93cu jhWZxpOrf5gsZqSBJNze24WruGUPxSDSQ4+XBC13orHpQnwj2hoSv0X9L5u3z5+A2r+l qsjw== X-Gm-Message-State: AOJu0YwNGGg3+z6bp06Ukx+XqJ3BFxS0vInrA6YCQDqfRUtU0T74NtxJ 9AMMaHDJCny1c4BwRegN7IUZdp0YwrEyZWbB4vsuJYgcoq24kX7ZHJXKlALC6m+YAlDuRCQAIC6 E X-Received: by 2002:a05:600c:491d:b0:425:6d66:e432 with SMTP id 5b1f17b1804b1-4257a03a6c8mr54270855e9.22.1719912089186; Tue, 02 Jul 2024 02:21:29 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af55c0asm188276115e9.15.2024.07.02.02.21.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Peter Maydell Subject: [PULL 06/67] hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30) Date: Tue, 2 Jul 2024 11:19:49 +0200 Message-ID: <20240702092051.45754-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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 Per sections 3.6.1 (SD Bus Protocol) and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Fixes: a1bb27b1e9 ("Initial SD card emulation") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Peter Maydell Message-Id: <20240628070216.92609-8-philmd@linaro.org> --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b5d002e6d7..1e9530f9ae 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1508,7 +1508,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } sd->state = sd_sendingdata_state; - *(uint32_t *) sd->data = sd_wpbits(sd, req.arg); + stl_be_p(sd->data, sd_wpbits(sd, req.arg)); sd->data_start = addr; sd->data_offset = 0; return sd_r1; From patchwork Tue Jul 2 09:19:50 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: 809057 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116710wru; Tue, 2 Jul 2024 02:23:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCvEBz+iOy2eqytGHdDZ0DlHYI7iXwJJ9oLs5oHvimo85N1pHXDbCaEkc9b8PAaux91osJvWV3P1cZ7pvjADcQ X-Google-Smtp-Source: AGHT+IEIzobXW4IOyj0Ddaj4cnVDQmLmi4YYhkSw5Hrp2KUWYxPZkxE2GIKbO/WQzA1hTlBTNIYn X-Received: by 2002:a05:620a:1373:b0:79d:65ac:dbb8 with SMTP id af79cd13be357-79d7ba82429mr920336785a.52.1719912213686; Tue, 02 Jul 2024 02:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912213; cv=none; d=google.com; s=arc-20160816; b=MGreuJExAysiwWKy0muTojhRA+GtRwnwFA/EbR3srsh2fLH2FNT/P7AGaOcEC8pPxw rwDJBo14vFnaamsyxqYitrzwjku5W5b7FVGYplqoRcuFKBE7AWnuMhlH84sfgEFW5QUr 1zCbEt3TE5gdDx1SILyGHzXzwJDjOSTaNbUQKN8pQ1KOI211FgPHOS5BjLK8JQLMw7dx LpSWp9GMPZRIA+C/wsjznWof7mSkQyqUxLrDAMEeVDpXZVbQfNXOZ7rWah9CLlMPHjeA xzRM8MQPGYcuJRxCrfYG0Zw3tvpzYc1cWqywdcxzzQYeoKWcEBx5A/s/SiTXfl0gnr+I vR/w== 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=+BJVqbuDB73td3icnKEL+Hn1IcWwELHqxD1Mx9jzZME=; fh=ewxdS7CPFYTNGqGRyltnxNKJTn3/a8RG3KK2A4AdeHA=; b=dswrP6M38QeH7ZW7BdtrB+hGENBLP+qvugYuWhMuFcmonDFgFps1MNr1DSXRjodZKy MgqNiGWScze5tAg8y9YIkbqwr+3kB1EZjibmT4ismrISjZ9nG9/Mt8MOPREeVzQjuPmg /ERNK+hWFxRw9UOFW8+pyLl+8snjoUi3gtZdmf/bvmhkrSCCXs6RLH38zfYbnOcSDFH/ neGg0oCKwhfYv6VqTKbBBtSeyDjxno1V2J8Lv546OeYlNRe3nltZ2JeutMu+xI6fHA95 qZFqIZ8Fi0UPs71o8nXOTZ++N7Tz2qAQSTJMr+ez3unPY9RFqfdAMEXyrfw7AgMPBV7D doGw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SN9ZqQb2; 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-79d6933d377si967709485a.647.2024.07.02.02.23.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:33 -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=SN9ZqQb2; 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 1sOZhu-000187-Bh; Tue, 02 Jul 2024 05:21:50 -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 1sOZhq-00017X-Sq for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:48 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhm-0006R6-8M for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:45 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ebe785b234so40005991fa.1 for ; Tue, 02 Jul 2024 02:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912095; x=1720516895; 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=+BJVqbuDB73td3icnKEL+Hn1IcWwELHqxD1Mx9jzZME=; b=SN9ZqQb2ehnCRFlBL5bHkWdxGBIhpsiuuNYFscBAzs1Fd+JisZiijgV/OR8iAe2YP3 rqSOyMpXj3va7W3GCmZhEQAQjfySW37nppdZdmxb38cTLC1OB1W/9ApwTtAJ+kIJMSS7 qfbgYueMvXnt8pjIKAmt2CoolVcBVwb/GOj7pspDZCO8Ex8MOM+NuNiIkYpE147D929D eFR5F2mKLFMCrl40zNDbSzHsTUZMSbQS7RRi9f2Tbkdoe77ePHVqxiFZ24op+OZrQiVQ Df53Ko84p/Q41zsfarf1LkAN4aGKtwZB6QX0fOb4z9xMnHsamKsOlScFtwwB5+/SJKBp Z0bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912095; x=1720516895; 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=+BJVqbuDB73td3icnKEL+Hn1IcWwELHqxD1Mx9jzZME=; b=htDGm6ISl4Es3h7u3bAffGLD8kEDQaIbP1XW47QhWhQy8iADKiqcREOkB7JupYlJNe uyBKJ2MaK6U6/AWcmQ2oNoEZkAVSNrTkx153b8o6npX4pAVK196sEosKDmyAWr28ZPRn OtbGDOfPRpiBSnIGkNo3RuIRwLTEM4KX3Y/2Pz01M5rwQJ+AnmCi5FI9L4ErpkGJBZVB WXXo+t/5NzNRhTkByPmV2ZhZafiDoHc65hTScgXGXbc1uMQcqe8rDnq5wOfwyQj3iwtO 6PmOcTOdBH0qXCGKkQEYl7+Op8IPzkxxrxDAJsgnruw77mxCyzpxgiQ0dkkhOIJhTDSA fYVg== X-Gm-Message-State: AOJu0YzbPNETf2VL8/EVj+nMo2uLILqgVKzKPvy4JSnmtaNNGMVA72Cp yvNPmiBp4MINhiKpTHBVlVhoe7c+aTBikIEuc7OvazE4Po1asIN2daaeX224S6zl5uXjiqUTeEU T X-Received: by 2002:a2e:9793:0:b0:2ec:5518:9550 with SMTP id 38308e7fff4ca-2ee5e390c38mr55097991fa.10.1719912095005; Tue, 02 Jul 2024 02:21:35 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a2bcsm187830895e9.36.2024.07.02.02.21.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Peter Maydell Subject: [PULL 07/67] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22) Date: Tue, 2 Jul 2024 11:19:50 +0200 Message-ID: <20240702092051.45754-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=philmd@linaro.org; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Per sections 3.6.1 (SD Bus Protocol), 4.3.4 "Data Write" and 7.3.2 (Responses): In the CMD line the Most Significant Bit is transmitted first. Use the stl_be_p() helper to store the value in big-endian. Fixes: a1bb27b1e9 ("Initial SD card emulation") Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Peter Maydell Message-Id: <20240628070216.92609-9-philmd@linaro.org> --- hw/sd/sd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1e9530f9ae..54bb0ff1c9 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1669,8 +1669,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: - *(uint32_t *) sd->data = sd->blk_written; - + stl_be_p(sd->data, sd->blk_written); sd->state = sd_sendingdata_state; sd->data_start = 0; sd->data_offset = 0; From patchwork Tue Jul 2 09:19:51 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: 809078 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117752wru; Tue, 2 Jul 2024 02:27:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXCu06zDjB1bx/O0n0RH33NRj2mFvEdnajlD+xfX+IPLzkUHE0uZyRnAqUFaBwWwli3yAP5kEp5ze6/wAXLFvVg X-Google-Smtp-Source: AGHT+IEIzFtqKkfXKn5t+nz8EXHPkfw6KmrmwVlJCrj46MNiNR8bp01a95SRYl2hWngxpmPvSJuQ X-Received: by 2002:a05:6122:430f:b0:4ef:53ad:97ad with SMTP id 71dfb90a1353d-4f2a5695248mr5265673e0c.6.1719912428020; Tue, 02 Jul 2024 02:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912428; cv=none; d=google.com; s=arc-20160816; b=kMhSaPlJXuxKDWUk0fajjlJ7SLPP47YRU8exe35pHYWRvqXBlFuk+O0t+1QGEWhXX5 LSGRvorQ6iaU18/hznrPbSKK5hA4qqFpVeNcF0eaTqO0Zpg4wmrsq87GGDkyF/eiZMTQ LbKTZIeedaffnQYt+Ui+TbUOO70SU/V3I8GN+XgkYKeo1wjxxxypm1ii0K6/zhPF5Ei6 Qtj5VtErZgT2JqfbtR5SQKJOIwQCt1+O9tnG1kS78bB47aAP/4k2NHQz2VW8EBRJyJCI EE90Gvc0t/C8R7Jg9M9ulexgHGFwCSxqDNN+5HQy2crsKHNKJI1j7sF2QcJGgJpvd72W pupw== 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=YMu0JsqJ0+r4fsG0B6FCI0Tvxg5Vyf5673gOlduh3A4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=Cl4O12m7ZFtj6TSD7Ar99nfzTkZSYwX3aT5dNTkrQRMNkDvZHH7DhX1zALyMpJB+UN SWlCas3WsPNnMr0rHpKy8vrUESG46FY8NvQdAV5icPbQ6n50BlwPujBVDFMtpYSXRpMj BORzJC+Gb50t9DSh0cWqOWeF7L/koLVRFnNvIKhWLs6wHBGrhFXH0h6YCJxDG9r5s81O tsMTGVbbybMRCfiHKDddgoM4VZN9JB+qcc75rQiUsYF1/G0o9VYY2UlvS886f0lEzhIP AJO0vX1CjwaLuuaFhjrYDxm0/H/2ndET8F/qZ7mUXC60VCfbgx47kq4UNyOKGevXjaYC VKnw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jQYZFj+u; 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-79d7883b81fsi710730785a.398.2024.07.02.02.27.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:27:08 -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=jQYZFj+u; 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 1sOZhv-00018E-Ck; Tue, 02 Jul 2024 05:21:51 -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 1sOZhq-00017Z-VL for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:48 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhm-0006RG-Oz for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:45 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ebeefb9a7fso44908401fa.0 for ; Tue, 02 Jul 2024 02:21:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912101; x=1720516901; 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=YMu0JsqJ0+r4fsG0B6FCI0Tvxg5Vyf5673gOlduh3A4=; b=jQYZFj+uVo+5j4n/xXlgwk41bH0Yj23Og0CzQMTuLa9jqGSwWlhrfkoATlGfkms/jf r4xx3XGGz4imNC04eUni6RytnCyL/RGxvJgVShygZNw0pIsk+lAgn4LTSFvgVNV3I08u ImAulvZWhNoDFlRXk96qMd/DimPrHZazPu/jnJjhccBi8jUfcN8jlRkBot4JWdqa7509 /BK1342PINeN9xA0utQio1kxct2A/ubOxamf5+oVPq9ZKdKXCt2UDOOF8I/EMeZw8ZiU B0o2dCisBnn4k+vOGjUvn0tb7CEFMyahNkDATWTJRwITSt3l54zCMapcD18K2jmnnLcA TEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912101; x=1720516901; 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=YMu0JsqJ0+r4fsG0B6FCI0Tvxg5Vyf5673gOlduh3A4=; b=gC8pk/ewTYHH2b01ATZ3BoCN++R2BtfpsL7D1tpVWiLbIRfBEcB08pVpP+NrLW0A1U jLpXOE1bgCaUMkgE0uM1IUjj9iwt0faocRLS5CbUKk5v016aUZCb3S4Z1nBtHqgQ3urR z8BpRC3fk3loaiJjIPqlZBP0ZJic62/8PgscPjFmtbjtgR4jN4xSH12t7qKgSJL60eiZ LZxix16HNx8+7VoajyAq7xMMCpIYf5HTX6b+hrzwwLfvDF5TaL0qDIlrjyRI4qvnNjZA 2Ed2FkIIy6gyQcSCp37njwFphzA0FrmWjGcoTQJpcJopZ4boK21WDR2dfaM2S2K3bXHW wXhQ== X-Gm-Message-State: AOJu0YxmJZc9UVLZ3be8PiN6JWGu0xBtwzlXjF9UX0AI3GrV1EKx7b0z fJjVIOaqgxgNOzO5MdiOlDm1IgyHYK1JbHX/koYJD/ATNADQSNvTRDwaW1/cAVrD/Tg1IzHs/hl Z X-Received: by 2002:a2e:9dd4:0:b0:2ec:4e59:a3de with SMTP id 38308e7fff4ca-2ee5e3811eemr50130121fa.10.1719912100813; Tue, 02 Jul 2024 02:21:40 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257c4e10d6sm117669665e9.30.2024.07.02.02.21.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 08/67] hw/sd/sdcard: Use READY_FOR_DATA definition instead of magic value Date: Tue, 2 Jul 2024 11:19:51 +0200 Message-ID: <20240702092051.45754-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=philmd@linaro.org; helo=mail-lj1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-10-philmd@linaro.org> --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 54bb0ff1c9..04ca895645 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -559,7 +559,7 @@ FIELD(CSR, OUT_OF_RANGE, 31, 1) static void sd_set_cardstatus(SDState *sd) { - sd->card_status = 0x00000100; + sd->card_status = READY_FOR_DATA; } static void sd_set_sdstatus(SDState *sd) From patchwork Tue Jul 2 09:19:52 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: 809063 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116871wru; Tue, 2 Jul 2024 02:24:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXBdNVHKsZk7I0VZ/5rn6daF+vvsBdSMeIjXydMBRuOS7ioqFAqLjttSJe/XcXJuFuwmKK1FnJELOk753eksfJ/ X-Google-Smtp-Source: AGHT+IG9nZ1u83GaGopMnWPafEOqrMbCc87ObHgCokiUjp2mmOohUB/rHyjhlOite4iqN1SNcrgf X-Received: by 2002:ac8:5f13:0:b0:446:5c33:d1fe with SMTP id d75a77b69052e-44662e66ad1mr104501541cf.64.1719912247724; Tue, 02 Jul 2024 02:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912247; cv=none; d=google.com; s=arc-20160816; b=FNBZmC5g0Uv4BGOFAD/6Dl9CYy/7pDqEf5SXBCBzwHPCtf3cqmqSmTL+lybXj1xFtq jkw3HWgK07pX7rp4olu9Rqm2pGUy90Lfwt8LyX7MUe8LA2i8d2Wv0Ai92QG7tlWFlVPk MG2iTLE+RgUt1Wz65gvmWePK/9d50wR+T5WPzibxfLuMTnsQuGjNb0m2CBZpJyIJ2xzm Zc0pr6Xz2AT5zO4JhVKOuxRv6e+KDbRe8BnOSARVbO+EvHuHRRkoE4ZqHCXhpxNtl1P5 z0yJ0tck3zhvuqGOZ5/5A0NAdGqc3A6A04efOhscIYg8VtwWDYh9VtedXExAkHMa25wc 6sBg== 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=VFi1L5rHZo7v36UetRUIEpZ+be6zBjT18RH5cfq/7Gg=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=gIu7ReKXRISMqF9CUNnTKb8EbqcY5gZE1SWoJ1DSr/PDxHfTudwTvv3wvShoqyRwi0 IQxh99lI7EpkxLVZ7oAfB3ahwXLhxZKRNbaMU9v2eEFp8qLtjHsgjmj4016aeW7C4tCS QcXFmqjLqhzx94X15mg+hIZklkE6ygP3FuVSCVbeXiwW1bn136h/vvQCqPKQ5KxbNTLP hfJRRfZj/DFcMnozQIOifPQPxlCZmmm9UM3Jvobh1rTrGZfvemNUSgkidv2l5oe72Mqi 4DgqQbO2ewn28qcsQqVP7TthNAhibkukQtl1yw+qJddZy1Ot5/zoiTx7ohinsZfW8ZMa ZRTA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c04R2OBL; 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-44651485f08si99937571cf.281.2024.07.02.02.24.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:24: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=c04R2OBL; 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 1sOZi7-0001Bf-5H; Tue, 02 Jul 2024 05:22:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZi3-0001B8-4e for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:59 -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 1sOZhs-0006Rv-Qv for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:58 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3626c29d3f0so2001288f8f.1 for ; Tue, 02 Jul 2024 02:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912106; x=1720516906; 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=VFi1L5rHZo7v36UetRUIEpZ+be6zBjT18RH5cfq/7Gg=; b=c04R2OBLwAdRAp7Nu2BSr46oWCvvpqAK+LMr4dgjMbXGFmj6UtsqdokCA+h12EP8Ft 5p7x0iMAhjaFe3WJpdVqI3cC7pFi8s3YcrLsDkEIqK61ok12yGMxZZcfphc/EYyUopSa cvLrORWx/5t01x2wzfWAM9t++wNUllM76BA6gI3jjai98HbP81XQKwehe35ddLc/Fmdy YkOOkL+7rNPkU6MLIW7KRlDKq4wRBS8Ub6lefVXKpXE+7SqdWKkV+Mqv7HmQ8REQexHK GO2u32lY3/DkDebEPAs+Vp268Knadj7CsXfIjxMWEH+CQTrvwlvm5QcKZxIEixGGzRwi 9EkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912106; x=1720516906; 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=VFi1L5rHZo7v36UetRUIEpZ+be6zBjT18RH5cfq/7Gg=; b=q2Q00cghyY9VgcV914DBMtIHUyjG3Sx2CiFguSl+txirczVkMa//rj87oXR36bQBI3 azu0xyM0j4cCyAXpVRD4SI8+ihr1BeHl2kSL8YN3TVeJGcd3e437CNwYNmQhbvZSgzly xwx2HixS3AMd8eVg3oaHs35qeYZ7c3oLjC7jHTlMt6BwuGPrw9WxiV8KMWGHF4ACg5N5 4UJQWSKC4Zfak5j/UnwGceOHt8IIVCCr360knPXuQS/SnpPQVytPo0qeOLNk9b1i9GGE cZY1trTSAybLwz3i6IrbSOP35pyMB7LizhC9JvvjWpUjUEgbC7h1XL+ooA5K8TW18Hqu 3PZQ== X-Gm-Message-State: AOJu0YxZyD6GV9wrtGaQAuqzB8pqkBapv5xH8lgSa2NgiPq8JDm4khPW oMMnsBl5KmhSdcDOx8REuCr0a9o7ZQzD/bc7SfxiIKB9Lv/I9bhOrfK2SQHPnIOnme9IFl7LSr2 E X-Received: by 2002:a5d:4043:0:b0:366:f8c3:ddcb with SMTP id ffacd0b85a97d-36775725c6emr5347764f8f.52.1719912106566; Tue, 02 Jul 2024 02:21:46 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fba2dsm12653980f8f.73.2024.07.02.02.21.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 09/67] hw/sd/sdcard: Assign SDCardStates enum values Date: Tue, 2 Jul 2024 11:19:52 +0200 Message-ID: <20240702092051.45754-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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=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 SDCardStates enum values are specified, so assign them correspondingly. It will be useful later when we add states from later specs, which might not be continuous. See CURRENT_STATE bits in section 4.10.1 "Card Status". Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-11-philmd@linaro.org> --- hw/sd/sd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 04ca895645..824cb47856 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -75,16 +75,16 @@ enum SDCardModes { }; enum SDCardStates { - sd_inactive_state = -1, - sd_idle_state = 0, - sd_ready_state, - sd_identification_state, - sd_standby_state, - sd_transfer_state, - sd_sendingdata_state, - sd_receivingdata_state, - sd_programming_state, - sd_disconnect_state, + sd_inactive_state = -1, + sd_idle_state = 0, + sd_ready_state = 1, + sd_identification_state = 2, + sd_standby_state = 3, + sd_transfer_state = 4, + sd_sendingdata_state = 5, + sd_receivingdata_state = 6, + sd_programming_state = 7, + sd_disconnect_state = 8, }; typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); From patchwork Tue Jul 2 09:19:53 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: 809048 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116454wru; Tue, 2 Jul 2024 02:22:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVZDJhbqWRnaR2HY74ifeo5xsiK1JWWbq+De5ssnoA5SzmABe0eP2Q9CjTQzWokRDVCSWSaZXWBlqTLG5euNSnz X-Google-Smtp-Source: AGHT+IGxYe5y1n+oDqKBt1XwZov/gRnmcj+IP+SNuEZoS30dRt0bYGEp3+0Yks1RsOWrOsLy0EYO X-Received: by 2002:a05:622a:1311:b0:446:5c05:ebd4 with SMTP id d75a77b69052e-44662e6a7f5mr111519511cf.47.1719912156489; Tue, 02 Jul 2024 02:22:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912156; cv=none; d=google.com; s=arc-20160816; b=GvFyuduXQ1axllO0/ISagGT0Ixafj1qaOxcCI+h8XAlia7dON2xwhfCdYVRILU9sVM NZhz2yLH/ITgv9nLN+knHjveYd2jYgTAzRbfu+pqtHAm8206xD63TPCApCf4N962mPFg xMlnqWeYCKtsV4SfqH2hHv4pORFHLK+CQU4AJD/3vkYQnzZzXjHdhj/468vK2IvKlWAV A6/RV2/Ro/U920XRc6l2i2iwGLhNafWMrgDPYpuSH+G6TxRCWSE4aL7/tjKEf5+qPryI CBUGg06dRMBG/IrKl81hQbw5R/9s9x4X1FDE69p3RwRCCdPi6F24I85NBNY8akzDskkr IFuQ== 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=VGAqlXXmWHNhTh9vgnZWCBaKbJgiHWhA9edkrjy7PcE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=JXEncjJeM3X3PcRs+S9612A/Mudnq42P3rb4T1Ky/ku3pmCQYBHANXKsDtAVuN7crp tW+qwMoF9xh5byLwUQaU7u96pdMSWjEFlN7WTnpKq0FCzrsIxnX+YZ2AH0V8EjGkExj0 EzghBS2AU2tkY7McXD8P9wlnUB1VWJWgKJxrvPPJ4wHcKHG51aeqxqOiNg/h05p1N7lH Xve4qPoZOQk2zS2lQj2adV3MKz/CEJImnI7OmWQl8PNEAh5TFERbPXVZa/EaqzapUHY0 c5hO4UG3bW3eCbh5nGXRVJJc5TkctIE7JwsokEUbbxZposhOPN3iQafTlQs6DuKGi/tp MPWQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ak49Db7z; 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-44651487616si107669881cf.348.2024.07.02.02.22.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:22:36 -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=Ak49Db7z; 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 1sOZi9-0001CT-96; Tue, 02 Jul 2024 05:22:05 -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 1sOZi3-0001B7-4e for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:59 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZhy-0006SF-Fn for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:21:58 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-424ad289949so28596435e9.2 for ; Tue, 02 Jul 2024 02:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912112; x=1720516912; 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=VGAqlXXmWHNhTh9vgnZWCBaKbJgiHWhA9edkrjy7PcE=; b=Ak49Db7zbTHvDl8yDot8XOnyehNXcLQNBGbjbwYuqSuBk4DWQIF/mE4Mc59MgU/5aT 2Dww1kBNkTQGrkXWhvER05zKobR9Gh0pEK2FlUIeNeVnzMDvqcZ5lftDhIyeFNDpeVa0 VPcmzB7pRksBQUfv6atbHZn2OmxJ1tt88q527+XLniC/GRhQctDariVb5Zq9BrKRhMAS 4G92+lUEgrODE1wh+wcP0us2nOBqiPW8aTBN82US4kTRutqtr5kpp9fClXup2vA7aCih GB80jxj/y4rFJFn8ox4p15vapOeHHKyfOhQrowwb7WCIjoVrtPDCwk07E+J/N+WMKB9Z 0Vrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912112; x=1720516912; 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=VGAqlXXmWHNhTh9vgnZWCBaKbJgiHWhA9edkrjy7PcE=; b=VaZys4X3z21yRy8Mwd+PsqvGQm9lXeI8XDEKJD2SgLy285Apn+uA5k6OYYMAi/T8Rq bW7/SXwyuq7fQTyT7sXSVYmjxsA/GSdIUBZ+LFYdcmTeGVfVtp7rOpHDkqsOjfdKnPI5 JZydVybksNxF5Ad678T+zvWLjEuHV3oqxnuIGOV1Ej5HqjNPHDYOq+8os8y7bETHpqL5 a2OvWcUODhQNfBWwrgmwbTnWQu0irIKRZCJ5KoLSpiD+yAlrkCavO1wJE4//VeHFC7gG w9huUaB4mQYgvz6s3d9cnaQfRc5TpfvB9t/+ewEGrrsApPDOh09csMW0cPibK1qHy8cb dz5A== X-Gm-Message-State: AOJu0YyiqFWaBi9DVQTNefCNWXie+vheSwat2A+DMqu5INtIDK52SuXM TfizepVBGVneSlx2bJC5yM77IsOVZiHWNwrMzWd3V2U2KVqBxyungRONG2t2WQuX3TO9Oz8ffAT S X-Received: by 2002:a7b:cbd2:0:b0:425:5eec:d261 with SMTP id 5b1f17b1804b1-4257a02805dmr62707875e9.34.1719912112410; Tue, 02 Jul 2024 02:21:52 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257a2f7451sm132918665e9.0.2024.07.02.02.21.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 10/67] hw/sd/sdcard: Simplify sd_inactive_state handling Date: Tue, 2 Jul 2024 11:19:53 +0200 Message-ID: <20240702092051.45754-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Card entering sd_inactive_state powers off, and won't respond anymore. Handle that once when entering sd_do_command(). Remove condition always true in sd_cmd_GO_IDLE_STATE(). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-12-philmd@linaro.org> --- hw/sd/sd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 824cb47856..30c1d299d4 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1078,10 +1078,8 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { - if (sd->state != sd_inactive_state) { - sd->state = sd_idle_state; - sd_reset(DEVICE(sd)); - } + sd->state = sd_idle_state; + sd_reset(DEVICE(sd)); return sd_is_spi(sd) ? sd_r1 : sd_r0; } @@ -1580,7 +1578,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (sd->state) { case sd_ready_state: case sd_identification_state: - case sd_inactive_state: return sd_illegal; case sd_idle_state: if (rca) { @@ -1801,6 +1798,11 @@ int sd_do_command(SDState *sd, SDRequest *req, return 0; } + if (sd->state == sd_inactive_state) { + rtype = sd_illegal; + goto send_response; + } + if (sd_req_crc_validate(req)) { sd->card_status |= COM_CRC_ERROR; rtype = sd_illegal; From patchwork Tue Jul 2 09:19:54 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: 809053 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116603wru; Tue, 2 Jul 2024 02:23:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/yltGrND/7KlzhUnq8HiW3IsaOgMSNds5GOYFNnA4T/YGoNdhMHgBHFvWtzFJ0vzSSf7JH/+ovJodZnsJ+YI2 X-Google-Smtp-Source: AGHT+IGu8FMtbTIzUvmTY4ixqtR1FQxK/NRMFJx4ChsHM9BYuasAt6xwFhUWIIIWjm8vP1LaQhtL X-Received: by 2002:a25:80c3:0:b0:e03:4782:3867 with SMTP id 3f1490d57ef6-e036eb6811cmr8140995276.29.1719912192881; Tue, 02 Jul 2024 02:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912192; cv=none; d=google.com; s=arc-20160816; b=mDlXz/gzldkNXZxJJM6lM0QoMsIjGXHv3s0iVXnM5+snN8AnoOALuFFTkdyM2YuFxr 9mKCWskChCREze4OOoxiNlCVNvRBFoxImmWMKcY+7Z8rGbEUJm4gQsWEk2poRXjth0Vu SC+iPb9Cq4BqKaHuiN5Hir6nSY/2BSTG+PQyychk+19Vg8jPa0XbZC/+MwzcByoeWvfs GQ/sS8fbllnY2J5Cp/crDt0m42LMvPYDBvC6wBB1W3FK+7ZSMSyZ7Q6PsDa9r2Cy4M0w yaFr1oR6kPG872ktwfCnJmFGmTWtO2BJpDz1RaTKoGkRxufbD48k2/cGrCTKvmEUlU2e 13xQ== 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=E+5gh8hAsErYp4RFAc5dc/YmikXj+fQzAy2bjo6tyAE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=rEOkOJzdKQnFb/kQQmuB70Nwk2LNWai6OBwfBAwdN5AOaKI9Biu5HaD5KaFTkPGBbk 5ucgrv2fuEYMoJnKqcWt5nTcCbf2juwaERWsP6X4gfirL3TmInm9s+0bBqGTZDLTrTNh WrldZCW1heJ+Sfsu6OixfDgpR1yAbfBhUOFsA/r7rG/302so5WEMtsByUq2L4yiAwPH4 IA11suslfIxDo5/k7foYD1abrZyDI544NhKvCUyogWP8awkp4VG3+S9FkFZiFaewHyjk gFjDesOpihL15KeABO1QUGSKWIMIi1HiPkZoF3atz1FlNnRBDBnlJorN45HIde8gWhVA 2+eA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sZd72Xof; 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-446514c20adsi96692571cf.576.2024.07.02.02.23.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:12 -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=sZd72Xof; 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 1sOZiD-0001D2-RM; Tue, 02 Jul 2024 05:22:09 -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 1sOZiA-0001Cb-UO for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:06 -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 1sOZi4-0006T4-Vx for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:06 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52ce01403f6so4485385e87.0 for ; Tue, 02 Jul 2024 02:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912118; x=1720516918; 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=E+5gh8hAsErYp4RFAc5dc/YmikXj+fQzAy2bjo6tyAE=; b=sZd72Xofb7JNwg5WXV63oFK9qFXkO6+I5w5srUOL2wsyAnLpiGxwnJgX3/wZaoz3GC hF9EZb+h9IceG5DOjLxpAt4p7soNvxosW8+y4Eh65VTYZhyF4sBChj1VtLSLCHqEDEet kkUh75ALRwYhVcsj89jmO7grd+I+rRJo4iYNhlMukTvg2SvcejfFdV4mwgeHZCxV2RQM Toqxk+sc/TD2q9DkNNT/SOB+XPz461hCAkxAwz+m20Ez9f/9sLmLMY+YvETdVEUKR3WE UlfgQpV4JY027i71TLadRM+Q6M6kPzLCkBkAf2neLAamSVf10hQ11AXREw+ytK4y0EW6 SGXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912118; x=1720516918; 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=E+5gh8hAsErYp4RFAc5dc/YmikXj+fQzAy2bjo6tyAE=; b=sLEJgAk8p30AtIhe2EGyAhE7nD77uM8MyhDioyXWFhF4jXbCe3EF/yfhM14r8fPZhw 4li0VKURYS8ecHvz8QjMQ3vA/756+fZ3ry+MR8XszLTx28Ya5IGeKurbq8qkmgQWOrXq SYFbesuTruLECDUAHl6nm6WmO7NyJjB5KuACkn5d10QWdj3oz6I8TtjVqB3IP+nOlQER f7sKFcZdNyWWY9vixLshmmXFjy2jin2HgYNOtT93qXJefHi+F69il9vzJfK24njz6U0q PT6alyyXN/a2zd6tMTZ039XiL3lvJtvy3PIoQZyPGtLdWVBVmZkGgBeBNJL8y2aJi0mt B0PQ== X-Gm-Message-State: AOJu0YxhTbGb+USPhiYy5mujj+uyMIXZaRW/lhM5w5+GT+iRng7uQKJF bQ7mx0/NDiMfXisR4ylA/I1j7ZXKGKqLYsUwdj9iiY1uWohHuem8Y53FkgoQXvQ0j9+2jC3wQIb X X-Received: by 2002:a05:6512:acd:b0:52c:caa6:13b4 with SMTP id 2adb3069b0e04-52e8264e4ecmr5958184e87.3.1719912118085; Tue, 02 Jul 2024 02:21:58 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09aa32sm189743195e9.34.2024.07.02.02.21.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:21:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 11/67] hw/sd/sdcard: Add direct reference to SDProto in SDState Date: Tue, 2 Jul 2024 11:19:54 +0200 Message-ID: <20240702092051.45754-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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, T_SPF_TEMPERROR=0.01 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 Keep direct reference to SDProto in SDState, remove then unnecessary sd_proto(). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-14-philmd@linaro.org> --- hw/sd/sd.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 30c1d299d4..d06e670024 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -116,6 +116,8 @@ struct SDState { uint8_t spec_version; BlockBackend *blk; + const SDProto *proto; + /* Runtime changeables */ uint32_t mode; /* current card mode, one of SDCardModes */ @@ -152,18 +154,11 @@ struct SDState { static void sd_realize(DeviceState *dev, Error **errp); -static const struct SDProto *sd_proto(SDState *sd) -{ - SDCardClass *sc = SD_CARD_GET_CLASS(sd); - - return sc->proto; -} - static const SDProto sd_proto_spi; static bool sd_is_spi(SDState *sd) { - return sd_proto(sd) == &sd_proto_spi; + return sd->proto == &sd_proto_spi; } static const char *sd_version_str(enum SDPhySpecificationVersion version) @@ -1041,7 +1036,7 @@ static bool address_in_range(SDState *sd, const char *desc, static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong state: %s (spec %s)\n", - sd_proto(sd)->name, req.cmd, sd_state_name(sd->state), + sd->proto->name, req.cmd, sd_state_name(sd->state), sd_version_str(sd->spec_version)); return sd_illegal; @@ -1050,7 +1045,7 @@ static sd_rsp_type_t sd_invalid_state_for_cmd(SDState *sd, SDRequest req) static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: CMD%i in a wrong mode: %s (spec %s)\n", - sd_proto(sd)->name, req.cmd, sd_mode_name(sd->mode), + sd->proto->name, req.cmd, sd_mode_name(sd->mode), sd_version_str(sd->spec_version)); return sd_illegal; @@ -1059,7 +1054,7 @@ static sd_rsp_type_t sd_invalid_mode_for_cmd(SDState *sd, SDRequest req) static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Unknown CMD%i for spec %s\n", - sd_proto(sd)->name, req.cmd, + sd->proto->name, req.cmd, sd_version_str(sd->spec_version)); return sd_illegal; @@ -1070,7 +1065,7 @@ __attribute__((unused)) static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) { qemu_log_mask(LOG_UNIMP, "%s: CMD%i not implemented\n", - sd_proto(sd)->name, req.cmd); + sd->proto->name, req.cmd); return sd_illegal; } @@ -1163,7 +1158,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) * However there is no ACMD55, so we want to trace this particular case. */ if (req.cmd != 55 || sd->expecting_acmd) { - trace_sdcard_normal_command(sd_proto(sd)->name, + trace_sdcard_normal_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); } @@ -1182,8 +1177,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_illegal; } - if (sd_proto(sd)->cmd[req.cmd]) { - return sd_proto(sd)->cmd[req.cmd](sd, req); + if (sd->proto->cmd[req.cmd]) { + return sd->proto->cmd[req.cmd](sd, req); } switch (req.cmd) { @@ -1629,12 +1624,12 @@ static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { sd->last_cmd_name = sd_acmd_name(req.cmd); - trace_sdcard_app_command(sd_proto(sd)->name, sd->last_cmd_name, + trace_sdcard_app_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; - if (sd_proto(sd)->acmd[req.cmd]) { - return sd_proto(sd)->acmd[req.cmd](sd, req); + if (sd->proto->acmd[req.cmd]) { + return sd->proto->acmd[req.cmd](sd, req); } switch (req.cmd) { @@ -1925,7 +1920,7 @@ void sd_write_byte(SDState *sd, uint8_t value) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return; - trace_sdcard_write_data(sd_proto(sd)->name, + trace_sdcard_write_data(sd->proto->name, sd->last_cmd_name, sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { @@ -2081,7 +2076,7 @@ uint8_t sd_read_byte(SDState *sd) io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; - trace_sdcard_read_data(sd_proto(sd)->name, + trace_sdcard_read_data(sd->proto->name, sd->last_cmd_name, sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { @@ -2226,7 +2221,9 @@ static const SDProto sd_proto_sd = { static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); + SDCardClass *sc = SD_CARD_GET_CLASS(sd); + sd->proto = sc->proto; sd->last_cmd_name = "UNSET"; sd->enable = true; sd->ocr_power_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sd_ocr_powerup, sd); From patchwork Tue Jul 2 09:19:55 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: 809073 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117516wru; Tue, 2 Jul 2024 02:26:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWBT4Mw64r/EYbkG1NDCaX5LBG0t3lhHZs2sMaD7L9Wkt6o1k8xXC4uOh0Nrhjs4YHL5VhnD/BSrB0xNKlQ4tLm X-Google-Smtp-Source: AGHT+IH3zr2lTSFB0W2agB4A78JsDcjIzyPpuJ/B+VnyO95r9sosuiH0azwSCUqX5REpTIklLHfv X-Received: by 2002:a05:6122:2899:b0:4ea:edfb:8d89 with SMTP id 71dfb90a1353d-4f2a56dd66cmr9037166e0c.12.1719912382458; Tue, 02 Jul 2024 02:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912382; cv=none; d=google.com; s=arc-20160816; b=Ybg7Rm/2qGCDu0WZeTTOYGxQ7OAZPJ3xOO6zxe5X46+FNRfbJ1smoPBQTMn/TGOVg9 UJKJGAJ4Kc3tULvujKPOijFPzAF7R8ZnfqdF0TKBuw+7KLC/Cz49f1TE2eDKzYjCYV83 JYwo466C5NFrfIjXcumZCjRRf+8WhHD6oQFgHoNLM7wnGXmLudsd+5mHGf7xVtqv35Ff OyDdxolAts3rvtvhzBCzu74bbkWoaeLGwbRRDhOfwRnpvz2XiwwTQT6xilWr7S+P2ef4 Bf7hdR2ERxJYQcVGeVQFa4VexT3Jiy00p9ar5l3f4RG224zvW+PkAIASA9KYPNpBFW3/ +8VQ== 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=UnOllaloZd2LpX3vFv80SvvLh9z9PQTQVpVybu389fk=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=xSM6u5NriudYIk+YHRDXIIpyO/LU9JdJonaCDKOdMB20AhnBO0XCV/CG3soKD9IGt3 SznahtNpQJSA/m0pgcNmaEo4jAaxkdq6ir1ES+O5gMsFhAo9yxJpus8mQBG4vHNbcwur iFlRIHXhaGzk/TYwvJdebokbINb9DA4tsoO1WvW4PHocsIwQMbCmJJpDvMboj4wISb8q 1GdBwUTSar0CzgK1Hz55JTs/LT5LAmeW5KQzqkXXr2B1Xm8pzeMX1orHeD1WzEyJOret 3YAXKdSnHJCPJs+0TuGd5/TF33fyW5aGpJmj0qTUtnrtvTZMfrzdOPRTRgvQ2qsj9R9s jyNA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a4nUkmHv; 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-79d692881b4si958842685a.212.2024.07.02.02.26.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:26:22 -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=a4nUkmHv; 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 1sOZiM-0001aV-47; Tue, 02 Jul 2024 05:22:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZiE-0001DD-Me for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:10 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZiB-0006TZ-2o for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:10 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-36701e6c6e8so2081742f8f.1 for ; Tue, 02 Jul 2024 02:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912124; x=1720516924; 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=UnOllaloZd2LpX3vFv80SvvLh9z9PQTQVpVybu389fk=; b=a4nUkmHvgRvGHnwTeZpyIPn5DxWLPUvquPd9JG0OIBdM0Ogcx8IBcfB07jRpJeL47o aOYiz2OWyVttxh9qmV8nWZr44BWpNenywbfH9Ux4HTJwYViNLcMchda2dHMdfi1HQfzQ XWY+5bxudzsu6VQZmV8AMJLV1ObaEneeAHtGl2Uti2Jo2NJ0gu5IOMzGNy+g68FqnlMm RJF/f9kN/IvO5dgy2atb2C+7oK5zo6bmmqaExQaKC8dlN0q7z4x6KGCjkzqYQpTn9s12 7vpSEIbey4ZkIT2xhdEKLRaby5aVU/G9w2OpHjNA+djUOZt66Ei/F49HfmegH/CHM5j4 6BoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912124; x=1720516924; 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=UnOllaloZd2LpX3vFv80SvvLh9z9PQTQVpVybu389fk=; b=DdwCfvBeEim6Qm0KW6wqfOcTpGMixrn+Bj9ojEMh0VkA841FZ90Kbd3ik32VjBtuWs gS9AoH9/urnZ38w/zhR62M7qXYid1EPHrKvBwkSK7cfskZnEjttSOICqjkVODtgX3QkM yFNub/rOK8dty3bW8g6Sw1QXWwuwneQ84rDQuy9MnVLMCcowymoEWyRibz5F0GbvwGyz ksGxgibyMTwj1oV7PDCz6pSJOQrp+zHXaCaH+Jm0SKUblGoXYsT41p2mz+J9jUSizQ0G zvMrjCylud8qcFnRMNd3+hPGwmSsb+Db6lyxxglG+HTzGo1fcXIAe0Yf1twc+xHeDkBK VpoA== X-Gm-Message-State: AOJu0Yy/kGA8BzABWZ/SFMqGbA1ZAGREg/PC4rjvA+I9G38/4v33Mgi/ 5CDXNjBazrh4YdtjDJBCz1APKs+aAUziajwAY1HqZXGFIb7Iu3DZ/+NNxanPO+FOcsUbNaseKii x X-Received: by 2002:a5d:6d8c:0:b0:367:1a39:e323 with SMTP id ffacd0b85a97d-367756bb528mr6296189f8f.31.1719912124237; Tue, 02 Jul 2024 02:22:04 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e13d4sm12852900f8f.56.2024.07.02.02.22.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 12/67] hw/sd/sdcard: Extract sd_blk_len() helper Date: Tue, 2 Jul 2024 11:19:55 +0200 Message-ID: <20240702092051.45754-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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é Extract sd_blk_len() helper, use definitions instead of magic values. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-15-philmd@linaro.org> --- hw/sd/sd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d06e670024..18bb2f9fd8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -601,6 +601,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) stl_be_p(response, sd->vhs); } +static uint32_t sd_blk_len(SDState *sd) +{ + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + return 1 << HWBLOCK_SHIFT; + } + return sd->blk_len; +} + static uint64_t sd_req_get_address(SDState *sd, SDRequest req) { uint64_t addr; @@ -2074,7 +2082,7 @@ uint8_t sd_read_byte(SDState *sd) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return 0x00; - io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; + io_len = sd_blk_len(sd); trace_sdcard_read_data(sd->proto->name, sd->last_cmd_name, From patchwork Tue Jul 2 09:19: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: 809076 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117650wru; Tue, 2 Jul 2024 02:26:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU19kZfYMzeIOXiMxjualm9+DqogytgCZqufolYQp4cgRA404IO621MwAWx38XG7EqBJ77FJ8XcvLYxDjMQ3yu8 X-Google-Smtp-Source: AGHT+IFeC5vSTmQI7Ms2sKPhezyFf4hHAdfMlTQH/iI6bZWjq7T7mxZnQJxVGoh7plNQF3V8nnGe X-Received: by 2002:a05:620a:4043:b0:79b:eb98:b03d with SMTP id af79cd13be357-79d7ba7a3cdmr960216385a.54.1719912409979; Tue, 02 Jul 2024 02:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912409; cv=none; d=google.com; s=arc-20160816; b=TDhUORj1qx5B+WOLGdFXMeIrCdGaVV8kwozo/5BkMZ+nnrhVEGt6OoE3HW1DL7QNNE NtGeHHP/ye5P+hU0bSnw4LvYnBfxYDh3nYtd3tXpkxea+d0rkNo3l0BD7OBOZwVF3E6/ TnVFqzlGczLgvVNIMdJrro+Ytt5wuGBWR/EEf7hIMVlymetPwrZ63dKtGca7WWRccita qcJ8p1xdc/gSNgbGHC9RvsjgsQfko1S48nmG1q8iD7UpvnxIZm91UNaz/Hxr8+esp1hg RpOVQtdhuf4jwmuSPXLMBLT4Wa+7ZrRHEq7E6EgiiL3JEy3bQBPD7rvx7tmm/logNInR A0YQ== 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=XqX6iaUQgzL1offrhP+HrFxeqPqsVcUC+AhsVlpqm/g=; fh=jw2PsKsd9I4Y/dvIN5GBF/pPu9bwWqQrIW4z01RRiXs=; b=sWKcTh6EqzgdxECek4eTBqeO9W2h2mSRM6PXlT3AGZut5rlZ3Giq7TsLYgkiwgWvkL n/lV1HpE10fn/0cpozgkoz+BBgpSpBN4Sn1iJhJYXbuGAN050KHyFGoqtB/cCQOwMN1p CRzLoDVFpgknlg0LrEVFCD/FkhZXIdhuRIvw9b8yAiuyCekRT0sUDqqgxVFi9BySdJF9 sVo7izUuVouwTRjp05LA1oMMHY5Ynf0A6T/TraBORBsS37SuXlIvKkunfST1cSLJsLw+ /do6uIyT0gTYJzI77jSOWPfMAeANJya6AbPmz5Hcy1BAuApcemlL7unw7tVyvOjhNvVw 5a7Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p1t6KJV7; 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-79d6933836dsi1077156885a.544.2024.07.02.02.26.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:26:49 -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=p1t6KJV7; 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 1sOZiM-0001eU-Hw; Tue, 02 Jul 2024 05:22:19 -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 1sOZiJ-0001QQ-0z for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:16 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZiH-0006UE-4b for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:14 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so2250208f8f.1 for ; Tue, 02 Jul 2024 02:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912130; x=1720516930; 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=XqX6iaUQgzL1offrhP+HrFxeqPqsVcUC+AhsVlpqm/g=; b=p1t6KJV70eZsL15wNHuZpbnL3b11zlNsYJEATh/eGjHZcv04hEFe/sumsaFSwvNr78 UxVQv8YYeCSyhrHhvSK+Mt+7nmxUVIICOPvje7rgkaDisa7c7sjuJcIx3ICiRaKclN4/ dMhQW/g5YzSkwBET2pNqfvMteZh9jKuLRhwO0W5RYfDgboeYX84UWTp5c3fRhFCHOAAU OpjP2dR10LoROusD5U/9hgz9T5R73S85fWwix98CbrjLSNgVZqNgNAtPHTC4JvgDZrDH RkHHqsuOQ5bmmI3W0Qxjju+521XWxveQVOZTYv17LfKUsdW3uj4rpIxZjACaCnwEBxFT qZ6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912130; x=1720516930; 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=XqX6iaUQgzL1offrhP+HrFxeqPqsVcUC+AhsVlpqm/g=; b=FntdBzXJTFVLP+hL69Mb19ZTjahzEuvsaC008n6Ch+edJpbfh2Fzz+40Ta4cgygEvD qbo0vpyROgAH/a+aoYrtofAFLfoeA+u72PypwUjZm8Rdlz/zAxVRO84ZYKC9rf3Pj6fJ ng78PQGjUBJBiL2Gtois8l81VYHnIwUic+/ViYsKwrCtyGLlTGZpOBh+cenO4ajsXvxx hBebOj7yZoCJCZCMa/6jB+LYBQLOnAP2PxTziC87XYYNEWmGxGqiUX3BX82pJ0gT4gU1 Qc5kboHpkwRvp9dVSSXwzbfIMrZwoFlKcSZm7OWi7EKOU+i3TplbIOxF3ElA8aTxXFYC 96tA== X-Gm-Message-State: AOJu0YxCc/wfAFQwd9cTOkNeNZ/r382sIj6TlIUYpVSah7dYDBbJjKCl b3dFzviEL+DMgbnFaSOtOkWt/dzvAHRQ5QeeLAIalNR3FN2921AJSs6PMmpBpx2sNePX+xpGXc3 b X-Received: by 2002:a05:6000:b01:b0:363:ac4d:c44f with SMTP id ffacd0b85a97d-36774f6cabdmr7104281f8f.17.1719912130181; Tue, 02 Jul 2024 02:22:10 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a103d00sm12665190f8f.99.2024.07.02.02.22.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?C=C3=A9dric_?= =?utf-8?q?Le_Goater?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 13/67] hw/sd/sdcard: Introduce definitions for EXT_CSD register Date: Tue, 2 Jul 2024 11:19:56 +0200 Message-ID: <20240702092051.45754-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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, UPPERCASE_50_75=0.008 autolearn=no 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: Cédric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Cédric Le Goater Co-Developed-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240628070216.92609-18-philmd@linaro.org> --- hw/sd/sdmmc-internal.h | 108 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index d8bf17d204..936c75cace 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -11,6 +11,114 @@ #ifndef SDMMC_INTERNAL_H #define SDMMC_INTERNAL_H +/* + * EXT_CSD Modes segment + * + * Define the configuration the Device is working in. + * These modes can be changed by the host by means of the SWITCH command. + */ +#define EXT_CSD_CMDQ_MODE_EN 15 /* R/W */ +#define EXT_CSD_FLUSH_CACHE 32 /* W */ +#define EXT_CSD_CACHE_CTRL 33 /* R/W */ +#define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ +#define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */ +#define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */ +#define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */ +#define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */ +#define EXT_CSD_CLASS_6_CTRL 59 +#define EXT_CSD_INI_TIMEOUT_EMU 60 +#define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */ +#define EXT_CSD_USE_NATIVE_SECTOR 62 +#define EXT_CSD_NATIVE_SECTOR_SIZE 63 +#define EXT_CSD_VENDOR_SPECIFIC_FIELD 64 /* 64 bytes */ +#define EXT_CSD_PROGRAM_CID_CSD_DDR_SUPPORT 130 +#define EXT_CSD_PERIODIC_WAKEUP 131 +#define EXT_CSD_TCASE_SUPPORT 132 +#define EXT_CSD_SEC_BAD_BLK_MGMNT 134 +#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ +#define EXT_CSD_PARTITION_SETTING_COMPLETED 155 /* R/W */ +#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ +#define EXT_CSD_MAX_ENH_SIZE_MULT 157 /* RO, 3 bytes */ +#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ +#define EXT_CSD_HPI_MGMT 161 /* R/W */ +#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ +#define EXT_CSD_BKOPS_EN 163 /* R/W */ +#define EXT_CSD_BKOPS_START 164 /* W */ +#define EXT_CSD_SANITIZE_START 165 /* W */ +#define EXT_CSD_WR_REL_PARAM 166 /* RO */ +#define EXT_CSD_WR_REL_SET 167 +#define EXT_CSD_RPMB_MULT 168 /* RO */ +#define EXT_CSD_FW_CONFIG 169 /* R/W */ +#define EXT_CSD_USER_WP 171 +#define EXT_CSD_BOOT_WP 173 /* R/W */ +#define EXT_CSD_BOOT_WP_STATUS 174 +#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ +#define EXT_CSD_BOOT_BUS_CONDITIONS 177 +#define EXT_CSD_BOOT_CONFIG_PROT 178 +#define EXT_CSD_PART_CONFIG 179 /* R/W */ +#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ +#define EXT_CSD_BUS_WIDTH 183 /* R/W */ +#define EXT_CSD_STROBE_SUPPORT 184 /* RO */ +#define EXT_CSD_HS_TIMING 185 /* R/W */ +#define EXT_CSD_POWER_CLASS 187 /* R/W */ +#define EXT_CSD_CMD_SET_REV 189 +#define EXT_CSD_CMD_SET 191 +/* + * EXT_CSD Properties segment + * + * Define the Device capabilities, cannot be modified by the host. + */ +#define EXT_CSD_REV 192 +#define EXT_CSD_STRUCTURE 194 +#define EXT_CSD_CARD_TYPE 196 +#define EXT_CSD_DRIVER_STRENGTH 197 +#define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 +#define EXT_CSD_PART_SWITCH_TIME 199 +#define EXT_CSD_PWR_CL_52_195 200 +#define EXT_CSD_PWR_CL_26_195 201 +#define EXT_CSD_PWR_CL_52_360 202 +#define EXT_CSD_PWR_CL_26_360 203 +#define EXT_CSD_SEC_CNT 212 /* 4 bytes */ +#define EXT_CSD_S_A_TIMEOUT 217 +#define EXT_CSD_S_C_VCCQ 219 +#define EXT_CSD_S_C_VCC 220 +#define EXT_CSD_REL_WR_SEC_C 222 +#define EXT_CSD_HC_WP_GRP_SIZE 221 +#define EXT_CSD_ERASE_TIMEOUT_MULT 223 +#define EXT_CSD_HC_ERASE_GRP_SIZE 224 +#define EXT_CSD_ACC_SIZE 225 +#define EXT_CSD_BOOT_MULT 226 +#define EXT_CSD_BOOT_INFO 228 +#define EXT_CSD_SEC_FEATURE_SUPPORT 231 +#define EXT_CSD_TRIM_MULT 232 +#define EXT_CSD_INI_TIMEOUT_PA 241 +#define EXT_CSD_BKOPS_STATUS 246 +#define EXT_CSD_POWER_OFF_LONG_TIME 247 +#define EXT_CSD_GENERIC_CMD6_TIME 248 +#define EXT_CSD_CACHE_SIZE 249 /* 4 bytes */ +#define EXT_CSD_EXT_SUPPORT 494 +#define EXT_CSD_LARGE_UNIT_SIZE_M1 495 +#define EXT_CSD_CONTEXT_CAPABILITIES 496 +#define EXT_CSD_TAG_RES_SIZE 497 +#define EXT_CSD_TAG_UNIT_SIZE 498 +#define EXT_CSD_DATA_TAG_SUPPORT 499 +#define EXT_CSD_MAX_PACKED_WRITES 500 +#define EXT_CSD_MAX_PACKED_READS 501 +#define EXT_CSD_BKOPS_SUPPORT 502 +#define EXT_CSD_HPI_FEATURES 503 +#define EXT_CSD_S_CMD_SET 504 + +#define EXT_CSD_WR_REL_PARAM_EN (1 << 2) +#define EXT_CSD_WR_REL_PARAM_EN_RPMB_REL_WR (1 << 4) + +#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7) +#define EXT_CSD_PART_CONFIG_ACC_DEFAULT (0x0) +#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1) + +#define EXT_CSD_PART_CONFIG_EN_MASK (0x7 << 3) +#define EXT_CSD_PART_CONFIG_EN_BOOT0 (0x1 << 3) +#define EXT_CSD_PART_CONFIG_EN_USER (0x7 << 3) + #define SDMMC_CMD_MAX 64 /** From patchwork Tue Jul 2 09:19:57 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: 809060 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116772wru; Tue, 2 Jul 2024 02:23:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzJfQUSqPGH8B77DITBpT4+8fu3WuRW+8hNueqk/5InDYjX3YlDGt+KHY9AjXkOUcokCsN7FTfHglz5kn9VND7 X-Google-Smtp-Source: AGHT+IGSh364qYEfvjiHFwzPjF16NWCyuFv37+/9nn0+w+0DooAU05iJv3ZxKx5rqvhLXk+cg2uq X-Received: by 2002:a05:622a:1483:b0:43e:3a65:3295 with SMTP id d75a77b69052e-446615febc3mr132011431cf.14.1719912230855; Tue, 02 Jul 2024 02:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912230; cv=none; d=google.com; s=arc-20160816; b=M+r5p+1XP/VISJwmV4WkPMgvcIJAfIgPBcyAfjMGHr82IMX2xn9oWmQbnuRFZzupJH hTw0nxe0DYOyW+IJSqCikfehy8Sdwy8WMQue0sEdGD7uzHExuBJfVIpX6PoZa/yVMN3b o0qRbcIT5n/r9G8X8wWFo1/uuFn4jQTQ+xUCYFA2GnfYzzIW6/BJVDuyKtKxmLuCQ/Ne Nab1sXVR11x/2hjfsFyXzqXafTy16i3OQlt0VJbe/QArZvgbfeqe/GIpklMSqphuSoNM xsegfZ9mYgmM/TIg2bY6SgWLFc21cSEJ9IudPPMAeLPyB8En4oPxG1WfnQ6Y4BY+UmPr MiEA== 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=HcI1AN4c5MSHGXZPNCWGySksYQ9YOF7GAxwDscUWZ8U=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=XuNJQTJjwBgET7X/8ejjELvfG0wJdV8k1TJR4eoOe8YxpjcbZhhLB7tYRVmjC+A5ri oCnoT/VY9Q8/N6XgpU3b+gksn5Zpyjy2YgdxCKsCiUVxuc3/ESfmRyO+z/k11K8xaXxd 2H1dMUBBhlyEwa3iyxaww7aHlF2bKVRtzsf95wAbFBJzaW41RtZLQxKXi+mFWQl0Lffg dzZro0zkfWSdFrIIE9MbCOC6lMuwESCPTaRpzXejQMhGd4H3PbZntSz7WcK3uY4vHPhO KxafplxA2jlYhu6we8q9UbdHAJS3a8h6CyWT4+M3FmUTjgp+nB9bCR3mgsNnGHWB5vqn wjcQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MwFvQXNq; 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-446514c0f37si96229861cf.539.2024.07.02.02.23.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:50 -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=MwFvQXNq; 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 1sOZiT-0001nf-6j; Tue, 02 Jul 2024 05:22:25 -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 1sOZiR-0001mR-Cf for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:23 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZiN-0006W7-JC for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:23 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ec6635aa43so39465971fa.1 for ; Tue, 02 Jul 2024 02:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912136; x=1720516936; 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=HcI1AN4c5MSHGXZPNCWGySksYQ9YOF7GAxwDscUWZ8U=; b=MwFvQXNqENgQtAsJnCbQWRX6M6uHlffU+hI0YWLUvupAKqSdDcJBPPo6v1sa6+Hb6F w7cMCedlgleuexUB9mCXT5Ep/+GBi7YDaJMhBIXBHsxsbCZegul5c6xf5b3ynSCA+aSQ rlbqfzAJQBqL6376WTnuX4theKN1mDBBOKQz2vvVDoXO8nRdDEvj/ZeAqQ7+3+n3l5Ws F0KVTiWcDwrpeuLx0hbaf4MZkq10luCIX9hQHD5y6ty70VzNvbU0+uzOgcVjWcWPE/nK YL/wnYd1TL8Q85X9OCT5k4r4WpJT2sLCt+TSEHCPJgQq9bbG3h85x/SEjfEZQcnjN8oX vwWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912136; x=1720516936; 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=HcI1AN4c5MSHGXZPNCWGySksYQ9YOF7GAxwDscUWZ8U=; b=jMU1nGQ+2Osrs6svH6YCqFFCjUKnnVhx3z1wGLEsWHxvhqHBwFi1w27S3tCHA3DU7S UedxUyAqXlJQrLCshVKLmQlnYcDSMnTVbeawWFqpm5bjT5WHxV3BNt3kAo1jvUfBHORT eRbRLNA1wHkHMAKqdauwFEr6GPOIgX97iu/cCSvk998eiNpgFiLNwbq0eeyqsBJ8iJ75 525tTey5hCY8EB+AHQfXJpGWMy5AhfWNZFi/l5IFVSlvzmLJi5OxgB0fYSkexZdm2+VH Lj2Fmv0yd74mgxYjHuIxJhVRhAzdJeLs4x0g18Gje7IV2JzAazMKv9XLB8KgPqOvNJbr 8yMA== X-Gm-Message-State: AOJu0YzIbLEIj+xfrcKpiG05l9rZNu0SBD7PB7asUapTCo40jMnZtvyO 06cQ5E71R5bkzuNV+3TJ//Y/E2+IYMWLhmZN0Nhdai5hFW2Bnhvgw4gH8tBxM2hU5ijPCAjqzVj w X-Received: by 2002:a05:651c:244:b0:2ee:7255:5047 with SMTP id 38308e7fff4ca-2ee7255541cmr20237461fa.50.1719912136338; Tue, 02 Jul 2024 02:22:16 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b061006sm187723585e9.22.2024.07.02.02.22.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 14/67] hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte Date: Tue, 2 Jul 2024 11:19:57 +0200 Message-ID: <20240702092051.45754-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.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 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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <4c9f7f51-83ee-421a-8690-9af2e80b134b@linaro.org> --- hw/sd/sd.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 18bb2f9fd8..60235d3898 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -141,8 +141,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]; qemu_irq readonly_cb; qemu_irq inserted_cb; @@ -1078,6 +1080,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 > 0 && size <= sizeof(sd->data)); + 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) { @@ -1912,6 +1937,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 Tue Jul 2 09:19:58 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: 809049 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116516wru; Tue, 2 Jul 2024 02:22:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWl7XQY4nA03mJmHIUVyx8s3qtL0/E/kFrFTh7SqjJhm+QNgMaftqTN8Z7ViO9F5fYiNegrsb4YP07j+LQ4OJBl X-Google-Smtp-Source: AGHT+IGY2TDox5dpWIahV8JNDnypX3ptNF8s4M5UUL+6xU1yB6/Mh85LWEoy7yUGYJDxCFPUcVFv X-Received: by 2002:a05:620a:94d:b0:79d:59bb:639f with SMTP id af79cd13be357-79d7ba8b0c2mr772333685a.65.1719912175532; Tue, 02 Jul 2024 02:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912175; cv=none; d=google.com; s=arc-20160816; b=YBebqRmdkDUoJ6ZVuN+aWld+ekcXTK+X0JqBCFAKMTjNIynKVdXij/ANXcAd6DE4Kg A36vzOFtpAFQzi0eaLMHvydKlPq/K1i498TLlDQPds6Qp+x+9VKSNaCI8BWus2a3+Lxx a7jlEW/6n6W4xcBQJ74+YWvsE9XsQME3uzMxyAIc+biK33ARsRJDdz3zsptX+wcR8E4/ zPn5RJ3XFngdyY7gOvo3/Dx432wPu+AYm6jCloPL1qkZL1nn/qKpQv1M9hYRVWme4a+4 sll5EIZzyTS1+DDOTzvubcHZmCPwuPPmsiT1Al8J4e0AWjaLcg0Qi4l7el6tFj6Vvvcr Ey+Q== 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=00CPRUcf9kqsnaJEo5PoDWaoJdXP5EBP+kdhrOAEpVg=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=PN1N9XGmN2CDYVv2MZC+f8NP24GwW9CtACgxYUdyLk7jwtpPBuvzva5juebBQqjjZ2 TWgDxAqEH62shbRp3WNR4Et41GpYSZnjCHU+TDhgGKW3VVcNbCiKEwA+H1Pdfi8ZeAO4 VG3x14BevB3xFxYB8sfbXmLvLZjhFSXgvxFv7UY/QCayT2h4GRd4ZCInREGR/nmxB3l1 Skj1SYF79Y/202ImqYgp6+ifo+PgVOA/7CNe+hvKk980To0NJBPVd1xSKXHbhtKhGOUg dMtuFQgOzE62deDiBFVIvK2NYpO3+PAwOnU2pf2lm2WLS3UipGWOVn+j98uBwvk6bPJR +GCg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g8JDhn08; 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-79d69307dedsi947640185a.445.2024.07.02.02.22.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:22:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g8JDhn08; 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 1sOZib-0002GL-Pt; Tue, 02 Jul 2024 05:22:34 -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 1sOZiX-0001vP-5S for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:29 -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 1sOZiS-0006Wf-92 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:28 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52cdcd26d61so4431993e87.2 for ; Tue, 02 Jul 2024 02:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912142; x=1720516942; 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=00CPRUcf9kqsnaJEo5PoDWaoJdXP5EBP+kdhrOAEpVg=; b=g8JDhn083tRCZOOZFJncHu6VEEb7MBas+6U01vp8iZ21i6l2bvCl2b48ioMqvRUXWE nlSy5fuEmo75I36ooKedHLpZuqMUVg6do4A3b7UUj4F5bKPfEC0/FFLjdYyPHkD1drp8 6UvoWMU69p3or8WyPiTXmSr7g+CVDcbddQQL8j3OwUJ3JaWapizYyMMSNliZe+S6swQU Lfe7mW4xkvjoPTIyFBmRNKng//BqVYkgUh9ZGdGYilRiR4rFLyCJugV/VHnGsXeRBDkl ++rhZdPc5tNxRv+AtMd0nycuyR+QXo+b3Hjssl4u9eygUyDVgEc8cPDinZhmdfUJJk/v FBZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912142; x=1720516942; 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=00CPRUcf9kqsnaJEo5PoDWaoJdXP5EBP+kdhrOAEpVg=; b=m3APZoudO30uwF6NM2rkC3qECEMvvQ54pk9mMmzi8x8aUigphX16O0rD0GK8Ly9pKr YAFv9shjYXBsAHTqaO8zUNOa+/BKO/8hgK/KRROZiaTGtATrl/P5HRK3KqlV82mFXmZq OpxEckkRnWpIAkRBcgGxbVCWh3pV21BHhsOYgm9D0hPPuKrjq/RnmJVqqyT1Fw2vmjTM Oj8i5/V0GEsbQhoDznb4Ge64hthXVqLBbyjel2z1wVOyz97PLru8tDANT2joGY19m8ca IQCEn2sfeuJAOyg1BKusTar5L/P+yIoBRnVaZi6dV4o4xMy/IxELI4yd8A+wo9P7YqMV syMg== X-Gm-Message-State: AOJu0YwgwdyNec58vQ8OuB46hwjeRGqhVEzD/q7MglpLTS5q+WbKzVN5 HmDdXY1ukEVsVXJZJIKPm67nIwtLz31eGH3TcVDacMmYGJzwtcp/oxgJhGRD/PMMksFzGWyMheP F X-Received: by 2002:a05:6512:b84:b0:52c:820e:a7e7 with SMTP id 2adb3069b0e04-52e826fb7bcmr5301284e87.50.1719912142153; Tue, 02 Jul 2024 02:22:22 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36784e3e0f5sm1416879f8f.11.2024.07.02.02.22.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 15/67] hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6) Date: Tue, 2 Jul 2024 11:19:58 +0200 Message-ID: <20240702092051.45754-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-20-philmd@linaro.org> --- 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 60235d3898..b073700180 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1081,7 +1081,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) @@ -1235,10 +1234,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); @@ -1938,7 +1934,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]; @@ -2128,10 +2123,7 @@ uint8_t sd_read_byte(SDState *sd) sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 64) - sd->state = sd_transfer_state; + sd_generic_read_byte(sd, &ret); break; case 9: /* CMD9: SEND_CSD */ From patchwork Tue Jul 2 09:19:59 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: 809050 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116524wru; Tue, 2 Jul 2024 02:22:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW7scXQwNoomf9DTC4T17fjN+rRrSkQWMw9kj4RmOcJGwF5/USZ8zNDngL/qXEqKF8rkAYqxbQtgxZQewSDFojN X-Google-Smtp-Source: AGHT+IGLFDOMlW4vpEXYM7sggp0xlLqu9P6LWTXttWVrOvx+VcII8X54ydjcqv2p6lBEhB2klW/Z X-Received: by 2002:a25:d64b:0:b0:df7:6030:bb4e with SMTP id 3f1490d57ef6-e036ec85491mr8380417276.61.1719912177109; Tue, 02 Jul 2024 02:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912177; cv=none; d=google.com; s=arc-20160816; b=FBCKi97HChUOHtF+WCM8XGXPfFQlncu7SY6EMJk2RWSZTeOJhzSptFSclFgnzXbtjq yyGjORTmCcoTZIUtGzJtKyhbDNugyEksy+ydKWznqcdaY6CWLV7YeAP+DNS738iXS4Ao e9Troe9wYCK3miYhD2ZtXuNGjgVOTDyClNKn6XKNGcsjtuXIOAusAsMvbyK9WMnfX0gJ KeZqVmHdK21zt6bovpnxAKKrSe1S7msYss7y9J1Lp2PMsUedXMYn1LaxZ/ryu4WvCc03 hl+GVKNiAK+HhfhKzeeukZ7a3zXglsQ+7zjzW/7Iaf41teMVpambKW5UjPALF0Rfdk6J Po3Q== 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=pum4FAVUTjoo+qizzaMYQ9jJ7vnP2diemnQewFpOPU0=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=P2rjWtknjx4PBtdee1iA+PyuHQH5pDYPi/obVDpPfmw5ReOGyEXs+zslMfrLig6Qn1 YOvCH/A3jP5f8gYTUefsHRQUOxb0i6CJjB9NwvAdFHzecjpfTFnVmfGE6RJ9023LIIgn UKJTpvCngeI/f0KNtwkf0vPQAIOzz/NZ7k+UEv8lwntgit1HCEqDBn43i4JHngV7vfHZ jryyvIDOW2TONSEaQVSH5a4HilO8kpsfcLTZYUvQAPoGAyyzR4+9V9LGGtwOZhbZc3XF oAKec1UbX4/Rl8pjBNQphNF89aXaW/vqgcLt8NcE8hNzESu+smB5G78FjP5g3Yl68ljX pHig==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wKiZhufl; 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-446514aa227si100652631cf.504.2024.07.02.02.22.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:22:57 -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=wKiZhufl; 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 1sOZid-0002Q4-Fl; Tue, 02 Jul 2024 05:22: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 1sOZia-0002Aa-EI for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:32 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZiY-0006XL-Ej for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:31 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52ce674da85so4260900e87.2 for ; Tue, 02 Jul 2024 02:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912148; x=1720516948; 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=pum4FAVUTjoo+qizzaMYQ9jJ7vnP2diemnQewFpOPU0=; b=wKiZhuflJZNOvfwwMtQRds6slGjwZWQXrAoDs0d2Kt8pl/b8CGg5nvZVgwVg4RdUhl CzVUNkVF0xTA1jo/hxSWchlFUJDbpCWe2srNlneVL4RZagkKfuH9sSQa+n6DXOOu2UbF wmwQDUBAXky9uvLqs3kv9sXciar+g2GN/q0zTAOdHnayfo9BlLNH5X5yIjWz8fY+hbg0 oSKZ8jcLm+OIQE3zm4eNgdo+yuqeoGOcznk2tQLDrzA8QmchszxkLOVxCJg22AXtNqQL 6GUgDT9S61ucQ+1xWtFn4thRxl9J8B/cp3ojzpWTDRoHmZ+hjHBF0kh7uYM61sn9aWAp chiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912148; x=1720516948; 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=pum4FAVUTjoo+qizzaMYQ9jJ7vnP2diemnQewFpOPU0=; b=RoTYbiYkJXW00jPfsALoOr4Kzg9Y59uh70qlXAIjTLp6gYbTQwJyG0rKiWYo7AphKV mAAO+tMy7HQ0FFtSevChISUBJW0uVgfS3cLyZ+SkxboP81I2Stm/970EwLD+XDsse6Sl 4lfHfPJhuU3Sshf0gxBcYspREJdroYIaTgbjyPekQ0pA02Ti0Ajw8ARqX7YbKzVRmmKZ hkDtTYggZ1hmGs22rYaRbekEdc65+v/dVvpIhZyCvPkyHnjT01UGsBe1Y0xmZ5bzyJEb FcOwj+8m26+gaESAEFraVk5p44HS0nVbL7S/jvZFbSdj05K0TM4fqfyM6z7qecnK840q baJQ== X-Gm-Message-State: AOJu0YzqsicqpRG41DV6Bww0vU92pqgeQp8DNjpDwUMQlCUXMud7U0Lm GzhD2ZuL1Qec4JZAwl7m8VujgQwEZROkiHD6BwB3TA7bDWe35EvAtz6JqOQ8wKMtA05sa5XtJVV e X-Received: by 2002:a05:6512:398f:b0:52c:e4bf:d55d with SMTP id 2adb3069b0e04-52e8264d9fdmr6743732e87.8.1719912147962; Tue, 02 Jul 2024 02:22:27 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd623sm12678718f8f.16.2024.07.02.02.22.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 16/67] hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 & 10) Date: Tue, 2 Jul 2024 11:19:59 +0200 Message-ID: <20240702092051.45754-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=philmd@linaro.org; helo=mail-lf1-x129.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-21-philmd@linaro.org> --- 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 b073700180..6b02e0a178 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1304,11 +1304,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; @@ -1328,11 +1325,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; @@ -2123,15 +2117,9 @@ uint8_t sd_read_byte(SDState *sd) sd->current_cmd, sd->data_offset, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ - sd_generic_read_byte(sd, &ret); - break; - case 9: /* CMD9: SEND_CSD */ - case 10: /* CMD10: SEND_CID */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 16) - sd->state = sd_transfer_state; + case 10: /* CMD10: SEND_CID */ + sd_generic_read_byte(sd, &ret); break; case 13: /* ACMD13: SD_STATUS */ From patchwork Tue Jul 2 09:20:00 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: 809056 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116693wru; Tue, 2 Jul 2024 02:23:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUn1J5ro0BzkcTEy7E4G7/rO7zjMcMVfKSxL4Pb2aSAdNB7Ax4J6kz7kiNBkVMlsZmiHW8rFTxImtl6ERS6func X-Google-Smtp-Source: AGHT+IES2CTQJ7QA3QWuFHizLKhOu6bqwaaJ/41nlhUuOQwjsBe5wIvd1y3vZyH0XN+NQEc42cU7 X-Received: by 2002:a05:622a:1483:b0:43e:3a65:3295 with SMTP id d75a77b69052e-446615febc3mr132002381cf.14.1719912210385; Tue, 02 Jul 2024 02:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912210; cv=none; d=google.com; s=arc-20160816; b=ILsupCWKQEdzx6l3ozubeL59lupyTz4CebcVA5aRnJPu5RBPYUPJUir/WpXkYpwjlJ C+08trT3pro7EY0YSgdOWawvwUHk/erqydueiwrCIjUfGY0NfptX4SwuOzSnEjWWUtgU L5YqpnCDj7iXD/ZgdUSEiA1NfvKbbQm6eN7SVm1KVOX1b5M8xwq4XbTr/yWO/H0rvkzp EqIGdBKakyxBJdzCP2syPvpKoyclPxiX6KWjHPoZ6UamzEzWmWmn8Vf/oWq2q+w6Sr4e /eTQtoWTzSLv7ufMd9gKwOepZ7I/C0aJmZ0+UWE+ZhT2eMCtLoczU1zRGVT8hYHoa6qt tJCA== 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=uMKhvT1FGVOx323MVuTarj+/Z918eObPJs1bE9cIdjE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=vaDbI2xFtj7XLonLqHWbqrbFwVRVlf7RczpF7gjXzYRDI45+Y6xSREWAy4kcX1deyT CcbOxGkPZEvlv06N3yLruPsNEeVtuG0DXsdEG9VMHMtwYKZm03leTen2c7fCvUore8Al gmQTv5zAxhR6UG33XrEtq8qpEZoXZ9FbWayKxxBV2zP+Ig4Bm6F8HlowdnfJJgGnIVkP botub9wS+ieKYIcacrxOOBLwjYDIL8sJNDc/cEHXasHgatAlSDpHB+Bj9UBbsx4+cWVc IkFLPv1ezcLvfEInnyeZ7b2oKg4HlWeomYS13Uxxgzyt+rboz2bWl6XoW1/VJFsrMHTF SumQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="y/ICYbk2"; 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-446514e5508si97587221cf.764.2024.07.02.02.23.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:30 -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="y/ICYbk2"; 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 1sOZiu-0003uI-OW; Tue, 02 Jul 2024 05:22:52 -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 1sOZis-0003kg-Fr for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:50 -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 1sOZie-0006Y5-D7 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:50 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4256eec963eso27758645e9.1 for ; Tue, 02 Jul 2024 02:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912154; x=1720516954; 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=uMKhvT1FGVOx323MVuTarj+/Z918eObPJs1bE9cIdjE=; b=y/ICYbk2DFgRAQ7/GP3L1w7BVKWdD2KDhjCMFJ7YVjKCpTCriBv/iUcnmj9ojfas70 DcxWDCgierEWzP4+iPrBiK1fIbBz4aIx9EoxjhULvCOkHOg39EI1VwwOr3Pw6An3NRI0 kycA29KrGjWY86pWlQPsTFg7QIr6WGhHc8jS6/AG5ifCEfN4u+Sz4X966y3a5U8gB03b J57nZ2+p/QpT1ohSKTYAxf8lYpOOQeDHrzjRuNgrjJYtajg7zHoWG73eKu0CLkSvsHIQ Nww/Lpxd92xtLpzjuAsIB1q7ON0AiMze2HzX+WdKEKmYdKbi/xX+M5WIV4cqxqIDLjEt hr0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912154; x=1720516954; 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=uMKhvT1FGVOx323MVuTarj+/Z918eObPJs1bE9cIdjE=; b=O571jRmKdNhcJnuy8PxcSDFK5jHLc4Zgek5lNM1JcLR1hbtS7txEbtRm2dHzQJTVat 337bn0NXt2cxVqQq/AodJ5tcV1309Y8IR6k1t8uJw71kZYBrHq+WKPDgxPK/VP3P+Sq/ dFxKd+uNq//SJB17MPD/qR/ll+p8JMaj3UCSgML9wKaLeVqModzCPHK8F7cD+bM4jeaW KC9qOJIGPcDF14mCLEc0Z9F5k4s3f2Ap2P14N0/lfRZswU1sIuZh4nXJeGhzHCSEevpk 3d8Co55QwnXnrTCMVJlZrWVQSj04emaB8MP5x7i67UCY2r7K7A75fpiA+T3pndBYHNGz jiig== X-Gm-Message-State: AOJu0YwrXEGSYkUes69RzZJp5iaskw9QnRnE81XR98sZSNGtIZdKJKNP hVLAv7euBLOOCM4VfPneYhgeltHk1iodm5uR7QjgCYa+yr4og9F/HQPzyztSzPjq87xtmV4sN9u F X-Received: by 2002:a05:600c:181b:b0:421:7bed:5274 with SMTP id 5b1f17b1804b1-4257a02f7f0mr58623805e9.10.1719912153756; Tue, 02 Jul 2024 02:22:33 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257cdf4982sm110284735e9.47.2024.07.02.02.22.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 17/67] hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases Date: Tue, 2 Jul 2024 11:20:00 +0200 Message-ID: <20240702092051.45754-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to modify the READ_SINGLE_BLOCK case in the next commit, duplicate it first. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-22-philmd@linaro.org> --- hw/sd/sd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6b02e0a178..43e0a2d925 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1390,6 +1390,24 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 17: /* CMD17: READ_SINGLE_BLOCK */ + addr = sd_req_get_address(sd, req); + switch (sd->state) { + case sd_transfer_state: + + if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + sd->state = sd_sendingdata_state; + sd->data_start = addr; + sd->data_offset = 0; + return sd_r1; + + default: + break; + } + break; + case 18: /* CMD18: READ_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { From patchwork Tue Jul 2 09:20:01 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: 809059 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116771wru; Tue, 2 Jul 2024 02:23:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXlkiiV1cB8DR7pzSBXkt+FmBun9tONhFzUr/kt7FF31pnwd2r3dbubAX2K226gFxWIBXVYdeFix0APn5o++kna X-Google-Smtp-Source: AGHT+IH7t9v+kI+pRRh0AAiUgpq/uEfPtEyYgc+1Ek+MKR/t1n/pu7CgYcQ4Wuo9gQPc0D2emfu2 X-Received: by 2002:a05:6214:5299:b0:6b5:4249:7c5 with SMTP id 6a1803df08f44-6b5b70cf238mr96914266d6.36.1719912230862; Tue, 02 Jul 2024 02:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912230; cv=none; d=google.com; s=arc-20160816; b=1JR2/58qPDteK2K9fEdW9TB8EX0RbCvfnZxzNbG82m/nwYeQzkZtNapUDMejRWEYtF 2wo02eeZvPdIz1fLGaOdXTYZXm3T14lzCGyBebvBiqBgbMbTPFbRrM3fGKRW0zqE8gtO +BBEV8S8PXGHwb14d3CwGQm4/ROEeuoSxj8pOrtSkMp9R8KG2qNVU/uXuDAqLVSL7094 Vpe29Ae3c3tDlUAbNhoUCe4UrFHyR7Pj7KycAOt5knXPsksIy8wZM1uOu5i54q+swC1B hg7ob814XQzL+K62+HnZDYt+iZaGdLrjGr4Uji9NzXmWKzKJGySnn6DTkFmavB++NIj4 GWDw== 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=fq0Hp2Una8Cq+xwhreR1xxCEuiahEpzKceutH3MuTZk=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=oQUePtCpeuE+ePf8cLlq0O3lDlDC81nBXpsYKoYyrvWYeq3dS3nNeFR2R7wcVe4DqJ 9h2/zSW+eUCPzgb4PLIdxj2pKbp3eqzv7HMYrVgTvRhEx6FCpVAkJWpd6rbxcEq9tE5y 8ndDo4kPz9YISToyOgM0VQ/ebQITxe4adnulyWbD/4wwkR2+x+5PEwCObvX2aX3Egnoa EiKhh7QC/Rr61mKAyJwxHLvamXG0Aj88iGsKwjC0O5B2mb60nHC9euxu/immrf7OXgH/ f90k2ujmAmlcfcgXtUVQ3v/O668PhkOJnp211zxaLFDWbUWpyx9Fp0J3+Vw4dgqZwmEn G8MQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qdt+3ZWJ; 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-6b59e363cadsi98311486d6.12.2024.07.02.02.23.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:50 -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=qdt+3ZWJ; 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 1sOZip-0003TX-Ci; Tue, 02 Jul 2024 05:22:47 -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 1sOZil-0003B5-J9 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:43 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZij-0006Yl-F2 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:43 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42564a0d3ceso24429365e9.0 for ; Tue, 02 Jul 2024 02:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912159; x=1720516959; 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=fq0Hp2Una8Cq+xwhreR1xxCEuiahEpzKceutH3MuTZk=; b=qdt+3ZWJqTeRbVKd8w7QB40JOUqY74DrAxG+IkeApxtHylJaQEtIFRTE7jk4UZU9QJ y8HnzQRnw8rzPbuLEyQ3CBUpwgNayjK4MBEtYnuAFRuwqtzTnUpvrRzCvEV2naV7oQ2s o+uf5KHVFmagKSVaeTuWlQbIaDThUS8KM8UuSbbczhh8wBPtublHpOjwa8CjjHrxctHX BZEVDBGXl3XK9KVhMkH1PTHQ/u4H0COp2106FmqAz6ko9dQXcaWIFvMETt04mJ4nvZ9/ tfrVIDxkAO2jzCtpzXeyrx1hQchm4cGaAxVfTrt6sAm7LFE0Dcr5oER0wm0MC+yGH6ml FKZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912159; x=1720516959; 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=fq0Hp2Una8Cq+xwhreR1xxCEuiahEpzKceutH3MuTZk=; b=PKomb9TEompUIvxIA5lQPHI59X6GaAMHWFbY3AOxYMPJIvkHYZ1SxUuTNTw/A0HHCr mlWul0qbe+Uf3/oaHycd0Sdi9eG1WiklI3nHJ/hey744IKl0uCBlf43ZS00iwPGSP0nI LoDIq/Bvij1YTsZ9rHz2i7Qu8ACQC0vHvuwswb1Dp5G0VZFgFgfPBJkYvXKcpV8iiCmo s9FzYouyYAJhubmXNq66oqWZi1LhvC/z3wFcPi8pXlJI1CKQwTOjpbLBujDZno+6/jT1 I8XNOkv49gw2+oExMIRDjWdFTo0DTFv8o66dj3YiFtD755shwWeLG299atlezQyOvLY0 E2mA== X-Gm-Message-State: AOJu0YzpGD6CX34QivM5zFp/xwHk97N86gUxqNaNd67Q1qL2hMBcvZNs coqwijrbHlfmE9maam+ktaUp9A5B1BkFrIpoXSufzH51i8LLXg4FkkMsZa81tD9jFEjvzPSLEaM 6 X-Received: by 2002:a05:600c:1d21:b0:423:394:cd28 with SMTP id 5b1f17b1804b1-4257a04fe67mr53501255e9.25.1719912159574; Tue, 02 Jul 2024 02:22:39 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d8cd8sm12607603f8f.27.2024.07.02.02.22.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 18/67] hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17) Date: Tue, 2 Jul 2024 11:20:01 +0200 Message-ID: <20240702092051.45754-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-23-philmd@linaro.org> --- 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 43e0a2d925..8415c23e20 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1397,11 +1397,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; @@ -2137,6 +2134,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; @@ -2147,16 +2145,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 17: /* CMD17: READ_SINGLE_BLOCK */ - if (sd->data_offset == 0) { - sd_blk_read(sd, sd->data_start, io_len); - } - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= io_len) - sd->state = sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset == 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK", From patchwork Tue Jul 2 09:20:02 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: 809052 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116593wru; Tue, 2 Jul 2024 02:23:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXudZdBxFxuQU3phk4vCXpfLIOFkIPu8A5/2IN+NavjDb7UlHWqT2n2eOH7cR94iUrkLveQq4oN7rT0lqG50CNM X-Google-Smtp-Source: AGHT+IEfwnU4PGIiXfdQpv85CtTy9Vkgvqd/Rp1Dx85VwbjyVSqapodzKXa7EZ45/9B6g4S0oDFZ X-Received: by 2002:a05:620a:4441:b0:79d:654b:7611 with SMTP id af79cd13be357-79d7b9ee831mr1124563185a.12.1719912191363; Tue, 02 Jul 2024 02:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912191; cv=none; d=google.com; s=arc-20160816; b=ltx6zG9W9ZkQ0fWK6Q4H/pk1V+5fzBdDkOqeopC1MeG2qq2hVSycC4YXTu9hifQNfm je8nvzFBRFMZR7jbeMe6JExPBM4rhBUdZUBsJ6q8dtY+pQH1rJ48hBIPhok+J3SjrO11 c6gU8jv95f1uHmWF90aHsnoNijDvUL4iHHJNLLNmfpr8Ug5MntHlWp39NAhLH+llOe1U mt1DHsEJwujWXTLgHaELqbt1w/Ya3z7gM2QTf7wgcXaTE4klx6Hj3cwWUFhtFqEH+wuW IwCA3u8kz6vcarqVrjy1SmZRCkxxsdAs/tnF2OF074lHbG8bPlSWGXdqEQXD9+VjXEfd Eefg== 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=TBkJoq7dOcnQq6fmt+Em92zeZnpvlQPX8gCdahknyqk=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=M+Zd9MsBku9wVg6CdF0yp4PfGOXviczAIUbaA4A4YgkSx6V610BZYHQVdDR/ZXvAKG hQjiKuBLAyjlQDzn3TCFNxRhoY8/Yzt/MMViNcdE0LmZJGuPmFaeGRdufM1lulxm53K+ 9+j3t/2hhlOFnAmFG/x+yhI63G0VnEBInod5yM2Jvmt0LM2le0lQfvL+WG1rVQbEIUGt fZIFn6LSH9onY7YxtHUrKUeYUk5j0KhbTZ9SoVV9DN/VS0n7wbLK1/i7v4gdI7CVj/ib TVgQ/15p7gNmQhvNxFt2jZ7Zwqt0mXUmUqOi2UTNESSBq9heg3jJcifp1lBfIxHeiS2t qejw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kzuPDa3Z; 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-79d6933b10csi964129085a.641.2024.07.02.02.23.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kzuPDa3Z; 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 1sOZiw-000430-Ma; Tue, 02 Jul 2024 05:22: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 1sOZit-0003o1-B1 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:51 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZiq-0006ZT-Em for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:50 -0400 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2ebe785b234so40017701fa.1 for ; Tue, 02 Jul 2024 02:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912165; x=1720516965; 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=TBkJoq7dOcnQq6fmt+Em92zeZnpvlQPX8gCdahknyqk=; b=kzuPDa3Zz6pVKl94q0SKXxpKunVP0+WqlhrIoLJ0Z29jkWhu5XHUeouhb+sF2TDxSO Hj7HzHOsfPHd005v3l1F5Qsayc5Kh5Nx3Ss1RXneVdrtyS2/yeSiCNQAHVyX8dRFfMzL yVQ8nApTNnoWPUaTT0pATGKVAN3pTIbmCSoVyhOuPwWA6ed5ckp2nzWMNKPb0RvQnXUi HFme/vm0sYtthxSdBSovjEdS5WhIbfWcw/dkc6RFYVJxCXfcX7CHjb+ipSJXC6O9jZua KQQeOmzPZZeN72ADsNKlyBw+I5NeofBN1zaNfaDM+GjJXvoMBIIDM5KEl8locRF6OYvt A0mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912165; x=1720516965; 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=TBkJoq7dOcnQq6fmt+Em92zeZnpvlQPX8gCdahknyqk=; b=hCYsW/WBQBxCCZW6kVrDPaTPzTb/L/z4tGQj5BDEJKW6sSp6atoY5Ytkm9G7ZPwR9z 6N28oEbUQw3d9gyAopVihz1VslJbhR6aN92Cyf6oGKGaCu7a0r4qBtUpg9vTFuFQqGzw Vm1Icf6G1BrQgiLTDq7XfVB1hINm+U1SUCx4dOkl854qKhWjnpJEhJHFx7Cs4wtip2VX iB/XxK2lfcavJUm2C/pW5xpIqyO2oblVqg3lRyYJSMJfzrDMRqCqQvwphjrA3t2LmRq7 RaPaevYmynCzQLI+6LP3YPjVOKTx9T/n3eu0q+RtTmZ4vY3pkfE7YBqWadbT91G2F2nh hxpA== X-Gm-Message-State: AOJu0YxaSQpWnmjAr8cXcgmW2ys5YYefjFNCtwBiXnt4c8OjppM7ApFt JNp1sXfi8zBA8p/rKsUOd+O2Ib22/+CdAG2SGklUw61zhqsVFxPxvsYGUp9uiPXDeHLo8pvONUc 1 X-Received: by 2002:a2e:88d1:0:b0:2ec:53a9:2037 with SMTP id 38308e7fff4ca-2ee5e6f2bcdmr50533321fa.37.1719912165465; Tue, 02 Jul 2024 02:22:45 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367898c64c1sm989990f8f.23.2024.07.02.02.22.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 19/67] hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19) Date: Tue, 2 Jul 2024 11:20:02 +0200 Message-ID: <20240702092051.45754-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=philmd@linaro.org; helo=mail-lj1-x22c.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-24-philmd@linaro.org> --- 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 8415c23e20..940cbb0d3c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -564,6 +564,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]; @@ -1153,14 +1168,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 */ @@ -2093,20 +2103,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 */ @@ -2135,6 +2131,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; @@ -2169,13 +2166,6 @@ uint8_t sd_read_byte(SDState *sd) } break; - case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ - if (sd->data_offset >= SD_TUNING_BLOCK_SIZE - 1) { - sd->state = sd_transfer_state; - } - ret = sd_tuning_block_pattern[sd->data_offset++]; - break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ ret = sd->data[sd->data_offset ++]; From patchwork Tue Jul 2 09:20:03 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: 809090 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118106wru; Tue, 2 Jul 2024 02:28:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV2cx5Nr/JYXESfYZoMa2UAQ5ekzok4yrjry4qxCYICv2mOo7gRrGYXtCLc8bkXPW8mEprBQhU8jV8qXv5v3zTU X-Google-Smtp-Source: AGHT+IG9ixNHJNKPnn9NwY3aeVk+sR4eUSt5wRyj/TCAo+CP0cUrtv4oYqqEwUwujELxsjPMW8uy X-Received: by 2002:a05:6122:438b:b0:4ef:594a:a710 with SMTP id 71dfb90a1353d-4f2a56f28fdmr7820374e0c.14.1719912512684; Tue, 02 Jul 2024 02:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912512; cv=none; d=google.com; s=arc-20160816; b=RBRRr+FMPR8plbvLmtuk0ZK+Urd0z8Lr9zRLyGEVZlB8TRR54277aWmVEDdD/PosFh 4VWZtZz0RDpzMHIQOjzGepbFt/V4OZUdiaw99OtTmNTPkZltm2ZbUd5nAROF55Ez7+i4 EhSemxxltkJYi2pzQNv/CSFMYhVQ9V7gyg0v98gs1Y0GD9m/roQ2gkjMeNLnuzAY3FFN 5GMWVvmfb+7cRpBCLfI+edfdPqiAo1Qp7UBvJi6JFoIFeL09w5QwkBPJ3IBrnchf2EEH zDULS5Lvz8b7IZMlXNJeGD8LH9yr/c4DaB+6uQnP0NDGdDV2R7PwdDR8/7cMKr8ySrI7 J16w== 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=44A7uKnrLEqCTNEeUcpB4p2VqBTe04M5aS1mgYhUgXI=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=zl+W7f0fCPsEj0XASt195QTQJp3cgH0JCmUGDQnHJvpnJO6ZPX5rvyMmkUxgF+64a1 sg8wPC9arUr1jaJ03ICEST5dBYNE2rd4IGRYOE4CxHYLFc9dY9ZMYuFBJMXOOMtRxRpr xaTRfifSYfUFjUgWuiaK+WuZD5TzrB2cVxOzUZxuH5m9A3WC1xS4dl6l7LSX52h6/O+n EPVjlXGh1lwsdRV80tf/QpTLGYzW+cEJ/1wJUMjSmSSRZE5tpdindnoCkKtCZOd16AQz ilA9EJC1j5A7j9JH2wrSDvOXU/OEHK3Wm58o2Vknnyyan/Es/7qh79xe5X3jHbJ5mjks tRTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TOWH08fH; 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-79d6933a9dcsi970880385a.653.2024.07.02.02.28.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28:32 -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=TOWH08fH; 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 1sOZj0-0004Lh-A7; Tue, 02 Jul 2024 05:22:58 -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 1sOZix-00045t-6S for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:55 -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 1sOZiv-0006et-69 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:22:54 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-363826fbcdeso2295332f8f.0 for ; Tue, 02 Jul 2024 02:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912171; x=1720516971; 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=44A7uKnrLEqCTNEeUcpB4p2VqBTe04M5aS1mgYhUgXI=; b=TOWH08fHC0LdJrKRZvZkA47y2Ja1IxkA726rpX/BlKmADnFnHHOW6AZO31jtAt1OGJ +Pp1xqJE5T4hIFkcr9pssKeb/DiGcyTveHzlsJFaOlAszFbJQeLksPyI183vFqJVSA/I UjEF8Sl+RZYOpeO5iOvzDaJ8QTUXRf5ykVllsAAwIs8e5KcBcKgoFWLd/jtuLrWAaMRz /ZYgT9r7sQyluOk4fk0e5JVACR7qjCKHkG40dSh0dKISPtd2ZlgxAC0k3JOQP8tgvXLE WWy114AGiiOsSNF3Oacx+f22UhpfquF2KtVooI6o+V9caR5l0AkzAPB4jV2YNd14qBHQ vIvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912171; x=1720516971; 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=44A7uKnrLEqCTNEeUcpB4p2VqBTe04M5aS1mgYhUgXI=; b=HKGrQomGMtsRgcsiGEuZs1R0l8zAWDBYlCmaCXip3o9Bno3EcbkSHFlW+XTRpJMRs1 N6EzAbgOHXxDgN9Jti+x9R1kvSMzJQb0zD6tcRUzHWNdp5b9pIFMRqU9X0P49eFT2UVj pjhHFDSTTw8Lx3onPL3ACAA3EW1ml+klOx4UcgWU8fpCKnKQAMnR7Onj9ye33/Y4HXmb fCkMBfeb/QxhuHK7U23b8ZSTC+onGXpCz1Lh2TXgC1E0jqJy6dt11HG3ShflliOLHx9c haJvxTQrR5a/Tl0/1N9bB44q772h5b73HjUK0hDE/eIboFPPSXW/MCQQVdsiCrHLI33V 1Xxw== X-Gm-Message-State: AOJu0YxCBsGp4Pp2QqTZkTMDGv0b0oNsuQaJjKGoAdiQ0T1LhexHUzEQ hvlirHVFtMGzyyoGcSu8xjgCUHrUDG7DOI6ABsvcBqrelpaQDQxVDeA3bBpSO1PobuEZeee5XFS b X-Received: by 2002:a5d:5f91:0:b0:367:83e9:b4a5 with SMTP id ffacd0b85a97d-36783e9b614mr993638f8f.49.1719912171329; Tue, 02 Jul 2024 02:22:51 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a112e19sm12631308f8f.116.2024.07.02.02.22.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 20/67] hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30) Date: Tue, 2 Jul 2024 11:20:03 +0200 Message-ID: <20240702092051.45754-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-25-philmd@linaro.org> --- 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 940cbb0d3c..1d6bacf885 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1194,6 +1194,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. @@ -1547,12 +1548,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; @@ -2132,6 +2129,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; @@ -2173,13 +2171,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 30: /* CMD30: SEND_WRITE_PROT */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 4) - sd->state = sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret = sd->scr[sd->data_offset ++]; From patchwork Tue Jul 2 09:20:04 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: 809055 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116647wru; Tue, 2 Jul 2024 02:23:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV7XQVNAWx9jSszKlT/K74naPfA5JuyitDvsPK0AjycS9D2Y2wkh1NMuJkVYucpL6eO/QKg2X9fCWJ0/+8LqhPZ X-Google-Smtp-Source: AGHT+IH+Y1heCcXmVltsfp9eyGqT8ogsF/po8bg1jnNEGBlgMWRL63AgFnnWIOaXw9jJksePZYs4 X-Received: by 2002:a05:622a:11c9:b0:446:425a:e721 with SMTP id d75a77b69052e-44662d9e199mr104739701cf.15.1719912199468; Tue, 02 Jul 2024 02:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912199; cv=none; d=google.com; s=arc-20160816; b=sSUyUqUuOFvyGoPGbPj23a3sgaBL3OChgZ3f7ys/gFuX8uFi7hFcgMpW8x/iXV7PQj yLsPp2IDreGNxxUlA/ujYfCO9uV1/Rm6X38sx/VropbMDaSsZrSCdHmPqS92rxzCyj9e XQERPAwIgE14hdEEv6T8ADQWO0xKVOXv1eIoNTA1OQK0zohkJXNBmfvj+gym4qEDuzGu FtUTg8C7yAwnXAyFtfQ4MFsa6aaj4Y3avzY6HBKAEHbal/DW2sGzM52r1kFdIgh+q8xA BfjKbIrxs2C+9nOIvVHaZc3xyACALvGYEh9zsrt0klEAlTtoW14/uat+rVgiZM2qRLHk 1EcQ== 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=imXLEvTuUF3KqVtejnZ3cyv6qmJ2G3srjMrqU8EXbpg=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=m8FD3Bs3WBXE+zCmC9t5JCfRKu/xoF7vOtvuPb8HRQk5E8P3FQSgw1TUdpF82y01GD 31T6vGtGd5pwfnM8D/WYHv55Oo/DLISucrp+J1d0XlhmIcSkIKW5hz5IU5pQG7Is4q+4 bQDK524kjnCUl8m02Oh4GPOEH15y/9JtRN6mVjcGKtlLyuHDw8ZJxlDnUBEO2R1C8JCH paWnPXZF/DemNVJl5SRw3zPKIgeWNpvv3yzltrOLUATXdYJRB+No0vOeST2z5uIq/uA3 ZRSAoiend0U/H0i5hD7WRlzy+V0DwufyvGrg7RW4KUvqRbDXWxP6de+BJYvc2W2rEGGI StFA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZDQprPED; 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-446514c7f00si99093601cf.646.2024.07.02.02.23.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23: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=ZDQprPED; 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 1sOZj4-0004uE-Us; Tue, 02 Jul 2024 05:23:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZj3-0004hr-19 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:01 -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 1sOZj1-0006lc-6q for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:00 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42574064b16so24374425e9.2 for ; Tue, 02 Jul 2024 02:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912177; x=1720516977; 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=imXLEvTuUF3KqVtejnZ3cyv6qmJ2G3srjMrqU8EXbpg=; b=ZDQprPED1gDgkUIuGnn6mnkir1X20xYVHunxECPgqZ+7RbkJtirLZjWtD5hSnDtcqC odXC/kOnw0fpINPSWxRwz+sLwg1F+8mVpSvIDN2xEGi2VaxJw/pGFYpJ/327AN4V0VsG SvyomzWD6DbmWZsT2ggCntTOPLOLch4WugED9XkSXVG7EtYll4oVjy80IlrmwVbelXL2 d0VYGKbWIKAfvGAYFcEl8uptrZCDJQ4pZGRijb4p+oqdkaoCoExzDhxnC30MedfdVdZn pSXJIZjPk02Soex04PDEJ8MmGnL/GaNZx+LNVMjfTjzdWckAa1MPJSvjMlBIsZ2KJdql zJzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912177; x=1720516977; 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=imXLEvTuUF3KqVtejnZ3cyv6qmJ2G3srjMrqU8EXbpg=; b=e0I4eV4YgIASUlXTyaEjesY36qertH+uoeBj3dETrT/NAW0+adlrKk1EjVrT4SzbsU CZ/NW1PAvAkYBdNt28FWYBTbpw9Gu99neBwU+Ax0GMUBOhgpaqjp5YmmPUlUsl4PLdOq JhtbwhAfz7I7HJTTI83uSToslLV2fwhtJSOmBYM4ECouJRtlKEW+HwzOV0Mf5NcPi3jd 8waLVpH650wTYcMSqH6uOi0mHXKwWsDGnOQCGBu0yicDS9BmHbH5mmjzkAF/I0q1L14Z rb0dV2XRKcylZt9gXv4WobdPfMNyEKRSJsXAJvZ8Tko3vURLAqdlFprPNJnZ7e90pWSA 3T5A== X-Gm-Message-State: AOJu0YzwWsu3WslE8fXg+tNSaB/U2G+qdvRPOhjUpKMc0kM+KFHwXC5i cvqp5Kp29MerhGCIpDqbRJrlTni8/xqBQhvxdHS1v4e3kuezZIeJDqK0Kh9p+5tCphI0vR39sgk Q X-Received: by 2002:a5d:5f8e:0:b0:364:4b4e:9310 with SMTP id ffacd0b85a97d-367756a333amr7635174f8f.1.1719912177249; Tue, 02 Jul 2024 02:22:57 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10302fsm12588472f8f.93.2024.07.02.02.22.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:22:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 21/67] hw/sd/sdcard: Convert SD_STATUS to generic_read_byte (ACMD13) Date: Tue, 2 Jul 2024 11:20:04 +0200 Message-ID: <20240702092051.45754-22-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-27-philmd@linaro.org> --- 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 1d6bacf885..0a65bd5a76 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1693,10 +1693,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; @@ -2127,19 +2126,13 @@ 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 */ sd_generic_read_byte(sd, &ret); break; - case 13: /* ACMD13: SD_STATUS */ - ret = sd->sd_status[sd->data_offset ++]; - - if (sd->data_offset >= sizeof(sd->sd_status)) - sd->state = sd_transfer_state; - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ if (sd->data_offset == 0) { if (!address_in_range(sd, "READ_MULTIPLE_BLOCK", From patchwork Tue Jul 2 09:20:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809068 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117354wru; Tue, 2 Jul 2024 02:25:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWCElGW4GvollZv5mX5marYgsRZI4qPV92r7Gf/lV0hn7WHicSCvQFGjtFSuXFrlouqynz1hsLRENtf7cSnT6d7 X-Google-Smtp-Source: AGHT+IE0gdhtZ1Hv9VIz5BRDxhARDFt0zUkZ0VFlFZl/AhSEHZb57A/dz2ZsmDrdOTk6Ya/cko6F X-Received: by 2002:a05:620a:2954:b0:79d:7577:dd5b with SMTP id af79cd13be357-79d7ba85545mr1128543385a.51.1719912346899; Tue, 02 Jul 2024 02:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912346; cv=none; d=google.com; s=arc-20160816; b=O+EGIfoNM0VzOUOP5Ty+wa3DcsW0JqB7wogKDd1iUOwhA/KQSirbnu8SdsfRVtvtEz SaPSxIKkHIJCprfuXRy8qp7eSCmlI/YqIekZ1bCQFSgpOXb8LPkAlMFp6e6s9yn4ZiTp tSjdS14V8K9IH2BCcGr+/pXK75d4wG0wIBTdHTP9BRvg5A0lHUteRXf7V88sCz/s11SP 9brHj+N3ALm4YzSOf4IrvrgtspS5mAgdNbS8zNAXtCgaGjQoNbI4spG2+WkOI/+c0Fqb q1Adnpfv7XC2tyDTuuAvnmZq52qsMj51rH3d3sXSGiLim93n975Ej6MUVTpfcLlL4oxt idkA== 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=l/eRkmwGVDEETYZdTpz1AxWYEJ+R0hQ9lI4q9Qx8IeM=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=tyag6CTf4nS9piCwi4ZK97lSO1Cnkq5y+jy6Bgl24A0iZaToyyut8hXTiTBOpOTLTE /yEmn73z/ZGBquaoCNDrCYvgL5CyJu9HqnEUvgtF3CmJS8vH+kqaObXFCrf8hgzTG63P yGU9IbKyTgIi17aGVXKQRdrxX+rL0wiLKxgTRa1H3FRP5YvfJl/JK9ovd1Y2n+NiJfSD //l4TYNGB5FyX0Plhv4GzpoVW2WohduwS1yFEEI2Mz816hyvc3mYrdpt5eZzmISsasCj ropSfHKLEtGW8GfXmfyuptR+3aU+/uQRITU91Q9+PdkhQIXVySyUn6t0mToicTKL6xOQ 8LTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bujLOGO6; 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-79d6a1cacfdsi1030581785a.595.2024.07.02.02.25.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:25: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=bujLOGO6; 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 1sOZjC-0005uJ-PN; Tue, 02 Jul 2024 05:23:10 -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 1sOZjB-0005jZ-48 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:09 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZj7-0006lx-9u for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:08 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-424ad289949so28603775e9.2 for ; Tue, 02 Jul 2024 02:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912183; x=1720516983; 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=l/eRkmwGVDEETYZdTpz1AxWYEJ+R0hQ9lI4q9Qx8IeM=; b=bujLOGO6y3pOJon/NskHK0VJLzT29GButuLECZqVMX+ClFlDBMau/JS/2rHh2dNXtE Syrmqo9vMHp6XFOzCaQ5q1fKwWlvWFZHpHUIxFhWKwNUH+SuFdP8cSFwYoWba8B92zVZ N1UfBrHnDx/ebXR5hJNBGpRAKxMueSwa8B0dv00FqM/0AgUWB9sICZXAQXRLXRIq6bya Gh+a9y3MD0kv4UuDus3y1mn34NxheoLl/3tuPhMaAUyt22QJI4L0WeyGMhZldL2xWkVl lcrvpFacDB0/EUny50u3msOLSTOmXJIOw8msuB5WXjrB3wSN/76jA3ycQAxgxoD6TY8G RFSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912183; x=1720516983; 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=l/eRkmwGVDEETYZdTpz1AxWYEJ+R0hQ9lI4q9Qx8IeM=; b=AITvhuP6AG1MEpBdjb0rBohurLSAkgCQAXmd3sHt4mJmm6try/bI3ksn2xpiJxveMk xDpZvH85efCp82mNS1+b0MfGvkVW1+N5pXWhWo1+s/dyphSt+scsm1Stg1icMRM6/3NQ y3TCs9LOjzLbsqrmnzt9QsekBM7k1lhsVTHYCEzS/nMqd477xFufTMSMx8vVE8xjMHDv NjhTqCAxn02UpZOAZvLY3WsJQmvEuOnMTY9Bjgsrz8hOUiklNuS/dvvTzm+qf6p0RLmn NoxT9KvbofO9BXOJ5x1IW9OpQXVFsHQB0BNnlbabQcdktsghf/2RmtKGmfEQOXz6Zq58 MO5A== X-Gm-Message-State: AOJu0Yx9VJCZ0IkZuUzRErWm2mTEakE2Lvgrk/9Fje7y5XB+1hjYtVBu bwsPIe+0YmyDe201S/NfbG2zMt0HCpXVqaTNRPkOXkdmNCNeHg7bCt42272lAoFRXX2o8NH5CWO U X-Received: by 2002:a05:600c:3510:b0:422:384e:4365 with SMTP id 5b1f17b1804b1-42579fff40dmr53861195e9.2.1719912182993; Tue, 02 Jul 2024 02:23:02 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256aed237dsm191953365e9.0.2024.07.02.02.23.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 22/67] hw/sd/sdcard: Convert SEND_NUM_WR_BLOCKS to generic_read_byte (ACMD22) Date: Tue, 2 Jul 2024 11:20:05 +0200 Message-ID: <20240702092051.45754-23-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-28-philmd@linaro.org> --- 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 0a65bd5a76..5d5e55243e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1705,11 +1705,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; @@ -2129,6 +2127,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 */ sd_generic_read_byte(sd, &ret); break; @@ -2157,13 +2156,6 @@ uint8_t sd_read_byte(SDState *sd) } break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 4) - sd->state = sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret = sd->scr[sd->data_offset ++]; From patchwork Tue Jul 2 09:20:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809065 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116952wru; Tue, 2 Jul 2024 02:24:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU3wyrxuaWi1lwVLmPiaTr4DXb5j6LK5lOzpIl6QL5ZklYAn3Qn582jounY75Y6sruc9UhJXFKF/Kx90SDmVLRO X-Google-Smtp-Source: AGHT+IHRYOv38uWb+fPqfQrJBh/LH4VrVaNMSB9KQjKltqEInuPSymfiG7oSwYkFMsSpDSrwMgHf X-Received: by 2002:a05:620a:4593:b0:79d:6dd6:5a66 with SMTP id af79cd13be357-79d7b9f1dfcmr1239904285a.36.1719912263583; Tue, 02 Jul 2024 02:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912263; cv=none; d=google.com; s=arc-20160816; b=dxNU8mMUAqPOT/t9jDo9WbWyQnAo4tgukdnXYj0JAg0SmEpAhainm6qg0iCAaNeStI sElr3XNnlLUYCgxY45Eiu6cJpuESflW8Tz/EKl/9MFzW2aCkL6VgzP0OfdjbT1uELo9y cd5/B0gWnXCUOHT4KnajwQEtucwgOD4CUiduSt6Y1TWc0tK/JOiffX0n+qGrPj5fushU qZ7B9FMiuFQHwQ2fWi6rXN9PCNL/ZdO26dhh59a8sQnNJMr0/M0yCq3ERBV+DCdqjr4u Cgi9TGcQxhTLW4fgZIDofvNfGP1LQ+uGmdH/lC+yT/Xcv4Ti2oumsnjR5esNRGGxH2Oq rbhg== 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=yJKBBwll7Vgxqrd4++eiEl6JZS58Z0q7hVOL9pUOlIU=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=ni1DoTufeaFzexXcpGAEEzzpvd9cAa3ozZLdRkjnTN/zqeQBixVQyLr1xpIHupDQQa 48O/0154HCyrSsJksChUjP7uyYdOTcDD2bKR+h7PQ2LTKfJnfdF1UWzJ4crTkKQya5GS +bUT01PFRM3Oaav3HFl2jfDiYH3Gb6a5fXVb7wlzR9CoRB7c825RvaEd3aBDzRJkEFUq dpnosDUsPkcvxvYcYsmp+qBKOufz0ug3+2RBgbkoBU5PuGtZ0KyoDwo6CZ+T5kI/p1Bs sdqHfMi0vg5DHZOq5O8yaP7vN4JRQPrn0NYo39npPqjaYUT/gJTzqzKRx2GF1fcojA+z dIeA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bds0P/Dx"; 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-79d9162def7si277044285a.259.2024.07.02.02.24.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:24:23 -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="bds0P/Dx"; 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 1sOZjH-0006FA-0M; Tue, 02 Jul 2024 05:23:15 -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 1sOZjE-00063a-Fa for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:12 -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 1sOZjC-0006ts-Nw for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:12 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-366e70d0330so2485569f8f.1 for ; Tue, 02 Jul 2024 02:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912189; x=1720516989; 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=yJKBBwll7Vgxqrd4++eiEl6JZS58Z0q7hVOL9pUOlIU=; b=bds0P/DxaoBOQXoYi44gPC/luvruztHy4rjmSkX2QDtLtOFuc/Pxyopzh6Iz4oKk5g TUxlYahlfWb2vHCmiwnlpm3ONY3NDhj/1SVHfdevVJ9ah5Yk4fCXl3FtIOBogGgbpbIh xVJVIzD8+GG53ZwI5LIkAV+oLKkZ1nE9OPQuFwGT7/1wHbGQf3T1q+oEcpeuEUUKuSyz xAg6MAiTaNBMfutadkPXvb/jrzhP1eO0uNREJoe80It89PVFXVsiHljsavAdCdxsx42W D+Bp4X4MIMdHzjQk7eBPY9q1ESB55AK0B7rSyJy7qTFLcbrp6saQWnlXcqMxbKcz8ico oEOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912189; x=1720516989; 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=yJKBBwll7Vgxqrd4++eiEl6JZS58Z0q7hVOL9pUOlIU=; b=FxFDvwJ04fV4KOpk01+FhmpvkEbZ1teF5IcN5tZwIM487h/AI79PVWFn8zPBALtKjI p9K/mEGuBI9T7galS+vdeJJBO8op1SKBa7AiDmaMSePRTz+yTrEUqsJLSfY+MNmoFY26 IiDKPg3XPWNHnZhFJ+O6Wp1iQcNCY7Oehi4U1b8EDMuQi3SqFxong5sjMP1mwa5ZW40r FAxMP/WlbFA9vkB27NgJs2pwG7tHrbviukHPZgnKEyF2oo3I2x2j73wE143rw4an57jo zHYnz9z0/du6cr+XnuZWZ/csLypfkP+y1vbkWseAldE6B5vAWiG+KDSKOjxB4l4bKfbh Hymg== X-Gm-Message-State: AOJu0YxevGlqqiIWLFWPxqdZY8ma+cJ8A7SIYvfSHD4kyTt3DsFkuyAQ tj+xVpE0hx+iymDKHcorRprVA2LySsZpGTPOPltOrzxf17aaujr1q6AIcz98pAydXYjucKoEyFF N X-Received: by 2002:adf:f406:0:b0:365:b695:ef76 with SMTP id ffacd0b85a97d-367756c71eemr5364221f8f.36.1719912188782; Tue, 02 Jul 2024 02:23:08 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb9c1sm12717294f8f.74.2024.07.02.02.23.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 23/67] hw/sd/sdcard: Convert SEND_SCR to generic_read_byte (ACMD51) Date: Tue, 2 Jul 2024 11:20:06 +0200 Message-ID: <20240702092051.45754-24-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-29-philmd@linaro.org> --- 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 5d5e55243e..78aabb65ac 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1775,10 +1775,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; @@ -2129,6 +2126,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 */ sd_generic_read_byte(sd, &ret); break; @@ -2156,13 +2154,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; - case 56: /* CMD56: GEN_CMD */ if (sd->data_offset == 0) APP_READ_BLOCK(sd->data_start, sd->blk_len); From patchwork Tue Jul 2 09:20:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809058 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116742wru; Tue, 2 Jul 2024 02:23:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUzcaszP5Rg9u2rzEklrIJStD1XjxR3pDK80f1wZPUfusbtwoh8TRw57AruTDsgckjqtZgH1F7iHVvkP0xtV6hh X-Google-Smtp-Source: AGHT+IExi5quBYt/QfRNasMz599F6Bq3WPxR4RMnZB3q3K+8yjfgzSYjKHSMXq60Yebx0gCY6Mwe X-Received: by 2002:a05:620a:2911:b0:795:5842:2457 with SMTP id af79cd13be357-79d7b99e0acmr1278558385a.15.1719912224399; Tue, 02 Jul 2024 02:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912224; cv=none; d=google.com; s=arc-20160816; b=vdhHElroH3W0Z0bRJw3FyCLcr1KIsYqP/0Cf7fIhqoHJBeR1EDdYJlnWICbhaUB9CN HMh6gcr+1i/R277m6w4i4DMvoS/a5DWhJGuiscGVE5SN7c7xiaYcAue7xm05uliNlin9 qwAlRqKluOigLS8JMsg0lkzejpP1UDSwaYO3MGfWH8e59wUEvEMHq14Tqwbcw1diw/gp IN5M/CvvDyMmwag7Dmo1Q9zfRv38LSHVwJ0tYV4N+5nQb9G+E7mM193cT+5gL8adq/IZ bM+SpwA65sgiHQVHQXo4yvsP2HiPUmuarw2IKvjWOi09j18HHCZpAGJQOBp++pOOdCiA Z5zQ== 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=UBCC3n87rxfV/0t7pp/Ldl4A4zhR6I/rWoz/G7mokgI=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=y/7vw5TtNo353cCr0BrmDU0oFnRw4FI9HAv6hqf3/FYr3zCBQcozkOWtsc50DQbQb9 yIwuRSpXCiB3wffsymAqfYuEh5lEk6xQa6N/jk3j3b2jMJHeDNiuCTmNOhROrk1kQCHc OvMHXzeHgTkZgJBQBPBnnuXtEcH6TijzW/G28eX3UYP7N9H0SCdilWjpEEsAsOanfzjZ XALpGHNDo87L4gKr2bJJB2N9wRvyHVOdd5dILy1xRwfS8oMi3RS3XTXOm4IpWjav4f+k i8GBewWFPl/82hanqSftZSGZj9bBNipwRq0AUWeT078TEjpnnMI2J/DHg7+dIKssL7q7 jaTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X3Ot5K6+; 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-79d6c575933si885900585a.775.2024.07.02.02.23.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:23:44 -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=X3Ot5K6+; 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 1sOZjU-0006z0-Jb; Tue, 02 Jul 2024 05:23: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 1sOZjL-0006hy-La for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:21 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZjJ-0007Ay-2g for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:18 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2e72224c395so44436271fa.3 for ; Tue, 02 Jul 2024 02:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912195; x=1720516995; 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=UBCC3n87rxfV/0t7pp/Ldl4A4zhR6I/rWoz/G7mokgI=; b=X3Ot5K6+ZY2wcvUeGg/7qQACiyfhsUUhGDQpCbVhYtD78RMNQA0t+hbp+hTwtpwui8 kt0/xqD2JYORny57jgPfF/bYs0HnYFMUc7XHiganww9K5AbPbGseyRoaSjAe1IykHnly RzyL/Oxm74ipsnmHCcxyRixoj5L6jJ6g8TRduN5P4QV4pwSyPFFZVWXiCYalsUoxJzsP jh6ns/A53BoPvKNeX5I597ext0b5sBMaKxjUYU5F1VyYl2KuGYvHndMmp/4RLjvkZ37h oBk13b3oDN6fOCMLZ0KoPzfjXxwPJDv1JIJzRXtUGqrcFEC3NpHppAuiznTH2d0a5RCO AaAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912195; x=1720516995; 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=UBCC3n87rxfV/0t7pp/Ldl4A4zhR6I/rWoz/G7mokgI=; b=HXzLj3ghl2920necEOIJSH7X1da/zbaon+7G1o1L4VRmGr7OpdUqDZfEgjLYw7id5/ jgVoMhcbYsuWYc3+e06Md10KN1uGYBxtBIGDg4EQnjGGUiM1q+JCI+tIjrjkeQ9USJhe s0kbkBYRmtmYVHdA+FdPpKxYxRccQDt/iSF68PXt6vMzb9c1yU/M6x8uTJF3eIAwHcu+ 8+yyIiL1qtpZu/dn/ceYLA5iOWBmSlNOyonZ26ZkrrXJlRtqedonTT4NuAIyFOlSx4TG IIrNniaM9zPuCjroydxilUi0oQAQqHWDl2+kgvnUUGs6vRdMpMiTh/J015TfTy3uYdB1 cZUA== X-Gm-Message-State: AOJu0Yz1ClP9G3S+v32l5Lru34/l52NhyEbi4l8HUmKzj90TSliYLF/k 8a9ps/xsMBvbssLiEu4ddhFMo+ImCg1ik/tokJVZWzKEa5fnZUUOJ6zr2w5wYWCKWf2EeJv7q23 w X-Received: by 2002:a2e:99d8:0:b0:2ec:51e8:d8fe with SMTP id 38308e7fff4ca-2ee5e382b9emr53809631fa.31.1719912194894; Tue, 02 Jul 2024 02:23:14 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42577a0dda2sm83964945e9.0.2024.07.02.02.23.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 24/67] hw/sd/sdcard: Introduce sd_cmd_to_receivingdata / sd_generic_write_byte Date: Tue, 2 Jul 2024 11:20:07 +0200 Message-ID: <20240702092051.45754-25-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.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 All commands switching from TRANSFER state to (receiving)DATA do the same: receive stream of data from the DAT lines. Instead of duplicating the same code many times, introduce 2 helpers: - sd_cmd_to_receivingdata() on the I/O line setup the data to be received on the data[] buffer, - sd_generic_write_byte() on the DAT lines to push the data. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-30-philmd@linaro.org> --- hw/sd/sd.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 78aabb65ac..990f038b79 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1095,6 +1095,22 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +/* Configure fields for following sd_generic_write_byte() calls */ +__attribute__((unused)) +static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, + uint64_t start, size_t size) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->state = sd_receivingdata_state; + sd->data_start = start; + sd->data_offset = 0; + /* sd->data[] used as receive buffer */ + sd->data_size = size ?: sizeof(sd->data); + return sd_r1; +} + /* Configure fields for following sd_generic_read_byte() calls */ static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *sd, SDRequest req, uint64_t start, @@ -1943,6 +1959,19 @@ send_response: return rsplen; } +/* Return true if buffer is consumed. Configured by sd_cmd_to_receivingdata() */ +__attribute__((unused)) +static bool sd_generic_write_byte(SDState *sd, uint8_t value) +{ + sd->data[sd->data_offset] = value; + + if (++sd->data_offset >= sd->data_size) { + sd->state = sd_transfer_state; + return true; + } + return false; +} + /* Return true when buffer is consumed. Configured by sd_cmd_to_sendingdata() */ static bool sd_generic_read_byte(SDState *sd, uint8_t *value) { From patchwork Tue Jul 2 09:20:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809062 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116867wru; Tue, 2 Jul 2024 02:24:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX4/4nZ327/afkJNXDT7T9f/hx2gdXI+e7I/eKbp5fFyQh3bhIfbq52qOaxSXWOuF5N7aTwXswQwHybgVXH33Lt X-Google-Smtp-Source: AGHT+IES8ZorMk5QzORwXWwoEFzeZik86QkzobuhNcik1mYxPFH33AmiByXhj0kxqE/JoUFo47mS X-Received: by 2002:a05:6214:1d03:b0:6b5:7ee:1d79 with SMTP id 6a1803df08f44-6b5b70bd991mr106994626d6.26.1719912246470; Tue, 02 Jul 2024 02:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912246; cv=none; d=google.com; s=arc-20160816; b=Jfw5L/rMikoFeTaielrFLWIvvkqA4q9VICLWIzg80P+maENnvuSmERoh2HGtQD7HAB uANGvsV96eHQqjc5fH2rCXW30m8NPTQdUmh7JCASSz3TegvQTBdxFeHMINgsxHi3LEB4 XXN2+ladptUeHt/C/zVU3BmdnZukoH7DeJzNzNG31PuepXkAlOZBuqmR34YL2qfGFMPH oyZ6fz/OCo5WWxYOO2pSdJkbzEV+tt2S8GePKz5+eStt9zeNW51Nk3PaXF7IJv1R8sgY bQGUwUeIR340s5yU6swxIWWL1/rPBhyGE0g6aqJxVOFS/P1LuQVZLox6ZnAk3WcUQLrm 6BaA== 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=McRtxYBX9h21CzT63G2Ji6yPLnYuFaXK4qV2KzZz24Y=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=heKsVB0X79N8jhT0ilaao0o5Hp9fisgUnv/IVFAavhGotHHPj0T1SyJEgkr2h+S6kN DuaSyHw6DQPs10tT4Gr+56MD65vwGbcM45yUFd+SiUcSaNaUIxkijoUV+onsoNZYAbJk +Z3jdZfkiMp0t6tsomryjSMHwDCzPAAWgEzqzNpeRQFarhb+Cev84h2HL2J7ecn6HHmP H+40t+N0hauFrfyHItSxRQm4XCNnl8gm0b+TeR3TG/XxoreF3zEYBEHIlEaJHMnkYJJA +j161G/fT0hzPs8ROU0+XzFv2bp9/SbnMBir0PRNrIROgZeN2yR0qrxlSZs1dwe7IW4k JfFA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rWIhb1Gc; 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-6b59e5ad413si100281526d6.276.2024.07.02.02.24.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:24:06 -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=rWIhb1Gc; 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 1sOZjY-0007CT-UG; Tue, 02 Jul 2024 05:23:32 -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 1sOZjT-0006z2-Qt for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:28 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZjO-0007KA-FU for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:27 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4256788e13bso28540915e9.2 for ; Tue, 02 Jul 2024 02:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912201; x=1720517001; 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=McRtxYBX9h21CzT63G2Ji6yPLnYuFaXK4qV2KzZz24Y=; b=rWIhb1Gc5CcmEBdGvOx44czg/t2Ql88yyrz63LaRFmqzvJSwWizcVGyxXrojgd8ifX H/VryfpdbgKKgrqSDmS8i90114XfCIB/cmG1gBas41RJFd1qgkIBAtKeDrsTzBH48sYD JHt5PVS6f+RS5zqO2cksyMYXx3/guBRohtQtAjI0oxcRjoyteoHF++NRioivRP25Lj2z 28SvlasUs4Qy7sIYoH4J8/TQ2J2RuvM7ZhQEcNCOP0xWoV9BeK4vDd/61nUVvNfLU6p1 3bMRkJAiuUpGUa2mCBHhoAgDqVSNQxJqLsZ5WJYcD4c/TtNIrWKoqW4PaO6/danPLJ/O 8TKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912201; x=1720517001; 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=McRtxYBX9h21CzT63G2Ji6yPLnYuFaXK4qV2KzZz24Y=; b=EfgZaGqvO+T8QbZyWaoLZfjoQGNCnFQYsEn/THad5zMIT5+yhCw2Nz+FyRqrqTgJSP uZWihSAxgEA9wtyfMdz1TA6Pi9Ytd1s3c+wheMaDM+eLc1VZxUViiKjeU1rezo86sOb+ umSLDvR68kxPUQnwImggkwUgol0cP40h4qZ4w6EvqZj3VVHwF+Cz2T6LNgUxg0BwrPuK wmDVkbQ4zFdGXWPqDfuPhDnSmfuANyFarE0Lt4RMv2fbzzZZJkGjZ4i7MgC2ComqttrZ m3Tlywe+HKrpS/ms4FHlzZ5enTBcZRxsipXHey/O93xSFLfUCZU3Xki069CMEntZHrXq 3Npg== X-Gm-Message-State: AOJu0Yx2QDkq+tVITM2fQOFMNkEPRUfRQVMSoD5GPDf0jPYfZuE8Nynm VZRYdDH7lgO1A66Co7Km6N6ICuOp7UOg4KzS/40crDurhvoj04tOPrXFgl6h2XZAGFc6trDPilG S X-Received: by 2002:a05:600c:5125:b0:425:672a:7683 with SMTP id 5b1f17b1804b1-4257a08ded2mr45418635e9.41.1719912200855; Tue, 02 Jul 2024 02:23:20 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5b91bsm190911205e9.20.2024.07.02.02.23.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 25/67] hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_BLOCK cases Date: Tue, 2 Jul 2024 11:20:08 +0200 Message-ID: <20240702092051.45754-26-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to modify the WRITE_SINGLE_BLOCK case in the next commit, duplicate it first. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-31-philmd@linaro.org> --- hw/sd/sd.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 990f038b79..b1acddca45 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1453,6 +1453,35 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Block write commands (Class 4) */ case 24: /* CMD24: WRITE_SINGLE_BLOCK */ + addr = sd_req_get_address(sd, req); + switch (sd->state) { + case sd_transfer_state: + + if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, + sd->blk_len)) { + return sd_r1; + } + + sd->state = sd_receivingdata_state; + sd->data_start = addr; + sd->data_offset = 0; + + if (sd->size <= SDSC_MAX_CAPACITY) { + if (sd_wp_addr(sd, sd->data_start)) { + sd->card_status |= WP_VIOLATION; + } + } + if (sd->csd[14] & 0x30) { + sd->card_status |= WP_VIOLATION; + } + sd->blk_written = 0; + return sd_r1; + + default: + break; + } + break; + case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { From patchwork Tue Jul 2 09:20:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809064 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp116926wru; Tue, 2 Jul 2024 02:24:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXj4rzYHGMbPmcxXQUgAFlnrgBCMKGPR/e6LwEgRCNuKQYh9XAGCwrTxoBqRDrPKQ8V+vyaFAIgp1S3aQ3WhdRK X-Google-Smtp-Source: AGHT+IEfO2CzqdOxFoArKCrwW6t6yXRRVojheT9lvabgDap1s0fbsQZqmcSN0nqz5LYAkNLNFu/0 X-Received: by 2002:a05:6214:5190:b0:6b5:1a8:7e38 with SMTP id 6a1803df08f44-6b5b71c2a91mr94799636d6.51.1719912258522; Tue, 02 Jul 2024 02:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912258; cv=none; d=google.com; s=arc-20160816; b=lLZdbYPqHkFGCdyjAnvDQmwMs9PUjusUvSH077fTUCgqdwAVJB90BM5soWM8adynrd isG6wIBbtQ3aWio43GelJRtk/FtcEsZHMpktqr8OLODaKwpuuBBuSxm5ELbchRJ6Vs/D gkoLIKtBJ9HeLq9yxRNuPOQh/lx8YpE9eBU+yAVgwSNmTO9k6vJ5AWsu9PGbAVjLAcRb eFuR2X3inCQxCzg8m0d8X8FSQq5NyQRcf4Vo33YqVFspTeJDVWnu0KiyTz/x7stDNcsm JFTeB9Qper8tQVR2SV8NvSqpKINXLItgLa0dLLzoomPo92P9+BqnLdtGeL4U9WiwuPsp pnPA== 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=fsQ5dZXMOKylcaTkeNe5NCCv+ATRu3UFQ5w5tnxMhiA=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=wkURL8LldDnzNYqAHe7fH5uDriNT/W7gdXi9WCwmQYeWnPGLU7fU6ATOgJ8WvNOtwh kubbG+cykYZNz+WQWnTERm3O6cdheVdQqB28XfU3cGkeTiqer8WPqNBKDQwuwZOrVAEs XzRbotts8JPWU4M3JpqCNhiGpZZiGf3Fi2ucGu3ndwGjeYrpFAZxJ04f8dqUPc85L0Rk T7eRFXybJ2v/q/UIjItmm4VSCjhk+tLjQdUi6h+zWWL1xt3x/H76hws2MFW3oX2O8AeY Gw09io0PCGVHyYPIUk/Y+SGvqBbiVd8UuZuYmdutkw+EVWARluWO0mGEoB+ID9xvcMy/ XAdQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pMiPF/ah"; 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-6b59e5ee05dsi102405336d6.388.2024.07.02.02.24.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:24:18 -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="pMiPF/ah"; 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 1sOZja-0007kz-O6; Tue, 02 Jul 2024 05:23:34 -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 1sOZjX-0007Ci-Ki for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:32 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZjV-0007Kn-PO for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:31 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52cdf4bc083so5980015e87.2 for ; Tue, 02 Jul 2024 02:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912207; x=1720517007; 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=fsQ5dZXMOKylcaTkeNe5NCCv+ATRu3UFQ5w5tnxMhiA=; b=pMiPF/ahxDbSmw+Z3jn67XJyeK7Fb606Ql5Z5heggJSXaSgbSQ2CRpb7tVC6PTJK0L GHMTyqEy8nsSGHqbVSiEJsqXIn5U7JuY0WPeB47pFxBh6AgK96S+qhq1tdBwGeSnmkxV t895XzR5d3Q5db3tbXIeYydUTnMnkuTT8/zk8J4ISmcx86nVhmvmdhasubifzDIcCIzE +vF/rACjZ/8MYw6fD5IPQKRlHKx+shoH35/ZhlYxY9L2UBAw4SWoEbJsgiudv4M3cdDX 60LS8rH3jywCcp18PEdEr8nl9lOVjA0ip7/zp5XD507mEaTuEjAtFaf02so/5jphLxrg vuew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912207; x=1720517007; 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=fsQ5dZXMOKylcaTkeNe5NCCv+ATRu3UFQ5w5tnxMhiA=; b=K8bUvyXqV9olXZFMNF/BA9F9WTp3hKOD2JEan1YgShENtYxugR/PCgDcJAEM/6AjbB /U+WBHCsuxsrGdLWmQZEatUNp2Y91wqM55fVPdVaPnh61v+32vvMq6yuaJwcqnATTDvm KGzS5Vb9vtGigC4I8e70+T2FzPw2sZDPm91f4JkFR4iPuJKmiFInc4t6Siz9gAf8/9qp E+XFbI9TphGgpXvbwt87EPsqbcxywTF6lG/Mfo2zYaWYCM0UcdKF+1FF/G6Utlth6XQG qF/ekLopdZKBVWrmTVQwf0rfLfQxoeirJT7o4NOZbfagzYJ32v5fSrqOSJPfdvB3VZ79 Uaqg== X-Gm-Message-State: AOJu0Yxd13qEKDj6ROAGd7w70TJ1WwtlZUcYZYbFp2uND5BEbUOja5lr p2U/dFrUMS2VOLFe5Q+TBaTPtGGU3gNQaUE1Th1DW3hfxKay0YhP+VnKDRtMq2nEcergBb9ws+v W X-Received: by 2002:a05:6512:39cc:b0:52c:c8bc:74d4 with SMTP id 2adb3069b0e04-52e826f1554mr6105380e87.48.1719912206735; Tue, 02 Jul 2024 02:23:26 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd6d9sm12585862f8f.12.2024.07.02.02.23.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 26/67] hw/sd/sdcard: Convert WRITE_SINGLE_BLOCK to generic_write_byte (CMD24) Date: Tue, 2 Jul 2024 11:20:09 +0200 Message-ID: <20240702092051.45754-27-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=philmd@linaro.org; helo=mail-lf1-x12c.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-32-philmd@linaro.org> --- hw/sd/sd.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b1acddca45..349549f801 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1096,7 +1096,6 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) } /* Configure fields for following sd_generic_write_byte() calls */ -__attribute__((unused)) static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, uint64_t start, size_t size) { @@ -1462,10 +1461,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_r1; } - sd->state = sd_receivingdata_state; - sd->data_start = addr; - sd->data_offset = 0; - if (sd->size <= SDSC_MAX_CAPACITY) { if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |= WP_VIOLATION; @@ -1475,7 +1470,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) sd->card_status |= WP_VIOLATION; } sd->blk_written = 0; - return sd_r1; + return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); default: break; @@ -1989,7 +1984,6 @@ send_response: } /* Return true if buffer is consumed. Configured by sd_cmd_to_receivingdata() */ -__attribute__((unused)) static bool sd_generic_write_byte(SDState *sd, uint8_t value) { sd->data[sd->data_offset] = value; @@ -2035,8 +2029,7 @@ void sd_write_byte(SDState *sd, uint8_t value) sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sd->blk_len) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; sd_blk_write(sd, sd->data_start, sd->data_offset); From patchwork Tue Jul 2 09:20:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809072 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117492wru; Tue, 2 Jul 2024 02:26:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXSjSHv+7Et7vmBWUbQPWlH/0JvpTMgi6pIlzaxMOVZIhg6lk9zQWy5OEkwSGCYqk3yuoJk5PdzQgUZn0iNoItf X-Google-Smtp-Source: AGHT+IHNnzOdIDDyLC3Y/8jGfqYxaG136DNnwZ9uU9aDix54xFOapZiMIAA424Tx42VocTywtKyx X-Received: by 2002:a81:9e12:0:b0:644:2639:8645 with SMTP id 00721157ae682-64c71ec6529mr90964407b3.26.1719912376849; Tue, 02 Jul 2024 02:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912376; cv=none; d=google.com; s=arc-20160816; b=mIqfIbAcYRoAx/8G3JHjYuRjPudvZPU00tpVIvlKUTI9rrirTpE+bP8HZM2U8iGO2j Cv+a4oIxUbmOr3CbFYS4qllldc/cBKO5ncL3OI/m+F8L3NhESV7OZs6XWPhQRhdI+KpV BxX7vxKMxnultqGp1BZ/e+wXWtu6B6IXZFONJ+9Z+dEACg+4xeNpbW8hDWPWtHUnsMAF vJNTrm0JKQMzUWMVs9uombqvqVAJwS4vJP0M7PthXxvjB5Sq+sBSebiSuRRKZ1ySE3lr 8ll3wBSA9TRkK1JZ6XYHQjtLYdjKTFajkWXDudB7l1Ghvqs+fAw7TBxxzIPN+jw+Mq10 3YOg== 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=4VJOT5ZcN/EvCEADOgKfKYKQ9sQEErpJJZeG9rUrgf8=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=hoo8MmWu4uprPP+gqB5yisZWLW0zeLYYNr9Q/fQDcIG3wJzsGwNhE+YgkJI+R0y3s4 8gyZPlByRBRP5pDYiyf+UUpO2GslDpK0x+DG9/X7nRNkZFN/zYl6UIvu1Avvz60h0xAn sR+8RQ7rEMahW88lIKDquJcpM9tPqeXPZPSx9D0+WQ7B/8y52Cx9cU0RxQ6Co99lD+DW xL/MHfG3S4LVbt1t4pAs1cARyg9imfYv9hsGmRWXsr2H7jvU6dosD+qD9MAEDpHo3Eab mmAJkfUEne/FqxpFZZfDVXjOC9A7oPasdJYZBa7CC2++rAkmwsmP/Sjk7WSkKcqJxhA0 Uziw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pwCusik8; 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-44651485b36si98932601cf.283.2024.07.02.02.26.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:26: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=pwCusik8; 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 1sOZjh-0008WJ-R9; Tue, 02 Jul 2024 05:23:41 -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 1sOZjg-0008VC-9j for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:40 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZjc-0007V9-Jh for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:39 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a72459d8d6aso399480966b.0 for ; Tue, 02 Jul 2024 02:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912213; x=1720517013; 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=4VJOT5ZcN/EvCEADOgKfKYKQ9sQEErpJJZeG9rUrgf8=; b=pwCusik83OhK9oMd7E4pjMCRa79euDk5DZdx+8c89McIRwj0xXRZzJT226EFDoDL8r AFVAPiGdaicHliDvjIzeYZxqbNQNuXQjyE97omUthIu24zUHMoiiaZH85hhp4XWnEv3S 3tBLyYrakefdoN9b2gGcXrVCtxIFoIF5f5HmhPfqQASIUxnNaDKFfmCr4VTJQZvrntok OdNxyLraoWYMwU7Z9mJoaBeykd0NLELho8wxK+I1BYy27X8iC/Eg8McAcLrR2KvHaC5y nM2OYb6y5uox4Qg3nFpSzhYmYdF6DKIitiOSZVA8aEEswGoEdq3lnuVNkGDWy7ja2aQG fgDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912213; x=1720517013; 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=4VJOT5ZcN/EvCEADOgKfKYKQ9sQEErpJJZeG9rUrgf8=; b=IbNepXbiWoVpoSUVc5BCp/I+bkPPAx+co8FZoBLFPiDfNxc7sW/2GfOeNYYuKZQU1c YyiXa54o+G45hYnw0RurLZKtJLvep0udwmHvjOne4PNejQrDFwyJadReTMsqUo6XdzlM XOvlsJZdBaW1aV3uMrItdKYex/0ZdzJpRQugs5b818Zm2OszI/0NNIUPl9oU+hjw8GNU Lh1DrHCjvDoW+Weaoign1PiWqeH3MSA/3OQPkm9bHF2dISjFPjXaX6DAK2XEJnTQ73aT S7bQHgnUffWOHiVotsI1xcVa73PEz53X83MJWY0mjpnae6/iJc56hv5no4wgQE8yuK1C ZEYw== X-Gm-Message-State: AOJu0YwWZ1E0mTtdY7g/D/CbAz5TYkvtzqB1J/lXbIetpa9Lgk0/eaVb TTlBXvDQ0no+zz2P6C+rF5o64Qamb3ON8Fr5YOISnba/Y3JZ9OJkQqScwvT7rXB9E1BksEIy3hs z X-Received: by 2002:a17:906:db0b:b0:a6f:e819:da9c with SMTP id a640c23a62f3a-a751444dab8mr691427266b.43.1719912212642; Tue, 02 Jul 2024 02:23:32 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb9absm12668064f8f.80.2024.07.02.02.23.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 27/67] hw/sd/sdcard: Convert PROGRAM_CID to generic_write_byte (CMD26) Date: Tue, 2 Jul 2024 11:20:10 +0200 Message-ID: <20240702092051.45754-28-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=philmd@linaro.org; helo=mail-ej1-x632.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-33-philmd@linaro.org> --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 349549f801..0aead3c866 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1507,17 +1507,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 26: /* CMD26: PROGRAM_CID */ - switch (sd->state) { - case sd_transfer_state: - sd->state = sd_receivingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); case 27: /* CMD27: PROGRAM_CSD */ switch (sd->state) { @@ -2078,8 +2068,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 26: /* CMD26: PROGRAM_CID */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sizeof(sd->cid)) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; for (i = 0; i < sizeof(sd->cid); i ++) From patchwork Tue Jul 2 09:20:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809074 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117582wru; Tue, 2 Jul 2024 02:26:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX8PiAkAsp91P+Yd636Saz1Bc6NRKuv0RGsy7ZIRDONijOr6vzjoAy5nTEGtrZr/6VB87OtGOfL9YfCxDdv5xay X-Google-Smtp-Source: AGHT+IFYPayTHXECINz5twDzYxO0OnfPyLUQ4PHOGYYiIIT4U/whuIYVyTEP40k2mKji00uDE2jD X-Received: by 2002:a05:620a:4091:b0:79c:e3d:6789 with SMTP id af79cd13be357-79d7b9e12bemr1086381585a.32.1719912394726; Tue, 02 Jul 2024 02:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912394; cv=none; d=google.com; s=arc-20160816; b=qJF02bSOpV4Xn8UyPzX0lWkPoAO1UFmiVAcpdP2WBCl+YbTtsgV6FqsLrSFaAxum99 0EpQWWSAaCj+eWqV7R3b3E/mKSpObl9XEdJwuETLMP/ecEG5im8DgV8ytEj/BxuKgVsY wLqb968CWzKg2+ZJvBFRqYwt9BaCFWnHo6omgZ58M79kTxBngJaYGfojiLhmuhBJOMq0 3hYVJ+A/rrapNbcfycaawRw6qp7Ef1XFaPyxgxejwAR4ndUtDuQbeay/FajXG80adCTT E1pIgcUO1P6FMNgOWcgDEAz+IwMlk8ZDrrwwY9eNlHwDNcrJE0wPmo/Lot6h3J/rdI7f 8hyA== 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=mik6Y+wbs8Uum7pP9/BoqNxBZgA0hVPmMXZ5DOoxW5k=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=r55N/svZifM7EWklNj/Ue7+6hYegiE3n2L3MWZy/Zp/xJU6bQEWnXRQHxghJZdS6fl lR47lueYAJzdgRMXuy/iaR0TVg5xxMCz7z3e3bcWDbal6kuKx2iS8tbTkyC7GEuf+sDi xQZ9ww0w4khOwO8p/sVnzR6mpxkOjL0obRcclqRAkiKpPhx1t+5wGkrK070h3VL6HSIP m6EEfgAgBxjrcy7ubZsOvoFG1Emuc70MHORknYEsjr6HqK+XzeR6BNxRCrM8vtNR4oix XOnYfWP4LycljCPdHF402aKVJ1wlhh4BUs5CRJ8Vu2czjPHnpIU9P9vNZD3V5uk9wUQL 2j3A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hHUfnrRY; 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-79d692f048asi1100232785a.360.2024.07.02.02.26.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:26: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=hHUfnrRY; 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 1sOZjm-0000cS-Fg; Tue, 02 Jul 2024 05:23:46 -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 1sOZjk-0000QW-VP for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:44 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZji-0007co-5m for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:44 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2e72224c395so44440061fa.3 for ; Tue, 02 Jul 2024 02:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912219; x=1720517019; 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=mik6Y+wbs8Uum7pP9/BoqNxBZgA0hVPmMXZ5DOoxW5k=; b=hHUfnrRYcGc9Zk5mCxmVVIQ1PCK3k4xSlqNS+osuDEDQr1fBJDlfUVUZHWJHS8MYN7 d4AxiIrIM9B/CbfmYN5Oc2QVQswKEl1L+sewf+CxPBzgJG3TVG5SIXuZkIRbN85ARPfl RO+pUihxeiM4yVCNbZ76CxQq9xTmOHs7w20FlVC+s/iys4aVnujDIhVFlhzvTakPw+AU 99VHPdwsFGnptxkMV6ZlSa2dOv18CNUORO6HQd7G/QOcGM9bWiJoWLGpc2d4hEeGPI2X 4/HySL+ZShDsFT4a3Z+GkVfyzJlO+davYatOOTY3q23fjZPYZGej7MGiPtsH6oBiCsEC EvzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912219; x=1720517019; 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=mik6Y+wbs8Uum7pP9/BoqNxBZgA0hVPmMXZ5DOoxW5k=; b=T+A/ECna3NV6ysq6BVxPhOVAP2x2GXQ9U1DfSKm1xmlnit9bE22sCOqdabsaZTr1pg d471Cq5l43BnVSfRM3UwFO4KtYpu0sLCn4EtanX7kixMGwsPZ3ekERUA41q0H0+vQzNt vA/htla7Ic6wlSGc80+1tKDQQo884ihJk320daSSS0P//kSnMUBgxrM3KniuMDdd20CA gYl64wV/EzPvh+Ha2lUQlyaCDdh9box65i3hEO4Pvr9BMXrzAcXvTm4zpDdxcn8BPecn 7W9QD2VPIdz9+IimSnYYWEtMGqDVLvLiS+pX07JKfxQ05HZ47vV+lskFZ5MmzBtHUvWZ O3SQ== X-Gm-Message-State: AOJu0Yxr2FATWStyWCWaAHIkha5h//C09bE1Q8bgE2AMyNANYwVcdqMC e7IQ17zf/LAfAcb7CAuZFHx1BLH5bm0IVqSKKePJ2LkUtljmJ2PzPQZoQjgg8z/mYVhCoSMTpbG K X-Received: by 2002:a2e:b704:0:b0:2ec:5128:1850 with SMTP id 38308e7fff4ca-2ee5e35452dmr49945211fa.13.1719912219530; Tue, 02 Jul 2024 02:23:39 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b061095sm180545945e9.23.2024.07.02.02.23.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 28/67] hw/sd/sdcard: Convert PROGRAM_CSD to generic_write_byte (CMD27) Date: Tue, 2 Jul 2024 11:20:11 +0200 Message-ID: <20240702092051.45754-29-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=philmd@linaro.org; helo=mail-lj1-x22a.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-34-philmd@linaro.org> --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0aead3c866..95ba4d0755 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1510,17 +1510,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); case 27: /* CMD27: PROGRAM_CSD */ - switch (sd->state) { - case sd_transfer_state: - sd->state = sd_receivingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); /* Write protection (Class 6) */ case 28: /* CMD28: SET_WRITE_PROT */ @@ -2086,8 +2076,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 27: /* CMD27: PROGRAM_CSD */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sizeof(sd->csd)) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; for (i = 0; i < sizeof(sd->csd); i ++) From patchwork Tue Jul 2 09:20:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809110 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp119086wru; Tue, 2 Jul 2024 02:32:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXYdfPG0L6tC2bg+GdALD6vPN0Gzlb8MxiEVJPqoDyY6Ohax7Hn6x6us/2DV8YZInWHqeIgd+yU9QTUJjbDy07Y X-Google-Smtp-Source: AGHT+IGb2kRRJNVxgMpxmtm0ZG+3EUTQlCIIf+q34XVNnBtNSAq10kE8ACj93vrkVnVRF1SpIqDz X-Received: by 2002:a05:6000:b83:b0:361:fd04:95ed with SMTP id ffacd0b85a97d-367756b75f2mr5610370f8f.15.1719912715443; Tue, 02 Jul 2024 02:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912715; cv=none; d=google.com; s=arc-20160816; b=RctPyAysBGfML0ukxnjiEW1AOXgh1Mj3Lg1vXvbiekkQ4OJc/m1aGm8w4O10u+jECz uVjgKomK3WP9Ts7ydJTAAODzAzWZFQuhTu0uQGMxL/Jrb+94YADTEKnFCuvhNq3E4tzX 3EDhXMwY6E8X2vU1JMBQJKrPg07xhtBnK19qnGJ/5n1Ot2OvF1br4ekTc+JfrbllIEmG uwO+qyLd9SwgGwxA/4iJNgLUO+pwN41cJ17kBFo5JNTv7hm9Y03zAEROulRQ3zOkvWbz llhZ+Q0KyZXLRmw5nXWy5PjGeLFOawWZQWQKYWnPWubQLkErccOc0XPFJWrNA4Un1K5H BuhQ== 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=upGfqqV5De+YauigIoBYXsU7px/Lanfz6QB2Qs40bCc=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=Ilqy+7ZPKA93dVQxnUDrSuNNYT20XJe1Qjg8f23sOKVMLIPlr02/hl0tYPww6N4xGR YjK4km+83fbai0WYBcLQvdsV+PH0ZVOTdoqJctiGF9qff+qnqYKY+u/nRU3pdnHmQY4v 4rpQX/vluyC1Ib4lVkgN0nfkHY6ho1Al2WApy5WB4hHNa7nby1AgDpm++Deh6dl7Gnvz LHD66+Tp4EbwOXjs5x619DLBq3P93JUSz3e9kfIcvDrXeQO0yyiVH0mIwMP9kgvz5D4k cXh3bPuH4qjKRmhKUQcdq+CZeGMUnrED69nmCQ0CwCBULVj7iZ9ViYyHVisw8hD0Kr24 uH6A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FD8wuC3P; 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 ffacd0b85a97d-3675a0f9250si5370654f8f.517.2024.07.02.02.31.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FD8wuC3P; 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 1sOZjs-00013j-C2; Tue, 02 Jul 2024 05:23:52 -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 1sOZjq-0000vL-G3 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:50 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZjo-0007xT-Hq for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:50 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52e743307a2so4454871e87.0 for ; Tue, 02 Jul 2024 02:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912225; x=1720517025; 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=upGfqqV5De+YauigIoBYXsU7px/Lanfz6QB2Qs40bCc=; b=FD8wuC3PgyqwYOpMrO7zBmWMq7Qj5E5N7+CPiKGpTve5v81oy5Uuk7JdudYW7q8AkA wxrtEBCVIUu246+Ab4tkvG7Si+UnN+1apL8BUkdMGUx2wTA+hLqTEkuqyIb8OiYuQQa/ apq0dWwJ4v6UsILtmRQ4l65/eRA+yIF2nXTw5XkXFAEsxOWbEHE7X8rAvWmb4vdkiteU KnYOFQhH8MrFGMT/pxHRGFRRI4hbfoPhdvG+N2w39VHv3PPt/Ww7zZUXpyUShTqCaeQL 3rg21QkwnyPh39LER7ZsrUOtgxvDpLD4TQxIhbT+AUf7icnD+a1+sfwrOiN5eBaDF2jb evdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912225; x=1720517025; 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=upGfqqV5De+YauigIoBYXsU7px/Lanfz6QB2Qs40bCc=; b=xAqos0YVF5sxmLX8h/l8Ng+A0bAn5iTlviptE0bDXZkcg59eadsgVluQheLQHHONtj sKYB5YulfK3VgDDCDezgTXjZBnCQtXP+sdoeN/5nfzr6a3yX7m1/4m99a8P6MkaXGO1b K7VtPBi3CW10mRZzVNe2quf1a0Kbjkcgg/qePgD8QFvaafHtRilKDkN3+xa7BkrS7kJA gwKeBjfUl/JqiPKjPGAQYRuJ0XqmeKDITwRydzlbDBeip0PSUOa75v0QWGuxkTsu11WG lW8+weKYtLscjhsN9yR33eNAu8arBfaawT/OC+6moAX6XAFwEdzEelf50K4HYTAZ//2C VKfg== X-Gm-Message-State: AOJu0YwxeRQ3KUMyg22WQyRy1rrwfH9N4bu0O451YPb8iTCRDOcvLCEx +YjsGsomaJ4Gbo6RVPKVXF18WYahbOpm7RIJ2L4r5hA4P0YiS3GLlLg6lHX+hr+uMbc2Z71F026 q X-Received: by 2002:a05:6512:3d86:b0:52c:e086:7953 with SMTP id 2adb3069b0e04-52e8264df6amr6388329e87.4.1719912225359; Tue, 02 Jul 2024 02:23:45 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257fc934b2sm93124925e9.44.2024.07.02.02.23.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 29/67] hw/sd/sdcard: Convert LOCK_UNLOCK to generic_write_byte (CMD42) Date: Tue, 2 Jul 2024 11:20:12 +0200 Message-ID: <20240702092051.45754-30-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=philmd@linaro.org; helo=mail-lf1-x132.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-35-philmd@linaro.org> --- hw/sd/sd.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 95ba4d0755..822debb28b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1620,17 +1620,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) /* Lock card commands (Class 7) */ case 42: /* CMD42: LOCK_UNLOCK */ - switch (sd->state) { - case sd_transfer_state: - sd->state = sd_receivingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, 0); /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ @@ -2099,8 +2089,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 42: /* CMD42: LOCK_UNLOCK */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sd->blk_len) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; sd_lock_command(sd); From patchwork Tue Jul 2 09:20:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809079 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117777wru; Tue, 2 Jul 2024 02:27:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXowprvzm8PEkWOgKUrzEcRnyZiSRE3uuRgeIoCnN9SYIGRIeG/+A2ALHNCQwyKCLA54E80LemdaP/irhhPAjkD X-Google-Smtp-Source: AGHT+IFIho4IubWsVVIx8jZCgxAaB489bFeUceywGqJG7Q0qCqhhuJw6QA2NX3P9VnWd8FJ79VlZ X-Received: by 2002:a05:620a:20dc:b0:79d:58fe:48ca with SMTP id af79cd13be357-79d7b97b1eamr973003485a.13.1719912433803; Tue, 02 Jul 2024 02:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912433; cv=none; d=google.com; s=arc-20160816; b=HSOrlkPWueOz5PtYiC20n2iPtQtcaS6Lr6an3KBLPy43N10ZdBgCyEbFNPQ42vbKKL MRL9KMtYEwAoAJ6o2V4xmClzUyCdq0jZ+7zE1bKKteo7XrS+oLQPj26fG8/8yUr6JY4P pJL8Y9M306FEJ8rOCJI9oivQRes58jcnbHVkreGU60N0C5m5VsOzLcCQPZoyr4j259S+ sQ72N8g9MOMO8AYcby1KdFWh/qLU+HTic76064wLXD4A+6tUPoWkw3skEdjGDJMzKsNj vxrg8yPAxxd41nAF7rwsJa2LmALy1opxP6pdylTEhmYgh3JkKlF5ShamRoaytL+YR0lB vIHg== 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=w91m07KsBglNi/fQY95FCrDPhq7oOjLmVtnvRjzEoPE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=LT/4uZFDdCfCx2/mPwstauPINjZ/1WCGn6F4MmiGQXIe3Vb8MJtLSw9NGb+OAZMYzX VlrwkU6j1Xm3RInlWe+OjiKXWPTRABCni9z9WSVp5d3v6lqwf8VACvO3bnAnRLFhMPHN iJtef4DJGfv0nquRmmAOVcCvjcEwSEQHMi+ITPu0IRmdONS5klX4vIZrshp6KJERCCk2 afc1hJ79s2q1Njxk5c4sO9PKNm+j8ZX90fFymLSTOQ0qScRJFuVrkgoiHbt+Wpae5NPZ gWOfy2acm7kcAdEpo2Tx52ELHRgZHzqVFlsD73B4Gei1sch17yWRKDigjDZbNjO1Mugn C+Cg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=imieRV1j; 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-79d692f0579si948222685a.319.2024.07.02.02.27.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:27:13 -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=imieRV1j; 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 1sOZjz-00025P-2s; Tue, 02 Jul 2024 05:23:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZjx-0001mI-5x for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:57 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZju-0007yC-QX for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:23:56 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52cf4ca8904so6414717e87.3 for ; Tue, 02 Jul 2024 02:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912232; x=1720517032; 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=w91m07KsBglNi/fQY95FCrDPhq7oOjLmVtnvRjzEoPE=; b=imieRV1jbrifcJYN2OU7wXBnZoFuboPb3i3P9TyQ5IbIuBwl8AASMTpFuiCzqGjYlf Z/Auuso9OlOBh4bmKCMkAkFpO3Grhuhoj4NoTXUfJAG4FN9sTezw7TJETQLzo54llij+ LrY581NTOoM85F7jsr9op7CM3+FzqKVdvkANZjJh8Wbhi2EISCtwQZqpOEiRjEZI2Z9g c60tvnAx+PqCiZD8L2XxwoosEFmt28aVD5RCxciBVwxhjkGuxUBJTc0xqheNBu79EUs1 EnBUJWswI/j5D/uV4aOuMSs8Jbxj1gV/nQFYH8LC3HDqUQRG6QQQ2jRvTRJaXkyltLki Q8lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912232; x=1720517032; 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=w91m07KsBglNi/fQY95FCrDPhq7oOjLmVtnvRjzEoPE=; b=uPFNTtVOD45iNrTMBz/TbMhYr7Zi2ktfZJOF8F1RbLyRh6cYm4m1Fy05jEYz74PKhe 2G4Oc5XdGjbH6OQ13OBlEid46aLeq3tZFC1w0xbVyh4Nt1nZwAd3PtqnuLN9i0sgNk/o RQX+OEBAmtCKUFPo6vSDV3fgyyu8Sq9y7ZkFvI8du94CyY1FftD/jLg4w2e1oCjCSv2X yvBdDfoKJS5ess1Y2T9LWXpDvVwgvvKVb4BSDywik5q1JX4bEEMTH6JaLi6qWmJOjpPb XddNFb00S86E7nRCr6Yh5tEAd/M5cvA4xhxB8KEaolq7at+CrML12ybQz8gFKfDgxH1e sRdA== X-Gm-Message-State: AOJu0YzxdByayqqdoZ0uYvq4cj9xz1IR96cxyUGMrdinB0pgnWLYpdNf I53k3ETfYxXv6Zk0X7P2YGuONUkyIixbSGeRKI6m7VrU080MWyp82h2f/lOrwErrOxWO/fS7aHm U X-Received: by 2002:a05:6512:3409:b0:52d:6673:11da with SMTP id 2adb3069b0e04-52e8273e68amr5309527e87.57.1719912231098; Tue, 02 Jul 2024 02:23:51 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257c4e1112sm117583805e9.3.2024.07.02.02.23.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 30/67] hw/sd/sdcard: Move sd_[a]cmd_name() methods to sd.c Date: Tue, 2 Jul 2024 11:20:13 +0200 Message-ID: <20240702092051.45754-31-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=philmd@linaro.org; helo=mail-lf1-x136.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 Merge sdmmc-internal.c into sd.c by moving sd_cmd_name() and sd_acmd_name() and updating meson.build. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-37-philmd@linaro.org> --- hw/sd/sdmmc-internal.h | 26 --------------- hw/sd/sd.c | 62 ++++++++++++++++++++++++++++++++++++ hw/sd/sdmmc-internal.c | 72 ------------------------------------------ hw/sd/meson.build | 2 +- 4 files changed, 63 insertions(+), 99 deletions(-) delete mode 100644 hw/sd/sdmmc-internal.c diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index 936c75cace..cc0b69e834 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -119,30 +119,4 @@ #define EXT_CSD_PART_CONFIG_EN_BOOT0 (0x1 << 3) #define EXT_CSD_PART_CONFIG_EN_USER (0x7 << 3) -#define SDMMC_CMD_MAX 64 - -/** - * sd_cmd_name: - * @cmd: A SD "normal" command, up to SDMMC_CMD_MAX. - * - * Returns a human-readable name describing the command. - * The return value is always a static string which does not need - * to be freed after use. - * - * Returns: The command name of @cmd or "UNKNOWN_CMD". - */ -const char *sd_cmd_name(uint8_t cmd); - -/** - * sd_acmd_name: - * @cmd: A SD "Application-Specific" command, up to SDMMC_CMD_MAX. - * - * Returns a human-readable name describing the application command. - * The return value is always a static string which does not need - * to be freed after use. - * - * Returns: The application command name of @cmd or "UNKNOWN_ACMD". - */ -const char *sd_acmd_name(uint8_t cmd); - #endif diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 822debb28b..90bb47ad26 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -87,6 +87,8 @@ enum SDCardStates { sd_disconnect_state = 8, }; +#define SDMMC_CMD_MAX 64 + typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { @@ -228,6 +230,66 @@ static const char *sd_response_name(sd_rsp_type_t rsp) return response_name[rsp]; } +static const char *sd_cmd_name(uint8_t cmd) +{ + static const char *cmd_abbrev[SDMMC_CMD_MAX] = { + [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", + [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR", + [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", + [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", + [8] = "SEND_IF_COND", [9] = "SEND_CSD", + [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH", + [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", + [15] = "GO_INACTIVE_STATE", + [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", + [18] = "READ_MULTIPLE_BLOCK", [19] = "SEND_TUNING_BLOCK", + [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec", + [23] = "SET_BLOCK_COUNT", + [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", + [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", + [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", + [30] = "SEND_WRITE_PROT", + [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", + [34] = "SW_FUNC_RSVD", [35] = "SW_FUNC_RSVD", + [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD", + [38] = "ERASE", + [40] = "DPS_spec", + [42] = "LOCK_UNLOCK", [43] = "Q_MANAGEMENT", + [44] = "Q_TASK_INFO_A", [45] = "Q_TASK_INFO_B", + [46] = "Q_RD_TASK", [47] = "Q_WR_TASK", + [48] = "READ_EXTR_SINGLE", [49] = "WRITE_EXTR_SINGLE", + [50] = "SW_FUNC_RSVD", + [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED", + [54] = "SDIO_RSVD", [55] = "APP_CMD", + [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", + [58] = "READ_EXTR_MULTI", [59] = "WRITE_EXTR_MULTI", + [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", + [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", + }; + return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; +} + +static const char *sd_acmd_name(uint8_t cmd) +{ + static const char *acmd_abbrev[SDMMC_CMD_MAX] = { + [6] = "SET_BUS_WIDTH", + [13] = "SD_STATUS", + [14] = "DPS_spec", [15] = "DPS_spec", + [16] = "DPS_spec", + [18] = "SECU_spec", + [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", + [41] = "SD_SEND_OP_COND", + [42] = "SET_CLR_CARD_DETECT", + [51] = "SEND_SCR", + [52] = "SECU_spec", [53] = "SECU_spec", + [54] = "SECU_spec", + [56] = "SECU_spec", [57] = "SECU_spec", + [58] = "SECU_spec", [59] = "SECU_spec", + }; + + return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; +} + static uint8_t sd_get_dat_lines(SDState *sd) { return sd->enable ? sd->dat_lines : 0; diff --git a/hw/sd/sdmmc-internal.c b/hw/sd/sdmmc-internal.c deleted file mode 100644 index c1d5508ae6..0000000000 --- a/hw/sd/sdmmc-internal.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SD/MMC cards common helpers - * - * Copyright (c) 2018 Philippe Mathieu-Daudé - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "qemu/osdep.h" -#include "sdmmc-internal.h" - -const char *sd_cmd_name(uint8_t cmd) -{ - static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", - [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR", - [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", - [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", - [8] = "SEND_IF_COND", [9] = "SEND_CSD", - [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH", - [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", - [15] = "GO_INACTIVE_STATE", - [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", - [18] = "READ_MULTIPLE_BLOCK", [19] = "SEND_TUNING_BLOCK", - [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec", - [23] = "SET_BLOCK_COUNT", - [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", - [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", - [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", - [30] = "SEND_WRITE_PROT", - [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", - [34] = "SW_FUNC_RSVD", [35] = "SW_FUNC_RSVD", - [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD", - [38] = "ERASE", - [40] = "DPS_spec", - [42] = "LOCK_UNLOCK", [43] = "Q_MANAGEMENT", - [44] = "Q_TASK_INFO_A", [45] = "Q_TASK_INFO_B", - [46] = "Q_RD_TASK", [47] = "Q_WR_TASK", - [48] = "READ_EXTR_SINGLE", [49] = "WRITE_EXTR_SINGLE", - [50] = "SW_FUNC_RSVD", - [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED", - [54] = "SDIO_RSVD", [55] = "APP_CMD", - [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", - [58] = "READ_EXTR_MULTI", [59] = "WRITE_EXTR_MULTI", - [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", - [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", - }; - return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; -} - -const char *sd_acmd_name(uint8_t cmd) -{ - static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [6] = "SET_BUS_WIDTH", - [13] = "SD_STATUS", - [14] = "DPS_spec", [15] = "DPS_spec", - [16] = "DPS_spec", - [18] = "SECU_spec", - [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", - [41] = "SD_SEND_OP_COND", - [42] = "SET_CLR_CARD_DETECT", - [51] = "SEND_SCR", - [52] = "SECU_spec", [53] = "SECU_spec", - [54] = "SECU_spec", - [56] = "SECU_spec", [57] = "SECU_spec", - [58] = "SECU_spec", [59] = "SECU_spec", - }; - - return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; -} diff --git a/hw/sd/meson.build b/hw/sd/meson.build index abfac9e461..bbb75af0c9 100644 --- a/hw/sd/meson.build +++ b/hw/sd/meson.build @@ -1,5 +1,5 @@ system_ss.add(when: 'CONFIG_PL181', if_true: files('pl181.c')) -system_ss.add(when: 'CONFIG_SD', if_true: files('sd.c', 'core.c', 'sdmmc-internal.c')) +system_ss.add(when: 'CONFIG_SD', if_true: files('sd.c', 'core.c')) system_ss.add(when: 'CONFIG_SDHCI', if_true: files('sdhci.c')) system_ss.add(when: 'CONFIG_SDHCI_PCI', if_true: files('sdhci-pci.c')) system_ss.add(when: 'CONFIG_SSI_SD', if_true: files('ssi-sd.c')) From patchwork Tue Jul 2 09:20:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809085 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118024wru; Tue, 2 Jul 2024 02:28:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6bFMPMRAsQc3OHOBpdXvsyDZ1+yIWpaaeL9Z4cCP7Wwo9edlqEinn0oJlUik/AGs6h6NJqHBiTL1QJsU8FLok X-Google-Smtp-Source: AGHT+IHoL78eoNI/kpVhUx1uIZjeY62JSVDObKT3yMLlH6KtSpEJJfYqRNw0Ra0/jlv6RFcRUoWJ X-Received: by 2002:a05:622a:1a18:b0:446:4c0f:ef03 with SMTP id d75a77b69052e-44662d938f7mr104995831cf.10.1719912492302; Tue, 02 Jul 2024 02:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912492; cv=none; d=google.com; s=arc-20160816; b=BoDk7J717/dva9ZPcbHEEoYwafqI/nyy947eXxWLOpmOythws7r2gNbRTy2VlLEeYM 0032TowZHq9SdU6tGQgL8wsZpuuTnLsuySdSvgyJZU4b0E64lvIRNDYqwYPRn2yw3Ykx tZpaZz2/XLvjNB7W/TpdU2s6AS83euyeO3TNGH9qbC+Ag5Njuhh0yeIytXi2LnGiWNrv IxLX4riillpMZ3YjfL6oPgw8emmfyrQKQlGvYKU71LzcaWfzxe5FgI/90DmBe3Xr0ChL tHHfTXKgCNamU8l8WupAbAELsRH4aJ33YJHCDBBNP37+BJFjg4f/NPBSyndfk5oa2My4 +15g== 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=MEAedVXIwS3IcpAZnKMoyPFq95SaykgChyIuzbCP5sU=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=ejNEy9VYjuKTXxtZIj8+If8yXM3ByySWksl3lo9xpiN2n/F8zQqvScu+1WTrHyL5yg YwN2Iv5q+1Xzs37J+1WHqsdnLdZ9jVMh0/dI8xcIqWne7MWONn4P4nLjvQn/Z6wNe1ta tevwE3ZBunNR9JEgcTXYjuZ5kTV5+fzCPX6GCWlVcLEZSVH3stwEXoWHfGTWO4Wc22h3 KJKkpF4eVhHYdh2vctgHKmInG/sFkqi4jVxNSJUtUZ9NzlGLMgr7YD3gSVY4HjeP71lt JV0BSfymhATrij0QiqvI8H9j9t5jMw80VLt4HI9L5fzht/LFZa3T1eFBd4+aBGcwHC+w lZPA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mFfZmIcR; 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-446514e62dfsi95594701cf.771.2024.07.02.02.28.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28:12 -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=mFfZmIcR; 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 1sOZk5-0002l4-LA; Tue, 02 Jul 2024 05:24:05 -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 1sOZk2-0002cV-Qg for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:02 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZk0-0007yl-34 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:02 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-36743a79dceso2868045f8f.0 for ; Tue, 02 Jul 2024 02:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912238; x=1720517038; 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=MEAedVXIwS3IcpAZnKMoyPFq95SaykgChyIuzbCP5sU=; b=mFfZmIcRb182k8XU2MSD4LLGk+E4VaawF8OEu/5/h7z6fUbUTK0griavI9r17YJnR6 xaw9J74svIT9mOCRLs5YLJa/B3MEtO2UcXEikjMXHHE8BraZR6w2TdN7Mcw8wFDaiJDW fszF3KyMzbPBDj57kSASVB6jKGDJNLaecCOy93M45QREhb0veIAAekNgTxx95eDoFCBT Qs9NFjKcCiBSQQQMdhi+qFUGszAYqp+Zui2zVe0bAh2VexlZQUsetDia3p1oW+UQ4eSF PNcQOOG+OhBZbnhpN4YQRs3hHYj8eF4Br3+DK+ceGuDQ/oMglsxkFN9AyC/fp/QKhnM3 qjFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912238; x=1720517038; 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=MEAedVXIwS3IcpAZnKMoyPFq95SaykgChyIuzbCP5sU=; b=O8GgkFqAl2OoxndHS4qIWxDTKdCElPDOZBorJu9oiecMFDdccjRKkhEalkToF2eSQx 6fFtiphIcRbKe3jwG3iaDrDbfjA48AboP591gWXfbeoKH5HAFvHRqiSal/745TCtJFNO +3xKTh65CF2ScYQVlImjIRQ7ZIlnDD2Yjv+X+LAgZ/3J0XF4itDZoqR/1/HPQ7czONnB aVbWG0AAlS4D8RCsWK0IhG0zGrOJgta3U9Q4KCzu9xzEy26ZvJFO1sPG6q7xX3FI5f6L sifK3MQA0UBR/OIsoqP4NRn17Sld/OursP1VFeMdJzm9I8AWxdgLiGcKRE05usm3QM4y 3vXg== X-Gm-Message-State: AOJu0Yx9s7Y/eIaXnDMWOomyCt3oqBK982aG2fk4uG7zbwESCEixpNed laHDW2rZHiOpHeptjnMMzAREG9ZkkFQ4UJUWVHOY5hyCeopEakG39raaPmFvtTie/NA6wmJqd9z / X-Received: by 2002:a05:6000:154e:b0:367:42ce:f004 with SMTP id ffacd0b85a97d-36760aa2ec0mr11625731f8f.23.1719912238218; Tue, 02 Jul 2024 02:23:58 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d8daasm12555614f8f.30.2024.07.02.02.23.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:23:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 31/67] hw/sd/sdcard: Pass SDState as argument to sd_[a]cmd_name() Date: Tue, 2 Jul 2024 11:20:14 +0200 Message-ID: <20240702092051.45754-32-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In order to access SDState::SDProto from sd_[a]cmd_name(), pass SDState as argument. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-38-philmd@linaro.org> --- hw/sd/sd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 90bb47ad26..5b356f0be8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -230,7 +230,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) return response_name[rsp]; } -static const char *sd_cmd_name(uint8_t cmd) +static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", @@ -269,7 +269,7 @@ static const char *sd_cmd_name(uint8_t cmd) return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; } -static const char *sd_acmd_name(uint8_t cmd) +static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { static const char *acmd_abbrev[SDMMC_CMD_MAX] = { [6] = "SET_BUS_WIDTH", @@ -1273,7 +1273,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) uint64_t addr; uint32_t data; - sd->last_cmd_name = sd_cmd_name(req.cmd); + sd->last_cmd_name = sd_cmd_name(sd, req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. * However there is no ACMD55, so we want to trace this particular case. */ @@ -1740,7 +1740,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req) { - sd->last_cmd_name = sd_acmd_name(req.cmd); + sd->last_cmd_name = sd_acmd_name(sd, req.cmd); trace_sdcard_app_command(sd->proto->name, sd->last_cmd_name, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; From patchwork Tue Jul 2 09:20:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 809092 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118285wru; Tue, 2 Jul 2024 02:29:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVTFX1teW/no7pB8jbPfKgM2XfxWPoj+fpDzEgT8XOyeZJOQ9SB40E+fBe4O1mCzkTYAFFpVHgWaSOvYfDAr4lS X-Google-Smtp-Source: AGHT+IEGLEppQXdbRCIsYYMdif/91rQ+YIJbPk2/olIbczs2lT0dENwgzAK464/kmaOGLLrAem94 X-Received: by 2002:a05:6214:2481:b0:6b0:8789:ae3d with SMTP id 6a1803df08f44-6b5b70d28bemr113298116d6.34.1719912554882; Tue, 02 Jul 2024 02:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912554; cv=none; d=google.com; s=arc-20160816; b=bz3s/JtpwyZZ3c87lCcMooKNYdBkm8KvRCmKT/1oZK0HlQzUTIuPr/7ixLxe2ZAO/r 2GWJ86fKb0qMTaZ2klu/5rjHvO9+3j9/0Aje2/zd356ffGR2iKqDZYApHOn6TdCmt/2C ZMenPxf72mc2WS2o4xszpqiBPGM8vjsQDBK/YCf9RMwML7lJjiNHDNiVB69nOxq5igG2 YX2W79Jv4hGK1n+E7tfjEPhlF4H3u6aNL6TnmJGQvbUYJ882SvI2hRgGOMoG1MWn3cVP 3TJQu8raN1RskXzYdcu6KZ+MM8o7PgI0MaKa9myZPrQQTjdwlYHIL5hdY8/4U8GBzzgj TczA== 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=kI14nFtkmVuLlf2mzl5p+7UiBT46U4YhEycE/q3yJNg=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=u3fpRlfVf8e7Oy5vv1CYP82wiSB9Y7s9Vp7ipuvfbC/d0x/UaKk9qKvQP0h2/+Tn4D RdKYoKWJoXg+9asICmYjivf/CLuxX3OI4tftBEoesgg0yvY+/bEfstBjvwuqDW0JOnSt 6U7OYlCGxK7J+gLQJ2+BbX6PSFbQILpANi17IDyvUiWaWydRxcsDnTLNWfrNQC5cC0oJ McwxTAkHwsWkJ531Twbn3JjHmZkiEVxll6rauVxVL9690jCIFulcegSB8JHaUeiVc4oF IF8G7jndkImgdSg/neaj7quAUI2wy0hNp5GJ9wKoC2ql1XWWp9N3UE7T4EajIBpBi//h 9kkA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WYLbpYjV; 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-6b59e60c5b1si96838436d6.512.2024.07.02.02.29.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:29:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WYLbpYjV; 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 1sOZkN-0003Do-3L; Tue, 02 Jul 2024 05:24:24 -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 1sOZk9-000300-Jg for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:11 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZk7-0007zq-Sc for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:09 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2ec1ac1aed2so46136821fa.3 for ; Tue, 02 Jul 2024 02:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912244; x=1720517044; 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=kI14nFtkmVuLlf2mzl5p+7UiBT46U4YhEycE/q3yJNg=; b=WYLbpYjVP3MPqj7HcQuYGd6E9nuBdcqLXrbVOrWUJ2o3uuUS1yxoaoAAaihL6ckaBy 0llCqb0rDxIMyCX1SY51ZLRKwwKwdxe8GHa/wzZD+ZpaJpOdIMJ4bkUmmtmExmlKe22u Zbu151gd3xb9Ek8Z2dyhWN7QHyKuRdEjIB369Qyp9OfDBdg8b2xvTSb2Li2kuwXWaEby CYuwcfpQE+qkr2NkFMdZ86bE++/A+ijl1tWvlwguFKP0MqiHN7Ryzo5rUa0O60f0CtHT kZwhk9kyR88vl/DkQFZwwDFpEIv3ZVEYAgMAh8+n9fODEONnI0qdzodXHRhWZY5spJ1C 4CiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912244; x=1720517044; 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=kI14nFtkmVuLlf2mzl5p+7UiBT46U4YhEycE/q3yJNg=; b=AUodriWVxWqk8CVeVzDqQL/a3exEZpXPQdWrgeqhF+XEyRtiwBv7jSrFFoDLU+ZgLR 7OcWKJToXT5iWuDkKS3djPuN7f3JMwIdHk85KA/rnLN73/ypGfz9L8z+X9KZJZTBpzPC NaPq6KHYvS5bJPyhYsDbNCqshKZNQeeV56q8eAZxrY04qAL1Z6BWHRLdOcLmnx2vOX+h UAs0kuqeWNUzkfs6IrrZjnygVarJM6KOyWtCm+v0h4LHNev9cl9h3N5elaWg8valO2RD 6URR7vYnkvNg0nXnfLh9Kes39tjUXrjjwDtrbKF9yWYhYWDPAkMeQuPtpXtpJGLtNbxa FNwA== X-Gm-Message-State: AOJu0Ywk5js3x35Cg7NBFDDfiwyRqy14EoAJZt49I8wtlx3WwwsRq0pN MbNsMc64dntQHAL/WgO7E/oB4IJ1hKLZruFFuPhFwb/ojQfPQiuOfp51nUsdfMgEgXsSyx9vdWN X X-Received: by 2002:a2e:6817:0:b0:2ec:514f:89b3 with SMTP id 38308e7fff4ca-2ee5e3b37b2mr51963261fa.28.1719912243896; Tue, 02 Jul 2024 02:24:03 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09aa32sm189836575e9.34.2024.07.02.02.24.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 32/67] hw/sd/sdcard: Prepare SDProto to contain more fields Date: Tue, 2 Jul 2024 11:20:15 +0200 Message-ID: <20240702092051.45754-33-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.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 Convert array of command handlers to array of structures. The structure contains the command handler. No logical change intended. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-39-philmd@linaro.org> --- hw/sd/sd.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5b356f0be8..fb82bc9aa3 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -93,8 +93,9 @@ typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { const char *name; - sd_cmd_handler cmd[SDMMC_CMD_MAX]; - sd_cmd_handler acmd[SDMMC_CMD_MAX]; + struct { + sd_cmd_handler handler; + } cmd[SDMMC_CMD_MAX], acmd[SDMMC_CMD_MAX]; } SDProto; struct SDState { @@ -1297,8 +1298,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_illegal; } - if (sd->proto->cmd[req.cmd]) { - return sd->proto->cmd[req.cmd](sd, req); + if (sd->proto->cmd[req.cmd].handler) { + return sd->proto->cmd[req.cmd].handler(sd, req); } switch (req.cmd) { @@ -1745,8 +1746,8 @@ static sd_rsp_type_t sd_app_command(SDState *sd, req.cmd, req.arg, sd_state_name(sd->state)); sd->card_status |= APP_CMD; - if (sd->proto->acmd[req.cmd]) { - return sd->proto->acmd[req.cmd](sd, req); + if (sd->proto->acmd[req.cmd].handler) { + return sd->proto->acmd[req.cmd].handler(sd, req); } switch (req.cmd) { @@ -2269,22 +2270,22 @@ void sd_enable(SDState *sd, bool enable) static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { - [0] = sd_cmd_GO_IDLE_STATE, - [1] = spi_cmd_SEND_OP_COND, + [0] = {sd_cmd_GO_IDLE_STATE}, + [1] = {spi_cmd_SEND_OP_COND}, }, .acmd = { - [41] = spi_cmd_SEND_OP_COND, + [41] = {spi_cmd_SEND_OP_COND}, }, }; static const SDProto sd_proto_sd = { .name = "SD", .cmd = { - [0] = sd_cmd_GO_IDLE_STATE, - [2] = sd_cmd_ALL_SEND_CID, - [3] = sd_cmd_SEND_RELATIVE_ADDR, - [19] = sd_cmd_SEND_TUNING_BLOCK, - [23] = sd_cmd_SET_BLOCK_COUNT, + [0] = {sd_cmd_GO_IDLE_STATE}, + [2] = {sd_cmd_ALL_SEND_CID}, + [3] = {sd_cmd_SEND_RELATIVE_ADDR}, + [19] = {sd_cmd_SEND_TUNING_BLOCK}, + [23] = {sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Tue Jul 2 09:20:16 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: 809104 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118703wru; Tue, 2 Jul 2024 02:30:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUkiWpTK08qSv5EfF6VSf8YjSf7U7C3IZsvTymwccXqnnuUJa15BAkqwmmlatWfhc+JRU17LNzZvHyXL8Qy8dNw X-Google-Smtp-Source: AGHT+IHlJQgk0Yd3WjRBjDG6DvCpQRL7UJDE7TOKSE2JUpzb9r5E29T+9CE9XSjYNR8iuaDQrEeA X-Received: by 2002:a05:620a:3bcb:b0:79b:a8df:7829 with SMTP id af79cd13be357-79d6ba4cccamr1616060685a.14.1719912645295; Tue, 02 Jul 2024 02:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912645; cv=none; d=google.com; s=arc-20160816; b=q3xO7tLR57E4dalXyBI9ibzylNxT9sjLnxKkG8AdvcLIWaMnQID9SNntsFNd7RLnWc R8CY5mPZbIWwDkB/91dipotoCrwKnnDs1U/RLGtS3aEx+gNuLk4SekP1pgwbZRKnwjdZ +e1Km0s5CsoUu7in5im0ssWRz+NwfV8zXQ3EFeDSNzSq6I1kT9kDUW/LuLmZ2Qtnw4ca EwK6TghC0dC1UeImogcvLF/OMrne5BPB8FPNyO34cSi3/T1j+SNqzAL/IVdDWW3Oa4r1 BaGQPCG4pGbe6CTrTwv4Ea0RLhuDT6L0qTk7X3E+ZQo/LRTziLtaRs+/fUuAcSJZMpsZ xlAg== 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=YPLvB2ZG14xjBMcX/e0G2maNGEfR8AYKqnkrhl4dPtE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=IqunbATNrhxxKIlwjuLADjF/5RouZ54IRgbMxedGpiPtdXlKLenkUtCaz+nNIU1gGT 1OZ8t2CKRdEaF28aTaiWdvl5ELrIKQKgc2+4H2juYtBwWSGRnXFzcqB+j3jNeCwGnxQ9 XEFiLN8MGWPX7kWrLJoCBV1Ps0j+5heV0xoAxsh0NAxUSIvBFK+LoJr67/JdaFfN+xjw K33X8F/E9J57+6PLoIwH7EQ7gvzqmCbVF1wujxlNrFzYBSbgQSmCbUA4APSpTZnCMLOx ygFtX5j/4plsUxldJAhNNu45DUHmsCpX0QkNhunVn+ah9KHEq9qtAduZX8ZITc3fbqs5 VPVA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I7BxzGd9; 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-79d8dbe4231si360272885a.267.2024.07.02.02.30.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:30:45 -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=I7BxzGd9; 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 1sOZkW-0003O9-Dp; Tue, 02 Jul 2024 05:24:32 -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 1sOZkE-00035Y-GU for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:16 -0400 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkC-00081b-Lw for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:14 -0400 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-52e8b27f493so2170326e87.2 for ; Tue, 02 Jul 2024 02:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912249; x=1720517049; 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=YPLvB2ZG14xjBMcX/e0G2maNGEfR8AYKqnkrhl4dPtE=; b=I7BxzGd9Bw/NJrLPONdqiiwZqZ/+nvJC/kDy9CrZoYpz1FHuCKMHOrOM1FCSlLJDnq 600Da2gxEDKfxj0NPNvY3rjJMQZDKWtTjf8Jqrfc7mNf7eycgViYxPnJU00IqUwvlS05 Ouol7IDjdBFcMoIgPORRZ3lbEd6SDNv1ExRPLNde7fP1luM+dzv53spfkYBz2K8i2RKl c8Wjwr7vd9GJNwnT6LeTyp4w6xozozlKnABlDOCvlrGoLDaCxdnxpk04u8jIeD5yVAoX rFgdFlZ98A6SdDwJkmTnu8qWkzVirUJiLb3cxAmxv3df2YMWyQX07/I97H8dMYFsQd6J yBFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912249; x=1720517049; 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=YPLvB2ZG14xjBMcX/e0G2maNGEfR8AYKqnkrhl4dPtE=; b=hrXieF71blzLyj14JUURrlOlUFSURO9Ic1qgJTU4dHMH+jTfwYmC7k5bBvWEBpxjC7 TqoGLqDXZhx7jyjwhJd/85BQBsFDSuj7ABSxqD+lb6fn/i9WZhUve1kimcz4IwJZ0QZD Bg60hT0duZ+rIEyRkqn6FV/++PAV6Vmf//A1UpRRUJFDC6AedQmYKB8dU/SVMylDVHEf B4wmR8t5ZBxsO5+jN75NaxKp6+sBhtKG+ms6ezFmSVU8ecDQswnjHwK9HzdDEb0sCKWf i/cbp3QVSoQTN1vqn26weoUfspDH6vi9dbAzYrk9va0PZcOwHXgPW0F1ON+b+V/HKVVv hdcA== X-Gm-Message-State: AOJu0YxIMcRD4Z9LSCl/i1uWjqMaGNdkF9N162SqJnaqHR143ZUVL3t5 v9UQtvf5sL9g1EOv9ebV/QNxynySTrAXGNyVWl8aJ6IWDPfnh17yW4HngqBqD34WIozZ0+rriMo F X-Received: by 2002:a05:6512:3ca9:b0:52e:765b:c00e with SMTP id 2adb3069b0e04-52e8264c2femr5297206e87.7.1719912249669; Tue, 02 Jul 2024 02:24:09 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b064f16sm190197265e9.27.2024.07.02.02.24.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 33/67] hw/sd/sdcard: Store command name in SDProto Date: Tue, 2 Jul 2024 11:20:16 +0200 Message-ID: <20240702092051.45754-34-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=philmd@linaro.org; helo=mail-lf1-x12b.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 We already have a const array where command handlers are listed. Store the command name there too. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-40-philmd@linaro.org> --- hw/sd/sd.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index fb82bc9aa3..2cfba6ff60 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -94,6 +94,7 @@ typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { const char *name; struct { + const char *name; sd_cmd_handler handler; } cmd[SDMMC_CMD_MAX], acmd[SDMMC_CMD_MAX]; } SDProto; @@ -234,8 +235,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [0] = "GO_IDLE_STATE", [1] = "SEND_OP_COND", - [2] = "ALL_SEND_CID", [3] = "SEND_RELATIVE_ADDR", [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", @@ -243,9 +242,8 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", - [18] = "READ_MULTIPLE_BLOCK", [19] = "SEND_TUNING_BLOCK", + [18] = "READ_MULTIPLE_BLOCK", [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec", - [23] = "SET_BLOCK_COUNT", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", @@ -267,6 +265,12 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; + const SDProto *sdp = sd->proto; + + if (sdp->cmd[cmd].handler) { + assert(!cmd_abbrev[cmd]); + return sdp->cmd[cmd].name; + } return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; } @@ -279,7 +283,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [16] = "DPS_spec", [18] = "SECU_spec", [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", - [41] = "SD_SEND_OP_COND", [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", @@ -287,6 +290,12 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [56] = "SECU_spec", [57] = "SECU_spec", [58] = "SECU_spec", [59] = "SECU_spec", }; + const SDProto *sdp = sd->proto; + + if (sdp->acmd[cmd].handler) { + assert(!acmd_abbrev[cmd]); + return sdp->acmd[cmd].name; + } return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; } @@ -2270,22 +2279,22 @@ void sd_enable(SDState *sd, bool enable) static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { - [0] = {sd_cmd_GO_IDLE_STATE}, - [1] = {spi_cmd_SEND_OP_COND}, + [0] = { "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = { "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, .acmd = { - [41] = {spi_cmd_SEND_OP_COND}, + [41] = { "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; static const SDProto sd_proto_sd = { .name = "SD", .cmd = { - [0] = {sd_cmd_GO_IDLE_STATE}, - [2] = {sd_cmd_ALL_SEND_CID}, - [3] = {sd_cmd_SEND_RELATIVE_ADDR}, - [19] = {sd_cmd_SEND_TUNING_BLOCK}, - [23] = {sd_cmd_SET_BLOCK_COUNT}, + [0] = { "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] = { "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] = { "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, + [19] = { "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, + [23] = { "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Tue Jul 2 09:20:17 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: 809083 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117964wru; Tue, 2 Jul 2024 02:28:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3CIwF6CXwshJSLSkInQXDb8BNxbylq71bGEjadJhdC2AFjRftRF7e4sP+2hB9787T/QALE7o1zbaycJCz+jdq X-Google-Smtp-Source: AGHT+IEGZANKzvxh0PcRYiyuY3f++CnddfVUcGbmLPLt7fS9gn4Y2aO74v75mkB53zQo9/mKIIt0 X-Received: by 2002:a05:6214:1c42:b0:6b4:4585:8e43 with SMTP id 6a1803df08f44-6b5b70cab6dmr128957976d6.31.1719912481936; Tue, 02 Jul 2024 02:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912481; cv=none; d=google.com; s=arc-20160816; b=R3GQ/Hlldz/xtaP0GRn45IH9/i700e+/b7ZlabVrZqmHzQYUr5bepB5x054Klby+dS zen0KCtMkXxAU1aewYCkoqJhyKBI2lYr0GIcTPzrXLKUA616/301amK9canYNcwf5BnX 8w9TcaTyAdignI70n4geVNQbKu2M912VVpp5LNMKhScsXz9vvW/WRpADMZckCoAa+BAT i0qst4rx53I4smH/eoOUMpDVNj8QyZoHVKbhBA7fhhydYoJTu/QGF0uS3jR2sMuF8bpy RfLAGoDyZvaodVka463p57y/IMQTbL1QR3s15zc1yCHfnuwQbqFThJukQ+oz6neuR8ss 9jSw== 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=jPA9R4YCYQBkQZ2o9Ln39vUoRWjzfB1ZKjrmxeGewtg=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=L4AXhQAA9FLdlvj27IQi1QMULvEEoKL6kQAcaLZOteLxlIDPDl8sxS8291XBJkKFoA DupvO6aoyoEN3Ng9Rd38FuF+B6MqTpSHsZofYv0HNCqmGk9b1ilPAlj18X71bv+rs/Tb vf3ULYnoHP3Gb+40/TbQUc3pBs4WzFZVZKb8+cQC86+EkB28b39l17HS5DazXdObL25E eLD8T4rYelqrQ08sUc7LwSToZ2TTaqaHBq1KH3mrk8Y2oUc60AL6rCdFitTwvYI9a+cn KY1dNtsormTTj1Ae2OcRF8klB2AG4lIwwLLrwT/Fsv3w5TZn+2qm45q1Tn8EXQYJlJzK qwqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lDGu8B3Y; 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-6b59e62541fsi102521746d6.602.2024.07.02.02.28.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28:01 -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=lDGu8B3Y; 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 1sOZkY-0003eT-D3; Tue, 02 Jul 2024 05:24:34 -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 1sOZkS-0003Nk-8v for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:28 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkI-00005H-W4 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:28 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2ee7885aa5fso3014801fa.1 for ; Tue, 02 Jul 2024 02:24:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912256; x=1720517056; 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=jPA9R4YCYQBkQZ2o9Ln39vUoRWjzfB1ZKjrmxeGewtg=; b=lDGu8B3YsG28PtcnU2QFl9n3tiCjVfKzwAkQqw18cUZjpagppqC4CqigLXRKG85R8o FuAa2ZlNndE7mzSkj5YgykezlQ7+cUI9xQb9bsiymmZFWg7usIiAttvt9P9XWDJfURl3 81XNVgF2hdUg66RBW8mPPfLm9Z/OnGT/BcjlPQUzOw+zD0gavq/0vI/VRKIsCbZooehK tjFapT48ldXWSjFliIryQ5K5YA4IsmkAk0u8Ia5PDrKLCx6+scMQxHr20AOj50Ma8efn nBOUJ3n+3AasMX4n5P5j1sMq8y2NmoSuOmHX1+mS63T2FhY7vQWXJdywSyywFks05rXA w+kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912256; x=1720517056; 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=jPA9R4YCYQBkQZ2o9Ln39vUoRWjzfB1ZKjrmxeGewtg=; b=P3DUPDXUSuV7vCwsxcxjPBvy6AtguQ8TglTm3FL5IROEtoTVqkE/cpqg5jW7MhFXBw 7heJ95qTOAgfPY5RTWqjI17e1AKPns/Zdcx0JbjILQBY05ikg+nJH0bMkOKcrq3/Lf03 potG6jjeq+n2n95NPewh/u+uvyRNbWSNbkPpEa/b3xxTKMtfdfL8hYt9snfHvfqS6tVD NE409n2LGoqrB4sAX0YpbFWYQW7pLFemOBq4UNcZ/hXhMJA8VUAnMniTMw4acpyYx/Ev Qo93qPw4cEXfsNRuCMay7Orjduuyg9n3fCNDqoL7+DzKRlJuZD9l+54pWYIZ7JLQyAyK peLA== X-Gm-Message-State: AOJu0YyEys06OcOj47f06G8Nz+3W6NMJ3BcgAhlPlDvygDYGo7zoMek7 Jl+UXaU3FtWCjoVNOkPaoPaCoTya71/PjN8iEjVDdjXKEf8D5+ucZPlgXvUgXSNVMHQGJFvs3Cm Y X-Received: by 2002:a2e:2407:0:b0:2ec:839c:938e with SMTP id 38308e7fff4ca-2ee5e6d746bmr49607001fa.45.1719912255749; Tue, 02 Jul 2024 02:24:15 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af389b3sm192408485e9.1.2024.07.02.02.24.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 34/67] hw/sd/sdcard: Store command type in SDProto Date: Tue, 2 Jul 2024 11:20:17 +0200 Message-ID: <20240702092051.45754-35-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.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 Store the command type altogether with the command handler and name. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-41-philmd@linaro.org> --- include/hw/sd/sd.h | 5 +++-- hw/sd/sd.c | 44 ++++++++++++++++++++------------------------ 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 2c8748fb9b..29c76935a0 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -76,8 +76,9 @@ typedef enum { } sd_uhs_mode_t; typedef enum { - sd_none = -1, - sd_bc = 0, /* broadcast -- no response */ + sd_none = 0, + sd_spi, + sd_bc, /* broadcast -- no response */ sd_bcr, /* broadcast with response */ sd_ac, /* addressed -- no data transfer */ sd_adtc, /* addressed with data transfer */ diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2cfba6ff60..9f257906b5 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -94,6 +94,7 @@ typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { const char *name; struct { + const sd_cmd_type_t type; const char *name; sd_cmd_handler handler; } cmd[SDMMC_CMD_MAX], acmd[SDMMC_CMD_MAX]; @@ -348,20 +349,6 @@ static void sd_set_mode(SDState *sd) } } -static const sd_cmd_type_t sd_cmd_type[SDMMC_CMD_MAX] = { - sd_bc, sd_none, sd_bcr, sd_bcr, sd_none, sd_none, sd_none, sd_ac, - sd_bcr, sd_ac, sd_ac, sd_adtc, sd_ac, sd_ac, sd_none, sd_ac, - /* 16 */ - sd_ac, sd_adtc, sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, - sd_adtc, sd_adtc, sd_adtc, sd_adtc, sd_ac, sd_ac, sd_adtc, sd_none, - /* 32 */ - sd_ac, sd_ac, sd_none, sd_none, sd_none, sd_none, sd_ac, sd_none, - sd_none, sd_none, sd_bc, sd_none, sd_none, sd_none, sd_none, sd_none, - /* 48 */ - sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_ac, - sd_adtc, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, sd_none, -}; - static const int sd_cmd_class[SDMMC_CMD_MAX] = { 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, @@ -567,10 +554,19 @@ static void sd_set_rca(SDState *sd) static uint16_t sd_req_get_rca(SDState *s, SDRequest req) { - if (sd_cmd_type[req.cmd] == sd_ac || sd_cmd_type[req.cmd] == sd_adtc) { + switch (s->proto->cmd[req.cmd].type) { + case sd_none: + /* Called from legacy code not ported to SDProto array */ + assert(!s->proto->cmd[req.cmd].handler); + /* fall-through */ + case sd_ac: + case sd_adtc: return req.arg >> 16; + case sd_spi: + g_assert_not_reached(); + default: + return 0; } - return 0; } /* Card Status register */ @@ -2279,22 +2275,22 @@ void sd_enable(SDState *sd, bool enable) static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { - [0] = { "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, - [1] = { "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [0] = { sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = { sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, .acmd = { - [41] = { "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [41] = { sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; static const SDProto sd_proto_sd = { .name = "SD", .cmd = { - [0] = { "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, - [2] = { "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, - [3] = { "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, - [19] = { "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, - [23] = { "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [0] = { sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] = { sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] = { sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, + [19] = { sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, + [23] = { sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Tue Jul 2 09:20:18 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: 809080 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117840wru; Tue, 2 Jul 2024 02:27:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUm8HHwyRPbbzL03TmOPMfP5fxKW6RogjvhoFYeSyQT3es5wdCGcqHo7qTbmQW90Q8ifTyEN2MT2e3qO8Ym5TkA X-Google-Smtp-Source: AGHT+IGh78ALZKhdemxs4UDCFCDXNlJKOkqwROp+CGBfvg4ax2E6Y8HLSYexHB+6sxu0Gx/pLkns X-Received: by 2002:a05:6214:e64:b0:6b0:91d4:5825 with SMTP id 6a1803df08f44-6b5b719b777mr89641876d6.56.1719912449320; Tue, 02 Jul 2024 02:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912449; cv=none; d=google.com; s=arc-20160816; b=Aneaa0aYde14hRH474VIfx0z5H3G2OIsPz8TS870QqBt6Fi7XVzx1NhnSnvnkVGS1K pNtYRXQbfK0gfmwal3239SbqWoknThm0Eb/WRwM+NpUN+XO+GczWXXO3nrUQEsH4SgxT QCuWMbYG/eWw0x8X6UVvSGnO8Lll8B6dlUXRG3583tVEbcF6MXiidV5O0kbZ0+1WECNx AO0W65GCw9Rw8FeyL1QeJJI3qhgtZP3cq3Kvr1Yr2ak7BcTKLe7fg1CLUIlm6KsBEiPV UsMmtknKywJkhzZp+UmuZGjhXlEPGgZvdZ4AjsYab8bMZYw3nf9am6o/xNf5vOYz1R52 lcPw== 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=NdXTl1syEL0/e8CCzGe/VrOY/+llJ3nM1VXYbHMVSR0=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=s9MZXfc+AN4+Evqq3n6ZF6OGZ6rf8dYvYqFNd9y1HIfX30P1SfPUEBkOncJPavJf7d AgBMXFIOUa8irVA7mj1M786cOfkmkF4bJRgwyw89jPLAuPmetQohHbyGYkdl0++H0DAq TrTU9lqU6JBDuk8egsfRoHWkiPn37p+eHfXozdvPRxUzMorvYGbqfRLkmrfTJq5t9FKw bLbdsnkl8+n9QCfWI8pDRGVTxnm97OdEm7AEY4EGJThh1umKI2MZgbv82+GKLPnJgrW3 XRKYnYiW5Z7qEGRDjUE7QqRaW81ZU6NpFbbuUIKiXXy+Wy0bjM7QU0NY+Ni1ol3axzAl c7Wg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DYwc7CYY; 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-6b59e3642e3si102016606d6.66.2024.07.02.02.27.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:27:29 -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=DYwc7CYY; 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 1sOZkc-0003rW-2h; Tue, 02 Jul 2024 05:24:38 -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 1sOZkT-0003Rt-RM for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:31 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkO-00009v-6w for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:29 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4257d5fc9b7so18826665e9.2 for ; Tue, 02 Jul 2024 02:24:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912261; x=1720517061; 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=NdXTl1syEL0/e8CCzGe/VrOY/+llJ3nM1VXYbHMVSR0=; b=DYwc7CYYNFvDiz9Dgt7ncebHM/JYq9uePATOHkIyREeahMg85ql0CwS1TaE2kPA96+ xwfhPCbMCltBa264HJB0qytorVKsWIAh4J7ckrO18onot9zytC36Yav9E3u2NdjvgeEM y4iaeh3mcYTbpD8Zr+azM2DtVcpIJ9nc+draIWfruVI5Mz7q8nRCKWdyId29Q9MKgTHx X/aDE0e7xpz2d4nfRNiQTAHJ81A2Gkcxla0fgLRRKShaWmGYTOZg+9pYppcVJ77QR6lW bfPR/efmF1XEwcPi9W+q18820MS/mCh/JVa0dQmTBr9dN/3NqTZoKE2vsv8ns4pukacV o2NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912261; x=1720517061; 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=NdXTl1syEL0/e8CCzGe/VrOY/+llJ3nM1VXYbHMVSR0=; b=Sbxr9BWjrxqLgOHHsz0qqyr4Lozk/3RvS8AvYyternmZ4zw6jfH3H7d8QPQp+U5OFy fTHsxJtBugshTI20WU9r2DlNW1MMtHgikcLEImzmKJSkW488RBZ+H/n+08T6IAJlQhmp VxFx7/F45S667sNS0ibn4TXiikeE3pEU1NGlrL4QDFaAsWqoW/TNkRrsqtOKdAZ/S4Ra z7WqY92mb4VBaLjHhmaAjZzJrF7UZGDovdIHpQVn7o42wJG6A/b65tKB1wpCfIDgRnDD 59nyWF24hGRvGfk8pyls2x7Gap5AYRu31lLKnE6YNjsjCmGfnUVU9e0bquwat8s6pxVZ QskA== X-Gm-Message-State: AOJu0YyrP/hAeKfHUbivIWMTzKDDgHlYmjspWEHzRJcGVeKJEWooCuZH bZoSe87dC/JE4PYVz5JFRj+adazPW5+/QaLO48Jcb7DQQR1s57nZYzxf9q1MPljOf0+rPbU9dLd 7 X-Received: by 2002:a05:600c:4a07:b0:421:29cd:5c95 with SMTP id 5b1f17b1804b1-4257a00674amr72069225e9.10.1719912261581; Tue, 02 Jul 2024 02:24:21 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af3912asm195612945e9.10.2024.07.02.02.24.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 35/67] hw/sd/sdcard: Store command class in SDProto Date: Tue, 2 Jul 2024 11:20:18 +0200 Message-ID: <20240702092051.45754-36-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 Store the command class altogether with the other command fields (handler, name and type). Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-42-philmd@linaro.org> --- hw/sd/sd.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9f257906b5..68e6944263 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -94,6 +94,7 @@ typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); typedef struct SDProto { const char *name; struct { + const unsigned class; const sd_cmd_type_t type; const char *name; sd_cmd_handler handler; @@ -349,13 +350,6 @@ static void sd_set_mode(SDState *sd) } } -static const int sd_cmd_class[SDMMC_CMD_MAX] = { - 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, - 5, 5, 10, 10, 10, 10, 5, 9, 9, 9, 7, 7, 7, 7, 7, 7, - 7, 7, 10, 7, 9, 9, 9, 8, 8, 10, 8, 8, 8, 8, 8, 8, -}; - static uint8_t sd_crc7(const void *message, size_t width) { int i, bit; @@ -1298,7 +1292,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) sd->multi_blk_cnt = 0; } - if (sd_cmd_class[req.cmd] == 6 && FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + if (sd->proto->cmd[req.cmd].class == 6 && FIELD_EX32(sd->ocr, OCR, + CARD_CAPACITY)) { /* Only Standard Capacity cards support class 6 commands */ return sd_illegal; } @@ -1883,6 +1878,8 @@ static sd_rsp_type_t sd_app_command(SDState *sd, static bool cmd_valid_while_locked(SDState *sd, unsigned cmd) { + unsigned cmd_class; + /* Valid commands in locked state: * basic class (0) * lock card class (7) @@ -1897,7 +1894,12 @@ static bool cmd_valid_while_locked(SDState *sd, unsigned cmd) if (cmd == 16 || cmd == 55) { return true; } - return sd_cmd_class[cmd] == 0 || sd_cmd_class[cmd] == 7; + if (!sd->proto->cmd[cmd].handler) { + return false; + } + cmd_class = sd->proto->cmd[cmd].class; + + return cmd_class == 0 || cmd_class == 7; } int sd_do_command(SDState *sd, SDRequest *req, @@ -2275,22 +2277,22 @@ void sd_enable(SDState *sd, bool enable) static const SDProto sd_proto_spi = { .name = "SPI", .cmd = { - [0] = { sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, - [1] = { sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, .acmd = { - [41] = { sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; static const SDProto sd_proto_sd = { .name = "SD", .cmd = { - [0] = { sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, - [2] = { sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, - [3] = { sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, - [19] = { sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, - [23] = { sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, + [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, + [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Tue Jul 2 09:20: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: 809070 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117438wru; Tue, 2 Jul 2024 02:26:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXkGfdQDVvzlsHFUEoHmqdC4dQutJtoatpUvkQZRm1FvfZXK3jIPLPyrXPj3NCEkycnj24Oa9V9bzXqkCSVEWsl X-Google-Smtp-Source: AGHT+IEVSzqkId/2+cRXfI3fe1zvvA+b/jZ9MKATBDRXWSK26dkzw8kCR5mQpq2ZqDRcEHTGAEc9 X-Received: by 2002:a05:622a:250:b0:446:5aac:ca7f with SMTP id d75a77b69052e-44662d975aamr115862631cf.22.1719912365613; Tue, 02 Jul 2024 02:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912365; cv=none; d=google.com; s=arc-20160816; b=I83KPp9y4T7oKexnELX2IVdc/hYe3ITlcvT6FMSHxtdL31DOiKlfbK0ztWznCnDZGm nR09uvSVYEXBwppOABHerW/+AnBfwPK/7cP7IBcc0fsJUjH4SZ1GilPfveRDL1o7oXaw Zg/pBsgD8V2vjhUL7e0/ytVDlWoJRyfKjog9ObDAKAO+SDOEtOoMqzYyPfmuF9gKOVow NctdZJv08PEHCxL5chip7XCJS4IwGdinkXGc05z6CCenVUTLRIH7zYx9R3iHcJSSE35J vz81xZlN1o+rPcCINI34VwtRs9dXqhx/K7vgnrijkUPLf7kWJO+1kcj2sITbPipel3Pn H9TQ== 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=HBHa6mNek3D9ym3Q87IBUwFBzBOdC5TAXndf6AluXYE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=vb/b4+FH7CvtY7EGjTDf9gATLMTsFRUgb1A2MnXbabhItxIvsaf3iMxi8hWA3FaBco /br8Nhaqqyce3u6oz/Id+eoPFMAXdVy+/lfpClGSVTjW8pNlD+Ur2bWGpyR1/xJQO/Xv 6WLo6EJtX44go6WuaqdNyMl2FjWIkDbW11STB6FQzBjs8UKGQ8rijgbH1L4v2BvEjtot E1GzmSQdtHIgYbvotBS+UtxTldbaY22IPm4cT6t4SAFi6QORDi36+SLTe7ql0cuzrkC8 9NjRh3mlihLJV8TgDoot7rAz0APbY0v7TI7GDfzgYDFtqbbzYn6iU+Cti6owBOEMYLML 4nSA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K10Y1QbV; 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-446514c2632si96324151cf.550.2024.07.02.02.26.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K10Y1QbV; 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 1sOZka-0003kR-3t; Tue, 02 Jul 2024 05:24:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZkW-0003Ug-IT for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:32 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkT-0000AI-8t for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:30 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42578fe58a6so19197785e9.3 for ; Tue, 02 Jul 2024 02:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912267; x=1720517067; 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=HBHa6mNek3D9ym3Q87IBUwFBzBOdC5TAXndf6AluXYE=; b=K10Y1QbVj8xLvNe0o6ZE0fwXkSTa2wJ3eFNKziO+HCLeXAi0ubXLwPaYQ23Qh0XqIq FR4KPEgqu49qZa9JiLLZdhnL3FJxWav/WEpaZgM4rQMsNtjvw3FPup9sc+pyoxrSuN8O MRMVl5CwiwVy5B994S9mjLeQySWTVuG0CZDTH1PmASkBLTBfc9SvzvTVNOlhamH10SsK 596fJDkhhaE6MbINHDQxP4s05b3tuMQdLQrsGOHgq1pDx1tfsSbSwcKWGsLM4MhnoCfO ZWWYMd6ZXw6WbBRN5Pxt+ChFM7koAwa5rEt4ZB++JTjqGf8zTExHTErwWQ6camzz9aQa taug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912267; x=1720517067; 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=HBHa6mNek3D9ym3Q87IBUwFBzBOdC5TAXndf6AluXYE=; b=cpPnFE+39DHJmM8AUSFLG74W2SvMOCfiPh2E2v/RrkqPvZAmGZ+x6xE3bbFygi3GM/ hfOiiyeujeMxmK63EGgDb4A28gN/9jxe4Zw9Yq6bSC1RfOlD6MInYJVRo72GVIQg7A8r 7AgkpC+L9LIG/DYVqGj+PpmLFjS5WZdexSYNqc7NWfAXOvU7p1nr+kQrkg4Gt/I5ZeXx bF+4dMCW64Xbcty0bC+Oy14g4HFVz+wRhbFIdckFiwrY7IXFfVeUzARNtgg2OXnNlb0b LkzJ+//MoKg6VKkHBrhi171trINIVNXevgbVdCTdx4mH9jzjqGxIF6ac82ohHRh39qED uqaQ== X-Gm-Message-State: AOJu0Yx+xBFU2b/yUj4y33u8s9Q2GPgrzky2IcqcCiRSaSPgnJKe+2pK kaPEjoJgX5ZwMQZRrgHVLzXXp/YnV027ieXu1LBf2a+ikaj1cmGITPNscVs3MLUrOLjfOFT7R/s + X-Received: by 2002:a05:600c:2252:b0:424:a823:51d9 with SMTP id 5b1f17b1804b1-4257a06e036mr52075535e9.30.1719912267536; Tue, 02 Jul 2024 02:24:27 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a103d00sm12672880f8f.99.2024.07.02.02.24.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 36/67] hw/sd/sdcard: Remove SEND_DSR dead case (CMD4) Date: Tue, 2 Jul 2024 11:20:19 +0200 Message-ID: <20240702092051.45754-37-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 The CSD::CSR_IMP bit defines whether the Driver Stage Register (DSR) is implemented or not. We do not set this bit in CSD: static void sd_set_csd(SDState *sd, uint64_t size) { ... if (size <= SDSC_MAX_CAPACITY) { /* Standard Capacity SD */ ... sd->csd[6] = 0xe0 | /* Partial block for read allowed */ ((csize >> 10) & 0x03); ... } else { /* SDHC */ ... sd->csd[6] = 0x00; ... } ... } The sd_normal_command() switch case for the SEND_DSR command do nothing and fallback to "illegal command". Since the command is mandatory (although the register isn't...) call the sd_cmd_unimplemented() handler. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-43-philmd@linaro.org> --- hw/sd/sd.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 68e6944263..c25e376b35 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [4] = "SET_DSR", [5] = "IO_SEND_OP_COND", + [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH", @@ -1148,7 +1148,6 @@ static sd_rsp_type_t sd_cmd_illegal(SDState *sd, SDRequest req) } /* Commands that are recognised but not yet implemented. */ -__attribute__((unused)) static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) { qemu_log_mask(LOG_UNIMP, "%s: CMD%i not implemented\n", @@ -1304,16 +1303,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 4: /* CMD4: SEND_DSR */ - switch (sd->state) { - case sd_standby_state: - break; - - default: - break; - } - break; - case 6: /* CMD6: SWITCH_FUNCTION */ if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); @@ -2291,6 +2280,7 @@ static const SDProto sd_proto_sd = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, + [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, From patchwork Tue Jul 2 09:20: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: 809109 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp119017wru; Tue, 2 Jul 2024 02:31:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUxF61qvzshMURONcI38lsS+SFXedTK1ZF9qb8Vinmn/g9JmvzLbQAs5+jmTRMSjLg6lMCwaMwe1gJvFzaxjKey X-Google-Smtp-Source: AGHT+IEXphQw1AC7ri1YoCLnBWU686xorOzPPGK1UkoQu0wKnEYkj8Eku/tkYS51OTVH+2fackXH X-Received: by 2002:a05:600c:4c95:b0:425:5e88:7133 with SMTP id 5b1f17b1804b1-4257a0076efmr69741215e9.13.1719912704227; Tue, 02 Jul 2024 02:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912704; cv=none; d=google.com; s=arc-20160816; b=XLK49gDKL3PDoH4opg2n4WYTNeh+Ecxd8ol6rtDQLvf6njNPg2INHa6ljRGwv6AmD1 nrX4L2C4NQ+vg/FMUBOvwiUIVG6666iS83A3Ujz0leDV+48RvcKftA4rEgkKMJNwoJ0R iDR3yiL3A52HOAf+OzMq/Ps1TwlzXxE1eLztunAaNDOwSbSjTb6eTB59RdPvRCs+/MgI YINjZx8xdUT2E5iy94CaeIQu0wRAdE/bN/qt6JUA48UaVgNXU3J2yDIT8nnb3r9wr6/D fqUfTT9WN2uqKFwqrm374UsbmNwQpF+yaLtMNh7J2obd7N/ibOohaP1s3JiuhTbAif9X hJWg== 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=ph442tiXvXeNCMFB68Xw+ODOVr0L1MOlNemy3MQKQw4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=yHMs074sODtKdcJ65fP7f51xTmQsRquaYybUhOT+NufFu+xIb36RyDP7fj8fFPQidl 5pHYb3ApazZwhd3n9eLRElHCEhG+4j0CCABC7AP2vR5Ps5PRzB046zq+eweUdeRfYTmZ nx+bb6x9MOCz0m8GG7qxBbiTxkAq+UEX6kusZgtYo0K8EW34E3f9TxQuoiicfuirxePO /6RT/IzNHl8Wu8bMbBDt06OuNdYuHzhGbYDHJo39p+3HlW5UvK3pUkhnAGpN3yFL60zp rlFaFLtpqcyVSeljfy0hkHRIRjwFUJezxKBS3GTMp+fhrRWhi+aFok6F+/Lo2/UbdTdA /kHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FbVONF0A; 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 ffacd0b85a97d-3675a0bddd7si5571133f8f.102.2024.07.02.02.31.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:31:44 -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=FbVONF0A; 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 1sOZl8-0004Uj-2k; Tue, 02 Jul 2024 05:25:10 -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 1sOZkj-0004E2-5d for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:46 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkZ-0000Aw-9g for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:44 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-364ff42999eso1746035f8f.3 for ; Tue, 02 Jul 2024 02:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912273; x=1720517073; 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=ph442tiXvXeNCMFB68Xw+ODOVr0L1MOlNemy3MQKQw4=; b=FbVONF0AfTAufll9euSrMmC7dwo9kOVFtmdOrqVc3UeCs51oAL3AwgQK9F1P/tj+20 COKRBTBdZ0vZj6X8KJcNgt4TH//5C9G/b4lexbvFOFDA7z4HJRRF/mQettB0MUBuzITq VqSmiCo+z6+w0fThGc6AMC9hgNauPFRflrhCupzA2h5Ofr907CJScIM42m9aJtKK1SoZ EKnFZ2rUNY8fEHQJNeBz/EmkjK1Sk3vFYsNX0ukON31U2CYfsyxA8gsmbhO6BSmBcfqr hQuhsIo5TGMPgLQ/mwS3EDfX2srKmdH2gP0qKv6sEvqBL3wY2d6N53zw+uJPCbZs+ytN BxTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912273; x=1720517073; 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=ph442tiXvXeNCMFB68Xw+ODOVr0L1MOlNemy3MQKQw4=; b=fWJmGz0VnlLr/AVP+fwQXQYvAeTy6FeIQ1YkhE1vL+uph/mNIHh3KDQCLDWAMHUB3Y A5E6SqlYyDTtphQ4aeaASMiNo3G93ctXUMiFQ0ve4//2mHav3r0iH8V9hy3OwWZ5RslV Zsk3cPKzvjfWGiPif0k6C7+PySw2Ut78D2KJjwqulH56TT4gzkV0qgg91LYYC0F+N06H jA/YjoPX2+fqKqWLd4X8U+PtA8gQjMgn53TnCN8/7EC1I9P9OP7hmysOnV7VLa0IRSzK RfBhR/PvlbVxUmUn5LuMuG02NaWo71FGe0GzkfLhGJgK5LMyP3JREwZpNtd+jbvv0Bnr QpaQ== X-Gm-Message-State: AOJu0Yy31ESWTQpJotpn9v5zcOPMcQIz1+/eVnmdZq7GoVLUPghZXX9g Fg9tXqy+BX1DDHcZ2vHiegXJtYsQ6bBqlYnM0QlQ2HsPNevZ/UJrDzsFpecFakhUgnx+Lm95fnJ b X-Received: by 2002:adf:ce0a:0:b0:364:29ce:b14e with SMTP id ffacd0b85a97d-367757307aemr7145020f8f.69.1719912273339; Tue, 02 Jul 2024 02:24:33 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b068e54sm192840175e9.25.2024.07.02.02.24.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 37/67] hw/sd/sdcard: Register generic optional handlers (CMD11 and CMD20) Date: Tue, 2 Jul 2024 11:20:20 +0200 Message-ID: <20240702092051.45754-38-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-44-philmd@linaro.org> --- hw/sd/sd.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c25e376b35..b4fd863189 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,12 +240,12 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", - [10] = "SEND_CID", [11] = "VOLTAGE_SWITCH", + [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", - [20] = "SPEED_CLASS_CONTROL", [21] = "DPS_spec", + [21] = "DPS_spec", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", @@ -1156,6 +1156,14 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd, SDRequest req) return sd_illegal; } +static sd_rsp_type_t sd_cmd_optional(SDState *sd, SDRequest req) +{ + qemu_log_mask(LOG_UNIMP, "%s: Optional CMD%i not implemented\n", + sd->proto->name, req.cmd); + + return sd_illegal; +} + /* Configure fields for following sd_generic_write_byte() calls */ static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, uint64_t start, size_t size) @@ -2281,7 +2289,9 @@ static const SDProto sd_proto_sd = { [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, + [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, + [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, }, }; From patchwork Tue Jul 2 09:20: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: 809071 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117461wru; Tue, 2 Jul 2024 02:26:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWaaHU1CX4vebE36T4NHfpjaNpA79KYp3WK4d+W8Q2SlxKBkXoDrSnChPgOLx1uzrC568TfBE8HknX0XCoUY4mw X-Google-Smtp-Source: AGHT+IGE8OykDiv6FRS/fks34x9vqtewBnZITIcHbwHaCE6Mi1odEy/G7sSoXrGi+G98dVqQTmpt X-Received: by 2002:a25:100a:0:b0:e03:527d:34ff with SMTP id 3f1490d57ef6-e036eafd649mr6962143276.3.1719912372248; Tue, 02 Jul 2024 02:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912372; cv=none; d=google.com; s=arc-20160816; b=fETm/wTGvSalmYn/V5pDEX1HCAzcORUpwqXM6e99HMCheMQRH0jH3zVPcMU8X0k7/y ksTNUQM1oIjEzrbJ7DWlkedvjKSPW79X/QalQxdmlULMZ7Ehh01gnhjUVtcz5cPg2Gt0 7uD4jmYvpS6vSgLaxOiVkYt86Uaj9WsJ+NE8xFXoBpxwORl4uquu6v2Ey9RX4o1B++QI 4wkjbBvAs8sDC97PgVU3g7YqNkXRCMlGI84AKtKP4HgdNsKBd9+DWHCweAOOWplKk5R/ gBZeXdc7Qp4U/Gw6BmEt/vDHFaxqvoFdEZrXzzG6CWImIr6ZOOXT2/jXT7RClpe4etC8 YhdA== 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=kBNEOV+SuPOCA0UAQQw56j+dIx9/wiXRzt0fyiV5P8w=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=AV5mNGg9NDcW+HgUaO3uUpxG69kycB9CmP6rpybeX+qCM0xHGoAypFnyVPSEm6oMcg tX7sQk2kcWMQ8OQXdB3rlAJfjcJ5o0h8g9hqqMfPBiYM9RnFBKOo9K0snevLesFnAdhX ZQ9Fbiz7TsWAxtK6B1ZL/L10Mlueir9DvLdm8rvNARt3dSDdLQfLsTSBiRMxHwO0snvy U10DGzB6UXB6bMMrKfG1PQnL/aO/TB520phBu53ATEd5c5XJ8JhYhAUudNwaRsXuIIrn rGGWkXa1TgeMXoFFyH6+OicTDJ5KEarUw+uf2xlYdvENZW0WW7ST5LCRQ5NGh6rcWJci HcKA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o90qysjr; 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-446512cc3cdsi108638771cf.118.2024.07.02.02.26.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:26:12 -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=o90qysjr; 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 1sOZkp-0004KV-8p; Tue, 02 Jul 2024 05:24:56 -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 1sOZkh-0004Bt-Jh for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:43 -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 1sOZke-0000B8-I7 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:43 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-36532d177a0so2323182f8f.2 for ; Tue, 02 Jul 2024 02:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912279; x=1720517079; 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=kBNEOV+SuPOCA0UAQQw56j+dIx9/wiXRzt0fyiV5P8w=; b=o90qysjraVHbOFsngDjlV60Wt/wBfGVLdTAIjXX6k0OwKuif6cyunDkPjmkT/eD9VL S92k+2tOE9NRylOrZVg+8lQDSjicAc+Otm5oryBQNBdYUfiXgyDytZ2UIrcUY7BdJePY 04aIg6KYF0EJZX+7hzJQINWYgzZ/Q3c6l2pWDusEgnzu/esj5Q71+egoUn6ohhK30zkN fkSSXOer3aPa4LKUDC7/RmjhOTRJRP7elPanwsJy72nfSM8vKScLH6k8dM89wm1GJ2s+ m5P1trYMb7ymlNri1c8xcAFNEccEhAWY4vAfTIAu6WloJpoCe+p2cmylqxRwv9P0qjK3 FIcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912279; x=1720517079; 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=kBNEOV+SuPOCA0UAQQw56j+dIx9/wiXRzt0fyiV5P8w=; b=tgBZzlAadz5u+n5vLSnfzf6SHtbEj4+Nwy94E19lMIlr94ziAK/AsuM0u5+tXi6w7Y qP/kOyet0QpW9u+frMThrqMyBCWqDl0KYd5aZmS2AndyjfsayVZNTT/XtvnwX9tK1/x6 Y346Wf6LIo5fKHdt2Us8N25sADO/Y1RL6tbQxgOSVws5GDh/2QHRz3rF6ni1XU+DMndn aCXExAvXL10VgdN6tj7L04zzN21SMj8fR8qJiJ6u7qnYjLkDMLuVAfDM8cClJr4p4gTt 2p6IugvrZwntQtG7vmwXEMtg0PPT//1kT883IKq7LYdld9iXL158yChiClDGOZvmc7hB j1CQ== X-Gm-Message-State: AOJu0YxezHDkr/L1wzowU2/rBD3JUrwB1MYQGxdgAbwQD/1mknFkKT4P sy+bldbIQ+xcH3XJKrywj5Vxb05UXR7+dujZwfePEsaVEXFEiEw4UCY9O7dY6PHKN5cxYUHKDAJ a X-Received: by 2002:a5d:54c9:0:b0:367:6b05:356a with SMTP id ffacd0b85a97d-367756bb441mr4604682f8f.36.1719912278951; Tue, 02 Jul 2024 02:24:38 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd663sm12752958f8f.3.2024.07.02.02.24.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 38/67] hw/sd/sdcard: Register optional handlers from spec v6.00 Date: Tue, 2 Jul 2024 11:20:21 +0200 Message-ID: <20240702092051.45754-39-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-45-philmd@linaro.org> --- hw/sd/sd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b4fd863189..f8672b6603 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -255,15 +255,11 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD", [38] = "ERASE", [40] = "DPS_spec", - [42] = "LOCK_UNLOCK", [43] = "Q_MANAGEMENT", - [44] = "Q_TASK_INFO_A", [45] = "Q_TASK_INFO_B", - [46] = "Q_RD_TASK", [47] = "Q_WR_TASK", - [48] = "READ_EXTR_SINGLE", [49] = "WRITE_EXTR_SINGLE", + [42] = "LOCK_UNLOCK", [50] = "SW_FUNC_RSVD", [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED", [54] = "SDIO_RSVD", [55] = "APP_CMD", [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", - [58] = "READ_EXTR_MULTI", [59] = "WRITE_EXTR_MULTI", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; @@ -2293,6 +2289,15 @@ static const SDProto sd_proto_sd = { [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [43] = {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, + [44] = {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, + [45] = {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, + [46] = {1, sd_adtc, "Q_RD_TASK", sd_cmd_optional}, + [47] = {1, sd_adtc, "Q_WR_TASK", sd_cmd_optional}, + [48] = {1, sd_adtc, "READ_EXTR_SINGLE", sd_cmd_optional}, + [49] = {1, sd_adtc, "WRITE_EXTR_SINGLE", sd_cmd_optional}, + [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, + [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, }; From patchwork Tue Jul 2 09:20: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: 809069 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117436wru; Tue, 2 Jul 2024 02:26:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXOyaNzwD2deM4MPqlZUg7W70u08i6NOBV4+kHcb2xNdpVPbKszv362500GJeGMADBLq80uQ0X0ocqIeATkG3E9 X-Google-Smtp-Source: AGHT+IHNydQJjM74Or3hZ1KLjGlenisPQoY4Mskp/YpnYCqEm3SGPM0sdj0iB/rmTASJ2XszbmHH X-Received: by 2002:ac8:7fcd:0:b0:43a:a89d:ee8 with SMTP id d75a77b69052e-44662e535acmr115215721cf.58.1719912365612; Tue, 02 Jul 2024 02:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912365; cv=none; d=google.com; s=arc-20160816; b=KNGxxVBr/Gy97zNpydstR9fb+yANJcqnH1XZFnqfD6GpxiAXJ52rEQKau9AusSmsXg 9RjsyDoZXL84+E23JL+ZxwrytX09q/XFL0UIWMBLEOSBvFvRDxyxz6as8jxerQD9xkYw vUYuJ1UDGh0WWHUvL8EF+Q6nc09YYANJtN4D19tE6TSWGB6xW/1OF4qiHzws0xJz9XzN 3I8Qnye8VJv5Ov2FpvMHRHlSfSEFeM2niYxEgG0sgAokmHKmQwNEqJkmoUGw8wtZwDL/ QLwi2i2yoAABqInHRoBRhJd5A42af6YgSrUPyke80dwsLGG/1ECh/OFSSOLSXZiOGRQv KLNw== 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=DNA/X248tgmPgC0TxVdzd0n0o4N/WEHWfZeXeWaMVQw=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=c6fLKfWA2VMQXeOZtXEfLeDiVwWVMZDnqBoaNdb34Ti5Cl9gvzOSCG1YMeLQ/4IlGX 8Hm5mlA5WcfscM5V9XD5hV66OrVs+65seSkbKC9/sWM2LYl2KW2fqHc6dGjn4Ef92qkZ ZAGm/mFg07p1dacB5RrQ0auph9YOmk5RZ7LXR9Zr0YIUvQzrYwfSm22+MZObUsoblIx6 AyTOQFLQbboSswQW7g9bFYelfuEOP2i/iDigTl9HqO4AVwbPy2GBaE9YQ6+RMqufH01T I8CV0bIUF0a9ncpSffN4f3PSZjrO4TsON0FTfuKhptCegXoFoyV1YGQqOjWjZFPXTRmA /3vQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ByagCKsj; 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-4465148650fsi97905121cf.336.2024.07.02.02.26.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ByagCKsj; 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 1sOZlA-0004qH-Rv; Tue, 02 Jul 2024 05:25:12 -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 1sOZkn-0004Ly-DK for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:51 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkl-0000C9-O7 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:49 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so23572085e9.1 for ; Tue, 02 Jul 2024 02:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912285; x=1720517085; 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=DNA/X248tgmPgC0TxVdzd0n0o4N/WEHWfZeXeWaMVQw=; b=ByagCKsjdwfkyV+Vm9i340lQTR5n6pv4HyoSVXW32zPeK64r9BGhM+AGJ4m+Gt7wzJ 6CanE+NVIZQV09YUMePb0NQdruzG5LAXOnWHWA4yPl5fERnIA9UOvKVYg5U/fGEu9m05 VRzOA0suIqUiy+s3OG7jOEQJ457QNLALFK5AUv2LJqUlnF/UkqiHWl+QFHopXKoMXP0m J59IaarKeJ0DcwZ3rMZJm/bPU0IlwXREjq6wSi0bNWlEg3DLf6SvlzqI4AObrycIptw2 TN0UAZFJch+I9uTXsA4sz50VRuWpte0jq3XQ8UhMLXrcrFDtfqhxLVRy+yi7+GxqNmbK cCXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912285; x=1720517085; 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=DNA/X248tgmPgC0TxVdzd0n0o4N/WEHWfZeXeWaMVQw=; b=TpjJ4exkBpKZoXZOhOn//ujiWykLoCm6yCGpkgDh/ieUTBDyQyxHcln095TkHBh0o1 ddfvXroNhJoYnOME50d9CF7kUC/w4ibxPGkq3qvR2gJdVFEmtgg2CRSeHtkuuNIDv6ey CfJ8c4Kc4aKMh4V1fND9geTpzq30554q0Du2CdTKiaWzabIyNcxk9R0Rx8xrkZRo+FZP zx0hsWPFvmNRN7qzDHmQuKw+LYcwYpJODSdMIDFoy+TcmZ5g7SlTzWqsdSY2D3PPPEPE K1MBGRBtzxQIb5Hw+Dz7I7vERzjGwqL/4jNRO7I0No/YSoarK7+fX0eMyr8GTQnN6c4N j1Qg== X-Gm-Message-State: AOJu0YzSZah6LoAN51qASck4f4LidMRkMjHgB38t+uJNGTl/Oy4P5yhF 0k4Q0PHCa19doGXDob95g7yLTdnFthsw3BwMka6cnYVWHZTlbikU4oLYfVCMqrvpCMH7Y9vcOVv L X-Received: by 2002:a05:600c:3552:b0:425:7c42:d24b with SMTP id 5b1f17b1804b1-4257c42d3a0mr62065735e9.18.1719912285154; Tue, 02 Jul 2024 02:24:45 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36789fd7a0esm830044f8f.104.2024.07.02.02.24.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 39/67] hw/sd/sdcard: Register SDIO optional handlers Date: Tue, 2 Jul 2024 11:20:22 +0200 Message-ID: <20240702092051.45754-40-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 See "SD Input/Output Card Specification" v1.00. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-46-philmd@linaro.org> --- hw/sd/sd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f8672b6603..e050f3d5ef 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [5] = "IO_SEND_OP_COND", [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", @@ -257,7 +256,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [40] = "DPS_spec", [42] = "LOCK_UNLOCK", [50] = "SW_FUNC_RSVD", - [52] = "IO_RW_DIRECT", [53] = "IO_RW_EXTENDED", [54] = "SDIO_RSVD", [55] = "APP_CMD", [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", @@ -2272,6 +2270,9 @@ static const SDProto sd_proto_spi = { .cmd = { [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, + [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, + [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, }, .acmd = { [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, @@ -2285,6 +2286,7 @@ static const SDProto sd_proto_sd = { [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, + [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, @@ -2296,6 +2298,8 @@ static const SDProto sd_proto_sd = { [47] = {1, sd_adtc, "Q_WR_TASK", sd_cmd_optional}, [48] = {1, sd_adtc, "READ_EXTR_SINGLE", sd_cmd_optional}, [49] = {1, sd_adtc, "WRITE_EXTR_SINGLE", sd_cmd_optional}, + [52] = {9, sd_bc, "IO_RW_DIRECT", sd_cmd_optional}, + [53] = {9, sd_bc, "IO_RW_EXTENDED", sd_cmd_optional}, [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, From patchwork Tue Jul 2 09:20: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: 809093 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118351wru; Tue, 2 Jul 2024 02:29:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXSkFzsUE5c8H9MvBJco+YhKa/WjqPnEqSJ9SXuloMglV3l5BZEdU8p+v7hWB+N5lS2mD1p4TPddzGvBVH0rFVR X-Google-Smtp-Source: AGHT+IFQv65IWE/lX4v+6hzLsjWGMIs0XDqQPcsqldRcFy7Y3wdXvlvxTPDVFEOdVMJjaZ7nycan X-Received: by 2002:a05:620a:470d:b0:79d:5b7a:5909 with SMTP id af79cd13be357-79d7b99e1ecmr1177437785a.8.1719912567867; Tue, 02 Jul 2024 02:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912567; cv=none; d=google.com; s=arc-20160816; b=EEzaL+T7xkuUJW8oDg3OAIn/uRaiQKjb8uVRpn56+eC+qCo4HaLxnzG1gjC88UOgO6 dA1Qa253dqJzbw+5q44h2pEmIROTzX7etoFI8SysRk9IkA0bYF4VrGAMALewd4nlUC6D xHH30nSQ99jFKZ9Ld8FFsKrf+mMcDyRN/vKbQJHKAHQnQZL1rSOegJdgyRifDJb/ifaI 5FvWIAJ2RIuY0XRDMQQxNS1EVTyF/2DUqv3SqC7leoslfILbl2mIjybJLJmM4PZIOnt3 UhTE3GlAjyqFL8PKWVFJE2wi1fbdr4VQXr0LiIKvECBdzs8INsPBJpO1KujDuUMEWuDx mE1A== 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=disMBuk3hJGg0W6cSmQCN+rvZQMEtFoRNmHfDWQp/Yk=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=AILpwDlEMoBTUb69wciOK3H3v7zazQyI+XsdcbM4WF0eiSSXv8FjqR2UsEP9InFNrl HQIj7PPfluyC/tZIFcTaiVUV4kGlyChGab0Lo+HM0Y6KOr8mat0h/rOZhfGv9S2P/D3y /HrAjhb4tT9SdVhD5oAahkYmwnFm1SvoWotnfrLtmkmYw0tHArcdYmy+gg95OerUmjNl Ka5QE4YEWVBn+HWG+l2BbjXeCKKnzNu8pW/D1C8QY6tgAInNQdyoHSczS60Yy8c0N8LT fpwsrlfVWLGg4Bm+Mewkvdz1EE7bQnp8eFJXo9PSL/ZHiFYZuf7tU1Rcmvg1ruRij7QF d4Fw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Um8eBSbT; 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-79d6933a162si960024885a.618.2024.07.02.02.29.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Um8eBSbT; 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 1sOZl9-0004kD-GH; Tue, 02 Jul 2024 05:25:11 -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 1sOZks-0004Os-Na for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:02 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkr-0000Cu-0p for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:54 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-363826fbcdeso2296550f8f.0 for ; Tue, 02 Jul 2024 02:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912291; x=1720517091; 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=disMBuk3hJGg0W6cSmQCN+rvZQMEtFoRNmHfDWQp/Yk=; b=Um8eBSbTqfhbp1VtkcJ6W2N1BcQH0/YXDeGNEUIPx2vfiy7KrN/UW4hR0GEQuyWx1v b4thLZF1aSMUubAVpf8TuHMZhskyxEroQddpyUUF3V/fj5i3XiAOcKgifk4b8I61Ga/1 SAaLKtlov+tthvw12LApNuR3ozrMTe7FxcpTwmDVwOGSdBmFGDktQ6LJTD/WfWs3QZCk MqzjSSTAf4Qlgs4TNrRlwy1bpcdrYjuP73JYamHKj9IpWMHQAO1vmc6s7j2M2Zfgj6qc OAX7p39MZELolUaQB8lXnFVr4zr2hWSXpFqrMO7188g/qnbNl7yzUcPaDTppO7+Yclxc rMqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912291; x=1720517091; 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=disMBuk3hJGg0W6cSmQCN+rvZQMEtFoRNmHfDWQp/Yk=; b=QNhxbjVqChxkALFzy0PcHpFBMM/b3jcyrhNpz1p+qxdvBRKkaKpCCPBVhQgoJJ9GVl oolItuKJg2lTdV2SIaM2M3GbIZxEK7VMt4LaFs6HZW8CiWWRE9Q4Hs78/PX/ek7O5mse TJXOvG4BLVUfNz1OecbpQj3uI4pwd2cpK4hBAbwvoCLQO8kCHnm9WFl/06T7SX//qQ7I hYlD+EV+JCfYSEraZ2DKZUSFDivHZvu0+RdNk2nmktQD9zwq4NA4ICD4G2uehVUF8ypy k4NyhVoUnNvogevXp5Es/2nASzSJ+OkgyUaSZbyVD+E2aqnBNFn3d4/QM0e3XIUbr5bz sOFg== X-Gm-Message-State: AOJu0YzLSkwp5D0I+vyAcFSMY1D+37ZRIpAnBvqs11GO2q6ItLcDX4Wy dQUnkQ5sUfS/8VDTXRX3i8ZEAUZcXvEVGIb+CBnN6vTDz4Ywpm+QQkXrkVe1hCF5msewtUWpfWy + X-Received: by 2002:a5d:4982:0:b0:35e:8364:f4d4 with SMTP id ffacd0b85a97d-36775728bd6mr4888040f8f.58.1719912290993; Tue, 02 Jul 2024 02:24:50 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e1688sm12672279f8f.60.2024.07.02.02.24.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 40/67] hw/sd/sdcard: Register Security Extension optional handlers Date: Tue, 2 Jul 2024 11:20:23 +0200 Message-ID: <20240702092051.45754-41-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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 See "Advanced Security SD Extension Specification" v2.00. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-47-philmd@linaro.org> --- hw/sd/sd.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e050f3d5ef..54b9ec72e4 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -250,14 +250,11 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", [30] = "SEND_WRITE_PROT", [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", - [34] = "SW_FUNC_RSVD", [35] = "SW_FUNC_RSVD", - [36] = "SW_FUNC_RSVD", [37] = "SW_FUNC_RSVD", [38] = "ERASE", [40] = "DPS_spec", [42] = "LOCK_UNLOCK", - [50] = "SW_FUNC_RSVD", [54] = "SDIO_RSVD", [55] = "APP_CMD", - [56] = "GEN_CMD", [57] = "SW_FUNC_RSVD", + [56] = "GEN_CMD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", }; @@ -2271,8 +2268,14 @@ static const SDProto sd_proto_spi = { [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, + [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, + [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, + [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, + [37] = {10, sd_spi, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, + [50] = {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, + [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, }, .acmd = { [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, @@ -2291,6 +2294,10 @@ static const SDProto sd_proto_sd = { [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, + [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, + [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, + [37] = {10, sd_ac, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, [43] = {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, [44] = {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, [45] = {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, @@ -2298,8 +2305,10 @@ static const SDProto sd_proto_sd = { [47] = {1, sd_adtc, "Q_WR_TASK", sd_cmd_optional}, [48] = {1, sd_adtc, "READ_EXTR_SINGLE", sd_cmd_optional}, [49] = {1, sd_adtc, "WRITE_EXTR_SINGLE", sd_cmd_optional}, + [50] = {10, sd_adtc, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_bc, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_bc, "IO_RW_EXTENDED", sd_cmd_optional}, + [57] = {10, sd_adtc, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, From patchwork Tue Jul 2 09:20: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: 809067 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117343wru; Tue, 2 Jul 2024 02:25:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWldg6ZUSIuDdqxhrG4OjPO0VKyr5Pgz6ux0cWFlGrokVnAPw/HH0Gea53Y9ZbbchJQBIYOUxL7bpERvHNXCiva X-Google-Smtp-Source: AGHT+IHLBSiFq2qRKaCL5aKhpVrYjI3By0Dp2QOXp+EyZM4bh3y6rkXLmLwMFzt31NGi5R4Z+S1+ X-Received: by 2002:a05:620a:13f7:b0:79d:6169:7ab9 with SMTP id af79cd13be357-79d7babf63dmr1047240285a.68.1719912345139; Tue, 02 Jul 2024 02:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912345; cv=none; d=google.com; s=arc-20160816; b=py9R1lYSSkt8KvWi/w0ipdqyjiWCJ1n3ZFRD1tgjiy9c95vjwG5WO9afKfVp4PAzo0 yXH6DLTAldteY2q8koTINj7cx9OFY9LtXXF7rQZ9V5YazpGB7rnxB3tIfKXHPv95uKj4 IVTilFwZfRqJnxSYD+U5qy87Is8agp6Wdd6GuoKlaGDrPudRjDF21BOy2ede3Nbcp5qz qWsiHGXnDI5/kuxMSF/577Ng3Mt95+YsufkVW1gn5Yf4McV/pDLGWa0iU9+kNqNpo4dK EEKP6RUjnEzHMyMsHnqe/P4X4Fyv/QgGTbpK2+IHCx3QMkOQuDSItV+qSqzJlfI62dE+ tJeQ== 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=2LarMpzFABrHElvj3cOvSN3U3cpCJlLI7z8esfggSjk=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=wHtcTHUX0jkXYvOJUWX1rLLkwMH5uMV3K7DYepFMMB+6iC3L+vhjK56C45vEKoaQgf 2+VH9hSpkFbNgP4Hu9/UoGZXD8YFz+TvSR2Wpg1hDpajIGeBp7QrP0bfbtszR4eZmjpx 93t9k7+jMDfK+HvF1kBiSXm//Sra959pfpgsNe0yx76YPm0+zFLBpAalrZB+RVBaUN03 VpKgOgejn3t6+znFSeVlETzEYQefMUFRO9x1qvUVSrNRA4xZ9frbU4ZYHrP6DkVJ3BBh evjFiN9Q/Q6gjj4Mt6i8Gs04PDEIAnxcM5DJxYAzO/XnKtZwZvmGMUIcpSONncZmZAc4 B2rw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OrGmEDNd; 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-79d6930891esi974728885a.419.2024.07.02.02.25.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:25:45 -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=OrGmEDNd; 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 1sOZl7-0004X1-2U; Tue, 02 Jul 2024 05:25:09 -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 1sOZky-0004QZ-7h for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:02 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkw-0000Dj-Do for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:59 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42574064b16so24385845e9.2 for ; Tue, 02 Jul 2024 02:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912297; x=1720517097; 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=2LarMpzFABrHElvj3cOvSN3U3cpCJlLI7z8esfggSjk=; b=OrGmEDNd822MH6A7DGmq8OKRX75lhOREqiRvseth7JjbMsaN6dXhEhcJKqEnxUPHPt HLURdfR1fFdmPSVVcgYgLdGXmljuJcRcQD3Emi+WGooCDBMrl0LSKANG3+ZWMbl7PxFA COksc+ly9ZswI5zNSPBpb015tUxf1EXA+EmCeLPr8n9Dg8IomEUCrKYsrufLwuJ4Aar+ 70R+zr68ym9t+kv1ghf0nJ9/lW/xK1SPBjaRB7bLkSFvaO7nlVQieaekpa35rO7LWGqa /XbvrcL+clCqbbf079NLt9WGogu4gmwj66xgJMQAMQKmm78kY6txpvCGIc9lh61mb+ph p97w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912297; x=1720517097; 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=2LarMpzFABrHElvj3cOvSN3U3cpCJlLI7z8esfggSjk=; b=nVcsVzqaFudC7Auimu2ZQnYa6Fj5ciMrwcBOUATIFm4zvNGfE4/4ZvtHefIdMesCol ZL4MOn/K6R8FE6r6s5X9P1nHQuLx2Y3SRGWFRoKYmw0X/zmJnGAvCfh3Ea8GiWbo7yzd eZM5IiJEi9L/GAbv0eAsb6YfTeLepXfINS453NAGSoapDsmIeTgWXlX1e8/7HJYzVx59 FqiIZW54hfohxCbPpdQj+ZUWsajeZu9CemgRbRAzRSM1xyH8Ydlr6CzClGfcrzt6e25c gH/kX79qzy7fpFHmVfcWFO6klK43KYn9LbdRz+8xsp0Dxi1Si03KyKRxo654b1BwzzcY +DUw== X-Gm-Message-State: AOJu0YzGX9e4fP9oJ88O/H3HIwM6iglmTRgRH2sNaoQv4YS0xRGWGFE5 QyhJE10WfGekbQKeVXIC0yL3/WQFXbxuDbF2/cvD14YSHhrEQhTygHohOu3depVm4kaFIc9quip g X-Received: by 2002:a05:600c:4814:b0:425:7693:3a38 with SMTP id 5b1f17b1804b1-4257a074b37mr57811185e9.36.1719912296856; Tue, 02 Jul 2024 02:24:56 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af59732sm190276995e9.11.2024.07.02.02.24.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 41/67] hw/sd/sdcard: Add sd_cmd_SWITCH_FUNCTION handler (CMD6) Date: Tue, 2 Jul 2024 11:20:24 +0200 Message-ID: <20240702092051.45754-42-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-48-philmd@linaro.org> --- hw/sd/sd.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 54b9ec72e4..5aa63f732f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", + [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", @@ -1236,6 +1236,20 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) } } +/* CMD6 */ +static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) +{ + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + sd_function_switch(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1302,17 +1316,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 6: /* CMD6: SWITCH_FUNCTION */ - if (sd->mode != sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - if (sd->state != sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } - - sd_function_switch(sd, req.arg); - return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); - case 7: /* CMD7: SELECT/DESELECT_CARD */ rca = sd_req_get_rca(sd, req); switch (sd->state) { @@ -2268,6 +2271,7 @@ static const SDProto sd_proto_spi = { [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, + [6] = {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2290,6 +2294,7 @@ static const SDProto sd_proto_sd = { [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, + [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, From patchwork Tue Jul 2 09:20: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: 809099 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118484wru; Tue, 2 Jul 2024 02:30:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUkb10RiUld4b2TleGDxlGBh2hgAqdktjXJhn9O/OEcUXmzvJFnO+gM9gcu9PlJe42agCb3Q5UrEDoCpwpVamkv X-Google-Smtp-Source: AGHT+IEC40rhH9xFF4c544qDXmR2gXSR3N7Z4mB0Z8OSHNIdUwB4TaFn1rppUWVgInocMOI7e+S/ X-Received: by 2002:ac8:4819:0:b0:446:6b89:bbe9 with SMTP id d75a77b69052e-4466b89caadmr77337931cf.15.1719912600783; Tue, 02 Jul 2024 02:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912600; cv=none; d=google.com; s=arc-20160816; b=p6RBmiR72meeapudW9tdkP2js3PAfN+g5pcbxsx2g+O+oDPyPmJEJqppwTMF1ZRhMv 9ixFNS14S49y9IZZwuFN+XX4x8L5V6YtFDRcG5AL173ZXlIqGlybblBHJiweKkwh8yxK snq8SnlgoNZ+IMhVYT/EISSahQ1vJqcOz+sgbu0vB2hthA1ycwTK1B6D/nUg/sUB+iz2 lUKlXAJoQq/ZdTt5INV4VJmUEhpUjGQSKzps8SKs+2GzHfGfkDSwrV+JSJaW4jCfnyw3 YGCeVne+AsEvyku9AAKSkUsk+rSUdNuJhqSTjWFmrNeM4T2p0gH5m47PaFWNMKMMqjqU ck3Q== 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=Zo/bpULpmegEUncNLm6vCJ+QfqrrZDPASrwEVg/COu8=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=II6CHe7KDgPxaNORTVopZzi/1QW0BrkVHc8VHozNNDcNrbp/jKOIFSQUqY4KuF+5t7 lsLsNWuYvNXEXnqZKdNWPw2C6ZPqX4DafRUc0LGGEEqYzGvvnjbvFkjaRTEM/+zqk9h/ taOxzf8rnnRYujh+VXmsrl5Aev5nOQ9dyJfBMO6U1V0k3dhdUxD9bVEz9f2btV4HNace nqQAyqK3yUre5IedGwray726SbE1DD9qU0HAQMpE2te6X5iYRikTWARnLYpA8TW1AhI7 CFWTszD39ULigChCgB4vdt5EioGnRSWaH6KiSi+rTRVFEohWPYP2fWyacYRkXXOh+U+U HiyA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aJ2g79Rx; 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-6b59e5edaf6si100335336d6.391.2024.07.02.02.30.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:30:00 -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=aJ2g79Rx; 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 1sOZlB-0004qu-2L; Tue, 02 Jul 2024 05:25:13 -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 1sOZl5-0004Um-Jm for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:08 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZl2-0000Ef-KF for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:07 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-366e70d0330so2486945f8f.1 for ; Tue, 02 Jul 2024 02:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912302; x=1720517102; 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=Zo/bpULpmegEUncNLm6vCJ+QfqrrZDPASrwEVg/COu8=; b=aJ2g79RxCsa1dDDOqTWfJ61gH3zda79vXbSDY6xigtVDNR55JTIrxLHQfyPrZc0VYA 7KgQrJfqw63Hc707nkg6g7a9XNMX7O6z1ZaQcrFkjnfrNhRkeEKSEOAZ5wlGTZe+UHU9 lFh8IHYYy9/VrPWzBZS87qp7PQfb6Whlxng0+uI6jdNc4dprGjh/DE9eswzgFJObSYLO kBVKecHeXCLiBWNnmMSFG3sBjJVSgKm4JdDS6uhrtmlHKkjhZFvGFB2JzXPRKRfHw4a2 qBz3HtZrcawZG1R/ve+psI6dW4uVvIWayXzvfZ46yuD778AeaN1UuUEURpB2v4pAPYXn 1ujw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912302; x=1720517102; 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=Zo/bpULpmegEUncNLm6vCJ+QfqrrZDPASrwEVg/COu8=; b=qtV21RWrtf+S2/nneM1SHUdija29TZJjI49humYJFdD+iM5Lb0pxqtG7ycF2VK7C+c u3cY5XcNmFhOKBQRzUHxIy7fgdfbkvcCed/Yurb09Hf/RnYL7qIYnpqVTWY1c2kO2V3u sx5BOtl/MbXkcFtE8c/mvZyc1ohvOGSbzhWZPL9LKiWdJ/YCD5dOmKnUgWPgQYD4f/kT PkyrQyTYykD8sc+Oa3Lb/eCvE+zHSj+vKsx37qsSoHpN0GnqUnExXXV6Ehx4KuRQUZtu 90Viq9SeDy9y3T+UBwV7mXo7gLgf3+Dyol+or5WaxmBlR4b0TKg7SYrCJ1XCFNtESw9O fM2Q== X-Gm-Message-State: AOJu0Yx+P6s+ocOEOFpXUS2kLEZfPI2v3qq6otstqy/EvMacXF3L6zju mDN8kZUQZ1WSLQQnov8mIFb/PqtbDu+iek0hIYZgmK/76bJMxxI2WyLq583CQF0NURDSxOHelaT b X-Received: by 2002:a05:6000:18a1:b0:366:ebf5:c6cc with SMTP id ffacd0b85a97d-367757214e0mr5316534f8f.50.1719912302643; Tue, 02 Jul 2024 02:25:02 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fc4c9sm12636424f8f.86.2024.07.02.02.25.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 42/67] hw/sd/sdcard: Add sd_cmd_DE/SELECT_CARD handler (CMD7) Date: Tue, 2 Jul 2024 11:20:25 +0200 Message-ID: <20240702092051.45754-43-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-49-philmd@linaro.org> --- hw/sd/sd.c | 85 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5aa63f732f..f83ae4ed18 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", @@ -554,6 +553,11 @@ static uint16_t sd_req_get_rca(SDState *s, SDRequest req) } } +static bool sd_req_rca_same(SDState *s, SDRequest req) +{ + return sd_req_get_rca(s, req) == s->rca; +} + /* Card Status register */ FIELD(CSR, AKE_SEQ_ERROR, 3, 1) @@ -1250,6 +1254,47 @@ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); } +/* CMD7 */ +static sd_rsp_type_t sd_cmd_DE_SELECT_CARD(SDState *sd, SDRequest req) +{ + bool same_rca = sd_req_rca_same(sd, req); + + switch (sd->state) { + case sd_standby_state: + if (!same_rca) { + return sd_r0; + } + sd->state = sd_transfer_state; + return sd_r1b; + + case sd_transfer_state: + case sd_sendingdata_state: + if (same_rca) { + break; + } + sd->state = sd_standby_state; + return sd_r1b; + + case sd_disconnect_state: + if (!same_rca) { + return sd_r0; + } + sd->state = sd_programming_state; + return sd_r1b; + + case sd_programming_state: + if (same_rca) { + break; + } + sd->state = sd_disconnect_state; + return sd_r1b; + + default: + break; + } + return sd_invalid_state_for_cmd(sd, req); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1316,43 +1361,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 7: /* CMD7: SELECT/DESELECT_CARD */ - rca = sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_standby_state: - if (sd->rca != rca) - return sd_r0; - - sd->state = sd_transfer_state; - return sd_r1b; - - case sd_transfer_state: - case sd_sendingdata_state: - if (sd->rca == rca) - break; - - sd->state = sd_standby_state; - return sd_r1b; - - case sd_disconnect_state: - if (sd->rca != rca) - return sd_r0; - - sd->state = sd_programming_state; - return sd_r1b; - - case sd_programming_state: - if (sd->rca == rca) - break; - - sd->state = sd_disconnect_state; - return sd_r1b; - - default: - break; - } - break; - case 8: /* CMD8: SEND_IF_COND */ if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { break; @@ -2295,6 +2303,7 @@ static const SDProto sd_proto_sd = { [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, + [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, From patchwork Tue Jul 2 09:20: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: 809066 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117306wru; Tue, 2 Jul 2024 02:25:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLfQiTyLQVUfPqCwMAf73afl2YHobltLKl0Z/ZL44OueyPidvCOG8Wc8pZvnwEwzbLU0tSIZ1cKDAG8quM/lWd X-Google-Smtp-Source: AGHT+IFPuQX6HcsRYPLC6lhOCGuWfCpnBHFGlGDrp8f/0kfIEupouu3rNTWIEInY6OwfBGnlsjLd X-Received: by 2002:a05:620a:578f:b0:79d:6039:784d with SMTP id af79cd13be357-79d7ba0fb25mr898525585a.41.1719912337296; Tue, 02 Jul 2024 02:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912337; cv=none; d=google.com; s=arc-20160816; b=LG3zgZzPYzq72P16wkacHJI13riDGBbKZDYqEGk2ilYwyrLp97SJ47AmAXLSbVGNdn 7TDMAymD+qreOmmP/M2g66vTN8v+whn0GjpdQWFSq4oBGYXsOEEx+o08/Bnem0Ype5iL dki6Jx/cD+JN9WRiKikJgSWae9SX7rMR2jlTB0hT3RVlin+/wggTdZUksX4CzFICiDbf dHYUBh7iMrUhTPPhaXQyYLV0SPOEdylfkDpdMhvPsQm2xNotufDVdUM5EnkELtS12oaX zKO2NRLGnln5xMHH1nwHFiLOY+1Qy0pjJsZTEv0KLHQtxLEiSzwaVRLLUkjCRTs58VCL SfQg== 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=1S0cqs0T2pBpC9otbYCEZV3ST8t5p98azNZmcVeDSZg=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=o32CDA3LWwxKJDqpn4coepmEfDrfx7cxajr+Q7cSvAdIfrVqqqCJC0FN75rvNTAFuz SvfSY1qlb1rMZ5/Lg5YeASdHkUX/gJ7EGcjdORD6R8uV2OpnbDluiUTOuGKjHJB8ZoZ/ 2XWSK0N7ByrBef7Fe7g5ibe6vdzVHy7UoUC1rtIg11cV7Ck0i0HQjUONzCFxAmj/mUu9 vxgmr8R83gKurt6Zr2osWd7tZr/UFtJMf0OixEeNdjGNi6s/qL77UmQaXmz52RK8txDj vEkC1NT0TtQlqHUAAnDZ7WKj4wjQ1JfdGUn70O7BXtQGG1ucUpPhM6l1uWsZ6BAA609R KWXg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3VxfJKJ; 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-79d69308fefsi952464185a.477.2024.07.02.02.25.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:25:37 -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=t3VxfJKJ; 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 1sOZlF-0005KB-83; Tue, 02 Jul 2024 05:25:17 -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 1sOZlA-0004qF-Km for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:12 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZl8-0000FQ-HB for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:12 -0400 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ec5fad1984so55054121fa.0 for ; Tue, 02 Jul 2024 02:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912308; x=1720517108; 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=1S0cqs0T2pBpC9otbYCEZV3ST8t5p98azNZmcVeDSZg=; b=t3VxfJKJuGfF6HrYCXhMPtl4lB/9Vlm1gly4aRkRkhFhC4hk2DMIjssp72Kah0UboJ t1lwE2vbl6kDQXH+HuUS0wy5I0qxQ+4C5dmR09KudJYqmQ9ThYQ5cXVVk9NYhoodWqn1 nhyXpWm26dVuJYQOOUT5hoIQf6WFtBClZuTGgoI3+t8spDpyuB4/37SlHOTFjAiQVLnX hGtsiJnbrzpxvGikdKXWqzEndar6DkIfKpVrj6kkLKGtY9eh8MrWUMPCaJDsZ26RP4gy 9ewaHyy4vd+C57zmEWd5pzEZpQuffh13g7lxLQhzxpm0c2PqWO81gA59vsD5O2IKHdEW 6Ulg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912308; x=1720517108; 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=1S0cqs0T2pBpC9otbYCEZV3ST8t5p98azNZmcVeDSZg=; b=YgPi2Bax+q0/vr42zR0qb2BwMYbGAS9CLcURvcbrmSrSU2lzP9qXdJrcJpqbD4LpL8 tUVD7fMk8lyXlSSnd2FumLtcvdxPSi/zAoUuFAGsNIs99qY9meALo4GA84gVk6v4maq3 +x/twS27xuIPX849VPuA+A/7oZZpR6gFc4zdvizDumE51xReXx+KLNDOIEoo5IUxCsll 5dgfu7aG8Ebq2IV9KVrAA0OKsTLeQLT1LjtR0n2MlV4i6eIphb94KTiFCRoCvRi9Z53C /VUPsqbZNgUb3P35AkO0typHWQmb3q04zSlasZXHSPj1BhdjZtZXq6uMRuvDyC/Nw6Ma SU+Q== X-Gm-Message-State: AOJu0YySOhJ9iiz1iGnmyocalyDoQwXQ+aW5qU3RkIIKtMVwhOjqM4WQ ik7kMaYOsP9V11kjY9DLTVKLjySw5oUpaBJZdbGrxrYkrZ572Xsv86bnklPX9DH53XyweDAzIJf 7 X-Received: by 2002:a05:651c:a0b:b0:2ec:3e02:9737 with SMTP id 38308e7fff4ca-2ee5e3809d7mr73730801fa.2.1719912308381; Tue, 02 Jul 2024 02:25:08 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a94csm189496255e9.33.2024.07.02.02.25.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 43/67] hw/sd/sdcard: Add sd_cmd_SEND_IF_COND handler (CMD8) Date: Tue, 2 Jul 2024 11:20:26 +0200 Message-ID: <20240702092051.45754-44-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=philmd@linaro.org; helo=mail-lj1-x232.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-50-philmd@linaro.org> --- hw/sd/sd.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f83ae4ed18..1bde4c9f7f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [8] = "SEND_IF_COND", [9] = "SEND_CSD", + [9] = "SEND_CSD", [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", @@ -1295,6 +1295,27 @@ static sd_rsp_type_t sd_cmd_DE_SELECT_CARD(SDState *sd, SDRequest req) return sd_invalid_state_for_cmd(sd, req); } +/* CMD8 */ +static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) +{ + if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { + return sd_cmd_illegal(sd, req); + } + if (sd->state != sd_idle_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->vhs = 0; + + /* No response if not exactly one VHS bit is set. */ + if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { + return sd_is_spi(sd) ? sd_r7 : sd_r0; + } + + /* Accept. */ + sd->vhs = req.arg; + return sd_r7; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1361,24 +1382,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 8: /* CMD8: SEND_IF_COND */ - if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { - break; - } - if (sd->state != sd_idle_state) { - break; - } - sd->vhs = 0; - - /* No response if not exactly one VHS bit is set. */ - if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { - return sd_is_spi(sd) ? sd_r7 : sd_r0; - } - - /* Accept. */ - sd->vhs = req.arg; - return sd_r7; - case 9: /* CMD9: SEND_CSD */ rca = sd_req_get_rca(sd, req); switch (sd->state) { @@ -2280,6 +2283,7 @@ static const SDProto sd_proto_spi = { [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, [6] = {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, + [8] = {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2304,6 +2308,7 @@ static const SDProto sd_proto_sd = { [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [8] = {0, sd_bcr, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, From patchwork Tue Jul 2 09:20: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: 809075 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117651wru; Tue, 2 Jul 2024 02:26:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWjDiT6LfN73umtpwtcHRaGze3RvhNM0bnci6B6D8LORBJKfAEhbjzGlC05CzyDHdGbuOk75jgmwK+scVkZdDVB X-Google-Smtp-Source: AGHT+IG62GDCkOJGt22D/TxUVEKW1XMdfK3tK89EZ1sivlrSAOonmOnQoacmHkkT5akUqyT9qJEu X-Received: by 2002:a05:6214:dc1:b0:6b5:7fa2:1e98 with SMTP id 6a1803df08f44-6b5b716c04cmr108434696d6.49.1719912410113; Tue, 02 Jul 2024 02:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912410; cv=none; d=google.com; s=arc-20160816; b=vNAIJ9szIOaigGzy45biM4VGjUZ40ZxXcsCle2RLP5roFespnPNc+TeWIp8NnVP2zN iLdQedRN3qdzc5SdbOcRGoeLVAE0lyj5X8ACEMaM/kRJGHJfTQz16qfgboiVk8ur6czX e7NJf9NslEe4Nx4AD5I4vqdSJ5jAVpkje/jBkMUFDutm6xmKPISYzEujVhtXpv6HFdJR +Wx11plg3vcPghNmvPLFi1BuhNTnlR1GkAGx+FYHcKaTFkNqCAbjnVGeJnX0B6OzHdbY I4s2PdbdtxDQ0HgIELqPOUzll3PtuwsXq90W19IeHAumYs4ndwCia+B4MzIN4A8EoV1O GVKg== 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=6+3xD1MV1Oqr8vKeJ5znDbygAt0rxvWxpBRrwLtzXO8=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=r0DvoE1iRblUKK8eW4buB3tFYgo43dcLuGKM3UhDumca8NY1+h8umC3b6qNHteQ4fV ziNnnZQQqfQESMGaf+RQ52WHYbOjyzxINiIBzP8s1DUtCzhAJiUGGFB1K0lVv8g8lhFu Vi3fmO+vc0/bIjALx09oPzqeF1phKUGJr8PO0uHdhAuoj4ATmOR4Iv5QN9+ayS+imopf 0lTN+iilzE7Qt0cweAquWzKCwQjAuXguEirq/ma6IqGJwTAgxFHcOpgf2ycWjxXOMwVl m2SIQwg8Phm1O2ULYr3NeA1fP+qgZHa77LkOcYzrahVJaZ1P+iYRoo0YBlli3G46Wbll uXdA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H+6Tt3s4; 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-6b59e5eb821si99387636d6.341.2024.07.02.02.26.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:26:50 -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=H+6Tt3s4; 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 1sOZlJ-0005tj-MX; Tue, 02 Jul 2024 05:25:21 -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 1sOZlF-0005by-Sl for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:17 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZlD-0000Hw-Rf for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:17 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-36786081ac8so217682f8f.0 for ; Tue, 02 Jul 2024 02:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912314; x=1720517114; 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=6+3xD1MV1Oqr8vKeJ5znDbygAt0rxvWxpBRrwLtzXO8=; b=H+6Tt3s4xAdHftTiPowqHvL7FnsI8x4whdmO2HUzPl736tqYS5+uqkN0CJbOsMYYlc kJBJfBZhSzTMMgXitm9k+/rX7m1nsHa2zBmHJdUDkJbFHf/QsuCIMV6PfgVZY2Vp+yEE Yos9Qc4f/IpRI2YmCIZow/GSZPDaOpoFgLSKTvP+PVS1trDyum/XbwLIcNaHBHolJNRI IblIzjcrhrL1dWikdwycvd7/+TfA/0Mhg/xXgG2fg2CkWhFE1lw0TvSasNRgwTOhe6cx geoEkJTcCtZiVKwgv7t6db/gKJca4yd9bANGu904oxyKDd6qp6QL08mR57ZLpRrHOsoU /LPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912314; x=1720517114; 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=6+3xD1MV1Oqr8vKeJ5znDbygAt0rxvWxpBRrwLtzXO8=; b=lUuJvSYUUXf5YHnnmK6G4ZyrtPNESh3mEHePrB0UMFA8DjIDB5wQEVJXzxDJaIWNMl 2Tc1LTLuvxHY+iF4C8GV4KHND3gNaICPm1ktfiBndaCLBVqjDtDJw0dePbYlIxKP79Vv PKb7zZSKbEfRuqsNr/6mbGcvAp2Mw3gO8ETsX8GjeHN9T2cRRAkVFfaigOQVF1+y+Uv1 P0BtkdalUppbKaE/LN9zQMwpoCFNRj+9D9PPdIlz1E6m8nB0etvn8AOh+kP4KR0tKJtl Zsz3RSWacPHAbRosQxk3LPvxOmFY51aHl3BnZHoyZ7M3EkjsvRBskrg/6E/veUANQCJ6 YhiQ== X-Gm-Message-State: AOJu0YyhLoqFQOfxQ04ROfTZELTYaSFH1+zWeDnzDDu4AKiSr8p0muVo SM4WckcksV3NDXUSvgh6AQDTovvUx8V0x/YSsj81OChtI8JQL10ndbear0I0nwrKs3xvjOGo7/m 9 X-Received: by 2002:a5d:5f4e:0:b0:35f:10ac:ea50 with SMTP id ffacd0b85a97d-367756cf30amr6092659f8f.37.1719912314122; Tue, 02 Jul 2024 02:25:14 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d9148sm12607592f8f.34.2024.07.02.02.25.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 44/67] hw/sd/sdcard: Add sd_cmd_SEND_CSD/CID handlers (CMD9 & CMD10) Date: Tue, 2 Jul 2024 11:20:27 +0200 Message-ID: <20240702092051.45754-45-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-51-philmd@linaro.org> --- hw/sd/sd.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1bde4c9f7f..e372f88073 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,8 +237,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [9] = "SEND_CSD", - [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", @@ -1316,6 +1314,26 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) return sd_r7; } +/* CMD9 */ +static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SDRequest req) +{ + if (sd->state != sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + return sd_req_rca_same(sd, req) ? sd_r2_s : sd_r0; +} + +/* CMD10 */ +static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) +{ + if (sd->state != sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + return sd_req_rca_same(sd, req) ? sd_r2_i : sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1385,12 +1403,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 9: /* CMD9: SEND_CSD */ rca = sd_req_get_rca(sd, req); switch (sd->state) { - case sd_standby_state: - if (sd->rca != rca) - return sd_r0; - - return sd_r2_s; - case sd_transfer_state: if (!sd_is_spi(sd)) { break; @@ -1406,12 +1418,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 10: /* CMD10: SEND_CID */ rca = sd_req_get_rca(sd, req); switch (sd->state) { - case sd_standby_state: - if (sd->rca != rca) - return sd_r0; - - return sd_r2_i; - case sd_transfer_state: if (!sd_is_spi(sd)) { break; @@ -2309,6 +2315,8 @@ static const SDProto sd_proto_sd = { [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [8] = {0, sd_bcr, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, + [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, + [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, From patchwork Tue Jul 2 09:20: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: 809098 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118474wru; Tue, 2 Jul 2024 02:29:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUy9Nyu7GhsQQmPGoYfjYbf7Cztbf+jBNUgyuHqV/n+XZGI8edwe2TXB5oCkElwHZttVRLUbeJACJcPtVYo5ed/ X-Google-Smtp-Source: AGHT+IE3hLMGbeXJOSc6Pxf/cNJSnQ3rQS+srSzPHNOg/xDTxwmTSyDQNf5taZDizEBQ0DBBJfCV X-Received: by 2002:ac8:5793:0:b0:43f:f291:120b with SMTP id d75a77b69052e-44662d97766mr110464191cf.24.1719912599357; Tue, 02 Jul 2024 02:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912599; cv=none; d=google.com; s=arc-20160816; b=XsMOBxJ/7yfdgJ5joz1Ekkb8ilM/14VO6vy1jf/IzK2XMcIaYPxIHo8goSZQelltAg Ld799SnH3vGdYHsiQNOi44ncdnNDiH8cZujFb9rlpNvtip0XN5Ud8rCmulGC99j2fbAz N2WkmgKikAM1jUQLXwbWuwZkOTIlR1Cb4bdcwHCjNHxY0E5BO+iqH7fNdRPbGI2kK7kH p1SvAMfbXXg6e0KRTBMw7mP1eO39BCSBQsxIyteXdtl54sadrqf2tOikL+69bkXky0+N Lr/bzqxDmeNul2lavHQlijPVOQ5Sd3CwgbcFnkSusHD9mX3weRpN+YEkz5R9hhoeNVk3 WOfw== 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=vw2vdkreXbtxIWqVAzubzR0s305Wl62ih68f1l2Fwrw=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=dVkh3KHYb/73a3MAB+i9Zm2k4z/MzHI2RUPhVWFqHBzCoCbU6JMB1sG3Obv8gPpHTe 3b39BWFhwEf3aeNVQ2usPkxlX+qw62oncqau7PUsu/txtecYVvTVmYqUn9NKhQ/Gfkg/ itYNRPvQrfc4hICNX3Ds9lsiCaUYZmSBDxdNGUYhuZ5DzmCB6dJH7y1pR6UlFswg3+Y9 XZGkKH3KGX50fvtYk8+holZvN8jwXSHD4kvL/oMaA0Op+8SUbLIUOdvLHJIN8A9GKfGx ZFnx2J+K3uOhczCuEcM52L9VhQ7ZOljmxaLNooMgFDAnNP6mKWBJmxGRknLWdb7Chdfa RWUw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UhUpUBym; 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-6b59e3625d4si105965166d6.51.2024.07.02.02.29.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:29:59 -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=UhUpUBym; 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 1sOZlW-0007Gs-2o; Tue, 02 Jul 2024 05:25:34 -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 1sOZlU-0007Ew-6K for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:32 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZlJ-0000IQ-LR for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:31 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-425680b1d3aso27252855e9.2 for ; Tue, 02 Jul 2024 02:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912320; x=1720517120; 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=vw2vdkreXbtxIWqVAzubzR0s305Wl62ih68f1l2Fwrw=; b=UhUpUBymf3npmi5uiv2Y6fq8DsLuUDKOxW98FihlxPZ88jJToGXkJt1tRYbgsZVmTM T6XFGe76qRXULUMtRFfwIR2XPJYsqo68n6Q8VO1OmG28RX/cK4oASCcOVc/qP5q2qjyG UUO9vEgReTqwRwmL45X7uyCv+QRth8BlyPeuoMWBkJKpaNdD3hKINBw64cr6jHWFWv2G hU8yJyt78O8WtfA+5oOhQYwkxH+8xmH+I4PEk9kMVHYvdHkmDPdgKwlu20gGI5v9OnSy WLgwxd6kAoIw5UFziK5Fxhexe52N70Na5SAr4dZ/Xbya+FFaBEd74bINwMzvsbvuZIaT jfhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912320; x=1720517120; 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=vw2vdkreXbtxIWqVAzubzR0s305Wl62ih68f1l2Fwrw=; b=ILJtwksB+jAuQRoEVg3KMf3nUHHlNbFz56P0n1jSyTdx025g1XMl+De6lAV+wp4YgK GnFGW11R1VbT38ZkuAnaAj0c/KEtrxKlM6KVt4LEQjxQMqT8Pz3pXRQaF0GFyxYSTUYC Ct+I4+3nd4LNLIDi6wKKq47rnO5vwbv8Fme9U95WkYWR9ydI2xi/PXVU79v5l0kUOlsR qwULyqn064QY7ClLWJWiscvqV/kOacPaAfmKdCEL9JJDU9oNSmWFXiuPOyDvcJsPUXbc GJ8y9NEsXnFOlCnWmK/GHwnaBsEhXh690xCpnpPTFQrQJ1e6icNy+4hLMcZOxhQ33Mla qXkg== X-Gm-Message-State: AOJu0Yx1OJLldSTarm8iBKp58CHz9zF8/Wu3qIcfih1LhsdCPazPc3+i FpnROdAHE28juesOaCPbSaXIM6l9OcqxLYJse0eMCeX5t798VKW9JHuH0fy4OLrd1zTIZ/up8/J Y X-Received: by 2002:a05:600c:2252:b0:424:a823:51d9 with SMTP id 5b1f17b1804b1-4257a06e036mr52088665e9.30.1719912320009; Tue, 02 Jul 2024 02:25:20 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a043a16sm12808371f8f.0.2024.07.02.02.25.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 45/67] hw/sd/sdcard: Add spi_cmd_SEND_CSD/CID handlers (CMD9 & CMD10) Date: Tue, 2 Jul 2024 11:20:28 +0200 Message-ID: <20240702092051.45754-46-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-52-philmd@linaro.org> --- hw/sd/sd.c | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e372f88073..49fc79cf8a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1315,6 +1315,15 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) } /* CMD9 */ +static sd_rsp_type_t spi_cmd_SEND_CSD(SDState *sd, SDRequest req) +{ + if (sd->state != sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->csd, 16); +} + static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SDRequest req) { if (sd->state != sd_standby_state) { @@ -1325,6 +1334,15 @@ static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SDRequest req) } /* CMD10 */ +static sd_rsp_type_t spi_cmd_SEND_CID(SDState *sd, SDRequest req) +{ + if (sd->state != sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->cid, 16); +} + static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) { if (sd->state != sd_standby_state) { @@ -1400,36 +1418,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 9: /* CMD9: SEND_CSD */ - rca = sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!sd_is_spi(sd)) { - break; - } - return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), - sd->csd, 16); - - default: - break; - } - break; - - case 10: /* CMD10: SEND_CID */ - rca = sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!sd_is_spi(sd)) { - break; - } - return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), - sd->cid, 16); - - default: - break; - } - break; - case 12: /* CMD12: STOP_TRANSMISSION */ switch (sd->state) { case sd_sendingdata_state: @@ -2290,6 +2278,8 @@ static const SDProto sd_proto_spi = { [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, [6] = {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [8] = {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, + [9] = {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, + [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, From patchwork Tue Jul 2 09:20: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: 809087 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118060wru; Tue, 2 Jul 2024 02:28:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVcdRN9Ghr5gRRzRuoaNfrq6+eUFhvQgIRtNTaN8/fAxZeRmO8PU7WrQuc0HsmKC+AF+NYQThQGyQNHN1fcwFLd X-Google-Smtp-Source: AGHT+IEeIpbw63bMTNpD+5DPotZQfHKhkWYiWmzwq3qB+bs9APtHGARE7fgrvAnY4wAt8Tyr/E76 X-Received: by 2002:a05:6122:3712:b0:4ef:5db8:fe15 with SMTP id 71dfb90a1353d-4f2a5687c6fmr9040000e0c.9.1719912499722; Tue, 02 Jul 2024 02:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912499; cv=none; d=google.com; s=arc-20160816; b=zLyK9N9cFI+3g+GB2vYegPVZQQlvCDebbBA47EE76cwcMr4Hiil/fy/ju1zEW8/yeu tCoxWsC2sA+1EkJSOrhnJaOoJe5lCW7Z3Yrro2GiA5/C12ffc+WgVzUaipVkBm6o+LzX F93r2HU1bqYWih/1f0DwWvTB49Z9eK7n2QdkM8dLbD19tmWO4sV7myBlqYOiB4OB1sXD TuW7ZBYVKd4XZybL+kyAsyVDheFt4sKp+0DkQSv7/4XxQ8+P5Qbo2IoosU4hb/mg2Jpj ZfpAGFrBiqvyMH9m8YGYegpRdpomboOLCkvOBFEi1wWKu3djF+Jv+YG00dzcRyzE/0sF 4vSw== 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=01K5Fpbyc/Wo8G4gat2aNkWhP6GApv43W9gex3KjoA4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=Nprt+jk2fsNBv9P8C6ujEKk/SDmb0altjc3ggxwUU+j9/PSVptv15zkI8OpKPss6Iy /TQDYp20KElVNykJMN8RbOXKGjLj5IzoPFx+qFpP4BxKpDUSscoebRsUtXVhTzVmkxbc pxM+M+6p7yxBEyOU8XKUyFjbJUrjCNIg+me5h/qrgsJXTp/YKXLAMQYt5yHVEQIrtJQZ SxP6GWSgSbmH7POms5QAGqoNx9RJ3HSgFk2bUiJxsatYdnY7zyTUAL/lh4tHf/OYdqFp oU754i8Hydgm+FfQYEUpME4yLmyOrBUpjSAhoAreCYUFAbsG/IM/yQengYhChufLPFp7 I01A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="l/7Zckfm"; 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-44651485f23si98360581cf.276.2024.07.02.02.28.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28: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="l/7Zckfm"; 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 1sOZlY-0007Iz-2j; Tue, 02 Jul 2024 05:25:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZlV-0007Gp-P0 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:33 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZlR-0000Kh-Ip for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:33 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42562a984d3so27643685e9.3 for ; Tue, 02 Jul 2024 02:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912326; x=1720517126; 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=01K5Fpbyc/Wo8G4gat2aNkWhP6GApv43W9gex3KjoA4=; b=l/7ZckfmQuOxDaDpadrInrH27qXXzF7C0GsJ/Kw7hCtQ6JigmKQkxIOKE00kP8N7rU z+oNwLaqaMSAuNsYgWMRb7ysphIKUgybhrAZZD3gpO6vVtAy6JMiWJNt1U4B0nzbR2nu kU2L55MvVgbrODAnyXOqLYPrBdAr7TCI2FMJNeZdoOgx5aJdmEGDLSecvhiUlqypS2vD vpzlEJS0UrpApAwks8dcDmL89x8N+kDnz8338AaC+w3z5X8XTPxufF0fa69mlv+zOclM hUUqRitfcy8rbYfrpSwhB0JLR+WyKDuSDvVUrsNH2YfAt8iH17vHRtZb5kx/W07bBvCY GYVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912326; x=1720517126; 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=01K5Fpbyc/Wo8G4gat2aNkWhP6GApv43W9gex3KjoA4=; b=gwIWL4xvcwyP0vTp/u4nbLrigfi3TXJ7JKytX+8Sg5Xfo3AnM5hyy+ovcQ7op4/XHx gnv/ERYmwpQGH4/Ynz1LNJJY9/tP9kWGw/hetmaUzPLPA2SoWJzU9PnZgIYLDJYHm8zI iE3k9Szvdjv6wvEnkq9XFss765NCzWMzjc47ZKzGrfgFaxyXwX8ciEuuzmg7pRxbbVfO e3eJo1vXfblxGFnZNSnJBOZgT1/zfs+Qgq6hyoGxj9bFowy5u/S6MFPpd+v2usCk+NH6 lOgVLZzcEy3vRtoAE1OIE6HXRcJ2L60/cstBh5MUM2/RLuQmaiyBA2dljGczNfm4O2D+ wSBA== X-Gm-Message-State: AOJu0YzrCg3JAHHX8op5uqgfGpn6WtuwPahYcPsYQIpIYdmWmiNAWEBP k6y5M5tmCukNqEx15rGRowcNveZTrvy08Fmqv5otRFZOA1oBaqMnFh9/e8Nem3vBkgA0nX0aphX g X-Received: by 2002:a05:6000:2c5:b0:365:32e0:f757 with SMTP id ffacd0b85a97d-367757214bdmr4490900f8f.50.1719912325832; Tue, 02 Jul 2024 02:25:25 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675f9dfbdbsm12298117f8f.103.2024.07.02.02.25.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 46/67] hw/sd/sdcard: Add sd_cmd_STOP_TRANSMISSION handler (CMD12) Date: Tue, 2 Jul 2024 11:20:29 +0200 Message-ID: <20240702092051.45754-47-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-53-philmd@linaro.org> --- hw/sd/sd.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 49fc79cf8a..0a554d30a2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", + [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", @@ -1352,6 +1352,23 @@ static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) return sd_req_rca_same(sd, req) ? sd_r2_i : sd_r0; } +/* CMD12 */ +static sd_rsp_type_t sd_cmd_STOP_TRANSMISSION(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_sendingdata_state: + sd->state = sd_transfer_state; + return sd_r1b; + case sd_receivingdata_state: + sd->state = sd_programming_state; + /* Bzzzzzzztt .... Operation complete. */ + sd->state = sd_transfer_state; + return sd_r1; + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1418,23 +1435,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 12: /* CMD12: STOP_TRANSMISSION */ - switch (sd->state) { - case sd_sendingdata_state: - sd->state = sd_transfer_state; - return sd_r1b; - - case sd_receivingdata_state: - sd->state = sd_programming_state; - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - case 13: /* CMD13: SEND_STATUS */ rca = sd_req_get_rca(sd, req); if (sd->mode != sd_data_transfer_mode) { @@ -2280,6 +2280,7 @@ static const SDProto sd_proto_spi = { [8] = {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [9] = {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, + [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2308,6 +2309,7 @@ static const SDProto sd_proto_sd = { [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, + [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Tue Jul 2 09:20:30 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: 809101 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118515wru; Tue, 2 Jul 2024 02:30:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUk/5VfsTRUEkOB7XPByY9oTGvTIJHgMsiOWtXFxmI68E4PF/8gjJPpI4ldQGc6vWSD6VCtwM6YTJQ3tEgU2tWJ X-Google-Smtp-Source: AGHT+IEETRzWPkqMc++T3eggzWfL1mnwW38LCZgpFRflbbK3tbREB/DoCXxPhF5Uj6YwdnRHLkpM X-Received: by 2002:a05:620a:200c:b0:79d:6e0a:f3f5 with SMTP id af79cd13be357-79d7b988286mr781724185a.10.1719912606454; Tue, 02 Jul 2024 02:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912606; cv=none; d=google.com; s=arc-20160816; b=v+xp5/uJpfvERGXZd+jdUq1LCjMsoju2T/PR9eQi4vpYWTokn3LnkGLpt4PRyfOHVT f9KfnUEZuaZU4LdyNQHaUmR0KjOOKZKiu1fWdLLicGbYgrc74Yb7FkhLHHKAG6gsgO9o N3nIzrM5rxP9BcKYsU+A2ds5JeKJbZDX2xWJCCGazYaY8/L5gaFJhIL2ZHSeXCE/vile JXVdVywVlVQgeokBx+A7ntD73FNe27Kbhi3Fl6yu0ddJRtdUFzHMGCE+M80V1v45CDf2 tgL9jXH1DUGsAIjB9/CcarxCBsmfyFUuRJ2v/kY0kPZvtcjAe/daS75oDx+aFUqFPV8O YBAw== 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=W8u75s6/EWdwDgm8HUCe5acoVohaEm/dxjOCFeqWaIc=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=jp1bjPyLjzJhPXhWeTW1V3Cdok95u2XmTg9xqiPXZACQRxeu5QHoLPEmYu2P2yMjNI DLLgtHm7xAwK3vVmYUkufJvFvveS8sWPgYvMULap4/Bp3oNJUPB4ChQ8TL7w2H/4/T7W QOsbylOFAWcX4ojHckB8xHHSackm/XxHen4Kmb8EY+A0zS3kXQbpdn1BJ3HBng+YUeC2 I5Lim7oRzod2h+8jZ8JBRimXBOlzMwrc8Or7m37GIgCL5IIonM5N56OlKAkBLYwOoQuw HBBpSEikZMuGtk1RbL31gQVB7GXf8euSEnsHanw5jkfpSwNhQJTcCXE+BQzdaeiUMOud 1kYQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ti3q5STm; 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-79d6933181fsi1027086485a.551.2024.07.02.02.30.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:30:06 -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=Ti3q5STm; 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 1sOZld-0007cq-CY; Tue, 02 Jul 2024 05:25:41 -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 1sOZlb-0007X5-MZ for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:39 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZlV-0000SU-HR for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:39 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-365663f51adso2403940f8f.1 for ; Tue, 02 Jul 2024 02:25:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912331; x=1720517131; 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=W8u75s6/EWdwDgm8HUCe5acoVohaEm/dxjOCFeqWaIc=; b=Ti3q5STmBqozmz6qOelHkKVFAewkGkscXME5i42wQSmmEuwUxx0j2J5HCKLpUrRFmX zur3JGI0sgnoFj5HxMAgBOl8H6Vp7rosDpnAOWC/Ucm71AW2XLWVhv/D4mXNpB+vsj+s Zon8RLJtIiB5qpbhi7HlutZlcUsWyR+tP0VV6g+FVKmXOn5LUqZW+IV81HBAqSPeMN0c i16D66TKSrHBq920v8ceKrLtpDz7MMD6jguV/gf+S6dPyoCfH2va4GH+nD84XrA54W+m SYnPlI51qmEJlFlVdkF+PymO0WVksjth4y8uNQxia5ZLb6+Sis27R1vi9ulyVZCL6t/g 5G+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912331; x=1720517131; 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=W8u75s6/EWdwDgm8HUCe5acoVohaEm/dxjOCFeqWaIc=; b=asVIcVwod8UfypO/Bu3ayrru89oL0P/2+9sZ93N2KSCb7EGn68Zy1CSB7KWjwQnGZh lvBncI1vN4r3kkMN8k9LAGjkvx+jI9Kmepymtc2MANIZHx52CeV6EXHimQyDB1jpOyhm trvNGQXbV5asbeOXaVv1oJPkr8KaNPUwoEdj24YhxanrF75FR9WhhrQ7uxWFG9qoypF7 RTk2zb7OuEt1TlEimEXII/9ZPayfc8ywDUIgKpYRyxw3zjXXQfmv3USgy5j18me7+lL8 3hx6OtmQogoYTqLlrJVViCgyOdC/O710KA2aCkGQxt/aVLexC8i2uq2t75Af51O2ItsJ RT4Q== X-Gm-Message-State: AOJu0YzYVE8+1YUS063IQO/JftR8cdydk75YMNFAAcYwwzLIIA83rA3V TLkBbRWgm/xQAguhw2lMzzgPkuuvo0zj54tplwjbO+D5lw1D9P2KvNsbniFRlVZr971rs3MY7IX 0 X-Received: by 2002:a5d:61cf:0:b0:367:31e0:950c with SMTP id ffacd0b85a97d-367756bb627mr4769624f8f.37.1719912331568; Tue, 02 Jul 2024 02:25:31 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd60dsm12680069f8f.2.2024.07.02.02.25.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 47/67] hw/sd/sdcard: Add sd_cmd_SEND_STATUS handler (CMD13) Date: Tue, 2 Jul 2024 11:20:30 +0200 Message-ID: <20240702092051.45754-48-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-54-philmd@linaro.org> --- hw/sd/sd.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0a554d30a2..426144c659 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", @@ -1369,6 +1368,32 @@ static sd_rsp_type_t sd_cmd_STOP_TRANSMISSION(SDState *sd, SDRequest req) } } +/* CMD13 */ +static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd, SDRequest req) +{ + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + + switch (sd->state) { + case sd_standby_state: + case sd_transfer_state: + case sd_sendingdata_state: + case sd_receivingdata_state: + case sd_programming_state: + case sd_disconnect_state: + break; + default: + return sd_invalid_state_for_cmd(sd, req); + } + + if (sd_is_spi(sd)) { + return sd_r2_s; + } + + return sd_req_rca_same(sd, req) ? sd_r1 : sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1435,17 +1460,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 13: /* CMD13: SEND_STATUS */ - rca = sd_req_get_rca(sd, req); - if (sd->mode != sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - if (!sd_is_spi(sd) && sd->rca != rca) { - return sd_r0; - } - - return sd_r1; - case 15: /* CMD15: GO_INACTIVE_STATE */ if (sd->mode != sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); @@ -2281,6 +2295,7 @@ static const SDProto sd_proto_spi = { [9] = {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, + [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2310,6 +2325,7 @@ static const SDProto sd_proto_sd = { [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, + [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Tue Jul 2 09:20:31 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: 809082 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117856wru; Tue, 2 Jul 2024 02:27:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWRiahD/FrshP6mbV4Itilj6beT4YWLcIz49EctgS5bPSS4OUjB8cKnRCwAoK7tYvLe0vZD+DJeqb+WeCvipIFR X-Google-Smtp-Source: AGHT+IFDWQ6xefAWSsY7y+Y050OitJ0DIfE2t8jHnC2xMbuttu+4eUOKShUad61LvKqywi04Oxu1 X-Received: by 2002:a05:620a:4110:b0:79d:6a25:c872 with SMTP id af79cd13be357-79d7b9e12a2mr1286392885a.29.1719912453966; Tue, 02 Jul 2024 02:27:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912453; cv=none; d=google.com; s=arc-20160816; b=rZDr8miYIn4MODztVGMekcw0TPscazzy2ngWq7uUS5Fe9TGtlfvS7fUwO2LY9CKKqP PmqkH3oHzKMrMPN0ClqK2rsO8fXNh5qzXXlQXEp/z/Sq0jFgiqZJoyszllAOoIFV3wAh yDDJ6mq5xnMMh0xPJ8ytDJk85cHnpOlEHvcUiWLBl4UXhYU0wm9i92iUeZzwocsI0FYt GxC1r7eSBinZsEcTA9rE+Pw934Tm3/UT1JlmmxlmfZWTfoXpGgKzOljVfunmW8PY73xN Y5/No8a0NRzAL2xz/6YzPmmWyjQybays+91s2LuQWoyAhub8WBLeMHi2RjyCe/KTGtI+ 2P3g== 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=NsTleHfMR+jNkMLGT2+7/tT9zaWyW/qieWJj1402poE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=REGrvRsYMZ1jwqteBv+uClfXKHR8w8rgFKLd/HdWKcMhcIARDhZC08Kg0bFMSuXzqy aptXQj0WCgp5JMKwRxlxWLkoFS0FqTBKlEOOwCLA54zyLskSfBwE2aDML9/BUiZVu+G8 eD8xpljFc2ZjgbL9W9w/iDCXtWF21idyzrMAMQuTL+4Ah2YHHy6fcq2ib6I0E3vF8AcV OCbafzEr5/XeSm6XQm1KcnMIwBGokvu6+6ZpdMnTajx74iwaWcWvCsVBvZVOPS3QA8xO dJCqKPEFlgMI0XTKJ2S6lS7f2SHvGA1irjSdbiaSF9qDhqh2bFizAq5mxV/PAKn+lb2d fVNw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ai7gSsbe; 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-79d6933b2c8si970245185a.678.2024.07.02.02.27.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:27:33 -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=ai7gSsbe; 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 1sOZly-0008Mi-Db; Tue, 02 Jul 2024 05:26:02 -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 1sOZln-0008Dr-Km for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:52 -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 1sOZla-0000md-WC for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:51 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-425624255f3so23638235e9.0 for ; Tue, 02 Jul 2024 02:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912337; x=1720517137; 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=NsTleHfMR+jNkMLGT2+7/tT9zaWyW/qieWJj1402poE=; b=ai7gSsbeUAUQy6vTqJLuFmpcdNT4cfbH9xG19nt958Fu1zPGtHSYZoNWG3z10bI7pt 2VsgJCTHvjDOePfi2tRKj+whjmNqLz5reAq6CzOwaRL7pVsdgbNyAYiPXKa7j9NF9NUA KxBWwBZbSvfqSoLUwSPmoFTAG5QQ5z7q3n1dyWdc+66zzQLAQEkbss0MrNDsNojCI84i LiS7NgSF9sGVLX4XlOtxbX0Z8m7mxJ1jpPXodbU/8eJU97cQ38gJEYRM/Nck2JBYGoSo ilDVuQ2+75Qzdppx3pkJrS1+bNmTFTx+o5Vtl6B4jChQLCBJGzVZ1WafDQIZUVhQzp3K R3GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912337; x=1720517137; 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=NsTleHfMR+jNkMLGT2+7/tT9zaWyW/qieWJj1402poE=; b=A880bi18W3PlSNyYmPHQZSQd5y4YkFk9trh00pU9BxXHRf/gvD6wVYKQi31xf9+XX/ PcNQabNJswV4ZmQ41jBdPt6NW1PTc8QRb7c+D1TwWB+t4cVOkFD2HlJg7kiH2LgRMir2 E/tu+8sPtpEV6QUSrk0ex1r8aD1OMjxSNzuHOypJJdb8sWcddfaYR7DrS116vCsFzWCb +ePyUiIalmm+VMLnRwz+s/melU8peBeF7/xOXgObTlZqY11tI+Rmy8bAmSL98W7aqP0y ESzgXQjC0uvrx+27NC+vH2sdI4ryJIFvFoR3IVBWxkkECMyd/oByO1kchFUEuDzo+N5f Mjaw== X-Gm-Message-State: AOJu0Yx1usO15toaHnH/duZuvWabBVR3oIEW+3YSWjZS3cltpHsWVJsV slXn3zj3Gz5pED9aTvd6OWb386J0lmJZYM4YoXjmqwCe9dhJbIvgB/Ly8ovtebEo9uBEl2RO6QV M X-Received: by 2002:a05:600c:4749:b0:425:8cc0:58b6 with SMTP id 5b1f17b1804b1-4258cc058e4mr4313835e9.14.1719912337363; Tue, 02 Jul 2024 02:25:37 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42577a0c286sm97143495e9.0.2024.07.02.02.25.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 48/67] hw/sd/sdcard: Add sd_cmd_GO_INACTIVE_STATE handler (CMD15) Date: Tue, 2 Jul 2024 11:20:31 +0200 Message-ID: <20240702092051.45754-49-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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, 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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-55-philmd@linaro.org> --- hw/sd/sd.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 426144c659..56b4b274a1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", @@ -1394,6 +1393,30 @@ static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd, SDRequest req) return sd_req_rca_same(sd, req) ? sd_r1 : sd_r0; } +/* CMD15 */ +static sd_rsp_type_t sd_cmd_GO_INACTIVE_STATE(SDState *sd, SDRequest req) +{ + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + switch (sd->state) { + case sd_standby_state: + case sd_transfer_state: + case sd_sendingdata_state: + case sd_receivingdata_state: + case sd_programming_state: + case sd_disconnect_state: + break; + default: + return sd_invalid_state_for_cmd(sd, req); + } + if (sd_req_rca_same(sd, req)) { + sd->state = sd_inactive_state; + } + + return sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1459,17 +1482,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } switch (req.cmd) { - /* Basic commands (Class 0 and Class 1) */ - case 15: /* CMD15: GO_INACTIVE_STATE */ - if (sd->mode != sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - rca = sd_req_get_rca(sd, req); - if (sd->rca == rca) { - sd->state = sd_inactive_state; - } - return sd_r0; - /* Block read commands (Class 2) */ case 16: /* CMD16: SET_BLOCKLEN */ switch (sd->state) { @@ -2326,6 +2338,7 @@ static const SDProto sd_proto_sd = { [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Tue Jul 2 09:20:32 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: 809095 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118398wru; Tue, 2 Jul 2024 02:29:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVvAFH37IG9Golc3YdS1BxuyQGUpZbwyeEGuUgBWceCsMmdXpilxfhRwFkxayMj+hLfCdbr8gJt+/TXXD0lAWzV X-Google-Smtp-Source: AGHT+IGNX3FrM7fyTlrc4q5uBC4G2MSAoa8EX6ngoevXAZnClXKMEU1tR+ZTP1IdShKVx0yOFTo2 X-Received: by 2002:a05:620a:a89:b0:79d:637e:cf6f with SMTP id af79cd13be357-79d7baba9b5mr922444785a.67.1719912579425; Tue, 02 Jul 2024 02:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912579; cv=none; d=google.com; s=arc-20160816; b=zJpPuoqeG3mWHMsEx18xOri/90dVLcGQ8Lmj3R8IE/5jMX3yy2khO1Oq/cCVJOh8Vn nCDGIyynLbPdcCEy1rmI26TTIBlYd0+INqNmOZbY8HagAO2dWDmyu2Dsnom0uBDZsI/c GcEgJI06xNMcUtcYpFMARrYL3oFT6JoAxk1h6cxw3/iP8HjcQ3+p2ySR5xy2lMjiBWd3 dmgyWw/U+aSpZ6Jhf5vY1s7+p4yjKKzjmPZBpDiQAg4GBoItwDPfNxDEoQLjYQUhV5dO b0Ur/Ox4KzBlT/DCKDXQnT+iolVjr/3bdsq0yeuevVa8QaKEh2Eur0mTtxGYVlNnj2no MXpQ== 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=LdTwu99eUQlsPY0aCQAbuEuylC9rmmKUSrJ2XBIqUJE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=hMrIIBnai1tPsQKwQlDrQ1zDL/r9x//d753nmfrsl22jo689+vTBP8haMVz+ZedxFu kS3AWc6WSIP+mMgFH5SZ70jQe0x1s7VX0GWBxhlh4q0kYpZBR9u6tFCu+NChPsRRaW1N dAvdl+sz1gcJtbUeMjlynDrRbmYUPzJcQYBwurzIzd1++Nx33wH+n4tIM5cf+ogrcYd9 8xuBhF7u6XRdOWOhO3kibBLsSpfuNkiG37YrkwIJS1MPjLSWpyvL2YpBrKalQve8ZJzt 3vG9fgOLTHZeUKRz+H0BGNnz0XUKBTgrlPTwKXZa6iMgqIF29+AGb/QL0th1hEAEYxHy zJIw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3dDEXFb; 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-79d69262bbesi1045515485a.130.2024.07.02.02.29.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:29:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3dDEXFb; 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 1sOZln-0008B5-SW; Tue, 02 Jul 2024 05:25:52 -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 1sOZlk-000837-Q2 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:48 -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 1sOZli-0000vf-8g for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:48 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-42565cdf99cso34784425e9.3 for ; Tue, 02 Jul 2024 02:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912343; x=1720517143; 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=LdTwu99eUQlsPY0aCQAbuEuylC9rmmKUSrJ2XBIqUJE=; b=t3dDEXFbeK4zBd3rEW3oXFsuB+PncLDZE3bDxYU+uM537pwOm+aDDnji9c3+vYDqfp D+rOJ4+bxUFruEILwGMjh8uCOAgIky7auDzY4hJpiaziq+kOkdWya8vwDO0qWAPkWluk ojJb7x/iwM1spUw2foA41G5Rx0AbGtNK9+WDl2nsSqMXCOJPQ62sD2ThBzmGUKwVlKu0 gZ6OrNqvgEtJvjHOOZAR7nLH6/wWRRa/BCl/PEMidk77Q8zX68e+G4s48tk5rt5LmQQG IKtXflKmxBHvwY0k/m5qV3eVI5UM1xzUPjTxmQ0rPW33R+Z0cQPTL/aA8VNRUuxENZWO mOFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912343; x=1720517143; 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=LdTwu99eUQlsPY0aCQAbuEuylC9rmmKUSrJ2XBIqUJE=; b=bEwcnYRgRklcO9d3vWsAH4SNMrjLoHZCz3I68chiRGn9hPvQimBqV0EF0r2RabUSnZ L/kesI6icolYUuHL5zuLe6E3BqZlD/somQZ7s6zbjdsN+yZCciMjljFgH6DHzTLaASZm uX4PAb4ZfzRprOWdpwGMYx7adrKmy7gnM1pV0cs6usIAahXcnQ9/D4OK4xe/NCpa6Su1 7wrvnmpXfbiL8F/+CFLZSCuvFBXSxlZww0JOeIJgB3lgzGHW3SQYTyL+qj1ujG5wvS3v HrKcaZq0jHruwqQwpaLO21YzwRShR4tDvBZHrMgTKNGECL+PfRCFygxjZjR688dj4ZoK 2r5A== X-Gm-Message-State: AOJu0YxOvffZnkyu9wLMDy84RyNXsYtvZlzHkMTUH6c0BLmTybahYWgP GZjywqZGNtCJVf3O0Mh5uc9fYS+VX2mqTC1Hy5zYCB19N5fbg9HV3mjivZRK7LoaWZCwooXOwG+ 8 X-Received: by 2002:a05:600c:19cb:b0:424:aa40:88ae with SMTP id 5b1f17b1804b1-42579ffcae6mr69016165e9.3.1719912343210; Tue, 02 Jul 2024 02:25:43 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257fb4fabdsm96398635e9.46.2024.07.02.02.25.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 49/67] hw/sd/sdcard: Add sd_cmd_SET_BLOCKLEN handler (CMD16) Date: Tue, 2 Jul 2024 11:20:32 +0200 Message-ID: <20240702092051.45754-50-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-56-philmd@linaro.org> --- hw/sd/sd.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 56b4b274a1..335b3e03db 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", + [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", @@ -1417,6 +1417,22 @@ static sd_rsp_type_t sd_cmd_GO_INACTIVE_STATE(SDState *sd, SDRequest req) return sd_r0; } +/* CMD16 */ +static sd_rsp_type_t sd_cmd_SET_BLOCKLEN(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + if (req.arg > (1 << HWBLOCK_SHIFT)) { + sd->card_status |= BLOCK_LEN_ERROR; + } else { + trace_sdcard_set_blocklen(req.arg); + sd->blk_len = req.arg; + } + + return sd_r1; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1483,23 +1499,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Block read commands (Class 2) */ - case 16: /* CMD16: SET_BLOCKLEN */ - switch (sd->state) { - case sd_transfer_state: - if (req.arg > (1 << HWBLOCK_SHIFT)) { - sd->card_status |= BLOCK_LEN_ERROR; - } else { - trace_sdcard_set_blocklen(req.arg); - sd->blk_len = req.arg; - } - - return sd_r1; - - default: - break; - } - break; - case 17: /* CMD17: READ_SINGLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { @@ -2308,6 +2307,7 @@ static const SDProto sd_proto_spi = { [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2339,6 +2339,7 @@ static const SDProto sd_proto_sd = { [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, + [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Tue Jul 2 09:20:33 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: 809097 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118455wru; Tue, 2 Jul 2024 02:29:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUX93grXJCU7STo6oebFdggZOXzmHqP7zNgWM2IYOH0PW7hUWrpZ/f+uWmhBnmUDMTU2svslFJOAqqIN2U7omv5 X-Google-Smtp-Source: AGHT+IHgiH6IyNQ3qvJQjNRy18QSORmbEr+yd+MPEuYFYu9NHt4z+ipGAi1VVsIyeW5+x6XDLt1G X-Received: by 2002:ac8:584f:0:b0:446:3cc8:2c32 with SMTP id d75a77b69052e-44662de818amr99887631cf.26.1719912595514; Tue, 02 Jul 2024 02:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912595; cv=none; d=google.com; s=arc-20160816; b=jyG544HWYY/GpHZHddgxhejC66MhkMQ/Cy85NC64aq1NBDY9/yDePBtx5GAl1G+r8z U+J+YVQaIwtxAwxrchoNXyNQlYqXqb4n79o8vCM8+zvt4yQPA3pUWZcGj5K03UMZ7PF3 3+wMSihRozG4q4AOhtgE9+inIZxqq4yc4phEEfqbm4g30Fh12pwsZoBFp/OuDlMEt6PT GZ97K7Rnj/U8Fv33QJQiA7HbIw6CmAko1eQ7lxp1RRPJ2aEzHXlMBNTzQR4+JYy1rz2a XsIwZXf2AQDWiCtDugpi9qL98EJAiLm7DL6vk29117PRrGTY6CxHFDMZyP/1PX7sKMZ1 ka9g== 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=+5p+b2GGIVB5B1uUI5bQzO6xootFfyz2SaKoSXjhZWM=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=peAtQ02aNL1IoPovAIoh7ax02jP/Go30HjDoLrcTYdBxrRBAh3cQc9a293LlgsYPH/ 3dT5F5VJGJBIHCxVEamuG8paGJeJsNN4lvMBMuqIjprpUSzNw85SzDK+lQ2p5y61gxtr QDYf6SCM/attyN32G8elN+tf21Z/CNEPgkn7W/IsFd3UBDb/BSGKMTTE1pxf6kPo2wxh 7fOjUWalOpGJbeQwfXEIUGSXEIFCD7we6AA2Z/ZeaNxTC/8T73ClCYNBbLyzbuiUf6JR 7orGrUKHMR9EXOyWeeODmTArIPDSs01R60KzLf3EgJ+vzd+ZaxO8p5fvkbmjJUmm4Qkn OCPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M7vsy5SH; 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-44651486cf3si98228731cf.346.2024.07.02.02.29.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M7vsy5SH; 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 1sOZm4-00006O-2k; Tue, 02 Jul 2024 05:26: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 1sOZlp-0008GZ-2Q for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:53 -0400 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZln-0000w9-3v for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:52 -0400 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ed5ac077f5so47037461fa.1 for ; Tue, 02 Jul 2024 02:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912349; x=1720517149; 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=+5p+b2GGIVB5B1uUI5bQzO6xootFfyz2SaKoSXjhZWM=; b=M7vsy5SH6Ljk8CryGjxsjsX7PLGWUBS9IF8sQZBf401amNd3Dtt+Y9lOhuB72xrvoq usCO5Qr2Tw92IcKvTs3lIk9V2Me3tSwhlAbv2fLjSgAIBouv/oafgn8l+JqZ84IxX6FZ 0wSEF4SYBso/1fhltduNMsVdgDNs8IzpMU0PyBGVuFBv++DJ++CCweZIaO7h8Ox03Sgt YyGrLcZaemmwbKzd7nXlLoLVmvdcP7+4WVg0+rw4VHtn7D+UJ05m8klGJ66us4ipienl 4298nTEap0tMqxfvhvHh65gY1mujyjT95T8HDkZ7aP+L52HnynmI1Ced8wNyVjJUz5x7 Dz1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912349; x=1720517149; 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=+5p+b2GGIVB5B1uUI5bQzO6xootFfyz2SaKoSXjhZWM=; b=ekIMdzKorFQZTEDz189ReRqVOEM3XB4DqwfXhlaFzgKDiy91IBSvbtrmaobtkzbFJG xIToROYpiF4W/sx5J3OJYTDkLve0IaSYvQXaGPMhfy6sq366LsTlFdvQbGCEjha3UML4 cxkTD5T5L9tsg65MxdGb4Z9H1Vbx9PMAvmotGyTWooDwtC/O3+XG3f9pYoNqNnN9VO1o EdFzAchGwsCKXvioq0Xnfy9M7zuWrQfym+oybrcTdu8FpAL3QxU9c65trmE+bmoLDv+f V5VLgroKHpHcBlSJgjMi6pwgDJF+C4ELGJFNprPnX3xpC21z/m5cOFFWZnDt6trPab4r nkew== X-Gm-Message-State: AOJu0YyXtHFjKgNeVRwzYLapFq6LcwGpMfb/rsrLaLrnnkd2NO2zmElu 2hDsup6qRU98hcnw8Rli5QVgjUnvQK9jeRtp3GrzsmEdhwr2xhvzp8TcjqK0X0xHPFKGJ15QR41 D X-Received: by 2002:a2e:9dcf:0:b0:2ec:520d:f1dd with SMTP id 38308e7fff4ca-2ee5e3594damr49077951fa.3.1719912349094; Tue, 02 Jul 2024 02:25:49 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b097fd4sm188808705e9.29.2024.07.02.02.25.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 50/67] hw/sd/sdcard: Add sd_cmd_READ_SINGLE_BLOCK handler (CMD17) Date: Tue, 2 Jul 2024 11:20:33 +0200 Message-ID: <20240702092051.45754-51-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=philmd@linaro.org; helo=mail-lj1-x232.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-57-philmd@linaro.org> --- hw/sd/sd.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 335b3e03db..3f5cc0c55c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] = { - [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", @@ -1433,6 +1432,24 @@ static sd_rsp_type_t sd_cmd_SET_BLOCKLEN(SDState *sd, SDRequest req) return sd_r1; } +/* CMD17 */ +static sd_rsp_type_t sd_cmd_READ_SINGLE_BLOCK(SDState *sd, SDRequest req) +{ + uint64_t addr; + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = sd_req_get_address(sd, req); + if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + sd_blk_read(sd, addr, sd->blk_len); + return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1499,22 +1516,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Block read commands (Class 2) */ - 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_blk_read(sd, addr, sd->blk_len); - return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); - - default: - break; - } - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { @@ -2308,6 +2309,7 @@ static const SDProto sd_proto_spi = { [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2340,6 +2342,7 @@ static const SDProto sd_proto_sd = { [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, From patchwork Tue Jul 2 09:20:34 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: 809107 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118933wru; Tue, 2 Jul 2024 02:31:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUCTGsLHiR78pVXZVT9ENMg5FoGnqBkojPek6/xVJsB/+sS+F0/yDLpxmOygzfjfU8mJFOfGE6uKVzVVCHl9dgB X-Google-Smtp-Source: AGHT+IFO74VXCvTHMm8PFP2wxRzFBWpdpQ4U+DuvelzljPrBAH1F6NyXgLxNKDu02LGYJq+v68ca X-Received: by 2002:a05:620a:c0d:b0:79d:5c31:718c with SMTP id af79cd13be357-79d7b9d4012mr825975285a.27.1719912691205; Tue, 02 Jul 2024 02:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912691; cv=none; d=google.com; s=arc-20160816; b=wTQ6qXWbK3KdSrWbYXYfxNnFBqk33D2XGrEhOW16I0+KzZHJpoJ6gAtPbWWsTuZoNr qoW3mAxpUwsvdMdTE3+eitso5Xjx3fLkoS6jpuD/NgQWfQMr9rB+EajYcqb6k25BS+Ts k/2SxTY1xyCkxSm4WfwTclE++YFf4HMPw9jj6Sw6G3n0GMyLJb28tV92RG2VLuM0u3e8 CdG6/S9cja/fdQRzocaMRoPdIh6+8s0usjI7F0fVcFmVnQMnlFgZ+akD+VJGZS9Pk4rN 08SJjFsRl/6LmLoARuMCtanuCMGOLCaik89dTWUeM+dEbJpJUm5cXUrMIVNexUad4VOI s2iA== 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=MYL5paPpv6jEUEf+c2iXnwTu+YdBcD9M6q75+huuwI4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=NpadpV1J31U2/wRUkvs9PldaIOo9C1eiAKufVOZLhx1pp00pqPomyp9/BOolAifyIW xafJo/WPQy9YryCPId6VfkKkDPSh8j+gSOMctcLUw9ogVHfWmBnboAFowRccICYjKikn VKMMeiGDPoN3nbj5hV/TTIdAvEVAB12ouFCQCAmz8/lyfOxNTSZuUX0H2GJ8GvEW91Jy okQHLKSPFwh7f/8aGfVXH50MK98h40YbLLFHn3rvy+o7kbsaV7Rsq9VV1/MGnAHlK0SW YMJLzevGPGZHYwt+qxXx/uycg7JhdSqbzCR0qZKnpXDsaaiuAeHjG4ksUfTxp6XmUuWh fXZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MIRVXuV2; 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-79d7334a6f8si960650385a.563.2024.07.02.02.31.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:31:31 -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=MIRVXuV2; 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 1sOZm6-0000QX-LA; Tue, 02 Jul 2024 05:26:10 -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 1sOZly-0008Pq-Sl for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:02 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZls-00012E-T8 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:02 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4257a390a4eso19067455e9.0 for ; Tue, 02 Jul 2024 02:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912355; x=1720517155; 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=MYL5paPpv6jEUEf+c2iXnwTu+YdBcD9M6q75+huuwI4=; b=MIRVXuV2oDuI7C7/1sEZ4LpEVjW+vzM0VWG7hLKSNPru1P9sFvxorYvODxDOJ3YcHv lXdWek3OsqNNmwk57dBrVCc/R1EO6nb/56F0JVWGe9FIVQ9qaTSTnMfOu9Gmkupa0WCk thM04EwjWkZfB56GmuuSBs3qGiGIKR8K1T4GhXk0WDLpcfqi+tYv0Vg+uVZcbZkkAgbb /oVlS02gVtx6TPhccGyxkBmuRUSet8sbggfI8VB2P3NsbKWwqHLd3WyOQLfgUXCmHg/Z +Eep+If+S+fMkqar8O8sabtN37NbxsJcA5Rniv1N58rV22v37Si4mryjgZugbTFckrsu zAIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912355; x=1720517155; 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=MYL5paPpv6jEUEf+c2iXnwTu+YdBcD9M6q75+huuwI4=; b=wuJAB4BsPwNujAAmZfbzoR8u/1rJpl014V+UBwHhRC9eWr0Qaqkj6vEPCjsc53865L nSU/zHQ5N1aXqO+JY2rUa3ztntLFyQbwwLI7xC6D3Wo/w7pWtGU5dDnSDhSj2xRPL2SW 5PuShWEeuLnpdhgFX7CB1M3DWLnLHc4wkgo+PvOpi/4ViqRJq3Bfu9O86ZL82bO+EciK TdwTM3jVYOhbMBaBakgMYSE/9hHpvwUF+SyafMO5N7aFIXnf/4YjzdH2dnjR6zxBEWCg Gow51PuA3AIr/bGzmlBkezz4jvn6r4IgwOr60tM8cvHE+gDnEld76gYiSRzTcCKzI7S8 xREQ== X-Gm-Message-State: AOJu0YytC9oq9L/bH4EiondWUCjb75l/DfNptyR+ThfLPY7LaUXJ6S5E wa2joIkTtP/b84PYD7BC6bnP/1XR614cNN6fI8SuSenbphGMfbkAIsY5emItzF7BY9Uo8dIPMTh r X-Received: by 2002:a7b:cbd2:0:b0:425:5eec:d261 with SMTP id 5b1f17b1804b1-4257a02805dmr62785395e9.34.1719912354928; Tue, 02 Jul 2024 02:25:54 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e1430sm12682288f8f.52.2024.07.02.02.25.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 51/67] hw/sd/sdcard: Add sd_cmd_WRITE_SINGLE_BLOCK handler (CMD24) Date: Tue, 2 Jul 2024 11:20:34 +0200 Message-ID: <20240702092051.45754-52-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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, T_SPF_TEMPERROR=0.01 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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-58-philmd@linaro.org> --- hw/sd/sd.c | 57 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 3f5cc0c55c..02a1203691 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -239,7 +239,7 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *cmd_abbrev[SDMMC_CMD_MAX] = { [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", - [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", + [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", [30] = "SEND_WRITE_PROT", @@ -1479,6 +1479,33 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) return sd_r1; } +/* CMD24 */ +static sd_rsp_type_t sd_cmd_WRITE_SINGLE_BLOCK(SDState *sd, SDRequest req) +{ + uint64_t addr; + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = sd_req_get_address(sd, req); + if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + if (sd->size <= SDSC_MAX_CAPACITY) { + if (sd_wp_addr(sd, addr)) { + sd->card_status |= WP_VIOLATION; + } + } + if (sd->csd[14] & 0x30) { + sd->card_status |= WP_VIOLATION; + } + + sd->blk_written = 0; + return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1536,32 +1563,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; /* Block write commands (Class 4) */ - case 24: /* CMD24: WRITE_SINGLE_BLOCK */ - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - - if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, - sd->blk_len)) { - return sd_r1; - } - - if (sd->size <= SDSC_MAX_CAPACITY) { - if (sd_wp_addr(sd, sd->data_start)) { - sd->card_status |= WP_VIOLATION; - } - } - if (sd->csd[14] & 0x30) { - sd->card_status |= WP_VIOLATION; - } - sd->blk_written = 0; - return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); - - default: - break; - } - break; - case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { @@ -2310,6 +2311,7 @@ static const SDProto sd_proto_spi = { [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, + [24] = {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2346,6 +2348,7 @@ static const SDProto sd_proto_sd = { [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Tue Jul 2 09:20:35 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: 809106 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118859wru; Tue, 2 Jul 2024 02:31:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVE2EghQwJIWMosIl214fM31U6102vBoB4jEdrsGK1HDwVgacrZpt3cYSv3LzIkzrhOciawSkUgKTPovottDgLq X-Google-Smtp-Source: AGHT+IGW0/qguqjlbTe1NstdfJc2ISiMJmM0I6b3/q1h575Zp2AcVTBCxbnQQ5+SFyg80CLacoB4 X-Received: by 2002:ac8:5b8d:0:b0:446:5ac5:f9dd with SMTP id d75a77b69052e-44662dc1235mr80695991cf.14.1719912675368; Tue, 02 Jul 2024 02:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912675; cv=none; d=google.com; s=arc-20160816; b=aXQE8FBlLLIR3ERtH1OUXFI2Yc+U+rKjtYawk9+JpPwBZRTd8knBxmCQaPmuE5/h8E Wnuk773EmfmMLOPycoNWb7hGjTgY7ZojmVXX67W4GRSXLqqEaWskxa6P5q2VUsHi/ixu 741DMJ+OkAo0KWfPHjr/0uX1e9jhwFqEDMtADEi43ZuqhGyZjvwieG4qLMhgLxaztRPt cgp9o00rjNUiqX3DfBvwEOVB6AfOY8mzJgnEzxkQo/FvHJaqC2z0kuhdZZYAWK9ZEceF 0J7lplwKWaM5be9sxuGX/Hdkd0t9aM1c5AjkBUzW/FjiccVarCpUD2rQDiLw4IE7IfzZ lP1g== 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=z/UKK5N0qGd6voyebxVz2Nr3WQRgwbnXplKwK5vNXYE=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=miMfHMletNHhzpIg6DiJSuHfupBUsFmA+0X0ZIh7zfZTAo8pl9FsXjvBB45MWmLSi1 9jtPdGD2uZt/FKqnlEbS5qRU9/R4IgjKrMZ+12/jcIcJMMFPrzbn1irMW11tvkIl51jj hGNZO6/DdGfnwIf+jH4BzzpWuc/ck+BnL92F+VL7qlXxIyzcQ07PDuD52/ba9r8RRPjb GDg6Vv3vQbqv/HtuvzDDEAcKE1bMEHTG/QCGuk6KNdJCLc+O5jq6xZ1D20bZo6jxQ3aT OR4kqso7h/ovL0M0Qna9qO/eSDIXSg8KWTkddsPnq4aALucSF8OFu75QTaH43qMZ7RA0 URRA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=szd3ELL2; 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-6b59e6158e5si102310116d6.545.2024.07.02.02.31.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:31:15 -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=szd3ELL2; 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 1sOZm4-0000Ew-Ed; Tue, 02 Jul 2024 05:26: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 1sOZm0-0008UD-IU for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:04 -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 1sOZly-00012i-K8 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:04 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42562fde108so28356865e9.0 for ; Tue, 02 Jul 2024 02:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912360; x=1720517160; 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=z/UKK5N0qGd6voyebxVz2Nr3WQRgwbnXplKwK5vNXYE=; b=szd3ELL2cGpIPmqX5hw/lwOqF+fbb4CKnYub3mselaT46ja4t7wmHZNc47uoUqCcTo P2+QyfSYJsInW9R75L0QH1RVt0UY9k02gEHr/EWS/1lYcpk1Q4HoMbNzhWjhONXUi/m5 r4EAHk6I7iY/yAo6zJWgc9y2n3pjd2cq3Sp/ZD7ttx0R/ZVVl5eTBaVQ50TJqhAh+vZq T2l682jzNMWuq6N3eAM71SR4XIPEnmreIVnz2G7iaalsmFZc4YqtSluanttfdO+aAK/+ Fx1L4h9Z6K41Df0vKQ8zd8BKtk16sCZOR1keGn3f1wR0QjtdytRAKp9O1R0nMORNjVQB EK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912360; x=1720517160; 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=z/UKK5N0qGd6voyebxVz2Nr3WQRgwbnXplKwK5vNXYE=; b=HK9oREaMwx8Yr5DoJkTU+QYpPmlGekcOnPPhqRmVoMC5L05gPfKp20/IHfh+YFWsdj 1icEk3ozzZ8PyYcWETIfIRgNr9T01NHrj9xmoApGdtVKOd4WchoFJF9H7qcx65+x4QHT rnCMZIO/R5DkHgwPRG/rCNKS7l0pipe3xB/yVjNlFvMPKMLVQfPAoOOuW53aMntyOMJS TVFY9izSIMCUAXrWEYFrWjrjd0xmUB4KK6gSFS0RNcRfpAWzTbgLzPR5EZQt0vnNiZed 7xr9e2yKAOwwlTwusUeyjwzXz3PGEMTaoG/HsFbPFgZkQhec+/2czk4dp+8+Qsz+nqcT R96g== X-Gm-Message-State: AOJu0Yy8RVDQI+cpf9cdsMv0ZU5z+WZpk+i4P+e2ZeouUR21VgYLr7W/ QwHOCMHuD+FMzcpRRTnjbXyAd8937EosjoUC7L92GGCF3e119xCoiKP2CSuDb5OWWIGk6CxhIVf p X-Received: by 2002:a05:600c:63c8:b0:425:7974:2266 with SMTP id 5b1f17b1804b1-4257a03a58amr55725555e9.24.1719912360730; Tue, 02 Jul 2024 02:26:00 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257dee5f2asm100810435e9.22.2024.07.02.02.25.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 52/67] hw/sd/sdcard: Add sd_cmd_PROGRAM_CSD handler (CMD27) Date: Tue, 2 Jul 2024 11:20:35 +0200 Message-ID: <20240702092051.45754-53-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-59-philmd@linaro.org> --- hw/sd/sd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 02a1203691..e1c799c117 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", - [26] = "MANUF_RSVD", [27] = "PROGRAM_CSD", + [26] = "MANUF_RSVD", [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", [30] = "SEND_WRITE_PROT", [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", @@ -1506,6 +1506,12 @@ static sd_rsp_type_t sd_cmd_WRITE_SINGLE_BLOCK(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); } +/* CMD27 */ +static sd_rsp_type_t sd_cmd_PROGRAM_CSD(SDState *sd, SDRequest req) +{ + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1595,9 +1601,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - case 27: /* CMD27: PROGRAM_CSD */ - return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); - /* Write protection (Class 6) */ case 28: /* CMD28: SET_WRITE_PROT */ if (sd->size > SDSC_MAX_CAPACITY) { @@ -2312,6 +2315,7 @@ static const SDProto sd_proto_spi = { [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [24] = {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, + [27] = {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2349,6 +2353,7 @@ static const SDProto sd_proto_sd = { [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, + [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Tue Jul 2 09:20:36 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: 809088 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118066wru; Tue, 2 Jul 2024 02:28:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXVuD33Z3acQbUddlPdHy0TX97CbScqFDRYy5bHDrlpmXmNv9PqKQCSzUJk9hyT5ydXZAZ/rSNrRkktl3uvmvm6 X-Google-Smtp-Source: AGHT+IFHKPh7jSPHszfyMU+bHpPmII0W6MDpi6o2z+w6UPmvZj4P5XcZtCI3MvoggLAPuBfcMDOT X-Received: by 2002:a05:6214:300c:b0:6b5:8056:6c80 with SMTP id 6a1803df08f44-6b5b70d3928mr101970876d6.36.1719912501547; Tue, 02 Jul 2024 02:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912501; cv=none; d=google.com; s=arc-20160816; b=XoibLejepRGijkU8rvoF37u8kc/Y4yYumCo5j+jtc5Q2e4WZNObfUIoZGpTppDe6Q4 A348JuFVLdefDFY9v4qzZ1NedClrx+6CdZ3fEFttNRjbOa5tGLe2WyIB3FP+nFqNSDcN LhRi541YayjI5vDd5Vwmxm0dUg+dbmdB+ZkwjJBSlL5LCoBdw2mqkwtf8mL/ZdP0bWe9 2Z71uMLAKW/rzYN4pHfPaqkHw0J2dfBGZI5DIk+wEtWMAEFCPNLlLA8ZztCNAevvEpAs 4PwkBdYDhfAaiwZVWMiYZD+UZCTH+nmLkPOmyUELA+ac40VnDW3f4bckVaSzYS+M3yw5 SxXw== 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=AXCg3w5PVdeJgjz/MXSI7N25wc9KB2lQFNoBJeyQQpg=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=PXo86qr9/K+dp6mX8c87lBMc5ft05Q8TeOIrCpsDyR1pfth2Ra1aka+f2i3SDr6vYf 6e/NBh0clc6lFtsFnEwor1Xz/E8WH5IeH+NXxGlXAnqT7OCEm0UgyoxbiFEkhwbU4QKm 8dkxI/1zL3qHVB7BXsON3pJ+PXJg+2/B0TcOFMx+SUNvqUTetQRE7xApRFcWQoypn/6m XB/UXkEn9lFDMgZ0YyhOtKR+9zIby61QJzDaiC7ft5XuHTyOj/I86cXUweJ4ciDHXRck g8khvKo23V0popV2Bk9F6mqU/XqXAn/3JFH4mUqmVR4JfsXDG2rRcaf01GiMyxd3xGcN +jPg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wo4NjNFr; 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-6b59e60b635si100490116d6.487.2024.07.02.02.28.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28:21 -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=Wo4NjNFr; 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 1sOZmC-0000qE-3U; Tue, 02 Jul 2024 05:26:17 -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 1sOZm8-0000ZZ-Cd for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:12 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZm4-00018H-B5 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:10 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3674e1931b7so2694159f8f.2 for ; Tue, 02 Jul 2024 02:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912366; x=1720517166; 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=AXCg3w5PVdeJgjz/MXSI7N25wc9KB2lQFNoBJeyQQpg=; b=Wo4NjNFrbZt8LAy5cJ9t/xD+9SAd3llgVHaiad0zYpPCo1rupOIoLWGnvo5HIldG4j ciVNSwEyFqyHotpYfdwAmrto9yahSenITRGTKtN7PmmmvoKy8So0IEZPSYGoRumeyLiL QYhQZs32rercr9Pg9Iop7SHmq5Yj0eyct9OWIysBEwts1Bf47IPkIOgvn/36Vdj9j/U1 DrzsN/Nk3ip/3pEZgT6u2zJFbodPnHtPOVfAX2m9mBE8ThSAWGvMFxjcFePTE0yQp/3B jJ8vkdJxnqcz9NcFlDtzLy3lpUhpHJ9sWDpGDFVAKgfiO2LSksPq0BxjHWqLVYq63ys1 pRMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912366; x=1720517166; 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=AXCg3w5PVdeJgjz/MXSI7N25wc9KB2lQFNoBJeyQQpg=; b=GaO8fjjc8rQgfDZaOMtQFQcUSLVjEryeInUNYxQReYNPrZTzHXjvKX2ldQEq6FRQVy HjQCzoQUU2JO5jkDDuWim8r+q22iGdxc2EnseTpo8RnXDBzzkVRmwjnzbmBT8Pz6cxgY 0Hn79cwNG7dDqygJ3zXHsIVq2eXwrBuE6az/8TGmQRXl128W8W/EKek0tg7u7W37Sx7/ CJ34S6ARgBBtJER6C62JF22qmtoBX6B2Sjyz+UzDjgsh8x/O6hahPAkWEyge9EGh8sfQ XGtoxtkG4kl5zmdgEIvpDCBocxLhtRqiYdq5YNCYeywedkfBEBNYrkmLbnv0L4zZQBV+ KqFg== X-Gm-Message-State: AOJu0YxtgZiXWMLXYCdPNym92DDfKAgehH6T1YJwC4aEby52FTKp+qid SZwenz4bSZffbu478ZTcR6FJ50lRq8h4Vj7Ni1mDKqC+qhziLZn+0+aOZFDxSF0Q0skm984186J R X-Received: by 2002:a5d:525c:0:b0:35f:1d40:82fa with SMTP id ffacd0b85a97d-367756ad6f5mr4253182f8f.18.1719912366443; Tue, 02 Jul 2024 02:26:06 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a103366sm12572103f8f.102.2024.07.02.02.26.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 53/67] hw/sd/sdcard: Add sd_cmd_SET/CLR_WRITE_PROT handler (CMD28 & CMD29) Date: Tue, 2 Jul 2024 11:20:36 +0200 Message-ID: <20240702092051.45754-54-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-60-philmd@linaro.org> --- hw/sd/sd.c | 91 +++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e1c799c117..384ce77b36 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -241,7 +241,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", - [28] = "SET_WRITE_PROT", [29] = "CLR_WRITE_PROT", [30] = "SEND_WRITE_PROT", [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", [38] = "ERASE", @@ -1512,6 +1511,48 @@ static sd_rsp_type_t sd_cmd_PROGRAM_CSD(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); } +static sd_rsp_type_t sd_cmd_SET_CLR_WRITE_PROT(SDState *sd, SDRequest req, + bool is_write) +{ + uint64_t addr; + + if (sd->size > SDSC_MAX_CAPACITY) { + return sd_illegal; + } + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = sd_req_get_address(sd, req); + if (!address_in_range(sd, is_write ? "SET_WRITE_PROT" : "CLR_WRITE_PROT", + addr, 1)) { + return sd_r1b; + } + + sd->state = sd_programming_state; + if (is_write) { + set_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); + } else { + clear_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); + } + /* Bzzzzzzztt .... Operation complete. */ + sd->state = sd_transfer_state; + return sd_r1; +} + +/* CMD28 */ +static sd_rsp_type_t sd_cmd_SET_WRITE_PROT(SDState *sd, SDRequest req) +{ + return sd_cmd_SET_CLR_WRITE_PROT(sd, req, true); +} + +/* CMD29 */ +static sd_rsp_type_t sd_cmd_CLR_WRITE_PROT(SDState *sd, SDRequest req) +{ + return sd_cmd_SET_CLR_WRITE_PROT(sd, req, false); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1602,50 +1643,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); /* Write protection (Class 6) */ - case 28: /* CMD28: SET_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "SET_WRITE_PROT", addr, 1)) { - return sd_r1b; - } - - sd->state = sd_programming_state; - set_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - - case 29: /* CMD29: CLR_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "CLR_WRITE_PROT", addr, 1)) { - return sd_r1b; - } - - sd->state = sd_programming_state; - clear_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - case 30: /* CMD30: SEND_WRITE_PROT */ if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; @@ -2316,6 +2313,8 @@ static const SDProto sd_proto_spi = { [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [24] = {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [27] = {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] = {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] = {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2354,6 +2353,8 @@ static const SDProto sd_proto_sd = { [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Tue Jul 2 09:20:37 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: 809094 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118397wru; Tue, 2 Jul 2024 02:29:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVgddPuxILyDbsCIQUBfneJR2XqfeVdH5oQ8c+Ra9esM+jXQpyVtBww6ofW9HIBnaVYJl3LvBTvVQIA6cFNj0vE X-Google-Smtp-Source: AGHT+IGT40fO/US1ySjfqtTDlMn0OMNXN32121LVx4aQzSeFif6OGOoW6TtWeoKCmuW/rD+SwBHZ X-Received: by 2002:a25:d805:0:b0:e02:b997:c7cb with SMTP id 3f1490d57ef6-e036ec50c37mr7915489276.44.1719912579403; Tue, 02 Jul 2024 02:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912579; cv=none; d=google.com; s=arc-20160816; b=Ew2pcPs2Kc7UrGH3gks8qUYiC0UM7Om9rSLmHHNlWn0SrjlXLfX85mIednrhnjPPGN mD8P8WRPYygNNQqyUXv5YkO7BSZXuSPUrW+xCb7dJhMTzInS1n0VqVpohvvSMaKLow0Z 0k34QIEqqVRX6gLDMsZxW/isOUdqShSAdMqqVHwQBOrB4ZT91sN4OxWDYKdMYvAHgter h4DB4XIeLODeJXohdsfCTyu9y32iGGbdlpN/8pXBEKg9hSNT9tNY52KObq9HWr/oeqHC eQGXWaQVzQH4+MZgM8nzfSu+6NLUde0hCQ/WaTL0wq11j/yLlZyb0/sQ6/vhQ+x1ds9Z cB4Q== 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=cBeUcx8Psy1taypQO+9k0SQLPvz0ZTjNS5TGwOTNSRg=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=b0AsWdC4TnxlN9EyKjRm1sVb22ffLffyOy/r7Mc2vPvsGuWDovBUHd8+TjsuPKnJ9O LyjyYHFuhQJxE2KDHoIhjMiHFCTmCbMnrGR3VfGf8EEgptK/kzwtFb5NAIMRyKEFtkrr njMY723OGTjCnad3nxjgYonwgvW2aDs7HHWFxby575LOQ6cMjLIKr9MIYeFpjPAn51si kEoxsS8XSWnTvuxEYWHCOXpbGF9T78h3ScZYFElVMl+2JRbJbRa4jasG7UpgCUho6ezf nqEJh+nWH2ilmYfgO9dQdURO0c+B1rEBV43yWGkM7RTtMkkuMqLa4VD2nFhMtmDithfz NWdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kroOfv6h; 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-446514875f2si98888911cf.320.2024.07.02.02.29.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:29:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kroOfv6h; 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 1sOZmG-0001RG-Mr; Tue, 02 Jul 2024 05:26:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZmF-0001E6-AK for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:19 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmD-0001Ms-AG for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:19 -0400 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ec61eeed8eso49000261fa.0 for ; Tue, 02 Jul 2024 02:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912372; x=1720517172; 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=cBeUcx8Psy1taypQO+9k0SQLPvz0ZTjNS5TGwOTNSRg=; b=kroOfv6hra57WSTQe2NV5IkKK7iIWGkfVWUzeEu98k0qsc818NhemVDUJ2w1/1mMxC ZJ7FtJWtHa8ZlzctQliVYBYhxAecYj9L4IOUkke0ia8IkkTRpHwu0Py6tGiBhVp3Uzjr KtToLKekIqBDdrdtm66BLRx1ywKaxjgLadQ5gGahETWUnx4dn5ZRviUthDH1WeSW5avd WOLJZ7kWva5xrYYd/z+I5/2GMZwKA5+B6zx3XGZvXifihkvzSIdiVHJuxpTeG+k78nfL IRdFaUrqF1uKQEoLomzS1rg5lp+Af41zCJmQguRMx0Y2pOxgbXyDxgR6rPJdhO76PcK0 7c5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912372; x=1720517172; 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=cBeUcx8Psy1taypQO+9k0SQLPvz0ZTjNS5TGwOTNSRg=; b=QuOhZFtxNFfk1kn4D+yI/G+OcK1nGe/d8iQ0L7xCg8pprpXcGynYNNJpTnwOpqIhJU O+Ip5F6CJFCTMALFlsWB0/0Z3c7anmXL23EsEINMRIPRdSBJ1nX4TDsK8gb5xYqBGJg7 ANBUOPmE2PUnkayqFhyd9cgpG1WfSYnTd7n/W6GEuVWUTQHpYx3/2oil8lzmxfe208g2 vvPrlV+z2g9o08NUU+4Lw3SwUitkBcATgwXpD9l2MoYf4BI2n3eJeev2DhIucD6FB6xO xS+lvOQ9HHXsy0wkWM4Oy5iRMzP/HLbv5iggSwTm5xgxXvPVXVvfZC31AqLSicofCzlM WmHA== X-Gm-Message-State: AOJu0YysZDUt5/QvVjWyS2bmbEyDfSFSRVfwDUhT/LwOXz63bYOaHnZG KOX4wrt8aqdTQFPQIrD819505vZwpuFCwh2x3+zzJwuks4i/IxDuH2OEEGAEZ5pFc9Uuf9lFe/3 t X-Received: by 2002:a2e:b951:0:b0:2ec:5685:f068 with SMTP id 38308e7fff4ca-2ee5e358fa9mr43497391fa.17.1719912372257; Tue, 02 Jul 2024 02:26:12 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257fb4fabdsm96420595e9.46.2024.07.02.02.26.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 54/67] hw/sd/sdcard: Add sd_cmd_SEND_WRITE_PROT handler (CMD30) Date: Tue, 2 Jul 2024 11:20:37 +0200 Message-ID: <20240702092051.45754-55-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=philmd@linaro.org; helo=mail-lj1-x233.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-61-philmd@linaro.org> --- hw/sd/sd.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 384ce77b36..b205cc4692 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -241,7 +241,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", - [30] = "SEND_WRITE_PROT", [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", [38] = "ERASE", [40] = "DPS_spec", @@ -1553,11 +1552,33 @@ static sd_rsp_type_t sd_cmd_CLR_WRITE_PROT(SDState *sd, SDRequest req) return sd_cmd_SET_CLR_WRITE_PROT(sd, req, false); } +/* CMD30 */ +static sd_rsp_type_t sd_cmd_SEND_WRITE_PROT(SDState *sd, SDRequest req) +{ + uint64_t addr; + uint32_t data; + + if (sd->size > SDSC_MAX_CAPACITY) { + return sd_illegal; + } + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = sd_req_get_address(sd, req); + if (!address_in_range(sd, "SEND_WRITE_PROT", addr, sd->blk_len)) { + return sd_r1; + } + + data = sd_wpbits(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); +} + 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(sd, req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1642,26 +1663,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - /* Write protection (Class 6) */ - case 30: /* CMD30: SEND_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "SEND_WRITE_PROT", - req.arg, sd->blk_len)) { - return sd_r1; - } - data = sd_wpbits(sd, req.arg); - return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); - - default: - break; - } - break; - /* Erase commands (Class 5) */ case 32: /* CMD32: ERASE_WR_BLK_START */ switch (sd->state) { @@ -2315,6 +2316,7 @@ static const SDProto sd_proto_spi = { [27] = {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] = {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] = {6, sd_spi, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2355,6 +2357,7 @@ static const SDProto sd_proto_sd = { [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] = {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Tue Jul 2 09:20:38 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: 809077 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117723wru; Tue, 2 Jul 2024 02:27:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVy8NukvPbSuOo5AJ5x+z8pZqSIaWz+elvm0eIAvJtg+FPPa9tt+ORQsTrfqIq94rS/RBB4ctpJboeioyb0muZA X-Google-Smtp-Source: AGHT+IHTUe5HyM317/rf/HPzipQFdhwODbp5BbdZGNezCvlfxwBBzcH9s4QNfytepP9poZRa81+s X-Received: by 2002:ac8:5816:0:b0:440:1e02:9e1d with SMTP id d75a77b69052e-44662eb659amr124642391cf.60.1719912424261; Tue, 02 Jul 2024 02:27:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912423; cv=none; d=google.com; s=arc-20160816; b=U2FSmB/sOA16tjFXUFiN9FvgxrgPD6Sp4TLxq9FbtY60yNLH13gLYCGKWyoOD0+R9k Ng3Ja+wLDuEyTyXk6Wud4So+OBlOTrcKWRc2WXLBz9MLRXCRpetVnvLWdzix5uLbx4Jh 1iBsoRJYFgB2zzFu3sY9EHGtIpXLtEAMi9LVi3Afv/XczCtRlXPBS1JCkt9S7Yv5w1se VSUJa/ZDGJbbNYvFOpv6iuDjhsHekp0Hh3NDRcxnSN75xy8d1pCjeZojW2fDb35DSCev nGDRPIQGFRLcRAXM1esuiKEryGf0VXeKahxEOdxMC82I7QMj9jycSg7IVRE8upDGfe/q oh9Q== 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=VWCogmQ5YMxblD7fAdd5ouQjKmXVnhB0D5NSysNvar4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=BE07ld4zj8zUbqzVZPGDH6Mh+lm4YDwknrGCXnl4HXbNw58R4MlGmNQ/d70t6+eDUd hr9kWS5f1p1EL3MGzAV97syJ3d5C2zC+8JEm76Stub20QLnGD5+DTDHKpVKryMzvuO74 e7NMIvgOWC/FQUGxhzfnnlOwTijaOjUqpefHgV7BQzum3A8IQrzOeg8v+fYGP0NekBRA e0QykoOWPCw8/ZucEcOovgj9WnVthi4be+oiUzIQwrAVHdXGN7uNgqDMAZ07d/kbLb8I LD5Rbejx5iwrhLutEochHJ+GwYIUsdAsL8diHzqHB/DyXAph4WuLPQJxJmkaxNzyQS9+ iKGQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RIezjv6R; 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-446514a0965si98149491cf.424.2024.07.02.02.27.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:27: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=RIezjv6R; 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 1sOZmM-0002Gj-Ck; Tue, 02 Jul 2024 05:26:26 -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 1sOZmK-0001we-8m for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:24 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmG-0001O5-7q for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:23 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52ce6c8db7bso5943074e87.1 for ; Tue, 02 Jul 2024 02:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912378; x=1720517178; 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=VWCogmQ5YMxblD7fAdd5ouQjKmXVnhB0D5NSysNvar4=; b=RIezjv6RM1IZqEjzuCMphhg/sy+W2SOU1yWGDabTf8XrDUa2RPsdnIBrkLJOSfwxD1 MMqJiMUfr1N3AlSjlbn6BIPk7FnI0QZ5g48u5IY7YR0WPKUh3ur/fDwvFlzK2HpH++OE WypMMXyYq9G1yA8C0X3FzAfAYW79QecBTzFbvJsCfihk8wufWgrsdE3WbHYnR4CqF9GJ S66tZz3Lk5OQcgdsaq+fX/6gZPWLJnUbUVjEfaWoX4r/zUqntsK//xqT7Evo6NkgsfnQ 0JIlY1sapYrVKIJWLCUvX+gQwRC6a9vPIL2SuM1HbMHPXersTCzTajhl8ic8d1rqIH52 RByg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912378; x=1720517178; 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=VWCogmQ5YMxblD7fAdd5ouQjKmXVnhB0D5NSysNvar4=; b=nv4sWFYs9XJiwHftNBVKDVYIYKkZL5ZEBgCD1AeC9nJ/GJYYsPofgs3555t9z15sNb fMS8MO/Yc4G4kj0yzC4+9N0AwI6HGyXpidqedopDIUOXPJpbm0bcZ8NJ3QWKY3qlntFT 9n2xBuKFMZGVIFp9/xCWJM2a3CkF8jWzT+inXaoym4bAxzlE3oH3LF4LwXin44BPtN1r wP3ygPswlX8d6Ih0fLaFimUyg770QNgxs5Z8+h1hsU68ljJFDM544RDcki+eY5zleLx9 xsGbkxoeWgBJXLl19s+U/kDdFoH07yFTSum+evJghm475r4w76RJJ9FLTB2i8j3TijtC 7S/g== X-Gm-Message-State: AOJu0YyNvQ80u04Pwpa0rLNVahjByPbIoT/IJiWsZLO+EKVkTcdb8lv6 J+esn1SL0pBImRMCkV77RbPNf/wsqtei49mL0o4YODJRdoFw/1VM6UM71Bmsrp9MwSxYt8vJSU6 j X-Received: by 2002:a05:6512:3e28:b0:52c:d905:9645 with SMTP id 2adb3069b0e04-52e8265184bmr6522600e87.13.1719912378233; Tue, 02 Jul 2024 02:26:18 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09abbfsm189020845e9.35.2024.07.02.02.26.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 55/67] hw/sd/sdcard: Add sd_cmd_ERASE_WR_BLK_START/END handlers (CMD32 & CMD33) Date: Tue, 2 Jul 2024 11:20:38 +0200 Message-ID: <20240702092051.45754-56-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=philmd@linaro.org; helo=mail-lf1-x132.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-62-philmd@linaro.org> --- hw/sd/sd.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b205cc4692..d517a00ee1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -241,7 +241,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", - [32] = "ERASE_WR_BLK_START", [33] = "ERASE_WR_BLK_END", [38] = "ERASE", [40] = "DPS_spec", [42] = "LOCK_UNLOCK", @@ -1575,6 +1574,26 @@ static sd_rsp_type_t sd_cmd_SEND_WRITE_PROT(SDState *sd, SDRequest req) return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); } +/* CMD32 */ +static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_START(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->erase_start = req.arg; + return sd_r1; +} + +/* CMD33 */ +static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_END(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->erase_end = req.arg; + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1664,28 +1683,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); /* Erase commands (Class 5) */ - case 32: /* CMD32: ERASE_WR_BLK_START */ - switch (sd->state) { - case sd_transfer_state: - sd->erase_start = req.arg; - return sd_r1; - - default: - break; - } - break; - - case 33: /* CMD33: ERASE_WR_BLK_END */ - switch (sd->state) { - case sd_transfer_state: - sd->erase_end = req.arg; - return sd_r1; - - default: - break; - } - break; - case 38: /* CMD38: ERASE */ switch (sd->state) { case sd_transfer_state: @@ -2317,6 +2314,8 @@ static const SDProto sd_proto_spi = { [28] = {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] = {6, sd_spi, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [32] = {5, sd_spi, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_START}, + [33] = {5, sd_spi, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2358,6 +2357,8 @@ static const SDProto sd_proto_sd = { [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] = {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [32] = {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_START}, + [33] = {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, [34] = {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, From patchwork Tue Jul 2 09:20:39 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: 809100 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118512wru; Tue, 2 Jul 2024 02:30:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWSa75GknOsnkulVxcdQSheuMKiX+4hnphiQkuPlUQ/+80W3N8ZtgzPUcTa0TQiUK1dp4cpbyrlUXa2OXih62dL X-Google-Smtp-Source: AGHT+IHRygJu6d89QgqIlnQH+B/X35mS8bpKqjhajZJzqRY1WRiclbA7zQLLsniBaWMOWnFy6onl X-Received: by 2002:a05:6214:2b07:b0:6b5:d311:969 with SMTP id 6a1803df08f44-6b5d31131dbmr13955616d6.62.1719912604981; Tue, 02 Jul 2024 02:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912604; cv=none; d=google.com; s=arc-20160816; b=hFUf/fdabgOVaW06SQwI56NMEg10Y1YdtKa4Ojl2j/RS+Tzh3NxP2Lz99aShvRVF6P pOPUT9uAP4nHkMHPTMLUl8onwycUmP0OfOJs75pth4Tq11OYGqJryQgkCD/u2TPENIzZ 5EtmnkaVneyCv/xI0wnCyQs9ZneT3PIuE2hEZ9X/aobCw2FkcpvOCqZCrCjUg45kVkaq SyZEju8Aw/oW4JT+kNd9/bvRDSmvymeEzo0+8ComszUX7TLQzaQ58FKY1CqSYKLPyPNw DFchv2Fdq+PMB7+TikLo25TEYPx5cRd0yDZyZjbgatxSCZqW3Q8OCjhXXWo6Enu7fp4g i3BA== 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=d8cKKzD5TFUU9UNeYz0boxlMOoI7h2YEt8SrgZwBqHs=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=vHs6kP77KRR2lCLfPhCpaRD0w3nWZTXOlAZPmKTZ63aY5ZT1gyMzBATtYawmMYUvLJ NoUX/j/0syO6E1EdVPenBj+vHBsxdaiYMXYMSCZXCUWOCcV8Zw6EDggRuqHBvhgqd//7 7WjphjO3UQTktOS+2Su6WvKrPjyhMbDlDV07C9tj1i52PoehK8fVwEmTtHtSZJpl3+Jn +3mngb/lERS0sAqxrzDpII6lvcIDNMqPoU5cuhchUjubrScNPZAnAuxJ+/7c16GXDcVH HXxqt7nSk+WjqoSIBpZqR2l6m/eTWPyj2NbXAlSdhnECqW/0BHw9ac1XpsiRh9BeS6T9 mhmg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mIyh20g+; 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-6b59e5f26fasi103050996d6.426.2024.07.02.02.30.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:30:04 -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=mIyh20g+; 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 1sOZmZ-0002mL-Ic; Tue, 02 Jul 2024 05:26:40 -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 1sOZmS-0002fa-Di for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:32 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmM-0001Y4-3k for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:32 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3629c517da9so3146224f8f.2 for ; Tue, 02 Jul 2024 02:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912384; x=1720517184; 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=d8cKKzD5TFUU9UNeYz0boxlMOoI7h2YEt8SrgZwBqHs=; b=mIyh20g+FjycBxtYzV25SgsuJyyUizYxWwoQgUuboFxjNIQtM5vCsbzlxIKRryEXn0 qflbsMNwJowFBXrjhj9ssXMdVMGcb2JxZYnPmeh2xDGudqUp/Z9VKytHrOEaVk69lris AbmgF6idxRYV7s/UAI8m+qbYV65T1WLRXvDZBFv3uXRWxliQKA2TyRanMatCTB02SBbt 7JZZHRoWeXSS/BfKsaGNuggQt2O5KMpTarW2Vq9SjLP0YPEhmkTS3AwNXISD0mZMf+Wb 1/Kf1H/1uQnJwWXTbdj44ikQgpwDZJXpR4+IKsy2a17upv1j89rM71x2xGGfVmQ9JGKC fMaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912384; x=1720517184; 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=d8cKKzD5TFUU9UNeYz0boxlMOoI7h2YEt8SrgZwBqHs=; b=uu43o2uweK07hIm3dwthKLFqq12otQxNdvOGtlKtSO9TzhesTCIbnq1hBGjCmGlvSw wI4ZLO00UaB2hgDLxSJCN23O9onvZiZ5L8/6KF1gHjFD8IYvwQowrvMeK/mNoVWO7jzY 13aEi3d5NQfPzA9DloxQ0Tn1O2OJActTcYmzTZN0DOVB/29hgBguUmfU9Bhc3IQ39Eg3 HbfB/Dy6C0zbsi0gcfuNsT1bhjRf7+YMQH2xI+Lrh7C6/MMYQiwlrPKQSw1L9+C0Uf85 JE4AYuZoqpvNV3iaQ06DISNw0XGd49Qjxw3Zr0jj8/Yz7w2+aK0uXFlqJYMrJNHcvdln xVHg== X-Gm-Message-State: AOJu0YyJkjR4JsnFdW/l7kXFnsil6oxYAiCDJJMv0LpX2crYkxQdLe50 TAiX4lnIOIued0WhK3M7NY/PN3UNQP25iLsD9E3GbvRsL0gqBNiIvFaa2rZDvouCyJt+v6QnnZQ J X-Received: by 2002:a5d:648f:0:b0:366:efbd:8aa3 with SMTP id ffacd0b85a97d-36775699521mr7233401f8f.2.1719912384073; Tue, 02 Jul 2024 02:26:24 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb92fsm12755145f8f.88.2024.07.02.02.26.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 56/67] hw/sd/sdcard: Add sd_cmd_ERASE handler (CMD38) Date: Tue, 2 Jul 2024 11:20:39 +0200 Message-ID: <20240702092051.45754-57-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-63-philmd@linaro.org> --- hw/sd/sd.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d517a00ee1..be9437141a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -241,7 +241,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] = "DPS_spec", [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", - [38] = "ERASE", [40] = "DPS_spec", [42] = "LOCK_UNLOCK", [54] = "SDIO_RSVD", [55] = "APP_CMD", @@ -1594,6 +1593,24 @@ static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_END(SDState *sd, SDRequest req) return sd_r1; } +/* CMD38 */ +static sd_rsp_type_t sd_cmd_ERASE(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + if (sd->csd[14] & 0x30) { + sd->card_status |= WP_VIOLATION; + return sd_r1b; + } + + sd->state = sd_programming_state; + sd_erase(sd); + /* Bzzzzzzztt .... Operation complete. */ + sd->state = sd_transfer_state; + return sd_r1b; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1682,26 +1699,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - /* Erase commands (Class 5) */ - case 38: /* CMD38: ERASE */ - switch (sd->state) { - case sd_transfer_state: - if (sd->csd[14] & 0x30) { - sd->card_status |= WP_VIOLATION; - return sd_r1b; - } - - sd->state = sd_programming_state; - sd_erase(sd); - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - /* Lock card commands (Class 7) */ case 42: /* CMD42: LOCK_UNLOCK */ return sd_cmd_to_receivingdata(sd, req, 0, 0); @@ -2320,6 +2317,7 @@ static const SDProto sd_proto_spi = { [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, [37] = {10, sd_spi, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, + [38] = {5, sd_spi, "ERASE", sd_cmd_ERASE}, [50] = {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, @@ -2363,6 +2361,7 @@ static const SDProto sd_proto_sd = { [35] = {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, [37] = {10, sd_ac, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, + [38] = {5, sd_ac, "ERASE", sd_cmd_ERASE}, [43] = {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, [44] = {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, [45] = {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, From patchwork Tue Jul 2 09:20:40 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: 809086 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118046wru; Tue, 2 Jul 2024 02:28:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVa+JSriUOXd3SAR3dsx/p4xEqZBEMr0WwctQiwJk8IJll66tiIIrBShYr4v8JZbHfA4bouPchBPY7EXsC+ALVW X-Google-Smtp-Source: AGHT+IGM6blLwIUokgk+FgzbUi3yOvh2W6OuCibRVaBAQ604Td+YwjCqQFlRVE71j8CuEaIGmjU3 X-Received: by 2002:a0d:e607:0:b0:643:bbee:be26 with SMTP id 00721157ae682-64c7123ae4dmr84779927b3.5.1719912497173; Tue, 02 Jul 2024 02:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912497; cv=none; d=google.com; s=arc-20160816; b=mlQk6VlNrX4r5nvbcoLB8z+sp64rPtBh1KgzumPSJNf3IGUs8lGP9nyPYDr2cNVv9V V8bqu7uHoQkq+sDMZiU26+L/0xY9IzebLPdHXffGPp8twNO58GESrWj1PZvONfU5cO1U 80jKRrvesBmKl058N65co01Aev2/QpAFzJF2IvhQK5+kWAvsT+7fIbgrYHOEr68tURZ/ JJsujcTSpqPV9Za4SGJptVevHBvR/S5yCFh84nOGhsG31Tuf/uTf/IL+RlIswANGFY+R rrvduPk2QxOsg7Xca/omwaNYAjE9qugSXu+SGoYgUsRUo43QrEm7C04ai5FBnHf/8j9n 182w== 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=IFulJ2oO2h99eDTEiqTYqq780MTJhbquTUdeCChl0+Y=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=eq1s+iErm7iYB1ejsgxLUxQL+LsobbNye60VlAM3hgQ2EdFQIi5q8I5Nr7gBaeTRN6 VnHgzfB/eXPrIVcAgh+U7dut4p8iBhvzIxa5s5elLO1h4Llk7e0nTa3ZTAafEaL8RDCp llx+T3LujkPkpUmQAIVko8FhPHQfQwhDc0eiNQYoivjZ6X1GegSUQR419+Zsh0vxbwS1 QG4IV7DNAEkMafuSvu1a16Mj/Hrl4H2ktDhGGhaLyMC6qDmk3HMPgwBiWRw2mou0OLgI kcs5a07nldtCW8CRtp25QxwIuRAsZ3LF+pIhMALpTYzDykOZtlJL+ya/rbgTtL4GRL5i D7gg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n14tGp0l; 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-44651485f35si97571671cf.384.2024.07.02.02.28.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02: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=n14tGp0l; 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 1sOZmc-0002q3-PG; Tue, 02 Jul 2024 05:26:43 -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 1sOZmU-0002lv-S5 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:35 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmS-0001YU-8O for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:33 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-424ad991c1cso34899725e9.1 for ; Tue, 02 Jul 2024 02:26:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912390; x=1720517190; 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=IFulJ2oO2h99eDTEiqTYqq780MTJhbquTUdeCChl0+Y=; b=n14tGp0lWBgxOmhjjGu2zvZZGlY1qS6wucB5LzlCzyJc6Mopa2t8gVFVRV9RLys7LO 13yAYKgTSnDkZdBjEDNviaZPu7kYfND/a/71kiuWMejF7L3BFziMeEHzuCRRb/5GN5sU Qj6oC1ShciFmsfbfDCWR9xONiU73iJmjU/f/9p80aL0qk6cURLJA6HOFwZIb0OstJmqC LtfS3Dvpbshu0GfsV2sZDV7TdvyiLfs8ti87cSZoQynAifkpfxn1EY+DEdPbjiKT6glM K2e5TfQ0h1pdAOBTqt0oni9SmsMFux9XpWu67Cyzp7znVEBv0a4JwG3nKjLQ1aT26DI7 KFpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912390; x=1720517190; 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=IFulJ2oO2h99eDTEiqTYqq780MTJhbquTUdeCChl0+Y=; b=QktO8A7WJgjaqCwfFoFuSsyYYc7jkpTqmSViFoVl9g0noG+LDIEGJTXoqsbjWaUJyJ h03t4sUQXa9lFIP0wwuBTOpRZkn+/n/1/UeBDItEippR9w1uwbcKDachSiJh8k2csLP7 6mKKKGKE7m0TZb/yLdz1g541mQGwGRLOD1e0dQWCM+gmuWHUMqncLYV+mO3nZBwdyMeh +0y7l26IDu7IFPU1pzGWKOH22bANgXOpprY5yyg1itS3TBCSd+f2px6Md/a4Ua3legUf oq+E3BsXY8wvhwH/jNTGsSEkvMqI/+Y8nDkVnLC47SJ2tA3Cmi3wSVi94L0QQtIydT+h C8yQ== X-Gm-Message-State: AOJu0YxXNnEub4S4ulb6PCqWuv/EPe6cwz8d0XCDwB5c47t3iZ8Gz9ma V5wknVsSQ8GpOlqgHo3I2Sjo8wmfP+NOApiPaYIgIn1Qdmc3GpI3Sn6PadBqRVISvNsmeHcp5Ri v X-Received: by 2002:a5d:4b4f:0:b0:360:9a40:3dd8 with SMTP id ffacd0b85a97d-367757301b1mr6133651f8f.65.1719912389920; Tue, 02 Jul 2024 02:26:29 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b098426sm188322325e9.32.2024.07.02.02.26.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 57/67] hw/sd/sdcard: Add sd_cmd_LOCK_UNLOCK handler (CMD42) Date: Tue, 2 Jul 2024 11:20:40 +0200 Message-ID: <20240702092051.45754-58-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-64-philmd@linaro.org> --- hw/sd/sd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index be9437141a..da344589f2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -242,7 +242,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [40] = "DPS_spec", - [42] = "LOCK_UNLOCK", [54] = "SDIO_RSVD", [55] = "APP_CMD", [56] = "GEN_CMD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", @@ -1611,6 +1610,12 @@ static sd_rsp_type_t sd_cmd_ERASE(SDState *sd, SDRequest req) return sd_r1b; } +/* CMD42 */ +static sd_rsp_type_t sd_cmd_LOCK_UNLOCK(SDState *sd, SDRequest req) +{ + return sd_cmd_to_receivingdata(sd, req, 0, 0); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1699,10 +1704,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - /* Lock card commands (Class 7) */ - case 42: /* CMD42: LOCK_UNLOCK */ - return sd_cmd_to_receivingdata(sd, req, 0, 0); - /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ rca = sd_req_get_rca(sd, req); @@ -2318,6 +2319,7 @@ static const SDProto sd_proto_spi = { [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, [37] = {10, sd_spi, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, [38] = {5, sd_spi, "ERASE", sd_cmd_ERASE}, + [42] = {7, sd_spi, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, [50] = {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, @@ -2362,6 +2364,7 @@ static const SDProto sd_proto_sd = { [36] = {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, [37] = {10, sd_ac, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, [38] = {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [42] = {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, [43] = {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, [44] = {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, [45] = {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, From patchwork Tue Jul 2 09:20:41 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: 809105 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118711wru; Tue, 2 Jul 2024 02:30:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUbt1CtuGBq0uzFDggvyhZhLAty1SX83YE44aHhRM3HB7s7NAmhXS+jtlkdVaN+XivGYMdygeo8y1C/GcKvJYpP X-Google-Smtp-Source: AGHT+IGBJa7EujYFH/TNox6ZPGqLoOOlOKXfrFXJVrGpiHXQUEbxzr2qs2xFlWjQp/E2T7U6hRLI X-Received: by 2002:a05:620a:211d:b0:79c:bd1:3910 with SMTP id af79cd13be357-79d7b9fc86amr668285285a.42.1719912646292; Tue, 02 Jul 2024 02:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912646; cv=none; d=google.com; s=arc-20160816; b=XCPfnedYg/E7RNtgrqIHWytBN4yJjU2r6cdIKa8vjFSUuz8yY8b2b20ExbCAEdFp4B 2hByjmAWnN4EzwinnhSQWxvEa+HFfDcrHx9bkKzOX6mbROtj3XJtVITQUcP4nYkkxwBu XMm/PDIsA9RLeFdOBYX4wfJiM+k/3BGreDcIQP1QMtbNfOEdWxmq1N2W8qPpDc8Tw7s6 /Waw6udE+BhiKeIlpuPkkTu9r6rIY5HDQZdx6G0YstyWKE/mHgab8PNjZ0GD/d5zVS8R IZXzB7QpCjVh7cWJISno4CtlLoYgWJURx1dB2uVMIVhCjCiU3DRGmEFw8BmLGZ6z0MLr NGdg== 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=odaH6p2tA7JjyfEGnhEe1HDwlvnEgHVlkHIdzE6llls=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=xd3suvYVvCBRBxJpyyMgbpq5DIcwK0vLprUb1UcMFeQ+xxG74JCW+90kklM9qPuhJU EmQXn8vb7Qb+sB3McgVCzSR9zn5VbPnrezEZPhSPxmpNr2tJUG8XKARxWMo+wAeIW6yO w1ekY5SXdEvt01nILPCjFGJC+Yd4pYRlP/P1+SlLYkg4O7JBZiRFoA3lUNvaNtK1xE+G xbSKU4cTdJgyoY8mLyLBFRMmgUPv6rFS+b4VcH6KubK9AOXJ2Qc7QynimXp9Wa3N5gyo lnJZ40Xoy553zDSAWIBpOWdE+o8yelp/KES+nugQD6cbUHoQ0mqFFkyJS5zjvSeOAgJX 2KOA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u3DUJtfF; 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-79d69260c87si998841385a.108.2024.07.02.02.30.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:30: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=u3DUJtfF; 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 1sOZmg-0002uj-5k; Tue, 02 Jul 2024 05:26:46 -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 1sOZmc-0002r6-Tl for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:42 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmX-0001Z9-Dz for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:42 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4256788e13bso28561295e9.2 for ; Tue, 02 Jul 2024 02:26:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912395; x=1720517195; 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=odaH6p2tA7JjyfEGnhEe1HDwlvnEgHVlkHIdzE6llls=; b=u3DUJtfFGVQVD1Pv3nm4O7lTx0oRlHmi1RLbxxOhObn3P50wGWrNVtDy5kXc9DOiJa DqiKkHV1WLLdQgiwqn7o0ihFogaKMJlP/WvqCgjM/ZFf9jKKs9NHdBMrkRqI5BS6ZuiS HJOesRDgyQCbZV1ttg7EXTBAnulU5ur5dR6ZPCZiIrVsaJKyBZF80+7sc4frBplHRhbw ZbnMxg73Lfxa/JCotKiPtC6Sym7t5hfzcpApY1Ryu23QMacj0CECSMG1esbbyvaitvqZ GkVp3f6fvcUrdLrosH5HDQvcfWIvciE9Y2UpC2Jyk3KtTsXRM2iEw3Yqj38dZYtSnl1H xkbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912395; x=1720517195; 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=odaH6p2tA7JjyfEGnhEe1HDwlvnEgHVlkHIdzE6llls=; b=rDPB1UMaPYSlW4Gr4jpE9H00HVbutNfSoMVCoRisRw+6G6BTJJ07bwPKKeMB3fe21z RApJDpWagfsyejIrkxBXmIJUZ63gzCvtw72ltXd75N3LuZDgdVLplEMNJhMKHnxleTTb Ugl3azpX7LIBwyPH9bZ2IbV2ExBF/ReEovu8ezgF6gxxDDcFzLKUdBkk8mz1LTVJU0iG KY/nqkd6IVHjNvdLmvUv9LYTgqrrAU63mVU0cclsuy3NoPvbD1/CYUYF90tyJdkEMqUx cxfHIt7535R+KcR6WSMCDiTo8Rdh3H3R7FDCi4LdVgS1u2mfAYpntzAxSCLvKKbQp1Rq XRcg== X-Gm-Message-State: AOJu0YyBhDA4NdaFXY+tfnjY19XTPQ4/eC3IfwQhOxf5/g+MFn5okws1 eP2J7zac3XUzSzfQ88WLasOesQRYp7vJjLj/XRaas+bQQhKA3hy2a1l75DIxBhwE5TGhyXUh8vF L X-Received: by 2002:a05:600c:c88:b0:425:6498:3b6c with SMTP id 5b1f17b1804b1-4257a06427bmr63720605e9.26.1719912395693; Tue, 02 Jul 2024 02:26:35 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fb950sm12559263f8f.83.2024.07.02.02.26.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 58/67] hw/sd/sdcard: Add sd_cmd_APP_CMD handler (CMD55) Date: Tue, 2 Jul 2024 11:20:41 +0200 Message-ID: <20240702092051.45754-59-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-65-philmd@linaro.org> --- hw/sd/sd.c | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index da344589f2..f5548d5667 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -242,7 +242,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [25] = "WRITE_MULTIPLE_BLOCK", [26] = "MANUF_RSVD", [40] = "DPS_spec", - [54] = "SDIO_RSVD", [55] = "APP_CMD", [56] = "GEN_CMD", [60] = "MANUF_RSVD", [61] = "MANUF_RSVD", [62] = "MANUF_RSVD", [63] = "MANUF_RSVD", @@ -1616,9 +1615,34 @@ static sd_rsp_type_t sd_cmd_LOCK_UNLOCK(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, 0); } +/* CMD55 */ +static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_ready_state: + case sd_identification_state: + case sd_inactive_state: + return sd_invalid_state_for_cmd(sd, req); + case sd_idle_state: + if (!sd_is_spi(sd) && sd_req_get_rca(sd, req) != 0x0000) { + qemu_log_mask(LOG_GUEST_ERROR, + "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); + } + /* fall-through */ + default: + break; + } + if (!sd_is_spi(sd) && !sd_req_rca_same(sd, req)) { + return sd_r0; + } + sd->expecting_acmd = true; + sd->card_status |= APP_CMD; + + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { - uint16_t rca; uint64_t addr; sd->last_cmd_name = sd_cmd_name(sd, req.cmd); @@ -1705,29 +1729,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); /* Application specific commands (Class 8) */ - case 55: /* CMD55: APP_CMD */ - rca = sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_ready_state: - case sd_identification_state: - return sd_illegal; - case sd_idle_state: - if (rca) { - qemu_log_mask(LOG_GUEST_ERROR, - "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); - } - default: - break; - } - if (!sd_is_spi(sd)) { - if (sd->rca != rca) { - return sd_r0; - } - } - sd->expecting_acmd = true; - sd->card_status |= APP_CMD; - return sd_r1; - case 56: /* CMD56: GEN_CMD */ switch (sd->state) { case sd_transfer_state: @@ -2323,6 +2324,7 @@ static const SDProto sd_proto_spi = { [50] = {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, + [55] = {8, sd_spi, "APP_CMD", sd_cmd_APP_CMD}, [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, }, .acmd = { @@ -2375,6 +2377,7 @@ static const SDProto sd_proto_sd = { [50] = {10, sd_adtc, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] = {9, sd_bc, "IO_RW_DIRECT", sd_cmd_optional}, [53] = {9, sd_bc, "IO_RW_EXTENDED", sd_cmd_optional}, + [55] = {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, [57] = {10, sd_adtc, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, From patchwork Tue Jul 2 09:20:42 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: 809084 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118013wru; Tue, 2 Jul 2024 02:28:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXGslza8n4cRtE0t6HK4Ok/xPdgbhI8fvT1gfe5aFl0L1bBMHPjLhtywq5OXst8w7zpNBxCiXJR+B8JplMYGami X-Google-Smtp-Source: AGHT+IEO70Aj6O5MLkPmKHixWbVJSVQ36XDKllwijMlnLUkBHyJ/iwST4deC8QfSmzkxT83bMRoS X-Received: by 2002:a05:620a:29ca:b0:795:69d:1948 with SMTP id af79cd13be357-79d6ba55d4fmr2211741485a.16.1719912489217; Tue, 02 Jul 2024 02:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912489; cv=none; d=google.com; s=arc-20160816; b=o4G4nb+5H3e8HJrtg+eGWVtMwYvqdTUFq7Hy601DBGzyfR1k6EdtkXXvj/jSXvGvGG sqlIgoShdBYh1S92crHeSY4h+xHmbUfe2JSFXMcevG6wolSm+008zg/9Jf+IZtSJhuH6 qTavr9RfyUhPLoQbU3tCMbWFrulORRW4X4w/CaK9u0PixGPXE8b5HwimO3LH2pdkp1SN BN15zlGA8z7m7rdoWKWBCLWRqvVw+bhPeEVSsNlcxNZRoBpbyd6IHnIy3TLtRE8Hz5FE 8nbMBLcC6fFyypwjNIr0R0gH0F2fZiNgjEu6uTtbRYfsE4EhuKrtsEmro4aqeuAxs7fr i3Tg== 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=hYt9NrY8vo8112paVkmJIP0WplWJ6pspD+deTZLbMcw=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=cqlfsLlZNO3LtbrTfsVHNHlRFH8Jyr2zrnnmNYaBFTbB7R4au3pJ8zwRsFdNnB7N5h H/NOK36n23W7lbhBY6noFW+SymaY3pTceCPFZXTqtncS1R70Q2twHTDuq9MiM2sMMYjN p+Uwn3IB9AYywXI7p1veAgQvVXX8UMINjSxuLiBI2VRlBJ1+/wLYmEXMj5U7v8FYrtiw bEO9AK0pNEa/EQPw78mMn293E1mPTm57KcLevynM1Eju6qmxanQ03M+9SdAT/WpjIR0M o6ibRjOosx8Mbw94yfixuuMdRIj+D7VJ3nqjrRruatLHtFWINIgCDansToR+vM7tNHXN ZCqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FdyQ2c+p; 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-79d69289350si959216485a.174.2024.07.02.02.28.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28:09 -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=FdyQ2c+p; 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 1sOZmm-00034r-FW; Tue, 02 Jul 2024 05:26:52 -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 1sOZmf-0002uO-MP for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:45 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmc-0001ZT-Uk for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:45 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4256aee6e4dso28693435e9.1 for ; Tue, 02 Jul 2024 02:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912401; x=1720517201; 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=hYt9NrY8vo8112paVkmJIP0WplWJ6pspD+deTZLbMcw=; b=FdyQ2c+p6ljntTKi+3mndjpFxmxmJmebvjqHxdiBmPqiISgm6HVRIGPzPslAIaHEAt 7NQjDKHueAqj9231zCpRK8HPeKvZN3cvKdVhtAD1MJ5rLHANr8K2ny3r16h1jh/8QjC9 NHBVb0EaWfLjlOxdBD9jNS0OtMKLwtizaFC9r7EhMoZJzEwxdzUP1PbHvPx84SJf+Hpt BuslMu+7bR/Kjwf3ldNWsD1Kw4KVDtZiZwjqaZWrYbmGfgmQ4M9dO/IejnmmFCRDqdaM bbkTQxySOwdyy4yaJRFgqY6753BMhQLpLiiW81KKMSyqRG2O5kUtj6IzA7bBTrM+v2IF cu7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912401; x=1720517201; 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=hYt9NrY8vo8112paVkmJIP0WplWJ6pspD+deTZLbMcw=; b=Jd8/1a80x5C4Ae8zigv2PYi4cnkyA03ZcGJPPIWP8lCMiyqb7zFtS/2SFBw7YD1WrQ 5b0FjN+LnbCwAgJou9RVNXoNVA5SwRr7gY2VSayEh9svMDZwxeQZAfy/M8tdormjn+HM fZA0XIGXY5TdGfwaNE/Y90PnWucXR3zA3P3/llLsxIhHxkri68zHiJXJhF+vMKCh0rHu ZCG2BkCH83fbMC73dk96fnoquAk0DJNnD5YcXqNX5MXlIXluebRkYp4W5InPu8lGQPZp +FvEzIuLVMTK3o19b/guO2jDKeqIgpDyEKZjjU6MC8noXioY1CHo5h7lmmIVLxnKIPBN QoYQ== X-Gm-Message-State: AOJu0YxKGN8wkBX1yXRoRecAsKif8LdSJisr1J62+SpRbsvVCJBS/yxO Sv8ujOnYV7bzRbt9xASC+Gct+5XbY2ONyjprllIT5iqAKO1sZ1KeSpCR+Y3IeVEgIdnCaaH7Mb+ m X-Received: by 2002:a7b:ce83:0:b0:425:6327:f00c with SMTP id 5b1f17b1804b1-4257a00ce8emr54531615e9.22.1719912401329; Tue, 02 Jul 2024 02:26:41 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af5901dsm190572775e9.14.2024.07.02.02.26.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 59/67] hw/sd/sdcard: Add spi_cmd_READ_OCR handler (CMD58) Date: Tue, 2 Jul 2024 11:20:42 +0200 Message-ID: <20240702092051.45754-60-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-67-philmd@linaro.org> --- hw/sd/sd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f5548d5667..08fb3cf9d3 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1641,6 +1641,12 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRequest req) return sd_r1; } +/* CMD58 */ +static sd_rsp_type_t spi_cmd_READ_OCR(SDState *sd, SDRequest req) +{ + return sd_r3; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1744,9 +1750,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } break; - case 58: /* CMD58: READ_OCR (SPI) */ - return sd_r3; - case 59: /* CMD59: CRC_ON_OFF (SPI) */ return sd_r1; @@ -2326,6 +2329,7 @@ static const SDProto sd_proto_spi = { [53] = {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, [55] = {8, sd_spi, "APP_CMD", sd_cmd_APP_CMD}, [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, + [58] = {0, sd_spi, "READ_OCR", spi_cmd_READ_OCR}, }, .acmd = { [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, From patchwork Tue Jul 2 09:20:43 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: 809091 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118120wru; Tue, 2 Jul 2024 02:28:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV1K0PUy69VxXe0OX6gSZ8VQGbBTdpxzMv6Px+OqIYXgjBK0wdAfRfrExkTQKdKw2lbszTKiCOdUKqxTqC0Frs6 X-Google-Smtp-Source: AGHT+IFPLanACE7SRafIOKQmRF5E2piPGCoDZgFN43Z/wrSylUOpamHuqr8ZSke+7/KSBYmn1m7r X-Received: by 2002:a05:6214:dc4:b0:6b5:2de3:32b0 with SMTP id 6a1803df08f44-6b5a53fecb6mr187527896d6.7.1719912517719; Tue, 02 Jul 2024 02:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912517; cv=none; d=google.com; s=arc-20160816; b=oN4zfljNFEVgZqz/pLHIGwM1ktVVHxbuWkP1osM2FHflgDZK56DT10nxo9/2qi17f8 4aoP/zi/aEIhsjVACJGutNADbbEehGT0o0XxTYw58K63wZFXAzg0jJYPgtsqyIdLx65x cpBPadjI87w8LzxSS9YcPFhJnXYY1eCjB9p5U0z4+6lCB8jumHLoPc3I/daGceJkg4D1 NGVfT+z/jJ/a/o0ySQr67Pi6AHsAgog9di64+Ps5O6qt6RfDdcOwH15YruKEqvys0XJT ECLWqSkq2HU6iE4DyXSaekuqVHmtU5ZrAVbIFNCOHPhO637Tzwrez9G+ru9o1IKnrtuG GGLA== 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=oZj5eYp/kb8EVrafSTzyBAO6e70CoLy2x/MnndJCff4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=t/zqq57pYEXOxRbU+AjxMWJiC0op/hYwrGlRdlES1AONP/k5iHe+QvOcSH5Tmq4XYT IGC8Yaczjmq/TlLh53hRGkB0zmQKS9npV3ndVf2xdx7vzqzE4mYYxcZshvNlFxkOILy7 j8PVTOdUsSp43HgsLsrnoQFC/xxnrpIF1exJ3i5GkDD6Qxv8eXtGmcTyZStPrepCyl4h VzQWTjKvWi36IAthQUooq8b4zAU6QOG7SHh9yGhpADEYqdNQcxNGQ/9EwnhiMwQHGfVH H8H4ZONn9f/MrPGCTrE9XmD2Qmbuomdpk5p5ZTKSYJnbXCA+/c2R2PlMUGQPdum/+6UU Xf0w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZEaqyu4B; 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-6b59e5ace3bsi96926296d6.294.2024.07.02.02.28.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28:37 -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=ZEaqyu4B; 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 1sOZmw-0003TQ-Ju; Tue, 02 Jul 2024 05:27:02 -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 1sOZmn-00037z-BP for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:54 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmj-0001aC-Cf for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:52 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-366de090da9so1961797f8f.1 for ; Tue, 02 Jul 2024 02:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912407; x=1720517207; 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=oZj5eYp/kb8EVrafSTzyBAO6e70CoLy2x/MnndJCff4=; b=ZEaqyu4B7CZ623jBRJ7EdAJGf3xfD4S9psP8Fok95D9ySsrdruXukwmI9fEusWP2/v Oi1v55pzYRWLAlMMX28uYzfLqFBnWt003BAwyIuWByVTo77qnmN/Sh1aG8i6FdxEWA28 suDjRvlOis805xNqSjJatpEyzPj/x3jW7EuJfsOnndDDwzvnoLvaPEY3pycMkjwPCda6 hClpBxHOYxKVeVC/cy1dHK/9XqhH9U6PRxL5LWFcPaPfAaLTPTyn9Btkb+0EszPf2e1x lUN9XHzpYMkhWM9faDVugRcLXPdRsIFkIJ4Su/5/gzPyJIgYHzGZnqdTtIK31mRvzFL/ tDgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912407; x=1720517207; 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=oZj5eYp/kb8EVrafSTzyBAO6e70CoLy2x/MnndJCff4=; b=UvufVBsX0cVkKv6GlvB2rA8DR4K9eHdDYqZqfg17vMTIOecisa+bhYTkzVvVuL14CH z6iQyWxn/LqZiZ+yG1kZQCyNR+cY91vthTznxFTWoponTYsV40ta7h6Ul8ewDvFhbgOb rfC7JAQqazc3vScaeoi3lu7D/Un5WX84K1M1roy5mXsKpYFw5DNOUlo+Eu/nI0noImWC XW0FppIgKz4ewW60Lu0rK1i1mwQjSu2IGOL5ef3pCECOyTT1lJH5L6RSSVIzGbXS29uZ 8BDcSpZgN1XQAf0Hg5RUYU9LWfEg87RV38FWgWquKCEf0v11YRoKdDKXi2QfWQ9LPB12 RxcQ== X-Gm-Message-State: AOJu0YxtYWm4E4I14/ZrruoAetuRNXDrCQO5ddo8M9PBDSiB56SCCOAW 0rjE2uUlIY92X4siJAV/imfL83esxT6nQmppLLfX3FmO1V2EqJTNkFOPM8l7/E9A0FY+VyQ+gAI B X-Received: by 2002:a05:6000:2a7:b0:362:d382:2569 with SMTP id ffacd0b85a97d-3677571c841mr4911201f8f.44.1719912407081; Tue, 02 Jul 2024 02:26:47 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0e12d7sm12654967f8f.51.2024.07.02.02.26.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 60/67] hw/sd/sdcard: Add spi_cmd_CRC_ON_OFF handler (CMD59) Date: Tue, 2 Jul 2024 11:20:43 +0200 Message-ID: <20240702092051.45754-61-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-68-philmd@linaro.org> --- hw/sd/sd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 08fb3cf9d3..31cebe609c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1647,6 +1647,12 @@ static sd_rsp_type_t spi_cmd_READ_OCR(SDState *sd, SDRequest req) return sd_r3; } +/* CMD59 */ +static sd_rsp_type_t spi_cmd_CRC_ON_OFF(SDState *sd, SDRequest req) +{ + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1750,9 +1756,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) } break; - case 59: /* CMD59: CRC_ON_OFF (SPI) */ - return sd_r1; - default: qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); return sd_illegal; @@ -2330,6 +2333,7 @@ static const SDProto sd_proto_spi = { [55] = {8, sd_spi, "APP_CMD", sd_cmd_APP_CMD}, [57] = {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] = {0, sd_spi, "READ_OCR", spi_cmd_READ_OCR}, + [59] = {0, sd_spi, "CRC_ON_OFF", spi_cmd_CRC_ON_OFF}, }, .acmd = { [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, From patchwork Tue Jul 2 09:20:44 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: 809081 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117843wru; Tue, 2 Jul 2024 02:27:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVzVNnpVXHxZnUNuILd0Ahl0puDK4W5ynxT7f00jw/Qo7VFUlSJ9ktuu9HDaIKxc3DePO3uCBkKmeC3flfy2Rd+ X-Google-Smtp-Source: AGHT+IH7wAswBrQQVqMGik4Cblk7xh2g+ZKCbsWCryR+PMH4PAjyCyqG0YkT5qFexf4zBLGPT4S5 X-Received: by 2002:a81:9e4c:0:b0:632:7f0f:ef86 with SMTP id 00721157ae682-64c71cd920bmr84332787b3.24.1719912449667; Tue, 02 Jul 2024 02:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912449; cv=none; d=google.com; s=arc-20160816; b=jH45QyHDjyxY7qPqz/+QyCdY8nikdh/V8Udft5/7hkF1TjLaF3ohHIqpqR8FC1W9qC wF0lHALr+9ulgVtz/qWRTQt9OUupbLsjo2ts9V4xxCUW4lW8M2zJvFp5PqG9Qb4SBYX0 GZdoaR4XrhuDT4EyxperyI0cKi9Xy70ZoqLiR03AL2RDBy1sLlF+Jz8iSfUOoTVp+FdC vlwXahLNL365V7X7arBvNcJRAYgOCFMsCP5qAm4TqA5UTLjoRZGuPJJcsnOMXrWnEuk0 3mVNGfarMnCweHxYFQtJg2dDSNvL1JnCzWLOacn83vjBzYJGzRgAsV9gGJRZ+j/ZI8Lf Okzw== 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=h18ZtpFi+1EoV+so/iHct3tNt9L7cd1pp1ExoGu8rMs=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=x01rGqX/lCI/P+qVDUC/ssT/iXEG7pCKdYzqHZNo350GmcOJJNmm0iOBblx5BZ0rZF lS3QorrAj6pG00ndVZu8Z+zd2aJNsDDM5CQ1q7bLzKuJyvY2TA+fe3FosSphbNOaEFBq BhOyJj0K85bpr/K4sE7ECjeKNPf0Wd2dtXgFKxdkMSAR0sjbQl7Ax+b+4OA4DE+4e1W4 d483RmylrT7WMyPHYfwMu5ADJBdsE3xbnEeamuw3H5qumzXXQ6fJAsl+myb1ddwBMboE 8jAp9M0Srn9DqxmelAaLv3JQbErbUcIAJ6mTYWsHA8D4afZLuN8iJr2r6soIpADNSgwC rAoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C2GxE5xu; 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-446514e61e9si96589211cf.773.2024.07.02.02.27.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:27:29 -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=C2GxE5xu; 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 1sOZn3-0003WE-N9; Tue, 02 Jul 2024 05:27:10 -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 1sOZmt-0003RQ-2M for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:59 -0400 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmo-0001ab-W6 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:26:58 -0400 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52cd87277d8so4045842e87.2 for ; Tue, 02 Jul 2024 02:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912413; x=1720517213; 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=h18ZtpFi+1EoV+so/iHct3tNt9L7cd1pp1ExoGu8rMs=; b=C2GxE5xuqfGYHJyRLMvWg5Tq0e66WahRs68NIRafEyj3Hx1uLoHjmBQwsKPdC9Qksu +p4VaNYoTCIK/qoyqBOot/roZi2fL/tCMMzcw9IturaXoYSaK3SNX7jMrI/0EBdkNHjp knaqsQfjx61J4dh3koHtZBh1Lgzlhg7+RpmdX6uqhAk1LgeTh6/yD99RHXol0V0AjCDo SJB7mtehNfDfn7nrXCdELyzXU5DDciBcOX2o1w+D08e6nm6UCbOiN3/VMtbsH/gBKxSz keCjXLCtrsdbxm1sDy4pvDgyqM0EmQvWekMnhqcpg+cd8L2M62AnJHqly6SBMQgMPPyt OlLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912413; x=1720517213; 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=h18ZtpFi+1EoV+so/iHct3tNt9L7cd1pp1ExoGu8rMs=; b=L3J5CoqT9kdprcdISIBDQwnRPZtx0qCDNtjY3aZz94lRq9HOAl/dT0/6qdf9ic4UV4 remy7i8V6sK2Blu/iv3PM2UJD3aNMT6kIuIF2Cxlvvbltckfqx2zYcNM6f/0sB750sk2 LdTC/Uqeu5uADKvZAx5t7SfihJrwht6BnMZHFN/5/k20R4K5QJIRj4t3i4Kw3YBPYLrK GMt263DHjiJ+7SHFc0R+qinISvsCZ31g5buvLGf723NGqj1wQ2hhQqUmckRfzzq6LMka SFZl5z76wXS4XYjXt739nrZoGoKUlUGV4K654JMXgLXXr1xXAmN3OpO421s3RNe9+4ys uDqQ== X-Gm-Message-State: AOJu0Yz5EpJ8tT/QvsrBiMPmYI42Ij2LK6Wqw+KkOPWQifSrVobQuXQU kEEs2VokB3nM2s5IlF+WBj56ZPzZsXUb2SovaVJeKqf6bNEL2G9sRIVPGokSIWNUfnLvbULBMuu m X-Received: by 2002:a05:6512:6c7:b0:52c:e16e:6033 with SMTP id 2adb3069b0e04-52e826513edmr5820126e87.2.1719912412816; Tue, 02 Jul 2024 02:26:52 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d9b1dsm12716474f8f.42.2024.07.02.02.26.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:52 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 61/67] hw/sd/sdcard: Add sd_acmd_SET_BUS_WIDTH handler (ACMD6) Date: Tue, 2 Jul 2024 11:20:44 +0200 Message-ID: <20240702092051.45754-62-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=philmd@linaro.org; helo=mail-lf1-x12d.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-69-philmd@linaro.org> --- hw/sd/sd.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 31cebe609c..fed95563b8 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -258,7 +258,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [6] = "SET_BUS_WIDTH", [13] = "SD_STATUS", [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", @@ -1653,6 +1652,18 @@ static sd_rsp_type_t spi_cmd_CRC_ON_OFF(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD6 */ +static sd_rsp_type_t sd_acmd_SET_BUS_WIDTH(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + sd->sd_status[0] &= 0x3f; + sd->sd_status[0] |= (req.arg & 0x03) << 6; + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1777,18 +1788,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 6: /* ACMD6: SET_BUS_WIDTH */ - switch (sd->state) { - case sd_transfer_state: - sd->sd_status[0] &= 0x3f; - sd->sd_status[0] |= (req.arg & 0x03) << 6; - return sd_r1; - - default: - break; - } - break; - case 13: /* ACMD13: SD_STATUS */ switch (sd->state) { case sd_transfer_state: @@ -2390,6 +2389,9 @@ static const SDProto sd_proto_sd = { [58] = {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] = {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, }, + .acmd = { + [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, + }, }; static void sd_instance_init(Object *obj) From patchwork Tue Jul 2 09:20:45 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: 809096 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118434wru; Tue, 2 Jul 2024 02:29:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVSr2qUdpxTJz3PQYt6FtC5k/BwO7DsXewxPpeb3gf+GqX+mUjyRrQzh3HZGLfjc9AX2NRGOLSCFewiU435CdZb X-Google-Smtp-Source: AGHT+IGIiD/ilmLzvGv+IqPFBJzis8TSSwzOoFmuRgHMWLrFvfnxBJFAXhN5t+BL8yaAqBVXj+nQ X-Received: by 2002:a05:622a:1346:b0:446:4968:45 with SMTP id d75a77b69052e-44662e980f3mr79414751cf.42.1719912588408; Tue, 02 Jul 2024 02:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912588; cv=none; d=google.com; s=arc-20160816; b=n+DeSPnZwbzatmg+cdXafGroyh16DbYEo4ymeDGsgCR3g9QKDJx5IQ4A5DXVygKcz+ 3IubxSpTq1gjm1BSAFK1I6EUA6dgLI2olUqhZBqCoQEWpFCTIrapMbGc7Cu15QJZKGy5 JbiOj6wRfWdhd5Q/AHIzpfm0HHPrgyooC7t7ZZv6tgb35a074GMf+LfKJjoOZbvHN4l3 twlYSAQGM/mY+/VeKRGUPI7TahaDJjp2w2FwoIfAB1b2gRDR11yCX+boxbg7LJgsPn6c C+lQ4r3Z8rCUCh2jTuPdr+sBm4eVZcQE0BJMrArlWo3JIyCt2IYwMPCvbMDYruyrlzXw fMBQ== 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=s9keY/jFkvIiFyvDvTcECImv8SUtBS1LmlJu/B1CPmg=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=L6tI5tl6fQT0O5E33rida7TS9iF68zISCjavLR726ojSqav/4O0B+Cg8qmpj309DkK +X+zovY++A+9rK47f0CS+DgNyQcNRta+KjTXcsxXNTvNsfz9RIesAEXHfc/ve9PGIU2y I4u5ICIUxSfjitDJ4sfpe1iLVZQfEHoIChWQitAoJQWVD+rQMnH0mgEHnQ2cFj0dnoeV ttzkl7P2mSRPARCqXo0DHxNk/RXEBsMkbU/bXvlz8OY6Ie1yxAujjOpTM3NsoFThi6zp VLA/38OcRd7Awl1y3C2xT6vtLVbKOuMkz4Ez2fEhp04JeTRI40/G6eU5hq4Rlrlf00sP sg0A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="y/sFqRp3"; 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-446514e49casi97748921cf.718.2024.07.02.02.29.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:29:48 -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="y/sFqRp3"; 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 1sOZnD-0003lE-BF; Tue, 02 Jul 2024 05:27:19 -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 1sOZmw-0003U1-Nn for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:02 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZmu-0001ap-It for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:01 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3627ef1fc07so2285135f8f.3 for ; Tue, 02 Jul 2024 02:26:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912418; x=1720517218; 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=s9keY/jFkvIiFyvDvTcECImv8SUtBS1LmlJu/B1CPmg=; b=y/sFqRp3U2tafWxzAb45mUtjulRJX7UbH86PRxqwNjIeAYb//htCIfCOjkK4jHupNZ j5XPeGsyEe0HRg5ZXnyvJI9AXT7xIku2vSCgL3Gz1HiFLEydWtpRbTjyRvzlmW3b84UP 6CNDiGpzDRYrPSeFSjePp1E/nsqf/oEXnCA+Zxr34Vj/azRwI8C652wNyJmdcoHf2vm3 jWaobB1E4tcsFvELVwJzgf79gKnC+OYCQR0QkFkOxh5oUm4gLw6abeaUhbIutbDfWpuX dhitcGDEjg7rjBjrmYKb2WzRYnpaNmpqrONFHXnL7uEOfNtPiuWnhwa84Q5qyukpVvIl fu9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912418; x=1720517218; 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=s9keY/jFkvIiFyvDvTcECImv8SUtBS1LmlJu/B1CPmg=; b=SLz8BuWS8/VIlS7rv7xwiE3F55GJYwSI+beER1acX4giGxsKmV5PiJbWHa29VvyYuL wN6VwAKe8Rdje8RC5+AjAYhFNNTlUm4ArCPu6EEZQ3U7ef/CVVbnXfppvgLI2t1274T5 Bv4g5hyZ4mef2l/5ts7XyKGn9zEEeaxHI8KTEPLt/kf+5QrVDQ0mJxRvaF/PE/rwsVt4 XBqBNFxgV+RH4i2M+VwjBftfkFPY9d+zpX2nr2BUpp4S4AkAhDoeJN/iU+68n4e5wrun crgrHOoyPAp27MCOw++ZuEQkWhALsOjm5j0GF+B6EQPEcVj17IvLQJHiTpJgBYoekMT4 p2aw== X-Gm-Message-State: AOJu0YzzWVgSRHG5t9yntbJxmX7d5f2FTqsCC2o9XRxD/fr3nzoVrSN9 kkxogalsxxxvUurixGyXZmAWzEj50xpltVzB08giSnTjQTgB5hnt9Atm2qZCEwpT7DJAj+3AniL 2 X-Received: by 2002:adf:cc81:0:b0:367:3b0:f8f6 with SMTP id ffacd0b85a97d-367756c7313mr4734925f8f.36.1719912418576; Tue, 02 Jul 2024 02:26:58 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0d9b1dsm12716767f8f.42.2024.07.02.02.26.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:26:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 62/67] hw/sd/sdcard: Add sd_acmd_SD_STATUS handler (ACMD13) Date: Tue, 2 Jul 2024 11:20:45 +0200 Message-ID: <20240702092051.45754-63-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-70-philmd@linaro.org> --- hw/sd/sd.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index fed95563b8..8b31e0b41c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -258,7 +258,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *sd_acmd_name(SDState *sd, uint8_t cmd) { static const char *acmd_abbrev[SDMMC_CMD_MAX] = { - [13] = "SD_STATUS", [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", @@ -1664,6 +1663,13 @@ static sd_rsp_type_t sd_acmd_SET_BUS_WIDTH(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD13 */ +static sd_rsp_type_t sd_acmd_SD_STATUS(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, + sd->sd_status, sizeof(sd->sd_status)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1788,18 +1794,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 13: /* ACMD13: SD_STATUS */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, - sd->sd_status, - sizeof(sd->sd_status)); - - default: - break; - } - break; - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ switch (sd->state) { case sd_transfer_state: @@ -2335,6 +2329,7 @@ static const SDProto sd_proto_spi = { [59] = {0, sd_spi, "CRC_ON_OFF", spi_cmd_CRC_ON_OFF}, }, .acmd = { + [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2391,6 +2386,7 @@ static const SDProto sd_proto_sd = { }, .acmd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, + [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, }, }; From patchwork Tue Jul 2 09:20:46 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: 809108 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118957wru; Tue, 2 Jul 2024 02:31:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV27xwE+eGCYRfPmgaJBnm3QfXdJZ5hl3RbUSxlTNveaPtyzty8KzHFd4vpxHvrp68gaySbPZJLkFR1zScQYNIB X-Google-Smtp-Source: AGHT+IFGeLZYFHAW064ubq0DLR2St7QF3zmIw+FQixQT1ED5chCYGpC/+fxo7RZD+18E538aZQxT X-Received: by 2002:a05:600c:4c14:b0:424:f2b9:81f5 with SMTP id 5b1f17b1804b1-4257a028321mr53756645e9.9.1719912694843; Tue, 02 Jul 2024 02:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912694; cv=none; d=google.com; s=arc-20160816; b=J6f3lId/MVfBiS0r2DKGWi/CVzK8emtwokZXG+OGtI0xCkW6iWb3DGb1aXNigqbXMx KCBmQ1Qw2/PjnzPShbPzNSDbx2XXJrcZYZ8ET6ZjcCuGS9cQ7zIC02ZdM85ayR4IFuh6 ie0GpxrG0AH2QYhjqzVPsYC1/tI4U0zYATgMBj4uDxWl27D5904PiRhWbF62KRGx04uo 17U6vpbW0bc+8Ms46f7AnCwueoLwCUWgL7F02gW/FkXIw2Jq6qvTUFXa4mEreSM2TOn+ 4Qi4vYqkPRYCm0+Iy1vJ0wAzBXMGY4+9RQ79Cqduzj7m8YcYSX4LPlgrpB+5MQZAU7Rw Tnsg== 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=+J0uE60QAC1qoAu1BGNiyLRNnbj4AKJfrIlOAls69nY=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=RR8a8QTUrKOX2+6bKK8Shljbo6zEOAwJqA05avRVk5WZcPPn/eGtgOkcFdRMMApDAJ edcdVI9oeGfThMRxUlfvfK+yApLvJE+0gvnNRPmSlaDDc7vgqyzaR/1yQgzing0cw7h2 4KuhYfrHg1En7Vv0IfGElxjY0l4J0rAQ0560J8X/49unftaD3lumwztU19qZ4h0KhAFB aWNOV85JVpQm3zHCczsJpSftfCrXlhu2fHJRS29RWnyZ4HGjuIV5gM26wW0bw3WSioN+ O1Gjc7cOGQep+lx2IHybB/KyapyHqaMOG2obTK+kl1gtnyNy2fsjyaNUscWSRdvUHYNr PqFQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d1RkojE2; 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 5b1f17b1804b1-4256b0ed5b9si56815055e9.178.2024.07.02.02.31.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:31: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=d1RkojE2; 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 1sOZnF-0003x3-QB; Tue, 02 Jul 2024 05:27:21 -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 1sOZn6-0003bV-FZ for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:14 -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 1sOZn0-0001bS-Hn for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:09 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-424ad991cbbso30465105e9.0 for ; Tue, 02 Jul 2024 02:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912424; x=1720517224; 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=+J0uE60QAC1qoAu1BGNiyLRNnbj4AKJfrIlOAls69nY=; b=d1RkojE2GZXXd0dT+7G/E4XwvI4oT5mW4uRxKYqvoHIGLnryxg/cI7H13mpMYUDCZY tJN4nPUXz/gazASCoquH8OSgSW3htcyW4fw4b5JMhsJTu10q0yTcZTVmHwZBM6i+UWhk B5q6QJnU81uGnPHyEXgvPOrnYWScTEOwD15es6TM49L/gxCmUpltoN35rZ7qemZxqTup CXw9QJ4i9tIwu1kJ/8iHZinGylDUPYeiMq/fOBu3Sz01e3was1USCaV/Tu9MeRdocVa2 prTN9zVTeZNTjB0SAtvpaBePe2ZVoiYKAPzZ+4kkFV/Byj1nl08m+CwnBqSk1ZSEeaUX v/qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912424; x=1720517224; 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=+J0uE60QAC1qoAu1BGNiyLRNnbj4AKJfrIlOAls69nY=; b=Pf7mm81Khyk5JcjPaKDsgRWHeiIW0gsKL2poHYTtavQLyDJnYHOdLFT8SMvYK/Bcim UIiJS8w2i5d3SuhyX9EEn+Q8U6YqU4g68WF0wrujXWen7oo6RrHJZiTuQEVa+DUvKRSN s4luGLZPEylgCykCvGVpwkXbWWt21uxE3RgKAvMxWKDHL0Jbbg7xeIX2hzYUxghN70vJ SV1LvY09MirPZkQhB0czYM5uUIXulWjvLOe4KNJIBWRBdcG++OlWaltFsqGLZnK08//9 TnjuFuZCLbBhO+04gMI/rpfTUg+IGAuma9cbZJFT1FKUkiYc8UlE9COBDjOVWJoKnvWS EYFg== X-Gm-Message-State: AOJu0YznzEaRBKBY5+u/SdW2y+K0az5Zb5ozOlwWr0ZTjlDhtWatjrzy OGNk818iVjk03h2WemDQGZdIGAcTCxMHJ0kUWsIIZMzr3E4isBNUf1rFvZlycoeufz46VhfTCnq h X-Received: by 2002:a7b:cd92:0:b0:425:781b:9802 with SMTP id 5b1f17b1804b1-4257a02b746mr53594915e9.12.1719912424299; Tue, 02 Jul 2024 02:27:04 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b099c72sm188322485e9.37.2024.07.02.02.27.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:27:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 63/67] hw/sd/sdcard: Add sd_acmd_SEND_NUM_WR_BLOCKS handler (ACMD22) Date: Tue, 2 Jul 2024 11:20:46 +0200 Message-ID: <20240702092051.45754-64-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-71-philmd@linaro.org> --- hw/sd/sd.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8b31e0b41c..6e9ab92a1a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -261,7 +261,7 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [22] = "SEND_NUM_WR_BLOCKS", [23] = "SET_WR_BLK_ERASE_COUNT", + [23] = "SET_WR_BLK_ERASE_COUNT", [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", @@ -1670,6 +1670,13 @@ static sd_rsp_type_t sd_acmd_SD_STATUS(SDState *sd, SDRequest req) sd->sd_status, sizeof(sd->sd_status)); } +/* ACMD22 */ +static sd_rsp_type_t sd_acmd_SEND_NUM_WR_BLOCKS(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, + &sd->blk_written, sizeof(sd->blk_written)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1794,18 +1801,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, - &sd->blk_written, - sizeof(sd->blk_written)); - - default: - break; - } - break; - case 23: /* ACMD23: SET_WR_BLK_ERASE_COUNT */ switch (sd->state) { case sd_transfer_state: @@ -2330,6 +2325,7 @@ static const SDProto sd_proto_spi = { }, .acmd = { [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, + [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2387,6 +2383,7 @@ static const SDProto sd_proto_sd = { .acmd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, + [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, }, }; From patchwork Tue Jul 2 09:20:47 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: 809089 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118096wru; Tue, 2 Jul 2024 02:28:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVpmN/WnqKt0ytgCo1de/+dElN6zQYfevTMS9Ome4wZqvRacfcYSlq4Gebpf6aO58BkyrLK12ipp+GaiqEVmV0s X-Google-Smtp-Source: AGHT+IEE5iqP9i8YFN+q9FNYPlt86rW3U3RJGOLorg9HPKTn08X9LZcYr3wBMsJ6DKOszMazlkba X-Received: by 2002:a05:620a:3bcb:b0:79b:a8df:7829 with SMTP id af79cd13be357-79d6ba4cccamr1615531785a.14.1719912510953; Tue, 02 Jul 2024 02:28:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912510; cv=none; d=google.com; s=arc-20160816; b=Oo0mO77T6gwwhIr7c3QJRd41jHEhzdxsDtNpBGcqw+0i2udmkWuEuTiF8TtkSDhrhQ fXpjzTuPmAr8TtXHaqT3fzIE5a21xT1UWBEvOSlccl4bsRBsswsVE6SDKUiwWxtp/dnP DfZc4uiMOCv9VbXcngHQ7BoK2yiMy/sJ38MzCuFrY8wtzfa9cMNqyS7FCgrE6gRDdcvO Nudqe8XE5+8WgTZCEf4WLni++EGdG+2NJ/XPZLjQcsJRUxGjtkBle7oHD1JzOTFtqVGF uI1cjnIfeM33JR1YfSJNhnyk0hZcEusfmccNuGAeC52YAIllDIp/uDq1sIeDEXCtarnr cFJg== 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=PRpXZ/lTgoptLk88HU8T9HvMCsCj/dqSxIEhw3vh1zM=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=WQgIOlVznG5+g5vCFJnoalWqBzjBUKJgnRYK54t5yfy9UG+R6Ch7YhoFrgX0zoPBC6 Cce6AL/kKY/kk0sOKHL0gAvmrl4nkaLNpQbBw2t0t3S5jULUr7WzJ2Tda4LafRn4K2RC UY9mzAB4doNkV/vR1SFxYbwPG4W3Fochy0ottp0MuuNrbMuYf6IxTEdKEJIF4x1zrjJ0 dR/g0LDWqJwLhCEqLxei0izikvZrK6da1H/AAgdZZ3VZX3U1aablcD4vLLh/AII9oR6c WmdffD8tXmQA0PygoIt9R8jJ2AICarn7k0YqQbs8e08MBmJg2RM7z/uiMVuByboKM2Aq QW3A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lswc24F0; 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-79d69260c43si963088485a.34.2024.07.02.02.28.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28:30 -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=lswc24F0; 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 1sOZnE-0003tx-Ak; Tue, 02 Jul 2024 05:27:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZn8-0003de-3y for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:14 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZn6-0001bf-Bc for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:13 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3636c572257so2884571f8f.0 for ; Tue, 02 Jul 2024 02:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912430; x=1720517230; 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=PRpXZ/lTgoptLk88HU8T9HvMCsCj/dqSxIEhw3vh1zM=; b=lswc24F04AUHre/zz29IdQAuPV8CngBhD2htQO6DLp7AS1uRHpZ85S5lLKrx/o7KC2 0T2z6BigeoMCxRScna7wPad7LlAfHaQwStHQjpklPtTIfK6ee+N+o900qFwvS11Q8dBm vDZphwwlbR+KEke7/riD1CdbSGTf6Q7Dps6/nvvfOFoX3eWZ2GuPjxMLsPbwL0zfryKm ynLzAE37DSjk4o+As1rSz++J8xyQkJaoUahVTclZ1ROUs3ISA+cMtUYtXeRvlnV1180/ 9nu4oigWtxi68Ad7u1XbgO8W1MZrrvgIppnLZeNmr6z8TH583ORMOGgtQRUnX4iqwERo Ir9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912430; x=1720517230; 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=PRpXZ/lTgoptLk88HU8T9HvMCsCj/dqSxIEhw3vh1zM=; b=N4ODmxOmdL0ruQNaVva3gTTjDdZOjZ+ui1qkHUVuGVGo/2NqfA5FPY7beQ4a3TXIdJ POLqzJ557SBdIx9rN0jBQTt93qnjpMHciiZiTQpX+7hwpIpzTdGKP1CoW6Oa3EZzeEZA YLBONXmcMtoN0CVn9E2nqi9AKQTKekV5Gq2pQcaooUVYDc1WZ1ui6Ma2sDkdmaS6aQFC WpDXxlihWWIRdAN91sgyevSQaDZlncs1JvXoMwPOl/8JBSIEWs3bqijHxSOo7YbzgF3e iCihcD7eUpykAEtZhHFFZsS2s/147mPQPvA8cYLGRl9g+I/D9VScEF1N7dcTIeXAgU7S 68kQ== X-Gm-Message-State: AOJu0YwSnS7nWN1GSIYfIlGz9R170VJBOyo0N7e5CMey1yNyrE+Yt4Fu T6Yv90sWg1GVCHWOzPmb2AMicZYeok5m4QrKl9kTkyCHE/oEzP7Y26KKb5fzNz2qgrUzsk9/drG m X-Received: by 2002:a5d:6d04:0:b0:367:4dce:1ff4 with SMTP id ffacd0b85a97d-36775699516mr6639342f8f.14.1719912430016; Tue, 02 Jul 2024 02:27:10 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0fc412sm12724646f8f.70.2024.07.02.02.27.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:27:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 64/67] hw/sd/sdcard: Add sd_acmd_SET_WR_BLK_ERASE_COUNT handler (ACMD23) Date: Tue, 2 Jul 2024 11:20:47 +0200 Message-ID: <20240702092051.45754-65-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-72-philmd@linaro.org> --- hw/sd/sd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6e9ab92a1a..c56790f091 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -261,7 +261,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [23] = "SET_WR_BLK_ERASE_COUNT", [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", @@ -1677,6 +1676,15 @@ static sd_rsp_type_t sd_acmd_SEND_NUM_WR_BLOCKS(SDState *sd, SDRequest req) &sd->blk_written, sizeof(sd->blk_written)); } +/* ACMD23 */ +static sd_rsp_type_t sd_acmd_SET_WR_BLK_ERASE_COUNT(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1801,16 +1809,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 23: /* ACMD23: SET_WR_BLK_ERASE_COUNT */ - switch (sd->state) { - case sd_transfer_state: - return sd_r1; - - default: - break; - } - break; - case 41: /* ACMD41: SD_APP_OP_COND */ if (sd->state != sd_idle_state) { break; @@ -2326,6 +2324,7 @@ static const SDProto sd_proto_spi = { .acmd = { [13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, + [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, }, }; @@ -2384,6 +2383,7 @@ static const SDProto sd_proto_sd = { [6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH}, [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, + [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, }, }; From patchwork Tue Jul 2 09:20:48 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: 809103 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118605wru; Tue, 2 Jul 2024 02:30:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV+ecMm8BHdfTfp6joXByh2BNcJb6kN/8WmUC7NDxxHaxl7mA52O43YEoaGxrcmDMjnxkDZ048wPAM49UvDZydw X-Google-Smtp-Source: AGHT+IFnsZ2KfMsqlls3xKBIL8K06oYpW7NCBB7atfwJJmHR1e1lmMjFMAeAyPAw5TkHVSzIDi2P X-Received: by 2002:a05:6102:373:b0:48f:4c7d:80c with SMTP id ada2fe7eead31-48faf08cfc7mr7816135137.8.1719912627871; Tue, 02 Jul 2024 02:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912627; cv=none; d=google.com; s=arc-20160816; b=pdF/8muYjCUULbaaswdtBuuRzJVY1oHzrdND8YVela25gwZiP9oPkHb+Ue/SkCwmlU vC264geqFjfUOkc5wJaPUyoyjxFzd/Sy8Od4hNcuFHDxIe9ZRMKshIHYLq7mJSR7K+M3 Lbj1+9Y3IHNC2V5Rr+pkaLkccv7LKl8BD4VEiqdVpHKgZc+mtjmMOUv5QnZygZukvyjl w8Q2vwTxUXIPEkXWZvC+4HCU8/npSlL5u1AShfIgcnGyjGm8Sij9/Zet51u8g5rTXGZz 5tRsA9qkArefDNoWsXfv07GLr+GkXL7aUUn1O+YGvSz2SLePxrdT7qZUFdrAXnf7fC/V pW5Q== 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=lKLmaY+ITMzDV6voXczq+aWnHEY0UJpGnuJKCBTpGi4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=yIomFWjNFLrRnx0O3QRvv8gJVv2Df14Qi6PpKppXhBFdWJJx7uxkO3d7lHb8pDk7aP 6/xVm/3CRhq/rt72WUuKvTrW+Y+zpvgFJBuMJjJjdDP4zdpZo2MUVqi2fXwJyzqAEAzf 8dEpjJ3BWsr0a5IwtTJnC2+s3c6RpPSX4eiokX7JUFzM/vfWwGqOjRcLpfBQ53TFZ3fl diZQhqui+oyEXz4zzryndwpA7jg+gET4cqybCbM8bV0v+x1XqLKzAlAF01CpQ/97LJi7 AiQ8xvA506HFPerdNRJnpq0JVIHFnsnRla5wt9MQe3Tvei/cXGTSGTdeB2kN0x361I2l BTtg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IYmr69Rp; 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-79d6933b2afsi948195985a.644.2024.07.02.02.30.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:30:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IYmr69Rp; 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 1sOZnK-0003yx-Fn; Tue, 02 Jul 2024 05:27:26 -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 1sOZnH-0003xX-Lp for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:24 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZnB-0001dk-Re for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:22 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52ce6c8db7bso5944624e87.1 for ; Tue, 02 Jul 2024 02:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912436; x=1720517236; 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=lKLmaY+ITMzDV6voXczq+aWnHEY0UJpGnuJKCBTpGi4=; b=IYmr69RpYj5bWzrFg7bj+sneEJYkSHz2PcPccAcVZGLVOGRcyMZvNlP9nYI4hTtNAd hant+LvxeYEzX9qEYun/BTchsfcOdIMkcoBp+xI1oL8+CS2ETr94HzGfHCREMqiNoMlb vm4AkuOi8IjSIDkE6SaNgClsO+mlBb8pa47VsZ/NJ1uTX2RB3lANciIZifa7qx3SjF6W zhFuic1DhVRmdAwPgxmbT1ZEzxz7C3LdFzjwGHPNrSxZ9xueK9qTbNtcNSZu0HwGa5Gm iLJ5E2+s5bP3JDfuCkj6mL7wdccCfGpOU4O4yEqdikSqSX5fJP95JWe28a0A0fV2a1Sv H7pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912436; x=1720517236; 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=lKLmaY+ITMzDV6voXczq+aWnHEY0UJpGnuJKCBTpGi4=; b=R3cBaAwKMMNImi87X8N43wjoPC4344ysL0NFuT8kjVCBDr/318QYzWVwlmjUflU2bh 0jhDnjQqESD3VNwg7h5GYskHzn0sY9ugeb5B2nxf0qsTEHESs05aBmiytnmRW7XIlD0U 0X98fyeNtDOkGCp8VQIjFc3fNX1vCzOx9O79Z0uPM8K1QBW5oI2CHqUXIM+eF0aL5zU2 vTah4Bh1ObMrytG61khbzRRpJAM5oo+AU02fj+EvgI+6g4BtndXwTcJlZjFnS0nr5YUT st6o5LqsHeyuAnSSQzkRUVHIGEDtAbDGm+ph3ICP5Q2OGB9VmQ5QONn+aC3txnqE1CQl 6WIw== X-Gm-Message-State: AOJu0YwayrY0pW86as3U8ppaqxx+g8aLpQeNQ/Y/VkH0LRTh0F3utKXH 7NkOOTSbcbx7l909ygxvAAnotxPE0jOq8Tg1RCXNs93g2sYBKYOuXVRnLWvPJbYS5GZO6fc2mey U X-Received: by 2002:a05:6512:12d1:b0:52c:e11e:d493 with SMTP id 2adb3069b0e04-52e8267b901mr5492188e87.26.1719912435873; Tue, 02 Jul 2024 02:27:15 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b0c1018sm188560715e9.40.2024.07.02.02.27.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:27:15 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 65/67] hw/sd/sdcard: Add sd_acmd_SD_APP_OP_COND handler (ACMD41) Date: Tue, 2 Jul 2024 11:20:48 +0200 Message-ID: <20240702092051.45754-66-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=philmd@linaro.org; helo=mail-lf1-x129.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-73-philmd@linaro.org> --- hw/sd/sd.c | 82 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c56790f091..207deb07e6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1685,6 +1685,50 @@ static sd_rsp_type_t sd_acmd_SET_WR_BLK_ERASE_COUNT(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD41 */ +static sd_rsp_type_t sd_acmd_SD_APP_OP_COND(SDState *sd, SDRequest req) +{ + if (sd->state != sd_idle_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + /* + * If it's the first ACMD41 since reset, we need to decide + * whether to power up. If this is not an enquiry ACMD41, + * we immediately report power on and proceed below to the + * ready state, but if it is, we set a timer to model a + * delay for power up. This works around a bug in EDK2 + * UEFI, which sends an initial enquiry ACMD41, but + * assumes that the card is in ready state as soon as it + * sees the power up bit set. + */ + if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { + if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { + timer_del(sd->ocr_power_timer); + sd_ocr_powerup(sd); + } else { + trace_sdcard_inquiry_cmd41(); + if (!timer_pending(sd->ocr_power_timer)) { + timer_mod_ns(sd->ocr_power_timer, + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + + OCR_POWER_DELAY_NS)); + } + } + } + + if (FIELD_EX32(sd->ocr & req.arg, OCR, VDD_VOLTAGE_WINDOW)) { + /* + * We accept any voltage. 10000 V is nothing. + * + * Once we're powered up, we advance straight to ready state + * unless it's an enquiry ACMD41 (bits 23:0 == 0). + */ + sd->state = sd_ready_state; + } + + return sd_r3; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1809,43 +1853,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 41: /* ACMD41: SD_APP_OP_COND */ - if (sd->state != sd_idle_state) { - break; - } - /* If it's the first ACMD41 since reset, we need to decide - * whether to power up. If this is not an enquiry ACMD41, - * we immediately report power on and proceed below to the - * ready state, but if it is, we set a timer to model a - * delay for power up. This works around a bug in EDK2 - * UEFI, which sends an initial enquiry ACMD41, but - * assumes that the card is in ready state as soon as it - * sees the power up bit set. */ - if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) { - if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) { - timer_del(sd->ocr_power_timer); - sd_ocr_powerup(sd); - } else { - trace_sdcard_inquiry_cmd41(); - if (!timer_pending(sd->ocr_power_timer)) { - timer_mod_ns(sd->ocr_power_timer, - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - + OCR_POWER_DELAY_NS)); - } - } - } - - if (FIELD_EX32(sd->ocr & req.arg, OCR, VDD_VOLTAGE_WINDOW)) { - /* We accept any voltage. 10000 V is nothing. - * - * Once we're powered up, we advance straight to ready state - * unless it's an enquiry ACMD41 (bits 23:0 == 0). - */ - sd->state = sd_ready_state; - } - - return sd_r3; - case 42: /* ACMD42: SET_CLR_CARD_DETECT */ switch (sd->state) { case sd_transfer_state: @@ -2384,6 +2391,7 @@ static const SDProto sd_proto_sd = { [13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, + [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, }, }; From patchwork Tue Jul 2 09:20:49 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: 809102 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118523wru; Tue, 2 Jul 2024 02:30:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVIJpEwnl3vjyuoya2/whY54SXQt6Jt82mkLmNAT5g86HaFAQKp82pR4elylRZKfAi+D2Yqa0hZvoDDqf0vCUfG X-Google-Smtp-Source: AGHT+IEXgiuJTVOa5rGO7uovRlrkAQ+HcBdqQ6g/Nwl251gKM40LjM6v4P+U2v77vAq3VmBPeFW9 X-Received: by 2002:a05:6214:5016:b0:6b5:4338:e029 with SMTP id 6a1803df08f44-6b5b70c94eamr104705326d6.28.1719912609101; Tue, 02 Jul 2024 02:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912609; cv=none; d=google.com; s=arc-20160816; b=zn/rWDlKlKeK9GJ4UB0VDD6r3YffZUS+kHP9ZbbrNcaUQnISHjRSqkKYsJjEWhw2je MBzSj+CuRy1xJXEbMMEh8HcdbCqiHqFDoZCBdttPrG1O5ZTf1LTOA27qdT/8y3YOVoIR /yvAa8HTCPSmzyNzN9tbEicleDhcsJJgV2Ic0BEUBvIk9CCZcAOf5cUchYHXX6DEw7sp 7iidxxUXJgryjjxxHD7O9tRRhGLbgL7kcZrZRXaQH6k8Kv7F82vAArCY2z9usCGqb1dd h6Tj8mTupxwM/ZWWh6/64yW+XABnQWJkYMtPlWiPhBwgrIfCS5hyQPAn9jc9Apqh9yEX jHvA== 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=PTfJi1XXPwjhNkGNkal4TzGgTuML6EnycC4lcNZtgo8=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=EI+9Hmk8wn0FfO2rtgnnSIFsMKQIhpZfizyV8IeDAm8Mq4gB1CE4wcDQQ1aFM+hXYh xTxk03gKb9ZE66pcdQrzHqjh0trHD87hranhCuC4r8qnu7m2DTBMrF4pGUystgP9MZh4 B0IFDb+naMAPo1NGL2RsLeSeUJogXbfNSgf+Bfj7q+4UD3xBvy0gIoWl0tOD/7V+E0Fo 06etWGjt5JGZjmTl3uc6rMXc3XP+yTlnB05Hwl/8Ex6XGoYGWqLWo1ICn5tXz7flgJDy VXscjkOAqeJH6Yik7/iiMdLgktypeGDJU4f+6BHs1QjeFk6glwPScQAAJnmefRAEPOgq ZK/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CBwQ0OZk; 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-6b59e5acf04si101196906d6.311.2024.07.02.02.30.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:30:09 -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=CBwQ0OZk; 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 1sOZnP-0004Mi-4Y; Tue, 02 Jul 2024 05:27:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZnM-00048m-S7 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:28 -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 1sOZnH-0001e3-Tu for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:28 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42562a984d3so27653545e9.3 for ; Tue, 02 Jul 2024 02:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912441; x=1720517241; 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=PTfJi1XXPwjhNkGNkal4TzGgTuML6EnycC4lcNZtgo8=; b=CBwQ0OZkk7/tFY46puxOCIC0bBA6X4svmNXDYNblC/AyxQCbHLoPWQNQiA/Pe02ljW lsPpBHSOh10gZkftO4eCU+Bmc0bzFi835FXF3tJFfUjAcxOCWffpFSO2fwrnPT3AEOHJ iS2n6yuf8GIgBqXd3ytRY6Vxwn+I02sk0lrEB/CyILOrwVhD1eVAPM5rDm6YnGa7/zN0 tGIQCBQHEa9y4TQ1jyhTuK8ItjBILaJHqeyYJ1nX+HqtW18D6DVhl6qUviINY59v6NiS uMSLsImFyBdchsS00hQW+/vsE4DV/DpDQDGW1xPweoHmdqrIE73mhO4KPQjK+id1QXnO i1VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912441; x=1720517241; 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=PTfJi1XXPwjhNkGNkal4TzGgTuML6EnycC4lcNZtgo8=; b=vgTkINFTR2KJ5TyE4VYJq8KkCT6DGaq93O5pObsi05OGowGmy72qRE1y2uBlG48fnv Xh/XqHZ6vQApTtMZZBxy9y+8cwU7YwO5DoxBno5ZQUJdUCSrkskpoW+my9j5uzYlKoIG pF0SB5xpYb0LJJGHAp41f3QIozwrJaeE06oLNl9Q13UFl+Xg1bL3E3ifI1inNsMNgPZf zXHsmzE31MqNWEDLXLdWDPCD+8judOHbgXfGmL7FIAuUHl9IXQN/zjUJRrot19Q7LcBb TCUyubxZLGjsIF+FsLl7nWpoRApmd/BfVe9Doog9vEVXYEdO/f41Nieu7spU9ZkF7mi1 I9CA== X-Gm-Message-State: AOJu0Yy7LhZZ4ViGIhnu9PNvWDD1M6VIqVJquduwLdlVqAC2Lvwk8S6L X9tzo6AoRxScuZ2rhPhEMGkF4IFSFav+B46Y4GW4nFx5C26h2SZe7IhF5P5rUv0p+/+27nXzfcL y X-Received: by 2002:a05:600c:3b07:b0:425:6979:9b5f with SMTP id 5b1f17b1804b1-4257a009c28mr54331655e9.6.1719912441249; Tue, 02 Jul 2024 02:27:21 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257d0d38bbsm106943455e9.38.2024.07.02.02.27.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:27:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 66/67] hw/sd/sdcard: Add sd_acmd_SET_CLR_CARD_DETECT handler (ACMD42) Date: Tue, 2 Jul 2024 11:20:49 +0200 Message-ID: <20240702092051.45754-67-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-74-philmd@linaro.org> --- hw/sd/sd.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 207deb07e6..698d64d2cb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -261,7 +261,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [42] = "SET_CLR_CARD_DETECT", [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", [54] = "SECU_spec", @@ -1729,6 +1728,17 @@ static sd_rsp_type_t sd_acmd_SD_APP_OP_COND(SDState *sd, SDRequest req) return sd_r3; } +/* ACMD42 */ +static sd_rsp_type_t sd_acmd_SET_CLR_CARD_DETECT(SDState *sd, SDRequest req) +{ + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + /* Bringing in the 50KOhm pull-up resistor... Done. */ + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1853,17 +1863,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 42: /* ACMD42: SET_CLR_CARD_DETECT */ - switch (sd->state) { - case sd_transfer_state: - /* Bringing in the 50KOhm pull-up resistor... Done. */ - return sd_r1; - - default: - break; - } - break; - case 51: /* ACMD51: SEND_SCR */ switch (sd->state) { case sd_transfer_state: @@ -2333,6 +2332,7 @@ static const SDProto sd_proto_spi = { [22] = {8, sd_spi, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, + [42] = {8, sd_spi, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, }, }; @@ -2392,6 +2392,7 @@ static const SDProto sd_proto_sd = { [22] = {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_BLOCKS}, [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, + [42] = {8, sd_ac, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, }, }; From patchwork Tue Jul 2 09:20:50 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: 809111 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp119573wru; Tue, 2 Jul 2024 02:33:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV79ikKKU34MJV2td0V9GQfo2D6sBHO3XN3ufeTF/22+lAYpK2DYA9ASe5KKo5yJLXovh27NQL1lQsWTYjel2kD X-Google-Smtp-Source: AGHT+IFsQb1Wa12jIg6s65hG0ME6wx1hktIScTEioNf8IyqXKGJwFdAclTkF2omEEkxZ/Yk8sprR X-Received: by 2002:a05:6000:1bd1:b0:366:f50a:2061 with SMTP id ffacd0b85a97d-367757249d3mr5509134f8f.50.1719912820914; Tue, 02 Jul 2024 02:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912820; cv=none; d=google.com; s=arc-20160816; b=myXeADwzfFPLkgMySm2hF4i6SiTLks/rH8BQjfzxycFmlFERGsNMFu3GciAO33a8Pq QvtPOayZ9muctFGd7CpXADKKm9rguqgOajp8bDHDu1+jRmFtPbIw28U41Jt3hpvH9gbr bO/XSZCStNHZnessKhrFkI6W4lGREX9PRL3d+EFuFP+OSvUg/LucTNes6qg1ZaKZ5kca 1PCLKH/h8lUdk1iwTqqY8rnW/fPHl7zddbnPG4K6Bgi3yLtfPPK327RijmBqPzI26gtS cVP3UVANO/t8o0a1ow00F/yvfHcH+AgXKGwn3KD7CPW8hFCPqka3jAXiik2HvQ5jfW8w 9mqg== 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=iTcgACkHrUOF7g7c1kRdnSX6PuMfUGO+Z91pQ+u8tPQ=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=C1yhtG/1xnFJSTsQDTgPsAgIhxuY+bkdMEcBYWhK7eBJLbXrePy1nFYB6VTk1bb4WR Po2/+RDaWKcZNto3UXx3xGNQpXs12YNsD5SE3NgK9dzXCwODzTjbjx67bqoc+gAaHlD/ rASCqszOhg29U5HATm5tkbrnLf6KwWDNeSkMtppjiZaYRKRlzXTfQEtmcuu5w7B9cJpk imWMj5CfDD9+TIiIqP3fgwaOnujthw7e9nqkoUfAppwOf56mz4Rn5h5CZoapqFBJ1C0v OiTHblZuYF/5KFB1oXn9ZlRhBziFR+rNW3K7oF8uM3IMEnCpYA0hm0KuEtCKvSUrR6sy WlFQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z46SGOou; 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 ffacd0b85a97d-3675a102043si5251951f8f.877.2024.07.02.02.33.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:33:40 -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=z46SGOou; 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 1sOZnR-0004aY-0N; Tue, 02 Jul 2024 05:27:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOZnP-0004Mn-4P for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:31 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZnN-0001ei-Co for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:27:30 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2eaae2a6dc1so51865291fa.0 for ; Tue, 02 Jul 2024 02:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912446; x=1720517246; 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=iTcgACkHrUOF7g7c1kRdnSX6PuMfUGO+Z91pQ+u8tPQ=; b=z46SGOouEiNw6H4liYi/Cz1aZzyjoTbeT4AxoY+XhlER+Lllf1Ob6FsSpvWsNSsX0j 2IzHoVsEUFc+Cf5f+0NyfS7YhAL0AnNjAc1zJcLGOumr4vsl35AkzlemTqJl2WSg5DCo bPcbonWMZSUHdHFDhzzhL5WXzIHoLpcTFxw6RCvuusFKdbjvOziHR5LCh2i6X+Jz4o19 FxbZJ+nOVUve2m7ZoMpwTzQuJyV/E5spcgphVbEywHzqo9JhvQfnZnrWJ63erFFO1fL4 LIu1PH7Ad/yi+YEYqtB/WchGOvES6Ku6iP3oKaRh37L6m9Y1xQnH/s2xhlh/G1Fmcafq bayg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912446; x=1720517246; 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=iTcgACkHrUOF7g7c1kRdnSX6PuMfUGO+Z91pQ+u8tPQ=; b=dknwdJniPTG3jiJe8fVnUdwx2Cx2dM8uOmJ59C96ExnqhPBksYKvNNfY9rTKl4R04n RRuw2ij9sgeWb+4UwGu12OworXjrVegwrTIqiSiKoIsISUteSkygL1Wc3Yw/To+YfQZT G+cBznc4VYO4I1HAlFc7T8enmkzMY4HLr1v2A/vn9PHow8N9QGOI7hf1LjlzL4cfbgEf xPYtTvXtyPHT7/iw4Sok/2bG4KvuYMwsbzJ4nVGvF++OIDaHJ4TM+/YlhZjds5qiOim5 zg946if3EZLgQJQUdojDo7COWVZB1921G+FNbXxuJ37udBR8+Y3bve0MN40Y6Qt8PRC/ WvvA== X-Gm-Message-State: AOJu0Yz/Qm174eS9P31ByEcZ/GKI351updZRq7zKTk4W8fli/5vBCM/H MqKTt8pgnTQJxiYwynbJ7VBz2YvgDnBBOhLOw5Ok3ncfpRRxbPAhuMusEMHgSFDQWDUMzdlNAxT I X-Received: by 2002:a05:651c:b14:b0:2ec:5488:cc9e with SMTP id 38308e7fff4ca-2ee5e3bbd14mr65967521fa.26.1719912446481; Tue, 02 Jul 2024 02:27:26 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4257d0d38bbsm106947395e9.38.2024.07.02.02.27.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:27:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 67/67] hw/sd/sdcard: Add sd_acmd_SEND_SCR handler (ACMD51) Date: Tue, 2 Jul 2024 11:20:50 +0200 Message-ID: <20240702092051.45754-68-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=philmd@linaro.org; helo=mail-lj1-x235.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-75-philmd@linaro.org> --- hw/sd/sd.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 698d64d2cb..552957b2e5 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -261,7 +261,6 @@ static const char *sd_acmd_name(SDState *sd, uint8_t cmd) [14] = "DPS_spec", [15] = "DPS_spec", [16] = "DPS_spec", [18] = "SECU_spec", - [51] = "SEND_SCR", [52] = "SECU_spec", [53] = "SECU_spec", [54] = "SECU_spec", [56] = "SECU_spec", [57] = "SECU_spec", @@ -1739,6 +1738,12 @@ static sd_rsp_type_t sd_acmd_SET_CLR_CARD_DETECT(SDState *sd, SDRequest req) return sd_r1; } +/* ACMD51 */ +static sd_rsp_type_t sd_acmd_SEND_SCR(SDState *sd, SDRequest req) +{ + return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->scr)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1863,16 +1868,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd, } switch (req.cmd) { - case 51: /* ACMD51: SEND_SCR */ - switch (sd->state) { - case sd_transfer_state: - return sd_cmd_to_sendingdata(sd, req, 0, sd->scr, sizeof(sd->scr)); - - default: - break; - } - break; - case 18: /* Reserved for SD security applications */ case 25: case 26: @@ -2333,6 +2328,7 @@ static const SDProto sd_proto_spi = { [23] = {8, sd_spi, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [42] = {8, sd_spi, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, + [51] = {8, sd_spi, "SEND_SCR", sd_acmd_SEND_SCR}, }, }; @@ -2393,6 +2389,7 @@ static const SDProto sd_proto_sd = { [23] = {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BLK_ERASE_COUNT}, [41] = {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, [42] = {8, sd_ac, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD_DETECT}, + [51] = {8, sd_adtc, "SEND_SCR", sd_acmd_SEND_SCR}, }, };