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.web10.8579.1675204562105254493 for ; Tue, 31 Jan 2023 14:36:02 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nj36wtuc; 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 A0A4661737; Tue, 31 Jan 2023 22:36:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14D24C433EF; Tue, 31 Jan 2023 22:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675204561; bh=ml1D/YKbCHte/pPlJGdIUYA9V+tJosTR4KfwAvCOxPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nj36wtucnWHYe80Ws4M/LbgJZgRs7F3N96cxIxZxOu7abrhnmBTBn2U4mZUUy1U6z ZDH48Vg+ATS1CGasJb/8M94u6l6FspKYkY+64X9MddC22t3z0WlxzgGU2iG4EqB5jF juF26tjBbbauKElGS3LHoVLVzHHaBuWu9ens26/JkZJXtwaJ8iYEG9jxauhPt+bE0s YqAGNnZAB/qF8LUM8krJcKuU4HOKwz2kh+/bDlQGY0x7qhLXOCA0Q6Tdl3St6cNCe6 57HIDcKORvcOBuFPNJbpY9gcjOv/TGeNG0rYoduafSCotkgvr6hhx5XFB7jMaHNSWB E2I0egFlEz98Q== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar Subject: [PATCH 1/4] MdePkg: Add Memory Attribute Protocol definition Date: Tue, 31 Jan 2023 23:35:47 +0100 Message-Id: <20230131223550.1775834-2-ardb@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230131223550.1775834-1-ardb@kernel.org> References: <20230131223550.1775834-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Sean Brogan Add the Memory Attribute Protocol definition, which was adopted and included in version 2.10 of the UEFI specification. Taken from Project Mu's mu_basecore repository. Link: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3519 Signed-off-by: Ard Biesheuvel --- MdePkg/Include/Protocol/MemoryAttribute.h | 131 ++++++++++++++++++++ MdePkg/MdePkg.dec | 3 + 2 files changed, 134 insertions(+) diff --git a/MdePkg/Include/Protocol/MemoryAttribute.h b/MdePkg/Include/Pro= tocol/MemoryAttribute.h new file mode 100644 index 000000000000..b33138732ad1 --- /dev/null +++ b/MdePkg/Include/Protocol/MemoryAttribute.h @@ -0,0 +1,131 @@ +/** @file=0D +=0D + EFI Memory Attribute Protocol provides retrieval and update service=0D + for memory attributes in EFI environment.=0D +=0D + Copyright (c) 2021, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef __EFI_MEMORY_ATTRIBUTE_H__=0D +#define __EFI_MEMORY_ATTRIBUTE_H__=0D +=0D +#define EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID \=0D + { \=0D + 0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1= , 0x89 } \=0D + }=0D +=0D +typedef struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL EFI_MEMORY_ATTRIBUTE_PROTOCO= L;=0D +=0D +/**=0D + This function set given attributes of the memory region specified by=0D + BaseAddress and Length.=0D +=0D + The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.= =0D +=0D + @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.=0D + @param BaseAddress The physical address that is the start address= of=0D + a memory region.=0D + @param Length The size in bytes of the memory region.=0D + @param Attributes The bit mask of attributes to set for the memo= ry=0D + region.=0D +=0D + @retval EFI_SUCCESS The attributes were set for the memory reg= ion.=0D + @retval EFI_INVALID_PARAMETER Length is zero.=0D + Attributes specified an illegal combinatio= n of=0D + attributes that cannot be set together.=0D + @retval EFI_UNSUPPORTED The processor does not support one or more= =0D + bytes of the memory resource range specifi= ed=0D + by BaseAddress and Length.=0D + The bit mask of attributes is not supporte= d for=0D + the memory resource range specified by=0D + BaseAddress and Length.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EFI_SET_MEMORY_ATTRIBUTES)(=0D + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + IN UINT64 Attributes=0D + );=0D +=0D +/**=0D + This function clears given attributes of the memory region specified by= =0D + BaseAddress and Length.=0D +=0D + The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.= =0D +=0D + @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.=0D + @param BaseAddress The physical address that is the start address= of=0D + a memory region.=0D + @param Length The size in bytes of the memory region.=0D + @param Attributes The bit mask of attributes to clear for the me= mory=0D + region.=0D +=0D + @retval EFI_SUCCESS The attributes were cleared for the memory= region.=0D + @retval EFI_INVALID_PARAMETER Length is zero.=0D + Attributes specified an illegal combinatio= n of=0D + attributes that cannot be cleared together= .=0D + @retval EFI_UNSUPPORTED The processor does not support one or more= =0D + bytes of the memory resource range specifi= ed=0D + by BaseAddress and Length.=0D + The bit mask of attributes is not supporte= d for=0D + the memory resource range specified by=0D + BaseAddress and Length.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EFI_CLEAR_MEMORY_ATTRIBUTES)(=0D + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + IN UINT64 Attributes=0D + );=0D +=0D +/**=0D + This function retrieves the attributes of the memory region specified by= =0D + BaseAddress and Length. If different attributes are got from different p= art=0D + of the memory region, EFI_NO_MAPPING will be returned.=0D +=0D + @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.=0D + @param BaseAddress The physical address that is the start address= of=0D + a memory region.=0D + @param Length The size in bytes of the memory region.=0D + @param Attributes Pointer to attributes returned.=0D +=0D + @retval EFI_SUCCESS The attributes got for the memory region.= =0D + @retval EFI_INVALID_PARAMETER Length is zero.=0D + Attributes is NULL.=0D + @retval EFI_NO_MAPPING Attributes are not consistent cross the me= mory=0D + region.=0D + @retval EFI_UNSUPPORTED The processor does not support one or more= =0D + bytes of the memory resource range specifi= ed=0D + by BaseAddress and Length.=0D +=0D +**/=0D +typedef=0D +EFI_STATUS=0D +(EFIAPI *EFI_GET_MEMORY_ATTRIBUTES)(=0D + IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length,=0D + OUT UINT64 *Attributes=0D + );=0D +=0D +///=0D +/// EFI Memory Attribute Protocol provides services to retrieve or update= =0D +/// attribute of memory in the EFI environment.=0D +///=0D +struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL {=0D + EFI_GET_MEMORY_ATTRIBUTES GetMemoryAttributes;=0D + EFI_SET_MEMORY_ATTRIBUTES SetMemoryAttributes;=0D + EFI_CLEAR_MEMORY_ATTRIBUTES ClearMemoryAttributes;=0D +};=0D +=0D +extern EFI_GUID gEfiMemoryAttributeProtocolGuid;=0D +=0D +#endif=0D diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 3d08f20d15b0..a8658403c8fd 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -1915,6 +1915,9 @@ [Protocols] ## Include/Protocol/RedfishDiscover.h=0D gEfiRedfishDiscoverProtocolGuid =3D { 0x5db12509, 0x4550, 0x4347, {= 0x96, 0xb3, 0x73, 0xc0, 0xff, 0x6e, 0x86, 0x9f }}=0D =0D + ## Include/Protocol/MemoryAttribute.h=0D + gEfiMemoryAttributeProtocolGuid =3D { 0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1= , 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89 }}=0D +=0D #=0D # Protocols defined in Shell2.0=0D #=0D --=20 2.39.0