summaryrefslogtreecommitdiff
path: root/cesar/hle/hle.h
blob: 1aaeeb39d65b0be86ca44d48bc3ad516e117573f (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#ifndef HLE_H_
#define HLE_H_

/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hle.h
 * \brief   Public functions
 * \ingroup hle
 *
 * High Entity Layer to receive Ethernet packets to the STA and provide data
 * from the STA.
 */

#include "hal/hle/ipmbox.h"
#include "hal/hle/defs.h"
#include "cl/cl.h"


/**
 * Provide a Interface buffer to the interface.
 *
 * \param  user_data  the interface user data.
 * \param  buffer  the buffer.
 */
typedef void (*hle_interface_buffer_add_cb_t) (void *user_data, u8 *buffer);

/** forward declaration */
typedef struct hle_t hle_t;

/** 
 * Initialise the interface to add an Interface buffer.
 *
 * \param  ctx  the hle context.
 * \param  cb  the function to call on interface buffer reception.
 * \param  user_data  the user_data to provide on function call.
 */
void
hle_init_interface_buffer_add_cb (hle_t *ctx, hle_interface_buffer_add_cb_t
                                  cb, void *user_data);

/**
 * Initialize the HLE.
 * 
 * \param  cl  the convergence layer context.
 * \return  the hle context
 */
hle_t *hle_init (cl_t *cl);

/**
 * Unitialize the HLE.
 * 
 * \param  hle  the hle context.
 */
void hle_uninit (hle_t *hle);

/**
 * Send a data to the Convergence Layer to be sent over the PWL.
 * 
 * \param  hle  the hle context.
 * \param  buffer  the buffer containing the data to send.
 * \param  length  the data length
 */
void hle_data_send (hle_t *hle, u8 *buffer, uint length);

/**
 * Called by the Convergence layer when the data has been sent to the PWL.
 * This allows the HLE to know which buffer is newly available to be used or
 * give it back to the ARM. (the buffer is borrowed by the linux).
 * 
 * \param  hle  the hle context.
 * \param  buffer the buffer used to send the data.
 */
void hle_data_send_done (hle_t *hle, u8 *buffer);

/**
 * Receives a data from the Convergence layer.
 * 
 * \param  hle  the hle context.
 * \param  buffer  the buffer used to receive the data
 * \param  length  the length of the data received.
 */
void hle_data_recv (hle_t *hle, u8 *buffer, uint length);

/**
 * Provides a buffer to the CL in order to receive new MMEs from the CP.
 * 
 * \param  hle  the hle context.
 * \param  buffer  the buffer to provide to the CL.
 */
void hle_data_buffer_add (hle_t *hle, u8 *buffer);

/**
 * Send a MME to the Convergence Layer to be provide to the CP.
 * 
 * \param  hle  the hle context.
 * \param  buffer  the buffer containing the data to send.
 * \param  length  the data length
 */
void hle_mme_send (hle_t *hle, u8 *buffer, uint length);

/**
 * Called by the Convergence layer when the data has been sent to the CP.
 * This allows the HLE to know which buffer is newly available to be used or
 * give it back to the ARM. (the buffer is borrowed by the linux).
 * 
 * \param  hle  the hle context.
 * \param  buffer the buffer used to send the data.
 */
void hle_mme_send_done (hle_t *hle, u8 *buffer);

/**
 * Receives a data from the Convergence layer.
 * 
 * \param  hle  the hle context.
 * \param  buffer  the buffer used to receive the data
 * \param  length  the length of the data received.
 */
void hle_mme_recv (hle_t *hle, u8 *buffer, uint length);

/**
 * Provides a buffer to the CL in order to receive new MMEs from the CP.
 * 
 * \param  hle  the hle context.
 * \param  buffer  the buffer to provide to the CL.
 */
void hle_mme_buffer_add (hle_t *hle, u8 *buffer);

/**
 * Activate the HLE to receive messages from the IPMbox.
 *
 * \param  ctx the HLE context.
 * \param  active  boolean to active or unactive the reception of messages.
 */
void
hle_activate (hle_t *ctx, bool active);

/**
 * Receives a message from the Linux.
 * 
 * \param  ctx  the hle context.
 * \param  msg_buffer  the pointer of the buffer containing the messages to read
 * \param  length  the length of the messages in words.
 */
bool
hle_ipmbox_recv (hle_t *ctx, u32 *msg_buffer, uint length);

/** 
 * Send a packet to the ipmbox.
 *
 * \param  ctx  the hle context.
 * \param  msg  the message address to post the message in the ipmbox.
 * \param  length  the length of the message in words.
 */
void
hle_ipmbox_send (hle_t *ctx, u32 *msg, uint length);

#endif /*HLE_H_*/