📄 rt0main.c
字号:
/************************************************************************/
/** Copyright (c) 1998, UTStarcom, Inc. */
/** All Rights Reserved. */
/** */
/** Subsystem: RT */
/** File: rt0main.c */
/** Created By: tara zhang */
/** Created On: 08/02/2003 */
/** */
/** Purpose: */
/** This file contains RT part entry and parse information element .*/
/** */
/** Necessary Compilation Flags: FLAG_1, , FLAG_N */
/********************************************************************** */
/** Modify by: */
/** Modify purpose: */
/************************************************************************/
#ifndef PM_ONPC
#define __RTMAIN_C_
#ifdef __cplusplus
extern "C"{
#endif
#include "rt.h"
//#include "sysdef.h"
#ifdef SIMU_ON_PC
extern CCH_MON_LIST CList;
extern U2 CchMonCount;
#define csid_mirr(mirr_data) ((mirr_data&0x80)>>7)|((mirr_data&0x40)>>5)|((mirr_data&0x20)>>3)\
|((mirr_data&0x10)>>1)|((mirr_data&0x08)<<1)|((mirr_data&0x04)<<3)\
|((mirr_data&0x02)<<5)|((mirr_data&0x01)<<7)
#endif
/***************************************************************************/
/*Warning: Following section is defined in the mn80.h. You must keep it synchronized*/
/* FEATURE DEFINION */
#define FEATURE_SEAMLESS 1 /*Seamless feature ID*/
#define FEATURE_POWER_OFF_REG 1 /*Power off registration subfeature ID*/
/*It also server as the feature mask bit*/
#define FEATURE_LOW_CS_PREFER 2 /*low power CS prefered subfeature ID*/
/*It also server as the feature mask bit*/
/* don't change it unless you're sure*/
/*************************************************************************************
Prototype : void rt_main ( void);
Description : this function is rt main entry point.it enters machine state
according to received message and RT state
Parameter :
Return : 0
**************************************************************************************/
#ifdef _ON_SANYO_
U1 rt_main(void)
#else
U1 rt_main(void * mbox)
#endif
{
// U1 count;
M_MSB *RtOpt;
// U1 ret;
U1 msg_type = 0;
U1 rt_ret = 0;
#ifndef _ON_SANYO_
memcpy ((void *) rt_syswork.in_evt, (const void *)(((EV_BUF_ST *)mbox)->event), sizeof (rt_syswork.in_evt));
#endif
set_up_b((U1 *)SYS_WORK->out_evt, 0, sizeof(SYS_WORK->out_evt));
rt_state_table = rt_table[Rt_sts]; /* enters rt machine state according to Rt_sts*/
switch(SYS_WORK->in_evt[0])
{
case ERT: /* message from high level */
msg_type = (U1)IN_PRIEVT->pri_cod;
#ifdef SIMU_ON_PC
ProtocolTrace(10,"!!!rt main %d %d %d\n",Rt_sts,msg_type,0);
#endif
#ifdef EXT_IO
switch (IN_PRIEVT->pri_cod)
{
case PRTR001P :
case PRTR101P :
case PRTR103P :
case PRTR105P :
case PRTR301P :
case PRTR3021P :
case PRTR3022P :
case PRTR304P :
case PRTR305P :
case PRTR306P :
case PRSYNBST:
HisOut(0, 0x33, (U1)IN_PRIEVT->pri_cod, Rt_sts, 0);
}
#endif
break;
case EPHDTDSP: /*message fome L1 */
msg_type = rx_cac[0] & ~BIT8; /* message type, bit 8 reserved */
break;
case EDLDTDSP : /* message from L2 */
case EDLUDTDSP :
msg_type = (((RT_MSGDAT *)IN_DLDEVT->msg_adr)->dat[1]) & ~BIT8;
if (((RT_MSGDAT *)IN_DLDEVT->msg_adr)->dat[1] > OPTMIN )
{
msg_type = OPTMIN;
}
break;
default:
msg_type = (U1)SYS_WORK->in_evt[0];
break;
}
for(;!(msg_type == rt_state_table->evt_code || rt_state_table->evt_code == 0xff);rt_state_table++);
/* in machine state,find the received message */
if(!(rt_state_table->fnc_adr))
{
}
else
{
//modify by chenwei in 2003/9/16
//return (rt_state_table->fnc_adr() ); /* if find,execute the corresponded function */
rt_ret = rt_state_table->fnc_adr() ;
//return (rt_ret);
}
switch ( SYS_WORK->in_evt[0] )
{ /* free memopry */
case ERT:
if ( IN_PRIEVT->buf_adr != 0 )
{
/* #J80-02 -> */
if (IN_PRIEVT->pri_cod == PRRTOPT)
{
RtOpt = (M_MSB *)IN_PRIEVT->inf_adr;
if (RtOpt->nxt)
{
m_frebuf(RtOpt->nxt);
}
}
/* #J80-02 <- */
m_frebuf(IN_PRIEVT->buf_adr);
}
break;
case EDLDTDSP :
case EDLUDTDSP :
if ( IN_DLDEVT->msg_adr != 0 )
{
/* #J80-02 -> */
if (( IN_MSGDAT->dat[1] >= OPTMIN )
&& ( IN_MSGDAT->dat[1] <= OPTMAX ))
{
if (IN_MSGDAT->next_po)
{
m_frebuf(IN_MSGDAT->next_po);
}
}
/* #J80-02 <- */
m_frebuf((U1 *)IN_DLDEVT->msg_adr);
}
break;
}
// return ( 0 );
return (rt_ret);
}
/*************************************************************************************
Prototype : void rt_page_area_compare ( U1 *csid1,U1 *csid2)
Description : compare the paging area number whether or not same
Parameter : csid1 :
csid2 :
Return : TRUE : paging area number is same
FALSE: paginf area number is different.
History : tara_zhang 08/02/2003 Initial version
**************************************************************************************/
U1 rt_page_area_compare(U1 *csid1,U1 *csid2)
{
U1 Np;
U1 i, j, m, n;
U1 temp_csid1[6];
U1 temp_csid2[6];
if((Sys_pbsid[6] & 0x0F) < 8) /*here calculate paging length*/
{
Np = (Sys_pbsid[6] & 0x0F) * 2 + 2;
}
else
{
Np = (Sys_pbsid[6] & 0x0F) + 9;
}
m=0;
i = Np/8;
n=i;
if(i !=0)
{
for(m=0 ; i>0;i--)
{/* get paging area number byte */
temp_csid1[m] =(U1)(((csid1[m+1]&0x7f)<<1)|(csid1[m+2]&0x80>>7));
temp_csid2[m] =(U1)(((csid2[m+1]&0x7f)<<1)|(csid2[m+2]&0x80>>7));
m++;
}
}
if ( (Np%8) != ZERO )
{/* get last byte's bit */
n++;
j = 0xff;
j = j<<(8-1-Np%8);
j &= 0x7f;
temp_csid1[m] = (csid1[m+1] & j)<<1 ;
temp_csid2[m] = (csid2[m+1] & j)<<1 ;
}
for(m=0 ; n>0 ; n--)
{/* compare the two csid */
if(temp_csid1[m] !=temp_csid2[m])
return FALSE;
m++;
}
return TRUE ;
}
/************************************************************************/
/* */
/* NUMBER */
/* CALL U1 rt_check_cause( U1 *input_ptr) */
/* PARAM U1 *input_ptr: information element and it's conent*/
/* FUNC when received tch switch reject message,
check the reject reason */
/* RETURN */
/* */
/************************************************************************/
U1 rt_check_cause(U1 *input_ptr)
{
if ( (input_ptr[1] & 0x70) == 0x70 ) /* option */
{
;
}
else if ( (input_ptr[1] & 0x70) == 0x00 ) /*normal class */
{
switch (input_ptr[1] & 0x0f)
{
case 0x00 : /* normal disconnect */
case 0x0f : /* other normal events */
break;
default :
return (0);
break;
}
}
else if ( (input_ptr[1] & 0x70) == 0x20 ) /* resource use impossible class */
{
switch (input_ptr[1] & 0x0f)
{
case 0x01 : /* no vacant channel (include no slot available)*/
case 0x03 : /*no outgoing circuit available */
if (Sys_ccsinf[19] < 0x04)
{
return (0);
break;
}
case 0x02 : /* no available channel */
case 0x09 : /* receiption level degredation (including specified channel use impossible)*/
case 0x0a : /* receiption quality degredation(including specified channel use impossible)*/
case 0x0c : /* equipment abnormal */
case 0x0f : /* other resource use impossible */
break;
default :
return (0);
break;
}
}
else if ( (input_ptr[1] & 0x70) == 0x40 ) /* service or option not impossible class*/
{
switch (input_ptr[1] & 0x0f)
{
case 0x0f : /* service or option not impossible*/
if (Sys_ccsinf[19] < 0x04)
{
return (0);
break;
}
break;
default :
return (0);
break;
}
}
else if ( (input_ptr[1] & 0x70) == 0x50 ) /* invalid message class */
{
switch (input_ptr[1] & 0x0f)
{
case 0x01 : /* assigned carrier non-corresponding(PS side)*/
case 0x08 : /* no channel adding function */
if (Sys_ccsinf[19] < 0x04)
{
return (0);
break;
}
break;
default :
return (0);
break;
}
}
else if ( (input_ptr[1] & 0x70) == 0x60 ) /* procedure error class */
{
switch (input_ptr[1] & 0x0f)
{
case 0x01 : /* message failure */
case 0x06 : /* timer expiration */
case 0x0f : /* other procedure error */
break;
default :
return (0);
break;
}
}
else
{
return (0);
}
return(1);
}
/************************************************************************/
/* */
/* NUMBER */
/* CALL void rt_rdbak() */
/* PARAM */
/* FUNC set radio info in communication state */
/* 1.when received lch reject message in recall switch state */
/* 2.when UWAVE error in tch switch state */
/* 3.when UWAVE error in recall switch state */
/* 4 timer TR101P time out */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -