int Test_Resource(SaHpiSessionIdT session, SaHpiRptEntryT report, callback2_t func) { SaErrorT status; int retval = SAF_TEST_UNKNOWN; // If there exist in this implementation an instance of // a resource with Full Hot Swap Model, then this test should // be valid. if ((report.ResourceCapabilities & SAHPI_CAPABILITY_MANAGED_HOTSWAP) && (report.ResourceCapabilities & SAHPI_CAPABILITY_FRU)) { // // Call saHpiResourceInactiveSet passing in a bad ResourceId // status = saHpiResourceInactiveSet(session, BAD_RESOURCE_ID); if (status != SA_ERR_HPI_INVALID_RESOURCE) { e_print(saHpiResourceInactiveSet, SA_ERR_HPI_INVALID_RESOURCE, status); retval = SAF_TEST_FAIL; } else retval = SAF_TEST_PASS; } else { // Not a Hot Swap supported Resource retval = SAF_TEST_NOTSUPPORT; } if (retval == SAF_TEST_UNKNOWN) { } return (retval); }
int Inactivate(SaHpiSessionIdT session, SaHpiResourceIdT resource, int *returnvalue, SaHpiBoolT * restore) { SaErrorT status; if ((*returnvalue == SAF_TEST_UNKNOWN) || (*restore != SAHPI_FALSE)) { status = saHpiResourceInactiveSet(session, resource); if (*restore == SAHPI_FALSE) { if (status != SA_OK) { e_print(saHpiResourceInactiveSet, SA_OK, status); *returnvalue = SAF_TEST_UNRESOLVED; } } } return (*returnvalue); }
int main(int argc, char **argv) { int testfail = 0; SaErrorT err, expected_err; SaHpiHsIndicatorStateT hs_ind_state = SAHPI_HS_INDICATOR_OFF; SaHpiHsStateT hs_state = SAHPI_HS_STATE_INACTIVE; SaHpiHsActionT act = 0; SaHpiResourceIdT id = 0; SaHpiRptEntryT rptentry; SaHpiSessionIdT sessionid; SaHpiTimeoutT timeout = SAHPI_TIMEOUT_IMMEDIATE; /***************************************** * Find a resource with hotswap capability *****************************************/ err = tsetup(&sessionid); if (err != SA_OK) { printf("Error! Cannot open session\n"); printf(" File=%s, Line=%d\n", __FILE__, __LINE__); return -1; } err = tfind_resource(&sessionid, SAHPI_CAPABILITY_FRU, SAHPI_FIRST_ENTRY, &rptentry, SAHPI_TRUE); if (err != SA_OK) { dbg("Cannot find a hotswap resource\n"); dbg(" File=%s, Line=%d\n", __FILE__, __LINE__); err = tcleanup(&sessionid); return SA_OK; } id = rptentry.ResourceId; /****************************** * Test: Bad parameter checking ******************************/ expected_err = SA_ERR_HPI_INVALID_PARAMS; err = saHpiAutoInsertTimeoutGet(sessionid, NULL); checkstatus(err, expected_err, testfail); err = saHpiAutoInsertTimeoutSet(sessionid, -5); checkstatus(err, expected_err, testfail); err = saHpiAutoExtractTimeoutGet(sessionid, id, NULL); checkstatus(err, expected_err, testfail); err = saHpiAutoExtractTimeoutSet(sessionid, id, -5); checkstatus(err, expected_err, testfail); err = saHpiHotSwapStateGet(sessionid, id, NULL); checkstatus(err, expected_err, testfail); err = saHpiHotSwapActionRequest(sessionid, id, -1); checkstatus(err, expected_err, testfail); err = saHpiHotSwapIndicatorStateGet(sessionid, id, NULL); checkstatus(err, expected_err, testfail); err = saHpiHotSwapIndicatorStateSet(sessionid, id, -1); checkstatus(err, expected_err, testfail); /******************************* * Test: Invalid session checking *******************************/ expected_err = SA_ERR_HPI_INVALID_SESSION; err = saHpiHotSwapPolicyCancel(-1, id); checkstatus(err, expected_err, testfail); err = saHpiResourceActiveSet(-1, id); checkstatus(err, expected_err, testfail); err = saHpiResourceInactiveSet(-1, id); checkstatus(err, expected_err, testfail); err = saHpiAutoInsertTimeoutGet(-1, &timeout); checkstatus(err, expected_err, testfail); err = saHpiAutoInsertTimeoutSet(-1, timeout); checkstatus(err, expected_err, testfail); err = saHpiAutoExtractTimeoutGet(-1, id, &timeout); checkstatus(err, expected_err, testfail); err = saHpiAutoExtractTimeoutSet(-1, id, timeout); checkstatus(err, expected_err, testfail); err = saHpiHotSwapStateGet(-1, id, &hs_state); checkstatus(err, expected_err, testfail); err = saHpiHotSwapActionRequest(-1, id, act); checkstatus(err, expected_err, testfail); err = saHpiHotSwapIndicatorStateGet(-1, id, &hs_ind_state); checkstatus(err, expected_err, testfail); err = saHpiHotSwapIndicatorStateSet(-1, id, hs_ind_state); checkstatus(err, expected_err, testfail); /**************************** * Test: Invalid RID checking ****************************/ expected_err = SA_ERR_HPI_INVALID_RESOURCE; err = saHpiHotSwapPolicyCancel(sessionid, -1); checkstatus(err, expected_err, testfail); err = saHpiResourceActiveSet(sessionid, -1); checkstatus(err, expected_err, testfail); err = saHpiResourceInactiveSet(sessionid, -1); checkstatus(err, expected_err, testfail); err = saHpiAutoExtractTimeoutGet(sessionid, -1, &timeout); checkstatus(err, expected_err, testfail); err = saHpiAutoExtractTimeoutSet(sessionid, -1, timeout); checkstatus(err, expected_err, testfail); err = saHpiHotSwapStateGet(sessionid, -1, &hs_state); checkstatus(err, expected_err, testfail); err = saHpiHotSwapActionRequest(sessionid, -1, act); checkstatus(err, expected_err, testfail); err = saHpiHotSwapIndicatorStateGet(sessionid, -1, &hs_ind_state); checkstatus(err, expected_err, testfail); err = saHpiHotSwapIndicatorStateSet(sessionid, -1, hs_ind_state); checkstatus(err, expected_err, testfail); /************************* * Cleanup after all tests *************************/ err = tcleanup(&sessionid); return testfail; }
cOpenHpiDaemon::tResult cOpenHpiDaemon::HandleMsg( cConnection *c, const cMessageHeader &header, const void *data, cMessageHeader &rh, void *&rd ) { cHpiMarshal *hm = HpiMarshalFind( header.m_id ); // check for function and data length if ( !hm || hm->m_request_len < header.m_len ) { //MessageHeaderInit( &rh, eMhError, header.m_seq, 0, 0 ); //rd = 0; fprintf( stderr, "wrong message length: id %d !\n", header.m_id ); return eResultError; } assert( hm->m_reply_len ); // init reply header MessageHeaderInit( &rh, eMhReply, header.m_seq, header.m_id, hm->m_reply_len ); // alloc reply buffer rd = calloc( 1, hm->m_reply_len ); SaErrorT ret; switch( header.m_id ) { case eFsaHpiSessionOpen: { SaHpiDomainIdT domain_id; SaHpiSessionIdT session_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, (void *)&domain_id ); ret = saHpiSessionOpen( domain_id, &session_id, 0 ); DbgFunc( "saHpiSessionOpen( %x, %x ) = %d\n", domain_id, session_id, ret ); if ( ret == SA_OK ) c->AddSession( session_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &session_id ); } break; case eFsaHpiSessionClose: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiSessionClose( session_id ); DbgFunc( "saHpiSessionClose( %x ) = %d\n", session_id, ret ); if ( ret == SA_OK ) c->RemSession( session_id ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourcesDiscover: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiResourcesDiscover( session_id ); DbgFunc( "saHpiResourcesDiscover( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiRptInfoGet: { SaHpiSessionIdT session_id; SaHpiRptInfoT rpt_info; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiRptInfoGet( session_id, &rpt_info ); DbgFunc( "saHpiRptInfoGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &rpt_info ); } break; case eFsaHpiRptEntryGet: { SaHpiSessionIdT session_id; SaHpiEntryIdT entry_id; SaHpiEntryIdT next_entry_id; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &entry_id ); ret = saHpiRptEntryGet( session_id, entry_id, &next_entry_id, &rpt_entry ); DbgFunc( "saHpiRptEntryGet( %x, %x, %x ) = %d\n", session_id, entry_id, next_entry_id, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &next_entry_id, &rpt_entry ); } break; case eFsaHpiRptEntryGetByResourceId: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiRptEntryGetByResourceId( session_id, resource_id, &rpt_entry ); DbgFunc( "saHpiRptEntryGetByResourceId( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &rpt_entry ); } break; case eFsaHpiResourceSeveritySet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSeverityT severity; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &severity ); ret = saHpiResourceSeveritySet( session_id, resource_id, severity ); DbgFunc( "saHpiResourceSeveritySet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceTagSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTextBufferT resource_tag; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &resource_tag ); ret = saHpiResourceTagSet( session_id, resource_id, &resource_tag ); DbgFunc( "saHpiResourceTagSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceIdGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiResourceIdGet( session_id, &resource_id ); DbgFunc( "saHpiResourceIdGet( %x ) = %d, %x\n", session_id, ret, resource_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &resource_id ); } break; case eFsaHpiEntitySchemaGet: { SaHpiSessionIdT session_id; SaHpiUint32T schema_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiEntitySchemaGet( session_id, &schema_id ); DbgFunc( "saHpiEntitySchemaGet( %x ) = %d, %x\n", session_id, ret, schema_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &schema_id ); } break; case eFsaHpiEventLogInfoGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelInfoT info; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogInfoGet( session_id, resource_id, &info ); DbgFunc( "saHpiEventLogInfoGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &info ); } break; case eFsaHpiEventLogEntryGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryIdT entry_id; SaHpiSelEntryIdT prev_entry_id = 0; SaHpiSelEntryIdT next_entry_id = 0; SaHpiSelEntryT event_log_entry; SaHpiRdrT rdr; SaHpiRptEntryT rpt_entry; memset( &rdr, 0, sizeof( SaHpiRdrT ) ); memset( &rpt_entry, 0, sizeof( SaHpiRptEntryT ) ); HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiEventLogEntryGet( session_id, resource_id, entry_id, &prev_entry_id, &next_entry_id, &event_log_entry, &rdr, &rpt_entry ); DbgFunc( "saHpiEventLogEntryGet( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply5( hm, rd, &ret, &prev_entry_id, &next_entry_id, &event_log_entry, &rdr, &rpt_entry ); } break; case eFsaHpiEventLogEntryAdd: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryT evt_entry; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &evt_entry ); ret = saHpiEventLogEntryAdd( session_id, resource_id, &evt_entry ); DbgFunc( "saHpiEventLogEntryAdd( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogEntryDelete: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryIdT entry_id; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiEventLogEntryDelete( session_id, resource_id, entry_id ); DbgFunc( "saHpiEventLogEntryDelete( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogClear: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogClear( session_id, resource_id ); DbgFunc( "saHpiEventLogClear( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogTimeGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeT ti; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogTimeGet( session_id, resource_id, &ti ); DbgFunc( "saHpiEventLogTimeGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &ti ); } break; case eFsaHpiEventLogTimeSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeT ti; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id , &ti ); ret = saHpiEventLogTimeSet( session_id, resource_id, ti ); DbgFunc( "saHpiEventLogTimeSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiBoolT enable; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogStateGet( session_id, resource_id, &enable ); DbgFunc( "saHpiEventLogStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &enable ); } break; case eFsaHpiEventLogStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiBoolT enable; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &enable ); ret = saHpiEventLogStateSet( session_id, resource_id, enable ); DbgFunc( "saHpiEventLogStateSet( %x, %x, %s ) = %d\n", session_id, resource_id, enable ? "true" : "false", ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiSubscribe: { SaHpiSessionIdT session_id; SaHpiBoolT provide_active_alarms; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &provide_active_alarms ); ret = saHpiSubscribe( session_id, provide_active_alarms ); DbgFunc( "saHpiSubscribe( %x, %s ) = %d\n", session_id, provide_active_alarms ? "true" : "false", ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiUnsubscribe: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiUnsubscribe( session_id ); DbgFunc( "saHpiUnsubscribe( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventGet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; SaHpiEventT event; SaHpiRdrT rdr; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &timeout ); if ( timeout == 0 ) { ret = saHpiEventGet( session_id, timeout, &event, &rdr, &rpt_entry ); DbgFunc( "saHpiEventGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply3( hm, rd, &ret, &event, &rdr, &rpt_entry ); } else { cSession *s = c->FindSession( session_id ); if ( s && !s->IsEventGet() ) { s->EventGet( true ); SaHpiTimeT end; gettimeofday1( &end ); if ( timeout == SAHPI_TIMEOUT_BLOCK ) end += (SaHpiTimeT)10000*1000000000; //set a long time else end += timeout; s->Timeout() = end; s->Seq() = header.m_seq; DbgEvent( "saHpiEventGet( %x ): add to event listener.\n", s->SessionId() ); return eResultOk; } // error ret = SA_ERR_HPI_BUSY; rh.m_len = HpiMarshalReply3( hm, rd, &ret, &event, &rdr, &rpt_entry ); } } break; case eFsaHpiRdrGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEntryIdT entry_id; SaHpiEntryIdT next_entry_id; SaHpiRdrT rdr; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiRdrGet( session_id, resource_id, entry_id, &next_entry_id, &rdr ); DbgFunc( "saHpiRdrGet( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &next_entry_id, &rdr ); } break; case eFsaHpiSensorReadingGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorReadingT reading; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorReadingGet( session_id, resource_id, sensor_num, &reading ); DbgFunc( "saHpiSensorReadingGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &reading ); } break; case eFsaHpiSensorReadingConvert: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorReadingT reading_input; SaHpiSensorReadingT converted_reading; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &reading_input ); ret = saHpiSensorReadingConvert( session_id, resource_id, sensor_num, &reading_input, &converted_reading ); DbgFunc( "saHpiSensorReadingConvert( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &converted_reading ); } break; case eFsaHpiSensorThresholdsGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorThresholdsT sensor_thresholds; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorThresholdsGet( session_id, resource_id, sensor_num, &sensor_thresholds); DbgFunc( "saHpiSensorThresholdsGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &sensor_thresholds ); } break; case eFsaHpiSensorThresholdsSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorThresholdsT sensor_thresholds; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &sensor_thresholds ); ret = saHpiSensorThresholdsSet( session_id, resource_id, sensor_num, &sensor_thresholds ); DbgFunc( "saHpiSensorThresholdsSet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiSensorTypeGet: { SaHpiResourceIdT resource_id; SaHpiSessionIdT session_id; SaHpiSensorNumT sensor_num; SaHpiSensorTypeT type; SaHpiEventCategoryT category; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorTypeGet( session_id, resource_id, sensor_num, &type, &category ); DbgFunc( "saHpiSensorTypeGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &type, &category ); } break; case eFsaHpiSensorEventEnablesGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorEvtEnablesT enables; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorEventEnablesGet( session_id, resource_id, sensor_num, &enables ); DbgFunc( "saHpiSensorEventEnablesGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &enables ); } break; case eFsaHpiSensorEventEnablesSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorEvtEnablesT enables; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &enables ); ret = saHpiSensorEventEnablesSet( session_id, resource_id, sensor_num, &enables ); DbgFunc( "saHpiSensorEventEnablesSet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiControlTypeGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlTypeT type; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num ); ret = saHpiControlTypeGet( session_id, resource_id, ctrl_num, &type ); DbgFunc( "saHpiControlTypeGet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &type ); } break; case eFsaHpiControlStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlStateT ctrl_state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num ); ret = saHpiControlStateGet( session_id, resource_id, ctrl_num, &ctrl_state ); DbgFunc( "saHpiControlStateGet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &ctrl_state ); } break; case eFsaHpiControlStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlStateT ctrl_state; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num, &ctrl_state ); ret = saHpiControlStateSet( session_id, resource_id, ctrl_num, &ctrl_state ); DbgFunc( "saHpiControlStateSet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEntityInventoryDataRead: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEirIdT eir_id; SaHpiUint32T buffer_size; unsigned char *buffer = 0; SaHpiUint32T actual_size; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &eir_id, &buffer_size ); if ( buffer_size ) buffer = new unsigned char [buffer_size]; ret = saHpiEntityInventoryDataRead( session_id, resource_id, eir_id, buffer_size, (SaHpiInventoryDataT *)(void *)buffer, &actual_size ); DbgFunc( "saHpintityInventoryDataRead( %x, %x, %x, %d ) = %d\n", session_id, resource_id, eir_id, buffer_size, ret ); const cMarshalType *reply[4]; reply[0] = &SaErrorType; // SA_OK reply[1] = &SaHpiUint32Type; // actual size const void *params[3]; params[0] = &ret; params[1] = &actual_size; if ( ret != SA_OK || buffer == 0 ) reply[2] = 0; else { reply[2] = &SaHpiInventoryDataType, // inventory data reply[3] = 0; params[2] = buffer; } rh.m_len = MarshalArray( reply, params, rd ); if ( buffer ) delete [] buffer; } break; case eFsaHpiEntityInventoryDataWrite: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEirIdT eir_id; unsigned char buffer[10240]; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &eir_id, buffer ); ret = saHpiEntityInventoryDataWrite( session_id, resource_id, eir_id, (SaHpiInventoryDataT *)(void *)buffer ); DbgFunc( "saHpintityInventoryDataWrite( %x, %x, %x ) = %d\n", session_id, resource_id, eir_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiWatchdogTimerGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; SaHpiWatchdogT watchdog; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num ); ret = saHpiWatchdogTimerGet( session_id, resource_id, watchdog_num, &watchdog ); DbgFunc( "saHpiWatchdogTimerGet( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &watchdog ); } break; case eFsaHpiWatchdogTimerSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; SaHpiWatchdogT watchdog; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num, &watchdog ); ret = saHpiWatchdogTimerSet( session_id, resource_id, watchdog_num, &watchdog ); DbgFunc( "saHpiWatchdogTimerSet( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiWatchdogTimerReset: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num ); ret = saHpiWatchdogTimerReset( session_id, resource_id, watchdog_num ); DbgFunc( "eFsaHpiWatchdogTimerReset( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapControlRequest: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapControlRequest( session_id, resource_id ); DbgFunc( "saHpiHotSwapControlRequest( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceActiveSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceActiveSet( session_id, resource_id ); DbgFunc( "saHpiResourceActiveSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceInactiveSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceInactiveSet( session_id, resource_id ); DbgFunc( "saHpiResourceInactiveSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiAutoInsertTimeoutGet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiAutoInsertTimeoutGet( session_id, &timeout ); DbgFunc( "saHpiAutoInsertTimeoutGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &timeout ); } break; case eFsaHpiAutoInsertTimeoutSet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &timeout ); ret = saHpiAutoInsertTimeoutSet( session_id, timeout ); DbgFunc( "saHpiAutoInsertTimeoutSet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiAutoExtractTimeoutGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeoutT timeout; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiAutoExtractTimeoutGet( session_id, resource_id, &timeout ); DbgFunc( "saHpiAutoExtractTimeoutGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &timeout ); } break; case eFsaHpiAutoExtractTimeoutSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeoutT timeout; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &timeout ); ret = saHpiAutoExtractTimeoutSet( session_id, resource_id, timeout ); DbgFunc( "saHpiAutoExtractTimeoutSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiHotSwapStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiHotSwapActionRequest: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsActionT action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &action ); ret = saHpiHotSwapActionRequest( session_id, resource_id, action ); DbgFunc( "saHpiHotSwapActionRequest( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourcePowerStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsPowerStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourcePowerStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiResourcePowerStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiResourcePowerStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsPowerStateT state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &state ); ret = saHpiResourcePowerStateSet( session_id, resource_id, state ); DbgFunc( "(saHpiResourcePowerStateSet %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapIndicatorStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsIndicatorStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapIndicatorStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiHotSwapIndicatorStateGet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiHotSwapIndicatorStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsIndicatorStateT state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &state ); ret = saHpiHotSwapIndicatorStateSet( session_id, resource_id, state ); DbgFunc( "saHpiHotSwapIndicatorStateSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiParmControl: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiParmActionT action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &action ); ret = saHpiParmControl( session_id, resource_id, action ); DbgFunc( "saHpiParmControl( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceResetStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiResetActionT reset_action; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceResetStateGet( session_id, resource_id, &reset_action ); DbgFunc( "saHpiResourceResetStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &reset_action ); } break; case eFsaHpiResourceResetStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiResetActionT reset_action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &reset_action ); ret = saHpiResourceResetStateSet( session_id, resource_id, reset_action ); DbgFunc( "saHpiResourceResetStateSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; default: assert( 0 ); break; } assert( rh.m_len <= hm->m_reply_len ); return eResultReply; }
int main(int argc, char **argv) { /* ************************ * Local variables * ***********************/ int testfail = 0; SaErrorT err; SaErrorT expected_err; SaHpiRptEntryT rptentry; SaHpiResourceIdT id = 0; SaHpiSessionIdT sessionid; SaHpiResetActionT act = 0; SaHpiHsIndicatorStateT state = 0; /* ************************************* * Find a resource with *no* Power capability * ************************************* */ err = tsetup(&sessionid); if (err != SA_OK) { printf("Error! Can not open session for test environment\n"); printf(" File=%s, Line=%d\n", __FILE__, __LINE__); return -1; } err = tfind_resource(&sessionid, SAHPI_CAPABILITY_POWER, SAHPI_FIRST_ENTRY, &rptentry, SAHPI_FALSE); if (err != SA_OK) { trace("Can not find a Power resource for test environment\n"); trace(" File=%s, Line=%d\n", __FILE__, __LINE__); err = tcleanup(&sessionid); return SA_OK; } id = rptentry.ResourceId; /************************** * Test: Capability checking **************************/ expected_err = SA_ERR_HPI_CAPABILITY; err = saHpiHotSwapIndicatorStateGet(sessionid, id, &state); checkstatus(err, expected_err, testfail); /************************** * Test : Capability checking * expected_err = SA_ERR_HPI_CAPABILITY; **************************/ err = saHpiHotSwapIndicatorStateSet(sessionid, id, state); checkstatus(err, expected_err, testfail); /************************** * Test : Capability checking * expected_err = SA_ERR_HPI_CAPABILITY; **************************/ err = saHpiHotSwapActionRequest(sessionid, id, act); checkstatus(err, expected_err, testfail); /************************** * Test : Capability checking * expected_err = SA_ERR_HPI_CAPABILITY; **************************/ err = saHpiResourceInactiveSet(sessionid, id); checkstatus(err, expected_err, testfail); /* ************************************* * Find a resource with Power capability * ************************************* */ err = tfind_resource(&sessionid, SAHPI_CAPABILITY_POWER, SAHPI_FIRST_ENTRY, &rptentry, SAHPI_TRUE); if (err != SA_OK) { printf("Can not find a Power resource for test environment\n"); printf(" File=%s, Line=%d\n", __FILE__, __LINE__); err = tcleanup(&sessionid); return SA_OK; } id = rptentry.ResourceId; expected_err = SA_ERR_HPI_INVALID_REQUEST; /************************** * Test :Parameter checking * expected_err = SA_ERR_HPI_INVALID_REQUEST; **************************/ expected_err = SA_ERR_HPI_INVALID_PARAMS; err = saHpiHotSwapActionRequest(sessionid, id, -1); checkstatus(err, expected_err, testfail); /************************** * Test :Parameter checking * expected_err = SA_ERR_HPI_INVALID_REQUEST; **************************/ expected_err = SA_ERR_HPI_INVALID_PARAMS; err = saHpiHotSwapIndicatorStateSet(sessionid, id, -1); checkstatus(err, expected_err, testfail); /************************** * Test :Parameter checking * expected_err = SA_ERR_HPI_INVALID_REQUEST; **************************/ /* ************************************* * Find a resource with *no* Power capability * ************************************* */ err = tfind_resource(&sessionid, SAHPI_CAPABILITY_MANAGED_HOTSWAP, SAHPI_FIRST_ENTRY, &rptentry, SAHPI_TRUE); if (err != SA_OK) { trace("Can not find a ManagedHotSwap resource for test environment\n"); trace(" File=%s, Line=%d\n", __FILE__, __LINE__); err = tcleanup(&sessionid); return SA_OK; } id = rptentry.ResourceId; err = saHpiResourceInactiveSet(sessionid, id); checkstatus(err, expected_err, testfail); /*************************** * Cleanup after all tests ***************************/ err = tcleanup(&sessionid); return testfail; }