linux/drivers/staging/csr/csr_msgconv.h
<<
>>
Prefs
   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
  18typedef size_t (CsrMsgSizeofFunc)(void *msg);
  19typedef u8 *(CsrMsgSerializeFunc)(u8 *buffer, size_t *length, void *msg);
  20typedef void (CsrMsgFreeFunc)(void *msg);
  21typedef void *(CsrMsgDeserializeFunc)(u8 *buffer, size_t length);
  22
  23/* Converter entry for one message type */
  24typedef struct CsrMsgConvMsgEntry
  25{
  26    u16              msgType;
  27    CsrMsgSizeofFunc      *sizeofFunc;
  28    CsrMsgSerializeFunc   *serFunc;
  29    CsrMsgDeserializeFunc *deserFunc;
  30    CsrMsgFreeFunc        *freeFunc;
  31} CsrMsgConvMsgEntry;
  32
  33/* Optional lookup function */
  34typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, u16 msgType);
  35
  36/* All converter entries for one specific primitive */
  37typedef struct CsrMsgConvPrimEntry
  38{
  39    u16                   primType;
  40    const CsrMsgConvMsgEntry   *conv;
  41    CsrMsgCustomLookupFunc     *lookupFunc;
  42    struct CsrMsgConvPrimEntry *next;
  43} CsrMsgConvPrimEntry;
  44
  45typedef struct
  46{
  47    CsrMsgConvPrimEntry *profile_converters;
  48    void *(*deserialize_data)(u16 primType, size_t length, u8 * data);
  49    u8 (*free_message)(u16 primType, u8 *data);
  50    size_t (*sizeof_message)(u16 primType, void *msg);
  51    u8 *(*serialize_message)(u16 primType, void *msg,
  52                                   size_t * length,
  53                                   u8 * buffer);
  54} CsrMsgConvEntry;
  55
  56size_t CsrMsgConvSizeof(u16 primType, void *msg);
  57u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg);
  58void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc);
  59void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce);
  60CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType);
  61CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType);
  62CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg);
  63CsrMsgConvEntry *CsrMsgConvInit(void);
  64
  65/* Prototypes for primitive type serializers */
  66void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value);
  67void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value);
  68void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value);
  69void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length);
  70void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value);
  71
  72void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset);
  73void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset);
  74void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset);
  75void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length);
  76void CsrCharStringDes(char **value, u8 *buffer, size_t *offset);
  77
  78#endif
  79