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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
/*******************************************************************************
* Copyright (C) ST-Ericsson SA 2011
* License terms: 3-clause BSD license
******************************************************************************/
#ifndef _R_BULK_PROTOCOL_H_
#define _R_BULK_PROTOCOL_H_
/**
* @addtogroup ldr_communication_serv
* @{
* @addtogroup r15_family
* @{
* @addtogroup bulk_protocol Bulk Protocol
* Functionalities for handling bulk protocol. Receiving/Sending bulk
* commands and state machines for receiving and sending bulk data chunks.
*
* @{
*/
/*******************************************************************************
* Includes
******************************************************************************/
#include "c_system_v2.h"
#include "t_bulk_protocol.h"
#include "t_r15_transport_layer.h"
#include "t_r15_network_layer.h"
#include "error_codes.h"
#include "r_communication_service.h"
#ifdef CFG_ENABLE_LOADER_TYPE
#include "t_security_algorithms.h"
#endif
#if (defined(WIN32) || defined(__CYGWIN__))
#ifdef LCM_EXPORTS
#define LCM_API __declspec(dllexport) // export DLL information
#else //LCM_EXPORTS
#define LCM_API __declspec(dllimport) // import DLL information
#endif // LCM_EXPORTS
#elif (defined(__linux__) || defined(__APPLE__))
#ifdef LCM_EXPORTS
#define LCM_API __attribute__((visibility("default")))
#else //LCM_EXPORTS
#define LCM_API
#endif // LCM_EXPORTS
#elif defined(CFG_ENABLE_LOADER_TYPE)
#define LCM_API
#endif //#ifdef CFG_ENABLE_LOADER_TYPE
/*******************************************************************************
* Declaration of functions
******************************************************************************/
/**
* State machine for bulk transfer from ME to PC.
*
* @param [in] Communication_p Communication module context.
* @param [in] BulkVector_p Pointer to the received buffer.
*
* @retval E_SUCCESS After successful execution.
* @retval E_INVALID_INPUT_PARAMETERS If Packet_p is NULL.
*/
ErrorCode_e R15_Bulk_Process_Write(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p);
/**
* Decoding received bulk command.
*
* @param [in] Communication_p Communication module context.
* @param [in] Packet_p Pointer to the received buffer.
*
* @retval E_SUCCESS After successful execution.
* @retval E_INVALID_INPUT_PARAMETERS If Packet_p is NULL.
*/
ErrorCode_e R15_Bulk_Process(Communication_t *Communication_p, PacketMeta_t *Packet_p);
#ifdef CFG_ENABLE_LOADER_TYPE
/**
* Generate bulk Session ID. Allowed bulk session ID is from 1 to 65535.
*
* @param [in] Communication_p Communication module context.
*
* @retval Session ID Next free session ID.
*/
uint16 Do_R15_Bulk_GenerateBulkSessionID(Communication_t *Communication_p);
#endif //#ifdef CFG_ENABLE_LOADER_TYPE
#ifdef __cplusplus
extern "C"
{
#endif // #ifdef __cplusplus
/**
* Opens Bulk session.
*
* @param [in] Communication_p Communication module context.
* @param [in] SessionId Session ID.
* @param [in] Mode Type of operation(Read or Write).
* (send or receive) over the bulk protocol.
*
* @return Vector ID Vector ID of the newly opened session.
* @retval BULK_ERROR If the session can not be opened.
*/
LCM_API uint32 Do_R15_Bulk_OpenSession(const Communication_t *const Communication_p, const uint16 SessionId, const TL_SessionMode_t Mode);
/**
* Creates Bulk Vector.
*
* @param [in] Communication_p Communication module context.
* @param [in] BulkVector Index of Bulk Vector.
* @param [in] Length Data Length in bytes.
* @param [in] BuffSize Requested size of each Buffer.
* @param [in] CreatedBulkVector_p Already created bulk vector which
* need to be updated with correct
* information.
*
* @return Vector ID The ID of the Vector that has been created.
* @retval BULK_ERROR If creation of vector failed.
*/
LCM_API TL_BulkVectorList_t *Do_R15_Bulk_CreateVector(const Communication_t *const Communication_p, const uint32 BulkVector, uint32 Length, const uint32 BuffSize, TL_BulkVectorList_t *CreatedBulkVector_p);
/**
* Frees Bulk Vector.
*
* @param [in] Communication_p Communication module context.
* @param [in] BulkVector_p Pointer to the Bulk Vector.
* @param [in] ReqReleaseBuffer Defines if complete buffers with metadata will
* be released or only only the metadata will be cleared.
*
* @retval E_SUCCESS After successful execution.
* @retval BULK_ERROR Error while destroying vector.
*/
LCM_API uint32 Do_R15_Bulk_DestroyVector(const Communication_t *const Communication_p, TL_BulkVectorList_t *BulkVector_p, boolean ReqReleaseBuffer);
/**
* Start specified bulk session.
*
* @param [in] Communication_p Communication module context.
* @param [in] BulkVector_p Pointer to the Bulk Vector.
* @param [in] Offset Sets the offset from where data
* read/write should be performed.
*
* @retval E_INVALID_BULK_MODE Invalid bulk mode.
* @retval E_FAILED_TO_START_BULK_SESSION Either the session is
* invalid or the BulkVector is invalid.
* @retval E_SUCCESS After successful execution.
*/
LCM_API ErrorCode_e Do_R15_Bulk_StartSession(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p, const uint64 Offset);
/**
* Get status of bulk transfer.
*
* @param [in] BulkVector_p Pointer to the Bulk Vector.
*
* @retval BULK_SESSION_IDLE Idle state of bulk protocol.
* @retval BULK_SESSION_OPEN Opened bulk protocol and ready for
* transmitting.
* @retval BULK_SESSION_PROCESSING Processing bulk transfer.
* @retval BULK_SESSION_FINISHED Bulk transfer finished.
*/
LCM_API TL_BulkSessionState_t Do_R15_Bulk_GetStatusSession(const TL_BulkVectorList_t *BulkVector_p);
/**
* Close specified Bulk session.
*
* @param [in] Communication_p Communication module context.
* @param [in] BulkVector_p Pointer to the Bulk Vector.
* for the session you want to close.
*
* @retval E_SUCCESS After successful execution.
* @retval E_FAILED_TO_CLOSE_BULK_SESSION If the BulkVector is not valid.
*/
LCM_API ErrorCode_e Do_R15_Bulk_CloseSession(Communication_t *Communication_p, TL_BulkVectorList_t *BulkVector_p);
#ifndef CFG_ENABLE_LOADER_TYPE
/**
* Sets pointers to callback functions regarding the bulk transfer.
*
* @param [in] Communication_p Communication module context.
* @param [in] BulkCommandCallback_p Pointer to the callback function
for handling a received command.
* @param [in] BulkDataCallback_p Pointer to the callback function
for handling a received data.
* @param [in] EndOfDump_p Pointer to the callback function
for handling a finished bulk transfer.
*/
LCM_API void Do_R15_Bulk_SetCallbacks(Communication_t *Communication_p, void *BulkCommandCallback_p, void *BulkDataCallback_p, void *EndOfDump_p);
LCM_API void Do_R15_Bulk_SetBuffersRelease(Communication_t *Communication_p, void *BulkBufferRelease_p);
#endif
#ifdef __cplusplus
};
#endif // #ifdef __cplusplus
/** @} */
/** @} */
/** @} */
#endif /* _R_BULK_PROTOCOL_H_*/
|