]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: MTL Library interface and Null library implementation
authorGirish Pathak <girish.pathak@arm.com>
Mon, 15 Jan 2018 14:41:51 +0000 (14:41 +0000)
committerLeif Lindholm <leif.lindholm@linaro.org>
Mon, 23 Apr 2018 11:12:23 +0000 (12:12 +0100)
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 <girish.pathak@arm.com>
Signed-off-by: Evan Lloyd <evan.lloyd@arm.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/ArmPkg.dec
ArmPkg/Include/Library/ArmMtlLib.h [new file with mode: 0644]
ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c [new file with mode: 0644]
ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf [new file with mode: 0644]

index 5dbd019e2966573b9f987bc6775ca42ffbffc230..3be5f13f8f4d0d13cee6285d23c74483c00c9c60 100644 (file)
@@ -2,7 +2,7 @@
 # ARM processor package.\r
 #\r
 # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>\r
-# Copyright (c) 2011 - 2017, ARM Limited. All rights reserved.\r
+# Copyright (c) 2011 - 2018, ARM Limited. All rights reserved.\r
 #\r
 #    This program and the accompanying materials\r
 #    are licensed and made available under the terms and conditions of the BSD License\r
@@ -39,6 +39,7 @@
   DefaultExceptionHandlerLib|Include/Library/DefaultExceptionHandlerLib.h\r
   ArmDisassemblerLib|Include/Library/ArmDisassemblerLib.h\r
   ArmGicArchLib|Include/Library/ArmGicArchLib.h\r
+  ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h\r
   ArmSvcLib|Include/Library/ArmSvcLib.h\r
 \r
 [Guids.common]\r
diff --git a/ArmPkg/Include/Library/ArmMtlLib.h b/ArmPkg/Include/Library/ArmMtlLib.h
new file mode 100644 (file)
index 0000000..4218a74
--- /dev/null
@@ -0,0 +1,137 @@
+/** @file\r
+\r
+  Copyright (c) 2017-2018, Arm Limited. All rights reserved.\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+  System Control and Management Interface V1.0\r
+    http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/\r
+    DEN0056A_System_Control_and_Management_Interface.pdf\r
+**/\r
+\r
+#ifndef ARM_MTL_LIB_H_\r
+#define ARM_MTL_LIB_H_\r
+\r
+#include <Uefi/UefiBaseType.h>\r
+\r
+// Ideally we don't need packed struct. However we can't rely on compilers.\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+  UINT32 Reserved1;\r
+  UINT32 ChannelStatus;\r
+  UINT64 Reserved2;\r
+  UINT32 Flags;\r
+  UINT32 Length;\r
+  UINT32 MessageHeader;\r
+\r
+  // NOTE: Since EDK2 does not allow flexible array member [] we declare\r
+  // here array of 1 element length. However below is used as a variable\r
+  // length array.\r
+  UINT32 Payload[1];    // size less object gives offset to payload.\r
+} MTL_MAILBOX;\r
+\r
+#pragma pack()\r
+\r
+// Channel Type, Low-priority, and High-priority\r
+typedef enum {\r
+  MTL_CHANNEL_TYPE_LOW = 0,\r
+  MTL_CHANNEL_TYPE_HIGH = 1\r
+} MTL_CHANNEL_TYPE;\r
+\r
+typedef struct {\r
+  UINT64 PhysicalAddress;\r
+  UINT32 ModifyMask;\r
+  UINT32 PreserveMask;\r
+} MTL_DOORBELL;\r
+\r
+typedef struct {\r
+  MTL_CHANNEL_TYPE ChannelType;\r
+  MTL_MAILBOX      * CONST MailBox;\r
+  MTL_DOORBELL     DoorBell;\r
+} MTL_CHANNEL;\r
+\r
+/** Wait until channel is free.\r
+\r
+  @param[in] Channel                Pointer to a channel.\r
+  @param[in] TimeOutInMicroSeconds  Time out in micro seconds.\r
+\r
+  @retval EFI_SUCCESS               Channel is free.\r
+  @retval EFI_TIMEOUT               Time out error.\r
+**/\r
+EFI_STATUS\r
+MtlWaitUntilChannelFree (\r
+  IN MTL_CHANNEL  *Channel,\r
+  IN UINT64       TimeOutInMicroSeconds\r
+  );\r
+\r
+/** Return the address of the message payload.\r
+\r
+  @param[in] Channel   Pointer to a channel.\r
+\r
+  @retval UINT32*      Pointer to the payload.\r
+**/\r
+UINT32*\r
+MtlGetChannelPayload (\r
+  IN MTL_CHANNEL  *Channel\r
+  );\r
+\r
+/** Return pointer to a channel for the requested channel type.\r
+\r
+  @param[in] ChannelType        ChannelType, Low or High priority channel.\r
+                                MTL_CHANNEL_TYPE_LOW or\r
+                                MTL_CHANNEL_TYPE_HIGH\r
+\r
+  @param[out] Channel           Holds pointer to the channel.\r
+\r
+  @retval EFI_SUCCESS           Pointer to channel is returned.\r
+  @retval EFI_UNSUPPORTED       Requested channel type not supported.\r
+**/\r
+EFI_STATUS\r
+MtlGetChannel (\r
+  IN  MTL_CHANNEL_TYPE  ChannelType,\r
+  OUT MTL_CHANNEL       **Channel\r
+  );\r
+\r
+/** Mark the channel busy and ring the doorbell.\r
+\r
+  @param[in] Channel               Pointer to a channel.\r
+  @param[in] MessageHeader         Message header.\r
+\r
+  @param[out] PayloadLength        Message length.\r
+\r
+  @retval EFI_SUCCESS              Message sent successfully.\r
+  @retval EFI_DEVICE_ERROR         Channel is busy.\r
+**/\r
+EFI_STATUS\r
+MtlSendMessage (\r
+  IN  MTL_CHANNEL  *Channel,\r
+  IN  UINT32       MessageHeader,\r
+  OUT UINT32       PayloadLength\r
+  );\r
+\r
+/** Wait for a response on a channel.\r
+\r
+  If channel is free after sending message, it implies SCP responded\r
+  with a response on the channel.\r
+\r
+  @param[in] Channel               Pointer to a channel.\r
+\r
+  @retval EFI_SUCCESS              Message received successfully.\r
+  @retval EFI_TIMEOUT              Time out error.\r
+**/\r
+EFI_STATUS\r
+MtlReceiveMessage (\r
+  IN  MTL_CHANNEL  *Channel,\r
+  OUT UINT32       *MessageHeader,\r
+  OUT UINT32       *PayloadLength\r
+  );\r
+\r
+#endif  /* ARM_MTL_LIB_H_ */\r
+\r
diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.c
new file mode 100644 (file)
index 0000000..f186237
--- /dev/null
@@ -0,0 +1,108 @@
+/** @file\r
+\r
+  Copyright (c) 2017-2018, Arm Limited. All rights reserved.\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+  System Control and Management Interface V1.0\r
+    http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/\r
+    DEN0056A_System_Control_and_Management_Interface.pdf\r
+**/\r
+\r
+#include <Library/ArmMtlLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+/** Wait until channel is free.\r
+\r
+  @param[in] Channel                Pointer to a channel.\r
+  @param[in] TimeOutInMicroSeconds  Timeout in micro seconds.\r
+\r
+  @retval EFI_UNSUPPORTED           Interface not implemented.\r
+**/\r
+EFI_STATUS\r
+MtlWaitUntilChannelFree (\r
+  IN MTL_CHANNEL  *Channel,\r
+  IN UINTN        TimeOutInMicroSeconds\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/** Return the address of the message payload.\r
+\r
+  @param[in] Channel   Pointer to a channel.\r
+\r
+  @retval UINT32*      Pointer to the payload.\r
+**/\r
+UINT32*\r
+MtlGetChannelPayload (\r
+  IN  MTL_CHANNEL  *Channel\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return NULL;\r
+}\r
+\r
+/** Return pointer to a channel for the requested channel type.\r
+\r
+  @param[in] ChannelType        ChannelType, Low or High priority channel.\r
+                                MTL_CHANNEL_TYPE_LOW or\r
+                                MTL_CHANNEL_TYPE_HIGH\r
+\r
+  @param[out] Channel           Holds pointer to the channel.\r
+\r
+  @retval EFI_UNSUPPORTED       Requested channel type not supported or\r
+                                interface not implemented.\r
+**/\r
+EFI_STATUS\r
+MtlGetChannel (\r
+  IN  MTL_CHANNEL_TYPE  ChannelType,\r
+  OUT MTL_CHANNEL       **Channel\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/** Mark the channel busy and ring the doorbell.\r
+\r
+  @param[in] Channel               Pointer to a channel.\r
+  @param[in] MessageHeader         Message header.\r
+\r
+  @param[out] PayloadLength        Message length.\r
+\r
+  @retval EFI_UNSUPPORTED          Interface not implemented.\r
+**/\r
+EFI_STATUS\r
+MtlSendMessage (\r
+  IN  MTL_CHANNEL  *Channel,\r
+  IN  UINT32       MessageHeader,\r
+  OUT UINT32       PayloadLength\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/** Wait for a response on a channel.\r
+\r
+  If channel is free after sending message, it implies SCP responded\r
+  with a response on the channel.\r
+\r
+  @param[in] Channel               Pointer to a channel.\r
+\r
+  @retval EFI_UNSUPPORTED          Interface not implemented.\r
+**/\r
+EFI_STATUS\r
+MtlReceiveMessage (\r
+  IN  MTL_CHANNEL  *Channel,\r
+  OUT UINT32       *MessageHeader,\r
+  OUT UINT32       *PayloadLength\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf b/ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
new file mode 100644 (file)
index 0000000..9c0426b
--- /dev/null
@@ -0,0 +1,26 @@
+#/** @file\r
+#  Copyright (c) 2017-2018, Arm Limited. All rights reserved.\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#**/\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010019\r
+  BASE_NAME                      = ArmMtlNullLib\r
+  FILE_GUID                      = 05810525-FDEC-4006-9F1F-37609B3675FA\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = ArmMtlLib\r
+\r
+[Sources.common]\r
+  ArmMtlNullLib.c\r
+\r
+[Packages]\r
+  ArmPkg/ArmPkg.dec\r
+  MdePkg/MdePkg.dec\r