// ====================================================================
// Copyright(C) 2008
// DALIAN SEA SKY AUTOMATION CO. LTD
// All Rights Reserved
// ====================================================================
// Products: SSMV SERVER
// Project : MVB Client-Server Model (MVB Client Driver Software)
// Revision: v1.08
// Date : 2008.02.25
// Author :
// --------------------------------------------------------------------
// Abstract:
// General Function Interface
// --------------------------------------------------------------------
//
// History :
// ====================================================================
///////////////////////////////////////////////////////////////////////
// Include Files
///////////////////////////////////////////////////////////////////////
// MVB Client Driver Software - Common Interface Definitions
#include "mvb_def.h"
// Standard Libraries
#if defined (O_PRINT_DEBUG)
#include <stdio.h>
#endif
// MVB Client Driver Software
#include "mcs_cpil.h"
#include "mcs_clch.h"
#ifdef O_MD
#include "mcs_ccb.h"
#endif
#include "mcs_cgf.h"
// MVB Client API
#include "mvb_gf.h"
#include "mvb_lp.h"
#ifdef O_MD
#include "mvb_md.h"
#endif
#if defined(__cplusplus)
extern "C"
{
#endif
///////////////////////////////////////////////////////////////////////
// General Definitions
///////////////////////////////////////////////////////////////////////
// Server Errors
#define CGF_SERVER_ERROR_NONE 0
#define CGF_SERVER_ERROR_MISSING 1
#define CGF_SERVER_ERROR_FAILED 2
// NSDB Entry Constants
#define CGF_MVB_CONFIG_NSDB_NSDB_HEADER 0x0001
#define CGF_MVB_CONFIG_NSDB_NSDB_VERSION 0x0002
#define CGF_MVB_CONFIG_NSDB_END_OF_NSDB 0x000F
#define CGF_MVB_CONFIG_NSDB_NS_RTP_ANNOUNCE_DEV 0x0010
#define CGF_MVB_CONFIG_NSDB_NS_RTP_INS_DIR_ENTR 0x0020
#define CGF_MVB_CONFIG_NSDB_NS_MAP_CONF 0x0030
#define CGF_MVB_CONFIG_NSDB_NS_UMS_CONF 0x0031
#define CGF_MVB_CONFIG_NSDB_NS_RTP_STADI_ENTR 0x0040
#define CGF_MVB_CONFIG_NSDB_NS_NMA_INIT 0x0050
#define CGF_MVB_CONFIG_NSDB_NS_TRAFFIC_STORE 0x0080
#define CGF_MVB_CONFIG_NSDB_NS_SINKTIME_SUPERVISION 0x0090
#define CGF_MVB_CONFIG_NSDB_NS_PDM_CONFIG 0x0100
#define CGF_MVB_CONFIG_NSDB_NS_MVBC_INIT 0x0200
#define CGF_MVB_CONFIG_NSDB_NS_MVB_BA 0x0210
#define CGF_MVB_CONFIG_NSDB_NS_APPL_OBJ_MIN 0x1000
#define CGF_MVB_CONFIG_NSDB_NS_KLIP 0x1100
#define CGF_MVB_CONFIG_NSDB_NS_HOST_FCTS 0x1200
#define CGF_MVB_CONFIG_NSDB_NS_ROM_FCTS_BASE 0x1300
#define CGF_MVB_CONFIG_NSDB_NS_ROM_NAME_BASE 0x1310
#define CGF_MVB_CONFIG_NSDB_NS_ROM_STATION_BASE 0x1320
#define CGF_MVB_CONFIG_NSDB_NS_GW_CONF 0x1400
// Server Areas
// Boot Loader Target Information Area
#define CGF_FLASH_BL_TARGET_INFO_BASE 0x00000400
#define CGF_FLASH_BL_TARGET_INFO_SIZE 0x00000100
//Boot Loader Software Version Information Area
#define CGF_FLASH_BL_SW_VERSION_INFO_BASE 0x00005E00
#define CGF_FLASH_BL_SW_VERSION_INFO_SIZE 0x00000100
///////////////////////////////////////////////////////////////////////
// Global Variables
///////////////////////////////////////////////////////////////////////
UNSIGNED16 cgf_device_address = 0;
#if defined (O_INIT_GLOBAL_DATA)
UNSIGNED8 cgf_server_status;
BOOLEAN1 bDone_gf_open_device;
BOOLEAN1 bDone_gf_init_device;
BOOLEAN1 bDone_gf_close_device;
BOOLEAN1 bDone_gf_mvb_init;
BOOLEAN1 bDone_gf_mvb_start;
BOOLEAN1 bDone_lp_init;
BOOLEAN1 bDone_am_init;
BOOLEAN1 bDone_am_announce_device;
BOOLEAN1 bDone_dsw_init;
BOOLEAN1 bDone_ba_init;
#else
UNSIGNED8 cgf_server_status = CGF_SERVER_STATUS_STOP;
BOOLEAN1 bDone_gf_open_device = FALSE;
BOOLEAN1 bDone_gf_init_device = FALSE;
BOOLEAN1 bDone_gf_close_device = FALSE;
BOOLEAN1 bDone_gf_mvb_init = FALSE;
BOOLEAN1 bDone_gf_mvb_start = FALSE;
BOOLEAN1 bDone_lp_init = FALSE;
BOOLEAN1 bDone_am_init = FALSE;
BOOLEAN1 bDone_am_announce_device = FALSE;
BOOLEAN1 bDone_dsw_init = FALSE;
BOOLEAN1 bDone_ba_init = FALSE;
#endif
///////////////////////////////////////////////////////////////////////
// Local Variables
///////////////////////////////////////////////////////////////////////
#if defined (O_INIT_GLOBAL_DATA)
static UNSIGNED16 cgf_device_status;
static UNSIGNED16 cgf_device_status_old;
static UNSIGNED16 cgf_device_status_supervisor;
#if defined (O_OS_SINGLE)
static BOOLEAN1 bCgfSupervisor;
#endif
static BOOLEAN1 bCgfCallbackBusy;
static BOOLEAN1 bStartUpServerDone;
static BOOLEAN1 bInitServerDone;
static BOOLEAN1 bInitPilDone;
#else
static UNSIGNED16 cgf_device_status = GF_DEVICE_STATUS_OK;
static UNSIGNED16 cgf_device_status_old = GF_DEVICE_STATUS_OK;
static UNSIGNED16 cgf_device_status_supervisor = GF_DEVICE_STATUS_OK;
#if defined (O_OS_SINGLE)
static BOOLEAN1 bCgfSupervisor = FALSE;
#endif
static BOOLEAN1 bCgfCallbackBusy = FALSE;
#endif
static UNSIGNED32 cgf_client_life_sign_timeout;
static GF_DEVICE_STATUS_CALLBACK cgf_device_status_callback;
///////////////////////////////////////////////////////////////////////
// Internal Function Prototypes
///////////////////////////////////////////////////////////////////////
static UNSIGNED16 cgf_get_value_16(UNSIGNED16 *p_value_16);
static UNSIGNED32 cgf_get_value_32(UNSIGNED32 *p_value_32);
static GF_RESULT cgf_check_server_status(UNSIGNED16 *server_error);
static GF_RESULT cgf_restart_device(void);
static GF_RESULT cgf_init_device(void);
#ifdef O_MD
static GF_RESULT cgf_get_callback_info(UNSIGNED16 *number_of_callbacks);
static GF_RESULT cgf_get_callback_next(BOOLEAN1 bUseCallbackCounter, UNSIGNED32 max_package_number);
static GF_RESULT cgf_get_callback_packages(UNSIGNED32 max_package_number);
#endif
///////////////////////////////////////////////////////////////////////
// Internal Functions
///////////////////////////////////////////////////////////////////////
// --------------------------------------------------------------------
// [Name] cgf_get_value_16
//
// [Function]
// This function gets a 16-bit value from a pointer
// to a memory location (little and big endian).
// [INPUT]
// p_value_16: pointer to 16-bit value
// [OUTPUT]
// none
// [RETURN]
// return_value_16: 16-bit return value
// --------------------------------------------------------------------
static UNSIGNED16 cgf_get_value_16 (UNSIGNED16 *p_value_16)
{
UNSIGNED8 *p_value_8;
UNSIGNED8 *p_return_value_8;
UNSIGNED16 return_value_16;
p_value_8 = (UNSIGNED8*)p_value_16;
p_return_value_8 = (UNSIGNED8*)&return_value_16;
#if defined (O_LE)
p_return_value_8[0] = p_value_8[1];
p_return_value_8[1] = p_value_8[0];
#else
p_return_value_8[0] = p_value_8[0];
p_return_value_8[1] = p_value_8[1];
#endif
return return_value_16;
}
// --------------------------------------------------------------------
// [Name] cgf_get_value_32
//
// [Function]
// This function gets a 32-bit value from a pointer
// to a memory location (little and big endian).
// [INPUT]
// p_value_32: pointer to 32-bit value
// [OUTPUT]
// none
// [RETURN]
// return_value_32: 32-bit return value
// --------------------------------------------------------------------
static UNSIGNED32 cgf_get_value_32 (UNSIGNED32 *p_value_32)
{
UNSIGNED8 *p_value_8;
UNSIGNED8 *p_return_value_8;
UNSIGNED32 return_value_32;
p_value_8 = (UNSIGNED8*)p_value_32;
p_return_value_8 = (UNSIGNED8*)&return_value_32;
#if defined (O_LE)
p_return_value_8[0] = p_value_8[3];
p_return_value_8[1] = p_value_8[2];
p_return_value_8[2] = p_value_8[1];
p_return_value_8[3] = p_value_8[0];
#else
p_return_value_8[0] = p_value_8[0];
p_return_value_8[1] = p_value_8[1];
p_return_value_8[2] = p_value_8[2];
p_return_value_8[3]
评论3