From patchwork Mon Jun 24 13:14: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: 807029 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1877510wrt; Mon, 24 Jun 2024 06:16:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX9hgsJaQOYL2qa1td6Qq371Ek083PONtGnMUivvFeDr/k/gfZHG/2r6XWeWmwEqa2uskTRLTjDpOQPAbGOUNAs X-Google-Smtp-Source: AGHT+IG/XqQ87uwaPZniy+gnxgcRX+1wwiHcIiw71hHdIEWfFK7hFg9Dj/De6A99+pbPizt6WJMO X-Received: by 2002:ac8:5a83:0:b0:440:5f3e:5a33 with SMTP id d75a77b69052e-444eec9de3emr7419651cf.7.1719235004001; Mon, 24 Jun 2024 06:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719235003; cv=none; d=google.com; s=arc-20160816; b=eYTV4QwFaXfQVfwgyysH1GH9LCIB2u6+k3Q2J3dBnpYc/Cmt8gQndpJPFFUrR7Gaul DUDiWQJkWEtnyj8QIl8RfvgDZUFYer8o/heb20zuRp5uxtDrdfKTheRgUNXrWxnuvbY3 phEITaad6E7vbcuwp++WEW4rXTTdp/iDDvL1MCtzlfegruSNjSVMmnzg/8F9EiDzji5e PJGbq211jRTRP9lDHiMgFDYHLAZenM3kYaTldTwDgIlXiL12AW5ck2k6HqdIYa1jHgYf aqOZ5LT14l2TgXhMF6TXXhWZEsVJ1qvdAU2hwEMaEgCSPziQSvyzDYmP1bUjmVlNK4ns y8gQ== 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=o15lljW0J8mLU8KoPH/cOET32R/ivJ529Ef9M/rh/b8=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=l2GbBPU7vTKb7ZfjUFvGvbDeW6b0KFGZneMYzzAol8EZn+yiwYD++4uOSLOJ6Ywy06 ihAs395hZpTkrM/H1gYg8ILK+pFStwcduf5OXDB2zPO9Yq0KUh/2HiBcS5eAN80yi+wq aCbHiI1V1HyhbWYGGZ6r34PnZ+j6F+w2kpwRChDqoJjm0XGHtXgJ20tecoUs+tIQj3h2 PkDcOoJQbJyQeYX+GHEsAvInXyEh/GCxePvs+09XGDI0aeK68B8RW1LFaO+QEkQsNcr+ FJMHMaUIC+vxhqRQm92INFAjkocw5V86tGTP0t54hBvnGRYR9o6wErdmNbeCLIccb84F 0fGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BfLxruUA; 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-444c2b70f68si81414331cf.214.2024.06.24.06.16.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:16:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BfLxruUA; 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 1sLjYg-0004Qw-TO; Mon, 24 Jun 2024 09:16: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 1sLjYI-0004Fs-FJ for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:10 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjYG-0005Zo-53 for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:16:09 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42172ed3597so25439175e9.0 for ; Mon, 24 Jun 2024 06:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234965; x=1719839765; 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=o15lljW0J8mLU8KoPH/cOET32R/ivJ529Ef9M/rh/b8=; b=BfLxruUA5uyuhB7xUoaomyYBhg1tNFjGtXTgn9K38tSe9K/6civ/LiBRgUTC1+YS+p SVL8WNo3OlyX2z2pin8YdzrDpH6+IfMQawSZpeRZNm404k7GIcG3hb7wXHY9A06OTEWW +IN2fG53ZR+hwLU+WbRYq2cCLwfSF03uwziUIQNbRSfeS7OkYOoDpV6F6LUrB7HIHVct P1por0bpwHIorpSqgZorWLyTGm+dBUl0prrDYMdxKYNVg+rbvygoicz3QpYJpttzz+Ql PwRVQr6Zy+pjS3WumIUYV2S/zaq+blRHRwrmfl3X93lfm6vVnMxvRLjfVA+WK0Yoozp6 GNlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234965; x=1719839765; 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=o15lljW0J8mLU8KoPH/cOET32R/ivJ529Ef9M/rh/b8=; b=rqFtB6Qz43CPg81B4Od51Q/rz0rPccU8ZHzP2Dfop/Qk9NGGrD8LcPhTKxfuUqRmpi 9D3g2RywEj84EubqaCOWffrvWbuezpQ/YN1dejthkaxUk2OCXFopuQR86AnAZwPc0QVi 362fOy6fU6AIJSr8Cg/M6zBMKN2csn8qpYdGS3AzB9KKr9h4YTkl1Yn9LvHJ8rDAD6hy AJwFdgwvwJt8wPRcnQt7P5VwQCStvbmcLMAotizV6P2XblLWiCO3WiGvv0OWAqdy9LaK MLAE90c1vGF5Xdw82408rOCs4xrOfuMs2EhNOd5pRgYngBWFHQux0/tj+EnVj3fw7Z6M tLNg== X-Gm-Message-State: AOJu0YxVVybwXfUB24RFItgh4Qzn28ooEwHIAogj9jI6Y9+FcqZ/PM+u qQIHMfmiXrN8ssjXRkwllha501PTgvNs5ibCpjSFeWBnyP696yp5p75b3xSIwe2z1t0Wv/5MtxL G X-Received: by 2002:a05:600c:3b28:b0:421:347a:f0a6 with SMTP id 5b1f17b1804b1-424893dfbadmr44229715e9.3.1719234964807; Mon, 24 Jun 2024 06:16:04 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4248179d506sm132267055e9.6.2024.06.24.06.16.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:16:04 -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/19] hw/sd/sdcard: Factor sd_req_get_address() method out Date: Mon, 24 Jun 2024 15:14:36 +0200 Message-ID: <20240624131440.81111-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extract sd_cmd_get_address() so we can re-use it in various SDProto handlers. Use CARD_CAPACITY and HWBLOCK_SHIFT definitions instead of magic values. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-17-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 912b2f8984..51ab7cd003 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -582,6 +582,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) stl_be_p(response, sd->vhs); } +static uint64_t sd_req_get_address(SDState *sd, SDRequest req) +{ + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + return (uint64_t) req.arg << HWBLOCK_SHIFT; + } + return req.arg; +} + static inline uint64_t sd_addr_to_wpnum(uint64_t addr) { return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); @@ -1106,7 +1114,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; - uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg; + uint64_t addr = sd_req_get_address(sd, req); /* 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.