From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 9CE1421194D28 for ; Mon, 17 Dec 2018 18:24:27 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2018 18:24:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,367,1539673200"; d="scan'208";a="108162460" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga007.fm.intel.com with ESMTP; 17 Dec 2018 18:24:26 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 17 Dec 2018 18:24:25 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.59]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.201]) with mapi id 14.03.0415.000; Tue, 18 Dec 2018 10:24:23 +0800 From: "Wang, Jian J" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" , "Gao, Liming" , "Ni, Ruiyu" , "Kinney, Michael D" , "Desimone, Nathaniel L" , "Chiu, Chasel" Thread-Topic: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of PcdPeiCoreMaxPpiSupported Thread-Index: AQHUk5folA08ku2U1kWo+PJLt5UTk6WDyHDA Date: Tue, 18 Dec 2018 02:24:23 +0000 Message-ID: References: <1544783322-17436-1-git-send-email-star.zeng@intel.com> <1544783322-17436-5-git-send-email-star.zeng@intel.com> In-Reply-To: <1544783322-17436-5-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGNhYzBhYjYtMGIxZS00ZTZhLWFjM2QtZjhkNGEzZmVhMjllIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiREdoXC9GeXVZd3NFSjg1TXJHdEx2aUhBT1wvaWpjK3U1SjJtc2ZtazdaNFM2RGxtaWQ3cXBxT1lPbzgyZjVvYnAxIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action 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 02:24:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 ; > Wu, Hao A ; Gao, Liming ; Ni, > Ruiyu ; Kinney, Michael D ; > Desimone, Nathaniel L ; Chiu, Chasel > > Subject: [PATCH 4/7] MdeModulePkg PeiCore: Remove the using of > 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 > in FSP binary with dispatch mode) could not predict how many FVs, > Files or PPIs for different platforms. >=20 > Burden: > Platform developers need configure the PCDs accordingly for different > platforms. >=20 > To solve the problem and remove the burden, we can update code to > remove the using of PcdPeiCoreMaxFvSupported, PcdPeiCoreMaxPeimPerFv > and PcdPeiCoreMaxPpiSupported by extending buffer dynamically for FV, > 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 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 > b/MdeModulePkg/Core/Pei/PeiMain.h > index b248118087ad..c6c932c3e233 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 NotifyLi= st. 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 of > room > /// > +#define PPI_GROWTH_STEP 64 > +#define CALLBACK_NOTIFY_GROWTH_STEP 32 > +#define 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 *) = ((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 (PEI_PPI_LIST_POINTER= S *) > ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs + 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 +218,15 @@ PeiCore ( > if (OldCoreData->CurrentFvFileHandles !=3D NULL) { > OldCoreData->CurrentFvFileHandles =3D (EFI_PEI_FILE_HANDLE *) = ((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 (PEI_PPI_LIST_POINTER= S *) > ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs - 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 +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 Memory = Discovered > PPI > // > - ProcessNotifyList (&PrivateData); > + ProcessDispatchNotifyList (&PrivateData); >=20 > PERF_INMODULE_END ("DisMem"); > } > diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c > b/MdeModulePkg/Core/Pei/Ppi/Ppi.c > index 6f03858b8a94..907b2bbcf466 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, 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 < PrivateData->PpiData.CallbackNotifyList.Curr= entCount; > Index++) { > + ConvertSinglePpiPointer ( > + SecCoreData, > + PrivateData, > + &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index] > + ); > + } > + > + // > + // Convert Dispatch Notification PPIs. > + // > + for (Index =3D 0; Index < PrivateData->PpiData.DispatchNotifyList.Curr= entCount; > 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 PpiListPointer->CurrentCount; > + LastCount =3D Index; >=20 > // > // This is loop installs all PPI descriptors in the PpiList. It is te= rminated > @@ -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", 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) * (PpiListPointer->MaxC= ount + > 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 @@ 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 (EFI_PEI_PPI_DESCRIPTO= R *) > NewPpi; > + PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi =3D (EFI_PEI_PPI_DESCR= IPTOR *) > 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 &PrivateData->PpiData.CallbackNotifyList= ; > + CallbackNotifyIndex =3D CallbackNotifyListPointer->CurrentCount; > + LastCallbackNotifyCount =3D CallbackNotifyIndex; > + > + DispatchNotifyListPointer =3D &PrivateData->PpiData.DispatchNotifyList= ; > + DispatchNotifyIndex =3D DispatchNotifyListPointer->CurrentCount; > + LastDispatchNotifyCount =3D DispatchNotifyIndex; >=20 > // > // This is loop installs all Notify descriptors in the NotifyList. 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", NotifyList->G= uid, > 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) * (CallbackNotifyList= Pointer- > >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 CallbackNotifyListPointe= r- > >MaxCount + CALLBACK_NOTIFY_GROWTH_STEP; > + } > + 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) * (DispatchNotifyList= Pointer- > >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 DispatchNotifyListPointe= r- > >MaxCount + DISPATCH_NOTIFY_GROWTH_STEP; > + } > + 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", 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 (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 Private= Data- > >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 =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 PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi->G= uid; > // > // Don't use CompareGuid function here for performance reasons. > // Instead we compare the GUID as INT32 at a time and branch > @@ -745,7 +770,7 @@ DispatchNotify ( > NotifyDescriptor->Notify ( > (EFI_PEI_SERVICES **) GetPeiServicesTablePoi= nter (), > NotifyDescriptor, > - (PrivateData->PpiData.PpiListPtrs[Index2].Pp= i)->Ppi > + (PrivateData->PpiData.PpiList.PpiPtrs[Index2= ].Ppi)->Ppi > ); > } > } > -- > 2.7.0.windows.1