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