示例#1
0
/*************************************************************************
* FUNCTION
*  DclSD_Initialize
*
* DESCRIPTION
* 	This function is to get SD DCL handler.
*
* PARAMETERS
*	eDev - only valid for DCL_SD.
*	flags -following bit stand for specific meaning.
*		DCL_SD_FLAGS_CARD1: to get a handle for card 1
*		DCL_SD_FLAGS_CARD2: to get a handle for card 2
*		DCL_SD_FLAGS_SIMPLUS: to get a handle for sim plus
*		Other values are prohibited
* RETURNS
*  DCL_HANDLE_INVALID - Open failed.
*  other value - a valid handle
*
*************************************************************************/
DCL_HANDLE DclSIM_Open(DCL_DEV dev, DCL_FLAGS flags)
{
    kal_uint32 retAddr = 0;
    kal_uint32 thdId;
    kal_uint32 loopIndex;


    if (dev != DCL_SIM)
    {
        ASSERT(0);
        return DCL_HANDLE_INVALID;
    }

#if defined(__RVCT__)
    /* RVCT doesn't support inline assemlber; bypass temporarily */
    retAddr = 0;
#elif defined(__GCC__)
    /* GCC has function to support this */
    retAddr = (kal_uint32) __builtin_return_address (0);
#else   /* __RVCT__ */
    /* GCC has function to support this */
    retAddr = (kal_uint32) __builtin_return_address (0);

//        /* get the return address */
//        __asm {
//            MOV retAddr,lr
//        }
#endif  /* __RVCT__ */
    thdId = (kal_uint32)kal_get_current_thread_ID();


    /*
    	In SIM DCL open, we only mark control block as assigned and return handle to user.
    	We don't support one resource used by multiple applications, so the control block will be not re-assigned.
    	Every time this function is called, we just find an unused control block, mark it assigned, and return the handle.
    */

    kal_take_sem(dclSimArb, KAL_INFINITE_WAIT);
    for(loopIndex = 0; DCL_SIM_MAX_INTERFACE > loopIndex; loopIndex ++) {
        if (KAL_FALSE == simResource[loopIndex].assigned) {
            simResource[loopIndex].assigned = KAL_TRUE;
            simResource[loopIndex].thdId = thdId;
            simResource[loopIndex].allocatedPoint = retAddr;
            kal_give_sem(dclSimArb);
            return (DCL_HANDLE)(&simResource[loopIndex]);
        }
    }
    kal_give_sem(dclSimArb);
    return DCL_HANDLE_NONE;
}
示例#2
0
/*****************************************************************************
 * FUNCTION
 *  jbt_cmd_kick_check_list
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void jbt_cmd_kick_check_list(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    ilm_struct *ilmPtr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_take_sem(jbt_cmd_kick_sem, KAL_INFINITE_WAIT);
    kal_trace(TRACE_FUNC, JBT_JBT_CMD_KICK_CHECK_LIST);
    kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_CONTEXTQUEUE_KICK_OFF_D, jbt_cmd_queue_context.queue_kick_off);

    if (jbt_cmd_queue_context.queue_kick_off != 1)
    {
        jbt_cmd_queue_context.queue_kick_off = 1;
        ilmPtr = allocate_ilm(MOD_JASYN);
        ilmPtr->msg_id = MSG_ID_BT_JSR_KICK_NEW_COMMAND;
        ilmPtr->local_para_ptr = NULL;
        ilmPtr->peer_buff_ptr = NULL;
        ilmPtr->dest_mod_id = MOD_JASYN;
        ilmPtr->src_mod_id = MOD_JASYN;
        ilmPtr->sap_id = BT_APP_SAP;
        msg_send_ext_queue(ilmPtr);
    }
    kal_give_sem(jbt_cmd_kick_sem);
}
示例#3
0
kal_bool
idp_hw_close(
    idp_hw_owner_t * const owner,
    kal_uint32 const key)
{
    kal_bool result = KAL_TRUE;

    if (NULL == owner)
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

    kal_take_sem(owner->sem, KAL_INFINITE_WAIT);

    if (owner->key != key)
    {
        result = KAL_FALSE;
    }
    else
    {
        owner->key = 0;
    }

    kal_give_sem(owner->sem);

    return result;
}
示例#4
0
/*****************************************************************************
 * FUNCTION
 *  jbt_cmd_queue_nonconcurrent_completed
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void jbt_cmd_queue_nonconcurrent_completed(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    JBT_cmd_node *list = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_take_sem(jbt_cmd_process_sem, KAL_INFINITE_WAIT);
    kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_NONCONCURRENT_COMPLETED);

    ASSERT(jbt_cmd_queue_context.cmd_run_no > 0);
    kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_CONTEXTCMD_RUN_NOx02X, jbt_cmd_queue_context.cmd_run_no);
    jbt_cmd_queue_context.cmd_run_no--;
    list = &jbt_cmd_queue_context.cmd_list;
    if (list->flink != list)
    {
        jbt_cmd_kick_check_list();
    }
    kal_give_sem(jbt_cmd_process_sem);

    if ((jbt_cmd_queue_context.cmd_run_no == 0) && (jbt_gap_power_state() == JBT_POWER_OTHERS))
    {
        jbt_restore_procedure(JBT_CMD_SUCCESS);
    }
}
示例#5
0
void L1Audio_ClearFlag( uint16 audio_id )
{
   uint32 savedMask;
   if (!kal_if_hisr() && !kal_if_lisr())  
      kal_trace( TRACE_GROUP_AUD_MD2GCTRL, L1AUDIO_CLEARFLAG_A,audio_id,l1audio.runningState);
   else
      kal_dev_trace( TRACE_GROUP_AUD_MD2GCTRL, L1AUDIO_CLEARFLAG_A,audio_id,l1audio.runningState);
   kal_take_sem( l1audio.sema, KAL_INFINITE_WAIT );
   ASSERT( l1audio.id_flag & (1 << audio_id) );
   ASSERT( l1audio.runningState & (1 << audio_id) );

   savedMask = SaveAndSetIRQMask();
   l1audio.runningState &= ~(1 << audio_id);
   RestoreIRQMask( savedMask );
   if(l1audio.runningState == 0 ) {
      SLEEP_UNLOCK();
   }
   
   if( (l1audio.runningState == 0) && (l1audio.disallowSleepState == 0) ) {
#if defined( __CENTRALIZED_SLEEP_MANAGER__ )
      Audio_Wake_DSP(audio_id, KAL_FALSE);
#endif
  }
   kal_give_sem( l1audio.sema ); 
}
示例#6
0
kal_bool
idp_hw_open(
    idp_hw_owner_t * const owner)
{
    kal_bool result = KAL_TRUE;

    if (NULL == owner)
    {
        //ASSERT(0);
        return KAL_FALSE;
    }
    kal_take_sem(owner->sem, KAL_INFINITE_WAIT);

    if (owner->key != 0)
    {
        result = KAL_FALSE;
    }
    else
    {
        kal_uint32 local_key = 0;

        while (0 == local_key)
        {
            local_key = rand();
        }

        owner->key = local_key;
    }

    kal_give_sem(owner->sem);

    return result;
}
示例#7
0
/*****************************************************************************
 * FUNCTION
 *  jbt_cmd_list_give_sem
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void jbt_cmd_list_give_sem(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_give_sem(jbt_cmd_sem);
}
示例#8
0
/******************************************************************************
* Function:
*	GPSAppDataBackupStore
* 
* Usage:
*	Store data to backup files.
*
* Parameters:
*	pBuff - pointer to caller's data buffer, which contains data to be stored.
*	Length - data length (in byte)
*
* Return:
*	Error code
******************************************************************************/
GPSAppDataBackupError_t GPSAppDataBackupStore(
	const kal_uint8* pBuff,
	kal_uint16 Length
	)
{
	kal_uint16 FileName[GPSAPP_DATABACKUP_FULLPATHNAME_LEN_MAX];
	GPSAppDataBackupError_t ErrCode = GPSAPP_DATABACKUP_ERROR_NONE;
	FS_HANDLE file_handle;
	int result;
	kal_uint32 len;
	kal_int32 FileID;

	if (pBuff == NULL || Length == 0)
	{
		return GPSAPP_DATABACKUP_ERROR_INVALID_PARAM;
	}
	//take the semaphore
	kal_take_sem(gGPSAppDataBackupSem, KAL_INFINITE_WAIT);
	//apply file name
	if ((FileID = GPSAppDataBackupApplyCell(FileName, CELLATTR_FREE)) < 0)
	{
		ErrCode = GPSAPP_DATABACKUP_ERROR_STORAGE_FULL;
		goto _RelSem_Return_;
	}
	//create file
	file_handle = FS_Open(FileName, FS_CREATE | FS_READ_WRITE);
	if (file_handle < FS_NO_ERROR)
	{
		//fail to open
		ErrCode = GPSAPP_DATABACKUP_ERROR_OPEN_FAIL;
		#if _GPSAPP_DATABACKUP_DBG_
		trace_printf("GPSAppDataBackupStore: Open fail (%d)", file_handle);
		#endif //_GPSAPP_DATABACKUP_DBG_
		goto _RelSem_Return_;
	}
	//write
	result = FS_Write(file_handle, (void*)pBuff, Length, &len);
	FS_Close(file_handle);
	if (result != FS_NO_ERROR || len != Length)
	{
		ErrCode = GPSAPP_DATABACKUP_ERROR_WRITE_FAIL;
		goto _RelSem_Return_;
	}
	//update attr
	GPSAppDataBackupUpdateAttrCache(FileID, ATTRUPDATE_ADD);
	ErrCode = GPSAppDataBackupWriteAttrFile(KAL_FALSE);
	
_RelSem_Return_:
	//release semaphore
	kal_give_sem(gGPSAppDataBackupSem);
	return ErrCode;
}
示例#9
0
/*************************************************************************
* FUNCTION
*  RTFSYSFreeMutex
*
* DESCRIPTION
*  This function implements to release filesystem mutex
*
* PARAMETERS
*
* RETURNS
*
* GLOBALS AFFECTED
*
*************************************************************************/
void RTFAPI
RTFSYSFreeMutex(RTFMutex * Mutex)
{
   kal_taskid current_task;

   #ifdef __P_PROPRIETARY_COPYRIGHT__
/* under construction !*/
/* under construction !*/
   #endif

   current_task = kal_get_current_thread_ID();

   // task not ready
   if(current_task == KAL_NILTASK_ID)
      return;
   /*
    * Bypass all FS lock operations in exception mode to avoid unexpected suspend behavior. (W10.37)
    *
    * NOTE 1. If a "HISR" triggers an exception, bypass lock operation to avoid another fatal error
    *         because only "task" can get semaphore (kal_take_sem) successfully.
    *
    * NOTE 2. HISR should NOT use FS in normal mode. It only walks here when an exception is triggerred in HISR.
    */
   else if (INT_QueryExceptionStatus() == KAL_TRUE)
      return;

   #ifndef WIN32
   if (INT_QueryExceptionStatus() == KAL_FALSE) /* Should only be possible for exception cases */
      fs_assert_local(Mutex->rtf_sem_owner == current_task);
   #else
      fs_assert_local(Mutex->rtf_sem_owner == current_task);
   #endif

   Mutex->rtf_lock_count--;

   if (Mutex->rtf_lock_count == 0)
   {
      Mutex->rtf_sem_owner = KAL_NILTASK_ID;
      /* Solve MMI hang for waiting lock, Karen Hsu, 2004/04/23, ADD START */
      Mutex->DeviceNum_1 = 0;
      Mutex->DeviceNum_2 = 0;
      /* Solve MMI hang for waiting lock, Karen Hsu, 2004/04/23, ADD END */

      kal_give_sem(Mutex->rtf_sem);

      #if defined(__AUDIO_DSP_LOWPOWER__)
      AUDMA_UNLOCK(AUDMA_ID_FS);
      #endif
   }
}
示例#10
0
/******************************************************************************
* Function:
*	GPSLocateNvramReadRecord
*
* Usage:
*	Read one record from the storage (NVRAM or FS)
*
* Parameters:
*	RecId - Record ID
*	pBuff - Pointer to the caller's memory buffer. On a successful request, the record data
*					 is copied to the buffer.
*	BuffLen - the buffer length
*
* Return:
*	KAL_TRUE - successfully
*	KAL_FALSE - failed
******************************************************************************/
kal_bool GPSLocateNvramReadRecord(
	GPSLocateNvramRecId_t RecId,
	void* pBuff,
	unsigned short BuffLen
	)
{
	kal_bool bRet = KAL_TRUE;
	
	//check parameters
	if (RecId >= GPS_NVRAM_RECID_Total || 
		pBuff == NULL ||
		BuffLen < GPSLOCATE_REC_SIZE[RecId])
	{
		return KAL_FALSE;
	}
	ASSERT((gGPSLocateNvramSem!=NULL));
	//take the semaphore
	kal_take_sem(gGPSLocateNvramSem, KAL_INFINITE_WAIT);
	if (gGPSLocateNvramDataCache.Valid == KAL_TRUE)
	{
		//read from cache
		memcpy(pBuff, 
			&(gGPSLocateNvramDataCache.Cache.Buff[GPSLocateNvramGetRecOffset(RecId)]), 
			GPSLOCATE_REC_SIZE[RecId]);
		bRet = KAL_TRUE;
		//return KAL_TRUE;
		goto _RelSem_Return_;
	}
	//read the file
	if (GPSLocateNvramLoadData() == KAL_FALSE)
	{
		bRet = KAL_FALSE;
		//return KAL_FALSE;
		goto _RelSem_Return_;
	}
	else
	{
		//load successfully, read from cache
		memcpy(pBuff, 
			&(gGPSLocateNvramDataCache.Cache.Buff[GPSLocateNvramGetRecOffset(RecId)]), 
			GPSLOCATE_REC_SIZE[RecId]);
		bRet = KAL_TRUE;
		//return KAL_TRUE;
		goto _RelSem_Return_;
	}
_RelSem_Return_:
	//release semaphore
	kal_give_sem(gGPSLocateNvramSem);
	return bRet;
}
示例#11
0
/*****************************************************************************
 * FUNCTION
 *  jbt_cmd_kick_check_list_done
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void jbt_cmd_kick_check_list_done(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_take_sem(jbt_cmd_kick_sem, KAL_INFINITE_WAIT);
    jbt_cmd_queue_context.queue_kick_off = 0;
    kal_trace(TRACE_FUNC, JBT_JBT_CMD_KICK_CHECK_LIST_DONE);
    kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_CONTEXTQUEUE_KICK_OFF_D, jbt_cmd_queue_context.queue_kick_off);
    kal_give_sem(jbt_cmd_kick_sem);
}
示例#12
0
kal_bool fm_scan(struct fm_scan_parm *parm){
	kal_bool return_value;
	
	kal_prompt_trace(MOD_MATV, "[FM] fm_scan In");
	if (NULL != matv_sem_id)
			kal_take_sem(matv_sem_id, KAL_INFINITE_WAIT);
	
	return_value=fmdrv_scan(parm);
			
	if (NULL != matv_sem_id)
			kal_give_sem(matv_sem_id);

	kal_prompt_trace(MOD_MATV, "[FM] fm_scan Out");
	
	return return_value;
}
示例#13
0
int fm_getchipid(void){
	kal_uint32 return_value;

	kal_prompt_trace(MOD_MATV, "[FM] fm_getchipid In");

	if (NULL != matv_sem_id)
			kal_take_sem(matv_sem_id, KAL_INFINITE_WAIT);	

	return_value=fmdrv_getchipid();

	if (NULL != matv_sem_id)
			kal_give_sem(matv_sem_id);
	
	kal_prompt_trace(MOD_MATV, "[FM] fm_getchipid Out");

	return return_value; 
}
示例#14
0
kal_bool fm_powerdown(kal_uint32 val){
	kal_bool return_value;

	kal_prompt_trace(MOD_MATV, "[FM] fm_powerdown In");

	if (NULL != matv_sem_id)
			kal_take_sem(matv_sem_id, KAL_INFINITE_WAIT);

	return_value=fmdrv_powerdown(val);

	if (NULL != matv_sem_id)
			kal_give_sem(matv_sem_id);

	kal_prompt_trace(MOD_MATV, "[FM] fm_powerdown Out");

	return return_value;
}
示例#15
0
/******************************************************************************
* Function:
*	GPSLocateNvramWriteRecord
*
* Usage:
*	Write one record to the storage (NVRAM or FS)
*
* Parameters:
*	RecId - Record ID
*	pBuff - Pointer to the caller's memory buffer. On a successful request, the record data
*					 is written to the storage.
*	BuffLen - the buffer length
*
* Return:
*	KAL_TRUE - successfully
*	KAL_FALSE - failed
******************************************************************************/
kal_bool GPSLocateNvramWriteRecord(
	GPSLocateNvramRecId_t RecId,
	const void* pBuff,
	unsigned short BuffLen
	)
{
	//check parameters
	if (RecId >= GPS_NVRAM_RECID_Total || 
		pBuff == NULL ||
		BuffLen < GPSLOCATE_REC_SIZE[RecId])
	{
		return KAL_FALSE;
	}

	ASSERT((gGPSLocateNvramSem!=NULL));
	//take the semaphore
	kal_take_sem(gGPSLocateNvramSem, KAL_INFINITE_WAIT);
	//backup the cache data
	memcpy(&CacheBackup, &(gGPSLocateNvramDataCache.Cache), sizeof(GPSLocateNvramDataStruct_t));
	if (gGPSLocateNvramDataCache.Valid == KAL_FALSE)
	{
		//the cache data is invalid, clear it firstly
		memset(&(gGPSLocateNvramDataCache.Cache), 0x00, sizeof(GPSLocateNvramDataStruct_t));
	}
	//write to cache
	memcpy(&(gGPSLocateNvramDataCache.Cache.Buff[GPSLocateNvramGetRecOffset(RecId)]),
			pBuff, GPSLOCATE_REC_SIZE[RecId]);
	gGPSLocateNvramDataCache.Changed = KAL_TRUE;
	//release semaphore
	kal_give_sem(gGPSLocateNvramSem);

	if (!gps_nvramstore_timer)
	{
		gps_nvramstore_timer = GPSAppTimer_Create(GENERAL_GPSAPP_TIMERID,
								GPSLocateNvramRepeatHandler,
								KAL_TICKS_1_MIN,
								KAL_TICKS_1_MIN,
								KAL_TRUE);
	}

	return KAL_TRUE;
}
示例#16
0
/******************************************************************************
* Function:
*	GPSAppDataBackupDelCurrFile
* 
* Usage:
*	Delete the current loading backup files.
*
* Parameters:
*	None
*
* Return:
*	Error code
******************************************************************************/
GPSAppDataBackupError_t GPSAppDataBackupDelCurrFile(void)
{
	kal_int8 tmpBuffer[GPSAPP_DATABACKUP_FULLPATHNAME_LEN_MAX];
	kal_uint16 FileName[GPSAPP_DATABACKUP_FULLPATHNAME_LEN_MAX];

	//take the semaphore
	kal_take_sem(gGPSAppDataBackupSem, KAL_INFINITE_WAIT);

	if (gGPSAppDataBackupCurrLoadingFileID < 0)
	{
		goto _RelSem_Return_;
	}
	//construct the file name
#if (GPSAPP_DATABACKUP_FILES_MAX <= 100)	
	sprintf(tmpBuffer, "%s%s%02d%s", 
		gGPSAppDataBackupFolderName, 
		GPSAPP_DATABACKUP_FILE_PREFIX, 
		gGPSAppDataBackupCurrLoadingFileID, 
		GPSAPP_DATABACKUP_FILE_SUFFIX);
#elif (GPSAPP_DATABACKUP_FILES_MAX <= 1000)
	sprintf(tmpBuffer, "%s%s%03d%s", 
		gGPSAppDataBackupFolderName, 
		GPSAPP_DATABACKUP_FILE_PREFIX, 
		gGPSAppDataBackupCurrLoadingFileID, 
		GPSAPP_DATABACKUP_FILE_SUFFIX);
#else
	#error "Cannot define GPSAPP_DATABACKUP_FILES_MAX larger than 1000"
#endif
	app_ansii_to_unicodestring((kal_int8*)FileName, (kal_int8*)tmpBuffer);
	//delete the file
	FS_Delete(FileName);
	//update cache
	GPSAppDataBackupUpdateAttrCache(gGPSAppDataBackupCurrLoadingFileID, ATTRUPDATE_REMOVE);
	//update attr file
	GPSAppDataBackupWriteAttrFile(KAL_FALSE);
	gGPSAppDataBackupCurrLoadingFileID = -1;
	
_RelSem_Return_:
	//release semaphore
	kal_give_sem(gGPSAppDataBackupSem);
	return GPSAPP_DATABACKUP_ERROR_NONE;
}
示例#17
0
/*****************************************************************************
* FUNCTION
*   gps_nvram_main
* DESCRIPTION
*   This function is the main function of GPS NVRAM task
* PARAMETERS
*   task_entry_ptr  IN   taks entry of GPS NVRAM
* RETURNS
*   None.
* GLOBALS AFFECTED
*   external_global
*****************************************************************************/
static void gps_nvram_main(task_entry_struct * task_entry_ptr)
{
   ilm_struct current_ilm;

   while ( 1 ) {
      receive_msg_ext_q(task_info_g[task_entry_ptr->task_indx].task_ext_qid, &current_ilm);

      switch (current_ilm.msg_id) {
	  case MSG_ID_GPSLOCATE_NVRAMSTORE_IND:
      	gps_nvram_log("GPS NVRAM receive msg: MSG_ID_GPSLOCATE_NVRAMSTORE_IND");
		gps_nvram_wr2fs_ind_hdlr(&current_ilm);
		break;

	//release semaphore
	kal_give_sem(gGPSLocateNvramSem);

      default:
         break;
      }
      free_ilm(&current_ilm);
   }
}
示例#18
0
DCL_STATUS DclSIM_Close(DCL_HANDLE handle)
{
    DCL_SIM_RESOURCE *resource;

    /*check the handle*/
    if(0 == handle)
    {
        ASSERT(0);
        return STATUS_INVALID_DCL_HANDLE;
    }
    resource = (DCL_SIM_RESOURCE *)handle;

    kal_take_sem(dclSimArb, KAL_INFINITE_WAIT);
    resource->assigned = KAL_FALSE;
    resource->thdId = 0;
    resource->allocatedPoint = 0;
    /*Blue added*/
    resource->driverHandle = SIM_RSC_HANDLE_UDEF;
    resource->driver = NULL;
    kal_give_sem(dclSimArb);

    return STATUS_OK;
}
示例#19
0
/////////////////////////////////////////////////////////////////////////////
//power on/off/suspend
/////////////////////////////////////////////////////////////////////////////
kal_bool fm_powerup(struct fm_tune_parm *parm){
	kal_bool return_value;
	
	mATV_task_init();
	kal_prompt_trace(MOD_MATV, "[FM] fm_powerup In");
	if (NULL != matv_sem_id)
			kal_take_sem(matv_sem_id, KAL_INFINITE_WAIT);
	
	return_value=fmdrv_init();

	if (NULL != matv_sem_id)
			kal_give_sem(matv_sem_id);
	
	if(return_value)
	{
		return_value = fm_tune(parm);
	}
			

	kal_prompt_trace(MOD_MATV, "[FM] fm_powerup Out");
	
	return return_value;
}
示例#20
0
/*****************************************************************************
 * FUNCTION
 *  jbt_cmd_queue_nonconcurrent_processing
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void jbt_cmd_queue_nonconcurrent_processing(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    JBT_cmd_node *node;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_take_sem(jbt_cmd_process_sem, KAL_INFINITE_WAIT);

    kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_NONCONCURRENT_PROCESSING);

    if (jbt_cmd_queue_context.cmd_run_no < JBT_MAX_COMMAND_NO)
    {
        kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_LIST_REMOVE_HEAD);
        node = jbt_cmd_list_remove_head(&jbt_cmd_queue_context.cmd_list);
        jbt_cmd_queue_context.cmd_run_no++;
        kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_CONTEXTCMD_RUN_NOxD, jbt_cmd_queue_context.cmd_run_no);
        kal_trace(TRACE_JBT_GROUP, JBT_NODECMD_CODExD, node->cmd_code);
        switch (node->cmd_code)
        {
            case JBT_CMDCODE_DEVICE_RESTORE_COD:
                jbt_set_local_cod_cmd_body(node->parms, BTBM_WRITE_COD_RESTORE);
                break;
            case JBT_CMDCODE_DEVICE_RESTORE_MMI:
                break;
            case JBT_CMDCODE_SET_LOCAL_COD:
                jbt_set_local_cod_cmd_body(node->parms, BTBM_WRITE_COD_MASK);
                break;
            case JBT_CMDCODE_GET_REMOTE_NAME:
                jbt_get_remote_name_cmd_body(node->parms);
                break;
            case JBT_CMDCODE_DEVICE_DISCOVERY_CMD:
                jbt_device_discovery_cmd_body(node->parms);
                break;
                /* Add 2007-1119 */
            case JBT_CMDCODE_SET_ACL_SECURITY_INFO:
                jbt_set_acl_security_cmd_body(node->parms);
                break;
            default:
                ASSERT(0);
                break;
        }
        if (node->parms != 0)
        {
            jbt_free_record(node->parms);
#ifndef JBT_SUPPORT_ADM_MEM
            jvm_free(node->parms);
#else
            kal_adm_free(jbt_get_mem_pool_id(),node->parms);
#endif
        }
        node->parms = 0;
        node->cmd_code = 0;
        kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_LIST_INIT);
        jbt_cmd_list_init(node);
        kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_LIST_INSERT_TAIL);
        jbt_cmd_list_insert_tail(&jbt_cmd_queue_context.empty_list, node);

    }
    kal_give_sem(jbt_cmd_process_sem);
    kal_trace(TRACE_JBT_GROUP, JBT_JBT_CMD_QUEUE_NONCONCURRENT_PROCESSING_END);

}
示例#21
0
kal_bool
idp_find_empty_and_register(
    kal_uint32 * const key,
    idp_owner_t ** const owner)
{
    kal_uint32 i;
    kal_bool result = KAL_FALSE;

    if (NULL == owner)
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

    /* Because I need to call semaphore API, I have to ensure
     * this function will not be called from HISR & LISR.
     */
    if (kal_if_hisr())
    {
        //ASSERT(0);
        return KAL_FALSE;
    }
    if (kal_if_lisr())
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

    kal_take_sem(idp_owners_sem, KAL_INFINITE_WAIT);

    for (i = 0; i < MAX_CONCURRENT_DP; ++i)
    {
        //kal_bool find_one = KAL_FALSE;

        if (0 == owners[i].key)
        {
            kal_uint32 local_key;

            while (1)
            {
                kal_bool cal_again = KAL_FALSE;

                local_key = 0;

                while (0 == local_key)
                {
                    local_key = rand();
                }

                {
                    int j;

                    for (j = 0; j < MAX_CONCURRENT_DP; ++j)
                    {
                        if (j != i)
                        {
                            if (owners[j].key == local_key)
                            {
                                cal_again = KAL_TRUE;
                            }

                            if (KAL_TRUE == cal_again)
                            {
                                break;
                            }
                        }
                    }
                }

                if (KAL_FALSE == cal_again)
                {
                    break;
                }
            }

            owners[i].key = local_key;
            (*key) = local_key;

            owners[i].task = kal_get_current_thread_ID();

            (*owner) = &(owners[i]);

            result = KAL_TRUE;

            //find_one = KAL_TRUE;
            break;
        }

        //if (KAL_TRUE == find_one)
        //{
        //  break;
        //}
    }

    kal_give_sem(idp_owners_sem);

    return result;
}
示例#22
0
/******************************************************************************
* Function:
*	GPSAppDataBackupLoad
* 
* Usage:
*	Load data from backup files.
*
* Parameters:
*	pBuff - pointer to caller's data buffer, which is used to store loading data.
*	pLength - (Input) the buffer size (in byte)
*			 (Output) data length loaded from the backup file (in byte)
*
*	NOTE: If just want to check whether backup files existing, the caller is allowed to assign a
*			NULL pointer to pBuff; the other parameter pLength is used to return the number
*			of these backup files, so it should not be NULL.
*
* Return:
*	Error code
******************************************************************************/
GPSAppDataBackupError_t GPSAppDataBackupLoad(
	kal_uint8* pBuff,
	kal_uint16* pLength
	)
{
	GPSAppDataBackupError_t ErrCode = GPSAPP_DATABACKUP_ERROR_NONE;
	kal_int32 FileID;
	kal_uint16 FileName[GPSAPP_DATABACKUP_FULLPATHNAME_LEN_MAX];
	FS_HANDLE file_handle;
	int result;
	unsigned int len;

	if (pBuff == NULL && pLength == NULL)
	{
		return GPSAPP_DATABACKUP_ERROR_INVALID_PARAM;
	}
	//take the semaphore
	kal_take_sem(gGPSAppDataBackupSem, KAL_INFINITE_WAIT);

	gGPSAppDataBackupCurrLoadingFileID = -1;
	
	if (pBuff == NULL)
	{
		//just inquery file amount
		*pLength = GPSAppDataBackupGetFileAmount();
		ErrCode = GPSAPP_DATABACKUP_ERROR_NONE;
		goto _RelSem_Return_;
	}

	//apply file name
	if ((FileID = GPSAppDataBackupApplyCell(FileName, CELLATTR_OCCUPIED)) < 0)
	{
		ErrCode = GPSAPP_DATABACKUP_ERROR_STORAGE_EMPTY;
		goto _RelSem_Return_;
	}
	//save file ID
	gGPSAppDataBackupCurrLoadingFileID = FileID;
	//create file
	file_handle = FS_Open(FileName, FS_READ_ONLY);
	if (file_handle < FS_NO_ERROR)
	{
		//fail to open
		ErrCode = GPSAPP_DATABACKUP_ERROR_OPEN_FAIL;
		goto _RelSem_Return_;
	}
	//read
	result = FS_Read(file_handle, pBuff, *pLength, &len);
	FS_Close(file_handle);
	if (result != FS_NO_ERROR)
	{
		//read fail
		ErrCode = GPSAPP_DATABACKUP_ERROR_READ_FAIL;
		goto _RelSem_Return_;
	}
	*pLength = len;

#if 0
	{
	GPS_GPRMC_Packed_Struct_t *pPack = (GPS_GPRMC_Packed_Struct_t *)pBuff;
	int tmpLen = len / sizeof(GPS_GPRMC_Packed_Struct_t);
	char tmpStr[128];
	int i;
	Result_t result = RESULT_ERROR;
	for (i = 0; i < tmpLen; i++)
		{
		memset(tmpStr, 0, sizeof(tmpStr));
		result = GPS_APP_GPRMC_Packed2Str(tmpStr, pPack);
		pPack++;
		trace_printf("XXX: %s", tmpStr);
		}
	}
#endif

_RelSem_Return_:
	//release semaphore
	kal_give_sem(gGPSAppDataBackupSem);
	return ErrCode;
}
示例#23
0
kal_bool
idp_close(
    kal_uint32 const key,
    idp_close_hook_t const hook)
{
    kal_bool result;
    idp_owner_t *owner = NULL;

    result = idp_find(key, &owner);
    if (KAL_FALSE == result)
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

    result = hook(owner);

    owner->key = 0;

    /* Because I need to call semaphore API, I have to ensure
     * this function will not be called from HISR & LISR.
     */
    if (kal_if_hisr())
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

    if (kal_if_lisr())
    {
        //ASSERT(0);
        return KAL_FALSE;
    }

#if ((!defined(DRV_IDP_6252_SERIES)) && (!defined(DRV_IDP_6253_SERIES)))
    // To see if there is no one use IDP.
    {
        kal_uint32 i;
        kal_bool can_poweroff = KAL_TRUE;

        // lock all possible data paths.
        kal_take_sem(idp_owners_sem, KAL_INFINITE_WAIT);

        for (i = 0; i < MAX_CONCURRENT_DP; ++i)
        {
            if (owners[i].key != 0)
            {
                // There at least one uses IDP now, so I can not
                // power off IDP.
                can_poweroff = KAL_FALSE;
            }
        }

        if (KAL_TRUE == can_poweroff)
        {
#if defined(IDP_DRVPDN_SUPPORT)
            turn_off_idp_power();
#endif
        }

        // unlock all possible data paths.
        kal_give_sem(idp_owners_sem);
    }
#endif // ((!defined(DRV_IDP_6252_SERIES))...

    return KAL_TRUE;
}
示例#24
0
void matv_kal_give_sem()
{
if (NULL != matv_sem_id)
			kal_give_sem(matv_sem_id);
}