From nobody Mon Feb 9 13:59:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+93172+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93172+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1662438978; cv=none; d=zohomail.com; s=zohoarc; b=AShJaeX4upD8B/90I+LexNxceffIO1C4+br2cIzaPI44osmxcGhpDbV5QLHzRbSylfMh/ghmB41rSnYXv45Eaz6z+aQReGgD4NQjswM23XLeK+PtHUk6wmkhDnsBqrCjOGULSTbl500ECCKnOaT5h97+ohf292327fEkxSzdRhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662438978; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Duq0040DhpV9peWOFLpa8CjoUjgFNN92r1pBS4jlvfg=; b=QXu8vXRGIfnQWjaOTDaVl8fFdR7kGC8HlzBdZYEXHnVcTQXUOA05Tc0ph42uIF7hZ0NPE+YNONiV+5txY/UfQU9/7tkvPkdvgr0ImICUnMa2+jPpUHY5XOKxAbZo/0AoC57340E/sIwKcj/iwllHvQ9kYmBpqctW9vv2rkLfdAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+93172+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1662438978869271.4417744456798; Mon, 5 Sep 2022 21:36:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id eXUgYY1788612xY5fpjCTFq6; Mon, 05 Sep 2022 21:36:18 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.303.1662438976985344787 for ; Mon, 05 Sep 2022 21:36:17 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10461"; a="296502056" X-IronPort-AV: E=Sophos;i="5.93,293,1654585200"; d="scan'208";a="296502056" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 21:36:17 -0700 X-IronPort-AV: E=Sophos;i="5.93,293,1654585200"; d="scan'208";a="675517285" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.4.118]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2022 21:36:16 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Leif Lindholm , Ard Biesheuvel , Abner Chang , Daniel Schaefer , Gerd Hoffmann Subject: [edk2-devel] [PATCH V5 1/8] EmbeddedPkg: Add AllocateRuntimePages in PrePiMemoryAllocationLib Date: Tue, 6 Sep 2022 12:35:53 +0800 Message-Id: <37f4a6991238ab679abe674d4f48141d59b06e42.1662423715.git.min.m.xu@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: cNxQKWTuqYJ47Q8upWR0QPclx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1662438978; bh=EgYAzabqWePv3UO+IKKIpSeY+tODbFSxmLXNT3Opvzg=; h=Cc:Date:From:Reply-To:Subject:To; b=dCNkb63KowEioXoN0zSrI06C0/3Tg6yUDWdrIRHRsoa8gZ2ErMJXMKK/LW19TQeZEa1 5OKqQDtqpiI58KO038dAWpUHwYxeH5cCayN1U55TNzrqrE7ejffV6KQbvyL+G4F0Py0iI zqqlzLHJxPezZ/9liF6j3wTGf3FLf3JK82E= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1662438979733100005 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ard Biesheuvel Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- EmbeddedPkg/Include/Library/PrePiLib.h | 19 ++++++ .../MemoryAllocationLib.c | 65 ++++++++++++++----- 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/EmbeddedPkg/Include/Library/PrePiLib.h b/EmbeddedPkg/Include/L= ibrary/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 ); =20 +/** + Allocates one or more 4KB pages of type EfiRuntimeServicesData. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and ret= urns 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 req= uest, 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. =20 diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationL= ib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c index 78f8da5e9527..2cc2a7112197 100644 --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c @@ -14,23 +14,12 @@ #include #include =20 -/** - 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 req= uest, 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. - -**/ +STATIC VOID * EFIAPI -AllocatePages ( - IN UINTN Pages +InternalAllocatePages ( + IN UINTN Pages, + IN EFI_MEMORY_TYPE MemoryType ) { EFI_PEI_HOB_POINTERS Hob; @@ -65,12 +54,56 @@ AllocatePages ( BuildMemoryAllocationHob ( Hob.HandoffInformationTable->EfiFreeMemoryTop, Pages * EFI_PAGE_SIZE, - EfiBootServicesData + MemoryType ); return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop; } } =20 +/** + 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 req= uest, 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 ret= urns 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 req= uest, 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 specifi= ed alignment. =20 --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#93172): https://edk2.groups.io/g/devel/message/93172 Mute This Topic: https://groups.io/mt/93494904/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-