/*****************************************************************************
 * FUNCTION
 *  phb_sat_file_change_confirm
 * DESCRIPTION
 *  This is phb_sat_file_change_confirm function of PHB module.
 * PARAMETERS
 *  result              [IN]        
 *  src_id              [IN]        
 *  control_block       [?]         
 *  ilm_ptr(?)          [IN]        The primitives
 * RETURNS
 *  void
 *****************************************************************************/
void phb_sat_file_change_confirm(phb_errno_enum result, kal_uint8 src_id, control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    local_para_struct *local_param_ptr = NULL;
    sat_file_change_res_struct *sat_file_change_res;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_SAT_FILE_CHANGE_CNF, result, src_id);

    sat_file_change_res = (sat_file_change_res_struct*) construct_local_para(
                                                            sizeof(sat_file_change_res_struct),
                                                            TD_CTRL);
    sat_file_change_res->src_id = src_id;

    local_param_ptr = (local_para_struct*) sat_file_change_res;

    /* Reject newly received request */
    if (result == PHB_ERRNO_BUSY)
    {
        sat_file_change_res->is_successful = KAL_FALSE;
    }

    else
    {
        sat_file_change_res->is_successful = (result == PHB_ERRNO_SUCCESS) ? KAL_TRUE : KAL_FALSE;

        if (control_block)
        {
            phb_free_control_block(control_block);
        }
    }

    phb_send_ilm(MOD_SIM, MSG_ID_SAT_FILE_CHANGE_RES, local_param_ptr, NULL);
}   /* end of phb_sat_file_change_confirm */
Exemple #2
0
/*****************************************************************************
 * FUNCTION
 *  phb_search_confirm
 * DESCRIPTION
 *  This is phb_search_confirm function of PHB module.
 * PARAMETERS
 *  result              [IN]        
 *  actual_count        [IN]        
 *  src_id              [IN]        
 *  cnf_msg_id          [IN]        
 *  control_block       [?]         
 *  ilm_ptr(?)          [IN]        The primitives
 * RETURNS
 *  void
 *****************************************************************************/
static void phb_search_confirm(
                phb_errno_enum result,
                kal_uint16 actual_count,
                kal_uint8 src_id,
                msg_type cnf_msg_id,
                control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    local_para_struct *local_param_ptr = NULL;
    peer_buff_struct *peer_buf_ptr = NULL;

    kal_uint16 msg_id = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_SEARCH_CNF, result, actual_count, src_id, cnf_msg_id);

    /* First we release local parameter. */
    if ((result != PHB_ERRNO_BUSY) && (control_block->local_param_ptr != NULL))
    {
        free_ctrl_buffer(control_block->local_param_ptr);
    }

    if ((result == PHB_ERRNO_BUSY) || (control_block->cnf_msg_id == MSG_ID_L4CPHB_SEARCH_REQ))
    {
        l4cphb_search_cnf_struct *l4cphb_search_cnf;

        l4cphb_search_cnf = (l4cphb_search_cnf_struct*) construct_local_para(
                                                            sizeof(l4cphb_search_cnf_struct),
                                                            TD_CTRL);
        l4cphb_search_cnf->total = actual_count;
        l4cphb_search_cnf->src_id = src_id;
        l4cphb_search_cnf->result = result;

        /* Field `cause' is meaningful when I/O occured by using control blocks */
        l4cphb_search_cnf->cause = control_block->cause;

        if (result == PHB_ERRNO_BUSY)
        {

            phb_send_ilm(MOD_L4C, MSG_ID_L4CPHB_SEARCH_CNF, (local_para_struct*) l4cphb_search_cnf, NULL);
            return;
        }

        local_param_ptr = (local_para_struct*) l4cphb_search_cnf;

        msg_id = MSG_ID_L4CPHB_SEARCH_CNF;
    }

   /**
    * Under ADN mode, only when is_retrieve is true and searching into
    * physical storage device is required will call search_continue(), which
    * in consequence results in this search_confirm() is invoked.
    *
    * Since it is ADN mode, no matter the search result is,
    * the approval result is ALWAYS success!!
    */
    else if (control_block->cnf_msg_id == MSG_ID_L4CPHB_APPROVE_REQ)
    {
        l4cphb_approve_cnf_struct *l4cphb_approve_cnf;

        l4cphb_approve_cnf = (l4cphb_approve_cnf_struct*) construct_local_para(
                                                            sizeof(l4cphb_approve_cnf_struct),
                                                            TD_CTRL);
        l4cphb_approve_cnf->result = PHB_ERRNO_SUCCESS;

        /* Field `cause' is meaningful when I/O occured by using control blocks */
        l4cphb_approve_cnf->cause = control_block->cause;

        l4cphb_approve_cnf->type = control_block->type;
        l4cphb_approve_cnf->src_id = control_block->src_id;

        local_param_ptr = (local_para_struct*) l4cphb_approve_cnf;

        msg_id = MSG_ID_L4CPHB_APPROVE_CNF;
    }

    /* EXCEPTION cannot reach here */
    if (control_block->peer_buf_ptr != NULL)
    {
        if (control_block->actual_count > 0)
        {
            peer_buf_ptr = (peer_buff_struct*) control_block->peer_buf_ptr;
            control_block->peer_buf_ptr = NULL;
        }
        else
        {
            free_ctrl_buffer(control_block->peer_buf_ptr);
            peer_buf_ptr = NULL;
        }
        control_block->need_free_peer = KAL_FALSE;
    }

    phb_free_control_block(control_block);

    phb_send_ilm(MOD_L4C, msg_id, local_param_ptr, peer_buf_ptr);
}   /* end of phb_search_confirm */
/*****************************************************************************
 * FUNCTION
 *  phb_sat_file_change_handler
 * DESCRIPTION
 *  In current implementation, all related EF's will be rescanned.
 *  Hence, actually the file_change request will be forwarded to
 *  startup_handler().
 * PARAMETERS
 *  ilm_ptr             [IN]        The primitives
 *  control_block       [?]         
 * RETURNS
 *  void
 *****************************************************************************/
void phb_sat_file_change_handler(ilm_struct *ilm_ptr, control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_SAT_FILE_CHANGE);

    if (ilm_ptr != NULL)
    {
        kal_uint16 i;
        kal_bool need_reset_flag = KAL_FALSE;
        sat_file_change_ind_struct *sat_file_change_ind;

        sat_file_change_ind = (sat_file_change_ind_struct*) ilm_ptr->local_para_ptr;

      /**
       * Since sat_file_change is an implicit reset, there 2 ways to implement this:
       *
       * 1. Interrupts other being processed operations and forbids 
       *   other further requests to PHB, except approve and search:
       *   In this implementation, 
       *   startup handler should always uses the first control_block, 
       *   and lock all control_blocks are locked temporarily;
       *   thus prevent other operations, except approve and search, 
       *   from accessing PHB while it is busy.
       *
       * 2. Allow all other operations to provide maximum possible
       *   concurrency degrees.
       *
       * Curretly, solution 1 is implemented.
       * Control_blocks are all locked to interrupt all other in-processing
       * operations and reject all further requests, to prevent
       * multiple access to PHB when it is not ready.
       */
        /* LN not ready means phb haven't been inited yet */
        if (phb_ptr->state == PHB_STATE_LN_NOT_READY)
        {
        }
        else if (sat_file_change_ind->is_full_changed)
        {
            need_reset_flag = KAL_TRUE;
        }
        else
        {
            for (i = 0; i < sat_file_change_ind->num_of_file; i++)
            {
                switch (sat_file_change_ind->file_list[i])
                {
                    case FILE_ADN_IDX:
                    case FILE_ECC_IDX:
                    case FILE_EXT1_IDX:                       
                #ifdef __PHB_USIM_SUPPORT__
                       need_reset_flag = KAL_TRUE;
                       /* MUST: Break CAN'T BE REMOVED */
                       break;                   
                    case FILE_U_ECC_IDX:
                        
                    case FILE_G_ADN_IDX:
                    case FILE_U_ADN_IDX:
                        
                    case FILE_G_PBR_IDX:
                    case FILE_U_PBR_IDX:
                        
                    case FILE_G_EXT1_IDX:
                    case FILE_U_EXT1_IDX:
                        
                    case FILE_U_FDN_IDX:
                    case FILE_U_SDN_IDX:
                    case FILE_U_EXT2_IDX:
                    case FILE_U_EXT3_IDX:
                    case FILE_U_BDN_IDX:
                    case FILE_U_EXT4_IDX:
                    case FILE_U_MSISDN_IDX:
                    case FILE_U_EXT5_IDX:
                #ifdef __PHB_USIM_ADDITIONAL_SUPPORT__
                    case FILE_G_IAP_IDX:
                    case FILE_U_IAP_IDX:
                        
                    case FILE_G_ANR_IDX:
                    case FILE_U_ANR_IDX:
                        
                    case FILE_G_EMAIL_IDX:
                    case FILE_U_EMAIL_IDX:
                        
                    case FILE_G_SNE_IDX:
                    case FILE_U_SNE_IDX:
                        
                    case FILE_G_GAS_IDX:
                    case FILE_U_GAS_IDX:
                        
                    case FILE_G_AAS_IDX:
                    case FILE_U_AAS_IDX:
                        
                    case FILE_G_GRP_IDX:
                    case FILE_U_GRP_IDX:
                #endif /* __PHB_USIM_ADDITIONAL_SUPPORT__ */
                       ASSERT(is_usim_type(PHB_WHICH_SIM));
                #endif /* __PHB_USIM_SUPPORT__ */
                    case FILE_FDN_IDX:
                    case FILE_SDN_IDX:
                    case FILE_EXT2_IDX:
                    case FILE_EXT3_IDX:
                    case FILE_BDN_IDX:
                    case FILE_EXT4_IDX:
                    case FILE_MSISDN_IDX:
                        need_reset_flag = KAL_TRUE;
                        break;
                    default:
                        break;
                }
            }
        }
        if (need_reset_flag)
        {
            for (i = 0; i < PHB_CONCURRENCY_DEGREE; i++)
            {
                if (phb_ptr->control_block[i].is_allocated == KAL_TRUE)
                {
                    phb_ptr->control_block[i].err_handler(NULL, &(phb_ptr->control_block[i]));
                }
            }

            phb_reset_all_control_blocks();
            control_block = phb_alloc_control_block();
            
            ASSERT(control_block != NULL);

            control_block->src_id = sat_file_change_ind->src_id;
            /* Retain msg_id */
            control_block->cnf_msg_id = ilm_ptr->msg_id;

            phb_is_sim_file_support();
        }
        phb_ptr->dn_type = l4csmu_get_dial_mode();

        if (need_reset_flag == KAL_FALSE)
        {
            phb_sat_file_change_confirm(PHB_ERRNO_SUCCESS, sat_file_change_ind->src_id, NULL);
        }
        else if ((phb_ptr->state == PHB_STATE_READY) ||
                 (phb_ptr->state == PHB_STATE_NOT_READY_FDN_READY) || (phb_ptr->state == PHB_STATE_NOT_READY))
        {
         /** 
          * Assume data descriptor obtained from nvram_get_infor() and
          * sim_service_table_query() remains consistent, DO NOT reset it.
          * What needs to be reset is their free_count!
          */
            phb_data_desc_reset();
            
            phb_se_reset();

            /* Reset context */
            kal_mem_set(&phb_ptr->ecc, 0, sizeof(sim_ecc_struct));
            phb_ptr->state = PHB_STATE_NOT_READY;
        #ifdef __PHB_USIM_SUPPORT__
            phb_ptr->is_global = KAL_TRUE;
        #endif
            kal_trace(TRACE_STATE, STATE_PHB_NOT_READY);

            // TODO: need to be able to reload specific files
            /*  
             *  Since SIM file changed, need to reload file info, and MMI also need to reload
             *  send begin inication to MMI, MMI will clear it's variable and reload phonebook.
             */
            {
            #if !defined(__PHB_STORAGE_BY_MMI__)
                kal_uint16 phb_total, phb_size;

                if (nvram_get_info(NVRAM_EF_PHB_LID, &phb_total, &phb_size) == NVRAM_ERRNO_SUCCESS)
                {
                    phb_data_desc_set_is_support(DATA_DESC_PHB, KAL_TRUE);

                /*
                 * MAX_ENTRIES_COUNT must NOT be exceeded. See comment
                 * of phb_get_info_set_value() for detail.
                 */
                    if (phb_total > NVRAM_PHB_INDEX_MAX_ENTRIES_COUNT)
                    {
                        phb_total = NVRAM_PHB_INDEX_MAX_ENTRIES_COUNT;
                    }
                    phb_data_desc_set(DATA_DESC_PHB, phb_total, phb_size);
                }
                else
            #endif /* __PHB_STORAGE_BY_MMI__ */
                {
                    phb_data_desc_set_is_support(DATA_DESC_PHB, KAL_FALSE);
                }
            }
            /* phb_get_info() will return to startup_handler() */
            control_block->proc_stage = startup_none;

        #if defined(__GEMINI__) || defined(GEMINI_PLUS)
            l4csmu_get_chv_info_status(NULL, &chv_status[phb_current_mod - MOD_PHB]);
            phb_query_count[phb_current_mod - MOD_PHB] = 0;
        #else
            l4csmu_get_chv_info_status(NULL, &chv_status[0]);
            phb_query_count[0] = 0;
        #endif
        
            phb_send_ilm(MOD_L4C, MSG_ID_L4CPHB_STARTUP_BEGIN_IND, NULL, NULL);
            
            phb_get_info(ilm_ptr, control_block);
            
        }
        /* error */
        else
        {
            kal_trace(TRACE_ERROR, ERROR_PHB_STATE);

            phb_sat_file_change_confirm(PHB_ERRNO_FAIL, control_block->src_id, control_block);
            return;
        }

    }
    else
    {
        kal_trace(TRACE_ERROR, ERROR_PHB_STATE);

        control_block->cnf_msg_id = MSG_ID_SAT_FILE_CHANGE_IND;
        phb_sat_file_change_confirm(PHB_ERRNO_FAIL, control_block->src_id, control_block);
        return;
    }
}   /* end of phb_sat_file_change_handler function */