提交 f6a0d9d5 编写于 作者: L Linus Torvalds

Merge tag 'staging-3.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging tree fixes from Greg KH:
 "Here are a few iio driver fixes for 3.11-rc2.  They are still spread
  across drivers/iio and drivers/staging/iio so they are coming in
  through this tree.

  I've also removed the drivers/staging/csr/ driver as the developers
  who originally sent it to me have moved on to other companies, and CSR
  still will not send us the specs for the device, making the driver
  pretty much obsolete and impossible to fix up.  Deleting it now
  prevents people from sending in lots of tiny codingsyle fixes that
  will never go anywhere.

  It also helps to offset the large lustre filesystem merge that
  happened in 3.11-rc1 in the overall 3.11.0 diffstat.  :)"

* tag 'staging-3.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: csr: remove driver
  iio: lps331ap: Fix wrong in_pressure_scale output value
  iio staging: fix lis3l02dq, read error handling
  staging:iio:ad7291: add missing .driver_module to struct iio_info
  iio: ti_am335x_adc: add missing .driver_module to struct iio_info
  iio: mxs-lradc: Remove useless check in read_raw
  iio: mxs-lradc: Fix misuse of iio->trig
  iio: inkern: fix iio_convert_raw_to_processed_unlocked
  iio: Fix iio_channel_has_info
  iio:trigger: device_unregister->device_del to avoid double free
  iio: dac: ad7303: fix error return code in ad7303_probe()
......@@ -183,6 +183,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
static const struct iio_info tiadc_info = {
.read_raw = &tiadc_read_raw,
.driver_module = THIS_MODULE,
};
static int tiadc_probe(struct platform_device *pdev)
......
......@@ -235,8 +235,10 @@ static int ad7303_probe(struct spi_device *spi)
if (ext_ref) {
st->vref_reg = regulator_get(&spi->dev, "REF");
if (IS_ERR(st->vref_reg))
if (IS_ERR(st->vref_reg)) {
ret = PTR_ERR(st->vref_reg);
goto err_disable_vdd_reg;
}
ret = regulator_enable(st->vref_reg);
if (ret)
......
......@@ -104,7 +104,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
ida_simple_remove(&iio_trigger_ida, trig_info->id);
/* Possible issue in here */
device_unregister(&trig_info->dev);
device_del(&trig_info->dev);
}
EXPORT_SYMBOL(iio_trigger_unregister);
......
......@@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
int ret;
ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
if (ret == 0)
if (ret >= 0)
raw64 += offset;
scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
......
......@@ -28,7 +28,9 @@
#include <linux/iio/common/st_sensors.h>
#include "st_pressure.h"
#define ST_PRESS_MBAR_TO_KPASCAL(x) (x * 10)
#define ST_PRESS_LSB_PER_MBAR 4096UL
#define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \
ST_PRESS_LSB_PER_MBAR)
#define ST_PRESS_NUMBER_DATA_CHANNELS 1
/* DEFAULT VALUE FOR SENSORS */
......@@ -51,8 +53,8 @@
#define ST_PRESS_1_FS_ADDR 0x23
#define ST_PRESS_1_FS_MASK 0x30
#define ST_PRESS_1_FS_AVL_1260_VAL 0x00
#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_MBAR_TO_KPASCAL(244141)
#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000
#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
#define ST_PRESS_1_BDU_ADDR 0x20
#define ST_PRESS_1_BDU_MASK 0x04
#define ST_PRESS_1_DRDY_IRQ_ADDR 0x22
......
......@@ -118,8 +118,6 @@ source "drivers/staging/ozwpan/Kconfig"
source "drivers/staging/gdm72xx/Kconfig"
source "drivers/staging/csr/Kconfig"
source "drivers/staging/silicom/Kconfig"
source "drivers/staging/ced1401/Kconfig"
......
......@@ -52,7 +52,6 @@ obj-$(CONFIG_MFD_NVEC) += nvec/
obj-$(CONFIG_ANDROID) += android/
obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/
obj-$(CONFIG_CSR_WIFI) += csr/
obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/
obj-$(CONFIG_CED1401) += ced1401/
obj-$(CONFIG_DRM_IMX) += imx-drm/
......
config CSR_WIFI
tristate "CSR wireless driver"
depends on MMC && CFG80211_WEXT && INET
select WIRELESS_EXT
select WEXT_PRIV
help
Driver for the CSR wireless SDIO device.
If unsure, select N.
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.
ccflags-y := -DCSR_SME_USERSPACE -DCSR_SUPPORT_SME -DREMOTE_SYS_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DENABLE_SHUTDOWN -DUNIFI_DEBUG
ccflags-y += -DSDIO_EXPORTS_STRUCT_DEVICE -DCSR_WIFI_SUPPORT_MMC_DRIVER -DCSR_WIFI_SINGLE_FUNCTION -DCSR_WIFI_SPLIT_PATCH
ccflags-y += -DCSR_SUPPORT_WEXT -DREMOTE_SYS_SAP -DREMOTE_MGT_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DCSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND -DENABLE_SHUTDOWN -DCSR_WIFI_NME_ENABLE -DCSR_WIFI_AP_ENABLE -DCSR_SUPPORT_WEXT_AP -DCSR_WIFI_REQUEUE_PACKET_TO_HAL
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 \
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_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_nme_ap_converter_init.o \
csr_wifi_nme_ap_free_downstream_contents.o \
csr_wifi_nme_ap_free_upstream_contents.o \
csr_wifi_nme_ap_serialize.o \
csr_wifi_nme_ap_sef.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 \
sme_wext.o \
wext_events.o
csr_helper-y := csr_time.o \
csr_util.o \
csr_framework_ext.o \
csr_wifi_serialize_primitive_types.o \
csr_serialize_primitive_types.o \
csr_msgconv.o
/*
* ---------------------------------------------------------------------------
* FILE: bh.c
*
* PURPOSE:
* Provides an implementation for the driver bottom-half.
* It is part of the porting exercise in Linux.
*
* Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
*
* Refer to LICENSE.txt included with this source code for details on
* the license terms.
*
* ---------------------------------------------------------------------------
*/
#include "csr_wifi_hip_unifi.h"
#include "unifi_priv.h"
#include <linux/sched/rt.h>
/*
* ---------------------------------------------------------------------------
* uf_start_thread
*
* Helper function to start a new thread.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
* thread Pointer to the thread object
* func The thread function
*
* Returns:
* 0 on success or else a Linux error code.
* ---------------------------------------------------------------------------
*/
int uf_start_thread(unifi_priv_t *priv,
struct uf_thread *thread, int (*func)(void *))
{
if (thread->thread_task != NULL) {
unifi_error(priv, "%s thread already started\n", thread->name);
return 0;
}
/* Start the kernel thread that handles all h/w accesses. */
thread->thread_task = kthread_run(func, priv, "%s", thread->name);
if (IS_ERR(thread->thread_task))
return PTR_ERR(thread->thread_task);
/* Module parameter overides the thread priority */
if (bh_priority != -1) {
if (bh_priority >= 0 && bh_priority <= MAX_RT_PRIO) {
struct sched_param param;
priv->bh_thread.prio = bh_priority;
unifi_trace(priv, UDBG1,
"%s thread (RT) priority = %d\n",
thread->name, bh_priority);
param.sched_priority = bh_priority;
sched_setscheduler(thread->thread_task,
SCHED_FIFO, &param);
} else if (bh_priority > MAX_RT_PRIO &&
bh_priority <= MAX_PRIO) {
priv->bh_thread.prio = bh_priority;
unifi_trace(priv, UDBG1, "%s thread priority = %d\n",
thread->name,
PRIO_TO_NICE(bh_priority));
set_user_nice(thread->thread_task,
PRIO_TO_NICE(bh_priority));
} else {
priv->bh_thread.prio = DEFAULT_PRIO;
unifi_warning(priv,
"%s thread unsupported (%d) priority\n",
thread->name, bh_priority);
}
} else
priv->bh_thread.prio = DEFAULT_PRIO;
unifi_trace(priv, UDBG2, "Started %s thread\n", thread->name);
return 0;
} /* uf_start_thread() */
/*
* ---------------------------------------------------------------------------
* uf_stop_thread
*
* Helper function to stop a thread.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
* thread Pointer to the thread object
*
* Returns:
*
* ---------------------------------------------------------------------------
*/
void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread)
{
if (!thread->thread_task) {
unifi_notice(priv, "%s thread is already stopped\n",
thread->name);
return;
}
unifi_trace(priv, UDBG2, "Stopping %s thread\n", thread->name);
kthread_stop(thread->thread_task);
thread->thread_task = NULL;
} /* uf_stop_thread() */
/*
* ---------------------------------------------------------------------------
* uf_wait_for_thread_to_stop
*
* Helper function to wait until a thread is stopped.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
*
* Returns:
*
* ---------------------------------------------------------------------------
*/
void
uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread)
{
/*
* kthread_stop() cannot handle the thread exiting while
* kthread_should_stop() is false, so sleep until kthread_stop()
* wakes us up
*/
unifi_trace(priv, UDBG2, "%s waiting for the stop signal.\n",
thread->name);
set_current_state(TASK_INTERRUPTIBLE);
if (!kthread_should_stop()) {
unifi_trace(priv, UDBG2, "%s schedule....\n", thread->name);
schedule();
}
thread->thread_task = NULL;
unifi_trace(priv, UDBG2, "%s exiting....\n", thread->name);
} /* uf_wait_for_thread_to_stop() */
/*
* ---------------------------------------------------------------------------
* handle_bh_error
*
* This function reports an error returned from the HIP core bottom-half.
* Normally, implemented during the porting exercise, passing the error
* to the SME using unifi_sys_wifi_off_ind().
* The SME will try to reset the device and go through
* the initialisation of the UniFi.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
*
* Returns:
* None.
* ---------------------------------------------------------------------------
*/
static void
handle_bh_error(unifi_priv_t *priv)
{
netInterface_priv_t *interfacePriv;
u8 conf_param = CONFIG_IND_ERROR;
u8 interfaceTag;
/* Block unifi_run_bh() until the error has been handled. */
priv->bh_thread.block_thread = 1;
/* Consider UniFi to be uninitialised */
priv->init_progress = UNIFI_INIT_NONE;
/* Stop the network traffic */
for (interfaceTag = 0;
interfaceTag < CSR_WIFI_NUM_INTERFACES; interfaceTag++) {
interfacePriv = priv->interfacePriv[interfaceTag];
if (interfacePriv->netdev_registered)
netif_carrier_off(priv->netdev[interfaceTag]);
}
#ifdef CSR_NATIVE_LINUX
/* Force any client waiting on an mlme_wait_for_reply() to abort. */
uf_abort_mlme(priv);
/* Cancel any pending workqueue tasks */
flush_workqueue(priv->unifi_workqueue);
#endif /* CSR_NATIVE_LINUX */
unifi_error(priv,
"handle_bh_error: fatal error is reported to the SME.\n");
/* Notify the clients (SME or unifi_manager) for the error. */
ul_log_config_ind(priv, &conf_param, sizeof(u8));
} /* handle_bh_error() */
/*
* ---------------------------------------------------------------------------
* bh_thread_function
*
* All hardware access happens in this thread.
* This means there is no need for locks on the hardware and we don't need
* to worry about reentrancy with the SDIO library.
* Provides and example implementation on how to call unifi_bh(), which
* is part of the HIP core API.
*
* It processes the events generated by unifi_run_bh() to serialise calls
* to unifi_bh(). It also demonstrates how the timeout parameter passed in
* and returned from unifi_bh() needs to be handled.
*
* Arguments:
* arg Pointer to OS driver structure for the device.
*
* Returns:
* None.
*
* Notes:
* When the bottom half of the driver needs to process signals, events,
* or simply the host status (i.e sleep mode), it invokes unifi_run_bh().
* Since we need all SDIO transaction to be in a single thread, the
* unifi_run_bh() will wake up this thread to process it.
*
* ---------------------------------------------------------------------------
*/
static int bh_thread_function(void *arg)
{
unifi_priv_t *priv = (unifi_priv_t *)arg;
CsrResult csrResult;
long ret;
u32 timeout, t;
struct uf_thread *this_thread;
unifi_trace(priv, UDBG2, "bh_thread_function starting\n");
this_thread = &priv->bh_thread;
t = timeout = 0;
while (!kthread_should_stop()) {
/*
* wait until an error occurs,
* or we need to process something.
*/
unifi_trace(priv, UDBG3, "bh_thread goes to sleep.\n");
if (timeout > 0) {
/* Convert t in ms to jiffies */
t = msecs_to_jiffies(timeout);
ret = wait_event_interruptible_timeout(
this_thread->wakeup_q,
(this_thread->wakeup_flag && !this_thread->block_thread) ||
kthread_should_stop(),
t);
timeout = (ret > 0) ? jiffies_to_msecs(ret) : 0;
} else {
ret = wait_event_interruptible(this_thread->wakeup_q,
(this_thread->wakeup_flag && !this_thread->block_thread) ||
kthread_should_stop());
}
if (kthread_should_stop()) {
unifi_trace(priv, UDBG2,
"bh_thread: signalled to exit\n");
break;
}
if (ret < 0) {
unifi_notice(priv,
"bh_thread: wait_event returned %d, thread will exit\n",
ret);
uf_wait_for_thread_to_stop(priv, this_thread);
break;
}
this_thread->wakeup_flag = 0;
unifi_trace(priv, UDBG3, "bh_thread calls unifi_bh().\n");
CsrSdioClaim(priv->sdio);
csrResult = unifi_bh(priv->card, &timeout);
if (csrResult != CSR_RESULT_SUCCESS) {
if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
CsrSdioRelease(priv->sdio);
uf_wait_for_thread_to_stop(priv, this_thread);
break;
}
/* Errors must be delivered to the error task */
handle_bh_error(priv);
}
CsrSdioRelease(priv->sdio);
}
/*
* I would normally try to call csr_sdio_remove_irq() here to make sure
* that we do not get any interrupts while this thread is not running.
* However, the MMC/SDIO driver tries to kill its' interrupt thread.
* The kernel threads implementation does not allow to kill threads
* from a signalled to stop thread.
* So, instead call csr_sdio_linux_remove_irq() always after calling
* uf_stop_thread() to kill this thread.
*/
unifi_trace(priv, UDBG2, "bh_thread exiting....\n");
return 0;
} /* bh_thread_function() */
/*
* ---------------------------------------------------------------------------
* uf_init_bh
*
* Helper function to start the bottom half of the driver.
* All we need to do here is start the I/O bh thread.
*
* Arguments:
* priv Pointer to OS driver structure for the device.
*
* Returns:
* 0 on success or else a Linux error code.
* ---------------------------------------------------------------------------
*/
int
uf_init_bh(unifi_priv_t *priv)
{
int r;
/* Enable mlme interface. */
priv->io_aborted = 0;
/* Start the BH thread */
r = uf_start_thread(priv, &priv->bh_thread, bh_thread_function);
if (r) {
unifi_error(priv,
"uf_init_bh: failed to start the BH thread.\n");
return r;
}
/* Allow interrupts */
r = csr_sdio_linux_install_irq(priv->sdio);
if (r) {
unifi_error(priv,
"uf_init_bh: failed to install the IRQ.\n");
uf_stop_thread(priv, &priv->bh_thread);
}
return r;
} /* uf_init_bh() */
/*
* ---------------------------------------------------------------------------
* unifi_run_bh
*
* Part of the HIP core lib API, implemented in the porting exercise.
* The bottom half of the driver calls this function when
* it wants to process anything that requires access to unifi.
* We need to call unifi_bh() which in this implementation is done
* by waking up the I/O thread.
*
* Arguments:
* ospriv Pointer to OS driver structure for the device.
*
* Returns:
* 0 on success or else a Linux error code.
*
* Notes:
* ---------------------------------------------------------------------------
*/
CsrResult unifi_run_bh(void *ospriv)
{
unifi_priv_t *priv = ospriv;
/*
* If an error has occurred, we discard silently all messages from the bh
* until the error has been processed and the unifi has been
* reinitialised.
*/
if (priv->bh_thread.block_thread == 1) {
unifi_trace(priv, UDBG3, "unifi_run_bh: discard message.\n");
/*
* Do not try to acknowledge a pending interrupt here.
* This function is called by unifi_send_signal()
* which in turn can be running in an atomic or 'disabled irq'
* level if a signal is sent from a workqueue task
* (i.e multicass addresses set). We can not hold the SDIO lock
* because it might sleep.
*/
return CSR_RESULT_FAILURE;
}
priv->bh_thread.wakeup_flag = 1;
/* wake up I/O thread */
wake_up_interruptible(&priv->bh_thread.wakeup_q);
return CSR_RESULT_SUCCESS;
} /* unifi_run_bh() */
/*****************************************************************************
(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/kthread.h>
#include <linux/module.h>
#include <linux/freezer.h>
#include <linux/semaphore.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include "csr_framework_ext.h"
/*----------------------------------------------------------------------------*
* NAME
* CsrThreadSleep
*
* DESCRIPTION
* Sleep for a given period.
*
* RETURNS
* void
*
*----------------------------------------------------------------------------*/
void CsrThreadSleep(u16 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);
#ifndef CSR_FRAMEWORK_EXT_H__
#define CSR_FRAMEWORK_EXT_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_result.h"
#include "csr_framework_ext_types.h"
/* Result codes */
#define CSR_FE_RESULT_NO_MORE_EVENTS ((CsrResult) 0x0001)
#define CSR_FE_RESULT_INVALID_POINTER ((CsrResult) 0x0002)
#define CSR_FE_RESULT_INVALID_HANDLE ((CsrResult) 0x0003)
#define CSR_FE_RESULT_NO_MORE_MUTEXES ((CsrResult) 0x0004)
#define CSR_FE_RESULT_TIMEOUT ((CsrResult) 0x0005)
#define CSR_FE_RESULT_NO_MORE_THREADS ((CsrResult) 0x0006)
/* Thread priorities */
#define CSR_THREAD_PRIORITY_HIGHEST ((u16) 0)
#define CSR_THREAD_PRIORITY_HIGH ((u16) 1)
#define CSR_THREAD_PRIORITY_NORMAL ((u16) 2)
#define CSR_THREAD_PRIORITY_LOW ((u16) 3)
#define CSR_THREAD_PRIORITY_LOWEST ((u16) 4)
#define CSR_EVENT_WAIT_INFINITE ((u16) 0xFFFF)
void CsrThreadSleep(u16 sleepTimeInMs);
#endif
#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.
*****************************************************************************/
#ifdef __KERNEL__
#include <linux/kthread.h>
#include <linux/semaphore.h>
#else
#include <pthread.h>
#endif
#ifdef __KERNEL__
typedef struct semaphore CsrMutexHandle;
#else /* __KERNEL __ */
typedef pthread_mutex_t CsrMutexHandle;
#endif /* __KERNEL__ */
#endif
#ifndef CSR_LOG_H__
#define CSR_LOG_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_sched.h"
#include "csr_prim_defs.h"
#include "csr_msgconv.h"
/*
* Log filtering
*/
/*----------------------------------------------------*/
/* Filtering on environment specific log levels */
/*----------------------------------------------------*/
typedef u32 CsrLogLevelEnvironment;
#define CSR_LOG_LEVEL_ENVIRONMENT_OFF ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */
#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */
#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO_LOC ((CsrLogLevelEnvironment) 0x00000800) /* The Location where the transport protocol event occurred are logged NB: This is a supplement to CSR_LOG_LEVEL_ENVIRONMENT_PROTO, it has no effect without it */
/* The bit masks between here are reserved for future usage */
#define CSR_LOG_LEVEL_ENVIRONMENT_ALL ((CsrLogLevelEnvironment) 0xFFFFFFFF) /* All possible environment data/events are logged WARNING: By using this define the application also accepts future possible environment data/events in the logs */
/*----------------------------------------------------*/
/* Filtering on task specific log levels */
/*----------------------------------------------------*/
typedef u32 CsrLogLevelTask;
#define CSR_LOG_LEVEL_TASK_OFF ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */
#define CSR_LOG_LEVEL_TASK_TEXT ((CsrLogLevelTask) 0x00000001) /* Text strings printed by a task are logged NB: This bit does not affect the CSR_LOG_TEXT_LEVEL interface. This has to be configured separately */
#define CSR_LOG_LEVEL_TASK_TEXT_LOC ((CsrLogLevelTask) 0x00000002) /* The locaction where the text string call occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TEXT, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_STATE ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */
#define CSR_LOG_LEVEL_TASK_STATE_NAME ((CsrLogLevelTask) 0x00000008) /* The name of each state in a FSM state transition are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_STATE_LOC ((CsrLogLevelTask) 0x00000010) /* The location where the FSM state transition occurred are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_TASK_SWITCH ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT_LOC ((CsrLogLevelTask) 0x00000100) /* The location where a message was sent are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_MESSAGE_PUT, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_MESSAGE_GET ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */
#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */
#define CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE ((CsrLogLevelTask) 0x00001000) /* Only the type of primitives in messages are logged. By default the entire primitive is serialized and logged */
#define CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT ((CsrLogLevelTask) 0x00002000) /* An upper limit (defined by CSR_LOG_PRIM_SIZE_UPPER_LIMIT) is applied to how much of a primitive in a message are logged. NB: This limit is only applied if CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE is _not_ defined */
#define CSR_LOG_LEVEL_TASK_TIMER_IN ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */
#define CSR_LOG_LEVEL_TASK_TIMER_IN_LOC ((CsrLogLevelTask) 0x00008000) /* The location where a timer was started are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_IN, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */
#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL_LOC ((CsrLogLevelTask) 0x00020000) /* The location where a timer was cancelled are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_CANCEL, it has no effect without it */
#define CSR_LOG_LEVEL_TASK_TIMER_FIRE ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */
#define CSR_LOG_LEVEL_TASK_TIMER_DONE ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */
/* The bit masks between here are reserved for future usage */
#define CSR_LOG_LEVEL_TASK_ALL ((CsrLogLevelTask) 0xFFFFFFFF & ~(CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE | CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT)) /* All info possible to log for a task are logged. WARNING: By using this define the application also accepts future possible task data/events in the logs */
u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level);
CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId);
u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level);
/*
* Logging stuff
*/
#define CSR_LOG_STRINGIFY_REAL(a) (#a)
#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a)
typedef struct {
u16 primitiveType;
const char *primitiveName;
CsrMsgConvMsgEntry *messageConv; /* Private - do not use */
} CsrLogPrimitiveInformation;
typedef struct {
const char *techVer;
u32 primitiveInfoCount;
CsrLogPrimitiveInformation *primitiveInfo;
} CsrLogTechInformation;
/*---------------------------------*/
/* Tech logging */
/*---------------------------------*/
typedef u8 bitmask8_t;
typedef u16 bitmask16_t;
typedef u32 bitmask32_t;
#ifdef CSR_LOG_ENABLE
#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER
/* DEPRECATED - replaced by csr_log_text.h */
#define CSR_LOG_TEXT(text) \
do { \
if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
CsrLogTaskText(text, __LINE__, __FILE__); \
} \
} while (0)
#else
/* DEPRECATED - replaced by csr_log_text.h */
#define CSR_LOG_TEXT(text) \
do { \
if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) { \
CsrLogTaskText(text, 0, NULL); \
} \
} while (0)
#endif
#else
#define CSR_LOG_TEXT(text)
#endif
/* DEPRECATED - replaced by csr_log_text.h */
void CsrLogTaskText(const char *text,
u32 line,
const char *file);
#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME (0x001)
#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE (0x002)
#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR (0x004)
#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE (0x008)
#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR (0x010)
#define CSR_LOG_STATE_TRANSITION_MASK_EVENT (0x020)
#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR (0x040)
/* DEPRECATED - replaced by csr_log_text.h */
void CsrLogStateTransition(bitmask16_t mask,
u32 identifier,
const char *fsm_name,
u32 prev_state,
const char *prev_state_str,
u32 in_event,
const char *in_event_str,
u32 next_state,
const char *next_state_str,
u32 line,
const char *file);
/*---------------------------------*/
/* BSP logging */
/*---------------------------------*/
void CsrLogSchedInit(u8 thread_id);
void CsrLogSchedDeinit(u8 thread_id);
void CsrLogSchedStart(u8 thread_id);
void CsrLogSchedStop(u8 thread_id);
void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName);
void CsrLogDeinitTask(u16 task_id);
void CsrLogActivate(CsrSchedQid tskid);
void CsrLogDeactivate(CsrSchedQid tskid);
#define SYNERGY_SERIALIZER_TYPE_DUMP (0x000)
#define SYNERGY_SERIALIZER_TYPE_SER (0x001)
void CsrLogMessagePut(u32 line,
const char *file,
CsrSchedQid src_task_id,
CsrSchedQid dst_taskid,
CsrSchedMsgId msg_id,
u16 prim_type,
const void *msg);
void CsrLogMessageGet(CsrSchedQid src_task_id,
CsrSchedQid dst_taskid,
u8 get_res,
CsrSchedMsgId msg_id,
u16 prim_type,
const void *msg);
void CsrLogTimedEventIn(u32 line,
const char *file,
CsrSchedQid task_id,
CsrSchedTid tid,
u32 requested_delay,
u16 fniarg,
const void *fnvarg);
void CsrLogTimedEventFire(CsrSchedQid task_id,
CsrSchedTid tid);
void CsrLogTimedEventDone(CsrSchedQid task_id,
CsrSchedTid tid);
void CsrLogTimedEventCancel(u32 line,
const char *file,
CsrSchedQid task_id,
CsrSchedTid tid,
u8 cancel_res);
void CsrLogBgintRegister(u8 thread_id,
CsrSchedBgint irq,
const char *callback,
const void *ptr);
void CsrLogBgintUnregister(CsrSchedBgint irq);
void CsrLogBgintSet(CsrSchedBgint irq);
void CsrLogBgintServiceStart(CsrSchedBgint irq);
void CsrLogBgintServiceDone(CsrSchedBgint irq);
void CsrLogExceptionStateEvent(u16 prim_type,
CsrPrim msg_type,
u16 state,
u32 line,
const char *file);
void CsrLogExceptionGeneral(u16 prim_type,
u16 state,
const char *text,
u32 line,
const char *file);
void CsrLogExceptionWarning(u16 prim_type,
u16 state,
const char *text,
u32 line,
const char *file);
#endif
#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_log.h"
/*--------------------------------------------*/
/* Filtering on log text warning levels */
/*--------------------------------------------*/
typedef u32 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 u16'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 u32 CsrLogTextTaskId;
#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_log_configure.h"
typedef struct CsrLogSubOrigin
{
u16 subOriginNumber; /* Id of the given SubOrigin */
const char *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 char *taskName, u16 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, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *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, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *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, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *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, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *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, u16 subOrigin, const char *formatString, ...);
void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *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
#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 <linux/types.h>
#define FALSE (0)
#define TRUE (1)
/*------------------------------------------------------------------*/
/* Endian conversion */
/*------------------------------------------------------------------*/
#define CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr) (((u16) ((u8 *) (ptr))[0]) | ((u16) ((u8 *) (ptr))[1]) << 8)
#define CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr) (((u32) ((u8 *) (ptr))[0]) | ((u32) ((u8 *) (ptr))[1]) << 8 | \
((u32) ((u8 *) (ptr))[2]) << 16 | ((u32) ((u8 *) (ptr))[3]) << 24)
#define CSR_COPY_UINT16_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x00FF)); \
((u8 *) (ptr))[1] = ((u8) ((uint) >> 8))
#define CSR_COPY_UINT32_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x000000FF)); \
((u8 *) (ptr))[1] = ((u8) (((uint) >> 8) & 0x000000FF)); \
((u8 *) (ptr))[2] = ((u8) (((uint) >> 16) & 0x000000FF)); \
((u8 *) (ptr))[3] = ((u8) (((uint) >> 24) & 0x000000FF))
/*------------------------------------------------------------------*/
/* Misc */
/*------------------------------------------------------------------*/
/* 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))
#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.
*****************************************************************************/
#ifndef CsrMsgTransport
#define CsrMsgTransport CsrSchedMessagePut
#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 <linux/types.h>
#include <linux/slab.h>
#include "csr_sched.h"
#include "csr_msgconv.h"
#include "csr_macro.h"
static CsrMsgConvEntry *converter;
CsrMsgConvPrimEntry *CsrMsgConvFind(u16 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, u16 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(u16 primType,
size_t length,
u8 *data)
{
CsrMsgConvPrimEntry *ptr;
u8 *ret;
ptr = CsrMsgConvFind(primType);
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
u16 msgId = 0;
size_t 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 size_t sizeof_message(u16 primType, void *msg)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
size_t ret;
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
u16 msgId = *(u16 *) msg;
cv = find_msg_converter(ptr, msgId);
if (cv)
{
ret = cv->sizeofFunc(msg);
}
else
{
ret = 0;
}
}
else
{
ret = 0;
}
return ret;
}
static u8 free_message(u16 primType, u8 *data)
{
CsrMsgConvPrimEntry *ptr;
u8 ret;
ptr = CsrMsgConvFind(primType);
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
u16 msgId = *(u16 *) data;
cv = find_msg_converter(ptr, msgId);
if (cv)
{
cv->freeFunc(data);
ret = TRUE;
}
else
{
ret = FALSE;
}
}
else
{
ret = FALSE;
}
return ret;
}
static u8 *serialize_message(u16 primType,
void *msg,
size_t *length,
u8 *buffer)
{
CsrMsgConvPrimEntry *ptr;
u8 *ret;
ptr = CsrMsgConvFind(primType);
*length = 0;
if (ptr)
{
const CsrMsgConvMsgEntry *cv;
cv = find_msg_converter(ptr, *(u16 *) msg);
if (cv)
{
ret = cv->serFunc(buffer, length, msg);
}
else
{
ret = NULL;
}
}
else
{
ret = NULL;
}
return ret;
}
size_t CsrMsgConvSizeof(u16 primType, void *msg)
{
return sizeof_message(primType, msg);
}
u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg)
{
if (converter)
{
size_t serializedLength;
u8 *bufSerialized;
u8 *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(u16 primType, const CsrMsgConvMsgEntry *ce)
{
CsrMsgConvPrimEntry *pc;
pc = CsrMsgConvFind(primType);
if (pc)
{
/* Already registered. Do nothing */
}
else
{
pc = kmalloc(sizeof(*pc), GFP_KERNEL);
pc->primType = primType;
pc->conv = ce;
pc->lookupFunc = NULL;
pc->next = converter->profile_converters;
converter->profile_converters = pc;
}
}
EXPORT_SYMBOL_GPL(CsrMsgConvInsert);
CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr)
{
return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
}
return NULL;
}
EXPORT_SYMBOL_GPL(CsrMsgConvFindEntry);
CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr && msg)
{
u16 msgType = *((u16 *) msg);
return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
}
return NULL;
}
void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc)
{
CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
if (ptr)
{
ptr->lookupFunc = lookupFunc;
}
}
EXPORT_SYMBOL_GPL(CsrMsgConvCustomLookupRegister);
CsrMsgConvEntry *CsrMsgConvInit(void)
{
if (!converter)
{
converter = kmalloc(sizeof(CsrMsgConvEntry), GFP_KERNEL);
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);
#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 <linux/types.h>
#include "csr_prim_defs.h"
#include "csr_sched.h"
typedef size_t (CsrMsgSizeofFunc)(void *msg);
typedef u8 *(CsrMsgSerializeFunc)(u8 *buffer, size_t *length, void *msg);
typedef void (CsrMsgFreeFunc)(void *msg);
typedef void *(CsrMsgDeserializeFunc)(u8 *buffer, size_t length);
/* Converter entry for one message type */
typedef struct CsrMsgConvMsgEntry
{
u16 msgType;
CsrMsgSizeofFunc *sizeofFunc;
CsrMsgSerializeFunc *serFunc;
CsrMsgDeserializeFunc *deserFunc;
CsrMsgFreeFunc *freeFunc;
} CsrMsgConvMsgEntry;
/* Optional lookup function */
typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, u16 msgType);
/* All converter entries for one specific primitive */
typedef struct CsrMsgConvPrimEntry
{
u16 primType;
const CsrMsgConvMsgEntry *conv;
CsrMsgCustomLookupFunc *lookupFunc;
struct CsrMsgConvPrimEntry *next;
} CsrMsgConvPrimEntry;
typedef struct
{
CsrMsgConvPrimEntry *profile_converters;
void *(*deserialize_data)(u16 primType, size_t length, u8 * data);
u8 (*free_message)(u16 primType, u8 *data);
size_t (*sizeof_message)(u16 primType, void *msg);
u8 *(*serialize_message)(u16 primType, void *msg,
size_t * length,
u8 * buffer);
} CsrMsgConvEntry;
size_t CsrMsgConvSizeof(u16 primType, void *msg);
u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg);
void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc);
void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce);
CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType);
CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType);
CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg);
CsrMsgConvEntry *CsrMsgConvInit(void);
/* Prototypes for primitive type serializers */
void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value);
void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value);
void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value);
void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length);
void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value);
void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset);
void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset);
void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset);
void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length);
void CsrCharStringDes(char **value, u8 *buffer, size_t *offset);
#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.
*****************************************************************************/
/************************************************************************************
* Segmentation of primitives in upstream and downstream segment
************************************************************************************/
typedef u16 CsrPrim;
#define CSR_PRIM_UPSTREAM ((CsrPrim) (0x8000))
/************************************************************************************
* Primitive definitions for Synergy framework
************************************************************************************/
#define CSR_SYNERGY_EVENT_CLASS_BASE ((u16) (0x0600))
#define CSR_HCI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_BCCMD_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_HQ_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_VM_PRIM ((u16) (0x0003 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_TM_BLUECORE_PRIM ((u16) (0x0004 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_FP_PRIM ((u16) (0x0005 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_IP_SOCKET_PRIM ((u16) (0x0006 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_IP_ETHER_PRIM ((u16) (0x0007 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_IP_IFCONFIG_PRIM ((u16) (0x0008 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_IP_INTERNAL_PRIM ((u16) (0x0009 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_FSAL_PRIM ((u16) (0x000A | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_DATA_STORE_PRIM ((u16) (0x000B | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_AM_PRIM ((u16) (0x000C | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_TLS_PRIM ((u16) (0x000D | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_DHCP_SERVER_PRIM ((u16) (0x000E | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_TFTP_PRIM ((u16) (0x000F | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_DSPM_PRIM ((u16) (0x0010 | CSR_SYNERGY_EVENT_CLASS_BASE))
#define CSR_TLS_INTERNAL_PRIM ((u16) (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 ((u16) (0x06A0))
#define CSR_UI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
#define CSR_APP_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
#define CSR_SDIO_PROBE_PRIM ((u16) (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 ((u16) (0x00FF | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
#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.
*****************************************************************************/
typedef u16 CsrResult;
#define CSR_RESULT_SUCCESS ((CsrResult) 0x0000)
#define CSR_RESULT_FAILURE ((CsrResult) 0xFFFF)
#endif
#ifndef CSR_SCHED_H__
#define CSR_SCHED_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/types.h>
#include "csr_time.h"
/* An identifier issued by the scheduler. */
typedef u32 CsrSchedIdentifier;
/* A task identifier */
typedef u16 CsrSchedTaskId;
/* A queue identifier */
typedef u16 CsrSchedQid;
/* A message identifier */
typedef CsrSchedIdentifier CsrSchedMsgId;
/* A timer event identifier */
typedef CsrSchedIdentifier CsrSchedTid;
#define CSR_SCHED_TID_INVALID ((CsrSchedTid) 0)
/* Time constants. */
#define CSR_SCHED_TIME_MAX (0xFFFFFFFF)
#define CSR_SCHED_MILLISECOND (1000)
#define CSR_SCHED_SECOND (1000 * CSR_SCHED_MILLISECOND)
#define CSR_SCHED_MINUTE (60 * CSR_SCHED_SECOND)
/* Queue and primitive that identifies the environment */
#define CSR_SCHED_TASK_ID 0xFFFF
#define CSR_SCHED_PRIM (CSR_SCHED_TASK_ID)
#define CSR_SCHED_EXCLUDED_MODULE_QUEUE 0xFFFF
/*
* Background interrupt definitions
*/
typedef u16 CsrSchedBgint;
#define CSR_SCHED_BGINT_INVALID ((CsrSchedBgint) 0xFFFF)
/*----------------------------------------------------------------------------*
* NAME
* CsrSchedMessagePut
*
* DESCRIPTION
* Sends a message consisting of the integer "mi" and the void * pointer
* "mv" to the message queue "q".
*
* "mi" and "mv" are neither inspected nor changed by the scheduler - the
* task that owns "q" is expected to make sense of the values. "mv" may
* be null.
*
* NOTE
* If "mv" is not null then it will typically be a chunk of kmalloc()ed
* memory, though there is no need for it to be so. Tasks should normally
* obey the convention that when a message built with kmalloc()ed memory
* is given to CsrSchedMessagePut() then ownership of the memory is ceded to the
* scheduler - and eventually to the recipient task. I.e., the receiver of
* the message will be expected to kfree() the message storage.
*
* RETURNS
* void.
*
*----------------------------------------------------------------------------*/
#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
void CsrSchedMessagePutStringLog(CsrSchedQid q,
u16 mi,
void *mv,
u32 line,
const char *file);
#define CsrSchedMessagePut(q, mi, mv) CsrSchedMessagePutStringLog((q), (mi), (mv), __LINE__, __FILE__)
#else
void CsrSchedMessagePut(CsrSchedQid q,
u16 mi,
void *mv);
#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/module.h>
#include <linux/slab.h>
#include "csr_prim_defs.h"
#include "csr_msgconv.h"
#include "csr_macro.h"
void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset)
{
*value = buffer[*offset];
*offset += sizeof(*value);
}
EXPORT_SYMBOL_GPL(CsrUint8Des);
void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset)
{
*value = (buffer[*offset + 0] << 0) |
(buffer[*offset + 1] << 8);
*offset += sizeof(*value);
}
EXPORT_SYMBOL_GPL(CsrUint16Des);
void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset)
{
*value = (buffer[*offset + 0] << 0) |
(buffer[*offset + 1] << 8) |
(buffer[*offset + 2] << 16) |
(buffer[*offset + 3] << 24);
*offset += sizeof(*value);
}
EXPORT_SYMBOL_GPL(CsrUint32Des);
void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length)
{
memcpy(value, &buffer[*offset], length);
*offset += length;
}
EXPORT_SYMBOL_GPL(CsrMemCpyDes);
void CsrCharStringDes(char **value, u8 *buffer, size_t *offset)
{
*value = kstrdup((char *) &buffer[*offset], GFP_KERNEL);
*offset += strlen(*value) + 1;
}
EXPORT_SYMBOL_GPL(CsrCharStringDes);
void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value)
{
buffer[*offset] = value;
*offset += sizeof(value);
}
EXPORT_SYMBOL_GPL(CsrUint8Ser);
void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value)
{
buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
*offset += sizeof(value);
}
EXPORT_SYMBOL_GPL(CsrUint16Ser);
void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value)
{
buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
buffer[*offset + 2] = (u8) ((value >> 16) & 0xFF);
buffer[*offset + 3] = (u8) ((value >> 24) & 0xFF);
*offset += sizeof(value);
}
EXPORT_SYMBOL_GPL(CsrUint32Ser);
void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length)
{
memcpy(&buffer[*offset], value, length);
*offset += length;
}
EXPORT_SYMBOL_GPL(CsrMemCpySer);
void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value)
{
if (value)
{
strcpy(((char *) &buffer[*offset]), value);
*offset += strlen(value) + 1;
}
else
{
CsrUint8Ser(buffer, offset, 0);
}
}
EXPORT_SYMBOL_GPL(CsrCharStringSer);
/*****************************************************************************
(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/time.h>
#include <linux/module.h>
#include "csr_time.h"
u32 CsrTimeGet(u32 *high)
{
struct timespec ts;
u64 time;
u32 low;
ts = current_kernel_time();
time = (u64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
if (high != NULL)
*high = (u32) ((time >> 32) & 0xFFFFFFFF);
low = (u32) (time & 0xFFFFFFFF);
return low;
}
EXPORT_SYMBOL_GPL(CsrTimeGet);
#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 <linux/types.h>
/*******************************************************************************
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.
*******************************************************************************/
u32 CsrTimeGet(u32 *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) ((s32) (t1) - (s32) (t2))
#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/module.h>
MODULE_DESCRIPTION("CSR Operating System Kernel Abstraction");
MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
MODULE_LICENSE("GPL and additional rights");
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifndef CSR_WIFI_COMMON_H__
#define CSR_WIFI_COMMON_H__
#include <linux/types.h>
#include "csr_result.h"
/* MAC address */
typedef struct
{
u8 a[6];
} CsrWifiMacAddress;
/* IPv4 address */
typedef struct
{
u8 a[4];
} CsrWifiIp4Address;
/* IPv6 address */
typedef struct
{
u8 a[16];
} CsrWifiIp6Address;
typedef struct
{
u8 ssid[32];
u8 length;
} CsrWifiSsid;
/*******************************************************************************
DESCRIPTION
Result values used on the Wifi Interfaces
VALUES
CSR_RESULT_SUCCESS
- The request/procedure succeeded
CSR_RESULT_FAILURE
- The request/procedure did not succeed because of an error
CSR_WIFI_RESULT_NOT_FOUND
- The request did not succeed because some resource was not
found.
CSR_WIFI_RESULT_TIMED_OUT
- The request/procedure did not succeed because of a time out
CSR_WIFI_RESULT_CANCELLED
- The request was canceled due to another conflicting
request that was issued before this one was completed
CSR_WIFI_RESULT_INVALID_PARAMETER
- The request/procedure did not succeed because it had an
invalid parameter
CSR_WIFI_RESULT_NO_ROOM
- The request did not succeed due to a lack of resources,
e.g. out of memory problem.
CSR_WIFI_RESULT_UNSUPPORTED
- The request/procedure did not succeed because the feature
is not supported yet
CSR_WIFI_RESULT_UNAVAILABLE
- The request cannot be processed at this time
CSR_WIFI_RESULT_WIFI_OFF
- The requested action is not available because Wi-Fi is
currently off
CSR_WIFI_RESULT_SECURITY_ERROR
- The request/procedure did not succeed because of a security
error
CSR_WIFI_RESULT_MIB_SET_FAILURE
- MIB Set Failure: either the MIB OID to be written to does
not exist or the MIB Value is invalid.
CSR_WIFI_RESULT_INVALID_INTERFACE_TAG
- The supplied Interface Tag is not valid.
CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT
- The new NOA configuration conflicts with the existing NOA configuration
hence not accepted"
*******************************************************************************/
#define CSR_WIFI_RESULT_NOT_FOUND ((CsrResult) 0x0001)
#define CSR_WIFI_RESULT_TIMED_OUT ((CsrResult) 0x0002)
#define CSR_WIFI_RESULT_CANCELLED ((CsrResult) 0x0003)
#define CSR_WIFI_RESULT_INVALID_PARAMETER ((CsrResult) 0x0004)
#define CSR_WIFI_RESULT_NO_ROOM ((CsrResult) 0x0005)
#define CSR_WIFI_RESULT_UNSUPPORTED ((CsrResult) 0x0006)
#define CSR_WIFI_RESULT_UNAVAILABLE ((CsrResult) 0x0007)
#define CSR_WIFI_RESULT_WIFI_OFF ((CsrResult) 0x0008)
#define CSR_WIFI_RESULT_SECURITY_ERROR ((CsrResult) 0x0009)
#define CSR_WIFI_RESULT_MIB_SET_FAILURE ((CsrResult) 0x000A)
#define CSR_WIFI_RESULT_INVALID_INTERFACE_TAG ((CsrResult) 0x000B)
#define CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT ((CsrResult) 0x000C)
#define CSR_WIFI_VERSION "5.1.0.0"
#endif
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifndef CSR_WIFI_FSM_H
#define CSR_WIFI_FSM_H
#include "csr_prim_defs.h"
#include "csr_log_text.h"
#include "csr_wifi_fsm_event.h"
/* including this file for CsrWifiInterfaceMode*/
#include "csr_wifi_common.h"
#define CSR_WIFI_FSM_ENV (0xFFFF)
/**
* @brief
* Toplevel FSM context data
*
* @par Description
* Holds ALL FSM static and dynamic data for a FSM
*/
typedef struct CsrWifiFsmContext CsrWifiFsmContext;
/**
* @brief
* FSM External Wakeup CallbackFunction Pointer
*
* @par Description
* Defines the external wakeup function for the FSM
* to call when an external event is injected into the systen
*
* @param[in] context : External context
*
* @return
* void
*/
typedef void (*CsrWifiFsmExternalWakupCallbackPtr)(void *context);
/**
* @brief
* Initialises a top level FSM context
*
* @par Description
* Initialises the FSM Context to an initial state and allocates
* space for "maxProcesses" number of instances
*
* @param[in] osaContext : OSA context
* @param[in] applicationContext : Internal fsm application context
* @param[in] externalContext : External context
* @param[in] maxProcesses : Max processes to allocate room for
*
* @return
* CsrWifiFsmContext* fsm context
*/
extern CsrWifiFsmContext* CsrWifiFsmInit(void *applicationContext, void *externalContext, u16 maxProcesses, CsrLogTextTaskId loggingTaskId);
/**
* @brief
* Resets the FSM's back to first conditions
*
* @par Description
* This function is used to free any dynamic resources allocated for the
* given context by CsrWifiFsmInit().
* The FSM's reset function is called to cleanup any fsm specific memory
* The reset function does NOT need to free the fsm data pointer as
* CsrWifiFsmShutdown() will do it.
* the FSM's init function is call again to reinitialise the FSM context.
* CsrWifiFsmReset() should NEVER be called when CsrWifiFsmExecute() is running.
*
* @param[in] context : FSM context
*
* @return
* void
*/
extern void CsrWifiFsmReset(CsrWifiFsmContext *context);
/**
* @brief
* Frees resources allocated by CsrWifiFsmInit
*
* @par Description
* This function is used to free any dynamic resources allocated for the
* given context by CsrWifiFsmInit(), prior to complete termination of
* the program.
* The FSM's reset function is called to cleanup any fsm specific memory.
* The reset function does NOT need to free the fsm data pointer as
* CsrWifiFsmShutdown() will do it.
* CsrWifiFsmShutdown() should NEVER be called when CsrWifiFsmExecute() is running.
*
* @param[in] context : FSM context
*
* @return
* void
*/
extern void CsrWifiFsmShutdown(CsrWifiFsmContext *context);
/**
* @brief
* Executes the fsm context
*
* @par Description
* Executes the FSM context and runs until ALL events in the context are processed.
* When no more events are left to process then CsrWifiFsmExecute() returns to a time
* specifying when to next call the CsrWifiFsmExecute()
* Scheduling, threading, blocking and external event notification are outside
* the scope of the FSM and CsrWifiFsmExecute().
*
* @param[in] context : FSM context
*
* @return
* u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
*/
extern u32 CsrWifiFsmExecute(CsrWifiFsmContext *context);
/**
* @brief
* Adds an event to the FSM context's external event queue for processing
*
* @par Description
* Adds an event to the contexts external queue
* This is thread safe and adds an event to the fsm's external event queue.
*
* @param[in] context : FSM context
* @param[in] event : event to add to the event queue
* @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id)
* @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
* @param[in] id : event id
*
* @return
* void
*/
extern void CsrWifiFsmSendEventExternal(CsrWifiFsmContext *context, CsrWifiFsmEvent *event, u16 source, u16 destination, CsrPrim primtype, u16 id);
/**
* @brief
* Adds an Alien event to the FSM context's external event queue for processing
*
* @par Description
* Adds an event to the contexts external queue
* This is thread safe and adds an event to the fsm's external event queue.
*
* @param[in] context : FSM context
* @param[in] event : event to add to the event queue
* @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id)
* @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
* @param[in] id : event id
*/
#define CsrWifiFsmSendAlienEventExternal(_context, _alienEvent, _source, _destination, _primtype, _id) \
{ \
CsrWifiFsmAlienEvent *_evt = kmalloc(sizeof(CsrWifiFsmAlienEvent), GFP_KERNEL); \
_evt->alienEvent = _alienEvent; \
CsrWifiFsmSendEventExternal(_context, (CsrWifiFsmEvent *)_evt, _source, _destination, _primtype, _id); \
}
/**
* @brief
* Current time of day in ms
*
* @param[in] context : FSM context
*
* @return
* u32 32 bit ms tick
*/
extern u32 CsrWifiFsmGetTimeOfDayMs(CsrWifiFsmContext *context);
/**
* @brief
* Gets the time until the next FSM timer expiry
*
* @par Description
* Returns the next timeout time or 0 if no timers are set.
*
* @param[in] context : FSM context
*
* @return
* u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
*/
extern u32 CsrWifiFsmGetNextTimeout(CsrWifiFsmContext *context);
/**
* @brief
* Fast forwards the fsm timers by ms Milliseconds
*
* @param[in] context : FSM context
* @param[in] ms : Milliseconds to fast forward by
*
* @return
* void
*/
extern void CsrWifiFsmFastForward(CsrWifiFsmContext *context, u16 ms);
/**
* @brief
* shift the current time of day by ms amount
*
* @par Description
* useful to speed up tests where time needs to pass
*
* @param[in] context : FSM context
* @param[in] ms : ms to adjust time by
*
* @return
* void
*/
extern void CsrWifiFsmTestAdvanceTime(CsrWifiFsmContext *context, u32 ms);
/**
* @brief
* Check if the fsm has events to process
*
* @param[in] context : FSM context
*
* @return
* u8 returns TRUE if there are events for the FSM to process
*/
extern u8 CsrWifiFsmHasEvents(CsrWifiFsmContext *context);
/**
* @brief
* function that installs the contexts wakeup function
*
* @param[in] context : FSM context
* @param[in] callback : Callback function pointer
*
* @return
* void
*/
extern void CsrWifiFsmInstallWakeupCallback(CsrWifiFsmContext *context, CsrWifiFsmExternalWakupCallbackPtr callback);
#endif /* CSR_WIFI_FSM_H */
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifndef CSR_WIFI_FSM_EVENT_H
#define CSR_WIFI_FSM_EVENT_H
#include "csr_prim_defs.h"
#include "csr_sched.h"
/**
* @brief
* FSM event header.
*
* @par Description
* All events MUST have this struct as the FIRST member.
* The next member is used internally for linked lists
*/
typedef struct CsrWifiFsmEvent
{
CsrPrim type;
u16 primtype;
CsrSchedQid destination;
CsrSchedQid source;
/* Private pointer to allow an optimal Event list */
/* NOTE: Ignore this pointer.
* Do not waste code initializing OR freeing it.
* The pointer is used internally in the CsrWifiFsm code
* to avoid a second malloc when queuing events.
*/
struct CsrWifiFsmEvent *next;
} CsrWifiFsmEvent;
#endif /* CSR_WIFI_FSM_EVENT_H */
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifndef CSR_WIFI_FSM_TYPES_H
#define CSR_WIFI_FSM_TYPES_H
#include <linux/types.h>
#include "csr_macro.h"
#include "csr_sched.h"
#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
#include "csr_framework_ext.h"
#endif
#include "csr_wifi_fsm.h"
#define CSR_WIFI_FSM_MAX_TRANSITION_HISTORY 10
/**
* @brief
* FSM event list header.
*
* @par Description
* Singly linked list of events.
*/
typedef struct CsrWifiFsmEventList
{
CsrWifiFsmEvent *first;
CsrWifiFsmEvent *last;
} CsrWifiFsmEventList;
/**
* @brief
* FSM timer id.
*
* @par Description
* Composite Id made up of the type, dest and a unique id so
* CsrWifiFsmRemoveTimer knows where to look when removing the timer
*/
typedef struct CsrWifiFsmTimerId
{
CsrPrim type;
u16 primtype;
CsrSchedQid destination;
u16 uniqueid;
} CsrWifiFsmTimerId;
/**
* @brief
* FSM timer header.
*
* @par Description
* All timer MUST have this struct as the FIRST member.
* The first members of the structure MUST remain compatable
* with the CsrWifiFsmEvent so that timers are just specialised events
*/
typedef struct CsrWifiFsmTimer
{
CsrPrim type;
u16 primtype;
CsrSchedQid destination;
CsrSchedQid source;
/* Private pointer to allow an optimal Event list */
struct CsrWifiFsmTimer *next;
CsrWifiFsmTimerId timerid;
u32 timeoutTimeMs;
} CsrWifiFsmTimer;
/**
* @brief
* Fsm Alien Event
*
* @par Description
* Allows the wrapping of alien events that do not use CsrWifiFsmEvent
* as the first member of the Event struct
*/
typedef struct
{
CsrWifiFsmEvent event;
void *alienEvent;
} CsrWifiFsmAlienEvent;
/**
* @brief
* FSM timer list header.
*
* @par Description
* Singly linked list of timers.
*/
typedef struct CsrWifiFsmTimerList
{
CsrWifiFsmTimer *first;
CsrWifiFsmTimer *last;
u16 nexttimerid;
} CsrWifiFsmTimerList;
/**
* @brief
* Process Entry Function Pointer
*
* @par Description
* Defines the entry function for a processes.
* Called at process initialisation.
*
* @param[in] context : FSM context
*
* @return
* void
*/
typedef void (*CsrWifiFsmProcEntryFnPtr)(CsrWifiFsmContext *context);
/**
* @brief
* Process Transition Function Pointer
*
* @par Description
* Defines a transition function for a processes.
* Called when an event causes a transition on a process
*
* @param[in] CsrWifiFsmContext* : FSM context
* @param[in] void* : FSM data (can be NULL)
* @param[in] const CsrWifiFsmEvent* : event to process
*
* @return
* void
*/
typedef void (*CsrWifiFsmTransitionFnPtr)(CsrWifiFsmContext *context, void *fsmData, const CsrWifiFsmEvent *event);
/**
* @brief
* Process reset/shutdown Function Pointer
*
* @par Description
* Defines the reset/shutdown function for a processes.
* Called to reset or shutdown an fsm.
*
* @param[in] context : FSM context
*
* @return
* void
*/
typedef void (*CsrWifiFsmProcResetFnPtr)(CsrWifiFsmContext *context);
/**
* @brief
* FSM Default Destination CallbackFunction Pointer
*
* @par Description
* Defines the default destination function for the FSM
* to call when an event does not have a valid destination.
* This
*
* @param[in] context : External context
*
* @return
* u16 a valid destination OR CSR_WIFI_FSM_ENV
*/
typedef u16 (*CsrWifiFsmDestLookupCallbackPtr)(void *context, const CsrWifiFsmEvent *event);
#ifdef CSR_WIFI_FSM_DUMP_ENABLE
/**
* @brief
* Trace Dump Function Pointer
*
* @par Description
* Called when we want to trace the FSM
*
* @param[in] context : FSM context
* @param[in] id : fsm id
*
* @return
* void
*/
typedef void (*CsrWifiFsmDumpFnPtr)(CsrWifiFsmContext *context, void *fsmData);
#endif
/**
* @brief
* Event ID to transition function entry
*
* @par Description
* Event ID to Transition Entry in a state table.
*/
typedef struct
{
u32 eventid;
CsrWifiFsmTransitionFnPtr transition;
#ifdef CSR_LOG_ENABLE
const char *transitionName;
#endif
} CsrWifiFsmEventEntry;
/**
* @brief
* Single State's Transition Table
*
* @par Description
* Stores Data for a single State's event to
* transition functions mapping
*/
typedef struct
{
const u8 numEntries;
const u8 saveAll;
const CsrWifiFsmEventEntry *eventEntryArray; /* array of transition function pointers for state */
#ifdef CSR_LOG_ENABLE
u16 stateNumber;
const char *stateName;
#endif
} CsrWifiFsmTableEntry;
/**
* @brief
* Process State Transtion table
*
* @par Description
* Stores Data for a processes State to transition table
*/
typedef struct
{
u16 numStates; /* number of states */
const CsrWifiFsmTableEntry *aStateEventMatrix; /* state event matrix */
} CsrWifiFsmTransitionFunctionTable;
/**
* @brief
* Const Process definition
*
* @par Description
* Constant process specification.
* This is ALL the non dynamic data that defines
* a process.
*/
typedef struct
{
const char *processName;
const u32 processId;
const CsrWifiFsmTransitionFunctionTable transitionTable;
const CsrWifiFsmTableEntry unhandledTransitions;
const CsrWifiFsmTableEntry ignoreFunctions;
const CsrWifiFsmProcEntryFnPtr entryFn;
const CsrWifiFsmProcResetFnPtr resetFn;
#ifdef CSR_WIFI_FSM_DUMP_ENABLE
const CsrWifiFsmDumpFnPtr dumpFn; /* Called to dump fsm specific trace if not NULL */
#endif
} CsrWifiFsmProcessStateMachine;
#ifdef CSR_WIFI_FSM_DUMP_ENABLE
/**
* @brief
* Storage for state transition info
*/
typedef struct
{
u16 transitionNumber;
CsrWifiFsmEvent event;
u16 fromState;
u16 toState;
CsrWifiFsmTransitionFnPtr transitionFn;
u16 transitionCount; /* number consecutive of times this transition was seen */
#ifdef CSR_LOG_ENABLE
const char *transitionName;
#endif
} CsrWifiFsmTransitionRecord;
/**
* @brief
* Storage for the last state X transitions
*/
typedef struct
{
u16 numTransitions;
CsrWifiFsmTransitionRecord records[CSR_WIFI_FSM_MAX_TRANSITION_HISTORY];
} CsrWifiFsmTransitionRecords;
#endif
/**
* @brief
* Dynamic Process data
*
* @par Description
* Dynamic process data that is used to keep track of the
* state and data for a process instance
*/
typedef struct
{
const CsrWifiFsmProcessStateMachine *fsmInfo; /* state machine info that is constant regardless of context */
u16 instanceId; /* Runtime process id */
u16 state; /* Current state */
void *params; /* Instance user data */
CsrWifiFsmEventList savedEventQueue; /* The saved event queue */
struct CsrWifiFsmInstanceEntry *subFsm; /* Sub Fsm instance data */
struct CsrWifiFsmInstanceEntry *subFsmCaller; /* The Fsm instance that created the SubFsm and should be used for callbacks*/
#ifdef CSR_WIFI_FSM_DUMP_ENABLE
CsrWifiFsmTransitionRecords transitionRecords; /* Last X transitions in the FSM */
#endif
} CsrWifiFsmInstanceEntry;
/**
* @brief
* OnCreate Callback Function Pointer
*
* @par Description
* Called when an fsm is created.
*
* @param[in] extContext : External context
* @param[in] instance : FSM instance
*
* @return
* void
*/
typedef void (*CsrWifiFsmOnCreateFnPtr)(void *extContext, const CsrWifiFsmInstanceEntry *instance);
/**
* @brief
* OnTransition Callback Function Pointer
*
* @par Description
* Called when an event is processed by a fsm
*
* @param[in] extContext : External context
* @param[in] eventEntryArray : Entry data
* @param[in] event : Event
*
* @return
* void
*/
typedef void (*CsrWifiFsmOnTransitionFnPtr)(void *extContext, const CsrWifiFsmEventEntry *eventEntryArray, const CsrWifiFsmEvent *event);
/**
* @brief
* OnStateChange Callback Function Pointer
*
* @par Description
* Called when CsrWifiFsmNextState is called
*
* @param[in] extContext : External context
*
* @return
* void
*/
typedef void (*CsrWifiFsmOnStateChangeFnPtr)(void *extContext, u16 nextstate);
/**
* @brief
* OnIgnore,OnError or OnInvalid Callback Function Pointer
*
* @par Description
* Called when an event is processed by a fsm
*
* @param[in] extContext : External context
* @param[in] event : Event
*
* @return
* void
*/
typedef void (*CsrWifiFsmOnEventFnPtr)(void *extContext, const CsrWifiFsmEvent *event);
/**
* @brief
* Toplevel FSM context data
*
* @par Description
* Holds ALL FSM static and dynamic data for a FSM
*/
struct CsrWifiFsmContext
{
CsrWifiFsmEventList eventQueue; /* The internal event queue */
CsrWifiFsmEventList externalEventQueue; /* The external event queue */
#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
CsrMutexHandle externalEventQueueLock; /* The external event queue mutex */
#endif
u32 timeOffset; /* Amount to adjust the TimeOfDayMs by */
CsrWifiFsmTimerList timerQueue; /* The internal timer queue */
u8 useTempSaveList; /* Should the temp save list be used */
CsrWifiFsmEventList tempSaveList; /* The temp save event queue */
CsrWifiFsmEvent *eventForwardedOrSaved; /* The event that was forwarded or Saved */
u16 maxProcesses; /* Size of instanceArray */
u16 numProcesses; /* Current number allocated in instanceArray */
CsrWifiFsmInstanceEntry *instanceArray; /* Array of processes for this component */
CsrWifiFsmInstanceEntry *ownerInstance; /* The Process that owns currentInstance (SubFsm support) */
CsrWifiFsmInstanceEntry *currentInstance; /* Current Process that is executing */
CsrWifiFsmExternalWakupCallbackPtr externalEventFn; /* External event Callback */
CsrWifiFsmOnEventFnPtr appIgnoreCallback; /* Application Ignore event Callback */
CsrWifiFsmDestLookupCallbackPtr appEvtDstCallback; /* Application Lookup event Destination Function*/
void *applicationContext; /* Internal fsm application context */
void *externalContext; /* External context (set by the user of the fsm)*/
CsrLogTextTaskId loggingTaskId; /* Task Id to use in any logging output */
#ifndef CSR_WIFI_FSM_SCHEDULER_DISABLED
CsrSchedTid schedTimerId; /* Scheduler TimerId for use in Scheduler Tasks */
u32 schedTimerNexttimeoutMs; /* Next timeout time for the current timer */
#endif
#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
#ifdef CSR_WIFI_FSM_TRANSITION_LOCK
CsrMutexHandle transitionLock; /* Lock when calling transition functions */
#endif
#endif
#ifdef CSR_LOG_ENABLE
CsrWifiFsmOnCreateFnPtr onCreate; /* Debug Transition Callback */
CsrWifiFsmOnTransitionFnPtr onTransition; /* Debug Transition Callback */
CsrWifiFsmOnTransitionFnPtr onUnhandedCallback; /* Unhanded event Callback */
CsrWifiFsmOnStateChangeFnPtr onStateChange; /* Debug State Change Callback */
CsrWifiFsmOnEventFnPtr onIgnoreCallback; /* Ignore event Callback */
CsrWifiFsmOnEventFnPtr onSaveCallback; /* Save event Callback */
CsrWifiFsmOnEventFnPtr onErrorCallback; /* Error event Callback */
CsrWifiFsmOnEventFnPtr onInvalidCallback; /* Invalid event Callback */
#endif
#ifdef CSR_WIFI_FSM_DUMP_ENABLE
u16 masterTransitionNumber; /* Increments on every transition */
#endif
};
#endif /* CSR_WIFI_FSM_TYPES_H */
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2012
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
/*
******************************************************************************
* FILE : csr_wifi_hip_card.h
*
* PURPOSE : Defines abstract interface for hardware specific functions.
* Note, this is a different file from one of the same name in the
* Windows driver.
*
*****************************************************************************
*/
#ifndef __CARD_H__
#define __CARD_H__
#include "csr_wifi_hip_card_sdio.h"
#include "csr_wifi_hip_signals.h"
#include "csr_wifi_hip_unifi_udi.h"
/*****************************************************************************
* CardEnableInt -
*/
CsrResult CardEnableInt(card_t *card);
/*****************************************************************************
* CardGenInt -
*/
CsrResult CardGenInt(card_t *card);
/*****************************************************************************
* CardPendingInt -
*/
CsrResult CardPendingInt(card_t *card, u8 *pintr);
/*****************************************************************************
* CardDisableInt -
*/
CsrResult CardDisableInt(card_t *card);
/*****************************************************************************
* CardClearInt -
*/
CsrResult CardClearInt(card_t *card);
/*****************************************************************************
* CardDisable -
*/
void CardDisable(card_t *card);
/*****************************************************************************
* CardIntEnabled -
*/
CsrResult CardIntEnabled(card_t *card, u8 *enabled);
/*****************************************************************************
* CardGetDataSlotSize
*/
u16 CardGetDataSlotSize(card_t *card);
/*****************************************************************************
* CardWriteBulkData -
*/
CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue);
/*****************************************************************************
* CardClearFromHostDataSlot -
*/
void CardClearFromHostDataSlot(card_t *card, const s16 aSlotNum);
#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
/*****************************************************************************
* CardClearFromHostDataSlotWithoutFreeingBulkData - Clear the data stot
* without freeing the bulk data
*/
void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 aSlotNum);
#endif
/*****************************************************************************
* CardGetFreeFromHostDataSlots -
*/
u16 CardGetFreeFromHostDataSlots(card_t *card);
u16 CardAreAllFromHostDataSlotsEmpty(card_t *card);
CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which);
CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr);
CsrResult unifi_dl_firmware(card_t *card, void *arg);
CsrResult unifi_dl_patch(card_t *card, void *arg, u32 boot_ctrl);
CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode);
void* unifi_dl_fw_read_start(card_t *card, s8 is_fw);
CsrResult unifi_coredump_handle_request(card_t *card);
CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult);
#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
void unifi_debug_log_to_buf(const char *fmt, ...);
void unifi_debug_string_to_buf(const char *str);
void unifi_debug_hex_to_buf(const char *buff, u16 length);
#endif
#endif /* __CARD_H__ */
此差异已折叠。
此差异已折叠。
此差异已折叠。
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifndef CSR_WIFI_HIP_CHIPHELPER_H__
#define CSR_WIFI_HIP_CHIPHELPER_H__
#include <linux/types.h>
/* The age of the BlueCore chip. This is probably not useful, if
you know the age then you can probably work out the version directly. */
enum chip_helper_bluecore_age
{
chip_helper_bluecore_pre_bc7,
chip_helper_bluecore_bc7_or_later
};
/* We support up to three windowed regions at the moment.
Don't reorder these - they're used to index into an array. */
enum chip_helper_window_index
{
CHIP_HELPER_WINDOW_1 = 0,
CHIP_HELPER_WINDOW_2 = 1,
CHIP_HELPER_WINDOW_3 = 2,
CHIP_HELPER_WINDOW_COUNT = 3
};
/* These are the things that we can access through a window.
Don't reorder these - they're used to index into an array. */
enum chip_helper_window_type
{
CHIP_HELPER_WT_CODE_RAM = 0,
CHIP_HELPER_WT_FLASH = 1,
CHIP_HELPER_WT_EXT_SRAM = 2,
CHIP_HELPER_WT_ROM = 3,
CHIP_HELPER_WT_SHARED = 4,
CHIP_HELPER_WT_COUNT = 5
};
/* Commands to stop and start the XAP */
enum chip_helper_dbg_emu_cmd_enum
{
CHIP_HELPER_DBG_EMU_CMD_XAP_STEP_MASK = 0x0001,
CHIP_HELPER_DBG_EMU_CMD_XAP_RUN_B_MASK = 0x0002,
CHIP_HELPER_DBG_EMU_CMD_XAP_BRK_MASK = 0x0004,
CHIP_HELPER_DBG_EMU_CMD_XAP_WAKEUP_MASK = 0x0008
};
/* Bitmasks for Stop and sleep status: DBG_SPI_STOP_STATUS & DBG_HOST_STOP_STATUS */
enum chip_helper_dbg_stop_status_enum
{
CHIP_HELPER_DBG_STOP_STATUS_NONE_MASK = 0x0000,
CHIP_HELPER_DBG_STOP_STATUS_P0_MASK = 0x0001,
CHIP_HELPER_DBG_STOP_STATUS_P1_MASK = 0x0002,
CHIP_HELPER_DBG_STOP_STATUS_P2_MASK = 0x0004,
CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P0_MASK = 0x0008,
CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P1_MASK = 0x0010,
CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P2_MASK = 0x0020,
/* Legacy names/alias */
CHIP_HELPER_DBG_STOP_STATUS_MAC_MASK = 0x0001,
CHIP_HELPER_DBG_STOP_STATUS_PHY_MASK = 0x0002,
CHIP_HELPER_DBG_STOP_STATUS_BT_MASK = 0x0004,
CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_MAC_MASK = 0x0008,
CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_PHY_MASK = 0x0010,
CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_BT_MASK = 0x0020
};
/* Codes to disable the watchdog */
enum chip_helper_watchdog_disable_enum
{
CHIP_HELPER_WATCHDOG_DISABLE_CODE1 = 0x6734,
CHIP_HELPER_WATCHDOG_DISABLE_CODE2 = 0xD6BF,
CHIP_HELPER_WATCHDOG_DISABLE_CODE3 = 0xC31E
};
/* Other bits have changed between versions */
enum chip_helper_gbl_misc_enum
{
CHIP_HELPER_GBL_MISC_SPI_STOP_OUT_EN_MASK = 0x0001,
CHIP_HELPER_GBL_MISC_MMU_INIT_DONE_MASK = 0x0004
};
/* Coex status register, contains interrupt status and reset pullup status.
* CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK can be used to check
* for WAPI on R03 chips and later. */
enum chip_helper_coex_status_mask_enum
{
CHIP_HELPER_COEX_STATUS_RST_PULLS_LSB_MASK = 0x0001,
CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK = 0x0008,
CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_LSB_MASK = 0x0010,
CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_MSB_MASK = 0x0080,
CHIP_HELPER_COEX_STATUS_INT_UART_MASK = 0x0100,
CHIP_HELPER_COEX_STATUS_INT_BT_LEG_MASK = 0x0200
};
/* How to select the different CPUs */
enum chip_helper_dbg_proc_sel_enum
{
CHIP_HELPER_DBG_PROC_SEL_MAC = 0,
CHIP_HELPER_DBG_PROC_SEL_PHY = 1,
CHIP_HELPER_DBG_PROC_SEL_BT = 2,
CHIP_HELPER_DBG_PROC_SEL_NONE = 2,
CHIP_HELPER_DBG_PROC_SEL_BOTH = 3
};
/* These are the only registers that we have to know the
address of before we know the chip version. */
enum chip_helper_fixed_registers
{
/* This is the address of GBL_CHIP_VERISON on BC7,
UF105x, UF60xx and
anything later than that. */
CHIP_HELPER_UNIFI_GBL_CHIP_VERSION = 0xFE81,
CHIP_HELPER_OLD_BLUECORE_GBL_CHIP_VERSION = 0xFF9A
/* This isn't used at the moment (but might be needed
to distinguish the BlueCore sub version?) */
/* CHIP_HELPER_OLD_BLUECORE_ANA_VERSION_ID = 0xFF7D */
};
/* Address-value pairs for defining initialisation values */
struct chip_helper_init_values
{
u16 addr;
u16 value;
};
/* A block of data that should be written to the device */
struct chip_helper_reset_values
{
u32 gp_address;
u32 len;
const u16 *data;
};
/*
* This is the C API.
*/
/* opaque type */
typedef const struct chip_device_desc_t ChipDescript;
/* Return a NULL descriptor */
ChipDescript* ChipHelper_Null(void);
/* This should get the correct version for any CSR chip.
The two parameters are what is read from addresses
0xFF9A and 0xFE81 (OLD_BLUECORE_GBL_CHIP_VERSION and
UNIFI_GBL_CHIP_VERSION). These should give a unique identity
for most (all?) chips.
FF9A is the old GBL_CHIP_VERSION register. If the high
eight bits are zero then the chip is a new (BC7 +) one
and FE81 is the _new_ GBL_CHIP_VERSION register. */
ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81);
/* The chip is a UniFi, but we don't know which type
The parameter is the value of UNIFI_GBL_CHIP_VERSION (0xFE81) */
ChipDescript* ChipHelper_GetVersionUniFi(u16 version);
/* This gets the version from the SDIO device id. This only
gives quite a coarse grained version, so we should update once
we hav access to the function N registers. */
ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_version);
/* The chip is some sort of BlueCore. If "age" is "pre_bc7" then
"version" is what was read from FF9A. If "age" is bc7_or_later
then "version" is read from FE81. If we don't know if we're pre
or post BC7 then we should use "GetVersionAny". */
ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age age,
u16 version);
/* The main functions of this class are built with an X macro. This
means we can generate the C and C++ versions from the same source
without the two diverging.
The DEF0 functions are simple and take no parameters. The first
parameter to the macro is the return type. The second parameter
is the function name and the third parameter is where to get the
info from (this is hidden from the user).
The DEF1 functions take one parameter. This time the third macro
parameter is the type of this parameter, and the fourth macro
parameter is the name of the parameter. The bodies of these
functions are hand written. */
#define CHIP_HELPER_LIST(m) \
CHIP_HELPER_DEF0(m, (const char *, FriendlyName, friendly_name)) \
CHIP_HELPER_DEF0(m, (const char *, MarketingName, marketing_name)) \
CHIP_HELPER_DEF0(m, (u16, DBG_EMU_CMD, regs->dbg_emu_cmd)) \
CHIP_HELPER_DEF0(m, (u16, DBG_HOST_PROC_SELECT, regs->host.dbg_proc_select)) \
CHIP_HELPER_DEF0(m, (u16, DBG_HOST_STOP_STATUS, regs->host.dbg_stop_status)) \
CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW1_PAGE, regs->host.window1_page)) \
CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW2_PAGE, regs->host.window2_page)) \
CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW3_PAGE, regs->host.window3_page)) \
CHIP_HELPER_DEF0(m, (u16, HOST_IO_LOG_ADDR, regs->host.io_log_addr)) \
CHIP_HELPER_DEF0(m, (u16, DBG_SPI_PROC_SELECT, regs->spi.dbg_proc_select)) \
CHIP_HELPER_DEF0(m, (u16, DBG_SPI_STOP_STATUS, regs->spi.dbg_stop_status)) \
CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW1_PAGE, regs->spi.window1_page)) \
CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW2_PAGE, regs->spi.window2_page)) \
CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW3_PAGE, regs->spi.window3_page)) \
CHIP_HELPER_DEF0(m, (u16, SPI_IO_LOG_ADDR, regs->spi.io_log_addr)) \
CHIP_HELPER_DEF0(m, (u16, DBG_RESET, regs->dbg_reset)) \
CHIP_HELPER_DEF0(m, (u16, DBG_RESET_VALUE, regs->dbg_reset_value)) \
CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN, regs->dbg_reset_warn)) \
CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN_VALUE, regs->dbg_reset_warn_value)) \
CHIP_HELPER_DEF0(m, (u16, DBG_RESET_RESULT, regs->dbg_reset_result)) \
CHIP_HELPER_DEF0(m, (u16, WATCHDOG_DISABLE, regs->watchdog_disable)) \
CHIP_HELPER_DEF0(m, (u16, PROC_PC_SNOOP, regs->proc_pc_snoop)) \
CHIP_HELPER_DEF0(m, (u16, GBL_CHIP_VERSION, regs->gbl_chip_version)) \
CHIP_HELPER_DEF0(m, (u16, GBL_MISC_ENABLES, regs->gbl_misc_enables)) \
CHIP_HELPER_DEF0(m, (u16, XAP_PCH, regs->xap_pch)) \
CHIP_HELPER_DEF0(m, (u16, XAP_PCL, regs->xap_pcl)) \
CHIP_HELPER_DEF0(m, (u16, MAILBOX0, regs->mailbox0)) \
CHIP_HELPER_DEF0(m, (u16, MAILBOX1, regs->mailbox1)) \
CHIP_HELPER_DEF0(m, (u16, MAILBOX2, regs->mailbox2)) \
CHIP_HELPER_DEF0(m, (u16, MAILBOX3, regs->mailbox3)) \
CHIP_HELPER_DEF0(m, (u16, SDIO_HIP_HANDSHAKE, regs->sdio_hip_handshake)) \
CHIP_HELPER_DEF0(m, (u16, SDIO_HOST_INT, regs->sdio_host_int)) \
CHIP_HELPER_DEF0(m, (u16, COEX_STATUS, regs->coex_status)) \
CHIP_HELPER_DEF0(m, (u16, SHARED_IO_INTERRUPT, regs->shared_io_interrupt)) \
CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_RAM_OFFSET, prog_offset.ram)) \
CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_ROM_OFFSET, prog_offset.rom)) \
CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_FLASH_OFFSET, prog_offset.flash)) \
CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_EXT_SRAM_OFFSET, prog_offset.ext_sram)) \
CHIP_HELPER_DEF0(m, (u16, DATA_MEMORY_RAM_OFFSET, data_offset.ram)) \
CHIP_HELPER_DEF0(m, (s32, HasFlash, bools.has_flash)) \
CHIP_HELPER_DEF0(m, (s32, HasExtSram, bools.has_ext_sram)) \
CHIP_HELPER_DEF0(m, (s32, HasRom, bools.has_rom)) \
CHIP_HELPER_DEF0(m, (s32, HasBt, bools.has_bt)) \
CHIP_HELPER_DEF0(m, (s32, HasWLan, bools.has_wlan)) \
CHIP_HELPER_DEF1(m, (u16, WINDOW_ADDRESS, enum chip_helper_window_index, window)) \
CHIP_HELPER_DEF1(m, (u16, WINDOW_SIZE, enum chip_helper_window_index, window)) \
CHIP_HELPER_DEF1(m, (u16, MapAddress_SPI2HOST, u16, addr)) \
CHIP_HELPER_DEF1(m, (u16, MapAddress_HOST2SPI, u16, addr)) \
CHIP_HELPER_DEF1(m, (u32, ClockStartupSequence, const struct chip_helper_init_values **, val)) \
CHIP_HELPER_DEF1(m, (u32, HostResetSequence, const struct chip_helper_reset_values **, val))
/* Some magic to help the expansion */
#define CHIP_HELPER_DEF0(a, b) \
CHIP_HELPER_DEF0_ ## a b
#define CHIP_HELPER_DEF1(a, b) \
CHIP_HELPER_DEF1_ ## a b
/* Macros so that when we expand the list we get "C" function prototypes. */
#define CHIP_HELPER_DEF0_C_DEC(ret_type, name, info) \
ret_type ChipHelper_ ## name(ChipDescript * chip_help);
#define CHIP_HELPER_DEF1_C_DEC(ret_type, name, type1, name1) \
ret_type ChipHelper_ ## name(ChipDescript * chip_help, type1 name1);
CHIP_HELPER_LIST(C_DEC)
/* FriendlyName
MarketingName
These two functions return human readable strings that describe
the chip. FriendlyName returns something that a software engineer
at CSR might understand. MarketingName returns something more like
an external name for a CSR chip.
*/
/* DBG_EMU_CMD
WATCHDOG_DISABLE
PROC_PC_SNOOP
GBL_CHIP_VERSION
XAP_PCH
XAP_PCL
These registers are used to control the XAPs.
*/
/* DBG_HOST_PROC_SELECT DBG_HOST_STOP_STATUS
HOST_WINDOW1_PAGE HOST_WINDOW2_PAGE HOST_WINDOW3_PAGE
HOST_IO_LOG_ADDR
DBG_SPI_PROC_SELECT DBG_SPI_STOP_STATUS
SPI_WINDOW1_PAGE SPI_WINDOW2_PAGE SPI_WINDOW3_PAGE
SPI_IO_LOG_ADDR
These register are used to control the XAPs and the memory
windows, normally while debugging the code on chip. There
are two versons of these registers, one for access via SPI
and another for access via the host interface.
*/
/* DBG_RESET
DBG_RESET_VALUE
DBG_RESET_WARN
DBG_RESET_WARN_VALUE
DBG_RESET_RESULT
These registers are used to reset the XAP. This can be
quite complex for some chips. If DBG_RESET_WARN is non
zero the DBG_RESET_WARN_VALUE should be written to address
DBG_RESET_WARN before the reset is perfeormed. DBG_RESET_VALUE
should then be written to DBG_RESET to make the reset happen.
The DBG_RESET_RESULT register should contain 0 if the reset
was successful.
*/
/* GBL_MISC_ENABLES
This register controls some special chip features. It
should be used with care is it changes quite a lot between
chip versions.
*/
/* MAILBOX0
MAILBOX1
MAILBOX2
MAILBOX3
The mailbox registers are for communication between the host
and the firmware. There use is described in part by the host
interface protcol specifcation.
*/
/* SDIO_HIP_HANDSHAKE
This is one of the more important SDIO HIP registers. On some
chips it has the same value as one of the mailbox registers
and on other chips it is different.
*/
/* SDIO_HOST_INT
SHARED_IO_INTERRUPT
These registers are used by some versions of the host interface
protocol specification. Their names should probably be changed
to hide the registers and to expose the functions more.
*/
/* COEX_STATUS
Coex status register, contains interrupt status and reset
pullup status. The latter is used to detect WAPI.
*/
/* PROGRAM_MEMORY_RAM_OFFSET
PROGRAM_MEMORY_ROM_OFFSET
PROGRAM_MEMORY_FLASH_OFFSET
PROGRAM_MEMORY_EXT_SRAM_OFFSET
DATA_MEMORY_RAM_OFFSET
These are constants that describe the offset of the different
memory types in the two different address spaces.
*/
/* HasFlash HasExtSram HasRom
HasBt HasWLan
These are a set of bools describing the chip.
*/
/* WINDOW_ADDRESS WINDOW_SIZE
These two functions return the size and address of the windows.
The address is the address of the lowest value in the address
map that is part of the window and the size is the number of
visible words.
Some of the windows have their lowest portion covered by
registers. For these windows address is the first address
after the registers and size is the siave excluding the part
covered by registers.
*/
/* MapAddress_SPI2HOST
MapAddress_HOST2SPI
The debugging interface is duplicated on UniFi and later chips
so that there are two versions - one over the SPI interaface and
the other over the SDIO interface. These functions map the
registers between these two interfaces.
*/
/* ClockStartupSequence
This function returns the list of register value pairs that
should be forced into UniFi to enable SPI communication. This
set of registers is not needed if the firmware is running, but
will be needed if the device is being booted from cold. These
register writes enable the clocks and setup the PLL to a basic
working state. SPI access might be unreliable until these writes
have occurred (And they may take mulitple goes).
*/
/* HostResetSequence
This returns a number of chunks of data and generic pointers.
All of the XAPs should be stopped. The data should be written
to the generic pointers. The instruction pointer for the MAC
should then be set to the start of program memory and then the
MAC should be "go"d. This will reset the chip in a reliable
and orderly manner without resetting the SDIO interface. It
is therefore not needed if the chip is being accessed by the
SPI interface (the DBG_RESET_ mechanism can be used instead).
*/
/* The Decode Window function is more complex. For the window
'window' it tries to return the address and page register
value needed to see offset 'offset' of memory type 'type'.
It return 1 on success and 0 on failure. 'page' is what
should be written to the page register. 'addr' is the
address in the XAPs 16 address map to read from. 'len'
is the length that we can read without having to change
the page registers. */
s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
enum chip_helper_window_index window,
enum chip_helper_window_type type,
u32 offset,
u16 *page, u16 *addr, u32 *len);
#endif
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifndef CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
#define CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
#include "csr_wifi_hip_chiphelper.h"
/* This GP stuff should be somewhere else? */
/* Memory spaces encoded in top byte of Generic Pointer type */
#define UNIFI_SH_DMEM 0x01 /* Shared Data Memory */
#define UNIFI_EXT_FLASH 0x02 /* External FLASH */
#define UNIFI_EXT_SRAM 0x03 /* External SRAM */
#define UNIFI_REGISTERS 0x04 /* Registers */
#define UNIFI_PHY_DMEM 0x10 /* PHY Data Memory */
#define UNIFI_PHY_PMEM 0x11 /* PHY Program Memory */
#define UNIFI_PHY_ROM 0x12 /* PHY ROM */
#define UNIFI_MAC_DMEM 0x20 /* MAC Data Memory */
#define UNIFI_MAC_PMEM 0x21 /* MAC Program Memory */
#define UNIFI_MAC_ROM 0x22 /* MAC ROM */
#define UNIFI_BT_DMEM 0x30 /* BT Data Memory */
#define UNIFI_BT_PMEM 0x31 /* BT Program Memory */
#define UNIFI_BT_ROM 0x32 /* BT ROM */
#define MAKE_GP(R, O) (((UNIFI_ ## R) << 24) | (O))
#define GP_OFFSET(GP) ((GP) & 0xFFFFFF)
#define GP_SPACE(GP) (((GP) >> 24) & 0xFF)
/* Address value pairs */
struct val_array_t
{
u32 len;
const struct chip_helper_init_values *vals;
};
/* Just a (counted) u16 array */
struct data_array_t
{
u32 len;
const u16 *vals;
};
struct reset_prog_t
{
u32 len;
const struct chip_helper_reset_values *vals;
};
/* The addresses of registers that are equivalent but on
different host transports. */
struct chip_map_address_t
{
u16 spi, host;
};
struct map_array_t
{
u32 len;
const struct chip_map_address_t *vals;
};
struct chip_device_regs_per_transport_t
{
u16 dbg_proc_select;
u16 dbg_stop_status;
u16 window1_page; /* PROG_PMEM1 or GW1 */
u16 window2_page; /* PROG_PMEM2 or GW2 */
u16 window3_page; /* SHARED or GW3 */
u16 io_log_addr;
};
struct chip_device_regs_t
{
u16 gbl_chip_version;
u16 gbl_misc_enables;
u16 dbg_emu_cmd;
struct chip_device_regs_per_transport_t host;
struct chip_device_regs_per_transport_t spi;
u16 dbg_reset;
u16 dbg_reset_value;
u16 dbg_reset_warn;
u16 dbg_reset_warn_value;
u16 dbg_reset_result;
u16 xap_pch;
u16 xap_pcl;
u16 proc_pc_snoop;
u16 watchdog_disable;
u16 mailbox0;
u16 mailbox1;
u16 mailbox2;
u16 mailbox3;
u16 sdio_host_int;
u16 shared_io_interrupt;
u16 sdio_hip_handshake;
u16 coex_status; /* Allows WAPI detection */
};
/* If allowed is false then this window does not provide this
type of access.
This describes how addresses should be shifted to make the
"page" address. The address is shifted left by 'page_shift'
and then has 'page_offset' added. This value should then be
written to the page register. */
struct window_shift_info_t
{
s32 allowed;
u32 page_shift;
u16 page_offset;
};
/* Each window has an address and size. These are obvious. It then
has a description for each type of memory that might be accessed
through it. There might also be a start to the offset of the window.
This means that that number of addresses at the start of the window
are unusable. */
struct window_info_t
{
u16 address;
u16 size;
u16 blocked;
const struct window_shift_info_t *mode;
};
/* If GBL_CHIP_VERSION and'ed with 'mask' and is equal to 'result'
then this is the correct set of info. If pre_bc7 is true then the
address of GBL_CHIP_VERSION is FF9A, else its FE81. */
struct chip_version_t
{
s32 pre_bc7;
u16 mask;
u16 result;
u8 sdio;
};
struct chip_device_desc_t
{
struct chip_version_t chip_version;
/* This is a text string that a human might find useful (BC02, UF105x) */
const char *friendly_name;
/* This is what we show to customers */
const char *marketing_name;
/* Initialisation values to write following a reset */
struct val_array_t init;
/* Binary sequence for hard reset */
struct reset_prog_t reset_prog;
/* The register map */
const struct chip_device_regs_t *regs;
/* Some misc. info on the chip */
struct
{
u32 has_flash : 1;
u32 has_ext_sram : 1;
u32 has_rom : 1;
u32 has_bt : 1;
u32 has_wlan : 1;
} bools;
/* This table is used to remap register addresses depending on what
host interface is used. On the BC7 and later chips there are
multiple sets of memory window registers, on for each host
interafce (SDIO / SPI). The correct one is needed. */
struct map_array_t map;
/* The offsets into the program address space of the different types of memory.
The RAM offset is probably the most useful. */
struct
{
u32 ram;
u32 rom;
u32 flash;
u32 ext_sram;
} prog_offset;
/* The offsets into the data address space of interesting things. */
struct
{
u16 ram;
/* maybe add shared / page tables? */
} data_offset;
/* Information on the different windows */
const struct window_info_t *windows[CHIP_HELPER_WINDOW_COUNT];
};
#endif /* CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__ */
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
/*
* ---------------------------------------------------------------------------
*
* FILE: csr_wifi_hip_conversions.h
*
* PURPOSE:
* This header file provides the macros for converting to and from
* wire format.
* These macros *MUST* work for little-endian AND big-endian hosts.
*
* ---------------------------------------------------------------------------
*/
#ifndef __CSR_WIFI_HIP_CONVERSIONS_H__
#define __CSR_WIFI_HIP_CONVERSIONS_H__
#define SIZEOF_UINT16 2
#define SIZEOF_UINT32 4
#define SIZEOF_UINT64 8
#define SIZEOF_SIGNAL_HEADER 6
#define SIZEOF_DATAREF 4
/*
* Macro to retrieve the signal ID from a wire-format signal.
*/
#define GET_SIGNAL_ID(_buf) CSR_GET_UINT16_FROM_LITTLE_ENDIAN((_buf))
/*
* Macros to retrieve and set the DATAREF fields in a packed (i.e. wire-format)
* HIP signal.
*/
#define GET_PACKED_DATAREF_SLOT(_buf, _ref) \
CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
#define GET_PACKED_DATAREF_LEN(_buf, _ref) \
CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
#define SET_PACKED_DATAREF_SLOT(_buf, _ref, _slot) \
CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_slot), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
#define SET_PACKED_DATAREF_LEN(_buf, _ref, _len) \
CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_len), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
#define GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(_buf) \
CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
#define GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(_buf) \
CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 4))
#define GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(_buf) \
CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
#define GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(_buf) \
CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 2))
s32 get_packed_struct_size(const u8 *buf);
CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig);
CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len);
#endif /* __CSR_WIFI_HIP_CONVERSIONS_H__ */
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
/*
* ---------------------------------------------------------------------------
* FILE: csr_wifi_hip_ta_sampling.h
*
* PURPOSE:
* This file contains Traffic Analysis definitions common to the
* sampling and analysis modules.
*
* ---------------------------------------------------------------------------
*/
#ifndef __TA_SAMPLING_H__
#define __TA_SAMPLING_H__
#include "csr_wifi_hip_unifi.h"
typedef struct ta_l4stats
{
u32 rxTcpBytesCount;
u32 txTcpBytesCount;
u32 rxUdpBytesCount;
u32 txUdpBytesCount;
} ta_l4stats_t;
/*
* Context structure to preserve state between calls.
*/
typedef struct ta_data
{
/* Current packet filter configuration */
u16 packet_filter;
/* Current packet custom filter configuration */
CsrWifiRouterCtrlTrafficFilter custom_filter;
/* The timestamp of the last tx packet processed. */
u32 tx_last_ts;
/* The timestamp of the last packet processed. */
u32 last_indication_time;
/* Statistics */
CsrWifiRouterCtrlTrafficStats stats;
/* Current traffic classification */
CsrWifiRouterCtrlTrafficType traffic_type;
/* Sum of packet rx rates for this interval used to calculate mean */
u32 rx_sum_rate;
ta_l4stats_t ta_l4stats;
} ta_data_t;
void unifi_ta_sampling_init(card_t *card);
#endif /* __TA_SAMPLING_H__ */
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
/*****************************************************************************
(c) Cambridge Silicon Radio Limited 2011
All rights reserved and confidential information of CSR
Refer to LICENSE.txt included with this source for details
on the license terms.
*****************************************************************************/
#ifndef CSR_WIFI_HOSTIO_H
#define CSR_WIFI_HOSTIO_H
#define CSR_WIFI_HOSTIO_PRIM 0x0453
#endif /* CSR_WIFI_HOSTIO_H */
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册