From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::244; helo=mail-pf0-x244.google.com; envelope-from=haojian.zhuang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EB564207DF47A for ; Fri, 27 Apr 2018 22:24:13 -0700 (PDT) Received: by mail-pf0-x244.google.com with SMTP id p12so2940618pff.13 for ; Fri, 27 Apr 2018 22:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=f6HgwyoVHH3HbvtrK7ncJrlt3ddqtePr7d8SexCdDeo=; b=OTzpol5K30i2NCn27dUWxJ5f0kACzQAjTOH9kMe37A2A6I2fgRYUXNDsFI06WBne3r uUACWuOzvhEKlLLQ6m746FK9VCNnaIoFgx8KIfDyYqQsVnNCSk54eYSoy+Zk/C+2gE7i XOahq2SMaj7Vrr1QG1wzEl+oiqzkp0J3jFSvY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=f6HgwyoVHH3HbvtrK7ncJrlt3ddqtePr7d8SexCdDeo=; b=KrGy01Izxt2b7mAS0Pzs7uK/pa2XDrSSngMJPhddU9zVNDx1qb0FTkhgCHFSEOsLrj HwvO7SP0bBqZiYSlsTKFe25auEV+5loC9XRGNCIcqY4U9lIUpggGAzjiKuGRbQIzzPqK pz0kdgUjQ+DHSjshY8AImvQTb3fbTmJmU4+s/aAo9WimhI7O5bk0F3/XtwjPq9lKwR0r zUoXSnB20RB3SPgGv8CjXE14JMLyZXXfaXlrXp5nzbJ8ryH4JWAUHgfIJ/4bpaz9s0nq GKhfV3js3sf04GuOp9Kwpby/gFQu0DLqG4ExCLfBCJyYA52L6gbZ35vJ8LqCYCv870wv IndA== X-Gm-Message-State: ALQs6tBIeJA944LQQynQVg9EkdwM12K2Wl9CPwNUcMJRyR0xE0RMp92o ZNUEgQ9hbGeq4yVymxkvbAtf6IyOkCY= X-Google-Smtp-Source: AB8JxZow4aLK87vXlMzaCiTmuYaPwmSYHRRJ+35txFoAcPT3bMbTuadkIz/h5oeLRs8+vacy0PvDkQ== X-Received: by 2002:a65:57c9:: with SMTP id q9-v6mr4320368pgr.215.1524893053299; Fri, 27 Apr 2018 22:24:13 -0700 (PDT) Received: from localhost.localdomain ([64.64.108.61]) by smtp.gmail.com with ESMTPSA id m3sm5120756pff.150.2018.04.27.22.24.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Apr 2018 22:24:12 -0700 (PDT) From: Haojian Zhuang To: edk2-devel@lists.01.org Cc: Haojian Zhuang , Star Zeng , Eric Dong , Ruiyu Ni , Leif Lindholm , Ard Biesheuvel Date: Sat, 28 Apr 2018 13:24:05 +0800 Message-Id: <1524893045-2958-1-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH 1/1] MdeModulePkg/Sd: append CMD12 for multiple blocks X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Apr 2018 05:24:14 -0000 Send CMD12 to stop transimission for accessing multiple blocks. It's required by SD Card protocol. Cc: Star Zeng Cc: Eric Dong Cc: Ruiyu Ni Cc: Leif Lindholm Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Haojian Zhuang --- MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c index 516c3e704288..64259f99f9bc 100644 --- a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c +++ b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c @@ -426,6 +426,36 @@ Error: return Status; } +EFI_STATUS +SdStopTrans ( + IN SD_DEVICE *Device + ) +{ + EFI_STATUS Status; + EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru; + EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk; + EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk; + EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet; + + PassThru = Device->Private->PassThru; + + ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk)); + ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk)); + ZeroMem (&Packet, sizeof (Packet)); + + Packet.SdMmcCmdBlk = &SdMmcCmdBlk; + Packet.SdMmcStatusBlk = &SdMmcStatusBlk; + Packet.Timeout = SD_GENERIC_TIMEOUT; + + SdMmcCmdBlk.CommandIndex = SD_STOP_TRANSMISSION; + SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc; + SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1b; + SdMmcCmdBlk.CommandArgument = 0; + + Status = PassThru->PassThru (PassThru, Device->Slot, &Packet, NULL); + return Status; +} + /** Read/write multiple blocks through sync or async I/O request. @@ -555,6 +585,11 @@ Error: } } + if (EFI_ERROR (Status)) { + return Status; + } + + Status = SdStopTrans (Device); return Status; } -- 2.7.4