From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 8D87B2119C8A4 for ; Mon, 17 Dec 2018 19:13:02 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2018 19:13:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,367,1539673200"; d="scan'208";a="119279589" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 17 Dec 2018 19:13:01 -0800 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 17 Dec 2018 19:13:01 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 17 Dec 2018 19:13:01 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.182]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.201]) with mapi id 14.03.0415.000; Tue, 18 Dec 2018 11:12:58 +0800 From: "Zeng, Star" To: "Wang, Jian J" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" , "Gao, Liming" , "Ni, Ruiyu" , "Kinney, Michael D" , "Desimone, Nathaniel L" , "Chiu, Chasel" , "Zeng, Star" Thread-Topic: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported Thread-Index: AQHUk5fovhFpHXGqrk6fMIEyY2Yn5qWDREeAgACQ7HA= Date: Tue, 18 Dec 2018 03:12:58 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB04831040220CEC@shsmsx102.ccr.corp.intel.com> References: <1544783322-17436-1-git-send-email-star.zeng@intel.com> <1544783322-17436-5-git-send-email-star.zeng@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Dec 2018 03:13:02 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jian, Good observation.=20 I did consider it. But they are handling different structures. Thanks, Star -----Original Message----- From: Wang, Jian J=20 Sent: Tuesday, December 18, 2018 10:24 AM To: Zeng, Star ; edk2-devel@lists.01.org Cc: Wu, Hao A ; Gao, Liming ; Ni,= Ruiyu ; Kinney, Michael D = ; Desimone, Nathaniel L ; Chiu, Chasel Subject: RE: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCo= reMaxPpiSupported Star, Please consider to extract the code to expand PPI buffer as a function or m= acro. I found it repeated 3 times in this patch. Regards, Jian > -----Original Message----- > From: Zeng, Star > Sent: Friday, December 14, 2018 6:29 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Wang, Jian J=20 > ; Wu, Hao A ; Gao, Liming=20 > ; Ni, Ruiyu ; Kinney,=20 > Michael D ; Desimone, Nathaniel L=20 > ; Chiu, Chasel > Subject: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of=20 > PcdPeiCoreMaxPpiSupported >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1405 >=20 > Background as below. >=20 > Problem: > As static configuration from the PCDs, the binary PeiCore (for example=20 > in FSP binary with dispatch mode) could not predict how many FVs,=20 > Files or PPIs for different platforms. >=20 > Burden: > Platform developers need configure the PCDs accordingly for different=20 > platforms. >=20 > To solve the problem and remove the burden, we can update code to=20 > remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv=20 > and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV,=20 > File and PPI management. >=20 > This patch removes the using of PcdPeiCoreMaxPpiSupported in PeiCore. >=20 > Cc: Jian J Wang > Cc: Hao Wu > Cc: Liming Gao > Cc: Ruiyu Ni > Cc: Michael D Kinney > Cc: Nate DeSimone > Cc: Chasel Chiu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 8 +- > MdeModulePkg/Core/Pei/PeiMain.h | 59 +++-- > MdeModulePkg/Core/Pei/PeiMain.inf | 1 - > MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 30 ++- > MdeModulePkg/Core/Pei/Ppi/Ppi.c | 355 ++++++++++++++------= ------ > 5 files changed, 254 insertions(+), 199 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c > b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c > index 71440bab9488..55a300adbdb8 100644 > --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c > +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c > @@ -1062,7 +1062,7 @@ PeiDispatcher ( > // Process the Notify list and dispatch any notifies for > // newly installed PPIs. > // > - ProcessNotifyList (Private); > + ProcessDispatchNotifyList (Private); > } > } > } > @@ -1209,10 +1209,10 @@ PeiDispatcher ( > // Process the Notify list and dispatch any notifies for > // newly installed PPIs. > // > - ProcessNotifyList (Private); > + ProcessDispatchNotifyList (Private); >=20 > // > - // Recheck SwitchStackSignal after ProcessNotifyList() > + // Recheck SwitchStackSignal after=20 > + ProcessDispatchNotifyList() > // in case PeiInstallPeiMemory() is done in a callback with > // EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH. > // > @@ -1253,7 +1253,7 @@ PeiDispatcher ( > // Process the Notify list and dispatch any notifies for > // newly installed PPIs. > // > - ProcessNotifyList (Private); > + ProcessDispatchNotifyList (Private); > } > } > } > diff --git a/MdeModulePkg/Core/Pei/PeiMain.h=20 > b/MdeModulePkg/Core/Pei/PeiMain.h index b248118087ad..c6c932c3e233=20 > 100644 > --- a/MdeModulePkg/Core/Pei/PeiMain.h > +++ b/MdeModulePkg/Core/Pei/PeiMain.h > @@ -66,37 +66,60 @@ typedef union { > } PEI_PPI_LIST_POINTERS; >=20 > /// > -/// PPI database structure which contains two link: PpiList and=20 > NotifyList. PpiList -/// is in head of PpiListPtrs array and notify is in= end of PpiListPtrs. > +/// Number of PEI_PPI_LIST_POINTERS to grow by each time we run out=20 > +of > room > /// > +#define PPI_GROWTH_STEP 64 > +#define CALLBACK_NOTIFY_GROWTH_STEP 32 #define=20 > +DISPATCH_NOTIFY_GROWTH_STEP 8 > + > typedef struct { > + UINTN CurrentCount; > + UINTN MaxCount; > + UINTN LastDispatchedCount; > /// > - /// index of end of PpiList link list. > + /// MaxCount number of entries. > /// > - INTN PpiListEnd; > + PEI_PPI_LIST_POINTERS *PpiPtrs; > +} PEI_PPI_LIST; > + > +typedef struct { > + UINTN CurrentCount; > + UINTN MaxCount; > /// > - /// index of end of notify link list. > + /// MaxCount number of entries. > /// > - INTN NotifyListEnd; > + PEI_PPI_LIST_POINTERS *NotifyPtrs; > +} PEI_CALLBACK_NOTIFY_LIST; > + > +typedef struct { > + UINTN CurrentCount; > + UINTN MaxCount; > + UINTN LastDispatchedCount; > /// > - /// index of the dispatched notify list. > + /// MaxCount number of entries. > /// > - INTN DispatchListEnd; > + PEI_PPI_LIST_POINTERS *NotifyPtrs; > +} PEI_DISPATCH_NOTIFY_LIST; > + > +/// > +/// PPI database structure which contains three links: > +/// PpiList, CallbackNotifyList and DispatchNotifyList. > +/// > +typedef struct { > /// > - /// index of last installed Ppi description in PpiList link list. > + /// PPI List. > /// > - INTN LastDispatchedInstall; > + PEI_PPI_LIST PpiList; > /// > - /// index of last dispatched notify in Notify link list. > + /// Notify List at dispatch level. > /// > - INTN LastDispatchedNotify; > + PEI_CALLBACK_NOTIFY_LIST CallbackNotifyList; > /// > - /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries. > + /// Notify List at callback level. > /// > - PEI_PPI_LIST_POINTERS *PpiListPtrs; > + PEI_DISPATCH_NOTIFY_LIST DispatchNotifyList; > } PEI_PPI_DATABASE; >=20 > - > // > // PEI_CORE_FV_HANDE.PeimState > // Do not change these values as there is code doing math to change stat= es. > @@ -550,13 +573,13 @@ PeiNotifyPpi ( >=20 > **/ > VOID > -ProcessNotifyList ( > +ProcessDispatchNotifyList ( > IN PEI_CORE_INSTANCE *PrivateData > ); >=20 > /** >=20 > - Dispatch notifications. > + Process notifications. >=20 > @param PrivateData PeiCore's private data structure > @param NotifyType Type of notify to fire. > @@ -567,7 +590,7 @@ ProcessNotifyList ( >=20 > **/ > VOID > -DispatchNotify ( > +ProcessNotify ( > IN PEI_CORE_INSTANCE *PrivateData, > IN UINTN NotifyType, > IN INTN InstallStartIndex, > diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf > b/MdeModulePkg/Core/Pei/PeiMain.inf > index dd41fe41bc89..140c4444b107 100644 > --- a/MdeModulePkg/Core/Pei/PeiMain.inf > +++ b/MdeModulePkg/Core/Pei/PeiMain.inf > @@ -104,7 +104,6 @@ [Ppis] > gEfiSecHobDataPpiGuid ## SOMETIMES_CONSUMES >=20 > [Pcd] > - gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported = ## > CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize = ## > CONSUMES >=20 > gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreImageLoaderSearchTeSectionFir > st ## CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport > ## CONSUMES > diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c > b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c > index 4869bf18f005..4da80a8222bc 100644 > --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c > +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c > @@ -190,7 +190,15 @@ PeiCore ( > if (OldCoreData->CurrentFvFileHandles !=3D NULL) { > OldCoreData->CurrentFvFileHandles =3D (EFI_PEI_FILE_HANDLE *)= =20 > ((UINT8 *) > OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset); > } > - OldCoreData->PpiData.PpiListPtrs =3D (PEI_PPI_LIST_POINTERS *) = ((UINT8 *) > OldCoreData->PpiData.PpiListPtrs + OldCoreData->HeapOffset); > + if (OldCoreData->PpiData.PpiList.PpiPtrs !=3D NULL) { > + OldCoreData->PpiData.PpiList.PpiPtrs =3D=20 > + (PEI_PPI_LIST_POINTERS *) > ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs +=20 > OldCoreData->HeapOffset); > + } > + if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs !=3D NULL= ) { > + OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs =3D > (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData- > >PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset); > + } > + if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs !=3D NULL= ) { > + OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs =3D > (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData- > >PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset); > + } > OldCoreData->Fv =3D (PEI_CORE_FV_HANDLE *) ((U= INT8 *) > OldCoreData->Fv + OldCoreData->HeapOffset); > for (Index =3D 0; Index < OldCoreData->FvCount; Index ++) { > if (OldCoreData->Fv[Index].PeimState !=3D NULL) { @@ -210,7=20 > +218,15 @@ PeiCore ( > if (OldCoreData->CurrentFvFileHandles !=3D NULL) { > OldCoreData->CurrentFvFileHandles =3D (EFI_PEI_FILE_HANDLE *)= =20 > ((UINT8 *) > OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset); > } > - OldCoreData->PpiData.PpiListPtrs =3D (PEI_PPI_LIST_POINTERS *) = ((UINT8 *) > OldCoreData->PpiData.PpiListPtrs - OldCoreData->HeapOffset); > + if (OldCoreData->PpiData.PpiList.PpiPtrs !=3D NULL) { > + OldCoreData->PpiData.PpiList.PpiPtrs =3D=20 > + (PEI_PPI_LIST_POINTERS *) > ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs -=20 > OldCoreData->HeapOffset); > + } > + if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs !=3D NULL= ) { > + OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs =3D > (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData- > >PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset); > + } > + if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs !=3D NULL= ) { > + OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs =3D > (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData- > >PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset); > + } > OldCoreData->Fv =3D (PEI_CORE_FV_HANDLE *) ((U= INT8 *) > OldCoreData->Fv - OldCoreData->HeapOffset); > for (Index =3D 0; Index < OldCoreData->FvCount; Index ++) { > if (OldCoreData->Fv[Index].PeimState !=3D NULL) { @@ -337,14=20 > +353,6 @@ PeiCore ( > // Initialize PEI Core Services > // > InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData); > - if (OldCoreData =3D=3D NULL) { > - // > - // Initialize PEI Core Private Data Buffer > - // > - PrivateData.PpiData.PpiListPtrs =3D AllocateZeroPool (sizeof > (PEI_PPI_LIST_POINTERS) * PcdGet32 (PcdPeiCoreMaxPpiSupported)); > - ASSERT (PrivateData.PpiData.PpiListPtrs !=3D NULL); > - } > - InitializePpiServices (&PrivateData, OldCoreData); >=20 > // > // Update performance measurements > @@ -414,7 +422,7 @@ PeiCore ( > // > // Process the Notify list and dispatch any notifies for the=20 > Memory Discovered PPI > // > - ProcessNotifyList (&PrivateData); > + ProcessDispatchNotifyList (&PrivateData); >=20 > PERF_INMODULE_END ("DisMem"); > } > diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c=20 > b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index 6f03858b8a94..907b2bbcf466=20 > 100644 > --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c > +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c > @@ -16,28 +16,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,=20 > EITHER EXPRESS OR IMPLIED. >=20 > /** >=20 > - Initialize PPI services. > - > - @param PrivateData Pointer to the PEI Core data. > - @param OldCoreData Pointer to old PEI Core data. > - NULL if being run in non-permament memory mode. > - > -**/ > -VOID > -InitializePpiServices ( > - IN PEI_CORE_INSTANCE *PrivateData, > - IN PEI_CORE_INSTANCE *OldCoreData > - ) > -{ > - if (OldCoreData =3D=3D NULL) { > - PrivateData->PpiData.NotifyListEnd =3D PcdGet32 > (PcdPeiCoreMaxPpiSupported)-1; > - PrivateData->PpiData.DispatchListEnd =3D PcdGet32 > (PcdPeiCoreMaxPpiSupported)-1; > - PrivateData->PpiData.LastDispatchedNotify =3D PcdGet32 > (PcdPeiCoreMaxPpiSupported)-1; > - } > -} > - > -/** > - > Migrate Pointer from the temporary memory to PEI installed memory. >=20 > @param Pointer Pointer to the Pointer needs to be converted. > @@ -192,14 +170,37 @@ ConvertPpiPointers ( { > UINT8 Index; >=20 > - for (Index =3D 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index+= +) { > - if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData- > >PpiData.NotifyListEnd) { > - ConvertSinglePpiPointer ( > - SecCoreData, > - PrivateData, > - &PrivateData->PpiData.PpiListPtrs[Index] > - ); > - } > + // > + // Convert normal PPIs. > + // > + for (Index =3D 0; Index < PrivateData->PpiData.PpiList.CurrentCount; I= ndex++) { > + ConvertSinglePpiPointer ( > + SecCoreData, > + PrivateData, > + &PrivateData->PpiData.PpiList.PpiPtrs[Index] > + ); > + } > + > + // > + // Convert Callback Notification PPIs. > + // > + for (Index =3D 0; Index <=20 > + PrivateData->PpiData.CallbackNotifyList.CurrentCount; > Index++) { > + ConvertSinglePpiPointer ( > + SecCoreData, > + PrivateData, > + &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index] > + ); > + } > + > + // > + // Convert Dispatch Notification PPIs. > + // > + for (Index =3D 0; Index <=20 > + PrivateData->PpiData.DispatchNotifyList.CurrentCount; > Index++) { > + ConvertSinglePpiPointer ( > + SecCoreData, > + PrivateData, > + &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index] > + ); > } > } >=20 > @@ -228,10 +229,11 @@ InternalPeiInstallPpi ( > IN BOOLEAN Single > ) > { > - PEI_CORE_INSTANCE *PrivateData; > - INTN Index; > - INTN LastCallbackInstall; > - > + PEI_CORE_INSTANCE *PrivateData; > + PEI_PPI_LIST *PpiListPointer; > + UINTN Index; > + UINTN LastCount; > + VOID *TempPtr; >=20 > if (PpiList =3D=3D NULL) { > return EFI_INVALID_PARAMETER; > @@ -239,8 +241,9 @@ InternalPeiInstallPpi ( >=20 > PrivateData =3D PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); >=20 > - Index =3D PrivateData->PpiData.PpiListEnd; > - LastCallbackInstall =3D Index; > + PpiListPointer =3D &PrivateData->PpiData.PpiList; Index =3D=20 > + PpiListPointer->CurrentCount; LastCount =3D Index; >=20 > // > // This is loop installs all PPI descriptors in the PpiList. It is=20 > terminated @@ -250,27 +253,37 @@ InternalPeiInstallPpi ( >=20 > for (;;) { > // > - // Since PpiData is used for NotifyList and PpiList, max resource > - // is reached if the Install reaches the NotifyList > - // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to = satisfy > more PPI requirement. > - // > - if (Index =3D=3D PrivateData->PpiData.NotifyListEnd + 1) { > - return EFI_OUT_OF_RESOURCES; > - } > - // > // Check if it is a valid PPI. > // If not, rollback list to exclude all in this list. > // Try to indicate which item failed. > // > if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) =3D=3D 0) { > - PrivateData->PpiData.PpiListEnd =3D LastCallbackInstall; > + PpiListPointer->CurrentCount =3D LastCount; > DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n",=20 > PpiList->Guid, > PpiList->Ppi)); > return EFI_INVALID_PARAMETER; > } >=20 > + if (Index =3D=3D PpiListPointer->MaxCount) { > + // > + // Run out of room, grow the buffer. > + // > + TempPtr =3D AllocateZeroPool ( > + sizeof (PEI_PPI_LIST_POINTERS) *=20 > + (PpiListPointer->MaxCount + > PPI_GROWTH_STEP) > + ); > + ASSERT (TempPtr !=3D NULL); > + CopyMem ( > + TempPtr, > + PpiListPointer->PpiPtrs, > + sizeof (PEI_PPI_LIST_POINTERS) * PpiListPointer->MaxCount > + ); > + PpiListPointer->PpiPtrs =3D TempPtr; > + PpiListPointer->MaxCount =3D PpiListPointer->MaxCount + > PPI_GROWTH_STEP; > + } > + It looks that he above PPI buffer expansion code have 3 copied in this patc= h. Please consider to extract it as a function or macro. > DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid)); > - PrivateData->PpiData.PpiListPtrs[Index].Ppi =3D (EFI_PEI_PPI_DESCRIP= TOR*) > PpiList; > - PrivateData->PpiData.PpiListEnd++; > + PpiListPointer->PpiPtrs[Index].Ppi =3D (EFI_PEI_PPI_DESCRIPTOR *) Pp= iList; > + Index++; > + PpiListPointer->CurrentCount++; >=20 > if (Single) { > // > @@ -284,23 +297,24 @@ InternalPeiInstallPpi ( > // > break; > } > + // > + // Go to the next descriptor. > + // > PpiList++; > - Index++; > } >=20 > // > - // Dispatch any callback level notifies for newly installed PPIs. > + // Process any callback level notifies for newly installed PPIs. > // > - DispatchNotify ( > + ProcessNotify ( > PrivateData, > EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, > - LastCallbackInstall, > - PrivateData->PpiData.PpiListEnd, > - PrivateData->PpiData.DispatchListEnd, > - PrivateData->PpiData.NotifyListEnd > + LastCount, > + PpiListPointer->CurrentCount, > + 0, > + PrivateData->PpiData.CallbackNotifyList.CurrentCount > ); >=20 > - > return EFI_SUCCESS; > } >=20 > @@ -355,7 +369,7 @@ PeiReInstallPpi ( > ) > { > PEI_CORE_INSTANCE *PrivateData; > - INTN Index; > + UINTN Index; >=20 >=20 > if ((OldPpi =3D=3D NULL) || (NewPpi =3D=3D NULL)) { @@ -372,35 +386,33= @@=20 > PeiReInstallPpi ( > // Find the old PPI instance in the database. If we can not find it, > // return the EFI_NOT_FOUND error. > // > - for (Index =3D 0; Index < PrivateData->PpiData.PpiListEnd; Index++) { > - if (OldPpi =3D=3D PrivateData->PpiData.PpiListPtrs[Index].Ppi) { > + for (Index =3D 0; Index < PrivateData->PpiData.PpiList.CurrentCount; I= ndex++) { > + if (OldPpi =3D=3D PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi) { > break; > } > } > - if (Index =3D=3D PrivateData->PpiData.PpiListEnd) { > + if (Index =3D=3D PrivateData->PpiData.PpiList.CurrentCount) { > return EFI_NOT_FOUND; > } >=20 > // > - // Remove the old PPI from the database, add the new one. > + // Replace the old PPI with the new one. > // > DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid)); > - ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported))); > - PrivateData->PpiData.PpiListPtrs[Index].Ppi =3D=20 > (EFI_PEI_PPI_DESCRIPTOR *) NewPpi; > + PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi =3D=20 > + (EFI_PEI_PPI_DESCRIPTOR *) > NewPpi; >=20 > // > - // Dispatch any callback level notifies for the newly installed PPI. > + // Process any callback level notifies for the newly installed PPI. > // > - DispatchNotify ( > + ProcessNotify ( > PrivateData, > EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, > Index, > Index+1, > - PrivateData->PpiData.DispatchListEnd, > - PrivateData->PpiData.NotifyListEnd > + 0, > + PrivateData->PpiData.CallbackNotifyList.CurrentCount > ); >=20 > - > return EFI_SUCCESS; > } >=20 > @@ -430,10 +442,10 @@ PeiLocatePpi ( > IN OUT VOID **Ppi > ) > { > - PEI_CORE_INSTANCE *PrivateData; > - INTN Index; > - EFI_GUID *CheckGuid; > - EFI_PEI_PPI_DESCRIPTOR *TempPtr; > + PEI_CORE_INSTANCE *PrivateData; > + UINTN Index; > + EFI_GUID *CheckGuid; > + EFI_PEI_PPI_DESCRIPTOR *TempPtr; >=20 >=20 > PrivateData =3D PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); > @@ -441,8 +453,8 @@ PeiLocatePpi ( > // > // Search the data base for the matching instance of the GUIDed PPI. > // > - for (Index =3D 0; Index < PrivateData->PpiData.PpiListEnd; Index++) { > - TempPtr =3D PrivateData->PpiData.PpiListPtrs[Index].Ppi; > + for (Index =3D 0; Index < PrivateData->PpiData.PpiList.CurrentCount; I= ndex++) { > + TempPtr =3D PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi; > CheckGuid =3D TempPtr->Guid; >=20 > // > @@ -498,15 +510,14 @@ InternalPeiNotifyPpi ( > IN BOOLEAN Single > ) > { > - PEI_CORE_INSTANCE *PrivateData; > - INTN Index; > - INTN NotifyIndex; > - INTN LastCallbackNotify; > - EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr; > - UINTN NotifyDispatchCount; > - > - > - NotifyDispatchCount =3D 0; > + PEI_CORE_INSTANCE *PrivateData; > + PEI_CALLBACK_NOTIFY_LIST *CallbackNotifyListPointer; > + UINTN CallbackNotifyIndex; > + UINTN LastCallbackNotifyCount; > + PEI_DISPATCH_NOTIFY_LIST *DispatchNotifyListPointer; > + UINTN DispatchNotifyIndex; > + UINTN LastDispatchNotifyCount; > + VOID *TempPtr; >=20 > if (NotifyList =3D=3D NULL) { > return EFI_INVALID_PARAMETER; > @@ -514,8 +525,13 @@ InternalPeiNotifyPpi ( >=20 > PrivateData =3D PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); >=20 > - Index =3D PrivateData->PpiData.NotifyListEnd; > - LastCallbackNotify =3D Index; > + CallbackNotifyListPointer =3D=20 > + &PrivateData->PpiData.CallbackNotifyList; > + CallbackNotifyIndex =3D CallbackNotifyListPointer->CurrentCount; > + LastCallbackNotifyCount =3D CallbackNotifyIndex; > + > + DispatchNotifyListPointer =3D=20 > + &PrivateData->PpiData.DispatchNotifyList; > + DispatchNotifyIndex =3D DispatchNotifyListPointer->CurrentCount; > + LastDispatchNotifyCount =3D DispatchNotifyIndex; >=20 > // > // This is loop installs all Notify descriptors in the NotifyList. =20 > It is @@ -525,31 +541,59 @@ InternalPeiNotifyPpi ( >=20 > for (;;) { > // > - // Since PpiData is used for NotifyList and InstallList, max resourc= e > - // is reached if the Install reaches the PpiList > - // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to = satisfy > more Notify PPIs requirement. > - // > - if (Index =3D=3D PrivateData->PpiData.PpiListEnd - 1) { > - return EFI_OUT_OF_RESOURCES; > - } > - > - // > // If some of the PPI data is invalid restore original Notify PPI da= tabase value > // > if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) =3D=3D= 0) { > - PrivateData->PpiData.NotifyListEnd =3D LastCallbackNotify; > - DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyLis= t- > >Guid, NotifyList->Notify)); > + CallbackNotifyListPointer->CurrentCount =3D LastCallbackNotifyCo= unt; > + DispatchNotifyListPointer->CurrentCount =3D LastDispatchNotifyCo= unt; > + DEBUG((EFI_D_ERROR, "ERROR -> NotifyPpi: %g %p\n",=20 > + NotifyList->Guid, > NotifyList->Notify)); > return EFI_INVALID_PARAMETER; > } >=20 > - if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != =3D 0) { > - NotifyDispatchCount ++; > + if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) != =3D 0) { > + if (CallbackNotifyIndex =3D=3D CallbackNotifyListPointer->MaxCount= ) { > + // > + // Run out of room, grow the buffer. > + // > + TempPtr =3D AllocateZeroPool ( > + sizeof (PEI_PPI_LIST_POINTERS) *=20 > + (CallbackNotifyListPointer- > >MaxCount + CALLBACK_NOTIFY_GROWTH_STEP) > + ); > + ASSERT (TempPtr !=3D NULL); > + CopyMem ( > + TempPtr, > + CallbackNotifyListPointer->NotifyPtrs, > + sizeof (PEI_PPI_LIST_POINTERS) * CallbackNotifyListPointer->Ma= xCount > + ); > + CallbackNotifyListPointer->NotifyPtrs =3D TempPtr; > + CallbackNotifyListPointer->MaxCount =3D=20 > + CallbackNotifyListPointer- > >MaxCount + CALLBACK_NOTIFY_GROWTH_STEP; > + } > + =20 > + CallbackNotifyListPointer->NotifyPtrs[CallbackNotifyIndex].Notify =3D > (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList; > + CallbackNotifyIndex++; > + CallbackNotifyListPointer->CurrentCount++; > + } else { > + if (DispatchNotifyIndex =3D=3D DispatchNotifyListPointer->MaxCount= ) { > + // > + // Run out of room, grow the buffer. > + // > + TempPtr =3D AllocateZeroPool ( > + sizeof (PEI_PPI_LIST_POINTERS) *=20 > + (DispatchNotifyListPointer- > >MaxCount + DISPATCH_NOTIFY_GROWTH_STEP) > + ); > + ASSERT (TempPtr !=3D NULL); > + CopyMem ( > + TempPtr, > + DispatchNotifyListPointer->NotifyPtrs, > + sizeof (PEI_PPI_LIST_POINTERS) * DispatchNotifyListPointer->Ma= xCount > + ); > + DispatchNotifyListPointer->NotifyPtrs =3D TempPtr; > + DispatchNotifyListPointer->MaxCount =3D=20 > + DispatchNotifyListPointer- > >MaxCount + DISPATCH_NOTIFY_GROWTH_STEP; > + } > + =20 > + DispatchNotifyListPointer->NotifyPtrs[DispatchNotifyIndex].Notify =3D > (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList; > + DispatchNotifyIndex++; > + DispatchNotifyListPointer->CurrentCount++; > } >=20 > - PrivateData->PpiData.PpiListPtrs[Index].Notify =3D > (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList; > - > - PrivateData->PpiData.NotifyListEnd--; > DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n",=20 > NotifyList->Guid)); > + > if (Single) { > // > // Only single entry in the NotifyList. > @@ -563,41 +607,21 @@ InternalPeiNotifyPpi ( > break; > } > // > - // Go the next descriptor. Remember the NotifyList moves down. > + // Go to the next descriptor. > // > NotifyList++; > - Index--; > - } > - > - // > - // If there is Dispatch Notify PPI installed put them on the bottom > - // > - if (NotifyDispatchCount > 0) { > - for (NotifyIndex =3D LastCallbackNotify; NotifyIndex > PrivateData- > >PpiData.NotifyListEnd; NotifyIndex--) { > - if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & > EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) !=3D 0) { > - NotifyPtr =3D PrivateData->PpiData.PpiListPtrs[NotifyIndex].Noti= fy; > - > - for (Index =3D NotifyIndex; Index < PrivateData->PpiData.Dispatc= hListEnd; > Index++){ > - PrivateData->PpiData.PpiListPtrs[Index].Notify =3D PrivateData= - > >PpiData.PpiListPtrs[Index + 1].Notify; > - } > - PrivateData->PpiData.PpiListPtrs[Index].Notify =3D NotifyPtr; > - PrivateData->PpiData.DispatchListEnd--; > - } > - } > - > - LastCallbackNotify -=3D NotifyDispatchCount; > } >=20 > // > - // Dispatch any callback level notifies for all previously installed P= PIs. > + // Process any callback level notifies for all previously installed PP= Is. > // > - DispatchNotify ( > + ProcessNotify ( > PrivateData, > EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, > 0, > - PrivateData->PpiData.PpiListEnd, > - LastCallbackNotify, > - PrivateData->PpiData.NotifyListEnd > + PrivateData->PpiData.PpiList.CurrentCount, > + LastCallbackNotifyCount, > + CallbackNotifyListPointer->CurrentCount > ); >=20 > return EFI_SUCCESS; > @@ -627,7 +651,6 @@ PeiNotifyPpi ( > return InternalPeiNotifyPpi (PeiServices, NotifyList, FALSE); } >=20 > - > /** >=20 > Process the Notify List at dispatch level. > @@ -636,55 +659,56 @@ PeiNotifyPpi ( >=20 > **/ > VOID > -ProcessNotifyList ( > +ProcessDispatchNotifyList ( > IN PEI_CORE_INSTANCE *PrivateData > ) > { > - INTN TempValue; > + UINTN TempValue; >=20 > while (TRUE) { > // > // Check if the PEIM that was just dispatched resulted in any > // Notifies getting installed. If so, go process any dispatch > // level Notifies that match the previouly installed PPIs. > - // Use "while" instead of "if" since DispatchNotify can modify > - // DispatchListEnd (with NotifyPpi) so we have to iterate until the = same. > + // Use "while" instead of "if" since ProcessNotify can modify > + // DispatchNotifyList.CurrentCount (with NotifyPpi) so we have > + // to iterate until the same. > // > - while (PrivateData->PpiData.LastDispatchedNotify !=3D PrivateData- > >PpiData.DispatchListEnd) { > - TempValue =3D PrivateData->PpiData.DispatchListEnd; > - DispatchNotify ( > + while=20 > + (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount !=3D > PrivateData->PpiData.DispatchNotifyList.CurrentCount) { > + TempValue =3D PrivateData->PpiData.DispatchNotifyList.CurrentCount= ; > + ProcessNotify ( > PrivateData, > EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH, > 0, > - PrivateData->PpiData.LastDispatchedInstall, > - PrivateData->PpiData.LastDispatchedNotify, > - PrivateData->PpiData.DispatchListEnd > + PrivateData->PpiData.PpiList.LastDispatchedCount, > + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount, > + PrivateData->PpiData.DispatchNotifyList.CurrentCount > ); > - PrivateData->PpiData.LastDispatchedNotify =3D TempValue; > + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount =3D > TempValue; > } >=20 > - > // > // Check if the PEIM that was just dispatched resulted in any > // PPIs getting installed. If so, go process any dispatch > // level Notifies that match the installed PPIs. > - // Use "while" instead of "if" since DispatchNotify can modify > - // PpiListEnd (with InstallPpi) so we have to iterate until the same= . > + // Use "while" instead of "if" since ProcessNotify can modify > + // PpiList.CurrentCount (with InstallPpi) so we have to iterate > + // until the same. > // > - while (PrivateData->PpiData.LastDispatchedInstall !=3D PrivateData- > >PpiData.PpiListEnd) { > - TempValue =3D PrivateData->PpiData.PpiListEnd; > - DispatchNotify ( > + while (PrivateData->PpiData.PpiList.LastDispatchedCount !=3D=20 > + PrivateData- > >PpiData.PpiList.CurrentCount) { > + TempValue =3D PrivateData->PpiData.PpiList.CurrentCount; > + ProcessNotify ( > PrivateData, > EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH, > - PrivateData->PpiData.LastDispatchedInstall, > - PrivateData->PpiData.PpiListEnd, > - PcdGet32 (PcdPeiCoreMaxPpiSupported)-1, > - PrivateData->PpiData.DispatchListEnd > + PrivateData->PpiData.PpiList.LastDispatchedCount, > + PrivateData->PpiData.PpiList.CurrentCount, > + 0, > + PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount > ); > - PrivateData->PpiData.LastDispatchedInstall =3D TempValue; > + PrivateData->PpiData.PpiList.LastDispatchedCount =3D TempValue; > } >=20 > - if (PrivateData->PpiData.LastDispatchedNotify =3D=3D PrivateData- > >PpiData.DispatchListEnd) { > + if (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount=20 > + =3D=3D > PrivateData->PpiData.DispatchNotifyList.CurrentCount) { > break; > } > } > @@ -693,7 +717,7 @@ ProcessNotifyList ( >=20 > /** >=20 > - Dispatch notifications. > + Process notifications. >=20 > @param PrivateData PeiCore's private data structure > @param NotifyType Type of notify to fire. > @@ -704,7 +728,7 @@ ProcessNotifyList ( >=20 > **/ > VOID > -DispatchNotify ( > +ProcessNotify ( > IN PEI_CORE_INSTANCE *PrivateData, > IN UINTN NotifyType, > IN INTN InstallStartIndex, > @@ -713,22 +737,23 @@ DispatchNotify ( > IN INTN NotifyStopIndex > ) > { > - INTN Index1; > - INTN Index2; > - EFI_GUID *SearchGuid; > - EFI_GUID *CheckGuid; > - EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor; > - > - // > - // Remember that Installs moves up and Notifies moves down. > - // > - for (Index1 =3D NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) = { > - NotifyDescriptor =3D PrivateData->PpiData.PpiListPtrs[Index1].Notify= ; > + INTN Index1; > + INTN Index2; > + EFI_GUID *SearchGuid; > + EFI_GUID *CheckGuid; > + EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor; > + > + for (Index1 =3D NotifyStartIndex; Index1 < NotifyStopIndex; Index1++) = { > + if (NotifyType =3D=3D EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) { > + NotifyDescriptor =3D PrivateData- > >PpiData.CallbackNotifyList.NotifyPtrs[Index1].Notify; > + } else { > + NotifyDescriptor =3D PrivateData- > >PpiData.DispatchNotifyList.NotifyPtrs[Index1].Notify; > + } >=20 > CheckGuid =3D NotifyDescriptor->Guid; >=20 > for (Index2 =3D InstallStartIndex; Index2 < InstallStopIndex; Index2= ++) { > - SearchGuid =3D PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid; > + SearchGuid =3D=20 > + PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi->Guid; > // > // Don't use CompareGuid function here for performance reasons. > // Instead we compare the GUID as INT32 at a time and branch @@=20 > -745,7 +770,7 @@ DispatchNotify ( > NotifyDescriptor->Notify ( > (EFI_PEI_SERVICES **) GetPeiServicesTablePoi= nter (), > NotifyDescriptor, > - (PrivateData->PpiData.PpiListPtrs[Index2].Pp= i)->Ppi > + =20 > + (PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi)->Ppi > ); > } > } > -- > 2.7.0.windows.1