Root/drivers/staging/csr/csr_msgconv.h

1#ifndef CSR_MSGCONV_H__
2#define CSR_MSGCONV_H__
3
4/*****************************************************************************
5
6            (c) Cambridge Silicon Radio Limited 2010
7            All rights reserved and confidential information of CSR
8
9            Refer to LICENSE.txt included with this source for details
10            on the license terms.
11
12*****************************************************************************/
13
14#include <linux/types.h>
15#include "csr_prim_defs.h"
16#include "csr_sched.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22typedef size_t (CsrMsgSizeofFunc)(void *msg);
23typedef u8 *(CsrMsgSerializeFunc)(u8 *buffer, size_t *length, void *msg);
24typedef void (CsrMsgFreeFunc)(void *msg);
25typedef void *(CsrMsgDeserializeFunc)(u8 *buffer, size_t length);
26
27/* Converter entry for one message type */
28typedef struct CsrMsgConvMsgEntry
29{
30    u16 msgType;
31    CsrMsgSizeofFunc *sizeofFunc;
32    CsrMsgSerializeFunc *serFunc;
33    CsrMsgDeserializeFunc *deserFunc;
34    CsrMsgFreeFunc *freeFunc;
35} CsrMsgConvMsgEntry;
36
37/* Optional lookup function */
38typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, u16 msgType);
39
40/* All converter entries for one specific primitive */
41typedef struct CsrMsgConvPrimEntry
42{
43    u16 primType;
44    const CsrMsgConvMsgEntry *conv;
45    CsrMsgCustomLookupFunc *lookupFunc;
46    struct CsrMsgConvPrimEntry *next;
47} CsrMsgConvPrimEntry;
48
49typedef struct
50{
51    CsrMsgConvPrimEntry *profile_converters;
52    void *(*deserialize_data)(u16 primType, size_t length, u8 * data);
53    u8 (*free_message)(u16 primType, u8 *data);
54    size_t (*sizeof_message)(u16 primType, void *msg);
55    u8 *(*serialize_message)(u16 primType, void *msg,
56                                   size_t * length,
57                                   u8 * buffer);
58} CsrMsgConvEntry;
59
60size_t CsrMsgConvSizeof(u16 primType, void *msg);
61u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg);
62void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc);
63void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce);
64CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType);
65CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType);
66CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg);
67CsrMsgConvEntry *CsrMsgConvInit(void);
68
69/* Prototypes for primitive type serializers */
70void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value);
71void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value);
72void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value);
73void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length);
74void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value);
75
76void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset);
77void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset);
78void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset);
79void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length);
80void CsrCharStringDes(char **value, u8 *buffer, size_t *offset);
81
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif
88

Archive Download this file



interactive