Exemplo n.º 1
0
Arquivo: dimm.c Projeto: ploetzma/occ
// Called after a failure to read a DIMM temperature.  The error will
// be counted and if threshold is reached, and error will be created with
// the DIMM as a callout and then set flag to trigger I2C reset
void mark_dimm_failed()
{
    const uint8_t port = G_dimm_sm_args.i2cPort;
    const uint8_t dimm = G_dimm_sm_args.dimm;
    INTR_TRAC_ERR("mark_dimm_failed: DIMM%04X failed in state/rc/count=0x%06X "
                  "(ffdc 0x%08X%08X, completion_state 0x%02X)",
                  DIMM_AND_PORT, (G_dimm_sm_args.state << 16) | (G_dimm_sm_args.error.rc << 8) | G_dimm[port][dimm].errorCount,
                  WORD_HIGH(G_dimm_sm_args.error.ffdc),
                  WORD_LOW(G_dimm_sm_args.error.ffdc),
                  G_dimm_sm_request.request.completion_state);

    if (++G_dimm[port][dimm].errorCount > MAX_CONSECUTIVE_DIMM_RESETS)
    {
        // Disable collection on this DIMM, collect FFDC and log error
        G_dimm[port][dimm].disabled = true;
        INTR_TRAC_ERR("mark_dimm_failed: disabling DIMM%04X due to %d consecutive errors (state=%d)",
                      DIMM_AND_PORT, G_dimm[port][dimm].errorCount, G_dimm_sm_args.state);
        errlHndl_t l_err = NULL;
        /*
         * @errortype
         * @moduleid    DIMM_MID_MARK_DIMM_FAILED
         * @reasoncode  DIMM_GPE_FAILURE
         * @userdata1   GPE returned rc code
         * @userdata4   ERC_DIMM_COMPLETE_FAILURE
         * @devdesc     Failure writing dimm i2c mode register
         */
        l_err = createErrl(DIMM_MID_MARK_DIMM_FAILED,
                           DIMM_GPE_FAILURE,
                           ERC_DIMM_COMPLETE_FAILURE,
                           ERRL_SEV_INFORMATIONAL,
                           NULL,
                           DEFAULT_TRACE_SIZE,
                           G_dimm_sm_args.error.rc,
                           0);
        addUsrDtlsToErrl(l_err,
                         (uint8_t*)&G_dimm_sm_request.ffdc,
                         sizeof(G_dimm_sm_request.ffdc),
                         ERRL_STRUCT_VERSION_1,
                         ERRL_USR_DTL_BINARY_DATA);
        addCalloutToErrl(l_err,
                         ERRL_CALLOUT_TYPE_HUID,
                         G_sysConfigData.dimm_huids[port][dimm],
                         ERRL_CALLOUT_PRIORITY_HIGH);
        commitErrl(&l_err);
    }

    // Reset DIMM I2C engine
    G_dimm_i2c_reset_required = true;
    G_dimm_i2c_reset_cause = port<<24 | dimm<<16 | (G_dimm_sm_args.error.rc & 0xFFFF);
    G_dimm_state = DIMM_STATE_RESET_MASTER;

} // end mark_dimm_failed()
Exemplo n.º 2
0
Arquivo: errlTest.c Projeto: deece/occ
// Function Specification
//
// Name: errlTestWordAlign
//
// Description: errlTestWordAlign
//
// End Function Specification
uint32_t errlTestWordAlign()
{
    uint32_t l_rc = 0;
    uint16_t l_entrySizeBefore = 0;
    uint16_t l_entrySizeAfter = 0;
    ERRL_DBG("START");

    do
    {
        /****************************************************/
        // Test word align for addUsrDtlsToErrl
        // Create log
        errlHndl_t l_handle = createErrl( TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, ERRL_SEV_PREDICTIVE, NULL, 0, 0x1, 0x2);
        CHECK_CONDITION( l_handle != INVALID_ERR_HNDL, l_rc);

        // l_handle will set to NULL after calling the commitErrl, so we need to store it
        errlHndl_t l_handleX = l_handle;
        ppdumpslot();

        // add 13 bytes of "user details"
        l_entrySizeBefore = l_handle->iv_userDetails.iv_entrySize;
        memset( G_data, 0xAA, sizeof( G_data ) );
        addUsrDtlsToErrl( l_handle, G_data, 13, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA );
        l_entrySizeAfter = l_handle->iv_userDetails.iv_entrySize;
        ERRL_DBG("Slots after create + 13 bytes" );
        ppdumpslot();
        // (header + WORDALIGN(13)) is the size that add to entry
        CHECK_CONDITION( l_entrySizeAfter == (l_entrySizeBefore+sizeof(ErrlUserDetailsEntry_t)+16), l_rc);

        /****************************************************/
        // Test word align for addTraceToErrl
        // add 21 bytes of trace
        l_entrySizeBefore = l_handle->iv_userDetails.iv_entrySize;
        addTraceToErrl(g_trac_inf, 21, l_handle); // @at012c
        l_entrySizeAfter = l_handle->iv_userDetails.iv_entrySize;
        ERRL_DBG("Slots after create + 21 bytes" );
        ppdumpslot();
        // (header + WORDALIGN(21)) is the size that add to entry
        CHECK_CONDITION( l_entrySizeAfter <= (l_entrySizeBefore+sizeof(ErrlUserDetailsEntry_t)+24), l_rc);

        commitErrl( &l_handle );
        deleteErrl(&l_handleX);
        ERRL_DBG("Slots should now be empty");
        ppdumpslot();
        ERRL_DBG("END \n");
    }while(0);

    return l_rc;
}
Exemplo n.º 3
0
void task_centaur_control( task_t * i_task )
{
    errlHndl_t            l_err     = NULL;    // Error handler
    int                   rc        = 0;       // Return code
    uint32_t              l_cent;
    amec_centaur_t        *l_cent_ptr = NULL;
    static uint8_t        L_scom_timeout[MAX_NUM_CENTAURS] = {0}; //track # of consecutive failures
    static bool           L_gpe_scheduled = FALSE;
    static uint8_t        L_gpe_fail_logged = 0;
    static bool           L_gpe_idle_traced = FALSE;
    static bool           L_gpe_had_1_tick = FALSE;

    // Pointer to the task data structure
    centaur_control_task_t * l_centControlTask =
            (centaur_control_task_t *) i_task->data_ptr;


    // Pointer to parameter field for GPE request
    GpeScomParms * l_parms =
          (GpeScomParms *)(l_centControlTask->gpe_req.parameter);

    do
    {
        l_cent = l_centControlTask->curCentaur;
        l_cent_ptr = &g_amec->proc[0].memctl[l_cent].centaur;

        //First, check to see if the previous GPE request still running
        //A request is considered idle if it is not attached to any of the
        //asynchronous request queues
        if( !(async_request_is_idle(&l_centControlTask->gpe_req.request)) )
        {
            L_scom_timeout[l_cent]++;
            //This can happen due to variability in when the task runs
            if(!L_gpe_idle_traced && L_gpe_had_1_tick)
            {
                TRAC_INFO("task_centaur_control: GPE is still running. cent[%d]", l_cent);
                l_centControlTask->traceThresholdFlags |= CENTAUR_CONTROL_GPE_STILL_RUNNING;
                L_gpe_idle_traced = TRUE;
            }
            L_gpe_had_1_tick = TRUE;
            break;
        }
        else
        {
            //Request is idle
            L_gpe_had_1_tick = FALSE;
            if(L_gpe_idle_traced)
            {
                TRAC_INFO("task_centaur_control: GPE completed. cent[%d]", l_cent);
                L_gpe_idle_traced = FALSE;
            }
        }

        //check scom status
        if(L_gpe_scheduled)
        {
            if(!async_request_completed(&l_centControlTask->gpe_req.request) || l_parms->rc)
            {
                if(!(L_gpe_fail_logged & (CENTAUR0_PRESENT_MASK >> l_cent)))
                {
                    // Check if the centaur has a channel checkstop. If it does,
                    // then do not log any errors. We also don't want to throttle
                    // a centaur that is in this condition.
                    if(!(cent_chan_checkstop(l_cent)))
                    {
                        L_gpe_fail_logged |= CENTAUR0_PRESENT_MASK >> l_cent;
                        TRAC_ERR("task_centaur_control: gpe_scom_centaur failed. l_cent=%d rc=%x, index=0x%08x", l_cent, l_parms->rc, l_parms->errorIndex);

                        /* @
                         * @errortype
                         * @moduleid    CENT_TASK_CONTROL_MOD
                         * @reasoncode  CENT_SCOM_ERROR
                         * @userdata1   rc - Return code of scom operation
                         * @userdata2   index of scom operation that failed
                         * @userdata4   OCC_NO_EXTENDED_RC
                         * @devdesc     OCC access to centaur failed
                         */
                        l_err = createErrl(
                                CENT_TASK_CONTROL_MOD,                  // modId
                                CENT_SCOM_ERROR,                        // reasoncode
                                OCC_NO_EXTENDED_RC,                     // Extended reason code
                                ERRL_SEV_PREDICTIVE,                    // Severity
                                NULL,                                   // Trace Buf
                                DEFAULT_TRACE_SIZE,                     // Trace Size
                                l_parms->rc,                            // userdata1
                                l_parms->errorIndex                     // userdata2
                                );

                        addUsrDtlsToErrl(l_err,                                  //io_err
                                (uint8_t *) &(l_centControlTask->gpe_req.ffdc),  //i_dataPtr,
                                sizeof(PoreFfdc),                                //i_size
                                ERRL_USR_DTL_STRUCT_VERSION_1,                   //version
                                ERRL_USR_DTL_BINARY_DATA);                       //type

                        //callout the centaur
                        addCalloutToErrl(l_err,
                                         ERRL_CALLOUT_TYPE_HUID,
                                         G_sysConfigData.centaur_huids[l_cent],
                                         ERRL_CALLOUT_PRIORITY_MED);

                        //callout the processor
                        addCalloutToErrl(l_err,
                                         ERRL_CALLOUT_TYPE_HUID,
                                         G_sysConfigData.proc_huid,
                                         ERRL_CALLOUT_PRIORITY_MED);

                        commitErrl(&l_err);
                    }
                }//if(l_gpe_fail_logged & (CENTAUR0_PRESENT_MASK >> l_cent))

                //Request failed. Keep count of failures and request a reset if we reach a
                //max retry count
                L_scom_timeout[l_cent]++;
                if(L_scom_timeout[l_cent] == CENTAUR_CONTROL_SCOM_TIMEOUT)
                {
                    break;
                }

            }//if(!async_request_completed(&l_centControlTask->gpe_req.request) || l_parms->rc)
            else
            {
                //request completed successfully.  reset the timeout.
                L_scom_timeout[l_cent] = 0;
            }
        }//if(L_gpe_scheduled)
Exemplo n.º 4
0
// Function Specification
//
// Name:  apss_initialize
//
// Description: Completes all APSS initialization including GPIOs, altitude and
//              mode
//
// End Function Specification
errlHndl_t apss_initialize()
{
    errlHndl_t l_err = NULL;
    PoreFlex request;

    // Setup the GPIO init structure to pass to the GPE program
    G_gpe_apss_initialize_gpio_args.error.error = 0;
    G_gpe_apss_initialize_gpio_args.error.ffdc = 0;
    G_gpe_apss_initialize_gpio_args.config0.direction
                                = G_gpio_config[0].direction;
    G_gpe_apss_initialize_gpio_args.config0.drive
                                = G_gpio_config[0].drive;
    G_gpe_apss_initialize_gpio_args.config0.interrupt
                                = G_gpio_config[0].interrupt;
    G_gpe_apss_initialize_gpio_args.config1.direction
                                = G_gpio_config[1].direction;
    G_gpe_apss_initialize_gpio_args.config1.drive = G_gpio_config[1].drive;
    G_gpe_apss_initialize_gpio_args.config1.interrupt
                                = G_gpio_config[1].interrupt;

    // Create/schedule GPE_apss_initialize_gpio and wait for it to complete (BLOCKING)
    TRAC_INFO("Creating request for GPE_apss_initialize_gpio");
    pore_flex_create(&request,                                  // request
                     &G_pore_gpe0_queue,                        // queue
                     (void*)GPE_apss_initialize_gpio,           // GPE entry_point
                     (uint32_t)&G_gpe_apss_initialize_gpio_args,// GPE argument_ptr
                     SSX_SECONDS(5),                            // timeout
                     NULL,                                      // callback
                     NULL,                                      // callback arg
                     ASYNC_REQUEST_BLOCKING);                   // options
    // Schedule the request to be executed
    pore_flex_schedule(&request);

    // Check for a timeout, will create the error log later
    // NOTE: As of 2013/07/16, simics will still fail here on a OCC reset

    if(ASYNC_REQUEST_STATE_TIMED_OUT == request.request.completion_state)
    {
        // For whatever reason, we hit a timeout.  It could be either
        // that the HW did not work, or the request didn't ever make
        // it to the front of the queue.
        // Let's log an error, and include the FFDC data if it was
        // generated.
        TRAC_ERR("Timeout communicating with PORE-GPE for APSS Init");
    }

    TRAC_INFO("GPE_apss_initialize_gpio completed w/rc=0x%08x\n",
              request.request.completion_state);

    // Only continue if completed without errors...
    if (ASYNC_REQUEST_STATE_COMPLETE == request.request.completion_state)
    {
        // Setup the composite mode structure to pass to the GPE program
        G_gpe_apss_set_composite_mode_args.error.error = 0;
        G_gpe_apss_set_composite_mode_args.error.ffdc = 0;
        G_gpe_apss_set_composite_mode_args.config.numAdcChannelsToRead =
                        G_apss_composite_config.numAdcChannelsToRead;
        G_gpe_apss_set_composite_mode_args.config.numGpioPortsToRead =
                        G_apss_composite_config.numGpioPortsToRead;

        // Create/schedule GPE_apss_set_composite_mode and wait for it to complete (BLOCKING)
        TRAC_INFO("Creating request for GPE_apss_set_composite_mode");
        pore_flex_create(&request,                                    // request
                         &G_pore_gpe0_queue,                          // queue
                         (void*)GPE_apss_set_composite_mode,          // GPE entry_point
                         (uint32_t)&G_gpe_apss_set_composite_mode_args,// GPE argument_ptr
                         SSX_SECONDS(5),                              // timeout
                         NULL,                                        // callback
                         NULL,                                        // callback arg
                         ASYNC_REQUEST_BLOCKING);                     // options
        pore_flex_schedule(&request);

        // Check for a timeout, will create the error log later
        if(ASYNC_REQUEST_STATE_TIMED_OUT == request.request.completion_state)
        {
            // For whatever reason, we hit a timeout.  It could be either
            // that the HW did not work, or the request didn't ever make
            // it to the front of the queue.
            // Let's log an error, and include the FFDC data if it was
            // generated.
            TRAC_ERR("Timeout communicating with PORE-GPE for APSS Init");
        }

        TRAC_INFO("GPE_apss_set_composite_mode completed w/rc=0x%08x",
                  request.request.completion_state);

        if (ASYNC_REQUEST_STATE_COMPLETE != request.request.completion_state)
        {
            /*
             * @errortype
             * @moduleid    PSS_MID_APSS_INIT
             * @reasoncode  INTERNAL_FAILURE
             * @userdata1   GPE returned rc code
             * @userdata2   GPE returned abort code
             * @userdata4   ERC_PSS_COMPOSITE_MODE_FAIL
             * @devdesc     Failure from GPE for setting composite mode on
             *              APSS
             */
            l_err = createErrl(PSS_MID_APSS_INIT,               // i_modId,
                               INTERNAL_FAILURE,                // i_reasonCode,
                               ERC_PSS_COMPOSITE_MODE_FAIL,     // extended reason code
                               ERRL_SEV_UNRECOVERABLE,          // i_severity
                               NULL,                            // i_trace,
                               0x0000,                          // i_traceSz,
                               request.request.completion_state,       // i_userData1,
                               request.request.abort_state);           // i_userData2
            addUsrDtlsToErrl(l_err,
                             (uint8_t*)&G_gpe_apss_set_composite_mode_args,
                             sizeof(G_gpe_apss_set_composite_mode_args),
                             ERRL_STRUCT_VERSION_1,
                             ERRL_USR_DTL_TRACE_DATA);

            // Returning an error log will cause us to go to safe
            // state so we can report error to FSP
        }


        TRAC_INFO("apss_initialize: Creating request G_meas_start_request.");
        //Create the request for measure start. Scheduling will happen in apss.c
        pore_flex_create(&G_meas_start_request,
                         &G_pore_gpe0_queue,                          // queue
                         (void*)GPE_apss_start_pwr_meas_read,         // entry_point
                         (uint32_t)&G_gpe_start_pwr_meas_read_args,   // entry_point arg
                         SSX_WAIT_FOREVER,                            // no timeout
                         NULL,                                        // callback
                         NULL,                                        // callback arg
                         ASYNC_CALLBACK_IMMEDIATE);                   // options

        TRAC_INFO("apss_initialize: Creating request G_meas_cont_request.");
        //Create the request for measure continue. Scheduling will happen in apss.c
        pore_flex_create(&G_meas_cont_request,
                         &G_pore_gpe0_queue,                          // request
                         (void*)GPE_apss_continue_pwr_meas_read,      // entry_point
                         (uint32_t)&G_gpe_continue_pwr_meas_read_args, // entry_point arg
                         SSX_WAIT_FOREVER,                            // no timeout
                         NULL,                                        // callback
                         NULL,                                        // callback arg
                         ASYNC_CALLBACK_IMMEDIATE);                   // options

        TRAC_INFO("apss_initialize: Creating request G_meas_complete_request.");
        //Create the request for measure complete. Scheduling will happen in apss.c
        pore_flex_create(&G_meas_complete_request,
                         &G_pore_gpe0_queue,                          // queue
                         (void*)GPE_apss_complete_pwr_meas_read,      // entry_point
                         (uint32_t)&G_gpe_complete_pwr_meas_read_args,// entry_point arg
                         SSX_WAIT_FOREVER,                            // no timeout
                         (AsyncRequestCallback)reformat_meas_data,    // callback,
                         (void*)NULL,                                 // callback arg
                         ASYNC_CALLBACK_IMMEDIATE);                   // options

    }
    else
    {
        /*
         * @errortype
         * @moduleid    PSS_MID_APSS_INIT
         * @reasoncode  INTERNAL_FAILURE
         * @userdata1   GPE returned rc code
         * @userdata2   GPE returned abort code
         * @userdata4   ERC_PSS_GPIO_INIT_FAIL
         * @devdesc     Failure from GPE for gpio initialization on APSS
         */
        l_err = createErrl(PSS_MID_APSS_INIT,           // i_modId,
                           INTERNAL_FAILURE,            // i_reasonCode,
                           ERC_PSS_GPIO_INIT_FAIL,      // extended reason code
                           ERRL_SEV_UNRECOVERABLE,      // i_severity
                           NULL,                        // tracDesc_t i_trace,
                           0x0000,                      // i_traceSz,
                           request.request.completion_state,   // i_userData1,
                           request.request.abort_state);       // i_userData2
        addUsrDtlsToErrl(l_err,
                         (uint8_t*)&G_gpe_apss_initialize_gpio_args,
                         sizeof(G_gpe_apss_initialize_gpio_args),
                         ERRL_STRUCT_VERSION_1,
                         ERRL_USR_DTL_TRACE_DATA);

        // Returning an error log will cause us to go to safe
        // state so we can report error to FSP
    }

    return l_err;
}
Exemplo n.º 5
0
// Verifies that each core is at the correct frequency after they have had
// time to stabilize
void amec_verify_pstate()
{
    uint8_t                             l_core = 0;
    int8_t                              l_pstate_from_fmax = 0;
    gpe_bulk_core_data_t *              l_core_data_ptr;
    pmc_pmsr_ffcdc_data_t               l_pmc_pmsr_ffdc;
    errlHndl_t                          l_err = NULL;

    if ( (G_time_until_freq_check == 0) &&
            ( CURRENT_MODE() != OCC_MODE_DYN_POWER_SAVE ) &&
            ( CURRENT_MODE() != OCC_MODE_DYN_POWER_SAVE_FP ) &&
            (!G_sysConfigData.system_type.kvm))
    {
        // Reset the counter
        G_time_until_freq_check = FREQ_CHG_CHECK_TIME;

        // Convert fmax to the corresponding pstate
        l_pstate_from_fmax = proc_freq2pstate(g_amec->sys.fmax);

        for( l_core = 0; l_core < MAX_NUM_CORES; l_core++ )
        {
            // If the core isn't present, skip it
            if(!CORE_PRESENT(l_core))
            {
                l_pmc_pmsr_ffdc.pmsr_ffdc_data.data[l_core].value = 0;
                continue;
            }

            // Get pointer to core data
            l_core_data_ptr = proc_get_bulk_core_data_ptr(l_core);

            // Get the core's pmsr data
            l_pmc_pmsr_ffdc.pmsr_ffdc_data.data[l_core] = l_core_data_ptr->pcb_slave.pmsr;

            // Verify that the core is running at the correct frequency
            // If not, log an error
            if( (l_pstate_from_fmax != l_pmc_pmsr_ffdc.pmsr_ffdc_data.data[l_core].fields.local_pstate_actual) &&
                (l_pstate_from_fmax > l_pmc_pmsr_ffdc.pmsr_ffdc_data.data[l_core].fields.pv_min) &&
                (l_err == NULL) )
            {
                TRAC_ERR("Frequency mismatch in core %d: actual_ps[%d] req_ps[%d] fmax[%d] mode[%d].",
                    l_core,
                    l_pmc_pmsr_ffdc.pmsr_ffdc_data.data[l_core].fields.local_pstate_actual,
                    l_pstate_from_fmax,
                    g_amec->sys.fmax,
                    CURRENT_MODE());

                fill_pmc_ffdc_buffer(&l_pmc_pmsr_ffdc.pmc_ffcdc_data);

                /* @
                 * @moduleid   AMEC_VERIFY_FREQ_MID
                 * @reasonCode TARGET_FREQ_FAILURE
                 * @severity   ERRL_SEV_PREDICTIVE
                 * @userdata1  0
                 * @userdata2  0
                 * @userdata4  OCC_NO_EXTENDED_RC
                 * @devdesc    A core is not running at the expected frequency
                 */
                l_err = createErrl( AMEC_VERIFY_FREQ_MID,      // i_modId,
                                    TARGET_FREQ_FAILURE,       // i_reasonCode,
                                    OCC_NO_EXTENDED_RC,
                                    ERRL_SEV_UNRECOVERABLE,
                                    NULL,                      // i_trace,
                                    DEFAULT_TRACE_SIZE,        // i_traceSz,
                                    0,                         // i_userData1,
                                    0);                        // i_userData2

                //Add firmware callout
                addCalloutToErrl(l_err,
                        ERRL_CALLOUT_TYPE_COMPONENT_ID,
                        ERRL_COMPONENT_ID_FIRMWARE,
                        ERRL_CALLOUT_PRIORITY_HIGH);

                //Add processor callout
                addCalloutToErrl(l_err,
                        ERRL_CALLOUT_TYPE_HUID,
                        G_sysConfigData.proc_huid,
                        ERRL_CALLOUT_PRIORITY_MED);
            }
        }

        if( l_err != NULL)
        {
            //Add our register dump to the error log
            addUsrDtlsToErrl(l_err,
                    (uint8_t*) &l_pmc_pmsr_ffdc,
                    sizeof(l_pmc_pmsr_ffdc),
                    ERRL_USR_DTL_STRUCT_VERSION_1,
                    ERRL_USR_DTL_BINARY_DATA);

            REQUEST_RESET(l_err);
        }
    }
}
Exemplo n.º 6
0
Arquivo: errlTest.c Projeto: deece/occ
// Function Specification
//
// Name: errlTestCreateMaxLogs
//
// Description: errlTestCreateMaxLogs
//
// End Function Specification
uint32_t errlTestCreateMaxLogs()
{
    uint32_t l_rc = 0;

    ERRL_DBG("START");
    do
    {

        /****************************************************/
        // Check max logs
        ERRL_SEVERITY l_sev = 0;
        errlHndl_t l_backupHandle[ERRL_MAX_SLOTS-2];
        errlHndl_t l_handle = NULL;

        uint32_t l_index = 0;
        // Create 7 ERRL_SEV_PREDICTIVE or ERRL_SEV_UNRECOVERABLE slots randomly
        for(l_index =0; l_index < ERRL_MAX_SLOTS-2; l_index++)
        {

            uint64_t l_time = ssx_timebase_get();
            l_sev = l_time%2 ? ERRL_SEV_PREDICTIVE : ERRL_SEV_UNRECOVERABLE;
            l_handle = createErrl( TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, l_sev, g_trac_inf, 512, 0x1, l_index);
            CHECK_CONDITION( (l_handle != INVALID_ERR_HNDL) &&
                             (l_handle != NULL), l_rc);

            // backup handle
            l_backupHandle[l_index] = l_handle;

            ERRL_DBG("Log Created @ %p with Sev: %d\n",l_handle, l_sev );
            // addUsrDtlsToErrl
            memset( G_data, l_index, sizeof( G_data ) );
            addUsrDtlsToErrl( l_handle, G_data, sizeof(G_data), ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA );

            // commitErrl( &l_handle );
        }
        // check if something wrong in for loop
        if(l_rc != 0)
            break;

        // Create one more and it should fail
        l_handle = createErrl( TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, l_sev, g_trac_inf, 512, 0x1, l_index);
        CHECK_CONDITION( l_handle == INVALID_ERR_HNDL, l_rc);

        // delete errl
        for(l_index = 0; l_index < ERRL_MAX_SLOTS-2; l_index++)
        {
            deleteErrl(&l_backupHandle[l_index]);
        }
        ppdumpslot();

        /****************************************************/
        // Check log id overflow
         for(l_index = 0; l_index < 256; l_index++)
        {
            l_handle = createErrl( TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, l_sev, g_trac_inf, 512, 0x1, l_index);
            CHECK_CONDITION( (l_handle != INVALID_ERR_HNDL) &&
                             (l_handle != NULL), l_rc);

            deleteErrl(&l_handle);
        }

        ERRL_DBG("END \n");
    }while(0);

    return l_rc;
}
Exemplo n.º 7
0
Arquivo: errlTest.c Projeto: deece/occ
// Function Specification
//
// Name: errlTestAddUsrDtlsToErrl
//
// Description: errlTestAddUsrDtlsToErrl
//
// End Function Specification
uint32_t errlTestAddUsrDtlsToErrl()
{
    uint32_t l_rc = 0;
    ERRL_DBG("START");
    uint16_t l_entrySizeBefore = 0;
    uint16_t l_entrySizeAfter = 0;

    do
    {
        // Create three err logs
        errlHndl_t l_handle = NULL;
        errlHndl_t l_handle2 = NULL;
        errlHndl_t l_handle3 = NULL;

        l_handle = createErrl( TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, ERRL_SEV_UNRECOVERABLE, NULL, 512, 0x1, 0x2);
        l_handle2 = createErrl( TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, ERRL_SEV_CALLHOME_DATA, NULL, 512, 0x1, 0x2);
        l_handle3 = createErrl( TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, ERRL_SEV_INFORMATIONAL, NULL, 512, 0x1, 0x2);

        // l_handle will set to NULL after calling the commitErrl, so we need to store it
        errlHndl_t l_handleX = l_handle;
        errlHndl_t l_handle2X = l_handle2;
        errlHndl_t l_handle3X = l_handle3;
        ERRL_DBG("Slots after Create - 3 slots should be used (one of each");
        ppdumpslot();

        CHECK_CONDITION( (l_handle != INVALID_ERR_HNDL) &&
                         (l_handle2 != INVALID_ERR_HNDL) &&
                         (l_handle3 != INVALID_ERR_HNDL), l_rc);

        /****************************************************/
        // Test size limit for addUsrDtlsToErrl
        // Add "user details" data that exceeds the max size for l_handle
        l_entrySizeBefore = l_handle->iv_userDetails.iv_entrySize;
        memset( G_data, 0xCC, sizeof( G_data ) );
        addUsrDtlsToErrl( l_handle, G_data, sizeof( G_data ), ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA );
        l_entrySizeAfter = l_handle->iv_userDetails.iv_entrySize;
        CHECK_CONDITION( l_entrySizeAfter == MAX_ERRL_ENTRY_SZ, l_rc);

        // Add "user details" data that exceeds the max size for l_handle2
        l_entrySizeBefore = l_handle2->iv_userDetails.iv_entrySize;
        memset( G_data, 0xDD, sizeof( G_data ) );
        addUsrDtlsToErrl( l_handle2, G_data, sizeof( G_data ), ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_CALLHOME_DATA );
        l_entrySizeAfter = l_handle2->iv_userDetails.iv_entrySize;
        CHECK_CONDITION( l_entrySizeAfter == MAX_ERRL_CALL_HOME_SZ, l_rc);

        // Add "user details" with size 76 for l_handle3
        l_entrySizeBefore = l_handle3->iv_userDetails.iv_entrySize;
        memset( G_data, 0xEE, sizeof( G_data ) );
        addUsrDtlsToErrl( l_handle3, G_data, 76, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA );
        l_entrySizeAfter = l_handle3->iv_userDetails.iv_entrySize;
        // (header + 76) is the size that add to entry
        CHECK_CONDITION( l_entrySizeAfter == (l_entrySizeBefore+sizeof(ErrlUserDetailsEntry_t)+76), l_rc);

        dumpLog( l_handle, l_handle->iv_userDetails.iv_entrySize );
        dumpLog( l_handle2, l_handle2->iv_userDetails.iv_entrySize );
        dumpLog( l_handle3, l_handle3->iv_userDetails.iv_entrySize );

        commitErrl( &l_handle );
        commitErrl( &l_handle2 );
        commitErrl( &l_handle3 );
        ERRL_DBG("Slots after Commit -  3 slots should be used/committed");
        ppdumpslot();

        deleteErrl(&l_handleX);
        deleteErrl(&l_handle2X);
        deleteErrl(&l_handle3X);
        CHECK_CONDITION( (l_handleX == NULL) &&
                         (l_handle2X == NULL) &&
                         (l_handle3X == NULL), l_rc);

        ERRL_DBG("Slots after delete Log - All slots should be empty");
        ppdumpslot();

        /****************************************************/
        // Test size limit for addUsrDtlsToErrl with continuous calls
        // Create log with 512 bytes trace
        l_handle = createErrl( TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, ERRL_SEV_PREDICTIVE, g_trac_inf, 512, 0x1, 0x2);
        CHECK_CONDITION( l_handle != INVALID_ERR_HNDL, l_rc);

        // l_handle will set to NULL after calling the commitErrl, so we need to store it
        l_handleX = l_handle;
        ppdumpslot();

        // add 256 bytes of "user details" (512+256)
        l_entrySizeBefore = l_handle->iv_userDetails.iv_entrySize;
        memset( G_data, 0xAA, sizeof( G_data ) );
        addUsrDtlsToErrl( l_handle, G_data, 256, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA );
        l_entrySizeAfter = l_handle->iv_userDetails.iv_entrySize;
        ERRL_DBG("Slots after create + 256 bytes" );
        ppdumpslot();
        // (header + 256) is the size that add to entry
        CHECK_CONDITION( l_entrySizeAfter == (l_entrySizeBefore+sizeof(ErrlUserDetailsEntry_t)+256), l_rc);

        // add 512 bytes of "user details" (512+256+512)
        l_entrySizeBefore = l_handle->iv_userDetails.iv_entrySize;
        memset( G_data, 0xBB, sizeof( G_data ) );
        addUsrDtlsToErrl( l_handle, G_data, 512, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA );
        l_entrySizeAfter = l_handle->iv_userDetails.iv_entrySize;
        ERRL_DBG("Slots after create + 256 + 512 bytes");
        ppdumpslot();
        // (header + 512) is the size that add to entry
        CHECK_CONDITION( l_entrySizeAfter == (l_entrySizeBefore+sizeof(ErrlUserDetailsEntry_t)+512), l_rc);

        // add 1024 bytes of "user details" (512+256+512+1024), the entry size is more than 2048 now
        l_entrySizeBefore = l_handle->iv_userDetails.iv_entrySize;
        memset( G_data, 0xCC, sizeof( G_data ) );
        addUsrDtlsToErrl( l_handle, G_data, 1024, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA );
        l_entrySizeAfter = l_handle->iv_userDetails.iv_entrySize;
        ERRL_DBG("Slots after create + 256 + 512 +1024 bytes");
        ppdumpslot();
        // (header + 1024) is the size that add to entry
        CHECK_CONDITION( l_entrySizeAfter <= MAX_ERRL_ENTRY_SZ, l_rc); // @at012c

        commitErrl( &l_handle );
        deleteErrl(&l_handleX);
        ERRL_DBG("Slots should now be empty");
        ppdumpslot();
        ERRL_DBG("END \n");
    }while(0);

    return l_rc;
}
Exemplo n.º 8
0
Arquivo: errlTest.c Projeto: deece/occ
// Function Specification
//
// Name: errlTestErrorHandling
//
// Description: errlTestErrorHandling
//
// End Function Specification
uint32_t errlTestErrorHandling()
{
    uint32_t l_rc = 0;
    errlHndl_t l_errlHnd = NULL;
    uint8_t l_dataPtr[10];
    uint16_t l_entrySizeBefore = 0;
    uint16_t l_entrySizeAfter = 0;

    ERRL_DBG(" START");
    do
    {
        /****************************************************/
        // Test createErrl  with incorrect parameter
        // Set ERRL_SEVERITY to 0x04, out of range so log won't be created
        l_errlHnd = createErrl(TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, 0x04, NULL, 0, 0x01, 0x02);
        CHECK_CONDITION( l_errlHnd == INVALID_ERR_HNDL, l_rc);

         /****************************************************/
        // Test addTraceToErrl  with incorrect parameter
        // Create a log
        l_errlHnd = createErrl(TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, ERRL_SEV_PREDICTIVE, NULL, 0, 0x01, 0x02);
        CHECK_CONDITION( l_errlHnd != INVALID_ERR_HNDL, l_rc);

        // i_trace = NULL, so entry size doesn't change
        l_entrySizeBefore = l_errlHnd->iv_userDetails.iv_entrySize;
        addTraceToErrl(NULL, 5, l_errlHnd);
        l_entrySizeAfter = l_errlHnd->iv_userDetails.iv_entrySize;
        CHECK_CONDITION(l_entrySizeBefore == l_entrySizeAfter, l_rc);

        // i_traceSz = 0, entry size doesn't change
        l_entrySizeBefore = l_errlHnd->iv_userDetails.iv_entrySize;
        addTraceToErrl(g_trac_inf, 0, l_errlHnd); // @at012c
        l_entrySizeAfter = l_errlHnd->iv_userDetails.iv_entrySize;
        CHECK_CONDITION( l_entrySizeBefore == l_entrySizeAfter, l_rc);

        // io_err = NULL, entry size doesn't change
        l_entrySizeBefore = l_errlHnd->iv_userDetails.iv_entrySize;
        addTraceToErrl(g_trac_inf, 32, NULL); // @at012c
        l_entrySizeAfter = l_errlHnd->iv_userDetails.iv_entrySize;
        CHECK_CONDITION( l_entrySizeBefore == l_entrySizeAfter, l_rc);

        // test addTraceToErrl after log is comitted so entry size doesn't change
        errlHndl_t l_errlHndx = l_errlHnd;
        commitErrl(&l_errlHnd);
        l_entrySizeBefore = l_errlHndx->iv_userDetails.iv_entrySize;
        addTraceToErrl(g_trac_inf, 32, l_errlHndx); // @at012c
        l_entrySizeAfter = l_errlHndx->iv_userDetails.iv_entrySize;
        CHECK_CONDITION( l_entrySizeBefore == l_entrySizeAfter, l_rc);

        deleteErrl(&l_errlHndx);
        CHECK_CONDITION( l_errlHndx == NULL, l_rc);

        // io_err = INVALID_ERR_HNDL
        // We are making sure that this function
        // handles a INVALID_ERR_HNDL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        l_errlHnd = INVALID_ERR_HNDL;
        addTraceToErrl(g_trac_inf, 32, l_errlHnd);

        /****************************************************/
        // Test commitErrl with incorrect parameter
        // io_err = NULL
        // We are making sure that this function
        // handles a NULL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        commitErrl( NULL);

        // l_errlHnd should be set to NULL
        l_errlHnd = INVALID_ERR_HNDL;
        commitErrl(&l_errlHnd);
        CHECK_CONDITION( l_errlHnd == NULL, l_rc);

        /****************************************************/
        // Test deleteErrl with incorrect parameter
        // io_err = NULL
        // We are making sure that this function
        // handles a NULL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        deleteErrl( NULL);

        // l_errlHnd should be set to NULL
        l_errlHnd = INVALID_ERR_HNDL;
        deleteErrl(&l_errlHnd);
        CHECK_CONDITION( l_errlHnd == NULL, l_rc);

        /****************************************************/
        // Test addCalloutToErrl with incorrect parameter
        // Set io_err to NULL
        // We are making sure that this function
        // handles a NULL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        addCalloutToErrl(NULL, ERRL_CALLOUT_TYPE_HUID, 0, ERRL_CALLOUT_PRIORITY_LOW);

        // Set io_err to INVALID_ERR_HNDL
        // We are making sure that this function
        // handles a INVALID_ERR_HNDL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        addCalloutToErrl(INVALID_ERR_HNDL, ERRL_CALLOUT_TYPE_HUID, 0, ERRL_CALLOUT_PRIORITY_LOW);

        /****************************************************/
        // Test addUsrDtlsToErrl with incorrect parameter
        // Create a log
        l_errlHnd = createErrl(TEST_MODULE_ID, 0x08, OCC_NO_EXTENDED_RC, ERRL_SEV_PREDICTIVE, NULL, 0, 0x01, 0x02);
        CHECK_CONDITION( l_errlHnd != INVALID_ERR_HNDL, l_rc);

        // io_err = NULL
        // We are making sure that this function
        // handles a NULL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        addUsrDtlsToErrl(NULL, l_dataPtr, 10, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA);

        // io_err = INVALID_ERR_HNDL
        // We are making sure that this function
        // handles a INVALID_ERR_HNDL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        addUsrDtlsToErrl(INVALID_ERR_HNDL, l_dataPtr, 10, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA);

        // i_dataPtr = NULL so entry size doesn't change
        l_entrySizeBefore = l_errlHnd->iv_userDetails.iv_entrySize;
        addUsrDtlsToErrl(l_errlHnd, NULL, 10, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA);
        l_entrySizeAfter = l_errlHnd->iv_userDetails.iv_entrySize;
        CHECK_CONDITION( l_entrySizeBefore == l_entrySizeAfter, l_rc);

        // i_size = 0 so so entry size doesn't change
        l_entrySizeBefore = l_errlHnd->iv_userDetails.iv_entrySize;
        addUsrDtlsToErrl(l_errlHnd, l_dataPtr, 0, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA);
        l_entrySizeAfter = l_errlHnd->iv_userDetails.iv_entrySize;
        CHECK_CONDITION( l_entrySizeBefore == l_entrySizeAfter, l_rc);

        // test addUsrDtlsToErrl after log is committed so entry size doesn't change
        l_errlHndx = l_errlHnd;
        commitErrl(&l_errlHnd);
        l_entrySizeBefore = l_errlHndx->iv_userDetails.iv_entrySize;
        addUsrDtlsToErrl(l_errlHndx, l_dataPtr, 10, ERRL_USR_DTL_STRUCT_VERSION_1, ERRL_USR_DTL_TRACE_DATA);
        l_entrySizeAfter = l_errlHndx->iv_userDetails.iv_entrySize;
        CHECK_CONDITION( l_entrySizeBefore == l_entrySizeAfter, l_rc);

        deleteErrl(&l_errlHndx);
        CHECK_CONDITION( l_errlHndx == NULL, l_rc);

        /****************************************************/
        // Test setErrlSevToInfo  with incorrect parameter
        // Set io_err to NULL.
        // We are making sure that this function
        // handles a NULL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        setErrlSevToInfo(NULL);

        // Set io_err to INVALID_ERR_HNDL
        // We are making sure that this function
        // handles a INVALID_ERR_HNDL being passed, and that we can't verify if
        // an error occurred by checking anything. (It will just cause
        // a TLB exception)
        setErrlSevToInfo(INVALID_ERR_HNDL);
    }while(0);

    return l_rc;
}