예제 #1
0
/*!
 @brief fta_stop

 FTA stop function

 @param      none

 @retval     none
*/
void fta_stop(fta_stop_reason_enum reason)
{

  if(fta_manager == NULL) return;

  FTA_ENTER_LOCK();

  if(fta_lock_keeper.manager_status == FTA_MANAGER_STATUS_ENABLED) {
    fta_lock_keeper.manager_status = FTA_MANAGER_STATUS_STOP;
    /* - - - - - - - - */
    switch(reason) {
    case FTA_STOP_REASON_NORMAL:
      FTA_LIB_CHANGEBIT_CLR(fta_manager->cmn.statbit, FTA_STORE_STATBIT_RECORDING);
      fta_manager->cmn.enabled = FTA_STORE_ENABLED_FALSE;
      fta_manager->parity      = fta_lib_check_parity16((uint16 *)fta_manager, fta_manager->cmn.size / 2, fta_manager->parity);
      break;
    case FTA_STOP_REASON_ABNORMAL:
      break;
    case FTA_STOP_REASON_INTENTIONAL:
      FTA_LIB_CHANGEBIT_SET(fta_manager->cmn.statbit, FTA_STORE_STATBIT_INTENTIONAL);
      fta_manager->parity      = fta_lib_check_parity16((uint16 *)fta_manager, fta_manager->cmn.size / 2, fta_manager->parity);
    }
    /* - - - - - - - - */
    FTA_MEMORY_FLUSH();
  }

  FTA_LEAVE_LOCK();

  _fta_manage_terminate_store_items(fta_manager);
  fta_reference = fta_reference_null;

  return;
}
예제 #2
0
/*!
 @brief _fta_lisext_hash_record

 operate the list hash record

 @param [in] p_store_item   item for manage
 @param [in] access_info    access information
 @param [in] key_info       key
 @param [in] access_type    FTA_LISTEX_HASH_ACCESS_GET: get record
                            FTA_LISTEX_HASH_ACCESS_ADD: add record
                            FTA_LISTEX_HASH_ACCESS_DEL: del record

 @retval       NULL: not found / over the max record
 @retval     others: pointer of record
*/
void *_fta_listex_hash_record(const fta_manager_store_item * const *p_store_item,
                            const fta_listex_hash_access_info *access_info,
                            const void *key_info, uint32 access_type)
{
  fta_list_store_header *list_header;
  void *list_record = NULL;

  /* parameter check */
  if(p_store_item == NULL || access_info == NULL || key_info == NULL ||
     access_type >= FTA_LISTEX_HASH_ACCESS_MAX) {
    FTA_LOG_MESSAGE(FTA_LIST, FTA_LOG_LEVEL_CRITICAL, "*** FTA LIST INTERNAL ERROR", 0, 0, 0);
    return NULL;
  }
  if(access_info->work_buffer == NULL) {
    FTA_LOG_MESSAGE(FTA_LIST, FTA_LOG_LEVEL_CRITICAL, "*** FTA LIST CONFIG ERROR", 0, 0, 0);
    return NULL;
  }

  if(access_info->lock_access) {

    FTA_ENTER_LOCK();
    /* - - - - - - - - */
    do {
      if(*p_store_item == NULL) {
        break;
      }
      if((*p_store_item)->lock_keeper->manager_status != FTA_MANAGER_STATUS_ENABLED) {
        break;
      }

      list_header = (fta_list_store_header *)((*p_store_item)->addr);
      list_record = _fta_listex_hash_record_i(list_header, access_info, key_info, access_type);

    } while(FALSE);
    /* - - - - - - - - */
    FTA_LEAVE_LOCK();

  } else {
    list_header = (fta_list_store_header *)((*p_store_item)->addr);
    list_record = _fta_listex_hash_record_i(list_header, access_info, key_info, access_type);
  }

  return list_record;
}
예제 #3
0
/*!
 @brief fta_terminate

 FTA terminate function

 @param      none

 @retval     none
*/
void fta_terminate(void)
{

  if(fta_manager == NULL) return;

  FTA_ENTER_LOCK();

  fta_lock_keeper.manager_status = FTA_MANAGER_STATUS_STOP;
  FTA_LIB_CHANGEBIT_CLR(fta_manager->cmn.statbit, FTA_STORE_STATBIT_RECORDING);
  fta_manager->cmn.enabled = FTA_STORE_ENABLED_FALSE;
  fta_manager->parity      = fta_lib_check_parity16((uint16 *)fta_manager, fta_manager->cmn.size / 2, fta_manager->parity);
  FTA_MEMORY_FLUSH();

  FTA_LEAVE_LOCK();

  _fta_manage_terminate_store_items(fta_manager);
  fta_reference = fta_reference_null;

  return;
}
예제 #4
0
/*!
 @brief _fta_var_alloc

 allocate the list record

 @param [in] p_store_item   item for manage
 @param [in] access_info    access information
 @param [in] key_info       key
 @param [in] alloc_len      size of the record

 @retval       NULL: over the max record
 @retval     others: pointer of record
*/
void *_fta_var_alloc(const fta_manager_store_item * const *p_store_item,
                     const fta_var_record_access_info *access_info, const void *key_info, uint32 alloc_len)
{
    fta_var_store_header *var_header;
    void *var_record = NULL;

    if(p_store_item == NULL || access_info == NULL || key_info == NULL) {
        FTA_LOG_MESSAGE(FTA_VAR, FTA_LOG_LEVEL_CRITICAL, "*** FTA VAR INTERNAL ERROR", 0, 0, 0);
        return NULL;
    }

    if(access_info->lock_access) {

        FTA_ENTER_LOCK();
        /* - - - - - - - - */
        do {
            if(*p_store_item == NULL) {
                break;
            }
            if((*p_store_item)->lock_keeper->manager_status != FTA_MANAGER_STATUS_ENABLED) {
                break;
            }

            var_header = (fta_var_store_header *)((*p_store_item)->addr);
            var_record = _fta_var_alloc_i(var_header, access_info, key_info, alloc_len);

        } while(FALSE);
        /* - - - - - - - - */
        FTA_LEAVE_LOCK();

    } else {
        var_header = (fta_var_store_header *)((*p_store_item)->addr);
        var_record = _fta_var_alloc_i(var_header, access_info, key_info, alloc_len);
    }

    return var_record;
}
예제 #5
0
/*!
 @brief _fta_var_find

 sarch for the record

 @param [in] p_store_item   item for manage
 @param [in] key_info       key
 @param [in] alloc_len      size of the record

   @retval       NULL: not found
   @retval     others: pointer of record
*/
void *_fta_var_find(const fta_manager_store_item * const *p_store_item,
                    const fta_var_record_access_info *access_info, const void *key_info)
{
    fta_var_store_header *var_header;
    void *var_record = NULL;

    uint8 *var_dataarea = NULL;
    uint32 dataarea_size = 0;
    uint32 record_count = 0;
    uint32 record_num;
    uint32 record_pos;
    uint32 key_size;
    uint32 datalen_size;
    uint32 datalen;
    boolean bad_condition = FALSE;

    if(p_store_item == NULL || access_info == NULL || key_info == NULL) {
        FTA_LOG_MESSAGE(FTA_VAR, FTA_LOG_LEVEL_CRITICAL, "*** FTA VAR INTERNAL ERROR", 0, 0, 0);
        return NULL;
    }

    FTA_ENTER_LOCK();

    /* - - - - - - - - */
    do {
        if(access_info->lock_access) {
            if(*p_store_item == NULL) {
                bad_condition = TRUE;
                break;
            }
            if((*p_store_item)->lock_keeper->manager_status != FTA_MANAGER_STATUS_ENABLED) {
                bad_condition = TRUE;
                break;
            }
        }
        var_header = (fta_var_store_header *)((*p_store_item)->addr);
        if(var_header->cmn.enabled != FTA_STORE_ENABLED_TRUE) {
            bad_condition = TRUE;
            break;
        }
        var_dataarea = FTA_LIB_OFFSET_ADDR(var_header, var_header->cmn.offset);
        record_count = var_header->count;
        dataarea_size = var_header->bottom;

    } while(FALSE);
    /* - - - - - - - - */

    FTA_LEAVE_LOCK();

    if(bad_condition) {
        return var_record;
    }

    key_size = access_info->key_size;
    datalen_size = access_info->datalen_size;
    record_pos = 0;
    /* - - - - - - - - */
    for(record_num = 0; record_num < record_count; record_num++) {
        if(dataarea_size < key_size + datalen_size + record_pos) {
            var_record = NULL;
            break;
        }
        var_record = (void *)FTA_LIB_OFFSET_ADDR(var_dataarea, record_pos);
        if(memcmp(var_record, key_info, key_size) == 0) {
            /* matched */
            break;
        }
        datalen = 0;
        if(datalen_size <= sizeof(uint32)) {
            memcpy(&datalen, FTA_LIB_OFFSET_ADDR(var_record, key_size), datalen_size);
        } else {
            memcpy(&datalen, FTA_LIB_OFFSET_ADDR(var_record, key_size), sizeof(uint32));
        }
        var_record = NULL;
        datalen = FTA_LIB_ALIGN4_32(datalen);
        record_pos += key_size + datalen_size + datalen;
    }
    /* - - - - - - - - */

    return var_record;
}