#ifndef hal_h #define hal_h /* Cleopatre project {{{ * * Copyright (C) 2008 Spidcom * * <<>> * * }}} */ /** * \file hal.h * \brief interfaces for mailbox layer * \ingroup Cleopatre - PlcDrv * * this file content interfaces and exported macros, variables... For the * Hardware Abstraction Layer */ #ifdef __UTESTS__ #include "hal_utests.h" #endif #define A2L_RING_MASK (A2L_RING_SIZE-1) #define L2A_RING_MASK (L2A_RING_SIZE-1) /** hal layer context structure */ struct halctx { uint32_t *A2L_ptr; uint32_t *L2A_ptr; const uint32_t *A2L_head; uint32_t *A2L_tail; uint32_t *L2A_head; const uint32_t *L2A_tail; uint32_t *A2L_it; uint32_t *L2A_it; uint32_t *L2A_it_mask; uint32_t (*virt_to_phys)(uint32_t); uint32_t (*phys_to_virt)(uint32_t); }; /** * Initialize the hal layer * * \param init user information. * \return hal context. */ struct halctx* halmbx_init(struct init_info *info); /** * UnInitialize the hal layer * * \param ctx hal context. */ void halmbx_uninit(struct halctx *ctx); /** * Check if Leon to Arm mailbox queue is empty. * * \return 0 if the queue is empty. */ int halmbx_L2Amail_not_empty_queue(void); /** * Check Arm to Leon mailbox queue status. * * \return queue state. */ int halmbx_A2Lmail_status_queue(void); /** * Check Leon to Arm mailbox queue status. * * \return queue state. */ int halmbx_L2Amail_status_queue(void); /** * Copy message to the ring buffer. * * \param message pointer to the message align on 32bits. * \param size message size in bytes and align on 32bits. * \return error code. */ int halmbx_copy_to_ring (uint32_t *message, int size); /** * Copy message from the ring buffer. * * \param message pointer to the message align on 32bits. * \param size max message size in bytes and align on 32bits. * \return error code. */ int halmbx_copy_from_ring (uint32_t *message, int size); /** * Update the ring management for Leon to Arm mailbox (TX). * * \param size real size of the last proceed message. * \return error code. */ int halmbx_A2Lmail_update (int size); /** * Update the ring management for Arm to Leon mailbox (RX). * * \param size real size of the last proceed message. * \return error code. */ int halmbx_L2Amail_update (int size); /** * Enable the Leon to Arm Trigger Interrupt. */ void L2At_it_enable(void); /** * Disable the Arm to Leon Acknowledge Interrupt. */ void A2La_it_disable(void); /** * Disable the Leon to Arm Trigger Interrupt. */ void L2At_it_disable(void); /** * Set the Arm to Leon Interrupt. */ void set_A2Lt_interrupt(void); /** * Set the Arm to Leon acknowledge Interrupt. */ void set_L2Aa_interrupt(void); /** * Clear the Leon to Arm Interrupt. */ void clr_L2At_interrupt(void); /** * Clear the Leon to Arm acknowledge Interrupt. */ void clr_A2La_interrupt(void); #endif /* hal_h */