diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8QM6/scfw_api/main/rpc.h')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8QM6/scfw_api/main/rpc.h | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8QM6/scfw_api/main/rpc.h b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8QM6/scfw_api/main/rpc.h new file mode 100644 index 000000000..b29528f99 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8QM6/scfw_api/main/rpc.h | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016, Freescale Semiconductor, Inc. | ||
3 | * Copyright 2017-2020 NXP | ||
4 | * | ||
5 | * SPDX-License-Identifier: BSD-3-Clause | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without modification, | ||
8 | * are permitted provided that the following conditions are met: | ||
9 | * | ||
10 | * o Redistributions of source code must retain the above copyright notice, this list | ||
11 | * of conditions and the following disclaimer. | ||
12 | * | ||
13 | * o Redistributions in binary form must reproduce the above copyright notice, this | ||
14 | * list of conditions and the following disclaimer in the documentation and/or | ||
15 | * other materials provided with the distribution. | ||
16 | * | ||
17 | * o Neither the name of the copyright holder nor the names of its | ||
18 | * contributors may be used to endorse or promote products derived from this | ||
19 | * software without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
25 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
27 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
28 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
31 | */ | ||
32 | |||
33 | /*! | ||
34 | * Header file for the RPC implementation. | ||
35 | */ | ||
36 | |||
37 | #ifndef SC_RPC_H | ||
38 | #define SC_RPC_H | ||
39 | |||
40 | /* Includes */ | ||
41 | |||
42 | #include "main/types.h" | ||
43 | #include "main/ipc.h" | ||
44 | |||
45 | /* Defines */ | ||
46 | |||
47 | /*! | ||
48 | * @name SCFW API version | ||
49 | */ | ||
50 | /*@{*/ | ||
51 | #define SCFW_API_VERSION_MAJOR 1U | ||
52 | #define SCFW_API_VERSION_MINOR 20U | ||
53 | /*@}*/ | ||
54 | |||
55 | /*! RPC version */ | ||
56 | #define SC_RPC_VERSION 1U | ||
57 | |||
58 | /*! | ||
59 | * @name Defines for service types | ||
60 | */ | ||
61 | /*@{*/ | ||
62 | #define SC_RPC_SVC_UNKNOWN 0U | ||
63 | #define SC_RPC_SVC_RETURN 1U | ||
64 | #define SC_RPC_SVC_PM 2U | ||
65 | #define SC_RPC_SVC_RM 3U | ||
66 | #define SC_RPC_SVC_TIMER 5U | ||
67 | #define SC_RPC_SVC_PAD 6U | ||
68 | #define SC_RPC_SVC_MISC 7U | ||
69 | #define SC_RPC_SVC_IRQ 8U | ||
70 | #define SC_RPC_SVC_SECO 9U | ||
71 | #define SC_RPC_SVC_ABORT 10U | ||
72 | /*@}*/ | ||
73 | |||
74 | /* Internal Defines */ | ||
75 | |||
76 | #define SC_RPC_MAX_MSG 8U | ||
77 | |||
78 | #define RPC_VER(MESG) ((MESG)->version) | ||
79 | #define RPC_SIZE(MESG) ((MESG)->size) | ||
80 | #define RPC_SVC(MESG) ((MESG)->svc) | ||
81 | #define RPC_FUNC(MESG) ((MESG)->func) | ||
82 | #define RPC_R8(MESG) ((MESG)->func) | ||
83 | #define RPC_I64(MESG, IDX) ((I64(RPC_U32((MESG), (IDX))) << 32ULL) \ | ||
84 | | I64(RPC_U32((MESG), (IDX) + 4U))) | ||
85 | #define RPC_I32(MESG, IDX) ((MESG)->DATA.i32[(IDX) / 4U]) | ||
86 | #define RPC_I16(MESG, IDX) ((MESG)->DATA.i16[(IDX) / 2U]) | ||
87 | #define RPC_I8(MESG, IDX) ((MESG)->DATA.i8[(IDX)]) | ||
88 | #define RPC_U64(MESG, IDX) ((U64(RPC_U32((MESG), (IDX))) << 32ULL) \ | ||
89 | | U64(RPC_U32((MESG), (IDX) + 4U))) | ||
90 | #define RPC_U32(MESG, IDX) ((MESG)->DATA.u32[(IDX) / 4U]) | ||
91 | #define RPC_U16(MESG, IDX) ((MESG)->DATA.u16[(IDX) / 2U]) | ||
92 | #define RPC_U8(MESG, IDX) ((MESG)->DATA.u8[(IDX)]) | ||
93 | |||
94 | #define SC_RPC_ASYNC_STATE_RD_START 0U | ||
95 | #define SC_RPC_ASYNC_STATE_RD_ACTIVE 1U | ||
96 | #define SC_RPC_ASYNC_STATE_RD_DONE 2U | ||
97 | #define SC_RPC_ASYNC_STATE_WR_START 3U | ||
98 | #define SC_RPC_ASYNC_STATE_WR_ACTIVE 4U | ||
99 | #define SC_RPC_ASYNC_STATE_WR_DONE 5U | ||
100 | |||
101 | /* SC -> Client general-purpose MU IRQs */ | ||
102 | #define SC_RPC_MU_GIR_SVC 0x1U | ||
103 | #define SC_RPC_MU_GIR_WAKE 0x2U | ||
104 | #define SC_RPC_MU_GIR_BOOT 0x4U | ||
105 | #define SC_RPC_MU_GIR_DBG 0x8U | ||
106 | |||
107 | /* Client -> SC general-purpose MU IRQs */ | ||
108 | #define SC_RPC_MU_GIR_RST 0x1U | ||
109 | |||
110 | #define I8(X) ((int8_t) (X)) | ||
111 | #define I16(X) ((int16_t) (X)) | ||
112 | #define I32(X) ((int32_t) (X)) | ||
113 | #define I64(X) ((int64_t) (X)) | ||
114 | #define U8(X) ((uint8_t) (X)) | ||
115 | #define U16(X) ((uint16_t) (X)) | ||
116 | #define U32(X) ((uint32_t) (X)) | ||
117 | #define U64(X) ((uint64_t) (X)) | ||
118 | |||
119 | #define PTR_I8(X) ((int8_t *) (X)) | ||
120 | #define PTR_I16(X) ((int16_t *) (X)) | ||
121 | #define PTR_I32(X) ((int32_t *) (X)) | ||
122 | #define PTR_I64(X) ((int64_t *) (X)) | ||
123 | #define PTR_U8(X) ((uint8_t *) (X)) | ||
124 | #define PTR_U16(X) ((uint16_t *) (X)) | ||
125 | #define PTR_U32(X) ((uint32_t *) (X)) | ||
126 | #define PTR_U64(X) ((uint64_t *) (X)) | ||
127 | |||
128 | #define U2B(X) (((X) != 0U) ? SC_TRUE : SC_FALSE) | ||
129 | #define U2B32(X) (((X) != 0UL) ? SC_TRUE : SC_FALSE) | ||
130 | #define B2U8(X) (((X) != SC_FALSE) ? U8(0x01U) : U8(0x00U)) | ||
131 | #define B2U16(X) (((X) != SC_FALSE) ? U16(0x01U) : U16(0x00U)) | ||
132 | #define B2U32(X) (((X) != SC_FALSE) ? U32(0x01U) : U32(0x00U)) | ||
133 | |||
134 | /* Types */ | ||
135 | |||
136 | typedef struct | ||
137 | { | ||
138 | uint8_t version; | ||
139 | uint8_t size; | ||
140 | uint8_t svc; | ||
141 | uint8_t func; | ||
142 | union | ||
143 | { | ||
144 | int32_t i32[(SC_RPC_MAX_MSG - 1U)]; | ||
145 | int16_t i16[(SC_RPC_MAX_MSG - 1U) * 2U]; | ||
146 | int8_t i8[(SC_RPC_MAX_MSG - 1U) * 4U]; | ||
147 | uint32_t u32[(SC_RPC_MAX_MSG - 1U)]; | ||
148 | uint16_t u16[(SC_RPC_MAX_MSG - 1U) * 2U]; | ||
149 | uint8_t u8[(SC_RPC_MAX_MSG - 1U) * 4U]; | ||
150 | } DATA; | ||
151 | } sc_rpc_msg_t; | ||
152 | |||
153 | typedef uint8_t sc_rpc_async_state_t; | ||
154 | |||
155 | typedef struct | ||
156 | { | ||
157 | sc_rpc_async_state_t state; | ||
158 | uint8_t wordIdx; | ||
159 | sc_rpc_msg_t msg; | ||
160 | uint32_t timeStamp; | ||
161 | } sc_rpc_async_msg_t; | ||
162 | |||
163 | /* Functions */ | ||
164 | |||
165 | /*! | ||
166 | * This is an internal function to send an RPC message over an IPC | ||
167 | * channel. It is called by client-side SCFW API function shims. | ||
168 | * | ||
169 | * @param[in] ipc IPC handle | ||
170 | * @param[in,out] msg handle to a message | ||
171 | * @param[in] no_resp response flag | ||
172 | * | ||
173 | * If \a no_resp is SC_FALSE then this function waits for a response | ||
174 | * and returns the result in \a msg. | ||
175 | */ | ||
176 | void sc_call_rpc(sc_ipc_t ipc, sc_rpc_msg_t *msg, sc_bool_t no_resp); | ||
177 | |||
178 | #endif /* SC_RPC_H */ | ||
179 | |||