📄 gsm.h
字号:
/*
+-----------------------------------------------------------------------------
| Project : GSM-PS (6147)
| Modul : GSM
+-----------------------------------------------------------------------------
| Copyright 2002 Texas Instruments Berlin, AG
| All rights reserved.
|
| This file is confidential and a trade secret of Texas
| Instruments Berlin, AG
| The receipt of or possession of this file does not convey
| any rights to reproduce or disclose its contents or to
| manufacture, use, or sell anything it may describe, in
| whole, or in part, without the specific written consent of
| Texas Instruments Berlin, AG.
+-----------------------------------------------------------------------------
| Purpose : Definition of global constants, types, and macros
| for the GSM Protocol Stack
+-----------------------------------------------------------------------------
*/
#ifndef GSM_H
#define GSM_H
#ifndef CCONST_CDG
#include "mconst.cdg" /* MAX_BITSTREAM_LEN */
#endif /* CCONST_CDG */
#ifndef PCONST_CDG
#include "pconst.cdg" /* MAX_PSTRUCT_LEN */
#endif /* PCONST_CDG */
/*==== CONSTANTS ==================================================*/
#define MAX_2_PRM 1
#define MAX_4_PRM 3
#define MAX_8_PRM 7
#define MAX_16_PRM 15
#define MAX_32_PRM 31
#define PRM_MASK 0x00FF /* protocol primitive mask*/
#define OPC_MASK 0xFF00 /* entity mask */
#define SYS_MASK 0x8000 /* system primitive mask */
#define SYS_CONFIG_REQ 0xF000
#define L3_CODING_OFFSET 32 /* coding offset in bits */
/*
* Not Present Value
*/
#define NOT_PRESENT_8BIT 0xFF
#define NOT_PRESENT_CHAR (CHAR)0xFF
#define NOT_PRESENT_16BIT 0xFFFF
#define NOT_PRESENT_32BIT 0xFFFFFFFFL
#define INVALID_ADDRESS 0xFFFFFFFFL
#define SET_NOT_PRESENT(A) (A) = (sizeof ((A)) EQ 1)\
? NOT_PRESENT_8BIT\
: (sizeof ((A)) EQ 2)\
? NOT_PRESENT_16BIT\
: NOT_PRESENT_32BIT
#define IS_PRESENT(A) ((A) NEQ ((sizeof ((A)) EQ 1)\
? NOT_PRESENT_8BIT\
: (sizeof ((A)) EQ 2)\
? NOT_PRESENT_16BIT\
: NOT_PRESENT_32BIT)) /* VK 09-12-96 */
#ifndef NEW_FRAME
/*
* Static Configurations
*/
#ifndef TC_FUNC
#define TC_FUNC 1
#endif
#ifdef TRACE_FKT
#define TRACE_FUNCTION(a) vsi_o_trace(VSI_CALLER TC_FUNC,a);
#else
// China change HM 6.07.00, one of this commented out
#define TRACE_FUNCTION(a)
//#define TRACE_FUNCTION(a) vsi_o_mtrace(a);
#endif
#ifndef TC_EVE
#define TC_EVE 2
#endif
#ifdef TRACE_EVE
#define TRACE_EVENT(a) vsi_o_trace(VSI_CALLER TC_EVENT,a);
#else
#define TRACE_EVENT(a)
#endif
#ifndef TC_ERROR
#define TC_ERROR 4
#endif
#ifdef TRACE_ERR
#define TRACE_ERROR(a) vsi_o_trace(VSI_CALLER TC_ERROR,a);
#else
#define TRACE_ERROR(a)
#endif
#ifndef TC_PRIM
#define TC_PRIM 8
#endif
#ifdef TRACE_PRIM
#define TRACE_PRIMITIVE(a) vsi_o_trace(VSI_CALLER TC_PRIM,a);
#else
#define TRACE_PRIMITIVE(a)
#endif
#ifndef TC_SYSTEM
#define TC_SYSTEM 16
#endif
/*
* Assert wrapper
*/
#if defined NDEBUG
#define TRACE_ASSERT(e) ((void)0)
#else
#ifdef SHARED_VSI
#define TRACE_ASSERT(e) if ( !(e) ) vsi_o_assert("",#e,__FILE__,__LINE__)
#else
#define TRACE_ASSERT(e) if ( !(e) ) vsi_o_assert(#e,__FILE__,__LINE__)
#endif
#endif
#ifdef assert
#undef assert
#endif
#define assert TRACE_ASSERT
#endif /* NEW_FRAME */
/*
* Memory Management(I)
*/
#ifdef OPTION_REF
#define FREE_BUFFER(p) vsi_c_free(VSI_CALLER (void **)&p)
#define NEW_BUFFER(p,s) T_PRIM *p = vsi_c_new(VSI_CALLER (T_VSI_CSIZE)((s)+sizeof(T_PRIM_HEADER)))
#else
#define FREE_BUFFER(p)
#define NEW_BUFFER(p,s) UBYTE buf_##p [(s)+sizeof(T_PRIM_HEADER)]; T_PRIM *p=(T_PRIM*)p1
#endif
#if !defined (_TMS470)
#define Sprintf sprintf
#else
int sprintf( char *buffer, const char *format, ... );
#endif
#ifndef NEW_FRAME
#ifdef _TMS470
#define SET_PRIM_OPCODE(P,O) P->custom.opc = O; P->custom.opc2 = 0
#else
#define SET_PRIM_OPCODE(P,O) P->custom.opc = O
#endif
#ifdef OPTION_LENGTH
#define SEND_PRIM(E,P,O,T) SET_PRIM_OPCODE (P,O); vsi_c_send (VSI_CALLER hComm##E, P, sizeof(T_PRIM_HEADER) + sizeof (T))
#define SEND_PRIM_0(E,P,O) SET_PRIM_OPCODE (P,O); vsi_c_send (VSI_CALLER hComm##E, P, sizeof(T_PRIM_HEADER))
#define SEND_PRIM_SDU(E,P,O,T,L) SET_PRIM_OPCODE (P,O); vsi_c_send (VSI_CALLER hComm##E, P, (T_VSI_CSIZE) (sizeof(T_PRIM_HEADER) + sizeof (T) + (L) - SDU_TRAIL))
#else
#define SEND_PRIM(E,P,O,T) SET_PRIM_OPCODE (P,O); vsi_c_send (VSI_CALLER hComm##E, P, sizeof(T_PRIM_HEADER) + sizeof (T))
#define SEND_PRIM_0(E,P,O) SET_PRIM_OPCODE (P,O); vsi_c_send (VSI_CALLER hComm##E, P, sizeof(T_PRIM_HEADER))
#define SEND_PRIM_SDU(E,P,O,T,L) SET_PRIM_OPCODE (P,O); vsi_c_send (VSI_CALLER hComm##E, P, (T_VSI_CSIZE) (sizeof(T_PRIM_HEADER) + sizeof (T) + (L) - SDU_TRAIL))
#endif
#endif /* NEW_FRAME */
/*
* declares a pointer variable (D) of the type T
* and initialize it with the startaddress of the data part
* of the primitive P
*/
#ifndef ALLOC_CHECK
#if defined (_TMS470) AND defined (NWARN)
#define PRIM_ACCESS(P,S) &P->data
#else
#define PRIM_ACCESS(P,S) P->data
#endif
#else
#define PRIM_ACCESS(P,S) vsi_c_access(VSI_CALLER P,S)
#endif
#define PRIM_CAST(P,D,T) T *D = (T *) PRIM_ACCESS (P, sizeof (T))
/*
* declares a pointer variable (D) of the type T and
* initialize it with the start address of the global declared
* buffer _decodedMsg[] wich contains the decoded message
* structure before encoding or after decoding the message
* with CCD.
*/
#define MSG_CAST(D,T) T *D = (T *) _decodedMsg
/*
* Memory Management(II)
*/
#ifndef NEW_FRAME
#if defined (_TMS470) AND defined (NWARN)
#define P2D(P) (&(P)->data)
#else
#define P2D(P) ((P)->data)
#endif
#define D2P(D) ((T_PRIM*)((T_PRIM_HEADER*)(D)-1))
#ifdef ALLOC_CHECK
#define P2D_AC(P,T) PRIM_ACCESS(P,sizeof(T))
#else
#define P2D_AC(P,T) P2D(P)
#endif
#define PRIM_TO_DATA P2D
#define DATA_TO_PRIM D2P
#define P_OPC(P) (P)->custom.opc
#define P_OPC2(P) (P)->custom.opc2
#define P_LEN(P) (P)->custom.len
#define P_TID(P) (P)->custom.tid
#define P_SDU(P) (P)->custom.sdu
#define D_OPC(D) P_OPC(D2P(D))
#define D_OPC2(D) P_OPC2(D2P(D))
#define D_LEN(D) P_LEN(D2P(D))
#define D_TID(D) P_TID(D2P(D))
#define D_SDU(D) P_SDU(D2P(D))
#define D_SDU_LEN(D) D_SDU(D)->l_buf
#define D_SDU_OFF(D) D_SDU(D)->o_buf
#define BITS_PER_BYTE 8
#define BYTELEN(BITLEN) ((BITLEN)<=0?0:((((BITLEN)-1)/BITS_PER_BYTE)+1))
#define PRIM_SIZE(D) (sizeof(T_PRIM_HEADER)+sizeof(*(D)))
#define PRIM_SIZE_SDU(D) (PRIM_SIZE(D)+BYTELEN((D)->sdu.o_buf+(D)->sdu.l_buf))
#define PSIZE(D) (D_LEN(D)+((D_SDU(D)==0)?0:(BYTELEN(D_SDU_LEN(D)+D_SDU_OFF(D))-SDU_TRAIL)))
#define SIZ(T) (sizeof(T_PRIM_HEADER)+sizeof(T))
#define SIZ_SDU(T,M) (SIZ(T)+BYTELEN((M)+ENCODE_OFFSET)-SDU_TRAIL)
#define P_ALL(T) (T_PRIM *) vsi_c_new(VSI_CALLER (T_VSI_CSIZE)SIZ(T) )
#define P_ALL_SDU(T,M) (T_PRIM *) vsi_c_new(VSI_CALLER (T_VSI_CSIZE)SIZ_SDU(T,M))
#endif /* NEW_FRAME */
#define OFFSETOF(P,C) ((char*)&(P->C) - (char*)P)
#ifdef NTRACE
#define xxxNotify(A,B,C,D,E)
#else
#define xxxNotify(A,B,C,D,E) /* not used yet */
#endif
#define ACT_PALLOC 0x01
#define ACT_PALLOC_SDU 0x02
#define ACT_PALLOC_MSG 0x03
#define ACT_PREUSE 0x04
#define ACT_PREUSE_SDU 0x05
#define ACT_PREUSE_MSG 0x06
#define ACT_PFREE 0x07
#define ACT_PSEND 0x08
#define ACT_PSTORE 0x09
#define ACT_PRETRIEVE 0x0A
#define ACT_PACCESS 0x0B
#define ACT_PPASS 0x0C
#define ACT_PCAST 0x0D
/*** memory alloction ***/
#ifndef NEW_FRAME
#define PSENDX PSEND
#define PALLOC(D,T) T_##T *D = (T_##T*)P2D(P_ALL(T_##T));\
D_OPC(D) = (T);\
D_OPC2(D) = 0;\
D_LEN(D) = SIZ(T_##T);\
D_SDU(D) = 0;\
xxxNotify(ACT_PALLOC,VSI_CALLER,__FILE__,__LINE__,D2P(D))
#define PALLOC_MSG(D,T,M) T_##T *D = (T_##T*)P2D(P_ALL_SDU(T_##T,BSIZE_##M));\
D_OPC(D) = (T);\
D_OPC2(D) = 0;\
D_LEN(D) = SIZ(T_##T);\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -