Commit 635d2b00 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Staging: add CSR wifi module

This consists of two modules, the driver, and a "helper" module that is
just a wrapper around common kernel functions.  The wrapper module will
be removed soon, but for now it's needed.

These files were based on the csr-linux-wifi-5.0.3-oss.tar.gz package
provided by CSR and Blue Giga, and is covered under the license
specified in the LICENSE.txt file (basically dual BSD and GPLv2).  The
files were flattened out of the deep directory mess they were originally
in, and a few EXPORT_SYMBOL_GPL() were added in order for everything to
link properly with the helper module setup.

Cc: Mikko Virkkilä <mikko.virkkila@bluegiga.com>
Cc: Lauri Hintsala <Lauri.Hintsala@bluegiga.com>
Cc: Riku Mettälä <riku.mettala@bluegiga.com>
Cc: Veli-Pekka Peltola <veli-pekka.peltola@bluegiga.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 15a4bc17
config CSR_WIFI config CSR_WIFI
tristate "CSR wireless driver" tristate "CSR wireless driver"
depends on PCI depends on PCI && MMC
help help
Driver for the CSR wireless SDIO device. Driver for the CSR wireless SDIO device.
......
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Except as contained in this notice, the names of above-listed
copyright holders and the names of any contributors shall not be used
in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Alternatively, this software may be distributed under the terms of the
GNU General Public License ("GPL") version 2 as published
by the Free Software Foundation.
As a special exception, if other files instantiate templates or use
macros or inline functions from this file, or you compile this file
and link it with other works to produce a work based on this file,
this file does not by itself cause the resulting work to be covered by
the GNU General Public License. However the source code for this file
must still be made available in accordance with section (3) of the GNU
General Public License.
This exception does not invalidate any other reasons why a work based
on this file might be covered by the GNU General Public License.
obj-$(CONFIG_CSR_WIFI) += oska/ obj-$(CONFIG_CSR_WIFI) += oska/
ccflags-y := -DCSR_SME_USERSPACE -DCSR_SUPPORT_SME -DREMOTE_SYS_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DENABLE_SHUTDOWN
obj-$(CONFIG_CSR_WIFI) += csr_wifi.o
obj-$(CONFIG_CSR_WIFI) += csr_helper.o
csr_wifi-y := bh.o \
data_tx.o \
drv.o \
firmware.o \
indications.o \
inet.o \
init_hw.o \
io.o \
monitor.o \
netdev.o \
os.o \
putest.o \
sdio_events.o \
sdio_mmc.o \
sdio_stubs.o \
sme_blocking.o \
ul_int.o \
unifi_dbg.o \
unifi_event.o \
unifi_pdu_processing.o \
unifi_sme.o \
csr_formatted_io.o \
csr_wifi_hip_card_sdio.o \
csr_wifi_hip_card_sdio_intr.o \
csr_wifi_hip_card_sdio_mem.o \
csr_wifi_hip_chiphelper.o \
csr_wifi_hip_download.o \
csr_wifi_hip_dump.o \
csr_wifi_hip_packing.o \
csr_wifi_hip_send.o \
csr_wifi_hip_signals.o \
csr_wifi_hip_ta_sampling.o \
csr_wifi_hip_udi.o \
csr_wifi_hip_unifi_signal_names.o \
csr_wifi_hip_xbv.o \
csr_wifi_router_ctrl_sef.o \
csr_wifi_router_sef.o \
csr_wifi_router_transport.o \
csr_wifi_sme_sef.o \
csr_wifi_sme_converter_init.o \
csr_wifi_sme_free_downstream_contents.o \
csr_wifi_sme_free_upstream_contents.o \
csr_wifi_sme_serialize.o \
csr_wifi_router_ctrl_converter_init.o \
csr_wifi_router_ctrl_free_downstream_contents.o \
csr_wifi_router_ctrl_free_upstream_contents.o \
csr_wifi_router_ctrl_serialize.o \
csr_wifi_router_converter_init.o \
csr_wifi_router_free_downstream_contents.o \
csr_wifi_router_free_upstream_contents.o \
csr_wifi_router_serialize.o \
sme_mgt.o \
sme_sys.o \
sme_userspace.o
csr_helper-y := csr_time.o \
csr_util.o \
csr_framework_ext.o \
csr_pmem.o \
csr_wifi_serialize_primitive_types.o \
csr_serialize_primitive_types.o \
csr_utf16.o \
csr_msgconv.o \
csr_panic.o
This diff is collapsed.
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#include "csr_formatted_io.h"
#include "csr_util.h"
CsrInt32 CsrSnprintf(CsrCharString *dest, CsrSize n, const CsrCharString *fmt, ...)
{
CsrInt32 r;
va_list args;
va_start(args, fmt);
r = CsrVsnprintf(dest, n, fmt, args);
va_end(args);
if (dest && (n > 0))
{
dest[n - 1] = '\0';
}
return r;
}
#ifndef CSR_FORMATTED_IO_H__
#define CSR_FORMATTED_IO_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "csr_types.h"
CsrInt32 CsrSnprintf(CsrCharString *dest, CsrSize n, const CsrCharString *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/kthread.h>
#include <linux/module.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
#include <linux/slab.h>
#endif
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19)
#include <linux/freezer.h>
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
#include <asm/semaphore.h>
#else
#include <linux/semaphore.h>
#endif
#include <linux/bitops.h>
#include "csr_types.h"
#include "csr_framework_ext.h"
#include "csr_panic.h"
/*----------------------------------------------------------------------------*
* NAME
* CsrMutexCreate
*
* DESCRIPTION
* Create a mutex and return a handle to the created mutex.
*
* RETURNS
* Possible values:
* CSR_RESULT_SUCCESS in case of success
* CSR_FE_RESULT_NO_MORE_MUTEXES in case of out of mutex resources
* CSR_FE_RESULT_INVALID_POINTER in case the mutexHandle pointer is invalid
*
*----------------------------------------------------------------------------*/
CsrResult CsrMutexCreate(CsrMutexHandle *mutexHandle)
{
if (mutexHandle == NULL)
{
return CSR_FE_RESULT_INVALID_POINTER;
}
sema_init(mutexHandle, 1);
return CSR_RESULT_SUCCESS;
}
/*----------------------------------------------------------------------------*
* NAME
* CsrMutexDestroy
*
* DESCRIPTION
* Destroy the previously created mutex.
*
* RETURNS
* void
*
*----------------------------------------------------------------------------*/
void CsrMutexDestroy(CsrMutexHandle *mutexHandle)
{
}
/*----------------------------------------------------------------------------*
* NAME
* CsrMutexLock
*
* DESCRIPTION
* Lock the mutex refered to by the provided handle.
*
* RETURNS
* Possible values:
* CSR_RESULT_SUCCESS in case of success
* CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
*
*----------------------------------------------------------------------------*/
CsrResult CsrMutexLock(CsrMutexHandle *mutexHandle)
{
if (mutexHandle == NULL)
{
return CSR_FE_RESULT_INVALID_POINTER;
}
if (down_interruptible(mutexHandle))
{
CsrPanic(CSR_TECH_FW, CSR_PANIC_FW_UNEXPECTED_VALUE, "CsrMutexLock Failed");
return CSR_FE_RESULT_INVALID_POINTER;
}
return CSR_RESULT_SUCCESS;
}
/*----------------------------------------------------------------------------*
* NAME
* CsrMutexUnlock
*
* DESCRIPTION
* Unlock the mutex refered to by the provided handle.
*
* RETURNS
* Possible values:
* CSR_RESULT_SUCCESS in case of success
* CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
*
*----------------------------------------------------------------------------*/
CsrResult CsrMutexUnlock(CsrMutexHandle *mutexHandle)
{
if (mutexHandle == NULL)
{
return CSR_FE_RESULT_INVALID_POINTER;
}
up(mutexHandle);
return CSR_RESULT_SUCCESS;
}
/*----------------------------------------------------------------------------*
* NAME
* CsrThreadSleep
*
* DESCRIPTION
* Sleep for a given period.
*
* RETURNS
* void
*
*----------------------------------------------------------------------------*/
void CsrThreadSleep(CsrUint16 sleepTimeInMs)
{
unsigned long t;
/* Convert t in ms to jiffies and round up */
t = ((sleepTimeInMs * HZ) + 999) / 1000;
schedule_timeout_uninterruptible(t);
}
EXPORT_SYMBOL_GPL(CsrThreadSleep);
/*----------------------------------------------------------------------------*
* NAME
* CsrMemCalloc
*
* DESCRIPTION
* Allocate dynamic memory of a given size calculated as the
* numberOfElements times the elementSize.
*
* RETURNS
* Pointer to allocated memory, or NULL in case of failure.
* Allocated memory is zero initialised.
*
*----------------------------------------------------------------------------*/
void *CsrMemCalloc(CsrSize numberOfElements, CsrSize elementSize)
{
void *buf;
size_t size;
size = numberOfElements * elementSize;
buf = kmalloc(size, GFP_KERNEL);
if (buf != NULL)
{
memset(buf, 0, size);
}
return buf;
}
/*----------------------------------------------------------------------------*
* NAME
* CsrMemAlloc
*
* DESCRIPTION
* Allocate dynamic memory of a given size.
*
* RETURNS
* Pointer to allocated memory, or NULL in case of failure.
* Allocated memory is not initialised.
*
*----------------------------------------------------------------------------*/
void *CsrMemAlloc(CsrSize size)
{
return kmalloc(size, GFP_KERNEL);
}
EXPORT_SYMBOL_GPL(CsrMemAlloc);
/*----------------------------------------------------------------------------*
* NAME
* CsrMemFree
*
* DESCRIPTION
* Free dynamic allocated memory.
*
* RETURNS
* void
*
*----------------------------------------------------------------------------*/
void CsrMemFree(void *pointer)
{
kfree(pointer);
}
EXPORT_SYMBOL_GPL(CsrMemFree);
This diff is collapsed.
#ifndef CSR_FRAMEWORK_EXT_TYPES_H__
#define CSR_FRAMEWORK_EXT_TYPES_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#ifdef __KERNEL__
#include <linux/kthread.h>
#include <linux/semaphore.h>
#else
#include <pthread.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __KERNEL__
struct CsrThread
{
struct task_struct *thread_task;
char name[16];
};
struct CsrEvent
{
/* wait_queue for waking the kernel thread */
wait_queue_head_t wakeup_q;
unsigned int wakeup_flag;
};
typedef struct CsrEvent CsrEventHandle;
typedef struct semaphore CsrMutexHandle;
typedef struct CsrThread CsrThreadHandle;
#else /* __KERNEL __ */
struct CsrEvent
{
pthread_cond_t event;
pthread_mutex_t mutex;
CsrUint32 eventBits;
};
typedef struct CsrEvent CsrEventHandle;
typedef pthread_mutex_t CsrMutexHandle;
typedef pthread_t CsrThreadHandle;
#endif /* __KERNEL__ */
#ifdef __cplusplus
}
#endif
#endif
#ifndef CSR_LIB_H__
#define CSR_LIB_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#include "csr_prim_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
CsrPrim type;
} CsrEvent;
/*----------------------------------------------------------------------------*
* CsrEvent_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEvent
*
*----------------------------------------------------------------------------*/
CsrEvent *CsrEvent_struct(CsrUint16 primtype, CsrUint16 msgtype);
typedef struct
{
CsrPrim type;
CsrUint8 value;
} CsrEventCsrUint8;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint8_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint8
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint8 *CsrEventCsrUint8_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint8 value);
typedef struct
{
CsrPrim type;
CsrUint16 value;
} CsrEventCsrUint16;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint16_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint16
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint16 *CsrEventCsrUint16_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint16 value);
typedef struct
{
CsrPrim type;
CsrUint16 value1;
CsrUint8 value2;
} CsrEventCsrUint16CsrUint8;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint16CsrUint8_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint16CsrUint8
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint16CsrUint8 *CsrEventCsrUint16CsrUint8_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint16 value1, CsrUint8 value2);
typedef struct
{
CsrPrim type;
CsrUint16 value1;
CsrUint16 value2;
} CsrEventCsrUint16CsrUint16;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint16CsrUint16_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint16CsrUint16
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint16CsrUint16 *CsrEventCsrUint16CsrUint16_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint16 value1, CsrUint16 value2);
typedef struct
{
CsrPrim type;
CsrUint16 value1;
CsrUint32 value2;
} CsrEventCsrUint16CsrUint32;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint16_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint16
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint16CsrUint32 *CsrEventCsrUint16CsrUint32_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint16 value1, CsrUint32 value2);
typedef struct
{
CsrPrim type;
CsrUint16 value1;
CsrCharString *value2;
} CsrEventCsrUint16CsrCharString;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint16CsrCharString_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint16CsrCharString
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint16CsrCharString *CsrEventCsrUint16CsrCharString_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint16 value1, CsrCharString *value2);
typedef struct
{
CsrPrim type;
CsrUint32 value;
} CsrEventCsrUint32;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint32_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint32
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint32 *CsrEventCsrUint32_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint32 value);
typedef struct
{
CsrPrim type;
CsrUint32 value1;
CsrUint16 value2;
} CsrEventCsrUint32CsrUint16;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint32CsrUint16_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint32CsrUint16
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint32CsrUint16 *CsrEventCsrUint32CsrUint16_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint32 value1, CsrUint32 value2);
typedef struct
{
CsrPrim type;
CsrUint32 value1;
CsrCharString *value2;
} CsrEventCsrUint32CsrCharString;
/*----------------------------------------------------------------------------*
* CsrEventCsrUint32CsrCharString_struct
*
* DESCRIPTION
* Generic message creator.
* Allocates and fills in a message with the signature CsrEventCsrUint32CsrCharString
*
*----------------------------------------------------------------------------*/
CsrEventCsrUint32CsrCharString *CsrEventCsrUint32CsrCharString_struct(CsrUint16 primtype, CsrUint16 msgtype, CsrUint32 value1, CsrCharString *value2);
#ifdef __cplusplus
}
#endif
#endif /* CSR_LIB_H__ */
This diff is collapsed.
#ifndef CSR_LOG_CONFIGURE_H__
#define CSR_LOG_CONFIGURE_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#include "csr_log.h"
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------*/
/* Log init/deinit */
/*---------------------------------*/
void CsrLogInit(CsrUint8 size);
void CsrLogDeinit(void);
/*---------------------------------*/
/* Log Framework Tech info */
/*---------------------------------*/
void CsrLogTechInfoRegister(void);
/* Set the logging level for the environment outside the scheduler context */
void CsrLogLevelEnvironmentSet(CsrLogLevelEnvironment environmentLogLevel);
/* Set the logging level for all scheduler tasks */
/* This function call takes precedence over all previous calls to CsrLogLevelTaskSetSpecific() */
void CsrLogLevelTaskSetAll(CsrLogLevelTask tasksLogLevelMask);
/* Set the logging level for a given Task */
/* This function can be used as a complement to CsrLogLevelTaskSetAll() to add more _or_ less log from a given task than what is set
generally with CsrLogLevelTaskSetAll(). */
void CsrLogLevelTaskSetSpecific(CsrSchedQid taskId, CsrLogLevelTask taskLogLevelMask);
/*--------------------------------------------*/
/* Filtering on log text warning levels */
/*--------------------------------------------*/
typedef CsrUint32 CsrLogLevelText;
#define CSR_LOG_LEVEL_TEXT_OFF ((CsrLogLevelText) 0x0000)
#define CSR_LOG_LEVEL_TEXT_CRITICAL ((CsrLogLevelText) 0x0001)
#define CSR_LOG_LEVEL_TEXT_ERROR ((CsrLogLevelText) 0x0002)
#define CSR_LOG_LEVEL_TEXT_WARNING ((CsrLogLevelText) 0x0004)
#define CSR_LOG_LEVEL_TEXT_INFO ((CsrLogLevelText) 0x0008)
#define CSR_LOG_LEVEL_TEXT_DEBUG ((CsrLogLevelText) 0x0010)
#define CSR_LOG_LEVEL_TEXT_ALL ((CsrLogLevelText) 0xFFFF)
/* The log text interface is used by both scheduler tasks and components outside the scheduler context.
* Therefore a CsrLogTextTaskId is introduced. It is effectively considered as two CsrUint16's. The lower
* 16 bits corresponds one2one with the scheduler queueId's (CsrSchedQid) and as such these bits can not be used
* by components outside scheduler tasks. The upper 16 bits are allocated for use of components outside the
* scheduler like drivers etc. Components in this range is defined independently by each technology. To avoid
* clashes the technologies are only allowed to assign values within the same restrictive range as allies to
* primitive identifiers. eg. for the framework components outside the scheduler is only allowed to assign
* taskId's in the range 0x0600xxxx to 0x06FFxxxx. And so on for other technologies. */
typedef CsrUint32 CsrLogTextTaskId;
/* Set the text logging level for all Tasks */
/* This function call takes precedence over all previous calls to CsrLogLevelTextSetTask() and CsrLogLevelTextSetTaskSubOrigin() */
void CsrLogLevelTextSetAll(CsrLogLevelText warningLevelMask);
/* Set the text logging level for a given Task */
/* This function call takes precedence over all previous calls to CsrLogLevelTextSetTaskSubOrigin(), but it can be used as a complement to
* CsrLogLevelTextSetAll() to add more _or_ less log from a given task than what is set generally with CsrLogLevelTextSetAll(). */
void CsrLogLevelTextSetTask(CsrLogTextTaskId taskId, CsrLogLevelText warningLevelMask);
/* Set the text logging level for a given tasks subOrigin */
/* This function can be used as a complement to CsrLogLevelTextSetAll() and CsrLogLevelTextSetTask() to add more _or_ less log from a given
* subOrigin within a task than what is set generally with CsrLogLevelTextSetAll() _or_ CsrLogLevelTextSetTask(). */
void CsrLogLevelTextSetTaskSubOrigin(CsrLogTextTaskId taskId, CsrUint16 subOrigin, CsrLogLevelText warningLevelMask);
/*******************************************************************************
NAME
CsrLogLevelTextSet
DESCRIPTION
Set the text logging level for a given origin and optionally sub origin
by name. If either string is NULL or zero length, it is interpreted as
all origins and/or all sub origins respectively. If originName is NULL
or zero length, subOriginName is ignored.
Passing NULL or zero length strings in both originName and subOriginName
is equivalent to calling CsrLogLevelTextSetAll, and overrides all
previous filter configurations for all origins and sub origins.
Passing NULL or a zero length string in subOriginName overrides all
previous filter configurations for all sub origins of the specified
origin.
Note: the supplied strings may be accessed after the function returns
and must remain valid and constant until CsrLogDeinit is called.
Note: when specifying an origin (originName is not NULL and not zero
length), this function can only be used for origins that use the
csr_log_text_2.h interface for registration and logging. Filtering for
origins that use the legacy csr_log_text.h interface must be be
configured using the legacy filter configuration functions that accept
a CsrLogTextTaskId as origin specifier. However, when not specifying an
origin this function also affects origins that have been registered with
the legacy csr_log_text.h interface. Furthermore, using this function
and the legacy filter configuration functions on the same origin is not
allowed.
PARAMETERS
originName - a string containing the name of the origin. Can be NULL or
zero length to set the log level for all origins. In this case, the
subOriginName parameter will be ignored.
subOriginName - a string containing the name of the sub origin. Can be
NULL or zero length to set the log level for all sub origins of the
specified origin.
warningLevelMask - The desired log level for the specified origin(s) and
sub origin(s).
*******************************************************************************/
void CsrLogLevelTextSet(const CsrCharString *originName,
const CsrCharString *subOriginName,
CsrLogLevelText warningLevelMask);
#ifdef __cplusplus
}
#endif
#endif
#ifndef CSR_LOG_TEXT_H__
#define CSR_LOG_TEXT_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#include "csr_log_configure.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct CsrLogSubOrigin
{
CsrUint16 subOriginNumber; /* Id of the given SubOrigin */
const CsrCharString *subOriginName; /* Prefix Text for this SubOrigin */
} CsrLogSubOrigin;
/* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */
#ifdef CSR_LOG_ENABLE
void CsrLogTextRegister(CsrLogTextTaskId taskId, const CsrCharString *taskName, CsrUint16 subOriginsLength, const CsrLogSubOrigin *subOrigins);
#else
#define CsrLogTextRegister(taskId, taskName, subOriginsLength, subOrigins)
#endif
/* CRITICAL: Conditions that are threatening to the integrity/stability of the
system as a whole. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_CRITICAL_DISABLE)
void CsrLogTextCritical(CsrLogTextTaskId taskId, CsrUint16 subOrigin, const CsrCharString *formatString, ...);
void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, CsrUint16 subOrigin, CsrSize bufferLength, const void *buffer, const CsrCharString *formatString, ...);
#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) CsrLogTextCritical taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_CRITICAL(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferCritical taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_CRITICAL(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs)
#endif
/* ERROR: Malfunction of a component rendering it unable to operate correctly,
causing lack of functionality but not loss of system integrity/stability. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_ERROR_DISABLE)
void CsrLogTextError(CsrLogTextTaskId taskId, CsrUint16 subOrigin, const CsrCharString *formatString, ...);
void CsrLogTextBufferError(CsrLogTextTaskId taskId, CsrUint16 subOrigin, CsrSize bufferLength, const void *buffer, const CsrCharString *formatString, ...);
#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) CsrLogTextError taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_ERROR(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferError taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_ERROR(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs)
#endif
/* WARNING: Conditions that are unexpected and indicative of possible problems
or violations of specifications, where the result of such deviations does not
lead to malfunction of the component. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_WARNING_DISABLE)
void CsrLogTextWarning(CsrLogTextTaskId taskId, CsrUint16 subOrigin, const CsrCharString *formatString, ...);
void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, CsrUint16 subOrigin, CsrSize bufferLength, const void *buffer, const CsrCharString *formatString, ...);
#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) CsrLogTextWarning taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_WARNING(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferWarning taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_WARNING(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs)
#endif
/* INFO: Important events that may aid in determining the conditions under which
the more severe conditions are encountered. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_INFO_DISABLE)
void CsrLogTextInfo(CsrLogTextTaskId taskId, CsrUint16 subOrigin, const CsrCharString *formatString, ...);
void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, CsrUint16 subOrigin, CsrSize bufferLength, const void *buffer, const CsrCharString *formatString, ...);
#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) CsrLogTextInfo taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_INFO(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferInfo taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_INFO(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs)
#endif
/* DEBUG: Similar to INFO, but dedicated to events that occur more frequently. */
#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_DEBUG_DISABLE)
void CsrLogTextDebug(CsrLogTextTaskId taskId, CsrUint16 subOrigin, const CsrCharString *formatString, ...);
void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, CsrUint16 subOrigin, CsrSize bufferLength, const void *buffer, const CsrCharString *formatString, ...);
#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) CsrLogTextDebug taskId_subOrigin_formatString_varargs
#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_DEBUG(logtextargs);}}
#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferDebug taskId_subOrigin_length_buffer_formatString_varargs
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_DEBUG(logtextbufferargs);}}
#else
#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs)
#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs)
#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs)
#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs)
#endif
/* CSR_LOG_TEXT_ASSERT (CRITICAL) */
#ifdef CSR_LOG_ENABLE
#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) \
{if (!(condition)) {CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Assertion \"%s\" failed at %s:%u", #condition, __FILE__, __LINE__));}}
#else
#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition)
#endif
/* CSR_LOG_TEXT_UNHANDLED_PRIM (CRITICAL) */
#ifdef CSR_LOG_ENABLE
#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) \
CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Unhandled primitive 0x%04X:0x%04X at %s:%u", primClass, primType, __FILE__, __LINE__))
#else
#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType)
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef CSR_MACRO_H__
#define CSR_MACRO_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/*------------------------------------------------------------------*/
/* Bits - intended to operate on CsrUint32 values */
/*------------------------------------------------------------------*/
#define CSR_MASK_IS_SET(val, mask) (((val) & (mask)) == (mask))
#define CSR_MASK_IS_UNSET(val, mask) ((((val) & (mask)) ^ mask) == (mask))
#define CSR_MASK_SET(val, mask) ((val) |= (mask))
#define CSR_MASK_UNSET(val, mask) ((val) = ((val) ^ (mask)) & (val)) /* Unsets the bits in val that are set in mask */
#define CSR_BIT_IS_SET(val, bit) ((CsrBool) ((((val) & (1UL << (bit))) != 0)))
#define CSR_BIT_SET(val, bit) ((val) |= (1UL << (bit)))
#define CSR_BIT_UNSET(val, bit) ((val) &= ~(1UL << (bit)))
#define CSR_BIT_TOGGLE(val, bit) ((val) ^= (1UL << (bit)))
/*------------------------------------------------------------------*/
/* Endian conversion */
/*------------------------------------------------------------------*/
#define CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr) (((CsrUint16) ((CsrUint8 *) (ptr))[0]) | ((CsrUint16) ((CsrUint8 *) (ptr))[1]) << 8)
#define CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr) (((CsrUint32) ((CsrUint8 *) (ptr))[0]) | ((CsrUint32) ((CsrUint8 *) (ptr))[1]) << 8 | \
((CsrUint32) ((CsrUint8 *) (ptr))[2]) << 16 | ((CsrUint32) ((CsrUint8 *) (ptr))[3]) << 24)
#define CSR_COPY_UINT16_TO_LITTLE_ENDIAN(uint, ptr) ((CsrUint8 *) (ptr))[0] = ((CsrUint8) ((uint) & 0x00FF)); \
((CsrUint8 *) (ptr))[1] = ((CsrUint8) ((uint) >> 8))
#define CSR_COPY_UINT32_TO_LITTLE_ENDIAN(uint, ptr) ((CsrUint8 *) (ptr))[0] = ((CsrUint8) ((uint) & 0x000000FF)); \
((CsrUint8 *) (ptr))[1] = ((CsrUint8) (((uint) >> 8) & 0x000000FF)); \
((CsrUint8 *) (ptr))[2] = ((CsrUint8) (((uint) >> 16) & 0x000000FF)); \
((CsrUint8 *) (ptr))[3] = ((CsrUint8) (((uint) >> 24) & 0x000000FF))
#define CSR_GET_UINT16_FROM_BIG_ENDIAN(ptr) (((CsrUint16) ((CsrUint8 *) (ptr))[1]) | ((CsrUint16) ((CsrUint8 *) (ptr))[0]) << 8)
#define CSR_GET_UINT24_FROM_BIG_ENDIAN(ptr) (((CsrUint24) ((CsrUint8 *) (ptr))[2]) | \
((CsrUint24) ((CsrUint8 *) (ptr))[1]) << 8 | ((CsrUint24) ((CsrUint8 *) (ptr))[0]) << 16)
#define CSR_GET_UINT32_FROM_BIG_ENDIAN(ptr) (((CsrUint32) ((CsrUint8 *) (ptr))[3]) | ((CsrUint32) ((CsrUint8 *) (ptr))[2]) << 8 | \
((CsrUint32) ((CsrUint8 *) (ptr))[1]) << 16 | ((CsrUint32) ((CsrUint8 *) (ptr))[0]) << 24)
#define CSR_COPY_UINT16_TO_BIG_ENDIAN(uint, ptr) ((CsrUint8 *) (ptr))[1] = ((CsrUint8) ((uint) & 0x00FF)); \
((CsrUint8 *) (ptr))[0] = ((CsrUint8) ((uint) >> 8))
#define CSR_COPY_UINT24_TO_BIG_ENDIAN(uint, ptr) ((CsrUint8 *) (ptr))[2] = ((CsrUint8) ((uint) & 0x000000FF)); \
((CsrUint8 *) (ptr))[1] = ((CsrUint8) (((uint) >> 8) & 0x000000FF)); \
((CsrUint8 *) (ptr))[0] = ((CsrUint8) (((uint) >> 16) & 0x000000FF))
#define CSR_COPY_UINT32_TO_BIG_ENDIAN(uint, ptr) ((CsrUint8 *) (ptr))[3] = ((CsrUint8) ((uint) & 0x000000FF)); \
((CsrUint8 *) (ptr))[2] = ((CsrUint8) (((uint) >> 8) & 0x000000FF)); \
((CsrUint8 *) (ptr))[1] = ((CsrUint8) (((uint) >> 16) & 0x000000FF)); \
((CsrUint8 *) (ptr))[0] = ((CsrUint8) (((uint) >> 24) & 0x000000FF))
/*------------------------------------------------------------------*/
/* XAP conversion macros */
/*------------------------------------------------------------------*/
#define CSR_LSB16(a) ((CsrUint8) ((a) & 0x00ff))
#define CSR_MSB16(b) ((CsrUint8) ((b) >> 8))
#define CSR_CONVERT_8_FROM_XAP(output, input) \
(output) = ((CsrUint8) (input));(input) += 2
#define CSR_CONVERT_16_FROM_XAP(output, input) \
(output) = (CsrUint16) ((((CsrUint16) (input)[1]) << 8) | \
((CsrUint16) (input)[0]));(input) += 2
#define CSR_CONVERT_32_FROM_XAP(output, input) \
(output) = (((CsrUint32) (input)[1]) << 24) | \
(((CsrUint32) (input)[0]) << 16) | \
(((CsrUint32) (input)[3]) << 8) | \
((CsrUint32) (input)[2]);input += 4
#define CSR_ADD_UINT8_TO_XAP(output, input) \
(output)[0] = (input); \
(output)[1] = 0;(output) += 2
#define CSR_ADD_UINT16_TO_XAP(output, input) \
(output)[0] = ((CsrUint8) ((input) & 0x00FF)); \
(output)[1] = ((CsrUint8) ((input) >> 8));(output) += 2
#define CSR_ADD_UINT32_TO_XAP(output, input) \
(output)[0] = ((CsrUint8) (((input) >> 16) & 0x00FF)); \
(output)[1] = ((CsrUint8) ((input) >> 24)); \
(output)[2] = ((CsrUint8) ((input) & 0x00FF)); \
(output)[3] = ((CsrUint8) (((input) >> 8) & 0x00FF));(output) += 4
/*------------------------------------------------------------------*/
/* Misc */
/*------------------------------------------------------------------*/
#define CSRMAX(a, b) (((a) > (b)) ? (a) : (b))
#define CSRMIN(a, b) (((a) < (b)) ? (a) : (b))
/* Use this macro on unused local variables that cannot be removed (such as
unused function parameters). This will quell warnings from certain compilers
and static code analysis tools like Lint and Valgrind. */
#define CSR_UNUSED(x) ((void) (x))
#define CSR_TOUPPER(character) (((character) >= 'a') && ((character) <= 'z') ? ((character) - 0x20) : (character))
#define CSR_TOLOWER(character) (((character) >= 'A') && ((character) <= 'Z') ? ((character) + 0x20) : (character))
#define CSR_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#ifdef __cplusplus
}
#endif
#endif
#ifndef CSR_MSG_TRANSPORT_H__
#define CSR_MSG_TRANSPORT_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef CsrMsgTransport
#define CsrMsgTransport CsrSchedMessagePut
#endif
#ifdef __cplusplus
}
#endif
#endif /* CSR_MSG_TRANSPORT */
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include <linux/module.h>
#include "csr_types.h"
#include "csr_pmem.h"
#include "csr_panic.h"
#include "csr_sched.h"
#include "csr_msgconv.h"
#include "csr_util.h"
static CsrMsgConvEntry *converter;
CsrMsgConvPrimEntry *CsrMsgConvFind(CsrUint16 primType)
{
CsrMsgConvPrimEntry *ptr = NULL;
if (converter)
{
ptr = converter->profile_converters;
while (ptr)
{
if (ptr->primType == primType)
{
break;
}
else
{
ptr = ptr->next;
}
}
}
return ptr;
}
static const CsrMsgConvMsgEntry *find_msg_converter(CsrMsgConvPrimEntry *ptr, CsrUint16 msgType)
{
const CsrMsgConvMsgEntry *cv = ptr->conv;
if (ptr->lookupFunc)
{
return (const CsrMsgConvMsgEntry *) ptr->lookupFunc((CsrMsgConvMsgEntry *) cv, msgType);
}
while (cv)
{
if (cv->serFunc == NULL)
{
/* We've reached the end of the chain */
cv = NULL;
break;
}
if (cv->msgType == msgType)
{
break;
}
else
{
cv++;
}
}
return cv;
}
static void *deserialize_data(CsrUint16 primType,
CsrSize length,
CsrUint8 *data)
{
CsrMsgConvPrimEntry *ptr;
CsrUint8 *ret;
ptr = CsrMsgConvFind(primType);
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
CsrUint16 msgId = 0;
CsrSize offset = 0;
CsrUint16Des(&msgId, data, &offset);
cv = find_msg_converter(ptr, msgId);
if (cv)
{
ret = cv->deserFunc(data, length);
}
else
{
ret = NULL;
}
}
else
{
ret = NULL;
}
return ret;
}
static CsrSize sizeof_message(CsrUint16 primType, void *msg)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
CsrSize ret;
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
CsrUint16 msgId = *(CsrUint16 *) msg;
cv = find_msg_converter(ptr, msgId);
if (cv)
{
ret = cv->sizeofFunc(msg);
}
else
{
ret = 0;
}
}
else
{
ret = 0;
}
return ret;
}
static CsrBool free_message(CsrUint16 primType, CsrUint8 *data)
{
CsrMsgConvPrimEntry *ptr;
CsrBool ret;
ptr = CsrMsgConvFind(primType);
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
CsrUint16 msgId = *(CsrUint16 *) data;
cv = find_msg_converter(ptr, msgId);
if (cv)
{
cv->freeFunc(data);
ret = TRUE;
}
else
{
ret = FALSE;
}
}
else
{
ret = FALSE;
}
return ret;
}
static CsrUint8 *serialize_message(CsrUint16 primType,
void *msg,
CsrSize *length,
CsrUint8 *buffer)
{
CsrMsgConvPrimEntry *ptr;
CsrUint8 *ret;
ptr = CsrMsgConvFind(primType);
*length = 0;
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
cv = find_msg_converter(ptr, *(CsrUint16 *) msg);
if (cv)
{
ret = cv->serFunc(buffer, length, msg);
}
else
{
ret = NULL;
}
}
else
{
ret = NULL;
}
return ret;
}
CsrSize CsrMsgConvSizeof(CsrUint16 primType, void *msg)
{
return sizeof_message(primType, msg);
}
CsrUint8 *CsrMsgConvSerialize(CsrUint8 *buffer, CsrSize maxBufferOffset, CsrSize *offset, CsrUint16 primType, void *msg)
{
if (converter)
{
CsrSize serializedLength;
CsrUint8 *bufSerialized;
CsrUint8 *bufOffset = &buffer[*offset];
bufSerialized = converter->serialize_message(primType, msg, &serializedLength, bufOffset);
*offset += serializedLength;
return bufSerialized;
}
else
{
return NULL;
}
}
/* Insert profile converter at head of converter list. */
void CsrMsgConvInsert(CsrUint16 primType, const CsrMsgConvMsgEntry *ce)
{
CsrMsgConvPrimEntry *pc;
pc = CsrMsgConvFind(primType);
if (pc)
{
/* Already registered. Do nothing */
}
else
{
pc = CsrPmemAlloc(sizeof(*pc));
pc->primType = primType;
pc->conv = ce;
pc->lookupFunc = NULL;
pc->next = converter->profile_converters;
converter->profile_converters = pc;
}
}
EXPORT_SYMBOL_GPL(CsrMsgConvInsert);
CsrMsgConvMsgEntry *CsrMsgConvFindEntry(CsrUint16 primType, CsrUint16 msgType)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr)
{
return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
}
return NULL;
}
EXPORT_SYMBOL_GPL(CsrMsgConvFindEntry);
CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(CsrUint16 primType, const void *msg)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr && msg)
{
CsrUint16 msgType = *((CsrUint16 *) msg);
return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
}
return NULL;
}
void CsrMsgConvCustomLookupRegister(CsrUint16 primType, CsrMsgCustomLookupFunc *lookupFunc)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr)
{
ptr->lookupFunc = lookupFunc;
}
}
EXPORT_SYMBOL_GPL(CsrMsgConvCustomLookupRegister);
CsrMsgConvEntry *CsrMsgConvInit(void)
{
if (!converter)
{
converter = (CsrMsgConvEntry *) CsrPmemAlloc(sizeof(CsrMsgConvEntry));
converter->profile_converters = NULL;
converter->free_message = free_message;
converter->sizeof_message = sizeof_message;
converter->serialize_message = serialize_message;
converter->deserialize_data = deserialize_data;
}
return converter;
}
EXPORT_SYMBOL_GPL(CsrMsgConvInit);
CsrMsgConvEntry *CsrMsgConvGet(void)
{
return converter;
}
#ifdef ENABLE_SHUTDOWN
void CsrMsgConvDeinit(void)
{
CsrMsgConvPrimEntry *s;
if (converter == NULL)
{
return;
}
/* Walk converter list and free elements. */
s = converter->profile_converters;
while (s)
{
CsrMsgConvPrimEntry *s_next;
s_next = s->next;
CsrPmemFree(s);
s = s_next;
}
CsrPmemFree(converter);
converter = NULL;
}
EXPORT_SYMBOL_GPL(CsrMsgConvDeinit);
#endif /* ENABLE_SHUTDOWN */
#ifndef CSR_MSGCONV_H__
#define CSR_MSGCONV_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#include "csr_prim_defs.h"
#include "csr_sched.h"
#include "csr_unicode.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef CsrSize (CsrMsgSizeofFunc)(void *msg);
typedef CsrUint8 *(CsrMsgSerializeFunc)(CsrUint8 *buffer, CsrSize *length, void *msg);
typedef void (CsrMsgFreeFunc)(void *msg);
typedef void *(CsrMsgDeserializeFunc)(CsrUint8 *buffer, CsrSize length);
/* Converter entry for one message type */
typedef struct CsrMsgConvMsgEntry
{
CsrUint16 msgType;
CsrMsgSizeofFunc *sizeofFunc;
CsrMsgSerializeFunc *serFunc;
CsrMsgDeserializeFunc *deserFunc;
CsrMsgFreeFunc *freeFunc;
} CsrMsgConvMsgEntry;
/* Optional lookup function */
typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, CsrUint16 msgType);
/* All converter entries for one specific primitive */
typedef struct CsrMsgConvPrimEntry
{
CsrUint16 primType;
const CsrMsgConvMsgEntry *conv;
CsrMsgCustomLookupFunc *lookupFunc;
struct CsrMsgConvPrimEntry *next;
} CsrMsgConvPrimEntry;
typedef struct
{
CsrMsgConvPrimEntry *profile_converters;
void *(*deserialize_data)(CsrUint16 primType, CsrSize length, CsrUint8 * data);
CsrBool (*free_message)(CsrUint16 primType, CsrUint8 *data);
CsrSize (*sizeof_message)(CsrUint16 primType, void *msg);
CsrUint8 *(*serialize_message)(CsrUint16 primType, void *msg,
CsrSize * length,
CsrUint8 * buffer);
} CsrMsgConvEntry;
CsrSize CsrMsgConvSizeof(CsrUint16 primType, void *msg);
CsrUint8 *CsrMsgConvSerialize(CsrUint8 *buffer, CsrSize maxBufferOffset, CsrSize *offset, CsrUint16 primType, void *msg);
void CsrMsgConvCustomLookupRegister(CsrUint16 primType, CsrMsgCustomLookupFunc *lookupFunc);
void CsrMsgConvInsert(CsrUint16 primType, const CsrMsgConvMsgEntry *ce);
CsrMsgConvPrimEntry *CsrMsgConvFind(CsrUint16 primType);
CsrMsgConvMsgEntry *CsrMsgConvFindEntry(CsrUint16 primType, CsrUint16 msgType);
CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(CsrUint16 primType, const void *msg);
CsrMsgConvEntry *CsrMsgConvGet(void);
CsrMsgConvEntry *CsrMsgConvInit(void);
#ifdef ENABLE_SHUTDOWN
void CsrMsgConvDeinit(void);
#endif /* ENABLE_SHUTDOWN */
/* SHOULD BE INTERNAL TO FRAMEWORK AKA DEPRECATED */
CsrUint32 CsrCharStringSerLen(const CsrCharString *str);
CsrUint32 CsrUtf8StringSerLen(const CsrUtf8String *str);
CsrUint32 CsrUtf16StringSerLen(const CsrUtf16String *str);
/* Prototypes for primitive type serializers */
void CsrUint8Ser(CsrUint8 *buffer, CsrSize *offset, CsrUint8 value);
void CsrUint16Ser(CsrUint8 *buffer, CsrSize *offset, CsrUint16 value);
void CsrUint32Ser(CsrUint8 *buffer, CsrSize *offset, CsrUint32 value);
void CsrMemCpySer(CsrUint8 *buffer, CsrSize *offset, const void *value, CsrSize length);
void CsrCharStringSer(CsrUint8 *buffer, CsrSize *offset, const CsrCharString *value);
void CsrUtf8StringSer(CsrUint8 *buffer, CsrSize *offset, const CsrUtf8String *value);
void CsrUtf16StringSer(CsrUint8 *buffer, CsrSize *offset, const CsrUtf16String *value);
void CsrVoidPtrSer(CsrUint8 *buffer, CsrSize *offset, void *ptr);
void CsrSizeSer(CsrUint8 *buffer, CsrSize *offset, CsrSize value);
void CsrUint8Des(CsrUint8 *value, CsrUint8 *buffer, CsrSize *offset);
void CsrUint16Des(CsrUint16 *value, CsrUint8 *buffer, CsrSize *offset);
void CsrUint32Des(CsrUint32 *value, CsrUint8 *buffer, CsrSize *offset);
void CsrMemCpyDes(void *value, CsrUint8 *buffer, CsrSize *offset, CsrSize length);
void CsrCharStringDes(CsrCharString **value, CsrUint8 *buffer, CsrSize *offset);
void CsrUtf8StringDes(CsrUtf8String **value, CsrUint8 *buffer, CsrSize *offset);
void CsrUtf16StringDes(CsrUtf16String **value, CsrUint8 *buffer, CsrSize *offset);
void CsrVoidPtrDes(void **value, CsrUint8 *buffer, CsrSize *offset);
void CsrSizeDes(CsrSize *value, CsrUint8 *buffer, CsrSize *offset);
CsrSize CsrEventSizeof(void *msg);
CsrUint8 *CsrEventSer(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventDes(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint8Sizeof(void *msg);
CsrUint8 *CsrEventCsrUint8Ser(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint8Des(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint16Sizeof(void *msg);
CsrUint8 *CsrEventCsrUint16Ser(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint16Des(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint32Sizeof(void *msg);
CsrUint8 *CsrEventCsrUint32Ser(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint32Des(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint16CsrUint8Sizeof(void *msg);
CsrUint8 *CsrEventCsrUint16CsrUint8Ser(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint16CsrUint8Des(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint16CsrUint16Sizeof(void *msg);
CsrUint8 *CsrEventCsrUint16CsrUint16Ser(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint16CsrUint16Des(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint16CsrUint32Sizeof(void *msg);
CsrUint8 *CsrEventCsrUint16CsrUint32Ser(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint16CsrUint32Des(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint16CsrCharStringSizeof(void *msg);
CsrUint8 *CsrEventCsrUint16CsrCharStringSer(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint16CsrCharStringDes(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint32CsrUint16Sizeof(void *msg);
CsrUint8 *CsrEventCsrUint32CsrUint16Ser(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint32CsrUint16Des(CsrUint8 *buffer, CsrSize length);
CsrSize CsrEventCsrUint32CsrCharStringSizeof(void *msg);
CsrUint8 *CsrEventCsrUint32CsrCharStringSer(CsrUint8 *ptr, CsrSize *len, void *msg);
void *CsrEventCsrUint32CsrCharStringDes(CsrUint8 *buffer, CsrSize length);
#ifdef __cplusplus
}
#endif
#endif
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/module.h>
#include "csr_types.h"
#include "csr_panic.h"
void CsrPanic(CsrUint8 tech, CsrUint16 reason, const char *p)
{
BUG_ON(1);
}
EXPORT_SYMBOL_GPL(CsrPanic);
#ifndef CSR_PANIC_H__
#define CSR_PANIC_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Synergy techonology ID definitions */
#define CSR_TECH_FW 0
#define CSR_TECH_BT 1
#define CSR_TECH_WIFI 2
#define CSR_TECH_GPS 3
#define CSR_TECH_NFC 4
/* Panic type ID definitions for technology type CSR_TECH_FW */
#define CSR_PANIC_FW_UNEXPECTED_VALUE 0
#define CSR_PANIC_FW_HEAP_EXHAUSTION 1
#define CSR_PANIC_FW_INVALID_PFREE_POINTER 2
#define CSR_PANIC_FW_EXCEPTION 3
#define CSR_PANIC_FW_ASSERTION_FAIL 4
#define CSR_PANIC_FW_NULL_TASK_HANDLER 5
#define CSR_PANIC_FW_UNKNOWN_TASK 6
#define CSR_PANIC_FW_QUEUE_ACCESS_VIOLATION 7
#define CSR_PANIC_FW_TOO_MANY_MESSAGES 8
#define CSR_PANIC_FW_TOO_MANY_TIMED_EVENTS 9
#define CSR_PANIC_FW_ABCSP_SYNC_LOST 10
#define CSR_PANIC_FW_OVERSIZE_ABCSP_PRIM 11
#define CSR_PANIC_FW_H4_CORRUPTION 12
#define CSR_PANIC_FW_H4_SYNC_LOST 13
#define CSR_PANIC_FW_H4_RX_OVERRUN 14
#define CSR_PANIC_FW_H4_TX_OVERRUN 15
#define CSR_PANIC_FW_TM_BC_RESTART_FAIL 16
#define CSR_PANIC_FW_TM_BC_START_FAIL 17
#define CSR_PANIC_FW_TM_BC_BAD_STATE 18
#define CSR_PANIC_FW_TM_BC_TRANSPORT_LOST 19
/* Panic interface used by technologies */
/* DEPRECATED - replaced by csr_log_text.h */
void CsrPanic(CsrUint8 tech, CsrUint16 reason, const char *p);
#ifdef __cplusplus
}
#endif
#endif /* CSR_PANIC_H__ */
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/module.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
#include <linux/autoconf.h>
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
#include <linux/config.h>
#endif
#include <linux/slab.h>
#include "csr_panic.h"
#include "csr_pmem.h"
void *CsrPmemAlloc(CsrSize size)
{
void *ret;
ret = kmalloc(size, GFP_KERNEL);
if (!ret)
{
CsrPanic(CSR_TECH_FW, CSR_PANIC_FW_HEAP_EXHAUSTION,
"out of memory");
}
return ret;
}
EXPORT_SYMBOL_GPL(CsrPmemAlloc);
void CsrPmemFree(void *ptr)
{
if (ptr == NULL)
{
return;
}
kfree(ptr);
}
EXPORT_SYMBOL_GPL(CsrPmemFree);
#ifndef CSR_PMEM_H__
#define CSR_PMEM_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#include "csr_util.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef CSR_PMEM_DEBUG_ENABLE
/*****************************************************************************
NAME
CsrPmemAlloc
DESCRIPTION
This function will allocate a contiguous block of memory of at least
the specified size in bytes and return a pointer to the allocated
memory. This function is not allowed to return NULL. A size of 0 is a
valid request, and a unique and valid (not NULL) pointer must be
returned in this case.
PARAMETERS
size - Size of memory requested. Note that a size of 0 is valid.
RETURNS
Pointer to allocated memory.
*****************************************************************************/
#ifdef CSR_PMEM_DEBUG
void *CsrPmemAllocDebug(CsrSize size,
const CsrCharString *file, CsrUint32 line);
#define CsrPmemAlloc(sz) CsrPmemAllocDebug((sz), __FILE__, __LINE__)
#else
void *CsrPmemAlloc(CsrSize size);
#endif
/*****************************************************************************
NAME
CsrPmemFree
DESCRIPTION
This function will deallocate a previously allocated block of memory.
PARAMETERS
ptr - Pointer to allocated memory.
*****************************************************************************/
void CsrPmemFree(void *ptr);
#endif
/*****************************************************************************
NAME
CsrPmemZalloc
DESCRIPTION
This function is equivalent to CsrPmemAlloc, but the allocated memory
is initialised to zero.
PARAMETERS
size - Size of memory requested. Note that a size of 0 is valid.
RETURNS
Pointer to allocated memory.
*****************************************************************************/
#define CsrPmemZalloc(s) (CsrMemSet(CsrPmemAlloc(s), 0x00, (s)))
/*****************************************************************************
NAME
pnew and zpnew
DESCRIPTIOM
Type-safe wrappers for CsrPmemAlloc and CsrPmemZalloc, for allocating
single instances of a specified and named type.
PARAMETERS
t - type to allocate.
*****************************************************************************/
#define pnew(t) ((t *) (CsrPmemAlloc(sizeof(t))))
#define zpnew(t) ((t *) (CsrPmemZalloc(sizeof(t))))
/*----------------------------------------------------------------------------*
* Csr Pmem Debug code. Allows custom callbacks on CsrPmemAlloc and CsrPmemFree
*----------------------------------------------------------------------------*/
#ifdef CSR_PMEM_DEBUG_ENABLE
typedef CsrUint8 CsrPmemDebugAllocType;
#define CSR_PMEM_DEBUG_TYPE_PMEM_ALLOC 1
#define CSR_PMEM_DEBUG_TYPE_MEM_ALLOC 2
#define CSR_PMEM_DEBUG_TYPE_MEM_CALLOC 3
#define CSR_PMEM_DEBUG_TYPE_MEM_ALLOC_DMA 4
typedef void (CsrPmemDebugOnAlloc)(void *ptr, void *userptr, CsrSize size, CsrPmemDebugAllocType type, const CsrCharString* file, CsrUint32 line);
typedef void (CsrPmemDebugOnFree)(void *ptr, void *userptr, CsrPmemDebugAllocType type, const CsrCharString* file, CsrUint32 line);
/*----------------------------------------------------------------------------*
* NAME
* CsrPmemInstallHooks
*
* DESCRIPTION
* Install debug hooks for memory allocation
* Use NULL values to uninstall the hooks
* headSize = The number of extra bytes to allocate in the head of the Allocated buffer
* footSize = The number of extra bytes to allocate in the end of the Allocated buffer
*
* RETURNS
* void
*
*----------------------------------------------------------------------------*/
void CsrPmemDebugInstallHooks(CsrUint8 headSize, CsrUint8 endSize, CsrPmemDebugOnAlloc *onAllocCallback, CsrPmemDebugOnFree *onFreeCallback);
void *CsrPmemDebugAlloc(CsrSize size, CsrPmemDebugAllocType type, const CsrCharString* file, CsrUint32 line);
#define CsrPmemAlloc(size) CsrPmemDebugAlloc(size, CSR_PMEM_DEBUG_TYPE_PMEM_ALLOC, __FILE__, __LINE__)
void CsrPmemDebugFree(void *ptr, CsrPmemDebugAllocType type, const CsrCharString* file, CsrUint32 line);
#define CsrPmemFree(ptr) CsrPmemDebugFree(ptr, CSR_PMEM_DEBUG_TYPE_PMEM_ALLOC, __FILE__, __LINE__)
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef CSR_PRIM_DEFS_H__
#define CSR_PRIM_DEFS_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/************************************************************************************
* Segmentation of primitives in upstream and downstream segment
************************************************************************************/
typedef CsrUint16 CsrPrim;
#define CSR_PRIM_UPSTREAM ((CsrPrim) (0x8000))
/************************************************************************************
* Primitive definitions for Synergy framework
************************************************************************************/
#define CSR_SYNERGY_EVENT_CLASS_BASE ((CsrUint16) (0x0600))
#define CSR_HCI_PRIM ((CsrUint16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_BCCMD_PRIM ((CsrUint16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_HQ_PRIM ((CsrUint16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_VM_PRIM ((CsrUint16) (0x0003 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_TM_BLUECORE_PRIM ((CsrUint16) (0x0004 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_FP_PRIM ((CsrUint16) (0x0005 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_IP_SOCKET_PRIM ((CsrUint16) (0x0006 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_IP_ETHER_PRIM ((CsrUint16) (0x0007 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_IP_IFCONFIG_PRIM ((CsrUint16) (0x0008 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_IP_INTERNAL_PRIM ((CsrUint16) (0x0009 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_FSAL_PRIM ((CsrUint16) (0x000A | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_DATA_STORE_PRIM ((CsrUint16) (0x000B | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_AM_PRIM ((CsrUint16) (0x000C | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_TLS_PRIM ((CsrUint16) (0x000D | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_DHCP_SERVER_PRIM ((CsrUint16) (0x000E | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_TFTP_PRIM ((CsrUint16) (0x000F | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_DSPM_PRIM ((CsrUint16) (0x0010 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_TLS_INTERNAL_PRIM ((CsrUint16) (0x0011 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define NUMBER_OF_CSR_FW_EVENTS (CSR_DSPM_PRIM - CSR_SYNERGY_EVENT_CLASS_BASE + 1)
#define CSR_SYNERGY_EVENT_CLASS_MISC_BASE ((CsrUint16) (0x06A0))
#define CSR_UI_PRIM ((CsrUint16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
#define CSR_APP_PRIM ((CsrUint16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
#define CSR_SDIO_PROBE_PRIM ((CsrUint16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
#define NUMBER_OF_CSR_FW_MISC_EVENTS (CSR_SDIO_PROBE_PRIM - CSR_SYNERGY_EVENT_CLASS_MISC_BASE + 1)
#define CSR_ENV_PRIM ((CsrUint16) (0x00FF | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
#ifdef __cplusplus
}
#endif
#endif /* CSR_PRIM_DEFS_H__ */
#ifndef CSR_RESULT_H__
#define CSR_RESULT_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef CsrUint16 CsrResult;
#define CSR_RESULT_SUCCESS ((CsrResult) 0x0000)
#define CSR_RESULT_FAILURE ((CsrResult) 0xFFFF)
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include <linux/kernel.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
#include <linux/autoconf.h>
#include <linux/config.h>
#endif
#include <linux/time.h>
#include <linux/module.h>
#include "csr_types.h"
#include "csr_time.h"
CsrTime CsrTimeGet(CsrTime *high)
{
struct timespec ts;
CsrUint64 time;
CsrTime low;
ts = current_kernel_time();
time = (CsrUint64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
if (high != NULL)
{
*high = (CsrTime) ((time >> 32) & 0xFFFFFFFF);
}
low = (CsrTime) (time & 0xFFFFFFFF);
return low;
}
EXPORT_SYMBOL_GPL(CsrTimeGet);
void CsrTimeUtcGet(CsrTimeUtc *tod, CsrTime *low, CsrTime *high)
{
struct timespec ts;
CsrUint64 time;
ts = current_kernel_time();
time = (CsrUint64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
if (high != NULL)
{
*high = (CsrTime) ((time >> 32) & 0xFFFFFFFF);
}
if (low != NULL)
{
*low = (CsrTime) (time & 0xFFFFFFFF);
}
if (tod != NULL)
{
struct timeval tv;
do_gettimeofday(&tv);
tod->sec = tv.tv_sec;
tod->msec = tv.tv_usec / 1000;
}
}
#ifndef CSR_TIME_H__
#define CSR_TIME_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
NAME
CsrTime
DESCRIPTION
Type to hold a value describing the current system time, which is a
measure of time elapsed since some arbitrarily defined fixed time
reference, usually associated with system startup.
*******************************************************************************/
typedef CsrUint32 CsrTime;
/*******************************************************************************
NAME
CsrTimeUtc
DESCRIPTION
Type to hold a value describing a UTC wallclock time expressed in
seconds and milliseconds elapsed since midnight January 1st 1970.
*******************************************************************************/
typedef struct
{
CsrUint32 sec;
CsrUint16 msec;
} CsrTimeUtc;
/*******************************************************************************
NAME
CsrTimeGet
DESCRIPTION
Returns the current system time in a low and a high part. The low part
is expressed in microseconds. The high part is incremented when the low
part wraps to provide an extended range.
The caller may provide a NULL pointer as the high parameter. In this case
the function just returns the low part and ignores the high parameter.
Although the time is expressed in microseconds the actual resolution is
platform dependent and can be less. It is recommended that the
resolution is at least 10 milliseconds.
PARAMETERS
high - Pointer to variable that will receive the high part of the
current system time. Passing NULL is valid.
RETURNS
Low part of current system time in microseconds.
*******************************************************************************/
CsrTime CsrTimeGet(CsrTime *high);
/*******************************************************************************
NAME
CsrTimeUtcGet
DESCRIPTION
Get the current system wallclock time, and optionally the current system
time in a low and a high part as would have been returned by
CsrTimeGet.
Although CsrTimeUtc is expressed in seconds and milliseconds, the actual
resolution is platform dependent, and can be less. It is recommended
that the resolution is at least 1 second.
PARAMETERS
tod - Pointer to variable that will receive the current system
wallclock time.
low - The low part of the current system time in microseconds. Passing
NULL is valid.
high - The high part of the current system time in microseconds. Passing
NULL is valid.
*******************************************************************************/
void CsrTimeUtcGet(CsrTimeUtc *tod, CsrTime *low, CsrTime *high);
/*------------------------------------------------------------------*/
/* CsrTime Macros */
/*------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*
* NAME
* CsrTimeAdd
*
* DESCRIPTION
* Add two time values. Adding the numbers can overflow the range of a
* CsrTime, so the user must be cautious.
*
* RETURNS
* CsrTime - the sum of "t1" and "t2".
*
*----------------------------------------------------------------------------*/
#define CsrTimeAdd(t1, t2) ((t1) + (t2))
/*----------------------------------------------------------------------------*
* NAME
* CsrTimeSub
*
* DESCRIPTION
* Subtract two time values. Subtracting the numbers can provoke an
* underflow, so the user must be cautious.
*
* RETURNS
* CsrTime - "t1" - "t2".
*
*----------------------------------------------------------------------------*/
#define CsrTimeSub(t1, t2) ((CsrInt32) (t1) - (CsrInt32) (t2))
/*----------------------------------------------------------------------------*
* NAME
* CsrTimeEq
*
* DESCRIPTION
* Compare two time values.
*
* RETURNS
* !0 if "t1" equal "t2", else 0.
*
*----------------------------------------------------------------------------*/
#define CsrTimeEq(t1, t2) ((t1) == (t2))
/*----------------------------------------------------------------------------*
* NAME
* CsrTimeGt
*
* DESCRIPTION
* Compare two time values.
*
* RETURNS
* !0 if "t1" is greater than "t2", else 0.
*
*----------------------------------------------------------------------------*/
#define CsrTimeGt(t1, t2) (CsrTimeSub((t1), (t2)) > 0)
/*----------------------------------------------------------------------------*
* NAME
* CsrTimeGe
*
* DESCRIPTION
* Compare two time values.
*
* RETURNS
* !0 if "t1" is greater than, or equal to "t2", else 0.
*
*----------------------------------------------------------------------------*/
#define CsrTimeGe(t1, t2) (CsrTimeSub((t1), (t2)) >= 0)
/*----------------------------------------------------------------------------*
* NAME
* CsrTimeLt
*
* DESCRIPTION
* Compare two time values.
*
* RETURNS
* !0 if "t1" is less than "t2", else 0.
*
*----------------------------------------------------------------------------*/
#define CsrTimeLt(t1, t2) (CsrTimeSub((t1), (t2)) < 0)
/*----------------------------------------------------------------------------*
* NAME
* CsrTimeLe
*
* DESCRIPTION
* Compare two time values.
*
* RETURNS
* !0 if "t1" is less than, or equal to "t2", else 0.
*
*----------------------------------------------------------------------------*/
#define CsrTimeLe(t1, t2) (CsrTimeSub((t1), (t2)) <= 0)
#ifdef __cplusplus
}
#endif
#endif
#ifndef CSR_TYPES_H__
#define CSR_TYPES_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifdef __KERNEL__
#include <linux/stddef.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <asm/byteorder.h>
#include <linux/string.h>
#else
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
#include <stdarg.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#undef FALSE
#define FALSE (0)
#undef TRUE
#define TRUE (1)
/* Basic types */
typedef size_t CsrSize; /* Return type of sizeof (ISO/IEC 9899:1990 7.1.6) */
typedef ptrdiff_t CsrPtrdiff; /* Type of the result of subtracting two pointers (ISO/IEC 9899:1990 7.1.6) */
typedef uintptr_t CsrUintptr; /* Unsigned integer large enough to hold any pointer (ISO/IEC 9899:1999 7.18.1.4) */
#ifdef __KERNEL__
typedef ptrdiff_t CsrIntptr; /* intptr_t is not defined in kernel. Use the equivalent ptrdiff_t. */
#else
typedef intptr_t CsrIntptr; /* Signed integer large enough to hold any pointer (ISO/IEC 9899:1999 7.18.1.4) */
#endif
/* Unsigned fixed width types */
typedef uint8_t CsrUint8;
typedef uint16_t CsrUint16;
typedef uint32_t CsrUint32;
/* Signed fixed width types */
typedef int8_t CsrInt8;
typedef int16_t CsrInt16;
typedef int32_t CsrInt32;
/* Boolean */
typedef CsrUint8 CsrBool;
/* String types */
typedef char CsrCharString;
typedef CsrUint8 CsrUtf8String;
typedef CsrUint16 CsrUtf16String; /* 16-bit UTF16 strings */
typedef CsrUint32 CsrUint24;
/*
* 64-bit integers
*
* Note: If a given compiler does not support 64-bit types, it is
* OK to omit these definitions; 32-bit versions of the code using
* these types may be available. Consult the relevant documentation
* or the customer support group for information on this.
*/
#define CSR_HAVE_64_BIT_INTEGERS
typedef uint64_t CsrUint64;
typedef int64_t CsrInt64;
/*
* Floating point
*
* Note: If a given compiler does not support floating point, it is
* OK to omit these definitions; alternative versions of the code using
* these types may be available. Consult the relevant documentation
* or the customer support group for information on this.
*/
#define CSR_HAVE_FLOATING_POINT
typedef float CsrFloat;
typedef double CsrDouble;
#ifdef __cplusplus
}
#endif
#endif
#ifndef CSR_UNICODE_H__
#define CSR_UNICODE_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#include "csr_types.h"
#ifdef __cplusplus
extern "C" {
#endif
CsrUtf16String *CsrUint32ToUtf16String(CsrUint32 number);
CsrUint32 CsrUtf16StringToUint32(const CsrUtf16String *unicodeString);
CsrUint32 CsrUtf16StrLen(const CsrUtf16String *unicodeString);
CsrUtf8String *CsrUtf16String2Utf8(const CsrUtf16String *source);
CsrUtf16String *CsrUtf82Utf16String(const CsrUtf8String *utf8String);
CsrUtf16String *CsrUtf16StrCpy(CsrUtf16String *target, const CsrUtf16String *source);
CsrUtf16String *CsrUtf16StringDuplicate(const CsrUtf16String *source);
CsrUint16 CsrUtf16StrICmp(const CsrUtf16String *string1, const CsrUtf16String *string2);
CsrUint16 CsrUtf16StrNICmp(const CsrUtf16String *string1, const CsrUtf16String *string2, CsrUint32 count);
CsrUtf16String *CsrUtf16MemCpy(CsrUtf16String *dest, const CsrUtf16String *src, CsrUint32 count);
CsrUtf16String *CsrUtf16ConcatenateTexts(const CsrUtf16String *inputText1, const CsrUtf16String *inputText2,
const CsrUtf16String *inputText3, const CsrUtf16String *inputText4);
CsrUtf16String *CsrUtf16String2XML(CsrUtf16String *str);
CsrUtf16String *CsrXML2Utf16String(CsrUtf16String *str);
CsrInt32 CsrUtf8StrCmp(const CsrUtf8String *string1, const CsrUtf8String *string2);
CsrInt32 CsrUtf8StrNCmp(const CsrUtf8String *string1, const CsrUtf8String *string2, CsrSize count);
CsrUint32 CsrUtf8StringLengthInBytes(const CsrUtf8String *string);
/*******************************************************************************
NAME
CsrUtf8StrTruncate
DESCRIPTION
In-place truncate a string on a UTF-8 character boundary by writing a
null character somewhere in the range target[count - 3]:target[count].
Please note that memory passed must be at least of length count + 1, to
ensure space for a full length string that is terminated at
target[count], in the event that target[count - 1] is the final byte of
a UTF-8 character.
PARAMETERS
target - Target string to truncate.
count - The desired length, in bytes, of the resulting string. Depending
on the contents, the resulting string length will be between
count - 3 and count.
RETURNS
Returns target
*******************************************************************************/
CsrUtf8String *CsrUtf8StrTruncate(CsrUtf8String *target, CsrSize count);
/*******************************************************************************
NAME
CsrUtf8StrCpy
DESCRIPTION
Copies the null terminated UTF-8 string pointed at by source into the
memory pointed at by target, including the terminating null character.
To avoid overflows, the size of the memory pointed at by target shall be
long enough to contain the same UTF-8 string as source (including the
terminating null character), and should not overlap in memory with
source.
PARAMETERS
target - Pointer to the target memory where the content is to be copied.
source - UTF-8 string to be copied.
RETURNS
Returns target
*******************************************************************************/
CsrUtf8String *CsrUtf8StrCpy(CsrUtf8String *target, const CsrUtf8String *source);
/*******************************************************************************
NAME
CsrUtf8StrNCpy
DESCRIPTION
Copies the first count bytes of source to target. If the end of the
source UTF-8 string (which is signaled by a null-character) is found
before count bytes have been copied, target is padded with null
characters until a total of count bytes have been written to it.
No null-character is implicitly appended to the end of target, so target
will only be null-terminated if the length of the UTF-8 string in source
is less than count.
PARAMETERS
target - Pointer to the target memory where the content is to be copied.
source - UTF-8 string to be copied.
count - Maximum number of bytes to be written to target.
RETURNS
Returns target
*******************************************************************************/
CsrUtf8String *CsrUtf8StrNCpy(CsrUtf8String *target, const CsrUtf8String *source, CsrSize count);
/*******************************************************************************
NAME
CsrUtf8StrNCpyZero
DESCRIPTION
Equivalent to CsrUtf8StrNCpy, but if the length of source is equal to or
greater than count the target string is truncated on a UTF-8 character
boundary by writing a null character somewhere in the range
target[count - 4]:target[count - 1], leaving the target string
unconditionally null terminated in all cases.
Please note that if the length of source is shorter than count, no
truncation will be applied, and the target string will be a one to one
copy of source.
PARAMETERS
target - Pointer to the target memory where the content is to be copied.
source - UTF-8 string to be copied.
count - Maximum number of bytes to be written to target.
RETURNS
Returns target
*******************************************************************************/
CsrUtf8String *CsrUtf8StrNCpyZero(CsrUtf8String *target, const CsrUtf8String *source, CsrSize count);
/*******************************************************************************
NAME
CsrUtf8StrDup
DESCRIPTION
This function will allocate memory and copy the source string into the
allocated memory, which is then returned as a duplicate of the original
string. The memory returned must be freed by calling CsrPmemFree when
the duplicate is no longer needed.
PARAMETERS
source - UTF-8 string to be duplicated.
RETURNS
Returns a duplicate of source.
*******************************************************************************/
CsrUtf8String *CsrUtf8StrDup(const CsrUtf8String *source);
CsrUtf8String *CsrUtf8StringConcatenateTexts(const CsrUtf8String *inputText1, const CsrUtf8String *inputText2, const CsrUtf8String *inputText3, const CsrUtf8String *inputText4);
/*
* UCS2
*
* D-13157
*/
typedef CsrUint8 CsrUcs2String;
CsrSize CsrUcs2ByteStrLen(const CsrUcs2String *ucs2String);
CsrSize CsrConverterUcs2ByteStrLen(const CsrUcs2String *str);
CsrUint8 *CsrUcs2ByteString2Utf8(const CsrUcs2String *ucs2String);
CsrUcs2String *CsrUtf82Ucs2ByteString(const CsrUint8 *utf8String);
CsrUint8 *CsrUtf16String2Ucs2ByteString(const CsrUtf16String *source);
CsrUtf16String *CsrUcs2ByteString2Utf16String(const CsrUint8 *source);
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
This diff is collapsed.
#ifndef CSR_UTIL_H__
#define CSR_UTIL_H__
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2010
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "csr_types.h"
#include "csr_macro.h"
/*------------------------------------------------------------------*/
/* Bits - intended to operate on CsrUint32 values */
/*------------------------------------------------------------------*/
CsrUint8 CsrBitCountSparse(CsrUint32 n);
CsrUint8 CsrBitCountDense(CsrUint32 n);
/*------------------------------------------------------------------*/
/* Base conversion */
/*------------------------------------------------------------------*/
CsrBool CsrHexStrToUint8(const CsrCharString *string, CsrUint8 *returnValue);
CsrBool CsrHexStrToUint16(const CsrCharString *string, CsrUint16 *returnValue);
CsrBool CsrHexStrToUint32(const CsrCharString *string, CsrUint32 *returnValue);
CsrUint32 CsrPow(CsrUint32 base, CsrUint32 exponent);
void CsrIntToBase10(CsrInt32 number, CsrCharString *str);
void CsrUInt16ToHex(CsrUint16 number, CsrCharString *str);
void CsrUInt32ToHex(CsrUint32 number, CsrCharString *str);
/*------------------------------------------------------------------*/
/* String */
/*------------------------------------------------------------------*/
void *CsrMemCpy(void *dest, const void *src, CsrSize count);
void *CsrMemSet(void *dest, CsrUint8 c, CsrSize count);
void *CsrMemMove(void *dest, const void *src, CsrSize count);
CsrInt32 CsrMemCmp(const void *buf1, const void *buf2, CsrSize count);
void *CsrMemDup(const void *buf1, CsrSize count);
CsrCharString *CsrStrCpy(CsrCharString *dest, const CsrCharString *src);
CsrCharString *CsrStrNCpy(CsrCharString *dest, const CsrCharString *src, CsrSize count);
int CsrStrNICmp(const CsrCharString *string1, const CsrCharString *string2, CsrSize count);
CsrCharString *CsrStrCat(CsrCharString *dest, const CsrCharString *src);
CsrCharString *CsrStrNCat(CsrCharString *dest, const CsrCharString *src, CsrSize count);
CsrCharString *CsrStrStr(const CsrCharString *string1, const CsrCharString *string2);
CsrSize CsrStrLen(const CsrCharString *string);
CsrInt32 CsrStrCmp(const CsrCharString *string1, const CsrCharString *string2);
CsrInt32 CsrStrNCmp(const CsrCharString *string1, const CsrCharString *string2, CsrSize count);
CsrCharString *CsrStrDup(const CsrCharString *string);
CsrCharString *CsrStrChr(const CsrCharString *string, CsrCharString c);
CsrUint32 CsrStrToInt(const CsrCharString *string);
CsrInt32 CsrVsnprintf(CsrCharString *string, CsrSize count, const CsrCharString *format, va_list args);
CsrCharString *CsrStrNCpyZero(CsrCharString *dest, const CsrCharString *src, CsrSize count);
/*------------------------------------------------------------------*/
/* Filename */
/*------------------------------------------------------------------*/
const CsrCharString *CsrGetBaseName(const CsrCharString *file);
/*------------------------------------------------------------------*/
/* Misc */
/*------------------------------------------------------------------*/
CsrBool CsrIsSpace(CsrUint8 c);
#define CsrOffsetOf(st, m) ((CsrSize) & ((st *) 0)->m)
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment