initial commit

This commit is contained in:
2022-10-23 23:45:43 -07:00
commit e190fa5193
6450 changed files with 8626944 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,338 @@
/*************************************************************************************************/
/*!
* \file
*
* \brief Link layer constant definitions.
*
* $Date: 2017-03-10 20:10:06 -0600 (Fri, 10 Mar 2017) $
* $Revision: 11511 $
*
* Copyright (c) 2013-2017 ARM Ltd., all rights reserved.
* ARM Ltd. confidential and proprietary.
*
* IMPORTANT. Your use of this file is governed by a Software License Agreement
* ("Agreement") that must be accepted in order to download or otherwise receive a
* copy of this file. You may not use or copy this file for any purpose other than
* as described in the Agreement. If you do not agree to all of the terms of the
* Agreement do not use this file and delete all copies in your possession or control;
* if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
* to any use, copying or further distribution of this software.
*/
/*************************************************************************************************/
#ifndef LL_DEFS_H
#define LL_DEFS_H
#include "wsf_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Constants
**************************************************************************************************/
/*** Version ***/
#define LL_VER_BT_CORE_SPEC_4_0 0x06 /*!< Bluetooth core specification 4.0 */
#define LL_VER_BT_CORE_SPEC_4_1 0x07 /*!< Bluetooth core specification 4.1 */
#define LL_VER_BT_CORE_SPEC_4_2 0x08 /*!< Bluetooth core specification 4.2 */
#define LL_VER_BT_CORE_SPEC_5_0 0x09 /*!< Bluetooth core specification 5.0 */
#define LL_COMP_ID_ARM 0x005F /*!< ARM Ltd. company ID. */
/*** Common ***/
#define LL_RSSI_MIN -127 /*!< Minimum RSSI value. */
#define LL_RSSI_MAX 20 /*!< Maximum RSSI value. */
#define LL_RSSI_NOT_AVAIL 127 /*!< RSSI is not available. */
#define LL_CRC_LEN 3 /*!< CRC length. */
#define LL_AA_LEN 4 /*!< Access address length. */
#define LL_PREAMBLE_LEN_1M 1 /*!< Preamble length (LE 1M PHY). */
#define LL_PREAMBLE_LEN_2M 2 /*!< Preamble length (LE 2M PHY). */
#define LL_PREAMBLE_LEN_CODED_BITS 10 /*!< Preamble length (LE Coded PHY). */
#define LL_CI_LEN_BITS 2 /*!< Coding indicator length (LE Coded PHY). */
#define LL_TERM1_LEN_BITS 3 /*!< TERM1 length (LE Coded PHY). */
#define LL_TERM2_LEN_BITS 3 /*!< TERM2 length (LE Coded PHY). */
#define LL_RAND_ADDR_MSBS_MASK 0x03 /*!< Mask of 2 most significant bits of BD Random Address */
#define LL_RAND_ADDR_MSBS_POS 46 /*!< Position of 2 MSBs of BD Random Address */
#define LL_RAND_ADDR_MSBS_STATIC 0x03 /*!< 2 most significant bits of BD Random Address are '0b11', static random address */
#define LL_RAND_ADDR_MSBS_RPA 0x01 /*!< 2 most significant bits of BD Random Address are '0b01', resolvable private address */
#define LL_RAND_ADDR_MSBS_NRPA 0x00 /*!< 2 most significant bits of BD Random Address are '0b00', non-resolvable private address */
#define LL_RAND_ADDR_MSBS_IVLD 0x02 /*!< 2 most significant bits of BD Random Address are '0b10', invalid random address */
/*** Advertising PDU ***/
/*! \brief Advertising channel PDU types. */
enum
{
/* --- Core Spec 4.0 --- */
LL_PDU_ADV_IND = 0, /*!< Connectable undirected advertising PDU. */
LL_PDU_ADV_DIRECT_IND = 1, /*!< Connectable directed advertising PDU. */
LL_PDU_ADV_NONCONN_IND = 2, /*!< Non-connectable undirected advertising PDU. */
LL_PDU_SCAN_REQ = 3, /*!< Scan request PDU. */
LL_PDU_SCAN_RSP = 4, /*!< Scan response PDU. */
LL_PDU_CONNECT_IND = 5, /*!< Connect indication PDU. */
LL_PDU_ADV_SCAN_IND = 6, /*!< Scannable undirected advertising PDU. */
/* --- Core Spec 5.0 --- */
LL_PDU_AUX_SCAN_REQ = 3, /*!< Auxiliary scan request PDU. */
LL_PDU_AUX_CONNECT_REQ = 5, /*!< Auxiliary connect request PDU. */
LL_PDU_ADV_EXT_IND = 7, /*!< Extended advertising PDU. */
LL_PDU_AUX_ADV_IND = 7, /*!< Auxiliary advertising PDU. */
LL_PDU_AUX_SCAN_RSP = 7, /*!< Auxiliary scan response PDU. */
LL_PDU_AUX_SYNC_IND = 7, /*!< Auxiliary synchronize PDU. */
LL_PDU_AUX_CHAIN_IND = 7, /*!< Auxiliary chain PDU. */
LL_PDU_AUX_CONNECT_RSP = 8, /*!< Auxiliary connect response PDU. */
};
#define LL_SCAN_REQ_PDU_LEN 12 /*!< Size of a scan request PDU. */
#define LL_CONN_IND_PDU_LEN 34 /*!< Size of a connect indication PDU. */
#define LL_CHAN_ADV_MIN_IDX 37 /*!< Minimum advertising channel index. */
#define LL_CHAN_ADV_MAX_IDX 39 /*!< Maximum advertising channel index. */
#define LL_NUM_CHAN_ADV 3 /*!< Total number of advertising channels. */
#define LL_ADVBU_MAX_LEN 31 /*!< Maximum advertising channel host data length. */
#define LL_ADVB_MAX_LEN 39 /*!< Maximum advertising channel PDU length. */
#define LL_ADVB_MIN_LEN (LL_ADVB_MAX_LEN - LL_ADVBU_MAX_LEN) /*!< Minimum advertising channel packet length. */
#define LL_ADVB_MAX_TIME_1M ((LL_BLE_US_PER_BYTE_1M * (LL_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_1M)
/*!< Maximum time for a 1M advertising channel PDU. */
#define LL_ADVB_MAX_TIME_2M ((LL_BLE_US_PER_BYTE_2M * (LL_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_2M)
/*!< Maximum time for a 2M advertising channel PDU. */
#define LL_ADVB_MAX_TIME_S2 ((LL_BLE_US_PER_BYTE_CODED_S2 * (LL_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_CODED_S2)
/*!< Maximum time for a Coded S2 advertising channel PDU. */
#define LL_ADVB_MAX_TIME_S8 ((LL_BLE_US_PER_BYTE_CODED_S8 * (LL_ADVB_MAX_LEN - LL_ADV_HDR_LEN)) + LL_MIN_PKT_TIME_US_CODED_S8)
/*!< Maximum time for a Coded S8 advertising channel PDU. */
#define LL_ADV_PKT_MAX_USEC LL_ADVB_MAX_TIME_1M /*!< Maximum time in microseconds for an advertising packet. */
#define LL_SCAN_REQ_MAX_USEC ((8 * (LL_ADV_PREFIX_LEN + LL_SCAN_PREFIX_LEN)) + LL_MIN_PKT_TIME_US_1M)
/*!< Maximum time in microseconds for a scan request packet. */
#define LL_SCAN_RSP_MAX_USEC LL_ADVB_MAX_TIME_1M /*!< Maximum time in microseconds for a scan response packet. */
#define LL_ADV_HDR_LEN 2 /*!< Advertising channel header length. */
#define LL_ADV_HDR_TYPE_OFFS 0 /*!< Advertising header type offset. */
#define LL_ADV_HDR_TYPE_MSK 0x0F /*!< Advertising header type mask. */
#define LL_ADV_HDR_LEN_OFFS 1 /*!< Advertising header length offset. */
#define LL_ADV_HDR_LEN_MSK 0x3F /*!< Advertising header length mask for 4.2. */
#define LL_ADV_EXT_HDR_LEN_MSK 0xFF /*!< Advertising extension header length mask for 5.0. */
#define LL_ADV_PREFIX_LEN 6 /*!< Advertising PDU payload prefix length (AdvA). */
#define LL_SCAN_PREFIX_LEN 6 /*!< Scan request/response PDU payload prefix length (AdvA). */
#define LL_ADV_ACCESS_ADDR UINT32_C(0x8E89BED6) /*!< Advertising channel access address. */
#define LL_ADV_CRC_INIT UINT32_C(0x555555) /*!< Advertising CRC initial value. */
#define LL_DIR_ADV_INTER_TICKS 6 /*!< Advertising interval between directed advertising events (3.75 ms). */
#define LL_DIR_ADV_DUR_TICKS 2048 /*!< Maximum high duty cycle directed advertising duration (1.28 seconds). */
enum
{
LL_EXT_HDR_ADV_ADDR_BIT = (1 << 0), /*!< Extended header AdvA bit. */
LL_EXT_HDR_TGT_ADDR_BIT = (1 << 1), /*!< Extended header TargetA bit. */
LL_EXT_HDR_SUPP_INFO_BIT = (1 << 2), /*!< Extended header SuppInfo bit. */
LL_EXT_HDR_ADI_BIT = (1 << 3), /*!< Extended header AdvDataInfo bit. */
LL_EXT_HDR_AUX_PTR_BIT = (1 << 4), /*!< Extended header AuxPtr bit. */
LL_EXT_HDR_SYNC_INFO_BIT = (1 << 5), /*!< Extended header SyncInfo bit. */
LL_EXT_HDR_TX_PWR_BIT = (1 << 6), /*!< Extended header TxPower bit. */
};
#define LL_MAX_ADV_HANDEL 0xEF /*!< Maximum advertising handle. */
#define LL_MAX_ADV_SID 0x0F /*!< Maximum advertising SID */
#define LL_EXT_ADV_HDR_MIN_LEN 1 /*!< Minimum extended advertising header length (+1 for ExtHdrLen and AdvMode fields). */
#define LL_EXT_ADV_HDR_MAX_LEN 64 /*!< Maximum extended advertising header length (+1 for ExtHdrLen and AdvMode fields). */
#define LL_EXT_ADVBU_MAX_LEN 251 /*!< Maximum extended advertising channel PDU host data length. */
#define LL_EXT_ADVB_MAX_LEN 257 /*!< Maximum extended advertising channel PDU length. */
#define LL_AUX_PTR_MAX_USEC 2457600 /*!< Maximum AuxPtr offset value in microseconds. */
#define LL_SYNC_MIN_TIMEOUT 0x000A /*!< Minimum synchronization timeout. */
#define LL_SYNC_MAX_TIMEOUT 0x4000 /*!< Maximum synchronization timeout. */
#define LL_SYNC_MAX_SKIP 0x01F3 /*!< Maximum synchronization skip. */
#define LL_SYNC_MAX_HANDLE 0x0EFF /*!< Maximum synchronization handle. */
#define LL_PER_ADV_INT_MIN 0x0006 /*!< Minimum periodic advertising interval. */
/*** Data PDU ***/
/*! \brief Data channel LL Control PDU types. */
enum
{
/* --- Core Spec 4.0 --- */
LL_PDU_CONN_UPDATE_IND = 0x00, /*!< Connection update indication PDU. */
LL_PDU_CHANNEL_MAP_IND = 0x01, /*!< Channel map indication PDU. */
LL_PDU_TERMINATE_IND = 0x02, /*!< Terminate indication PDU. */
LL_PDU_ENC_REQ = 0x03, /*!< Encryption request PDU. */
LL_PDU_ENC_RSP = 0x04, /*!< Encryption response PDU. */
LL_PDU_START_ENC_REQ = 0x05, /*!< Start encryption request PDU. */
LL_PDU_START_ENC_RSP = 0x06, /*!< Start encryption response PDU. */
LL_PDU_UNKNOWN_RSP = 0x07, /*!< Unknown response PDU. */
LL_PDU_FEATURE_REQ = 0x08, /*!< Feature request PDU. */
LL_PDU_FEATURE_RSP = 0x09, /*!< Feature response PDU. */
LL_PDU_PAUSE_ENC_REQ = 0x0A, /*!< Pause encryption request PDU. */
LL_PDU_PAUSE_ENC_RSP = 0x0B, /*!< Pause encryption response PDU. */
LL_PDU_VERSION_IND = 0x0C, /*!< Version indication PDU. */
LL_PDU_REJECT_IND = 0x0D, /*!< Reject indication PDU. */
/* --- Core Spec 4.2 --- */
LL_PDU_SLV_FEATURE_REQ = 0x0E, /*!< Slave feature request PDU. */
LL_PDU_CONN_PARAM_REQ = 0x0F, /*!< Connection parameter request PDU. */
LL_PDU_CONN_PARAM_RSP = 0x10, /*!< Connection parameter response PDU. */
LL_PDU_REJECT_EXT_IND = 0x11, /*!< Reject extended indication PDU. */
LL_PDU_PING_REQ = 0x12, /*!< Ping request PDU. */
LL_PDU_PING_RSP = 0x13, /*!< Ping response PDU. */
LL_PDU_LENGTH_REQ = 0x14, /*!< Data length request PDU. */
LL_PDU_LENGTH_RSP = 0x15, /*!< Data length response PDU. */
/* --- Core Spec 5.0 --- */
LL_PDU_PHY_REQ = 0x16, /*!< PHY request PDU. */
LL_PDU_PHY_RSP = 0x17, /*!< PHY response PDU. */
LL_PDU_PHY_UPDATE_IND = 0x18, /*!< PHY update indication PDU. */
LL_PDU_MIN_USED_CHAN_IND = 0x19, /*!< Minimum used channels indication PDU. */
LL_PDU_UNSPECIFIED = 0xFF /*!< Unspecified PDU. */
};
/* Data PDU length */
/* --- Core Spec 4.0 --- */
#define LL_CONN_UPD_IND_PDU_LEN 12 /*!< Connection update indication PDU length. */
#define LL_CHAN_MAP_IND_PDU_LEN 8 /*!< Channel map indication PDU length. */
#define LL_TERMINATE_IND_PDU_LEN 2 /*!< Terminate indication PDU length. */
#define LL_ENC_REQ_LEN 23 /*!< Encryption request PDU length. */
#define LL_ENC_RSP_LEN 13 /*!< Encryption response PDU length. */
#define LL_START_ENC_LEN 1 /*!< Start encryption request/response PDU length. */
#define LL_UNKNOWN_RSP_LEN 2 /*!< Unknown response PDU length. */
#define LL_FEATURE_PDU_LEN 9 /*!< Feature request/response PDU length. */
#define LL_PAUSE_ENC_LEN 1 /*!< Pause encryption request/response PDU length. */
#define LL_VERSION_IND_PDU_LEN 6 /*!< Version indication PDU length. */
#define LL_REJECT_IND_PDU_LEN 2 /*!< Reject indication PDU length. */
/* --- Core Spec 4.2 --- */
#define LL_CONN_PARAM_PDU_LEN 24 /*!< Connection parameter request or response PDU length. */
#define LL_REJECT_EXT_IND_PDU_LEN 3 /*!< Reject extended indication PDU length. */
#define LL_PING_PDU_LEN 1 /*!< Ping request/response PDU length. */
#define LL_DATA_LEN_PDU_LEN 9 /*!< Data length request or response PDU length. */
/* --- Core Spec 5.0 --- */
#define LL_PHY_PDU_LEN 3 /*!< PHY request/response PDU length. */
#define LL_PHY_UPD_IND_PDU_LEN 5 /*!< PHY update indication PDU length. */
#define LL_MIN_USED_CHAN_PDU_LEN 3 /*!< Minimum used channels indication PDU length. */
#define LL_EMPTY_PDU_LEN 2 /*!< Length of an empty data PDU. */
#define LL_DATA_HDR_LEN 2 /*!< Data channel header length. */
#define LL_DATA_MIC_LEN 4 /*!< Data channel PDU MIC length. */
#define LL_DATA_HDR_LLID_MSK 0x03 /*!< Data PDU LLID mask. */
#define LL_DATA_HDR_LEN_MSK 0xFF /*!< Data header length mask. BLE 4.2 data len extension allows 8 bits. */
#define LL_MAX_NUM_CHAN_DATA 37 /*!< Maximum number of used data channels. */
#define LL_MIN_NUM_CHAN_DATA 2 /*!< Minimum number of used data channels. */
/*! \brief Data PDU LLID types. */
enum
{
LL_LLID_VS_PDU = 0x00, /*!< Vendor specific PDU. */
/* N.B. next two enumerations intentionally use identical values. */
LL_LLID_EMPTY_PDU = 0x01, /*!< Empty PDU. */
LL_LLID_CONT_PDU = 0x01, /*!< Data PDU: continuation fragment of an L2CAP message. */
LL_LLID_START_PDU = 0x02, /*!< Data PDU: start of an L2CAP message or a complete L2CAP message with no fragmentation. */
LL_LLID_CTRL_PDU = 0x03, /*!< Control PDU. */
};
/*** Encryption ***/
#define LL_ECC_KEY_LEN 32 /*!< ECC key length. */
#define LL_DEF_RES_ADDR_TO_SEC 900 /*!< Default resolvable address timeout in seconds. */
#define LL_RAND_LEN 8 /*!< Length of random number */
#define LL_KEY_LEN 16 /*!< Encryption key length. */
#define LL_SKD_LEN LL_KEY_LEN /*!< Session key diversifier length. */
#define LL_IV_LEN 8 /*!< Initialization vector length. */
#define LL_DEF_AUTH_TO_MS 30000 /*!< Default authentication timeout in milliseconds. */
/*** LLCP ***/
#define LL_DATA_LEN_TO_TIME_1M(len) ((LL_BLE_US_PER_BYTE_1M * ((len) + LL_DATA_MIC_LEN)) + LL_MIN_PKT_TIME_US_1M)
/*!< Convert data length to time. */
#define LL_DATA_LEN_TO_TIME_2M(len) ((LL_BLE_US_PER_BYTE_2M * ((len) + LL_DATA_MIC_LEN)) + LL_MIN_PKT_TIME_US_2M)
/*!< Convert data length to time. */
#define LL_DATA_LEN_TO_TIME_CODED_S8(len) ((LL_BLE_US_PER_BYTE_CODED_S8 * ((len) + LL_DATA_MIC_LEN)) + LL_MIN_PKT_TIME_US_CODED_S8)
/*!< Convert data length to time. */
#define LL_DATA_LEN_TO_TIME_CODED_S2(len) ((LL_BLE_US_PER_BYTE_CODED_S2 * ((len) + LL_DATA_MIC_LEN)) + LL_MIN_PKT_TIME_US_CODED_S2)
/*!< Convert data length to time. */
#define LL_MIN_INSTANT 6 /*!< Minimum number of CE to apply a CONN_UPD or CHAN_MAP. */
#define LL_MAX_DATA_LEN_MIN 27 /*!< Minimum value for maximum Data PDU length */
#define LL_MAX_DATA_LEN_ABS_MAX 251 /*!< Absolute maximum limit for maximum Data PDU length */
#define LL_MAX_DATA_TIME_MIN 328 /*!< Minimum value for maximum Data PDU time */
#define LL_MAX_DATA_TIME_ABS_MAX 17040 /*!< Absolute maximum limit for maximum Data PDU time */
#define LL_MAX_DATA_TIME_ABS_MAX_1M 2120 /*!< Absolute maximum limit for maximum Data PDU time (LE 1M PHY) */
#define LL_T_PRT_SEC 40 /*!< LLCP procedure response timeout in seconds. */
#define LL_MAX_ADV_DLY_MS 10 /*!< Maximum advertising delay in milliseconds. */
#define LL_MIN_CONN_INTERVAL 6 /*!< Minimum value for connection interval. */
#define LL_MAX_CONN_INTERVAL 3200 /*!< Maximum value for connection interval. */
#define LL_MIN_TX_WIN_SIZE 1 /*!< Minimum value for transmit window size. */
#define LL_MAX_TX_WIN_SIZE 8 /*!< Maximum value for transmit window size. */
#define LL_MAX_CONN_LATENCY 499 /*!< Maximum value for connection slave latency. */
#define LL_MIN_SUP_TIMEOUT 10 /*!< Minimum value for connection supervision timeout. */
#define LL_MAX_SUP_TIMEOUT 3200 /*!< Maximum value for connection supervision timeout. */
#define LL_MIN_POWER_THRESHOLD -128 /*!< Minimum value for power threshold. */
#define LL_MAX_POWER_THRESHOLD 127 /*!< Maximum value for power threshold. */
#define LL_ALL_PHYS_MSK 0x7 /*!< All supported LE PHYs mask. */
/*** DTM ***/
#define LL_DTM_HDR_LEN 2 /*!< Direct Test Mode PDU header length. */
#define LL_DTM_SYNC_WORD UINT32_C(0x71764129) /*!< Direct Test Mode sync word. */
#define LL_DTM_CRC_INIT UINT32_C(0x555555) /*!< Direct Test Mode CRC initial value. */
#define LL_DTM_MAX_INT_US 12500 /*!< Maximum time interval between packets in microseconds. */
#define LL_DTM_PDU_ABS_MAX_LEN 255 /*!< Absolute maximum DTM PDU length. */
#define LL_DTM_MAX_CHAN_IDX 39 /*!< Maximum channel index. */
/*** Baseband ***/
#define LL_CHAN_DATA_MIN_IDX 0 /*!< Minimum data channel index. */
#define LL_CHAN_DATA_MAX_IDX 36 /*!< Maximum data channel index. */
#define LL_CHAN_DATA_ALL UINT64_C(0x0000001FFFFFFFFF) /*!< Maximum data channel index. */
#define LL_BLE_BIT_PER_US 1 /*!< BLE PHY rate. */
#define LL_BLE_US_PER_BYTE_1M 8 /*!< BLE PHY speed (LE 1M PHY). */
#define LL_BLE_US_PER_BYTE_2M 4 /*!< BLE PHY speed (LE 2M PHY). */
#define LL_BLE_US_PER_BYTE_CODED_S8 64 /*!< BLE PHY speed (LE Coded PHY, S=8). */
#define LL_BLE_US_PER_BIT_CODED_S8 8 /*!< BLE PHY speed (LE Coded PHY, S=8). */
#define LL_BLE_US_PER_BYTE_CODED_S2 16 /*!< BLE PHY speed (LE Coded PHY, S=2). */
#define LL_BLE_US_PER_BIT_CODED_S2 2 /*!< BLE PHY speed (LE Coded PHY, S=2). */
#define LL_BLE_TIFS_US 150 /*!< BLE inter-frame space. */
#define LL_BLE_MAFS_US 300 /*!< BLE minimum AUX frame space. */
#define LL_BLE_US_PER_TICK 625 /*!< Microseconds per BLE tick. */
#define LL_MIN_PKT_TIME_US_1M 80 /*!< Minimum packet time (i.e. empty PDU) on LE 1M PHY. */
#define LL_MIN_PKT_TIME_US_2M 44 /*!< Minimum packet time (i.e. empty PDU) on LE 2M PHY. */
#define LL_MIN_PKT_TIME_US_CODED_S8 720 /*!< Minimum packet time (i.e. empty PDU) on LE Coded PHY, S=8. */
#define LL_MIN_PKT_TIME_US_CODED_S2 462 /*!< Minimum packet time (i.e. empty PDU) on LE Coded PHY, S=2. */
#define LL_MIN_ADV_TX_PWR_LVL -20 /*!< Minimum Tx power level for advertising. */
#define LL_MAX_ADV_TX_PWR_LVL 10 /*!< Maximum Tx power level for advertising. */
#define LL_MIN_TX_PWR_LVL -30 /*!< Minimum Tx power level for connections. */
#define LL_MAX_TX_PWR_LVL 20 /*!< Maximum Tx power level for connections. */
#define LL_MAX_TIFS_DEVIATION 2 /*!< Maximum TIFS deviation in microseconds. */
#ifdef __cplusplus
};
#endif
#endif /* LL_DEFS_H */
@@ -0,0 +1,196 @@
/*************************************************************************************************/
/*!
* \file wsf_buf.h
*
* \brief Buffer pool service.
*
* $Date: 2017-03-04 13:45:34 -0600 (Sat, 04 Mar 2017) $
* $Revision: 11379 $
*
* Copyright (c) 2009-2017 ARM Ltd., all rights reserved.
* ARM Ltd. confidential and proprietary.
*
* IMPORTANT. Your use of this file is governed by a Software License Agreement
* ("Agreement") that must be accepted in order to download or otherwise receive a
* copy of this file. You may not use or copy this file for any purpose other than
* as described in the Agreement. If you do not agree to all of the terms of the
* Agreement do not use this file and delete all copies in your possession or control;
* if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
* to any use, copying or further distribution of this software.
*/
/*************************************************************************************************/
#ifndef WSF_BUF_H
#define WSF_BUF_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Length of the buffer statistics array */
#define WSF_BUF_STATS_MAX_LEN 128
/*! Failure Codes */
#define WSF_BUF_ALLOC_FAILED 0x01
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Buffer pool descriptor structure */
typedef struct
{
uint16_t len; /*! length of buffers in pool */
uint8_t num; /*! number of buffers in pool */
} wsfBufPoolDesc_t;
/*! Pool statistics */
typedef struct
{
uint16_t bufSize; /*!< Pool buffer size. */
uint8_t numBuf; /*!< Total number of buffers. */
uint8_t numAlloc; /*!< Number of outstanding allocations. */
uint8_t maxAlloc; /*!< High allocation watermark. */
uint16_t maxReqLen; /*!< Maximum requested buffer length. */
} WsfBufPoolStat_t;
/*! WSF buffer diagnostics - buffer allocation failure */
typedef struct
{
uint8_t taskId; /*! Task handler ID where failure occured */
uint16_t len; /*! Length of buffer being allocated */
} wsfBufDiagAllocFail_t;
/*! WSF buffer diagnostics message */
typedef struct
{
union
{
wsfBufDiagAllocFail_t alloc; /*! Buffer allocation failure */
} param;
uint8_t type; /*! Type of error */
} WsfBufDiag_t;
/**************************************************************************************************
Callback Function Datatypes
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn wsfBufDiagCback_t
*
* \brief Callback providing WSF buffer diagnostic messages.
*
* \param pInfo Diagnostics message
*
* \return None.
*/
/*************************************************************************************************/
typedef void (*wsfBufDiagCback_t)(WsfBufDiag_t *pInfo);
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn WsfBufInit
*
* \brief Initialize the buffer pool service. This function should only be called once
* upon system initialization.
*
* \param bufMemLen Length in bytes of memory pointed to by pBufMem.
* \param pBufMem Memory in which to store the pools used by the buffer pool service.
* \param numPools Number of buffer pools.
* \param pDesc Array of buffer pool descriptors, one for each pool.
*
* \return Amount of pBufMem used or 0 for failures.
*/
/*************************************************************************************************/
uint16_t WsfBufInit(uint16_t bufMemLen, uint8_t *pBufMem, uint8_t numPools, wsfBufPoolDesc_t *pDesc);
/*************************************************************************************************/
/*!
* \fn WsfBufAlloc
*
* \brief Allocate a buffer.
*
* \param len Length of buffer to allocate.
*
* \return Pointer to allocated buffer or NULL if allocation fails.
*/
/*************************************************************************************************/
void *WsfBufAlloc(uint16_t len);
/*************************************************************************************************/
/*!
* \fn WsfBufFree
*
* \brief Free a buffer.
*
* \param pBuf Buffer to free.
*
* \return None.
*/
/*************************************************************************************************/
void WsfBufFree(void *pBuf);
/*************************************************************************************************/
/*!
* \fn WsfBufGetAllocStats
*
* \brief Diagnostic function to get the buffer allocation statistics.
*
* \return Buffer allocation statistics array.
*/
/*************************************************************************************************/
uint8_t *WsfBufGetAllocStats(void);
/*************************************************************************************************/
/*!
* \fn WsfBufGetNumPool
*
* \brief Get number of pools.
*
* \return Number of pools.
*/
/*************************************************************************************************/
uint8_t WsfBufGetNumPool(void);
/*************************************************************************************************/
/*!
* \fn WsfBufGetPoolStats
*
* \brief Get statistics for each pool.
*
* \param pStat Buffer to store the statistics.
* \param numPool Number of pool elements.
*
* \return Pool statistics.
*/
/*************************************************************************************************/
void WsfBufGetPoolStats(WsfBufPoolStat_t *pStat, uint8_t numPool);
/*************************************************************************************************/
/*!
* \fn WsfBufDiagRegister
*
* \brief Called to register the buffer diagnostics callback function.
*
* \param pCallback Pointer to the callback function.
*
* \return None.
*/
/*************************************************************************************************/
void WsfBufDiagRegister(wsfBufDiagCback_t callback);
#ifdef __cplusplus
};
#endif
#endif /* WSF_BUF_H */
@@ -0,0 +1,95 @@
/*************************************************************************************************/
/*!
* \file wsf_bufio.h
*
* \brief Buffer I/O service.
*
* Copyright (c) 2009-2018 Arm Ltd.
*
* Copyright (c) 2019 Packetcraft, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*************************************************************************************************/
#ifndef WSF_BUF_IO_H
#define WSF_BUF_IO_H
#ifdef __cplusplus
extern "C" {
#endif
/*! \addtogroup WSF_BUF_IO_API
* \{ */
/**************************************************************************************************
Macros
**************************************************************************************************/
/**************************************************************************************************
Data Types
**************************************************************************************************/
/**************************************************************************************************
Callback Function Datatypes
**************************************************************************************************/
/*! \brief Buffer IO UART Rx callback. */
typedef void (*WsfBufIoUartRxCback_t)(uint8_t rxByte);
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \brief Initialize the platform UART.
*
* \param pBuf Tx Buffer pointer.
* \param size Length of buffer.
*
* \return memory used.
*/
/*************************************************************************************************/
uint32_t WsfBufIoUartInit(void *pBuf, uint32_t size);
/*************************************************************************************************/
/*!
* \brief Register the platform UART RX callback.
*
* \param[in] Callback function for UART RX.
*
* \return None.
*/
/*************************************************************************************************/
void WsfBufIoUartRegister(WsfBufIoUartRxCback_t rxCback);
/*************************************************************************************************/
/*!
* \brief Transmit buffer on platform UART.
*
* \param pBuf Buffer to transmit.
* \param len Length of buffer in octets.
*
* \return None.
*/
/*************************************************************************************************/
bool_t WsfBufIoWrite(const uint8_t *pBuf, uint32_t len);
/*! \} */ /* WSF_BUF_IO_API */
#ifdef __cplusplus
};
#endif
#endif /* WSF_BUF_IO_H */
@@ -0,0 +1,449 @@
/*************************************************************************************************/
/*!
* \file wsf_efs.h
*
* \brief Embedded File System service.
*
* $Date: 2017-03-09 12:18:38 -0600 (Thu, 09 Mar 2017) $
* $Revision: 11460 $
*
* Copyright (c) 2014-2017 ARM Ltd., all rights reserved.
* ARM Ltd. confidential and proprietary.
*
* IMPORTANT. Your use of this file is governed by a Software License Agreement
* ("Agreement") that must be accepted in order to download or otherwise receive a
* copy of this file. You may not use or copy this file for any purpose other than
* as described in the Agreement. If you do not agree to all of the terms of the
* Agreement do not use this file and delete all copies in your possession or control;
* if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
* to any use, copying or further distribution of this software.
*/
/*************************************************************************************************/
#ifndef WSF_EFS_H
#define WSF_EFS_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/* Max Number of Files and Media */
#ifndef WSF_EFS_MAX_FILES
#define WSF_EFS_MAX_FILES 6
#endif
/* Max Number of Media */
#ifndef WSF_EFS_MAX_MEDIA
#define WSF_EFS_MAX_MEDIA 4
#endif
/* Status codes */
#define WSF_EFS_SUCCESS 0 /*! Success */
#define WSF_EFS_FAILURE 1 /*! Failure */
#define WSF_EFS_GET_FAILED 0xFFFF /*! Get operation failure */
#define WSF_EFS_PUT_FAILED 0xFFFF /*! PUT operation failure */
/* Invalid parameter Identifiers */
#define WSF_EFS_INVALID_HANDLE 0xFFFF /*! Invalid Handle */
#define WSF_EFS_INVALID_OFFSET 0xFFFFFFFF /*! Invalid Offset */
#define WSF_EFS_INVALID_SIZE 0xFFFFFFFF /*! Invalid Size */
#define WSF_EFS_INVALID_MEDIA 0xFF /*! Invalid Media */
/* File Types */
#define WSF_EFS_FILE_TYPE_BULK 0 /*! Bulk File Type */
#define WSF_EFS_FILE_TYPE_STREAM 1 /*! Stream File Type */
/* Offset to WsfEfsAddFile indicating any file offset can be used */
#define WSF_EFS_FILE_OFFSET_ANY 0xFFFFFFFF
/* File Permissions */
#define WSF_EFS_REMOTE_PERMISSIONS_MASK 0xFF /*! Remote Permissions */
#define WSF_EFS_REMOTE_GET_PERMITTED 0x01 /*! Remote Get Permitted */
#define WSF_EFS_REMOTE_PUT_PERMITTED 0x02 /*! Remote Put Permitted */
#define WSF_EFS_REMOTE_ERASE_PERMITTED 0x04 /*! Remote Erase Permitted */
#define WSF_EFS_REMOTE_VERIFY_PERMITTED 0x08 /*! Remote Verify Permitted */
#define WSF_EFS_LOCAL_GET_PERMITTED 0x0100 /*! Local Get Permitted */
#define WSF_EFS_LOCAL_PUT_PERMITTED 0x0200 /*! Local Put Permitted */
#define WSF_EFS_LOCAL_ERASE_PERMITTED 0x0400 /*! Local Erase Permitted */
#define WSF_EFS_REMOTE_VISIBLE 0x0800 /*! File Visible via Remote WDXS */
/* File name length in bytes */
#define WSF_EFS_NAME_LEN 16
/* File version length in bytes */
#define WSF_EFS_VERSION_LEN 16
/* Standard Media Specific Command Identifiers */
#define WSF_EFS_WDXS_PUT_COMPLETE_CMD 0x00 /*! Put Complete */
#define WSF_EFS_VALIDATE_CMD 0x01 /*! Validate Req for the file */
/* Media Specific Command Identifiers reserved for applications begin at 0x80 */
#define WSF_EFS_USER_CMD 0x80
/**************************************************************************************************
Data Types
**************************************************************************************************/
/* File handle data type */
typedef uint16_t wsfEfsHandle_t;
/* File attributes data type */
typedef struct
{
char name[WSF_EFS_NAME_LEN];
char version[WSF_EFS_VERSION_LEN];
uint16_t permissions;
uint8_t type;
} wsfEsfAttributes_t;
/* File control block data type */
typedef struct
{
uint32_t maxSize;
uint32_t address;
uint8_t media;
uint32_t size;
wsfEsfAttributes_t attributes;
} wsfEfsControl_t;
/* File Listing Information */
typedef struct
{
wsfEfsHandle_t handle;
uint32_t size;
wsfEsfAttributes_t attributes;
} wsfEfsFileInfo_t;
/*************************************************************************************************/
/*!
* \fn wsfMediaInitFunc_t
*
* \brief Media Init function, called when media is registered.
*
* \param none.
*
* \return Status of the operation.
*/
/*************************************************************************************************/
typedef uint8_t wsfMediaInitFunc_t(void);
/*************************************************************************************************/
/*!
* \fn wsfMediaEraseFunc_t
*
* \brief Media Erase function.
*
* \param address Address in media to start erasing.
* \param size Number of bytes to erase.
*
* \return Status of the operation.
*/
/*************************************************************************************************/
typedef uint8_t wsfMediaEraseFunc_t(uint32_t address, uint32_t size);
/*************************************************************************************************/
/*!
* \fn wsfMediaReadFunc_t
*
* \brief Media Read function.
*
* \param pBuf Buffer to hold data.
* \param address Address in media to read from.
* \param size Size of pBuf in bytes.
*
* \return Status of the operation.
*/
/*************************************************************************************************/
typedef uint8_t wsfMediaReadFunc_t(uint8_t *pBuf, uint32_t address, uint32_t size);
/*************************************************************************************************/
/*!
* \fn wsfMediaWriteFunc_t
*
* \brief Media Write function.
*
* \param pBuf Buffer with data to be written.
* \param address Address in media to write to.
* \param size Size of pBuf in bytes.
*
* \return Status of the operation.
*/
/*************************************************************************************************/
typedef uint8_t wsfMediaWriteFunc_t(const uint8_t *pBuf, uint32_t address, uint32_t size);
/*************************************************************************************************/
/*!
* \fn wsfMediaHandleCmdFunc_t
*
* \brief Media Specific Command handler.
*
* \param cmd Identifier of the media specific command.
* \param param Optional Parameter to the command.
*
* \return Status of the operation.
*/
/*************************************************************************************************/
typedef uint8_t wsfMediaHandleCmdFunc_t(uint8_t cmd, uint32_t param);
/* Media Control data type */
typedef struct
{
uint32_t startAddress;
uint32_t endAddress;
uint32_t pageSize;
wsfMediaInitFunc_t *init;
wsfMediaEraseFunc_t *erase;
wsfMediaReadFunc_t *read;
wsfMediaWriteFunc_t *write;
wsfMediaHandleCmdFunc_t *handleCmd;
} wsfEfsMedia_t;
/* Pointer to Media Control data type */
typedef const wsfEfsMedia_t *pWsfEfsMedia_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn WsfEfsInit
*
* \brief Initialise the embedded file system.
*
* \return none.
*/
/*************************************************************************************************/
void WsfEfsInit(void);
/*************************************************************************************************/
/*!
* \fn WsfEfsAddFile
*
* \brief Create a file in the embedded file system.
*
* \param maxSize Max length in bytes of of the file.
* \param media Identifier of the media where the file is stored.
* \param pAttr Attributes of the file
* \param offset Offset address of the file in the memory space.
*
* \return File Handle, or WSF_EFS_INVALID_HANDLE.
*/
/*************************************************************************************************/
wsfEfsHandle_t WsfEfsAddFile(uint32_t maxSize, uint8_t media, wsfEsfAttributes_t *pAttr, uint32_t offset);
/*************************************************************************************************/
/*!
* \fn WsfEfsRemoveFile
*
* \brief Deletes a file in the embedded file system.
*
* \param handle Handle identifying the file.
*
* \return WSF_EFS_SUCCESS or WSF_EFS_FAILURE.
*/
/*************************************************************************************************/
uint8_t WsfEfsRemoveFile(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsErase
*
* \brief Clears the contents of a file without deleting the file.
*
* \param handle Handle identifying the file.
*
* \return WSF_EFS_SUCCESS or WSF_EFS_FAILURE.
*/
/*************************************************************************************************/
uint8_t WsfEfsErase(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsGetAttributes
*
* \brief Gets the attributes of a file.
*
* \param handle Handle identifying the file.
* \param pAttr Pointer to memory to store the attributes.
*
* \return WSF_EFS_SUCCESS or WSF_EFS_FAILURE.
*/
/*************************************************************************************************/
uint8_t WsfEfsGetAttributes(wsfEfsHandle_t handle, wsfEsfAttributes_t *pAttr);
/*************************************************************************************************/
/*!
* \fn WsfEfsSetAttributes
*
* \brief Updates the attributes of a file.
*
* \param handle Handle identifying the file.
* \param pAttr Pointer to memory to with the updated attributes.
*
* \return WSF_EFS_SUCCESS or WSF_EFS_FAILURE.
*/
/*************************************************************************************************/
uint8_t WsfEfsSetAttributes(wsfEfsHandle_t handle, wsfEsfAttributes_t *pInfo);
/*************************************************************************************************/
/*!
* \fn WsfEfsGet
*
* \brief Copies data from a file.
*
* \param handle Handle identifying the file.
* \param offset Offset into the file to begin copying from.
* \param pBuffer Location to copy the data to.
* \param len Number of bytes to copy into pBuffer.
*
* \return The number of bytes read from the file
*/
/*************************************************************************************************/
uint16_t WsfEfsGet(wsfEfsHandle_t handle, uint32_t offset, uint8_t *pBuffer, uint16_t len);
/*************************************************************************************************/
/*!
* \fn WsfEfsPut
*
* \brief Writes data to a file.
*
* \param handle Handle identifying the file.
* \param offset Offset into the file to begin writing to.
* \param pBuffer Data to write to the file.
* \param len Number of bytes to write to the file.
*
* \return The number of bytes written to the file
*/
/*************************************************************************************************/
uint16_t WsfEfsPut(wsfEfsHandle_t handle, uint32_t offset, const uint8_t *pBuffer, uint16_t len);
/*************************************************************************************************/
/*!
* \fn WsfEfsRegisterMedia
*
* \brief Registers a File Storage Medium with the Embedded File System.
*
* \param pMedia Pointer to the media control structure.
* \param mediaID User specified identifier of the media.
*
* \return WSF_EFS_SUCCESS or WSF_EFS_FAILURE.
*/
/*************************************************************************************************/
uint8_t WsfEfsRegisterMedia(const wsfEfsMedia_t *pMediaCtrl, uint8_t mediaID);
/*************************************************************************************************/
/*!
* \fn wsfEfsGetFileByHandle
*
* \brief Returns the file control block for the given handle.
*
* \param handle Handle of the file
*
* \return File control block, or NULL.
*/
/*************************************************************************************************/
wsfEfsControl_t *WsfEfsGetFileByHandle(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsGetFileName
*
* \brief Get the name of a file.
*
* \param handle File Handle.
*
* \return Filename string of a file.
*/
/*************************************************************************************************/
char *WsfEfsGetFileName(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsGetFileVersion
*
* \brief Get the version of a file.
*
* \param handle File Handle.
*
* \return Version string of a file.
*/
/*************************************************************************************************/
char *WsfEfsGetFileVersion(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsGetFileSize
*
* \brief Get the size of a file.
*
* \param handle File Handle.
*
* \return Size of the file.
*/
/*************************************************************************************************/
uint32_t WsfEfsGetFileSize(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsGetFileMaxSize
*
* \brief Get the number of bytes of memory reserved for use by a file.
*
* \param handle File Handle.
*
* \return Max size of the file.
*/
/*************************************************************************************************/
uint32_t WsfEfsGetFileMaxSize(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsGetFileType
*
* \brief Get the type of a file.
*
* \param handle File Handle.
*
* \return Type of file (bulk or stream).
*/
/*************************************************************************************************/
uint8_t WsfEfsGetFileType(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsGetFilePermissions
*
* \brief Get the permissions of a file.
*
* \param handle File Handle.
*
* \return Permissions of the file.
*/
/*************************************************************************************************/
uint16_t WsfEfsGetFilePermissions(wsfEfsHandle_t handle);
/*************************************************************************************************/
/*!
* \fn WsfEfsMediaSpecificCommand
*
* \brief Execute a media specific command on a file.
*
* \param handle File Handle.
* \param cmd Media specific command identifier.
* \param param Command specific parameter.
*
* \return Status of the operation.
*/
/*************************************************************************************************/
uint8_t WsfEfsMediaSpecificCommand(wsfEfsHandle_t handle, uint8_t cmd, uint32_t param);
#ifdef __cplusplus
}
#endif
#endif /* WSF_EFS_H */
@@ -0,0 +1,45 @@
/*************************************************************************************************/
/*!
* \file wsf_math.h
*
* \brief Common math utilities.
*
* $Date: 2016-12-28 16:12:14 -0600 (Wed, 28 Dec 2016) $
* $Revision: 10805 $
*
* Copyright (c) 2013-2017 ARM Ltd., all rights reserved.
* ARM Ltd. confidential and proprietary.
*
* IMPORTANT. Your use of this file is governed by a Software License Agreement
* ("Agreement") that must be accepted in order to download or otherwise receive a
* copy of this file. You may not use or copy this file for any purpose other than
* as described in the Agreement. If you do not agree to all of the terms of the
* Agreement do not use this file and delete all copies in your possession or control;
* if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
* to any use, copying or further distribution of this software.
*/
/*************************************************************************************************/
#ifndef WSF_MATH_H
#define WSF_MATH_H
#include "wsf_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! \brief Returns the minimum of two values. */
#define WSF_MIN(a,b) ((a) < (b) ? (a) : (b))
/*! \brief Returns the maximum of two values. */
#define WSF_MAX(a,b) ((a) > (b) ? (a) : (b))
#ifdef __cplusplus
};
#endif
#endif /* WSF_MATH_H */
@@ -0,0 +1,137 @@
/*************************************************************************************************/
/*!
* \file wsf_msg.h
*
* \brief Message passing service.
*
* $Date: 2017-03-10 14:08:37 -0600 (Fri, 10 Mar 2017) $
* $Revision: 11501 $
*
* Copyright (c) 2009-2017 ARM Ltd., all rights reserved.
* ARM Ltd. confidential and proprietary.
*
* IMPORTANT. Your use of this file is governed by a Software License Agreement
* ("Agreement") that must be accepted in order to download or otherwise receive a
* copy of this file. You may not use or copy this file for any purpose other than
* as described in the Agreement. If you do not agree to all of the terms of the
* Agreement do not use this file and delete all copies in your possession or control;
* if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
* to any use, copying or further distribution of this software.
*/
/*************************************************************************************************/
#ifndef WSF_MSG_H
#define WSF_MSG_H
#include "wsf_queue.h"
#include "wsf_os.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn WsfMsgDataAlloc
*
* \brief Allocate a data message buffer to be sent with WsfMsgSend().
*
* \param len Message length in bytes.
* \param tailroom Tailroom length in bytes.
*
* \return Pointer to data message buffer or NULL if allocation failed.
*/
/*************************************************************************************************/
void *WsfMsgDataAlloc(uint16_t len, uint8_t tailroom);
/*************************************************************************************************/
/*!
* \fn WsfMsgAlloc
*
* \brief Allocate a message buffer to be sent with WsfMsgSend().
*
* \param len Message length in bytes.
*
* \return Pointer to message buffer or NULL if allocation failed.
*/
/*************************************************************************************************/
void *WsfMsgAlloc(uint16_t len);
/*************************************************************************************************/
/*!
* \fn WsfMsgFree
*
* \brief Free a message buffer allocated with WsfMsgAlloc().
*
* \param pMsg Pointer to message buffer.
*
* \return None.
*/
/*************************************************************************************************/
void WsfMsgFree(void *pMsg);
/*************************************************************************************************/
/*!
* \fn WsfMsgSend
*
* \brief Send a message to an event handler.
*
* \param handlerId Event handler ID.
* \param pMsg Pointer to message buffer.
*
* \return None.
*/
/*************************************************************************************************/
void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg);
/*************************************************************************************************/
/*!
* \fn WsfMsgEnq
*
* \brief Enqueue a message.
*
* \param pQueue Pointer to queue.
* \param handerId Set message handler ID to this value.
* \param pElem Pointer to message buffer.
*
* \return None.
*/
/*************************************************************************************************/
void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg);
/*************************************************************************************************/
/*!
* \fn WsfMsgDeq
*
* \brief Dequeue a message.
*
* \param pQueue Pointer to queue.
* \param pHandlerId Handler ID of returned message; this is a return parameter.
*
* \return Pointer to message that has been dequeued or NULL if queue is empty.
*/
/*************************************************************************************************/
void *WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
/*************************************************************************************************/
/*!
* \fn WsfMsgPeek
*
* \brief Get the next message without removing it from the queue.
*
* \param pQueue Pointer to queue.
* \param pHandlerId Handler ID of returned message; this is a return parameter.
*
* \return Pointer to the next message on the queue or NULL if queue is empty.
*/
/*************************************************************************************************/
void *WsfMsgPeek(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
#ifdef __cplusplus
};
#endif
#endif /* WSF_MSG_H */
@@ -0,0 +1,191 @@
/*************************************************************************************************/
/*!
* \file wsf_os.h
*
* \brief Software foundation OS API.
*
* $Date: 2017-03-02 16:50:43 -0600 (Thu, 02 Mar 2017) $
* $Revision: 11350 $
*
* Copyright (c) 2009-2017 ARM Ltd., all rights reserved.
* ARM Ltd. confidential and proprietary.
*
* IMPORTANT. Your use of this file is governed by a Software License Agreement
* ("Agreement") that must be accepted in order to download or otherwise receive a
* copy of this file. You may not use or copy this file for any purpose other than
* as described in the Agreement. If you do not agree to all of the terms of the
* Agreement do not use this file and delete all copies in your possession or control;
* if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
* to any use, copying or further distribution of this software.
*/
/*************************************************************************************************/
#ifndef WSF_OS_H
#define WSF_OS_H
#include "wsf_os_int.h"
#include "wsf_queue.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Configuration
**************************************************************************************************/
/* OS Diagnistics */
#ifndef WSF_OS_DIAG
#define WSF_OS_DIAG FALSE
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/* Invalid Task Identifier */
#define WSF_INVALID_TASK_ID 0xFF
#if WSF_OS_DIAG == TRUE
#define WSF_OS_GET_ACTIVE_HANDLER_ID() WsfActiveHandler
#else
#define WSF_OS_GET_ACTIVE_HANDLER_ID() WSF_INVALID_TASK_ID
#endif /* WSF_OS_DIAG */
/**************************************************************************************************
External Variables
**************************************************************************************************/
/* Diagnistic Task Identifier */
extern wsfHandlerId_t WsfActiveHandler;
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Common message structure passed to event handler */
typedef struct
{
uint16_t param; /*! General purpose parameter passed to event handler */
uint8_t event; /*! General purpose event value passed to event handler */
uint8_t status; /*! General purpose status value passed to event handler */
} wsfMsgHdr_t;
/**************************************************************************************************
Callback Function Types
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn wsfEventHandler_t
*
* \brief Event handler callback function.
*
* \param event Mask of events set for the event handler.
* \param pMsg Pointer to message for the event handler.
*
* \return None.
*/
/*************************************************************************************************/
typedef void (*wsfEventHandler_t)(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn WsfSetEvent
*
* \brief Set an event for an event handler.
*
* \param handlerId Handler ID.
* \param event Event or events to set.
*
* \return None.
*/
/*************************************************************************************************/
void WsfSetEvent(wsfHandlerId_t handlerId, wsfEventMask_t event);
/*************************************************************************************************/
/*!
* \fn WsfTaskLock
*
* \brief Lock task scheduling.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTaskLock(void);
/*************************************************************************************************/
/*!
* \fn WsfTaskUnlock
*
* \brief Unlock task scheduling.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTaskUnlock(void);
/*************************************************************************************************/
/*!
* \fn WsfTaskSetReady
*
* \brief Set the task used by the given handler as ready to run.
*
* \param handlerId Event handler ID.
* \param event Task event mask.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTaskSetReady(wsfHandlerId_t handlerId, wsfTaskEvent_t event);
/*************************************************************************************************/
/*!
* \fn WsfTaskMsgQueue
*
* \brief Return the task message queue used by the given handler.
*
* \param handlerId Event handler ID.
*
* \return Task message queue.
*/
/*************************************************************************************************/
wsfQueue_t *WsfTaskMsgQueue(wsfHandlerId_t handlerId);
/*************************************************************************************************/
/*!
* \fn WsfOsSetNextHandler
*
* \brief Set the next WSF handler function in the WSF OS handler array. This function
* should only be called as part of the OS initialization procedure.
*
* \param handler WSF handler function.
*
* \return WSF handler ID for this handler.
*/
/*************************************************************************************************/
wsfHandlerId_t WsfOsSetNextHandler(wsfEventHandler_t handler);
/*************************************************************************************************/
/*!
* \fn wsfOsSetEventObject
*
* \brief Pass RTOS event object to wsf OS scheduler. This function
* should only be called as part of the OS (RTOS) initialization procedure.
*
* \param event_object The pointer to an event object for RTOS.
*
* \return None
*/
/*************************************************************************************************/
void wsfOsSetEventObject(void *event_object);
#ifdef __cplusplus
};
#endif
#endif /* WSF_OS_H */
@@ -0,0 +1,155 @@
/*************************************************************************************************/
/*!
* \file wsf_queue.h
*
* \brief General purpose queue service.
*
* $Date: 2016-12-28 16:12:14 -0600 (Wed, 28 Dec 2016) $
* $Revision: 10805 $
*
* Copyright (c) 2009-2017 ARM Ltd., all rights reserved.
* ARM Ltd. confidential and proprietary.
*
* IMPORTANT. Your use of this file is governed by a Software License Agreement
* ("Agreement") that must be accepted in order to download or otherwise receive a
* copy of this file. You may not use or copy this file for any purpose other than
* as described in the Agreement. If you do not agree to all of the terms of the
* Agreement do not use this file and delete all copies in your possession or control;
* if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
* to any use, copying or further distribution of this software.
*/
/*************************************************************************************************/
#ifndef WSF_QUEUE_H
#define WSF_QUEUE_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/*! Initialize a queue */
#define WSF_QUEUE_INIT(pQueue) {(pQueue)->pHead = NULL; (pQueue)->pTail = NULL;}
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Queue structure */
typedef struct
{
void *pHead; /*! head of queue */
void *pTail; /*! tail of queue */
} wsfQueue_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn WsfQueueEnq
*
* \brief Enqueue an element to the tail of a queue.
*
* \param pQueue Pointer to queue.
* \param pElem Pointer to element.
*
* \return None.
*/
/*************************************************************************************************/
void WsfQueueEnq(wsfQueue_t *pQueue, void *pElem);
/*************************************************************************************************/
/*!
* \fn WsfQueueDeq
*
* \brief Dequeue an element from the head of a queue.
*
* \param pQueue Pointer to queue.
*
* \return Pointer to element that has been dequeued or NULL if queue is empty.
*/
/*************************************************************************************************/
void *WsfQueueDeq(wsfQueue_t *pQueue);
/*************************************************************************************************/
/*!
* \fn WsfQueuePush
*
* \brief Push an element to the head of a queue.
*
* \param pQueue Pointer to queue.
* \param pElem Pointer to element.
*
* \return None.
*/
/*************************************************************************************************/
void WsfQueuePush(wsfQueue_t *pQueue, void *pElem);
/*************************************************************************************************/
/*!
* \fn WsfQueueInsert
*
* \brief Insert an element into a queue. This function is typically used when iterating
* over a queue.
*
* \param pQueue Pointer to queue.
* \param pElem Pointer to element to be inserted.
* \param pPrev Pointer to previous element in the queue before element to be inserted.
* Note: set pPrev to NULL if pElem is first element in queue.
* \return None.
*/
/*************************************************************************************************/
void WsfQueueInsert(wsfQueue_t *pQueue, void *pElem, void *pPrev);
/*************************************************************************************************/
/*!
* \fn WsfQueueRemove
*
* \brief Remove an element from a queue. This function is typically used when iterating
* over a queue.
*
* \param pQueue Pointer to queue.
* \param pElem Pointer to element to be removed.
* \param pPrev Pointer to previous element in the queue before element to be removed.
*
* \return None.
*/
/*************************************************************************************************/
void WsfQueueRemove(wsfQueue_t *pQueue, void *pElem, void *pPrev);
/*************************************************************************************************/
/*!
* \fn WsfQueueCount
*
* \brief Count the number of elements in a queue.
*
* \param pQueue Pointer to queue.
*
* \return Number of elements in queue.
*/
/*************************************************************************************************/
uint16_t WsfQueueCount(wsfQueue_t *pQueue);
/*************************************************************************************************/
/*!
* \fn WsfQueueEmpty
*
* \brief Return TRUE if queue is empty.
*
* \param pQueue Pointer to queue.
*
* \return TRUE if queue is empty, FALSE otherwise.
*/
/*************************************************************************************************/
bool_t WsfQueueEmpty(wsfQueue_t *pQueue);
#ifdef __cplusplus
};
#endif
#endif /* WSF_QUEUE_H */
@@ -0,0 +1,168 @@
/*************************************************************************************************/
/*!
* \file wsf_timer.h
*
* \brief Timer service.
*
* $Date: 2016-12-28 16:12:14 -0600 (Wed, 28 Dec 2016) $
* $Revision: 10805 $
*
* Copyright (c) 2009-2017 ARM Ltd., all rights reserved.
* ARM Ltd. confidential and proprietary.
*
* IMPORTANT. Your use of this file is governed by a Software License Agreement
* ("Agreement") that must be accepted in order to download or otherwise receive a
* copy of this file. You may not use or copy this file for any purpose other than
* as described in the Agreement. If you do not agree to all of the terms of the
* Agreement do not use this file and delete all copies in your possession or control;
* if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
* to any use, copying or further distribution of this software.
*/
/*************************************************************************************************/
#ifndef WSF_TIMER_H
#define WSF_TIMER_H
#include "wsf_os.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
#ifndef WSF_MS_PER_TICK
/*! Default milliseconds per tick rate */
#define WSF_MS_PER_TICK 10
#endif
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Timer ticks data type */
typedef uint32_t wsfTimerTicks_t;
/*! Timer structure */
typedef struct wsfTimer_tag
{
struct wsfTimer_tag *pNext; /*! pointer to next timer in queue */
wsfTimerTicks_t ticks; /*! number of ticks until expiration */
wsfHandlerId_t handlerId; /*! event handler for this timer */
bool_t isStarted; /*! TRUE if timer has been started */
wsfMsgHdr_t msg; /*! application-defined timer event parameters */
} wsfTimer_t;
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn WsfTimerInit
*
* \brief Initialize the timer service. This function should only be called once
* upon system initialization.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTimerInit(void);
/*************************************************************************************************/
/*!
* \fn WsfTimerStartSec
*
* \brief Start a timer in units of seconds. Before this function is called parameter
* pTimer->handlerId must be set to the event handler for this timer and parameter
* pTimer->msg must be set to any application-defined timer event parameters.
*
* \param pTimer Pointer to timer.
* \param sec Seconds until expiration.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTimerStartSec(wsfTimer_t *pTimer, wsfTimerTicks_t sec);
/*************************************************************************************************/
/*!
* \fn WsfTimerStartMs
*
* \brief Start a timer in units of milliseconds.
*
* \param pTimer Pointer to timer.
* \param ms Milliseconds until expiration.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTimerStartMs(wsfTimer_t *pTimer, wsfTimerTicks_t ms);
/*************************************************************************************************/
/*!
* \fn WsfTimerStop
*
* \brief Stop a timer.
*
* \param pTimer Pointer to timer.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTimerStop(wsfTimer_t *pTimer);
/*************************************************************************************************/
/*!
* \fn WsfTimerUpdate
*
* \brief Update the timer service with the number of elapsed ticks. This function is
* typically called only from timer porting code.
*
* \param ticks Number of ticks since last update.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTimerUpdate(wsfTimerTicks_t ticks);
/*************************************************************************************************/
/*!
* \fn WsfTimerNextExpiration
*
* \brief Return the number of ticks until the next timer expiration. Note that this
* function can return zero even if a timer is running, indicating the timer
* has expired but has not yet been serviced.
*
* \param pTimerRunning Returns TRUE if a timer is running, FALSE if no timers running.
*
* \return The number of ticks until the next timer expiration.
*/
/*************************************************************************************************/
wsfTimerTicks_t WsfTimerNextExpiration(bool_t *pTimerRunning);
/*************************************************************************************************/
/*!
* \fn WsfTimerServiceExpired
*
* \brief Service expired timers for the given task. This function is typically called only
* WSF OS porting code.
*
* \param taskId OS Task ID of task servicing timers.
*
* \return Pointer to next expired timer or NULL if there are no expired timers.
*/
/*************************************************************************************************/
wsfTimer_t *WsfTimerServiceExpired(wsfTaskId_t taskId);
void WsfTimerUpdateTicks(void);
#ifdef __cplusplus
};
#endif
#endif /* WSF_TIMER_H */