⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mms_pei.c

📁 是一个手机功能的模拟程序
💻 C
字号:
/*
+-----------------------------------------------------------------------------
|  File     : mms_pei.c
+-----------------------------------------------------------------------------
|  Purpose  : This module implements the process body interface
|             for the entity mms.                         
|
|             Exported functions:
|              
|             pei_create    - Create the Protocol Stack Entity
|             pei_init      - Initialize Protocol Stack Entity
|             pei_primitive - Process Primitive
|             pei_timeout   - Process Timeout
|             pei_exit      - Close resources and terminate
|             pei_run       - Process Primitive
|             pei_config    - Dynamic Configuration
|             pei_monitor   - Monitoring of physical Parameters
|
+-----------------------------------------------------------------------------
*/




#define ENTITY_MMS


/*==== INCLUDES ===================================================*/
#if defined (NEW_FRAME)

#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "typedefs.h"
#include "pcm.h"
#include "pconst.cdg"
#include "mconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "pei.h"
#include "tok.h"

#else

#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "stddefs.h"
#include "pconst.cdg"
#include "mconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "vsi.h"
#include "pei.h"
#include "tok.h"

#endif

#include "MMStask.h"

#define TRACE_FUNCTION(f) MMS_TRACE_EVENT((f));
#define TRACE_EVENT(f) TRACE_FUNCTION(f)

/*==== MMS EXPORT =================================================*/
#if defined (NEW_FRAME)
GLOBAL T_HANDLE hCommMMI = VSI_ERROR;      /* MMI Communication */
GLOBAL T_HANDLE hCommMMS = VSI_ERROR;      /* MMS Communication */
GLOBAL T_HANDLE mms_handle;
#else
GLOBAL T_VSI_CHANDLE hCommMMI = VSI_ERROR;      /* MMI Communication */
GLOBAL T_VSI_CHANDLE hCommMMS = VSI_ERROR;      /* MMI Communication */
#endif
/*==== VAR LOCAL ==================================================*/

#ifdef OPTION_RELATIVE
LOCAL ULONG offset; 
#endif

LOCAL USHORT s_flag = 0;         /* signal flag        */
LOCAL BOOL exit_flag = FALSE;
LOCAL BOOL first_access = TRUE;

LOCAL T_MONITOR mms_mon;





/*
  PURPOSE : Handle the next signal in the signal table

*/
LOCAL void pei_handle_signal (void)
{
	TRACE_FUNCTION("mms pei_handle_signal ");
}



/*
  PURPOSE : An unsupported primitive is received.
 
*/
LOCAL const void pei_not_supported (void *data)
{
  	TRACE_FUNCTION ("mms pei_not_supported()")

  	PFREE (data)
}

/*
 * Use MAK_FUNC_N for non supported opcodes.
 * This entries normally branches to pei_not_supported.
 *
 * Use MAK_FUNC_O for primitives which contains no SDU.
 *
 * Use MAK_FUNC_S for primitives which contains a SDU.
 */

/*
 * jumptable for the entity service access point. Contains
 * the processing-function addresses and opcodes of
 * request and response primitives.
 *
 */

#ifndef TAB_SIZE
#define TAB_SIZE(T) sizeof T / sizeof *T;
#endif
/*包含mmi --> mms task 的所有primitive*/
LOCAL const T_FUNC hisr_mms_table[] =
{
    MAK_FUNC_S( mmi_mms_ind, MMI_MMS_IND)//异步操作完成后mmi->pc syn task
};



/*
  PURPOSE : Process protocol specific primitive.
*/
#if defined (NEW_FRAME)
LOCAL SHORT pei_primitive (void * ptr)
#else
GLOBAL T_PEI_RETURN pei_primitive (T_PRIM *prim)
#endif
{
#if defined (NEW_FRAME)
	T_PRIM * prim = ptr;
#endif

TRACE_FUNCTION("mms pei_primitive");

	if (prim NEQ NULL)
	{
	USHORT opc = prim->custom.opc;
	USHORT n;
	const T_FUNC *table;

 	MMS_TRACE_EVENT(("%d",opc));
	switch (opc)
	{
	case MMI_MMS_IND:
	    	table = hisr_mms_table;
	 	n =TAB_SIZE (hisr_mms_table);
		break;
	  default :
	    table = NULL;
	    n = 0;
	    break;
	}

	if (table != NULL)
	{
	    	if ((opc & PRM_MASK) < n)
      		{
        		table += opc & PRM_MASK;
			JUMP (table->func) (P2D(prim));
	    	}
		else
	      {
	       	pei_not_supported (P2D(prim));
	      }
		return PEI_OK;
	}

	/*
	 * Primitive is no GSM Primitive
	 * then forward to the environment
	 */

#ifdef GSM_ONLY
	PFREE (P2D(prim))

	return PEI_ERROR;
#else
	if (opc & SYS_MASK)
	vsi_c_primitive (VSI_CALLER prim);
	else
	{
	  PFREE (P2D(prim));
	  return PEI_ERROR;
	}
#endif
	}
	return PEI_OK;
}//end pei_primitive



	/*
	PURPOSE : Initialize Protocol Stack Entity

	*/
#if defined (NEW_FRAME)
LOCAL SHORT pei_init (T_HANDLE handle)
#else
GLOBAL T_PEI_RETURN pei_init (void)
#endif
{
#if defined (NEW_FRAME)
	mms_handle = handle;
#endif
	TRACE_FUNCTION ("mms pei_init()");

	vsi_t_sleep (VSI_CALLER 1);

	if (hCommMMI < VSI_OK)
	{
		/* robert.chen modified, 2004-08-11, integrated to TCS2112 */
		//if ((hCommMMI = vsi_c_open (VSI_CALLER MMI_NAME)) < VSI_OK)
		if ((hCommMMI = vsi_c_open (VSI_CALLER ACI_NAME)) < VSI_OK)
	 		 return PEI_ERROR;
	}

	if(hCommMMS< VSI_OK)
	{
		 if ((hCommMMS = vsi_c_open (VSI_CALLER MMS_NAME)) < VSI_OK)
	 		 return PEI_ERROR;
	}

	exit_flag = FALSE;

	/*
	* timer initialization
	*/
	if (! mms_init_timer())
   			 return PEI_ERROR;

	/*no timer initialization*/
	TRACE_FUNCTION ("mms pei_init success");

	return PEI_OK;
}



/*
  PURPOSE : Process timeout
 
*/
#if defined (NEW_FRAME)
LOCAL SHORT pei_timeout (USHORT index)
#else
GLOBAL T_PEI_RETURN pei_timeout (T_VSI_THANDLE handle)
#endif
{
	TRACE_FUNCTION ("mms pei_timeout()")

  	mms_timeout(index);
	return PEI_OK;
}


/*
  PURPOSE : Close Resources and terminate
 
*/
#if defined (NEW_FRAME)
LOCAL SHORT pei_exit (void)
#else
GLOBAL T_PEI_RETURN pei_exit (void)
#endif
{

  TRACE_FUNCTION ("mms pei_exit()")

      
  /*
   * clean up communication
   */
  vsi_c_close (VSI_CALLER hCommMMI);
  hCommMMI = VSI_ERROR;

	vsi_c_close (VSI_CALLER hCommMMS);
  	hCommMMS = VSI_ERROR;
/*
   * Close mms timer
   */
  mms_close_timer ();
  exit_flag = TRUE;

  return PEI_OK;
}



/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444)             MODULE  : WAP_PEI             |
| STATE   : code                       ROUTINE : pei_run             |
+--------------------------------------------------------------------+
 
  PURPOSE : Process Primitives, main loop is located in the
            Protocol Stack Entity
 
*/

#if !defined (NEW_FRAME)
GLOBAL T_PEI_RETURN pei_run (T_VSI_CHANDLE handle)
{
  return PEI_OK;
}
#endif



/*
+------------------------------------------------------------------------------
|	Function		: pei_config
+------------------------------------------------------------------------------
|	Description	: This function is called by the frame when a primitive is
|               received indicating dynamic configuration.
|
|               This function is not used in this entity.
|
|	Parameters	:	handle            - Communication handle
|
|	Return			:	PEI_OK            - sucessful
|               PEI_ERROR         - not successful
|
+------------------------------------------------------------------------------
*/
#if defined NEW_FRAME
LOCAL SHORT pei_config (char *inString)
#else /* NEW_FRAME */
GLOBAL T_PEI_RETURN pei_config (char *inString, char *outString)
#endif /* NEW_FRAME */
{
  TRACE_FUNCTION ("mms pei_config");
  TRACE_FUNCTION (inString);

  return PEI_OK;
}


/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444)             MODULE  : WAP_PEI             |
| STATE   : code                       ROUTINE : pei_monitor         |
+--------------------------------------------------------------------+
 
  PURPOSE : Monitoring of physical Parameters
 
*/
#if defined (NEW_FRAME)
LOCAL SHORT pei_monitor (void **monitor)
#else
GLOBAL T_PEI_RETURN pei_monitor (void **monitor)
#endif
{
  TRACE_FUNCTION ("mms pei_monitor()")

  mms_mon.version = VERSION_MMS;

  *monitor = &mms_mon;

  return PEI_OK;
}



/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444)             MODULE  : WAP_PEI             |
| STATE   : code                       ROUTINE : pei_create          |
+--------------------------------------------------------------------+
 
  PURPOSE : Create the Protocol Stack Entity
 
*/
#if defined (NEW_FRAME)
GLOBAL SHORT mms_pei_create (T_PEI_INFO **info)
{
  static const T_PEI_INFO pei_info =
    {
      "MMS",
      {
        pei_init,
        pei_exit,
        pei_primitive,
        pei_timeout,
        NULL,              /* no signal function  */
        NULL,              /* no run function     */
        pei_config,
        pei_monitor
      },
      4096,                /* stack size          */
      5,                  /* queue entries       */
     	99,                 /* priorities          */
      1,                   /* number of timer     */
      0x03                 /* flags               */
    };

  TRACE_FUNCTION ("mms_pei_create()")

  /*
   *  Close Resources if open
   */

  if (first_access)
    first_access = FALSE;
  else
    pei_exit ();

  /*
   *  Export startup configuration data
   */

  * info = (T_PEI_INFO *) & pei_info;

  return PEI_OK;
}

#else

GLOBAL T_PEI_RETURN pei_create (T_VSI_CNAME *name)
{
#ifdef OPTION_RELATIVE
  static T_PEI_RETURN (*compile_addr)() = pei_create;

  offset = (char *)pei_create - (char *)compile_addr;
#endif

  TRACE_FUNCTION ("mms pei_create()")

  /*
  *  Close Resources if open
  */

  if (first_access)
    first_access = FALSE;
  else
    pei_exit ();

  /*
  *  Initialize entity data
  */

  *name = "MMS";

  return PEI_OK;
}

#endif


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -