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