From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::241; helo=mail-wr0-x241.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 133DE2277AF0D for ; Mon, 23 Apr 2018 04:11:24 -0700 (PDT) Received: by mail-wr0-x241.google.com with SMTP id p5-v6so12306895wre.12 for ; Mon, 23 Apr 2018 04:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YXz3VNLiqEa6Untp0H/y1ifJlystK+IBFzkvQGvEv5I=; b=A252eykMqzvW/wRWXiTZCpUhRFotBcQG6uJ01bFXyCQW5eHX7fb725CJf80ZryUHVq Tf7CeXTcjcHz2rOqG5SqyCuyx2QZTcCNivkzp9gpz0UBFxlG3aGVTPaSDwCgbQPzu/Cg klfGwegApMKw0Wb09G6+q4ERS6tltVVjwuB2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YXz3VNLiqEa6Untp0H/y1ifJlystK+IBFzkvQGvEv5I=; b=NxsdNMK3BNsIaPyhPPrFoWaDnYU+/5gEW4c18Cq4gkZ4FyPHcNFT5iu+N8XwPjYf8F IDdFRVH6ZEdYXxWaLQUEbk7HPXQarXsY1YMLuEk635iGn8e6KAlwRPnkGO/6Mxo8/P6j /HuIe2f/9LKqrxZqjdGotzPeY9qVf1U36ISdorae0IPgb5iGgJUjPtzDFA/kqzqWELdR PHhgxpEUGDJ6MBQeFI5sX2I9A0mGV586LTurgW8jgHvq4be4hKKkMDl8IYxDbRwBtVmp xmHXH20ETYfUXWB8uPFGaC5IqmfUfJ8HgwTBXVeKM9vqNyF41hDpGwtoU4vAatEr06TH 8SzQ== X-Gm-Message-State: ALQs6tBJU9+Mvsl0RBA4v/8hDLhy4pV0xDfIayyNe6Kmehq8mLsk+ypH sL9Ldzdbijf9cbaJDmWSUOrYDQ== X-Google-Smtp-Source: AIpwx4+q+VuHy9rRgeC5hKHLpwu0wNyu2QcEms08WRAAN/2TkOEUyE4RlaRBcNZdUagKKkDrKcyVtQ== X-Received: by 2002:adf:9654:: with SMTP id c20-v6mr17548143wra.89.1524481883463; Mon, 23 Apr 2018 04:11:23 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id m6sm13158050wmb.9.2018.04.23.04.11.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Apr 2018 04:11:22 -0700 (PDT) Date: Mon, 23 Apr 2018 12:11:20 +0100 From: Leif Lindholm To: Girish Pathak Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, Matteo.Carlini@arm.com, Stephanie.Hughes-Fitt@arm.com, nd@arm.com Message-ID: <20180423111120.mc32ph7j2ft2lp57@bivouac.eciton.net> References: <20180320161212.79120-1-girish.pathak@arm.com> <20180320161212.79120-16-girish.pathak@arm.com> MIME-Version: 1.0 In-Reply-To: <20180320161212.79120-16-girish.pathak@arm.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH v3 15/16] ArmPkg: MTL Library interface and Null library implementation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2018 11:11:25 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Mar 20, 2018 at 04:12:11PM +0000, Girish Pathak wrote: > Upcoming new component ArmPkg/Drivers/ArmScmiDxe is dependent on > platform specific ArmMtlLib library implementation, however in order > to be able to build the ArmScmiDxe component outside of the context of a > particular platform, this change adds Null implementation of the > ArmMtlLib along with ARM MTL library header. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Girish Pathak > Signed-off-by: Evan Lloyd > --- > ArmPkg/ArmPkg.dec | 3 +- > ArmPkg/Include/Library/ArmMtlLib.h | 137 ++++++++++++++++++++ > ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c | 108 +++++++++++++++ > ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf | 26 ++++ > 4 files changed, 273 insertions(+), 1 deletion(-) > > diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec > index a55b6268ff85ffd7da140be813ec875f7f242c4d..881751d81c6384a3eb0b4c180c76d01a58266a74 100644 > --- a/ArmPkg/ArmPkg.dec > +++ b/ArmPkg/ArmPkg.dec > @@ -2,7 +2,7 @@ > # ARM processor package. > # > # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.
> -# Copyright (c) 2011 - 2017, ARM Limited. All rights reserved. > +# Copyright (c) 2011 - 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 > @@ -40,6 +40,7 @@ [LibraryClasses.common] > ArmDisassemblerLib|Include/Library/ArmDisassemblerLib.h > ArmGicArchLib|Include/Library/ArmGicArchLib.h > ArmSvcLib|Include/Library/ArmSvcLib.h > + ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h Unless you scream before I get around to pushing, I'm going to move that line up one step. / Leif > > [Guids.common] > gArmTokenSpaceGuid = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } } > diff --git a/ArmPkg/Include/Library/ArmMtlLib.h b/ArmPkg/Include/Library/ArmMtlLib.h > new file mode 100644 > index 0000000000000000000000000000000000000000..4218a741e5ebddd08022b94354d5ef47576cd3b8 > --- /dev/null > +++ b/ArmPkg/Include/Library/ArmMtlLib.h > @@ -0,0 +1,137 @@ > +/** @file > + > + Copyright (c) 2017-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. > + > + System Control and Management Interface V1.0 > + http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/ > + DEN0056A_System_Control_and_Management_Interface.pdf > +**/ > + > +#ifndef ARM_MTL_LIB_H_ > +#define ARM_MTL_LIB_H_ > + > +#include > + > +// Ideally we don't need packed struct. However we can't rely on compilers. > +#pragma pack(1) > + > +typedef struct { > + UINT32 Reserved1; > + UINT32 ChannelStatus; > + UINT64 Reserved2; > + UINT32 Flags; > + UINT32 Length; > + UINT32 MessageHeader; > + > + // NOTE: Since EDK2 does not allow flexible array member [] we declare > + // here array of 1 element length. However below is used as a variable > + // length array. > + UINT32 Payload[1]; // size less object gives offset to payload. > +} MTL_MAILBOX; > + > +#pragma pack() > + > +// Channel Type, Low-priority, and High-priority > +typedef enum { > + MTL_CHANNEL_TYPE_LOW = 0, > + MTL_CHANNEL_TYPE_HIGH = 1 > +} MTL_CHANNEL_TYPE; > + > +typedef struct { > + UINT64 PhysicalAddress; > + UINT32 ModifyMask; > + UINT32 PreserveMask; > +} MTL_DOORBELL; > + > +typedef struct { > + MTL_CHANNEL_TYPE ChannelType; > + MTL_MAILBOX * CONST MailBox; > + MTL_DOORBELL DoorBell; > +} MTL_CHANNEL; > + > +/** Wait until channel is free. > + > + @param[in] Channel Pointer to a channel. > + @param[in] TimeOutInMicroSeconds Time out in micro seconds. > + > + @retval EFI_SUCCESS Channel is free. > + @retval EFI_TIMEOUT Time out error. > +**/ > +EFI_STATUS > +MtlWaitUntilChannelFree ( > + IN MTL_CHANNEL *Channel, > + IN UINT64 TimeOutInMicroSeconds > + ); > + > +/** Return the address of the message payload. > + > + @param[in] Channel Pointer to a channel. > + > + @retval UINT32* Pointer to the payload. > +**/ > +UINT32* > +MtlGetChannelPayload ( > + IN MTL_CHANNEL *Channel > + ); > + > +/** Return pointer to a channel for the requested channel type. > + > + @param[in] ChannelType ChannelType, Low or High priority channel. > + MTL_CHANNEL_TYPE_LOW or > + MTL_CHANNEL_TYPE_HIGH > + > + @param[out] Channel Holds pointer to the channel. > + > + @retval EFI_SUCCESS Pointer to channel is returned. > + @retval EFI_UNSUPPORTED Requested channel type not supported. > +**/ > +EFI_STATUS > +MtlGetChannel ( > + IN MTL_CHANNEL_TYPE ChannelType, > + OUT MTL_CHANNEL **Channel > + ); > + > +/** Mark the channel busy and ring the doorbell. > + > + @param[in] Channel Pointer to a channel. > + @param[in] MessageHeader Message header. > + > + @param[out] PayloadLength Message length. > + > + @retval EFI_SUCCESS Message sent successfully. > + @retval EFI_DEVICE_ERROR Channel is busy. > +**/ > +EFI_STATUS > +MtlSendMessage ( > + IN MTL_CHANNEL *Channel, > + IN UINT32 MessageHeader, > + OUT UINT32 PayloadLength > + ); > + > +/** Wait for a response on a channel. > + > + If channel is free after sending message, it implies SCP responded > + with a response on the channel. > + > + @param[in] Channel Pointer to a channel. > + > + @retval EFI_SUCCESS Message received successfully. > + @retval EFI_TIMEOUT Time out error. > +**/ > +EFI_STATUS > +MtlReceiveMessage ( > + IN MTL_CHANNEL *Channel, > + OUT UINT32 *MessageHeader, > + OUT UINT32 *PayloadLength > + ); > + > +#endif /* ARM_MTL_LIB_H_ */ > + > diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c > new file mode 100644 > index 0000000000000000000000000000000000000000..f1862371113e342e4a4c8059be27884842210d08 > --- /dev/null > +++ b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c > @@ -0,0 +1,108 @@ > +/** @file > + > + Copyright (c) 2017-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. > + > + System Control and Management Interface V1.0 > + http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/ > + DEN0056A_System_Control_and_Management_Interface.pdf > +**/ > + > +#include > +#include > + > +/** Wait until channel is free. > + > + @param[in] Channel Pointer to a channel. > + @param[in] TimeOutInMicroSeconds Timeout in micro seconds. > + > + @retval EFI_UNSUPPORTED Interface not implemented. > +**/ > +EFI_STATUS > +MtlWaitUntilChannelFree ( > + IN MTL_CHANNEL *Channel, > + IN UINTN TimeOutInMicroSeconds > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +/** Return the address of the message payload. > + > + @param[in] Channel Pointer to a channel. > + > + @retval UINT32* Pointer to the payload. > +**/ > +UINT32* > +MtlGetChannelPayload ( > + IN MTL_CHANNEL *Channel > + ) > +{ > + ASSERT (FALSE); > + return NULL; > +} > + > +/** Return pointer to a channel for the requested channel type. > + > + @param[in] ChannelType ChannelType, Low or High priority channel. > + MTL_CHANNEL_TYPE_LOW or > + MTL_CHANNEL_TYPE_HIGH > + > + @param[out] Channel Holds pointer to the channel. > + > + @retval EFI_UNSUPPORTED Requested channel type not supported or > + interface not implemented. > +**/ > +EFI_STATUS > +MtlGetChannel ( > + IN MTL_CHANNEL_TYPE ChannelType, > + OUT MTL_CHANNEL **Channel > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +/** Mark the channel busy and ring the doorbell. > + > + @param[in] Channel Pointer to a channel. > + @param[in] MessageHeader Message header. > + > + @param[out] PayloadLength Message length. > + > + @retval EFI_UNSUPPORTED Interface not implemented. > +**/ > +EFI_STATUS > +MtlSendMessage ( > + IN MTL_CHANNEL *Channel, > + IN UINT32 MessageHeader, > + OUT UINT32 PayloadLength > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +/** Wait for a response on a channel. > + > + If channel is free after sending message, it implies SCP responded > + with a response on the channel. > + > + @param[in] Channel Pointer to a channel. > + > + @retval EFI_UNSUPPORTED Interface not implemented. > +**/ > +EFI_STATUS > +MtlReceiveMessage ( > + IN MTL_CHANNEL *Channel, > + OUT UINT32 *MessageHeader, > + OUT UINT32 *PayloadLength > + ) > +{ > + return EFI_UNSUPPORTED; > +} > diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf > new file mode 100644 > index 0000000000000000000000000000000000000000..9c0426b00e48e791dae9ad11e2f47d248d9c09ce > --- /dev/null > +++ b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf > @@ -0,0 +1,26 @@ > +#/** @file > +# Copyright (c) 2017-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. > +#**/ > + > +[Defines] > + INF_VERSION = 0x00010019 > + BASE_NAME = ArmMtlNullLib > + FILE_GUID = 05810525-FDEC-4006-9F1F-37609B3675FA > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = ArmMtlLib > + > +[Sources.common] > + ArmMtlNullLib.c > + > +[Packages] > + ArmPkg/ArmPkg.dec > + MdePkg/MdePkg.dec > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > >