]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ArmPkg/Include/Library/ArmMtlLib.h
ArmPkg: MTL Library interface and Null library implementation
[mirror_edk2.git] / ArmPkg / Include / Library / ArmMtlLib.h
... / ...
CommitLineData
1/** @file\r
2\r
3 Copyright (c) 2017-2018, Arm Limited. All rights reserved.\r
4\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13 System Control and Management Interface V1.0\r
14 http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/\r
15 DEN0056A_System_Control_and_Management_Interface.pdf\r
16**/\r
17\r
18#ifndef ARM_MTL_LIB_H_\r
19#define ARM_MTL_LIB_H_\r
20\r
21#include <Uefi/UefiBaseType.h>\r
22\r
23// Ideally we don't need packed struct. However we can't rely on compilers.\r
24#pragma pack(1)\r
25\r
26typedef struct {\r
27 UINT32 Reserved1;\r
28 UINT32 ChannelStatus;\r
29 UINT64 Reserved2;\r
30 UINT32 Flags;\r
31 UINT32 Length;\r
32 UINT32 MessageHeader;\r
33\r
34 // NOTE: Since EDK2 does not allow flexible array member [] we declare\r
35 // here array of 1 element length. However below is used as a variable\r
36 // length array.\r
37 UINT32 Payload[1]; // size less object gives offset to payload.\r
38} MTL_MAILBOX;\r
39\r
40#pragma pack()\r
41\r
42// Channel Type, Low-priority, and High-priority\r
43typedef enum {\r
44 MTL_CHANNEL_TYPE_LOW = 0,\r
45 MTL_CHANNEL_TYPE_HIGH = 1\r
46} MTL_CHANNEL_TYPE;\r
47\r
48typedef struct {\r
49 UINT64 PhysicalAddress;\r
50 UINT32 ModifyMask;\r
51 UINT32 PreserveMask;\r
52} MTL_DOORBELL;\r
53\r
54typedef struct {\r
55 MTL_CHANNEL_TYPE ChannelType;\r
56 MTL_MAILBOX * CONST MailBox;\r
57 MTL_DOORBELL DoorBell;\r
58} MTL_CHANNEL;\r
59\r
60/** Wait until channel is free.\r
61\r
62 @param[in] Channel Pointer to a channel.\r
63 @param[in] TimeOutInMicroSeconds Time out in micro seconds.\r
64\r
65 @retval EFI_SUCCESS Channel is free.\r
66 @retval EFI_TIMEOUT Time out error.\r
67**/\r
68EFI_STATUS\r
69MtlWaitUntilChannelFree (\r
70 IN MTL_CHANNEL *Channel,\r
71 IN UINT64 TimeOutInMicroSeconds\r
72 );\r
73\r
74/** Return the address of the message payload.\r
75\r
76 @param[in] Channel Pointer to a channel.\r
77\r
78 @retval UINT32* Pointer to the payload.\r
79**/\r
80UINT32*\r
81MtlGetChannelPayload (\r
82 IN MTL_CHANNEL *Channel\r
83 );\r
84\r
85/** Return pointer to a channel for the requested channel type.\r
86\r
87 @param[in] ChannelType ChannelType, Low or High priority channel.\r
88 MTL_CHANNEL_TYPE_LOW or\r
89 MTL_CHANNEL_TYPE_HIGH\r
90\r
91 @param[out] Channel Holds pointer to the channel.\r
92\r
93 @retval EFI_SUCCESS Pointer to channel is returned.\r
94 @retval EFI_UNSUPPORTED Requested channel type not supported.\r
95**/\r
96EFI_STATUS\r
97MtlGetChannel (\r
98 IN MTL_CHANNEL_TYPE ChannelType,\r
99 OUT MTL_CHANNEL **Channel\r
100 );\r
101\r
102/** Mark the channel busy and ring the doorbell.\r
103\r
104 @param[in] Channel Pointer to a channel.\r
105 @param[in] MessageHeader Message header.\r
106\r
107 @param[out] PayloadLength Message length.\r
108\r
109 @retval EFI_SUCCESS Message sent successfully.\r
110 @retval EFI_DEVICE_ERROR Channel is busy.\r
111**/\r
112EFI_STATUS\r
113MtlSendMessage (\r
114 IN MTL_CHANNEL *Channel,\r
115 IN UINT32 MessageHeader,\r
116 OUT UINT32 PayloadLength\r
117 );\r
118\r
119/** Wait for a response on a channel.\r
120\r
121 If channel is free after sending message, it implies SCP responded\r
122 with a response on the channel.\r
123\r
124 @param[in] Channel Pointer to a channel.\r
125\r
126 @retval EFI_SUCCESS Message received successfully.\r
127 @retval EFI_TIMEOUT Time out error.\r
128**/\r
129EFI_STATUS\r
130MtlReceiveMessage (\r
131 IN MTL_CHANNEL *Channel,\r
132 OUT UINT32 *MessageHeader,\r
133 OUT UINT32 *PayloadLength\r
134 );\r
135\r
136#endif /* ARM_MTL_LIB_H_ */\r
137\r