From 6b13aa602aa1f44743d40691baff2714d842c550 Mon Sep 17 00:00:00 2001 From: erictian Date: Fri, 9 Nov 2012 06:39:56 +0000 Subject: MdeModulePkg/AtaAtapiPassThru: valid ports transverse algo of AHCI controller is updated to handle inconsecutive case Signed-off-by: Feng Tian Reviewed-by: Liming Gao git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13932 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c | 13 ++++++++++++- MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c index 7101c66..1c45312 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c @@ -2202,8 +2202,19 @@ AhciModeInitialization ( return EFI_OUT_OF_RESOURCES; } - for (Port = 0; Port < MaxPortNumber; Port ++) { + for (Port = 0; Port < EFI_AHCI_MAX_PORTS; Port ++) { if ((PortImplementBitMap & (BIT0 << Port)) != 0) { + // + // According to AHCI spec, MaxPortNumber should be equal or greater than the number of implemented ports. + // + if ((MaxPortNumber--) == 0) { + // + // Should never be here. + // + ASSERT (FALSE); + return EFI_SUCCESS; + } + IdeInit->NotifyPhase (IdeInit, EfiIdeBeforeChannelEnumeration, Port); // diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h index 052e783..485b647 100644 --- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h +++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h @@ -26,6 +26,8 @@ #define EFI_AHCI_IS_OFFSET 0x0008 #define EFI_AHCI_PI_OFFSET 0x000C +#define EFI_AHCI_MAX_PORTS 32 + typedef struct { UINT32 Lower32; UINT32 Upper32; -- cgit v1.1