int processWatchdogRdr(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiRdrT * rdr, SaHpiWatchdogRecT * watchdogRec) { SaErrorT status; int retval; SaHpiWatchdogT wd_old; SaHpiWatchdogT watchdog; SaHpiWatchdogNumT wd_num = watchdogRec->WatchdogNum; status = saHpiWatchdogTimerGet(sessionId, resourceId, wd_num, &wd_old); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiWatchdogTimerGet, SA_OK, status); } else { initSmsWatchdogFields(&watchdog); status = saHpiWatchdogTimerSet(sessionId, resourceId, wd_num, &watchdog); if (status != SA_OK) { retval = SAF_TEST_FAIL; e_print(saHpiWatchdogTimerSet, SA_OK, status); } else { retval = SAF_TEST_PASS; status = saHpiWatchdogTimerSet(sessionId, resourceId, wd_num, &wd_old); } } return retval; }
int processWatchdogRdr(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiRdrT * rdr, SaHpiWatchdogRecT * watchdogRec) { SaErrorT status; int retval; SaHpiWatchdogT watchdog; SaHpiWatchdogT old_watchdog; SaHpiWatchdogNumT wd_num = watchdogRec->WatchdogNum; // Save the original watchdog timer for later restoration. status = saHpiWatchdogTimerGet(sessionId, resourceId, wd_num, &old_watchdog); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiWatchdogTimerGet, SA_OK, status); } else { initSmsWatchdogFields(&watchdog); status = saHpiWatchdogTimerSet(sessionId, resourceId, wd_num, &watchdog); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiWatchdogTimerSet, SA_OK, status); } else { status = saHpiWatchdogTimerReset(sessionId, resourceId, wd_num); if (status == SA_OK) { retval = SAF_TEST_PASS; } else { retval = SAF_TEST_FAIL; e_print(saHpiWatchdogTimerReset, SA_OK, status); } // Restore the original watchdog timer. status = saHpiWatchdogTimerSet(sessionId, resourceId, wd_num, &old_watchdog); if (status != SA_OK) { e_print(saHpiWatchdogTimerSet, SA_OK, status); } } } return retval; }
int set_watchdog(saHpiWatchdogTable_context *ctx) { SaHpiWatchdogT wdog; SaHpiSessionIdT session_id; SaErrorT rc; if (ctx) { wdog.Log = (ctx->saHpiWatchdogLog == MIB_TRUE) ? SAHPI_TRUE : SAHPI_FALSE; wdog.Running = (ctx->saHpiWatchdogRunning == MIB_TRUE) ? SAHPI_TRUE : SAHPI_FALSE; wdog.TimerUse = ctx->saHpiWatchdogTimerUse; wdog.TimerAction = ctx->saHpiWatchdogTimerAction; wdog.PretimerInterrupt = ctx->saHpiWatchdogPretimerInterrupt; wdog.PreTimeoutInterval = ctx->saHpiWatchdogPreTimeoutInterval; wdog.TimerUseExpFlags = ctx->saHpiWatchdogTimerUseExpFlags; wdog.InitialCount = ctx->saHpiWatchdogTimerInitialCount; wdog.PresentCount = ctx->saHpiWatchdogTimerPresentCount; DEBUGMSGTL((AGENT,"log: %d, Run: %d\n", wdog.Log, wdog.Running)); DEBUGMSGTL((AGENT,"initial: %d, presentcount: %d\n", wdog.InitialCount, wdog.PresentCount)); // Get the seesion_id rc = getSaHpiSession(&session_id); if (rc != AGENT_ERR_NOERROR) return rc; DEBUGMSGTL((AGENT,"Calling saHpiWatchdogTimerSet with %d\n", ctx->saHpiWatchdogNum )); rc = saHpiWatchdogTimerSet (session_id, ctx->resource_id, ctx->saHpiWatchdogNum, &wdog); DEBUGMSGTL((AGENT,"rc is %d, SA_OK is %d\n", rc, SA_OK)); if (rc != SA_OK) { return AGENT_ERR_OPERATION; } DEBUGMSGTL((AGENT,"Calling saHpiWatchdogTimerGet with %d\n", ctx->saHpiWatchdogNum )); rc = saHpiWatchdogTimerGet (session_id, ctx->resource_id, ctx->saHpiWatchdogNum, &wdog); DEBUGMSGTL((AGENT,"rc is %d, SA_OK is %d\n", rc, SA_OK)); if (rc != SA_OK) { return AGENT_ERR_OPERATION; } DEBUGMSGTL((AGENT,"log: %d, Run: %d\n", wdog.Log, wdog.Running)); ctx->saHpiWatchdogLog = (wdog.Log == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiWatchdogRunning = (wdog.Running == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiWatchdogTimerUse = wdog.TimerUse; ctx->saHpiWatchdogTimerAction = wdog.TimerAction; ctx->saHpiWatchdogPretimerInterrupt = wdog.PretimerInterrupt; ctx->saHpiWatchdogPreTimeoutInterval = wdog.PreTimeoutInterval; ctx->saHpiWatchdogTimerUseExpFlags = wdog.TimerUseExpFlags; ctx->saHpiWatchdogTimerInitialCount = wdog.InitialCount; ctx->saHpiWatchdogTimerPresentCount = wdog.PresentCount; return AGENT_ERR_NOERROR; } return AGENT_ERR_NULL_DATA; }
int processWatchdogRdr(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiRdrT * rdr, SaHpiWatchdogRecT * watchdogRec) { SaErrorT status; int retval; SaHpiWatchdogT Watchdog; SaHpiWatchdogNumT w_num = watchdogRec->WatchdogNum; initWatchdogFields(&Watchdog); Watchdog.TimerUse = SAHPI_WTU_OEM + 1; //out of range // Call saHpiWatchdogTimerSet passing in an // out-of-range value for the TimerUse Field. status = saHpiWatchdogTimerSet(sessionId, resourceId, w_num, &Watchdog); if (status == SA_ERR_HPI_INVALID_PARAMS) { retval = SAF_TEST_PASS; } else { retval = SAF_TEST_FAIL; e_print(saHpiWatchdogTimerSet, SA_ERR_HPI_INVALID_PARAMS, status); } return retval; }
int processWatchdogRdr(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiRdrT * rdr, SaHpiWatchdogRecT * watchdogRec) { SaErrorT status; int retval; SaHpiWatchdogT Watchdog; initWatchdogFields(&Watchdog); // Call saHpiWatchdogTimerSet passing in a bad Watchdog Number. status = saHpiWatchdogTimerSet(sessionId, resourceId, BAD_WATCHDOG_NUM, &Watchdog); if (status == SA_ERR_HPI_NOT_PRESENT) { retval = SAF_TEST_PASS; } else { retval = SAF_TEST_FAIL; e_print(saHpiWatchdogTimerSet, SA_ERR_HPI_NOT_PRESENT, status); } return retval; }
static ret_code_t wtd_set(void) { SaHpiResourceIdT rptid; SaHpiWatchdogNumT wtdnum; SaHpiWatchdogT watchdog; SaHpiWatchdogExpFlagsT flags; SaErrorT rv; ret_code_t ret; int i, res; char *str, *str1; char tmp[256]; ret = ask_rpt(&rptid); if (ret != HPI_SHELL_OK) return(ret); ret = ask_rdr(rptid, SAHPI_WATCHDOG_RDR, &wtdnum); if (ret != HPI_SHELL_OK) return(ret); i = get_string_param("Log(0 | 1): ", tmp, 255); if (i != 0) { printf("Invalid Log value: %s\n", tmp); return(HPI_SHELL_PARM_ERROR); }; if (tmp[0] == '1') watchdog.Log = SAHPI_TRUE; else watchdog.Log = SAHPI_FALSE; i = get_string_param("Running(0 | 1): ", tmp, 255); if (i != 0) { printf("Invalid Running value: %s\n", tmp); return(HPI_SHELL_PARM_ERROR); }; if (tmp[0] == '1') watchdog.Running = SAHPI_TRUE; else watchdog.Running = SAHPI_FALSE; i = get_string_param( "TimerUse(none|bios_frb2|bios_post|os_load|sms_os|oem): ", tmp, 255); if (i != 0) { printf("Invalid TimerUse value: %s\n", tmp); return(HPI_SHELL_PARM_ERROR); }; if (strcmp(tmp, "none") == 0) watchdog.TimerUse = SAHPI_WTU_NONE; else if (strcmp(tmp, "bios_frb2") == 0) watchdog.TimerUse = SAHPI_WTU_BIOS_FRB2; else if (strcmp(tmp, "bios_post") == 0) watchdog.TimerUse = SAHPI_WTU_BIOS_POST; else if (strcmp(tmp, "os_load") == 0) watchdog.TimerUse = SAHPI_WTU_OS_LOAD; else if (strcmp(tmp, "sms_os") == 0) watchdog.TimerUse = SAHPI_WTU_SMS_OS; else if (strcmp(tmp, "oem") == 0) watchdog.TimerUse = SAHPI_WTU_OEM; else { printf("Invalid TimerUse value: %s\n", tmp); return(HPI_SHELL_PARM_ERROR); }; i = get_string_param( "TimerAction(no|reset|pwr_down|pwr_cycle|int): ", tmp, 255); if (i != 0) { printf("Invalid TimerAction value: %s\n", tmp); return(HPI_SHELL_PARM_ERROR); }; if (strcmp(tmp, "no") == 0) watchdog.TimerAction = SAHPI_WAE_NO_ACTION; else if (strcmp(tmp, "reset") == 0) watchdog.TimerAction = SAHPI_WAE_RESET; else if (strcmp(tmp, "pwr_down") == 0) watchdog.TimerAction = SAHPI_WAE_POWER_DOWN; else if (strcmp(tmp, "pwr_cycle") == 0) watchdog.TimerAction = SAHPI_WAE_POWER_CYCLE; else if (strcmp(tmp, "int") == 0) watchdog.TimerAction = SAHPI_WAE_TIMER_INT; else { printf("Invalid TimerAction value: %s\n", tmp); return(HPI_SHELL_PARM_ERROR); }; i = get_string_param("PretimerInterrupt(no|smi|nmi|mess|oem): ", tmp, 255); if (i != 0) { printf("Invalid PretimerInterrupt value: %s\n", tmp); return(HPI_SHELL_PARM_ERROR); }; if (strcmp(tmp, "no") == 0) watchdog.PretimerInterrupt = SAHPI_WPI_NONE; else if (strcmp(tmp, "smi") == 0) watchdog.PretimerInterrupt = SAHPI_WPI_SMI; else if (strcmp(tmp, "nmi") == 0) watchdog.PretimerInterrupt = SAHPI_WPI_NMI; else if (strcmp(tmp, "mess") == 0) watchdog.PretimerInterrupt = SAHPI_WPI_MESSAGE_INTERRUPT; else if (strcmp(tmp, "oem") == 0) watchdog.PretimerInterrupt = SAHPI_WPI_OEM; else { printf("Invalid TimerAction value: %s\n", tmp); return(HPI_SHELL_PARM_ERROR); }; i = get_int_param("TimeOut: ", &res); if (i != 1) { printf("Invalid TimeOut value\n"); return(HPI_SHELL_PARM_ERROR); }; watchdog.PreTimeoutInterval = res; i = get_string_param("Flags(\"bios_frb2|bios_post|os_load|sms_os|oem\"): ", tmp, 255); if (i != 0) *tmp = 0; flags = 0; str = tmp; while (strlen(str) != 0) { while (isspace(*str)) str++; str1 = str; while ((*str1 != ' ') && (*str1 != 0) && (*str1 != '|')) str1++; if (*str1 != 0) *str1++ = 0; else *str1 = 0; if (strcmp(str, "bios_frb2") == 0) flags |= SAHPI_WATCHDOG_EXP_BIOS_FRB2; if (strcmp(str, "bios_post") == 0) flags |= SAHPI_WATCHDOG_EXP_BIOS_POST; if (strcmp(str, "os_load") == 0) flags |= SAHPI_WATCHDOG_EXP_OS_LOAD; if (strcmp(str, "sms_os") == 0) flags |= SAHPI_WATCHDOG_EXP_SMS_OS; if (strcmp(str, "oem") == 0) flags |= SAHPI_WATCHDOG_EXP_OEM; str = str1; }; watchdog.TimerUseExpFlags = flags; i = get_int_param("InitialCount: ", &res); if (i != 1) { printf("Invalid InitialCount value\n"); return(HPI_SHELL_PARM_ERROR); }; watchdog.InitialCount = res; rv = saHpiWatchdogTimerSet(Domain->sessionId, rptid, wtdnum, &watchdog); if (rv != SA_OK) { printf("ERROR!!! Set Watchdog: ResourceId=%d WatchdogNum=%d: %s\n", rptid, wtdnum, oh_lookup_error(rv)); return(HPI_SHELL_CMD_ERROR); }; return HPI_SHELL_OK; }
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) { SaErrorT rv; SaHpiSessionIdT sessionid; SaHpiDomainInfoT domainInfo; SaHpiRptEntryT rptentry; SaHpiEntryIdT rptentryid; SaHpiEntryIdT nextrptentryid; SaHpiResourceIdT resourceid; SaHpiWatchdogNumT wdnum; SaHpiWatchdogT wdt; GOptionContext *context; /* Print version strings */ oh_prog_version(argv[0]); /* Parsing options */ static char usetext[]="- Read and Enables the watchdog timer.\n " OH_SVN_REV; OHC_PREPARE_REVISION(usetext); context = g_option_context_new (usetext); g_option_context_add_main_entries (context, my_options, NULL); if (!ohc_option_parse(&argc, argv, context, &copt, OHC_ALL_OPTIONS - OHC_ENTITY_PATH_OPTION //TODO: Feature 880127 - OHC_VERBOSE_OPTION )) { // no verbose mode implemented g_option_context_free (context); return 1; } g_option_context_free (context); if (ftimeout == 0) ftimeout = 120; else fenable = TRUE; rv = ohc_session_open_by_option ( &copt, &sessionid); if (rv != SA_OK) return rv; rv = saHpiDiscover(sessionid); if (copt.debug) DBG("saHpiDiscover rv = %s",oh_lookup_error(rv)); rv = saHpiDomainInfoGet(sessionid, &domainInfo); if (copt.debug) DBG("saHpiDomainInfoGet rv = %s",oh_lookup_error(rv)); printf("DomainInfo: UpdateCount = %x, UpdateTime = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); if (rv != SA_OK) printf("RptEntryGet: rv = %s\n",oh_lookup_error(rv)); if (rv == SA_OK) { /* handle WDT for this RPT entry */ resourceid = rptentry.ResourceId; rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; if (copt.debug) printf("rptentry[%u] resourceid=%u capab=%x tag: %s\n", rptentryid, resourceid, rptentry.ResourceCapabilities, rptentry.ResourceTag.Data); if (rptentry.ResourceCapabilities & SAHPI_CAPABILITY_WATCHDOG) { printf("%s has watchdog capability\n",rptentry.ResourceTag.Data); wdnum = SAHPI_DEFAULT_WATCHDOG_NUM; rv = saHpiWatchdogTimerGet(sessionid,resourceid,wdnum,&wdt); if (copt.debug) DBG("saHpiWatchdogTimerGet rv = %s",oh_lookup_error(rv)); if (rv != 0) { printf("saHpiWatchdogTimerGet error = %s\n",oh_lookup_error(rv)); rv = 0; rptentryid = nextrptentryid; continue; } show_wdt(wdnum,&wdt); if (fdisable) { printf("Disabling watchdog timer ...\n"); /* clear FRB2, timeout back to 120 sec */ /* TODO: add setting wdt values here */ wdt.TimerUse = SAHPI_WTU_NONE; /* 1=FRB2 2=POST 3=OSLoad 4=SMS_OS 5=OEM */ wdt.TimerAction = SAHPI_WA_NO_ACTION; /* 0=none 1=reset 2=powerdown 3=powercycle */ wdt.PretimerInterrupt = SAHPI_WPI_NONE; /* 0=none 1=SMI 2=NMI 3=message */ wdt.PreTimeoutInterval = 60000; /*msec*/ wdt.InitialCount = 120000; /*msec*/ wdt.PresentCount = 120000; /*msec*/ rv = saHpiWatchdogTimerSet(sessionid,resourceid,wdnum,&wdt); if (copt.debug) DBG("saHpiWatchdogTimerSet rv = %s",oh_lookup_error(rv)); if (rv == 0) show_wdt(wdnum,&wdt); } else if (fenable) { printf("Enabling watchdog timer ...\n"); /* hard reset action, no pretimeout, clear SMS/OS when done */ /* use ftimeout for timeout */ wdt.TimerUse = SAHPI_WTU_SMS_OS; /* 1=FRB2 2=POST 3=OSLoad 4=SMS_OS 5=OEM */ wdt.TimerAction = SAHPI_WA_RESET; /* 0=none 1=reset 2=powerdown 3=powercycle */ wdt.PretimerInterrupt = SAHPI_WPI_NMI; /* 0=none 1=SMI 2=NMI 3=message */ wdt.PreTimeoutInterval = (ftimeout / 2) * 1000; /*msec*/ wdt.InitialCount = ftimeout * 1000; /*msec*/ wdt.PresentCount = ftimeout * 1000; /*msec*/ rv = saHpiWatchdogTimerSet(sessionid,resourceid,wdnum,&wdt); if (copt.debug) DBG("saHpiWatchdogTimerSet rv = %s",oh_lookup_error(rv)); if (rv == 0) show_wdt(wdnum,&wdt); } if (freset && !fdisable) { printf("Resetting watchdog timer ...\n"); rv = saHpiWatchdogTimerReset(sessionid,resourceid,wdnum); if (copt.debug) DBG("saHpiWatchdogTimerReset rv = %s",oh_lookup_error(rv)); } } /*watchdog capability*/ rptentryid = nextrptentryid; /* get next RPT (usu only one anyway) */ } /*endif RPT ok*/ } /*end while loop*/ rv = saHpiSessionClose(sessionid); return 0; }
int main(int argc, char **argv) { int c; SaErrorT rv; SaHpiVersionT hpiVer; SaHpiSessionIdT sessionid; SaHpiRptInfoT rptinfo; SaHpiRptEntryT rptentry; SaHpiEntryIdT rptentryid; SaHpiEntryIdT nextrptentryid; SaHpiResourceIdT resourceid; SaHpiWatchdogNumT wdnum; SaHpiWatchdogT wdt; int t = 0; char freset = 0; char fenable = 0; char fdisable = 0; printf("%s ver %s\n", argv[0],progver); while ( (c = getopt( argc, argv,"dert:x?")) != EOF ) switch(c) { case 'r': /* reset wdt */ freset = 1; break; case 'e': /* disable wdt */ fenable = 1; break; case 'd': /* disable wdt */ fdisable = 1; break; case 't': /* timeout (enable implied) */ t = atoi(optarg); fenable = 1; break; case 'x': fdebug = 1; break; /* debug messages */ default: printf("Usage: %s [-derx -t sec]\n", argv[0]); printf(" where -e enables the watchdog timer\n"); printf(" -d disables the watchdog timer\n"); printf(" -r resets the watchdog timer\n"); printf(" -t N sets timeout to N seconds\n"); printf(" -x show eXtra debug messages\n"); exit(1); } if (t == 0) t = 120; rv = saHpiInitialize(&hpiVer); if (rv != SA_OK) { printf("saHpiInitialize error %d\n",rv); exit(-1); } rv = saHpiSessionOpen(SAHPI_DEFAULT_DOMAIN_ID,&sessionid,NULL); if (rv != SA_OK) { if (rv == SA_ERR_HPI_ERROR) printf("saHpiSessionOpen: error %d, SpiLibd not running\n",rv); else printf("saHpiSessionOpen error %d\n",rv); exit(-1); } rv = saHpiResourcesDiscover(sessionid); if (fdebug) printf("saHpiResourcesDiscover rv = %d\n",rv); rv = saHpiRptInfoGet(sessionid,&rptinfo); if (fdebug) printf("saHpiRptInfoGet rv = %d\n",rv); printf("RptInfo: UpdateCount = %x, UpdateTime = %lx\n", rptinfo.UpdateCount, (unsigned long)rptinfo.UpdateTimestamp); /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); if (rv != SA_OK) printf("RptEntryGet: rv = %d\n",rv); if (rv == SA_OK) { /* handle WDT for this RPT entry */ resourceid = rptentry.ResourceId; rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; printf("rptentry[%d] resourceid=%d tag: %s\n", rptentryid, resourceid, rptentry.ResourceTag.Data); /* * The definition for SAHPI_DEFAULT_WATCHDOG_NUM is broken, * so we are assigning wdnum to 0x00 which is what SaHpi.h * attempted to set the default as. */ wdnum = (SaHpiWatchdogNumT)0x00; rv = saHpiWatchdogTimerGet(sessionid,resourceid,wdnum,&wdt); if (fdebug) printf("saHpiWatchdogTimerGet rv = %d\n",rv); show_wdt(wdnum,&wdt); if (fdisable) { printf("Disabling watchdog timer ...\n"); /* clear FRB2, timeout back to 120 sec */ /* TODO: add setting wdt values here */ wdt.TimerUse = 1; /* 1=FRB2 2=POST 3=OSLoad 4=SMS_OS 5=OEM */ wdt.TimerAction = 0; /* 0=none 1=reset 2=powerdown 3=powercycle */ wdt.PretimerInterrupt = 0; /* 0=none 1=SMI 2=NMI 3=message */ wdt.PreTimeoutInterval = 60000; /*msec*/ wdt.InitialCount = 120000; /*msec*/ wdt.PresentCount = 120000; /*msec*/ rv = saHpiWatchdogTimerSet(sessionid,resourceid,wdnum,&wdt); if (fdebug) printf("saHpiWatchdogTimerSet rv = %d\n",rv); show_wdt(wdnum,&wdt); } else if (fenable) { printf("Enabling watchdog timer ...\n"); /* hard reset action, no pretimeout, clear SMS/OS when done */ /* use t for timeout */ /* TODO: add setting wdt values here */ wdt.TimerUse = 4; /* 1=FRB2 2=POST 3=OSLoad 4=SMS_OS 5=OEM */ wdt.TimerAction = 1; /* 0=none 1=reset 2=powerdown 3=powercycle */ wdt.PretimerInterrupt = 2; /* 0=none 1=SMI 2=NMI 3=message */ wdt.PreTimeoutInterval = (t / 2) * 1000; /*msec*/ wdt.InitialCount = t * 1000; /*msec*/ wdt.PresentCount = t * 1000; /*msec*/ rv = saHpiWatchdogTimerSet(sessionid,resourceid,wdnum,&wdt); if (fdebug) printf("saHpiWatchdogTimerSet rv = %d\n",rv); show_wdt(wdnum,&wdt); } if (freset && !fdisable) { printf("Resetting watchdog timer ...\n"); rv = saHpiWatchdogTimerReset(sessionid,resourceid,wdnum); if (fdebug) printf("saHpiWatchdogTimerReset rv = %d\n",rv); } rptentryid = nextrptentryid; /* get next RPT (usu only one anyway) */ } /*endif RPT ok*/ } /*end while loop*/ rv = saHpiSessionClose(sessionid); rv = saHpiFinalize(); exit(0); return(0); }
int set_watchdog (saHpiWatchdogTable_context * ctx) { SaHpiWatchdogT wdog; SaHpiSessionIdT session_id; SaErrorT rc; if (ctx) { wdog.Log = (ctx->saHpiWatchdogLog == MIB_TRUE) ? SAHPI_TRUE : SAHPI_FALSE; wdog.Running = (ctx->saHpiWatchdogRunning == MIB_TRUE) ? SAHPI_TRUE : SAHPI_FALSE; wdog.TimerUse = ctx->saHpiWatchdogTimerUse + 1; wdog.TimerAction = ctx->saHpiWatchdogTimerAction + 1; wdog.PretimerInterrupt = ctx->saHpiWatchdogPretimerInterrupt + 1; wdog.PreTimeoutInterval = ctx->saHpiWatchdogPreTimeoutInterval; wdog.TimerUseExpFlags = ctx->saHpiWatchdogTimerUseExpFlags; wdog.InitialCount = ctx->saHpiWatchdogTimerInitialCount; wdog.PresentCount = ctx->saHpiWatchdogTimerPresentCount; // Get the seesion_id rc = getSaHpiSession (&session_id); if (rc != AGENT_ERR_NOERROR) { DEBUGMSGTL ((AGENT, "Call to getSaHpiSession failed with rc: %d\n", rc)); return rc; } DEBUGMSGTL ((AGENT, "Calling saHpiWatchdogTimerSet with %d\n", ctx->saHpiWatchdogNum)); rc = saHpiWatchdogTimerSet (session_id, ctx->resource_id, ctx->saHpiWatchdogNum, &wdog); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to saHpiWatchdogTimerSet failed with return code: %s\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call saHpiWatchdogTimerSet failed with return code: %s\n", get_error_string (rc))); return AGENT_ERR_OPERATION; } DEBUGMSGTL ((AGENT, "Calling saHpiWatchdogTimerGet with %d\n", ctx->saHpiWatchdogNum)); rc = saHpiWatchdogTimerGet (session_id, ctx->resource_id, ctx->saHpiWatchdogNum, &wdog); if (rc != SA_OK) { snmp_log (LOG_ERR, "Call to saHpiWatchdogTimerGet failed with rc: %s\n", get_error_string (rc)); DEBUGMSGTL ((AGENT, "Call to saHpiWatchdogTimerGet failed with rc: %s\n", get_error_string (rc))); return AGENT_ERR_OPERATION; } ctx->saHpiWatchdogLog = (wdog.Log == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiWatchdogRunning = (wdog.Running == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiWatchdogTimerUse = wdog.TimerUse + 1; ctx->saHpiWatchdogTimerAction = wdog.TimerAction + 1; ctx->saHpiWatchdogPretimerInterrupt = wdog.PretimerInterrupt + 1; ctx->saHpiWatchdogPreTimeoutInterval = wdog.PreTimeoutInterval; ctx->saHpiWatchdogTimerUseExpFlags = wdog.TimerUseExpFlags; ctx->saHpiWatchdogTimerInitialCount = wdog.InitialCount; ctx->saHpiWatchdogTimerPresentCount = wdog.PresentCount; return AGENT_ERR_NOERROR; } return AGENT_ERR_NULL_DATA; }