From patchwork Mon Oct 26 11:03:11 2020 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: 302046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ECE3C4363A for ; Mon, 26 Oct 2020 11:19:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9A522223C for ; Mon, 26 Oct 2020 11:18:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kjc/4RFE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9A522223C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Wg-0001BS-Rw for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:18:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0He-0008G6-65; Mon, 26 Oct 2020 07:03:26 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:36722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kX0Hc-0002d8-Lk; Mon, 26 Oct 2020 07:03:25 -0400 Received: by mail-wr1-x429.google.com with SMTP id x7so11935707wrl.3; Mon, 26 Oct 2020 04:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yrIfSe6YicHcmNa56yOajmgv3h3ly3b3aUGVmAig4lI=; b=kjc/4RFE5iK3HHoKlDbqjcnlyim9wIhQpf5LzbcLMfBew2cg/MEkszynKYCplZMMdv BiDNzy8oZbG3x72qf4q30ypL9xM81FvkUt7GdIBBHbTUjppYGBF6d2pCRdtMYO46yNCq HEOSAfbyaElweX2waulKR1jQ/BhIXv6gcw70mdaI/YDnz0UMxobvebs9O1fnM7aLdDMe bdvz2+qxuSVuK3h96seYoo7hxSj0p8bkTsqiqZgcE4MB3z5dMeAH6syRcrdrSp50E86h TOu6xmhVtsmnq1RqB8jV6NsJWSiPrndylItjmatwh41r48DbsM26tW4Bq6S49Ri4Igfl nRGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yrIfSe6YicHcmNa56yOajmgv3h3ly3b3aUGVmAig4lI=; b=tfWpSG6tqXJARUmOqQssYrYRQRBoawxOPu777pkyZiVmpjLGhVaojgWPKXxA/Qj8Us v40M/4w66+X4rlyIZvOd9wgi/3FQEuasGCXPd805i9QmR+XzBAT+86jBVr2PUuXNpDcl v+40oHpoulGpOikCq/XU6bEor7xNLI3uIJt29gavv/vaP/+E8GtH34eMPGQ6RaFiNdrR 4HETthl4gshpA3ZOKwlSL2liuG8O5vUGLdZOpVVItAJPuhtE8gbPQKtwBvXMmaEiE/Y5 +/C2/yqMCG9eISOt2CnyleBePHqru2pgrgpOdnpQNEhkWmaH81tjQ/qmfdpJx0vHitLa fxKw== X-Gm-Message-State: AOAM5313pDgLeFbAVquj60plTX5SLjPaA07T92Swk/uM3OTKQCc4JsMr ji/1XoRjP6cwJjeJ26CYmkStCqHoDF4= X-Google-Smtp-Source: ABdhPJzCxwyFqVQw/x5Cl5hWncgMKCklk4TYvbavJ3Vxcq64FiMZgKkzI7R5qC1Rs8NKZbXH+2YLqQ== X-Received: by 2002:adf:f44d:: with SMTP id f13mr16484159wrp.385.1603710202607; Mon, 26 Oct 2020 04:03:22 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id x64sm19263766wmg.33.2020.10.26.04.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03:21 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 1/5] hw/sd/sdcard: Update the SDState documentation Date: Mon, 26 Oct 2020 12:03:11 +0100 Message-Id: <20201026110315.4026183-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x429.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add more descriptive comments to keep a clear separation between static property vs runtime changeable. Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-12-f4bug@amsat.org> --- hw/sd/sd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c3febed2434..9b53053527e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -102,11 +102,14 @@ struct SDState { uint32_t card_status; uint8_t sd_status[64]; - /* Configurable properties */ + /* Static properties */ + uint8_t spec_version; BlockBackend *blk; bool spi; + /* Runtime changeables */ + uint32_t mode; /* current card mode, one of SDCardModes */ int32_t state; /* current card state, one of SDCardStates */ uint32_t vhs; From patchwork Mon Oct 26 11:03:12 2020 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: 270436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DB40C4363A for ; Mon, 26 Oct 2020 11:18:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE0D32223C for ; Mon, 26 Oct 2020 11:18:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UCo+P/Ki" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE0D32223C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0WP-0000aQ-Kc for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:18:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0Hm-0008HU-6y; Mon, 26 Oct 2020 07:03:38 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:54310) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kX0Hk-0002fE-P9; Mon, 26 Oct 2020 07:03:33 -0400 Received: by mail-wm1-x329.google.com with SMTP id w23so10068518wmi.4; Mon, 26 Oct 2020 04:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yet6HVLB8K+LmlUq3G4sMPBL+CDXC+2uR7gzK1ybwmo=; b=UCo+P/KimaEH9WytkmPvQ/gRniaWbuuX5EwVTO78FshBUt9XvuxdcqKUYg2HRl2/HF uujgy62NrA307zdeDZagBpPrb/WBbmK6ejwOmopfjlJxceDfmhznY5D7Z3JCk8g0Smnu JhLVbOk/kmZrBxfpz8OR6d2BsVM3r8NABNpEu/WudgZe9NI7uvPKSQFuP6dkEJzV2pGG sYxzpmWo68kYWQpX7fY4ep45ReiTDtXAClQkBrLYwm+hcrdFgdiWvjWtkUJyoMbIBst+ CVgSTIlAIZcGZX+rez0oJ/N/ZAo7trHBDrT+PNwt5jBUx+yH4JEBaWVqqMxfvNUIp10M mKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Yet6HVLB8K+LmlUq3G4sMPBL+CDXC+2uR7gzK1ybwmo=; b=Wi2hOUSgIEG10H3Cqkhl6jLFIer7UWe4v4EslMSxoZJl8x1po0GIcpGf2f9xKkdr2O PkQIu1Sd7JJXlLm0u3NHQWCmNxIwx41TMb2KgQJQvpSh6km67q67GG9tKavw2OkNYIbX OJOArpd/eZe7wdTHA9RGToSSd+ifxTgCCaMSOcbNKzPGp4fVIW1xbscVxxnftMIKnf84 6GcwxbWnBNUqGSknadTlNuQ2aQgjMphLJi69APz+D0zFKHbh7ftSHH/Y1tYCwhnKhwI4 0WJfTuPIT/0O69rJT61TEe4pjfOcznqmC0H7vFkDsGNBmxLBxYzBOYMNIpGhBlhPdItH H5yQ== X-Gm-Message-State: AOAM532KkxmwbLTJLJY50rIuBB9q2Pz4Sc1MDYlZYrSHUa7KmI0dgPT/ K6TNai8KPyJNxtmWno18H3iqDB6abi4= X-Google-Smtp-Source: ABdhPJySLdeCrCbVanjmhMuFWvOBkSLtLEZCareuAGPGAtFaAqKlTzrurMZUBBK7Bia6aOfWyrjV6w== X-Received: by 2002:a1c:1946:: with SMTP id 67mr15250854wmz.15.1603710207286; Mon, 26 Oct 2020 04:03:27 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id d142sm3477530wmd.11.2020.10.26.04.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 2/5] hw/sd/sdcard: Simplify cmd_valid_while_locked() Date: Mon, 26 Oct 2020 12:03:12 +0100 Message-Id: <20201026110315.4026183-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x329.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" cmd_valid_while_locked() only needs to read SDRequest->cmd, pass it directly and make it const. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-13-f4bug@amsat.org> --- hw/sd/sd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9b53053527e..5510a64401b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1679,7 +1679,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, return sd_illegal; } -static int cmd_valid_while_locked(SDState *sd, SDRequest *req) +static int cmd_valid_while_locked(SDState *sd, const uint8_t cmd) { /* Valid commands in locked state: * basic class (0) @@ -1690,13 +1690,12 @@ static int cmd_valid_while_locked(SDState *sd, SDRequest *req) * Anything else provokes an "illegal command" response. */ if (sd->expecting_acmd) { - return req->cmd == 41 || req->cmd == 42; + return cmd == 41 || cmd == 42; } - if (req->cmd == 16 || req->cmd == 55) { + if (cmd == 16 || cmd == 55) { return 1; } - return sd_cmd_class[req->cmd] == 0 - || sd_cmd_class[req->cmd] == 7; + return sd_cmd_class[cmd] == 0 || sd_cmd_class[cmd] == 7; } int sd_do_command(SDState *sd, SDRequest *req, @@ -1722,7 +1721,7 @@ int sd_do_command(SDState *sd, SDRequest *req, } if (sd->card_status & CARD_IS_LOCKED) { - if (!cmd_valid_while_locked(sd, req)) { + if (!cmd_valid_while_locked(sd, req->cmd)) { sd->card_status |= ILLEGAL_COMMAND; sd->expecting_acmd = false; qemu_log_mask(LOG_GUEST_ERROR, "SD: Card is locked\n"); From patchwork Mon Oct 26 11:03:13 2020 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: 270437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E34FEC4363A for ; Mon, 26 Oct 2020 11:13:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6452622263 for ; Mon, 26 Oct 2020 11:13:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dzfljq8f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6452622263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Rh-0004cw-2m for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:13:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0Hq-0008Hm-Q9; Mon, 26 Oct 2020 07:03:40 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:38099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kX0Hm-0002fn-4l; Mon, 26 Oct 2020 07:03:35 -0400 Received: by mail-wr1-x434.google.com with SMTP id n18so11898877wrs.5; Mon, 26 Oct 2020 04:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3PqeCvMaRSfOqr/6xhOfmbV28LZjwldqha7vO+7WnUc=; b=Dzfljq8fBMOykHo/ksRTTp5iGGkuIy5dPJHu6b4p5BLmM4tyMbfIvgS6BwRBgId/6l ImdPHDmN4/Uu4EV++mPxvJScZZpf3VcKyU8DlSJBxRMham/HvasbhKW2wvtLmgAcE/Tk 755Va/3x+YMrTaD35I+JHNuL35h0h3m/joSMHZZ9XmsPiG976L0+nnpDj08yKUfuvrhr fDDTTo66XCptH8gO5oI29S6m0kWBOXnU+F/3wBbnW8TzUBzzmg8ou3HhFxLi3VHomkiq swF6F+GOr7NHDKgJfyFRJxk6cjbv6+bN42MKhsSLm6HPvo3KOMdFDN3NnA/IBQsmvRxw 1KfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3PqeCvMaRSfOqr/6xhOfmbV28LZjwldqha7vO+7WnUc=; b=sP0Xvkfq74HYlA4BmFHaZODPZW3D7nAyqc1wzFiBJ4v3Wc71kfijlxx7Nf3fZTWd32 g8vlTbGSXDOJnOgBbcd8IE9ghF/IOQP76ok5ENOxG1svs/+aAwxh2TXXemyN31MrmyH3 dL7IWtGKtJ6Jj2F8WdSoPV+CaqDtj+XubgV+3YY5oOuKPXq1OBxC2b1e1JPQ3F19w307 xJ4Go+ydZ/vc+lEp+cKdtcFdElu8zH3zvVhlFuWDM7cdSo54vOeedd1nYi5tyHLbwDG1 5OF7slZtzrPLYGCDcbyYAmEypgz53ivmxR9EYeZQR6Mi1c0XUYlnFTabrBcxq5eG+1ln gZUA== X-Gm-Message-State: AOAM533+cSdLvSAjKHBA4jH1J6PSZaf8Uv+8ji3MfQSDHS7UKw65mHTg VfowuC4jfURxwd+hrD9YMDM/xrCKxAg= X-Google-Smtp-Source: ABdhPJxXPyQANOS53JmNBde6/D2k8al9tvWCuQLC+USjzFwj6ItTzX25RiIhbfb1ulBKL8GLsWuq6w== X-Received: by 2002:adf:ee4c:: with SMTP id w12mr16429071wro.22.1603710212265; Mon, 26 Oct 2020 04:03:32 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id d129sm20226273wmf.19.2020.10.26.04.03.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 3/5] hw/sd/sdcard: Constify sd_crc*()'s message argument Date: Mon, 26 Oct 2020 12:03:13 +0100 Message-Id: <20201026110315.4026183-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x434.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" CRC functions don't modify the buffer argument, make it const. Reviewed-by: Alistair Francis Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20200630133912.9428-14-f4bug@amsat.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 5510a64401b..aa6059d2ad6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -254,11 +254,11 @@ static const int sd_cmd_class[SDMMC_CMD_MAX] = { 7, 7, 10, 7, 9, 9, 9, 8, 8, 10, 8, 8, 8, 8, 8, 8, }; -static uint8_t sd_crc7(void *message, size_t width) +static uint8_t sd_crc7(const void *message, size_t width) { int i, bit; uint8_t shift_reg = 0x00; - uint8_t *msg = (uint8_t *) message; + const uint8_t *msg = (const uint8_t *)message; for (i = 0; i < width; i ++, msg ++) for (bit = 7; bit >= 0; bit --) { @@ -270,11 +270,11 @@ static uint8_t sd_crc7(void *message, size_t width) return shift_reg; } -static uint16_t sd_crc16(void *message, size_t width) +static uint16_t sd_crc16(const void *message, size_t width) { int i, bit; uint16_t shift_reg = 0x0000; - uint16_t *msg = (uint16_t *) message; + const uint16_t *msg = (const uint16_t *)message; width <<= 1; for (i = 0; i < width; i ++, msg ++) From patchwork Mon Oct 26 11:03:14 2020 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: 270434 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E877C4363A for ; Mon, 26 Oct 2020 11:21:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7F9E24641 for ; Mon, 26 Oct 2020 11:21:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B51UdXVN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7F9E24641 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0ZM-0004oB-OB for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:21:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0I0-0008Lr-9X; Mon, 26 Oct 2020 07:03:48 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:50224) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kX0Hx-0002hg-7T; Mon, 26 Oct 2020 07:03:47 -0400 Received: by mail-wm1-x331.google.com with SMTP id 13so11163579wmf.0; Mon, 26 Oct 2020 04:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CaEc+EndnthM/jQRSTritjVWMWjtPivpLOdnvFGKtOc=; b=B51UdXVNUMxIJXfJbtOeTXONrMoctRM+wW11QjE6H/PSYVoSRYayynce9vro6AfVkW 8GKbBCnOo1VvecTZaTVZq5fx962sOXz9AeSJvUPkKPiDpS6WQrKnR3CvGQjz+i1VjJ5x FyiHUtyctPri1rqi2p/OHAkFRFrBS6yqSBQRRiT5CcYnvGbvdkEqYcNLEbbPLwTsvC45 V1RdzZX7OxyPZG/Di85O8ZPk1EDt6fzwBObdQfj3s2Zhs8VWRqHai4EsOKIJFK+gt4pR JVsUcVGYGGBLKVdsKo7UbSL9vUJbzA5A4NYpR9qn/qHLDWRQnZVuwVjJRen/YeWHoGed I/dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=CaEc+EndnthM/jQRSTritjVWMWjtPivpLOdnvFGKtOc=; b=P+J842Q6eN7fkj8KNtstbPWvXd8b7cX2Im/x108jwLqzBVTOj6ClSvcu662XI8rMPO eyf5Wj6WBS+7cFEz9kVtpc5wo9m8u9O9P7c8rVTWDuomkLcMBuKEhlpW/bkpjucCLOdA vQaC3QYtJcexKdvqvFmlvfavRaU194jbClaY5L8PnQAFopomOZzhaGITM0xTAUOU8N9S shJkvqq7TETNcsmhNE1IbNHU9ug6krqdbZkaRq+fJWo40JVGhB3ZSg7sUIOXOkE1QvKK 2gR+MgtD0YWl43iexTXUZecPl61Eknugy3NToFjyURLLQFo5Bk2cAaflJsNv0gJtFzDw DAJA== X-Gm-Message-State: AOAM530Xn2vbI1Xn2AbYLy7YqEmW+TvRZT2PzTdkORbt8aUw8vOJuvCk HBf7HpVXBHw5cwCV3QLh/M110G9gtf0= X-Google-Smtp-Source: ABdhPJyF1JOQLXzJb3x+ZLCPuqMyMqIwI8BIc/uwm2/AcK/dwJkNka42hifUNxBvR6TNrLS6P3KkBg== X-Received: by 2002:a1c:2302:: with SMTP id j2mr15469805wmj.100.1603710217030; Mon, 26 Oct 2020 04:03:37 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id h4sm21987467wrv.11.2020.10.26.04.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 4/5] hw/sd/sdcard: Make iolen unsigned Date: Mon, 26 Oct 2020 12:03:14 +0100 Message-Id: <20201026110315.4026183-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x331.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" I/O request length can not be negative. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-15-f4bug@amsat.org> --- hw/sd/sd.c | 2 +- hw/sd/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index aa6059d2ad6..fcbc1fd9d6e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1982,7 +1982,7 @@ uint8_t sd_read_byte(SDState *sd) { /* TODO: Append CRCs */ uint8_t ret; - int io_len; + uint32_t io_len; if (!sd->blk || !blk_is_inserted(sd->blk) || !sd->enable) return 0x00; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 96c7ea5e52f..4140e485403 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -52,7 +52,7 @@ 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, int length) "%s %20s/ CMD%02d len %d" +sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t length) "%s %20s/ CMD%02d len %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" # milkymist-memcard.c From patchwork Mon Oct 26 11:03:15 2020 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: 302045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 308E3C55178 for ; Mon, 26 Oct 2020 11:21:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A6A182465E for ; Mon, 26 Oct 2020 11:21:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UOj5nklj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6A182465E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0ZQ-0004yb-JQ for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:21:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0I0-0008Lv-8f; Mon, 26 Oct 2020 07:03:48 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:44483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kX0Hx-0002ht-AR; Mon, 26 Oct 2020 07:03:47 -0400 Received: by mail-wr1-x441.google.com with SMTP id t9so11879429wrq.11; Mon, 26 Oct 2020 04:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5U8VWtvmcB+mOzFUXcILRLEPHX5B//Lhi6i5VjZPllk=; b=UOj5nkljlDKhYh9w621rfwoxMHKbnxCtTvOi7lU7FI8flRBUzf+nAAxVssUzllX74M PrCAc78J5684apPjU6UYhL/KuhuqY71UuKKAmwdwasNwnpmi2JJmnl13dCB7XcPNolFx 6mXVG1h5iHavMb7U0Y+fe1SIPZvB+a6MjUuDLLrocZXZVKZbaCDMCG9jxyhM+u7eTzGM JMMgD/clOYZ9B0CvxBUSnMZpCh5Hbwt4bWfrDCTDgQ/zP5UArL/awQw9T+ug6dNFp0np 0gvos3DU+wxUabBMgH770AGviFtwxcmGng2NjgVv2S8kReNsACBy+W/d5LhxvmuFpeIZ pKRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=5U8VWtvmcB+mOzFUXcILRLEPHX5B//Lhi6i5VjZPllk=; b=sOR/s4UUTuzMJS5V36bu+eu57EoAmHccpVEazBKxarrUenJ+5JslYmdlBhVmHO1nE4 7t5xA+qW7/O3KBBGlGGxBmtavw4oAOjy8E31ZySzl2b6pnuVKHiI4Mucjd3fyPbEeR2C gRNO5D0nYT3jJXrdye/FNeUmKWJVKPn/GgAAML5uLcF0CGF9sQck4P6cZx0j8ggT9amH eW9bnrhttORUYCGbr9x54CDKbNsHeJDgNnO/aXl26XauSlLlpGl1h9lhdS956yjI4Ecw W0Ew7Wwfy0YRsVnXPt/Ou8emQPeK0FxzqBuWKjV+ZI6Urcg9o2J8dqko8AKU+weoaWGY 0/xQ== X-Gm-Message-State: AOAM533cu+uSuUxD3shpipgml/MZzTkpJAhXLMd3RK8hGm0PZ+s926ih MScN69kPk8+EYRy37VB5v/Tjc10hJCU= X-Google-Smtp-Source: ABdhPJwIJMSkzJ9ZdoIAXXHOUZikvdrmcf4UsVi4o8MR3oHqi50bixMugLvnZ1sXYwCqLf/R1z5AIg== X-Received: by 2002:a5d:6551:: with SMTP id z17mr17252423wrv.266.1603710222066; Mon, 26 Oct 2020 04:03:42 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id k18sm21141582wrx.96.2020.10.26.04.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 5/5] hw/sd/sdcard: Zero out function selection fields before being populated Date: Mon, 26 Oct 2020 12:03:15 +0100 Message-Id: <20201026110315.4026183-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , qemu-block@nongnu.org, Michael Roth Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng The function selection fields (399:376) should be zeroed out to prevent leftover from being or'ed into the switch function status data structure. This fixes the boot failure as seen in the acceptance testing on the orangepi target. Fixes: b638627c723a ("hw/sd: Fix incorrect populated function switch status data structure") Reported-by: Michael Roth Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20201024014954.21330-1-bmeng.cn@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index fcbc1fd9d6e..30913826145 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -827,6 +827,7 @@ static void sd_function_switch(SDState *sd, uint32_t arg) sd->data[12] = 0x80; /* Supported group 1 functions */ sd->data[13] = 0x03; + memset(&sd->data[14], 0, 3); for (i = 0; i < 6; i ++) { new_func = (arg >> (i * 4)) & 0x0f; if (mode && new_func != 0x0f)