pkarashchenko commented on code in PR #6304: URL: https://github.com/apache/incubator-nuttx/pull/6304#discussion_r878087167
########## arch/risc-v/src/mpfs/mpfs_ihc.c: ########## @@ -367,6 +440,50 @@ static void mpfs_ihc_rx_handler(uint32_t *message, bool is_ack) } } +/**************************************************************************** + * Name: mpfs_ihc_message_present_handler + * + * Description: + * This function fills up a structure that gets into the remote end, such + * as Linux kernel. The structure may contain data from the + * MPFS_IHC_MSG_IN -register, or in case of an ack, just the irq_type. + * + * Input Parameters: + * message - Pointer for storing data, must not be NULL + * mhartid - The primary hart id of a set of hartids. Not necessarily + * the absolute mhartid if multiple harts are incorporated + * within the remote (eg. Linux kernel used on 2 harts). + * rhartid - Remote hart id + * is_ack - Boolean indicating an ack message + * + * Returned Value: + * None + * + ****************************************************************************/ + +static void mpfs_ihc_message_present_handler(uint32_t *message, + uint32_t mhartid, + uint32_t rhartid, + bool is_ack) +{ + struct ihc_sbi_rx_msg msg; + uintptr_t message_ihc = (uintptr_t)MPFS_IHC_MSG_IN(mhartid, rhartid); + uint32_t message_size_ihc = getreg32(MPFS_IHC_MSG_SIZE(mhartid, rhartid)); + + if (is_ack) + { + msg.irq_type = ACK_IRQ; + } + else + { + msg.irq_type = MP_IRQ; + DEBUGASSERT(sizeof(msg.ihc_msg) >= message_size_ihc); + memcpy(&msg.ihc_msg, (void *)message_ihc, message_size_ihc); + } + + memcpy(message, &msg, sizeof(struct ihc_sbi_rx_msg)); Review Comment: If `message` already a 32bit aligned pointer, then maybe it just can be casted to `struct ihc_sbi_rx_msg *` and `memcpy`s can be removed? What do you think? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org