summaryrefslogtreecommitdiff
path: root/cesar/hal/ipmbox/ipmbox.h
blob: 509a3e1a15ac397ba29d497c6a10a983ea56365d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef hal_ipmbox_ipmbox_h
#define hal_ipmbox_ipmbox_h
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal/ipmbox/ipmbox.h
 * \brief   HAL IPMbox public interface.
 * \ingroup hal_ipmbox
 */
#include "common/ipmbox/queue.h"

/* Context forward declaration. */
typedef struct ipmbox_t ipmbox_t;

/**
 * RX DSR callback function.
 * \param  user_data  user data
 * \param  first_msg  pointer to the first received message header
 * \param  length  total length (in word) of received messages
 */
typedef void (*ipmbox_rx_cb_t) (void *user_data, u32 *first_msg, uint length);

/**
 * Empty buf DSR callback function.
 * \param  user_data  user data
 */
typedef void (*ipmbox_empty_buf_cb_t) (void *user_data);

BEGIN_DECLS

/**
 * Initialise the HAL HLE.
 * \return  the newly created context
 */
ipmbox_t *
ipmbox_init (void);

/**
 * Uninitialise the HAL HLE.
 * \param  ctx  ipmbox context
 */
void
ipmbox_uninit (ipmbox_t *ctx);

/**
 * Activate ipmbox interruptions.
 * \param  ctx  ipmbox context
 * \param  activation  indicates if interruptions are activated or deactivated
 */
void
ipmbox_activate (ipmbox_t *ctx, bool activation);

/**
 * Register callbacks for DATA queue.
 * \param  ctx  ipmbox context
 * \param  user_data  the user_data
 * \param  rx_cb_data  callback to handle DATA.
 */
void
ipmbox_register_rx_data_cb (ipmbox_t *ctx, void *data_user_data,
                            ipmbox_rx_cb_t rx_cb_data);

/**
 * Register callbacks for MBX queue.
 * \param  ctx  ipmbox context
 * \param  user_data  the user_data
 * \param  rx_cb_mbx  callback to handle MBox.
 */
void
ipmbox_register_rx_mbx_cb (ipmbox_t *ctx, void *data_user_data,
                           ipmbox_rx_cb_t rx_cb_mbx);

/**
 * Register callbacks for empty buf queue.
 * \param  ctx  ipmbox context
 * \param  user_data  the user_data
 * \param  rx_cb_empty_buf  callback to handle empty buffers.
 */
void
ipmbox_register_empty_buf_cb (ipmbox_t *ctx, void *data_user_data,
                              ipmbox_empty_buf_cb_t empty_buf_cb);

/** Transmit a message to DATA queue.
 * \param  ctx  ipmbox context
 * \param  first_msg  pointer to the first message header
 * \param  length  total length (in word) of messages to transmit
 */
void
ipmbox_tx_data (ipmbox_t *ctx, u32 *first_msg, uint length);

/** Transmit a message to EMPTY_BUF queue.
 * \param  ctx  ipmbox context
 * \param  first_msg  pointer to the first message header
 * \param  length  total length (in word) of messages to transmit
 */
void
ipmbox_tx_empty_buf (ipmbox_t *ctx, u32 *first_msg, uint length);

/** Transmit a message to MBX queue.
 * \param  ctx  ipmbox context
 * \param  first_msg  pointer to the first message header
 * \param  length  total length (in word) of messages to transmit
 */
void
ipmbox_tx_mbx (ipmbox_t *ctx, u32 *first_msg, uint length);

/**
 * Get nb empty buffers from the empty buf queue.
 * \param  ctx  ipmbox context
 * \param  msg_buf  destination array for the messages
 * \param  nb  number of elements of msg_buf.
 * \return  number of copied element in msg_buf.
 */
uint
ipmbox_empty_buf_get (ipmbox_t *ctx, u32 *msg_buf, uint nb);

/**
 * Receive message from mailbox, interrupts locked.
 * \param  ctx  ipmbox context
 * \param  first_msg  pointer to store first received message address
 * \return  total length (in word) of received messages
 */
uint
ipmbox_rx_sync (ipmbox_t *ctx, const u32 **first_msg);

END_DECLS

#endif /* hal_ipmbox_ipmbox_h */