Re: [edk2] [PATCH v2 02/17] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
On Wed, 2018-05-09 at 20:52 +, Udit Kumar wrote: > > > > > -Original Message- > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf > > Of > > Supreeth Venkatesh > > Sent: Saturday, May 5, 2018 2:11 AM > > To: edk2-devel@lists.01.org > > Cc: ard.biesheu...@linaro.org; leif.lindh...@linaro.org; jiewen.yao > > @intel.com; > > liming....@intel.com; michael.d.kin...@intel.com > > Subject: [edk2] [PATCH v2 02/17] ArmPkg/Drivers: Add > > EFI_MM_COMMUNICATION_PROTOCOL DXE driver. > > > > PI v1.5 Specification Volume 4 defines Management Mode Core > > Interface > > and defines EFI_MM_COMMUNICATION_PROTOCOL. This protocol provides a > > means of communicating between drivers outside of MM and MMI > > handlers inside of MM. > > > > This patch implements the EFI_MM_COMMUNICATION_PROTOCOL DXE > > runtime > > driver for AARCH64 platforms. It uses SMCs allocated from the > > standard > > SMC range defined in DEN0060A_ARM_MM_Interface_Specification.pdf > > to communicate with the standalone MM environment in the secure > > world. > > > > This patch also adds the MM Communication driver (.inf) file to > > define entry point for this driver and other compile > > related information the driver needs. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Achin Gupta <achin.gu...@arm.com> > > Signed-off-by: Supreeth Venkatesh <supreeth.venkat...@arm.com> > > --- > > .../Drivers/MmCommunicationDxe/MmCommunication.c | 408 > > + > > .../Drivers/MmCommunicationDxe/MmCommunication.inf | 50 +++ > > 2 files changed, 458 insertions(+) > > create mode 100644 > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > > create mode 100644 > > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf > > > > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > > new file mode 100644 > > index 00..8ba1790af9 > > --- /dev/null > > +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > > @@ -0,0 +1,408 @@ > > +/** @file > > + > > + Copyright (c) 2016-2018, ARM Limited. All rights reserved. > > + > > + This program and the accompanying materials > > + are licensed and made available under the terms and conditions > > of the BSD > > License > > + which accompanies this distribution. The full text of the > > license may be found > > at > > + > > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fo > > penso > > urce.org%2Flicenses%2Fbsd- > > license.php=02%7C01%7Cudit.kumar%40nxp.com%7Cc6986ed63017483b > > 89dd08d5b1ff6c2d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63 > > 6610632972644435=CoYRxTy3iCIKcy2xXEF6BJl1qNQEPZTLHBX9pXmrHR > > w%3D=0 > > + > > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > > BASIS, > > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > > EXPRESS OR IMPLIED. > > + > > +**/ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > + > > +#include > > + > > +#define MM_MAJOR_VER_MASK0x > > +#define MM_MINOR_VER_MASK0x > > +#define MM_MAJOR_VER_SHIFT 16 > > + > > +const UINT32 MM_MAJOR_VER = 1; > > +const UINT32 MM_MINOR_VER = 0; > This should be UINT16 , as compare is done against UINT16 As per the interface spec, The version number is a 31-bit unsigned integer, with the upper 15 bits denoting the major revision, and the lower 16 bits denoting the minor revision. I can modify this, if you like, but it is a cosmetic change. > > > > > > + > > +// > > +// Address, Length of the pre-allocated buffer for communication > > with the > > secure > > +// world. > > +// > > +STATIC ARM_MEMORY_REGION_DESCRIPTOR mNsCommBuffMemRegion; > > + > > +// Notification event when virtual address map is set. > > +STATIC EFI_EVENT mSetVirtualAddressMapEvent; > > + > > +// > > +// Handle to install the MM Communication Protocol > > +// > > +STATIC EFI_HANDLE mMmCommunicateHandle; > > + > > +/** > > + Communicates with a registered handler. > > + > > + This function provides an interface to send and receive messages > > t
Re: [edk2] [PATCH v2 02/17] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
> -Original Message- > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of > Supreeth Venkatesh > Sent: Saturday, May 5, 2018 2:11 AM > To: edk2-devel@lists.01.org > Cc: ard.biesheu...@linaro.org; leif.lindh...@linaro.org; jiewen@intel.com; > liming@intel.com; michael.d.kin...@intel.com > Subject: [edk2] [PATCH v2 02/17] ArmPkg/Drivers: Add > EFI_MM_COMMUNICATION_PROTOCOL DXE driver. > > PI v1.5 Specification Volume 4 defines Management Mode Core Interface > and defines EFI_MM_COMMUNICATION_PROTOCOL. This protocol provides a > means of communicating between drivers outside of MM and MMI > handlers inside of MM. > > This patch implements the EFI_MM_COMMUNICATION_PROTOCOL DXE > runtime > driver for AARCH64 platforms. It uses SMCs allocated from the standard > SMC range defined in DEN0060A_ARM_MM_Interface_Specification.pdf > to communicate with the standalone MM environment in the secure world. > > This patch also adds the MM Communication driver (.inf) file to > define entry point for this driver and other compile > related information the driver needs. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Achin Gupta <achin.gu...@arm.com> > Signed-off-by: Supreeth Venkatesh <supreeth.venkat...@arm.com> > --- > .../Drivers/MmCommunicationDxe/MmCommunication.c | 408 > + > .../Drivers/MmCommunicationDxe/MmCommunication.inf | 50 +++ > 2 files changed, 458 insertions(+) > create mode 100644 > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > create mode 100644 > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf > > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > new file mode 100644 > index 00..8ba1790af9 > --- /dev/null > +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c > @@ -0,0 +1,408 @@ > +/** @file > + > + Copyright (c) 2016-2018, ARM Limited. All rights reserved. > + > + This program and the accompanying materials > + are licensed and made available under the terms and conditions of the BSD > License > + which accompanies this distribution. The full text of the license may be > found > at > + > https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fopenso > urce.org%2Flicenses%2Fbsd- > license.php=02%7C01%7Cudit.kumar%40nxp.com%7Cc6986ed63017483b > 89dd08d5b1ff6c2d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63 > 6610632972644435=CoYRxTy3iCIKcy2xXEF6BJl1qNQEPZTLHBX9pXmrHR > w%3D=0 > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include > + > +#define MM_MAJOR_VER_MASK0x > +#define MM_MINOR_VER_MASK0x > +#define MM_MAJOR_VER_SHIFT 16 > + > +const UINT32 MM_MAJOR_VER = 1; > +const UINT32 MM_MINOR_VER = 0; This should be UINT16 , as compare is done against UINT16 > + > +// > +// Address, Length of the pre-allocated buffer for communication with the > secure > +// world. > +// > +STATIC ARM_MEMORY_REGION_DESCRIPTOR mNsCommBuffMemRegion; > + > +// Notification event when virtual address map is set. > +STATIC EFI_EVENT mSetVirtualAddressMapEvent; > + > +// > +// Handle to install the MM Communication Protocol > +// > +STATIC EFI_HANDLE mMmCommunicateHandle; > + > +/** > + Communicates with a registered handler. > + > + This function provides an interface to send and receive messages to the > + Standalone MM environment on behalf of UEFI services. This function is > part > + of the MM Communication Protocol that may be called in physical mode prior > to > + SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap(). > + > + @param[in] ThisThe EFI_MM_COMMUNICATION_PROTOCOL > + instance. > + @param[in, out] CommBuffer A pointer to the buffer to convey > + into MMRAM. > + @param[in, out] CommSizeThe size of the data buffer being > + passed in. This is optional. > + > + @retval EFI_SUCCESS The message was successfully posted. > + @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. > + @retval EFI_BAD_BUFFER_SIZE The buffer size is incorrect for the MM > +
[edk2] [PATCH v2 02/17] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
PI v1.5 Specification Volume 4 defines Management Mode Core Interface and defines EFI_MM_COMMUNICATION_PROTOCOL. This protocol provides a means of communicating between drivers outside of MM and MMI handlers inside of MM. This patch implements the EFI_MM_COMMUNICATION_PROTOCOL DXE runtime driver for AARCH64 platforms. It uses SMCs allocated from the standard SMC range defined in DEN0060A_ARM_MM_Interface_Specification.pdf to communicate with the standalone MM environment in the secure world. This patch also adds the MM Communication driver (.inf) file to define entry point for this driver and other compile related information the driver needs. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Achin GuptaSigned-off-by: Supreeth Venkatesh --- .../Drivers/MmCommunicationDxe/MmCommunication.c | 408 + .../Drivers/MmCommunicationDxe/MmCommunication.inf | 50 +++ 2 files changed, 458 insertions(+) create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c create mode 100644 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c new file mode 100644 index 00..8ba1790af9 --- /dev/null +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -0,0 +1,408 @@ +/** @file + + Copyright (c) 2016-2018, ARM Limited. All rights reserved. + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define MM_MAJOR_VER_MASK0x +#define MM_MINOR_VER_MASK0x +#define MM_MAJOR_VER_SHIFT 16 + +const UINT32 MM_MAJOR_VER = 1; +const UINT32 MM_MINOR_VER = 0; + +// +// Address, Length of the pre-allocated buffer for communication with the secure +// world. +// +STATIC ARM_MEMORY_REGION_DESCRIPTOR mNsCommBuffMemRegion; + +// Notification event when virtual address map is set. +STATIC EFI_EVENT mSetVirtualAddressMapEvent; + +// +// Handle to install the MM Communication Protocol +// +STATIC EFI_HANDLE mMmCommunicateHandle; + +/** + Communicates with a registered handler. + + This function provides an interface to send and receive messages to the + Standalone MM environment on behalf of UEFI services. This function is part + of the MM Communication Protocol that may be called in physical mode prior to + SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap(). + + @param[in] ThisThe EFI_MM_COMMUNICATION_PROTOCOL + instance. + @param[in, out] CommBuffer A pointer to the buffer to convey + into MMRAM. + @param[in, out] CommSizeThe size of the data buffer being + passed in. This is optional. + + @retval EFI_SUCCESS The message was successfully posted. + @retval EFI_INVALID_PARAMETER The CommBuffer was NULL. + @retval EFI_BAD_BUFFER_SIZE The buffer size is incorrect for the MM + implementation. If this error is + returned, the MessageLength field in + the CommBuffer header or the integer + pointed by CommSize are updated to reflect + the maximum payload size the + implementation can accommodate. + @retval EFI_ACCESS_DENIED The CommunicateBuffer parameter + or CommSize parameter, if not omitted, + are in address range that cannot be + accessed by the MM environment +**/ +STATIC +EFI_STATUS +EFIAPI +MmCommunicationCommunicate ( + IN CONST EFI_MM_COMMUNICATION_PROTOCOL *This, + IN OUT VOID *CommBuffer, + IN OUT UINTN*CommSize OPTIONAL + ) +{ + EFI_MM_COMMUNICATE_HEADER *CommunicateHeader; + ARM_SMC_ARGSCommunicateSmcArgs; + EFI_STATUS Status; + UINTN BufferSize; + + Status = EFI_ACCESS_DENIED; + BufferSize = 0; + + ZeroMem (, sizeof (ARM_SMC_ARGS)); + + // + // Check parameters + // + if (CommBuffer == NULL) { +return EFI_INVALID_PARAMETER; + } + + CommunicateHeader = CommBuffer; + //