Exemplo n.º 1
0
int main(int argc, char **argv)
{
	SaHpiSessionIdT sid = 0;
        SaHpiWatchdogT wd;
	SaErrorT rc = SA_OK;

        rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL);
	if (rc != SA_OK) {
		dbg("Failed to open session");
                return -1;
	}

	rc = saHpiDiscover(sid);
	if (rc != SA_OK) {
		dbg("Failed to run discover");
                return -1;
	}

        rc = saHpiWatchdogTimerGet(sid, 1, 1, &wd);
        if (rc != SA_OK) {
		dbg("Couldn't get watchdog timer");
		dbg("Error %s",oh_lookup_error(rc));
                return -1;
	}

	return 0;
}
Exemplo n.º 2
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;
    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;
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
	SaHpiSessionIdT sid = 0;
        SaHpiWatchdogT wd;
	SaErrorT rc = SA_OK;

        rc = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL);
	if (rc != SA_OK) {
		dbg("Failed to open session");
                return -1;
	}

	rc = saHpiDiscover(sid);
	if (rc != SA_OK) {
		dbg("Failed to run discover");
                return -1;
	}

        /* get the resource id of the chassis */
        SaHpiResourceIdT resid = get_resid(sid, SAHPI_ENT_SYSTEM_CHASSIS);
        if (resid == 0) {
		dbg("Couldn't find the resource id of the chassis");
                return -1;
	}

        rc = saHpiWatchdogTimerGet(sid, resid, 1, &wd);
        if (rc != SA_OK) {
		dbg("Couldn't get watchdog timer");
		dbg("Error %s",oh_lookup_error(rc));
                return -1;
	}

	return 0;
}
Exemplo n.º 4
0
int Test_Resource(SaHpiSessionIdT sessionId,
		  SaHpiRptEntryT report, callback2_t func)
{
	SaErrorT status;
	int retval = SAF_TEST_NOTSUPPORT;
	SaHpiWatchdogT Watchdog;

	if (!hasWatchdogCapability(&report)) {

		//  Call saHpiWatchdogTimerGet on a resource which 
		//  does not support watchdog timers.

		status = saHpiWatchdogTimerGet(sessionId, report.ResourceId,
					       0, &Watchdog);

		if (status == SA_ERR_HPI_CAPABILITY) {
			retval = SAF_TEST_PASS;
		} else {
			retval = SAF_TEST_FAIL;
			e_print(saHpiWatchdogTimerGet, SA_ERR_HPI_CAPABILITY,
				status);
		}
	}

	return retval;
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
void cHpiSubProviderWatchdog::GetInfo( std::deque<HpiInfo>& info ) const
{
    info.clear();

    SaErrorT rv;
    SaHpiRdrT rdr;
    rv = saHpiRdrGetByInstrumentId( m_ctx.session_id,
                                    m_ctx.resource_id,
                                    SAHPI_WATCHDOG_RDR,
                                    m_ctx.instrument_id,
                                    &rdr );
    if ( rv != SA_OK ) {
        Line( info, L"saHpiRdrGetByInstrumentId failed", rv, I32_SaError );
        return;
    }

    Line( info, L"Resource Id", m_ctx.resource_id, UI32_SaHpiResourceId );
    Line( info, L"Entity", rdr.Entity );
    Line( info, L"IsFru", rdr.IsFru, UI8_SaHpiBool );

    const SaHpiWatchdogRecT& wr = rdr.RdrTypeUnion.WatchdogRec;

    Line( info, L"Watchdog Num", wr.WatchdogNum, UI32_SaHpiWatchdogNum );
    Line( info, L"OEM", wr.Oem );
    Line( info, L"IdString", rdr.IdString );

    SaHpiWatchdogT w;
    rv = saHpiWatchdogTimerGet( m_ctx.session_id,
                                m_ctx.resource_id,
                                m_ctx.instrument_id,
                                &w );
    if ( rv != SA_OK ) {
        Line( info, L"saHpiWatchdogTimerGet failed", rv, I32_SaError );
        return;
    }

    Line( info, L"Current Settings and Configuration", L"" );
    Line( info, L"  Log", w.Log, UI8_SaHpiBool );
    Line( info, L"  Running", w.Running, UI8_SaHpiBool );
    Line( info, L"  Timer Use", w.TimerUse );
    Line( info, L"  Timer Action", w.TimerAction );
    Line( info, L"  Pre-Timer Interrupt", w.PretimerInterrupt );
    Line( info, L"  Pre-Timeout Interval, ms", w.PreTimeoutInterval );
    Line( info, L"  Timer Use Expiration Flags",
          w.TimerUseExpFlags,
          UI8_SaHpiWatchdogExpFlags );
    Line( info, L"  Initial Count", w.InitialCount );
    Line( info, L"  Present Count", w.PresentCount );
}
Exemplo n.º 8
0
static ret_code_t wtd_get(void)
{
	SaHpiResourceIdT	rptid;
	SaHpiWatchdogNumT	wtdnum;
	SaHpiWatchdogT		watchdog;
	SaHpiWatchdogExpFlagsT	flags;
	SaErrorT		rv;
	ret_code_t		ret;
	char			*str;
	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);

	rv = saHpiWatchdogTimerGet(Domain->sessionId,
		rptid, wtdnum, &watchdog);
	if (rv != SA_OK) {
		printf("ERROR!!! Get Watchdog: ResourceId=%d "
			"WatchdogNum=%d: %s\n",
			rptid, wtdnum, oh_lookup_error(rv));
		return(HPI_SHELL_CMD_ERROR);
	};
	if (watchdog.Log) str = "TRUE";
	else str = "FALSE";
	printf("  Watchdogtimer (%d/%d): Log=%s", rptid, wtdnum, str);
	if (watchdog.Running) str = "Running";
	else str = "Stopped";
	printf("  %s\n", str);
	switch (watchdog.TimerUse) {
		case SAHPI_WTU_NONE:
			str = "NONE"; break;
		case SAHPI_WTU_BIOS_FRB2:
			str = "BIOS_FRB2"; break;
		case SAHPI_WTU_BIOS_POST:
			str = "BIOS_POST"; break;
		case SAHPI_WTU_OS_LOAD:	
			str = "OS_LOAD"; break;
		case SAHPI_WTU_SMS_OS:
			str = "SMS_OS"; break;
		case SAHPI_WTU_OEM:
			str = "OEM"; break;
		case SAHPI_WTU_UNSPECIFIED:
			str = "UNSPEC"; break;
		default: str = "Unknown"; break;
	};
	printf("  Timer Use: %s", str);
	switch (watchdog.TimerAction) {
		case SAHPI_WAE_NO_ACTION:
			str = "NO_ACTION"; break;
		case SAHPI_WAE_RESET:
			str = "RESET"; break;
		case SAHPI_WAE_POWER_DOWN:
			str = "POWER_DOWN"; break;
		case SAHPI_WAE_POWER_CYCLE:
			str = "POWER_CYCLE"; break;
		case SAHPI_WAE_TIMER_INT:
			str = "TIMER_INT"; break;
		default: str = "Unknown"; break;
	};
	printf("  Action: %s", str);
	switch (watchdog.PretimerInterrupt) {
		case SAHPI_WPI_NONE:
			str = "NONE"; break;
		case SAHPI_WPI_SMI:
			str = "SMI"; break;
		case SAHPI_WPI_NMI:
			str = "NMI"; break;
		case SAHPI_WPI_MESSAGE_INTERRUPT:
			str = "MESSAGE"; break;
		case SAHPI_WPI_OEM:
			str = "OEM"; break;
		default: str = "Unknown"; break;
	};
	printf("  Interrupt: %s", str);
	printf("  TimeOut: %d\n", watchdog.PreTimeoutInterval);
	tmp[0] = 0;
	flags = watchdog.TimerUseExpFlags;
	if (flags & SAHPI_WATCHDOG_EXP_BIOS_FRB2)
		strcat(tmp, " BIOS_FRB2 |");
	if (flags & SAHPI_WATCHDOG_EXP_BIOS_POST)
		strcat(tmp, " BIOS_POST |");
	if (flags & SAHPI_WATCHDOG_EXP_OS_LOAD)
		strcat(tmp, " OS_LOAD |");
	if (flags & SAHPI_WATCHDOG_EXP_SMS_OS)
		strcat(tmp, " SMS_OS |");
	if (flags & SAHPI_WATCHDOG_EXP_OEM)
		strcat(tmp, " OEM |");
	if (strlen(tmp) > 0) {
		tmp[strlen(tmp) - 1] = 0;
		printf("  Flags: {%s}\n", tmp);
	} else
		printf("  Flags: (null)\n");
	printf("  InitialCount = %d  PresentCount = %d\n",
		watchdog.InitialCount, watchdog.PresentCount);
	return HPI_SHELL_OK;
}
Exemplo n.º 9
0
int
populate_watchdog(SaHpiWatchdogRecT *watchdog,  
		  SaHpiResourceIdT resource_id,		  
		  oid *rdr_entry_oid, size_t rdr_entry_oid_len,
		  oid *watchdog_oid, size_t *watchdog_oid_len) 
{

  SaHpiWatchdogT wdog;
  SaHpiSessionIdT session_id;
  int rc = AGENT_ERR_NOERROR;

  oid index_oid[1];
  oid column[2];

  netsnmp_index	watchdog_index;
  saHpiWatchdogTable_context	*watchdog_context; 

  DEBUGMSGTL((AGENT,"\n\t--- populate_watchdog: Entry.\n"));

  if (watchdog) {

    rc = AGENT_ERR_NOERROR;
    watchdog_index.len = 1;

    // Look at the MIB to find out what the indexs are
    index_oid[0] = watchdog->WatchdogNum;
    // Possible more indexes?

    watchdog_index.oids = (oid *)&index_oid;
    // We are re-populating. Check for existing entries
    watchdog_context = NULL;
    watchdog_context = CONTAINER_FIND(cb.container, &watchdog_index);
    // If we don't find it - we create it.
    if (!watchdog_context) {
      // New entry. Add it
      watchdog_context = saHpiWatchdogTable_create_row(&watchdog_index);
    } 
    if (!watchdog_context) 
      return AGENT_ERR_INTERNAL_ERROR;
    
    // Generate our full OID
    column[0] = 1;
    column[1] = COLUMN_SAHPIWATCHDOGNUM;
	     
    build_full_oid(saHpiWatchdogTable_oid, saHpiWatchdogTable_oid_len,
		   column, 2,
		   &watchdog_index,
		   watchdog_oid, MAX_OID_LEN, watchdog_oid_len);
    

    // By this stage, watchdog_context surely has something in it.
    // '*_modify_context' does a checksum check to see if 
    // the record needs to be altered, and if so populates with
    // information from RDR and the OIDs passed.
    rc = getSaHpiSession(&session_id);
    if (rc != AGENT_ERR_NOERROR) 
      return rc;
     
    DEBUGMSGTL((AGENT,"Calling saHpiWatchdogTimerGet with %d\n", watchdog->WatchdogNum ));
    
    rc = saHpiWatchdogTimerGet (session_id, resource_id,
				watchdog->WatchdogNum,
				&wdog);

    DEBUGMSGTL((AGENT,"rc is %d, SA_OK is %d\n", rc, SA_OK));
    if (rc != SA_OK) {
	return AGENT_ERR_OPERATION;
    }
    
    if (saHpiWatchdogTable_modify_context(watchdog, resource_id, &wdog,
					  rdr_entry_oid, rdr_entry_oid_len,
					  watchdog_context)
	== AGENT_NEW_ENTRY) {
      
      CONTAINER_INSERT(cb.container, watchdog_context);	  
      watchdog_count = CONTAINER_SIZE(cb.container);
      /*
	if (send_traps_on_startup == AGENT_TRUE) {
	send_saHpiWatchdogTable_notification(watchdog_context);
	}      
      */
    }
    rc = AGENT_ERR_NOERROR;
  } else
    rc = AGENT_ERR_OPERATION;

  DEBUGMSGTL((AGENT,"\n\t--- populate_watchdog. Exit\n"));
  return rc;
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
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;
}
Exemplo n.º 12
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);
}
Exemplo n.º 13
0
int
populate_watchdog (SaHpiWatchdogRecT * watchdog,
		   SaHpiRptEntryT * rpt_entry,
		   oid * rdr_entry_oid, size_t rdr_entry_oid_len,
		   oid * watchdog_oid, size_t * watchdog_oid_len)
{

  SaHpiWatchdogT wdog;
  SaHpiSessionIdT session_id;
  int rc = AGENT_ERR_NOERROR;

  oid index_oid[WATCHDOG_INDEX_NR];
  oid column[2];

  netsnmp_index watchdog_index;
  saHpiWatchdogTable_context *watchdog_context;

  DEBUGMSGTL ((AGENT, "\n\t--- populate_watchdog: Entry.\n"));

  if (watchdog)
    {

      rc = AGENT_ERR_NOERROR;
      watchdog_index.len = WATCHDOG_INDEX_NR;

      // Look at the MIB to find out what the indexs are
      index_oid[0] = rpt_entry->DomainId;
      index_oid[1] = rpt_entry->ResourceId;
      index_oid[2] = watchdog->WatchdogNum;
      // Possible more indexes?

      watchdog_index.oids = (oid *) & index_oid;
      // We are re-populating. Check for existing entries
      watchdog_context = NULL;
      watchdog_context = CONTAINER_FIND (cb.container, &watchdog_index);
      // If we don't find it - we create it.
      if (!watchdog_context)
	{
	  // New entry. Add it
	  watchdog_context = saHpiWatchdogTable_create_row (&watchdog_index);
	}
      if (!watchdog_context)
	{
	  snmp_log (LOG_ERR, "Not enough memory for a watchdog row!");
	  return AGENT_ERR_INTERNAL_ERROR;
	}
      // Generate our full OID
      column[0] = 1;
      column[1] = COLUMN_SAHPIWATCHDOGNUM;

      build_full_oid (saHpiWatchdogTable_oid, saHpiWatchdogTable_oid_len,
		      column, 2,
		      &watchdog_index,
		      watchdog_oid, MAX_OID_LEN, watchdog_oid_len);


      // By this stage, watchdog_context surely has something in it.
      // '*_modify_context' does a checksum check to see if 
      // the record needs to be altered, and if so populates with
      // information from RDR and the OIDs passed.
      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 saHpiWatchdogTimerGet with %d\n",
		   watchdog->WatchdogNum));

      rc = saHpiWatchdogTimerGet (session_id, rpt_entry->ResourceId,
				  watchdog->WatchdogNum, &wdog);


      if (rc != SA_OK)
	{
	  snmp_log (LOG_ERR,
		    "Call to saHpiWatchdogTimerGet failed with return code: %s.\n",
		    get_error_string (rc));
	  DEBUGMSGTL ((AGENT,
		       "Call to saHpiWatchdogTimerGet failed with rc: %s\n",
		       get_error_string (rc)));
	  return AGENT_ERR_OPERATION;
	}

      if (saHpiWatchdogTable_modify_context (watchdog, rpt_entry, &wdog,
					     rdr_entry_oid, rdr_entry_oid_len,
					     watchdog_context)
	  == AGENT_NEW_ENTRY)
	{

	  CONTAINER_INSERT (cb.container, watchdog_context);
	  watchdog_count = CONTAINER_SIZE (cb.container);

	}
      rc = AGENT_ERR_NOERROR;
    }
  else
    rc = AGENT_ERR_OPERATION;

  DEBUGMSGTL ((AGENT, "\n\t--- populate_watchdog. Exit\n"));
  return rc;
}
Exemplo n.º 14
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;
}
Exemplo n.º 15
0
int
set_timer_reset (saHpiWatchdogTable_context * ctx)
{
  SaHpiWatchdogT wdog;
  SaHpiSessionIdT session_id;
  SaErrorT rc;

  if (ctx)
    {
      if (ctx->saHpiWatchdogRunning == MIB_TRUE)
	{

	  // 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 saHpiWatchdogTimerReset with %d\n",
		       ctx->saHpiWatchdogNum));

	  rc = saHpiWatchdogTimerReset (session_id,
					ctx->resource_id,
					ctx->saHpiWatchdogNum);

	  if (rc != SA_OK)
	    {
	      snmp_log (LOG_ERR,
			"Call to saHpiWatchdogTimerReset failed with rc: %s\n",
			get_error_string (rc));
	      DEBUGMSGTL ((AGENT,
			   "Call to saHpiWatchdogTimerReset failed with rc: %s\n",
			   get_error_string (rc)));
	      return AGENT_ERR_OPERATION;
	    }
	  // Get the new changes.
	  DEBUGMSGTL ((AGENT, "Calling saHpiWatchdogTimerGet with %d\n",
		       ctx->saHpiWatchdogNum));
	  memset (&wdog, 0x00, sizeof (SaHpiWatchdogT));

	  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;
	    }
	  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 + 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;
	  // MIB change. 
	  // IBM-KR: Should this be set to something else, perhaps?
	  ctx->saHpiWatchdogTimerReset = MIB_FALSE;
	  return AGENT_ERR_NOERROR;
	}
      return AGENT_ERR_OPERATION;
    }
  return AGENT_ERR_NULL_DATA;

}