From nobody Mon Feb 9 01:02:04 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+79176+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+79176+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1628769501; cv=none; d=zohomail.com; s=zohoarc; b=U43orypnPBDDet9K0KU4P7FprB6c+SFvt+ferx/GttYehn5KIE53vBcmQGSMgGPvxabyGoT9DZtUkf79DCM5HSSBtN781uiVpd0ALT76uwhvqVx+aXQU4y19oaeC1i1+W11+AcG+BIGCGygqxNelAfWAmu4jo8JfxRE6USRo8xQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628769501; h=Content-Type: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=guu/Fg+jNev6R77/3qISAUsW8OKZbVMONGMdZnoivNQ=; b=J1CxfrAjf2/nBnNoUK685uNu/HL7EK0CkxPJKM463wq7epEn3PB4LOeFnPPUfw1Ht6By2vq4z+7ZwtT1//K/yk+KFn7thMKLnN6nT/kNit0XHRjwXtBgcXJom96trLLBcQZIJWt1410EyGfH9SqOP6LibyCRtt8IoysjKwKiTNo= 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+79176+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 1628769501251955.7463474449692; Thu, 12 Aug 2021 04:58:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5JcNYY1788612xYO9XPFx29N; Thu, 12 Aug 2021 04:58:20 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web09.21069.1628769481864596349 for ; Thu, 12 Aug 2021 04:58:20 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10073"; a="202524387" X-IronPort-AV: E=Sophos;i="5.84,315,1620716400"; d="scan'208";a="202524387" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2021 04:58:20 -0700 X-IronPort-AV: E=Sophos;i="5.84,315,1620716400"; d="scan'208";a="517433917" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.175.248]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2021 04:58:17 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Liming Gao , Zhiguang Liu , Jiewen Yao Subject: [edk2-devel] [PATCH 20/23] MdePkg: Add AllocatePagesWithMemoryType support in PeiMemoryAllocationLib Date: Thu, 12 Aug 2021 19:56:59 +0800 Message-Id: <6924228fa3969ae944d6aebbe653d4046b6cef54.1628767741.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: kN9zvFAk7lB3pIXqbhC7i4Tux1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1628769500; bh=26wFjmx3L4yACzga/sFN2BJXFujIIczLz4/l0l2zVrg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=syyyWtWMq/bGEuHRGYWYUjywhvKQfPNyQETObd2w/0wDHgj19SNRjm2G1s/mxSMOsPt 07YB4WH/x/Ym1GrNHlGN+g0taLrZkAS6X5kZhkLlXOOPo8+MlSU3qzYBR6hLNXRgRRQcB G7VuGdRJ03ww6HFMzKRwyNR4iEWnR7dKqlc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1628769502941100002 RFC=EF=BC=9A https://bugzilla.tianocore.org/show_bug.cgi?id=3D3429 Allocates one or more 4KB pages of given type MemoryType. 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. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Jiewen Yao Signed-off-by: Min Xu --- MdePkg/Include/Library/MemoryAllocationLib.h | 21 +++++++++++++++ .../MemoryAllocationLib.c | 27 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/MdePkg/Include/Library/MemoryAllocationLib.h b/MdePkg/Include/= Library/MemoryAllocationLib.h index 65a30cf146dd..2bdc0592ef3e 100644 --- a/MdePkg/Include/Library/MemoryAllocationLib.h +++ b/MdePkg/Include/Library/MemoryAllocationLib.h @@ -484,4 +484,25 @@ FreePool ( IN VOID *Buffer ); =20 +/** + Allocates one or more 4KB pages of given type MemoryType. + + 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 P= ages + is 0, then NULL is returned. If there is not enough memory remaining to = satisfy + the request, then NULL is returned. + + @param MemoryType Type of memory to use for this allocation. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocatePagesWithMemoryType ( + IN UINTN MemoryType, + IN UINTN Pages + ); + #endif diff --git a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/= MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c index b3f9df74f139..dcb313349729 100644 --- a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c @@ -839,4 +839,31 @@ FreePool ( // } =20 +/** + Allocates one or more 4KB pages of given type MemoryType. =20 + 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 P= ages + is 0, then NULL is returned. If there is not enough memory remaining to = satisfy + the request, then NULL is returned. + + @param MemoryType Type of memory to use for this allocation. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocatePagesWithMemoryType ( + IN UINTN MemoryType, + IN UINTN Pages + ) +{ + if (MemoryType >=3D EfiMaxMemoryType) { + ASSERT (FALSE); + return NULL; + } + + return InternalAllocatePages (MemoryType, Pages); +} --=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 (#79176): https://edk2.groups.io/g/devel/message/79176 Mute This Topic: https://groups.io/mt/84837917/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-