From 2dc5090d76ad2e95eb55bbb6f6e6423f5c635cbd Mon Sep 17 00:00:00 2001 From: Reza Jelveh Date: Tue, 22 Sep 2015 11:18:31 +0000 Subject: [PATCH] MdeModulePkg: AtaAtapiPassThru: select master/slave around DIAG command Some IDE controllers only update ID fields such as sector information on specific commands such as the DIAG command. The master/slave device is therefore selected both before and after sending the DIAG command; otherwise reading the IDE registers yields the master's ID fields. (Reza's patch originally *moved* the master/slave selection from after the DIAG command before it, however Feng asked for the original master/slave select to be preserved; effectively making the master/slave select *bracket* the DIAG command. See this subthread: .) Cc: Alexander Graf Cc: Reza Jelveh Cc: Jordan Justen Cc: Hannes Reinecke Cc: Gabriel L. Somlo Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Reza Jelveh [feng.tian@intel.com: see above] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian [lersek@redhat.com: updated commit message] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Feng Tian Tested-by: Gabriel Somlo Reviewed-by: Jordan Justen git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18529 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c index 420ad273dc..4928ed570b 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c @@ -2613,6 +2613,11 @@ DetectAndConfigIdeDevice ( PciIo = Instance->PciIo; for (IdeDevice = 0; IdeDevice < EfiIdeMaxDevice; IdeDevice++) { + // + // Select Master or Slave device to get the return signature for ATA DEVICE DIAGNOSTIC cmd. + // + IdeWritePortB (PciIo, IdeRegisters->Head, (UINT8)((IdeDevice << 4) | 0xe0)); + // // Send ATA Device Execut Diagnostic command. // This command should work no matter DRDY is ready or not -- 2.39.2