From 59b1b9d20a8726ba165bad000b5d1f3f9c8ed32b Mon Sep 17 00:00:00 2001 From: "Tian, Feng" Date: Fri, 11 Oct 2013 07:37:30 +0000 Subject: [PATCH] MdeModulePkg/AtaAtapiPassThru: Add parameter check to ResetDevice() to follow UEFI spec. Signed-off-by: Tian, Feng reviewed-by: Jin, Eric git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14764 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Ata/AtaAtapiPassThru/AtaAtapiPassThru.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c index dbc4433723..cc575b98c7 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c @@ -1809,6 +1809,17 @@ AtaPassThruResetDevice ( IN UINT16 PortMultiplierPort ) { + ATA_ATAPI_PASS_THRU_INSTANCE *Instance; + LIST_ENTRY *Node; + + Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (This); + + Node = SearchDeviceInfoList (Instance, Port, PortMultiplierPort, EfiIdeHarddisk); + + if (Node == NULL) { + return EFI_INVALID_PARAMETER; + } + // // Return success directly then upper layer driver could think reset device operation is done. // @@ -2313,6 +2324,37 @@ ExtScsiPassThruResetTargetLun ( IN UINT64 Lun ) { + ATA_ATAPI_PASS_THRU_INSTANCE *Instance; + LIST_ENTRY *Node; + UINT8 Port; + UINT8 PortMultiplier; + + Instance = EXT_SCSI_PASS_THRU_PRIVATE_DATA_FROM_THIS (This); + // + // For ATAPI device, doesn't support multiple LUN device. + // + if (Lun != 0) { + return EFI_INVALID_PARAMETER; + } + // + // The layout of Target array: + // ________________________________________________________________________ + // | Byte 0 | Byte 1 | ... | TARGET_MAX_BYTES - 1 | + // |_____________________|_____________________|_____|______________________| + // | | The port multiplier | | | + // | The port number | port number | N/A | N/A | + // |_____________________|_____________________|_____|______________________| + // + // For ATAPI device, 2 bytes is enough to represent the location of SCSI device. + // + Port = Target[0]; + PortMultiplier = Target[1]; + + Node = SearchDeviceInfoList(Instance, Port, PortMultiplier, EfiIdeCdrom); + if (Node == NULL) { + return EFI_INVALID_PARAMETER; + } + // // Return success directly then upper layer driver could think reset target LUN operation is done. // -- 2.39.2