mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-21 10:25:54 +08:00
更新硬件SDK
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,468 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
|
||||
* File name: apmu_external.h
|
||||
* Description: EC618 platform power management header file
|
||||
* History: 05/28/2018 Originated by bchang
|
||||
* A77F40058A2024A1DB6C8CDCD7888A53
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _EC_PM_EXT_H
|
||||
#define _EC_PM_EXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
#include "mem_map.h"
|
||||
#include "commontypedef.h"
|
||||
|
||||
|
||||
extern uint8_t apFlashMem[];
|
||||
extern uint8_t psSleep2Mem[];
|
||||
|
||||
|
||||
#define PS_PMUTIME_TEST (1)
|
||||
|
||||
#define PMU_ENABLE_MAGIC 0x504D5545 //"PMUE"
|
||||
#define PMU_DISABLE_MAGIC 0x504D5544 //"PMUD"
|
||||
|
||||
/* HIBCNT maximum value is 745 hours */
|
||||
#define HIBCNT_10MS_MAXIMUM 0x0FFFFFFF
|
||||
|
||||
#define DEEPSLP_TIMER_MAXRANGE 0x9EC96A00 // ticks in 740 hours
|
||||
|
||||
/******************************************************************************
|
||||
* For CAT1bis:
|
||||
* AP total AON RAM (Flash) 12 KB memory:
|
||||
* AON MEM
|
||||
* |<-------------------------- 4KB ------------------------------->|
|
||||
* +---------+-----------------+---------+-------------+------------+
|
||||
* |PLAT (1K)| MIDWARE |LWIP (1K)| CERRC BOOT | ERASECNT |
|
||||
* +---------+-----------------+---------+-------------+------------+
|
||||
* |<- 1KB ->|<-- 1792 Byte -->|<- 1KB ->|<- 252 Byte->|<- 4 Byte ->|
|
||||
*
|
||||
* |<-------------------------- 4KB ------------------------------->|
|
||||
* +---------------------------------------------------+------------+
|
||||
* | RRC Tiny Context | ERASECNT |
|
||||
* +---------------------------------------------------+------------+
|
||||
* | |<- 4 Byte ->|
|
||||
*
|
||||
* |<-------------------------- 4KB ------------------------------->|
|
||||
* +---------------------------------------------------+------------+
|
||||
* | CAM CCM NAS(CEPLMN/CEMM/CESM/SMS) UICC L2 | ERASECNT |
|
||||
* +---------------------------------------------------+------------+
|
||||
* |<- 4 Byte ->|
|
||||
*
|
||||
*=============================================================================
|
||||
* Note:
|
||||
* 1> All these 12 KB RAM, located in ASMB, and write back to flash before enter
|
||||
* HIB state, if any context changed.
|
||||
* 2> Only the first 4KB context need read to ASMB when wakeup from HIB to receive
|
||||
* paging.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*****
|
||||
* 4KB AON MEM 0
|
||||
*****/
|
||||
#define APMU_PLAT_AON_MEM_SIZE (1024) //1KB
|
||||
#define APMU_MID_WARE_AON_MEM_SIZE (1792) //1024+768
|
||||
#define APMU_TCPIP_AON_MEM_SIZE (1024)
|
||||
#define APMU_CERRC_BOOT_AON_MEM_SIZE (252)
|
||||
|
||||
|
||||
#define PLAT_AON_MEM_ADDR (apFlashMem)
|
||||
#define MID_WARE_AON_MEM_ADDR (apFlashMem + APMU_PLAT_AON_MEM_SIZE)
|
||||
#define TCPIP_AON_MEM_ADDR (MID_WARE_AON_MEM_ADDR + APMU_MID_WARE_AON_MEM_SIZE)
|
||||
#define CERRC_BOOT_AON_MEM_ADDR (TCPIP_AON_MEM_ADDR + APMU_TCPIP_AON_MEM_SIZE)
|
||||
|
||||
/*****
|
||||
* 4KB AON MEM 1
|
||||
*****/
|
||||
#define PS_AON_MEM_1_ADDR (apFlashMem + 4096)
|
||||
|
||||
|
||||
/*****
|
||||
* 4KB AON MEM 2
|
||||
*****/
|
||||
#define PS_AON_MEM_2_ADDR (apFlashMem + 8192)
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* SLEEP2 AP MEM
|
||||
* 4KB memory which could remain during SLEEP2 PMU state
|
||||
* Total
|
||||
* +-----------------------------+
|
||||
* | PS SLEEP2 MEM (4KB) |
|
||||
* +-----------------------------+
|
||||
* |<----------- 4K ------------>|
|
||||
*
|
||||
******************************************************************************/
|
||||
#define PS_SLEEP2_MEM_ADDR psSleep2Mem
|
||||
#define PS_SLEEP2_MEM_SIZE 4096 //4KB
|
||||
|
||||
|
||||
#define HIB_SECONDS_TO_TICKS(S) (UINT32)(S)
|
||||
#define HIB_MINUTES_TO_TICKS(M) (HIB_SECONDS_TO_TICKS(M)*60)
|
||||
|
||||
|
||||
//list which module should vote before system enter sleep state
|
||||
typedef enum PmuVoteSleepModule_enum
|
||||
{
|
||||
PMU_SLEEP_UICC_MOD,
|
||||
PMU_SLEEP_SCT_MOD,
|
||||
PMU_SLEEP_AT_UART_MOD,
|
||||
PMU_SLEEP_NUM_OF_MOD
|
||||
}PmuVoteSleepModule;
|
||||
|
||||
/*
|
||||
* list which module should vote before system enter hib state
|
||||
*/
|
||||
typedef enum PmuVoteDeepSlpModule_enum
|
||||
{
|
||||
PMU_DEEPSLP_PS_CCM_MOD,
|
||||
PMU_DEEPSLP_PS_CEMM_MOD,
|
||||
PMU_DEEPSLP_PS_CERRC_MOD,
|
||||
PMU_DEEPSLP_PS_UICC_MOD,
|
||||
PMU_DEEPSLP_PS_LWIP_MOD,
|
||||
PMU_DEEPSLP_CMS_MOD,
|
||||
|
||||
PMU_DEEPSLP_PS_CEUP_MOD, /* Note, CEUP MOD should be last,
|
||||
* as the UP preSleep Callback need check whether other module tiny context changed
|
||||
*/
|
||||
//...
|
||||
PMU_DEEPSLP_NUM_OF_MOD
|
||||
}PmuVoteDeepSlpModule;
|
||||
|
||||
|
||||
/*
|
||||
* list which module should vote before system enter off state
|
||||
*/
|
||||
typedef enum PmuVoteOffModule_enum
|
||||
{
|
||||
PMU_OFF_MODEM_MOD, /* modem vote off state, call when cfun0 success */
|
||||
PMU_OFF_USR_MOD, /* user vote off state, user call api to enable off state*/
|
||||
|
||||
PMU_OFF_NUM_OF_MOD
|
||||
}PmuVoteOffModule;
|
||||
|
||||
|
||||
/*
|
||||
* |<-------------------------- 4KB ------------------------------->|
|
||||
* +---------+-----------------+---------+-------------+------------+
|
||||
* |PLAT (1K)| MIDWARE |LWIP (1K)| CERRC BOOT | ERASECNT |
|
||||
* +---------+-----------------+---------+-------------+------------+
|
||||
* |<- 1KB ->|<-- 1792 Byte -->|<- 1KB ->|<- 252 Byte->|<- 4 Byte ->|
|
||||
*
|
||||
* |<-------------------------- 4KB ------------------------------->|
|
||||
* +---------------------------------------------------+------------+
|
||||
* | RRC Tiny Context | ERASECNT |
|
||||
* +---------------------------------------------------+------------+
|
||||
* | |<- 4 Byte ->|
|
||||
*
|
||||
* |<-------------------------- 4KB ------------------------------->|
|
||||
* +---------------------------------------------------+------------+
|
||||
* | CAM CCM NAS(CEPLMN/CEMM/CESM/SMS) UICC L2 | ERASECNT |
|
||||
* +---------------------------------------------------+------------+
|
||||
* |<- 4 Byte ->|
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* 4KB, flash sector 0 */
|
||||
AP_FLASHREQ_HIBTIMER = 0,
|
||||
AP_FLASHREQ_GLOBALCNT,
|
||||
AP_FLASHREQ_MIDWARE_CFG,
|
||||
AP_FLASHREQ_MIDWARE_AON,
|
||||
AP_FLASHREQ_LWIP,
|
||||
AP_FLASHREQ_CERRC_BOOT,
|
||||
AP_FLASHREQ_SECTOR0_END = AP_FLASHREQ_CERRC_BOOT,
|
||||
|
||||
/* 4KB, flash sector 1 */
|
||||
AP_FLASHREQ_RRC,
|
||||
AP_FLASHREQ_SECTOR1_END = AP_FLASHREQ_RRC,
|
||||
|
||||
/* 4KB, flash sector 2 */
|
||||
AP_FLASHREQ_CCM,
|
||||
AP_FLASHREQ_NAS,
|
||||
AP_FLASHREQ_UICC,
|
||||
AP_FLASHREQ_L2,
|
||||
AP_FLASHREQ_PDCP_PKG_STATIS,
|
||||
AP_FLASHREQ_SECTOR2_END = AP_FLASHREQ_PDCP_PKG_STATIS,
|
||||
|
||||
/* 4KB, flash sector 3 */
|
||||
AP_FLASHREQ_RSVD,
|
||||
AP_FLASHREQ_SECTOR3_END = AP_FLASHREQ_RSVD,
|
||||
|
||||
}APFlashWrReq_e;
|
||||
|
||||
typedef enum _EPAT_APSleepState_TAG
|
||||
{
|
||||
AP_STATE_ACTIVE=0,
|
||||
AP_STATE_IDLE,
|
||||
AP_STATE_SLEEP1,
|
||||
AP_STATE_SLEEP2,
|
||||
AP_STATE_HIBERNATE,
|
||||
AP_STATE_OFF,
|
||||
NUM_AP_LP_MODE
|
||||
} APSleepState;
|
||||
|
||||
typedef enum _EPAT_APBootFlag_e_TAG
|
||||
{
|
||||
AP_BOOT_FROM_POWER_ON = 0x0,
|
||||
AP_BOOT_FROM_UNDEF = 0x1,
|
||||
AP_BOOT_FROM_AS1 = 0x2,
|
||||
AP_BOOT_FROM_AS2 = 0x3,
|
||||
AP_BOOT_FROM_AH = 0x4,
|
||||
AP_BOOT_FROM_AO = 0x5,
|
||||
}APBootFlag_e;
|
||||
|
||||
|
||||
typedef enum _pmuen_config_id
|
||||
{
|
||||
PLAT_DISABLE_CONFIG_ACTION = 0, /**< pmu disable item */
|
||||
PLAT_ENABLE_CONFIG_ACTION, /**< pmu enable item */
|
||||
PLAT_ENABLE_ITEM_TOTAL_NUMBER /**< total number of items */
|
||||
} PmuEnCfgId;
|
||||
|
||||
|
||||
//internal pmu vote for platform use
|
||||
typedef enum PmuVotePlatInternal_enum
|
||||
{
|
||||
PMU_SLEEP_ATCMD_MOD, // vote to sleep when receive some at command
|
||||
PMU_SLEEP_NUM_OF_Other_MOD
|
||||
}PmuVotePlatInternal;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
WAKEUP_PAD_0 = 0,
|
||||
WAKEUP_PAD_1,
|
||||
WAKEUP_PAD_2,
|
||||
WAKEUP_PAD_3,
|
||||
WAKEUP_PAD_4,
|
||||
WAKEUP_PAD_5,
|
||||
WAKEUP_LPUART,
|
||||
WAKEUP_LPUSB,
|
||||
WAKEUP_PWRKEY,
|
||||
WAKEUP_CHARGE,
|
||||
WAKEUP_PAD_MAX
|
||||
}APmuWakeupPad_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool posEdgeEn;
|
||||
bool negEdgeEn;
|
||||
bool pullUpEn;
|
||||
bool pullDownEn;
|
||||
}APmuWakeupPadSettings_t;
|
||||
|
||||
|
||||
typedef void(* pmuPreDeepSlpCb_t)(void *pdata, APSleepState state);
|
||||
typedef void(* pmuPostDeepSlpCb_t)(void *pdata, APSleepState state);
|
||||
|
||||
|
||||
void apmuVoteToSleep1State(PmuVoteSleepModule pmuMod, BOOL bAllow);
|
||||
void apmuVoteToSleep2State(PmuVoteDeepSlpModule pmuMod, BOOL bAllow);
|
||||
void apmuVoteToHibState(PmuVoteDeepSlpModule pmuMod, BOOL bAllow);
|
||||
void apmuVoteToOffState(PmuVoteOffModule pmuMod, BOOL bAllow);
|
||||
BOOL apmuBVoteToSleep1State(PmuVoteSleepModule pmuMod);
|
||||
BOOL apmuBVoteToSleep2State(PmuVoteDeepSlpModule pmuMod);
|
||||
BOOL apmuBVoteToHibState(PmuVoteDeepSlpModule pmuMod);
|
||||
BOOL apmuBVoteToSleep1State(PmuVoteSleepModule pmuMod);
|
||||
void apmuGetSDKVoteDetail(uint32_t *sleepVoteFlag, uint32_t *sleep2VoteFlag, uint32_t *hibVoteFlag);
|
||||
void apmuSetDeepestSleepMode(APSleepState state);
|
||||
APSleepState apmuGetDeepestSleepMode(void);
|
||||
BOOL apmuBWakeupFromHib(void);
|
||||
BOOL apmuBWakeupFromSleep1(void);
|
||||
BOOL apmuBWakeupFromSleep2(void);
|
||||
BOOL pmuBPsVoteToDeepSAPSleepState(void);
|
||||
uint32_t apmuBuildWaitSlpCfg(uint32_t value);
|
||||
uint32_t apmuGetWaitSlpCfg(uint32_t value);
|
||||
void apmuSdkFlashWrReq(APFlashWrReq_e reqID);
|
||||
BOOL apmuSdkFlashBlockBeWr(APFlashWrReq_e reqID);
|
||||
void apmuPreDeepSlpCbRegister(PmuVoteDeepSlpModule module, pmuPreDeepSlpCb_t cb, void *pdata);
|
||||
void apmuPostDeepSlpCbRegister(PmuVoteDeepSlpModule module, pmuPostDeepSlpCb_t cb, void *pdata);
|
||||
void apmuGetPMUSettings(APSleepState defaultState);
|
||||
BOOL apmuBPsVoteToDeepSlpState(void);
|
||||
bool apmuGetSleepedFlag(void);
|
||||
void apmuPrintPostPagingSlowCnt(void);
|
||||
uint16_t apmuGetLatchExternalInt(void);
|
||||
void ApmuWakeupProc(uint8_t wakeupEvent, uint8_t branchFlag);
|
||||
|
||||
/**
|
||||
* @brief apmuSetWakeupPadCfg
|
||||
* @details set a specific pad as a wakeup pad and control the wakeup edge and pull settings
|
||||
* @return
|
||||
* @note
|
||||
*/
|
||||
void apmuSetWakeupPadCfg(APmuWakeupPad_e padNum, bool wakeupEn, APmuWakeupPadSettings_t *cfg);
|
||||
/**
|
||||
* @brief apmuGetWakeupPadCfg
|
||||
* @details get wakeup pad config
|
||||
* @return
|
||||
* @note
|
||||
*/
|
||||
void apmuGetWakeupPadCfg(APmuWakeupPad_e padNum, bool *isWakeupEn, APmuWakeupPadSettings_t *cfg);
|
||||
/**
|
||||
* @brief apmuGetAPBootFlag
|
||||
* @details get AP Boot Flag
|
||||
* @return
|
||||
* @note
|
||||
*/
|
||||
APBootFlag_e apmuGetAPBootFlag(void);
|
||||
/**
|
||||
* @brief apmuGetAPLLBootFlag
|
||||
* @details get AP LLBoot Flag
|
||||
* @return
|
||||
* @note
|
||||
*/
|
||||
APBootFlag_e apmuGetAPLLBootFlag(void);
|
||||
/**
|
||||
* @brief apmuIntInit
|
||||
* @details enable ap interrupt
|
||||
* @return
|
||||
* @note
|
||||
*/
|
||||
void apmuIntInit(void);
|
||||
/**
|
||||
* @brief apmuRestoreHibTimer
|
||||
* @details retore hib timer
|
||||
* @return
|
||||
* @note
|
||||
*/
|
||||
void apmuRestoreHibTimer(void);
|
||||
/**
|
||||
* @brief apmuSetSwWakeupSlowCnt
|
||||
* @details get a slowcnt as soon as the software wakeup, this api call in ram
|
||||
* @note
|
||||
*/
|
||||
void apmuSetSwWakeupSlowCnt(void);
|
||||
/**
|
||||
* @brief apmuSetSwWakeupSlowCnt
|
||||
* @details get a slowcnt as soon as the software wakeup, this api call in flash
|
||||
* @note
|
||||
*/
|
||||
void apmuSetSwWakeupSlowCntFlash(void);
|
||||
/**
|
||||
* @brief apmuGetBT10MsCnt
|
||||
* @details get BT counter in 10ms, for hibcnt
|
||||
* @note
|
||||
*/
|
||||
uint32_t apmuGetBT10MsCnt(void);
|
||||
/**
|
||||
* @brief apmuGetBTMsCnt
|
||||
* @details get BT counter in 1ms, for system time check
|
||||
* @note
|
||||
*/
|
||||
uint32_t apmuGetBTMsCnt(void);
|
||||
/**
|
||||
* @brief apmuGetBTSampleCnt
|
||||
* @details get accurate BT counter in 30.72M
|
||||
[31:15]: in milisecond
|
||||
[14: 0]: 30720 in 1 milisecond
|
||||
* @note
|
||||
*/
|
||||
uint32_t apmuGetBTSampleCnt(void);
|
||||
/**
|
||||
* @brief apmuSetCPFastBoot
|
||||
* @details set cp fast boot, but not power on cp
|
||||
|
||||
* @param force_on =true if cp code is not valid still config fast boot
|
||||
force_on=false if cp code is not valid do not config fast boot
|
||||
|
||||
* @note
|
||||
*/
|
||||
void apmuSetCPFastBoot(bool force_on);
|
||||
/**
|
||||
* @brief apmuPsFullImageTransfer
|
||||
* @details set toFullImage = true if ps want to go full image
|
||||
|
||||
* @param toFullImage =true if ps want to go full image
|
||||
toFullImage=false continue to loop in ap paging
|
||||
* @note
|
||||
*/
|
||||
void apmuPsFullImageTransfer(bool toFullImage);
|
||||
/**
|
||||
* @brief ApmuWtdgStop
|
||||
* @details aon watchdog is start in closed source api when power on, but can close through calling this api
|
||||
|
||||
* @note
|
||||
*/
|
||||
void ApmuWtdgStop(void);
|
||||
/**
|
||||
* @brief ApmuWtdgStop
|
||||
* @details feed aon watch dog
|
||||
* @note
|
||||
*/
|
||||
void ApmuFeedWtdg(void);
|
||||
/**
|
||||
* @brief restore boot flag to RAM var
|
||||
* @details called when paltform boot up to record golbal boot flag
|
||||
|
||||
* @note
|
||||
*/
|
||||
void apmuRestoreBootFlag(void);
|
||||
/**
|
||||
* @brief AonRegGetAPBootFlag
|
||||
* @details get ap bootflag
|
||||
|
||||
* @note
|
||||
*/
|
||||
uint8_t AonRegGetAPBootFlag(void);
|
||||
/**
|
||||
* @brief AonRegSetSimLatchEnable
|
||||
* @details for uicc use
|
||||
|
||||
* @note
|
||||
*/
|
||||
void AonRegSetSimLatchEnable(bool en);
|
||||
/**
|
||||
* @brief AonRegGetSimLatchState
|
||||
* @details for uicc use
|
||||
|
||||
* @note
|
||||
*/
|
||||
bool AonRegGetSimLatchState(void);
|
||||
/**
|
||||
* @brief apmuGetImageType
|
||||
* @details get current image type
|
||||
* @note
|
||||
*/
|
||||
uint8_t apmuGetImageType(void);
|
||||
/**
|
||||
* @brief apmuSetBootTimeStamp
|
||||
* @details set and store time stamp in boot flow
|
||||
* @note
|
||||
*/
|
||||
void apmuSetBootTimeStamp(bool isPostPaging, uint8_t index);
|
||||
/**
|
||||
* @brief apmuPrintBootTimeStamp
|
||||
* @details print time stamp in boot flow
|
||||
* @note
|
||||
*/
|
||||
void apmuPrintBootTimeStamp(bool isPostPaging);
|
||||
/**
|
||||
* @brief apmuBTChangedFlag(int value)
|
||||
* @details indicate bt has changed, param value is for debug, always set to 0
|
||||
* @note
|
||||
*/
|
||||
void apmuBTChangedFlag(int value);
|
||||
/**
|
||||
* @brief void apmuInit(void)
|
||||
* @details apmu init
|
||||
* @note
|
||||
*/
|
||||
void apmuInit(void);
|
||||
|
||||
#define BOOT_TIMESTAMP_SET(type, index) apmuSetBootTimeStamp(type, index)
|
||||
#define BOOT_TIMESTAMP_PRINT(type) apmuPrintBootTimeStamp(type)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,568 @@
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: ccio_device.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2021/1/19 created by xuwang
|
||||
*
|
||||
* Notes: channel device of Channel Centre for Input/Output(CCIO) service
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef CCIO_DEVICE_H
|
||||
#define CCIO_DEVICE_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "ccio_pub.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/* build device status flag begin & end Idx
|
||||
1 1 1
|
||||
6 3 2 0
|
||||
|--ht--+-irq-+----------------code-------|
|
||||
|======+=====+===========================|
|
||||
| CCIO Device FLAG |
|
||||
|======+=====+===========================|
|
||||
--[NOTE]
|
||||
ht : hw type
|
||||
*/
|
||||
#define CCIO_DSF_BASE_BUILD(ht) ((0x0D5F << 16) | ((ht) << 13))
|
||||
#define CCIO_DSF_END_BUILD(ht) (CCIO_DSF_BASE_BUILD(ht) | CCIO_BITMASK(13, 0))
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
/* 'flags' definition of 'chdevExecFunc' */
|
||||
typedef enum
|
||||
{
|
||||
CCIO_DEF_BEGIN = 0x0DEF0000,
|
||||
|
||||
CCIO_DEF_CHG_SERL_CONF = CCIO_DEF_BEGIN,
|
||||
CCIO_DEF_GET_RECV_CONF,
|
||||
CCIO_DEF_SET_RECV_CONF,
|
||||
CCIO_DEF_SET_STATIC_CONF,
|
||||
CCIO_DEF_SET_DATA_CONF,
|
||||
|
||||
CCIO_DEF_ULDP_RESET,
|
||||
CCIO_DEF_ULDP_RESUME,
|
||||
CCIO_DEF_ULDP_START_SW,
|
||||
CCIO_DEF_ULDP_SET_SW_CONF,
|
||||
CCIO_DEF_ULDP_CLR_NPT_STATE,
|
||||
|
||||
CCIO_DEF_SET_PPP_ACCM,
|
||||
CCIO_DEF_SET_PPP_SPEC,
|
||||
CCIO_DEF_ETH_MEDIA_STATUS,
|
||||
CCIO_DEF_FLUSH_TX_FIFO,
|
||||
CCIO_DEF_DIRECT_OUTPUT,
|
||||
CCIO_DEF_UNBLOCK_SCT_EP,
|
||||
CCIO_DEF_SERL_DCD_STATUS,
|
||||
CCIO_DEF_SERL_RI_STATUS,
|
||||
CCIO_DEF_GET_CTS_SIGNAL,
|
||||
|
||||
CCIO_DEF_CUST_RSVD_BEGIN = 0x0DEFC000,
|
||||
/*
|
||||
* rsvd for customers
|
||||
* refer to 'CcioCustDevExecFlags_e'
|
||||
*/
|
||||
CCIO_DEF_CUST_RSVD_END = 0x0DEFFFFF,
|
||||
|
||||
CCIO_DEF_END = CCIO_DEF_CUST_RSVD_END,
|
||||
CCIO_DEF_UNDEF = CCIO_DEF_END
|
||||
}CcioDevExecFlags_e;
|
||||
|
||||
/* CCIO_DEF_CHG_SERL_CONF */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t baudRate;
|
||||
uint32_t frameFmt;
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDeaChgSerlConf_t;
|
||||
|
||||
/* CCIO_DEF_GET_RECV_CONF */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t isRxWinEn :1;
|
||||
uint8_t isXferChk :1;
|
||||
uint8_t rsvdBits :6;
|
||||
uint16_t rxWinSize; /* recv window size */
|
||||
uint16_t dummySti; /* dummy startIdx, valid @dummyCnt != 0 */
|
||||
uint16_t dummyCnt; /* dummy cnt, for uart rbuf flush */
|
||||
uint16_t xferCnt;
|
||||
uint16_t writeIdx; /* in: last writeIdx, out: latest writeIdx */
|
||||
}CcioDeaGetRecvConf_t;
|
||||
|
||||
/* CCIO_DEF_SET_RECV_CONF */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t isCctEn :1;
|
||||
uint8_t forceTrigg :1;
|
||||
uint8_t rsvdBits :6;
|
||||
uint16_t readIdx;
|
||||
uint16_t writeIdx;
|
||||
}CcioDeaSetRecvConf_t;
|
||||
|
||||
/* CCIO_DEF_SET_STATIC_CONF */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t rsvd[3];
|
||||
uint16_t ahcbSize :6; /* Additional-Header-Control-Block */
|
||||
uint16_t alignVal :3;
|
||||
uint16_t isThresEn :1;
|
||||
uint16_t rsvdBits :6;
|
||||
uint16_t cctSize;
|
||||
uint16_t avlbThres;
|
||||
uint16_t writeIdx;
|
||||
uint16_t readIdx;
|
||||
uint16_t bufLen;
|
||||
uint8_t *buffer;
|
||||
}CcioDeaSetStaticConf_t;
|
||||
|
||||
/* CCIO_DEF_SET_DATA_CONF */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t bmHwAcm;
|
||||
uint16_t cctSize;
|
||||
uint8_t alignVal;
|
||||
uint8_t rsvd[2];
|
||||
uint8_t dtype; /* CcioDevType_e */
|
||||
union
|
||||
{
|
||||
CsioDevType_e stype;
|
||||
CnioDevType_e ntype;
|
||||
CuioDevType_e utype;
|
||||
}subtype;
|
||||
}CcioDeaSetDataConf_t;
|
||||
|
||||
/* CCIO_DEF_ULDP_RESET */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t rsvd[4];
|
||||
}CcioDeaUldpReset_t;
|
||||
|
||||
/* CCIO_DEF_ULDP_RESUME */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t rsvd[4];
|
||||
}CcioDeaUldpResume_t;
|
||||
|
||||
/* CCIO_DEF_ULDP_START_SW */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t rsvd[4];
|
||||
}CcioDeaUldpStartSw_t;
|
||||
|
||||
/* CCIO_DEF_ULDP_SET_SW_CONF */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *srcAddr;
|
||||
uint16_t len;
|
||||
uint8_t rsvd[2];
|
||||
}CcioDeaUldpSetSwConf_t;
|
||||
|
||||
/* CCIO_DEF_ULDP_CLR_NPT_STATE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t rsvd[4];
|
||||
}CcioDeaUldpClrNptState_t;
|
||||
|
||||
/* CCIO_DEF_SET_PPP_ACCM */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t isOut; /* is accm for output or input? */
|
||||
uint8_t rsvd[2];
|
||||
uint32_t accm[8];
|
||||
}CcioDeaSetPppAccm_t;
|
||||
|
||||
/* CCIO_DEF_SET_PPP_SPEC */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t data[3];
|
||||
uint8_t rsvd;
|
||||
}CcioDeaSetPppSpec_t;
|
||||
|
||||
/* CCIO_DEF_ETH_MEDIA_STATUS */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t lanType; /* refer to 'CcioLanMediaType_e' */
|
||||
uint8_t isWanAvlb;
|
||||
uint8_t rsvd[2];
|
||||
}CcioDeaEthMediaStatus_t;
|
||||
|
||||
/* CCIO_DEF_FLUSH_TX_FIFO */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t rsvd[3];
|
||||
void *extras;
|
||||
}CcioDeaFlushTxFifo_t;
|
||||
|
||||
/* CCIO_DEF_DIRECT_OUTPUT */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t rsvd[3];
|
||||
void *dlpdu;
|
||||
}CcioDeaDirectOutput_t;
|
||||
|
||||
/* CCIO_DEF_UNBLOCK_SCT_EP */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t rsvd[3];
|
||||
}CcioDeaUnblockSctEp_t;
|
||||
|
||||
/* CCIO_DEF_SERL_DCD_STATUS */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t state; /* CcioSerlDcdState_e */
|
||||
uint8_t rsvd[2];
|
||||
}CcioDeaSerlDcdStatus_t;
|
||||
|
||||
/* CCIO_DEF_SERL_RI_STATUS */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t rsvd[3];
|
||||
uint16_t cycleCnt;
|
||||
uint16_t dutyCyclePct;
|
||||
uint32_t cycleTimeMs;
|
||||
}CcioDeaSerlRiStatus_t;
|
||||
|
||||
/* CCIO_DEF_GET_CTS_SIGNAL */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t llsn;
|
||||
uint8_t isAllowed;
|
||||
uint8_t rsvd[2];
|
||||
}CcioDeaGetCtsSignal_t;
|
||||
|
||||
/* 'flags' definition of 'chdevStatusCallback' */
|
||||
typedef enum
|
||||
{
|
||||
CCIO_DSF_USB_BEGIN = CCIO_DSF_BASE_BUILD(CCIO_HT_USB),
|
||||
CCIO_DSF_QUERY_PEER_MAC = CCIO_DSF_USB_BEGIN,
|
||||
CCIO_DSF_QUERY_LOCAL_MAC,
|
||||
CCIO_DSF_RNDIS_INIT,
|
||||
CCIO_DSF_RNDIS_HALT,
|
||||
CCIO_DSF_RNDIS_RESET,
|
||||
CCIO_DSF_ECM_SET_FILTER,
|
||||
CCIO_DSF_PPP_SPEC_PATTN,
|
||||
CCIO_DSF_RBUF_EBNA,
|
||||
CCIO_DSF_RNDIS_ESIZE,
|
||||
CCIO_DSF_USB_ESTATUS,
|
||||
CCIO_DSF_AHB_EADDR,
|
||||
CCIO_DSF_SCT_TX_FDBACK,
|
||||
CCIO_DSF_SCT_TX_DONE,
|
||||
CCIO_DSF_SCT_USB_STATE,
|
||||
CCIO_DSF_SCT_USB_TMEXPR,
|
||||
CCIO_DSF_SCT_USB_UNBLKEP,
|
||||
CCIO_DSF_USB_STATE,
|
||||
CCIO_DSF_USB_END = CCIO_DSF_END_BUILD(CCIO_HT_USB),
|
||||
|
||||
CCIO_DSF_UART_BEGIN = CCIO_DSF_BASE_BUILD(CCIO_HT_UART),
|
||||
CCIO_DSF_AUTO_BAUDRATE = CCIO_DSF_UART_BEGIN,
|
||||
CCIO_DSF_WAIT_TX_DONE,
|
||||
CCIO_DSF_SET_TX_DONE,
|
||||
CCIO_DSF_IPR_FLUSH,
|
||||
CCIO_DSF_UART_END = CCIO_DSF_END_BUILD(CCIO_HT_UART),
|
||||
|
||||
CCIO_DSF_RADIO_BEGIN = CCIO_DSF_BASE_BUILD(CCIO_HT_RADIO),
|
||||
CCIO_DSF_ULPDU_FREE = CCIO_DSF_RADIO_BEGIN,
|
||||
CCIO_DSF_DLPDU_FREE,
|
||||
CCIO_DSF_WAN_MEDIA_NOTIF,
|
||||
CCIO_DSF_RADIO_END = CCIO_DSF_END_BUILD(CCIO_HT_RADIO),
|
||||
|
||||
CCIO_DSF_HWIND_BEGIN = CCIO_DSF_BASE_BUILD(CCIO_HT_HWIND),
|
||||
CCIO_DSF_DEV_ADD,
|
||||
CCIO_DSF_DEV_DEL,
|
||||
CCIO_DSF_CTS_CHG,
|
||||
CCIO_DSF_DTR_CHG,
|
||||
CCIO_DSF_RI_DONE,
|
||||
CCIO_DSF_HWIND_END = CCIO_DSF_END_BUILD(CCIO_HT_HWIND),
|
||||
|
||||
CCIO_DSF_CUSTOM_BEGIN = CCIO_DSF_BASE_BUILD(CCIO_BITMASK(3, 0)),
|
||||
/*
|
||||
* rsvd for customers
|
||||
* refer to 'CcioCustDevStatusFlags_e'
|
||||
*/
|
||||
CCIO_DSF_CUSTOM_END = CCIO_DSF_END_BUILD(CCIO_BITMASK(3, 0)),
|
||||
|
||||
CCIO_DSF_UNDEF = 0x0D5FFFFF
|
||||
}CcioDevStatusFlags_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t xferCnt;
|
||||
uint16_t startIdx;
|
||||
uint32_t xferCos; /* refer to CCIO_CHAN_MSG_CF_COS0/1/2 */
|
||||
uint32_t flags; /* for CcioDevStatusFlags_e */
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDevInXfer_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCIO_OXT_PDU_LIST_WITHOUT_TAIL, /* "DlPduBlock_t" one node/list need output, only pass the header, carried in: "CcioDevOutXfer_t->dlpdu" */
|
||||
CCIO_OXT_PDU_LIST_WITH_TAIL, /* "DlPduBlock_t" list need output, pass the header and tail,
|
||||
* header: "CcioDevOutXfer_t->dlpdu"
|
||||
* tail : "CcioDevOutXfer_t->extra"
|
||||
*/
|
||||
CCIO_OXT_PDU_LIST_EVENT /* "DlPduBlock_t" is in a shared list, notify Tx task to get from the list when proc this type
|
||||
* Only used for PS DL PDU (IP), sent from L2
|
||||
*/
|
||||
}CcioOutXferType_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCIO_OXF_RAW_DATA,
|
||||
CCIO_OXF_CMD_LINE,
|
||||
|
||||
CCIO_OXF_MAXNUM
|
||||
}CcioOutXferFormat_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t outType; /* CcioOutXferType_e */
|
||||
uint8_t outFmt; /* CcioOutXferFormat_e */
|
||||
uint8_t xtag; /* some kind of private info */
|
||||
uint8_t rsvd; /* used for 4 byte aligned */
|
||||
void *head; /* DlPduBlock_t */
|
||||
void *tail;
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDevOutXfer_t;
|
||||
|
||||
typedef CcioDevInXfer_t CcioDsaRxStatus_t;
|
||||
|
||||
/* CCIO_DSF_QUERY_PEER_MAC */
|
||||
typedef CcioMacAddr_t CcioDsaQueryPeerMac_t;
|
||||
|
||||
/* CCIO_DSF_QUERY_LOCAL_MAC */
|
||||
typedef CcioMacAddr_t CcioDsaQueryLocalMac_t;
|
||||
|
||||
/* CCIO_DSF_RNDIS_INIT */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaRndisInit_t;
|
||||
|
||||
/* CCIO_DSF_RNDIS_HALT */
|
||||
/* CCIO_DSF_RNDIS_RESET */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaRndisDeinit_t;
|
||||
|
||||
/* CCIO_DSF_ECM_SET_FILTER */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaEcmSetFilter_t;
|
||||
|
||||
/* CCIO_DSF_SCT_TX_FDBACK */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t isCmplt;
|
||||
uint8_t rsvd[3];
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaSctTxFdback_t;
|
||||
|
||||
/* CCIO_DSF_SCT_TX_DONE */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t txEvt;
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaSctTxDone_t;
|
||||
|
||||
/* CCIO_DSF_SCT_USB_STATE */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t stateEvt;
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaSctUsbState_t;
|
||||
|
||||
/* CCIO_DSF_SCT_USB_TMEXPR */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t timerId;
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaSctUsbTmExpr_t;
|
||||
|
||||
/* CCIO_DSF_SCT_USB_UNBLKEP */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t epNum;
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaSctUsbUnblkEp_t;
|
||||
|
||||
/* CCIO_DSF_USB_STATE */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t isEnable;
|
||||
uint16_t devState;
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaUsbState_t;
|
||||
|
||||
/* CCIO_DSF_AUTO_BAUDRATE */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t baudRate;
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaAutoBaudRate_t;
|
||||
|
||||
/* CCIO_DSF_WAIT_TX_DONE */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaWaitTxDone_t;
|
||||
|
||||
/* CCIO_DSF_SET_TX_DONE */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaSetTxDone_t;
|
||||
|
||||
/* CCIO_DSF_ULPDU_FREE */
|
||||
typedef struct
|
||||
{
|
||||
void *ulpdu; /* maybe a list */
|
||||
void *extras;
|
||||
}CcioDsaUlPduFree_t;
|
||||
|
||||
/* CCIO_DSF_DLPDU_FREE */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t isFast; /* If TRUE, "list" set to PNULL, and Tx task call: NetifLanDlPkgListGet() to get the DL PDu to free */
|
||||
uint8_t xtag; /* some kind of private info */
|
||||
uint8_t rsvd[2];
|
||||
void *dlpdu; /* maybe a list */
|
||||
void *chdev;
|
||||
}CcioDsaDlPduFree_t;
|
||||
|
||||
/* CCIO_DSF_WAN_MEDIA_NOTIF */
|
||||
typedef CcioDataPathCap_t CcioDsaWanMediaNotif_t;
|
||||
|
||||
/* CCIO_DSF_DEV_ADD */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaDevAdd_t;
|
||||
|
||||
/* CCIO_DSF_DEV_DEL */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaDevDel_t;
|
||||
|
||||
/* CCIO_DSF_CTS_CHG */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t isAllowed;
|
||||
uint8_t epNum;
|
||||
uint8_t rsvd[2];
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaCtsChg_t;
|
||||
|
||||
/* CCIO_DSF_DTR_CHG */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaDtrChg_t;
|
||||
|
||||
/* CCIO_DSF_RI_DONE */
|
||||
typedef struct
|
||||
{
|
||||
struct CcioDevice *chdev;
|
||||
}CcioDsaRiDone_t;
|
||||
|
||||
|
||||
typedef int32_t (*chdevPostHandleFunc)(CcioDevice_t *chdev, void *extras);
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
/**
|
||||
* get rigestered device ctlr map in DeviceMan;
|
||||
*/
|
||||
uint32_t ccioGetDevRdcm(void);
|
||||
/**
|
||||
* Add an I/O device to the list of CCIO devices by driver
|
||||
* And it is disabled by default if not referred by an entity,
|
||||
* In which state drivers cannot input anything.
|
||||
*/
|
||||
CcioDevice_t* ccioAddDevice(CcioDevice_t *chdev);
|
||||
/**
|
||||
* Delete an I/O device from the list of CCIO devices by driver;
|
||||
*/
|
||||
int32_t ccioDelDevice(CcioDevice_t *chdev);
|
||||
/**
|
||||
* Find a device by searching for its device Id
|
||||
*/
|
||||
CcioDevice_t* ccioFindDevice(uint16_t devId);
|
||||
/**
|
||||
* Find a device by searching for its device type and subtype
|
||||
*/
|
||||
CcioDevice_t* ccioFindDeviceByTypes(CcioHwType_e hwtype, CcioDevType_e dtype, uint8_t subtype);
|
||||
/**
|
||||
* assign an unused device to channel entity via specific device types
|
||||
*/
|
||||
CcioDevice_t* ccioAssignDeviceByTypes(CcioDevType_e dtype, uint8_t subtype);
|
||||
/**
|
||||
* assign an unused device to channel entity via device type
|
||||
*/
|
||||
CcioDevice_t* ccioAssignDeviceByType(CcioDevType_e dtype);
|
||||
/**
|
||||
* traverse all devices by searching for its hw type
|
||||
*/
|
||||
int32_t ccioTraverseDeviceByHwType(CcioHwType_e hwtype, void *extras, chdevPostHandleFunc postHandleFn);
|
||||
/**
|
||||
* check if there are any free device in the list
|
||||
*/
|
||||
bool_t ccioHasFreeDevice(void);
|
||||
/**
|
||||
* release the device ever used by channel entity
|
||||
*/
|
||||
int32_t ccioReleaseDevice(CcioDevice_t* chdev);
|
||||
/**
|
||||
* set the device neccesary facility.
|
||||
*/
|
||||
void ccioSetDeviceEntity(CcioDevice_t *chdev, chdevInCallback chdevInCb, void *chent);
|
||||
/**
|
||||
* set the working state of device.
|
||||
*/
|
||||
void ccioSetDeviceState(CcioDevice_t *chdev, CcioDevWorkState_e state, uint8_t bmHwAcm);
|
||||
|
||||
uint8_t ccioAsgnDeviceTxCos(CcioHwType_e htype, uint8_t idx);
|
||||
|
||||
/**
|
||||
* free the ulpdu list for a certain kind of device.
|
||||
*/
|
||||
void ccioFreeDeviceUlPdu(CcioDevice_t *chdev, void *ulpduList);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: ccio_entity.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2021/1/19 created by xuwang
|
||||
*
|
||||
* Notes: Channel Centre for Input/Output(CCIO) service
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef CCIO_ENTITY_H
|
||||
#define CCIO_ENTITY_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "ccio_base.h"
|
||||
#include "ccio_pub.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define CCIO_CHAN_OPEN(chent) (chent)->open = 1
|
||||
#define CCIO_CHAN_CLOSE(chent) (chent)->open = 0
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
/* 'flags' definition of 'chentStatusCallback' */
|
||||
typedef enum
|
||||
{
|
||||
CCIO_ESF_BEGIN = 0x0E5F0000,
|
||||
CCIO_ESF_SET_WAN_ENTITY = CCIO_ESF_BEGIN,
|
||||
CCIO_ESF_UNSET_WAN_ENTITY,
|
||||
CCIO_ESF_SET_LAN_ENTITY,
|
||||
CCIO_ESF_UNSET_LAN_ENTITY,
|
||||
CCIO_ESF_SET_DIAG_ENTITY,
|
||||
CCIO_ESF_UNSET_DIAG_ENTITY,
|
||||
|
||||
CCIO_ESF_CUST_RSVD_BEGIN = 0x0E5FC000,
|
||||
/*
|
||||
* rsvd for customers
|
||||
* refer to 'CcioCustEntStatusFlags_e'
|
||||
*/
|
||||
CCIO_ESF_CUST_RSVD_END = 0x0E5FFFFF,
|
||||
|
||||
CCIO_ESF_END = CCIO_ESF_CUST_RSVD_END,
|
||||
CCIO_ESF_UNDEF = CCIO_ESF_END
|
||||
}CcioEntStatusFlags_e;
|
||||
|
||||
/* CCIO_ESF_SET_WAN_ENTITY */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t pdpCid;
|
||||
uint8_t rsvd[3];
|
||||
void *chent;
|
||||
}CcioEsaSetWanEntity_t;
|
||||
|
||||
/* CCIO_ESF_UNSET_WAN_ENTITY */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t pdpCid;
|
||||
uint8_t rsvd[3];
|
||||
}CcioEsaUnsetWanEntity_t;
|
||||
|
||||
/* CCIO_ESF_SET_LAN_ENTITY */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t lanType; /* refer to 'CcioLanMediaType_e' */
|
||||
uint8_t rsvd[3];
|
||||
void *chent;
|
||||
}CcioEsaSetLanEntity_t;
|
||||
|
||||
/* CCIO_ESF_UNSET_LAN_ENTITY */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t lanType; /* refer to 'CcioLanMediaType_e' */
|
||||
uint8_t rsvd[3];
|
||||
}CcioEsaUnsetLanEntity_t;
|
||||
|
||||
/* CCIO_ESF_SET_DIAG_ENTITY */
|
||||
typedef struct
|
||||
{
|
||||
void *chent;
|
||||
}CcioEsaSetDiagEntity_t;
|
||||
|
||||
/* CCIO_ESF_UNSET_DIAG_ENTITY */
|
||||
typedef struct
|
||||
{
|
||||
void *chent;
|
||||
}CcioEsaUnsetDiagEntity_t;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief ccioSetBaseEntity(CcioEntity_t *chent,
|
||||
uint8_t hasRbuf,
|
||||
uint8_t chanType,
|
||||
uint8_t servType,
|
||||
chentStatusCallback statusCb)
|
||||
* @details base entity settings
|
||||
*
|
||||
* @param chent The base entity to be set
|
||||
* @param chanType The channel type
|
||||
* @param servType The service type
|
||||
* @param status_cb The handler of entity status
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ccioSetBaseEntity(CcioEntity_t *chent,
|
||||
uint8_t hasRbuf,
|
||||
uint8_t chanType,
|
||||
uint8_t servType,
|
||||
chentStatusCallback statusCb);
|
||||
|
||||
/**
|
||||
* @brief ccioResetBaseEntity(CcioEntity_t *chent)
|
||||
* @details base entity clearing
|
||||
*
|
||||
* @param chent The base entity to be set
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ccioResetBaseEntity(CcioEntity_t *chent);
|
||||
|
||||
/**
|
||||
* @brief ccioAddEntity(CcioEntity_t *chent)
|
||||
* @details add the entity to the list
|
||||
*
|
||||
* @param chent The chan entity to be added
|
||||
* @return !NULL the 1st entity in list; NULL failure.
|
||||
*/
|
||||
CcioEntity_t* ccioAddEntity(CcioEntity_t *chent);
|
||||
|
||||
/**
|
||||
* @brief ccioDelEntity(void *chent)
|
||||
* @details delete the entity from the list
|
||||
*
|
||||
* @param chent The entity to be deleted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ccioDelEntity(CcioEntity_t *chent);
|
||||
|
||||
/**
|
||||
* @brief ccioFindEntity(uint16_t chanId)
|
||||
* @details find the channel entity in the list by chanId or chanNo
|
||||
*
|
||||
* @param chanId The channel ID/No
|
||||
* @return NULL if not found; != NULL the found entity.
|
||||
*/
|
||||
CcioEntity_t* ccioFindEntity(uint16_t chanId);
|
||||
|
||||
/**
|
||||
* @brief ccioFindEntityByTypes(uint8_t chanType, uint8_t servType)
|
||||
* @details find the channel entity in the list by chanType & servType
|
||||
*
|
||||
* @param chanType The channel type
|
||||
* @param servType The service type
|
||||
* @return NULL if not found; != NULL the found entity.
|
||||
*/
|
||||
CcioEntity_t* ccioFindEntityByTypes(uint8_t chanType, uint8_t servType);
|
||||
|
||||
/**
|
||||
* @brief ccioCheckNoDevEntity(uint8_t *nodevNum)
|
||||
* @details check the entity which is not assigned with device in the list
|
||||
*
|
||||
* @param nodevNum output the count of entity that has no device
|
||||
* @return NULL if not found; != NULL the found entity.
|
||||
*/
|
||||
CcioEntity_t* ccioCheckNoDevEntity(uint8_t *nodevNum);
|
||||
|
||||
/**
|
||||
* @brief ccioGetEntityRbuf(uint16_t chanId)
|
||||
* @details find the channel entity in the list by an ID
|
||||
*
|
||||
* @param chanId The channel ID
|
||||
* @return NULL if not found; != NULL the found entity.
|
||||
*/
|
||||
void* ccioGetEntityRbuf(uint16_t chanId);
|
||||
|
||||
/**
|
||||
* @brief ccioTryAssignDevice(CcioEntity_t *chent)
|
||||
* @details assign an unused device to channel entity in the specific mode
|
||||
*
|
||||
* @param chent the entity to be assigned
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ccioTryAssignDevice(CcioEntity_t *chent);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: ccio_tfc.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2021/1/19 created by xuwang
|
||||
*
|
||||
* Notes: flow controlling policy for Transmitting
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef CCIO_TFC_H
|
||||
#define CCIO_TFC_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define CCIO_TFC_PID_UNDEF 0xFFFF
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef uint16_t CcioTfcPid_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CCIO_TOI_SOCK = 0,
|
||||
CCIO_TOI_HTTP,
|
||||
CCIO_TOI_SSL,
|
||||
CCIO_TOI_MQTT,
|
||||
CCIO_TOI_RSVD_1,
|
||||
CCIO_TOI_RSVD_2,
|
||||
|
||||
CCIO_TOI_MAXNUM
|
||||
}CcioTfcObjId_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t mediaType; /* CcioLanMediaType_e */
|
||||
uint8_t mediaCid; /* such as atCid/... */
|
||||
uint8_t rsvd[2];
|
||||
}CcioTfcObjKeys_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t objId; /* CcioTfcObjId_e */
|
||||
uint8_t rsvd[3];
|
||||
}CcioTfcObjAttr_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *handle;
|
||||
CcioDevice_t *chdev;
|
||||
}CcioTfcPolicyEnable_t;
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
CcioTfcPid_t ccioCreateTfcPolicy(CcioTfcObjKeys_t *keys, CcioTfcObjAttr_t *attr);
|
||||
int32_t ccioDeleteTfcPolicy(CcioTfcPid_t afcPid, CcioTfcObjAttr_t *attr);
|
||||
int32_t ccioEnableTfcPolicy(CcioTfcPid_t afcPid);
|
||||
uint8_t ccioIsTfcPolicyEnable(CcioTfcObjKeys_t *keys, CcioTfcObjAttr_t *attr);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: ecm_entity.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2022/2/22 created by xuwang
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef ECM_ENTITY_H
|
||||
#define ECM_ENTITY_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#if 0
|
||||
typedef struct
|
||||
{
|
||||
/* inherited field & MUST be placed on the top! */
|
||||
CcioEntity_t base;
|
||||
|
||||
uint8_t lanState; /* refer to 'CcioLanMediaState_e', via monitor/user */
|
||||
uint8_t pdp4Cid; /* ipv4 pdp context Id, via monitor */
|
||||
uint8_t pdp6Cid; /* ipv6 pdp context Id, via monitor */
|
||||
uint8_t rsvd;
|
||||
|
||||
void *extras; /* for user context. */
|
||||
|
||||
/* TODO: statistic, via monitor */
|
||||
}EcmEntity_t;
|
||||
|
||||
#else
|
||||
|
||||
typedef EtherEntity_t EcmEntity_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief ceioInitEntity(SerialEntity_t *serlEnt, chentStatusCallback statusCb, void *extras)
|
||||
* @details create a ecm entity
|
||||
*
|
||||
* @param rndisEnt The entity to be created
|
||||
* @param status_cb The handler of entity status
|
||||
* @param extras The user's extra info/useful context
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ceioInitEntity(EcmEntity_t *ecmEnt,
|
||||
chentStatusCallback statusCb,
|
||||
void *extras);
|
||||
|
||||
/**
|
||||
* @brief ceioDeinitEntity(EcmEntity_t *ecmEnt)
|
||||
* @details delete/reset a ecm entity
|
||||
*
|
||||
* @param rndisEnt The entity to be deleted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ceioDeinitEntity(EcmEntity_t *ecmEnt);
|
||||
|
||||
/**
|
||||
* @brief ceioSetUpChannel(EcmEntity_t *ecmEnt)
|
||||
* @details establish a ecm channel
|
||||
*
|
||||
* @param rndisEnt The entity to be established the channel
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ceioSetUpChannel(EcmEntity_t *ecmEnt);
|
||||
|
||||
/**
|
||||
* @brief ceioPullDownChannel(EcmEntity_t *ecmEnt)
|
||||
* @details destroy a ecm channel
|
||||
*
|
||||
* @param rndisEnt The entity to be destroied the channel
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ceioPullDownChannel(EcmEntity_t *ecmEnt);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: eutra_entity.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2021/1/19 created by xuwang
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef EUTRA_ENTITY_H
|
||||
#define EUTRA_ENTITY_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "lwip/netif.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* inherited field & MUST be placed on the top! */
|
||||
CcioEntity_t base;
|
||||
|
||||
uint8_t isPrimary:1;
|
||||
uint8_t rsvdBit:7;
|
||||
uint8_t rsvd[3];
|
||||
|
||||
struct netif *eutraIf; /* lwip netif, via user/monitor */
|
||||
void *extras; /* for user context. */
|
||||
}EutraEntity_t;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief cuioInitEntity(EutraEntity_t *eutraEnt, struct netif *eutraIf, chentStatusCallback statusCb, void *extras)
|
||||
* @details create a rndis entity
|
||||
*
|
||||
* @param eutraEnt The entity to be created
|
||||
* @param eutraIf The eutra(ps) netif info
|
||||
* @param status_cb The handler of entity status
|
||||
* @param extras The user's extra info/useful context
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t cuioInitEntity(EutraEntity_t *eutraEnt,
|
||||
struct netif *eutraIf,
|
||||
chentStatusCallback statusCb,
|
||||
void *extras);
|
||||
|
||||
/**
|
||||
* @brief cuioDeinitEntity(EutraEntity_t *eutraEnt)
|
||||
* @details delete/reset a rndis entity
|
||||
*
|
||||
* @param eutraEnt The entity to be deleted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t cuioDeinitEntity(EutraEntity_t *eutraEnt);
|
||||
|
||||
/**
|
||||
* @brief cuioSetUpChannel(EutraEntity_t *eutraEnt)
|
||||
* @details establish a eutra channel
|
||||
*
|
||||
* @param eutraEnt The entity to be established the channel
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t cuioSetUpChannel(EutraEntity_t *eutraEnt);
|
||||
|
||||
/**
|
||||
* @brief cuioPullDownChannel(EutraEntity_t *eutraEnt)
|
||||
* @details destroy a eutra channel
|
||||
*
|
||||
* @param eutraEnt The entity to be destroied the channel
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t cuioPullDownChannel(EutraEntity_t *eutraEnt);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef HAL_TRIM_H
|
||||
#define HAL_TRIM_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
\brief ADC EFUSE calibration code
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t code500 : 12;
|
||||
uint32_t code900 : 12;
|
||||
uint32_t reserved : 8;
|
||||
} AdcEfuseCalCode_t;
|
||||
|
||||
|
||||
/**
|
||||
\brief ADC EFUSE thermal code
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t codet0 : 12;
|
||||
uint32_t t0 : 10;
|
||||
uint32_t reserved : 10;
|
||||
} AdcEfuseT0Code_t;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
/**
|
||||
\fn trimEfuseNotAon( void )
|
||||
\brief used to read trim value from efuse, then write into none Aon reg
|
||||
\note called in bootloader when POR/SLEEP2/HIB, in ramboot when SLEEP1
|
||||
*/
|
||||
void trimEfuseNotAon( void );
|
||||
|
||||
|
||||
/**
|
||||
\fn trimEfuseAon( void )
|
||||
\brief used to read trim value from efuse, then write into Aon reg
|
||||
\note called in bootloader when POR
|
||||
*/
|
||||
void trimEfuseAon( void );
|
||||
|
||||
|
||||
/**
|
||||
\fn trimFromCalNv2Aon( void )
|
||||
\brief used to read trim value from ap nv, then write into Aon reg
|
||||
\note called in app img after ap nv init when POR
|
||||
*/
|
||||
void trimFromCalNv2Aon( void );
|
||||
|
||||
|
||||
/**
|
||||
\fn trimAdcSetGolbalVar( void )
|
||||
\brief read the adc cali value in efuse and set to a golbal var for ADC use
|
||||
\note this golbal var will be used in both paging and app img, and should be set when POR/SLEEP2/HIB case
|
||||
no need for SLEEP1.
|
||||
*/
|
||||
void trimAdcSetGolbalVar( void );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn trimAdcGetCalCode( void )
|
||||
\brief used by ADC to get the Cali code
|
||||
\return retrun the address of Cali code golbal var
|
||||
\note
|
||||
*/
|
||||
AdcEfuseCalCode_t* trimAdcGetCalCode ( void );
|
||||
|
||||
/**
|
||||
\fn trimAdcGetT0Code( void )
|
||||
\brief used by ADC to get the T0 code
|
||||
\return retrun the address of T0 code golbal var
|
||||
\note
|
||||
*/
|
||||
AdcEfuseT0Code_t* trimAdcGetT0Code( void );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,266 @@
|
||||
/* This file has been prepared for Doxygen automatic documentation generation.*/
|
||||
/*! \file ndis.h ***************************************************************
|
||||
*
|
||||
* \brief
|
||||
* This file contains the possible external configuration of the USB.
|
||||
*
|
||||
* \addtogroup usbstick
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
\ingroup usbstick
|
||||
\defgroup RNDIS RNDIS Support
|
||||
@{
|
||||
*/
|
||||
|
||||
/*
|
||||
* ndis.h
|
||||
*
|
||||
* Modified by Colin O'Flynn <coflynn@newae.com>
|
||||
* ntddndis.h modified by Benedikt Spranger <b.spranger@pengutronix.de>
|
||||
*
|
||||
* Thanks to the cygwin development team,
|
||||
* espacially to Casper S. Hornstrup <chorns@users.sourceforge.net>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NDIS_H
|
||||
#define _LINUX_NDIS_H
|
||||
|
||||
|
||||
#define NDIS_STATUS_MULTICAST_FULL 0xC0010009
|
||||
#define NDIS_STATUS_MULTICAST_EXISTS 0xC001000A
|
||||
#define NDIS_STATUS_MULTICAST_NOT_FOUND 0xC001000B
|
||||
|
||||
/* from drivers/net/sk98lin/h/skgepnmi.h */
|
||||
#define OID_PNP_CAPABILITIES 0xFD010100
|
||||
#define OID_PNP_SET_POWER 0xFD010101
|
||||
#define OID_PNP_QUERY_POWER 0xFD010102
|
||||
#define OID_PNP_ADD_WAKE_UP_PATTERN 0xFD010103
|
||||
#define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104
|
||||
#define OID_PNP_ENABLE_WAKE_UP 0xFD010106
|
||||
|
||||
enum NDIS_DEVICE_POWER_STATE {
|
||||
NdisDeviceStateUnspecified = 0,
|
||||
NdisDeviceStateD0,
|
||||
NdisDeviceStateD1,
|
||||
NdisDeviceStateD2,
|
||||
NdisDeviceStateD3,
|
||||
NdisDeviceStateMaximum
|
||||
};
|
||||
|
||||
struct NDIS_PM_WAKE_UP_CAPABILITIES {
|
||||
enum NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp;
|
||||
enum NDIS_DEVICE_POWER_STATE MinPatternWakeUp;
|
||||
enum NDIS_DEVICE_POWER_STATE MinLinkChangeWakeUp;
|
||||
};
|
||||
|
||||
/* NDIS_PNP_CAPABILITIES.Flags constants */
|
||||
#define NDIS_DEVICE_WAKE_UP_ENABLE 0x00000001
|
||||
#define NDIS_DEVICE_WAKE_ON_PATTERN_MATCH_ENABLE 0x00000002
|
||||
#define NDIS_DEVICE_WAKE_ON_MAGIC_PACKET_ENABLE 0x00000004
|
||||
|
||||
/*
|
||||
struct NDIS_PNP_CAPABILITIES {
|
||||
__le32 Flags;
|
||||
struct NDIS_PM_WAKE_UP_CAPABILITIES WakeUpCapabilities;
|
||||
};
|
||||
|
||||
struct NDIS_PM_PACKET_PATTERN {
|
||||
__le32 Priority;
|
||||
__le32 Reserved;
|
||||
__le32 MaskSize;
|
||||
__le32 PatternOffset;
|
||||
__le32 PatternSize;
|
||||
__le32 PatternFlags;
|
||||
};
|
||||
*/
|
||||
|
||||
/* Required Object IDs (OIDs) */
|
||||
#define OID_GEN_SUPPORTED_LIST 0x00010101
|
||||
#define OID_GEN_HARDWARE_STATUS 0x00010102
|
||||
#define OID_GEN_MEDIA_SUPPORTED 0x00010103
|
||||
#define OID_GEN_MEDIA_IN_USE 0x00010104
|
||||
#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105
|
||||
#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106
|
||||
#define OID_GEN_LINK_SPEED 0x00010107
|
||||
#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108
|
||||
#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109
|
||||
#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A
|
||||
#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B
|
||||
#define OID_GEN_VENDOR_ID 0x0001010C
|
||||
#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D
|
||||
#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E
|
||||
#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F
|
||||
#define OID_GEN_DRIVER_VERSION 0x00010110
|
||||
#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111
|
||||
#define OID_GEN_PROTOCOL_OPTIONS 0x00010112
|
||||
#define OID_GEN_MAC_OPTIONS 0x00010113
|
||||
#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114
|
||||
#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115
|
||||
#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116
|
||||
#define OID_GEN_SUPPORTED_GUIDS 0x00010117
|
||||
#define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118
|
||||
#define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119
|
||||
#define OID_GEN_MACHINE_NAME 0x0001021A
|
||||
#define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B
|
||||
#define OID_GEN_VLAN_ID 0x0001021C
|
||||
|
||||
/* Optional OIDs */
|
||||
#define OID_GEN_MEDIA_CAPABILITIES 0x00010201
|
||||
#define OID_GEN_PHYSICAL_MEDIUM 0x00010202
|
||||
|
||||
/* Required statistics OIDs */
|
||||
#define OID_GEN_XMIT_OK 0x00020101
|
||||
#define OID_GEN_RCV_OK 0x00020102
|
||||
#define OID_GEN_XMIT_ERROR 0x00020103
|
||||
#define OID_GEN_RCV_ERROR 0x00020104
|
||||
#define OID_GEN_RCV_NO_BUFFER 0x00020105
|
||||
|
||||
/* Optional statistics OIDs */
|
||||
#define OID_GEN_DIRECTED_BYTES_XMIT 0x00020201
|
||||
#define OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202
|
||||
#define OID_GEN_MULTICAST_BYTES_XMIT 0x00020203
|
||||
#define OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204
|
||||
#define OID_GEN_BROADCAST_BYTES_XMIT 0x00020205
|
||||
#define OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206
|
||||
#define OID_GEN_DIRECTED_BYTES_RCV 0x00020207
|
||||
#define OID_GEN_DIRECTED_FRAMES_RCV 0x00020208
|
||||
#define OID_GEN_MULTICAST_BYTES_RCV 0x00020209
|
||||
#define OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A
|
||||
#define OID_GEN_BROADCAST_BYTES_RCV 0x0002020B
|
||||
#define OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C
|
||||
#define OID_GEN_RCV_CRC_ERROR 0x0002020D
|
||||
#define OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E
|
||||
#define OID_GEN_GET_TIME_CAPS 0x0002020F
|
||||
#define OID_GEN_GET_NETCARD_TIME 0x00020210
|
||||
#define OID_GEN_NETCARD_LOAD 0x00020211
|
||||
#define OID_GEN_DEVICE_PROFILE 0x00020212
|
||||
#define OID_GEN_INIT_TIME_MS 0x00020213
|
||||
#define OID_GEN_RESET_COUNTS 0x00020214
|
||||
#define OID_GEN_MEDIA_SENSE_COUNTS 0x00020215
|
||||
#define OID_GEN_FRIENDLY_NAME 0x00020216
|
||||
#define OID_GEN_MINIPORT_INFO 0x00020217
|
||||
#define OID_GEN_RESET_VERIFY_PARAMETERS 0x00020218
|
||||
|
||||
/* IEEE 802.3 (Ethernet) OIDs */
|
||||
#define NDIS_802_3_MAC_OPTION_PRIORITY 0x00000001
|
||||
|
||||
#define OID_802_3_PERMANENT_ADDRESS 0x01010101
|
||||
#define OID_802_3_CURRENT_ADDRESS 0x01010102
|
||||
#define OID_802_3_MULTICAST_LIST 0x01010103
|
||||
#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104
|
||||
#define OID_802_3_MAC_OPTIONS 0x01010105
|
||||
#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101
|
||||
#define OID_802_3_XMIT_ONE_COLLISION 0x01020102
|
||||
#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103
|
||||
#define OID_802_3_XMIT_DEFERRED 0x01020201
|
||||
#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202
|
||||
#define OID_802_3_RCV_OVERRUN 0x01020203
|
||||
#define OID_802_3_XMIT_UNDERRUN 0x01020204
|
||||
#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205
|
||||
#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206
|
||||
#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207
|
||||
|
||||
/* Wireless LAN OIDs */
|
||||
/* Mandatory */
|
||||
#define OID_802_11_BSSID 0x0D010101 /* Q S */
|
||||
#define OID_802_11_SSID 0x0D010102 /* Q S */
|
||||
#define OID_802_11_NETWORK_TYPE_IN_USE 0x0D010204 /* Q S */
|
||||
#define OID_802_11_RSSI 0x0D010206 /* Q I */
|
||||
#define OID_802_11_BSSID_LIST 0x0D010217 /* Q */
|
||||
#define OID_802_11_BSSID_LIST_SCAN 0x0D01011A /* S */
|
||||
#define OID_802_11_INFRASTRUCTURE_MODE 0x0D010108 /* Q S */
|
||||
#define OID_802_11_SUPPORTED_RATES 0x0D01020E /* Q */
|
||||
#define OID_802_11_CONFIGURATION 0x0D010211 /* Q S */
|
||||
#define OID_802_11_ADD_WEP 0x0D010113 /* S */
|
||||
#define OID_802_11_WEP_STATUS 0x0D01011B /* Q S */
|
||||
#define OID_802_11_REMOVE_WEP 0x0D010114 /* S */
|
||||
#define OID_802_11_DISASSOCIATE 0x0D010115 /* S */
|
||||
#define OID_802_11_AUTHENTICATION_MODE 0x0D010118 /* Q S */
|
||||
#define OID_802_11_RELOAD_DEFAULTS 0x0D01011C /* S */
|
||||
|
||||
|
||||
|
||||
/* OID_GEN_MINIPORT_INFO constants */
|
||||
#define NDIS_MINIPORT_BUS_MASTER 0x00000001
|
||||
#define NDIS_MINIPORT_WDM_DRIVER 0x00000002
|
||||
#define NDIS_MINIPORT_SG_LIST 0x00000004
|
||||
#define NDIS_MINIPORT_SUPPORTS_MEDIA_QUERY 0x00000008
|
||||
#define NDIS_MINIPORT_INDICATES_PACKETS 0x00000010
|
||||
#define NDIS_MINIPORT_IGNORE_PACKET_QUEUE 0x00000020
|
||||
#define NDIS_MINIPORT_IGNORE_REQUEST_QUEUE 0x00000040
|
||||
#define NDIS_MINIPORT_IGNORE_TOKEN_RING_ERRORS 0x00000080
|
||||
#define NDIS_MINIPORT_INTERMEDIATE_DRIVER 0x00000100
|
||||
#define NDIS_MINIPORT_IS_NDIS_5 0x00000200
|
||||
#define NDIS_MINIPORT_IS_CO 0x00000400
|
||||
#define NDIS_MINIPORT_DESERIALIZE 0x00000800
|
||||
#define NDIS_MINIPORT_REQUIRES_MEDIA_POLLING 0x00001000
|
||||
#define NDIS_MINIPORT_SUPPORTS_MEDIA_SENSE 0x00002000
|
||||
#define NDIS_MINIPORT_NETBOOT_CARD 0x00004000
|
||||
#define NDIS_MINIPORT_PM_SUPPORTED 0x00008000
|
||||
#define NDIS_MINIPORT_SUPPORTS_MAC_ADDRESS_OVERWRITE 0x00010000
|
||||
#define NDIS_MINIPORT_USES_SAFE_BUFFER_APIS 0x00020000
|
||||
#define NDIS_MINIPORT_HIDDEN 0x00040000
|
||||
#define NDIS_MINIPORT_SWENUM 0x00080000
|
||||
#define NDIS_MINIPORT_SURPRISE_REMOVE_OK 0x00100000
|
||||
#define NDIS_MINIPORT_NO_HALT_ON_SUSPEND 0x00200000
|
||||
#define NDIS_MINIPORT_HARDWARE_DEVICE 0x00400000
|
||||
#define NDIS_MINIPORT_SUPPORTS_CANCEL_SEND_PACKETS 0x00800000
|
||||
#define NDIS_MINIPORT_64BITS_DMA 0x01000000
|
||||
|
||||
#define NDIS_MEDIUM_802_3 0x00000000
|
||||
#define NDIS_MEDIUM_802_5 0x00000001
|
||||
#define NDIS_MEDIUM_FDDI 0x00000002
|
||||
#define NDIS_MEDIUM_WAN 0x00000003
|
||||
#define NDIS_MEDIUM_LOCAL_TALK 0x00000004
|
||||
#define NDIS_MEDIUM_DIX 0x00000005
|
||||
#define NDIS_MEDIUM_ARCENT_RAW 0x00000006
|
||||
#define NDIS_MEDIUM_ARCENT_878_2 0x00000007
|
||||
#define NDIS_MEDIUM_ATM 0x00000008
|
||||
#define NDIS_MEDIUM_WIRELESS_LAN 0x00000009
|
||||
#define NDIS_MEDIUM_IRDA 0x0000000A
|
||||
#define NDIS_MEDIUM_BPC 0x0000000B
|
||||
#define NDIS_MEDIUM_CO_WAN 0x0000000C
|
||||
#define NDIS_MEDIUM_1394 0x0000000D
|
||||
|
||||
#define NDIS_PACKET_TYPE_DIRECTED 0x00000001
|
||||
#define NDIS_PACKET_TYPE_MULTICAST 0x00000002
|
||||
#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
|
||||
#define NDIS_PACKET_TYPE_BROADCAST 0x00000008
|
||||
#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
|
||||
#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
|
||||
#define NDIS_PACKET_TYPE_SMT 0x00000040
|
||||
#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
|
||||
#define NDIS_PACKET_TYPE_GROUP 0x00000100
|
||||
#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
|
||||
#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
|
||||
#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
|
||||
|
||||
#define NDIS_MEDIA_STATE_CONNECTED 0x00000000
|
||||
#define NDIS_MEDIA_STATE_DISCONNECTED 0x00000001
|
||||
|
||||
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001
|
||||
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002
|
||||
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND 0x00000004
|
||||
#define NDIS_MAC_OPTION_NO_LOOPBACK 0x00000008
|
||||
#define NDIS_MAC_OPTION_FULL_DUPLEX 0x00000010
|
||||
#define NDIS_MAC_OPTION_EOTX_INDICATION 0x00000020
|
||||
#define NDIS_MAC_OPTION_8021P_PRIORITY 0x00000040
|
||||
#define NDIS_MAC_OPTION_RESERVED 0x80000000
|
||||
|
||||
#endif /* _LINUX_NDIS_H */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,199 @@
|
||||
#ifndef __OSA_CFG_NVM_H__
|
||||
#define __OSA_CFG_NVM_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M Ltd.
|
||||
File name: - osacfgnvm.h
|
||||
Description: - OSA EC config NVM file operation code
|
||||
History: - 2021/04/06, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "winsys.h"
|
||||
#else
|
||||
#include "commontypedef.h"
|
||||
#endif
|
||||
|
||||
#include "osanvm.h"
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
1. "NVMCFG" use the struture:
|
||||
a> TV: LF: Length Flag: 0, T: Parameter Type, V: Value
|
||||
15 14 12 11 0
|
||||
+-----+-----+----------------+
|
||||
|LF(0)|RSVD |ParamId(12 bits)|
|
||||
+-----+-----+----------------+
|
||||
| Value (16 bits) |
|
||||
+----------------------------+
|
||||
b> TLV: LF: Length Flag: 1, T: Value type, L: Value byte length, V: Value
|
||||
15 14 12 11 0
|
||||
+-----+-----+----------------+
|
||||
|LF(1)|RSVD |ParamId(12 bits)|
|
||||
+-----+-----+----------------+
|
||||
|Value byte length (16 bits) |
|
||||
+----------------------------+
|
||||
\ Value \
|
||||
+----------------------------+
|
||||
2. The 3 "RSVD" bits must set to 0, and used for future;
|
||||
3. The "paramId" is 12 bits, with the range: [0 ~ 4095]
|
||||
a> [0 ~ 1023], reserved for PS
|
||||
b> [1024 ~ 1535], reserved for middle ware
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* 12 bits parameter ID
|
||||
*/
|
||||
#define OSA_CFG_NVM_MAX_PARAM_ID 0xFFF
|
||||
|
||||
/*
|
||||
* TV type, paramter value max size, 2 bytes
|
||||
*/
|
||||
#define OSA_CFG_TV_PARAM_VALUE_MAX_SIZE 2
|
||||
|
||||
/*
|
||||
* update config NVM, when read/update, need to reserve some more buffer
|
||||
*/
|
||||
#define OSA_CFG_UPDATE_NVM_RSVD_LEN 128
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
#define OSA_CFG_SET_DEFAULT_TV_VALUE(paramId, value) {(paramId), (value)}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT/ENUM
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
typedef enum OsaCfgType_Enum
|
||||
{
|
||||
OSA_CFG_TV_TYPE = 0,
|
||||
OSA_CFG_TLV_TYPE = 1 //OsaCfgParam->lf = 1
|
||||
}OsaCfgType;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
1. "NVMCFG" use the struture:
|
||||
a> TV: LF: Length Flag: 0, T: Parameter Type, V: Value
|
||||
15 14 12 11 0
|
||||
+-----+-----+----------------+
|
||||
|LF(0)|RSVD |ParamId(12 bits)|
|
||||
+-----+-----+----------------+
|
||||
| Value (16 bits) |
|
||||
+----------------------------+
|
||||
b> TLV: LF: Length Flag: 1, T: Value type, L: Value byte length, V: Value
|
||||
15 14 12 11 0
|
||||
+-----+-----+----------------+
|
||||
|LF(1)|RSVD |ParamId(12 bits)|
|
||||
+-----+-----+----------------+
|
||||
|Value byte length (16 bits) |
|
||||
+----------------------------+
|
||||
\ Value \
|
||||
+----------------------------+
|
||||
******************************************************************************/
|
||||
typedef struct OsaCfgParam_Tag
|
||||
{
|
||||
UINT16 paramId : 12;
|
||||
UINT16 rsvd : 3; //must set to 0
|
||||
UINT16 lf : 1; //length flag
|
||||
|
||||
union
|
||||
{
|
||||
UINT8 tvVal[2];
|
||||
UINT16 tlvLen;
|
||||
}valOrLen; /* if lf == OSA_CFG_TV_TYPE, this is the value, and must limited in 2 bytes
|
||||
* if lf == OSA_CFG_TLV_TYPE, this is the value length
|
||||
*/
|
||||
|
||||
UINT8 tlvVal[]; /* if lf == OSA_CFG_TLV_TYPE, this is the value of this parameter */
|
||||
}OsaCfgParam;
|
||||
|
||||
typedef struct OsaCfgTVTypeValue_Tag
|
||||
{
|
||||
UINT16 paramId;
|
||||
UINT16 val;
|
||||
}OsaCfgTVTypeValue;
|
||||
|
||||
|
||||
/*
|
||||
* Read/parse every parameter in the CFG NVM file
|
||||
*/
|
||||
typedef struct OsaCfgParseInfo_Tag
|
||||
{
|
||||
OsaNvmBodyInfo *pBodyInfo;
|
||||
|
||||
UINT16 parseOffset; /* parse position */
|
||||
UINT16 rsvd;
|
||||
}OsaCfgParseInfo;
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* FUNC
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
\fn OsaNvmRet OsaCfgNvmGetNextParam(OsaCfgParam **pCfgParam, OsaCfgParseInfo *pNvmParseInfo)
|
||||
\brief Get next config parameters info from NVM body info, used when parse all CFG NVM file
|
||||
\param[out] pCfgParam return cfg parameter info
|
||||
\param[in] pNvmParseInfo CFG NVM parse info
|
||||
\returns OsaNvmRet
|
||||
\ Note: a) if all parsed, return OSA_NVM_SUCC, and "*pCfgParam" set to PNULL
|
||||
\ b) if CFG NVM file error, return ERR, and caller should delete this cfg file
|
||||
*/
|
||||
OsaNvmRet OsaCfgNvmGetNextParam(OsaCfgParam **pCfgParam, OsaCfgParseInfo *pNvmParseInfo);
|
||||
|
||||
/**
|
||||
\fn void OsaCfgNvmRemoveParamFromParseInfo(OsaCfgParam *pRmCfg, OsaCfgParseInfo *pNvmParseInfo)
|
||||
\brief Remove config parameters info from NVM body info, and update the parse offset
|
||||
\param[out] pRmCfg config parameter info which need remove
|
||||
\param[in] pNvmParseInfo CFG NVM parse info
|
||||
\returns void
|
||||
*/
|
||||
void OsaCfgNvmRemoveParamFromParseInfo(OsaCfgParam *pRmCfg, OsaCfgParseInfo *pNvmParseInfo);
|
||||
|
||||
|
||||
/**
|
||||
\fn OsaCfgNvmUpdateParam(UINT16 paramId, UINT8 cfgType, UINT16 paramLen, void *pParamValue, OsaNvmBodyInfo *pNvmBufInfo)
|
||||
\brief Update one configuration into NVM body, note: not write to flash in this API
|
||||
\param[in] paramId 12 bits parameter ID
|
||||
\param[in] cfgType TV or TLV type
|
||||
\param[in] paramLen parameter length
|
||||
\param[in] pParamValue parameter value
|
||||
\param[in] pNvmBodyInfo NVM body buffer info
|
||||
\returns INT32 //OsaNvmRet
|
||||
*/
|
||||
OsaNvmRet OsaCfgNvmUpdateParam(UINT16 paramId, UINT8 cfgType, UINT16 paramLen, void *pParamValue, OsaNvmBodyInfo *pNvmBodyInfo);
|
||||
|
||||
|
||||
/**
|
||||
\fn OsaNvmRet OsaCfgNvmAddParam(UINT16 paramId, UINT8 cfgType, UINT16 paramLen, void *pParamValue, OsaNvmBodyInfo *pNvmBodyInfo)
|
||||
\brief Add one configuration into end of NVM body
|
||||
\param[in] paramId 12 bits parameter ID
|
||||
\param[in] cfgType TV or TLV type
|
||||
\param[in] paramLen parameter length
|
||||
\param[in] pParamValue parameter value
|
||||
\param[in] pNvmBodyInfo NVM body buffer info
|
||||
\returns INT32 //OsaNvmRet
|
||||
\Note: The caller must make sure no this cfg already in the NVM
|
||||
*/
|
||||
OsaNvmRet OsaCfgNvmAddParam(UINT16 paramId, UINT8 cfgType, UINT16 paramLen, void *pParamValue, OsaNvmBodyInfo *pNvmBodyInfo);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: osadlfcmem.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2021/8/15 created by xuwang
|
||||
*
|
||||
* Notes: memroy operations with an attribute of DownLink Flow Controlling policy.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef OSA_DLFC_MEM_H
|
||||
#define OSA_DLFC_MEM_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "pspdu.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define OSA_DLFC_MFI_INNER_MASK ((1 << (OSA_DLFC_MFI_INNER_END - OSA_DLFC_MFI_INNER_BEGIN + 1)) - 1)
|
||||
#define OSA_DLFC_MFI_OUTER_MASK (((1 << (OSA_DLFC_MFI_OUTER_END - OSA_DLFC_MFI_OUTER_BEGIN + 1)) - 1) << OSA_DLFC_MFI_OUTER_BEGIN)
|
||||
|
||||
|
||||
|
||||
/* dlfc malloc buffer with/without a (pbuf+)dlpdu header in blocking/non-blocking mode?
|
||||
* usage: only for application's exchange data, mostly downlink data.
|
||||
*/
|
||||
#define OsaDlfcAllocMemBlocking(wantedSize) OsaDlfcAllocMem((wantedSize), 0, 0, 1, 0)
|
||||
#define OsaDlfcAllocMemNonBlocking(wantedSize) OsaDlfcAllocMem((wantedSize), 0, 0, 0, 0)
|
||||
#define OsaDlfcAllocDlPduBlocking(wantedSize) OsaDlfcAllocMem((wantedSize), 0, 1, 1, 0)
|
||||
#define OsaDlfcAllocDlPduNonBlocking(wantedSize) OsaDlfcAllocMem((wantedSize), 0, 1, 0, 0)
|
||||
#define OsaDlfcAllocPbufDlPduBlocking(wantedSize) OsaDlfcAllocMem((wantedSize), 1, 1, 1, 0)
|
||||
#define OsaDlfcAllocPbufDlPduNonBlocking(wantedSize) OsaDlfcAllocMem((wantedSize), 1, 1, 0, 0)
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t magicNum;
|
||||
uint16_t extras;
|
||||
uint32_t memSize; /* aligned size */
|
||||
}OsaDlfcMemHdr_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* inner factors */
|
||||
OSA_DLFC_MFI_INNER_BEGIN = 0,
|
||||
OSA_DLFC_MFI_MEM_THRES = OSA_DLFC_MFI_INNER_BEGIN,
|
||||
|
||||
OSA_DLFC_MFI_INNER_END = 9,
|
||||
|
||||
/* outer factors */
|
||||
OSA_DLFC_MFI_OUTER_BEGIN = 10,
|
||||
OSA_DLFC_MFI_MSG_QUEUE = OSA_DLFC_MFI_OUTER_BEGIN,
|
||||
|
||||
OSA_DLFC_MFI_OUTER_END = 31,
|
||||
|
||||
OSA_DLFC_MFI_MAXNUM
|
||||
}OsaDlfcMemFactorId_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OSA_DLFC_MEF_LOW_WATER = 0,
|
||||
OSA_DLFC_MEF_HIGH_WATER,
|
||||
|
||||
OSA_DLFC_MEF_MAXNUM
|
||||
}OsaDlfcMemEvtFlags_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t memUsed;
|
||||
uint32_t extras;
|
||||
}OsaDlfcMemEvtArgs_t;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint32_t OsaDlfcGetMemUsedThresAlertPct(void);
|
||||
void OsaDlfcSetMemUsedThresAlertPct(uint8_t alertPct);
|
||||
|
||||
uint32_t OsaDlfcGetMemUsedSizeThres(void);
|
||||
void OsaDlfcSetMemUsedSizeThres(uint32_t usedSize);
|
||||
|
||||
void OsaDlfcSetMemOuterFactor(OsaDlfcMemFactorId_e fid);
|
||||
void OsaDlfcClrMemOuterFactor(OsaDlfcMemFactorId_e fid);
|
||||
|
||||
uint32_t OsaDlfcQueryMemAvlbSize(void);
|
||||
|
||||
void* OsaDlfcAllocMem(uint32_t wantedSize, uint8_t hasPbuf, uint8_t hasDldpu, uint8_t isBlocking, uint16_t extras);
|
||||
void OsaDlfcFreeMem(void *ptr);
|
||||
void OsaDlfcReallocMem(void *ptr, uint32_t wantedSize);
|
||||
|
||||
void OsaDlfcNotifyMemEvent(OsaDlfcMemEvtFlags_e flags, OsaDlfcMemEvtArgs_t *args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
#ifndef __OSA_NVM_H__
|
||||
#define __OSA_NVM_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M Ltd.
|
||||
File name: - osanvm.h
|
||||
Description: - OSA EC NVM operation code
|
||||
History: - 2021/04/06, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "winsys.h"
|
||||
#else
|
||||
#include "commontypedef.h"
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO/ENUM
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* NVM file now should limited in 4KB
|
||||
*/
|
||||
#define OSA_NVM_FILE_BODY_MAX_SIZE 4096
|
||||
|
||||
/*
|
||||
*/
|
||||
typedef enum OsaNvmRet_enum
|
||||
{
|
||||
OSA_NVM_SUCC = 0,
|
||||
OSA_NVM_ERR = -1,
|
||||
OSA_NVM_NO_FILE_ERR = -2, /* if read only, no file exist */
|
||||
OSA_NVM_NO_MEM_ERR = -3,
|
||||
OSA_NVM_CKS_ERR = -4, /* checksum err */
|
||||
OSA_NVM_FILE_ERR = -5, /* file format/context not right */
|
||||
OSA_NVM_INPUT_ERR = -6,
|
||||
}OsaNvmRetE;
|
||||
|
||||
typedef INT32 OsaNvmRet;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* EC NVM file header struct
|
||||
*/
|
||||
#define OSA_NVM_FILE_NAME_SIZE 32
|
||||
typedef struct OsaNvmHeader_Tag
|
||||
{
|
||||
UINT8 fName[OSA_NVM_FILE_NAME_SIZE];
|
||||
|
||||
UINT16 fileBodySize; //file body size, not include size of header
|
||||
UINT16 checkSum;
|
||||
|
||||
UINT8 version;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
}OsaNvmHeader; //40 bytes
|
||||
|
||||
|
||||
/*
|
||||
* OSA NVM file body info
|
||||
*/
|
||||
typedef struct OsaNvmBodyInfo_Tag
|
||||
{
|
||||
UINT8 *pBuf; //allocated in heap: OsaAllocMemory()/OsaFreeMemory()
|
||||
|
||||
/*
|
||||
* As the caller maybe need to write new parameter into NVM, here reserve more memory
|
||||
* 1> "bodySize": real NVM body data size
|
||||
* 2> "bufSize": allcated buffer size
|
||||
* 3> "bufSize" >= "bodySize", and reserved size: "bufSize" - "bodySize"
|
||||
*/
|
||||
UINT16 bodySize;
|
||||
UINT16 bufSize;
|
||||
}OsaNvmBodyInfo; // 8 bytes
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* FUNC
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Read whole NVM file, the file size should limited in 4KB
|
||||
* Note: if file not exist, return: OSA_NVM_NO_FILE_ERR, and not allocate buffer for NVM body
|
||||
*/
|
||||
OsaNvmRet OsaNvmRead(const CHAR *pName, UINT8 *pVer, OsaNvmBodyInfo *pBodyInfo, UINT16 rsvdLen);
|
||||
|
||||
/*
|
||||
* Write whole NVM file
|
||||
*/
|
||||
OsaNvmRet OsaNvmWrite(const CHAR *pName, UINT8 ver, void *pData, UINT32 size);
|
||||
|
||||
/*
|
||||
* remove file
|
||||
*/
|
||||
OsaNvmRet OsaNvmRemove(const CHAR *pName);
|
||||
|
||||
/*
|
||||
* After the NVM body used/parsed, need to free the memory
|
||||
*/
|
||||
void OsaNvmFreeBody(OsaNvmBodyInfo *pNvmBodyInfo);
|
||||
|
||||
/*
|
||||
* Allocate buffer to store NVM file body
|
||||
*/
|
||||
void OsaNvmAllocBody(OsaNvmBodyInfo *pNvmBodyInfo, UINT16 bufSize);
|
||||
|
||||
/*
|
||||
* realloc/enlarge buffer to store NVM file body
|
||||
*/
|
||||
void OsaNvmReAllocBody(OsaNvmBodyInfo *pNvmBodyInfo, UINT16 newBufSize);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
#ifndef __PS_OSA_SIG_H__
|
||||
#define __PS_OSA_SIG_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M
|
||||
File name: - osasig.h
|
||||
Description: - OSA signal operation
|
||||
History:
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#include "commontypedef.h"
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* offset of body in a structure
|
||||
*/
|
||||
#ifndef OFFSETOF
|
||||
#define OFFSETOF(type, body) ((UINT32)&(((type *)0)->body))
|
||||
#endif
|
||||
|
||||
#define OSA_BIG_FAST_SIG_BODY_MAX_SIZE 128
|
||||
|
||||
|
||||
/*
|
||||
* OSA related common signal ID
|
||||
*/
|
||||
typedef enum _SIG_EPAT_OSASIGIDTAG
|
||||
{
|
||||
SIG_TIMER_EXPIRY = 0x0100, //OsaTimerExpiry
|
||||
SIG_HIB_TIMER_EXPIRY, //OsaHibTimerExpiry
|
||||
SIG_OSA_FAST_IPC, //OsaFastIpcSig
|
||||
SIG_CP_PAGING_IMG_EVENT_IND, //CpPagingImgEventInd
|
||||
|
||||
SIG_OSA_SIG_END = 0x0110,
|
||||
|
||||
SIG_C2A_FREE_AP_MEMORY_REQ = 0x3102, /* Same ID: C2A_FREE_AP_MEMORY_REQ, add here, only used for EPAT logging */
|
||||
|
||||
}OSASIGID;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* SIGID: SIG_TIMER_EXPIRY
|
||||
*/
|
||||
typedef struct OsaTimerExpiry_Tag
|
||||
{
|
||||
UINT16 timerEnum;
|
||||
UINT16 destTaskId;
|
||||
}OsaTimerExpiry;
|
||||
|
||||
/*
|
||||
* SIGID: SIG_OSA_FAST_IPC
|
||||
* 1> Fast IPC message (> 128)
|
||||
* Signal A2C fast IPC CP ISR signal: SIG_OSA_FAST_IPC, to PHY task
|
||||
* 31 0 31 0
|
||||
* 31 0 +--------+--------+ +--------+--------+
|
||||
* +--------+--------+ -------------<-+-+ | ipcId |F|ipclen| | ipcId | ipclen |
|
||||
* | sigId | bodyLen| (bodyLen > 128)| | +--------+--------+ +--------+--------+
|
||||
* +--------+--------+ | +--> | Signal_Addr | = +-- | Signal_Addr |
|
||||
* / / | +--------+--------+ | +--------+--------+
|
||||
* / sig body / +--------<-----------------------<-+
|
||||
* / /
|
||||
* +--------+--------+
|
||||
* a) ipcId = sigId; F_flag = 1; ipcLen = sigBodyLen + 4 (Signal header length)
|
||||
* 'Signal_Addr' set the signal address, NOT SIGNAL BODY address
|
||||
* b) Signal should allocated by: ACAlloApMemory();
|
||||
* c) When CP process done, should send the "C2A_FREE_AP_MEMORY_REQ" IPC to let AP free the memory
|
||||
*/
|
||||
typedef struct OsaFastIpcSig_Tag
|
||||
{
|
||||
UINT16 ipcMsgId; //For easy IPC MSG ID, just the same as signalID
|
||||
UINT16 msgBodyLen; //siganl read len, including 4 bytes signal header (sigBodyLen + 4)
|
||||
|
||||
UINT8 *pIpcMsg; //point to "SignalBuf", this msg buffer in fact allocated in another core, should call to free it.
|
||||
}OsaFastIpcSig;
|
||||
|
||||
/*
|
||||
* SIGID: SIG_HIB_TIMER_EXPIRY
|
||||
*/
|
||||
typedef struct OsaHibTimerExpiry_Tag
|
||||
{
|
||||
UINT8 hibTimerId;
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
}OsaHibTimerExpiry;
|
||||
|
||||
|
||||
/*
|
||||
* The result of handling CP Paging image evert, i.e. whether wake up AP/CP full image
|
||||
*/
|
||||
typedef enum _EPAT_CpPagingImgEventRet_enum
|
||||
{
|
||||
BOOT_RET_NO_WAKEUP = 0, /* Stay in HIB/SLEEP2 state not wakeup */
|
||||
BOOT_RET_AP_CP_WAKEUP = 1, /* wakeup CP for sure, send CephyCpWakeupInd */
|
||||
BOOT_RET_AP_WAKEUP = 2, /* wakeup CP or not is undetermined */
|
||||
}CpPagingImgEventRet;
|
||||
|
||||
|
||||
/*
|
||||
* CP/PHY paging image event ID
|
||||
*/
|
||||
typedef enum _EPAT_CpPagingImgEventId_enum
|
||||
{
|
||||
CP_PAGING_IMG_NO_EVENT = 0,
|
||||
CP_UE_PAGING_EVENT = 1, /* recv UE paging */
|
||||
CP_MEAS_EVENT = 2, /* recv Cell measurement */
|
||||
CP_RE_SELECT_EVENT = 3 /* recv measurement, need wakeup PS, and send CephyStartRelectionInd to RRC */
|
||||
|
||||
}CpPagingImgEventId;
|
||||
|
||||
/*
|
||||
* SIG_CP_PAGING_IMG_EVENT_IND
|
||||
* Signal send to ERRC, to proc CP/PHY paging/measurment event
|
||||
*/
|
||||
typedef struct CpPagingImgEventInd_Tag
|
||||
{
|
||||
UINT8 eventId; //CpPagingImgEventId
|
||||
BOOL bWakeupCp; //TRUE if cerrc boot API returns BOOT_RET_AP_CP_WAKEUP, need send CephyCpWakeupInd to PHY
|
||||
UINT16 eventSize; //event body/buffer size
|
||||
|
||||
/*
|
||||
* ID event size
|
||||
* CP_UE_PAGING_EVENT CephyPagingInd PHY_MSMB_PAGING_SHARE_MEM_SIZE (>= sizeof(CephyPagingInd))
|
||||
* CP_MEAS_EVENT CephyCellMeasInd PHY_MSMB_MEASUREMENT_SHARE_MEM_SIZE (>= sizeof(CephyCellMeasInd))
|
||||
* CP_RE_SELECT_EVENT CephyStartRelectionInd 0 !!! here, size is 0 !!!
|
||||
*/
|
||||
void *pEvent; /* event body/buffer, !!! not need to free, as using AP/CP share global memory !!! */
|
||||
}CpPagingImgEventInd; // 8 bytes
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* OS signal struct definition
|
||||
*****************************************************************************/
|
||||
typedef struct SignalBuf_Tag
|
||||
{
|
||||
UINT16 sigId;
|
||||
UINT16 sigBodyLen;
|
||||
UINT8 sigBody[];
|
||||
}SignalBuf;
|
||||
|
||||
#define OSA_GET_SIGNAL_FROM_BODY(pSigBody) (SignalBuf *)(((UINT8 *)(pSigBody)) - OFFSETOF(SignalBuf, sigBody))
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* EMPTY SIGNAL
|
||||
******************************************************************************/
|
||||
typedef UINT32 OsaEmptySignal;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* external SYS/OSA API
|
||||
******************************************************************************
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* OSA Signal functions
|
||||
*/
|
||||
void OsaCreateSignal(UINT16 sigId, UINT16 sigBodySize, SignalBuf **signal);
|
||||
void OsaCreateZeroSignal(UINT16 sigId, UINT16 sigBodySize, SignalBuf **signal);
|
||||
void OsaCreateFastSignal(UINT16 sigId, UINT16 sigBodySize, SignalBuf **signal);
|
||||
void OsaCreateZeroFastSignal(UINT16 sigId, UINT16 sigBodySize, SignalBuf **signal);
|
||||
//void OsaSendSignal(UINT16 taskId, SignalBuf **signal);
|
||||
void OsaSendSignalToFront(UINT16 taskId, SignalBuf **signal);
|
||||
void OsaDestroySignal(SignalBuf **signal);
|
||||
void OsaDestroyFastSignal(SignalBuf **signal);
|
||||
void OsaReceiveSignal(UINT16 taskId, SignalBuf **signal); // if no signal received, just blocked
|
||||
|
||||
void OsaSendNoLogSignal(UINT16 taskId, SignalBuf **signal); /*no signal record*/
|
||||
void OsaSendDumpSignal(UINT16 taskId, SignalBuf **signal); /*dump signal entity*/
|
||||
void OsaSendNoDumpSignal(UINT16 taskId, SignalBuf **signal); /*not dump the signal, only record the signalId/destTaskId*/
|
||||
|
||||
void OsaSendCustNoLogSignal(osMessageQueueId_t mq_id, SignalBuf **signal);
|
||||
void OsaReceiveCustSignal(osMessageQueueId_t mq_id, SignalBuf **signal, UINT32 timeOut);
|
||||
|
||||
|
||||
#define OsaCreateIsrSignal OsaCreateFastSignal
|
||||
#define OsaCreateZeroIsrSignal OsaCreateZeroFastSignal
|
||||
#define OsaDestroyIsrSignal OsaDestroyFastSignal
|
||||
|
||||
/*
|
||||
* void OsaSendSignal(UINT16 taskId, SignalBuf **signal);
|
||||
*/
|
||||
#define OsaSendSignal OsaSendDumpSignal
|
||||
|
||||
|
||||
/**
|
||||
* Get signal number in current task queue
|
||||
*/
|
||||
UINT32 OsaGetSignalCount(UINT16 taskId);
|
||||
|
||||
/**
|
||||
* Get signal space of current task queue, how many signals could be input.
|
||||
*/
|
||||
UINT32 OsaGetSignalSpace(UINT16 taskId);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,469 @@
|
||||
#ifndef __PS_OSA_SYS_H__
|
||||
#define __PS_OSA_SYS_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M
|
||||
File name: - osasys.h
|
||||
Description: - OSA system common include header files, and common MARCO
|
||||
History:
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#include "cmsis_os2.h"
|
||||
#include "osasig.h"
|
||||
#include "osautil.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "debug_trace.h"
|
||||
#include "cmsis_compiler.h"
|
||||
#include "time.h"
|
||||
#include "Driver_Common.h"
|
||||
#include "os_common.h"
|
||||
#include DEBUG_LOG_HEADER_FILE
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#define SECONDS_TO_TICKS(S) (UINT32)((S)*configTICK_RATE_HZ)
|
||||
#define MINUTES_TO_TICKS(M) (SECONDS_TO_TICKS((M)*60))
|
||||
|
||||
//
|
||||
#define MILLISECONDS_TO_TICKS(MS) (SECONDS_TO_TICKS((MS))/1000)
|
||||
|
||||
#define SECONDS_TO_MILLISECONDS(S) (UINT32)((S) * 1000)
|
||||
#define MINUTES_TO_MILLISECONDS(M) (SECONDS_TO_MILLISECONDS((M)*60))
|
||||
|
||||
#define TICKS_TO_SECONDS(T) (UINT32)((T)/configTICK_RATE_HZ)
|
||||
|
||||
#define TICKS_TO_MILLISECONDS(T) (UINT32)(((UINT64)(T)*1000)/configTICK_RATE_HZ)
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* UnitQueue
|
||||
* Use to buffer a fixed size message/signal/entity, FIFO
|
||||
* 8 bytes
|
||||
******************************************************************************/
|
||||
typedef struct UnitQueue_Tag
|
||||
{
|
||||
UINT8 totalNum; /*total number of entity, which memory allocated in *queue*/
|
||||
UINT8 validNum; /*how many entity already stored in this queue*/
|
||||
UINT8 header; /*queue header (first entity index), so the input tail index: (header+validNum)%totalNum */
|
||||
UINT8 entitySize; /*each element size*/
|
||||
UINT8 *buf;
|
||||
}UnitQueue;
|
||||
#define UNIT_QUE_STEP 4 /*allo 4/8/12/16 entity memory*/
|
||||
#define UNIT_QUE_MAX_SIZE 32
|
||||
|
||||
/******************************************************************************
|
||||
* SignalQueue
|
||||
* OS task internal FIFO queue, which used to buffer signal internally
|
||||
*****************************************************************************/
|
||||
typedef UnitQueue SignalQueue;
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* TIMER/SYS time ticks info, which need to still runing in HIBERNATE STATE
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
/*
|
||||
* HIB time enum ID
|
||||
*/
|
||||
typedef enum _EPAT_OsaHibTimerId_enum
|
||||
{
|
||||
OSA_HIB_INVALID_TIMER = 0,
|
||||
PS_HIB_PLMN_PERIOD_OR_OOS_TIMER = 1,
|
||||
PS_HIB_EMM_T3245_TIMER,
|
||||
PS_HIB_EMM_T3247_TIMER,
|
||||
PS_HIB_EMM_T3324_TIMER,
|
||||
PS_HIB_EMM_T3325_TIMER,
|
||||
PS_HIB_EMM_T3346_TIMER,
|
||||
PS_HIB_EMM_T3402_TIMER,
|
||||
PS_HIB_EMM_T3411_TIMER,
|
||||
PS_HIB_EMM_T3412_TIMER,
|
||||
PS_HIB_EMM_T3448_TIMER = 10,
|
||||
PS_HIB_EMM_FORBIDDEN_TA_TIMER_ID,
|
||||
PS_HIB_EMM_BLOCK_PLMN_TIMER_ID,
|
||||
//PS_HIB_ESM_T3396_TIMER,
|
||||
PS_HIB_POWER_ON_DELAY_TIMER,
|
||||
PS_HIB_EMM_EMERGENCY_CAMP_TIMER_ID,
|
||||
|
||||
PS_HIB_ERRC_T320_TIMER = 30,
|
||||
PS_HIB_ERRC_T325_TIMER,
|
||||
PS_HIB_ERRC_T330_TIMER,
|
||||
PS_HIB_ERRC_BCCH_MOD_TIMER,
|
||||
PS_HIB_ERRC_LOG_INTERVAL_TIMER,
|
||||
|
||||
PS_HIB_MAX_TIMER = 0x40, /* 64 HIB timer resversed for PS */
|
||||
|
||||
CMS_HIB_POWER_ON_DELAY_TIMER = 0x41, /* Now, power on random delay handled in CMS task */
|
||||
|
||||
|
||||
OSA_HIB_MAX_TIMER = 0xFF
|
||||
}OsaHibTimerId;
|
||||
|
||||
/*
|
||||
* RTC ticks, which should be also need to recorded during Hibernate state
|
||||
*/
|
||||
typedef UINT32 OsaHibMs;
|
||||
typedef UINT32 OsaHibSecond;
|
||||
|
||||
#define EC_TIME_RANG_MAX (10) /* 10s */
|
||||
#define EC_TIME_FLASH_VERSION ((0x11) & 0xFFFFU)
|
||||
|
||||
|
||||
typedef __PACKED_STRUCT _timer_value
|
||||
{
|
||||
/* UTCtimer1 ---UINT16 year--UINT8 mon--UINT8 day */
|
||||
/* UTCtimer2 ---UINT8 hour--UINT8 mins--UINT8 sec--INT8 tz */
|
||||
//unsigned int UTCtimer1;
|
||||
//unsigned int UTCtimer2;
|
||||
unsigned int UTCsecs; /*secs since 1970*/
|
||||
unsigned int UTCms; /*current ms */
|
||||
unsigned int CTtimer;
|
||||
unsigned int Swtimer;
|
||||
unsigned int timeZone;
|
||||
} timer_value_t;
|
||||
|
||||
typedef __PACKED_STRUCT _utc_timer_value
|
||||
{
|
||||
/* UTCtimer1 ---UINT16 year--UINT8 mon--UINT8 day */
|
||||
/* UTCtimer2 ---UINT8 hour--UINT8 mins--UINT8 sec--INT8 tz */
|
||||
unsigned int UTCtimer1;
|
||||
unsigned int UTCtimer2;
|
||||
unsigned int UTCsecs; /*secs since 1970*/
|
||||
unsigned int UTCms; /*current ms */
|
||||
int timeZone;
|
||||
} utc_timer_value_t;
|
||||
|
||||
typedef enum {
|
||||
SYNC_NITZ_LOCAL_TIME,
|
||||
SET_LOCAL_TIME = 1,
|
||||
}AtTimeOptVal;
|
||||
|
||||
typedef enum {
|
||||
NITZ_TIME_SRC,
|
||||
SNTP_TIME_SRC = 1,
|
||||
APP_TIME_SRC = 2,
|
||||
OTHER_TIME_SRC,
|
||||
}AtTimeSrcVal;
|
||||
|
||||
typedef enum {
|
||||
AT_FLASH_TIME = 1,
|
||||
AT_FLASH_MAX,
|
||||
}AtGetFlashVal;
|
||||
|
||||
/******************************************************************************
|
||||
* OsaHibTimerStart
|
||||
* Description: Start HIB timer
|
||||
* input: OsaHibTimerExpiryFunc callback; //time expiry callback
|
||||
* OsaHibTimerId timerId; //which HIB timer
|
||||
* OsaHibMs nMs; //timer period
|
||||
* output: void
|
||||
* Comment:
|
||||
* if "timerId" already start before, just print a warning, and restart it
|
||||
******************************************************************************/
|
||||
void OsaHibTimerStart(OsaHibTimerId timerId, OsaHibMs nMs);
|
||||
|
||||
/******************************************************************************
|
||||
* OsaHibTimerIsRunning
|
||||
* Description: whether the HIB timer is running
|
||||
* input: OsaHibTimerId timerId
|
||||
* output: BOOL
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
BOOL OsaHibTimerIsRunning(OsaHibTimerId timerId);
|
||||
|
||||
/******************************************************************************
|
||||
* OsaHibTimerStopAndDel
|
||||
* Description: delete HIB timer
|
||||
* input: OsaHibTimerId timerId
|
||||
* output: void
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void OsaHibTimerStopAndDel(OsaHibTimerId timerId);
|
||||
|
||||
/******************************************************************************
|
||||
* OsaHibTimerGetRemainMs
|
||||
* Description: Get HIB timer remaining time value in milli-seconds
|
||||
* input: OsaHibTimerId hibTId
|
||||
* output: UINT32
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
UINT32 OsaHibTimerGetRemainMs(OsaHibTimerId hibTId);
|
||||
/*
|
||||
* OSA Task Flags functionc
|
||||
*/
|
||||
UINT32 OsaTaskFlagsSet(UINT16 taskId, UINT32 flags);
|
||||
UINT32 OsaTaskFlagsWait(UINT32 waitFlags);
|
||||
UINT32 OsaTaskFlagsClear(UINT32 clearFlags);
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
externl functions
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
#define PSOSA 0x01 //useless, add it just to remove compilation warning
|
||||
|
||||
#define OsaPrintf(level, fmt, ...)
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GosCheck/GosDebugBegin/GosDebugEnd
|
||||
******************************************************************************/
|
||||
extern void GosLogDebugAssertInfo(UINT8 *pCond, UINT8 *pFile, UINT16 line, UINT32 var1, UINT32 var2, UINT32 var3);
|
||||
extern void GosLogAssertInfo(UINT8 *pCond, UINT8 *pFile, UINT16 line, UINT32 var1, UINT32 var2, UINT32 var3);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* OSA signal timer function
|
||||
* When timer expiry, timer task will create a signal (TIMER_EXPIRY) to SRC task
|
||||
******************************************************************************/
|
||||
typedef osTimerId_t OsaTimerId;
|
||||
|
||||
#define OSA_TIMER_NOT_CREATE 0
|
||||
|
||||
void OsaTimerExpiryFunc(void *argument);
|
||||
|
||||
//GosTimerId GosTimerNew(UINT16 taskId, UINT16 timerEnum, osTimerType_t type);
|
||||
//osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr)
|
||||
#define OsaTimerNew(taskId, timerEnum, type) \
|
||||
osTimerNew(OsaTimerExpiryFunc, type, (void *)(((taskId)<<16)|((timerEnum)&0xffff)), PNULL)
|
||||
|
||||
#define OsaTimerStart(TID, TICKS) osTimerStart((TID), (TICKS))
|
||||
#define OsaTimerStop(TID) osTimerStop((TID))
|
||||
#define OsaTimerIsRunning(TID) osTimerIsRunning((TID))
|
||||
//osStatus_t GosTimerDelete(GosTimerId *timer_id);
|
||||
#define OsaTimerDelete(pTID) \
|
||||
do { \
|
||||
OsaCheck((pTID) != PNULL && *(pTID) != OSA_TIMER_NOT_CREATE, (pTID), 0, 0); \
|
||||
osTimerDelete(*(pTID)); \
|
||||
*(pTID) = OSA_TIMER_NOT_CREATE; \
|
||||
}while(FALSE)
|
||||
|
||||
/* Get how many ticks remained */
|
||||
UINT32 OsaTimerGetRemainTicks(OsaTimerId timerId);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* UNIT QUEUE function
|
||||
******************************************************************************/
|
||||
void UnitQueueInit(UnitQueue *queue, UINT8 entitySize);
|
||||
void UnitEnQueue(UnitQueue *queue, void *entity);
|
||||
void UnitDeQueue(UnitQueue *queue, void *entity);
|
||||
BOOL UnitOnQueue(UnitQueue *queue);
|
||||
void UnitFlushQueue(UnitQueue *queue);
|
||||
|
||||
/******************************************************************************
|
||||
* NV FILE function
|
||||
******************************************************************************/
|
||||
#define SEEK_SET 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
|
||||
#define RET_FILE_OK 0
|
||||
#define RET_FILE_ERR 1
|
||||
|
||||
typedef UINT32 NVFILE_HANDLER;
|
||||
|
||||
NVFILE_HANDLER NVFopen(UINT32 fileId, UINT8 *mode);
|
||||
UINT32 NVFclose(NVFILE_HANDLER fd);
|
||||
UINT32 NVFread(void* buf, UINT32 size, UINT32 count, NVFILE_HANDLER fd);
|
||||
UINT32 NVFwrite(void* buf, UINT32 size, UINT32 count, NVFILE_HANDLER fd);
|
||||
UINT32 NVFtell(NVFILE_HANDLER fd);
|
||||
UINT32 NVFseek(NVFILE_HANDLER fd, UINT32 offset, UINT8 seekType);
|
||||
UINT32 NVFremove(NVFILE_HANDLER fd); //fake
|
||||
|
||||
/**
|
||||
\fn UINT8 OsaCalcCrcValue(const UINT8 *dataBuf, UINT16 bufSize)
|
||||
\brief Calculate the "CRC" value of data buffer
|
||||
\param[in] dataBuf data buffer pointer
|
||||
\param[in] bufSize data buffer size
|
||||
\returns crcValue
|
||||
\code
|
||||
The implementation of this function is listed below:
|
||||
UINT8 OsaCalcCrcValue(const UINT8 *dataBuf, UINT16 bufSize)
|
||||
{
|
||||
UINT32 i;
|
||||
UINT32 a = 1, b = 0;
|
||||
|
||||
OsaCheck(dataBuf != PNULL && bufSize > 0, dataBuf, bufSize, 0);
|
||||
|
||||
for (i = bufSize; i > 0; )
|
||||
{
|
||||
a += (UINT32)(dataBuf[--i]);
|
||||
b += a;
|
||||
}
|
||||
|
||||
return (UINT8)(((a>>24)&0xFF)^((a>>16)&0xFF)^((a>>8)&0xFF)^((a)&0xFF)^
|
||||
((b>>24)&0xFF)^((b>>16)&0xFF)^((b>>8)&0xFF)^((b)&0xFF)^
|
||||
(bufSize&0xFF));
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
UINT8 OsaCalcCrcValue(const UINT8 *dataBuf, UINT16 bufSize);
|
||||
|
||||
/******************************************************************************
|
||||
* OSA FILE function (little filesystem)
|
||||
******************************************************************************/
|
||||
typedef void* OSAFILE;
|
||||
|
||||
/**
|
||||
\fn OSAFILE OsaFopen(UINT8 *fileName, UINT8* mode)
|
||||
\brief OSA open one file
|
||||
\param[in] fileName file name
|
||||
\param[in] mode file open mode (read/write/etc)
|
||||
currently supported modes are:
|
||||
"r" or "rb" : read only
|
||||
"w" : write only
|
||||
"r+" or "rb+" : read & write
|
||||
"wb" : write & create
|
||||
"wb+" : read & write & create
|
||||
\returns OSAFILE
|
||||
*/
|
||||
OSAFILE OsaFopen(const char *fileName, const char* mode);
|
||||
|
||||
/**
|
||||
\fn INT32 OsaFtell(OSAFILE fp)
|
||||
\brief Return the position of the file
|
||||
\param[in] fp file description
|
||||
\returns INT32 On success, return the "fp" current offset; On failure, -1 is returned.
|
||||
*/
|
||||
INT32 OsaFtell(OSAFILE fp);
|
||||
|
||||
|
||||
/**
|
||||
\fn INT32 OsaFclose(OSAFILE fp)
|
||||
\brief OSA close one file, and free the file description
|
||||
\param[in] OSAFILE fp
|
||||
\returns int
|
||||
*/
|
||||
INT32 OsaFclose(OSAFILE fp);
|
||||
|
||||
/**
|
||||
\fn UINT32 OsaFread(void *buf, UINT32 size, UINT32 count, OSAFILE fp)
|
||||
\brief read file content into buffer
|
||||
\param[out] *buf output buffer
|
||||
\param[in] size one context/entity size
|
||||
\param[in] count how many context/entity need to read
|
||||
\param[in] fp file description
|
||||
\returns UINT32 the total number of context/entity successfully read
|
||||
*/
|
||||
UINT32 OsaFread(void *buf, UINT32 size, UINT32 count, OSAFILE fp);
|
||||
|
||||
/**
|
||||
\fn UINT32 OsaFwrite(void *buf, UINT32 size, UINT32 count, GOSFILE fp)
|
||||
\brief write buffer content into file
|
||||
\param[out] *buf output buffer
|
||||
\param[in] size one context/entity size
|
||||
\param[in] count how many context/entity need to write
|
||||
\param[in] fp file description
|
||||
\returns UINT32 the total number of context/entity successfully written
|
||||
*/
|
||||
UINT32 OsaFwrite(void *buf, UINT32 size, UINT32 count, OSAFILE fp);
|
||||
|
||||
/**
|
||||
\fn INT32 OsaFseek(OSAFILE fp, INT32 offset, UINT8 seekType)
|
||||
\brief Change the position of the file
|
||||
\param[in] fp file description
|
||||
\param[in] offset offset to set
|
||||
\param[in] seekType valid values:
|
||||
- SEEK_SET : beginning of file
|
||||
- SEEK_CUR : current position of the file pointer
|
||||
- SEEK_END : end of file
|
||||
\returns INT32 If successful, returns 0, otherwise -1 is returned.
|
||||
*/
|
||||
INT32 OsaFseek(OSAFILE fp, INT32 offset, UINT8 seekType);
|
||||
|
||||
/**
|
||||
\fn INT32 OsaFsize(OSAFILE fp)
|
||||
\brief Return the size of the file
|
||||
\param[in] fp file description
|
||||
\returns INT32 On success, return the size of file in unit of bytes; On failure, -1 is returned.
|
||||
*/
|
||||
INT32 OsaFsize(OSAFILE fp);
|
||||
|
||||
/**
|
||||
\fn UINT32 OsaFremove(const char *fileName)
|
||||
\brief Deletes the file specified by fileName
|
||||
\param[in] fileName file name
|
||||
\returns 0
|
||||
*/
|
||||
UINT32 OsaFremove(const char *fileName);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* OSA Signal QUEUE function
|
||||
******************************************************************************/
|
||||
#define OsaSigQueueInit(Q) UnitQueueInit((Q), sizeof(void *))
|
||||
//void OsaSigEnQueue(SignalQueue *que, SignalBuf **signal);
|
||||
#define OsaSigEnQueue(Q, S) \
|
||||
do { \
|
||||
OsaCheck((S) != PNULL && *(S) != PNULL, (S), 0, 0); \
|
||||
UnitEnQueue((Q), (S)); \
|
||||
*(S) = PNULL; \
|
||||
}while(FALSE)
|
||||
|
||||
//void OsaSigDeQueue(SignalQueue *que, SignalBuf **signal);
|
||||
#define OsaSigDeQueue(Q, S) \
|
||||
do { \
|
||||
OsaCheck((S) != PNULL && *(S) == PNULL, (S), 0, 0); \
|
||||
UnitDeQueue((Q), (S)); \
|
||||
OsaCheck((S) != PNULL && *(S) != PNULL, (S), 0, 0); \
|
||||
}while(FALSE)
|
||||
|
||||
//BOOL OsaSigOnQueue(SignalQueue *que);
|
||||
#define OsaSigOnQueue(Q) UnitOnQueue((Q))
|
||||
|
||||
//void OsaSigFlushQueue(SignalQueue *que);
|
||||
#define OsaSigFlushQueue (Q) \
|
||||
do { \
|
||||
SignalBuf *sig = PNULL; \
|
||||
while (UnitOnQueue((Q))) \
|
||||
{ \
|
||||
UnitDeQueue((Q), &sig); \
|
||||
OsaCheck(sig != PNULL, 0, 0, 0); \
|
||||
OsaDestroySignal(&sig); \
|
||||
OsaCheck(sig == PNULL, sig, 0, 0); \
|
||||
} \
|
||||
UnitFlushQueue((Q)); \
|
||||
}while(FALSE)
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
typedef unsigned int time_t;
|
||||
#endif
|
||||
|
||||
|
||||
CHAR *strdup(const CHAR *string);
|
||||
BOOL OsaGetImeiNumSync(CHAR* imei);
|
||||
INT32 OsaTimerSync(UINT32 srcType, UINT32 cmd, UINT32 Timer1, UINT32 Timer2, UINT32 Timer3);
|
||||
time_t OsaSystemTimeReadSecs(void);
|
||||
utc_timer_value_t *OsaSystemTimeReadUtc(void);
|
||||
utc_timer_value_t *OsaSystemTimeReadRamUtc(void);
|
||||
|
||||
/*
|
||||
* From LSB(right/low) to MSB (left/high), to find the first postion of bit 0
|
||||
*/
|
||||
UINT8 OsaUintBit0Search(UINT32 data);
|
||||
|
||||
/*
|
||||
* From LSB(right/low) to MSB (left/high), to find the first postion of bit 1
|
||||
*/
|
||||
UINT8 OsaUintBit1Search(UINT32 data);
|
||||
void OsaSrand(void);
|
||||
UINT32 OsaRand(void);
|
||||
|
||||
struct tm *gmtime_ec(const time_t* tim_p, struct tm* res);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: osaulfcmem.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2022/2/14 created by xuwang
|
||||
*
|
||||
* Notes: memroy operations with an attribute of UpLink Flow Controlling policy.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef OSA_ULFC_MEM_H
|
||||
#define OSA_ULFC_MEM_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "pspdu.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define OSA_ULFC_MEM_USED_THRES_ANY_ALERT_PCT 0xff
|
||||
#define OSA_ULFC_MEM_USED_THRES_ANY 0xffff
|
||||
|
||||
/* ulfc malloc buffer with/without a (pbuf+)ulpdu header in blocking/non-blocking mode?
|
||||
* usage: only for application's exchange data, mostly uplink data.
|
||||
*/
|
||||
#define OsaUlfcAllocMemBlocking(wantedSize, chanNo) OsaUlfcAllocMem(wantedSize, 0, 0, 1, chanNo)
|
||||
#define OsaUlfcAllocMemNonBlocking(wantedSize, chanNo) OsaUlfcAllocMem(wantedSize, 0, 0, 0, chanNo)
|
||||
#define OsaUlfcAllocUlPduBlocking(wantedSize, chanNo) OsaUlfcAllocMem(wantedSize, 0, 1, 1, chanNo)
|
||||
#define OsaUlfcAllocUlPduNonBlocking(wantedSize, chanNo) OsaUlfcAllocMem(wantedSize, 0, 1, 0, chanNo)
|
||||
#define OsaUlfcAllocPbufUlPduBlocking(wantedSize, chanNo) OsaUlfcAllocMem(wantedSize, 1, 1, 1, chanNo)
|
||||
#define OsaUlfcAllocPbufUlPduNonBlocking(wantedSize, chanNo) OsaUlfcAllocMem(wantedSize, 1, 1, 0, chanNo)
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t magicNum;
|
||||
uint16_t extras;
|
||||
uint32_t memSize; /* aligned size */
|
||||
}OsaUlfcMemHdr_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OSA_ULFC_MFI_MEM_THRES = 0,
|
||||
|
||||
OSA_ULFC_MFI_MAXNUM
|
||||
}OsaUlfcMemFactorId_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OSA_ULFC_STI_CCIO_RX = 0,
|
||||
|
||||
OSA_ULFC_STI_MAXNUM
|
||||
}OsaUlfcSrcTaskId_e;
|
||||
|
||||
typedef uint32_t OsaUlfcSrcTaskId_bm;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
OSA_ULFC_MEF_LOW_WATER = 0,
|
||||
OSA_ULFC_MEF_HIGH_WATER,
|
||||
|
||||
OSA_ULFC_MEF_MAXNUM
|
||||
}OsaUlfcMemEvtFlags_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t memUsed;
|
||||
uint32_t extras;
|
||||
}OsaUlfcMemEvtArgs_t;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint32_t OsaUlfcGetMemUsedThresAlertPct(uint8_t chanNo);
|
||||
void OsaUlfcSetMemUsedThresAlertPct(uint8_t chanNo, uint8_t alertPct);
|
||||
|
||||
uint32_t OsaUlfcGetMemUsedSizeThres(uint8_t chanNo);
|
||||
void OsaUlfcSetMemUsedSizeThres(uint8_t chanNo, uint32_t usedSize);
|
||||
|
||||
uint8_t OsaUlfcQueryEnableState(uint8_t chanNo);
|
||||
uint32_t OsaUlfcQueryMemAvlbSize(uint8_t chanNo);
|
||||
|
||||
void* OsaUlfcAllocMem(uint32_t wantedSize, uint8_t hasPbuf, uint8_t hasUldpu, uint8_t isBlocking, uint16_t extras);
|
||||
void OsaUlfcFreeMem(void *ptr);
|
||||
void OsaUlfcReallocMem(void *ptr, uint32_t wantedSize);
|
||||
|
||||
void OsaUlfcEnable(uint8_t chanNo, uint8_t isBlocking, OsaUlfcSrcTaskId_e taskId);
|
||||
void OsaUlfcDisable(uint8_t chanNo, OsaUlfcSrcTaskId_e taskId);
|
||||
|
||||
void OsaUlfcNotifyMemEvent(OsaUlfcMemEvtFlags_e flags, OsaUlfcMemEvtArgs_t *args);
|
||||
void OsaUlfcConfmMemEvent(uint8_t chanNo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
#ifndef __OSA_UTIL_H__
|
||||
#define __OSA_UTIL_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M Ltd.
|
||||
File name: - osautil.h
|
||||
Description: - defined some common functions/structures
|
||||
History: - 2021/02/20, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "winsys.h"
|
||||
#else
|
||||
#include "commontypedef.h"
|
||||
#endif
|
||||
|
||||
#include "pspdu.h"
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef OsaBit1Set
|
||||
/*
|
||||
* set bit B to 1 in D
|
||||
* example:
|
||||
* OsaBit1Set(0x00, 0) = 0x01
|
||||
* OsaBit1Set(0x01, 4) = 0x11
|
||||
*/
|
||||
#define OsaBit1Set(D, B) ((D) |= ((UINT32)1<<(B)))
|
||||
#endif
|
||||
|
||||
#ifndef OsaBit0Set
|
||||
/*
|
||||
* set bit B to 0 in D
|
||||
* example:
|
||||
* OsaBit1Set(0xFF, 0) = 0xFE
|
||||
* OsaBit1Set(0xFE, 4) = 0xEE
|
||||
*/
|
||||
#define OsaBit0Set(D, B) ((D) &= (~((UINT32)1<<(B))))
|
||||
#endif
|
||||
|
||||
#ifndef OsaIsBit1
|
||||
/*
|
||||
* whether bit B in D is 1
|
||||
* example:
|
||||
* OsaIsBit1(1010 1010, 0) = FALSE
|
||||
* OsaIsBit1(1010 1010, 1) = TRUE
|
||||
*/
|
||||
#define OsaIsBit1(D, B) ((((D)>>(B))&0x01) == 0x01)
|
||||
#endif
|
||||
|
||||
#ifndef OsaIsBit0
|
||||
/*
|
||||
* whether bit B in D is 0
|
||||
* example:
|
||||
* OsaIsBit0(1010 1010, 0) = TRUE
|
||||
* OsaIsBit0(1010 1010, 1) = FALSE
|
||||
*/
|
||||
#define OsaIsBit0(D, B) ((((D)>>(B))&0x01) == 0x00)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* get byte length from bit length
|
||||
* example:
|
||||
* OsaBitsByteLen(1) = 1
|
||||
* OsaBitsByteLen(7) = 1
|
||||
* OsaBitsByteLen(9) = 2
|
||||
*/
|
||||
#define OsaBitsByteLen(bits) (((bits)+7)>>3)
|
||||
|
||||
/*
|
||||
* Set N bits of D (UINT8) start from S to V,
|
||||
* (D) &= ~((~(0xFFFFFFFF<<(N)))<<(S)); // set N bits to 0
|
||||
* (D) |= (((V)&(~(0xFFFFFFFF<<(N))))<<(S)); // set N bits to V
|
||||
* Example
|
||||
* OsaSetUint8BitsN(1111 1111, 2, 4, 1010) => 1110 1011
|
||||
* ^S
|
||||
* OsaSetUint8BitsN(0000 0000, 4, 3, 101) => 0101 0000
|
||||
* ^S
|
||||
*/
|
||||
#define OsaSetUint8BitsN(D, S, N, V) ((D) &= ~((~(0xFFFFFFFF<<(N)))<<(S)), (D) |= (((V)&(~(0xFFFFFFFF<<(N)))) << (S)))
|
||||
|
||||
/*
|
||||
* Example
|
||||
* OsaGetBitsN(0001 1000, 0, 4) = 0x08
|
||||
* ^S
|
||||
* OsaGetBitsN(0001 1000, 3, 2) = 0x03
|
||||
* ^S
|
||||
*/
|
||||
#define OsaGetBitsN(D, S, N) (((D)>>(S))&(~(0xFFFFFFFF << (N))))
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
#define OSA_IE_BUF_STEP_SIZE 128
|
||||
|
||||
#define OSA_IE_BUF_MAX_SIZE 4096
|
||||
|
||||
/*
|
||||
* Osa4ByteAlignLen(0) = 0
|
||||
* Osa4ByteAlignLen(1) = 4
|
||||
* Osa4ByteAlignLen(8) = 8
|
||||
*/
|
||||
#define Osa4ByteAlignLen(byteLen) (((byteLen)+3)&0xFFFFFFFC)
|
||||
|
||||
|
||||
/*
|
||||
* Single linked list operation MARCO
|
||||
* !!!! STRUCT must have "pNext" element !!!
|
||||
*/
|
||||
#define OsaSingleLinkAddOne(pHdr, pTailer, pNew) \
|
||||
do { \
|
||||
if ((pHdr) == PNULL) \
|
||||
{ \
|
||||
OsaCheck((pTailer) == PNULL && (pNew) != PNULL && ((pNew)->pNext) == PNULL, (pTailer), ((pNew)->pNext), 0xABCDEF); \
|
||||
(pHdr) = (pTailer) = (pNew); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
OsaCheck((pTailer) != PNULL && (pNew) != PNULL && ((pNew)->pNext) == PNULL, (pTailer), ((pNew)->pNext), 0xFEDCBA); \
|
||||
(pTailer)->pNext = (pNew); \
|
||||
(pTailer) = (pNew); \
|
||||
} \
|
||||
}while(FALSE)
|
||||
|
||||
/*
|
||||
*/
|
||||
#define OsaSingleLinkAddList(pHdr, pTailer, pNewHdr, pNewTailer) \
|
||||
do { \
|
||||
if ((pHdr) == PNULL) \
|
||||
{ \
|
||||
OsaCheck((pTailer) == PNULL && (pNewHdr) != PNULL && ((pNewTailer)->pNext) == PNULL, (pTailer), ((pNewTailer)->pNext), 0x12345678); \
|
||||
(pHdr) = (pNewHdr); \
|
||||
(pTailer) = (pNewTailer); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
OsaCheck((pTailer) != PNULL && (pNewHdr) != PNULL && ((pNewTailer)->pNext) == PNULL, (pTailer), ((pNewTailer)->pNext), 0x87654321); \
|
||||
(pTailer)->pNext = (pNewHdr); \
|
||||
(pTailer) = (pNewTailer); \
|
||||
} \
|
||||
}while(FALSE)
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Dynamic memory allocated for ASN1 read/decode
|
||||
*/
|
||||
typedef struct OsaIeBuffer_Tag
|
||||
{
|
||||
struct OsaIeBuffer_Tag *pNext;
|
||||
|
||||
/*
|
||||
* total allocated size of current memory
|
||||
*/
|
||||
UINT16 totalSize;
|
||||
/*
|
||||
* free memory address = pStart + freeOffset
|
||||
*/
|
||||
UINT16 freeOffset;
|
||||
|
||||
UINT8 pStart[];
|
||||
}OsaIeBuffer; // 8 bytes
|
||||
|
||||
typedef struct OsaIeMemInfo_Tag
|
||||
{
|
||||
OsaIeBuffer *pBufHdr;
|
||||
}OsaIeMemInfo;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* FUNC
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* OsaBit1Search
|
||||
* Description: From LSB(right/low) to MSB (left/high), to find the first postion
|
||||
* of bit 1
|
||||
* input: UINT32 data
|
||||
* output: UINT8 //if not found, return 0xFF
|
||||
* Comment:
|
||||
* example: 10100100 00001000 10101111 11000000, return 6
|
||||
* 0x00000000 return 0xFF
|
||||
* 0xFFFFFFFF return 0
|
||||
******************************************************************************/
|
||||
UINT8 OsaBit1Search(UINT32 data);
|
||||
|
||||
/******************************************************************************
|
||||
* OsaBit0Search
|
||||
* Description: From LSB(right/low) to MSB (left/high), to find the first postion
|
||||
* of bit 0
|
||||
* input: UINT32 data
|
||||
* output: UINT8 //if not found, return 0xFF
|
||||
* Comment:
|
||||
* example: 1010 1011, return 2
|
||||
* 0000 0000, return 0
|
||||
* 0xFFFFFFFF, return 0xFF
|
||||
******************************************************************************/
|
||||
UINT8 OsaBit0Search(UINT32 data);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* OsaBeZeroMemory
|
||||
* Description: Whether all memory are set to zero
|
||||
* input:
|
||||
* output: UINT32 // 0 - not all zero, 1 - all zero
|
||||
*
|
||||
******************************************************************************/
|
||||
UINT32 OsaBeZeroMemory(const void *pMem, UINT32 size);
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* OsaIeMemInit
|
||||
* Description: init PS IE (information element) memory info
|
||||
* input: OsaIeMemInfo *pIeMemInfo //IE memory info
|
||||
* UINT16 estIeSize //estimate IE structure size
|
||||
* void **ppRootIebuf //output, return root IE buffer
|
||||
* output: void
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void OsaIeMemInit(OsaIeMemInfo *pIeMemInfo, UINT16 estIeSize, void **ppRootIebuf);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* OsaIeMemAllocate
|
||||
* Description: Allocate memory from IE memory
|
||||
* input: OsaIeMemInfo *pIeMemInfo //IE memory info
|
||||
* UINT16 wantSize //want size
|
||||
* output: void
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void* OsaIeMemAllocate(OsaIeMemInfo *pIeMemInfo, UINT16 wantSize);
|
||||
|
||||
/******************************************************************************
|
||||
* OsaIeMemDestroy
|
||||
* Description: destroy/free all IE memory
|
||||
* input: OsaIeMemInfo *pIeMemInfo //IE memory info
|
||||
* output: void
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void OsaIeMemDestroy(OsaIeMemInfo *pIeMemInfo);
|
||||
|
||||
/******************************************************************************
|
||||
* OsaSetBufBitsValue
|
||||
* Description: Set "bitLen" (MAX 32 bits) bits value in "pBuf" start from "bitOffset", to "value"
|
||||
* input: UINT8 *pBuf;
|
||||
* UINT32 *startBitOffset //IN & OUT put, output = *startBitOffset + bitsLen
|
||||
* UINT8 bitsLen
|
||||
* UINT32 value
|
||||
* output: void
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void OsaSetBufBitsValue(UINT8 *pBuf, UINT32 *startBitOffset, UINT8 bitsLen, UINT32 value);
|
||||
|
||||
/******************************************************************************
|
||||
* OsaGetBufBitsValue
|
||||
* Description: Get "bitLen" (MAX 32 bits) bits value from "pBuf" start from "bitOffset"
|
||||
* input: UINT8 *pBuf;
|
||||
* UINT32 *startBitOffset //IN & OUT put, output = *startBitOffset + bitsLen
|
||||
* UINT8 bitsLen
|
||||
* output: UINT32
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
UINT32 OsaGetBufBitsValue(const UINT8 *pBuf, UINT32 *startBitOffset, UINT8 bitsLen);
|
||||
|
||||
/*
|
||||
* Alloc one "DlPduBlock" from heap, if failed, return PNULL
|
||||
*/
|
||||
DlPduBlock* OsaAllocDlPduBlock(UINT32 len);
|
||||
|
||||
/*
|
||||
* Free one DL PDU block
|
||||
*/
|
||||
void OsaFreeOneDlPduBlock(DlPduBlock **pDlPduBlk);
|
||||
|
||||
/*
|
||||
* Free DL PDU list
|
||||
*/
|
||||
void OsaFreeDlPduBlockList(DlPduBlock **pDlPduBlk);
|
||||
|
||||
/*
|
||||
* Free one UL PDU block
|
||||
*/
|
||||
void OsaFreeOneUlPduBlock(UlPduBlock **pUlPduBlk);
|
||||
|
||||
/*
|
||||
* Free UL PDU list
|
||||
*/
|
||||
void OsaFreeUlPduBlockList(UlPduBlock **pUlPduBlk);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
|
||||
* File name: ostask.h
|
||||
* Description: adpter layer for ps to use os task, queue API
|
||||
* History:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _PS_OSTAS_H
|
||||
#define _PS_OSTAS_H
|
||||
|
||||
#ifndef CORE_IS_CP //for AP
|
||||
|
||||
#include "commontypedef.h"
|
||||
#include "cmsis_os2.h" // ::CMSIS:RTOS2
|
||||
|
||||
#define CMS_TASK_NAME "CmsTask"
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Task STACK size
|
||||
*
|
||||
******************************************************************************/
|
||||
#define PS_TASK_STACK_SIZE 1536
|
||||
|
||||
#define UICC_CTRL_TASK_STACK_SIZE 2048
|
||||
#define UICC_DRV_TASK_STACK_SIZE 1536
|
||||
|
||||
//#define TCPIP_THREAD_STACKSIZE 2048
|
||||
#define LWIP_TASK_STACK_SIZE 1536
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Task signal queue size
|
||||
*
|
||||
******************************************************************************/
|
||||
#define PS_TASK_QUEUE_SIZE 20 // queue size of ps tasks
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Task priority, from low -> high
|
||||
*
|
||||
******************************************************************************/
|
||||
#define OTHER_TASK_PRIORITY osPriorityNormal /* all APP task priority should <= osPriorityNormal*/
|
||||
|
||||
|
||||
#define CMS_TASK_PRIORITY osPriorityNormal2
|
||||
|
||||
//#define TCPIP_THREAD_PRIO 26 //osPriorityNormal2
|
||||
|
||||
#define CCM_TASK_PRIORITY osPriorityAboveNormal
|
||||
#define UICC_CTRL_TASK_PRIORITY osPriorityAboveNormal1
|
||||
#define CENAS_TASK_PRIORITY osPriorityAboveNormal2
|
||||
#define CERRC_TASK_PRIORITY osPriorityAboveNormal4
|
||||
#define CEUP_TASK_PRIORITY osPriorityAboveNormal7
|
||||
|
||||
//#define configTIMER_TASK_PRIORITY 40 //osPriorityHigh
|
||||
|
||||
#define UICC_DRV_TASK_PRIORITY osPriorityHigh1 //UICC DRV task should have more high priority
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum OsaTaskIdTag /* tasks sent to identified by their task ids */
|
||||
{
|
||||
CCM_TASK_ID, // 0
|
||||
NAS_TASK_ID, // 1
|
||||
CERRC_TASK_ID, // 2
|
||||
CEUP_TASK_ID, // 3
|
||||
UICC_CTRL_TASK_ID, // 4
|
||||
UICC_DRV_TASK_ID, // 5
|
||||
|
||||
CMS_TASK_ID, // 6, CMS (Communication Modem Service) task
|
||||
|
||||
NUM_OF_REAL_TASKS,
|
||||
|
||||
CEPHY_TASK_ID ,
|
||||
} OsaTaskId;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Typedef : PsTaskInitDefTag
|
||||
*
|
||||
* Type : structure
|
||||
* Description : This structure is used to hold information about a task that
|
||||
* needs to be created at run time. This is the base type of
|
||||
* the psTaskInitTable array. NOTE: that this must hold only
|
||||
* things that are known at compile time as the psTaskInitTable
|
||||
* array is marked as constant i.e. in ROM.
|
||||
*******************************************************************************/
|
||||
typedef struct PsTaskInitDefTag
|
||||
{
|
||||
/* Member: task id of this task. */
|
||||
OsaTaskId taskId;
|
||||
/* Member: void *() entryPoint = Pointer to entry point function for
|
||||
** this task. */
|
||||
void (*entryPoint)();
|
||||
/* Member: void *stack = A pointer to the memory to use for this tasks
|
||||
** stack. */
|
||||
void *stack;
|
||||
/* Member: Int16 stackSize = The number bytes in this tasks stack. */
|
||||
INT16 stackSize;
|
||||
/* Member: Int16 priority = The priority of this task. */
|
||||
INT16 priority;
|
||||
|
||||
void *queue;
|
||||
INT16 queueSize;
|
||||
const CHAR* taskName;
|
||||
|
||||
|
||||
} PsTaskInitDef;
|
||||
|
||||
/** Function prototype for functions callback */
|
||||
typedef void (*app_callback_fn)(void *ctx);
|
||||
|
||||
|
||||
typedef struct appFunCbTag
|
||||
{
|
||||
app_callback_fn function;
|
||||
void *ctx;
|
||||
} appFunCb;
|
||||
|
||||
// number of Message Queue objects
|
||||
#define MSGQUEUE_OBJECTS (4)
|
||||
|
||||
// message queue element typedef
|
||||
typedef struct
|
||||
{
|
||||
uint32_t uart_chann; // current uart chann
|
||||
uint32_t recv_cnt; // current receiver buffer coounter
|
||||
} msgqueue_obj_t;
|
||||
|
||||
|
||||
/*
|
||||
* CMS task create
|
||||
*/
|
||||
void CmsTaskAndQCeate(osThreadFunc_t func, UINT32 stackSize, UINT32 queueCount, void *pStackMem, void *pQueueMem);
|
||||
|
||||
/*
|
||||
* Whether CMS & AT task createds
|
||||
*/
|
||||
BOOL CmsTaskIsCreated(void);
|
||||
|
||||
/*
|
||||
* Get CMS task ID
|
||||
*/
|
||||
osThreadId_t CmsTaskGetId(void);
|
||||
|
||||
|
||||
/*
|
||||
* create all PS tasks and their associated queues.
|
||||
*/
|
||||
void PsInitialiseTasks(BOOL taskCreatedBefore);
|
||||
|
||||
void PsOsGetLwipTaskMemory(void **tcbBuf, int *tcbSize, void **stackBuf, int *stackSize);
|
||||
void registerAppEntry(osThreadFunc_t func, void *arg);
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#include "commontypedef.h"
|
||||
#include "cmsis_os2.h" // ::CMSIS:RTOS2
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Task STACK size
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define PHY_HIGH_TASK_STACK_SIZE 1536
|
||||
#define PHY_MID_TASK_STACK_SIZE 2048 // NOTE: 1536 is not enough, verified by zlfu @20200511
|
||||
#define PHY_LOW_TASK_STACK_SIZE 1536 // NOTE: 1024 is not enough, verified by zlfu @20200511
|
||||
|
||||
//#define TCPIP_THREAD_STACKSIZE 2048
|
||||
#define LWIP_TASK_STACK_SIZE 1536
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Task signal queue size
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define PHY_HIGH_TASK_QUEUE_SIZE 10 // queue size of phy tasks
|
||||
#define PHY_MID_TASK_QUEUE_SIZE 10 // queue size of phy tasks
|
||||
#define PHY_LOW_TASK_QUEUE_SIZE 10 // queue size of phy tasks
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Task priority, from low -> high
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#define PHY_LOW_TASK_PRIORITY osPriorityHigh5 //L1 low priority task
|
||||
#define PHY_MID_TASK_PRIORITY osPriorityHigh6 //L1 task should have high priority
|
||||
#define PHY_HIGH_TASK_PRIORITY osPriorityHigh7 //L1 low priority task
|
||||
|
||||
|
||||
typedef enum OsaTaskIdTag /* tasks sent to identified by their task ids */
|
||||
{
|
||||
PHY_HIGH_TASK_ID, // For PHY HwTask Config only
|
||||
|
||||
PHY_MID_TASK_ID, // L1 task, used for parse message from PS
|
||||
|
||||
|
||||
PHY_LOW_TASK_ID, // L1 low priority task
|
||||
|
||||
|
||||
|
||||
NUM_OF_REAL_TASKS
|
||||
} OsaTaskId;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Typedef : PsTaskInitDefTag
|
||||
*
|
||||
* Type : structure
|
||||
* Description : This structure is used to hold information about a task that
|
||||
* needs to be created at run time. This is the base type of
|
||||
* the psTaskInitTable array. NOTE: that this must hold only
|
||||
* things that are known at compile time as the psTaskInitTable
|
||||
* array is marked as constant i.e. in ROM.
|
||||
*******************************************************************************/
|
||||
typedef struct PsTaskInitDefTag
|
||||
{
|
||||
/* Member: TaskId taskId = The GKI task id of this task. */
|
||||
OsaTaskId taskId;
|
||||
/* Member: void *() entryPoint = Pointer to entry point function for
|
||||
** this task. */
|
||||
void (*entryPoint)();
|
||||
/* Member: void *stack = A pointer to the memory to use for this tasks
|
||||
** stack. */
|
||||
void *stack;
|
||||
/* Member: Int16 stackSize = The number bytes in this tasks stack. */
|
||||
INT16 stackSize;
|
||||
/* Member: Int16 priority = The priority of this task. */
|
||||
INT16 priority;
|
||||
|
||||
void *queue;
|
||||
INT16 queueSize;
|
||||
const CHAR* taskName;
|
||||
|
||||
|
||||
} PsTaskInitDef;
|
||||
|
||||
/** Function prototype for functions callback */
|
||||
typedef void (*app_callback_fn)(void *ctx);
|
||||
|
||||
|
||||
typedef struct appFunCbTag
|
||||
{
|
||||
app_callback_fn function;
|
||||
void *ctx;
|
||||
} appFunCb;
|
||||
|
||||
// number of Message Queue objects
|
||||
#define MSGQUEUE_OBJECTS (4)
|
||||
|
||||
// message queue element typedef
|
||||
typedef struct
|
||||
{
|
||||
uint32_t uart_chann; // current uart chann
|
||||
uint32_t recv_cnt; // current receiver buffer coounter
|
||||
} msgqueue_obj_t;
|
||||
|
||||
|
||||
//extern osThreadId_t psTaskIdTable[NUM_OF_REAL_TASKS];
|
||||
//extern osMessageQueueId_t psQueueHandleTable[NUM_OF_REAL_TASKS];
|
||||
|
||||
void PsInitialiseTasks(void);
|
||||
void registerAppEntry(osThreadFunc_t func, void *arg);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,442 @@
|
||||
#ifndef __PS_PDU_H__
|
||||
#define __PS_PDU_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M Ltd.
|
||||
File name: - pspdu.h
|
||||
Description: - PS DATA PDU info
|
||||
History: - 10/19/2018, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "winsys.h"
|
||||
#else
|
||||
#include "commontypedef.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* UL PDU memory type
|
||||
*/
|
||||
typedef enum UlPduMemType_Tag
|
||||
{
|
||||
UL_HEAP_MEM = 0, // dynamic memory, OsaAllocMemory/OsaAllocZeroMemory/OsaFreeMemory
|
||||
UL_LWIP_PKG_MEM, // LwipFreeUlIpPkgMem() free it
|
||||
UL_STACK_MEM, // stack memory, don't need to free
|
||||
UL_RBUF_MEM, // uldp rbuf memory, uldpRbufDequeue
|
||||
UL_AFC_MEM, // ulfc memory, OsaUlfcFreeMem
|
||||
|
||||
UL_MEM_TYPE_MAX = 15
|
||||
}UlPduMemType;
|
||||
|
||||
|
||||
/*
|
||||
* ticks type, which carried in "UlPduBlock"
|
||||
*/
|
||||
typedef enum UlPduTickType_Tag
|
||||
{
|
||||
UL_PDU_NO_TICK_INFO = 0,// no tick info
|
||||
UL_PDU_DISCARD_TICK, // this UL PDU could be discarded if exceed this tick: "current tick" > "UL_PDU_DISCARD_TICK"
|
||||
UL_PDU_START_TICK // systick when LWIP create/send this UL PDU
|
||||
}UlPduTickType;
|
||||
|
||||
|
||||
/*
|
||||
* UL data PDU info, this just the UL user data need to send to NW
|
||||
*
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* A: if UL data is "IP PKG" from LWIP, memtype = "UL_LWIP_PKG_MEM"
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* Maybe need ROHC:
|
||||
* Before ROHC:
|
||||
* +------------------+-----------------------------------+
|
||||
* | ip/udp/other hdr | payload |
|
||||
* +------------------+-----------------------------------+
|
||||
* ^
|
||||
* |ptr
|
||||
* |<------------------- length ------------------------->|
|
||||
*
|
||||
* After ROHC:
|
||||
* 1> if (ip/udp/other hdr length) >= (comp len): (most case)
|
||||
* +---------+--------+-----------------------------------+
|
||||
* | |comp hdr| payload |
|
||||
* +---------+--------+-----------------------------------+
|
||||
* ^
|
||||
* |ptr
|
||||
* |<------->|validOffset
|
||||
* | |<-------------- length -------------------->|
|
||||
*
|
||||
* 2> if (ip/udp/other hdr length) < (comp len):
|
||||
* i> need to create a new "data_pdu_info" to store the compressed header
|
||||
* ii> and this "data_pdu_info" only contain the payload info;
|
||||
* +--------------------+
|
||||
* | comp hdr |
|
||||
* +--------------------+
|
||||
* ^
|
||||
* |ptr
|
||||
* |<---- length ------>|
|
||||
* bContinue = TRUE, and pNext ->
|
||||
* +------------------+-----------------------------------+
|
||||
* | ip/udp/other hdr | payload |
|
||||
* +------------------+-----------------------------------+
|
||||
* ^
|
||||
* |ptr
|
||||
* |<---------------->|validOffset
|
||||
* | |<----------- length -------------->|
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* B: if UL data is not from LWIP, maybe from ATCMD, memtype = "UL_HEAP_MEM"
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* +------------------------------------------------------+
|
||||
* | UL USER DATA |
|
||||
* +------------------------------------------------------+
|
||||
* ^
|
||||
* |ptr
|
||||
* |<------------------- length ------------------------->|
|
||||
*
|
||||
*/
|
||||
typedef struct UlPduBlock_Tag
|
||||
{
|
||||
UINT8 memType :4; /* UlPduMemType
|
||||
* indicate the "ptr" memory type, which would affect how to free the "*ptr" memory
|
||||
*/
|
||||
UINT8 bSameMem :1; /* whether the UlPduBlock and "ptr" use the same memory,
|
||||
* if TRUE, this memory only need to free once,
|
||||
* if not, UlPduBlock struct should allocated in heap, the memType indicated the memory type of ptr
|
||||
*/
|
||||
UINT8 bFreed :1; /* whether this UlPduBlock and ptr are freed, only used for USB Rx Cycle buffer */
|
||||
UINT8 bContinue :1; /* Whether following seg belong to the same IP PKG:
|
||||
* TRUE - next seg is the same IP PKG PDU
|
||||
* FALSE - Not the same IP PKG PDU
|
||||
*/
|
||||
UINT8 pbufBefore :1; /* whether consecutive memory for "struct pbuf" before this block, set when allocate buffer */
|
||||
UINT8 validOffset; /* Valid/real data offset, start from: ptr */
|
||||
UINT16 length;
|
||||
|
||||
UINT8 *ptr;
|
||||
struct UlPduBlock_Tag *pNext;
|
||||
|
||||
|
||||
/*
|
||||
* Other DATA info
|
||||
*/
|
||||
UINT32 epsId :4; /* epsId, should set in ESM task */
|
||||
UINT32 esmRai :2; /* DataRelAssistIndEnum, release assistance indication, set in APP */
|
||||
UINT32 bExceptData :1; /* need to pass to CEMM/CERRC, if "Except Data", CERRC need to establish connection even if it's barred, set in APP */
|
||||
UINT32 bRohcFeedback :1; /* Whether this pkg is ROHC feedback pkg only, set in ROHC task */
|
||||
|
||||
UINT32 bRohcComped :1; /* Whether ROHC compressed in this pkg */
|
||||
UINT32 bTestLoopback :1; /* Whether this UL data is test loop back data*/
|
||||
UINT32 tickType :2; /* UlPduTickType, indicate the "sysTick" type */
|
||||
UINT32 pppCrcNok :1; /* PPP deescape, whether CRC checked failed */
|
||||
UINT32 fastPathNextAction :2; /*the ul pdu hase process by fastpath. and the next action is rohc process*/ /*UlPduNextActType*/
|
||||
UINT32 rsvd0 :1;
|
||||
|
||||
UINT32 chanNo :5; /* for uldp UL_RBUF_MEM */
|
||||
UINT32 rsvd :11;
|
||||
|
||||
/*
|
||||
* Note:
|
||||
* 1> if "systick" is "UL_PDU_DISCARD_TICK", then PS (DR/ESM/EMM) MAYBE (not must) discard this pkg, if "current sys tick" > "sysTick";
|
||||
* LWIP could set this if has a clear valid period for this UL PKG, such as: TCP pkg, or DNS/IPv6 RS pkg (as has retry timer);
|
||||
* 2> if "systick" is "UL_PDU_START_TICK", then PS (DR/ESM/EMM) MAYBE (not must) discard this pkg in case:
|
||||
* a> the time passed more than 20s, and b> has anyother UL pkg followed;
|
||||
* 3> if "systick" is "UL_PDU_NO_TICK_INFO", then PS (DR/ESM/EMM) could try best to send it, don't discard it easily;
|
||||
*
|
||||
* Another note:
|
||||
* 1> DR/ESM will pending not more then (3*1500) bytes pkgs, or not more then 10 pkgs;
|
||||
* if exceeded, will discard the oldest pkg;
|
||||
*/
|
||||
UINT32 sysTick; /*system tick, type is indicated by: tickType */
|
||||
}UlPduBlock; //20 bytes
|
||||
|
||||
#define UL_PDU_BLOCK_SET_BASICS(ulpdu, chno, mtype, bsame, buf, len, bpbuf, bcont, next) \
|
||||
do\
|
||||
{\
|
||||
((UlPduBlock*)(ulpdu))->chanNo = (chno);\
|
||||
((UlPduBlock*)(ulpdu))->memType = (mtype);\
|
||||
((UlPduBlock*)(ulpdu))->bSameMem = (bsame);\
|
||||
((UlPduBlock*)(ulpdu))->ptr = (buf);\
|
||||
((UlPduBlock*)(ulpdu))->validOffset = 0;\
|
||||
((UlPduBlock*)(ulpdu))->length = (len);\
|
||||
((UlPduBlock*)(ulpdu))->pbufBefore = (bpbuf);\
|
||||
((UlPduBlock*)(ulpdu))->bContinue = (bcont);\
|
||||
((UlPduBlock*)(ulpdu))->pNext = (next);\
|
||||
}while(0)
|
||||
|
||||
#define UL_PDU_BLOCK_INCR(ulpdu, n) \
|
||||
do\
|
||||
{\
|
||||
EC_ASSERT(((UlPduBlock*)(ulpdu))->length >= (n), ((UlPduBlock*)(ulpdu))->length, n, ulpdu);\
|
||||
((UlPduBlock*)(ulpdu))->validOffset += (n);\
|
||||
((UlPduBlock*)(ulpdu))->length -= (n);\
|
||||
}while(0)
|
||||
|
||||
#define UL_PDU_BLOCK_DECR(ulpdu, n) \
|
||||
do\
|
||||
{\
|
||||
EC_ASSERT(((UlPduBlock*)(ulpdu))->validOffset >= (n), ((UlPduBlock*)(ulpdu))->validOffset, n, ulpdu);\
|
||||
((UlPduBlock*)(ulpdu))->validOffset -= (n);\
|
||||
((UlPduBlock*)(ulpdu))->length += (n);\
|
||||
}while(0)
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* DL PDU defination
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Reserved for ROHC decompression;
|
||||
* 80 = ipv6 + udp + rtp + 20 others
|
||||
*/
|
||||
#define ROHC_DL_HDR_RSVD_LEN 80
|
||||
|
||||
#define LWIP_PBUF_STRUCT_LEN 24 //sizeof(pbuf)
|
||||
|
||||
/*
|
||||
* +----------+----------+----------+---------+------------------------------------+---------+---------+
|
||||
* | pbuf |DlPduBlock| RNDIS HDR|Ether HDR| ip pkg (len <= MTU) |Ether CRC|RNDIS PAD|
|
||||
* +----------+----------+----------+---------|------------------------------------+---------+---------+
|
||||
* | 24 bytes | 16 bytes | 44 bytes | 14 bytes| 28 ~ 1500 bytes | 4 bytes | 3 bytes |
|
||||
*
|
||||
* RNDIS_ETH_NET_DL_RESV_LEN = 44+14+7 = 65 ~= 68
|
||||
*/
|
||||
#define RNDIS_ETH_NET_DL_RSVD_HDR_LEN 60 // 44+14 = 58 ~= 60
|
||||
#define RNDIS_ETH_NET_DL_RSVD_TAILER_LEN 8 // 4+3 = 7 ~= 8
|
||||
|
||||
|
||||
/*
|
||||
* Magic word
|
||||
*/
|
||||
#define DL_PDU_MAGIC_WORD 0xA7C5
|
||||
|
||||
/*
|
||||
* set and check one magic byte
|
||||
*/
|
||||
#define DL_PDU_BLOCK_SET_MAGIC_WORD(pDlPduBlock) ((pDlPduBlock)->magicWord = DL_PDU_MAGIC_WORD)
|
||||
#define DL_PDU_BLOCK_CHECK_MAGIC_WORD(pDlPduBlock) ((pDlPduBlock)->magicWord == DL_PDU_MAGIC_WORD)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* DL PDU memory type
|
||||
*/
|
||||
typedef enum DlPduMemType_Tag
|
||||
{
|
||||
DL_HEAP_MEM = 0, // dynamic memory, GosAllocMemory/GosAllocZeroMemory/GosFreeMemory
|
||||
DL_PS_PKG_MEM,
|
||||
DL_AFC_MEM, // OsaDlfcFreeMem
|
||||
|
||||
DL_MEM_TYPE_MAX = 15
|
||||
}DlPduMemType;
|
||||
|
||||
/*
|
||||
* DL PDU memory type
|
||||
*/
|
||||
typedef enum DlPduIpType_Tag
|
||||
{
|
||||
DL_PDU_IP_TYPE_INVALID = 0, // invalid ip type
|
||||
DL_PDU_IP_TYPE_V4 = 1, // invalid ip type
|
||||
DL_PDU_IP_TYPE_V6 = 2, // invalid ip type
|
||||
}DlPduIpType;
|
||||
|
||||
|
||||
/*
|
||||
* How LWIP/Txtask proc this DL PDU
|
||||
*/
|
||||
typedef enum DlPduNextActType_Tag
|
||||
{
|
||||
DL_PDU_NO_ACT = 0, /* No special action, default value.
|
||||
* Case example: DLPDU(AT CMD) only need to transmit to USB host.
|
||||
*/
|
||||
DL_PDU_PARSE = 0, /* need parse received IP pkg, LWIP task response how to proc this DL IP pkg.
|
||||
* 1> when PS (L2) recv a DL IP pkg, set to this value.
|
||||
*/
|
||||
DL_PDU_DISCARD = 1, /* This DL PDU need to discard, as PDU memory can't be freed in ISR, then if
|
||||
* this DL PDU is useless, could set to this value, and discard it later in task
|
||||
*/
|
||||
DL_PDU_NAT_PAT_MAP = 2, /* This DL PDU need to NAT/PAT transliation
|
||||
* Note: NAT/PAT transliation is handled in LWIP task
|
||||
*/
|
||||
DL_PDU_NEED_FRAGEMENT = 3, /* This DL PDU is too large, IP pkg length > LAN MTU size, it need fragment
|
||||
*/
|
||||
DL_PDU_NEED_MSS_CHECK = 4, /* TCP MSS adpt */
|
||||
|
||||
DL_PDU_NEED_WINDOWS_CHECK = 5, /* TCP widnows adpt, TCP SYN PKG */
|
||||
|
||||
DL_PDU_NEED_NDS_RELAY = 6, /* for RNDIS private IP solution, host DNS resolve need relay */
|
||||
/* === to RNDIS host === */
|
||||
DL_PDU_ADD_IPV4_ETH_RNDIS_HDR = 7, /* DL PDU to RNDIS host, need to add ethernet ipv4 header and RNDIS header */
|
||||
DL_PDU_ADD_IPV6_ETH_RNDIS_HDR_0 = 8, /* DL PDU to RNDIS host, need to add ethernet ipv6 header and RNDIS header */
|
||||
DL_PDU_ADD_IPV6_ETH_RNDIS_HDR_1 = 9, /* DL PDU to RNDIS host, need to add ethernet ipv6 header and RNDIS header */
|
||||
DL_PDU_ADD_IPV6_ETH_RNDIS_HDR_2 = 10, /* DL PDU to RNDIS host, need to add ethernet ipv6 header and RNDIS header */
|
||||
DL_PDU_ADD_RNDIS_HDR = 11, /* DL PDU to RNDIS host, need to add RNDIS header
|
||||
* 1> if eth_type is not ipv4(0x0800U)/ipv6(0x86DDU) (enum eth_type in ethernet.h)
|
||||
* need to set it in LWIP task
|
||||
*/
|
||||
|
||||
/* === to PPP host === */
|
||||
DL_PDU_ADD_IPV4_PPP_HDR = 12, /* DL PDU to PPP host, need to add IPv4 PPP header */
|
||||
DL_PDU_ADD_IPV6_PPP_HDR = 13, /* DL PDU to PPP host, need to add IPv6 PPP header */
|
||||
|
||||
/* === to ECM host === */
|
||||
DL_PDU_ADD_IPV4_ETH_ECM_HDR = 14, /* DL PDU to ECM host, need to add ethernet ipv4 header and ECM header */
|
||||
DL_PDU_ADD_IPV6_ETH_ECM_HDR_0 = 15, /* DL PDU to ECM host, need to add ethernet ipv6 header and ECM header */
|
||||
DL_PDU_ADD_IPV6_ETH_ECM_HDR_1 = 16, /* DL PDU to ECM host, need to add ethernet ipv6 header and ECM header */
|
||||
DL_PDU_ADD_IPV6_ETH_ECM_HDR_2 = 17, /* DL PDU to ECM host, need to add ethernet ipv6 header and ECM header */
|
||||
DL_PDU_ADD_ECM_HDR = 18, /* DL PDU to ECM host, need to add ECM HDR
|
||||
* 1> if eth_type is not ipv4(0x0800U)/ipv6(0x86DDU) (enum eth_type in ethernet.h)
|
||||
* need to set it in LWIP task
|
||||
*/
|
||||
|
||||
/* === to local wan/UE local socket APP === */
|
||||
DL_PDU_TO_LOCAL_WAN = 19, /* DL PDU is sent to local WAN/local socket APP */
|
||||
|
||||
DL_PDU_TO_LOCAL_TCP_WINDOWS_CHECK_ETH = 20,
|
||||
|
||||
DL_PDU_TO_LOCAL_TCP_WINDOWS_CHECK_PPP = 21,
|
||||
|
||||
DL_PDU_ACT_TYPE_MAX = 31
|
||||
}DlPduNextActType;
|
||||
|
||||
/*
|
||||
* How LWIP proc this UL PDU
|
||||
*/
|
||||
typedef enum UlPduNextActType_Tag
|
||||
{
|
||||
UL_PDU_PARSE = 0, /*need lwip parse and process*/
|
||||
UL_PDU_ROHC_IP4 = 1, /*need do rohc with ip4 channel*/
|
||||
UL_PDU_ROHC_IP6 = 2, /*need do rohc with ip6 channel*/
|
||||
UL_PDU_ACT_TYPE_MAX = 3,
|
||||
}UlPduNextActType;
|
||||
|
||||
|
||||
/*
|
||||
* DL PDU BLOCK info, just the DL user data
|
||||
*
|
||||
* 1> !!! "DlPduBlock" and "DL user data" should use the continuous memory !!!
|
||||
* 2> !!! One "DlPduBlock" one DL IP packet !!!
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* A. if DL user PDU is IP PKG data, and need to pass to up layer
|
||||
* this memory should be allocated in memory: DL_PS_PKG_MEM
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* DL IP PDU buffer:
|
||||
* 1. If no ROHC:
|
||||
* +----------+----------+----------+---------+------------------------------------+---------+---------+
|
||||
* | pbuf |DlPduBlock| RNDIS HDR|Ether HDR| ip pkg (len <= MTU) |Ether CRC|RNDIS PAD|
|
||||
* +----------+----------+----------+---------|------------------------------------+---------+---------+
|
||||
* | 24 bytes | 16 bytes | 44 bytes | 14 bytes| 28 ~ 1500 bytes | 4 bytes | 3 bytes |
|
||||
* *payload--------------------------------^
|
||||
* pPdu-------------------------^
|
||||
* length = |<---------------------------------->|
|
||||
*
|
||||
* 2. If ROHC Feedback:
|
||||
* +--------------+---------------------------+
|
||||
* | DlPduBlock | ROHC Feedback |
|
||||
* +--------------+---------------------------+
|
||||
* pPdu-----^
|
||||
* length = |<------------------------->|
|
||||
*
|
||||
* 3. If ROHC, before decomp:
|
||||
* +----------+----------+----------+---------+--------------------+--------+---------------------+---------+---------+
|
||||
* | pbuf |DlPduBlock| RNDIS HDR|Ether HDR|ROHC_DL_HDR_RSVD_LEN|comp hdr| pkg data |Ether CRC|RNDIS PAD|
|
||||
* +----------+----------+----------+---------|--------------------+--------+---------------------+---------+---------+
|
||||
* | 24 bytes | 16 bytes | 44 bytes | 14 bytes| 80 bytes | 3 ~ 1500 bytes | 4 bytes | 3 bytes |
|
||||
* pPdu----------------------------------------------^
|
||||
* length = |<---------------------------->|
|
||||
*
|
||||
* Note: ROHC_DL_HDR_RSVD_LEN = 80, reserved for decompressed IP header, 80 = ipv6 + udp + rtp + 20 others
|
||||
*
|
||||
* After decomp:
|
||||
* 3.1> If reserved 80 bytes is enough (most case):
|
||||
* +----------+----------+----------+---------+------------+----------------+---------------------+---------+---------+
|
||||
* | pbuf |DlPduBlock| RNDIS HDR|Ether HDR| | decomped ip hdr| pkg data |Ether CRC|RNDIS PAD|
|
||||
* +----------+----------+----------+---------|------------+----------------+---------------------+---------+---------+
|
||||
* | 24 bytes | 16 bytes | 44 bytes | 14 bytes|RSVD/useless| 28 ~ 1500 bytes | 4 bytes | 3 bytes |
|
||||
* pPdu--------------------------------------^
|
||||
* length = |<------------------------------------>|
|
||||
* *payload----------------------------------------------^
|
||||
*
|
||||
* 3.2> If reserved 80 bytes is not enough (rarely)
|
||||
* ROHC decompression side, need to allocate a new block (suggest also from : DL_PS_PKG_MEM), and soft copy to this new block;
|
||||
* i> copy to ->
|
||||
* +----------+----------+----------+---------+----------------+---------------------+---------+---------+
|
||||
* | pbuf |DlPduBlock| RNDIS HDR|Ether HDR| decomped ip hdr| pkg data |Ether CRC|RNDIS PAD|
|
||||
* +----------+----------+----------+---------|----------------+---------------------+---------+---------+
|
||||
* | 24 bytes | 16 bytes | 44 bytes | 14 bytes| 28 ~ 1500 bytes | 4 bytes | 3 bytes |
|
||||
* *payload--------------------------------^
|
||||
* pPdu-------------------------^
|
||||
* length = |<------------------------------------>|
|
||||
*
|
||||
* ii> Free the old block
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* A. if DL user PDU is not IP PKG data, (if need to LOOPBACK, or non-ip data)
|
||||
* This memory should be allcated in HEAP
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* +----------+-----------------------------------+
|
||||
* |DlPduBlock| PDCP User data |
|
||||
* +----------+-----------------------------------+
|
||||
* pPdu------^
|
||||
* length = |<--------------------------------->|
|
||||
*
|
||||
*/
|
||||
typedef struct DlPduBlock_Tag
|
||||
{
|
||||
UINT16 magicWord; // used to memory protection
|
||||
UINT16 length;
|
||||
|
||||
/*
|
||||
* !!! "DlPduBlock" and "pPdu" should use the continuous memory !!!
|
||||
*/
|
||||
UINT8 *pPdu;
|
||||
struct DlPduBlock_Tag *pNext;
|
||||
|
||||
/*
|
||||
* Other DATA info
|
||||
*/
|
||||
UINT32 dlMemType : 4; /* DlPduMemType */
|
||||
UINT32 bOnlyDecomp : 1; /* Whether only need to do ROHC DECOMP, but don't need to pass to LWIP;
|
||||
* Note:
|
||||
* 1> During PDCP DL re-establishment procedure, here, as PDCP COUNT maybe re-order, DL PDCP SDU need to
|
||||
* deciphered & decompressed, and stored in PDCP side;
|
||||
* 2> Here, set it (in PDCP task), notify LWIP(ROHC) task only do decompression, but don't pass to LWIP task;
|
||||
* 3> Set & Clear it in PDCP task;
|
||||
*/
|
||||
UINT32 bIgnoreDecomp : 1; /* If configed ROHC, whether need to ignore decompression for this pkg;
|
||||
* Note:
|
||||
* 1> PDCP set it, if pass re-order PDCP SDU, which decomped before
|
||||
*/
|
||||
UINT32 bRohcFeedback : 1; /* The PDU is ROHC feedback, not IP data, PDCP set it. */
|
||||
UINT32 bRohcBuffRsvd : 1; /* whether reserved ROHC buffer with length: ROHC_DL_HDR_RSVD_LEN, in this DL PDU */
|
||||
|
||||
UINT32 pbufBefore : 1; /* whether memory for "struct pbuf" before this block, set when allocate buffer */
|
||||
UINT32 bNetHdrRsvd : 1; /* whether reserved RNDIS/Ethernet header and padding, in this DL PDU */
|
||||
UINT32 reserved0 : 1;
|
||||
UINT32 nextAct : 5; /* DlPduNextActType, how LWIP/Tx task proc this DL PDU */
|
||||
|
||||
UINT32 reserved : 16;
|
||||
}DlPduBlock; // 16 bytes
|
||||
|
||||
#define DL_PDU_BLOCK_SET_BASICS(dlpdu, mtype, buf, len, bpbuf, next) \
|
||||
do\
|
||||
{\
|
||||
((DlPduBlock*)(dlpdu))->magicWord = DL_PDU_MAGIC_WORD;\
|
||||
((DlPduBlock*)(dlpdu))->dlMemType = (mtype);\
|
||||
((DlPduBlock*)(dlpdu))->pPdu = (buf);\
|
||||
((DlPduBlock*)(dlpdu))->length = (len);\
|
||||
((DlPduBlock*)(dlpdu))->pbufBefore = (bpbuf);\
|
||||
((DlPduBlock*)(dlpdu))->pNext = (next);\
|
||||
}while(0)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: reset.h
|
||||
*
|
||||
* Description: header of reset.c, for reset reason check
|
||||
*
|
||||
* History: 2021.04.02 initiated by Zhao Weiqi
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef RESET_H
|
||||
#define RESET_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define RESET_REASON_MAGIC (0xACD20E00)
|
||||
#define RESET_REASON_MASK (0xFFFFFF00)
|
||||
#define DUMP_UNREADY_MAGIC (0x8)
|
||||
#define DUMP_UNREADY_MASK (0xF)
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
typedef enum _EPAT_ResetReason_e
|
||||
{
|
||||
RESET_REASON_CLEAR = 0x80,
|
||||
RESET_REASON_CPPOR = 0x90,
|
||||
RESET_REASON_HARDFAULT = 0xA0,
|
||||
RESET_REASON_ASSERT = 0xB0,
|
||||
RESET_REASON_WDT = 0xC0,
|
||||
RESET_REASON_BAT = 0xD0,
|
||||
RESET_REASON_TEMP = 0xE0,
|
||||
RESET_REASON_FOTA = 0xF0,
|
||||
}ResetReason_e;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LAST_RESET_POR = 0,
|
||||
LAST_RESET_NORMAL, // can be sleep2/hib
|
||||
LAST_RESET_SWRESET,
|
||||
LAST_RESET_HARDFAULT,
|
||||
LAST_RESET_ASSERT,
|
||||
LAST_RESET_WDTSW,
|
||||
LAST_RESET_WDTHW,
|
||||
LAST_RESET_LOCKUP,
|
||||
LAST_RESET_AONWDT,
|
||||
LAST_RESET_BATLOW,
|
||||
LAST_RESET_TEMPHI,
|
||||
LAST_RESET_FOTA,
|
||||
LAST_RESET_CPRESET,
|
||||
LAST_RESET_UNKNOWN,
|
||||
LAST_RESET_MAXNUM,
|
||||
}LastResetState_e;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef CORE_IS_CP
|
||||
/**
|
||||
* @brief ResetReasonWriteCP
|
||||
* @details CP write reset reason
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetReasonWriteCP(ResetReason_e reason);
|
||||
/**
|
||||
* @brief cpNVIC_SystemReset
|
||||
* @details call this api to process cp system reset,
|
||||
do not call __NVIC_SystemReset
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void cpNVIC_SystemReset(void);
|
||||
/**
|
||||
* @brief cpClearBootFlag
|
||||
* @details clear cp boot flag when enter hardfault or assert, in case of lockup happens
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void cpClearBootFlag(void);
|
||||
#else
|
||||
/**
|
||||
* @brief ResetReasonWriteAP
|
||||
* @details AP write reset reason
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetReasonWriteAP(ResetReason_e reason);
|
||||
/**
|
||||
* @brief ResetCheckCpNeedPorReset
|
||||
* @details or cp reset ap cases, always trigger a por reset
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetCheckCpNeedPorReset(void);
|
||||
/**
|
||||
* @brief ResetReasonInit
|
||||
* @details call in AP bsp customInit to print reset reason
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetReasonInit(void);
|
||||
/**
|
||||
* @brief ResetReasonCpRstCheck
|
||||
* @details call in CP Rst Irq to update cp reset reason
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetReasonCpRstCheck(void);
|
||||
/**
|
||||
* @brief ResetStateGet
|
||||
* @details get last reset state
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetStateGet(LastResetState_e *apRstState, LastResetState_e *cpRstState);
|
||||
/**
|
||||
* @brief ResetLockupCfg
|
||||
* @details set ap and cp lockup process, this settings will store in aon
|
||||
set true to reset when lockup happen. set false will stop cpu when lockup happen
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetLockupCfg(bool apLockupRstEn, bool cpLockupRstEn);
|
||||
/**
|
||||
* @brief ResetApplyAPLockupCfg
|
||||
* @details get ap lockup settings from aon and apply
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetApplyAPLockupCfg(void);
|
||||
/**
|
||||
* @brief ResetECSystemReset
|
||||
* @details System reset, call this api is more safe than _NVIC_SystemReset
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetECSystemReset(void);
|
||||
/**
|
||||
* @brief ResetStartPorReset
|
||||
* @details process a por reset, a reset magic is write to flash in this api
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
void ResetStartPorReset(ResetReason_e reason);
|
||||
/**
|
||||
* @brief ResetIsSwPorReset
|
||||
* @details check flash to decide whether it is por reset
|
||||
use to bypass pwrkey debounce flow
|
||||
* @param
|
||||
* @note
|
||||
*/
|
||||
bool ResetIsSwPorReset(ResetReason_e *pReason);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: rndis_entity.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2021/1/19 created by xuwang
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef RNDIS_ENTITY_H
|
||||
#define RNDIS_ENTITY_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#if 0
|
||||
typedef struct
|
||||
{
|
||||
/* inherited field & MUST be placed on the top! */
|
||||
CcioEntity_t base;
|
||||
|
||||
uint8_t lanState; /* refer to 'CcioLanMediaState_e', via monitor/user */
|
||||
uint8_t pdp4Cid; /* ipv4 pdp context Id, via monitor */
|
||||
uint8_t pdp6Cid; /* ipv6 pdp context Id, via monitor */
|
||||
uint8_t rsvd;
|
||||
|
||||
void *extras; /* for user context. */
|
||||
|
||||
/* TODO: statistic, via monitor */
|
||||
}RndisEntity_t;
|
||||
|
||||
#else
|
||||
|
||||
typedef EtherEntity_t RndisEntity_t;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief crioInitEntity(SerialEntity_t *serlEnt, chentStatusCallback statusCb, void *extras)
|
||||
* @details create a rndis entity
|
||||
*
|
||||
* @param rndisEnt The entity to be created
|
||||
* @param status_cb The handler of entity status
|
||||
* @param extras The user's extra info/useful context
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t crioInitEntity(RndisEntity_t *rndisEnt,
|
||||
chentStatusCallback statusCb,
|
||||
void *extras);
|
||||
|
||||
/**
|
||||
* @brief crioDeinitEntity(RndisEntity_t *rndisEnt)
|
||||
* @details delete/reset a rndis entity
|
||||
*
|
||||
* @param rndisEnt The entity to be deleted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t crioDeinitEntity(RndisEntity_t *rndisEnt);
|
||||
|
||||
/**
|
||||
* @brief crioSetUpChannel(RndisEntity_t *rndisEnt)
|
||||
* @details establish a rndis channel
|
||||
*
|
||||
* @param rndisEnt The entity to be established the channel
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t crioSetUpChannel(RndisEntity_t *rndisEnt);
|
||||
|
||||
/**
|
||||
* @brief crioPullDownChannel(RndisEntity_t *rndisEnt)
|
||||
* @details destroy a rndis channel
|
||||
*
|
||||
* @param rndisEnt The entity to be destroied the channel
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t crioPullDownChannel(RndisEntity_t *rndisEnt);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
#ifndef _RNDIS_H
|
||||
#define _RNDIS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#define RNDIS_MAJOR_VERSION 1
|
||||
#define RNDIS_MINOR_VERSION 0
|
||||
|
||||
#define RNDIS_STATUS_SUCCESS 0X00000000
|
||||
#define RNDIS_STATUS_FAILURE 0XC0000001
|
||||
#define RNDIS_STATUS_INVALID_DATA 0XC0010015
|
||||
#define RNDIS_STATUS_NOT_SUPPORTED 0XC00000BB
|
||||
#define RNDIS_STATUS_MEDIA_CONNECT 0X4001000B
|
||||
#define RNDIS_STATUS_MEDIA_DISCONNECT 0X4001000C
|
||||
|
||||
|
||||
/* Message set for Connectionless (802.3) Devices */
|
||||
#define REMOTE_NDIS_PACKET_MSG 0x00000001
|
||||
#define REMOTE_NDIS_INITIALIZE_MSG 0X00000002
|
||||
#define REMOTE_NDIS_HALT_MSG 0X00000003
|
||||
#define REMOTE_NDIS_QUERY_MSG 0X00000004
|
||||
#define REMOTE_NDIS_SET_MSG 0X00000005
|
||||
#define REMOTE_NDIS_RESET_MSG 0X00000006
|
||||
#define REMOTE_NDIS_INDICATE_STATUS_MSG 0X00000007
|
||||
#define REMOTE_NDIS_KEEPALIVE_MSG 0X00000008
|
||||
#define REMOTE_NDIS_INITIALIZE_CMPLT 0X80000002
|
||||
#define REMOTE_NDIS_QUERY_CMPLT 0X80000004
|
||||
#define REMOTE_NDIS_SET_CMPLT 0X80000005
|
||||
#define REMOTE_NDIS_RESET_CMPLT 0X80000006
|
||||
#define REMOTE_NDIS_KEEPALIVE_CMPLT 0X80000008
|
||||
|
||||
typedef uint32_t rndis_MessageType_t;
|
||||
typedef uint32_t rndis_MessageLength_t;
|
||||
typedef uint32_t rndis_RequestId_t;
|
||||
typedef uint32_t rndis_MajorVersion_t;
|
||||
typedef uint32_t rndis_MinorVersion_t;
|
||||
typedef uint32_t rndis_MaxTransferSize_t;
|
||||
typedef uint32_t rndis_Status_t;
|
||||
|
||||
|
||||
/* Device Flags */
|
||||
#define RNDIS_DF_CONNECTIONLESS 0x00000001
|
||||
#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002
|
||||
typedef uint32_t rndis_DeviceFlags_t;
|
||||
|
||||
/* Mediums */
|
||||
#define RNDIS_MEDIUM_802_3 0x00000000
|
||||
typedef uint32_t rndis_Medium_t;
|
||||
|
||||
|
||||
typedef uint32_t rndis_MaxPacketsPerTransfer_t;
|
||||
typedef uint32_t rndis_PacketAlignmentFactor_t;
|
||||
typedef uint32_t rndis_AfListOffset_t;
|
||||
typedef uint32_t rndis_AfListSize_t;
|
||||
|
||||
/*** Remote NDIS Generic Message type ***/
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
} rndis_generic_msg_t;
|
||||
|
||||
|
||||
/*** Remote NDIS Initialize Message ***/
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
rndis_MajorVersion_t MajorVersion;
|
||||
rndis_MinorVersion_t MinorVersion;
|
||||
rndis_MaxTransferSize_t MaxTransferSize;
|
||||
} rndis_initialize_msg_t;
|
||||
|
||||
/* Response: */
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
rndis_Status_t Status;
|
||||
rndis_MajorVersion_t MajorVersion;
|
||||
rndis_MinorVersion_t MinorVersion;
|
||||
rndis_DeviceFlags_t DeviceFlags;
|
||||
rndis_Medium_t Medium;
|
||||
rndis_MaxPacketsPerTransfer_t MaxPacketsPerTransfer;
|
||||
rndis_MaxTransferSize_t MaxTransferSize;
|
||||
rndis_PacketAlignmentFactor_t PacketAlignmentFactor;
|
||||
rndis_AfListOffset_t AfListOffset;
|
||||
rndis_AfListSize_t AfListSize;
|
||||
} rndis_initialize_cmplt_t;
|
||||
|
||||
|
||||
/*** Remote NDIS Halt Message ***/
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
} rndis_halt_msg_t;
|
||||
|
||||
typedef uint32_t rndis_Oid_t;
|
||||
typedef uint32_t rndis_InformationBufferLength_t;
|
||||
typedef uint32_t rndis_InformationBufferOffset_t;
|
||||
typedef uint32_t rndis_DeviceVcHandle_t;
|
||||
|
||||
/*** Remote NDIS Query Message ***/
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
rndis_Oid_t Oid;
|
||||
rndis_InformationBufferLength_t InformationBufferLength;
|
||||
rndis_InformationBufferOffset_t InformationBufferOffset;
|
||||
rndis_DeviceVcHandle_t DeviceVcHandle;
|
||||
} rndis_query_msg_t;
|
||||
|
||||
/* Response: */
|
||||
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
rndis_Status_t Status;
|
||||
rndis_InformationBufferLength_t InformationBufferLength;
|
||||
rndis_InformationBufferOffset_t InformationBufferOffset;
|
||||
} rndis_query_cmplt_t;
|
||||
|
||||
/*** Remote NDIS Set Message ***/
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
rndis_Oid_t Oid;
|
||||
rndis_InformationBufferLength_t InformationBufferLength;
|
||||
rndis_InformationBufferOffset_t InformationBufferOffset;
|
||||
rndis_DeviceVcHandle_t DeviceVcHandle;
|
||||
} rndis_set_msg_t;
|
||||
|
||||
/* Response */
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
rndis_Status_t Status;
|
||||
}rndis_set_cmplt_t;
|
||||
|
||||
/* Information buffer layout for OID_GEN_RNDIS_CONFIG_PARAMETER */
|
||||
typedef uint32_t rndis_ParameterNameOffset_t;
|
||||
typedef uint32_t rndis_ParameterNameLength_t;
|
||||
typedef uint32_t rndis_ParameterType_t;
|
||||
typedef uint32_t rndis_ParameterValueOffset_t;
|
||||
typedef uint32_t rndis_ParameterValueLength_t;
|
||||
|
||||
#define PARAMETER_TYPE_STRING 2
|
||||
#define PARAMETER_TYPE_NUMERICAL 0
|
||||
|
||||
typedef struct{
|
||||
rndis_ParameterNameOffset_t ParameterNameOffset;
|
||||
rndis_ParameterNameLength_t ParameterNameLength;
|
||||
rndis_ParameterType_t ParameterType;
|
||||
rndis_ParameterValueOffset_t ParameterValueOffset;
|
||||
rndis_ParameterValueLength_t ParameterValueLength;
|
||||
}rndis_config_parameter_t;
|
||||
|
||||
typedef uint32_t rndis_Reserved_t;
|
||||
|
||||
/*** Remote NDIS Soft Reset Message ***/
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_Reserved_t Reserved;
|
||||
} rndis_reset_msg_t;
|
||||
|
||||
typedef uint32_t rndis_AddressingReset_t;
|
||||
|
||||
/* Response: */
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_Status_t Status;
|
||||
rndis_AddressingReset_t AddressingReset;
|
||||
} rndis_reset_cmplt_t;
|
||||
|
||||
/*** Remote NDIS Indicate Status Message ***/
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_Status_t Status;
|
||||
rndis_Status_t StatusBufferLength;
|
||||
rndis_Status_t StatusBufferOffset;
|
||||
} rndis_indicate_status_t;
|
||||
|
||||
typedef uint32_t rndis_DiagStatus_t;
|
||||
typedef uint32_t rndis_ErrorOffset_t;
|
||||
|
||||
typedef struct {
|
||||
rndis_DiagStatus_t DiagStatus;
|
||||
rndis_ErrorOffset_t ErrorOffset;
|
||||
}rndis_diagnostic_info_t;
|
||||
|
||||
/*** Remote NDIS Keepalive Message */
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
}rndis_keepalive_msg_t;
|
||||
|
||||
/* Response: */
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_RequestId_t RequestId;
|
||||
rndis_Status_t Status;
|
||||
}rndis_keepalive_cmplt_t;
|
||||
|
||||
/*** Remote NDIS Data Packet ***/
|
||||
|
||||
typedef uint32_t rndis_DataOffset_t;
|
||||
typedef uint32_t rndis_DataLength_t;
|
||||
typedef uint32_t rndis_OOBDataOffset_t;
|
||||
typedef uint32_t rndis_OOBDataLength_t;
|
||||
typedef uint32_t rndis_NumOOBDataElements_t;
|
||||
typedef uint32_t rndis_PerPacketInfoOffset_t;
|
||||
typedef uint32_t rndis_PerPacketInfoLength_t;
|
||||
|
||||
typedef struct{
|
||||
rndis_MessageType_t MessageType;
|
||||
rndis_MessageLength_t MessageLength;
|
||||
rndis_DataOffset_t DataOffset;
|
||||
rndis_DataLength_t DataLength;
|
||||
rndis_OOBDataOffset_t OOBDataOffset;
|
||||
rndis_OOBDataLength_t OOBDataLength;
|
||||
rndis_NumOOBDataElements_t NumOOBDataElements;
|
||||
rndis_PerPacketInfoOffset_t PerPacketInfoOffset;
|
||||
rndis_PerPacketInfoLength_t PerPacketInfoLength;
|
||||
rndis_DeviceVcHandle_t DeviceVcHandle;
|
||||
rndis_Reserved_t Reserved;
|
||||
}rndis_data_packet_t;
|
||||
|
||||
typedef uint32_t rndis_ClassInformationOffset_t;
|
||||
typedef uint32_t rndis_Size_t;
|
||||
typedef uint32_t rndis_Type_t;
|
||||
|
||||
typedef struct{
|
||||
rndis_Size_t Size;
|
||||
rndis_Type_t Type;
|
||||
rndis_ClassInformationOffset_t ClassInformationType;
|
||||
}rndis_OOB_packet_t;
|
||||
|
||||
#include "ndis.h"
|
||||
|
||||
typedef enum rnids_state_e {
|
||||
rndis_uninitialized,
|
||||
rndis_initialized,
|
||||
rndis_data_initialized
|
||||
} rndis_state_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t txok;
|
||||
uint32_t rxok;
|
||||
uint32_t txbad;
|
||||
uint32_t rxbad;
|
||||
uint16_t ext_notifyok;
|
||||
uint16_t int_encbuf_notifyok;
|
||||
uint8_t int_listbuf_notifyok;
|
||||
uint8_t int_encbuf_srcmiss; //enc buf is send, but no encbuf src flag is set
|
||||
uint8_t int_listbuf_srcmiss;
|
||||
uint8_t int_listbuf_overlap_cnt;
|
||||
uint8_t int_listbuf_rstdrop_cnt;
|
||||
uint8_t int_listbuf_livedrop_cnt;
|
||||
|
||||
} usb_eth_stat_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
rndis_state_t rndis_state;
|
||||
uint32_t oid_packet_filter;
|
||||
usb_eth_stat_t usb_eth_stat;
|
||||
}rndis_ctrl_data_st;
|
||||
|
||||
|
||||
void RdsProInitalMsgHdl(rndis_generic_msg_t *msgIn);
|
||||
void RdsProQueryHdl(rndis_query_msg_t *m, rndis_ctrl_data_st *p_ctrl_data);
|
||||
void FuncRndisInitNotify(void);
|
||||
void FuncRndisHaltNotify(void);
|
||||
void FuncRndisResetNotify(void);
|
||||
uint32_t RndisGetEncBufSize(void);
|
||||
|
||||
void RdsProInitalMsgHdl(rndis_generic_msg_t *msgIn);
|
||||
void RdsProQueryCmplt(rndis_query_msg_t *m, int status, const void *data, int size);
|
||||
void RdsProQueryCmplt32(rndis_query_msg_t *m, int status, uint32_t data);
|
||||
void RdsProQueryHdl(rndis_query_msg_t *m, rndis_ctrl_data_st *p_ctrl_data);
|
||||
void RdsProCfgParaHdl(const char *data, int keyoffset, int valoffset, int keylen, int vallen);
|
||||
void RdsProPktFilter(uint32_t newfilter);
|
||||
void RdsProSetMsgHdl(rndis_set_msg_t *msgIn, rndis_ctrl_data_st *p_ctrl_data);
|
||||
void RdsProResetMsgHdl(rndis_reset_cmplt_t *m, rndis_ctrl_data_st *p_ctrl_data);
|
||||
|
||||
void RdsProKeepAliveMsgHdl(rndis_keepalive_cmplt_t *m, uint32_t RequestId, rndis_ctrl_data_st *p_ctrl_data);
|
||||
|
||||
#define RNDIS_MTU 1500
|
||||
#define RNDIS_LINK_SPEED 100000000
|
||||
#define RNDIS_VENDOR "AirM2M"
|
||||
#define RNDIS_HWADDR 0x20,0x89,0x84,0x6A,0x96,0xAB
|
||||
|
||||
|
||||
#define RNDIS_MAX_PACK_PER_XFER 10
|
||||
#define ETH_HEADER_SIZE 14
|
||||
#define ETH_MAX_PACKET_SIZE ETH_HEADER_SIZE + RNDIS_MTU
|
||||
#define ETH_MIN_PACKET_SIZE 60
|
||||
|
||||
#define RNDIS_RX_BUFFER_SIZE ((((ETH_MAX_PACKET_SIZE + sizeof(rndis_data_packet_t)) + 99) / 100) * 100 * 2)
|
||||
#define RNDIS_TX_BUFFER_SIZE (ETH_MAX_PACKET_SIZE + sizeof(rndis_data_packet_t))
|
||||
|
||||
|
||||
|
||||
#endif /* _RNDIS_H */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,209 @@
|
||||
#ifndef __SCT_USB_TX_API_H__
|
||||
#define __SCT_USB_TX_API_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copy right: 2017-, Copyrigths of AirM2M Ltd.
|
||||
File name: sct_usb_tx_api.h
|
||||
Description: SCT PPP and CRC API, external provide to app
|
||||
History: 2020/12/02 Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#include "pspdu.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SCT_USB_TX_RET_OK = 0,
|
||||
SCT_USB_TX_ERR = -1,
|
||||
SCT_USB_TX_BUSY = -2
|
||||
}SctUsbTxRetEnum;
|
||||
|
||||
typedef INT32 SctUsbTxRet;
|
||||
|
||||
|
||||
/*
|
||||
* USB Tx Block
|
||||
*/
|
||||
typedef DlPduBlock SctUsbTxBlock;
|
||||
|
||||
|
||||
/*
|
||||
* SCT USB ISR event
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SCT_USB_DEINT = 0, /* when USB plug out, or suspended */
|
||||
SCT_USB_INIT = 1, /* USB is OK (EP enumed), and SCT could sent data to USBC TxFIFO, when USB plug in, or resumed */
|
||||
SCT_USB_RESET = 2 /* USB is reseted, SCT USB channel should be reset, and wait USB init(OK) again. */
|
||||
}SctUsbStateEvent;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* Functions
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
#define SCT_USB_TX_EP_PARALLEL
|
||||
#ifdef SCT_USB_TX_EP_PARALLEL
|
||||
|
||||
|
||||
/*
|
||||
* SCT USB channel init config, and not enable EEA (Cipher) function.
|
||||
*/
|
||||
void SctUsbChanlInitConfig(BOOL timeOutInit);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* SctUsbTxRawDataNew
|
||||
* Description: SCT USB Tx raw data, without cipher/CRC/PPP operation.
|
||||
* input: UINT32 epId //USB EP ID < 16
|
||||
* SctUsbTxBlock *pTxHead //input, Tx block header
|
||||
* SctUsbTxBlock *pTxTail //input, Tx block header
|
||||
* BOOL allowConcatenated //input, whether allow serveral PDU Tx in one USB transfer
|
||||
* output: SctUsbTxRet
|
||||
* Comment:
|
||||
* 1> As the MAX USB Tx transfer size is limited, Tx block maybe can't transmit one time
|
||||
* then, "pRetHead" will return the next not transmited block header
|
||||
* 2> This API return OK, just means block inserted into SCT FIFO, not means already
|
||||
* transmited to USB host, so the caller: !!! can't free the block memory !!!
|
||||
* let the SCT responsible for freeing it after SCT done
|
||||
* 3> This API could only be called in USB TX task
|
||||
* 4> The caller don't need any handling after called this API
|
||||
******************************************************************************/
|
||||
SctUsbTxRet SctUsbTxRawDataNew(UINT32 epId, SctUsbTxBlock *pTxHead, SctUsbTxBlock *pTxTail, BOOL allowConcatenated);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* SctUsbTxPppDataNew
|
||||
* Description: SCT USB Tx raw data, data need PPP escaption.
|
||||
* input: UINT32 epId //USB EP ID < 16
|
||||
* SctUsbTxBlock *pTxHead //input, Tx block header
|
||||
* SctUsbTxBlock *pTxTail //input, Tx block header
|
||||
* output: SctUsbTxRet
|
||||
* Comment:
|
||||
* 1> As the MAX USB Tx transfer size is limited, Tx block maybe can't transmit one time
|
||||
* then, "pRetHead" will return the next not transmited block header
|
||||
* 2> This API return OK, just means block inserted into SCT FIFO, not means already
|
||||
* transmited to USB host, so the caller: !!! can't free the block memory !!!
|
||||
* let the SCT responsible for freeing it after SCT done
|
||||
* 3> This API could only be called in USB TX task
|
||||
* 4> The caller don't need any handling after called this API
|
||||
******************************************************************************/
|
||||
SctUsbTxRet SctUsbTxPppDataNew(UINT32 epId, SctUsbTxBlock *pTxHead, SctUsbTxBlock *pTxTail);
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/*
|
||||
* SCT USB channel init config, and not enable EEA (Cipher) function.
|
||||
*/
|
||||
//void SctUsbChanlInitConfig(void);
|
||||
|
||||
/******************************************************************************
|
||||
* SctUsbTxRawData
|
||||
* Description: SCT USB Tx raw data, without cipher/CRC/PPP operation.
|
||||
* input: UINT32 epId //USB EP ID < 16
|
||||
* SctUsbTxBlock *pTxHdr //input, Tx block header
|
||||
* SctUsbTxBlock **pRetNext //output, next not Tx block header
|
||||
* output: SctUsbTxRet
|
||||
* Comment:
|
||||
* 1> As the MAX USB Tx transfer size is limited, Tx block maybe can't transmit one time
|
||||
* then, "pRetNext" will return the next not transmited block header
|
||||
* 2> This API return OK, just means block inserted into SCT FIFO, not means already
|
||||
* transmited to USB host, so the caller: !!! can't free the block memory !!!
|
||||
* let the SCT responsible for freeing it after SCT done
|
||||
* 3> This API could only be called in USB TX task
|
||||
******************************************************************************/
|
||||
SctUsbTxRet SctUsbTxRawData(UINT32 epId, SctUsbTxBlock *pTxHdr, SctUsbTxBlock **pRetNext);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* SctUsbTxPppData
|
||||
* Description: SCT USB Tx raw data, data need PPP escaption.
|
||||
* input: UINT32 epId //USB EP ID < 16
|
||||
* SctUsbTxBlock *pTxHdr //input, Tx block header
|
||||
* SctUsbTxBlock **pRetNext //output, next not Tx block header
|
||||
* output: SctUsbTxRet
|
||||
* Comment:
|
||||
* 1> As the MAX USB Tx transfer size is limited, Tx block maybe can't transmit one time
|
||||
* then, "pRetNext" will return the next not transmited block header
|
||||
* 2> This API return OK, just means block inserted into SCT FIFO, not means already
|
||||
* transmited to USB host, so the caller: !!! can't free the block memory !!!
|
||||
* let the SCT responsible for freeing it after SCT done
|
||||
* 3> This API could only be called in USB TX task
|
||||
* 4> The header and tailer PPP flag: "7E" inserted in this API, don't need to fill in caller
|
||||
******************************************************************************/
|
||||
SctUsbTxRet SctUsbTxPppData(UINT32 epId, SctUsbTxBlock *pTxHdr, SctUsbTxBlock **pRetNext);
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* SctUsbProcDoneChainInfo
|
||||
* Description: SCT USB process chain done info
|
||||
* input: BOOL *pSctAvailable //
|
||||
* output: void
|
||||
* Comment:
|
||||
* 1> Called when USB Tx task scheduled
|
||||
* 2> if "pSctAvailable" return TRUE, just means SCT USB channel is available again
|
||||
* and the caller could Tx data again
|
||||
******************************************************************************/
|
||||
void SctUsbProcDoneChainInfo(BOOL *pSctAvailable);
|
||||
|
||||
/******************************************************************************
|
||||
* SctUsbProcUsbEvent
|
||||
* Description: SCT USB process USB event notification
|
||||
* input: SctUsbStateEvent usbState
|
||||
* output: void
|
||||
* Comment:
|
||||
* 1> Called when USB Tx task when USB event signal/message received
|
||||
******************************************************************************/
|
||||
void SctUsbProcUsbEvent(SctUsbStateEvent usbEvent);
|
||||
|
||||
#ifdef SCT_USB_TX_EP_PARALLEL
|
||||
/******************************************************************************
|
||||
* SctUsbProcTimerExpiry
|
||||
* Description: SCT USB retry timer expiry handling
|
||||
* input: UINT32 tid
|
||||
* output: void
|
||||
* Comment: Called when CCIO Tx task
|
||||
******************************************************************************/
|
||||
void SctUsbProcTimerExpiry(UINT32 tid);
|
||||
|
||||
/*
|
||||
* SCT USB proc EP unblock signal, EP unblock now
|
||||
*/
|
||||
void SctUsbProcEpUnblock(UINT32 epId);
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* SctUsbCtsBeAllowSend
|
||||
* Description: whether CTS(Clear to Send) signal (trigger in MCU side) allow UE
|
||||
* to send data
|
||||
* input: UINT32 epId
|
||||
* BOOL bAllow //TRUE - allow to send, FALSE - not allow
|
||||
* output: void
|
||||
* Comment: Called in Tx task
|
||||
* 1> if virtual CTS signal is not allow to send data via current USB EP,
|
||||
* current USB EP will be blocked 10 seconds waiting for CTS allow signal,
|
||||
* data will be pended during this time
|
||||
* 2> if exceed 10 seconds, the pending data and following data are all discarded.
|
||||
******************************************************************************/
|
||||
void SctUsbCtsBeAllowSend(UINT32 epId, BOOL bAllow);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
#ifndef SCT_DEF_H
|
||||
#define SCT_DEF_H
|
||||
|
||||
|
||||
#ifndef RAM_BOOT_AP
|
||||
#define RAM_BOOT_AP
|
||||
#define RAM_BOOT_CODE __attribute__((__section__(".ramBootCode")))
|
||||
#endif
|
||||
|
||||
|
||||
//boost power up speed clk init code
|
||||
#define QSPI_XIPSTART_IN_AP_RAM __attribute__((__section__(".XIPStartRamCode")))
|
||||
// for plat use only, only used in bootloader for HW SHA256, since SCT could only access MSMB
|
||||
// But this area should init by user
|
||||
#define PLAT_BL_SCT_ZI __attribute__((__section__(".platBlSctZIData")))
|
||||
|
||||
|
||||
// ap section define
|
||||
|
||||
// for ps use only, load before paging image, placed in asmb
|
||||
#define PS_PA_RAMCODE __attribute__((__section__(".psPARamcode")))
|
||||
// for ps use only, load before paging image, placed in msmb
|
||||
#define PS_PM_RAMCODE __attribute__((__section__(".psPMRamcode")))
|
||||
// for ps use only, load before full image, placed in asmb
|
||||
#define PS_FA_RAMCODE __attribute__((__section__(".psFARamcode")))
|
||||
// for ps use only, load before full image, placed in msmb
|
||||
#define PS_FM_RAMCODE __attribute__((__section__(".psFMRamcode")))
|
||||
|
||||
// for plat use only, load before paging image, placed in asmb
|
||||
#define PLAT_BOOT_RAMCODE_FLASHCLK __attribute__((__section__(".platBootRamcodeFCLK")))
|
||||
|
||||
// for plat use only, load before paging image, placed in asmb
|
||||
#define PLAT_PA_RAMCODE __attribute__((__section__(".platPARamcode")))
|
||||
// for plat use only, load before paging image, placed in msmb
|
||||
#define PLAT_PM_RAMCODE __attribute__((__section__(".platPMRamcode")))
|
||||
// for plat use only, load before full image, placed in asmb
|
||||
#define PLAT_FA_RAMCODE __attribute__((__section__(".platFARamcode")))
|
||||
// for plat use only, load before full image, placed in msmb
|
||||
#define PLAT_FM_RAMCODE __attribute__((__section__(".platFMRamcode")))
|
||||
// ram code to set flash clock
|
||||
#define PLAT_PM_RAMCODE_FLASHCLK __attribute__((__section__(".platPMRamcodeFCLK")))
|
||||
|
||||
// data placed in asmb
|
||||
#define PLAT_FA_ZI __attribute__((__section__(".platFAZIData")))
|
||||
#define PLAT_FA_DATA __attribute__((__section__(".platFARWData")))
|
||||
|
||||
// rw and zi for ps use, init when fullimage start(only from hibernate and power on)
|
||||
// never re-init if asmb not power off
|
||||
#define PS_FA_ZI __attribute__((__section__(".psFAZIData")))
|
||||
#define PS_FA_DATA __attribute__((__section__(".psFARWData")))
|
||||
|
||||
// up and down buffer
|
||||
#define CAT_PSPHY_SHAREDATA __attribute__((__section__(".catShareBuf")))
|
||||
|
||||
// cp section define
|
||||
|
||||
// Most timing critical code, both used in paging&full image
|
||||
// so need to copy from FLASH when wakeup from HIB
|
||||
// NOTE: Paging&PreSync related CODE should only allocated to PHY_CODE_IN_CSMB0 or FLASH
|
||||
#define CP_PLAT_CODE_IN_CSMB __attribute__((__section__(".cpPlatCodeCsmb")))
|
||||
// Most timing critical code, only used in full image
|
||||
// TX/RA/CSI/ConnMeas/CDRX should be allocate to CSMB1 or MSMB1
|
||||
// so NO need to copy from FLASH when wakeup from HIB(these code do not used in paging image)
|
||||
#define CP_PLAT_CODE_IN_MSMB __attribute__((__section__(".cpPlatCodeMsmb")))
|
||||
#define CP_PLAT_CODE_IN_FLASH __attribute__((__section__(".cpPlatCodeFlash")))
|
||||
|
||||
|
||||
// OS related, all dynamic allocated data, other static global data
|
||||
#define CP_PLAT_DATA_IN_MSMB __attribute__((__section__(".cpPlatDataMsmb")))
|
||||
|
||||
#define CP_PLAT_DATA_IN_FLASH __attribute__((__section__(".cpPlatDataFlash")))
|
||||
|
||||
|
||||
|
||||
#ifndef USED
|
||||
#define USED __attribute__((used))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename: serial_entity.h
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History: 2021/1/19 created by xuwang
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef SERIAL_ENTITY_H
|
||||
#define SERIAL_ENTITY_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "lwip/netif.h"
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define ATOS_ENTITY_FLAGS_INIT 0x01 /* created */
|
||||
#define ATOS_ENTITY_FLAGS_ACT 0x02 /* activated */
|
||||
typedef uint8_t AtosEntFlags;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SERIAL_CHM_CMD_OFFLINE = 0,
|
||||
SERIAL_CHM_CMD_ONLINE,
|
||||
SERIAL_CHM_DATA_ONLINE,
|
||||
|
||||
SERIAL_CHM_MAXNUM
|
||||
}SerialChanMode_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t flags; /* AtosEntFlags */
|
||||
uint8_t atCid; /* at context Id between ps */
|
||||
uint8_t outFmt; /* CcioOutXferFormat_e */
|
||||
uint8_t rsvd;
|
||||
|
||||
void *extras; /* for user context. */
|
||||
}AtosEntity_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t lanState; /* refer to 'CcioLanMediaState_e', via monitor/user */
|
||||
uint8_t pdp4Cid; /* ipv4 pdp context Id, via monitor */
|
||||
uint8_t pdp6Cid; /* ipv6 pdp context Id, via monitor */
|
||||
uint8_t needAct; /* 0/1: need to activate pdp context or not? */
|
||||
struct netif pppIf;
|
||||
|
||||
void *extras; /* for user context. */
|
||||
|
||||
//struct stats_proto link; /* statistic, via user */
|
||||
}PpposEntity_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* inherited field & MUST be placed on the top! */
|
||||
CcioEntity_t base;
|
||||
|
||||
uint8_t baseOnly :1; /* if set 1, other fields are meaningless except baseEnt. */
|
||||
uint8_t isChgMode :1; /* is channel mode changing or not? */
|
||||
uint8_t rsvdBits :6;
|
||||
uint8_t chanMode; /* refer to 'SerialChanMode_e', via monitor */
|
||||
uint8_t rsvd[2];
|
||||
uint32_t memThres; /* dlfc memory threshold */
|
||||
osSemaphoreId_t semaId;
|
||||
|
||||
UlPduBlockList_t inList; /* for raw ppp via sct */
|
||||
DlPduBlockList_t outList; /* for uart raw ppp */
|
||||
|
||||
AtosEntity_t at;
|
||||
PpposEntity_t *ppp;
|
||||
}SerialEntity_t;
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief csioInitAtEntity(SerialEntity_t *serlEnt, chentStatusCallback statusCb, void *extras)
|
||||
* @details create an AToS entity
|
||||
*
|
||||
* @param serlEnt The entity to be created
|
||||
* @param isForPpp The entity is for ppp service or not
|
||||
* @param status_cb The handler of entity status
|
||||
* @param extras The user's extra info/useful context
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioInitAtEntity(SerialEntity_t *serlEnt,
|
||||
uint8_t isForPpp,
|
||||
chentStatusCallback statusCb,
|
||||
void *extras);
|
||||
|
||||
/**
|
||||
* @brief csioDeinitAtEntity(SerialEntity_t *serlEnt)
|
||||
* @details delete/reset an AToS entity
|
||||
*
|
||||
* @param serlEnt The entity to be deleted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioDeinitAtEntity(SerialEntity_t *serlEnt);
|
||||
|
||||
/**
|
||||
* @brief csioInitPppEntity(SerialEntity_t *serlEnt, void *extras)
|
||||
* @details create an PPPoS entity
|
||||
*
|
||||
* @param serlEnt The entity to be created
|
||||
* @param extras The user's extra info/useful context
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioInitPppEntity(SerialEntity_t *serlEnt, void *extras);
|
||||
|
||||
/**
|
||||
* @brief csioDeinitPppEntity(SerialEntity_t *serlEnt)
|
||||
* @details delete/reset an PPPoS entity
|
||||
*
|
||||
* @param serlEnt The entity to be deleted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioDeinitPppEntity(SerialEntity_t *serlEnt);
|
||||
|
||||
/**
|
||||
* @brief csioInitDiagEntity(SerialEntity_t *serlEnt, chentStatusCallback statusCb, void *extras)
|
||||
* @details create an DIAGoS entity
|
||||
*
|
||||
* @param serlEnt The entity to be created
|
||||
* @param status_cb The handler of entity status
|
||||
* @param extras The user's extra info/useful context
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioInitDiagEntity(SerialEntity_t *serlEnt,
|
||||
chentStatusCallback statusCb,
|
||||
void *extras);
|
||||
|
||||
/**
|
||||
* @brief csioDeinitDiagEntity(SerialEntity_t *serlEnt)
|
||||
* @details delete/reset an DIAGoS entity
|
||||
*
|
||||
* @param serlEnt The entity to be deleted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioDeinitDiagEntity(SerialEntity_t *serlEnt);
|
||||
|
||||
/**
|
||||
* @brief csioInitOpaqEntity(SerialEntity_t *serlEnt, chentStatusCallback statusCb, void *extras)
|
||||
* @details create an opaqos entity
|
||||
*
|
||||
* @param serlEnt The entity to be created
|
||||
* @param status_cb The handler of entity status
|
||||
* @param extras The user's extra info/useful context
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioInitOpaqEntity(SerialEntity_t *serlEnt,
|
||||
chentStatusCallback statusCb,
|
||||
void *extras);
|
||||
|
||||
/**
|
||||
* @brief csioDeinitOpaqEntity(SerialEntity_t *serlEnt)
|
||||
* @details delete/reset an opaqoS entity
|
||||
*
|
||||
* @param serlEnt The entity to be deleted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioDeinitOpaqEntity(SerialEntity_t *serlEnt);
|
||||
|
||||
/**
|
||||
* @brief csioSetUpChannel(SerialEntity_t *serlEnt)
|
||||
* @details establish a serial(AT or PPP) channel
|
||||
*
|
||||
* @param serlEnt The entity to be established the channel
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioSetUpChannel(SerialEntity_t *serlEnt);
|
||||
|
||||
/**
|
||||
* @brief csioPullDownChannel(SerialEntity_t *serlEnt)
|
||||
* @details destroy a serial(AT or PPP) channel
|
||||
*
|
||||
* @param serlEnt The entity to be destroied the channel
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioPullDownChannel(SerialEntity_t *serlEnt);
|
||||
|
||||
/**
|
||||
* @brief csioSetChanMode(SerialEntity_t *serlEnt, SerialChanMode_e chanMode)
|
||||
* @details set/change the serial channel mode
|
||||
*
|
||||
* @param serlEnt The serial entity whose chanMode is changed
|
||||
* @param chanMode The value of new chan mode
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioSetChanMode(SerialEntity_t *serlEnt, SerialChanMode_e chanMode);
|
||||
|
||||
/**
|
||||
* @brief csioTryAdjustDlfcMemThres(SerialEntity_t *serlEnt)
|
||||
* @details try to adjust dlfc memory threshold according the serial baudrate
|
||||
*
|
||||
* @param serlEnt The serial entity whose dlfc memory threshold will be adjusted
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioTryAdjustDlfcMemThres(SerialEntity_t *serlEnt);
|
||||
|
||||
/**
|
||||
* @brief csioTryRestoreDlfcMemThres(SerialEntity_t *serlEnt)
|
||||
* @details try to restore dlfc memory threshold if adjusted
|
||||
*
|
||||
* @param serlEnt The serial entity whose dlfc memory threshold will be restored
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t csioTryRestoreDlfcMemThres(SerialEntity_t *serlEnt);
|
||||
|
||||
/**
|
||||
* @brief ccioHoldOnPppSessn(SerialEntity_t *serlEnt)
|
||||
* @details switch to online command mode and hold on ppp sessn
|
||||
*
|
||||
* @param serlEnt The serial entity whose ppp sessn will be hold on
|
||||
* @return 0 succ; < 0 failure with errno.
|
||||
*/
|
||||
int32_t ccioHoldOnPppSessn(SerialEntity_t *serlEnt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,896 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
|
||||
* File name: slp_manager.h
|
||||
* Description: EC618 platform sleep management header file
|
||||
* History: 09/28/2018 Originated by wqzhao
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef SLP_MANAGER_H
|
||||
#define SLP_MANAGER_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "mem_map.h"
|
||||
#include "apmu_external.h"
|
||||
/*
|
||||
AT+ECPMUCFG=0,0 disable pmu and can debug on keil
|
||||
AT+ECPMUCFG=1,1 enable pmu and enter wfi only
|
||||
AT+ECPMUCFG=1,2 enable pmu and can enter sleep1
|
||||
AT+ECPMUCFG=1,3 enable pmu and can enter sleep2
|
||||
AT+ECPMUCFG=1,4 enable pmu and can enter hibernate
|
||||
AT+ECPMUCFG? check current pmu state
|
||||
*/
|
||||
|
||||
#define GD_FALSH 1
|
||||
#define PY_FLASH 0
|
||||
|
||||
#define PMU_TIMING_CB_NUM 8
|
||||
|
||||
#if GD_FALSH
|
||||
#define PMU_FLASH_WRITE_TIME_1SECTOR (39) // page write max time 2.4ms, 1 sector 38.4ms
|
||||
#define PMU_PREHIB_EXPECTED_CODE_RUNNING_TIME (PMU_FLASH_WRITE_TIME_1SECTOR*4+2) // time for code running before sleep
|
||||
#define PMU_PRESLP2_EXPECTED_CODE_RUNNING_TIME (PMU_FLASH_WRITE_TIME_1SECTOR*4+2) // time for code running before sleep
|
||||
#endif
|
||||
|
||||
#define PMU_WORTH_HIB_TIME (80+PMU_PREHIB_EXPECTED_CODE_RUNNING_TIME)
|
||||
#define PMU_POSTHIB_EXPECTED_CODE_RUNNING_TIME (27)
|
||||
|
||||
#define PMU_WORTH_SLP2_TIME (80+PMU_PRESLP2_EXPECTED_CODE_RUNNING_TIME)
|
||||
#define PMU_POSTSLP2_EXPECTED_CODE_RUNNING_TIME (27)
|
||||
|
||||
#define PMU_PRESLP_EXPECTED_CODE_RUNNING_TIME (5)
|
||||
#define PMU_POSTSLP_EXPECTED_CODE_RUNNING_TIME (2)
|
||||
#define PMU_WORTH_SLEEP_TIME (50+PMU_PRESLP_EXPECTED_CODE_RUNNING_TIME+PMU_POSTSLP_EXPECTED_CODE_RUNNING_TIME)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DEEPSLP_TIMER_ID0 = 0, // num 0/1: 2 AONTimer, without flash storage, 2.5 hour in 100Hz
|
||||
DEEPSLP_TIMER_ID1,
|
||||
DEEPSLP_TIMER_ID2, // num 2-6: 5 HibTimer, need flash storage, 740 hour in 100Hz
|
||||
DEEPSLP_TIMER_ID3,
|
||||
DEEPSLP_TIMER_ID4,
|
||||
DEEPSLP_TIMER_ID5,
|
||||
DEEPSLP_TIMER_ID6,
|
||||
DEEPSLP_TIMER_ID7 = 7, // num 7-9: Internal HibTimer for AirM2M only, 740 hour in 100Hz
|
||||
DEEPSLP_TIMER_ID8 = 8,
|
||||
DEEPSLP_TIMER_ID9 = 9,
|
||||
}slpManTimerID_e;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t flash_write_time;
|
||||
uint16_t prehib_coderun_time;
|
||||
uint16_t preslp2_coderun_time;
|
||||
uint16_t preslp1_coderun_time;
|
||||
uint16_t posthib_coderun_time;
|
||||
uint16_t postslp2_coderun_time;
|
||||
uint16_t postslp1_coderun_time;
|
||||
uint16_t worth_hib_time;
|
||||
uint16_t worth_slp2_time;
|
||||
uint16_t worth_slp1_time;
|
||||
}pmuTimeCfg_t;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AonIOLatch_Disable = 0,
|
||||
AonIOLatch_Enable = 1,
|
||||
}IOLatchEn;
|
||||
|
||||
/*
|
||||
|
||||
//boot flag defination
|
||||
typedef enum
|
||||
{
|
||||
BOOT_FROM_POWER_ON = 0x0,
|
||||
BOOT_FROM_UNDEF = 0x1,
|
||||
BOOT_FROM_SLEEP1 = 0x4,
|
||||
BOOT_FROM_SLEEP2 = 0x5,
|
||||
BOOT_FROM_HIBERNATE1 = 0x6,
|
||||
BOOT_FROM_HIBERNATE2 = 0x7,
|
||||
}BootFlag_e;
|
||||
*/
|
||||
/**
|
||||
\addtogroup slpman_interface_gr
|
||||
\{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
#define SLP_CALLBACK_USRDEF_MAX_NUM 8
|
||||
#define SLP_PLAT_VOTE_MAX_NUM 32
|
||||
#define SLP_PLAT_VOTE_INFO_LEN 9
|
||||
|
||||
// Flash mem for APP backup in power management-----just consider based on PS/PHY + offset(8K)
|
||||
#define APP_BACKUP_XIP_ADDR (FLASH_MEM_BACKUP_ADDR + 0x2000)
|
||||
#define APP_BACKUP_NONXIP_ADDR (FLASH_MEM_BACKUP_ADDR-FLASH_XIP_ADDR + 0x2000)
|
||||
#define APP_BACKUP_SIZE (0x1000)
|
||||
|
||||
|
||||
/**
|
||||
\brief slpManLpState, to indicate in which sleep state should we call the backup and restore function.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SLPMAN_INVALID_STATE = 0, /**< invalid deepsleep state */
|
||||
SLPMAN_SLEEP1_STATE, /**< sleep1 state */
|
||||
SLPMAN_SLEEP2_STATE, /**< sleep2 state */
|
||||
SLPMAN_HIBERNATE_STATE, /**< hibernate state */
|
||||
MAX_SLEEP_STATE,
|
||||
}slpManLpState;
|
||||
|
||||
/**
|
||||
\brief enum of sleep status for voting. we should always try to vote a higher status for power saving.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SLP_ACTIVE_STATE = 0, /**< active state */
|
||||
SLP_IDLE_STATE, /**< idle state */
|
||||
SLP_SLP1_STATE, /**< sleep1 state */
|
||||
SLP_SLP2_STATE, /**< sleep2 state */
|
||||
SLP_HIB_STATE, /**< hibernate state */
|
||||
SLP_STATE_MAX
|
||||
}slpManSlpState_t;
|
||||
|
||||
|
||||
typedef enum _EPAT_slpManWakeSrc_e_TAG
|
||||
{
|
||||
WAKEUP_FROM_POR = 0,
|
||||
WAKEUP_FROM_RTC,
|
||||
WAKEUP_FROM_PAD,
|
||||
WAKEUP_FROM_LPUART,
|
||||
WAKEUP_FROM_LPUSB,
|
||||
WAKEUP_FROM_PWRKEY,
|
||||
WAKEUP_FROM_CHARG,
|
||||
}slpManWakeSrc_e;
|
||||
|
||||
|
||||
/**
|
||||
\brief definition of backup callback(called before sleep)
|
||||
*/
|
||||
typedef void(* slpManBackupCb_t)(void *pdata, slpManLpState state);
|
||||
/**
|
||||
\brief definition of restore callback(called after sleep)
|
||||
*/
|
||||
typedef void(* slpManRestoreCb_t)(void *pdata, slpManLpState state);
|
||||
/**
|
||||
\brief definition of deepsleep timer callback function
|
||||
*/
|
||||
typedef void (*slpManUsrDeepSlpTimerCb_Func)(uint8_t id);
|
||||
/**
|
||||
\brief definition of deepsleep timer callback function
|
||||
*/
|
||||
typedef void (*slpManPmuTimingChangeCb_Func)(void);
|
||||
|
||||
typedef slpManSlpState_t (* slpUserdefSleepCb_Func)(void);
|
||||
|
||||
/**
|
||||
\brief a stucture for array to store backup function and it's parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
slpManBackupCb_t backup_func; /**< function execute before enter sleep */
|
||||
void *pdata; /**< a pointer to the input param of callback function */
|
||||
}slpManBackupCbFunc_t;
|
||||
|
||||
/**
|
||||
\brief a stucture for array to store restore function and it's parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
slpManBackupCb_t restore_func; /**< function execute after sleep is exited. When sleep2 or hibernate success the function will not execute */
|
||||
void *pdata; /**< a pointer to the input param of callback function */
|
||||
}slpManRestoreCbFunc_t;
|
||||
|
||||
/**
|
||||
\brief enum of error code used in slp manager
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RET_TRUE, /**< Error code: no error */
|
||||
RET_UNKNOW_FALSE, /**< Error code: unknow error */
|
||||
RET_CB_ARRAY_FULL, /**< Error code: callback array is full */
|
||||
RET_CALLBACK_EXIST, /**< Error code: duplicate callback in callback array */
|
||||
RET_CALLBACK_UNEXIST, /**< Error code: callback unexist */
|
||||
RET_VOTE_SLP_OVERFLOW, /**< Error code: vote overflow (above 256) */
|
||||
RET_VOTE_SLP_UNDERFLOW, /**< Error code: vote underflow (below 0) */
|
||||
RET_ZERO_NAME_LEN, /**< Error code: input name is empty */
|
||||
RET_INVALID_NAME, /**< Error code: input name has illegal character */
|
||||
RET_VOTE_HANDLE_FULL, /**< Error code: no place for more vote handle */
|
||||
RET_INVALID_HANDLE, /**< Error code: vote handle is invalid */
|
||||
RET_INVALID_VOTE, /**< Error code: the vote state is invalid */
|
||||
RET_VOTE_CONFLICT, /**< Error code: vote conflict */
|
||||
RET_GIVEBACK_FAILED, /**< Error code: vote handle give back error */
|
||||
RET_HANDLE_NOT_FOUND, /**< Error code: vote handle not found */
|
||||
}slpManRet_t;
|
||||
|
||||
/**
|
||||
\brief enum of predefined module for backup and restore functions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SLP_CALLBACK_GPR_MODULE = 0, /**< sleep callback of gpr module */
|
||||
SLP_CALLBACK_PAD_MODULE, /**< sleep callback of pad module */
|
||||
SLP_CALLBACK_DMA_MODULE, /**< sleep callback of dma module */
|
||||
SLP_CALLBACK_GPIO_MODULE, /**< sleep callback of gpio module */
|
||||
SLP_CALLBACK_LPUSART_MODULE, /**< sleep callback of lpusart module */
|
||||
SLP_CALLBACK_LPUSB_MODULE, /**< sleep callback of lpusb module */
|
||||
SLP_CALLBACK_USART_MODULE, /**< sleep callback of usart module */
|
||||
SLP_CALLBACK_SPI_MODULE, /**< sleep callback of spi module */
|
||||
SLP_CALLBACK_I2S_MODULE, /**< sleep callback of i2s module */
|
||||
SLP_CALLBACK_UNILOG_MODULE, /**< sleep callback of unilog module */
|
||||
SLP_CALLBACK_TIMER_MODULE, /**< sleep callback of timer module */
|
||||
SLP_CALLBACK_I2C_MODULE, /**< sleep callback of i2c module */
|
||||
SLP_CALLBACK_ADC_MODULE, /**< sleep callback of adc module */
|
||||
SLP_CALLBACK_SIM_MODULE, /**< sleep callback of sim module */
|
||||
SLP_CALLBACK_SCT_MODULE, /**< sleep callback of SCT module */
|
||||
SLP_CALLBACK_WDT_MODULE, /**< sleep callback of WDT module */
|
||||
SLP_CALLBACK_ALM_MODULE, /**< sleep callback of alarm module */
|
||||
SLP_CALLBACK_ULDP_MODULE, /**< sleep callback of ULDP module */
|
||||
SLP_CALLBACK_UTFC_MODULE, /**< sleep callback of UTFC module */
|
||||
SLP_CALLBACK_KPC_MODULE, /**< sleep callback of KPC module */
|
||||
SLP_CALLBACK_ATCMD_MODULE, /**< sleep callback of ATCMD module */
|
||||
SLP_CALLBACK_MAX_NUM,
|
||||
}slpCbModule_t;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
// @ 1.8V level
|
||||
IOVOLT_1_65V = 0,
|
||||
IOVOLT_1_70V,
|
||||
IOVOLT_1_75V,
|
||||
IOVOLT_1_80V,
|
||||
IOVOLT_1_85V,
|
||||
IOVOLT_1_90V,
|
||||
IOVOLT_1_95V,
|
||||
IOVOLT_2_00V,
|
||||
|
||||
// @ 2.8V level
|
||||
IOVOLT_2_65V = 8,
|
||||
IOVOLT_2_70V,
|
||||
IOVOLT_2_75V,
|
||||
IOVOLT_2_80V,
|
||||
IOVOLT_2_85V,
|
||||
IOVOLT_2_90V,
|
||||
IOVOLT_2_95V,
|
||||
IOVOLT_3_00V,
|
||||
|
||||
// @ 3.3V level
|
||||
IOVOLT_3_05V = 16,
|
||||
IOVOLT_3_10V,
|
||||
IOVOLT_3_15V,
|
||||
IOVOLT_3_20V,
|
||||
IOVOLT_3_25V,
|
||||
IOVOLT_3_30V,
|
||||
IOVOLT_3_35V,
|
||||
IOVOLT_3_40V,
|
||||
|
||||
}IOVoltageSel_t;
|
||||
|
||||
|
||||
/**
|
||||
\brief enum of predefined module for backup and restore functions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SLP_VOTE_USART = 0, /**< vote module: Usart */
|
||||
SLP_VOTE_LPUSART, /**< vote module: Lpusart */
|
||||
SLP_VOTE_LPUSB, /**< vote module: Lpusb */
|
||||
SLP_VOTE_I2C, /**< vote module: I2C */
|
||||
SLP_VOTE_SPI, /**< vote module: SPI */
|
||||
SLP_VOTE_I2S, /**< vote module: I2S */
|
||||
SLP_VOTE_ADC, /**< vote module: ADC */
|
||||
SLP_VOTE_DMA, /**< vote module: DMA */
|
||||
SLP_VOTE_TIMER, /**< vote module: Timer */
|
||||
SLP_VOTE_PWRKEY, /**< vote module: Pwrkey */
|
||||
SLP_VOTE_MAX_NUM,
|
||||
|
||||
}slpDrvVoteModule_t;
|
||||
|
||||
|
||||
/**
|
||||
\brief a stucture to store driver vote flag and vote counter.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t drv_vote_slp_bitmap; /**< vote bitmap of driver */
|
||||
uint8_t vote_counter[SLP_VOTE_MAX_NUM]; /**< vote counter */
|
||||
}slpManDrvVote_t;
|
||||
|
||||
|
||||
/**
|
||||
\brief a stucture to store platform(user defined) vote information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t plat_vote_slp1_bitmap; /**< vote bitmap of sleep1 */
|
||||
uint32_t plat_vote_slp2_bitmap; /**< vote bitmap of sleep2 */
|
||||
uint32_t plat_vote_hib_bitmap; /**< vote bitmap of hibernate */
|
||||
uint32_t plat_vote_valid; /**< valid flag of platform vote */
|
||||
uint8_t vote_counter[SLP_PLAT_VOTE_MAX_NUM]; /**< platform vote counter */
|
||||
uint8_t plat_vote_info[SLP_PLAT_VOTE_MAX_NUM][SLP_PLAT_VOTE_INFO_LEN]; /**< platform vote information */
|
||||
}slpManPlatVote_t;
|
||||
|
||||
/**
|
||||
\fn slpManRet_t slpManRegisterPredefinedBackupCb(slpCbModule_t module, slpManBackupCb_t backup_cb,
|
||||
void *pdata, slpManLpState state)
|
||||
\brief Register the predefined backup callback functions.
|
||||
\param[in] module predefined module
|
||||
\param[in] backup_cb pointer to the function of backup
|
||||
\param[in] pdata the input param of backup function
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManRegisterPredefinedBackupCb(slpCbModule_t module, slpManBackupCb_t backup_cb, void *pdata);
|
||||
/**
|
||||
\fn slpManRet_t slpManRegisterPredefinedRestoreCb(slpCbModule_t module, slpManBackupCb_t restore_cb,
|
||||
void *pdata, slpManLpState state)
|
||||
\brief Register the predefined restore callback functions.
|
||||
\param[in] module predefined module
|
||||
\param[in] restore_cb pointer to the function of restore
|
||||
\param[in] pdata the input param of restore function
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManRegisterPredefinedRestoreCb(slpCbModule_t module, slpManRestoreCb_t restore_cb, void *pdata);
|
||||
/**
|
||||
\fn slpManRet_t slpManRegisterUsrdefinedBackupCb(slpManBackupCb_t backup_cb,
|
||||
void *pdata)
|
||||
\brief Register the usrdefined backup callback functions.
|
||||
\param[in] backup_cb pointer to the function of backup
|
||||
\param[in] pdata the input param of backup function
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManRegisterUsrdefinedBackupCb(slpManBackupCb_t backup_cb, void *pdata);
|
||||
/**
|
||||
\fn slpManRet_t slpManRegisterUsrdefinedRestoreCb(slpManBackupCb_t restore_cb,
|
||||
void *pdata)
|
||||
\brief Register the usrdefined restore callback functions.
|
||||
\param[in] restore_cb pointer to the function of restore
|
||||
\param[in] pdata the input param of restore function
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManRegisterUsrdefinedRestoreCb(slpManRestoreCb_t restore_cb, void *pdata);
|
||||
/**
|
||||
\fn slpManRet_t slpManUnregisterPredefinedBackupCb(slpCbModule_t module);
|
||||
\brief Unregister the Predefined callback according to module
|
||||
\param[in] module predefined module whose callback need unregister
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManUnregisterPredefinedBackupCb(slpCbModule_t module);
|
||||
/**
|
||||
\fn slpManRet_t slpManUnregisterPredefinedRestoreCb(slpCbModule_t module);
|
||||
\brief Unregister the Predefined callback according to module
|
||||
\param[in] module predefined module whose callback need unregister
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManUnregisterPredefinedRestoreCb(slpCbModule_t module);
|
||||
/**
|
||||
\fn slpManRet_t slpManUnregisterUsrdefinedBackupCb(slpManBackupCb_t backup_cb)
|
||||
\brief Unregister the userdefined callback according to the callback function.
|
||||
\param[in] backup_cb user defined callback which need unregister
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManUnregisterUsrdefinedBackupCb(slpManBackupCb_t backup_cb);
|
||||
/**
|
||||
\fn slpManRet_t slpManUnregisterUsrdefinedRestoreCb(slpManBackupCb_t restore_cb)
|
||||
\brief Unregister the userdefined callback according to the callback function.
|
||||
\param[in] restore_cb user defined callback which need unregister
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManUnregisterUsrdefinedRestoreCb(slpManRestoreCb_t restore_cb);
|
||||
/**
|
||||
\fn void slpManSetDrvVoteMask(uint32_t mask)
|
||||
\brief driver vote mask. The vote of the driver is already done by sdk, but we can mask specific vote result.
|
||||
\param[in] mask driver vote mask to set
|
||||
\return none
|
||||
*/
|
||||
void slpManSetDrvVoteMask(uint32_t mask);
|
||||
/**
|
||||
\fn uint32_t slpManGetDrvVoteMask(void)
|
||||
\brief get driver vote mask
|
||||
\return driver vote mask
|
||||
*/
|
||||
uint32_t slpManGetDrvVoteMask(void);
|
||||
/**
|
||||
\fn void slpManGetDrvBitmap(uint32_t *bitmap, uint32_t *mask)
|
||||
\brief get the driver's vote information
|
||||
\param[out] bitmap the bitmap of vote information.
|
||||
\param[out] mask set 1 means the specific driver always alow to sleep
|
||||
\return none.
|
||||
*/
|
||||
void slpManGetDrvBitmap(uint32_t *bitmap, uint32_t *mask);
|
||||
|
||||
/**
|
||||
\fn slpManSlpState_t slpManPlatGetSlpState(void)
|
||||
\brief get which sleep state can we go now
|
||||
\return the sleep state we can go.
|
||||
*/
|
||||
slpManSlpState_t slpManPlatGetSlpState(void);
|
||||
/**
|
||||
\fn slpManWakeSrc_e slpManGetWakeupSrc(void)
|
||||
\brief get the reason of wakeup, por,rtc,pad...
|
||||
\return wakeup reason.
|
||||
*/
|
||||
slpManWakeSrc_e slpManGetWakeupSrc(void);
|
||||
/**
|
||||
\fn void slpManGetPlatBitmap(uint32_t *slp_bitmap, uint32_t *slp2_bitmap, uint32_t *hib_bitmap)
|
||||
\brief get the bitmap of vote information
|
||||
\param[in] slp_bitmap the bitmap vote to sleep state.
|
||||
\param[in] slp2_bitmap the bitmap vote to sleep2 state.
|
||||
\param[in] hib_bitmap the bitmap vote to hibernate state.
|
||||
\return none.
|
||||
*/
|
||||
void slpManGetPlatBitmap(uint32_t *slp_bitmap, uint32_t *slp2_bitmap, uint32_t *hib_bitmap);
|
||||
/**
|
||||
\fn slpManRet_t slpManApplyPlatVoteHandle(const char* name, uint8_t *handle)
|
||||
\brief apply for a vote handle.
|
||||
\param[in] name the name of the handle(max length is 8)
|
||||
\param[out] handle the handle allocate to use
|
||||
\return error code.
|
||||
*/
|
||||
slpManRet_t slpManApplyPlatVoteHandle(const char* name, uint8_t *handle);
|
||||
/**
|
||||
\fn slpManRet_t slpManGivebackPlatVoteHandle(uint8_t handle)
|
||||
\brief give back the platform vote handle
|
||||
\param[in] handle the platform vote handle.
|
||||
\return error code.
|
||||
*/
|
||||
slpManRet_t slpManGivebackPlatVoteHandle(uint8_t handle);
|
||||
/**
|
||||
\fn uint8_t *slpManGetVoteInfo(uint8_t handle)
|
||||
\brief Get Vote handle Name information according to the handle
|
||||
\param[in] handle the platform vote handle.
|
||||
\return error code.
|
||||
*/
|
||||
uint8_t *slpManGetVoteInfo(uint8_t handle);
|
||||
/**
|
||||
\fn slpManRet_t slpManPlatVoteDisableSleep(uint8_t handle, slpManSlpState_t status);
|
||||
\brief vote for keep wakeup
|
||||
\param[in] handle the platform vote handle.
|
||||
\param[in] status input the sleep status. A handle can only vote to a specific status.
|
||||
\return error code.
|
||||
*/
|
||||
slpManRet_t slpManPlatVoteDisableSleep(uint8_t handle, slpManSlpState_t status);
|
||||
/**
|
||||
\fn slpManRet_t slpManPlatVoteEnableSleep(uint8_t handle, slpManSlpState_t status);
|
||||
\brief vote for going to sleep
|
||||
\param[in] handle the platform vote handle.
|
||||
\param[in] status input the sleep status. A handle can only vote to a specific status.
|
||||
\return error code.
|
||||
*/
|
||||
slpManRet_t slpManPlatVoteEnableSleep(uint8_t handle, slpManSlpState_t status);
|
||||
/**
|
||||
\fn slpManRet_t slpManPlatVoteEnableSleep(uint8_t handle, slpManSlpState_t status);
|
||||
\brief vote for going to sleep, and force the specific handle to clear all vote counter. This API should be
|
||||
carefully use as it may force sleep without consider the vote counter
|
||||
\param[in] handle the platform vote handle.
|
||||
\param[in] status input the sleep status. A handle can only vote to a specific status.
|
||||
\return error code.
|
||||
*/
|
||||
slpManRet_t slpManPlatVoteForceEnableSleep(uint8_t handle, slpManSlpState_t status);
|
||||
/**
|
||||
\fn slpManRet_t slpManCheckVoteState(uint8_t handle, slpManSlpState_t *pstate, uint8_t *counter);
|
||||
\brief Check vote state according to the vote handle
|
||||
\param[in] handle the platform vote handle.
|
||||
\param[out] pstate output the sleep status of current handle, if return SLP_ACTIVE_STATE, means this handle is not used.
|
||||
\param[out] counter vote counter, indicate how many times the specific handle votes,
|
||||
slpManPlatVoteDisableSleep let the counter count down,
|
||||
slpManPlatVoteEnableSleep let the counter count up
|
||||
when conter = 0 the specific handle enable the sleep.
|
||||
\return error code.
|
||||
*/
|
||||
slpManRet_t slpManCheckVoteState(uint8_t handle, slpManSlpState_t *pstate, uint8_t *counter);
|
||||
/**
|
||||
\fn slpManRet_t slpManFindPlatVoteHandle(const char* name, uint8_t *handle);
|
||||
\brief Find a vote handle applied before according to the name
|
||||
\param[in] name string of handle name.
|
||||
\param[out] handle the platform vote handle.
|
||||
\return error code.
|
||||
*/
|
||||
slpManRet_t slpManFindPlatVoteHandle(const char* name, uint8_t *handle);
|
||||
/**
|
||||
\fn void slpManSetPmuSleepMode(bool pmu_enable, slpManSlpState_t mode, bool save2flash);
|
||||
\brief Disable or Enable Pmu, and set the deepest sleep mode.
|
||||
\param[in] pmu_enable when enable pmu set pmu_enable = true
|
||||
\param[in] mode valid only when pmu_enable is true.
|
||||
\param[in] save2flash set whether the settings need to flush into flash
|
||||
\return none.
|
||||
*/
|
||||
void slpManSetPmuSleepMode(bool pmu_enable, slpManSlpState_t mode, bool save2flash);
|
||||
/**
|
||||
\fn void slpManRegisterUsrSlpDepthCb(pmuUserdefSleepCb_Func callback);
|
||||
\brief register a user callback function to control sleep depth
|
||||
\param[in] callback input a callback function
|
||||
\return none.
|
||||
*/
|
||||
void slpManRegisterUsrSlpDepthCb(slpUserdefSleepCb_Func callback);
|
||||
/**
|
||||
\fn void slpManAONIOLatchEn(IOLatchEn en);
|
||||
\brief set to enable io retention during sleep, can use in bootloader
|
||||
\param[in] en enable io retention
|
||||
\return none.
|
||||
*/
|
||||
void slpManAONIOLatchEn(IOLatchEn en);
|
||||
/**
|
||||
\fn void slpManUsim1LatchEn(IOLatchEn en);
|
||||
\brief when usim1 is used some AONIO will use, ec call this api to latch usim1 IO
|
||||
\param[in] en enable io retention
|
||||
\return none.
|
||||
*/
|
||||
void slpManUsim1LatchEn(IOLatchEn en);
|
||||
|
||||
/**
|
||||
\fn IOLatchEn slpManAONIOGetLatchCfg(void);
|
||||
\brief get io latch config
|
||||
\return io latch config.
|
||||
*/
|
||||
IOLatchEn slpManAONIOGetLatchCfg(void);
|
||||
/**
|
||||
\fn void slpManAONIOPowerOn(void);
|
||||
\brief power on ldo of aonio. Call this function and than use gpio driver to config the aonio. Can use in bootloader
|
||||
\return none.
|
||||
*/
|
||||
void slpManAONIOPowerOn(void);
|
||||
/**
|
||||
\fn void slpManAONIOPowerOff(void);
|
||||
\brief power off ldo of aonio. All AonIO will switch to low because of power loss. Can use in bootloader
|
||||
\return none.
|
||||
*/
|
||||
void slpManAONIOPowerOff(void);
|
||||
|
||||
/**
|
||||
\fn slpManSlpState_t slpManGetLastSlpState(void);
|
||||
\brief check last sleep state
|
||||
\return last sleep state
|
||||
*/
|
||||
slpManSlpState_t slpManGetLastSlpState(void);
|
||||
/**
|
||||
\fn void slpManDeepSlpTimerRegisterExpCb(slpManUsrDeepSlpTimerCb_Func cb);
|
||||
\brief register user deep sleep timer expired callback
|
||||
\param[in] cb input callback function
|
||||
\return none
|
||||
*/
|
||||
void slpManDeepSlpTimerRegisterExpCb(slpManTimerID_e timerId, slpManUsrDeepSlpTimerCb_Func cb);
|
||||
/**
|
||||
\fn void slpManDeepSlpTimerStart(uint8_t timerId, uint32_t nMs);
|
||||
\brief Start a User Deep Sleep Timer
|
||||
\param[in] timerId timer id
|
||||
\param[in] nMs timer value
|
||||
\return none
|
||||
*/
|
||||
void slpManDeepSlpTimerStart(slpManTimerID_e timerId, uint32_t nMs);
|
||||
/**
|
||||
\fn bool slpManDeepSlpTimerIsRunning(uint8_t timerId);
|
||||
\brief Check whether the deep sleep timer is running
|
||||
\param[in] timerId timer id
|
||||
\return true or false
|
||||
*/
|
||||
bool slpManDeepSlpTimerIsRunning(uint8_t timerId);
|
||||
/**
|
||||
\fn void slpManDeepSlpTimerDel(uint8_t timerId);
|
||||
\brief Delete a deep sleep timer
|
||||
\param[in] timerId timer id
|
||||
\return none
|
||||
*/
|
||||
void slpManDeepSlpTimerDel(uint8_t timerId);
|
||||
/**
|
||||
\fn uint32_t slpManDeepSlpTimerRemainMs(uint8_t timerId);
|
||||
\brief Delete a deep sleep timer
|
||||
\param[in] timerId timer id
|
||||
\return millisecond to timer expired, return 0xffffffff when timerId is invalid
|
||||
*/
|
||||
uint32_t slpManDeepSlpTimerRemainMs(uint8_t timerId);
|
||||
/**
|
||||
\fn uint8_t slpManGetWakeupPinValue(void);
|
||||
\brief Get the bitmap of 6 Wakeup Pin Value, can use in bootloader
|
||||
e.g. return 0x13 = 0b010011 means wakeup pad 4, wakeup pad 1 and wakeup pad 0 is high level,
|
||||
the other wakeup pads is low level.
|
||||
return 0x3F = 0b111111 means all wakeup pads are high level.
|
||||
return 0x00 = 0b000000 means all wakeup pads are low level.
|
||||
\return a bitmap of 6 pin value
|
||||
*/
|
||||
uint8_t slpManGetWakeupPinValue(void);
|
||||
/**
|
||||
\fn void slpManUpdateUserNVMem(void);
|
||||
\brief Call this API to tell SDK that user NVMem area need update to flash.
|
||||
The Update actually happened before sleep2 or hibernate.
|
||||
\return none
|
||||
*/
|
||||
void slpManUpdateUserNVMem(void);
|
||||
/**
|
||||
\fn void slpManRestoreUsrNVMem(void)
|
||||
\brief Restore UserNVMem from FileSystem to ram
|
||||
\return none
|
||||
*/
|
||||
void slpManRestoreUsrNVMem(void);
|
||||
/**
|
||||
\fn uint8_t * slpManGetUsrNVMem(void);
|
||||
\brief Get the pointer to the header of user NVMem which has the maximum size of (2048-32)=2016e.
|
||||
User NVMem will be recovered by sdk after wakeup from sleep2, hibernate or power on.
|
||||
User can access to user NVMem freely. It's the user's responsibility to ensure the data integrity of this area.
|
||||
Illegal access to the offset larger than 4064 will cause hardfault.
|
||||
\return none
|
||||
*/
|
||||
uint8_t * slpManGetUsrNVMem(void);
|
||||
/**
|
||||
\fn void slpManFlushUsrNVMem(void);
|
||||
\brief Flush the User none volatile memory immediately to File System.
|
||||
\return none
|
||||
*/
|
||||
void slpManFlushUsrNVMem(void);
|
||||
/**
|
||||
\fn void slpManStartWaitATTimer(void);
|
||||
\brief Once Receive AT Command, can use this funtion to add a delay before sleep. The delay is slpWaitTime
|
||||
Use AT+ECPCFG="slpWaitTime",4000 to set the slpWaitTime to 4000ms
|
||||
\return none
|
||||
*/
|
||||
void slpManStartWaitATTimer(void);
|
||||
/**
|
||||
\fn void slpManWaitATTimerSet(uint16_t nMs, bool save2flash);
|
||||
\brief Set the slpWaitTime used by slpManStartWaitATTimer function.
|
||||
\param[in] nMs set slpWaitTime in micro second
|
||||
\param[in] save2flash choose whether to save slpWaitTime settings to flash or not. We suggest to save this setting, as in hib/slp2 the setting will lost
|
||||
\return none
|
||||
*/
|
||||
void slpManWaitATTimerSet(uint16_t nMs, bool save2flash);
|
||||
/**
|
||||
\fn void slpManNormalIOVoltSet(IOVoltageSel_t sel);
|
||||
\brief select normal io voltage, can use in bootloader
|
||||
\return none
|
||||
*/
|
||||
void slpManNormalIOVoltSet(IOVoltageSel_t sel);
|
||||
/**
|
||||
\fn IOVoltageSel_t slpManNormalIOVoltGet(void);
|
||||
\brief Get normal io voltage, can use in bootloader
|
||||
\return none
|
||||
*/
|
||||
IOVoltageSel_t slpManNormalIOVoltGet(void);
|
||||
|
||||
/**
|
||||
\fn IOVoltageSel_t slpManAONIOVoltGet(void);
|
||||
\brief Get normal io voltage, can use in bootloader
|
||||
\return none
|
||||
*/
|
||||
IOVoltageSel_t slpManAONIOVoltGet(void);
|
||||
/**
|
||||
\fn void slpManAONIOVoltSet(IOVoltageSel_t sel);
|
||||
\brief select aon io voltage, can use in bootloader
|
||||
\return none
|
||||
*/
|
||||
void slpManAONIOVoltSet(IOVoltageSel_t sel);
|
||||
/**
|
||||
\fn bool slpManGetIOSelPin(void);
|
||||
\brief IO 1828 Sel status read, can use in bootloader
|
||||
\return true: NC, false: GND
|
||||
*/
|
||||
bool slpManGetIOSelPin(void);
|
||||
/**
|
||||
\fn bool slpManGetChargePinValue(void);
|
||||
\brief get charge pad pin value, can use in bootloader
|
||||
\return true: floating or high false: low
|
||||
*/
|
||||
bool slpManGetChargePinValue(void);
|
||||
/**
|
||||
\fn bool slpManGetPwrkeyPinValue(void);
|
||||
\brief get pwrkey pin value, can use in bootloader
|
||||
\return true: floating or high false: low
|
||||
*/
|
||||
bool slpManGetPwrkeyPinValue(void);
|
||||
/**
|
||||
\fn void slpManNormalIoPowerCtrl(bool isPwrOn);
|
||||
\brief set normal io power on/off
|
||||
\return none
|
||||
*/
|
||||
void slpManNormalIoPowerCtrl(bool isPwrOn);
|
||||
/**
|
||||
\fn void slpManSavePmuTimingCfg(pmuTimeCfg_t *cfg);
|
||||
\brief Set Pmu Timing configure if presleep/postsleep callback takes too much time
|
||||
\param[in] cfg new configure
|
||||
\return none
|
||||
*/
|
||||
void slpManSavePmuTimingCfg(pmuTimeCfg_t *cfg);
|
||||
/**
|
||||
\fn void slpManGetCurrentPmuTimingCfg(pmuTimeCfg_t *cfg);
|
||||
\brief Get current Pmu Timing configure for changing and set back by calling slpManSetPmuTimingCfg
|
||||
\param[out] cfg current configure
|
||||
\return none
|
||||
*/
|
||||
void slpManGetCurrentPmuTimingCfg(pmuTimeCfg_t *cfg);
|
||||
/**
|
||||
\fn uint32_t slpManGetEstimateSlpTime(void)
|
||||
\brief Get estimated sleep time, used in userdefined backup callback.
|
||||
The actual sleep time may be a little bit shorter(less than 100ms)
|
||||
\return slpTime in ms
|
||||
*/
|
||||
uint32_t slpManGetEstimateSlpTime(void);
|
||||
/**
|
||||
\fn void slpManAPPSetAONFlag1(bool flag);
|
||||
\brief One bit flag for app to use, valid in all sleep mode
|
||||
when wakeup from hib/sleep2/sleep1, it is still the value before sleep
|
||||
\param[in] flag one bit flag for app use
|
||||
\return none
|
||||
*/
|
||||
void slpManAPPSetAONFlag1(bool flag);
|
||||
/**
|
||||
\fn bool slpManAPPGetAONFlag1(void);
|
||||
\brief Get one bit flag set by slpManAPPSetAONFlag1
|
||||
\return flag
|
||||
*/
|
||||
bool slpManAPPGetAONFlag1(void);
|
||||
/**
|
||||
\fn void slpManAPPSetAONFlag2(bool flag);
|
||||
\brief One bit flag for app to use, valid in all sleep mode
|
||||
when wakeup from hib/sleep2/sleep1, it is still the value before sleep
|
||||
\param[in] flag one bit flag for app use
|
||||
\return none
|
||||
*/
|
||||
void slpManAPPSetAONFlag2(bool flag);
|
||||
/**
|
||||
\fn bool slpManAPPGetAONFlag2(void);
|
||||
\brief Get one bit flag set by slpManAPPSetAONFlag2
|
||||
\return flag
|
||||
*/
|
||||
bool slpManAPPGetAONFlag2(void);
|
||||
|
||||
|
||||
bool slpManExtIntPreProcess(uint8_t bitmap);
|
||||
/**
|
||||
\fn uint8_t slpManExcutePredefinedBackupCb(slpManLpState state)
|
||||
\brief Excute the predefined backup function.
|
||||
\param[in] state input the state of current sleep process
|
||||
\return how many callback have been excute.
|
||||
*/
|
||||
uint8_t slpManExcutePredefinedBackupCb(slpManLpState state);
|
||||
/**
|
||||
\fn uint8_t slpManExcutePredefinedRestoreCb(slpManLpState state)
|
||||
\brief Excute the predefined restore function.
|
||||
\param[in] state input the state of current sleep process
|
||||
\return how many callback have been excute.
|
||||
*/
|
||||
uint8_t slpManExcutePredefinedRestoreCb(slpManLpState state);
|
||||
/**
|
||||
\fn uint8_t slpManExcuteUsrdefinedBackupCb(slpManLpState state)
|
||||
\brief Excute the user defined backup function.
|
||||
\param[in] state input the state of current sleep process
|
||||
\return how many callback have been excute.
|
||||
*/
|
||||
uint8_t slpManExcuteUsrdefinedBackupCb(slpManLpState state);
|
||||
/**
|
||||
\fn uint8_t slpManExcuteUsrdefinedRerstoreCb(slpManLpState state)
|
||||
\brief Excute the user defined restore function.
|
||||
\param[in] state input the state of current sleep process
|
||||
\return how many callback have been excute.
|
||||
*/
|
||||
uint8_t slpManExcuteUsrdefinedRestoreCb(slpManLpState state);
|
||||
/**
|
||||
\fn slpManRet_t slpManDrvVoteSleep(slpDrvVoteModule_t module, slpManSlpState_t status)
|
||||
\brief drivers vote to sleep.
|
||||
\param[in] module input the vote module.
|
||||
\param[in] status input the sleep status, user should try to vote to the deepest state.
|
||||
\return error code
|
||||
*/
|
||||
slpManRet_t slpManDrvVoteSleep(slpDrvVoteModule_t module, slpManSlpState_t status);
|
||||
|
||||
/**
|
||||
\fn void slpManProductionTest(uint8_t mode)
|
||||
\brief for current test for sleep mode in production line only
|
||||
\param[in] mode SLEEP1 = 0,
|
||||
SLEEP2 = 1,
|
||||
HIBERNATE1 = 2,
|
||||
HIBERNATE2 = 3,
|
||||
OFF = 4
|
||||
\return none
|
||||
*/
|
||||
void slpManProductionTest(uint8_t mode);
|
||||
/**
|
||||
\fn uint32_t slpManGetWakeupSlowCnt(void)
|
||||
\brief Get wakeup slow cnt
|
||||
\return wakeup slow cnt
|
||||
*/
|
||||
uint32_t slpManGetWakeupSlowCnt(void);
|
||||
/**
|
||||
\fn uint32_t slpManGetCurSlowCnt(void)
|
||||
\brief Get current slow cnt
|
||||
\return current slow cnt
|
||||
*/
|
||||
uint32_t slpManGetCurSlowCnt(void);
|
||||
/**
|
||||
\fn uint32_t slpManGetSleepTime(void)
|
||||
\brief Get sleep time
|
||||
\return sleep time
|
||||
*/
|
||||
uint32_t slpManGetSleepTime(void);
|
||||
/**
|
||||
\fn void slpManStartPowerOff(void)
|
||||
\brief call this api to enter off state
|
||||
\return null
|
||||
*/
|
||||
void slpManStartPowerOff(void);
|
||||
/**
|
||||
\fn void slpManAonWdtFeed(void)
|
||||
\brief Feed Aon Watch dog
|
||||
\return null
|
||||
*/
|
||||
void slpManAonWdtFeed(void);
|
||||
/**
|
||||
\fn void slpManAonWdtStop(void)
|
||||
\brief aon watchdog is always open when system start,
|
||||
but you can stop aon watch dog through this api
|
||||
\return null
|
||||
*/
|
||||
void slpManAonWdtStop(void);
|
||||
/**
|
||||
\fn void slpManGetRawFlashEraseCnt(void *flashCntAry)
|
||||
\brief get pmu raw flash erase cnt
|
||||
\return null
|
||||
*/
|
||||
void slpManGetRawFlashEraseCnt(void *flashCntAry);
|
||||
/**
|
||||
\fn slpManRet_t slpManRegisterPmuTimingCb(slpManPmuTimingChangeCb_Func timingCb)
|
||||
\brief add a pmu timing change callback
|
||||
\return null
|
||||
*/
|
||||
slpManRet_t slpManRegisterPmuTimingCb(slpManPmuTimingChangeCb_Func timingCb);
|
||||
/**
|
||||
\fn slpManRet_t slpManUnregisterPmuTimingCb(slpManPmuTimingChangeCb_Func timingCb)
|
||||
\brief delete a pmutiming change callback
|
||||
\return null
|
||||
*/
|
||||
slpManRet_t slpManUnregisterPmuTimingCb(slpManPmuTimingChangeCb_Func timingCb);
|
||||
/**
|
||||
\fn void slpManPmuTimingChangedReq(void)
|
||||
\brief indicate pmu timing may change
|
||||
\return null
|
||||
*/
|
||||
void slpManPmuTimingChangedReq(void);
|
||||
/**
|
||||
\fn void slpManGetCPVoteStatus(bool *cpSleeped, uint8_t *cpVote)
|
||||
\brief get cp vote and sleep status
|
||||
\return null
|
||||
*/
|
||||
void slpManGetCPVoteStatus(bool *cpSleeped, uint8_t *cpVote);
|
||||
/**
|
||||
\fn bool slpManGetCPWakeupFlag(void)
|
||||
\brief 1: ap is wakeup for cp, 0: ap is wakeup by itself
|
||||
\return null
|
||||
*/
|
||||
bool slpManGetCPWakeupFlag(void);
|
||||
/**
|
||||
\fn bool slpManIsLocalTimePrecise(void)
|
||||
\brief whether the system time is sync to network
|
||||
\return null
|
||||
*/
|
||||
bool slpManIsLocalTimePrecise(void);
|
||||
/**
|
||||
* @brief slpManGet6P25HZGlobalCnt
|
||||
* @details A global count, to indicate how many second from power on till now, in 6.25HZ
|
||||
* @param null
|
||||
* @return global count in 6.25HZ
|
||||
* @note
|
||||
*/
|
||||
uint32_t slpManGet6P25HZGlobalCnt(void);
|
||||
/**
|
||||
* @brief void slpManSetSleepLimitTime(bool slpLimitEn, uint32_t slpLimitTime)
|
||||
* @details to limit the maximum sleep time.
|
||||
In cfun0 state only, it always wakeup to application. Other wise it may keep in paging flow when cp time is shorter
|
||||
* @param slpLimitEn: enable sleep time limit. slpLimitTime: sleep time in ms
|
||||
* @return null
|
||||
* @note
|
||||
*/
|
||||
void slpManSetSleepLimitTime(bool slpLimitEn, uint32_t slpLimitTime);
|
||||
|
||||
|
||||
/** \} */
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
#ifndef TIME_TRANSLATE_H
|
||||
#define TIME_TRANSLATE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SC_FREQ_32K=0,
|
||||
SC_FREQ_2048=1,
|
||||
SC_FREQ_100=2,
|
||||
SC_FREQ_32000,
|
||||
SC_FREQ_XXK,
|
||||
// other possiable value
|
||||
|
||||
}ScFreq;
|
||||
|
||||
uint32_t SlowCounterToSysTick(uint32_t scCntValue, ScFreq freq);
|
||||
uint32_t SlowCounterToMs(uint32_t scCntValue, ScFreq freq);
|
||||
uint32_t SysTickToSlowCounter(uint32_t ticks, ScFreq freq);
|
||||
uint32_t SlowCounterTo8HzCounter(uint32_t delta_sc_value, ScFreq freq, uint32_t *remain, bool need_compensate);
|
||||
void SlowCounter32KTSave(uint32_t freq);
|
||||
uint32_t SlowCounter32KTFreqGet(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,494 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef ULDP_H
|
||||
#define ULDP_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "ec618.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*DEFINE ULDP return code*/
|
||||
|
||||
#define ULDP_RET_OK (0)
|
||||
#define ULDP_RET_ALREADY_EN (-1)
|
||||
#define ULDP_PARA_ERROR (-2)
|
||||
#define ULDP_NOT_INIT (-3)
|
||||
#define ULDP_RET_FAIL (-4)
|
||||
|
||||
|
||||
#define MAX_OEP_NUM 14
|
||||
|
||||
|
||||
#define ULDP_REG_BASE 0x40070000
|
||||
//#define USBC_REG_BASE 0x1A000000
|
||||
|
||||
//#define USBC_GRXSTSP_ADDR (USBC_REG_BASE+0x20)
|
||||
|
||||
//#define USBC_RXFIFO_BASE_ADDR (USBC_REG_BASE+0x1000)
|
||||
|
||||
#define DEST_BUFF_BASE_ADDR 0x00400000
|
||||
|
||||
|
||||
|
||||
#define RING_BUF_SIZE (0x2000)
|
||||
|
||||
#define PT_TEST_DATA_SIZE 0x20
|
||||
|
||||
|
||||
|
||||
/*5 USB devices
|
||||
VCOM1: OUT=EP1 IN=EP2
|
||||
VCOM2: OUT=EP2 IN=EP4
|
||||
VCOM3: OUT=EP3 IN=EP6
|
||||
VCOM4: OUT=EP4 IN=EP8
|
||||
VCOM5: OUT=EP5 IN=EP10
|
||||
|
||||
|
||||
RNDIS simulation use COM1, RX EP NUM=1 SCT TX EP NUM=2
|
||||
AT use COM2, RX EP NUM=2,SCT TX EP NUM=4
|
||||
UNILOG use COM3 RX EP NUM=3 TX EP=6
|
||||
PPP use COM4 ,RX EP NUM=4 SCT TX EP NUM=8
|
||||
|
||||
TXFIFO NUM should be same as EP NUM
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define ULDP_HDR_MAGIC 0x5B8E
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// temp define here, should be a common define for ALL EP according to usage
|
||||
typedef enum
|
||||
{
|
||||
USB_RX_EP_0= 0,
|
||||
USB_RX_EP_1,
|
||||
USB_RX_EP_2,
|
||||
USB_RX_EP_3,
|
||||
USB_RX_EP_4,
|
||||
USB_RX_EP_5,
|
||||
USB_RX_EP_6,
|
||||
USB_RX_EP_7,
|
||||
USB_RX_EP_8,
|
||||
USB_RX_EP_9,
|
||||
USB_RX_EP_10,
|
||||
USB_RX_EP_11,
|
||||
USB_RX_EP_12,
|
||||
USB_RX_EP_13,
|
||||
USB_RX_EP_SW=USB_RX_EP_13,
|
||||
USB_RX_EP_MAX
|
||||
} UsbRxEpNum_e;
|
||||
|
||||
|
||||
|
||||
// epn process mode
|
||||
typedef enum
|
||||
{
|
||||
EPN_DATA_PROCESS_MODE_PT=0,
|
||||
EPN_DATA_PROCESS_MODE_EXTRACT,
|
||||
EPN_DATA_PROCESS_MODE_MAX
|
||||
} UldpEPnMode_e;
|
||||
|
||||
|
||||
|
||||
// pt mode input data endian(byte order)
|
||||
typedef enum
|
||||
{
|
||||
PT_MODE_RXDATA_LITTLE_ENDIAN=0,//default
|
||||
PT_MODE_RXDATA_BIG_ENDIAN,
|
||||
PT_MODE_RXDATA_ENDIAN_MAX
|
||||
} UldpPTRxEndian_e;
|
||||
|
||||
|
||||
|
||||
//CRC method select
|
||||
typedef enum
|
||||
{
|
||||
CRC_METHOD_RNDIS=0,//default
|
||||
CRC_METHOD_PPP,
|
||||
CRC_METHOD_COMMON,
|
||||
CRC_METHOD_MAX
|
||||
} UldpCrcMethod_e;
|
||||
|
||||
|
||||
//RNDIS/PPP rx data(input to ULDP) endian(byte order)
|
||||
typedef enum
|
||||
{
|
||||
RNDIS_PPP_RXDATA_BYTE_ORDER_NO_CHANGE=0,//default
|
||||
RNDIS_PPP_RXDATA_BYTE_ORDER_CHANGE,
|
||||
RNDIS_PPP_RXDATA_BYTE_ORDER_MAX
|
||||
} UldpRdsPppRxByteOrder_e;
|
||||
|
||||
|
||||
//uldp work mode
|
||||
typedef enum
|
||||
{
|
||||
ULDP_RNDIS_MODE=0,
|
||||
ULDP_PPP_MODE=1,
|
||||
ULDP_PASS_THROUGH_MODE=2
|
||||
}UldpWorkMode_e;
|
||||
|
||||
|
||||
//rndis crc byte cnt
|
||||
typedef enum
|
||||
{
|
||||
RNDIS_CRC_1_BYTE=0,//default
|
||||
RNDIS_CRC_2_BYTE,
|
||||
RNDIS_CRC_3_BYTE,
|
||||
RNDIS_CRC_4_BYTE,
|
||||
RNDIS_CRC_BYTE_MAX
|
||||
}UldpRdsCrcByteCnt_e;
|
||||
|
||||
|
||||
//rndis input byte bit swap
|
||||
typedef enum
|
||||
{
|
||||
RNDIS_INBYTE_FROM_BIT7=0,
|
||||
RNDIS_INBYTE_FROM_BIT0,//default
|
||||
RNDIS_INBYTE_MAX
|
||||
}UldpRdsInByteBitSwap_e;
|
||||
|
||||
|
||||
//rndis CRC output bit swap
|
||||
typedef enum
|
||||
{
|
||||
RNDIS_CRC_OUT_BIT_NO_SWAP=0,
|
||||
RNDIS_CRC_OUT_BIT_SWAP,//default
|
||||
RNDIS_CRC_OUT_BIT_SWAP_MAX
|
||||
}UldpRdsCrcOutBitSwap_e;
|
||||
|
||||
|
||||
//rndis CRC output bit complement
|
||||
typedef enum
|
||||
{
|
||||
RNDIS_CRC_OUT_BIT_NO_COMPLE=0,
|
||||
RNDIS_CRC_OUT_BIT_COMPLE,//default
|
||||
RNDIS_CRC_OUT_BIT_COMPLE_MAX
|
||||
}UldpRdsCrcOutBitComple_e;
|
||||
|
||||
|
||||
|
||||
//ppp input byte bit swap
|
||||
typedef enum
|
||||
{
|
||||
PPP_INBYTE_FROM_BIT7=0,//default
|
||||
PPP_INBYTE_FROM_BIT0,
|
||||
PPP_INBYTE_MAX
|
||||
}UldpPppInByteBitSwap_e;
|
||||
|
||||
|
||||
|
||||
//common CRC output bit swap
|
||||
typedef enum
|
||||
{
|
||||
COMMON_CRC_OUT_BIT_NO_SWAP=0,
|
||||
COMMON_CRC_OUT_BIT_SWAP,//default
|
||||
COMMON_CRC_OUT_BIT_SWAP_MAX
|
||||
}UldpComCrcOutBitSwap_e;
|
||||
|
||||
|
||||
//common input byte bit swap
|
||||
typedef enum
|
||||
{
|
||||
COMMON_INBYTE_FROM_BIT7=0,//default
|
||||
COMMON_INBYTE_FROM_BIT0,
|
||||
COMMON_INBYTE_MAX
|
||||
}UldpComInByteBitSwap_e;
|
||||
|
||||
//common CRC output bit complement
|
||||
typedef enum
|
||||
{
|
||||
COMMON_CRC_OUT_BIT_NO_COMPLE=0,//default
|
||||
COMMON_CRC_OUT_BIT_COMPLE,
|
||||
COMMON_CRC_OUT_BIT_COMPLE_MAX
|
||||
}UldpComCrcOutBitComple_e;
|
||||
|
||||
//common crc byte cnt
|
||||
typedef enum
|
||||
{
|
||||
COMMON_CRC_1_BYTE=0,//default
|
||||
COMMON_CRC_2_BYTE,
|
||||
COMMON_CRC_3_BYTE,
|
||||
COMMON_CRC_4_BYTE,
|
||||
COMMON_CRC_BYTE_MAX
|
||||
}UldpComCrcByteCnt_e;
|
||||
|
||||
|
||||
|
||||
typedef struct UldpHdrInfo
|
||||
{
|
||||
|
||||
uint32_t magicNum : 16; /* magic number use as a flag */
|
||||
uint32_t descpInvalidDataNum : 8; /* PPP de-escape invalid data number*/
|
||||
uint32_t resv24to31 : 8; /* reserve 8 bits */
|
||||
|
||||
uint32_t crcValue; /* crc value caculated by ULDP, SW may use it */
|
||||
|
||||
uint32_t msgLen: 16; /* byte counter only for data , no need to 4 bytes aligned */
|
||||
uint32_t isRdsPppCmpl: 1; /* whether current RNDIS (PPP)packets in the transfer is complete 1-cmpl*/
|
||||
uint32_t crcResult: 1; /* whether crc checking result is correct 1-correct*/
|
||||
uint32_t resv18to23: 6; /* reserve 6 bits*/
|
||||
uint32_t isPppHasInvalidData: 1; /* whether PPP has invalid data when de-escape 1-ppp has invalid data*/
|
||||
uint32_t firstNoStartFlagPppPkt: 1; /* first PPP packet without 7E at the begainning*/
|
||||
uint32_t resv26to27: 2; /* reserve 2 bits*/
|
||||
uint32_t errRndisMsgType: 1; /* whether RNDIS message type is error, should be 0x1 1-error*/
|
||||
uint32_t errRndisMsgLen: 1; /* whether RNDIS message length is error, should be >MinLen configured < MaxLen configured 1-error*/
|
||||
uint32_t errRndisDataLen: 1; /* whether RNDIS data len is error,dataOffset+((dataLen+3)/4)*4 > msgLen 1-error*/
|
||||
uint32_t errRndisMsgOfst: 1; /* whether RNDIS data offset is error, dataOffset should >=8 and 4 Bytes aligned, 1-error*/
|
||||
}UldpHdrInfo_t; // 3*4=12 bytes
|
||||
|
||||
|
||||
|
||||
// typedef of register 'uldp_err_int_info'
|
||||
typedef struct {
|
||||
|
||||
uint8_t uldpMode;// set uldp to PPP/RNIDS/PT(pass through)
|
||||
uint8_t uldpHdrLen;//ULDP header len, should be 0 when PT mode, and should set to uldphdr(hw fill)+dlpduhdr(sw)
|
||||
uint8_t crcEn; // CRC enable
|
||||
uint8_t crcMethodSel;// PPP/RNDNIS/COMMON(defined by user)
|
||||
|
||||
|
||||
//PT mode
|
||||
uint8_t ptModeByteOrder;// only for PT mode ,0-- default little endian 1--big endian
|
||||
|
||||
//PPP mode
|
||||
uint32_t pppInDataEndian;//0--default fetch RX data as little endian 1--fetch RX data as big endian
|
||||
uint32_t pppCrcInitVal;//CRC init value,default 0xffff
|
||||
uint32_t pppCrcFinalVal;//CRC expected final value, used to match with CRC result,default 0xf0b8
|
||||
uint32_t pppInByteSwap;// 0--default CRC from in data[7], 1--CRC from in data[0]
|
||||
uint32_t pppSpecData; // special match data pattern, should be "+++"
|
||||
|
||||
//RNDIS mode
|
||||
uint32_t rndisMinLen;// min valid RNDIS length
|
||||
uint32_t rndisInByteOrder;//0--default not change RX data byte order 1-- change RX data byte order
|
||||
uint32_t rndisMaxLen;//RNDIS max length, if received length exceed this value, trigger int
|
||||
uint32_t rndisCrcInitVal;//RNDIS init CRC value
|
||||
uint32_t rndisCrcByteCnt;//0--1 byte 1--2 bytes 2--3 bytes 3--4 bytes, also for common CRC!!!!
|
||||
uint32_t rndisInDataSwap;//1--default crc from in data[0] 0---crc from in data[7]
|
||||
uint32_t rndisCrcInCompleCnt;//how many bytes should be ~ ,should be 4 and default is 4
|
||||
uint32_t rndisOutBitSwap;// swap bit in CRC result
|
||||
uint32_t rndisCrcBitComple;//0--CRC bit not ~ 1--default CRC bit ~
|
||||
|
||||
//common crc
|
||||
uint32_t comCrcPoly;// Poly to direct how to do CRC
|
||||
uint32_t comCrcInitVal;//CRC init value
|
||||
uint32_t comCrcOutBitSwap;//CRC result bit swap
|
||||
uint32_t comCrcInByteSwap; //0--default CRC from in data[7], 1--CRC from in data[0]
|
||||
uint32_t comCrcOutComple;//0--default CRC reuslt not ~ 1--CRC reuslt ~
|
||||
uint32_t comCrcInCompleCnt;//how many bytes shold be ~
|
||||
uint32_t comCrcBitCnt;//0--8 bits 1-- 16 bits 2--24 bits 3--32 bits
|
||||
|
||||
} UldpCfgInfo_t;
|
||||
|
||||
typedef void (*uldpCallback_t)(uint8_t epNum, uint32_t xferCnt,uint32_t event);
|
||||
|
||||
// typedef of uldp galobal info
|
||||
typedef struct {
|
||||
|
||||
uint8_t isUldpEnabled;// whether uldp is enbaled
|
||||
uldpCallback_t uldpCallback;
|
||||
|
||||
} UldpCtrl_t;
|
||||
|
||||
|
||||
/****** ULDP Event *****/
|
||||
#define ULDP_EVENT_XFER_COMPLETE (1UL << 0) ///< current ULDP transfer is complete
|
||||
#define ULDP_EVENT_PPP_SPECIAL_MATCH (1UL << 1) ///< current ULDP trasnfer is complete and last 3 bytes match special pattern,only for PPP OEP
|
||||
#define ULDP_EVENT_BUF_NOT_AVLB (1UL << 2) ///< buffer is not enough
|
||||
#define ULDP_EVENT_RNDIS_LEN_ERROR (1UL << 3) ///< RNDIS length is not correct
|
||||
#define ULDP_EVENT_USB_STATUS_ERROR (1UL << 4) ///< USB fatal error, receive invalid rx status
|
||||
#define ULDP_EVENT_AHB_ADDR_ERROR (1UL << 5) ///< USB AHB access error, sw bug
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\fn uldpInit(uldpCallback_t callback)
|
||||
\brief used by USB driver, called when USBC init.
|
||||
\param[in] callback pointer to ULDP int callback function
|
||||
\note called when usb init, ULDP global and static configure
|
||||
*/
|
||||
int32_t uldpInit(uldpCallback_t callback);
|
||||
|
||||
|
||||
/**
|
||||
\fn uldpDinit( void )
|
||||
\brief used by USB driver, called when USBC deinit.
|
||||
\note called when usb init, ULDP global and static configure
|
||||
*/
|
||||
int32_t uldpDinit( void );
|
||||
|
||||
|
||||
/**
|
||||
\fn uldpCfgDataProc(UldpCfgInfo_t * pUldpCfg,UsbRxEpNum_e epNum)
|
||||
\brief used by USB driver, called before enable next RX.
|
||||
\param[in] pUldpCfg pointer to the configuration set by user
|
||||
\param[in] epNum out endpoint number
|
||||
\note 2 level configure for the ULDP process
|
||||
1st level, ep configure pass through or data extract mode
|
||||
2nd level: ep select data extract mode, configure PPP/RDNIS
|
||||
select a need CRC method.
|
||||
*/
|
||||
int32_t uldpCfgDataProc(UldpCfgInfo_t * pUldpCfg,UsbRxEpNum_e epNum);
|
||||
|
||||
|
||||
/**
|
||||
\fn uldpCfgRxEpStaticPara(UsbRxEpNum_e epNum, uint32_t bufAddr,uint32_t buflen)
|
||||
\brief static ep rx buffer configure, only need in case of ringbuf change e.g. BNA triggered
|
||||
\param[in] epNum out endpoint number
|
||||
\param[in] bufAddr buffer start address, should be 4 bytes aligned
|
||||
\param[in] buflen buffer total length, should be 4 bytes aligned
|
||||
\note called during init stage or BNA triggered stage
|
||||
*/
|
||||
int32_t uldpCfgRxEpStaticPara(UsbRxEpNum_e epNum, uint32_t bufAddr,uint32_t buflen);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t uldpCfgRxEpPara(UsbRxEpNum_e epNum, uint8_t needUpdIdx, uint32_t idx,uint32_t avlbSize)
|
||||
\brief used by USB driver, called before enable next RX.
|
||||
\param[in] epNum out endpoint num
|
||||
\param[in] needUpdIdx whether need to update rx index
|
||||
\param[in] idx index which need tobe configured
|
||||
\param[in] avlbSize avlbSize which need tobe configured
|
||||
\note dynamic configure when transfer complete,called by USB driver
|
||||
*/
|
||||
int32_t uldpCfgRxEpPara(UsbRxEpNum_e epNum, uint8_t needUpdIdx, uint32_t idx,uint32_t avlbSize);
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t uldpEpBufInfoGet(uint8_t * para)
|
||||
\brief used to get epn ringbuf current idx and avlbSize
|
||||
\param[in] epNum out endpoint num
|
||||
\param[in] pointer of idx used to return idx read from register
|
||||
\param[in] pointer of avlbSize used to return avlbSize read from register
|
||||
\return int32_t
|
||||
\note idx and avlbSize is updated automaticly by ULDP HW when receive data from USB FIFO
|
||||
*/
|
||||
int32_t uldpEpBufInfoGet(UsbRxEpNum_e epNum, uint32_t * idx, uint32_t *avlbSize);
|
||||
|
||||
|
||||
/**
|
||||
\fn uldpCfgSwEpSrcPara(uint8_t * srcAddr, uint16_t * len)
|
||||
\brief ram2ram mode source data setting
|
||||
\param[in] srcAddr pointer to source address
|
||||
\param[in] len data length which need tobe processed by ULDP
|
||||
\note called when source data is prepared
|
||||
*/
|
||||
int32_t uldpCfgSwEpSrcPara(uint8_t * srcAddr, uint16_t len);
|
||||
|
||||
|
||||
/**
|
||||
\fn uldpCfgSwEpSrcPara(uint8_t * srcAddr, uint16_t * len)
|
||||
\brief ram2ram mode source data setting
|
||||
\param[in] srcAddr pointer to source address
|
||||
\param[in] len data length which need tobe processed by ULDP
|
||||
\note called when source data is prepared
|
||||
*/
|
||||
void uldpStartSwEp( void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn uldpSetPppDescpBmTbl(uint8_t* bmTblPtr,uint8_t offset,uint8_t len)
|
||||
\brief used to configure the PPP de-escape bitmap table.
|
||||
\param[in] bmTblPtr pointer to the table to be set ,should be uint32_t pointer
|
||||
\param[in] offset the location to start set
|
||||
\param[in] len actual set length(32bits*length)
|
||||
\note called by PPP module when PPP neigoation. should be set per 32bits,
|
||||
since ULDP register is 32bits. Offset indicates which 32bits to set,
|
||||
offset=0 means set from the 1st register
|
||||
*/
|
||||
void uldpSetPppDescpBmTbl(uint32_t* bmTblPtr,uint8_t offset,uint8_t len);
|
||||
|
||||
|
||||
/**
|
||||
\fn int32_t uldpResume( void )
|
||||
\brief used to resume ULDP after blocked by BNA error.
|
||||
*/
|
||||
void uldpResume( void );
|
||||
|
||||
/**
|
||||
\fn uldpReset( void )
|
||||
\brief called when need to reset ULDP.
|
||||
\note called when need to reset ULDP.
|
||||
*/
|
||||
void uldpReset( void );
|
||||
|
||||
|
||||
/**
|
||||
\fn void uldpPppSpecDataSet(uint8_t * para)
|
||||
\brief used to set PPP specical matching data, most case it should be "+++".
|
||||
\param[in] para pointer to specical parameter need to be set
|
||||
\return void
|
||||
\note called when PPP initialized
|
||||
*/
|
||||
void uldpPppSpecDataSet(uint8_t * para);
|
||||
|
||||
/**
|
||||
\fn uldpSetSetupAddr( uint32_t addr )
|
||||
\brief used to set setup recv buffer addr.
|
||||
\note called when need to reset ULDP.
|
||||
*/
|
||||
void uldpSetSetupAddr( uint32_t addr );
|
||||
|
||||
/**
|
||||
\fn uldpRdsPppClr( void )
|
||||
\brief called when need to clear ULDP RNDIS/PPP state.
|
||||
\note called when need to clear ULDP RNDIS/PPP state.
|
||||
*/
|
||||
void uldpRdsPppClr( void );
|
||||
|
||||
|
||||
/**
|
||||
\fn uldpUsbEp0RecvHandle( void )
|
||||
\brief used to handle EP0 recv data in polling mode
|
||||
\return void
|
||||
\note called only in EEh dump
|
||||
*/
|
||||
int32_t uldpUsbEp0RecvHandle( void );
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef __USB_BL_API_H__
|
||||
#define __USB_BL_API_H__
|
||||
|
||||
#define VCOM_DBGEN
|
||||
|
||||
#ifdef VCOM_DBGEN
|
||||
void vcomdbg_hex(uint32_t hex);
|
||||
void vcomdbg_str(uint8_t* str);
|
||||
void vcomdbg_str_and_hex(uint8_t* str, uint32_t hex);
|
||||
|
||||
#define VCDBG_STR(str) vcomdbg_str((uint8_t*)str)
|
||||
#define VCDBG_STR_AND_HEX(str, hex) vcomdbg_str_and_hex((uint8_t*)str, hex)
|
||||
#else
|
||||
void vcomdbg_hex(uint32_t hex);
|
||||
void vcomdbg_str(uint8_t* str);
|
||||
void vcomdbg_str_and_hex(uint8_t* str, uint32_t hex);
|
||||
#define VCDBG_STR(str)
|
||||
#define VCDBG_STR_AND_HEX(str, hex)
|
||||
#endif
|
||||
|
||||
|
||||
#define ERR_DEV_BASE (-200)
|
||||
#define ERR_DEV_NUM_REDEF(err) (ERR_DEV_BASE + err)
|
||||
#define ERR_DEV_NO_CONNECT ERR_DEV_NUM_REDEF(-2)
|
||||
#define ERR_DEV_RX_TIMOUT ERR_DEV_NUM_REDEF(-32)
|
||||
#define ERR_DEV_TX_TIMOUT ERR_DEV_NUM_REDEF(-33)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
#ifndef __USB_EXT_INC_H__
|
||||
#define __USB_EXT_INC_H__
|
||||
uint8_t usblpw_retwkup_stack_restore(void);
|
||||
void usblpw_retwkup_stack_enable(void);
|
||||
|
||||
|
||||
//Important, do not modify this macro
|
||||
#define USBC_CTRL_HIB_LITE_MODE 1
|
||||
|
||||
#if (USBC_CTRL_HIB_LITE_MODE==1)
|
||||
|
||||
#define USB_WKMON_TASK_EXIST 0
|
||||
#else
|
||||
#define USB_WKMON_TASK_EXIST 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t usblpw_is_retwkups2_start(void);
|
||||
uint8_t usblpw_is_retothwks2_start(void);
|
||||
|
||||
typedef enum {
|
||||
usblpw_retothwk_stg_none =0,
|
||||
usblpw_retothwk_stg_bt_pre_idle,
|
||||
usblpw_retothwk_stg_bt_later_idle,
|
||||
usblpw_retothwk_stg_bt_actv,
|
||||
usblpw_retothwk_stg_hibslp2_wkmon,
|
||||
usblpw_retothwk_stg_slp1_wkmon,
|
||||
usblpw_retothwk_stg_succ,
|
||||
usblpw_retothwk_stg_teminate,
|
||||
}usblpw_retothwk_stg_type;
|
||||
|
||||
|
||||
|
||||
uint8_t usblpw_retothwk_set_bt_pre_idle_stage(void);
|
||||
uint8_t usblpw_retothwk_set_bt_later_idle_stage(void);
|
||||
uint8_t usblpw_retothwk_set_bt_actv_stage(void);
|
||||
uint8_t usblpw_retothwk_set_hibslp2_wkmon_stage(void);
|
||||
uint8_t usblpw_retothwk_set_slp1_wkmon_stage(void);
|
||||
uint8_t usblpw_retothwk_set_terminate_stage(void);
|
||||
uint8_t usblpw_retothwk_set_succ_stage(void);
|
||||
|
||||
void usblpw_clear_retothwk_proc_stat(void);
|
||||
|
||||
uint8_t usblpw_get_retothwk_stage(void);
|
||||
|
||||
usblpw_retothwk_stg_type usblpw_retothwk_get_cur_stg(void);
|
||||
|
||||
uint8_t usblpw_retothwk_cur_stg_none(void);
|
||||
uint8_t usblpw_retothwk_cur_stg_bt_pre_idle(void);
|
||||
uint8_t usblpw_retothwk_cur_stg_bt_later_idle(void);
|
||||
uint8_t usblpw_retothwk_cur_stg_bt_actv(void);
|
||||
uint8_t usblpw_retothwk_cur_stg_hibslp2_wkmon(void);
|
||||
uint8_t usblpw_retothwk_cur_stg_slp1_wkmon(void);
|
||||
|
||||
uint8_t usblpw_retothwk_cur_stg_terminate(void);
|
||||
uint8_t usblpw_retothwk_cur_stg_success(void);
|
||||
|
||||
|
||||
#if (USBC_CTRL_HIB_LITE_MODE==0)
|
||||
|
||||
void usblpw_retothwk_set_pre_rest_illegal(uint8_t stage);
|
||||
uint8_t usblpw_retothwk_pre_rest_chk_illegal(uint8_t stage);
|
||||
uint8_t usblpw_retothwk_poll_gpwr_match(uint8_t stage);
|
||||
|
||||
uint8_t usblpw_retothwk_chk_pre_rest_worth(void);
|
||||
uint8_t usblpw_retothwk_try_pre_restore(uint8_t stage);
|
||||
|
||||
uint8_t usblpw_retothwk_stackrest_chk_illegal(uint8_t stage);
|
||||
void usblpw_retothwk_set_stack_rest_illegal(uint8_t stage);
|
||||
void usblpw_retothwk_set_stack_rest_fail(uint8_t stage);
|
||||
|
||||
uint8_t usblpw_retwkup_slp1_stack_restore(void);
|
||||
|
||||
uint8_t usblpw_retothwk_hibslp2_stack_restore(uint8_t stage);
|
||||
uint8_t usblpw_retothwk_hibslp2_try_stack_rest(uint8_t stage);
|
||||
uint8_t usblpw_retothwk_slp1_try_stack_rest(uint8_t stage);
|
||||
|
||||
uint8_t usblpw_retothwk_bt_pre_idle_stage_proc(void);
|
||||
|
||||
uint8_t usblpw_retothwk_hibslp2_bt_later_idle_stage_proc(void);
|
||||
uint8_t usblpw_retothwk_slp1_bt_later_idle_stage_proc(void);
|
||||
|
||||
uint8_t usblpw_retothwk_hibslp2_bt_actv_stage_proc(void);
|
||||
uint8_t usblpw_retothwk_slp1_bt_actv_stage_proc(void);
|
||||
|
||||
|
||||
|
||||
uint8_t usblpw_retothwk_wkmon_idle_to_actv_proc(void);
|
||||
|
||||
uint8_t usblpw_retothwk_hibslp2_wkmon_actv_proc(void);
|
||||
uint8_t usblpw_retothwk_slp1_wkmon_actv_proc(void);
|
||||
|
||||
uint8_t usblpw_retothwk_wkmon_actv_proc(void);
|
||||
|
||||
|
||||
uint8_t usblpw_get_retothwk_proc_stat(void);
|
||||
uint8_t usblpw_retothwk_cur_proc_stat_gpwr_umatch(void);
|
||||
|
||||
void usblpw_retothwk_clear_errinfo(void);
|
||||
|
||||
int usb_wkmon_pre_init(void);
|
||||
int usb_wkmon_cmmon_clear(void);
|
||||
void usb_wkmon_task_init(void);
|
||||
|
||||
int usb_wkmon_hibslp2_stat_evt_start(void);
|
||||
int usb_wkmon_slp1_stat_evt_start(void);
|
||||
|
||||
extern void usblpw_wkmon_ll_enter_ctx_clear(void);
|
||||
extern uint8_t usblpw_wkmon_ll_enter_ctx_get(void);
|
||||
extern void usblpw_enter_wkmon_chk_abort_ll_inirq(void);
|
||||
|
||||
extern void usblpw_wkmon_lpusbwkup_flag_clear(void);
|
||||
extern void usblpw_wkmon_lpusbwkup_flag_set(void);
|
||||
extern uint8_t usblpw_wkmon_lpusbwkup_flag_get(void);
|
||||
#endif
|
||||
|
||||
#if (USBC_CTRL_HIB_LITE_MODE==1)
|
||||
uint8_t usblpw_retothwk_hibslp2_stack_restore(uint8_t stage);
|
||||
#endif
|
||||
|
||||
void usblpw_enable_lpusbwkup_src(void);
|
||||
uint32_t usblpw_clear_lpusbwkup_src(void);
|
||||
|
||||
|
||||
|
||||
uint8_t usbstack_init(void);
|
||||
uint8_t usbstack_deinit(void);
|
||||
|
||||
void usblpw_get_pwr_info(uint8_t* p_pwr_state, uint8_t* p_boot_stat, uint8_t* p_last_wkup);
|
||||
uint8_t usblpw_is_retwkup_support(void);
|
||||
|
||||
|
||||
void usbc_trace_cfg(uint32_t usb_sw_trace);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef __USB_PORTMON_H__
|
||||
#define __USB_PORTMON_H__
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef __USB_WKMON_H__
|
||||
#define __USB_WKMON_H__
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef __USBC_BASIC_DEF_H__
|
||||
#define __USBC_BASIC_DEF_H__
|
||||
|
||||
#include "sctdef.h"
|
||||
|
||||
#define USBC_CTRL_CORE_BASE_ADDR 0x1A000000
|
||||
#define USBC_MAX_EP_UNUM (1+12)
|
||||
#define USBC_GRXSTSP_ADDR (USBC_CTRL_CORE_BASE_ADDR+0x20)
|
||||
|
||||
//ALIGN TO USBC_CTRL_DATA_FIFO_OFFSET
|
||||
#define USBC_FIFO_BASE_ADDR (USBC_CTRL_CORE_BASE_ADDR+0x1000)
|
||||
|
||||
|
||||
#define MAX_EP_IN_NUM USBC_MAX_EP_UNUM
|
||||
#define MAX_EP_OUT_NUM USBC_MAX_EP_UNUM
|
||||
|
||||
typedef struct usb_setup_req {
|
||||
|
||||
uint8_t bmRequest;
|
||||
uint8_t bRequest;
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
} usb_setup_req_st;
|
||||
|
||||
|
||||
typedef enum {
|
||||
EPOUT_TYPE = 0,
|
||||
EPIN_TYPE =1,
|
||||
EP_MAX_TYPE = 2
|
||||
}USBC_EP_TYPE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t func_idx :4; /* usb func idx */
|
||||
uint16_t cls_type :4; /* cls type */
|
||||
uint16_t bulk_epin_valid :1;
|
||||
uint16_t bulk_epout_valid :1;
|
||||
uint16_t int_epin_valid :1;
|
||||
uint16_t resv_0 :1;
|
||||
uint16_t bulk_epin_idx :4;
|
||||
uint16_t bulk_epout_idx :4;
|
||||
uint16_t int_epin_idx :4;
|
||||
uint16_t resv_1 :8;
|
||||
}usbd_locmap_elem_st;
|
||||
typedef struct
|
||||
{
|
||||
uint8_t func_elem_arr_cnt;
|
||||
uint8_t epout_func_idx_arr_cnt;
|
||||
usbd_locmap_elem_st *p_func_elem_arr;
|
||||
uint8_t * p_epout_func_idx_arr;
|
||||
}usbd_locmap_para_st;
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
#ifndef __USBD_CDC_H__
|
||||
#define __USBD_CDC_H__
|
||||
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "usbd_desc_def.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t bitrate;
|
||||
uint8_t format;
|
||||
uint8_t paritytype;
|
||||
uint8_t datatype;
|
||||
}line_coding_st;
|
||||
|
||||
|
||||
//cdc class descriptor
|
||||
struct tag_usb_cdc_header_desc {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bcdCDC_Low;
|
||||
uint8_t bcdCDC_High;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct tag_usb_cdc_call_mgmt_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bmCapabilities;
|
||||
uint8_t bDataInterface;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct tag_usb_cdc_acm_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bmCapabilities;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct tag_usb_cdc_union_desc {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bMasterInterface0;
|
||||
uint8_t bSlaveInterface0;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct tag_usb_cdc_ether_desc {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t iMacAddr;
|
||||
uint32_t bmEthStat; //statis tic
|
||||
uint16_t wMaxSegSz;
|
||||
uint16_t wNumMCFilters;
|
||||
uint8_t bNumPwrFilters;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct tag_usb_cdc_notification {
|
||||
uint8_t bmReqType;
|
||||
uint8_t bNotifyType;
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
typedef struct tag_usb_cdc_header_desc usb_cdc_header_desc_st;
|
||||
typedef struct tag_usb_cdc_call_mgmt_descriptor usb_cdc_call_mgmt_descriptor_st;
|
||||
typedef struct tag_usb_cdc_acm_descriptor usb_cdc_acm_descriptor_st;
|
||||
typedef struct tag_usb_cdc_union_desc usb_cdc_union_desc_st;
|
||||
|
||||
typedef struct tag_usb_cdc_ether_desc usb_cdc_ether_desc_st;
|
||||
|
||||
typedef struct tag_usb_cdc_notification usb_cdc_notification_st;
|
||||
struct tag_usbd_cdc_desc
|
||||
{
|
||||
usb_config_desc_st cfg_desc;
|
||||
|
||||
usb_intf_assoc_desc_st intf_asso_desc;
|
||||
|
||||
usb_interface_descriptor_st intf_ctrl_desc;
|
||||
usb_cdc_header_desc_st cdc_head_desc;
|
||||
usb_cdc_call_mgmt_descriptor_st cdc_callmgr_desc;
|
||||
usb_cdc_acm_descriptor_st cdc_acm_desc;
|
||||
usb_cdc_union_desc_st cdc_union_desc;
|
||||
usb_endpoint_descriptor_st cdc_cmd_ep_desc;
|
||||
|
||||
usb_interface_descriptor_st intf_data_desc;
|
||||
usb_endpoint_descriptor_st cdc_doep_desc;
|
||||
usb_endpoint_descriptor_st cdc_diep_desc;
|
||||
|
||||
}__attribute__ ((packed));
|
||||
|
||||
typedef struct tag_usbd_cdc_desc usbd_cdc_desc_st;
|
||||
|
||||
|
||||
struct tag_usbd_cdc_ccinst_desc_inhrnt
|
||||
{
|
||||
usb_intf_assoc_desc_st intf_asso_desc;
|
||||
|
||||
usb_interface_descriptor_st intf_ctrl_desc;
|
||||
usb_cdc_header_desc_st cdc_head_desc;
|
||||
usb_cdc_call_mgmt_descriptor_st cdc_callmgr_desc;
|
||||
usb_cdc_acm_descriptor_st cdc_acm_desc;
|
||||
usb_cdc_union_desc_st cdc_union_desc;
|
||||
usb_endpoint_descriptor_st cdc_cmd_ep_desc;
|
||||
|
||||
usb_interface_descriptor_st intf_data_desc;
|
||||
usb_endpoint_descriptor_st cdc_doep_desc;
|
||||
usb_endpoint_descriptor_st cdc_diep_desc;
|
||||
|
||||
}__attribute__ ((packed));
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef __USBD_CDC_CUSTQUEC_H__
|
||||
#define __USBD_CDC_CUSTQUEC_H__
|
||||
|
||||
//#include "usbd_conf.h"
|
||||
#include "usbd_desc_def.h"
|
||||
//#include "usbd_function.h"
|
||||
//#include "usbd_clsdev.h"
|
||||
|
||||
|
||||
#define USBD_CDC_QUEC_TP1 1
|
||||
#define USBD_CDC_QUEC_TP2 2
|
||||
|
||||
|
||||
#define CDC_QUEC_ASSO_SUPP 0
|
||||
|
||||
struct tag_usbd_cdc_desc_custp1
|
||||
{
|
||||
usb_interface_descriptor_st intf_ctrl_desc;
|
||||
usb_endpoint_descriptor_st cdc_doep_desc;
|
||||
usb_endpoint_descriptor_st cdc_diep_desc;
|
||||
|
||||
}__attribute__ ((packed));
|
||||
|
||||
|
||||
struct tag_usbd_cdc_desc_custp2
|
||||
{
|
||||
usb_interface_descriptor_st intf_ctrl_desc;
|
||||
usb_cdc_header_desc_st cdc_head_desc;
|
||||
usb_cdc_call_mgmt_descriptor_st cdc_callmgr_desc;
|
||||
usb_cdc_acm_descriptor_st cdc_acm_desc;
|
||||
usb_cdc_union_desc_st cdc_union_desc;
|
||||
usb_endpoint_descriptor_st cdc_cmd_ep_desc;
|
||||
usb_endpoint_descriptor_st cdc_diep_desc;
|
||||
usb_endpoint_descriptor_st cdc_doep_desc;
|
||||
}__attribute__ ((packed));
|
||||
|
||||
#ifndef EPIN_MARK_DIR
|
||||
#define EPIN_MARK_DIR(FUNC_EP) ((FUNC_EP)|0x80)
|
||||
#endif
|
||||
|
||||
typedef struct tag_usbd_cdc_desc_custp1 usbd_cdc_desc_custp1_st;
|
||||
typedef struct tag_usbd_cdc_desc_custp2 usbd_cdc_desc_custp2_st;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef __USBD_DESC_DEF_H__
|
||||
#define __USBD_DESC_DEF_H__
|
||||
|
||||
struct tag_usb_config_desc
|
||||
{
|
||||
uint8_t bLength; //config desc size
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t wTotalLength_Low; // wTotalLength
|
||||
uint8_t wTotalLength_High; // wTotalLength
|
||||
uint8_t bNumInterfaces;
|
||||
uint8_t bConfigurationValue;
|
||||
uint8_t iConfiguration;
|
||||
uint8_t bmAttributes;
|
||||
uint8_t bMaxPower;
|
||||
}__attribute__ ((packed));
|
||||
|
||||
struct tag_usb_intf_assoc_desc {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
uint8_t bFirstInterface;
|
||||
uint8_t bInterfaceCount;
|
||||
uint8_t bFunctionClass;
|
||||
uint8_t bFunctionSubClass;
|
||||
uint8_t bFunctionProtocol;
|
||||
uint8_t iFunction;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct tag_usb_interface_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
uint8_t bInterfaceNumber;
|
||||
uint8_t bAlternateSetting;
|
||||
uint8_t bNumEndpoints;
|
||||
uint8_t bInterfaceClass;
|
||||
uint8_t bInterfaceSubClass;
|
||||
uint8_t bInterfaceProtocol;
|
||||
uint8_t iInterface;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct tag_usb_endpoint_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmAttributes;
|
||||
uint8_t wMaxPacketSize_Low;
|
||||
uint8_t wMaxPacketSize_High;
|
||||
uint8_t bInterval;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
typedef struct tag_usb_config_desc usb_config_desc_st;
|
||||
typedef struct tag_usb_intf_assoc_desc usb_intf_assoc_desc_st;
|
||||
typedef struct tag_usb_interface_descriptor usb_interface_descriptor_st;
|
||||
typedef struct tag_usb_endpoint_descriptor usb_endpoint_descriptor_st;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,113 @@
|
||||
#ifndef __USBD_ERRINFO_H__
|
||||
#define __USBD_ERRINFO_H__
|
||||
|
||||
typedef enum
|
||||
{
|
||||
usb_ctrl_mod = 0x10,
|
||||
|
||||
usb_lpwmod = 0x20,
|
||||
|
||||
usb_func_vcom_mod = 0x100,
|
||||
usb_func_ecm_mod ,
|
||||
usb_func_rndis_mod ,
|
||||
usb_dev_vcom_mod,
|
||||
usb_dev_ecm_mod ,
|
||||
usb_dev_rndis_mod ,
|
||||
usb_mdev_lib_mod,
|
||||
|
||||
usb_user_base_mod = 0x1000,
|
||||
usb_ccinst_inhrnt_mod ,
|
||||
}usb_stat_mod_type;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
usbc_ctrl_fifo_cfg_err = 110,
|
||||
usbc_ctrl_fifo_retwkup_cfg_err,
|
||||
usbpcd_deinit_terminate_err,
|
||||
usbpcd_deinit_bsp_err,
|
||||
|
||||
|
||||
mdev_lib_load_reset_err = 180,
|
||||
mdev_lib_load_init_err,
|
||||
|
||||
mdev_lib_load_upd_err,
|
||||
mdev_lib_load_end_err,
|
||||
mdev_lib_load_stat_err,
|
||||
mdev_lib_load_cnt_err,
|
||||
mdev_lib_bind_upd_err,
|
||||
|
||||
mdev_lib_init_start_ptr_nul_err = 190,
|
||||
mdev_lib_init_fin_ptr_nul_err,
|
||||
mdev_lib_init_func_bind_err,
|
||||
mdev_lib_init_clstype_bind_err,
|
||||
|
||||
|
||||
mdev_lib_cust_ptr_nul_err =210,
|
||||
mdev_lib_devnm_nul_err,
|
||||
mdev_lib_elem_cnt_err,
|
||||
mdev_lib_elem_swap_err,
|
||||
mdev_lib_map_residx_err,
|
||||
mdev_lib_func_nul_err,
|
||||
mdev_lib_cls_nul_err,
|
||||
mdev_lib_clsbase_nul_err,
|
||||
|
||||
|
||||
mdev_lib_ccinfo_map_err,
|
||||
mdev_lib_ccinst_nul_err,
|
||||
mdev_lib_ccset_nul_err,
|
||||
|
||||
mdev_cls_deinit_terminate_start_err = 230,
|
||||
mdev_cls_deinit_terminate_finish_err,
|
||||
mdev_cls_deinit_unbind_err,
|
||||
|
||||
|
||||
func_bind_flag_err = 240,
|
||||
func_data_null_err,
|
||||
func_malloc_fail_err,
|
||||
func_intf_cnt_err,
|
||||
func_intf_id_err,
|
||||
func_oep_id_err,
|
||||
func_iep_id_err,
|
||||
func_cmdep_id_err,
|
||||
|
||||
func_buf_type_err,
|
||||
|
||||
func_txbuf_null_err,
|
||||
func_rxbuf_null_err,
|
||||
func_terminate_initstat_err,
|
||||
|
||||
func_ccinst_bind_fail_err,
|
||||
func_ccinst_invalid_err,
|
||||
func_ccinst_maintp_err,
|
||||
func_ccinst_desc_ass_err,
|
||||
func_ccinst_desc_parse_err,
|
||||
func_inst_id_err ,
|
||||
func_str_id_err,
|
||||
|
||||
func_set_strdesc_err,
|
||||
|
||||
desc_parse_err_base = 280,
|
||||
desc_parse_err_tpinvalid,
|
||||
desc_parse_err_ass0,
|
||||
desc_parse_err_len0,
|
||||
desc_parse_err_len_ovf,
|
||||
desc_parse_err_epdesclen,
|
||||
|
||||
desc_parse_err_epdescptr_1,
|
||||
desc_parse_err_epdescptr_2,
|
||||
desc_parse_err_intfdesclen,
|
||||
desc_parse_err_parserslt,
|
||||
|
||||
usblpw_retothwk_pre_rest_illegal = 0x300,
|
||||
usblpw_retothwk_pre_rest_fail,
|
||||
usblpw_retothwk_gpwr_match_fail,
|
||||
usblpw_retothwk_stack_rest_illeagl,
|
||||
usblpw_retothwk_stack_rest_fail,
|
||||
}usb_mod_err_type;
|
||||
|
||||
void usbd_set_mod_last_err(uint16_t mod, uint16_t err_no);
|
||||
uint32_t usbd_get_mod_last_err(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
#ifndef __USBD_FUNC_CC_H__
|
||||
#define __USBD_FUNC_CC_H__
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ccinst_setting_mainttp_none = 0,
|
||||
ccinst_setting_cdc_vcom_maintp = 1,
|
||||
}ccinst_setting_maintype;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ccinst_setting_subtp_none = 0,
|
||||
ccinst_setting_vcom_subtp0_inhrnt =1,
|
||||
ccinst_setting_vcom_subtp1_2ep,
|
||||
ccinst_setting_vcom_subtp2_3ep,
|
||||
}ccinst_setting_subtype;
|
||||
|
||||
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
|
||||
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
|
||||
#define USB_STRING_DESCRIPTOR_TYPE 0x03
|
||||
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
|
||||
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
|
||||
|
||||
#define STANDARD_ENDPOINT_DESC_SIZE 0x07
|
||||
|
||||
|
||||
struct tag_usb_func_ccinst;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *p_desc_buff_ptr;
|
||||
uint16_t desc_buff_size;
|
||||
|
||||
uint8_t b_intf_ctrl_desc_upd: 1;
|
||||
uint8_t rsv: 7;
|
||||
uint8_t bInterfaceClass;
|
||||
uint8_t bInterfaceSubClass;
|
||||
uint8_t bInterfaceProtocol;
|
||||
}ccinst_desc_call_data_st;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t intf_str_id;
|
||||
|
||||
uint8_t ep_ctrl_num : 4;
|
||||
uint8_t ep_datain_num: 4;
|
||||
uint8_t ep_dataout_num: 4;
|
||||
|
||||
uint8_t interface_cnt:4;
|
||||
uint8_t intf_base_idx: 4;
|
||||
uint8_t intf_1st_idx :4;
|
||||
uint8_t intf_2nd_idx:4;
|
||||
uint8_t rsv:4;
|
||||
|
||||
}ccinst_bind_call_data_st;
|
||||
|
||||
|
||||
typedef struct tag_ccinst_setting_base
|
||||
{
|
||||
ccinst_setting_maintype setting_maintp;
|
||||
ccinst_setting_subtype setting_subtp;
|
||||
}ccinst_setting_base_st;
|
||||
|
||||
|
||||
typedef struct tag_ccinst_cdc_setting
|
||||
{
|
||||
ccinst_setting_base_st bs_set;
|
||||
uint8_t map_flag : 1;
|
||||
uint8_t desc_assigned : 1;
|
||||
uint8_t desc_parsed : 1;
|
||||
uint8_t binded :1;
|
||||
uint8_t epctrl_valid : 1;
|
||||
uint8_t epout_valid : 1;
|
||||
uint8_t epin_valid: 1;
|
||||
uint8_t rsv_1: 2;
|
||||
|
||||
uint8_t interface_cnt:4;
|
||||
uint8_t rsv_2:4;
|
||||
|
||||
uint8_t ep_ctrl_num : 4;
|
||||
uint8_t ep_datain_num: 4;
|
||||
uint8_t ep_dataout_num: 4;
|
||||
uint8_t intf_base_idx: 4;
|
||||
|
||||
uint8_t intf_1st_idx :4;
|
||||
uint8_t intf_2nd_idx:4;
|
||||
|
||||
uint8_t intf_str_id;
|
||||
|
||||
uint16_t desc_src_size;
|
||||
|
||||
usb_endpoint_descriptor_st * p_epctrl_d;
|
||||
usb_endpoint_descriptor_st * p_epin_d;
|
||||
usb_endpoint_descriptor_st * p_epout_d;
|
||||
const uint8_t *p_desc_src;
|
||||
|
||||
}ccinst_cdc_setting_st;
|
||||
|
||||
struct tag_usb_func_ccinst;
|
||||
|
||||
|
||||
typedef uint8_t (*pfn_func_ccinst_desc_ass)(struct tag_usb_func_ccinst *p_func_ccinst);
|
||||
typedef uint8_t (*pfn_func_ccinst_desc_parse)(struct tag_usb_func_ccinst *p_func_ccinst);
|
||||
typedef uint8_t (*pfn_func_ccinst_bind)(struct tag_usb_func_ccinst *p_func_ccinst, ccinst_bind_call_data_st *p_bind_call_data);
|
||||
|
||||
typedef void (*pfn_func_ccinst_reset)(struct tag_usb_func_ccinst *p_func_ccinst, uint8_t speed);
|
||||
typedef uint8_t (*pfn_func_ccinst_init)(struct tag_usb_func_ccinst *p_func_ccinst, uint8_t cfgidx);
|
||||
typedef uint8_t (* pfn_func_ccinst_deinit)(struct tag_usb_func_ccinst *p_func_ccinst, uint8_t cfgidx);
|
||||
typedef uint8_t (* pfn_func_ccinst_get_desc)(struct tag_usb_func_ccinst *p_func_ccinst, ccinst_desc_call_data_st* p_desc_call_data);
|
||||
typedef uint8_t (*pfn_func_ccisnt_unbind)(struct tag_usb_func_ccinst *p_func_ccinst);
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct tag_usb_func_ccinst
|
||||
{
|
||||
void * p_cc_setting;
|
||||
pfn_func_ccinst_desc_ass func_desc_ass;
|
||||
pfn_func_ccinst_desc_parse func_desc_parse;
|
||||
pfn_func_ccinst_bind func_bind;
|
||||
pfn_func_ccinst_get_desc func_get_desc;
|
||||
|
||||
pfn_func_ccinst_get_desc func_get_othspd_desc;
|
||||
|
||||
pfn_func_ccinst_init func_init;
|
||||
pfn_func_ccinst_deinit func_deinit;
|
||||
pfn_func_ccisnt_unbind func_unbind;
|
||||
|
||||
#if 0
|
||||
pfn_func_setup func_setup;
|
||||
pfn_func_ep0_din_stage_comp func_ep0_din_stage_comp;
|
||||
pfn_func_ep0_dout_stage_comp func_ep0_dout_stage_comp;
|
||||
|
||||
pfn_func_data_in_proc func_data_in_proc;
|
||||
pfn_func_data_out_proc func_data_out_proc;
|
||||
pfn_func_sof_proc func_sof_proc;
|
||||
|
||||
pfn_func_desc_get_ptr func_desc_get_ptr;
|
||||
pfn_func_desc_get_size func_desc_get_size;
|
||||
pfn_func_desc_get_othcfg_ptr func_desc_get_othcfg_ptr;
|
||||
pfn_func_desc_get_othcfg_size func_desc_get_othcfg_size;
|
||||
pfn_func_desc_get_intf_num func_desc_get_intf_num;
|
||||
pfn_func_desc_get_clstype func_desc_get_clstype;
|
||||
pfn_func_desc_get_cfginfo func_desc_get_cfginfo;
|
||||
#endif
|
||||
}usb_func_ccinst_st;
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef __FUNC_VCOM_CONF_H__
|
||||
#define __FUNC_VCOM_CONF_H__
|
||||
|
||||
|
||||
//#include "usbc_ctrl_config.h"
|
||||
|
||||
|
||||
#define USBD_CFG_MAX_NUM 1
|
||||
|
||||
|
||||
#define CDC_DATA_MAX_PACKET_SIZE 512
|
||||
|
||||
|
||||
|
||||
#define CDC_IN_FRAME_INTERVAL 40
|
||||
|
||||
#ifndef USE_USBC_CTRL_HS
|
||||
#define USE_USBC_CTRL_HS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef __USBD_MACRO_DEF_H__
|
||||
#define __USBD_MACRO_DEF_H__
|
||||
#ifndef INVALID_EP_NUM
|
||||
#define INVALID_EP_NUM 0xff
|
||||
#endif
|
||||
|
||||
#ifndef INVALID_INTF_NUM
|
||||
#define INVALID_INTF_NUM 0xff
|
||||
#endif
|
||||
|
||||
#ifndef INVALID_FUNC_NUM
|
||||
//#define INVALID_FUNC_NUM 0xff
|
||||
#endif
|
||||
|
||||
|
||||
#define USBC_CTRL_EP_CONTROL 0
|
||||
#define USBC_CTRL_EP_ISOC 1
|
||||
#define USBC_CTRL_EP_BULK 2
|
||||
#define USBC_CTRL_EP_INTR 3
|
||||
|
||||
|
||||
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
|
||||
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
|
||||
#define USB_STRING_DESCRIPTOR_TYPE 0x03
|
||||
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
|
||||
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
|
||||
|
||||
#define STANDARD_INTERFACE_DESC_SIZE 0x09
|
||||
#define STANDARD_ENDPOINT_DESC_SIZE 0x07
|
||||
|
||||
#ifndef LOBYTE
|
||||
#define LOBYTE(x) ((uint8_t)(x & 0x00FF))
|
||||
#endif
|
||||
|
||||
#ifndef HIBYTE
|
||||
#define HIBYTE(x) ((uint8_t)((x & 0xFF00) >>8))
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
usbd_ret_no_err = 0,
|
||||
usbd_ret_busy,
|
||||
usbd_ret_fail,
|
||||
}usbd_ret_type;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef __USBD_MULTI_CLSTYPE_H__
|
||||
#define __USBD_MULTI_CLSTYPE_H__
|
||||
|
||||
typedef enum
|
||||
{
|
||||
multidev_tp_none = 0,
|
||||
multidev_tp_rndis = 1,
|
||||
multidev_tp_ecm,
|
||||
multidev_tp_vcom_at,
|
||||
multidev_tp_vcom_log,
|
||||
multidev_tp_vcom_ppp,
|
||||
multidev_tp_vcom_com,
|
||||
}multidev_cls_type;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef __USBD_MULTI_EXTMSG_H__
|
||||
#define __USBD_MULTI_EXTMSG_H__
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MULTIDEV_EXT_MSG_NONE = 0,
|
||||
MULTIDEV_EXT_NTF_REQ = 1,
|
||||
}multidev_extmsg_type;
|
||||
|
||||
struct tag_multidev_ext_msg
|
||||
{
|
||||
uint8_t multidev_load_idx;
|
||||
uint8_t dev_cls_type;
|
||||
|
||||
uint16_t msgtype;
|
||||
uint16_t msg_len;
|
||||
uint8_t *p_msg;
|
||||
uint8_t mid_para_valid; // for internal usage
|
||||
void * p_mid_para; // for internal usage
|
||||
} __attribute__ ((packed));
|
||||
|
||||
typedef struct tag_multidev_ext_msg multidev_ext_msg_st;
|
||||
|
||||
|
||||
int usbd_multi_lib_dev_extmsg(multidev_ext_msg_st *p_ext_msg);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
#ifndef __USBD_MULTI_USRCFG_H__
|
||||
#define __USBD_MULTI_USRCFG_H__
|
||||
|
||||
#include "usbd_multi_clstype.h"
|
||||
#include "usbd_errinfo.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* USB CUSTOM MULTIDEV CFG MACRO DEFINE *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define VCOM_CCINST_ORG_CASE 0
|
||||
#define VCOM_CCINST_CUST_CASE 1
|
||||
|
||||
#define VCOM_CCINST_CASE_SEL VCOM_CCINST_ORG_CASE
|
||||
//#define VCOM_CCINST_CASE_SEL VCOM_CCINST_CUST_CASE
|
||||
|
||||
#if (VCOM_CCINST_CASE_SEL==VCOM_CCINST_ORG_CASE)
|
||||
#define VCOM_CCINST_SUBTP0_INHERENT_CNT 4
|
||||
#define VCOM_CCINST_SUBTP1_2EP_CNT 0
|
||||
#define VCOM_CCINST_SUBTP2_3EP_CNT 0
|
||||
#endif
|
||||
|
||||
#if (VCOM_CCINST_CASE_SEL==VCOM_CCINST_CUST_CASE)
|
||||
#define VCOM_CCINST_SUBTP0_INHERENT_CNT 0
|
||||
#define VCOM_CCINST_SUBTP1_2EP_CNT 1
|
||||
#define VCOM_CCINST_SUBTP2_3EP_CNT 2
|
||||
#endif
|
||||
|
||||
#define VCOM_CCINST_TOTAL_CNT (VCOM_CCINST_SUBTP0_INHERENT_CNT+ \
|
||||
VCOM_CCINST_SUBTP1_2EP_CNT + \
|
||||
VCOM_CCINST_SUBTP2_3EP_CNT)
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* USB CUSTOM MULTIDEV CFG DESCRIPTOR *
|
||||
*----------------------------------------------------------------------------*/
|
||||
struct tag_usbcust_md_intf_assoc_desc {
|
||||
uint8_t bFunctionClass;
|
||||
uint8_t bFunctionSubClass;
|
||||
uint8_t bFunctionProtocol;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
struct tag_usbcust_md_interface_descriptor
|
||||
{
|
||||
uint8_t bInterfaceClass;
|
||||
uint8_t bInterfaceSubClass;
|
||||
uint8_t bInterfaceProtocol;
|
||||
}__attribute__ ((packed));
|
||||
|
||||
|
||||
typedef struct tag_usbcust_md_intf_assoc_desc ucmd_intf_assoc_desc_st;
|
||||
typedef struct tag_usbcust_md_interface_descriptor ucmd_interface_descriptor_st;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//md renamed to mdcd md call data
|
||||
|
||||
typedef struct {
|
||||
uint8_t cls_type;
|
||||
uint8_t inst_id;
|
||||
uint8_t *p_func_name;
|
||||
uint8_t string_id;
|
||||
uint8_t valid;
|
||||
uint8_t * p_str;
|
||||
}usbcust_mdcd_strdesc_st;
|
||||
|
||||
struct tag_usbcust_cmndesc_data{
|
||||
//uint8_t b_intf_asso_desc_upd: 1;
|
||||
uint8_t b_intf_ctrl_desc_upd: 1;
|
||||
//uint8_t b_intf_data_desc_upd: 1;
|
||||
uint8_t rsv: 7;
|
||||
|
||||
//ucmd_intf_assoc_desc_st intf_asso_desc;
|
||||
ucmd_interface_descriptor_st intf_ctrl_desc;
|
||||
//ucmd_interface_descriptor_st intf_data_desc;
|
||||
}__attribute__ ((packed));
|
||||
|
||||
typedef struct tag_usbcust_cmndesc_data usbcust_cmndesc_data_st;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t cls_type;
|
||||
uint8_t inst_id;
|
||||
uint8_t *p_func_name;
|
||||
usbcust_cmndesc_data_st t_cmndesc_data;
|
||||
}usbcust_mdcd_cmndesc_st;
|
||||
|
||||
typedef struct {
|
||||
uint8_t cls_type;
|
||||
uint8_t inst_id;
|
||||
uint8_t *p_func_name;
|
||||
ccinst_setting_maintype setting_maintp;
|
||||
ccinst_setting_subtype setting_subtp;
|
||||
usb_func_ccinst_st *p_func_ccinst;
|
||||
}usbcust_mdcd_ccinfo_st;
|
||||
|
||||
typedef struct {
|
||||
uint32_t cmd; //Bit 31 : 0 host to dev, 1 dev to host
|
||||
uint8_t* buf;
|
||||
uint32_t len;
|
||||
}usbcust_mdctl_req_st;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t cls_type;
|
||||
uint8_t inst_id;
|
||||
uint8_t func_idx;
|
||||
|
||||
uint8_t *p_func_name;
|
||||
usbcust_mdctl_req_st t_ctl_req;
|
||||
}usbcust_md_ctrl_st;
|
||||
|
||||
typedef struct {
|
||||
uint8_t cls_type;
|
||||
uint8_t inst_id;
|
||||
uint8_t *p_func_name;
|
||||
}usbcust_md_cb_paradef_st;
|
||||
|
||||
|
||||
|
||||
|
||||
#define USBD_DEV_NAME_LEN_MAX 10
|
||||
#define MULTI_DEV_RESOURCE_NUM 6
|
||||
|
||||
|
||||
#define MULTI_DEV_CNT_MAX 6
|
||||
#define MULTI_DEV_LOADCNT_MAX (MULTI_DEV_CNT_MAX-1)
|
||||
|
||||
#define MULTI_DEV_LOAD_NONE 0
|
||||
#define MULTI_DEV_LOAD_RESET 1
|
||||
#define MULTI_DEV_LOAD_UPDATED 2
|
||||
#define MULTI_DEV_LOAD_END_SUC 3
|
||||
|
||||
#define MULTI_DEV_LOAD_BIND_SUC 4
|
||||
|
||||
|
||||
//cust concrete type
|
||||
#define MULTI_DEV_CUST_CC_TYPE_NONE 0
|
||||
|
||||
typedef struct {
|
||||
const uint8_t* p_dev_name;
|
||||
multidev_cls_type cls_type;
|
||||
ccinst_setting_maintype setting_maintp;
|
||||
ccinst_setting_subtype setting_subtp;
|
||||
}multidev_custom_element;
|
||||
|
||||
typedef struct {
|
||||
uint8_t elem_cnt;
|
||||
multidev_custom_element elem_arr[MULTI_DEV_CNT_MAX];
|
||||
}multidev_custom_info_st;
|
||||
|
||||
typedef struct {
|
||||
uint8_t dev_enable;
|
||||
uint8_t map_res_index;
|
||||
multidev_cls_type cls_type;
|
||||
ccinst_setting_maintype setting_maintp;
|
||||
ccinst_setting_subtype setting_subtp;
|
||||
|
||||
const uint8_t* p_dev_name;
|
||||
}multidev_load_element;
|
||||
|
||||
typedef struct {
|
||||
uint8_t load_stat;
|
||||
uint8_t load_cnt;
|
||||
uint8_t filter_cnt;
|
||||
multidev_load_element elem_arr[MULTI_DEV_CNT_MAX];
|
||||
}multidev_load_info_st;
|
||||
|
||||
extern uint8_t usbcustom_multidev_cfg_reset(void);
|
||||
extern multidev_custom_info_st* usbcustom_multidev_cfg_update(void);
|
||||
extern uint8_t usbcustom_multidev_cfg_end(multidev_load_info_st *p_multidev_load);
|
||||
|
||||
|
||||
#define USBD_CUST_MAX_INEP_CNT 4
|
||||
#define USBD_CUST_MAX_OUTEP_CNT 4
|
||||
|
||||
typedef struct {
|
||||
uint8_t epin_num;
|
||||
uint8_t epout_num;
|
||||
uint8_t epin_idx_arr[USBD_CUST_MAX_INEP_CNT];
|
||||
uint8_t epout_idx_arr[USBD_CUST_MAX_OUTEP_CNT];
|
||||
uint8_t epin_trans_attr[USBD_CUST_MAX_INEP_CNT];
|
||||
uint8_t epout_trans_attr[USBD_CUST_MAX_OUTEP_CNT];
|
||||
uint16_t epin_maxpkt_sz[USBD_CUST_MAX_INEP_CNT];
|
||||
uint16_t epout_maxpkt_sz[USBD_CUST_MAX_OUTEP_CNT];
|
||||
}usbd_cust_ep_info_st;
|
||||
|
||||
|
||||
#define USBD_CUST_MAX_INTFNUM 2
|
||||
typedef struct
|
||||
{
|
||||
uint8_t custCfgValid;
|
||||
uint8_t wTotalLength;
|
||||
uint8_t *pDesc;
|
||||
uint8_t bNumInterfaces;
|
||||
usbd_cust_ep_info_st tEpInfo;
|
||||
}usbd_cust_config_st;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t (*multidev_reset)(void);
|
||||
multidev_custom_info_st* (*multidev_update)(void);
|
||||
uint8_t (*multidev_end)(multidev_load_info_st *p_multidev_load);
|
||||
uint8_t (*multidev_ccinfo_map)(usbcust_mdcd_ccinfo_st *p_mdcd_ccinfo);
|
||||
uint8_t * (*multidev_strdesc)(usbcust_mdcd_strdesc_st *p_mdcd_strdesc);
|
||||
uint8_t (*multidev_cmndesc)(usbcust_mdcd_cmndesc_st *p_mdcd_cmndesc);
|
||||
uint8_t (*multidev_ctrl_proc)(usbcust_md_ctrl_st* p_usbcust_md_ctrl);
|
||||
|
||||
}usbcustom_multidev_cb_ops_st, *ptr_usbcustom_multidev_cb_ops_st;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* FUNCTIONS DECLEARATION FOR MULTIDEV DESCRIPTOR *
|
||||
*----------------------------------------------------------------------------*/
|
||||
uint8_t usbcustom_multidev_ccinfo_map(usbcust_mdcd_ccinfo_st *p_mdcd_ccinfo);
|
||||
|
||||
|
||||
uint8_t *usbcustom_multidev_strdesc(usbcust_mdcd_strdesc_st *p_mdcd_strdesc);
|
||||
uint8_t usbcustom_multidev_cmndesc(usbcust_mdcd_cmndesc_st *p_mdcd_cmndesc);
|
||||
uint8_t usbcustom_multidev_ctrl_proc(usbcust_md_ctrl_st* p_usbcust_md_ctrl);
|
||||
|
||||
|
||||
uint8_t *usbd_multi_lib_strdesc_cb(usbcust_mdcd_strdesc_st *p_mdcd_strdesc);
|
||||
uint8_t usbd_multi_lib_cmndesc_cb(usbcust_mdcd_cmndesc_st *p_mdcd_cmndesc);
|
||||
|
||||
//#define usbd_multi_libcall_intfstr_desc usbd_multi_lib_intfstr_desc_cb
|
||||
//uint8_t *usbd_multi_libcall_intfstr_desc(usbcust_mdcd_desc_st *p_usbcust_md_desc);
|
||||
|
||||
//extern uint8_t usbd_multi_lib_set_cmndesc_para(usb_func_st *p_usb_func,
|
||||
// usbcust_mdcd_cmndesc_st* p_mdcd_cmndesc);
|
||||
|
||||
extern uint8_t usbd_multi_libcall_cmndesc(usbcust_mdcd_cmndesc_st *p_mdcd_cmndesc);
|
||||
|
||||
extern uint8_t* usbd_multi_libcall_strdesc(usbcust_mdcd_strdesc_st *p_mdcd_strdesc);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef __USBD_VCOM_EXTMSG_H__
|
||||
#define __USBD_VCOM_EXTMSG_H__
|
||||
|
||||
typedef enum
|
||||
{
|
||||
VCOM_EXT_NTF_REQ_NONE = 0,
|
||||
VCOM_EXT_NTF_REQ_STAT = 1,
|
||||
}vcom_ext_ntf_req_type;
|
||||
|
||||
|
||||
struct tag_vcom_ntf_req_basedef {
|
||||
|
||||
uint8_t bmRequest;
|
||||
uint8_t bRequest;
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
typedef struct tag_vcom_ntf_req_basedef vcom_ntf_req_basedef_st;
|
||||
|
||||
struct tag_vcom_ext_ntf_msg
|
||||
{
|
||||
uint8_t ext_req_used;
|
||||
vcom_ntf_req_basedef_st base_req;
|
||||
uint16_t len;
|
||||
uint8_t *p_data;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
typedef struct tag_vcom_ext_ntf_msg vcom_ext_ntf_msg_st;
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef __USBMST_EXTERNAL_H__
|
||||
#define __USBMST_EXTERNAL_H__
|
||||
|
||||
#define ERR_DEV_BASE (-200)
|
||||
#define ERR_DEV_NUM_REDEF(err) (ERR_DEV_BASE + err)
|
||||
|
||||
#define ERR_DEV_NO_INIT ERR_DEV_NUM_REDEF(-1)
|
||||
#define ERR_DEV_NO_CONNECT ERR_DEV_NUM_REDEF(-2)
|
||||
|
||||
#define ERR_DEV_NOTIFY_COND_DEFAULT_ERR ERR_DEV_NUM_REDEF(-40)
|
||||
#define ERR_DEV_NOTIFY_COND_EXIST_ERR ERR_DEV_NUM_REDEF(-41)
|
||||
#define ERR_DEV_NOTIFY_HOSTNODET_ERR ERR_DEV_NUM_REDEF(-43)
|
||||
|
||||
int serial_vcom0_uplink_xfer_cfg(uint16_t xfsiz);
|
||||
int serial_vcom0_uplink_get_epnum(void);
|
||||
int serial_vcom0_downlink_get_epnum(void);
|
||||
|
||||
int serial_vcom1_uplink_xfer_cfg(uint16_t xfsiz);
|
||||
int serial_vcom1_uplink_get_epnum(void);
|
||||
int serial_vcom1_downlink_get_epnum(void);
|
||||
|
||||
int serial_vcom2_uplink_xfer_cfg(uint16_t xfsiz);
|
||||
int serial_vcom2_uplink_get_epnum(void);
|
||||
int serial_vcom2_downlink_get_epnum(void);
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
rndis_stat_connect = 0,
|
||||
rndis_stat_disconn = 1
|
||||
}rndis_conn_stat_type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ecm_stat_disconn = 0,
|
||||
ecm_stat_connect = 1,
|
||||
}ecm_conn_stat_type;
|
||||
|
||||
typedef struct tag_ecm_ext_conn_info
|
||||
{
|
||||
uint8_t conn_stat;
|
||||
uint32_t speed;
|
||||
}ecm_ext_conninfo_msg_st;
|
||||
|
||||
int32_t rndis0_uplink_xfer_cfg(uint16_t xfsiz);
|
||||
int32_t rndis0_uplink_get_epnum(void);
|
||||
int32_t rndis0_downlink_get_epnum(void);
|
||||
|
||||
int32_t rndis0_sig_conn_test(rndis_conn_stat_type conn_stat);
|
||||
int32_t rndis0_sig_conn_stat(rndis_conn_stat_type conn_stat);
|
||||
|
||||
int ecm0_sig_conn_stat(ecm_conn_stat_type conn_stat);
|
||||
int ecm0_sig_conn_info(ecm_ext_conninfo_msg_st *p_conn_info);
|
||||
|
||||
#define NOTIFY_MSG_INIT 0x00000002
|
||||
#define NOTIFY_MSG_HALT 0x00000003
|
||||
#define NOTIFY_MSG_RESET 0x00000004
|
||||
|
||||
extern void usbDevNotifyRndisEvent(uint32_t flag, void* args);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,174 @@
|
||||
#ifndef __USBMST_TOP_H__
|
||||
#define __USBMST_TOP_H__
|
||||
|
||||
#include "usbc_basic_def.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#if 0
|
||||
/*usbc low level defination*/
|
||||
#define USBC_CTRL_CORE_BASE_ADDR 0x1A000000
|
||||
#define USBC_GRXSTSP_ADDR (USBC_CTRL_CORE_BASE_ADDR+0x20)
|
||||
|
||||
#define USBC_FIFO_BASE_ADDR (USBC_CTRL_CORE_BASE_ADDR+0x1000)
|
||||
|
||||
#define MAX_EP_OUT_NUM (13)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#define LOCMAP_MAX_SUPPORT_FUNCTION 5
|
||||
#define LOCMAP_MAX_EP_OUT_NUM 13
|
||||
#define LOCMAP_INVALID_FUNC_NUM 0xf
|
||||
typedef struct
|
||||
{
|
||||
usbd_locmap_elem_st func_elem_arr[LOCMAP_MAX_SUPPORT_FUNCTION];
|
||||
uint8_t epout_func_idx_arr[LOCMAP_MAX_EP_OUT_NUM];
|
||||
}usbd_locmap_st;
|
||||
|
||||
typedef struct {
|
||||
//fix len 8
|
||||
uint8_t* setup_dest_base_addr;
|
||||
}usbc_uldpmgr_setup_trans;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t * xfer_buff;
|
||||
uint32_t xfer_len;
|
||||
}usbc_uldpmgr_oep_trans;
|
||||
|
||||
typedef struct {
|
||||
uint32_t total_size;
|
||||
uint8_t * extract_addr;//extract mode addr, used only for rndis, ppp
|
||||
}usbc_uldpmgr_extract_trans;//not used
|
||||
|
||||
struct tag_usbmst_top;
|
||||
|
||||
|
||||
typedef struct tag_usbmst_cmn_lowlevel_ops
|
||||
{
|
||||
void (*reset_handler)(void *pdev ,uint8_t speed);
|
||||
|
||||
int32_t (*init_handler) (struct tag_usbmst_top *ptop , uint8_t cfgidx);
|
||||
int32_t (*deinit_handler) (struct tag_usbmst_top *ptop , uint8_t cfgidx);
|
||||
int32_t (*suspend_handler) (struct tag_usbmst_top *ptop);
|
||||
int32_t (*resume_handler) (struct tag_usbmst_top *ptop);
|
||||
}usbmst_cmn_lowlevel_ops;
|
||||
|
||||
typedef struct tag_usbmst_uldp_lowlevel_ops
|
||||
{
|
||||
int32_t (*cfg_setup_trans) (struct tag_usbmst_top *p_usbmst_top, usbc_uldpmgr_setup_trans*);
|
||||
int32_t (*cfg_ep_trans) (struct tag_usbmst_top *p_usbmst_top, uint8_t epnum, usbc_uldpmgr_oep_trans*);
|
||||
int32_t (*get_avail_size) (struct tag_usbmst_top *p_usbmst_top, uint8_t epnum);
|
||||
int32_t (*get_ep_all_cmpl_stat) (struct tag_usbmst_top *p_usbmst_top);
|
||||
int32_t (*clear_epn_cmpl_stat) (struct tag_usbmst_top *p_usbmst_top, uint8_t epnum, uint8_t usb_intr_ctx);
|
||||
}usbmst_uldp_lowlevel_ops;
|
||||
|
||||
|
||||
typedef struct tag_usbmst_tftc_lowlevel_ops
|
||||
{
|
||||
int32_t (*func_rsv)(struct tag_usbmst_top *ptop);
|
||||
}usbmst_tftc_lowlevel_ops;
|
||||
|
||||
typedef struct tag_usbmst_uldp_ctrl_ep
|
||||
{
|
||||
uint8_t is_packet_extract_mode;
|
||||
uint32_t extract_head_len;
|
||||
|
||||
|
||||
uint32_t idx;
|
||||
uint32_t avail_size_end;
|
||||
uint32_t avail_size_start;
|
||||
uint32_t total_size;
|
||||
uint8_t * extract_addr;//extract mode addr, used only for rndis, ppp
|
||||
}usbmst_uldp_ctrl_ep_st;
|
||||
|
||||
typedef struct tag_usbmst_uldp_ep_trans_stat
|
||||
{
|
||||
uint8_t ep_idx;
|
||||
uint8_t ep_event;
|
||||
}usbmst_uldp_ep_trans_stat_st;
|
||||
|
||||
typedef struct tag_usbmst_uldp_trans_stat
|
||||
{
|
||||
uint8_t ep_cnt;
|
||||
usbmst_uldp_ep_trans_stat_st ep_arr[MAX_EP_OUT_NUM];
|
||||
}usbmst_uldp_ctrl_trans_stat_st;
|
||||
|
||||
struct tag_usbmst_uldp_dev;
|
||||
typedef uint32_t (* pfn_usbmst_uldp_handler)(struct tag_usbmst_top *pdev);
|
||||
|
||||
typedef struct tag_usbmst_top_dev
|
||||
{
|
||||
uint8_t wkup_first_reset;
|
||||
uint8_t enum_spd;
|
||||
usbmst_uldp_ctrl_ep_st out_ep[MAX_EP_OUT_NUM];//not used
|
||||
usbmst_cmn_lowlevel_ops *p_usbmst_cmn_lowlevel_ops;//common usb event callback, provided by uplayer, called by usbc
|
||||
usbmst_uldp_lowlevel_ops *p_usbmst_uldp_lowlevel_ops;//uldp event callback, provided by uplayer, called by usbc
|
||||
usbmst_tftc_lowlevel_ops *p_usbmst_tftc_lowlevel_ops;//currently reserved
|
||||
usbd_locmap_st t_usbd_locmap;
|
||||
uint8_t *setup_pkt_addr;
|
||||
uint8_t zlp_xfer_buff_fix[64];
|
||||
}usbmst_top_dev_st;
|
||||
|
||||
|
||||
|
||||
typedef struct tag_usbmst_top
|
||||
{
|
||||
usbmst_top_dev_st dev;
|
||||
usbmst_uldp_ctrl_trans_stat_st t_trans_stat;/*filled by uldp rx callback, to pass event info to usbc, current only for ep0*/
|
||||
pfn_usbmst_uldp_handler ptr_usbmst_uldp_handler;/*provided by usbc, called by uldp rx callback to indicate ep0 recv info to usbc*/
|
||||
}
|
||||
usbmst_top_st;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\fn uint32_t usbmst_top_early_init(usbmst_top_st *p_usbmst_top)
|
||||
\brief provide by uplayer, called by usbc driver to get callbacks
|
||||
\param[in] p_usbmst_top pointer to usbmst top var
|
||||
\return uint32_t
|
||||
\note
|
||||
*/
|
||||
uint32_t usbmst_top_early_init(usbmst_top_st *p_usbmst_top);
|
||||
|
||||
/**
|
||||
\fn uint32_t usbmst_get_oep_xfer_reg(uint32_t epnum)
|
||||
\brief provide by usbc, called by uldp callback to get transfer info
|
||||
raw register info.
|
||||
\param[in] epnum out ep number
|
||||
\return uint32_t
|
||||
\note called in uldp rx callback,interrupt context
|
||||
*/
|
||||
uint32_t usbmst_get_oep_xfer_reg(uint32_t epnum);
|
||||
|
||||
/**
|
||||
\fn uint32_t usbmst_get_oep_real_xfercnt(uint32_t epnum)
|
||||
\brief provide by usbc, called by uldp callback to get current
|
||||
transfer cnt
|
||||
\param[in] epnum out ep number
|
||||
\return uint32_t
|
||||
\note called in uldp rx callback,interrupt context
|
||||
pass to rx task for recv length checking
|
||||
*/
|
||||
uint32_t usbmst_get_oep_real_xfercnt(uint32_t epnum);
|
||||
int serial_vcom0_uplink_xfer_cfg(uint16_t xfsiz);
|
||||
int serial_vcom1_uplink_xfer_cfg(uint16_t xfsiz);
|
||||
int serial_vcom2_uplink_xfer_cfg(uint16_t xfsiz);
|
||||
|
||||
int32_t usbmst_transfer_devcfg_uplink_transfer(uint8_t multidev_load_idx, uint8_t dev_cls_type, uint16_t xfer_size);
|
||||
void usbc_usbmst_mgr_resume_hook(void);
|
||||
void usbc_usbmst_mgr_suspend_hook(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
/******************************************************************************
|
||||
|
||||
*(C) Copyright 2018 AirM2M International Ltd.
|
||||
|
||||
* All Rights Reserved
|
||||
|
||||
******************************************************************************
|
||||
* Filename:
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef UTFC_H
|
||||
#define UTFC_H
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* INCLUDES *
|
||||
*----------------------------------------------------------------------------*/
|
||||
#include "ec618.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* MACROS *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*DEFINE UTFC return code*/
|
||||
|
||||
#define UTFC_RET_OK (0)
|
||||
#define UTFC_RET_ALREADY_EN (-1)
|
||||
#define UTFC_PARA_ERROR (-2)
|
||||
#define UTFC_NOT_INIT (-3)
|
||||
#define UTFC_RET_FAIL (-4)
|
||||
#define UTFC_EP_NOT_SUPPORT (-5)
|
||||
|
||||
|
||||
#define UTFC_REG_BASE 0x40060000
|
||||
|
||||
#define UTFC_CODE_BASE_ADDR 0x00400000
|
||||
|
||||
|
||||
#define UTFC_MAX_IF_NUM (5)// max 5 ifs, 5 code section, --ulg=4 resv 1
|
||||
|
||||
#define UTFC_INVALID_EP_NUM (0xffffffff)
|
||||
|
||||
|
||||
#define UTFC_REL_EP_MAGIC (0xbcdb0000)
|
||||
|
||||
#define UTFC_NUM_OF_USB_CODE 0x03
|
||||
|
||||
|
||||
|
||||
//base addr for 3 code, same for all ep
|
||||
#define UTFC_CFG_REG1_BASE_ADDR (0x1A000000+0x908)
|
||||
#define UTFC_CFG_REG2_BASE_ADDR (0x1A000000+0x910)
|
||||
#define UTFC_CFG_REG3_BASE_ADDR (0x1A000000+0x900)
|
||||
|
||||
#define UTFC_CFG_REG1_VALUE 0x00000001
|
||||
#define UTFC_CFG_REG2_VALUE 0x03
|
||||
//bit25-22 txfnum bit21---16=0, bit15=1,USBActEP bit14:11=0, bit10:0 MPS=512=0x200*/
|
||||
#define UTFC_CFG_REG3_VALUE (0x84088200)
|
||||
|
||||
//bit25-22 txfnum bit21---16=0, bit15=1,USBActEP bit14:11=0, bit10:0 MPS=64=0x040*/
|
||||
#define UTFC_CFG_REG3_FS_VALUE (0x84088040)
|
||||
|
||||
|
||||
//zi setting reg2 val, same for all ep, only for sct
|
||||
#define UTFC_CFG_ZL_REG2_VALUE ((0x1<<19)|(0x0))//pakcnt=1,xfersize=0 for ZI packet
|
||||
|
||||
#define UTFC_ULG_CFG_REG2_VALUE ((0x1<<19)|(448))//pakcnt=1,xfersize=512-64
|
||||
|
||||
#define UTFC_ULG_CFG_REG2_FS_VALUE ((0x2<<19)|(96))//pakcnt=2,xfersize=96
|
||||
|
||||
|
||||
#define UTFC_MAX_XFER_SIZE (1024*64)//64k
|
||||
#define UTFC_EP_MPS (512)//may include from USB later
|
||||
#define UTFC_EP_FS_MPS (64)// may include from USB later
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
// temp define here, should be a common define for ALL EP according to usage
|
||||
typedef enum
|
||||
{
|
||||
UTFC_START_ADDR_SW= 0,
|
||||
UTFC_START_ADDR_HW
|
||||
} UsbStartAddrSel_e;
|
||||
|
||||
|
||||
// uta request source
|
||||
typedef enum
|
||||
{
|
||||
UTA_REQ_SRC_SW = 0,
|
||||
UTA_REQ_SRC_ULDP = 1,
|
||||
UTA_REQ_SRC_SCT = 2,
|
||||
UTA_REQ_SRC_ULG = 3,
|
||||
UTA_REQ_SRC_MAX
|
||||
} UtaReqSrc_e;
|
||||
|
||||
|
||||
// utfc code array
|
||||
typedef enum
|
||||
{
|
||||
UTFC_ULG_CODE = 0,
|
||||
UTFC_RNDIS_ZI_CODE = 1,
|
||||
UTFC_AT_ZI_CODE = 2,
|
||||
UTFC_PPP_ZI_CODE = 3,
|
||||
UTFC_CODE_MAX
|
||||
} UtfcCfgCode_e;
|
||||
|
||||
|
||||
// temp define here, should be a common define for ALL EP according to usage
|
||||
typedef enum
|
||||
{
|
||||
USB_TX_EP_0= 0,
|
||||
USB_TX_EP_1,
|
||||
USB_TX_EP_2,
|
||||
USB_TX_EP_3,
|
||||
USB_TX_EP_4,
|
||||
USB_TX_EP_5,
|
||||
USB_TX_EP_6,
|
||||
USB_TX_EP_7,
|
||||
USB_TX_EP_8,
|
||||
USB_TX_EP_9,
|
||||
USB_TX_EP_10,
|
||||
USB_TX_EP_11,
|
||||
USB_TX_EP_12,
|
||||
USB_TX_EP_MAX
|
||||
} UsbTxEpNum_e;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UTFC_ERROR_STATE = -1, /* SW check error */
|
||||
UTFC_IDLE_STATE = 0,
|
||||
UTFC_START_CFG = 1, /* UTFC READ the command to config the USB REG */
|
||||
UTFC_PACKET = 2, /* UTFC Tx data to USB TxFIFO, and wait for USB Tx_complete */
|
||||
UTFC_ZL_PEND = 3, /* If ZERO PKG need, after Recv Tx_complete, enter this state */
|
||||
UTFC_CL_CFG = 4, /* UTFC config ZERO PKG command */
|
||||
UTFC_ZL_PACKET = 5 /* wait for ZERO PKG USB Tx_complete */
|
||||
}UtfcState_e;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* DATA TYPE DEFINITION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// typedef of register 'UtfcCfgInfo_t'
|
||||
typedef struct {
|
||||
|
||||
uint32_t codeBaseAddr;// base address of the code
|
||||
UsbStartAddrSel_e startAddrSel;// 0:select from SW, configure in register 1: select from HW(SCT)
|
||||
uint8_t zlStageEn;// 0:disable 1: enable. normally SW should not enable ZI
|
||||
uint16_t swAddrOffset;// code address offset for epn, 9 bits word address
|
||||
uint16_t ziAddrOffset;// ZI code address offset for epn,9 bits word address
|
||||
|
||||
} UtfcCfgInfo_t;
|
||||
|
||||
// typedef of utfc galobal info
|
||||
typedef struct {
|
||||
|
||||
uint8_t isUtfcEnabled;// whether utfc is enbaled
|
||||
//add more global control var here if needed
|
||||
|
||||
} UtfcCtrl_t;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* |32bits --number of code, 0:3 valid, 4:31 reserved|
|
||||
|
||||
|
||||
|32bits --usb cfg register address, 0:1 should be 0|
|
||||
|32bits --usb cfg register value|
|
||||
|
||||
|32bits --usb cfg register address, 0:1 should be 0|
|
||||
|32bits --usb cfg register value|
|
||||
|
||||
.................
|
||||
.................
|
||||
|
||||
max 15 cfg
|
||||
*/
|
||||
|
||||
|
||||
// typedef of utfc usb in ep cfg section
|
||||
typedef struct {
|
||||
|
||||
uint32_t usbRegAddr;
|
||||
uint32_t usbRegVal;
|
||||
|
||||
} UtfcUsbRegCfg_t;
|
||||
|
||||
|
||||
// typedef of utfc usb in ep cfg section
|
||||
typedef struct {
|
||||
|
||||
uint32_t numOfCode;
|
||||
UtfcUsbRegCfg_t usbCode[UTFC_NUM_OF_USB_CODE];
|
||||
uint32_t rEpInfo;//related ep info, 4B for 4 align
|
||||
|
||||
} UtfcUsbCfgCode_t;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*
|
||||
* GLOBAL FUNCTIONS DECLEARATION *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
\fn utfcInit( void )
|
||||
\brief used by unilog and SCT.
|
||||
\note called when when UNILOG/SCT USB direct path enabled
|
||||
*/
|
||||
int32_t utfcInit(void);
|
||||
|
||||
|
||||
/**
|
||||
\fn utfcDinit( void )
|
||||
\brief used by USB driver, called when USBC deinit.
|
||||
\note
|
||||
*/
|
||||
int32_t utfcDinit(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn utfcReset( void )
|
||||
\brief used to reset UTFC
|
||||
\note called when needed
|
||||
*/
|
||||
void utfcReset(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn utfcEpnCfg( UtfcCfgInfo_t * utfcCfg, UsbTxEpNum_e epNum )
|
||||
\brief used by unilog/sct driver, called when unilog to USB path en or SCT to USB path en.
|
||||
\note currently, SW only use for unilog, SCT will only need to configure utfcCfg->startAddrSel=1
|
||||
*/
|
||||
int32_t utfcEpnCfg( UtfcCfgInfo_t * utfcCfg, UsbTxEpNum_e epNum );
|
||||
|
||||
|
||||
/**
|
||||
\fn utfcEpnStartReq( UsbTxEpNum_e epNum )
|
||||
\brief used by unilog driver, called when unilog first start.
|
||||
\note
|
||||
*/
|
||||
int32_t utfcEpnStartReq( UsbTxEpNum_e epNum );
|
||||
|
||||
/**
|
||||
\fn utfcEpnClear( UtfcCfgInfo_t * utfcCfg, UsbTxEpNum_e epNum )
|
||||
\brief used by unilog/sct, called to clear UTFC EP
|
||||
\note
|
||||
*/
|
||||
int32_t utfcEpnClear(UsbTxEpNum_e epNum);
|
||||
|
||||
/**
|
||||
\fn UtfcState_e utfcEpnGetState(UsbTxEpNum_e epNum)
|
||||
\brief used by unilog/sct, called to get UTFC state
|
||||
\note
|
||||
*/
|
||||
UtfcState_e utfcEpnGetState(UsbTxEpNum_e epNum);
|
||||
|
||||
/**
|
||||
\fn utfcUlgCfg( UsbTxEpNum_e epNum )
|
||||
\brief used by unilog driver, called when unilog first start.
|
||||
\note
|
||||
*/
|
||||
int32_t utfcUlgCfg( UsbTxEpNum_e epNum );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn utfcSetZLForSct(uint8_t idx, UsbTxEpNum_e epNum )
|
||||
\brief used by sct driver to set zero length packet cfg code
|
||||
\note
|
||||
*/
|
||||
int32_t utfcSetZLForSct(uint8_t idx, UsbTxEpNum_e epNum );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\fn utfcSetCodeForSct(UsbTxEpNum_e epNum,uint16_t xferSize,uint32_t *codeBuf)
|
||||
\brief used by sct driver to set normal length packet cfg code
|
||||
\note
|
||||
*/
|
||||
int32_t utfcSetCodeForSct(UsbTxEpNum_e epNum,uint16_t xferSize,uint32_t *codeBuf);
|
||||
|
||||
/**
|
||||
\fn utaReqClr( UtaReqSrc_e reqSrc )
|
||||
\brief used by usb TXFIFO master to clear the request, normally used when the request source
|
||||
is working, it will also clear the working state
|
||||
should be set to 1 to clear, HW self clear
|
||||
\note HW clear
|
||||
*/
|
||||
int32_t utaReqClr( UtaReqSrc_e reqSrc );
|
||||
|
||||
/**
|
||||
\fn utaReqSrcDisEn( UtaReqSrc_e reqSrc, uint8_t disEn )
|
||||
\brief used by usb TXFIFO master to disable the request
|
||||
should be set disEn to 1 to disable, disEn=0 to enable
|
||||
\note !!! 1 is disable, 0 (default) is enable !!!
|
||||
*/
|
||||
int32_t utaReqSrcDisEn(UtaReqSrc_e reqSrc, uint8_t disEn);
|
||||
|
||||
/**
|
||||
\fn utaSwAckStateRd( void )
|
||||
\brief used by usb sw device IN transfer e.g. VCOM_SEND
|
||||
polling this bit until it is set to 0b001, 1 means get the ack, sw could write USB TX FIFO
|
||||
\note usb sw polling
|
||||
*/
|
||||
uint32_t utaAckStateRd(void);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,556 @@
|
||||
#ifndef __CMI_COMM_H__
|
||||
#define __CMI_COMM_H__
|
||||
/******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M Ltd.
|
||||
File name: - cmicomm.h
|
||||
Description: - CMI (CIoT modem interface) common interface defination
|
||||
History: - 08/09/2020, Originated by Jason
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "pssys.h"
|
||||
#else
|
||||
#include "osasys.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Same defination in: cms_def.h
|
||||
*/
|
||||
#define PS_BROADCAST_IND_HANDLER 0x0001
|
||||
|
||||
/*
|
||||
* used in CAM, this reserved for CAM SYNC API
|
||||
* Same defination in: cms_def.h: CAM_CMI_SYNC_REQ_START_HANDLER
|
||||
*/
|
||||
#define CMI_SYNC_REQ_NUM 16
|
||||
#define CMI_SYNC_REQ_START_HANDLER 0x0030
|
||||
#define CMI_SYNC_REQ_END_HANDLER (CMI_SYNC_REQ_START_HANDLER + CMI_SYNC_REQ_NUM - 1)
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* STRUCT definition
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* MT error result code
|
||||
* refer: 27.007 9.2
|
||||
******************************************************************************/
|
||||
typedef enum MtErrorResultCode_TAG
|
||||
{
|
||||
CME_SUCC = 0,
|
||||
/*
|
||||
* 0 - 100 are reserved for general errors
|
||||
*/
|
||||
//CME_PHONE_FAILURE = 0, error 0 should not support for easy process
|
||||
CME_MT_NO_CONNECTION = 1,
|
||||
CME_MT_LINK_RESERVED,
|
||||
CME_OPERATION_NOT_ALLOW,
|
||||
CME_OPERATION_NOT_SUPPORT,
|
||||
CME_PH_SIM_PIN_REQ,
|
||||
CME_PH_FSIM_PIN_REQ,
|
||||
CME_PH_FSIM_PUK_REQ,
|
||||
|
||||
CME_SIM_NOT_INSERT = 10,
|
||||
CME_SIM_PIN_REQ,
|
||||
CME_SIM_PUK_REQ,
|
||||
CME_SIM_FAILURE,
|
||||
CME_SIM_BUSY,
|
||||
CME_SIM_WRONG,
|
||||
CME_INCORRECT_PASSWORD,
|
||||
CME_SIM_PIN2_REQ,
|
||||
CME_SIM_PUK2_REQ,
|
||||
CME_MEMORY_FULL = 20, /*accroding to 27.007 9.2.1*/
|
||||
CME_INVALID_INDEX,
|
||||
CME_NOT_FOUND,
|
||||
CME_MEMORY_FAILURE,
|
||||
CME_TEXT_STR_TOO_LONG,
|
||||
CME_INVALID_CHAR_IN_TXT_STR,
|
||||
CME_DIAL_STR_TOO_LONG,
|
||||
CME_INVALID_CHAR_IN_DIAL_STR = 27,
|
||||
CME_NO_NW_SERVICE = 30,
|
||||
CME_NW_TIMEOUT,
|
||||
CME_NW_NOT_ALLOWED_EC_ONLY, /*network not allowed - emergency calls only*/
|
||||
CME_NW_PERSONAL_PIN_REQ = 40, /*40 network personalization PIN required */
|
||||
CME_NW_PERSONAL_PUK_REQ, /*41 network personalization PUK required*/
|
||||
CME_NW_SUBSET_PERSONAL_PIN_REQ, /*42 network subset personalization PIN required*/
|
||||
CME_NW_SUBSET_PERSONAL_PUK_REQ, /*43 network subset personalization PUK required*/
|
||||
CME_SRV_PROVIDER_PERSONAL_PIN_REQ, /*44 service provider personalization PIN required*/
|
||||
CME_SRV_PROVIDER_PERSONAL_PUK_REQ, /*45 service provider personalization PUK required*/
|
||||
CME_CORPORATE_PERSONAL_PIN_REQ, /*46 corporate personalization PIN required*/
|
||||
CME_CORPORATE_PERSONAL_PUK_REQ, /*47 corporate personalization PUK required*/
|
||||
CME_HIDDEN_KEY_REQ, /*48 hidden key required (See NOTE 2)*/
|
||||
CME_EAP_METHOD_NOT_SUPPORT, /*49 EAP method not supported*/
|
||||
CME_INCORRECT_PARAM = 50, /*50 Incorrect parameters*/
|
||||
CME_CMD_IMPLEMENTED_BUT_CUR_DISABLED, /*51 command implemented but currently disabled*/
|
||||
CME_CMD_ABORT_BY_USER, /*52 command aborted by user*/
|
||||
CME_NOT_ATTACHED_DUE_TO_RESTRICT, /*53 not attached to network due to MT functionality restrictions*/
|
||||
CME_MODEM_NOT_ALLOWED_EC_ONLY, /*54 modem not allowed - MT restricted to emergency calls only*/
|
||||
CME_OPER_NOT_ALLOWED_DUE_TO_RESTRICT, /*55 operation not allowed because of MT functionality restrictions*/
|
||||
CME_FIXED_DIAL_NUM_ONLY, /*56 fixed dial number only allowed - called number is not a fixed dial number (refer 3GPP TS 22.101 [147])*/
|
||||
CME_TEMP_OOS_DUE_TO_OTHER_USAGE, /*57 temporarily out of service due to other MT usage*/
|
||||
CME_LANG_NOT_SUPPORT, /*58 language/alphabet not supported*/
|
||||
CME_UNEXPECTED_DATA_VALUE, /*59 unexpected data value*/
|
||||
CME_SYS_FAIL = 60, /*60 system failure*/
|
||||
CME_DATA_MISSING, /*61 data missing*/
|
||||
CME_CALL_BARRED, /*62 call barred*/
|
||||
CME_MSG_WAIT_IND_SUB_FAIL, /*63 message waiting indication subscription failure*/
|
||||
|
||||
/* ... */
|
||||
CME_UNKNOWN = 100,
|
||||
/*
|
||||
* 101 - 150 are reserved for use by GPRS and EPS
|
||||
*/
|
||||
CME_ILLEGAL_MS = 103,//#3
|
||||
CME_ILLEGAL_ME = 106,//#6
|
||||
CME_GPRS_SERVICES_NOT_ALLOWED = 107,//#7
|
||||
CME_GPRS_SERVICES_AND_NON_GPRS_SERVICES_NOT_ALLOWED = 108,//#8
|
||||
CME_PLMN_NOT_ALLOWED = 111,//#11
|
||||
CME_LOCATION_AREA_NOT_ALLOWED,//#12
|
||||
CME_ROAMING_NOT_ALLOWED_IN_THIS_LOCATION_AREA,//#13
|
||||
CME_GPRS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN,//#14
|
||||
CME_NO_SUITABLE_CELLS_IN_LOCATION_AREA,//#15
|
||||
CME_PTI_MISMATCH = 121, /*121 PTI mismatch (#47)*/
|
||||
CME_CONGESTION = 122,//#22
|
||||
CME_INSUFFICIENT_RESOURCES = 126, /*126 Insufficient resources (#26)*/
|
||||
CME_MISSING_OR_UNKNOWN_APN, /*127 Missing or unknown APN (#27)*/
|
||||
CME_UNKNOWN_PDP_ADDRESS_OR_PDP_TYPE, /*128 Unknown PDN type (#28)*/
|
||||
CME_USER_AUTHENTICATION_FAILED, /*129 User authentication or authorization failed (#29)*/
|
||||
CME_ACTIVATE_REJECT_BY_GGSN_SERVING_GW_OR_PDN_GW, /*130 Activation rejected by Serving GW or PDN GW (#30)*/
|
||||
CME_ACTIVATE_REJECT_UNSPECIFIED, /*131 Request rejected, unspecified (#31)*/
|
||||
CME_SERVICE_OPTION_NOT_SUPPORTED, /*132 Service option not supported (#32)*/
|
||||
CME_REQUESTED_SERVICE_OPTION_NOT_SUBSCRIBED, /*133 Requested service option not subscribed (#33)*/
|
||||
CME_SERVICE_OPTION_TEMPORATILY_OUT_OF_ORDER, /*134 Service option temporarily out of order (#34)*/
|
||||
CME_PTI_ALREADY_IN_USE = 135, /*135 PTI already in use (#35)*/
|
||||
CME_REGULAR_DEACTIVATION, /*136 Regular deactivation (#36) NOTE 2*/
|
||||
CME_EPS_QOS_NOT_ACCEPT, /*137 EPS QoS not accepted (#37) NOTE 2*/
|
||||
CME_FEATURE_NOT_SUPPORTED = 140, /*140 Feature not supported (#40) -for UMTS */
|
||||
CME_SEMANTIC_ERRORS_IN_THE_TFT_OPERATION, /*141 Semantic error in the TFT operation (#41)*/
|
||||
CME_SYNTACTICAL_ERRORS_IN_THE_TFT_OPERATION,/*142 Syntactical error in the TFT operation (#42)*/
|
||||
CME_INVALID_EPS_ID, /*143 Invalid EPS bearer identity (#43)*/
|
||||
CME_SEMANTIC_ERRORS_IN_PACKET_FILTERS, /*144 Semantic errors in packet filter(s) (#44)*/
|
||||
CME_SYNTACTICAL_ERRORS_IN_PACKET_FILTERS, /*145 Syntactical errors in packet filter(s) (#45)*/
|
||||
CME_PDP_CONTEXT_WITHOUT_TFT_ALREADY_ACTIVATED, /*146 PDP context without TFT already activated (#46), -for UMTS*/
|
||||
CME_UNSPECIFIED_GPRS_ERROR = 148, /*148 Unspecified GPRS error, -for UMTS*/
|
||||
CME_PDP_AUTHENTICATION_FAILURE = 149, /*149 PDP authentication failure*/
|
||||
CME_INVALID_MOBILE_CLASS = 150, /*150 Invalid mobile class*/
|
||||
|
||||
|
||||
/*
|
||||
* 151 - 170 are reserved for use by VBS/VGCS and eMLPP
|
||||
*/
|
||||
|
||||
/*
|
||||
* 171 - 256 are reserved for use by GPRS or EPS
|
||||
*/
|
||||
CME_LAST_PDN_DISCONNECTION_NOT_ALLOWED = 171, /*171 Last PDN disconnection not allowed (#49)*/
|
||||
CME_SEMANTICALLY_INCORECT_MESSAGE, /*172 Semantically incorrect message (#95)*/
|
||||
CME_MANDATORY_INFORMATION_ELEMENT_ERROR, /*173 Invalid mandatory information (#96) NOTE 2*/
|
||||
CME_INFORMATION_ELEMENT_NON_EXISTENT_OR_NOT_IMPLEMENTED, /*174 Message type non-existent or not implemented (#97) NOTE 2*/
|
||||
CME_CONDITIONAL_IE_ERROR, /*175 Conditional IE error (#100) NOTE 2*/
|
||||
CME_PROTOCOL_ERROR_UNSPECIFIED, /*176 Protocol error, unspecified (#111) NOTE 2*/
|
||||
CME_OPERATOR_DETERMINED_BARRING, /*177 Operator determined barring (#8)*/
|
||||
CME_MAX_NUMBER_OF_PDP_CONTEXTS_REACHED, /*178 Maximum number of EPS bearers reached (#65)*/
|
||||
CME_REQUESTED_APN_NOT_SUPPORTED_IN_CURRENT_RAT_AND_PLMN_COMBINATION, /*179 Requested APN not supported in current RAT and PLMN combination (#66)*/
|
||||
CME_REQUEST_REJECTED_BEARER_CONTROL_MODE_VIOLATION, /*180 Request rejected, bearer control mode violation (#48) (UMTS)*/
|
||||
CME_UNSUPPORTED_QCI_VALUE = 181, /*181 unsupported QCI value (#59)*/
|
||||
CME_USER_DATA_TRANSMISSION_VIA_CONTROL_PLANE_IS_CONGESTED, /*182 User data transmission via control plane is congested*/
|
||||
|
||||
CME_INVALID_PTI_VALUE = 184, /*184 Invalid PTI value (#81)*/
|
||||
CME_MSG_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 186, /*186 Message not compatible with protocol state (#101) NOTE 2*/
|
||||
CME_NETWORK_FAILURE = 190, /*190 Network failure (#38) NOTE 2*/
|
||||
CME_REACTIVATION_REQUESTED, /*191 Reactivation requested (#39) NOTE 2*/
|
||||
CME_PDN_IPV4_ONLY_ALLOWED, /*192 PDN type IPv4 only allowed (#50) NOTE 2*/
|
||||
CME_PDN_IPV6_ONLY_ALLOWED, /*193 PDN type IPv6 only allowed (#51) NOTE 2*/
|
||||
CME_SINGLE_ADDRESS_BEARERS_ONLY_ALLOWED, /*194 Single address bearers only allowed (#52) NOTE 2*/
|
||||
CME_COLLISION_WITH_NETWORK_INITIATED_REQUEST, /*195 Collision with network initiated request (#56) NOTE 2*/
|
||||
CME_PDN_IPV4V6_ONLY_ALLOWED, /*196 PDN type IPv4v6 only allowed (#57) NOTE 2*/
|
||||
CME_PDN_NON_IP_ONLY_ALLOWED, /*197 PDN type non IP only allowed (#58) NOTE 2*/
|
||||
CME_BEARER_HANDLING_NOT_SUPPORTED, /*198 Bearer handling not supported (#60) NOTE 2*/
|
||||
CME_APN_RESTRICTION_VALUE_INCOMPATIBLE_WITH_ACTIVATE_PDP_CTX, /*199 APN restriction value incompatible with active PDP context (#112) NOTE 2*/
|
||||
CME_MULTIPLE_ACCESS_TO_A_PDN_NOW_ALLOWED = 200, /*200 Multiple accesses to a PDN connection not allowed (#113) NOTE 2*/
|
||||
CME_ESM_INFORMATION_NOT_RECEIVED, /*201 ESM information not received (#53) NOTE 2*/
|
||||
CME_PDN_CONNECTION_NOT_EXIST, /*202 PDN connection does not exist (#54) NOTE 2*/
|
||||
CME_MULTIPLE_PDN_CONNECTION_FOR_A_GIVEN_APN_NOT_ALLOWED, /*203 Multiple PDN connections for a given APN not allowed (#55) NOTE 2*/
|
||||
CME_MSG_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE, /*208 Message type not compatible with protocol state (#98) NOTE 2*/
|
||||
CME_INFO_ELEMENT_NOT_EXIST_OR_NOT_IMPLEMENTED = 209, /*209 Information element non-existent or not implemented (#99) NOTE 2*/
|
||||
|
||||
/*
|
||||
* 257 - 300 are reserved for general errors
|
||||
*/
|
||||
|
||||
/*
|
||||
* 301 - 0xFFFF are reserved for internal
|
||||
*/
|
||||
CME_INTERNAL_ERROR_BASE = 301,
|
||||
CME_UE_BUSY,
|
||||
//CME_OPERATION_NOT_SUPPORT,
|
||||
//CME_INVALID_INPUT_PARM,
|
||||
CME_NOT_POWER_ON,
|
||||
CME_PDN_NOT_ACTIVED,
|
||||
CME_PDN_NOT_VALID,
|
||||
CME_PDN_INVALID_TYPE, /* request default/dedicated bearer, but bearer is dedicated/default */
|
||||
CME_PDN_NO_PARAM,
|
||||
|
||||
CME_UE_FAIL,
|
||||
CME_PDP_APN_AND_PDN_TYPE_DUPLICATE_USED,//#309
|
||||
CME_PDP_PAP_AND_EITF_NOT_MATCHED,
|
||||
|
||||
CME_SIM_PIN_DISABLED,
|
||||
CME_SIM_PIN_ALREADY_ENABLED,
|
||||
//CME_SIM_PIN_BLOCKED,
|
||||
CME_SIM_PIN_WRONG_FORMAT,
|
||||
|
||||
CME_PS_INTERNAL_ERROR_MAX1 = 400,
|
||||
|
||||
/*
|
||||
* 401 - 500 are reserved for socket error.
|
||||
* Defined in: cms_sock_mgr.h
|
||||
*/
|
||||
|
||||
/*
|
||||
* 500 - 600 is reserved for REF error
|
||||
*/
|
||||
CME_REF_START_ERROR = 501,
|
||||
CME_REQ_PARAM_NOT_CFG = 512, //512 Required parameter not configured
|
||||
CME_TUP_NOT_REGISTERED = 513, //513 TUP not registered
|
||||
CME_AT_INTERNAL_ERROR, //514 AT internal error
|
||||
CME_CID_IS_ACT, //515 CID is active
|
||||
CME_INCORRECT_STATE_FOR_CMD, //516 Incorrect state for command
|
||||
CME_CID_INVALID, //517 CID is invalid
|
||||
CME_CID_NOT_ACT, //518 CID is not active
|
||||
CME_DEACT_LAST_ACT_CID = 520, //520 Deactivate the last active CID
|
||||
CME_CID_NOT_DEFINED, //521 CID is not defined
|
||||
CME_UART_PARITY_ERROR, //522 UART parity error
|
||||
CME_UART_FRAME_ERROR, //523 UART frame error
|
||||
CME_IN_CFUN0_STATE, //524 UE is in minimal function mode
|
||||
CME_CMD_ABORT_ONGOING, //525 AT command aborted: in processing
|
||||
CME_CMD_ABORT_ERROR, //526 AT command aborted: error
|
||||
CME_CMD_INTERRUPT, //527 Command interrupted
|
||||
CME_CFG_CONFLICT, //528 Configuration conflicts
|
||||
CME_DURING_FOTA_UPDATING, //529 During FOTA updating
|
||||
CME_NOT_AT_ALLOC_SOCKET = 530, //530 Not the AT allocated socket
|
||||
CME_USIM_PIN_BLOCKED, //531 USIM PIN is blocked
|
||||
CME_SIM_PIN_BLOCKED = CME_USIM_PIN_BLOCKED,
|
||||
CME_USIM_PUK_BLOCKED, //532 USIM PUK is blocked
|
||||
CME_NOT_MIPI_MODE, //533 Not mipi module
|
||||
CME_FILE_NOT_FOUND, //534 File not found
|
||||
CME_CONDITION_NOT_SATISFIED, //535 conditions of use not satisfied
|
||||
CME_AT_UART_BUF_ERROR, //536 AT UART buffer error
|
||||
CME_BACK_OFF_TIME_RUNNING, //537 Back off timer is running
|
||||
//...
|
||||
CME_REF_END_ERROR = 600,
|
||||
|
||||
|
||||
|
||||
|
||||
CME_MAX_ERROR = 0xFFFF
|
||||
}MtErrorResultCode;
|
||||
|
||||
typedef UINT16 CmiRcCode; //MtErrorResultCode/SmsErrorResultCode
|
||||
|
||||
/******************************************************************************
|
||||
* SMS error result code
|
||||
* refer: 27.005 3.2.5
|
||||
******************************************************************************/
|
||||
typedef enum SmsErrorResultCode_TAG
|
||||
{
|
||||
CMS_SMS_SUCC = 0,
|
||||
|
||||
/*
|
||||
* 300 - 500 are reserved for SMS errors
|
||||
*/
|
||||
CMS_SMS_ME_FAILURE = 300,
|
||||
CMS_SMS_SERVICE_OF_ME_RESV,
|
||||
CMS_SMS_OPERATION_NOT_ALLOWED,
|
||||
CMS_SMS_OPERATION_NOT_SUPPORTED,
|
||||
CMS_SMS_INVALID_PDU_MODE_PARAMETER,
|
||||
CMS_SMS_INVALID_TEXT_MODE_PARAMETER,
|
||||
CMS_SMS_USIM_NOT_INSERTED = 310,
|
||||
CMS_SMS_USIM_PIN_REQUIRED,
|
||||
CMS_SMS_PHSIM_PIN_REQUIRED,
|
||||
CMS_SMS_USIM_FAILURE,
|
||||
CMS_SMS_USIM_BUSY,
|
||||
CMS_SMS_USIM_WRONG,
|
||||
CMS_SMS_USIM_PUK_REQUIRED,
|
||||
CMS_SMS_USIM_PIN2_REQUIRED,
|
||||
CMS_SMS_USIM_PUK2_REQUIRED,
|
||||
CMS_SMS_MEMORY_FAILURE = 320,
|
||||
CMS_SMS_INVALID_MEM_INDEX,
|
||||
CMS_SMS_MEM_FULL,
|
||||
CMS_SMS_SMSC_ADDR_UNKNOWN = 330,
|
||||
CMS_SMS_NO_NETWORK_SERVICE,
|
||||
CMS_SMS_NETWORK_TIMEOUT,
|
||||
CMS_SMS_NO_CNMA_ACK_EXPECTED = 340,
|
||||
|
||||
CMS_SMS_UNKNOWN_ERROR = 500,
|
||||
CMS_SMS_INVALID_DATA = 550,
|
||||
|
||||
CMS_MAX_ERROR = 0xFFFF
|
||||
}SmsErrorResultCode;
|
||||
|
||||
typedef UINT16 CmiSmsErrorCode;
|
||||
|
||||
/******************************************************************************
|
||||
* CAM service group enum definition
|
||||
******************************************************************************/
|
||||
typedef enum CamSgIdEnum_Tag
|
||||
{
|
||||
CAM_BASE = 1,//basic/common
|
||||
CAM_DEV = 2,
|
||||
CAM_MM = 3,
|
||||
CAM_PS = 4,
|
||||
CAM_SIM = 5,
|
||||
CAM_SMS = 6,
|
||||
|
||||
CAM_MAX = 15
|
||||
}CamSgIdEnum;
|
||||
|
||||
/*
|
||||
* CMI SIGNAL ID, between AtCmdSrv Task & CAM/CCM Task
|
||||
*/
|
||||
typedef enum _SIG_EPAT_CAMCMISIGID_enum
|
||||
{
|
||||
SIG_CAM_CMI_BASE = 0x11F0,
|
||||
SIG_CAM_CMI_REQ,
|
||||
SIG_CAM_CMI_CNF,
|
||||
SIG_CAM_CMI_IND,
|
||||
SIG_CAM_CMI_RSP,
|
||||
SIG_CAM_CMI_SYNC_REQ, /* CamCmiSyncReq */
|
||||
SIG_CAM_CMI_END = 0x11FF,
|
||||
}CAMCMISIGID;
|
||||
|
||||
/*
|
||||
* Numberic PLMN format, 4 bytes,
|
||||
* example: CMCC: 46000; mcc = 0x0460, mnc = 0xf000
|
||||
*/
|
||||
typedef struct CmiNumericPlmn_Tag
|
||||
{
|
||||
UINT16 mcc;
|
||||
UINT16 mncWithAddInfo; // if 2-digit MNC type, the 4 MSB bits should set to 'F',
|
||||
}CmiNumericPlmn;
|
||||
|
||||
#define CAM_GET_PURE_MNC(mncWithAddInfo) ((mncWithAddInfo)&0xFFF)
|
||||
#define CAM_IS_2_DIGIT_MNC(mncWithAddInfo) (((mncWithAddInfo)>>12) == 0x0F)
|
||||
|
||||
#define CAM_SET_MNC_WITH_ADD_INFO(twoDigitType, pureMnc) ((twoDigitType)?((pureMnc)|0xF000):((pureMnc)&0xFFF))
|
||||
|
||||
|
||||
/*
|
||||
* IP address info
|
||||
*/
|
||||
#define CMI_IPV4_ADDR_LEN 4
|
||||
|
||||
#if 0
|
||||
typedef struct CmiIpv4Addr_Tag
|
||||
{
|
||||
UINT8 addr[CMI_IPV4_ADDR_LEN];
|
||||
}CmiIpv4Addr;
|
||||
#endif
|
||||
#define CMI_IPV6_ADDR_LEN 16
|
||||
|
||||
#if 0
|
||||
typedef struct CmiIpv6Addr_Tag
|
||||
{
|
||||
UINT8 addr[CMI_IPV6_ADDR_LEN];
|
||||
}CmiIpv6Addr;
|
||||
#endif
|
||||
|
||||
#define CMI_IPV6_INTERFACE_LEN 8
|
||||
|
||||
/*
|
||||
* IP address info
|
||||
*/
|
||||
#define CMI_MAX_IP_ADDR_LEN 16
|
||||
|
||||
/*
|
||||
* Address IP type
|
||||
*/
|
||||
typedef enum CmiIpAddrTypeTag
|
||||
{
|
||||
CMI_INVALID_IP_ADDR = 0,
|
||||
CMI_IPV4_ADDR, //4 bytes length
|
||||
CMI_IPV6_INTERFACE_ADDR,//8 bytes length
|
||||
CMI_FULL_IPV6_ADDR //16 bytes length
|
||||
}CmiIpAddrType;
|
||||
|
||||
typedef struct CmiIpAddrTag
|
||||
{
|
||||
UINT8 addrType; //CmiIpAddrType
|
||||
UINT8 subnetMaskLen; //if not set, set to 0
|
||||
UINT16 reserved0;
|
||||
|
||||
union {
|
||||
UINT8 ipv4[CMI_IPV4_ADDR_LEN];
|
||||
UINT8 ipv6If[CMI_IPV6_INTERFACE_LEN];
|
||||
UINT8 ipv6[CMI_IPV6_ADDR_LEN];
|
||||
UINT8 addr[CMI_MAX_IP_ADDR_LEN];
|
||||
}ip;
|
||||
}CmiIpAddr; //20 bytes
|
||||
|
||||
|
||||
#define CMI_SIM_MAX_IMSI_STRING_LENGTH 16
|
||||
/*
|
||||
* IMSI string structure, 20 bytes
|
||||
*/
|
||||
typedef struct CmiSimImsiStrTag
|
||||
{
|
||||
UINT8 length;
|
||||
BOOL bThreeDigitalMnc;
|
||||
UINT16 reserved0;
|
||||
/*example: IMSI: "460002343454245" */
|
||||
CHAR contents[CMI_SIM_MAX_IMSI_STRING_LENGTH];
|
||||
}CmiSimImsiStr;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* CamCmiReq - SIG_CAM_CMI_REQ
|
||||
* CMI interface request, all other module (AT CMD server) use this signal to
|
||||
* access the CIOT modem
|
||||
* Int16 reqId; 4 MSB bits SG ID | 12 bits PRIM ID;
|
||||
* Int16 srcHandler; ID use to identify which module send this request
|
||||
* Int8 body[0]; request PRIM entity
|
||||
******************************************************************************/
|
||||
typedef struct CamCmiReqTag
|
||||
{
|
||||
struct {
|
||||
UINT16 reqId;
|
||||
UINT16 srcHandler;
|
||||
}header;
|
||||
|
||||
UINT8 body[];
|
||||
}CamCmiReq;
|
||||
|
||||
#define CAM_GET_SG_ID(reqId) (((reqId)>>12)&0x000f)
|
||||
#define CAM_GET_PRIM_ID(reqId) ((reqId)&0x0fff)
|
||||
#define CAM_SET_REQ_CNF_ID(sgId, primId) ((UINT16)(((sgId)<<12)|((primId)&0x0fff)))
|
||||
|
||||
/******************************************************************************
|
||||
* CamCmiCnf - SIG_CAM_CMI_CNF
|
||||
******************************************************************************/
|
||||
typedef struct CamCmiCnfTag
|
||||
{
|
||||
struct {
|
||||
UINT16 cnfId; //4 MSB bits SG ID | 12 bits PRIM ID
|
||||
UINT16 srcHandler; //Handler from CamCmiReq
|
||||
UINT16 rc;
|
||||
UINT16 reserved;
|
||||
}header;
|
||||
|
||||
UINT8 body[];
|
||||
}CamCmiCnf;
|
||||
|
||||
#define CAM_GET_CMICNF_FROM_BODY(pCmiBody) (CamCmiCnf *)(((UINT8 *)(pCmiBody)) - (UINT32)(OFFSETOF(CamCmiCnf, body)))
|
||||
|
||||
/******************************************************************************
|
||||
* CamCmiInd - SIG_CAM_CMI_IND
|
||||
******************************************************************************/
|
||||
typedef struct CamCmiIndTag
|
||||
{
|
||||
struct {
|
||||
UINT16 indId; //4 MSB bits SG ID | 12 bits PRIM ID
|
||||
/*
|
||||
* As some indication is triggered by some AT request, in such as need to fill this "reqHandler",
|
||||
* otherwise set to "PS_BROADCAST_IND_HANDLER".
|
||||
*/
|
||||
UINT16 reqHandler;
|
||||
}header;
|
||||
|
||||
UINT8 body[];
|
||||
}CamCmiInd;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* CamCmiRsp - SIG_CAM_CMI_RSP
|
||||
******************************************************************************/
|
||||
typedef struct CamCmiRspTag
|
||||
{
|
||||
struct {
|
||||
UINT16 rspId; //4 MSB bits SG ID | 12 bits PRIM ID
|
||||
UINT16 rspHandler;
|
||||
}header;
|
||||
|
||||
UINT8 body[];
|
||||
}CamCmiRsp;
|
||||
|
||||
|
||||
#define CAM_GET_CMIIND_FROM_BODY(pCmiBody) (CamCmiInd *)(((UINT8 *)(pCmiBody)) - (UINT32)(OFFSETOF(CamCmiInd, body)))
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* CamCmiReq - SIG_CAM_CMI_SYNC_REQ
|
||||
* CMI interface request, all other module (AT CMD server) use this signal to
|
||||
* access the CIOT modem, and syn confirm
|
||||
******************************************************************************/
|
||||
typedef struct CamCmiSyncReqTag
|
||||
{
|
||||
osSemaphoreId_t sem;
|
||||
|
||||
/* output info */
|
||||
UINT32 *pCmiRc; /* MtErrorResultCode/SmsErrorResultCode */
|
||||
UINT16 cnfBufSize;
|
||||
UINT16 rsvd0;
|
||||
void *pOutCmiCnf; /* CMI confirm struct, CMI CNF, copy to here */
|
||||
|
||||
/* input info */
|
||||
CamCmiReq cmiReq;
|
||||
}CamCmiSyncReq;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* If no parameters carried in signal, just pass a reserved Int32
|
||||
******************************************************************************/
|
||||
typedef UINT32 CamCmiEmptySig;
|
||||
//typedef UINT8 CamCmiEmptySig[]; // sizeof it == 0
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* API definition
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
/*
|
||||
* SIG_CAM_CMI_REQ to CAM task
|
||||
*/
|
||||
//void CamCmiRequest(UINT16 srcHdr, UINT8 sgId, UINT16 primId, UINT16 primSize, void *primBody);
|
||||
|
||||
/******************************************************************************
|
||||
* CamCmiSynReq
|
||||
* Description: Send "SIG_CAM_CMI_SYNC_REQ" to CAM task
|
||||
* input: UINT16 srcHdr;
|
||||
* UINT8 sgId; // CamSgIdEnum
|
||||
* UINT16 primId;// prim ID
|
||||
* UINT16 primSize; //prim body size
|
||||
* void *primBody; //prim body
|
||||
* output: UINT32 //MtErrorResultCode/SmsErrorResultCode
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
UINT32 CamCmiSynReq(UINT8 sgId, UINT16 primId, UINT16 primSize, const void *primBody, UINT16 outCnfSize, void *pOutCnfBody);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* CamMmGetCurCELevel
|
||||
* Description: return current UE (NB/EMTC) Coverage Enhancement level
|
||||
* input: UINT8 *pAct; //output, current ACT: NB/EMTC
|
||||
* UINT8 *pCeLevel; //output, current CE level
|
||||
* output: void
|
||||
* Comment:
|
||||
* Return:
|
||||
* *pAct:
|
||||
* 0 CMI_MM_CES_NO_CE_ACT //UE not attached;
|
||||
* 1 CMI_MM_CES_EUTRAN_EMTC
|
||||
* 2 CMI_MM_CES_EC_GSM //not support
|
||||
* 3 CMI_MM_CES_EUTRAN_NB
|
||||
* *pCeLevel:
|
||||
* 0 No Coverage Enhancement in the serving cell
|
||||
* 1 Coverage Enhancement level 0
|
||||
* 2 Coverage Enhancement level 1
|
||||
* 3 Coverage Enhancement level 2
|
||||
* 4 Coverage Enhancement level 3 // for EMTC
|
||||
******************************************************************************/
|
||||
void CamMmGetCurCELevel(UINT8 *pAct, UINT8 *pCeLevel);
|
||||
|
||||
#endif
|
||||
|
||||
2593
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/cmidev.h
Normal file
2593
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/cmidev.h
Normal file
File diff suppressed because it is too large
Load Diff
1363
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/cmimm.h
Normal file
1363
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/cmimm.h
Normal file
File diff suppressed because it is too large
Load Diff
2344
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/cmips.h
Normal file
2344
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/cmips.h
Normal file
File diff suppressed because it is too large
Load Diff
1236
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/cmisim.h
Normal file
1236
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/cmisim.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,748 @@
|
||||
#ifndef __CMI_SMS_H__
|
||||
#define __CMI_SMS_H__
|
||||
/******************************************************************************
|
||||
Copyright: - 2017- Copyrights of AirM2M Ltd.
|
||||
File name: - cmisms.h
|
||||
Description: - CMI (CIoT modem interface) SMS handling interface defination
|
||||
History: - 10/12/2017, Originated by xpliu
|
||||
******************************************************************************/
|
||||
#include "cmicomm.h"
|
||||
|
||||
|
||||
typedef enum CMI_SMS_PRIM_ID_TAG
|
||||
{
|
||||
CMI_SMS_PRIM_BASE = 0,
|
||||
|
||||
CMI_SMS_SEND_MSG_REQ,//AT+CMGS=...<ctrl+z>
|
||||
CMI_SMS_SEND_MSG_CNF,
|
||||
|
||||
CMI_SMS_SEND_STORED_MSG_REQ,//AT+CMSS=<index>
|
||||
CMI_SMS_SEND_STORED_MSG_CNF,
|
||||
|
||||
CMI_SMS_SEND_COMMAND_REQ,//AT+CMGC=...<ctrl+z>
|
||||
CMI_SMS_SEND_COMMAND_CNF,
|
||||
|
||||
CMI_SMS_NEW_MSG_MEM_LOCATION_IND,//+CMTI
|
||||
CMI_SMS_NEW_MSG_IND,//+CMT
|
||||
CMI_SMS_NEW_MSG_RSP,//+CNMA
|
||||
|
||||
CMI_SMS_GET_SMSC_ADDR_REQ = 10,//AT+CSCA? //10
|
||||
CMI_SMS_GET_SMSC_ADDR_CNF,
|
||||
CMI_SMS_SET_SMSP_REQ,//AT+CSCA/CSMP
|
||||
CMI_SMS_SET_SMSP_CNF,
|
||||
|
||||
CMI_SMS_SELECT_MESSAGE_SERVICE_REQ, //AT+CSMS=
|
||||
CMI_SMS_SELECT_MESSAGE_SERVICE_CNF,
|
||||
CMI_SMS_GET_CURRENT_SMS_SERVICE_REQ, //AT+CSMS?
|
||||
CMI_SMS_GET_CURRENT_SMS_SERVICE_CNF,
|
||||
CMI_SMS_GET_SUPPORTED_SMS_SERVICE_REQ, //AT+CSMS=?
|
||||
CMI_SMS_GET_SUPPORTED_SMS_SERVICE_CNF,
|
||||
|
||||
CMI_SMS_SET_MORE_MESSAGE_MODE_REQ = 20, //AT+CMMS= //20
|
||||
CMI_SMS_SET_MORE_MESSAGE_MODE_CNF,
|
||||
CMI_SMS_GET_MORE_MESSAGE_MODE_REQ, //AT+CMMS?
|
||||
CMI_SMS_GET_MORE_MESSAGE_MODE_CNF,
|
||||
|
||||
CMI_SMS_GET_CSCB_SETTING_REQ,//AT+CSCB?
|
||||
CMI_SMS_GET_CSCB_SETTING_CNF,
|
||||
CMI_SMS_SET_CSCB_SETTING_REQ,//AT+CSCB=
|
||||
CMI_SMS_SET_CSCB_SETTING_CNF,
|
||||
|
||||
CMI_SMS_GET_SMS_MSG_RECORD_REQ, //+CMSS/+CMGR get SMS storaged message from SIM.
|
||||
CMI_SMS_GET_SMS_MSG_RECORD_CNF,
|
||||
|
||||
CMI_SMS_SET_SMS_MSG_RECORD_REQ = 30, //+CMGW save the SMS message to SIM //30
|
||||
CMI_SMS_SET_SMS_MSG_RECORD_CNF,
|
||||
|
||||
CMI_SMS_DEL_SMS_MSG_RECORD_REQ, //+CMGD, delet SMS message record in SIM
|
||||
CMI_SMS_DEL_SMS_MSG_RECORD_CNF,
|
||||
|
||||
CMI_SMS_LIST_SMS_MSG_RECORD_REQ, //+CMGL, List all SMS message record in SIM, +CPMS get statistics info of the SMS storage in SIM
|
||||
CMI_SMS_LIST_SMS_MSG_RECORD_CNF,
|
||||
|
||||
CMI_SMS_GET_SMS_STORAGE_STATUS_REQ, // +CPMS get statistics info of the SMS storage in SIM
|
||||
CMI_SMS_GET_SMS_STORAGE_STATUS_CNF,
|
||||
|
||||
CMI_SMS_SEND_SMMA_REQ, //send RP-SMMA
|
||||
CMI_SMS_SEND_SMMA_CNF,
|
||||
|
||||
CMI_SMS_MEM_CAP_IND = 40, //Report SMS Memory Capacity Exceeded flag
|
||||
|
||||
CMI_SMS_SET_MEM_CAP_REQ, //Setting SMS "Memory Capacity Exceeded" Notification Flag
|
||||
CMI_SMS_SET_MEM_CAP_CNF,
|
||||
|
||||
CMI_SMS_IDLE_STATUS_IND,
|
||||
|
||||
CMI_SMS_PRIM_END = 0x0fff
|
||||
}CMI_SMS_PRIM_ID;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_SEND_MSG_REQ
|
||||
******************************************************************************/
|
||||
#define CMI_SMS_MAX_PDU_SIZE 180
|
||||
#define CMI_SMS_MAX_LENGTH_OF_ADDRESS_VALUE 40
|
||||
|
||||
/* Refer to TS-27.005 3.1 Parameter definitions Parameter <Stat> for PDU mode */
|
||||
typedef enum CmiSmsRecStorStatus_Enum
|
||||
{
|
||||
CMI_SMS_STOR_STATUS_REC_UNREAD = 0, /* Received unread message, i.e new message */
|
||||
CMI_SMS_STOR_STATUS_REC_READ = 1, /* Received read message */
|
||||
CMI_SMS_STOR_STATUS_STO_UNSENT = 2, /* Stored unsent message only applicable to SMs */
|
||||
CMI_SMS_STOR_STATUS_STO_SENT = 3, /* Stored sent message only applicable to SMs */
|
||||
CMI_SMS_STOR_STATUS_ALL = 4, /* All message, only applicable to +CGML command */
|
||||
CMI_SMS_STOR_STATUS_END
|
||||
}CmiSmsRecStorStatus;
|
||||
|
||||
/*
|
||||
* enum to record current MSG/SMS operation
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CMI_SMS_OPER_NULL,
|
||||
CMI_SMS_OPER_LIST_MSG_WITH_STATUS = 1, /* List all storaged SMS msg, +CMGL */
|
||||
CMI_SMS_OPER_STORE_INFO_GETTING, /* Get the SMS storaged memory information. for +CPMS? */
|
||||
CMI_SMS_OPER_STORE_INFO_SETTING, /* Set the SMS storaged memory information. for +CPMS= */
|
||||
CMI_SMS_OPER_READ_MSG, /* Read a SMS message, for +CMGR */
|
||||
CMI_SMS_OPER_READ_SEND_MSG, /* Read a SMS message and send it, for +CMSS */
|
||||
CMI_SMS_OPER_STORE_MT_MSG, /* Store the received SMS msg for MT SMS (+CMT/+CMTI) */
|
||||
CMI_SMS_OPER_STORE_MT_MSG_NO_RSP, /* Store the received SMS msg for MT SMS and no need send indication for Mem index. */
|
||||
CMI_SMS_OPER_STORE_CBM, /* Store the received Cell Broadcast msg for CBM (+CBM/+CBMI) */
|
||||
CMI_SMS_OPER_STORE_UNSENT_MSG, /* Store the Unsend message, for +CMGW */
|
||||
CMI_SMS_OPER_STORE_STATUS_RPT, /* Store the SMS status report, for (+CDS/+CDSI) */
|
||||
CMI_SMS_OPER_STORE_STATUS_RPT_NO_RSP, /* Store the SMS status report and no need send indication for Mem index */
|
||||
CMI_SMS_OPER_DEL_MSG_WITH_INDEX, /* Deleted a SMS messag with index, for +CMGD and delflag is NULL. */
|
||||
CMI_SMS_OPER_DEL_MSG_WITH_STATE, /* Deleted somes message with the status of SMS message, for +CMGD and delflag is not NULL */
|
||||
CMI_SMS_OPER_DEL_ALL_MSG, /* Deleted all SMS message. for +GMGD, and the delflag is 4. */
|
||||
CMI_SMS_OPER_DEL_INFO_GETTING, /* Get the SMS storaged memory information. for +CMGD=? */
|
||||
CMI_SMS_OPER_IS_SMSFULL, /* Get the SMS storaged memory information. for +ECSMSFULL */
|
||||
CMI_SMS_OPER_END
|
||||
}CmiSmsOperationMode;
|
||||
|
||||
/*
|
||||
* the result of read/write SMS message from/to Preferred storage memory. for API read/write SMS message
|
||||
*/
|
||||
typedef enum CmiSmsAccessMemRet_enum
|
||||
{
|
||||
CMS_ACC_MEM_RET_SUCC = 0,
|
||||
CMS_ACC_MEM_RET_CONTINUE = 1,
|
||||
|
||||
CMS_ACC_MEM_RET_FAIL = 100,
|
||||
CMS_ACC_MEM_RET_INVALID_PARAM = 101,
|
||||
CMS_ACC_MEM_RET_LIST_FULL = 102,
|
||||
CMS_ACC_MEM_RET_LIST_NOT_FOUND = 103,
|
||||
CMS_ACC_MEM_RET_OPER_NOT_SUPPROT = 104, /* operation not supported */
|
||||
CMS_ACC_MEM_RET_NO_MEM = 105,
|
||||
|
||||
CMS_ACC_MEM_RET_END
|
||||
}CmiSmsAccMemRet;
|
||||
|
||||
typedef struct _EPAT_CmiSmsPdu_Tag
|
||||
{
|
||||
UINT16 pduLength;
|
||||
UINT16 reserved0;
|
||||
UINT8 pduData[CMI_SMS_MAX_PDU_SIZE];
|
||||
}CmiSmsPdu;
|
||||
|
||||
/* Refer to TS 23.040-9.1.2.5 Address fields */
|
||||
typedef enum CmiSmsTypeOfNumberEnum_Tag
|
||||
{
|
||||
CMI_SMS_TYPE_OF_NUM_UNKNOWN = 0, /* Unknown */
|
||||
CMI_SMS_TYPE_OF_NUM_INTERNATIONAL = 1, /* Internation Number */
|
||||
CMI_SMS_TYPE_OF_NUM_NATIONAL = 2, /* National Number */
|
||||
CMI_SMS_TYPE_OF_NUM_NETWORK_SPECIFIC = 3, /* Network Specific */
|
||||
CMI_SMS_TYPE_OF_NUM_SUBSCRIBER = 4, /* Subscriber number */
|
||||
CMI_SMS_TYPE_OF_NUM_ALPHANUMERIC = 5, /* Alphanumeric, GSM 7-bit */
|
||||
CMI_SMS_TYPE_OF_NUM_EXTENSION = 7 /* Reserved for Extension */
|
||||
|
||||
}CmiSmsTypeOfNumberEnum;
|
||||
|
||||
typedef enum CmiSmsNumberPlanIdEnum_Tag
|
||||
{
|
||||
CMI_SMS_NUM_PLAN_ID_UNKNOWN = 0, /* Unknown */
|
||||
CMI_SMS_NUM_PLAN_ID_ISDN_TELEPHONY = 1, /* ISDN/telephony numbering plan */
|
||||
CMI_SMS_NUM_PLAN_ID_DATA = 3, /* Data Numbering Plan(X.121) */
|
||||
CMI_SMS_NUM_PLAN_ID_TELEX = 4, /* Telex Numbering Plan */
|
||||
CMI_SMS_NUM_PLAN_SERVICE_CENTRE_SPECIFIC = 5, /* Service Centre Specific plan */
|
||||
CMI_SMS_NUM_PLAN_ID_NATIONAL = 8, /* National Number Plan */
|
||||
CMI_SMS_NUM_PLAN_ID_PRIVATE = 9, /* Private Numbering Plan */
|
||||
CMI_SMS_NUM_PLAN_ID_ERMES = 10, /* ERMES numbering plan */
|
||||
CMI_SMS_NUM_PLAN_ID_RESERVED_FOR_EXTENSION = 15 /* Reserved for Extension */
|
||||
|
||||
}CmiSmsNumberPlanIdEnum;
|
||||
|
||||
typedef struct _EPAT_CmiSmsAddressType_Tag
|
||||
{
|
||||
UINT8 typeOfNumber; /* Type of Number CmiSmsTypeOfNumberEnum */
|
||||
UINT8 numberPlanId; /* Number Plan Identification CmiSmsNumberPlanIdEnum */
|
||||
UINT16 reserved0;
|
||||
}CmiSmsAddressType;
|
||||
|
||||
typedef struct _EPAT_CmiSmsAddressInfo_Tag
|
||||
{
|
||||
CmiSmsAddressType addressType; /* Address Type Information */
|
||||
UINT8 addressLength; /* Address Length in digits */
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
UINT8 addressDigits[CMI_SMS_MAX_LENGTH_OF_ADDRESS_VALUE]; /* Address digits */
|
||||
}CmiSmsAddressInfo;
|
||||
|
||||
typedef struct CmiSmsOptAddressInfo_Tag
|
||||
{
|
||||
BOOL present; /* Address info present or not */
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
CmiSmsAddressInfo addressInfo;
|
||||
}CmiSmsOptAddressInfo;
|
||||
|
||||
typedef enum CmiSmsRPCause_Tag
|
||||
{
|
||||
CMI_SMS_RP_CAUSE_UNASSIGNED_NUMBER = 1,
|
||||
CMI_SMS_RP_CAUSE_OPERATOR_DETERMIN_BARRING = 8,
|
||||
CMI_SMS_RP_CAUSE_BARRED = 10,
|
||||
CMI_SMS_RP_CAUSE_RESERVD = 11,
|
||||
CMI_SMS_RP_CAUSE_TRANSFER_REJECTED = 21,
|
||||
CMI_SMS_RP_CAUSE_NEMORY_EXCEED = 22,
|
||||
CMI_SMS_RP_CAUSE_DESTION_OUT_OF_ORDER = 27,
|
||||
CMI_SMS_RP_CAUSE_UNIDENTIFIED_FORMAT = 28,
|
||||
CMI_SMS_RP_CAUSE_FACILITY_REJECTED = 29,
|
||||
CMI_SMS_RP_CAUSE_UNKNOWN_SUBSCRIBER = 30,
|
||||
CMI_SMS_RP_CAUSE_NETWORK_OUT_OF_ORDER = 38,
|
||||
CMI_SMS_RP_CAUSE_TEMP_FAILURE = 41,
|
||||
CMI_SMS_RP_CAUSE_CONGETION = 42,
|
||||
CMI_SMS_RP_CAUSE_RESOURCE_UNAVAILABLE = 47,
|
||||
CMI_SMS_RP_CAUSE_REQ_FAC_NOT_SUBSCR = 50,
|
||||
CMI_SMS_RP_CAUSE_REQ_FACILITY_NOT_IMPLEMENT = 69,
|
||||
CMI_SMS_RP_CAUSE_INVALID_TI_VALUE = 81,
|
||||
CMI_SMS_RP_CAUSE_INVALID_MSG_SEMANTICALLY = 95,
|
||||
CMI_SMS_RP_CAUSE_MANDATORY_IE_ERROR = 96,
|
||||
CMI_SMS_RP_CAUSE_MSG_TYPE_NO_EXISTENT = 97,
|
||||
CMI_SMS_RP_CAUSE_MSG_NOT_COMPATIABLE = 98,
|
||||
CMI_SMS_RP_CAUSE_IE_NON_EXISTENT = 99,
|
||||
CMI_SMS_RP_CAUSE_PROTOCOL_ERROR = 111,
|
||||
CMI_SMS_RP_CAUSE_INTERWORKING = 127
|
||||
|
||||
}CmiSmsRPCause;
|
||||
|
||||
typedef struct CmiSmsSendMsgReq_Tag
|
||||
{
|
||||
CmiSmsOptAddressInfo optSca;
|
||||
CmiSmsPdu pdu;
|
||||
}CmiSmsSendMsgReq,CmiSmsSendStoredMsgReq;
|
||||
|
||||
typedef struct CmiSmsSendMsgCnf_Tag
|
||||
{
|
||||
UINT8 msgReference; /* Message Reference */
|
||||
UINT8 rpCause; /* RP cause */
|
||||
UINT8 tpCause; /* TP cause */
|
||||
BOOL ackPduPresent;
|
||||
UINT16 errorCode;
|
||||
UINT16 reserved1;
|
||||
CmiSmsPdu pdu;
|
||||
}CmiSmsSendMsgCnf, CmiSmsSendStoredMsgCnf, CmiSmsSendSMMACnf;
|
||||
|
||||
typedef struct CmiSmsRspInfo_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode; /* Error code */
|
||||
UINT8 msgReference; /* Message Reference */
|
||||
UINT8 rpCause; /* RP cause */
|
||||
UINT8 tpCause; /* TP cause */
|
||||
CmiSmsPdu pdu;
|
||||
}CmiSmsRspInfo;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_SEND_COMMAND_REQ
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct CmiSmsCmdRspInfo_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode;
|
||||
UINT8 msgReference; /* Message Reference */
|
||||
}CmiSmsCmdRspInfo;
|
||||
|
||||
typedef struct CmiSmsSendCommandReq_Tag
|
||||
{
|
||||
CmiSmsPdu pdu;
|
||||
}CmiSmsSendCommandReq;
|
||||
|
||||
typedef struct CmiSmsSendCommandCnf_Tag
|
||||
{
|
||||
UINT8 msgReference; /* Message Reference */
|
||||
BOOL ackPduPresent;
|
||||
CmiSmsPdu pdu;
|
||||
}CmiSmsSendCommandCnf;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_NEWMSG_IND
|
||||
******************************************************************************/
|
||||
typedef enum CmiSmsMsgCoding_Tag
|
||||
{
|
||||
CMI_SMS_CODING_DEFAULT_ALPHABET = 0, /* Default 7 bit coding */
|
||||
CMI_SMS_CODING_8_BIT_DATA = 1, /* 8bit coding */
|
||||
CMI_SMS_CODING_UCS2_ALPHABET = 3, /* UCS2 coding */
|
||||
|
||||
}CmiSmsMsgCoding;
|
||||
|
||||
typedef enum CmiSmsMessageType_Tag
|
||||
{
|
||||
CMI_SMS_TYPE_DELIVER = 0, /* SMS-Deliver PDU */
|
||||
CMI_SMS_TYPE_DELIVER_REPORT, /* SMS-Deliver Report PDU */
|
||||
CMI_SMS_TYPE_STATUS_REPORT, /* SMS-Status Report PDU */
|
||||
CMI_SMS_TYPE_CB_ETWS_CMAS, /* CB SMS */
|
||||
CMI_SMS_TYPE_SUBMIT, /* SMS-SUBMIT */
|
||||
CMI_SMS_TYPE_COMMAND, /* SMS-COMMAND */
|
||||
|
||||
CMI_SMS_TYPE_RESERVE
|
||||
}CmiSmsMessageType;
|
||||
|
||||
typedef enum CmiSmsMessageClass_Tag
|
||||
{
|
||||
CMI_SMS_MESSAGE_CLASS0 = 0x00,
|
||||
CMI_SMS_MESSAGE_CLASS1 = 0x01,
|
||||
CMI_SMS_MESSAGE_CLASS2 = 0x02,
|
||||
CMI_SMS_MESSAGE_CLASS3 = 0x03,
|
||||
CMI_SMS_NO_MESSAGE_CLASS,
|
||||
}CmiSmsMessageClass;
|
||||
|
||||
/* Refer to TS-27.005 3.4.1 <mt> SMS-DELIVER report mode configured by +CNMI
|
||||
* spec 27.005 Table 3.4.1-2 <mt> parameter
|
||||
*/
|
||||
typedef enum CmiSmsDeliverRptMode_Tag
|
||||
{
|
||||
CMI_SMS_DELIVER_RPT_MODE_0 = 0,
|
||||
CMI_SMS_DELIVER_RPT_MODE_1 = 1,
|
||||
CMI_SMS_DELIVER_RPT_MODE_2 = 2,
|
||||
CMI_SMS_DELIVER_RPT_MODE_3 = 3,
|
||||
CMI_SMS_DELIVER_RPT_RESERVE
|
||||
}CmiSmsDeliverRptMode;
|
||||
|
||||
/* Refer to TS-27.005 3.4.1 <bm> CBM(Cell Broadcast Message) report mode configured by +CNMI
|
||||
* spec 27.005 Table 3.4.1-4 <bm> parameter
|
||||
*/
|
||||
typedef enum CmiSmsCbmRptMode_Tag
|
||||
{
|
||||
CMI_SMS_CBM_RPT_MODE_0 = 0,
|
||||
CMI_SMS_CBM_RPT_MODE_1 = 1,
|
||||
CMI_SMS_CBM_RPT_MODE_2 = 2,
|
||||
CMI_SMS_CBM_RPT_MODE_3 = 3,
|
||||
CMI_SMS_CBM_RPT_RESERVE
|
||||
}CmiSmsCbmRptMode;
|
||||
|
||||
/* Refer to TS-27.005 3.4.1 <ds> SMS-STATUS-REPORTs report mode configured by +CNMI
|
||||
* spec 27.005 Table 3.4.1-5 <ds> parameter
|
||||
*/
|
||||
typedef enum CmiSmsStatusRptMode_Tag
|
||||
{
|
||||
CMI_SMS_STATUS_RPT_MODE_0 = 0,
|
||||
CMI_SMS_STATUS_RPT_MODE_1 = 1,
|
||||
CMI_SMS_STATUS_RPT_MODE_2 = 2,
|
||||
CMI_SMS_STATUS_RPT_RESERVE
|
||||
}CmiSmsStatusRptMode;
|
||||
|
||||
/* Refer to TS-27.005 3.1 Parameter definitions Parameter <mem1>/<mem2>/<mem3> */
|
||||
typedef enum CmiSmsStorage_Tag
|
||||
{
|
||||
CMI_SMS_STORAGE_BM = 0, /* BM(Broadcast Message) Storage */
|
||||
CMI_SMS_STORAGE_ME = 1, /* ME Storage */
|
||||
CMI_SMS_STORAGE_MT = 2, /* MT Storage */
|
||||
CMI_SMS_STORAGE_SM = 3, /* SIM Storage */
|
||||
CMI_SMS_STORAGE_TA = 4, /* TA message storage */
|
||||
CMI_SMS_STORAGE_SR = 5 /* SMS-Status Report Storage */
|
||||
|
||||
}CmiSmsStorage;
|
||||
|
||||
/* Display SMS content AT command */
|
||||
typedef enum CmiSmsDisplayCmd_Tag
|
||||
{
|
||||
CMI_SMS_SHOW_CMGR = 0, //+CMGR
|
||||
CMI_SMS_SHOW_CMGL = 1, //+CMGL
|
||||
CMI_SMS_SHOW_CMT = 2, //+CMT
|
||||
CMI_SMS_SHOW_CMTI = 3, //+CMTI
|
||||
CMI_SMS_SHOW_CBM = 4, //+CBM
|
||||
CMI_SMS_SHOW_CBMI = 5, //+CBMI
|
||||
CMI_SMS_SHOW_CDS = 6, //+CDS
|
||||
CMI_SMS_SHOW_CDSI = 7, //+CDSI
|
||||
CMI_SMS_SHOW_ECCMGR = 8, //+ECMGR
|
||||
CMI_SMS_DISPLAY_END
|
||||
|
||||
} CmiSmsDisplayCmd;
|
||||
|
||||
typedef struct CmiNewSmsInfo_Tag
|
||||
{
|
||||
UINT8 smsType; /* CmiSmsMessageType */
|
||||
UINT8 smsId;
|
||||
UINT8 smsCoding; /* CmiSmsMsgCoding */
|
||||
UINT8 smsClass; /* SmsMessageClass */
|
||||
}CmiNewSmsInfo;
|
||||
|
||||
typedef struct CmiSmsNewMsgInd_Tag
|
||||
{
|
||||
UINT8 smsType; /* CmiSmsMessageType */
|
||||
UINT8 smsId;
|
||||
UINT8 smsCoding; /* CmiSmsMsgCoding */
|
||||
UINT8 smsClass; /* SmsMessageClass */
|
||||
BOOL smscPresent;
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
CmiSmsAddressInfo smscAddress;
|
||||
CmiSmsPdu pdu;
|
||||
}CmiSmsNewMsgInd;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_NEW_MSG_MEM_LOCATION_IND
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsNewMsgMemLocationInd_Tag
|
||||
{
|
||||
UINT16 rc;
|
||||
UINT8 index;
|
||||
UINT8 operatmode; /* CmiSmsOperationMode */
|
||||
}CmiSmsNewMsgMemLocationInd;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_NEW_MSG_RSP
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsNewMsgRsp_Tag
|
||||
{
|
||||
BOOL bRPAck;
|
||||
UINT8 smsId;
|
||||
UINT8 tpCause;
|
||||
BOOL pduPresent;
|
||||
CmiSmsPdu pdu;
|
||||
}CmiSmsNewMsgRsp;
|
||||
|
||||
typedef CamCmiEmptySig CmiSmsGetScAddressRequest;
|
||||
|
||||
typedef struct CmiSmsGetScAddressConfirm_Tag
|
||||
{
|
||||
BOOL smscPresent;
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
CmiSmsAddressInfo smscAddress; /* Service center address */
|
||||
}CmiSmsGetScAddressConfirm;
|
||||
|
||||
typedef struct CmiSmsSetSmspRequest_Tag
|
||||
{
|
||||
BOOL destAddrPresent;
|
||||
BOOL protocolIdPresent;
|
||||
BOOL codingSchemePresent;
|
||||
BOOL validityPeriodPresent;
|
||||
CmiSmsAddressInfo destAddr;
|
||||
CmiSmsAddressInfo smscAddress; /* Service center address */
|
||||
UINT8 smsProtocolId;
|
||||
UINT8 smsDataCodingScheme;
|
||||
UINT8 validityPeriod;
|
||||
BOOL scAddrPresent;
|
||||
}CmiSmsSetSmspRequest;
|
||||
|
||||
typedef CamCmiEmptySig CmiSmsSetSmspCnfonfirm;
|
||||
|
||||
#define SMS_SERVICE_NUM 3
|
||||
|
||||
typedef enum CmiSmsMessageService_Tag
|
||||
{
|
||||
CMI_SMS_MESSAGE_SERVICE_NO_ACKNOWLEDGEMENT = 0, /* no acknowledgement */
|
||||
CMI_SMS_MESSAGE_SERVICE_ACKNOWLEDGEMENT = 1, /* acknowledgement */
|
||||
/* 2...127 reserved */
|
||||
CMI_SMS_MESSAGE_SERVICE_MANUFACTURER_SPECIFIC = 128 /* manufacturer specific */
|
||||
|
||||
}CmiSmsMessageService;
|
||||
|
||||
typedef struct CmiSmsTypesOfMessages_Tag
|
||||
{
|
||||
BOOL mtTypeSupported;
|
||||
BOOL moTypeSupported;
|
||||
BOOL bmTypeSupported;
|
||||
}CmiSmsTypesOfMessages;
|
||||
|
||||
typedef CamCmiEmptySig CmiSmsGetSupportedSmsServiceReq;
|
||||
|
||||
typedef struct CmiSmsGetSupportedSmsServiceCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode;
|
||||
UINT8 length;
|
||||
CmiSmsMessageService serviceList[SMS_SERVICE_NUM];
|
||||
}CmiSmsGetSupportedSmsServiceCnf;
|
||||
|
||||
typedef struct CmiSmsSelectMessageServiceReq_Tag
|
||||
{
|
||||
CmiSmsMessageService smsMsgService;
|
||||
}CmiSmsSelectMessageServiceReq;
|
||||
|
||||
typedef struct CmiSmsSelectMessageServiceCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode;
|
||||
CmiSmsTypesOfMessages typeOfMessage;
|
||||
}CmiSmsSelectMessageServiceCnf;
|
||||
|
||||
typedef CamCmiEmptySig CmiSmsGetCurrentSmsServiceReq;
|
||||
|
||||
typedef struct CmiSmsGetCurrentSmsServiceCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode;
|
||||
CmiSmsMessageService smsMsgService;
|
||||
CmiSmsTypesOfMessages typeOfMessage;
|
||||
}CmiSmsGetCurrentSmsServiceCnf;
|
||||
|
||||
typedef enum _SIG_EPAT_CCM_CFG_SMS_MORE_MSG_MODE
|
||||
{
|
||||
CMI_SMS_DISABLE_MORE_MESSAGE_SEND = 0, /* disable more message send */
|
||||
CMI_SMS_TEMP_MORE_MESSAGE_SEND = 1, /* keep enabled until UE close the link */
|
||||
CMI_SMS_ALWAYS_MORE_MESSAGE_SEND = 2, /* keep enabled until UE set AT+CMMS=0 or 1 */
|
||||
CMI_SMS_ERROR_MORE_MESSAGE_SEND = 255
|
||||
|
||||
}CmiSmsMoreMessage;
|
||||
|
||||
typedef struct CmiSmsSetMoreMessageReq_Tag
|
||||
{
|
||||
CmiSmsMoreMessage smsMoreMsgMode;
|
||||
}CmiSmsSetMoreMessageReq;
|
||||
|
||||
typedef CamCmiEmptySig CmiSmsSetMoreMessageModeCnf;
|
||||
|
||||
typedef CamCmiEmptySig CmiSmsGetMoreMessageModeReq;
|
||||
|
||||
typedef struct CmiSmsGetMoreMessageModeCnf_Tag
|
||||
{
|
||||
UINT8 smsMoreMsgMode;
|
||||
}CmiSmsGetMoreMessageModeCnf;
|
||||
|
||||
#define CI_SMS_SIGNAL_NUM_MAX 5
|
||||
#define CI_SMS_RANGE_LIST_MAX 5
|
||||
|
||||
|
||||
typedef struct CmiSmsNumberRange_Tag
|
||||
{
|
||||
UINT32 min;
|
||||
UINT32 max;
|
||||
}CmiSmsNumberRange;
|
||||
|
||||
typedef struct CmiSmsNumberList_Tag
|
||||
{
|
||||
BOOL bSignalNum;
|
||||
BOOL bRangeNum;
|
||||
UINT8 rangeLen;
|
||||
UINT8 signalNum;
|
||||
UINT32 signalNumList[CI_SMS_SIGNAL_NUM_MAX];
|
||||
CmiSmsNumberRange rangeList[CI_SMS_RANGE_LIST_MAX];
|
||||
}CmiSmsNumberList;
|
||||
|
||||
typedef struct CmiSmsSetCscbSettingReq_Tag
|
||||
{
|
||||
BOOL mode;
|
||||
UINT8 rsv0;
|
||||
UINT16 rsv1;
|
||||
CmiSmsNumberList mids;
|
||||
CmiSmsNumberList dcss;
|
||||
}CmiSmsSetCscbSettingReq;
|
||||
|
||||
typedef CamCmiEmptySig CmiSmsGetCscbSettingReq;
|
||||
|
||||
typedef struct CmiSmsSetCscbSettingCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode;
|
||||
UINT16 reserved;
|
||||
}CmiSmsSetCscbSettingCnf;
|
||||
|
||||
typedef struct CmiSmsGetCscbSettingCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode;
|
||||
BOOL mode;
|
||||
CmiSmsNumberList mids;
|
||||
CmiSmsNumberList dcss;
|
||||
}CmiSmsGetCscbSettingCnf;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_GET_SMS_MSG_RECORD_REQ
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsGetSmsMsgRecReq_Tag
|
||||
{
|
||||
UINT8 index; /* the specified index to read SIM */
|
||||
UINT8 operatmode; /* CmiSmsOperationMode */
|
||||
UINT16 reserved;
|
||||
}CmiSmsGetSmsMsgRecReq;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_GET_SMS_MSG_RECORD_CNF
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct CmiSmsReadSmsRecRspInfo_Tag
|
||||
{
|
||||
INT8 index; /* The index which was provided by SIM */
|
||||
UINT8 smsStatus; /* SMS record status. CmiSmsRecStorStatus */
|
||||
BOOL scAddrPresent; /* SC Address info present or not */
|
||||
UINT8 operatmode; /* CmiSmsOperationMode */
|
||||
CmiSmsAddressInfo scAddrInfo; /* SC address info */
|
||||
CmiSmsPdu smsPduData; /* SMS PDU contents */
|
||||
}CmiSmsReadSmsRecRspInfo;
|
||||
|
||||
typedef struct CmiSmsGetSmsMsgRecCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode; /* Response result */
|
||||
UINT8 operatmode; /* CmiSmsOperationMode */
|
||||
UINT8 smsStatus; /* SMS record status. CmiSmsRecStorStatus */
|
||||
UINT8 smsMsgType; /* SMS message type, defined type CmiSmsMessageType */
|
||||
BOOL scAddrPresent; /* SC Address info present or not */
|
||||
UINT16 reserved;
|
||||
CmiSmsAddressInfo scAddrInfo; /* SC address info */
|
||||
CmiSmsPdu smsPduData; /* SMS PDU contents */
|
||||
}CmiSmsGetSmsMsgRecCnf;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_SET_SMS_MSG_RECORD_REQ
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsSetSmsMsgRecReq_Tag
|
||||
{
|
||||
UINT8 operatmode; /* CmiSmsOperationMode */
|
||||
UINT8 smsStatus; /* SMS record status. CmiSmsRecStorStatus */
|
||||
UINT16 reserved;
|
||||
CmiSmsAddressInfo scAddrInfo; /* SC address info */
|
||||
CmiSmsPdu smsPduData; /* SMS PDU contents */
|
||||
|
||||
}CmiSmsSetSmsMsgRecReq;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_SET_SMS_MSG_RECORD_CNF
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsSetSmsMsgRecCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode; /* response result */
|
||||
UINT8 index; /* the index which was provided by SIM */
|
||||
UINT8 operatmode; /* CmiSmsOperationMode */
|
||||
|
||||
}CmiSmsSetSmsMsgRecCnf;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_DEL_SMS_MSG_RECORD_REQ
|
||||
******************************************************************************/
|
||||
|
||||
/*for AT+CMGD, <delflag> see TS-27.005 3.5.4 */
|
||||
typedef enum CmiSmsDelFlag_Tag
|
||||
{
|
||||
CMI_SMS_DEL_FLAG_INDEX = 0, /* delete the message specified in index*/
|
||||
CMI_SMS_DEL_FLAG_STATUS_1 = 1, /* delete all Read message from the message storage */
|
||||
CMI_SMS_DEL_FLAG_STATUS_2 = 2, /* delete all Read message and sent mobile originated message */
|
||||
CMI_SMS_DEL_FLAG_STATUS_3 = 3, /* delete all read message, sent MO message and unsent mobile originated message */
|
||||
CMI_SMS_DEL_FLAG_ALL = 4, /* delete all message */
|
||||
|
||||
CMI_SMS_DEL_FLAG_UNKNOWN
|
||||
}CmiSmsDelFlag;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_DEL_SMS_MSG_RECORD_REQ
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct CmiSmsDelSmsMsgRecReq_Tag
|
||||
{
|
||||
UINT8 index; /* the specified index to delete SIM */
|
||||
UINT8 delFlag; /* CmiSmsDelFlag */
|
||||
UINT16 reserved;
|
||||
}CmiSmsDelSmsMsgRecReq;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_DEL_SMS_MSG_RECORD_CNF
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct CmiSmsDelSmsMsgRecCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode;
|
||||
UINT16 reserved;
|
||||
}CmiSmsDelSmsMsgRecCnf;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_LIST_SMS_MSG_RECORD_REQ
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsListSmsMsgRecReq_Tag
|
||||
{
|
||||
UINT8 listStuts; /* CmiSmsRecStorStatus the specified status which need to list */
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
}CmiSmsListSmsMsgRecReq;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_LIST_SMS_MSG_RECORD_CNF
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsListSmsMsgRecCnf_Tag
|
||||
{
|
||||
CmiSmsErrorCode errorCode;
|
||||
UINT8 endStatus; /* where or not is the last item */
|
||||
BOOL scAddrPresent; /* SC Address info present or not */
|
||||
|
||||
UINT8 index; /* the index of the SMS reocord in SIM */
|
||||
UINT8 smsStatus; /* SMS record status. CmiSmsRecStorStatus */
|
||||
UINT8 smsMsgType; /* SMS message type, defined type CmiSmsMessageType */
|
||||
UINT8 reserved0;
|
||||
|
||||
CmiSmsAddressInfo scAddrInfo; /* SC address info */
|
||||
CmiSmsPdu smsPduData; /* SMS PDU contents */
|
||||
|
||||
}CmiSmsListSmsMsgRecCnf;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_GET_SMS_STORAGE_STATUS_REQ
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsGetStorageStatusReq_Tag
|
||||
{
|
||||
UINT8 operatmode; /* CmiSmsOperationMode */
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
}CmiSmsGetStorageStatusReq;
|
||||
|
||||
#define CI_SMS_RECORD_MAX_NUMBER 254 /* The total number of the saved SMS message in SIM */
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_GET_SMS_STORAGE_STATUS_CNF
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsGetStorageStatusCnf_Tag
|
||||
{
|
||||
UINT8 operatmode; /* CmiSmsOperationMode */
|
||||
UINT8 usedNumOfSim;
|
||||
UINT8 totalNumOfSim;
|
||||
UINT8 reserved;
|
||||
UINT8 usedIndexOfSim[CI_SMS_RECORD_MAX_NUMBER];
|
||||
}CmiSmsGetStorageStatusCnf;
|
||||
|
||||
|
||||
typedef CamCmiEmptySig CmiSmsSendSMMARequest;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_MEM_CAP_IND
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsMemCapInd_Tag
|
||||
{
|
||||
BOOL smsMemCapExceed;
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
}CmiSmsMemCapInd;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_SET_MEM_CAP_REQ, CMI_SMS_SET_MEM_CAP_CNF
|
||||
******************************************************************************/
|
||||
typedef struct CmiSmsSetMemCapReq_Tag
|
||||
{
|
||||
BOOL isMemCapExceed;
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
}CmiSmsSetMemCapReq, CmiSmsSetMemCapCnf;
|
||||
|
||||
/******************************************************************************
|
||||
* CMI_SMS_IDLE_STATUS_IND
|
||||
******************************************************************************/
|
||||
typedef CamCmiEmptySig CmiSmsIdleStatusInd;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
#ifndef NETIF_ADPT_HDR_API_H
|
||||
#define NETIF_ADPT_HDR_API_H
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2021- Copyrights of AirM2M Ltd.
|
||||
File name: - netifadptapi.h
|
||||
Description: - netif adpt common api header
|
||||
History: - 03/04/2021, Originated by xwang
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#include "pspdu.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#define NETIF_DLPDUBLOCK_SIZE sizeof(DlPduBlock)
|
||||
|
||||
#define NETIF_UL_BUFF_RSVD_RNDIS_HDR_LEN 44
|
||||
#define NETIF_UL_BUFF_RSVD_RNDIS_TAILER_LEN 8
|
||||
#define NETIF_UL_BUFF_RSVD_PPP_HDR_LEN 8
|
||||
#define NETIF_UL_BUFF_RSVD_PPP_TAILER_LEN 4;
|
||||
|
||||
#define NETIF_UL_DL_TCP_MSS_CHECK 1
|
||||
|
||||
#define NETIF_DL_TCP_WINDOWS_ADPT 1
|
||||
|
||||
#define NETIF_DL_TCP_MAX_WINDOWS 0xFFFF
|
||||
|
||||
#define NETIF_TCP_MAX_SCALE_VALUE 14
|
||||
|
||||
typedef enum NetIfRetEnum_Tag
|
||||
{
|
||||
NETIF_SUCC = 0,
|
||||
NETIF_ERROR
|
||||
}NetIfRetEnum;
|
||||
|
||||
// lan netif type
|
||||
typedef enum NetifType_Tag
|
||||
{
|
||||
NETIF_TYPE_INVALID = 0,
|
||||
NETIF_TYPE_PS_WAN = 1,
|
||||
NETIF_TYPE_RNDIS_LAN = 2,
|
||||
NETIF_TYPE_PPP_LAN = 3,
|
||||
}NetifType;
|
||||
|
||||
|
||||
typedef UINT8 NetIfRet;
|
||||
|
||||
//ip4 pkg input process result
|
||||
typedef enum NetifIp4InputResult_Tag
|
||||
{
|
||||
NETIF_IP4_INPUT_RESULT_DISCARD = 0,
|
||||
NETIF_IP4_INPUT_RESULT_LOCAL_INPUT = 1,
|
||||
NETIF_IP4_INPUT_RESULT_FORWARD_WAN = 2,
|
||||
NETIF_IP4_INPUT_RESULT_FORWARD_LAN = 3,
|
||||
NETIF_IP4_INPUT_RESULT_FORWARD_LAN_ETH = 4,
|
||||
NETIF_IP4_INPUT_RESULT_FORWARD_LAN_PPP = 5,
|
||||
NETIF_IP4_INPUT_RESULT_FORWARD_LAN_AND_INPUT = 6,
|
||||
NETIF_IP4_INPUT_RESULT_FORWARD_LAN_ETH_AND_INPUT = 7,
|
||||
NETIF_IP4_INPUT_RESULT_FORWARD_LAN_PPP_AND_INPUT = 8,
|
||||
NETIF_IP4_INPUT_RESULT_FORWARD_WAN_AND_INPUT = 9,
|
||||
NETIF_IP4_INPUT_RESULT_FORWAD_WAN_AND_DNS_RELAY_CHECK = 10,
|
||||
NETIF_IP4_INPUT_RESULT_FORWAD_LAN_AND_DNS_RELAY_CHECK = 11,
|
||||
NETIF_IP4_INPUT_RESULT_FORWAD_LAN_ETH_AND_DNS_RELAY_CHECK = 12,
|
||||
NETIF_IP4_INPUT_RESULT_FORWAD_LAN_PPP_AND_DNS_RELAY_CHECK = 13,
|
||||
NETIF_IP4_INPUT_RESULT_FAIL = 14,
|
||||
}NetifIp4InputResult;
|
||||
|
||||
|
||||
/*
|
||||
* DL PDU block list
|
||||
*/
|
||||
typedef struct NetifDlPduList_Tag
|
||||
{
|
||||
UINT16 pkgNum;
|
||||
UINT16 rsvd;
|
||||
|
||||
DlPduBlock *pHead;
|
||||
DlPduBlock *pTail;
|
||||
}NetifDlPduList; //12 bytes
|
||||
|
||||
/*
|
||||
* UL PDU block list
|
||||
*/
|
||||
typedef struct NetifUlPduList_Tag
|
||||
{
|
||||
UINT16 pkgNum;
|
||||
UINT16 pkgLen;
|
||||
|
||||
UlPduBlock *pHead;
|
||||
UlPduBlock *pTail;
|
||||
}NetifUlPduList; //12 bytes
|
||||
|
||||
/*
|
||||
* NETIF_UL_PDU_LIST_ADD_ONE(NetifUlPduList *pUlList, UlPduBlock *pPkgHead, UlPduBlock *pPkgTail, UINT16 pkgLen)
|
||||
*/
|
||||
#define NETIF_UL_PDU_LIST_ADD_ONE(PULLIST, PPKGHEAD, PPKGTAIL, PKGLEN) \
|
||||
do { \
|
||||
OsaSingleLinkAddList((PULLIST)->pHead, (PULLIST)->pTail, (PPKGHEAD), (PPKGTAIL)); \
|
||||
(PULLIST)->pkgNum += 1; \
|
||||
(PULLIST)->pkgLen += (PKGLEN); \
|
||||
}while(FALSE)
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetifUpdateFastPathChkInfo
|
||||
* Description: update fast path chk info
|
||||
* input:
|
||||
* output:
|
||||
* Comment: it will be called for these cases as below:
|
||||
* 1. wan link up /link down(ipv6 maybe link up delay)
|
||||
* 2. lan link up/link down
|
||||
* 3. lan link layer status change
|
||||
* 4. lan netif related arp cache update
|
||||
* 5. lan netif related ndp cache update(ToDo: ndp cache timeout)
|
||||
******************************************************************************/
|
||||
void NetifUpdateFastPathChkInfo(void);
|
||||
|
||||
/******************************************************************************
|
||||
* NetGetLanNetif
|
||||
* Description: netmgr adpt get system bind LAN netif by ip4 wan netif
|
||||
* input:
|
||||
* output:struct netif *
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
struct netif *NetGetBindLanNetifByIp4WanNetif(struct netif *wanNetif);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetGetLanNetif
|
||||
* Description: netmgr adpt get system bind LAN netif by ip6 wan netif
|
||||
* input:
|
||||
* output:struct netif *
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
struct netif *NetGetBindLanNetifByIp6WanNetif(struct netif *wanNetif);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetGetLanNetif
|
||||
* Description: netmgr adpt get system bind WAN ip4 netif by lan netif
|
||||
* input:
|
||||
* output:struct netif *
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
struct netif *NetGetBindIp4WanNetifByLanNetif(struct netif *lanNetif);
|
||||
|
||||
/******************************************************************************
|
||||
* NetGetLanNetif
|
||||
* Description: netmgr adpt get system bind WAN ip6 netif by lan netif
|
||||
* input:
|
||||
* output:struct netif *
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
struct netif *NetGetBindIp6WanNetifByLanNetif(struct netif *lanNetif);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetifUlGetOnePkg
|
||||
* Description: get one whole pkg from "UlPduBlock" list, and return to next pkg head
|
||||
* input: UlPduBlock *pUlHdr //in
|
||||
* UlPduBlock **ppOnePkgHead //out
|
||||
* UlPduBlock **ppOnePkgTail //out
|
||||
* UINT16 *pPkgLen //out
|
||||
* output: UlPduBlock*
|
||||
******************************************************************************/
|
||||
UlPduBlock* NetifUlGetOnePkg(UlPduBlock *pUlHdr,
|
||||
UlPduBlock **ppOnePkgHead,
|
||||
UlPduBlock **ppOnePkgTail,
|
||||
UINT16 *pPkgLen);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetifLanDlOnePkgDataReq
|
||||
* Description: provide by ppp service, lwip send IP pkg to ppp/rndis service by this API
|
||||
* input: DlPduBlock *pDlPdu
|
||||
* output:
|
||||
* Comment:
|
||||
* Called by tcpip statck (ppp netif adpt layer)
|
||||
******************************************************************************/
|
||||
void NetifLanDlOnePkgDataReq(UINT8 lanNetifType, DlPduBlock *pDlPdu);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetifDumpUlPacket
|
||||
* Description: netif dump UL data(ulpdu buffer)
|
||||
* input: UlPduBlock *ulData, UINT8 type(lwip_netif_type_t)
|
||||
* output:
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void NetifDumpUlPduPacket(UlPduBlock *ulData, UINT8 type);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetifDumpDlPduPacket
|
||||
* Description: netif dump DL data(dlpdu buffer)
|
||||
* input: DlPduBlock *dlData, UINT8 type(lwip_netif_type_t)
|
||||
* output:
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void NetifDumpDlPduPacket(DlPduBlock *dlData, UINT8 type);
|
||||
|
||||
/******************************************************************************
|
||||
* NetifDumpDlPbufPacket
|
||||
* Description: netif dump DL data(pbuf buffer)
|
||||
* input: struct pbuf *pbufdata, UINT8 type(lwip_netif_type_t)
|
||||
* output:
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void NetifDumpDlPbufPacket(struct pbuf *pbufData, UINT8 type);
|
||||
|
||||
/******************************************************************************
|
||||
* NetifDumpUlPbufPacket
|
||||
* Description: netif dump UL data(pbuf buffer)
|
||||
* input: struct pbuf *pbufdata, UINT8 type(lwip_netif_type_t)
|
||||
* output:
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
void NetifDumpUlPbufPacket(struct pbuf *pbufData, UINT8 type);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetifCopyDataFromUlPdu
|
||||
* Description:
|
||||
* input: UlPduBlock *pUlPdu
|
||||
* output:UINT16
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
UINT16 NetifCopyDataFromUlPdu(UINT8 *payload, UlPduBlock *pUlPdu);
|
||||
|
||||
/******************************************************************************
|
||||
* NetifProcessIp4InputPkg
|
||||
* Description:
|
||||
* input: struct netif *inp, struct pbuf *p
|
||||
* output:UINT8
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* NetGetLanNetif
|
||||
* Description: netmgr adpt get system bind LAN channel id by LAN netif
|
||||
* input:
|
||||
* output:struct netif *
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
UINT8 NetGetBindLanChannelIdByLanNetif(struct netif *pLanNetif);
|
||||
|
||||
UINT8 NetifProcessIp4InputPkg(struct netif *inp, struct pbuf *p);
|
||||
|
||||
|
||||
err_t NetifLanTcpipInput(u8_t lanType, UlPduBlock *pPduHdr);
|
||||
|
||||
/*
|
||||
*/
|
||||
void NetifLanDlPkgListOutput(UINT8 lanNetifType, UINT16 pkgNum, DlPduBlock *pHead, DlPduBlock *pTail);
|
||||
|
||||
/*
|
||||
*/
|
||||
void NetifLanDlPkgListGet(UINT8 lanType, DlPduBlock **ppHead, DlPduBlock **ppTail);
|
||||
|
||||
void NetifIp4PkgFwdWanFromLanSrcAddrProcess(struct pbuf *p, struct netif *wanIf, struct netif *lanIf, ip4_addr_t *srcAddr);
|
||||
|
||||
void NetifIp4PkgFwdLanFromWanDestAddrProcess(struct pbuf *p, struct netif *wanIf, struct netif *lanIf, ip4_addr_t *destAddr);
|
||||
|
||||
UINT8 *NetifParseTcpOption(UINT8 *pOption, UINT16 len, UINT8 type, UINT8 **pPreOption);
|
||||
|
||||
UINT16 NetifUpdateTcpIpCheckSumUint16(UINT16 oldChkSum, UINT16 oldValue, UINT16 newValue);
|
||||
|
||||
UINT16 NetifUpdateTcpIpCheckSumUint32(UINT16 oldChkSum, UINT32 oldValue, UINT32 newValue);
|
||||
|
||||
BOOL NetifCopyDataToUlPdu(UlPduBlock *pUlPdu, UINT16 offset, UINT8 *pIn, UINT16 length);
|
||||
|
||||
BOOL NetifDnsRelayWanProcess(struct netif *wanIf, struct netif *lanIf, struct pbuf *p, ip4_addr_t *srcAddr);
|
||||
|
||||
BOOL NetifDnsRelayLanProcess(struct netif *lanIf, struct netif *wanIf, struct pbuf *p, ip4_addr_t *destAddr);
|
||||
|
||||
void NetifDlTcpDisableWSOption(UINT8 *pTransport);
|
||||
|
||||
err_t NetifProcessIp6TcpSyncInputPkg(struct pbuf *pbuf, UINT8 lanType);
|
||||
|
||||
void NetifClearPortMappingTable(UINT8 connSource, UINT8 cid);
|
||||
|
||||
struct netif *NetGetBindLanNetifByIp4WanNetifAndLanType(struct netif *wanNetif, UINT8 lanNetifType);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,936 @@
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2018- Copyrights of AirM2M Ltd.
|
||||
File name: - networkmgr.h
|
||||
Description: - network data path mange related function header
|
||||
History: - 01/02/2018, Originated by xwang
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#ifndef TCPIP_NETWORK_MGR_H
|
||||
#define TCPIP_NETWORK_MGR_H
|
||||
|
||||
/*
|
||||
* !!! note, this is the header file which provide to app/cms/at/ccio, and should be opened in SDK !!!
|
||||
* !!! not suggect to include more other header filer !!!
|
||||
*/
|
||||
#include "commontypedef.h"
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "netif/ethernet.h"
|
||||
#include "cmips.h"
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
#define NM_ADDR_MAX_LENGTH 16
|
||||
|
||||
/*
|
||||
* set bit B to 1 in D
|
||||
* example:
|
||||
* NmBit1Set(0x00, 0) = 0x01
|
||||
* NmBit1Set(0x01, 4) = 0x11
|
||||
*/
|
||||
#define NmBit1Set(D, B) ((D) |= (1<<(B)))
|
||||
|
||||
/*
|
||||
* set bit B to 0 in D
|
||||
* example:
|
||||
* NmBit0Set(0xFF, 0) = 0xFE
|
||||
* NmBit0Set(0xFE, 4) = 0xEE
|
||||
*/
|
||||
#define NmBit0Set(D, B) ((D) &= (~(1<<(B))))
|
||||
|
||||
|
||||
#define NM_MAGIC_WORD 0xA5B7
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT/ENUM
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* the action result
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NM_SUCCESS = 0,
|
||||
NM_FAIL = 1,
|
||||
}NmResult;
|
||||
|
||||
/*
|
||||
* NM NET type
|
||||
*/
|
||||
typedef enum _EPAT_NmNetIpType_tag
|
||||
{
|
||||
NM_NET_TYPE_INVALID = 0, //net not available
|
||||
NM_NET_TYPE_IPV4 = 1, //ipv4 available
|
||||
NM_NET_TYPE_IPV6 = 2, //ipv6 available
|
||||
NM_NET_TYPE_IPV4V6 = 3, //ipv4&ipv6 available
|
||||
NM_NET_TYPE_IPV6preparing = 4, //ipv6 preparing
|
||||
NM_NET_TYPE_IPV4_IPV6preparing = 5, //ipv4 available &ipv6 preparing
|
||||
}NmNetIpType;
|
||||
|
||||
/*
|
||||
* the ip address type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NM_ADDR_INVALID_ADDR = 0,
|
||||
NM_ADDR_IPV4_ADDR, // 4 bytes length
|
||||
NM_ADDR_IPV6_ID, //8 bytes length
|
||||
NM_ADDR_FULL_IPV6_ADDR //16 bytes length
|
||||
}NmAddrType;
|
||||
|
||||
/*
|
||||
*NM LAN type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NM_LAN_TYPE_INVALID = 0,
|
||||
NM_LAN_TYPE_RNDIS,
|
||||
NM_LAN_TYPE_ECM,
|
||||
NM_LAN_TYPE_PPP,
|
||||
}NmLanType;
|
||||
|
||||
/*
|
||||
*NM LAN NET type
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NM_LAN_NET_TYPE_INVALID = 0,
|
||||
NM_LAN_NET_TYPE_ETH,
|
||||
NM_LAN_NET_TYPE_PPP,
|
||||
}NmLanNetType;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* NM LAN link layer status type:
|
||||
* RNDIS/ECM, HOST and UE Link/connection state
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NM_LAN_LINK_STATUS_DISCONNECTED,
|
||||
NM_LAN_LINK_STATUS_CONNECTED,
|
||||
}NmLanLinkStatus;
|
||||
|
||||
/*
|
||||
* NM LAN data path status
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NM_LAN_NET_DEACTIVED, //lan data path is deactive, init state, or LAN is linkdown by CCIO
|
||||
NM_LAN_NET_ACTIVED, //lan data path is active, LAN is linkup by CCIO
|
||||
NM_LAN_NET_ACTIVED_AND_CHANGED, //lan data path is active and changed, such as ipv4 ready change to ipv4ipv6 ready
|
||||
}NmLanNetStatus;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* NM ethernet LAN (RNDIS/ECM) data path ip4 mode (ip6 is always pass through mode)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NM_ETH_LAN_IP4_PATH_MODE_PASSTHROUGH = 0, //pass through mode
|
||||
NM_ETH_LAN_IP4_PATH_MODE_NAT, //nat mode
|
||||
}NmEthLanIp4PathMode;
|
||||
|
||||
|
||||
/*
|
||||
*NM LAN ctrl api
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NM_LAN_CTRL_ACTION_BIND = 0, //pass through mode
|
||||
NM_LAN_CTRL_ACTION_UNBIND, //nat mode
|
||||
}NmLanCtrlAction;
|
||||
|
||||
typedef struct NetMgrWanIpv6Info_Tag
|
||||
{
|
||||
ip6_addr_t ipv6GlobalAddr;
|
||||
ip6_addr_t ipv6LinklocalAddr;
|
||||
|
||||
UINT8 dnsNum;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
ip6_addr_t dns[NM_PDN_TYPE_MAX_DNS_NUM];
|
||||
}NetMgrWanIpv6Info; //52 bytes
|
||||
|
||||
|
||||
typedef struct NetMgrWanIpv4Info_Tag
|
||||
{
|
||||
ip4_addr_t ipv4Addr;
|
||||
|
||||
UINT8 dnsNum;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
ip4_addr_t dns[NM_PDN_TYPE_MAX_DNS_NUM];
|
||||
}NetMgrWanIpv4Info; //16 bytes
|
||||
|
||||
|
||||
typedef struct NetMgrWanInfo_Tag
|
||||
{
|
||||
UINT8 ipType;
|
||||
UINT8 ipv4Cid;
|
||||
UINT8 ipv6Cid;
|
||||
BOOL bEnableRohc;
|
||||
|
||||
NetMgrWanIpv4Info wanIpv4Info;
|
||||
NetMgrWanIpv6Info wanIpv6Info;
|
||||
}NetMgrWanInfo;
|
||||
|
||||
typedef struct NetMgrLanIPv6Info_Tag
|
||||
{
|
||||
ip6_addr_t ipv6GlobalAddr;
|
||||
ip6_addr_t ipv6LinklocalAddr;
|
||||
}NetMgrLanIPv6Info;
|
||||
|
||||
typedef struct NetMgrLanIPv4Info_Tag
|
||||
{
|
||||
ip4_addr_t ipv4Addr;
|
||||
}NetMgrLanIPv4Info;
|
||||
|
||||
typedef struct NetMgrRndisLanInfo_Tag
|
||||
{
|
||||
UINT8 ipType;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
|
||||
NetMgrLanIPv4Info lanIpv4Info;
|
||||
NetMgrLanIPv6Info lanIpv6Info;
|
||||
|
||||
UINT8 etherAddr[ETH_HWADDR_LEN];
|
||||
}NetMgrRndisLanInfo;
|
||||
|
||||
typedef struct NetMgrPppLanInfo_Tag
|
||||
{
|
||||
UINT8 ipType;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
|
||||
NetMgrLanIPv4Info lanIpv4Info;
|
||||
NetMgrLanIPv6Info lanIpv6Info;
|
||||
}NetMgrPppLanInfo;
|
||||
|
||||
typedef struct NetMgrLanInfo_Tag
|
||||
{
|
||||
UINT8 type;
|
||||
union
|
||||
{
|
||||
NetMgrRndisLanInfo rndisLanInfo;
|
||||
NetMgrPppLanInfo pppLanInfo;
|
||||
}lanInfo;
|
||||
}NetMgrLanInfo;
|
||||
|
||||
|
||||
|
||||
typedef struct NetMgrEthLanCfg_Tag
|
||||
{
|
||||
UINT8 ethLanIp4PathMode; //NmEthLanIp4PathMode, nat/passthrough mode
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
|
||||
ip4_addr_t ethLocalAddr; //Ethernet LAN netif (ECM/RNDIS) address, example: 192.168.10.1
|
||||
ip4_addr_t ethHostAddr; //host lan netif(ECM/RNDIS) address, if NAT mode, example: 192.168.10.5
|
||||
ip4_addr_t ethHostNetMask; //host lan netif(ECM/RNDIS) netmask.if NAT mode, example:255.255.255.0; if the setting is 0.0.0.0, ue will use the deault value
|
||||
}NetMgrEthLanCfg; // 12 bytes
|
||||
|
||||
#if 0
|
||||
typedef struct NetMgrPppLanCfg_Tag
|
||||
{
|
||||
ip4_addr_t pppLocalAddr; //PPP LAN netif address, should not same as: "ethLocalAddr", example: 192.168.20.1
|
||||
}NetMgrPppLanCfg;
|
||||
#endif
|
||||
|
||||
typedef struct NetMgrLanCfg_Tag
|
||||
{
|
||||
NetMgrEthLanCfg ethLanCfg;
|
||||
//NetMgrPppLanCfg pppLanCfg;
|
||||
}NetMgrLanCfg; // 12 bytes
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
typedef struct NetMgrLanDataPathCap_Tag
|
||||
{
|
||||
UINT8 lanType; /* NmNetLanType */
|
||||
BOOL bConnected; /* Whether LAN is connected/disconnected
|
||||
* 1> if connected, CCIO need to try linkup LAN, if ethernet(RNDID/ECM)/PPP enabled
|
||||
* 2> if disconnected, CCIO need to linkdown LAN
|
||||
*/
|
||||
UINT16 rsvd0;
|
||||
|
||||
/*
|
||||
* Some basic lan info
|
||||
*/
|
||||
UINT8 lanIpType; /* NmNetIpType */
|
||||
UINT8 lanBindIp4Cid; /* If not bind, set to : 0xFF */
|
||||
UINT8 lanBindIp6Cid; /* If not bind, set to : 0xFF */
|
||||
UINT8 rsvd1;
|
||||
}NetMgrLanDataPathCap;
|
||||
|
||||
/*
|
||||
* When LAN (PPP/RNDIS/ECM) state changes (connect/disconnect) need to notify CCIO
|
||||
*/
|
||||
//void radioDevNotifyTcpipDataPathCapability(NetMgrLanDataPathCap *pLanDataPathCap);
|
||||
|
||||
/*
|
||||
* query the lan tcpip data path capability, called by CCIO, to descide whether can do lan link up
|
||||
*/
|
||||
//NmResult NetMgrQueryLanTcpipDataPathCapability(NmLanType lanType, NetMgrLanDataPathCap *pLanDataPathCap);
|
||||
|
||||
|
||||
/*
|
||||
*NM LAN channel TCPIP data path status
|
||||
*/
|
||||
typedef struct NetMgrLanChannelTcpipDataPathStatus_Tag
|
||||
{
|
||||
UINT8 status; /* NmLanNetStatus, event status with (NM_LAN_NET_DEACTIVED/NM_LAN_NET_ACTIVED/NM_LAN_NET_ACTIVED_AND_CHANGED);
|
||||
* query return (NM_LAN_NET_DEACTIVED/NM_LAN_NET_ACTIVED)
|
||||
*/
|
||||
UINT8 lanIpType; /* NmNetIpType */
|
||||
UINT8 lanBindIp4Cid; /* If not bind, set to : 0xFF */
|
||||
UINT8 lanBindIp6Cid; /* If not bind, set to : 0xFF */
|
||||
}NetMgrLanChannelTcpipDataPathStatus;
|
||||
|
||||
/*
|
||||
/NM LAN channel TCPIP data path info(assign to host)
|
||||
*/
|
||||
typedef struct NetMgrLanTcpipDataPathHostInfo_Tag
|
||||
{
|
||||
/*
|
||||
* Some basic lan info
|
||||
*/
|
||||
UINT8 lanIpType; /* NmNetIpType */
|
||||
UINT8 lanBindIp4Cid; /* If not bind, set to : 0xFF */
|
||||
UINT8 lanBindIp6Cid; /* If not bind, set to : 0xFF */
|
||||
UINT8 rsvd1;
|
||||
|
||||
ip4_addr_t hostIp4Addr; /*the ip4 address which will assigned to host*/
|
||||
UINT32 hostIp6Prefix[2]; /*the ip6 prefix which will assigned to host*/
|
||||
UINT32 hostIp6Id[2]; /*the ip6 ID which will assigned to host*/
|
||||
|
||||
ip4_addr_t hostIp4Dns[NM_PDN_TYPE_MAX_DNS_NUM]; /*the ip4 dns which will assigned to host*/
|
||||
ip6_addr_t hostIp6Dns[NM_PDN_TYPE_MAX_DNS_NUM]; /*the ip6 dns which will assigned to host*/
|
||||
|
||||
}NetMgrLanTcpipDataPathHostInfo;
|
||||
|
||||
/*
|
||||
*/
|
||||
typedef struct NmAtiLanInfo_Tag
|
||||
{
|
||||
UINT8 lanType; /*NmLanNetType, ETH/PPP LAN*/
|
||||
BOOL bound; /*whether current LAN , bind a WAN/netif */
|
||||
|
||||
UINT8 lanBindIp4Cid; /* If not bind, set to : 0xFF */
|
||||
UINT8 lanBindIp6Cid; /* If not bind, set to : 0xFF */
|
||||
}NmAtiLanInfo;
|
||||
|
||||
/*
|
||||
* notify the CMS/psdial the LAN info
|
||||
*/
|
||||
//void NetMgrNotifyAtiLanInfoInd(NmAtiLanInfo *pAtiLanInfo);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Net manager entity
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* PS NET status, status from CEREG
|
||||
*/
|
||||
typedef enum NmPsNetStatus_Tag
|
||||
{
|
||||
/*
|
||||
* PS is not registered, and UE is not under dialing
|
||||
*/
|
||||
NM_PS_NET_NOT_DIAL,
|
||||
|
||||
/*
|
||||
* 1> PS is not registered, but under registration
|
||||
* 2> and no ACT NETIF (bearer)
|
||||
*/
|
||||
NM_PS_NET_NOT_REG,
|
||||
|
||||
/*
|
||||
* 1> PS is OOS (out of service)
|
||||
* 2> and must have ACT NETIF (bearer);
|
||||
* 3> If no ACT NETIF (bearer), status need to change to "NM_PS_NET_NOT_REG"
|
||||
*/
|
||||
NM_PS_NET_OOS,
|
||||
|
||||
/*
|
||||
* PS is registered, and NETIF maybe comes later
|
||||
*/
|
||||
NM_PS_NET_REG
|
||||
}NmPsNetStatus;
|
||||
|
||||
typedef struct NmEntity_Tag
|
||||
{
|
||||
UINT8 psNetStatus; //NmPsNetStatus
|
||||
UINT8 rsvd0;
|
||||
|
||||
/*
|
||||
* CID valid value: 1 - 15;
|
||||
* If one CID (bearer) activated, related bit set to 1
|
||||
*/
|
||||
UINT16 actCidsBitmap;
|
||||
}NmEntity;
|
||||
|
||||
#if 0
|
||||
/******************************************************************************
|
||||
* A blocked callback designation, which called in LWIP task
|
||||
******************************************************************************/
|
||||
typedef enum NmBlockCallbackMsgId_Tag
|
||||
{
|
||||
NM_BLOCK_CB_INVALID_ID,
|
||||
NM_NET_LINK_UP,
|
||||
NM_NET_LINK_DOWN,
|
||||
NM_NET_LAN_LINK_UP,
|
||||
NM_NET_LAN_LINK_DOWN,
|
||||
NM_NET_LAN_LINK_LAYER_STATUS_CHANGE,
|
||||
NM_GET_NET_INFO,
|
||||
NM_CLEAR_DNS_CACHE,
|
||||
NM_GET_DNS_SERVER,
|
||||
NM_SET_DNS_SERVER,
|
||||
}NmBlockCallbackMsgId;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The ip address structure
|
||||
* NM_ADDR_IPV4_ADDR: 12~15:0 0~3:address
|
||||
* NM_ADDR_FULL_IPV6_ADDR: 0~15 prefix:id
|
||||
* NM_ADDR_IPV6_ID: 8~15:0 0~7:id
|
||||
*/
|
||||
typedef struct NmIpAddr_Tag
|
||||
{
|
||||
UINT8 addrType; //NmAddrType
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
UINT8 addr[NM_ADDR_MAX_LENGTH];
|
||||
}NmIpAddr; //20 bytes
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* PS netif configuration info
|
||||
* Use to link up one netif
|
||||
******************************************************************************/
|
||||
typedef struct NmIfConfiguration_Tag
|
||||
{
|
||||
UINT16 dnsNum : 3;
|
||||
UINT16 mtuPresent : 1; //if mtu is invalid ,this value will be zero
|
||||
UINT16 cgevReason: 4; //CmiPsPdnTypeReason
|
||||
UINT16 rsvd0 : 8;
|
||||
|
||||
UINT16 mtu;
|
||||
NmIpAddr ipv4Addr;
|
||||
NmIpAddr ipv6Addr;
|
||||
NmIpAddr dns[NM_MAX_DNS_NUM];
|
||||
}NmIfConfiguration; //124 bytes
|
||||
|
||||
|
||||
typedef struct NmNetIfDnsCfg_Tag{
|
||||
UINT8 dnsNum;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
ip_addr_t dns[NM_MAX_DNS_NUM];
|
||||
}NmNetIfDnsCfg; //84 bytes
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NM_ATI_SYNC_GET_NET_INFO_REQ
|
||||
******************************************************************************/
|
||||
typedef struct NmAtiGetNetInfoReq_Tag
|
||||
{
|
||||
/*
|
||||
* 1> If user want to get the default netif info, CID could set to "LWIP_PS_DEFAULT_CID", CID 0 is used for attached bearer (initial PDP context)
|
||||
* 2> Valid value: [LWIP_PS_MIN_VALID_CID - LWIP_PS_MAX_VALID_CID]/[0-15]
|
||||
*/
|
||||
UINT8 cid;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
}NmAtiGetNetInfoReq;
|
||||
|
||||
typedef struct NmAtiGetDnsServerReq_Tag
|
||||
{
|
||||
UINT8 cid;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
}NmAtiGetDnsServerReq;
|
||||
|
||||
typedef struct NmAtiSetDnsServerReq_Tag
|
||||
{
|
||||
UINT8 cid;
|
||||
NmNetIfDnsCfg dnsCfg;
|
||||
}NmAtiSetDnsServerReq;
|
||||
|
||||
typedef struct NmAtiClearDnsCacheReq_Tag
|
||||
{
|
||||
|
||||
BOOL bAll;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
CHAR name[DNS_MAX_NAME_LENGTH];
|
||||
}NmAtiClearDnsCacheReq;
|
||||
|
||||
typedef struct NmAtiSetDnsCacheReq_Tag
|
||||
{
|
||||
|
||||
BOOL bEanble;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
}NmAtiSetDnsCacheReq;
|
||||
|
||||
typedef struct NmAtiGetLanDataPathCapReq_Tag
|
||||
{
|
||||
UINT8 lanType; //NmLanNetType
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
}NmAtiGetLanDataPathCapReq;
|
||||
|
||||
typedef struct NmAtiGetLanDataPathStatusReq_Tag
|
||||
{
|
||||
UINT8 lanType; //NmLanNetType
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
}NmAtiGetLanDataPathStatusReq;
|
||||
|
||||
typedef struct NmAtiGetLanDataPathHostInfoReq_Tag
|
||||
{
|
||||
UINT8 lanType; //NmLanNetType
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
}NmAtiGetLanDataPathHostInfoReq;
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* the netif related ip info
|
||||
*/
|
||||
typedef struct NmNetIpv6Info_Tag{
|
||||
ip6_addr_t ipv6Addr;
|
||||
ip6_addr_t ipv6LinkLocalAddr;
|
||||
|
||||
UINT8 dnsNum;
|
||||
UINT8 rsvd0;
|
||||
UINT16 ipv6GetPrefixDelay;
|
||||
ip6_addr_t dns[NM_PDN_TYPE_MAX_DNS_NUM];
|
||||
}NmNetIpv6Info; //52 bytes
|
||||
#endif
|
||||
/*
|
||||
* the netif related ip info
|
||||
*/
|
||||
typedef struct NmNetIpv6Info_Tag{
|
||||
ip6_addr_t ipv6Addr; /* ipv6 global addree */
|
||||
|
||||
UINT8 dnsNum;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
|
||||
ip6_addr_t dns[NM_PDN_TYPE_MAX_DNS_NUM];
|
||||
}NmNetIpv6Info; //52 bytes
|
||||
|
||||
|
||||
typedef struct NmNetIpv4Info_Tag{
|
||||
ip4_addr_t ipv4Addr;
|
||||
|
||||
UINT8 dnsNum;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
ip4_addr_t dns[NM_PDN_TYPE_MAX_DNS_NUM];
|
||||
}NmNetIpv4Info; //16 bytes
|
||||
|
||||
/*
|
||||
* netif type
|
||||
*/
|
||||
typedef enum NmNetifType_Tag
|
||||
{
|
||||
NM_INVALID_NETIF,
|
||||
NM_DEFAULT_NETIF, //default netif, all socket data default to send via this netif
|
||||
NM_IMS_NETIF, //FFS
|
||||
NM_OTHER_NETIF
|
||||
}NmNetifType;
|
||||
|
||||
|
||||
/*
|
||||
* netif status
|
||||
*/
|
||||
typedef enum _EPAT_NmNetifStatus_Tag
|
||||
{
|
||||
/*
|
||||
* no netif created, and UE is not under dialing
|
||||
*/
|
||||
NM_NO_NETIF_NOT_DIAL,
|
||||
|
||||
/*
|
||||
* No netif created
|
||||
* 1> maybe UE is not registered, but already under dialing, and NETIF maybe be OK later
|
||||
* 2> or APP request one specific NETIF (by CID), which not created,
|
||||
* 3> when a NETIF deactivated
|
||||
*/
|
||||
NM_NO_NETIF_OR_DEACTIVATED,
|
||||
|
||||
/*
|
||||
* netif is created, but NETIF is OOS
|
||||
*/
|
||||
NM_NETIF_OOS,
|
||||
|
||||
/*
|
||||
* NETIF is suspend
|
||||
* When NETIF is OOS, must be also suspend, in such case, state should be set to OOS
|
||||
*/
|
||||
//NM_NETIF_SUSPEND,
|
||||
|
||||
/*
|
||||
* NETIF is activated
|
||||
*/
|
||||
NM_NETIF_ACTIVATED,
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* NETIF ACTED, but some info changed, such as:
|
||||
* 1> ipv4v6 type, ipv6 RS success later, need to report NETIF changed;
|
||||
* 2> ipv4v6 two bearers, if one bearer deactivated, but another one is still exist, also need to report NETIF changed;
|
||||
* 3> This status only used for event indication report;
|
||||
*/
|
||||
NM_NETIF_ACTIVATED_INFO_CHNAGED
|
||||
#endif
|
||||
}NmNetifStatus;
|
||||
|
||||
/*
|
||||
* ps/wan net status change cause
|
||||
*/
|
||||
typedef enum _EPAT_NmNetifStatusChangeCause_Tag
|
||||
{
|
||||
NM_STATUS_CHANGE_INVALID,
|
||||
NM_STATUS_CHANGE_LINK_UP, /* IPV6 and IPV4 bearer/netif set up, maybe one IPV4V6 bearer, or two bearers (one Ipv4, one Ipv6) */
|
||||
NM_STATUS_CHANGE_LINK_UP_IPV4, /* Only IPV4 bearer/netif set up */
|
||||
NM_STATUS_CHANGE_LINK_UP_IPV6, /* Only IPV6 bearer/netif set up */
|
||||
|
||||
NM_STATUS_CHANGE_RA_SUCCESS, /* IPV6 RS succ, IPV6 full address gotten */
|
||||
NM_STATUS_CHANGE_RA_TIMEOUT, /* IPV6 RS timeout */
|
||||
NM_STATUS_CHANGE_ENTER_OOS,
|
||||
NM_STATUS_CHANGE_EXIT_OOS,
|
||||
|
||||
NM_STATUS_CHANGE_LINK_DOWN, /* bearer/netif down, which bearer? CID indicated in: NmAtiNetifInfo->ipv4Cid/ipv6Cid */
|
||||
NM_STATUS_CHANGE_LINK_DOWN_IPV4, /* 1> If two bearers used for this netif, this just means IPV4 bearer deactivated,
|
||||
* and only IPV6 bearer now.
|
||||
* 2> which IPV4 bearer deactivated? indicated in: NmAtiNetifInfo->ipv4Cid.
|
||||
*/
|
||||
NM_STATUS_CHANGE_LINK_DOWN_IPV6, /* 1> If two bearers used for this netif, this just means IPV6 bearer deactivated,
|
||||
* and only IPV4 bearer now.
|
||||
* 2> which IPV4 bearer deactivated? indicated in: NmAtiNetifInfo->ipv6Cid.
|
||||
*/
|
||||
#if 0
|
||||
NM_STATUS_CHANGE_LINK_UP_PDN_IPV4_ONLY, /* Ipv4v6 bearer request, but only ipv4 supported/activated */
|
||||
NM_STATUS_CHANGE_LINK_UP_PDN_IPV6_ONLY, /* Ipv4v6 bearer request, but only ipv6 supported/activated */
|
||||
NM_STATUS_CHANGE_LINK_UP_PDN_SINGLE_ADDRESS_ONLY, /* Ipv4v6 bearer request, but only ipv4 or v6 supported/activated */
|
||||
NM_STATUS_CHANGE_LINK_UP_PDN_SINGLE_ADDR_ONLY_ALLOWED_AND_SECOND_BEARER_FAILED, /* Ipv4v6 bearer request, and the second bearer act failed */
|
||||
#endif
|
||||
NM_STATUS_CHANGE_OTHERS,
|
||||
}NmNetifStatusChangeCause;
|
||||
|
||||
/*
|
||||
* lan net status change cause
|
||||
*/
|
||||
typedef enum NmLanNetifStatusChangeCause_Tag
|
||||
{
|
||||
NM_LAN_STATUS_CHANGE_INVALID,
|
||||
NM_LAN_STATUS_CHANGE_LINK_UP, // the bind wan has active,then the lan link up success, mabybe one IPV4IPV6 wan
|
||||
NM_LAN_STATUS_CHANGE_LINK_DOWN, // the lan link down
|
||||
NM_LAN_STATUS_CHANGE_LAN_BIND, // for nat mode, the lan link up has already,the the lan bind with one active wan
|
||||
NM_LAN_STATUS_CHANGE_LAN_UNBIND,// for nat mode, the lan link up has already,the the lan unbind with one active wan
|
||||
NM_LAN_STATUS_CHANGE_WAN_LINK_UP,// for nat mode, the lan link up has already and bind a deactive wan, than the wan active
|
||||
NM_LAN_STATUS_CHANGE_WAN_LINK_DOWN,// for nat mode, the lan link up has already and bind a active wan, than the wan deactive
|
||||
NM_LAN_STATUS_CHANGE_OTHERS,
|
||||
}NmLanNetifStatusChangeCause;
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* One NETIF info
|
||||
*/
|
||||
typedef struct NmAtiNetifInfo_Tag
|
||||
{
|
||||
UINT8 netStatus; //NmNetifStatus
|
||||
UINT8 netifType; //NmNetifType
|
||||
UINT8 ipType; //NmNetIpType
|
||||
UINT8 cause; //NmNetifStatusChangeCause
|
||||
|
||||
/*
|
||||
* 1> if NETIF is ipv4v6 type:
|
||||
* a> if two bearers created, "ipv4Cid" is for IPV4 bearer, and "ipv6Cid" is for IPV6 bearer
|
||||
* b> if one bearer (ipv4v6) created, "ipv4Cid" = "ipv6Cid"
|
||||
* 2> if NETIF is ipv4 type
|
||||
* a> "ipv6Cid" should set to NM_PS_INVALID_CID
|
||||
* 3> if NETIF is ipv6 type
|
||||
* a> "ipv4Cid" should set to NM_PS_INVALID_CID
|
||||
*/
|
||||
UINT8 ipv4Cid;
|
||||
UINT8 ipv6Cid;
|
||||
UINT16 mtu; //mtu size
|
||||
|
||||
NmNetIpv4Info ipv4Info; //first need to check "ipType", if "ipType" indicate ipv4 or ipv4v6, then this info must be valid
|
||||
NmNetIpv6Info ipv6Info; //first need to check "ipType", if "ipType" indicate ipv6 or ipv4v6, then this info must be valid
|
||||
}NmAtiNetifInfo; // 76 bytes
|
||||
#endif
|
||||
|
||||
/*
|
||||
* One WAN NETIF basic info, note, these info will return to user, should be clear
|
||||
*/
|
||||
typedef struct NmAtiNetifInfo_Tag
|
||||
{
|
||||
UINT8 netStatus; //NmNetifStatus
|
||||
UINT8 netifType; //NmNetifType
|
||||
UINT8 ipType; //NmNetIpType
|
||||
UINT8 rsvd0;
|
||||
|
||||
/*
|
||||
* 1> if NETIF is ipv4v6 type:
|
||||
* a> if two bearers created, "ipv4Cid" is for IPV4 bearer, and "ipv6Cid" is for IPV6 bearer
|
||||
* b> if one bearer (ipv4v6) created, "ipv4Cid" = "ipv6Cid"
|
||||
* 2> if NETIF is ipv4 type
|
||||
* a> "ipv6Cid" should set to LWIP_PS_INVALID_CID
|
||||
* 3> if NETIF is ipv6 type
|
||||
* a> "ipv4Cid" should set to LWIP_PS_INVALID_CID
|
||||
* ==================================================
|
||||
* Note, in case of "NmAtiNetInfoInd" indication.
|
||||
* These "ipv4Cid" and "ipv6Cid" maybe set to valid value, to indicate which bearer/netif is deactivated
|
||||
*/
|
||||
UINT8 ipv4Cid;
|
||||
UINT8 ipv6Cid;
|
||||
UINT16 mtu; //mtu size
|
||||
|
||||
NmNetIpv4Info ipv4Info; //first need to check "ipType", if "ipType" indicate ipv4 or ipv4v6, then this info must be valid
|
||||
NmNetIpv6Info ipv6Info; //first need to check "ipType", if "ipType" indicate ipv6 or ipv4v6, then this info must be valid
|
||||
}NmAtiNetifInfo; // 76 bytes
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Result for: NM_ATI_SYNC_GET_NET_INFO_REQ, just return NET info info
|
||||
*/
|
||||
typedef struct NmAtiGetNetInfoRet_Tag
|
||||
{
|
||||
NmAtiNetifInfo netifInfo;
|
||||
}NmAtiGetNetInfoRet; //76 bytes
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* NM ATI SYNC result
|
||||
*/
|
||||
typedef struct NmAtiSyncRet_Tag
|
||||
{
|
||||
union {
|
||||
NmAtiGetNetInfoRet netInfoRet; //76 bytes
|
||||
NmNetIfDnsCfg getDnsServer; //84 bytes
|
||||
}body;
|
||||
}NmAtiSyncRet; // 84 bytes
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* NM_ATI_NET_INFO_IND
|
||||
* NmAtiNetInfoInd
|
||||
******************************************************************************/
|
||||
typedef struct NmAtiNetInfoInd_Tag
|
||||
{
|
||||
UINT8 indCause; //NmNetifStatusChangeCause
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
|
||||
NmAtiNetifInfo netifInfo;
|
||||
}NmAtiNetInfoInd;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* Functions
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrLinkUp
|
||||
* Description: net manager pdn linkup function
|
||||
* input: UINT8 cid //which CID (CAC layer ID)
|
||||
* NmIfConfiguration *ifConf //default bearer configuration
|
||||
* UINT8 bindToCid //if NW assign two bearer (one for IPV4, and another for IPV6)
|
||||
* // when second bearer setup, need to bind to orig "netif"
|
||||
* // if set to "255", just means not such case
|
||||
* BOOL bWakeup; //whether this NETIF/bearer is linked up during sleep2/hib wake up procedure
|
||||
* output: NmResult;
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
NmResult NetMgrLinkUp(UINT8 cid, NmIfConfiguration *pIfCfg, UINT8 bindToCid, BOOL bWakeUp);
|
||||
|
||||
/*
|
||||
* Netmgr dedicated bearer linkup
|
||||
*/
|
||||
NmResult NetMgrDedLinkUp(UINT8 cid, UINT8 pcid, BOOL bWakeUp);
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrLinkDown
|
||||
* Description: netmngr pdn linkdown function
|
||||
* input: UINT8 cid
|
||||
* output: NmResult
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
NmResult NetMgrLinkDown(UINT8 cid);
|
||||
|
||||
/*
|
||||
* Netmgr default/dedicated bearer TFT config
|
||||
*/
|
||||
NmResult NetMgrTftConfig(UINT8 cid, UINT8 pfNum, CmiPsPacketFilter *pPFList);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrLanLinkLayerStatusChange
|
||||
* Description: notify the tcpip stack the LAN device link layer status change
|
||||
* input: (NmLanType type, NmLanLinkStatus newStatus)
|
||||
* output:
|
||||
* return: NmResult
|
||||
* Comment: called by rndis/ppp service or psdial
|
||||
* the default link layer status of LAN is disconnected, and if the status has been change, it must be notify to tcpip stack by this API
|
||||
******************************************************************************/
|
||||
NmResult NetMgrLanLinkLayerStatusChange(NmLanType type, NmLanLinkStatus newStatus);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrGetNetInfo
|
||||
* Description: get UE wan net info
|
||||
* input: UINT8 cid, NmAtiGetNetInfoRet *wanInfo
|
||||
* output: NmResult
|
||||
* Comment: called by app
|
||||
* if cid is LWIP_PS_INVALID_CID, will return default netif status
|
||||
******************************************************************************/
|
||||
NmResult NetMgrGetNetInfo(UINT8 cid, NmAtiNetifInfo *pWanInfo);
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrGetNetInfoWithoutPsStatusCheck
|
||||
* Description: get UE wan net info
|
||||
* input: UINT8 cid, NmAtiNetifInfo *pNetifInfo
|
||||
* output: NmResult
|
||||
* Comment: In this API not check whether PS is started, this API is only called
|
||||
* by ESM, as ESM maybe call it to get IPV6 address during wakeup procedure
|
||||
******************************************************************************/
|
||||
NmResult NetMgrGetNetInfoWithoutPsStatusCheck(UINT8 cid, NmAtiNetifInfo *pNetifInfo);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrGetDnsServerInfo
|
||||
* Description: get UE dns server config
|
||||
* input: UINT8 cid, NmNetIfDnsCfg *pGetDnsServer
|
||||
* output: NmResult
|
||||
* Comment: called by app
|
||||
******************************************************************************/
|
||||
NmResult NetMgrGetDnsServerInfo(UINT8 cid, NmNetIfDnsCfg *pGetDnsServer);
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrSetDnsServerInfo
|
||||
* Description: set UE dns cache
|
||||
* input: UINT8 cid, UINT8 number, ip_addr_t dns[NM_MAX_DNS_NUM]
|
||||
* output: NmResult
|
||||
* Comment: called by app
|
||||
******************************************************************************/
|
||||
NmResult NetMgrSetDnsServerInfo(UINT8 cid, UINT8 number, ip_addr_t dns[NM_MAX_DNS_NUM]);
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrClearDnsServerInfo
|
||||
* Description: clear UE dns cache
|
||||
* input: UINT8 cid, NmAtiGetNetInfoRet *wanInfo
|
||||
* output: NmResult
|
||||
* Comment: called by app
|
||||
******************************************************************************/
|
||||
NmResult NetMgrClearDnsCacheInfo(BOOL bClearAll, CHAR name[DNS_MAX_NAME_LENGTH]);
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrSetDnsCache
|
||||
* Description: enable/sidable dns cache
|
||||
* input: BOOL bEnable
|
||||
* output: NmResult
|
||||
* Comment: called by app
|
||||
******************************************************************************/
|
||||
NmResult NetMgrSetDnsCache(BOOL bEnable);
|
||||
|
||||
|
||||
/*
|
||||
* Send NET (NETIF) info (status)
|
||||
*/
|
||||
void NetMgrSendNetInfoInd(NmAtiNetInfoInd *pNetInfoInd);
|
||||
|
||||
/*
|
||||
* Proc "CMI_PS_GET_CEREG_CNF"
|
||||
*/
|
||||
void NetMgrProcCeregCnf(CmiPsGetCeregCnf *pCregCnf);
|
||||
|
||||
/*
|
||||
* Proc "CMI_PS_CEREG_IND"
|
||||
*/
|
||||
void NetMgrProcCeregInd(CmiPsCeregInd *pCregInd);
|
||||
|
||||
|
||||
/*
|
||||
* net mgr lan configuration for tcpip data path
|
||||
*/
|
||||
NmResult NetMgrLanConfig(NetMgrLanCfg *lanCfg);
|
||||
|
||||
/*
|
||||
* net mgr lan ctrl api(control the lan data path wether bind with pdp context)
|
||||
* if the same lan type has bind, it will be replace with the new pdp context
|
||||
* if the related lan tcpip data path has been actived,then you can not bind with the new pdp context, and it will return error
|
||||
*/
|
||||
NmResult NetMgrLanCtrl(NmLanCtrlAction action, NmLanNetType type, UINT8 ip4Cid, UINT8 ip6Cid);
|
||||
|
||||
|
||||
/*
|
||||
* query the lan tcpip data path capability, called by CCIO, to descide whether can do lan link up
|
||||
*/
|
||||
NmResult NetMgrQueryLanTcpipDataPathCapability(NmLanNetType lanType, NetMgrLanDataPathCap *pLanDataPathCap);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrLanLinkUp
|
||||
* Description: netmngr establish LAN TCPIP data path function
|
||||
* input:
|
||||
* output:
|
||||
* return: NmResult
|
||||
* Comment: called by rndis/ppp service
|
||||
******************************************************************************/
|
||||
NmResult NetMgrLanLinkUp(NmLanType lanType, BOOL bWakeUp, UINT16 mtu);
|
||||
|
||||
/******************************************************************************
|
||||
* NetMgrLanDataPathDown
|
||||
* Description: netmngr LAN data path disconnect function
|
||||
* input: UINT8 lanChannelId(channel[NM_LAN_RNDIS_CHANNEL_ID]->rndis/ecm, channel[NM_LAN_PPP_CHANNEL_ID]->ppp)
|
||||
* output:
|
||||
* return:NmResult
|
||||
* Comment:called by psdial or ps event(NM_ATI_NET_INFO_IND) callback or rndis/ppp service
|
||||
******************************************************************************/
|
||||
NmResult NetMgrLanLinkDown(NmLanType lanType);
|
||||
|
||||
|
||||
/*
|
||||
* net mgr query lan tcpip data path status api
|
||||
*/
|
||||
NmResult NetMgrGetLanTcpipDataPathStatus(NmLanNetType lanType, NetMgrLanChannelTcpipDataPathStatus *status);
|
||||
|
||||
/*
|
||||
* notify the CMS/psdial the LAN info
|
||||
*/
|
||||
void NetMgrNotifyAtiLanInfoInd(NmAtiLanInfo *pAtiLanInfo);
|
||||
|
||||
/*
|
||||
* net mgr query lan tcpip data path host info api
|
||||
*/
|
||||
NmResult NetMgrGetLanTcpipDataPathHostInfo(NmLanNetType lanType, NetMgrLanTcpipDataPathHostInfo *info);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,858 @@
|
||||
#ifndef __PS_COMM_TYPE_H__
|
||||
#define __PS_COMM_TYPE_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M Ltd.
|
||||
File name: - pscommtype.h
|
||||
Description: - PS common typedef structure
|
||||
History: - 10/19/2018, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#include "pssys.h"
|
||||
#include "psl1commtype.h"
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MACRO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
#define SUPPORT_MAX_FREQ_NUM 8
|
||||
#define MAX_PLMN_LIST_SIZE 6 //this value is max number of plmn Id in SIB1, maxPLMN-r11
|
||||
#define CE_INVALID_MCC 0xFFFF
|
||||
#define SUPPORT_MAX_PLMN_NUM 20 //TBD
|
||||
#define CEMM_PLMN_LIST_MAX_NUM 16
|
||||
#define MAX_BAND_MASK_NUM 3 //the max number of UINT32 bandmask, i.e. the max supported band num is 32*MAX_BAND_MASK_NUM
|
||||
#define MAX_NAS_MSG_BITMAP_NUM 8 // equal to 256/32
|
||||
|
||||
#define PS_INVALID_PHY_CELL_ID 0xFFFF
|
||||
#define PS_MAX_PHY_CELL_ID 503
|
||||
|
||||
//SHA-256 MACROS
|
||||
#define SHA256_HASH_WORDS 8 /* number of words in H(0) */
|
||||
#define SHA256_OUTPUT_SIZE 32 /* Block size (in bytes) of the output of the Approved hash function. */
|
||||
#define SHA256_BLOCK_SIZE 64 /* Block size (in bytes) of the input to the Approved hash function. */
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define NB_DRB_NUM 2
|
||||
#define CAT_DRB_NUM 11
|
||||
|
||||
#define MAX_DRB_NUM CAT_DRB_NUM
|
||||
|
||||
/* PAP/CHAP ID and pwd max length */
|
||||
#define CESM_MAX_AUTH_STR_LEN 64
|
||||
|
||||
/* CID is max to 15, and valid value: [0:15], in PS layer */
|
||||
#define PS_MAX_PDP_CID 15
|
||||
#define PS_PDP_CID_NUM 16 /* [0:15] */
|
||||
#define PS_INVALID_PDP_CID 255
|
||||
#define MAX_EPS_BEARER_CONTEXT_NUM 11
|
||||
#define PS_APN_MAX_LEN 100
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Part of MARCO used to parse IP header
|
||||
*/
|
||||
#define PS_IP_HDR_GET_VER(ptr) ((*(UINT8*)(ptr)) >> 4)
|
||||
|
||||
#define PS_IP_PROTO_UDP 17
|
||||
#define PS_IP_PROTO_TCP 6
|
||||
#define PS_IP_PROTO_ESP 50
|
||||
|
||||
#define LITTLE_ENDIAN_BITFIELD
|
||||
|
||||
#if defined(LITTLE_ENDIAN_BITFIELD)
|
||||
#define PS_HTONS(x) ((((x) & 0x00ffUL) << 8) | (((x) & 0xff00UL) >> 8))
|
||||
#define PS_HTONL(x) ((((x) & 0x000000ffUL) << 24) | \
|
||||
(((x) & 0x0000ff00UL) << 8) | \
|
||||
(((x) & 0x00ff0000UL) >> 8) | \
|
||||
(((x) & 0xff000000UL) >> 24))
|
||||
#else
|
||||
#define PS_HTONS(x) (x)
|
||||
#define PS_HTONL(x) (x)
|
||||
#endif
|
||||
|
||||
#define PS_NTOHS(x) PS_HTONS((x))
|
||||
#define PS_NTOHL(x) PS_HTONL((x))
|
||||
|
||||
/* Get ipv6 header value */
|
||||
#define PS_IP6H_V(hdr) ((PS_NTOHL((hdr)->ver_tc_fl) >> 28) & 0x0f)
|
||||
#define PS_IP6H_TC(hdr) ((PS_NTOHL((hdr)->ver_tc_fl) >> 20) & 0xff)
|
||||
#define PS_IP6H_FL(hdr) (PS_NTOHL((hdr)->ver_tc_fl) & 0x000fffff)
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
typedef UINT16 AccessClass;
|
||||
typedef UINT16 AccessTechnologyId;
|
||||
|
||||
#define PLMN_GET_PURE_MNC(mncWithAddInfo) ((mncWithAddInfo)&0xFFF)
|
||||
#define PLMN_IS_2_DIGIT_MNC(mncWithAddInfo) (((mncWithAddInfo)>>12) == 0x0F)
|
||||
|
||||
#define PLMN_SET_MNC_WITH_ADD_INFO(twoDigitType, pureMnc) ((twoDigitType)?((pureMnc)|0xF000):((pureMnc)&0xFFF))
|
||||
|
||||
#define IS_VALID_PLMN(plmn) (((plmn).mcc != 0) ? TRUE : FALSE)
|
||||
|
||||
#define IS_SAME_PLMN(plmn1, plmn2) (((plmn1).mcc == (plmn2).mcc) && ((plmn1).mncWithAddInfo == (plmn2).mncWithAddInfo))
|
||||
|
||||
typedef enum PlmnMncDigitType_enum
|
||||
{
|
||||
PLMN_UNKNOW_DIGIT_MNC = 0,
|
||||
PLMN_2_DIGIT_MNC = 2,
|
||||
PLMN_3_DIGIT_MNC = 3
|
||||
}PlmnMncDigitType;
|
||||
|
||||
/******************************************************************************
|
||||
* NwMode
|
||||
* NB_IOT, EMTC, etc...
|
||||
******************************************************************************/
|
||||
typedef enum _SIG_EPAT_CCM_CFG_NW_MODE
|
||||
{
|
||||
NB_IOT = 0,
|
||||
CAT1,
|
||||
EMTC_IOT
|
||||
}NwMode;
|
||||
|
||||
/******************************************************************************
|
||||
* UeService
|
||||
* EPS/NON_EPS/EPS AND NON_EPS
|
||||
******************************************************************************/
|
||||
typedef enum _SIG_EPAT_CCM_CFG_UE_SERVICE
|
||||
{
|
||||
EPS_ONLY = 0, // NB
|
||||
NON_EPS = 1,
|
||||
EPS_AND_NON_EPS = 2,
|
||||
NON_SERVICE
|
||||
}UeService;
|
||||
|
||||
typedef UINT8 UeServiceT;
|
||||
|
||||
/******************************************************************************
|
||||
* UeUsageSetting
|
||||
* VOICE_CENTRIC/DATA_CENTRIC
|
||||
******************************************************************************/
|
||||
typedef enum UeUsageSetting_Tag
|
||||
{
|
||||
VOICE_CENTRIC = 0,
|
||||
DATA_CENTRIC
|
||||
}UeUsageSetting;
|
||||
|
||||
typedef UINT8 UeUsageSettingT;
|
||||
|
||||
/******************************************************************************
|
||||
* VoiceDomainPreference
|
||||
* CS_VOICE_ONLY/IMS_PS_VOICE_ONLY
|
||||
* CS_VOICE_PREFERRED_IMS_PS_VOICE_SECONDARY
|
||||
* IMS_PS_VOICE_PREFERRED_CS_VOICE_SECONDARY
|
||||
******************************************************************************/
|
||||
typedef enum VoiceDomainPreference_Tag
|
||||
{
|
||||
CS_VOICE_ONLY = 0,
|
||||
IMS_PS_VOICE_ONLY = 1,
|
||||
CS_VOICE_PREFERRED_IMS_PS_VOICE_SECONDARY = 2,
|
||||
IMS_PS_VOICE_PREFERRED_CS_VOICE_SECONDARY
|
||||
}VoiceDomainPreference;
|
||||
|
||||
typedef UINT8 VoiceDomainPreferenceT;
|
||||
|
||||
/******************************************************************************
|
||||
* UE modes of operation for EPS
|
||||
* PS_MODE_2_OF_OPERATION
|
||||
* CSPS_MODE_1_OF_OPERATION
|
||||
* CSPS_MODE_2_OF_OPERATION
|
||||
* PS_MODE_1_OF_OPERATION
|
||||
******************************************************************************/
|
||||
typedef enum _SIG_EPAT_CCM_CFG_UE_OPERATION_MODE
|
||||
{
|
||||
PS_MODE_2_OF_OPERATION = 0,
|
||||
CSPS_MODE_1_OF_OPERATION = 1,
|
||||
CSPS_MODE_2_OF_OPERATION = 2,
|
||||
PS_MODE_1_OF_OPERATION = 3
|
||||
}PsUeOperationModeEnum;
|
||||
|
||||
typedef UINT8 UeOperationModeT;
|
||||
|
||||
/******************************************************************************
|
||||
* PlmnType
|
||||
* HPLMN/EHPLMN/RPLMN/EPLMN.....
|
||||
******************************************************************************/
|
||||
typedef enum _EPAT_PlmnTypeEnum_Tag
|
||||
{
|
||||
HPLMN = 0, //home PLMN, derived from IMSI
|
||||
EHPLMN, //equivalent home PLMN
|
||||
//RPLMN, //registered PLMN, not the same level meaning
|
||||
//EPLMN, //equivalent PLMN, not the same level meaning
|
||||
VPLMN, //visited PLMN
|
||||
UPLMN, //user controlled PLMN
|
||||
OPLMN, //operator controlled PLMN
|
||||
FPLMN, //forbidden PLMN
|
||||
APLMN, //available PLMN
|
||||
}PlmnType;
|
||||
|
||||
/******************************************************************************
|
||||
* CipheringAlgorithm
|
||||
* EEA0/EEA1/EEA2/EEA3
|
||||
******************************************************************************/
|
||||
typedef enum CipheringAlgorithmTag
|
||||
{
|
||||
// see TS 34.401 5.1.3.2
|
||||
EEA0 = 0,
|
||||
EEA1 = 1,
|
||||
EEA2 = 2,
|
||||
EEA3 = 3,
|
||||
}CipheringAlgorithm;
|
||||
|
||||
/******************************************************************************
|
||||
* IntegrityAlgorithm
|
||||
* EIA0/EIA1/EIA2/EIA3
|
||||
******************************************************************************/
|
||||
typedef enum _EPAT_IntegrityAlgorithmTag
|
||||
{
|
||||
// see TS 34.401 5.1.4.2
|
||||
EIA0 = 0,
|
||||
EIA1 = 1,
|
||||
EIA2 = 2,
|
||||
EIA3 = 3
|
||||
}IntegrityAlgorithm;
|
||||
|
||||
/*
|
||||
* 24.301: 9.9.4.25 Release assistance indication
|
||||
* 0 0 No information regarding DDX is conveyed by the information element. If
|
||||
* received it shall be interpreted as 'neither value "01" nor "10" applies'
|
||||
* 0 1 No further uplink or downlink data transmission subsequent to the uplink data
|
||||
* transmission is expected
|
||||
* 1 0 Only a single downlink data transmission and no further uplink data
|
||||
* transmission subsequent to the uplink data transmission is expected
|
||||
* 1 1 reserved
|
||||
*/
|
||||
typedef enum DataRelAssistIndEnum_Tag
|
||||
{
|
||||
DATA_RAI_NO_INFO = 0,
|
||||
DATA_RAI_NO_UL_DL_FOLLOWED = 1,
|
||||
DATA_RAI_ONLY_DL_FOLLOWED = 2,
|
||||
DATA_RAI_RESERVED = 3
|
||||
}DataRelAssistIndEnum;
|
||||
|
||||
/******************************************************************************
|
||||
* Tai
|
||||
* Tai = mcc + mnc + tac
|
||||
******************************************************************************/
|
||||
typedef struct Tai_Tag
|
||||
{
|
||||
Plmn plmn;
|
||||
UINT16 tac;
|
||||
UINT16 reserved;
|
||||
}Tai;
|
||||
|
||||
/******************************************************************************
|
||||
* Lai
|
||||
* Lai = mcc + mnc + lac
|
||||
******************************************************************************/
|
||||
typedef struct LocationAreaIdTag
|
||||
{
|
||||
Plmn plmn;
|
||||
UINT16 lac;
|
||||
UINT16 reserved;
|
||||
}
|
||||
LocationAreaId;
|
||||
|
||||
/******************************************************************************
|
||||
* Kasme
|
||||
******************************************************************************/
|
||||
#define KASME_SIZE 32
|
||||
typedef struct AsmeKey_Tag
|
||||
{
|
||||
UINT8 data[KASME_SIZE];
|
||||
}AsmeKey;
|
||||
|
||||
/******************************************************************************
|
||||
* NAS COUNT
|
||||
******************************************************************************/
|
||||
#define NAS_COUNT_SIZE 4
|
||||
typedef struct NasCount_Tag
|
||||
{
|
||||
UINT8 data[NAS_COUNT_SIZE];
|
||||
}NasCount;
|
||||
|
||||
/******************************************************************************
|
||||
* IMSI
|
||||
******************************************************************************/
|
||||
#define MAX_IMSI_LENGTH 8
|
||||
typedef struct Imsi_Tag
|
||||
{
|
||||
UINT8 length;
|
||||
UINT8 mncType; //PlmnMncDigitType
|
||||
AccessTechnologyId accessTech;
|
||||
UINT8 contents[MAX_IMSI_LENGTH];
|
||||
}Imsi;
|
||||
|
||||
/******************************************************************************
|
||||
* Additional Update Result
|
||||
******************************************************************************/
|
||||
typedef enum AdditionalUpdateResultTag
|
||||
{
|
||||
NO_ADDITIONAL_INFORMATION = 0,
|
||||
CS_FALLBACK_NOT_PREFERRED = 1,
|
||||
SMS_ONLY = 2,
|
||||
RESERVED_VALUE = 3
|
||||
}
|
||||
AdditionalUpdateResult;
|
||||
|
||||
/******************************************************************************
|
||||
* DCN ID
|
||||
******************************************************************************/
|
||||
typedef struct DedicatedCoreNetworkId_Tag
|
||||
{
|
||||
Plmn plmn;
|
||||
UINT16 dcnIdWithinPlmn;
|
||||
}DedicatedCoreNetworkId;
|
||||
|
||||
typedef enum TimerUnitTag
|
||||
{
|
||||
TIMER1_MULTIPLES_OF_TWO_SECONDS = 0,
|
||||
TIMER1_MULTIPLES_OF_ONE_MINUTE = 1,
|
||||
TIMER1_MULTIPLES_OF_DECIHOURS = 2,
|
||||
TIMER1_TIMER_DEACTIVATED = 7
|
||||
}
|
||||
TimerUnit;
|
||||
|
||||
typedef UINT8 TimerUnitT;
|
||||
typedef TimerUnit Timer2Unit;
|
||||
typedef UINT8 Timer2UnitT;
|
||||
|
||||
|
||||
typedef enum Timer3UnitTag
|
||||
{
|
||||
TIMER3_MULTIPLES_OF_TEN_MINUTES = 0,
|
||||
TIMER3_MULTIPLES_OF_ONE_HOUR = 1,
|
||||
TIMER3_MULTIPLES_OF_TEN_HOURS = 2,
|
||||
TIMER3_MULTIPLES_OF_TWO_SECONDS = 3,
|
||||
TIMER3_MULTIPLES_OF_THIRTY_SECONDS = 4,
|
||||
TIMER3_MULTIPLES_OF_ONE_MINUTE = 5,
|
||||
TIMER3_MULTIPLES_OF_320_HOURS = 6,
|
||||
TIMER3_TIMER_DEACTIVATED = 7
|
||||
}
|
||||
Timer3Unit;
|
||||
|
||||
typedef UINT8 Timer3UnitT;
|
||||
|
||||
typedef struct GprsTimerTag
|
||||
{
|
||||
UINT8 timerValue;
|
||||
TimerUnitT unit;
|
||||
}
|
||||
GprsTimer;
|
||||
|
||||
typedef struct _EPAT_GprsTimer2Tag
|
||||
{
|
||||
UINT8 timerValue;
|
||||
Timer2UnitT unit;
|
||||
}
|
||||
GprsTimer2; // 2 bytes
|
||||
|
||||
typedef struct _EPAT_GprsTimer3Tag
|
||||
{
|
||||
UINT8 timerValue;
|
||||
Timer3UnitT unit;
|
||||
}
|
||||
GprsTimer3;
|
||||
|
||||
/* The field contains the PTW value in seconds for WB-S1 mode */
|
||||
typedef enum PagingTimeWindowForWBModeTag
|
||||
{
|
||||
PAGING_TIME_WINDOW_WB_1_SEC_280_MS = 0,
|
||||
PAGING_TIME_WINDOW_WB_2_SEC_560_MS = 1,
|
||||
PAGING_TIME_WINDOW_WB_3_SEC_840_MS = 2,
|
||||
PAGING_TIME_WINDOW_WB_5_SEC_120_MS = 3,
|
||||
PAGING_TIME_WINDOW_WB_6_SEC_400_MS = 4,
|
||||
PAGING_TIME_WINDOW_WB_7_SEC_680_MS = 5,
|
||||
PAGING_TIME_WINDOW_WB_8_SEC_960_MS = 6,
|
||||
PAGING_TIME_WINDOW_WB_10_SEC_240_MS = 7,
|
||||
PAGING_TIME_WINDOW_WB_11_SEC_520_MS = 8,
|
||||
PAGING_TIME_WINDOW_WB_12_SEC_800_MS = 9,
|
||||
PAGING_TIME_WINDOW_WB_14_SEC_80_MS = 10,
|
||||
PAGING_TIME_WINDOW_WB_15_SEC_360_MS = 11,
|
||||
PAGING_TIME_WINDOW_WB_16_SEC_640_MS = 12,
|
||||
PAGING_TIME_WINDOW_WB_17_SEC_920_MS = 13,
|
||||
PAGING_TIME_WINDOW_WB_19_SEC_200_MS = 14,
|
||||
PAGING_TIME_WINDOW_NB_20_SEC_480_MS = 15
|
||||
}PagingTimeWindowForWBMode;
|
||||
|
||||
typedef UINT8 PagingTimeWindowForWBModeT;
|
||||
|
||||
/* The field contains the eDRX value for S1 mode */
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
NOTE 4: The value is applicable only in WB-S1 mode. If received in NB-S1
|
||||
mode it is interpreted as if the Extended DRX parameters IE were not
|
||||
included in the message by this version of the protocol.
|
||||
|
||||
NOTE 5: The value is applicable only in WB-S1 mode. If received in NB-S1
|
||||
mode it is interpreted as 0010 by this version of the protocol.
|
||||
|
||||
NOTE 6: The value is applicable only in NB-S1 mode. If received in WB-S1
|
||||
mode it is interpreted as 1101 by this version of the protocol.
|
||||
--------------------------------------------------------------------------*/
|
||||
typedef enum EdrxValueForS1ModeTag
|
||||
{
|
||||
EDRX_CYCLE_LEN_5_SEC_120_MS = 0, /* Rfer to NOTE 4 */
|
||||
EDRX_CYCLE_LEN_10_SEC_240_MS = 1, /* Rfer to NOTE 4 */
|
||||
EDRX_CYCLE_LEN_20_SEC_480_MS = 2,
|
||||
EDRX_CYCLE_LEN_40_SEC_960_MS = 3,
|
||||
EDRX_CYCLE_LEN_61_SEC_440_MS = 4, /* Rfer to NOTE 5 */
|
||||
EDRX_CYCLE_LEN_81_SEC_920_MS = 5,
|
||||
EDRX_CYCLE_LEN_102_SEC_400_MS = 6, /* Rfer to NOTE 5 */
|
||||
EDRX_CYCLE_LEN_122_SEC_880_MS = 7, /* Rfer to NOTE 5 */
|
||||
EDRX_CYCLE_LEN_143_SEC_360_MS = 8, /* Rfer to NOTE 5 */
|
||||
EDRX_CYCLE_LEN_163_SEC_840_MS = 9,
|
||||
EDRX_CYCLE_LEN_327_SEC_680_MS = 10,
|
||||
EDRX_CYCLE_LEN_655_SEC_360_MS = 11,
|
||||
EDRX_CYCLE_LEN_1310_SEC_720_MS = 12,
|
||||
EDRX_CYCLE_LEN_2621_SEC_440_MS = 13,
|
||||
EDRX_CYCLE_LEN_5242_SEC_880_MS = 14, /* Rfer to NOTE 6 */
|
||||
EDRX_CYCLE_LEN_10485_SEC_760_MS = 15, /* Rfer to NOTE 6 */
|
||||
EDRX_CYCLE_LEN_INVALID = 0xFF /* Set to this value while AT+CEDRX=0(disable the use of eDRX and discard all parameters for eDRX) */
|
||||
}EdrxValueForS1Mode;
|
||||
|
||||
typedef UINT8 EdrxValueForS1ModeT;
|
||||
|
||||
typedef struct _EPAT_ExtendedDrxParametersTag
|
||||
{
|
||||
EdrxValueForS1ModeT edrxValue;
|
||||
PagingTimeWindowForWBModeT ptw;
|
||||
}ExtendedDrxParameters; // 2 bytes
|
||||
|
||||
typedef enum CemmCiotOptTypeEnum_Tag
|
||||
{
|
||||
CEMM_NO_CIOT_OPT = 0, // not support CIOT OPT, for NB, CP OPT is must, useless, but for CAT1, this is set to default value
|
||||
CEMM_CP_CIOT_OPT = 1,
|
||||
CEMM_UP_CIOT_OPT = 2,
|
||||
CEMM_CP_AND_UP_OPT = 3
|
||||
}CemmCiotOptTypeEnum;
|
||||
|
||||
typedef enum CemmPsmReqModeEnum_Tag
|
||||
{
|
||||
CEMM_DISABLE_PSM = 0,
|
||||
CEMM_ENABLE_PSM = 1,
|
||||
CEMM_DISCARD_PSM = 2 /* disable PSM, and discard PSM PARMs */
|
||||
}CemmPsmReqModeEnum;
|
||||
|
||||
typedef enum CemmEdrxReqModeEnum_Tag
|
||||
{
|
||||
CEMM_DISABLE_EDRX = 0,
|
||||
CEMM_ENABLE_EDRX = 1,
|
||||
CEMM_DISCARD_EDRX = 2 /* disable EDRX, and discard EDRX PARMs */
|
||||
}CemmEdrxReqModeEnum;
|
||||
|
||||
/******************************************************************************
|
||||
* EPS update status
|
||||
******************************************************************************/
|
||||
typedef enum EpsUpdateStatus_Tag
|
||||
{
|
||||
USIM_EUS_UPDATED = 0,
|
||||
USIM_EUS_NOT_UPDATED = 1,
|
||||
USIM_EUS_ROAMING_NOT_ALLOWED = 2,
|
||||
USIM_EUS_RESERVED = 7
|
||||
}EpsUpdateStatus;
|
||||
|
||||
/******************************************************************************
|
||||
* NAS key set identifier
|
||||
******************************************************************************/
|
||||
typedef enum NasKsiTag
|
||||
{
|
||||
NAS_KSI_0 = 0,
|
||||
NAS_KSI_1 = 1,
|
||||
NAS_KSI_2 = 2,
|
||||
NAS_KSI_3 = 3,
|
||||
NAS_KSI_4 = 4,
|
||||
NAS_KSI_5 = 5,
|
||||
NAS_KSI_6 = 6,
|
||||
NO_KEY_IS_AVAILABLE = 7 /* no key is available(UE to network);reserved(network to UE) */
|
||||
}NasKsi;
|
||||
|
||||
typedef enum CemmPlmnSelectTypeEnum_Tag
|
||||
{
|
||||
CEMM_DEFAULT_PLMN_REG = 0, // CEMM PLMN module decide by self
|
||||
CEMM_AUTO_PLMN_REG,
|
||||
CEMM_MANUAL_PLMN_REG,
|
||||
CEMM_MANUAL_THEN_AUTO_PLMN_REG, //if manual selection fails, automatic mode
|
||||
}CemmPlmnSelectTypeEnum;
|
||||
|
||||
typedef enum _SIG_EPAT_CEPLMN_CFG_PLMN_SEARCH_LEVEL
|
||||
{
|
||||
/*
|
||||
* OOS PLMN interval: 5s, 10s, 20s
|
||||
*/
|
||||
PLMN_SEARCH_POWER_LEVEL_NOT_CARE = 0,
|
||||
/*
|
||||
* OOS PLMN interval: 15s, 30s, 1 min (default setting)
|
||||
*/
|
||||
PLMN_SEARCH_POWER_LEVEL_NORMAL_CARE = 1,
|
||||
/*
|
||||
* OOS PLMN interval: 5 mins, 10 mins, 15 mins
|
||||
*/
|
||||
PLMN_SEARCH_POWER_LEVEL_MORE_CARE = 2,
|
||||
/*
|
||||
* OOS PLMN interval: 30s, then stop PLMN search, and let AT: AT+ECPLMNS to start PLMN search
|
||||
*/
|
||||
PLMN_SEARCH_POWER_LEVEL_STRICT_CARE = 3,
|
||||
/*
|
||||
* Don't trigger PLMN search after OOS, let user decide to start PLMN search or not
|
||||
*/
|
||||
PLMN_SEARCH_POWER_LEVEL_USER_CONTROL = 4
|
||||
}PlmnSearchPowerLevel;
|
||||
|
||||
/******************************************************************************
|
||||
* Access Point Name
|
||||
******************************************************************************/
|
||||
#define MAX_APN_NAME 100
|
||||
typedef struct AccessPointNameTag
|
||||
{
|
||||
UINT8 length;
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
UINT8 name[MAX_APN_NAME];
|
||||
}AccessPointName; //104 byte
|
||||
|
||||
typedef enum ConfigurationProtocolTag
|
||||
{
|
||||
CONFIG_PROTOCOL_PPP = 0,
|
||||
CONFIG_PROTOCOL_OSP_IHOSS = 1
|
||||
}ConfigurationProtocol;
|
||||
|
||||
typedef enum PdnTypeTag
|
||||
{
|
||||
PDN_IP_V4 = 0x01,
|
||||
PDN_IP_V6 = 0x02,
|
||||
PDN_IP_V4V6 = 0x03,
|
||||
PDN_UNUSED = 0x04,
|
||||
PDN_NON_IP = 0x05
|
||||
}PdnType;
|
||||
|
||||
typedef UINT8 PdnTypeT;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* MSGADDRESS
|
||||
******************************************************************************/
|
||||
#define MAX_SMS_ADDRESS_LENGTH 20
|
||||
#define MAX_SMS_LEN 160
|
||||
#define UICC_MAX_ADDR_LEN 20
|
||||
|
||||
typedef struct MsgAddress_Tag
|
||||
{
|
||||
UINT8 length;
|
||||
UINT8 typeOfNumber; //TypeOfNumber
|
||||
UINT8 numberPlanId; //NumberingPlanId
|
||||
UINT8 reserved;
|
||||
UINT8 addressValue[MAX_SMS_ADDRESS_LENGTH];
|
||||
}MsgAddress;
|
||||
|
||||
typedef struct UsatAddressTag
|
||||
{
|
||||
UINT8 TON; //UsatBcdTON
|
||||
UINT8 NPI; //UsatBcdNPI
|
||||
UINT8 len;
|
||||
UINT8 addrValue[UICC_MAX_ADDR_LEN]; //Bcd number
|
||||
}
|
||||
UsatAddress;
|
||||
|
||||
typedef enum UsatSmsTpduType_Tag
|
||||
{
|
||||
USAT_SMTPDU_DELIVER = 0,
|
||||
USAT_SMTPDU_SUBMIT = 1,
|
||||
USAT_SMTPDU_COMMAND = 2
|
||||
}UsatSmsTpduType;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* SMS Protocol ID
|
||||
*****************************************************************************/
|
||||
typedef struct SmsProtocolIdentifier_Tag
|
||||
{
|
||||
UINT8 smsPidType; //SmsPidType
|
||||
union
|
||||
{
|
||||
UINT8 smAlProtocolid; /* NO_INTERWORKING */
|
||||
UINT8 interWorkingProtocolId; /* TELEMATIC_INTERWORKING */
|
||||
UINT8 scCommandProtocolId; /* SHORT_MESSAGE_RELATED */
|
||||
UINT8 meCommandProtocolId; /* ME_RELATED */
|
||||
UINT8 reservedProtocolId; /* RESERVED */
|
||||
UINT8 scSpecificProtocolId; /* SC_SPECIFIC_USE */
|
||||
UINT8 pId;
|
||||
}protocolId;
|
||||
UINT16 reserved;
|
||||
}SmsProtocolIdentifier;
|
||||
|
||||
/******************************************************************************
|
||||
* SMS Data Coding
|
||||
*****************************************************************************/
|
||||
|
||||
typedef enum MessageWaitingIndicationType_Tag
|
||||
{
|
||||
VOICEMAIL_MESSAGE_WAITING = 0x00, /* Voicemail Message Waiting */
|
||||
FAX_MESSAGE_WAITING = 0x01, /* Fax Message Waiting */
|
||||
ELECTRONIC_MAIL_MESSAGE_WAITING = 0x02, /* Electronic Mail Message Waiting */
|
||||
OTHER_MESSAGE_WAITING = 0x03 /* Other Message Waiting */
|
||||
}MessageWaitingIndicationType;
|
||||
|
||||
typedef struct MessageWaitingIndication_Tag
|
||||
{
|
||||
BOOL discardMessage; /* Discard Message */
|
||||
BOOL storeMessage; /* Store Message */
|
||||
BOOL setIndActive; /* Set Indication Active(TRUE)/Inactive(FALSE) */
|
||||
UINT8 waitingIndType; /* MessageWaitingIndicationType */
|
||||
}MessageWaitingIndication;
|
||||
|
||||
typedef struct SmsDataCodingSchemeTag
|
||||
{
|
||||
UINT8 smsCoding; /* SmsCoding */
|
||||
UINT8 smsClass; /* SmsMessageClass */
|
||||
BOOL bCompressed; /* the text is compressed */
|
||||
BOOL bCodingAndClass; /* Data coding/message class */
|
||||
BOOL bMessageWait; /* Message Waiting Indication Group */
|
||||
MessageWaitingIndication waitIndication; /* Message Waiting Indication Group content */
|
||||
}SmsDataCodingScheme;
|
||||
|
||||
/*
|
||||
* Uicc Pin status
|
||||
*/
|
||||
typedef struct UiccPinStatusTag
|
||||
{
|
||||
UINT8 keyRef; /* UiccKeyRefValue */
|
||||
UINT8 numRemainingAttempts;/* the number of remianing PIN attempts */
|
||||
UINT8 bEnabled:1; /* indicate whether the status of PIN is enable or not (disabled) */
|
||||
UINT8 bVerified:1; /* indicate whether the status of PIN is verified or not */
|
||||
UINT8 bUsed:1; /* TS102.221 9.5.2 The usage qualifier indicates whether an enabled PIN need to be verfied for access */
|
||||
UINT8 reserved1:5;
|
||||
UINT8 reserved2;
|
||||
}
|
||||
UiccPinStatus;
|
||||
|
||||
/*
|
||||
* Uicc File path
|
||||
*/
|
||||
#define MAX_FILE_PATH_ELEMENTS 10
|
||||
typedef struct UiccFilePathTag
|
||||
{
|
||||
UINT8 len;
|
||||
UINT8 reserved;
|
||||
UINT8 path[MAX_FILE_PATH_ELEMENTS];
|
||||
}
|
||||
UiccFilePath;
|
||||
|
||||
typedef struct EmmEventStatisNvmInfo_Tag
|
||||
{
|
||||
UINT16 numAttachSucc; /* count of Attach Success */
|
||||
UINT16 numAttachFail;
|
||||
UINT16 numTauSucc; /* count of TAU Success */
|
||||
UINT16 numTauFail;
|
||||
UINT16 numSrSucc; /* count of Service request Success */
|
||||
UINT16 numSrFail;
|
||||
UINT16 numAuthFail; /* count of Authentication Success */
|
||||
UINT16 numDetach; /* count of Detach */
|
||||
}
|
||||
EmmEventStatisNvmInfo;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* ---------------------ipv4 header format--------------------
|
||||
* 0 1 2 3
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* |Version| IHL |Type of Service| Total Length |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Identification |Flags| Fragment Offset |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Time to Live | Protocol | Header Checksum |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Source Address |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Destination Address |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Options | Padding |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* Example Internet Datagram Header
|
||||
*/
|
||||
typedef struct PsIp4Hdr_Tag
|
||||
{
|
||||
#if defined (LITTLE_ENDIAN_BITFIELD)
|
||||
UINT8 ihl :4;
|
||||
UINT8 version :4;
|
||||
#else
|
||||
UINT8 version :4;
|
||||
UINT8 ihl :4;
|
||||
#endif
|
||||
UINT8 tos;
|
||||
UINT16 tot_len;
|
||||
UINT16 id;
|
||||
UINT16 frag_off;
|
||||
UINT8 ttl;
|
||||
UINT8 protocol;
|
||||
UINT16 check_sum;
|
||||
UINT8 saddr[4];
|
||||
UINT8 daddr[4];
|
||||
}PsIp4Hdr;
|
||||
|
||||
/*
|
||||
* IPv6 Header Format
|
||||
*
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* |Version| Traffic Class | Flow Label |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Payload Length | Next Header | Hop Limit |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* + +
|
||||
* | |
|
||||
* + Source Address +
|
||||
* | |
|
||||
* + +
|
||||
* | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* + +
|
||||
* | |
|
||||
* + Destination Address +
|
||||
* | |
|
||||
* + +
|
||||
* | |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
*/
|
||||
typedef struct PsIp6Hdr_Tag
|
||||
{
|
||||
UINT32 ver_tc_fl;
|
||||
UINT16 payload_len;
|
||||
UINT8 protocol; //next header
|
||||
UINT8 hop_limit;
|
||||
|
||||
UINT8 saddr[16];
|
||||
UINT8 daddr[16];
|
||||
}PsIp6Hdr;
|
||||
|
||||
/*
|
||||
* ------ User Datagram Header Format
|
||||
* 0 7 8 15 16 23 24 31
|
||||
* +--------+--------+--------+--------+
|
||||
* | SourcePort | DestinationPort |
|
||||
* +--------+--------+--------+--------+
|
||||
* | Length | Checksum |
|
||||
* +--------+--------+--------+--------+
|
||||
* |
|
||||
* | data octets ...
|
||||
* +---------------- ...
|
||||
*/
|
||||
typedef struct PsUdpHdr_Tag
|
||||
{
|
||||
UINT16 sport;
|
||||
UINT16 dport;
|
||||
UINT16 length;
|
||||
UINT16 check_sum;
|
||||
}PsUdpHdr;
|
||||
|
||||
/*
|
||||
*/
|
||||
typedef struct PsTcpHdr_Tag
|
||||
{
|
||||
UINT16 sport;
|
||||
UINT16 dport;
|
||||
UINT32 seq; /* sequence number */
|
||||
UINT32 ack; /* ack number */
|
||||
#if defined (LITTLE_ENDIAN_BITFIELD)
|
||||
UINT8 rsvd0 : 4;
|
||||
UINT8 thl : 4; /* tcp header length */
|
||||
UINT8 flag : 6;
|
||||
UINT8 rsvd1 : 2;
|
||||
#else
|
||||
UINT8 thl : 4; /* tcp header length */
|
||||
UINT8 rsvd0 : 4;
|
||||
UINT8 rsvd1: 2;
|
||||
UINT8 flag : 6;
|
||||
#endif
|
||||
UINT16 window; /* window size */
|
||||
UINT16 cks; /* check sum */
|
||||
UINT16 urgt; /* urgent */
|
||||
}PsTcpHdr;
|
||||
|
||||
|
||||
/*
|
||||
* ----IPSEC_HEADER format ----
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Security parameter index |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Sequence number |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | |
|
||||
* | Authentication data.... |
|
||||
* +------------------------------------ ...
|
||||
*
|
||||
*/
|
||||
typedef struct PsIpSecEspHdr_Tag
|
||||
{
|
||||
UINT32 spi;
|
||||
UINT32 sn;
|
||||
}PsIpSecEspHdr;
|
||||
|
||||
|
||||
typedef UINT8 LocationType_r10_t;
|
||||
typedef enum _EPAT_LocationType_r10_Tag
|
||||
{
|
||||
LocationInfo_r10_ellipsoid_Point_r10,
|
||||
LocationInfo_r10_ellipsoidPointWithAltitude_r10,
|
||||
LocationInfo_r10_ellipsoidPointWithUncertaintyCircle_r11,
|
||||
LocationInfo_r10_ellipsoidPointWithUncertaintyEllipse_r11,
|
||||
LocationInfo_r10_ellipsoidPointWithAltitudeAndUncertaintyEllipsoid_r11,
|
||||
LocationInfo_r10_ellipsoidArc_r11,
|
||||
LocationInfo_r10_r10_polygon_r11,
|
||||
}LocationType_r10;
|
||||
|
||||
typedef struct LocationOcteStringTag
|
||||
{
|
||||
UINT8 data[22]; //temp data size
|
||||
UINT16 size;
|
||||
}LocationOcteString;
|
||||
|
||||
//LocationInfo_r10 provided for cerrc
|
||||
typedef struct LocationInformationTag
|
||||
{
|
||||
LocationType_r10_t locationInfoType; //LocationType_r10
|
||||
LocationOcteString locationCoordinates;
|
||||
|
||||
UINT8 horizontalVelocity_r10Present;
|
||||
UINT8 gnss_TOD_msec_r10Present;
|
||||
UINT8 reserved;
|
||||
LocationOcteString horizontalVelocity_r10;
|
||||
LocationOcteString gnss_TOD_msec_r10;
|
||||
}LocationInformation;
|
||||
|
||||
|
||||
typedef struct Psmd5HashContextTag
|
||||
{
|
||||
UINT32 total[2];
|
||||
UINT32 state[4];
|
||||
UINT8 buffer[64]; /*temp buffer*/
|
||||
}
|
||||
Psmd5HashContext;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
#ifndef __PS_DEBUG_H__
|
||||
#define __PS_DEBUG_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M
|
||||
File name: - psdebug.h
|
||||
Description: - PS system common include header files, and common MARCO
|
||||
History: - 02/28/2020, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* include OS header files
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "winsys.h"
|
||||
#else
|
||||
#include "osasys.h"
|
||||
#include "ostask.h"
|
||||
#include "cmsis_os2.h"
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* same as: "T_SYS_TIME", to record the PHY TIME info
|
||||
*/
|
||||
typedef struct {
|
||||
UINT32 hfnsfnsbn; // hfn(10)|sfn(10)|sbn(4)
|
||||
UINT32 spn; // spn(11)
|
||||
}PHY_T_SYS_TIME;
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* PS RAM LOG
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
#define PS_RAM_LOG_BUF_SIZE 32*1024
|
||||
|
||||
#define PS_RAM_LOG_BUF_END_OFFSET (PS_RAM_LOG_BUF_SIZE-4)
|
||||
|
||||
#define PS_RAM_LOG_START_OFFSET_INIT 0xFFFF
|
||||
|
||||
#define PS_RAM_LOG_MAGIC_WORD 0xB6C7
|
||||
|
||||
/*
|
||||
* PsRamLogBuf
|
||||
* Used as a cycle buffer,
|
||||
* RAM log record from "endOffset"
|
||||
*/
|
||||
typedef struct PsRamLogBuf_Tag
|
||||
{
|
||||
UINT16 magicWord;
|
||||
UINT16 endOffset; //Next RAM log start from it;
|
||||
|
||||
UINT8 buf[PS_RAM_LOG_BUF_SIZE-4];
|
||||
}PsRamLogBuf;
|
||||
|
||||
/*
|
||||
* +-----------------------+-----------------------+
|
||||
* | PsRamLogHdr (4 bytes) | RAM RECORD BODY... |
|
||||
* +-----------------------+-----------------------+
|
||||
*/
|
||||
|
||||
/*
|
||||
* 4 bits, MAX 15
|
||||
*/
|
||||
typedef enum PsRamLogType_Enum
|
||||
{
|
||||
PS_RAM_VAR = 0,
|
||||
PS_RAM_SIG_RECORD = 1,
|
||||
PS_RAM_SIG_DUMP = 2,
|
||||
PS_RAM_HEX_DUMP = 3,
|
||||
PS_RAM_INTERNAL_MSG_RECORD = 4,
|
||||
PS_RAM_DEBUG_ASSERT_RECORD = 5,
|
||||
PS_RAM_ASSERT_RECORD = 6
|
||||
}PsRamLogType;
|
||||
|
||||
/*
|
||||
* 8 bytes header, before PS RAM LOG
|
||||
*/
|
||||
typedef struct PsRamLogHdr_Tag
|
||||
{
|
||||
UINT16 magicWord;
|
||||
UINT16 logType: 4;
|
||||
UINT16 logLen: 12;
|
||||
UINT32 hfnhfnSfnSbn; //hfn(10)|sfn(10)|sbn(4)
|
||||
}PsRamLogHdr;
|
||||
|
||||
#define PS_RAM_LOG_HDR_SIZE sizeof(PsRamLogHdr)
|
||||
|
||||
/*
|
||||
* VAR RAM LOG
|
||||
* 10 bytes (filename) + 2 bytes (line) + 12 bytes (var1&var2&var3)
|
||||
* 24 bytes
|
||||
* PS_RAM_VAR
|
||||
*/
|
||||
typedef struct PsRamVarLog_Tag
|
||||
{
|
||||
UINT8 fileName[10];
|
||||
UINT16 lineNum;
|
||||
UINT32 var1;
|
||||
UINT32 var2;
|
||||
UINT32 var3;
|
||||
}PsRamVarLog;
|
||||
|
||||
#define PS_RAM_VAR_LOG_SIZE sizeof(PsRamVarLog)
|
||||
|
||||
/*
|
||||
* SIGNAL RAM LOG
|
||||
* 4 bytes
|
||||
* PS_RAM_SIG_RECORD
|
||||
*/
|
||||
typedef struct PsRamSigLog_Tag
|
||||
{
|
||||
UINT16 dTaskId;
|
||||
UINT16 sigId;
|
||||
}PsRamSigLog;
|
||||
|
||||
#define PS_RAM_SIG_LOG_SIZE sizeof(PsRamSigLog)
|
||||
|
||||
/*
|
||||
* SIGNAL DUMP RAM LOG
|
||||
* 4 bytes
|
||||
* PS_RAM_SIG_DUMP
|
||||
*/
|
||||
typedef struct PsRamSigDumpLog_Tag
|
||||
{
|
||||
UINT16 dTaskId;
|
||||
UINT16 sigId;
|
||||
UINT8 sigBody[];
|
||||
}PsRamSigDumpLog;
|
||||
|
||||
|
||||
/*
|
||||
* VAR RAM LOG
|
||||
* 10 bytes (filename) + 2 bytes (line) + hexDump
|
||||
* PS_RAM_HEX_DUMP
|
||||
*/
|
||||
#define PS_RAM_HEX_DUMP_FILE_NAME_SIZE 8
|
||||
typedef struct PsRamHexDumpLog_Tag
|
||||
{
|
||||
UINT8 fileName[PS_RAM_HEX_DUMP_FILE_NAME_SIZE];
|
||||
UINT16 hexLen;
|
||||
UINT16 lineNum;
|
||||
UINT8 hexDump[];
|
||||
}PsRamHexDumpLog;
|
||||
|
||||
#define PS_RAM_HEX_DUMP_MAX_SIZE 1024
|
||||
|
||||
|
||||
/*
|
||||
* INTERNAL MSG RECORD
|
||||
* PS_RAM_INTERNAL_MSG_RECORD
|
||||
* 40 bytes
|
||||
*/
|
||||
#define PS_RAM_INTERNAL_MSG_STR_SIZE 32
|
||||
typedef struct PsRamInternalMsgLog_Tag
|
||||
{
|
||||
UINT8 srcId; // msg from which sub-module
|
||||
UINT8 argvUint8;
|
||||
UINT16 argvUint16;
|
||||
UINT32 argvUint32;
|
||||
|
||||
UINT8 handlerStr[PS_RAM_INTERNAL_MSG_STR_SIZE];
|
||||
}PsRamInternalMsgLog;
|
||||
|
||||
#define PS_RAM_INTERNAL_MSG_LOG_SIZE sizeof(PsRamInternalMsgLog)
|
||||
|
||||
/*
|
||||
* PS_RAM_DEBUG_ASSERT_RECORD
|
||||
* PS_RAM_ASSERT_RECORD
|
||||
* sizeof(PsRamAssertInfoLog) = 60
|
||||
*/
|
||||
#define PS_RAM_ASSERT_FUNC_STR_SIZE 32
|
||||
#define PS_RAM_ASSERT_FILE_STR_SIZE 14
|
||||
typedef struct PsRamAssertInfoLog_Tag
|
||||
{
|
||||
//printf("Assert (%.32s), file: %s, (0x%lx, 0x%lx, 0x%lx), line: %d", #cond, __FILE__, (v1), (v2), (v3), __LINE__);
|
||||
UINT8 func[PS_RAM_ASSERT_FUNC_STR_SIZE];
|
||||
UINT8 fileName[PS_RAM_ASSERT_FILE_STR_SIZE];
|
||||
UINT16 lineNum;
|
||||
UINT32 var1;
|
||||
UINT32 var2;
|
||||
UINT32 var3;
|
||||
}PsRamAssertInfoLog;
|
||||
#define PS_RAM_ASSERT_INFO_LOG_SIZE sizeof(PsRamAssertInfoLog)
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* API
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
void PsRamLogVar(UINT8 *file, UINT16 line, UINT32 var1, UINT32 var2, UINT32 var3);
|
||||
void PsRamLogSig(UINT16 dTaskId, UINT16 sigId);
|
||||
void PsRamLogSigDump(UINT16 dTaskId, SignalBuf *pSig);
|
||||
void PsRamLogHexDump(UINT8 *file, UINT16 line, UINT16 hexLen, UINT8 *hex);
|
||||
void PsRamLogInternalMsg(UINT8 *strHandler, UINT8 srcId, UINT8 argvUint8, UINT16 argvUint16, UINT32 argvUint32);
|
||||
//void GosLogDebugAssertInfo(UINT8 *pFunc, UINT8 *pFile, UINT16 line, UINT32 var1, UINT32 var2, UINT32 var3);
|
||||
//void GosLogAssertInfo(UINT8 *pFunc, UINT8 *pFile, UINT16 line, UINT32 var1, UINT32 var2, UINT32 var3);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
#ifndef PSIF_HDR_API_H
|
||||
#define PSIF_HDR_API_H
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2018- Copyrights of AirM2M Ltd.
|
||||
File name: - psifapi.h
|
||||
Description: - ps netif UL/DL function header
|
||||
History: - 01/02/2018, Originated by xwang
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#include "pspdu.h"
|
||||
|
||||
#define PS_DLPDUBLOCK_SIZE sizeof(DlPduBlock)
|
||||
|
||||
typedef enum PsIfRetEnum_Tag
|
||||
{
|
||||
PSIF_SUCC = 0,
|
||||
PSIF_ERROR
|
||||
}PsIfRetEnum;
|
||||
|
||||
typedef struct PsifDlDataHeader_Tag
|
||||
{
|
||||
UINT16 magic; //PS_UL_MAGIC
|
||||
UINT16 dlLen; // UL packet length
|
||||
}PsifDlDataHeader;
|
||||
|
||||
#define PBUF_DLRAM_HLEN (sizeof(PsifDlDataHeader))
|
||||
|
||||
|
||||
typedef UINT8 PsIfRet;
|
||||
|
||||
/******************************************************************************
|
||||
* DL, NW -> UE, PS -> LWIP *
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* PSIF API:
|
||||
* DL IP PKG memory allocation API
|
||||
* 1> Here, LWIP could reserve the "pbuf" memory before this return memory, and LWIP don't need to copy the PKG data again
|
||||
* in function "ps_receive_data()";
|
||||
* 2> This API dhouls safe for several tasks access
|
||||
* 3> ip pkg len must not bigger than: (PBUF_POOL_BUFSIZE - sizeof(struct pbuf) - sizeof(DlPduBlock))
|
||||
* The memory allocated:
|
||||
* +-----------------+--------------------------+--------------------------+
|
||||
* | pbuf (16 bytes) | DlPduBlock (12 bytes) | ip pkg Len |
|
||||
* +-----------------+--------------------------+--------------------------+
|
||||
* ^
|
||||
* | return address
|
||||
*
|
||||
* Input: UINT16 ipPkgLen = ip pkg len
|
||||
*
|
||||
* Note: DlPduBlock not need to init in this API
|
||||
*/
|
||||
DlPduBlock *PsifAllocDlIpPkgBlockMem(UINT16 ipPkgLen);
|
||||
|
||||
/*
|
||||
* LWIP API
|
||||
* DL IP PKG memory free API, free all list memory
|
||||
* if PS found the IP PKG is not right, could free the memory
|
||||
*/
|
||||
void PsifFreeDlIpPkgBlockList(DlPduBlock *pPkgBlock);
|
||||
|
||||
/*
|
||||
* LWIP API
|
||||
* process the DL IP PKG
|
||||
* 1> This API maybe called in ISR, don't take too much operation;
|
||||
* 2> PS -> LWIP, could send several IP pkg at one time;
|
||||
* 3> LWIP response for the memory free;
|
||||
* 4> 0 success,others fail
|
||||
*/
|
||||
PsIfRet PsifRecvDlIpPkg(UINT8 cid, DlPduBlock *pPduHdr);
|
||||
|
||||
/*
|
||||
* LWIP API
|
||||
*/
|
||||
void PsifFreeUlIpPkgMem(UINT8 *pPkgData);
|
||||
|
||||
|
||||
/*
|
||||
* LWIP API
|
||||
* Whether LWIP DL high water, if return not zero, don't call "PsifAllocDlIpPkgBlockMem()" to allocate the DL memory;
|
||||
*/
|
||||
UINT8 PsifIsDlHighWater(void);
|
||||
|
||||
|
||||
/*
|
||||
* LWIP API
|
||||
* Called by PS, notify LWIP task whether PS is suspended or resumed;
|
||||
* Note:
|
||||
* 1> if need to some operation with NETIF, suggest handle it in LWIP task;
|
||||
* 2> "bSuspend" = TRUE, just means PS suspended, can't send any UL pkg;
|
||||
* 3> "bSuspend" = FALSE, just means PS resumed, then LWIP could send UL pkg (maybe pended UL pkg);
|
||||
* 4> In some case, maybe UL "exception" data could still allow to send if suspended, here, we don't support it now; - TBD
|
||||
*/
|
||||
void PsifPsResumeSuspendInd(BOOL bSuspend);
|
||||
|
||||
/*
|
||||
* LWIP API
|
||||
* Check whether any UL pending(suspended) pkg in LWIP task;
|
||||
*/
|
||||
BOOL PsifAnySuspendULPendingPkg(void);
|
||||
|
||||
|
||||
/*
|
||||
* PSIF API
|
||||
* check whether reserved size (LWIP_PBUF_STRUCT_LEN) is enough for pbuf
|
||||
*/
|
||||
void PsifPbufSizeCheck(void);
|
||||
|
||||
/*
|
||||
* PSIF API
|
||||
* Set and init pbuf struct, which located before "DlPduBlock", called by CEDR, when alloc DL PKG memory
|
||||
*/
|
||||
void PsifInitPsDlPkgPbuf(DlPduBlock *pDlPduBlk);
|
||||
|
||||
/*
|
||||
* PSIF API
|
||||
* Free pbuf which type is: PBUF_PS_DL_PKG, called by: pbuf_free()
|
||||
* input: struct pbuf *p
|
||||
*/
|
||||
void PsifFreePsDlPkgPbuf(void *pbuf);
|
||||
|
||||
UINT16 PsifGetCurrentPacketDelay(void);
|
||||
|
||||
|
||||
/*
|
||||
* Free all netif TFT packet filter list
|
||||
*/
|
||||
void PsifNetifTftFree(void *tft_list);
|
||||
|
||||
BOOL PsifDlRamCheckHighWater(UINT16 preAllocLength);
|
||||
|
||||
struct pbuf * PsifTcpipDlHighWaterChkInput(struct pbuf *pInput);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef PSIF_HDR_EVENT_H
|
||||
#define PSIF_HDR_EVENT_H
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2018- Copyrights of AirM2M Ltd.
|
||||
File name: - psifevent.h
|
||||
Description: - ps if related event header file
|
||||
History: - 11/01/2018, Originated by xwang
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#include "networkmgr.h"
|
||||
#include "netif.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* Functions
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
//void PsifSendNetifInfoInd(struct netif *pNetif, NmNetifStatus status, NmNetifStatusChangeCause cause);
|
||||
void PsifSendNetifInfoInd(struct netif *pNetif, NmNetifStatusChangeCause cause);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
|
||||
* File name: psl1commtype.h
|
||||
* Description:
|
||||
* History: 25/04/2021 Originated
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _PS_L1_COMMON_TYPE_H_
|
||||
#define _PS_L1_COMMON_TYPE_H_
|
||||
|
||||
/*********************************************************************************
|
||||
* Includes
|
||||
*********************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "pssys.h"
|
||||
#else
|
||||
#include "CommonTypedef.h"
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MACRO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
#define SUPPORT_MAX_BAND_NUM 32 //Extend from 16 to 32, 2020-7-28
|
||||
#define RRC_PHY_SUPPORT_BAND_NUM SUPPORT_MAX_BAND_NUM //this value should be the same as PHY_SUPPORT_BAND_NUM
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Plmn
|
||||
* Numberic PLMN format, 4 bytes,
|
||||
* example: CMCC: 46000; mcc = 0x0460, mnc = 0xf000
|
||||
* 00101; mcc = 0x0001, mnc = 0xf001
|
||||
* 46012; mcc = 0x0460, mnc = 0xf012
|
||||
* 460123; mcc = 0x0460, mnc = 0x0123
|
||||
******************************************************************************/
|
||||
typedef struct _EPAT_Plmn_Tag
|
||||
{
|
||||
UINT16 mcc;
|
||||
UINT16 mncWithAddInfo; // if 2-digit MNC type, the 4 MSB bits should set to 'F',
|
||||
}Plmn;
|
||||
|
||||
|
||||
/*
|
||||
* UE category, ref to 36.306
|
||||
*/
|
||||
typedef UINT8 UeCategoryType_t;
|
||||
typedef enum _EPAT_UeCategoryType_Tag
|
||||
{
|
||||
UeCategory_NB1 = 0x01,
|
||||
UeCategory_NB2 = 0x02,
|
||||
UeCategory_M1 = 0x11,
|
||||
UeCategory_M2 = 0x12,
|
||||
UeCategory_Cat1Base = 0x20, //only used for Cat1 start point
|
||||
UeCategory_Cat1 = 0x21,
|
||||
UeCategory_Cat1bis = 0x22,
|
||||
}UeCategoryType;
|
||||
|
||||
/*
|
||||
* As Release, start from Rel-13
|
||||
*/
|
||||
typedef UINT8 AsReleaseType_t;
|
||||
typedef enum _EPAT_AsReleaseType_Tag
|
||||
{
|
||||
AsRelease_13 = 13,
|
||||
AsRelease_14,
|
||||
AsRelease_15,
|
||||
}AsReleaseType;
|
||||
|
||||
|
||||
/*
|
||||
* CERRC_CFG_UE_POWER_CLASS_SETTING
|
||||
*/
|
||||
typedef struct PsCfgConfigedUePowerClassTag
|
||||
{
|
||||
//now support to 255
|
||||
UINT8 freqBandIndicator;
|
||||
/*refer to TS36.101 table 6.2.2F-1,
|
||||
-- 3 represents Class3(maxpower: 23dBm)
|
||||
-- 5 represents Class5 (maxpower: 20dBm)
|
||||
-- 6 represents Class6 (maxpower: 14dBm) and only apply for R14 and later */
|
||||
UINT8 uePowerClass;
|
||||
}PsCfgConfigedUePowerClass;
|
||||
|
||||
typedef struct PsCfgCerrcUePowerClassSetting_Tag
|
||||
{
|
||||
UINT8 numOfBand;
|
||||
UINT8 rsvd0;
|
||||
UINT16 rsvd1;
|
||||
PsCfgConfigedUePowerClass bandAndPowerClass[RRC_PHY_SUPPORT_BAND_NUM];
|
||||
}PsCfgCerrcUePowerClassSetting; // 68 bytes
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#ifndef __PS_NVM_UTIL_H__
|
||||
#define __PS_NVM_UTIL_H__
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017- Copyrights of AirM2M Ltd.
|
||||
File name: - psnvmutil.h
|
||||
Description: - Protocol Stack NVM basic utility
|
||||
History: - 13/09/2020, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#include "pssys.h"
|
||||
|
||||
#define PS_USE_OSA_NVM_FUNC 1
|
||||
|
||||
typedef enum PsNvmFileIdEnum_Tag
|
||||
{
|
||||
//PS_BASE_NVM = 0,
|
||||
/*
|
||||
* PS info NVM, maintained in psinfonvm.c
|
||||
*/
|
||||
PS_CCM_INFO_NVM = 0,
|
||||
PS_CEMM_EMM_INFO_NVM,
|
||||
PS_CEMM_COMM_INFO_NVM,
|
||||
PS_CEMM_PLMN_INFO_NVM,
|
||||
PS_CESM_INFO_NVM,
|
||||
PS_UICCCTRL_INFO_NVM,
|
||||
PS_CERRC_INFO_NVM,
|
||||
|
||||
PS_INFO_NVM_MAX,
|
||||
|
||||
/*
|
||||
* PS config NVM, maintained in psnvm.c
|
||||
*/
|
||||
PS_CESM_PDP_CONFIG_NVM = PS_INFO_NVM_MAX,
|
||||
PS_CESM_PDP_AUTH_CONFIG_NVM,
|
||||
|
||||
PS_MAX_NVM
|
||||
}PsNvmFileIdEnum;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* PS NVM filer header structure
|
||||
* by now: 36 bytes
|
||||
******************************************************************************/
|
||||
#define PS_NVM_FILE_NAME_SIZE 32
|
||||
|
||||
#if (PS_USE_OSA_NVM_FUNC != 1)
|
||||
typedef struct PsNvmFileHeader_Tag
|
||||
{
|
||||
UINT8 fName[PS_NVM_FILE_NAME_SIZE];
|
||||
UINT16 fileBodySize; //file body size, not include size of header;
|
||||
UINT8 version;
|
||||
UINT8 checkSum;
|
||||
}PsNvmFileHeader; //36 bytes
|
||||
#endif
|
||||
|
||||
/*
|
||||
* if no NVM file found, use the default value.
|
||||
*/
|
||||
typedef void (*PsNvmSetDefaultValueFunc)(void *ctxBuf, UINT16 bufSize);
|
||||
/*
|
||||
* adjust NVM file, from OLD VERSION -> CUR/Latest verion
|
||||
*/
|
||||
typedef BOOL (*PsNvmAdjustVersionFunc)(UINT8 oldVer, void *oldCtx, UINT16 oldCtxSize, void *curCtx, UINT16 curCtxSize);
|
||||
/*
|
||||
* 44 bytes
|
||||
*/
|
||||
typedef struct PsNvmFileOper_Tag
|
||||
{
|
||||
UINT8 fileId; //PsNvmFileIdEnum
|
||||
UINT8 curVersion;
|
||||
UINT16 fileSize;
|
||||
|
||||
UINT8 fileName[PS_NVM_FILE_NAME_SIZE];
|
||||
|
||||
PsNvmSetDefaultValueFunc setDefaultFunc;
|
||||
PsNvmAdjustVersionFunc adjustVerFunc;
|
||||
}PsNvmFileOper;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* Functions
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
BOOL PsNvmRead(PsNvmFileIdEnum fileId, void *dataBuf, UINT16 bufSize);
|
||||
BOOL PsNvmWrite(PsNvmFileIdEnum fileId, void *dataBuf, UINT16 bufSize);
|
||||
#define PsNvmUpdate(fileId, dataBuf, bufSize) \
|
||||
PsNvmWrite(fileId, dataBuf, bufSize)
|
||||
void PsNvmSaveAll(void);
|
||||
BOOL PsNvmSave(PsNvmFileIdEnum fileId);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
603
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/pssys.h
Normal file
603
sdk/合宙/air780e/csdk/luatos-soc-2022/PLAT/prebuild/PS/inc/pssys.h
Normal file
@@ -0,0 +1,603 @@
|
||||
#ifndef __PS_SYS_H__
|
||||
#define __PS_SYS_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M
|
||||
File name: - pssys.h
|
||||
Description: - PS system common include header files, and common MARCO
|
||||
History: - 08/09/2020, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* include OS header files
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "winsys.h"
|
||||
#include "osautil.h"
|
||||
#else
|
||||
#include "osasys.h"
|
||||
#include "ostask.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "debug_trace.h"
|
||||
#include "sctdef.h"
|
||||
#endif
|
||||
#include "osanvm.h"
|
||||
#include "psdebug.h"
|
||||
#include "pstrace.h"
|
||||
|
||||
#ifdef WIN32
|
||||
//#define EUTRAN_CAT_MODE
|
||||
#endif
|
||||
//#define EUTRAN_NB_MODE
|
||||
|
||||
#undef PS_ENABLE_LPP_LCS_FEATURE /* Cat1 disable LCS feature */
|
||||
//#define PS_ENABLE_LPP_LCS_FEATURE
|
||||
|
||||
/*
|
||||
* offset of body in a structure
|
||||
*/
|
||||
#ifndef OFFSETOF
|
||||
#define OFFSETOF(type, body) ((UINT32)&(((type *)0)->body))
|
||||
#endif
|
||||
|
||||
#ifndef GOS_GET_SIGNAL_FROM_BODY
|
||||
#define GOS_GET_SIGNAL_FROM_BODY OSA_GET_SIGNAL_FROM_BODY
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 4 bytes align
|
||||
*/
|
||||
#ifndef ALIGNED_4BYTE
|
||||
#ifdef WIN32
|
||||
#define ALIGNED_4BYTE
|
||||
#else
|
||||
#define ALIGNED_4BYTE __ALIGNED(4)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ALIGNED_128KB
|
||||
#ifdef WIN32
|
||||
#define ALIGNED_128KB
|
||||
#else
|
||||
#define ALIGNED_128KB CAT_UP_DATA //__ALIGNED(0x20000)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Code in RAM
|
||||
*/
|
||||
#ifndef PS_CODE_IN_RAM
|
||||
#ifdef WIN32
|
||||
#define PS_CODE_IN_RAM
|
||||
#else
|
||||
//#define PS_CODE_IN_RAM __attribute__((__section__(".ramCode2")))
|
||||
#define PS_CODE_IN_RAM PS_FM_RAMCODE /* FM: Full image, MSMB */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PS_SLP2_ZI
|
||||
#ifdef WIN32
|
||||
#define PS_SLP2_ZI
|
||||
#else
|
||||
#define PS_SLP2_ZI PS_FA_ZI /* DATA in ASMB, remain in sleep2, and zero inited */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PS_SLP2_DATA
|
||||
#ifdef WIN32
|
||||
#define PS_SLP2_DATA
|
||||
#else
|
||||
#define PS_SLP2_DATA PS_FA_DATA /* DATA in ASMB, remain in sleep2 */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* 4 bytes aligned size
|
||||
*/
|
||||
#define FOUR_BYTE_ALIGN_SIZE(size) (((size)+3)&(0xFFFFFFFC))
|
||||
|
||||
#ifndef CAT_PSPHY_SHAREDATA
|
||||
#ifdef WIN32
|
||||
#define CAT_PSPHY_SHAREDATA
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#define PS_HW_REG_WRITE_32(_pHW, val)
|
||||
#define PS_HW_REG_READ_32(_pHW, val)
|
||||
#else
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
|
||||
#define PS_HW_REG_WRITE_32(_pHW, val) \
|
||||
do { \
|
||||
__asm \
|
||||
{ \
|
||||
STR val, [_pHW] \
|
||||
} \
|
||||
}while(FALSE)
|
||||
|
||||
#define PS_HW_REG_READ_32(_pHW, val) \
|
||||
do { \
|
||||
__asm \
|
||||
{ \
|
||||
LDR val, [_pHW] \
|
||||
} \
|
||||
}while(FALSE)
|
||||
|
||||
#elif defined ( __GNUC__ )
|
||||
|
||||
#define PS_HW_REG_WRITE_32(_pHW, val) __STREXW(val, _pHW)
|
||||
|
||||
#define PS_HW_REG_READ_32(_pHW, val) val = __LDREXW(_pHW)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* InternalMsg
|
||||
* internal message in a task, used to communicate between sub-modules in a task
|
||||
* 16 bytes
|
||||
*****************************************************************************/
|
||||
typedef void (*MsgHandler)(UINT8 srcId, UINT8 argvUint8, UINT16 argvUint16, UINT32 argvUint32, void* argvPtr);
|
||||
typedef struct InternalMsg_Tag
|
||||
{
|
||||
MsgHandler msgHandler;
|
||||
|
||||
UINT8 srcId; // msg from which sub-module
|
||||
UINT8 argvUint8;
|
||||
UINT16 argvUint16;
|
||||
UINT32 argvUint32;
|
||||
void *argvPtr;
|
||||
}InternalMsg;
|
||||
|
||||
/******************************************************************************
|
||||
* MsgQueue
|
||||
* Message buffer queue, use to buffer internal message
|
||||
*****************************************************************************/
|
||||
typedef UnitQueue MsgQueue;
|
||||
|
||||
/******************************************************************************
|
||||
* EMPTY SIGNAL
|
||||
******************************************************************************/
|
||||
typedef UINT32 GosEmptySignal;
|
||||
|
||||
/******************************************************************************
|
||||
* SIG_WIN_SIMULATE_INTERNAL_MSG
|
||||
******************************************************************************/
|
||||
typedef struct WinSimulateInternalMsg_Tag
|
||||
{
|
||||
MsgHandler msgHandler;
|
||||
|
||||
UINT8 srcId; // msg from which sub-module
|
||||
UINT8 argvUint8;
|
||||
UINT16 argvUint16;
|
||||
UINT32 argvUint32;
|
||||
void *argvPtr;
|
||||
}WinSimulateInternalMsg;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* external some SYS/OS API
|
||||
******************************************************************************
|
||||
*****************************************************************************/
|
||||
void GosLogSig(UINT16 dTaskId, SignalBuf *pSig);
|
||||
void GosDumpSig(UINT16 dTaskId, SignalBuf *pSig);
|
||||
|
||||
//void GosCreateSignal(UINT16 sigId, UINT16 sigBodySize, SignalBuf **signal);
|
||||
#define GosCreateSignal OsaCreateSignal
|
||||
//void GosCreateZeroSignal(UINT16 sigId, UINT16 sigBodySize, SignalBuf **signal);
|
||||
#define GosCreateZeroSignal OsaCreateZeroSignal
|
||||
//void GosCreateIsrSignal(UINT16 sigId, UINT16 sigBodySize, SignalBuf **signal);
|
||||
#define GosCreateIsrSignal OsaCreateIsrSignal
|
||||
#define GosCreateZeroIsrSignal OsaCreateZeroIsrSignal
|
||||
|
||||
//void GosSendSignal(UINT16 taskId, SignalBuf **signal);
|
||||
#define GosSendSignal OsaSendSignal
|
||||
#define GosSendNoLogSignal OsaSendNoLogSignal
|
||||
// dump the signal to RAM
|
||||
#define GosSendDumpSignal OsaSendDumpSignal
|
||||
#define GosSendNoDumpSignal OsaSendNoDumpSignal
|
||||
//void OsaSendSignalToFront(UINT16 taskId, SignalBuf **signal)
|
||||
#define GosSendSignalToFront OsaSendSignalToFront
|
||||
|
||||
|
||||
//void GosDestroySignal(SignalBuf **signal);
|
||||
#define GosDestroySignal OsaDestroySignal
|
||||
//void OsaDestroyFastSignal(SignalBuf **signal);
|
||||
#define GosDestroyIsrSignal OsaDestroyIsrSignal
|
||||
//void GosReceiveSignal(UINT16 taskId, SignalBuf **signal); // if no signal received, just blocked
|
||||
#define GosReceiveSignal OsaReceiveSignal
|
||||
|
||||
|
||||
/* Create PHY signal, called by ERRC/L2 */
|
||||
void GosCreateSignalToPhy(UINT16 sigId, UINT16 sigBodySize, SignalBuf **signal);
|
||||
|
||||
/* Send the signal to PHY*/
|
||||
void GosSendSignalToPhy(SignalBuf **signal);
|
||||
|
||||
/* Destory the signal to PHY, if ERRC/L2 not need to send the signal to PHY */
|
||||
void GosDestroySignalToPhy(SignalBuf **signal);
|
||||
|
||||
/* Destory the signal send from PHY, called by ERRC/L2 */
|
||||
void GosDestroySignalFromPhy(SignalBuf **signal);
|
||||
|
||||
/* Allocate the dynamic memory, which need to pass to PHY */
|
||||
void* GosAllocMemoryToPhy(UINT16 size);
|
||||
|
||||
/* Free the memory, which comes from PHY */
|
||||
void GosFreeMemoryFromPhy(void **ptr); //after free it, *ptr is set to PNULL
|
||||
|
||||
//void* GosAllocMemory(UINT16 size); // if no memory left, NULL will return
|
||||
#define GosAllocMemory OsaAllocMemory
|
||||
//void* GosAllocZeroMemory(UINT16 size);
|
||||
#define GosAllocZeroMemory OsaAllocZeroMemory
|
||||
//void* GosAllocMemoryNoAssert(UINT32 size);
|
||||
#define GosAllocMemoryNoAssert OsaAllocMemoryNoAssert /* return PNULL, if no memory allcated */
|
||||
//void* GosAllocZeroMemoryNoAssert(UINT32 size);
|
||||
#define GosAllocZeroMemoryNoAssert OsaAllocZeroMemoryNoAssert /* return PNULL, if no memory allcated */
|
||||
//void GosFreeMemory(void **ptr); //after free it, *ptr is set to PNULL
|
||||
#define GosFreeMemory OsaFreeMemory
|
||||
|
||||
|
||||
//UINT8 PsNvmCalcCrcValue(const UINT8 *dataBuf, UINT16 bufSize)
|
||||
#define PsNvmCalcCrcValue OsaCalcCrcValue
|
||||
|
||||
#ifdef WIN32
|
||||
#define GosRand rand
|
||||
#else
|
||||
#define GosRand OsaRand
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define PsAllocSlp2Mem GosAllocMemory
|
||||
#define PsAllocZeroSlp2Mem GosAllocZeroMemory
|
||||
#define PsFreeSlp2Mem GosFreeMemory
|
||||
#else
|
||||
/*
|
||||
* Memory allocated in sleep2 ASMB memory
|
||||
* !!! Note: memory may alloc fail. and return PNULL !!!
|
||||
*/
|
||||
void *PsSlp2MallocEC(UINT32 xWantedSize, unsigned int funcPtr);
|
||||
void *PsSlp2MallocZero(UINT32 xWantedSize);
|
||||
void PsSlp2FreeEC( void *pv );
|
||||
|
||||
#define PsAllocSlp2Mem(size) PsSlp2MallocEC((size), 0)
|
||||
#define PsAllocZeroSlp2Mem(size) PsSlp2MallocZero((size))
|
||||
#define PsFreeSlp2Mem(pPtr) \
|
||||
do { \
|
||||
GosCheck((pPtr) != PNULL && (*(pPtr)) != PNULL, (pPtr), (*(pPtr)), 0); \
|
||||
PsSlp2FreeEC(*(pPtr)); \
|
||||
(*(pPtr)) = PNULL; \
|
||||
}while(FALSE);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NVM file APIs
|
||||
*/
|
||||
#ifdef WIN32
|
||||
typedef FILE* GOSFILE;
|
||||
//GOSFILE GosFopen(UINT8 nvId, UINT8 *fileName, UINT8 *mode);
|
||||
#define GosFopen(nvId, fileName, mode) WinFopen((fileName), (mode))
|
||||
#define GosFclose WinFclose
|
||||
#define GosFread WinFread
|
||||
#define GosFwrite WinFwrite
|
||||
#define GosFremove WinFremove
|
||||
#elif defined NVRAM_FILE_SYSTEM //old file system
|
||||
//typedef NVFILE_HANDLER GOSFILE;
|
||||
typedef void* GOSFILE;
|
||||
//GOSFILE GosFopen(UINT8 nvId, UINT8 *fileName, UINT8 *mode);
|
||||
#define GosFopen(nvId, fileName, mode) (GOSFILE)NVFopen((nvId), (mode))
|
||||
//UINT32 GosFclose(GOSFILE fp);
|
||||
#define GosFclose(fp) NVFclose((NVFILE_HANDLER)(fp))
|
||||
//UINT32 GosFread(void *buf, UINT32 size, UINT32 count, GOSFILE fp);
|
||||
#define GosFread(buf, size, count, fp) NVFread((buf), (size), (count), (NVFILE_HANDLER)(fp))
|
||||
//UINT32 GosFwrite(void *buf, UINT32 size, UINT32 count, GOSFILE fp);
|
||||
#define GosFwrite(buf, size, count, fp) NVFwrite((buf), (size), (count), (NVFILE_HANDLER)(fp))
|
||||
//UINT32 GosFremove(UINT8 *fileName);
|
||||
#define GosFremove(fileName) NVFremove(0)
|
||||
#else
|
||||
typedef OSAFILE GOSFILE;
|
||||
//GOSFILE GosFopen(UINT8 nvId, UINT8 *fileName, UINT8 *mode);
|
||||
#define GosFopen(nvId, fileName, mode) (GOSFILE)OsaFopen((const char *)(fileName), (const char *)(mode))
|
||||
#define GosFclose OsaFclose
|
||||
#define GosFread OsaFread
|
||||
#define GosFwrite OsaFwrite
|
||||
#define GosFremove OsaFremove
|
||||
#endif
|
||||
|
||||
/*
|
||||
* OSA NVM operation
|
||||
*/
|
||||
typedef OsaNvmRet PsNvmRet;
|
||||
typedef OsaNvmBodyInfo PsNvmBodyInfo;
|
||||
|
||||
/*
|
||||
* void OsaNvmFreeBody(OsaNvmBodyInfo *pNvmBodyInfo);
|
||||
*/
|
||||
#define PsNvmFreeBody OsaNvmFreeBody
|
||||
|
||||
|
||||
/*
|
||||
* GosGetSysTickCout
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#define GosGetSysTickCount() GetTickCount()
|
||||
#else
|
||||
#define GosGetSysTickCount() osKernelGetTickCount()
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
externl functions
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
typedef enum PsPrintModId_Tag
|
||||
{
|
||||
PS_MOD_START_ID = 0x10,
|
||||
PS = PS_MOD_START_ID,
|
||||
PS_UP = 0x11,
|
||||
PS_CERRC,
|
||||
PS_NAS,
|
||||
PS_UICC,
|
||||
PS_UICC_DRV,
|
||||
PS_CCM,
|
||||
PS_CAC,
|
||||
|
||||
PS_MOD_MAX_ID = 0x30
|
||||
}PsPrintModId;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GosPrintf/GosPsPrintf
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#define GosTraceAddModule(_module_name, _trace_level)
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define GosPrintf OsaPrintf
|
||||
#else
|
||||
#define GosPrintf(level, fmt, ...)
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define GosPsPrintf OsaPsPrintf
|
||||
#else
|
||||
#define GosPsPrintf(mod, submod, level, fmt, ...)
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define GosHexDump(_module, _level, _dump_name, _data, _len) \
|
||||
OsaHexDump((_dump_name), _data, _len)
|
||||
#else
|
||||
//void GosHexDump(_module, _level,_dump_name, _data, _len)
|
||||
#define GosHexDump(_module, _level, _dump_name, _data, _len)
|
||||
#endif
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GosCheck/GosDebugBegin/GosDebugEnd
|
||||
******************************************************************************/
|
||||
#define GosCheck OsaCheck
|
||||
#define GosDebugBegin OsaDebugBegin
|
||||
#define GosDebugEnd OsaDebugEnd
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Internal message queue function
|
||||
******************************************************************************/
|
||||
void GosLogInternalMsg(InternalMsg *msg, const CHAR *pHdr, UINT16 varSize);
|
||||
|
||||
//void GosMsgQueueInit(MsgQueue *msgQ);
|
||||
#define GosMsgQueueInit(Q) UnitQueueInit((Q), sizeof(InternalMsg))
|
||||
/*
|
||||
* void GosMsgEnQueue(MsgQueue *msgQ, InternalMsg *msg, MsgHandler hdr, UINT16 varSize);
|
||||
* MsgQueue *msgQ; // internal Msg queue
|
||||
* InternalMsg *msg; // internal Msg;
|
||||
* MsgHandler hdr; //which callback func;
|
||||
* UINT16 varSize; //size of "argvPtr"
|
||||
*/
|
||||
//#define GosMsgEnQueue(Q, M, H, S) UnitEnQueue((Q), (M))
|
||||
#define GosMsgEnQueue(Q, M, H, S) \
|
||||
do { \
|
||||
GosLogInternalMsg((M), #H, (S)); \
|
||||
UnitEnQueue((Q), (M)); \
|
||||
}while(FALSE)
|
||||
|
||||
|
||||
//void GosMsgDeQueue(MsgQueue *msgQ, InternalMsg *msg);
|
||||
#define GosMsgDeQueue(Q, M) UnitDeQueue((Q), (M))
|
||||
//void GosMsgOnQueue(MsgQueue *msgQ);
|
||||
#define GosMsgOnQueue(Q) UnitOnQueue((Q))
|
||||
//void GosMsgFlushQueue(MsgQueue *msgQ);
|
||||
#define GosMsgFlushQueue(Q) UnitFlushQueue((Q))
|
||||
|
||||
/******************************************************************************
|
||||
* Gos Signal QUEUE function
|
||||
******************************************************************************/
|
||||
#define GosSigQueueInit OsaSigQueueInit
|
||||
//void GosSigEnQueue(SignalQueue *que, SignalBuf **signal);
|
||||
#define GosSigEnQueue OsaSigEnQueue
|
||||
//void GosSigDeQueue(SignalQueue *que, SignalBuf **signal);
|
||||
#define GosSigDeQueue OsaSigDeQueue
|
||||
//BOOL GosSigOnQueue(SignalQueue *que);
|
||||
#define GosSigOnQueue OsaSigOnQueue
|
||||
//void GosSigFlushQueue(SignalQueue *que);
|
||||
#define GosSigFlushQueue OsaSigFlushQueue
|
||||
|
||||
/******************************************************************************
|
||||
* Gos Task Flags function
|
||||
******************************************************************************/
|
||||
//UINT32 GosTaskFlagsSet(UINT16 taskId, UINT32 flags);
|
||||
#define GosTaskFlagsSet OsaTaskFlagsSet
|
||||
//UINT32 GosTaskFlagsWait(UINT32 waitFlags);
|
||||
#define GosTaskFlagsWait OsaTaskFlagsWait
|
||||
//UINT32 OsaTaskFlagsClear(UINT32 clearFlags)
|
||||
#define GosTaskFlagsClear OsaTaskFlagsClear
|
||||
|
||||
/******************************************************************************
|
||||
* Gos signal timer function
|
||||
* When timer expiry, timer task will create a signal (TIMER_EXPIRY) to SRC task
|
||||
******************************************************************************/
|
||||
typedef OsaTimerId GosTimerId;
|
||||
|
||||
#define GOS_TIMER_NOT_CREATE OSA_TIMER_NOT_CREATE
|
||||
|
||||
typedef OsaTimerExpiry GosTimerExpiry;
|
||||
|
||||
void GosPsHibTimerExpiryFunc(OsaHibTimerId hibTimerId);
|
||||
|
||||
//GosTimerId GosTimerNew(UINT16 taskId, UINT16 timerEnum, osTimerType_t type);
|
||||
//osTimerId_t osTimerNew (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr)
|
||||
#ifdef WIN32
|
||||
void OsaTimerExpiryFunc(void *argument);
|
||||
#define OsaTimerNew(taskId, timerEnum, type) \
|
||||
osTimerNew(OsaTimerExpiryFunc, type, taskId, timerEnum) /* used for LPP UT */
|
||||
#define GosTimerNew(taskId, timerEnum, type) \
|
||||
osTimerNew(OsaTimerExpiryFunc, type, taskId, timerEnum)
|
||||
#else
|
||||
#define GosTimerNew OsaTimerNew
|
||||
#endif
|
||||
#define GosTimerStart OsaTimerStart
|
||||
#define GosTimerStop OsaTimerStop
|
||||
#define GosTimerIsRunning OsaTimerIsRunning
|
||||
//osStatus_t GosTimerDelete(GosTimerId *timer_id);
|
||||
#define GosTimerDelete OsaTimerDelete
|
||||
#define GosTimerGetRemainTicks OsaTimerGetRemainTicks
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* TIMER/SYS time ticks info, which need to still runing in HIBERNATE STATE
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
typedef OsaHibMs GosHibMs;
|
||||
|
||||
#ifdef WIN32
|
||||
typedef struct GosHibTimerExpiry_Tag
|
||||
{
|
||||
UINT8 hibTimerId;
|
||||
UINT8 reserved0;
|
||||
UINT16 reserved1;
|
||||
}GosHibTimerExpiry;
|
||||
#else
|
||||
typedef OsaHibTimerExpiry GosHibTimerExpiry;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get current HIB second count
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#define GosGetHibSecondCount() GetTickCount()
|
||||
#else
|
||||
extern uint32_t apmuGetHibSecondCount(void);
|
||||
#define GosGetHibSecondCount() apmuGetHibSecondCount()
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get current HIB count in unit of 10 ms
|
||||
* Max count: 0x0FFFFFFF (745 hours), when extended 0x0FFFFFFF, will set to 0
|
||||
*/
|
||||
#define GOS_HIB_10MS_COUNT_MAX 0x0FFFFFFF
|
||||
#ifdef WIN32
|
||||
#define GosGetHib10MsCount() GetTickCount()
|
||||
#else
|
||||
extern uint32_t hibTimerGet10MsCnt(void);
|
||||
#define GosGetHib10MsCount() hibTimerGet10MsCnt()
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* MARCO:
|
||||
* SECONDS_TO_HIB_TICKS(sec)
|
||||
* MINUTES_TO_HIB_TICKS(min)
|
||||
* MILLISECONDS_TO_HIB_TICKS(MS)
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* GosHibTimerStart
|
||||
* Description: Start HIB timer
|
||||
* OsaHibTimerId timerId; //which HIB timer
|
||||
* UINT32 periodMs; //timer period in millisecond
|
||||
* output: void
|
||||
* Comment:
|
||||
* if "timerId" already start before, just print a warning, and restart it
|
||||
******************************************************************************/
|
||||
//void OsaHibTimerStart(OsaHibTimerId timerId, OsaHibMs nMs);
|
||||
#define GosHibTimerStart(hibTid, periodMs) OsaHibTimerStart(hibTid, periodMs)
|
||||
|
||||
/******************************************************************************
|
||||
* GosHibTimerIsRunning
|
||||
* Description: whether the HIB timer is running
|
||||
* input: OsaHibTimerId timerId
|
||||
* output: BOOL
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
//BOOL OsaHibTimerIsRunning(OsaHibTimerId timerId);
|
||||
#define GosHibTimerIsRunning(hibTid) OsaHibTimerIsRunning(hibTid)
|
||||
|
||||
/******************************************************************************
|
||||
* GosHibTimerStopAndDel
|
||||
* Description: stop HIB and delete HIB timer
|
||||
* input: OsaHibTimerId timerId
|
||||
* output: void
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
//void OsaHibTimerStopAndDel(OsaHibTimerId timerId);
|
||||
//#define GosHibTimerStop(hibTid)
|
||||
#define GosHibTimerStopAndDel(hibTid) OsaHibTimerStopAndDel(hibTid)
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GosHibTimerGetRemainMs
|
||||
* Description: Get HIB timer remaining time value in milli-seconds
|
||||
* input: OsaHibTimerId hibTId
|
||||
* output: UINT32
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
//UINT32 OsaHibTimerGetRemainMs(OsaHibTimerId hibTId)
|
||||
#define GosHibTimerGetRemainMs(hibTid) OsaHibTimerGetRemainMs(hibTid)
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* GosFwdWinSimulateInternalMsgSig
|
||||
* This API only use for integration testing in WIN PC
|
||||
******************************************************************************/
|
||||
void GosFwdWinSimulateInternalMsgSig(UINT8 srcId, UINT8 argvUint8, UINT16 argvUint16, UINT32 argvUint32, void* argvPtr);
|
||||
|
||||
/******************************************************************************
|
||||
* PsLastDeepHib
|
||||
* Description: Whether PS wake up from HIB. just means ASMB are all lost
|
||||
* input:
|
||||
* output: BOOL
|
||||
* Comment: Now: apmuBWakeupFromHib() & apmuBWakeupFromSlp2() is not suitable called for PS
|
||||
* as AP sleep mode maybe changed in MCU mode.
|
||||
******************************************************************************/
|
||||
BOOL PsLastDeepHib(void);
|
||||
|
||||
/******************************************************************************
|
||||
* PsLastDeepSlp2
|
||||
* Description: Whether PS wake up from sleep2. just means ASMB are still usefull
|
||||
* input:
|
||||
* output: BOOL
|
||||
* Comment:
|
||||
******************************************************************************/
|
||||
BOOL PsLastDeepSlp2(void);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
#ifndef __PS_TRACE_H__
|
||||
#define __PS_TRACE_H__
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017, All rights reserved by AirM2M
|
||||
File name: - pstrace.h
|
||||
Description: - PS unilog trace header
|
||||
History: - 2020/11/24, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* include OS header files
|
||||
******************************************************************************/
|
||||
#ifndef WIN32
|
||||
#include "debug_trace.h"
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* MARCO
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* EC618 unilog header/Payload0 (UINT32) struct:
|
||||
* 31 28 27 23 21 20 16 15 9 8 7 0
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | ownId | modId | subId | payLoadLen |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* A> ownId[28:31], 4 bits
|
||||
* UniLogOwnerIdType: UNILOG_PLAT/UNILOG_MIDWARE/UNILOG_PS1/UNILOG_PS2/
|
||||
* UNILOG_PHY_ONLINE/UNILOG_PHY_OFFLINE/UNILOG_APP/...
|
||||
* B> modId[21:27], 7 bits, MAX: 127
|
||||
* C> subId[11:20], 10 bits, MAX: 1023
|
||||
* D> payLoadLen[0:10], 11 bits
|
||||
* Log length MAX: 2023 bytes
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT/ENUM
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Module ID defination for owner: UNILOG_PS1
|
||||
*/
|
||||
typedef enum UniLogPs1ModIdType_enum
|
||||
{
|
||||
UNILOG_PS_DUMP = 0, /**< used for PS HEX dump */
|
||||
|
||||
UNILOG_NB_RRC_BCCH_BCH_DUMP = 1,
|
||||
UNILOG_NB_RRC_BCCH_DL_SCH_DUMP,
|
||||
UNILOG_NB_RRC_DL_CCCH_DUMP,
|
||||
UNILOG_NB_RRC_DL_DCCH_DUMP,
|
||||
UNILOG_NB_RRC_DL_PCCH_DUMP,
|
||||
UNILOG_NB_RRC_UL_CCCH_DUMP,
|
||||
UNILOG_NB_RRC_UL_DCCH_DUMP,
|
||||
|
||||
UNILOG_LTE_RRC_BCCH_BCH_DUMP,
|
||||
UNILOG_LTE_RRC_BCCH_DL_SCH_DUMP,
|
||||
UNILOG_LTE_RRC_BCCH_DL_SCH_BR_DUMP,
|
||||
UNILOG_LTE_RRC_DL_CCCH_DUMP,
|
||||
UNILOG_LTE_RRC_DL_DCCH_DUMP,
|
||||
UNILOG_LTE_RRC_DL_PCCH_DUMP,
|
||||
UNILOG_LTE_RRC_SC_MCCH_DUMP,
|
||||
UNILOG_LTE_RRC_UL_CCCH_DUMP,
|
||||
UNILOG_LTE_RRC_UL_DCCH_DUMP,
|
||||
UNILOG_LTE_RRC_VAR_MEASCONFIG_DUMP,
|
||||
|
||||
UNILOG_EPS_SECURITY_DUMP,
|
||||
UNILOG_EPS_PLAIN_DUMP,
|
||||
|
||||
UNILOG_PS = 30,
|
||||
UNILOG_PS_SIG_DUMP,
|
||||
UNILOG_PS_INTER_MSG,
|
||||
UNILOG_UP,
|
||||
UNILOG_MAC,
|
||||
UNILOG_RLC,
|
||||
UNILOG_PDCP,
|
||||
UNILOG_BM,
|
||||
UNILOG_DR,
|
||||
UNILOG_CERRC = 40,
|
||||
UNILOG_NAS = 50,
|
||||
UNILOG_CEMM,
|
||||
UNILOG_CESM,
|
||||
UNILOG_SMS,
|
||||
UNILOG_SS,
|
||||
UNILOG_NAS_PLMN,
|
||||
UNILOG_UICC = 60,
|
||||
UNILOG_UICC_DRV,
|
||||
UNILOG_CCM = 70,
|
||||
UNILOG_CCM_REG,
|
||||
UNILOG_CCM_DEV,
|
||||
UNILOG_CCM_PS,
|
||||
UNILOG_CCM_SMS,
|
||||
UNILOG_CCM_SIM,
|
||||
UNILOG_CAM = 80,
|
||||
UNILOG_CAM_DEV,
|
||||
UNILOG_CAM_MM,
|
||||
UNILOG_CAM_PS,
|
||||
UNILOG_CAM_SIM,
|
||||
UNILOG_CAM_SMS,
|
||||
|
||||
/*
|
||||
* PS1 modID add here
|
||||
*/
|
||||
|
||||
UNILOG_PS1_MOD_MAX = 127
|
||||
}UniLogPs1ModIdType;
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
/*
|
||||
* used to compate: ECOMM_TRACE()
|
||||
*/
|
||||
#define ECPS_TRACE(moduleId, subId, debugLevel, argLen, format, ...) \
|
||||
do \
|
||||
{ \
|
||||
swLogPrintf(UNILOG_PS1##__##moduleId##__##subId, debugLevel, ##__VA_ARGS__); \
|
||||
{(void)format;} \
|
||||
}while(0)
|
||||
|
||||
/*
|
||||
* New API: ECPS_PRINTF(), could print atmost: 8 parameters, and support string print
|
||||
*/
|
||||
#define ECPS_PRINTF(moduleId, subId, debugLevel, format, ...) \
|
||||
do \
|
||||
{ \
|
||||
swLogPrintf(UNILOG_PS1##__##moduleId##__##subId, debugLevel, ##__VA_ARGS__); \
|
||||
{(void)format;} \
|
||||
}while(0)
|
||||
|
||||
/*
|
||||
* #define ECOMM_DUMP(moduleId, subId, debugLevel, format, dumpLen, dump)
|
||||
*/
|
||||
#define ECPS_DUMP(moduleId, subId, debugLevel, format, dumpLen, dump) \
|
||||
do \
|
||||
{ \
|
||||
swLogDump(UNILOG_PS1##__##moduleId##__##subId, debugLevel, dumpLen, dump); \
|
||||
{(void)format;} \
|
||||
}while(0)
|
||||
|
||||
/*
|
||||
* #define ECOMM_DUMP_POLLING(moduleID, subID, debugLevel, format, dumpLen, dump)
|
||||
*/
|
||||
#define ECPS_DUMP_POLLING(moduleId, subId, debugLevel, format, dumpLen, dump) \
|
||||
do \
|
||||
{ \
|
||||
swLogDumpPolling(UNILOG_PS1##__##moduleId##__##subId, debugLevel, dumpLen, dump); \
|
||||
{(void)format;} \
|
||||
}while(0)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
* API
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,415 @@
|
||||
#ifndef __PS_UTIL_H__
|
||||
#define __PS_UTIL_H__
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2017- Copyrights of AirM2M Ltd.
|
||||
File name: - psutil.h
|
||||
Description: - Protocol Stack COMMON utility, just defined some common
|
||||
functions/structures which is common for all PS tasks
|
||||
History: - 14/09/2020, Originated by Jason
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
#include "pssys.h"
|
||||
#include "pscommtype.h"
|
||||
#include "pspdu.h"
|
||||
#include "nascommon.h"
|
||||
|
||||
#define CHECK_EBI_VALID(ebi) (((ebi) >= EBI_5) && ((ebi) <= EBI_15))
|
||||
#define CHECK_CID_VALID(cid) (((UINT32)(cid)) <= 15)
|
||||
|
||||
|
||||
/*
|
||||
* UL PKG default (LT) life time
|
||||
*/
|
||||
#define PS_UL_PKG_DEFAULT_LIFE_TIME_SEC 20
|
||||
|
||||
/*
|
||||
* MAX UL PKG pending PKG size
|
||||
*/
|
||||
#define PS_NB_UL_MAX_PENDING_PKG_SIZE 4500 //3*1500
|
||||
|
||||
/*
|
||||
* MAX UL PKG pending PKG number
|
||||
*/
|
||||
#define PS_NB_UL_MAX_PENDING_PKG_NUM 10
|
||||
|
||||
/*
|
||||
* MAX UL PKG pending PKG size used for CAT1 mode
|
||||
* Here, we suggest service request procedure cost 50ms, and UL TPT is 5.12 Mbps
|
||||
* So pending PKG size = 50*5120/8 = 32KB
|
||||
*/
|
||||
#define PS_UL_MAX_PENDING_PKG_SIZE 32000
|
||||
|
||||
/*
|
||||
* MAX UL PKG pending PKG number, 32000/1500 ~= 22, here set to 32
|
||||
*/
|
||||
#define PS_UL_MAX_PENDING_PKG_NUM 32
|
||||
|
||||
|
||||
/*
|
||||
* Invalid band indicator, band range (1..70) ref to 36.101, Table 5.7.3-1
|
||||
*/
|
||||
#define PS_INVALID_BAND 0
|
||||
|
||||
|
||||
/*
|
||||
* set bit B to 1 in D
|
||||
* example:
|
||||
* Bit1Set(0x00, 0) = 0x01
|
||||
* Bit1Set(0x01, 4) = 0x11
|
||||
*/
|
||||
#define Bit1Set(D, B) ((D) |= ((UINT32)1<<(B)))
|
||||
|
||||
/*
|
||||
* set bit B to 0 in D
|
||||
* example:
|
||||
* Bit0Set(0xFF, 0) = 0xFE
|
||||
* Bit0Set(0xFE, 4) = 0xEE
|
||||
*/
|
||||
#define Bit0Set(D, B) ((D) &= (~((UINT32)1<<(B))))
|
||||
|
||||
|
||||
/*
|
||||
* whether bit B in D is 1
|
||||
* example:
|
||||
* IsBit1(1010 1010, 0) = FALSE
|
||||
* IsBit1(1010 1010, 1) = TRUE
|
||||
*/
|
||||
#define IsBit1(D, B) ((((D)>>(B))&0x01) == 0x01)
|
||||
|
||||
/*
|
||||
* whether bit B in D is 0
|
||||
* example:
|
||||
* IsBit0(1010 1010, 0) = TRUE
|
||||
* IsBit0(1010 1010, 1) = FALSE
|
||||
*/
|
||||
#define IsBit0(D, B) ((((D)>>(B))&0x01) == 0x00)
|
||||
|
||||
/*
|
||||
* Get bit N value
|
||||
* example:
|
||||
* GetBitN(1010 1010, 0) = 0
|
||||
* GetBitN(1010 1010, 1) = 1
|
||||
*/
|
||||
#define GetBitN(D, B) (((D)>>(B))&0x01)
|
||||
|
||||
/*
|
||||
* Get N bits value, start from S,
|
||||
* example:
|
||||
* GetBitsN(0x18, 0, 4) = 0x08
|
||||
* GetBitsN(0x18, 3, 2) = 0x03
|
||||
*/
|
||||
#define GetBitsN(D, S, N) (((D)>>(S))&(~(0xFFFFFFFF << (N))))
|
||||
|
||||
/*
|
||||
* Set N bits of D (UINT8) start from S to V,
|
||||
* (D) &= ~((~(0xFFFFFFFF<<(N)))<<(S)); // set N bits to 0
|
||||
* (D) |= (((V)&(~(0xFFFFFFFF<<(N))))<<(S)); // set N bits to V
|
||||
* example:
|
||||
* SetUint8BitsN(1111 1111, 2, 4, 1010) => 1110 1011
|
||||
* SetUint8BitsN(0000 0000, 4, 3, 101) => 0101 0000
|
||||
*/
|
||||
#define SetUint8BitsN(D, S, N, V) ((D) &= ~((~(0xFFFFFFFF<<(N)))<<(S)), (D) |= (((V)&(~(0xFFFFFFFF<<(N))))<<(S)))
|
||||
|
||||
/*
|
||||
* GET bytes number from bits number
|
||||
* example: GetBitsByteLen(3) = 1
|
||||
* GetBitsByteLen(8) = 1
|
||||
* GetBitsByteLen(10) = 2
|
||||
*/
|
||||
//#define GetBitsByteLen(bits) (((bits)&0x07) == 0 ? ((bits)>>3) : (((bits)>>3)+1))
|
||||
#define GetBitsByteLen(bitlen) (((bitlen)+7)>>3)
|
||||
|
||||
/*
|
||||
* GetBitLen(1) = 8
|
||||
* GetBitLen(2) = 16
|
||||
*/
|
||||
#define GetBitLen(byteLen) ((byteLen)<<3)
|
||||
|
||||
/*
|
||||
* Get4ByteAlignLen(0) = 0
|
||||
* Get4ByteAlignLen(1) = 4
|
||||
* Get4ByteAlignLen(8) = 8
|
||||
*/
|
||||
#define Get4ByteAlignLen(byteLen) (((byteLen)+3)&0xFFFFFFFC)
|
||||
|
||||
/*
|
||||
* IsByteAligned(8) = TRUE
|
||||
* IsByteAligned(13) = FALSE
|
||||
* IsByteAligned(16) = TRUE
|
||||
*/
|
||||
#define IsByteAligned(bitLen) (((bitLen)&0x07) == 0)
|
||||
|
||||
|
||||
/*
|
||||
* SHA-256 functions
|
||||
*/
|
||||
/* The right shift operation */
|
||||
#define SHR(x, n) ((x) >> (n))
|
||||
/* The rotate right (circular right shift) operation */
|
||||
#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
|
||||
#define Ch(x, y, z) (((x) & (y)) ^ (~(x) & (z)))
|
||||
#define Maj(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
|
||||
#define SIGMA0(x) (ROTR((x), 2) ^ ROTR((x), 13) ^ ROTR((x), 22))
|
||||
#define SIGMA1(x) (ROTR((x), 6) ^ ROTR((x), 11) ^ ROTR((x), 25))
|
||||
#define sigma0(x) (ROTR((x), 7) ^ ROTR((x), 18) ^ (SHR((x), 3)))
|
||||
#define sigma1(x) (ROTR((x), 17) ^ ROTR((x), 19) ^ (SHR((x), 10)))
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
void PsFreeOneDlPduBlock(DlPduBlock **pDlPduBlk); //specification
|
||||
#else
|
||||
#define PsFreeOneDlPduBlock(ppDlPduBlk) OsaFreeOneDlPduBlock((ppDlPduBlk))
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
void PsFreeDlPduBlockList(DlPduBlock **pDlPduBlk); //specification
|
||||
#else
|
||||
#define PsFreeDlPduBlockList(ppDlPduBlk) OsaFreeDlPduBlockList((ppDlPduBlk))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
void PsFreeOneUlPduBlock(UlPduBlock **pUlPduBlk); //specification
|
||||
#else
|
||||
#define PsFreeOneUlPduBlock(ppUlPduBlk) OsaFreeOneUlPduBlock((ppUlPduBlk))
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
void PsFreeUlPduBlockList(UlPduBlock **pUlPduBlk); //specification
|
||||
#else
|
||||
#define PsFreeUlPduBlockList(ppUlPduBlk) OsaFreeUlPduBlockList((ppUlPduBlk))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Free the "UlPduBlock" list
|
||||
* void PsFreeDataPduList(UlPduBlock **pPdu);
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#define PsFreeDataPduList(ppUlPduBlk) PsFreeUlPduBlockList((ppUlPduBlk))
|
||||
#else
|
||||
#define PsFreeDataPduList(ppUlPduBlk) OsaFreeUlPduBlockList((ppUlPduBlk))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Single linked list operation MARCO
|
||||
* !!!! STRUCT must have "pNext" element !!!
|
||||
*/
|
||||
#define PsSingleLinkAddOne(pHdr, pTailer, pNew) \
|
||||
do { \
|
||||
if ((pHdr) == PNULL) \
|
||||
{ \
|
||||
GosCheck((pTailer) == PNULL && (pNew) != PNULL && ((pNew)->pNext) == PNULL, (pTailer), ((pNew)->pNext), 0xABCDEF); \
|
||||
(pHdr) = (pTailer) = (pNew); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
GosCheck((pTailer) != PNULL && (pNew) != PNULL && ((pNew)->pNext) == PNULL, (pTailer), ((pNew)->pNext), 0xFEDCBA); \
|
||||
(pTailer)->pNext = (pNew); \
|
||||
(pTailer) = (pNew); \
|
||||
} \
|
||||
}while(FALSE)
|
||||
|
||||
/*
|
||||
*/
|
||||
#define PsSingleLinkAddList(pHdr, pTailer, pNewHdr, pNewTailer) \
|
||||
do { \
|
||||
if ((pHdr) == PNULL) \
|
||||
{ \
|
||||
GosCheck((pTailer) == PNULL && (pNewHdr) != PNULL && ((pNewTailer)->pNext) == PNULL, (pTailer), ((pNewTailer)->pNext), 0x12345678); \
|
||||
(pHdr) = (pNewHdr); \
|
||||
(pTailer) = (pNewTailer); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
GosCheck((pTailer) != PNULL && (pNewHdr) != PNULL && ((pNewTailer)->pNext) == PNULL, (pTailer), ((pNewTailer)->pNext), 0x87654321); \
|
||||
(pTailer)->pNext = (pNewHdr); \
|
||||
(pTailer) = (pNewTailer); \
|
||||
} \
|
||||
}while(FALSE)
|
||||
|
||||
|
||||
|
||||
#define SET_UINT32_DATA_LEFT_SHIFT(n,b,i) \
|
||||
{ \
|
||||
(n) = ( (UINT32) (b)[(i) ] ) \
|
||||
| ( (UINT32) (b)[(i) + 1] << 8 ) \
|
||||
| ( (UINT32) (b)[(i) + 2] << 16 ) \
|
||||
| ( (UINT32) (b)[(i) + 3] << 24 ); \
|
||||
}
|
||||
|
||||
#define SET_UINT32_DATA_RIGHT_SHIFT(n,b,i) \
|
||||
{ \
|
||||
(b)[(i) ] = (UINT8) (((n) ) & 0xFF ); \
|
||||
(b)[(i) + 1] = (UINT8) (((n) >> 8 ) & 0xFF ); \
|
||||
(b)[(i) + 2] = (UINT8) (((n) >> 16 ) & 0xFF ); \
|
||||
(b)[(i) + 3] = (UINT8) (((n) >> 24 ) & 0xFF ); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef enum PS_CHAP_AUTH_CODE_TYPE_Tag
|
||||
{
|
||||
CHAP_MSG_CODE_TYPE_CHALLENGE = 1,
|
||||
CHAP_MSG_CODE_TYPE_RESPONSE = 2,
|
||||
CHAP_MSG_CODE_TYPE_SUCCESS = 3,
|
||||
CHAP_MSG_CODE_TYPE_FAILURE = 4,
|
||||
}PS_CHAP_AUTH_CODE_TYPE;
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* Functions specification
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
UINT8 Uint8Bit1Search(UINT8 data);
|
||||
UINT8 Uint16Bit1Search(UINT16 data);
|
||||
UINT8 Uint32Bit1Search(UINT32 data);
|
||||
UINT8 UintBit1Search(UINT32 data);
|
||||
|
||||
UINT8 Uint4Bit0Search(UINT8 data);
|
||||
UINT8 Uint8Bit0Search(UINT8 data);
|
||||
UINT8 Uint16Bit0Search(UINT16 data);
|
||||
UINT8 Uint32Bit0Search(UINT32 data);
|
||||
UINT8 UintBit0Search(UINT32 data);
|
||||
|
||||
#ifdef WIN32
|
||||
/*
|
||||
* set bits value (1-32 bits) ina UINT8 pBuf
|
||||
*/
|
||||
void SetBufBitsValue(UINT8 *pBuf, UINT32 *startBitOffset, UINT8 bitsLen, UINT32 value);
|
||||
|
||||
/*
|
||||
* Get "bitLen" (MAX 32 bits) bits value from "pBuf" start from "bitOffset"
|
||||
*/
|
||||
UINT32 GetBufBitsValue(const UINT8 *pBuf, UINT32 *startBitOffset, UINT8 bitsLen);
|
||||
|
||||
/*
|
||||
* Whether memory is all set to zero, 1 - TRUE, 0 - FALSE
|
||||
*/
|
||||
UINT32 BeZeroMemory(const void *pMem, UINT32 size);
|
||||
|
||||
#else
|
||||
|
||||
#define SetBufBitsValue(pBuf, startBitOffset, bitsLen, value) \
|
||||
OsaSetBufBitsValue((pBuf), (startBitOffset), (bitsLen), (value))
|
||||
|
||||
#define GetBufBitsValue(pBuf, startBitOffset, bitsLen) \
|
||||
OsaGetBufBitsValue((pBuf), (startBitOffset), (bitsLen))
|
||||
|
||||
#define BeZeroMemory(pMem, size) \
|
||||
OsaBeZeroMemory((pMem), (size))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* BITS COPY
|
||||
*/
|
||||
void PsBitsCopy(UINT8 *pDestBuf, UINT16 *pDestBO, UINT8 *pSrcBuf, UINT16 ibo, UINT16 bitLen);
|
||||
|
||||
/*
|
||||
* get PLMN info from IMSI
|
||||
*/
|
||||
Plmn PsGetPlmnFromImsi(Imsi *pImsi);
|
||||
|
||||
void HmacSha256(UINT16 inputKeyLength, UINT8 *pInputKey, UINT32 messageLength, UINT8 *pMessageContent, UINT8 *outPut);
|
||||
|
||||
/*
|
||||
* Free the Data memory, which type is : UlPduMemType
|
||||
*/
|
||||
void PsFreeDataPduMem(UINT8 memType, UINT8 **ptr);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Free the "PacketFilterList" list
|
||||
*/
|
||||
void PsFreePacketFilterlist(PacketFilterList** pflist);
|
||||
|
||||
/*
|
||||
* Copy the "PacketFilterList" list
|
||||
*/
|
||||
void PsCopyTftList(const PacketFilterList *pSrcTftHdr, PacketFilterList **ppDestTftHdr);
|
||||
|
||||
/*
|
||||
* get next UL Pkg header in the list
|
||||
*/
|
||||
UlPduBlock* PsGetNextUlPkgHdr(UlPduBlock *pPdu);
|
||||
|
||||
/*
|
||||
* check whether the UL PKG(DATA) is out of date
|
||||
*/
|
||||
BOOL PsUlDataBeOutDate(UINT8 tickType, UINT32 sysTick, BOOL *bMustDiscard);
|
||||
|
||||
/*
|
||||
* Get the PDU pkg number, and valid total length in UL PDU list
|
||||
*/
|
||||
void PsGetUlPduNumAndLenInList(const UlPduBlock *pHdr, const UlPduBlock *pTailer, UINT32 *pPduNum, UINT32 *pPduLen);
|
||||
|
||||
/*
|
||||
* Clear the UL pending PKG list
|
||||
* check whether out of date, or pending pkg number/size overflow
|
||||
*/
|
||||
//UINT32 PsClearUlPendingPduList(UlPduBlock **pHdr, UlPduBlock **pTailer);
|
||||
|
||||
/*
|
||||
* Clear the UL pending PKG list
|
||||
* check whether out of date, or pending pkg number/size overflow
|
||||
*/
|
||||
void PsClearUlPendingPduList(UlPduBlock **pHdr,
|
||||
UlPduBlock **pTailer,
|
||||
UINT32 *pOutPkgNum,
|
||||
UINT32 *pOutPkgLen);
|
||||
|
||||
/*
|
||||
* TFT route, decide which bearer (return CID) carry this UL PKG
|
||||
*/
|
||||
UINT8 PsTftRouteUlPkg(UINT8 defaultIpv4Cid, UINT8 defaultIpv6Cid, const PacketFilterList *pfList, const UlPduBlock *pPdu);
|
||||
|
||||
/*
|
||||
* APN format convert
|
||||
*/
|
||||
void ConvertDisPlayApnToNetworkFormat(const UINT8 *srcApn, UINT8 srcApnLen, UINT8 *desApn, UINT8 *desApnLen);
|
||||
void ConvertNetworkApnToDisPlayFormat(const UINT8 *srcApn, UINT8 srcApnLen, UINT8 *desApn, UINT8 *desApnLen);
|
||||
|
||||
/*
|
||||
* Convert DL EARFCN to BAND
|
||||
*/
|
||||
UINT8 PsGetBandFromDlEarfcn(UINT32 dlEarfcn);
|
||||
|
||||
/*
|
||||
* Check overseas operator
|
||||
*/
|
||||
BOOL PsIsOverseasOperator(Plmn plmn);
|
||||
|
||||
/*
|
||||
* Encode GSM 7Bit
|
||||
*/
|
||||
UINT16 PsEncodeGsm7BitData(UINT8 *pInput, UINT16 inputLength, UINT8 *pOutput, UINT16 outputLength, UINT16 shiftBits);
|
||||
|
||||
/*
|
||||
* Decode GSM 7Bit
|
||||
*/
|
||||
UINT16 PsDecodeGsm7BitData(UINT8 *pInput, UINT16 inputLength, UINT8 *pOutput, UINT16 outputLength, UINT16 shiftBits);
|
||||
|
||||
/*Generate a defined length random */
|
||||
UINT16 PsGenRandom(UINT16 outPutLen,UINT8 *pOutPut);
|
||||
|
||||
|
||||
/* to generate a CHAP authenticaion response with MD5 hash */
|
||||
void PsGenChapMd5HashResponse(
|
||||
const UINT8 *identifier,
|
||||
const UINT8 *pSecretVal,
|
||||
const UINT16 secretLen,
|
||||
const UINT8 *pChallenge,
|
||||
const UINT16 challengeLen,
|
||||
UINT8 outPut[16]);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef TCPIP_HDR_HIB_API_H
|
||||
#define TCPIP_HDR_HIB_API_H
|
||||
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2019- Copyrights of AirM2M Ltd.
|
||||
File name: - tcpiphibapi.h
|
||||
Description: - tcpip layer hib/sleep2 mode related API
|
||||
History: - 04/24/2019, Originated by xwang
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include "winsys.h"
|
||||
#else
|
||||
#include "commontypedef.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define PSIF_DNSCACHE_MAX_URL_LEN 68
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* STRUCT
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
enum pcb_hib_state {
|
||||
PCB_HIB_DISABLE_DEACTIVE = 0,
|
||||
PCB_HIB_ENABLE_DEACTIVE = 1,
|
||||
PCB_HIB_ENABLE_ACTIVE = 2,
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*****************************************************************************
|
||||
* Functions
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
BOOL PsifIsTcpipAllowEnterHIB(void);
|
||||
|
||||
void PsifRequestRecoverContextFromHib(void);
|
||||
|
||||
BOOL PsifGetPreTcpipHibContextInfo(UINT8 type);
|
||||
|
||||
BOOL PsifGetCurrTcpipHibContextInfo(UINT8 type);
|
||||
|
||||
void PsifSetCurrTcpipHibContext(BOOL exist, UINT8 type);
|
||||
|
||||
void PsifSetTcpipHibContextChanged(BOOL change, UINT8 type);
|
||||
|
||||
BOOL PsifGetTcpipHibContextChanged(UINT8 type);
|
||||
|
||||
void PisfCheckTcpipHibContextNeedChang(void);
|
||||
|
||||
void PsifTcpipAllowEnterHib(void);
|
||||
|
||||
void PsifTcpipNotAllowEnterHib(void);
|
||||
|
||||
void PsifTcpipHibModeInit(void);
|
||||
|
||||
UINT32 PsifGetCurrHibTicks(void);
|
||||
|
||||
BOOL PsifCheckWetherRecoverFromHib(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/******************************************************************************
|
||||
******************************************************************************
|
||||
Copyright: - 2020- Copyrights of AirM2M Ltd.
|
||||
File name: - tcpipportmgrapi.h
|
||||
Description: - tcpip TCP/UDP port manager API:
|
||||
History: - 12/25/2020 xwang
|
||||
******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef TCPIP_PORT_MGR_API_H
|
||||
#define TCPIP_PORT_MGR_API_H
|
||||
|
||||
#include "commontypedef.h"
|
||||
|
||||
#define TCPIP_IP_TYPE_4 4
|
||||
#define TCPIP_IP_TYPE_6 6
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PORT_MGR_CONN_SOURCE_INVALID = 0,
|
||||
PORT_MGR_CONN_SOURCE_UE = 1,
|
||||
PORT_MGR_CONN_SOURCE_HOST_ETH = 2,
|
||||
PORT_MGR_CONN_SOURCE_HOST_PPP = 3,
|
||||
PORT_MGR_CONN_SOURCE_HOST_ETH_SECONDARY = 4,
|
||||
PORT_MGR_CONN_SOURCE_HOST_PPP_SECONDARY = 5,
|
||||
PORT_MGR_CONN_SOURCE_NW = 6,
|
||||
PORT_MGR_CONN_SOURCE_ANY = 7,
|
||||
|
||||
}PortMgrConnSource;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PORT_MGR_CONN_DEST_UNDEFINE = 0,
|
||||
PORT_MGR_CONN_DEST_UE = 1,
|
||||
PORT_MGR_CONN_DEST_HOST = 2,
|
||||
PORT_MGR_CONN_DEST_HOST_ETH = 3,
|
||||
PORT_MGR_CONN_DEST_HOST_PPP = 4,
|
||||
PORT_MGR_CONN_DEST_NW = 5,
|
||||
PORT_MGR_CONN_DEST_MAPPING = 6,
|
||||
|
||||
PORT_MGR_CONN_DEST_UE_AND_HOST_ALL = 7,
|
||||
PORT_MGR_CONN_DEST_UE_AND_NW = 8,
|
||||
PORT_MGR_CONN_DEST_HOST_DNS_PKG = 9,
|
||||
PORT_MGR_CONN_DEST_HOST_ETH_DNS_PKG = 10,
|
||||
PORT_MGR_CONN_DEST_HOST_PPP_DNS_PKG = 11,
|
||||
PORT_MGR_CONN_DEST_NW_DNS_PKG = 12,
|
||||
PORT_MGR_CONN_DEST_DHCP_REQ_PKG = 13,
|
||||
|
||||
}PortMgrConnDest;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PORT_MGR_CONN_TYPE_UDP = 0,
|
||||
PORT_MGR_CONN_TYPE_TCP = 1,
|
||||
}PortMgrConnType;
|
||||
|
||||
|
||||
UINT8 PortMgrCheckDest(UINT8 source, UINT8 destination, UINT16 sourcePort, UINT16 destPort, UINT8 ipType);
|
||||
|
||||
UINT16 PortMgrUlProcess(UINT8 connType, UINT8 source, UINT16 sourcePort, UINT16 destPort, UINT8 ipType, UINT8 cid);
|
||||
|
||||
UINT8 PortMgrDlMappingProcess(UINT8 connType, UINT16 *originalPort, UINT16 mappingPort, UINT8 ipType, UINT8 cid);
|
||||
|
||||
UINT16 PortMgrNewUeTcpPort(void);
|
||||
|
||||
UINT16 PortMgrNewUeUdpPort(void);
|
||||
|
||||
void PortMgrInit(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user