From nobody Tue Dec 24 00:24:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151264050853526.60103780177917; Thu, 7 Dec 2017 01:55:08 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 34D2421B0283E; Thu, 7 Dec 2017 01:50:34 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F3F4821B02839 for ; Thu, 7 Dec 2017 01:50:32 -0800 (PST) Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2017 01:55:05 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.14]) by orsmga007.jf.intel.com with ESMTP; 07 Dec 2017 01:55:04 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="791121" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Thu, 7 Dec 2017 17:55:03 +0800 Message-Id: <20171207095503.20652-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.0.gvfs.1.preview.4 Subject: [edk2] [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao A Wu , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Current code always return EFI_MEDIA_CHANGED no matter the media is removed from CD/DVD drive or the media is changed. It doesn't strictly follow the UEFI Spec. Update code to return EFI_NO_MEDIA when media is removed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Hao A Wu Reviewed-by: Hao Wu Reviewed-by: Star Zeng --- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 41 ++++++++++++++++++++----= ---- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bu= s/Scsi/ScsiDiskDxe/ScsiDisk.c index 2289f20152..6a0a193556 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c @@ -568,6 +568,7 @@ ScsiDiskReadBlocks ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -598,14 +599,17 @@ ScsiDiskReadBlocks ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media =3D ScsiDiskDevice->BlkIo.Media; BlockSize =3D Media->BlockSize; =20 NumberOfBlocks =3D BufferSize / BlockSize; @@ -700,6 +704,7 @@ ScsiDiskWriteBlocks ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -730,14 +735,17 @@ ScsiDiskWriteBlocks ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media =3D ScsiDiskDevice->BlkIo.Media; BlockSize =3D Media->BlockSize; =20 NumberOfBlocks =3D BufferSize / BlockSize; @@ -922,6 +930,7 @@ ScsiDiskReadBlocksEx ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -952,14 +961,17 @@ ScsiDiskReadBlocksEx ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media =3D ScsiDiskDevice->BlkIo2.Media; BlockSize =3D Media->BlockSize; =20 NumberOfBlocks =3D BufferSize / BlockSize; @@ -1081,6 +1093,7 @@ ScsiDiskWriteBlocksEx ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -1111,14 +1124,17 @@ ScsiDiskWriteBlocksEx ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media =3D ScsiDiskDevice->BlkIo2.Media; BlockSize =3D Media->BlockSize; =20 NumberOfBlocks =3D BufferSize / BlockSize; @@ -1230,6 +1246,7 @@ ScsiDiskFlushBlocksEx ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -1260,13 +1277,15 @@ ScsiDiskFlushBlocksEx ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } =20 - Media =3D ScsiDiskDevice->BlkIo2.Media; - if (!(Media->MediaPresent)) { Status =3D EFI_NO_MEDIA; goto Done; --=20 2.15.0.gvfs.1.preview.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel