From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web08.23740.1662378903337796414 for ; Mon, 05 Sep 2022 04:55:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dIYmuwl+; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9D14F61254 for ; Mon, 5 Sep 2022 11:55:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80C5FC43470 for ; Mon, 5 Sep 2022 11:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662378901; bh=7zFBNhJbjzG3ssG+U8btZJDKzGWngGlRMR/V4Z+8tiA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=dIYmuwl+TjO5BV63wXQ5l+im6VFFPj5SfuUJiuF+UcPk9iEOiKRzUzmSSdXP7rjyi HjCF6RuNSpeH4NllTa3fNPCmlC7XXVMd7qb1f1/hsLXnFuKInxqAHzLvHQxobFRYnl SWwXdZlkwvTzq6HC6nPAuFNotCsB9RHXPu26QPqXBS87+TNGBwCoku9Kg+F3/tBsy+ W8fJX66HyRH1SRfdDLhKr3gQuLumMlWOmD0o89GzvSzJqt/VXKj6x9DB7Cg0iaxmO7 bsEH8razKpItqueisDQzUpEQC4mXCFrVwO1FYFhw40ODWubKNUquOjEEdk1tDYPAdH dVCRm5hyASOMA== Received: by mail-lf1-f54.google.com with SMTP id g7so12751853lfe.11 for ; Mon, 05 Sep 2022 04:55:01 -0700 (PDT) X-Gm-Message-State: ACgBeo3opZihYzlq1cYu5KI+en7rTO6iM86XnFjbpcy1TeUHXRPTMwrh lDVjh3a65BNSv3g3RDwjzysyuLuN5BW/agoU44s= X-Google-Smtp-Source: AA6agR67gdvI68Pin2lZnOG78Fg6nCeGEtCx6/3ncjjrQM7lt4RyDI+k7YUt3rf8UrRB/3WKUpudRG5oeCXwYkUJzkw= X-Received: by 2002:a05:6512:2294:b0:494:8dc5:10af with SMTP id f20-20020a056512229400b004948dc510afmr7366530lfu.426.1662378899471; Mon, 05 Sep 2022 04:54:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Ard Biesheuvel" Date: Mon, 5 Sep 2022 13:54:48 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH V4 1/8] EmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib To: devel@edk2.groups.io, min.m.xu@intel.com Cc: Leif Lindholm , Ard Biesheuvel , Abner Chang , Daniel Schaefer , Gerd Hoffmann Content-Type: text/plain; charset="UTF-8" On Fri, 1 Jul 2022 at 01:29, Min Xu wrote: > > From: Min M Xu > > AllocateRuntimePages is used to allocate one or more 4KB pages of > type EfiRuntimeServicesData. > > Cc: Leif Lindholm > Cc: Ard Biesheuvel > Cc: Abner Chang > Cc: Daniel Schaefer > Cc: Gerd Hoffmann > Signed-off-by: Min Xu With one comment below addressed: Reviewed-by: Ard Biesheuvel > --- > EmbeddedPkg/Include/Library/PrePiLib.h | 19 ++++++ > .../MemoryAllocationLib.c | 64 ++++++++++++++----- > 2 files changed, 67 insertions(+), 16 deletions(-) > > diff --git a/EmbeddedPkg/Include/Library/PrePiLib.h b/EmbeddedPkg/Include/Library/PrePiLib.h > index 7b2cea296f1c..3741b08c4478 100644 > --- a/EmbeddedPkg/Include/Library/PrePiLib.h > +++ b/EmbeddedPkg/Include/Library/PrePiLib.h > @@ -665,6 +665,25 @@ AllocatePages ( > IN UINTN Pages > ); > > +/** > + Allocates one or more 4KB pages of type EfiRuntimeServicesData. > + > + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the > + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL > + is returned. If there is not enough memory remaining to satisfy the request, then NULL is > + returned. > + > + @param Pages The number of 4 KB pages to allocate. > + > + @return A pointer to the allocated buffer or NULL if allocation fails. > + > +**/ > +VOID * > +EFIAPI > +AllocateRuntimePages ( > + IN UINTN Pages > + ); > + > /** > Allocates a buffer of type EfiBootServicesData. > > diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > index 78f8da5e9527..9d7b34ad28fa 100644 > --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c > @@ -14,23 +14,11 @@ > #include > #include > > -/** > - Allocates one or more 4KB pages of type EfiBootServicesData. > - > - Allocates the number of 4KB pages of MemoryType and returns a pointer to the > - allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL > - is returned. If there is not enough memory remaining to satisfy the request, then NULL is > - returned. > - > - @param Pages The number of 4 KB pages to allocate. > - > - @return A pointer to the allocated buffer or NULL if allocation fails. > - > -**/ > VOID * > EFIAPI > -AllocatePages ( > - IN UINTN Pages > +InternalAllocatePages ( Please make this STATIC > + IN UINTN Pages, > + IN EFI_MEMORY_TYPE MemoryType > ) > { > EFI_PEI_HOB_POINTERS Hob; > @@ -65,12 +53,56 @@ AllocatePages ( > BuildMemoryAllocationHob ( > Hob.HandoffInformationTable->EfiFreeMemoryTop, > Pages * EFI_PAGE_SIZE, > - EfiBootServicesData > + MemoryType > ); > return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop; > } > } > > +/** > + Allocates one or more 4KB pages of type EfiBootServicesData. > + > + Allocates the number of 4KB pages of MemoryType and returns a pointer to the > + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL > + is returned. If there is not enough memory remaining to satisfy the request, then NULL is > + returned. > + > + @param Pages The number of 4 KB pages to allocate. > + > + @return A pointer to the allocated buffer or NULL if allocation fails. > + > +**/ > +VOID * > +EFIAPI > +AllocatePages ( > + IN UINTN Pages > + ) > +{ > + return InternalAllocatePages (Pages, EfiBootServicesData); > +} > + > +/** > + Allocates one or more 4KB pages of type EfiRuntimeServicesData. > + > + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the > + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL > + is returned. If there is not enough memory remaining to satisfy the request, then NULL is > + returned. > + > + @param Pages The number of 4 KB pages to allocate. > + > + @return A pointer to the allocated buffer or NULL if allocation fails. > + > +**/ > +VOID * > +EFIAPI > +AllocateRuntimePages ( > + IN UINTN Pages > + ) > +{ > + return InternalAllocatePages (Pages, EfiRuntimeServicesData); > +} > + > /** > Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment. > > -- > 2.29.2.windows.2 > > > > > >