📄 ffs_pei.c
字号:
/*
+-----------------------------------------------------------------------------
| Project : Riv2Gpf
| Modul : FFS
+-----------------------------------------------------------------------------
| 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 : This module implements the process body interface
| for the entity FFS
|
| 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
|+-----------------------------------------------------------------------------
*/
/*============================ Includes ======================================*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "typedefs.h"
#include "vsi.h"
#include "ccdapi.h"
#include "pei.h"
#include "tok.h"
#include "task.h"
#include "rvf/rvf_api.h"
#include "rvm/rvm_priorities.h"
#include "rvm/rvm_use_id_list.h"
#include "ffs/ffs_env.h"
//#include "ffs/pc/ffs_pc_i.h"
/*============================ Macros ========================================*/
#define VSI_CALLER FFS_handle,
#define pei_create ffs_pei_create
#define RVM_TRACE_DEBUG_HIGH(string)\
rvf_send_trace (string,(sizeof(string)-1),NULL_PARAM,RV_TRACE_LEVEL_DEBUG_HIGH,RVM_USE_ID )
/*============================ Global Variables ==============================*/
T_HANDLE FFS_handle;
T_HANDLE ffs_hCommFFS = -1;
LOCAL BOOL first_access = TRUE;
T_FFS_TASK_INFO ffs_task_info;
/*============================ External declaration===========================*/
extern void ffs_task_init(T_RVF_MB_ID mbid, T_RVF_ADDR_ID addr_id);
/*===============global pointer to the error function=========================*/
static T_RVM_RETURN (*ffs_error_ft)(T_RVM_NAME swe_name, T_RVM_RETURN error_cause,
T_RVM_ERROR_TYPE error_type,T_RVM_STRING error_msg);
/*============================ Function Definition============================*/
/*
+------------------------------------------------------------------------------
| Function : pei_monitor
+------------------------------------------------------------------------------
| Description : This function is called by the frame in case sudden entity
| specific data is requested (e.g. entity Version).
|
| Parameters : out_monitor - return the address of the data to be
| monitoredCommunication handle
|
| Return : PEI_OK - successful (address in out_monitor is valid)
| PEI_ERROR - not successful
+------------------------------------------------------------------------------
*/
LOCAL SHORT pei_monitor (void ** out_monitor)
{
RVM_TRACE_DEBUG_HIGH ("FFS: pei_monitor");
return PEI_OK;
} /* End pei_monitor(..) */
/*
+------------------------------------------------------------------------------
| 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 : in_string - configuration string
|
| Return : PEI_OK - sucessful
| PEI_ERROR - not successful
|
+------------------------------------------------------------------------------
*/
LOCAL SHORT pei_config (char *inString)
{
RVM_TRACE_DEBUG_HIGH ("FFS: pei_config");
return PEI_OK;
}/* End of pei_config(..) */
/*
+------------------------------------------------------------------------------
| Function : pei_timeout
+------------------------------------------------------------------------------
| Description : Process timeout.
|
| Parameters : index - timer index
|
| Return : PEI_OK - timeout processed
| PEI_ERROR - timeout not processed
+------------------------------------------------------------------------------
*/
LOCAL SHORT pei_timeout (unsigned short index)
{
RVM_TRACE_DEBUG_HIGH ("FFS: pei_timeout");
return PEI_OK;
}/* End of pei_timeout(..) */
/*
+------------------------------------------------------------------------------
| Function : pei_signal
+------------------------------------------------------------------------------
| Description : This function is called by the frame when a signal has been
| received.
|
| Parameters : opc - signal operation code
| *data - pointer to primitive
|
| Return : PEI_OK - signal processed
| PEI_ERROR - signal not processed
|
+------------------------------------------------------------------------------
*/
LOCAL SHORT pei_signal (ULONG opc, void *data)
{
RVM_TRACE_DEBUG_HIGH ("FFS: pei_signal");
return PEI_OK;
}/* End of pei_signal(..) */
/*
+------------------------------------------------------------------------------
| Function : pei_exit
+------------------------------------------------------------------------------
| Description : This function is called by the frame when the entity is
| terminated. All open resources are freed.
|
| Parameters : -
|
| Return : PEI_OK - exit successful
| PEI_ERROR - exit not successful
|
+------------------------------------------------------------------------------
*/
LOCAL SHORT pei_exit (void)
{
RVM_TRACE_DEBUG_HIGH ("FFS: pei_exit");
/*
* Close communication channels
*/
vsi_c_close (VSI_CALLER ffs_hCommFFS);
ffs_hCommFFS = VSI_ERROR;
ffs_stop();
ffs_kill();
return PEI_OK;
}/* End pei_exit(..) */
/*
+------------------------------------------------------------------------------
| Function : pei_primitive
+------------------------------------------------------------------------------
| Description : Process protocol specific primitive.
|
| Parameters : prim - pointer to the received primitive
|
| Return : PEI_OK - function succeeded
| PEI_ERROR - function failed
+------------------------------------------------------------------------------
*/
LOCAL SHORT pei_primitive (void * primptr)
{
T_RV_HDR* msg_p;
RVM_TRACE_DEBUG_HIGH("FFS: pei_primitive");
msg_p = (T_RV_HDR*) P2D(primptr);
// ffs_handle_msg(msg_p);
return PEI_OK;
}/* End pei_primitive(..) */
/*
+------------------------------------------------------------------------------
| Function : pei_run
+------------------------------------------------------------------------------
| Description : This function is called by the frame when entering the main
| loop. This fucntion is only required in the active variant.
|
| This function is not used.
|
| Parameters : taskhandle - handle of current process
| comhandle - queue handle of current process
|
| Return : PEI_OK - sucessful
| PEI_ERROR - not successful
|
+------------------------------------------------------------------------------
*/
LOCAL SHORT pei_run (T_HANDLE TaskHandle, T_HANDLE ComHandle)
{
RVM_TRACE_DEBUG_HIGH("FFS: pei_run");
ffs_start();
return PEI_OK;
}/* End pei_run(..) */
/*
+------------------------------------------------------------------------------
| Function : pei_init
+------------------------------------------------------------------------------
| Description : This function is called by the frame. It is used to initialise
| the entitiy.
|
| Parameters : handle - task handle
|
| Return : PEI_OK - entity initialised
| PEI_ERROR - entity not (yet) initialised
|
+------------------------------------------------------------------------------
*/
LOCAL SHORT pei_init (T_HANDLE handle)
{
T_RV_RET ret = RV_OK;
RVM_TRACE_DEBUG_HIGH ("FFS: pei_init");
/*
* Initialize task handle
*/
FFS_handle = handle;
ffs_hCommFFS = -1;
if(FFS_handle != gsp_get_taskid())
{
RVM_TRACE_DEBUG_HIGH("FFS_handle != gsp_get_taskid");
}
if( gsp_init_remu_task( FFS_handle, "FFS" ) != RVF_OK)
{
RVM_TRACE_DEBUG_HIGH("gsp_init_remu_task != returning RVF_OK");
}
/*
* Open communication channels
*/
if (ffs_hCommFFS < VSI_OK)
{
if ((ffs_hCommFFS = vsi_c_open (VSI_CALLER "FFS" )) < VSI_OK)
return PEI_ERROR;
}
RVM_TRACE_DEBUG_HIGH("FFS Open communication channels done");
/* store the pointer to the error function */
ffs_error_ft = rvm_error;
ffs_task_init(0, ffs_hCommFFS);
/* Store the address ID. */
ffs_task_info.addr_id = FFS_handle;
ffs_task_info.mbid = EXT_MEM_POOL;
/* Initialise ffs driver */
ffs_init();
RVM_TRACE_DEBUG_HIGH("FFS: ffs_init() done");
return (PEI_OK);
} /* End pei_init(..) */
/*
+------------------------------------------------------------------------------
| Function : pei_create
+------------------------------------------------------------------------------
| Description : This function is called by the frame when the process is
| created.
|
| Parameters : out_name - Pointer to the buffer in which to locate
| the name of this entity
|
| Return : PEI_OK - entity created successfuly
| PEI_ERROR - entity could not be created
|
+------------------------------------------------------------------------------
*/
GLOBAL SHORT pei_create (T_PEI_INFO **info)
{
static const T_PEI_INFO pei_info =
{
"FFS", /* name */
{ /* pei-table */
pei_init,
pei_exit,
NULL, /* NO pei_primitive */
NULL, /* NO pei_timeout */
NULL, /* NO pei_signal */
pei_run,
NULL, /* NO pei_config */
NULL /* NO pei_monitor */
},
FFS_STACK_SIZE, /* stack size */
10, /* queue entries */
(255 - RVM_FFS_TASK_PRIORITY), /* priority (1->low, 255->high) */
0, /* number of timers */
COPY_BY_REF|TRC_NO_SUSPEND | PRIM_NO_SUSPEND
};
RVM_TRACE_DEBUG_HIGH("FFS: 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;
}/* End pei_create(..) */
/*
+------------------------------------------------------------------------------
| Function : ffs_init
+------------------------------------------------------------------------------
| Description : Called to start the FFS SWE.
|
| Parameters : None
|
| Return : PEI_OK - successful
| PEI_ERROR - not successful
+------------------------------------------------------------------------------
*/
T_RVM_RETURN ffs_init(void)
{
RVM_TRACE_DEBUG_HIGH("FFS: ffs_init()");
return RV_OK;
}
/*
+------------------------------------------------------------------------------
| Function : ffs_start
+------------------------------------------------------------------------------
| Description : Called to start the FFS SWE.
|
| Parameters : None
|
| Return : PEI_OK - successful
| PEI_ERROR - not successful
+------------------------------------------------------------------------------
*/
T_RVM_RETURN ffs_start(void)
{
RVM_TRACE_DEBUG_HIGH("FFS: ffs_start()");
ffs_task();
return RV_OK;
}
/*
+------------------------------------------------------------------------------
| Function : ffs_stop
+------------------------------------------------------------------------------
| Description : Called to stop the FFS SWE.
|
| Parameters : Message
|
| Return : PEI_OK - successful
| PEI_ERROR - not successful
+------------------------------------------------------------------------------
*/
T_RVM_RETURN ffs_stop(void)
{
/* other SWEs have not been killed yet, ffs can send messages to other SWEs */
RVM_TRACE_DEBUG_HIGH("FFS: ffs_stop()");
return RV_OK;
}
/*
+------------------------------------------------------------------------------
| Function : ffs_kill
+------------------------------------------------------------------------------
| Description : Called to stop the FFS SWE.
|
| Parameters : None
|
| Return : PEI_OK - successful
| PEI_ERROR - not successful
|
+------------------------------------------------------------------------------
*/
T_RVM_RETURN ffs_kill (void)
{
/* free all memory buffer previously allocated */
RVM_TRACE_DEBUG_HIGH("FFS: ffs_kill()");
return RV_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -