@@ -30,20 +30,6 @@ static inline void write_reg(paddr_t addr, paddr_t offset, uint32_t value)
3030 * ((volatile uint32_t * )((paddr_t )(addr + offset ))) = value ;
3131}
3232
33- /**
34- * @brief Verifies the status and configuration of a Secure Proxy thread before
35- * a transaction.
36- *
37- * @desc This function checks for thread corruption, validates the thread's
38- * configured direction (read/write) against its intended usage, and ensures the
39- * message queue is not empty if reading.
40- *
41- * @param thread_id The ID of the thread to verify.
42- * @param msg_drxn Expected message direction (MSG_DRXN_READ or MSG_DRXN_WRITE).
43- *
44- * @return int32_t STATUS_CODE_NO_ERROR if the thread is valid and ready,
45- * otherwise respective error codes.
46- */
4733int32_t mbox_k3_sec_proxy_verify_thread (uint8_t thread_id , uint8_t msg_drxn )
4834{
4935 paddr_t thread_rt_base =
@@ -108,7 +94,7 @@ int32_t mbox_k3_sec_proxy_verify_thread(uint8_t thread_id, uint8_t msg_drxn)
10894 * | not reached yet | +------------------------------------+
10995 * +-------------------------+
11096 */
111- int32_t mbox_k3_sec_proxy_read (uint8_t thread_id , mbox_k3_sec_proxy_msg * msg )
97+ int32_t mbox_k3_sec_proxy_read (uint8_t thread_id , void * buffer , size_t len )
11298{
11399 /* verify thread status */
114100 int32_t read_status = mbox_k3_sec_proxy_verify_thread (thread_id , MSG_DRXN_READ );
@@ -123,20 +109,19 @@ int32_t mbox_k3_sec_proxy_read(uint8_t thread_id, mbox_k3_sec_proxy_msg* msg)
123109
124110 /* read whole words first */
125111 uint32_t word_iterator ;
126- size_t num_words = msg -> len / sizeof (uint32_t );
112+ size_t num_words = len / sizeof (uint32_t );
127113 for (word_iterator = 0 ; word_iterator < num_words ; word_iterator ++ ) {
128- ((uint32_t * )msg -> buffer )[word_iterator ] =
129- read_reg (data_reg , word_iterator * sizeof (uint32_t ));
114+ ((uint32_t * )buffer )[word_iterator ] = read_reg (data_reg , word_iterator * sizeof (uint32_t ));
130115 }
131116
132117 /* read remaining bytes */
133- uint32_t trail_bytes = msg -> len % sizeof (uint32_t );
118+ uint32_t trail_bytes = len % sizeof (uint32_t );
134119 if (0 != trail_bytes ) {
135120 uint32_t data_trail = read_reg (data_reg , word_iterator ++ * sizeof (uint32_t ));
136121
137- size_t trail_iterator = msg -> len - trail_bytes ;
122+ size_t trail_iterator = len - trail_bytes ;
138123 while (trail_bytes -- ) {
139- ((uint8_t * )msg -> buffer )[trail_iterator ++ ] = (uint8_t )(data_trail & 0xFFU );
124+ ((uint8_t * )buffer )[trail_iterator ++ ] = (uint8_t )(data_trail & 0xFFU );
140125 data_trail >>= 8 ;
141126 }
142127 }
@@ -183,7 +168,7 @@ int32_t mbox_k3_sec_proxy_read(uint8_t thread_id, mbox_k3_sec_proxy_msg* msg)
183168 * | end offset (trigger) | +------------------------------------+
184169 * +-------------------------+
185170 */
186- int32_t mbox_k3_sec_proxy_write (uint8_t thread_id , mbox_k3_sec_proxy_msg * msg )
171+ int32_t mbox_k3_sec_proxy_write (uint8_t thread_id , void * buffer , size_t len )
187172{
188173 /* verify thread status */
189174 int32_t write_status = mbox_k3_sec_proxy_verify_thread (thread_id , MSG_DRXN_WRITE );
@@ -193,7 +178,7 @@ int32_t mbox_k3_sec_proxy_write(uint8_t thread_id, mbox_k3_sec_proxy_msg* msg)
193178 }
194179
195180 /* msg len check */
196- if (msg -> len > sec_proxy_desc .thread_inst .max_msg_size ) {
181+ if (len > sec_proxy_desc .thread_inst .max_msg_size ) {
197182 ERROR ("secure_proxy_thread_%d msg len exceeds limit" , thread_id );
198183 return STATUS_CODE_INVALID_MSG_LEN ;
199184 }
@@ -204,20 +189,19 @@ int32_t mbox_k3_sec_proxy_write(uint8_t thread_id, mbox_k3_sec_proxy_msg* msg)
204189
205190 /* write whole words first */
206191 uint32_t word_iterator ;
207- size_t num_words = msg -> len / sizeof (uint32_t );
192+ size_t num_words = len / sizeof (uint32_t );
208193 for (word_iterator = 0 ; word_iterator < num_words ; word_iterator ++ ) {
209- write_reg (data_reg , word_iterator * sizeof (uint32_t ),
210- ((uint32_t * )msg -> buffer )[word_iterator ]);
194+ write_reg (data_reg , word_iterator * sizeof (uint32_t ), ((uint32_t * )buffer )[word_iterator ]);
211195 }
212196
213197 /* write remaining bytes */
214- uint32_t trail_bytes = msg -> len % sizeof (uint32_t );
198+ uint32_t trail_bytes = len % sizeof (uint32_t );
215199 if (0 != trail_bytes ) {
216200 uint32_t data_trail = 0 ;
217201
218- size_t trail_iterator = msg -> len - trail_bytes ;
202+ size_t trail_iterator = len - trail_bytes ;
219203 for (uint32_t i = 0 ; i < trail_bytes ; i ++ ) {
220- data_trail |= (uint32_t )((uint8_t * )msg -> buffer )[trail_iterator ++ ] << (i * 8 );
204+ data_trail |= (uint32_t )((uint8_t * )buffer )[trail_iterator ++ ] << (i * 8 );
221205 }
222206
223207 write_reg (data_reg , word_iterator ++ * sizeof (uint32_t ), data_trail );
@@ -273,9 +257,6 @@ int32_t mbox_k3_sec_proxy_probe(uint8_t thread_id)
273257 sec_proxy_desc .thread_inst .scfg_base + MBOX_K3_SEC_PROXY_THREAD_OFFSET (thread_id );
274258 uint32_t config = read_reg (thread_scfg_base , MBOX_K3_SEC_PROXY_SCFG_THREAD_CTRL_OFFSET );
275259
276- paddr_t thread_rt_base =
277- sec_proxy_desc .thread_inst .rt_base + MBOX_K3_SEC_PROXY_THREAD_OFFSET (thread_id );
278-
279260 uint8_t hw_host = (config >> 8 ) & 0xFF ;
280261 uint8_t expected_host = sec_proxy_desc .sec_proxy_thread_desc [thread_id ].host_id ;
281262
@@ -287,19 +268,25 @@ int32_t mbox_k3_sec_proxy_probe(uint8_t thread_id)
287268 }
288269
289270 /* [step-2] verify if thread is clean */
290- int32_t probe_status = mbox_k3_sec_proxy_verify_thread (thread_id , MSG_DRXN_WRITE );
291- if (STATUS_CODE_NO_ERROR != probe_status ) {
292- INFO ("sec_proxy_thread_%d probe failed (error_id=%d)" , thread_id , probe_status );
293- return probe_status ;
294- }
271+ int32_t probe_status = mbox_k3_sec_proxy_verify_thread (thread_id ,
272+ sec_proxy_desc .sec_proxy_thread_desc [thread_id ].msg_drxn );
295273
296- if (0 !=
297- (read_reg (thread_rt_base , MBOX_K3_SEC_PROXY_RT_THREAD_STATUS_OFFSET ) &
298- MBOX_K3_SEC_PROXY_RT_STATUS_CUR_CNT_MASK )) {
274+ if (MSG_DRXN_READ == sec_proxy_desc .sec_proxy_thread_desc [thread_id ].msg_drxn &&
275+ STATUS_CODE_NO_ERROR == probe_status ) {
299276 ERROR ("secure_proxy_thread_%d probe failed (message queue not clean)" , thread_id );
300277 return STATUS_CODE_DIRTY_HANDOFF ;
301278 }
302279
280+ if (MSG_DRXN_READ == sec_proxy_desc .sec_proxy_thread_desc [thread_id ].msg_drxn &&
281+ STATUS_CODE_NO_DATA == probe_status ) {
282+ probe_status = STATUS_CODE_NO_ERROR ;
283+ }
284+
285+ if (STATUS_CODE_NO_ERROR != probe_status ) {
286+ INFO ("sec_proxy_thread_%d probe failed (error_id=%d)" , thread_id , probe_status );
287+ return probe_status ;
288+ }
289+
303290 /* [step-3] check pipeline health by pinging sysfw
304291 *
305292 * @notes
0 commit comments